malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5;   int m;   int num[MAXN + 10];   int tree[4 * MAXN + 10];   int prop[4 * MAXN + 10];   void upd(int cn, int b, int e, int l, int r, int x, int p = 0) {     if (l <= b && e <= r) {       tree[cn] += x + p;       prop[cn] += x + p;       return;     }     if (r < b || l > e) {       tree[cn] += p;       prop[cn] += p;       return;     }     p += prop[cn];     prop[cn] = 0;     int m = (b + e) / 2;     upd(2 * cn, b, m, l, r, x, p);     upd(2 * cn + 1, m + 1, e, l, r, x, p);     tree[cn] = min(tree[2 * cn], tree[2 * cn + 1]);   }   void upd(int i, int x) { upd(1, 1, m, i, m, x); }   int get(int cn, int b, int e, int l, int r, int p = 0) {     if (l <= b && e <= r) return tree[cn] + p;     if (r < b || l > e) return 1e9;     int m = (b + e) / 2;     int L = get(2 * cn, b, m, l, r, p + prop[cn]);     int R = get(2 * cn + 1, m + 1, e, l, r, p + prop[cn]);     return min(L, R);   }   bool oka(int j) {     if (j == 0) return 0 < get(1, 1, m, m, m);     return get(1, 1, m, j, m) < get(1, 1, m, m, m);   }   int solve() {     int lo = 0, hi = m - 1;     while (hi - lo > 1) {       int m = (lo + hi) / 2;       if (oka(m))         lo = m;       else         hi = m - 1;     }     if (oka(hi)) return num[hi + 1];     if (oka(lo)) return num[lo + 1];     return -1;   }   int main() {     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       int ps, tp;       scanf( %d%d , &ps, &tp);       if (tp == 0)         upd(ps, -1);       else {         int x;         scanf( %d , &x);         num[ps] = x;         upd(ps, +1);       }       printf( %d n , solve());     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)2e9;   const int mod = (int)1e9 + 123;   const int N = (int)1e6 + 10;   const long long LLINF = (long long)3e18 + 10;   const long double pi = acos(-1);   template <typename T1, typename T2>   bool umin(T1 &x, T2 y) {     if (x > y) return x = y, true;     return false;   }   template <typename T1, typename T2>   bool umax(T1 &x, T2 y) {     if (x < y) return x = y, true;     return false;   }   template <typename T>   T getint() {     char c = getchar();     T p = 1, x = 0;     while (c ==     || c ==   n ) c = getchar();     if (c ==  - ) p = -1, c = getchar();     while (c >=  0  && c <=  9 ) x = x * 10 + c -  0 , c = getchar();     return x * p;   }   long long bp[N], h[N];   int n, m, q;   map<tuple<int, int, int, int>, long long> s;   struct tree {     vector<tree *> t;     vector<long long> a;     tree(int n, int m) {       t.resize(n + 1);       for (int i = 1; i <= n; ++i) {         t[i] = new tree(m);       }     }     tree(int m) { a.resize(m + 1); }     void add(int x, int y, long long val) {       if (x >= t.size()) return;       for (; x <= n; x |= (x + 1)) t[x]->add(y, val);     }     void add(int y, long long val) {       if (y >= a.size()) return;       for (; y <= m; y |= (y + 1)) a[y] += val;     }     long long get(int x, int y) {       long long ans = 0;       for (; x >= 1; x = (x & (x + 1)) - 1) {         ans += t[x]->get(y);       }       return ans;     }     long long get(int y) {       long long ans = 0;       for (; y >= 1; y = (y & (y + 1)) - 1) {         ans += a[y];       }       return ans;     }     void couttree() {       if (t.size()) {         for (int i = 1; i < t.size(); ++i) {           t[i]->couttree();           cout <<   n ;         }         cout << endl;       } else {         for (int i = 1; i < a.size(); ++i) {           cout << a[i] <<    ;         }       }     }   };   int main() {     srand(time(NULL));     ios_base::sync_with_stdio(0);     n = getint<int>();     m = getint<int>();     q = getint<int>();     tree *t = new tree(n, m);     for (int i = 0; i < q; ++i) {       bp[i] = (i ? bp[i - 1] * 23123 % mod : 1);       h[i] = ((i ? h[i - 1] : 0) + (i + 1) * bp[i]) % mod;       int ty = getint<int>();       int x1 = getint<int>(), y1 = getint<int>();       int x2 = getint<int>(), y2 = getint<int>();       if (ty == 1) {         s[make_tuple(x1, y1, x2, y2)] = h[i];         t->add(x1, y1, h[i]);         t->add(x1, y2 + 1, -h[i]);         t->add(x2 + 1, y1, -h[i]);         t->add(x2 + 1, y2 + 1, h[i]);       }       if (ty == 2) {         long long val = s[make_tuple(x1, y1, x2, y2)];         t->add(x1, y1, -val);         t->add(x1, y2 + 1, val);         t->add(x2 + 1, y1, val);         t->add(x2 + 1, y2 + 1, -val);       }       if (ty == 3) {         if (t->get(x1, y1) == t->get(x2, y2))           printf( Yes n );         else           printf( No n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5;   int n, m, k, a[N][5];   int sparse[5][17][N];   vector<int> last(5, 0);   void build(int u) {     for (int i = 0; i < n; i++) sparse[u][0][i] = a[i][u];     for (int j = 1; j <= 17; j++)       for (int i = 0; i + (1 << (j - 1)) < n; i++)         sparse[u][j][i] =             max(sparse[u][j - 1][i], sparse[u][j - 1][i + (1 << (j - 1))]);   }   int q(int u, int x, int y) {     int v = log2(y - x + 1);     return max(sparse[u][v][x], sparse[u][v][y + 1 - (1 << v)]);   }   bool check(int mid) {     vector<int> v(5, 0);     int sum;     for (int i = 0; i < n - mid; i++) {       sum = 0;       for (int j = 0; j < m; j++) {         v[j] = q(j, i, i + mid);         sum += v[j];       }       if (sum <= k) {         last = v;         return 1;       }     }     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> a[i][j];     for (int i = 0; i < m; i++) build(i);     int l = 0, r = n, mid;     while (l <= r) {       mid = (l + r) / 2;       if (check(mid))         l = mid + 1;       else         r = mid - 1;     }     for (int i = 0; i < m; i++) cout << last[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   struct pi {     int x, y, t;     double p;   } pp[1005];   double dp[1005];   int cmp(pi a, pi b) { return a.t < b.t; }   double get(int a, int b) {     return sqrt(pow(pp[a].x - pp[b].x, 2.0) + pow(pp[a].y - pp[b].y, 2.0));   }   int main() {     int i, j, n;     cin >> n;     for (i = 1; i <= n; i++) {       scanf( %d%d%d%lf , &pp[i].x, &pp[i].y, &pp[i].t, &pp[i].p);     }     sort(pp + 1, pp + 1 + n, cmp);     dp[1] = pp[1].p;     for (i = 2; i <= n; i++) {       dp[i] = pp[i].p;       for (j = 1; j < i; j++) {         if (get(j, i) <= pp[i].t - pp[j].t) {           dp[i] = max(dp[i], dp[j] + pp[i].p);         }       }     }     double s = 0;     for (i = 1; i <= n; i++) s = max(s, dp[i]);     printf( %.9lf n , s);   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7, mod2 = 998244353;   unsigned long long base = 131;   const int w = 1e7 + 5;   long long m, n;   int main() {     long long i, j, k, t, qqq;     cin >> n;     string a, b;     cin >> a >> b;     int flag = 0;     for (i = a.size() - 1; i >= 0; i--) {       int x = (b[i] -  a );       int y = (int)a[i] + x;       if (flag) y++, flag = 0;       if (y > (int) z ) y -= 26, flag++;       a[i] = (char)y;     }     if (flag) a.insert(a.begin(),  b );     flag = 0;     for (i = 0; i < a.size(); i++) {       int x = a[i] -  a ;       if (flag) x += 26, flag = 0;       int y = x % 2;       x /= 2;       a[i] = x +  a ;       if (y) flag = 1;     }     if (a.size() == n)       cout << a << endl;     else {       for (i = 1; i < a.size(); i++) printf( %c , a[i]);       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   const int maxm = 1e5 + 10;   const int INF = 0x3f3f3f3f;   const long long LINF = 3e17 + 1;   const int mod = 998244353;   int n, m, eid, sz;   inline int read() {     register int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 3) + (x << 1) + ch -  0 ;       ch = getchar();     }     return (f == 1) ? x : -x;   }   int a[maxn];   int main() {     ;     ios::sync_with_stdio(0);     cin.tie(0);     ;     int r;     cin >> n >> r;     for (int i = 1; i <= n; i++) cin >> a[i];     int cur = 1, res = 0;     while (cur <= n) {       int idx = 0;       for (int i = 1; i <= n; i++) {         if (a[i]) {           if (cur >= i - r + 1 && cur <= i + r - 1) {             idx = i;           }         }       }       if (idx == 0) {         cout << -1 << endl;         return 0;       }       res++;       cur = idx + r;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1LL << 28;   const long long mod = 1LL;   int arr[3 * 100010];   int main() {     int n, k, i, ans, flag, j;     while (scanf( %d %d , &n, &k) == 2) {       for (i = 0; i < n; i++) {         scanf( %d , &arr[i]);       }       sort(arr, arr + n);       ans = arr[0];       while (true) {         flag = true;         for (i = 0; i < n; i++) {           if (arr[i] % ans <= k) continue;           flag = false;           j = arr[i] / ans;           j++;           ans = arr[i] / j;         }         if (flag) break;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   const int dx[4] = {1, 0, -1, 0};   const int dy[4] = {0, 1, 0, -1};   const char dz[4] = { R ,  U ,  L ,  D };   int n, m, bs, i, j, xa, ya, xb, yb, xx, yy, dd, d[1010], a[1010][1010], g[1010],       c[1010], x[1010], y[1010], u[1010], f[1010], it;   long long cnt, cur;   char s[5];   int main() {     scanf( %d%d , &n, &bs);     for (i = 1; i <= n; i++) {       scanf( %d%d%d%d , &xa, &ya, &xb, &yb);       x[i] = xb;       y[i] = yb;       if (xa == xb) {         if (ya > yb) {           d[i] = 3;           for (j = yb; j <= ya; j++) a[xa][j] = i;         } else {           d[i] = 1;           for (j = ya; j <= yb; j++) a[xa][j] = i;         }       } else {         if (xa > xb) {           d[i] = 2;           for (j = xb; j <= xa; j++) a[j][ya] = i;         } else {           d[i] = 0;           for (j = xa; j <= xb; j++) a[j][ya] = i;         }       }     }     for (i = 1; i <= n; i++) {       for (xx = x[i], yy = y[i], dd = d[i];            xx >= 0 && yy >= 0 && xx <= bs && yy <= bs;            xx += dx[dd], yy += dy[dd], c[i]++) {         j = a[xx][yy];         if (j > 0) {           dd = d[j];           if (c[i] > 0 && x[j] == xx && y[j] == yy) break;         }       }       if (xx >= 0 && yy >= 0 && xx <= bs && yy <= bs) g[i] = j;     }     scanf( %d , &m);     while (m--) {       scanf( %d%d , &xx, &yy);       scanf( %s , s);       for (dd = 0; dd < 4; dd++)         if (dz[dd] == s[0]) break;       scanf( %I64d , &cnt);       for (; xx >= 0 && yy >= 0 && xx <= bs && yy <= bs;            xx += dx[dd], yy += dy[dd], cnt--) {         if (cnt == 0) break;         j = a[xx][yy];         if (j > 0) {           dd = d[j];           if (x[j] == xx && y[j] == yy) break;         }       }       if (xx >= 0 && yy >= 0 && xx <= bs && yy <= bs) {         if (cnt == 0) {           printf( %d %d n , xx, yy);           continue;         }       } else {         printf( %d %d n , xx - dx[dd], yy - dy[dd]);         continue;       }       for (cur = 0, ++it;; j = g[j]) {         if (u[j] == it) {           cnt -= f[j];           cnt %= cur - f[j];           cur = 0;           ++it;         }         xx = x[j];         yy = y[j];         dd = d[j];         if (g[j] == 0 || cur + c[j] > cnt) {           cnt -= cur;           break;         }         u[j] = it;         f[j] = cur;         cur += c[j];       }       for (; xx >= 0 && yy >= 0 && xx <= bs && yy <= bs;            xx += dx[dd], yy += dy[dd], cnt--) {         if (cnt == 0) break;         j = a[xx][yy];         if (j > 0) dd = d[j];       }       if (xx >= 0 && yy >= 0 && xx <= bs && yy <= bs)         printf( %d %d n , xx, yy);       else         printf( %d %d n , xx - dx[dd], yy - dy[dd]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 7;   const long long INF = 1e18;   const long long mod = 1e9 + 7;   int n;   int a;   int b;   int mxa;   int mxb;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> a >> b;     mxb = b;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       if (x && b < mxb) {         if (a) {           a--;           b += b < mxb;         } else if (b) {           b--;         }       } else {         if (b) {           b--;         } else if (a) {           a--;         }       }       if (!a && !b) {         cout << i << endl;         return 0;       }     }     cout << n << endl;   }
#include <bits/stdc++.h>   int prm[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};   long long n, ans;   void find(int k, long long cnt, long long sum) {     int i;     if (sum > n) return;     if (sum == n && cnt < ans) ans = cnt;     for (i = 1; i <= 63; i++) {       if (ans / prm[k] < cnt) break;       cnt = cnt * prm[k];       find(k + 1, cnt, sum * (i + 1));     }   }   int main() {     while (scanf( %I64d , &n) != EOF) {       ans = 2e65;       find(0, 1, 1);       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int v[4000 + 10], d[4000 + 10], p[4000 + 10];   int result[4000 + 10], check[1000000 + 10];   int main() {     int n, a, b;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       cin >> v[i] >> d[i] >> p[i];     }     int lost = 0;     for (int i = 0; i < n; i++) {       if (p[i] >= 0) {         result[lost++] = i + 1;         long long q = v[i];         long long k = 0;         for (int j = i + 1; j < n; j++) {           if (p[j] < 0) continue;           p[j] -= q;           p[j] -= k;           if (q) q--;           if (p[j] < 0 && k < 1e7) k += d[j];         }       }     }     printf( %d n , lost);     for (int i = 0; i < lost; i++) {       printf( %d  , result[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 7;   const int inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int mod = 1e9 + 7;   const double eps = 1e-8;   const double PI = acos(-1);   int n;   long long h[N], dp[N][2];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %lld , &h[i]), h[i]--;     h[n + 1] = inf;     dp[1][0] = h[1];     dp[1][1] = min(h[1], h[2]);     long long ans = dp[1][0];     for (int i = 2; i <= n; i++) {       dp[i][0] = (dp[i - 1][1] * min(h[i - 1], h[i]) + h[i]) % mod;       dp[i][1] = ((dp[i - 1][1] * min(h[i - 1], min(h[i], h[i + 1])) % mod) +                   min(h[i], h[i + 1])) %                  mod;       ans = (ans + dp[i][0]) % mod;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 4 * atan(1);   int T, N;   long long X[100013], Y[100013], Z[100013];   long long xmi, xma, ymi, yma, zmi, zma, smi, sma;   long long ansx, ansy, ansz;   inline bool is(long long x, int p) { return (((x % 2) + 2) % 2) == p; }   bool go(long long d) {     xmi = -8.1e18, xma = 8.1e18, ymi = -8.1e18, yma = 8.1e18, zmi = -8.1e18,     zma = 8.1e18, smi = -8.1e18, sma = 8.1e18;     for (int i = 0; i < N; i++) {       xmi = max(xmi, Y[i] + Z[i] - X[i] - d);       xma = min(xma, Y[i] + Z[i] - X[i] + d);       ymi = max(ymi, -Y[i] + Z[i] + X[i] - d);       yma = min(yma, -Y[i] + Z[i] + X[i] + d);       zmi = max(zmi, Y[i] - Z[i] + X[i] - d);       zma = min(zma, Y[i] - Z[i] + X[i] + d);       smi = max(smi, Y[i] + Z[i] + X[i] - d);       sma = min(sma, Y[i] + Z[i] + X[i] + d);     }     if (smi > sma || xmi > xma || ymi > yma || zmi > zma) return false;     for (int p = 0; p < 2; p++) {       if (smi == sma && is(smi, !p) || xmi == xma && is(xmi, !p) ||           ymi == yma && is(ymi, !p) || zmi == zma && is(zmi, !p))         continue;       long long qmi = 0;       qmi += (is(xmi, p) ? xmi : xmi + 1);       qmi += (is(ymi, p) ? ymi : ymi + 1);       qmi += (is(zmi, p) ? zmi : zmi + 1);       long long qma = 0;       qma += (is(xma, p) ? xma : xma - 1);       qma += (is(yma, p) ? yma : yma - 1);       qma += (is(zma, p) ? zma : zma - 1);       if (qmi <= qma && qmi <= sma && qma >= smi) {         if (qmi >= smi) {           ansx = (is(xmi, p) ? xmi : xmi + 1);           ansy = (is(ymi, p) ? ymi : ymi + 1);           ansz = (is(zmi, p) ? zmi : zmi + 1);         } else if (qma <= sma) {           ansx = (is(xma, p) ? xma : xma - 1);           ansy = (is(yma, p) ? yma : yma - 1);           ansz = (is(zma, p) ? zma : zma - 1);         } else {           xmi += is(xmi, !p);           xma -= is(xma, !p);           ymi += is(ymi, !p);           yma -= is(yma, !p);           zmi += is(zmi, !p);           zma -= is(zma, !p);           smi += is(smi, !p);           sma -= is(sma, !p);           if (xma + ymi + zmi < smi) {             if (xma + yma + zmi < smi) {               ansx = xma;               ansy = yma;               ansz = smi - ansx - ansy;             } else {               ansx = xma;               ansz = zmi;               ansy = smi - ansx - ansz;             }           } else {             ansy = ymi;             ansz = zmi;             ansx = smi - ymi - zmi;           }         }         return true;       }     }     return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> T;     while (T--) {       cin >> N;       for (int i = 0; i < N; i++) {         cin >> X[i] >> Y[i] >> Z[i];       }       long long lo = 0;       long long hi = 3.1e18;       while (lo != hi) {         long long mid = (lo + hi) / 2;         if (go(mid)) {           hi = mid;         } else {           lo = mid + 1;         }       }       go(lo);       cout << (ansy + ansz) / 2 <<     << (ansx + ansz) / 2 <<                << (ansx + ansy) / 2 <<   n ;     }     cout.flush();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[4];   int aux[100010];   int next(int x) {     if (x == 0) {       if (arr[1] > 0)         return 1;       else         return -1;     }     if (x == 1) {       if (arr[0] > 0)         return 0;       else if (arr[2] > 0)         return 2;       else         return -1;     }     if (x == 2) {       if (arr[1] > 0)         return 1;       else if (arr[3] > 0)         return 3;       else         return -1;     }     if (x == 3) {       if (arr[2] > 0)         return 2;       else         return -1;     }   }   int arrini[4];   int n;   void ok() {     cout <<  YES n ;     for (int i = 0; i < n; i++) cout << aux[i] <<    ;     cout <<   n ;   }   bool tenta(int ini) {     for (int i = 0; i < 4; i++) arr[i] = arrini[i];     arr[ini]--;     aux[0] = ini;     for (int i = 1; i < n; i++) {       int nex = next(aux[i - 1]);       if (nex == -1) return false;       aux[i] = nex;       arr[nex]--;     }     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> arrini[0] >> arrini[1] >> arrini[2] >> arrini[3];     for (int i = 0; i < 4; i++) arr[i] = arrini[i];     n = arr[0] + arr[1] + arr[2] + arr[3];     if (arrini[0] > 0) {       if (tenta(0)) {         ok();         return 0;       }     }     if (arrini[1] > 0) {       if (tenta(1)) {         ok();         return 0;       }     }     if (arrini[2] > 0) {       if (tenta(2)) {         ok();         return 0;       }     }     if (arrini[3] > 0) {       if (tenta(3)) {         ok();         return 0;       }     }     cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 25;   const long long LL_INF = 1ll << 61;   int main() {     int n;     scanf( %d , &n);     vector<int> count(3, 0);     for (int i = 0; i < n; i++) {       int num;       scanf( %d , &num);       count[num]++;     }     if (count[1] == 0) {       for (int i = 0; i < count[2]; i++) printf( 2  );       printf(  n );     } else {       if (count[2] == 0) {         for (int i = 0; i < count[1]; i++) printf( 1  );         printf(  n );       } else {         printf( 2 1  );         count[2]--;         count[1]--;         for (int i = 0; i < count[2]; i++) printf( 2  );         for (int i = 0; i < count[1]; i++) printf( 1  );         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define int               long long   #define pb                push_back   #define ppb               pop_back   #define pf                push_front   #define ppf               pop_front   #define all(x)            (x).begin(),(x).end()   #define uniq(v)           (v).erase(unique(all(v)),(v).end())   #define sz(x)             (int)((x).size())   #define fr                first   #define sc                second   #define pii               pair<int,int>   #define rep(i,a,b)        for(int i=a;i<b;i++)   #define mem1(a)           memset(a,-1,sizeof(a))   #define mem0(a)           memset(a,0,sizeof(a))   #define ppc               __builtin_popcount   #define ppcll             __builtin_popcountll      template<typename T1, typename T2>istream& operator>>(istream& in, pair<T1, T2> &a) {in >> a.fr >> a.sc; return in;}   template<typename T1, typename T2>ostream& operator<<(ostream& out, pair<T1, T2> a) {out << a.fr <<     << a.sc; return out;}   template<typename T, typename T1>T amax(T &a, T1 b) {if (b > a)a = b; return a;}   template<typename T, typename T1>T amin(T &a, T1 b) {if (b < a)a = b; return a;}      const long long INF = 1e18;   const int32_t M = 1e9 + 7;   const int32_t MM = 998244353;      const int N = 0;         void solve() {       int n, m, k;    cin >> n >> m >> k;    int fl = 0;    int sum = 1;    sum = 1 * (m - 1) + m * (n - 1);          if (sum == k)     cout <<  YES n ;    else     cout <<  NO n ;      }         signed main() {    ios_base::sync_with_stdio(false);    cin.tie(0); cout.tie(0);   #ifndef ONLINE_JUDGE    freopen( input.txt ,  r , stdin);    freopen( output.txt ,  w , stdout);   #endif    int t = 1;    cin >> t;    while (t--) solve();    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int t;     cin >> t;     while (t--) {       int n, g[105], sum = 0, s = 0;       cin >> n;       for (register int i = 0; i < n; i++)         cin >> g[i], g[i] == 0 ? sum++, g[i]++ : 0, s += g[i];       if (s == 0) sum++;       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int setb = 0;     int t[1000][1000];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> t[i][j];       }     }     int q;     cin >> q;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         setb += t[i][j] * t[j][i];       }     }     bool anss = setb % 2;     while (q--) {       char c;       cin >> c;       if (c ==  1 ) {         int idx;         cin >> idx;         anss ^= 1;       } else if (c ==  2 ) {         int idx;         cin >> idx;         anss ^= 1;       } else {         cout << anss;       }     }     cout << endl;     return 0;   }