malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int f = 0, num;     char ch;     while (ch = getchar(), !isdigit(ch))       if (ch ==  - ) f = 1;     num = ch -  0 ;     while (ch = getchar(), isdigit(ch)) num = num * 10 + ch -  0 ;     return f ? -num : num;   }   const int N = 103;   char s[N], ans[N], tmp[103];   char ch;   void is() {     ch = getchar();     while (ch !=   n ) ch = getchar();   }   int cnt, tot, T, f;   int main() {     T = read();     f = 0, cnt = 0;     while (T--) {       int f1 = 0;       tot = 0;       ch = getchar();       while (ch !=   n ) {         if (ch ==    ) f1 = 1;         if (f1)           s[tot++] = ch;         else if (ch !=    )           s[tot++] = ch;         ch = getchar();       }       s[tot++] =   0 ;       if (f) {         if (s[1] ==  r ) cnt++;         if (s[0] ==  c ) {           if (cnt)             cnt--;           else {             tot = 0;             int i = 6;             while (s[i] !=  , ) {               tmp[tot++] = s[i];               i++;             }             tmp[tot++] =   0 ;             if (!strcmp(tmp, ans)) {               int i = 7 + tot;               while (s[i] !=    ) {                 cout << s[i];                 i++;               }               cout << endl;               f = 0;             }           }         }       }       if (s[1] ==  h ) {         f = 1;         tot = 0;         for (int i = 6; s[i] !=  ) ; i++) ans[tot++] = s[i];         ans[tot++] =   0 ;       }     }     if (f) cout <<  Unhandled Exception  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long t;     cin >> t;     while (t--) {       long long n, k, i;       cin >> n >> k;       string s(n,  a );       long long temp = k;       i = 1;       long long x = 0, y = 0;       while (temp >= i) {         temp -= i;         i++;       }       if (temp != 0) {         s[n - i - 1] =  b ;         s[n - temp] =  b ;       } else {         s[n - i + 1] =  b ;         s[n - i] =  b ;       }       cout << s << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int z[2 * 1000 * 1000 + 10];   char s[2 * 1000 * 1000 + 10];   bool T[2 * 1000 * 1000 + 10];   int cnt[2 * 1000 * 1000 + 10];   int main() {     int K, L;     scanf( %d%d , &L, &K);     scanf( %s , &s);     for (int i = 1, l = 0, r = 0; i < L; ++i) {       if (i <= r) z[i] = min(r - i + 1, z[i - l]);       while (i + z[i] < L && s[z[i]] == s[i + z[i]]) ++z[i];       if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;     }     int k, m;     for (int i = 1; i < L; i++) {       k = z[i] / i + 1;       m = z[i] % (i);       if (k == K) {         T[i * K - 1] = true;         cnt[i * K - 1] = max(cnt[i * K - 1], m);       }       if (k > K) {         T[i * K - 1] = true;         cnt[i * K - 1] = max(cnt[i * K - 1], i);       }       if (k >= K + 1) T[i * (K + 1) - 1] = true;     }     for (int i = 0; i < L; i++) {       if (K == 1) T[i] = true;       if (cnt[i]) {         T[i + 1] = true;         cnt[i + 1] = max(cnt[i + 1], cnt[i] - 1);       }       printf( %d , T[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[30000];   int main() {     int n;     cin >> n;     cnt[0] = 1;     for (long long i = 0; i < n; ++i) {       int a;       cin >> a;       for (long long q = 0; q < 30000 - a; ++q) {         if (cnt[q] == 1) {           cnt[q + a] = 1;         }       }     }     for (int i = 0; i < 30000; ++i) {       if (cnt[i] == 0) {         cout << i << endl;         return 0;       }     }     cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool rev[35];   int main() {     int n, m;     cin >> m >> n;     for (int i = 0; i < n; i++) {       printf( 1 n );       fflush(stdout);       int x;       scanf( %d , &x);       if (x == 0) return 0;       if (x < 0)         rev[i] = true;       else         rev[i] = false;     }     int l = 1, r = m;     for (int i = n; i < 60; i++) {       int mid = (l + r) / 2;       printf( %d n , mid);       fflush(stdout);       int x;       scanf( %d , &x);       if (x == 0) return 0;       if (x < 0) {         if (rev[i % n]) {           l = mid + 1;         } else           r = mid - 1;       } else {         if (rev[i % n]) {           r = mid - 1;         } else           l = mid + 1;       }     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     char c = getchar();     bool flag = false;     while (!isdigit(c)) {       if (c ==  - ) flag = true;       c = getchar();     }     while (isdigit(c)) {       x = (x << 1) + (x << 3) + (c ^ 48);       c = getchar();     }     if (flag) x = -x;   }   int n, q, root = 1;   int a[1000010], mn[4000010], val[4000010], tag[4000010];   void pushup(int cur) {     if (mn[(cur << 1)] < mn[(cur << 1 | 1)])       mn[cur] = mn[(cur << 1)], val[cur] = val[(cur << 1)];     else if (mn[(cur << 1)] > mn[(cur << 1 | 1)])       mn[cur] = mn[(cur << 1 | 1)], val[cur] = val[(cur << 1 | 1)];     else       mn[cur] = mn[(cur << 1)], val[cur] = val[(cur << 1)] + val[(cur << 1 | 1)];   }   void pushtag(int cur, int v) { mn[cur] += v, tag[cur] += v; }   void pushdown(int cur) {     if (!tag[cur]) return;     pushtag((cur << 1), tag[cur]), pushtag((cur << 1 | 1), tag[cur]),         tag[cur] = 0;   }   void update(int l, int r, int pos, int v, int cur) {     if (l == r) {       val[cur] += v;       return;     }     pushdown(cur);     if (pos <= ((l + r) >> 1))       update(l, ((l + r) >> 1), pos, v, (cur << 1));     else       update(((l + r) >> 1) + 1, r, pos, v, (cur << 1 | 1));     pushup(cur);   }   void modify(int L, int R, int l, int r, int v, int cur) {     if (L > R) return;     if (L <= l && R >= r) {       pushtag(cur, v);       return;     }     pushdown(cur);     if (L <= ((l + r) >> 1)) modify(L, R, l, ((l + r) >> 1), v, (cur << 1));     if (R > ((l + r) >> 1))       modify(L, R, ((l + r) >> 1) + 1, r, v, (cur << 1 | 1));     pushup(cur);   }   int query(int L, int R, int l, int r, int cur) {     if (L <= l && R >= r) return mn[cur] == 1 ? val[cur] : 0;     int v = 0;     pushdown(cur);     if (L <= ((l + r) >> 1)) v += query(L, R, l, ((l + r) >> 1), (cur << 1));     if (R > ((l + r) >> 1))       v += query(L, R, ((l + r) >> 1) + 1, r, (cur << 1 | 1));     return v;   }   int main() {     read(n), read(q), a[0] = 1000001;     for (int i = 1; i <= n; ++i) read(a[i]), update(0, 1000001, a[i], 1, root);     for (int i = 0; i <= n; ++i)       modify(min(a[i], a[i + 1]), max(a[i], a[i + 1]) - 1, 0, 1000001, 1, root);     while (q--) {       int x;       read(x), update(0, 1000001, a[x], -1, root);       modify(min(a[x], a[x + 1]), max(a[x], a[x + 1]) - 1, 0, 1000001, -1, root);       modify(min(a[x - 1], a[x]), max(a[x - 1], a[x]) - 1, 0, 1000001, -1, root);       read(a[x]), update(0, 1000001, a[x], 1, root);       modify(min(a[x], a[x + 1]), max(a[x], a[x + 1]) - 1, 0, 1000001, 1, root);       modify(min(a[x - 1], a[x]), max(a[x - 1], a[x]) - 1, 0, 1000001, 1, root);       printf( %d n , query(1, 1000001 - 1, 0, 1000001, root));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18;   const long long mod = 1e9 + 7;   void __p(long long x) { cout << x; }   void __p(int32_t x) { cout << x; }   void __p(float x) { cout << x; }   void __p(double x) { cout << x; }   void __p(long double x) { cout << x; }   void __p(char x) { cout <<      << x <<     ; }   void __p(const char *x) { cout <<     << x <<    ; }   void __p(const string &x) { cout <<     << x <<    ; }   void __p(bool x) { cout << (x ?  true  :  false ); }   void _p() { cout <<  ] n ; }   template <typename T, typename V>   void __p(const pair<T, V> &x) {     cout <<  { ;     __p(x.first);     cout <<  , ;     __p(x.second);     cout <<  } ;   }   template <typename T>   void __p(const T &x) {     long long f = 0;     cout <<  { ;     for (auto &i : x) cout << (f++ ?  ,  :   ), __p(i);     cout <<  } ;   }   template <typename T, typename... V>   void _p(T t, V... v) {     __p(t);     if (sizeof...(v)) cout <<  ,  ;     _p(v...);   }   long long po(long long x, long long p) {     long long ans = 1;     x %= mod;     while (p > 0) {       if (p & 1) ans = (ans * x) % mod;       p = p >> 1;       x = (x * x) % mod;     }     return ans;   }   long long inv(long long x) { return po(x, mod - 2) % mod; }   const long long N = 1e6 + 6;   long long n, m, k, x, y, z, a, b, c, d, i, j, l, r, f, q;   void sol() {     string s;     cin >> n >> s;     map<long long, long long> m;     m[0] = 1;     long long pre = 0;     long long ans = 0;     for (i = 0; i < n; i++) {       pre += s[i] -  0 ;       ans += m[pre - (i + 1)];       m[pre - (i + 1)]++;     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) sol();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char c = getchar();     int x = 0;     bool f = 0;     for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);     for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);     if (f) x = -x;     return x;   }   const int M = 4e6 + 10;   int n, maxn, pp[M], a[M], b[M], cnt, ppp[M];   int max1, max2, sum1, sum2, vis[M];   map<int, int> t;   vector<int> e[M];   void dfs(int u) {     if (vis[u]) return;     vis[u] = 1, sum2++;     max2 = max(max2, u);     if (max1 < max2) swap(max1, max2);     for (int i = 0; i < e[u].size(); i++) {       int to = e[u][i];       sum1++;       dfs(to);     }   }   signed main() {     n = read();     for (int i = 1; i <= n; i++)       pp[++cnt] = a[i] = read(), pp[++cnt] = b[i] = read();     sort(pp + 1, pp + 1 + cnt);     cnt = 0;     for (int i = 1; i <= 2 * n; i++)       if (pp[i] != pp[i - 1] || i == 1) t[pp[i]] = ++cnt, ppp[cnt] = pp[i];     for (int i = 1; i <= n; i++)       a[i] = t[a[i]], b[i] = t[b[i]], e[a[i]].push_back(b[i]),       e[b[i]].push_back(a[i]);     for (int i = 1; i <= cnt; i++)       if (!vis[i]) {         max1 = max2 = sum1 = sum2 = 0;         dfs(i);         sum1 /= 2;         if (sum2 == sum1)           maxn = max(maxn, max1);         else if (sum2 > sum1)           maxn = max(maxn, max2);         else           return puts( -1 ), 0;       }     cout << ppp[maxn] << endl;     return 0;   }
#include <bits/stdc++.h>   char s[100] =  bear , str[10000];   int check(int index) {     int i;     for (i = index; i <= index + 3; i++) {       if (str[i] != s[i - index]) return 0;     }     return 1;   }   int main() {     int len, i, j;     while (scanf( %s , str) != EOF) {       int ans = 0, index = 0;       int len = strlen(str);       for (i = 0; i <= len - 4; i++) {         if (check(i)) ans += (i + 1 - index) * (len - (i + 3)), index = i + 1;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct p {     int L, R, U, D;   } point[5005], pos[5005];   string g[5005];   void DEL(int x) {     pos[pos[x].D].U = pos[x].U;     pos[pos[x].U].D = pos[x].D;     pos[pos[x].R].L = pos[x].L;     pos[pos[x].L].R = pos[x].R;   }   int main() {     int m, n, i, j, l, sx, sy;     scanf( %d%d , &m, &n);     for (i = 0; i < m; i++) cin >> g[i];     n = g[0].size();     for (i = 0; i < m; i++) {       for (j = 0; j < n; j++) {         if (g[i][j] !=  . ) {           for (l = i - 1; l >= 0; l--)             if (g[l][j] !=  . ) break;           if (l < 0)             point[i * n + j].U = -1;           else             point[i * n + j].U = l * n + j;           for (l = i + 1; l < m; l++)             if (g[l][j] !=  . ) break;           if (l >= m)             point[i * n + j].D = -1;           else             point[i * n + j].D = l * n + j;           for (l = j - 1; l >= 0; l--)             if (g[i][l] !=  . ) break;           if (l < 0)             point[i * n + j].L = -1;           else             point[i * n + j].L = i * n + l;           for (l = j + 1; l < n; l++)             if (g[i][l] !=  . ) break;           if (l >= n)             point[i * n + j].R = -1;           else             point[i * n + j].R = i * n + l;         }       }     }     int r1 = 0, r2 = 0, cnt, t, x, y;     for (sx = 0; sx < m; sx++) {       for (sy = 0; sy < n; sy++)         if (g[sx][sy] !=  . ) {           for (i = 0; i < m; i++) {             for (j = 0; j < n; j++) {               pos[i * n + j] = point[i * n + j];             }           }           if (g[sx][sy] ==  D )             t = pos[sx * n + sy].D;           else if (g[sx][sy] ==  U )             t = pos[sx * n + sy].U;           else if (g[sx][sy] ==  R )             t = pos[sx * n + sy].R;           else if (g[sx][sy] ==  L )             t = pos[sx * n + sy].L;           DEL(sx * n + sy);           cnt = 1;           while (t != -1) {             cnt++;             x = t / n;             y = t % n;             DEL(t);             if (g[x][y] ==  D )               t = pos[t].D;             else if (g[x][y] ==  U )               t = pos[t].U;             else if (g[x][y] ==  R )               t = pos[t].R;             else if (g[x][y] ==  L )               t = pos[t].L;           }           if (cnt > r1) {             r1 = cnt;             r2 = 1;           } else if (cnt == r1) {             r2++;           }         }     }     printf( %d %d n , r1, r2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e3 + 40;   int f[maxn][maxn];   int dp[maxn];   char s[maxn];   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       scanf( %s , s + 1);       f[n][n + 1] = f[n + 1][n] = f[n + 1][n + 1] = 0;       for (int i = n; i >= 1; i--)         for (int j = n; j >= 1; j--) {           if (s[i] == s[j]) {             f[i][j] = f[i + 1][j + 1] + 1;           } else {             f[i][j] = 0;           }         }       int ans = 0;       for (int i = 1; i <= n; i++) {         dp[i] = n - i + 1;         for (int j = 1; j < i; j++) {           int len = f[i][j];           if (i + len - 1 >= n || s[i + len] <= s[j + len]) continue;           dp[i] = max(dp[i], dp[j] + n - i + 1 - len);         }         ans = max(ans, dp[i]);       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> primes;   bool sums[1003];   int n, k;   bool pr[1003];   void sieve() {     pr[1] = pr[0] = 1;     for (int i = 2; i <= n; i++)       if (!pr[i]) {         for (int j = i + i; j <= n; j += i) pr[j] = 1;         primes.push_back(i);       }     return;   }   int main() {     cin >> n >> k;     sieve();     for (int i = 1; i < primes.size(); i++)       if (primes[i] + primes[i - 1] <= n) sums[primes[i] + primes[i - 1]] = 1;     for (int i = 2; i <= n; ++i)       if (sums[i - 1] && !pr[i]) k--;     cout << (k <= 0 ?  YES  :  NO );   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v(100003);   long long solve() {     long long n;     vector<long long> u;     string s;     cin >> n;     while (n > 0) {       auto itr = lower_bound((v).begin(), (v).end(), n);       long long a = itr - v.begin();       if (v[a] > n) a--;       u.push_back(a + 2);       n = n - v[a];     }     s.push_back( 1 );     long long j = 1;     for (long long i = 0; i < u[0]; i++) {       while (j < u.size() && i + u[j] == u[0]) {         s.push_back( 1 );         j++;       }       s.push_back( 3 );     }     s.push_back( 7 );     cout << s;     return 0;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long t = 1;     cin >> t;     v[0] = 1;     for (long long i = 1; i < 100003; i++) v[i] = v[i - 1] + i + 1;     while (t--) {       solve();       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 101010;   pair<int, int> arr[MAXN];   pair<int, int> a[MAXN], b[MAXN];   int N;   bool cmp(const pair<int, int> &a, const pair<int, int> &b) {     return a.second < b.second;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> N;     for (int i = 0; i < N; i++) {       cin >> arr[i].first;       arr[i].second = i;     }     sort(arr, arr + N);     int c3 = (N + 1) / 3;     int c6 = (2 * N + 1) / 3;     for (int i = 0; i < c3; i++) {       a[i].first = arr[i].first;       b[i].first = 0;     }     for (int i = c3; i < c6; i++) {       a[i].first = 0;       b[i].first = arr[i].first;     }     for (int i = c6; i < N; i++) {       b[i].first = N - i - 1;       a[i].first = arr[i].first - b[i].first;     }     for (int i = 0; i < N; i++) {       a[i].second = b[i].second = arr[i].second;     }     sort(a, a + N, cmp);     sort(b, b + N, cmp);     cout <<  YES  << endl;     for (int i = 0; i < N; i++) cout << a[i].first << (i == N - 1 ?   n  :    );     for (int i = 0; i < N; i++) cout << b[i].first << (i == N - 1 ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   const double eps = 1e-9;   const int INF = inf;   const double EPS = eps;   struct __timestamper {};   class fenv_tree {     static int f(int x) { return x & -x; }     vector<int> tr;       public:     fenv_tree(int n) : tr(n + 1, -inf) {}     void relax(int x, int v) {       for (x++; x < ((int)(tr).size()); x += f(x)) tr[x] = max(tr[x], v);     }     int get(int x) {       int res = -inf;       for (x++; x > 0; x -= f(x)) res = max(res, tr[x]);       return res;     }   };   vector<vector<pair<int, int>>> rests;   int n;   vector<int> rig, spl;   vector<int> ans;   void restore(int v) {     if (v + 1 < spl[v]) {       rig[v + 1] = spl[v] - 1;       restore(v + 1);     }     ans.push_back(v);     if (spl[v] <= rig[v]) {       rig[spl[v]] = rig[v];       restore(spl[v]);     }   }   bool check() {     rig = vector<int>(n);     for (int i = 0; i < (n); i++) rig[i] = i;     spl = vector<int>(n);     fenv_tree tr(n);     for (int i = 0; i < (n); i++) tr.relax(i, rig[i]);     for (int i = n - 1; i >= 0; i--) {       for (pair<int, int> r : rests[i]) {         if (r.first <= i) return false;         rig[i] = max(rig[i], rig[r.first]);       }       rig[i] = tr.get(rig[i]);       tr.relax(i, rig[i]);       vector<pair<int, int>> seq;       for (int i2 = i + 1; i2 <= rig[i];) {         seq.push_back(make_pair(i2, rig[i2]));         i2 = rig[i2] + 1;       }       int b1 = 0, b2 = ((int)(seq).size());       for (pair<int, int> r : rests[i]) {         int id = upper_bound(seq.begin(), seq.end(), make_pair(r.first, inf)) -                  seq.begin() - 1;         if (r.second == 0) {           b1 = max(b1, id + 1);         } else {           b2 = min(b2, id);         }       }       if (b1 > b2) return false;       if (seq.empty()) {         spl[i] = i + 1;       } else {         spl[i] = b1 == ((int)(seq).size()) ? rig[i] + 1 : seq[b1].first;       }     }     ans.clear();     rig[0] = n - 1;     restore(0);     for (int i = 0; i < (n); i++) printf( %d%c , ans[i] + 1,   n  [i + 1 < n]);     return true;   }   int main() {     int m;     while (scanf( %d%d , &n, &m) == 2) {       rests = vector<vector<pair<int, int>>>(n);       for (int i = 0; i < (m); i++) {         int a, b;         char ty[10];         scanf( %d%d%s , &a, &b, ty), a--, b--;         rests[a].push_back(make_pair(b, !strcmp(ty,  LEFT ) ? 0 : 1));       }       if (!check()) {         printf( IMPOSSIBLE n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 151, maxs = 150 * 150 / 4 + 5, inf = 1e9;   vector<vector<int> > d[maxs];   int a[maxn];   int n, k, s;   int main() {     scanf( %d%d%d , &n, &k, &s);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     if (s >= maxs - 2) {       sort(a, a + n);       int sum = 0;       for (int i = 0; i < k; ++i) {         sum += a[i];       }       printf( %d , sum);       return 0;     } else {       for (int g = 0; g <= s; ++g) {         d[g].resize(n - k + 2);         for (int j = 0; j < n - k + 2; ++j) {           d[g][j].resize(k + 1, inf);         }       }       d[s][0][k] = 0;       for (int i = k; i >= 0; --i) {         for (int j = k; j <= n; ++j) {           for (int g = s; g >= 0; --g) {             int j1 = j - k;             if (i > 0)               d[g][j1][i - 1] = min(d[g][j1][i - 1], d[g][j1][i] + a[i - 1]);             if (j < n) d[g][j1 + 1][i] = min(d[g][j1 + 1][i], d[g][j1][i]);             int st = j - i + 1;             if (i > 0 && j < n && g - st >= 0) {               d[g - st][j1 + 1][i - 1] =                   min(d[g - st][j1 + 1][i - 1], d[g][j1][i] + a[j]);             }             if (i > 0 && j < n) {               d[g][j1 + 1][i - 1] =                   min(d[g][j1 + 1][i - 1], d[g][j1][i] + a[i - 1]);             }           }         }       }       int ans = inf;       for (int g = 0; g <= s; ++g) {         ans = min(d[g][n - k][0], ans);       }       printf( %d , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       for (int pw = 2; pw < 30; ++pw) {         int val = (1 << pw) - 1;         if (n % val == 0) {           cout << n / val << endl;           break;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = int(1.5 * 1e7);   const int inf = 1e9 + 7;   const long long ll_inf = 1e18 + 420;   const double eps = 1e-4;   const int N = 1e6;   const int MAX = 2e5 + 9;   const int MOD = 1e9 + 7;   const long double pi = 3.14159265359;   string s;   bool was[10][10];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> s;     for (int i0 = 0; i0 < s.size(); ++i0) {       int cnt = 0;       for (int i = 1; i <= 4; ++i, cnt = 0) {         for (int j = 1; j <= 4; ++j) {           cnt += was[i][j];         }         if (cnt == 4) {           for (int j = 1; j <= 4; ++j) {             was[i][j] = 0;           }         }       }       for (int i = 1; i <= 4; ++i, cnt = 0) {         for (int j = 1; j <= 4; ++j) {           cnt += was[j][i];         }         if (cnt == 4) {           for (int j = 1; j <= 4; ++j) {             was[j][i] = 0;           }         }       }       if (s[i0] ==  1 ) {         bool q = 0;         for (int i = 1; i <= 4; ++i) {           for (int j = 1; j <= 3; ++j) {             if (!was[i][j] && !was[i][j + 1]) {               was[i][j] = 1;               was[i][j + 1] = 1;               cout << i <<     << j <<   n ;               q = 1;               break;             }           }           if (q) break;         }       } else {         bool q = 0;         for (int i = 1; i <= 4; ++i) {           for (int j = 1; j <= 3; ++j) {             if (!was[j][i] && !was[j + 1][i]) {               was[j][i] = 1;               was[j + 1][i] = 1;               cout << j <<     << i <<   n ;               q = 1;               break;             }           }           if (q) break;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int T;     cin >> T;     while (T--) {       long long n, m;       cin >> n >> m;       if (m + 1 <= n) {         cout << 0 << endl;         continue;       }       m++;       bool flag = false;       for (int i = 32; i >= 0; --i) {         int x = n >> i & 1, y = m >> i & 1;         if (flag) {           m -= y << i;           m += x << i;         } else if (x > y) {           flag = 1;           m += (1 << i);         }       }       cout << (n ^ m) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   int n;   int a[maxn];   int c[maxn];   int main() {     int ans = 0;     int i, j, x;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     int id = 0;     for (i = 2; i <= n; i++) {       if (a[i] < a[i - 1]) id = i - 1;     }     printf( %d n , id);     return 0;   }