#include #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #define fi first #define se second #define int long long #define vec vector using namespace std; void solve() { int n, k; cin>>n>>k; vec a(n); for(int i = 0;i>a[i]; } vec> pred(n, vec(35, -1)); vec cur(35, -1); for(int i = 0;i> j) & 1; if(rew > 0 ){ cur[j] = i; } } pred[i] = cur; } vec block(n, -1); for(int i = 0;i>j) & 1; if(flag > 0){ mn = min(pred[i][j], mn); } } if(block[i] < mn){ ans += (mn - block[i]); } } cout << ans << "\n"; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tests = 1; while(tests--) { solve(); } }