malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int c[105], sum[105];   pair<int, int> p[105];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &c[i]);       sum[i] = sum[i - 1] + c[i];     }     int st = 1, tot = 0;     for (int i = 1; i <= n; i++) {       if (sum[i] - sum[st - 1] < 0 && (c[i + 1] > 0 || i == n))         p[++tot].first = st, p[tot].second = i, st = i + 1;       else if (sum[i] - sum[st - 1] > 0 && (c[i + 1] < 0 || i == n))         p[++tot].first = st, p[tot].second = i, st = i + 1;     }     if (st != n + 1)       printf( NO );     else {       printf( YES n%d n , tot);       for (int i = 1; i <= tot; i++) printf( %d %d n , p[i].first, p[i].second);     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},                               {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};   using namespace std;   int n, x, a[1 << 19];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cerr.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     multiset<int> ms;     for (int i = 1; i <= n; i++) {       cin >> x;       ms.insert(x);     }     for (int i = 1; i <= n; i++) {       auto it = ms.begin();       auto itt = ms.end();       itt--;       int x = 0;       for (int j = 29; j + 1; j--) {         if (a[i] & (1LL << j)) {           if (*itt >= x + (1LL << j)) {             x += (1LL << j);             auto luh = ms.lower_bound(x);             if (*luh > *it) it = luh;           }         } else {           if (*it < x + (1LL << j)) {             auto luh = ms.lower_bound(x + (1LL << j));             luh--;             if (*luh < *itt) itt = luh;           } else             x += (1LL << j);         }       }       cout << (a[i] ^ (*it)) <<    ;       ms.erase(it);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 512, M = 20000 + 10;   struct Stage {     int p[N];   } stage[N * 2];   struct Edge {     int u, v;     void init() { scanf( %d%d , &u, &v); }   } edge[M];   int preStg[M], postStg[M], nstg;   int p[N], num[N];   int n, m;   int findr(int x, int* P) {     int r = x;     while (P[r]) r = P[r];     while (P[x]) {       int t = P[x];       P[x] = r;       x = t;     }     return r;   }   void join(int x, int y, int* P) {     int r1 = findr(x, P);     int r2 = findr(y, P);     if (r1 == r2) return;     if (num[r1] > num[r2]) {       num[r1] += num[r2];       P[r2] = r1;     } else {       num[r2] += num[r1];       P[r1] = r2;     }   }   int l, r;   int solve() {     Stage st1 = stage[preStg[l]];     Stage st2 = stage[postStg[r]];     memset(num, 0, sizeof(num));     for (int i = 1; i <= n; ++i) {       join(i, st2.p[i], st1.p);     }     int sum = 0;     for (int i = 1; i <= n; ++i) {       sum += (findr(i, st1.p) == i);     }     return sum;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       edge[i].init();     }     memset(p, 0, sizeof(p));     memset(num, 0, sizeof(num));     for (int i = 1; i <= n; ++i) {       stage[nstg].p[i] = p[i];     }     nstg++;     for (int i = 1; i <= m; ++i) {       preStg[i] = nstg - 1;       if (findr(edge[i].u, p) != findr(edge[i].v, p)) {         join(edge[i].u, edge[i].v, p);         for (int j = 1; j <= n; ++j) {           stage[nstg].p[j] = p[j];         }         nstg++;       }     }     memset(p, 0, sizeof(p));     memset(num, 0, sizeof(num));     for (int i = 1; i <= n; ++i) {       stage[nstg].p[i] = p[i];     }     nstg++;     for (int i = m; i >= 1; --i) {       postStg[i] = nstg - 1;       if (findr(edge[i].u, p) != findr(edge[i].v, p)) {         join(edge[i].u, edge[i].v, p);         for (int j = 1; j <= n; ++j) {           stage[nstg].p[j] = p[j];         }         nstg++;       }     }     int q;     scanf( %d , &q);     while (q--) {       scanf( %d %d , &l, &r);       printf( %d n , solve());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, k, i, x, y, s, p;     cin >> n >> m;     s = 0;     k = 1;     for (i = 1; i <= n; i++) {       cin >> x >> y;       k = x - k;       p = k % m;       x -= p;       s += y - x + 1;       k = y + 1;     }     cout << s << endl;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:136777216 )   using namespace std;   int bits(int x) { return x == 0 ? 0 : 1 + bits(x & (x - 1)); }   int v[30][30];   int dp[2][26][111];   int main() {     const int ninf = -1000000;     for (int(i) = 0; (i) < (30); (i)++)       for (int(j) = 0; (j) < (30); (j)++) v[i][j] = 0;     string s;     int K, m;     cin >> s >> K >> m;     int n = (int)(s).size();     K = min(K, n);     char a, b;     int c;     for (int(i) = 0; (i) < (m); (i)++) {       cin >> a >> b >> c;       v[a -  a ][b -  a ] = c;     }     for (int(j) = 0; (j) < (26); (j)++)       for (int(k) = 0; (k) < (K + 1); (k)++) dp[0][j][k] = ninf;     for (int(j) = 0; (j) < (26); (j)++)       if (j == s[0] -  a )         dp[0][j][0] = 0;       else         dp[0][j][1] = 0;     int add;     for (int i = 1; i < n; i++) {       int now = i % 2, bef = 1 - now;       for (int(j) = 0; (j) < (26); (j)++)         for (int(k) = 0; (k) < (K + 1); (k)++) dp[now][j][k] = ninf;       for (int(prev) = 0; (prev) < (26); (prev)++)         for (int(cur) = 0; (cur) < (26); (cur)++) {           if (cur == s[i] -  a )             add = 0;           else             add = 1;           if (add == 0)             dp[now][cur][0] =                 max(dp[now][cur][0], dp[bef][prev][0] + v[prev][cur]);           for (int(ch) = (1); (ch) < (K + 1); (ch)++) {             dp[now][cur][ch] =                 max(dp[now][cur][ch], dp[bef][prev][ch - add] + v[prev][cur]);           }         }     }     int r = ninf, t = (n - 1) % 2;     for (int(j) = 0; (j) < (26); (j)++)       for (int(k) = 0; (k) < (K + 1); (k)++) r = max(r, dp[t][j][k]);     cout << r;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, a = 0, b = 0, c = 0, d = 0, i, e = 0, mine = 0, mn = 0;     cin >> n;     string s;     cin >> s;     for (i = 0; i < s.size(); i++) {       if (s[i] ==  z ) a++;       if (s[i] ==  e ) b++;       if (s[i] ==  r ) c++;       if (s[i] ==  o ) d++;       if (s[i] ==  n ) e++;     }     mn = min(min(d, c), min(a, b));     if (b > mn && d > mn && e > 0) {       mine = min(min((b - mn), (d - mn)), e);       for (i = 0; i < mine; i++) {         cout <<  1               <<    ;       }     }     if (mn > 0) {       for (i = 0; i < mn; i++) {         cout <<  0               <<    ;       }     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int hm(string s) {     int c = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  a  || s[i] ==  e  || s[i] ==  i  || s[i] ==  o  || s[i] ==  u )         c++;     }     return c;   }   int main() {     string s1, s2, s3;     getline(cin, s1);     getline(cin, s2);     getline(cin, s3);     if (hm(s1) == 5 && hm(s2) == 7 && hm(s3) == 5)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long oll = 0;   bool comp(const pair<int, int> &a, const pair<int, int> &b) {     return a.second < b.second;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<long long> first, second;     long long fr = 0, sc = 0;     int lst = -1;     for (long long i = 0; i < n; i++) {       int temp;       cin >> temp;       if (temp > 0) {         if (i == n - 1) {           lst = 1;         }         first.push_back(temp);         fr += temp;       } else {         if (i == n - 1) {           lst = 2;         }         temp *= -1;         second.push_back(temp);         sc += (temp);       }     }     if (fr > sc) {       cout <<  first             <<   n ;     } else if (fr < sc) {       cout <<  second             <<   n ;     } else {       int win = -1;       for (long long i = 0; i < min(first.size(), second.size()); i++) {         if (first[i] > second[i]) {           win = 1;           break;         } else if (first[i] < second[i]) {           win = 2;           break;         }       }       if (win == 1) {         cout <<  first               <<   n ;       } else if (win == 2) {         cout <<  second               <<   n ;       } else {         if (lst == 1) {           cout <<  first                 <<   n ;         } else {           cout <<  second                 <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dr[] = {-1, 0, 1, 0, -1, 1, 1, -1};   int dc[] = {0, 1, 0, -1, 1, 1, -1, -1};   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     while (cin >> n) {       vector<int> arr;       int st = 1;       int ans = 0;       for (int i = (0); i <= (2 * n - 1); i += (1)) {         string s;         cin >> s;         if (s ==  remove ) {           if (arr.empty()) {             st++;             continue;           }           if (st == arr[(int)arr.size() - 1]) {             st++;             arr.pop_back();           } else {             arr.clear();             st++;             ans++;           }         } else {           int nn;           cin >> nn;           arr.push_back(nn);         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     char a[100010];     int k;     cin >> s;     k = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] == a[k])         k--;       else {         k++;         a[k] = s[i];       }     }     if (k == 0)       cout <<  Yes ;     else       cout <<  No ;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T abs(T x) {     if (x < 0) return -x;     return x;   }   template <class T>   T sqr(T a) {     return a * a;   }   const double pi = acos(-1.0);   const double eps = 1e-8;   int ar[150010];   int flag[150010];   int i, n;   int main() {     while (1 == scanf( %d , &n)) {       memset(flag, 0, sizeof flag);       for (i = 0; i < n; i++) scanf( %d , &ar[i]);       sort(&ar[0], &ar[n]);       for (i = 0; i < n; i++) {         if (flag[ar[i] - 1] == 0 && ar[i] > 1)           flag[ar[i] - 1]++;         else if (flag[ar[i]] == 0)           flag[ar[i]]++;         else if (flag[ar[i] + 1] == 0)           flag[ar[i] + 1]++;       }       int cnt = 0;       for (i = 1; i <= 150001; i++)         if (flag[i]) cnt++;       printf( %d n , cnt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 2000000000;   const long double eps = 1e-07;   int n, m;   int a[2000];   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; ++i) {       int x, y;       scanf( %d %d , &x, &y);       ++a[x];       ++a[y];     }     for (int i = 0; i < n; ++i)       if (a[i + 1] == 0) {         printf( %d n , n - 1);         for (int j = 1; j <= n; ++j) {           if (j != (i + 1)) printf( %d %d n , i + 1, j);         }         return 0;       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, L, a;   int t[int(1e5 + 9)], l[int(1e5 + 9)];   int ans;   int main() {     cin >> n >> L >> a;     for (int i = 0; i < n; i++) {       cin >> t[i] >> l[i];     }     for (int i = 0; i + 1 < n; i++) {       int st = t[i] + l[i];       int en = t[i + 1];       if (en - st >= a) {         ans += (en - st) / a;       }     }     if (t[0] >= a) ans += t[0] / a;     if (L - (t[n - 1] + l[n - 1]) >= a) ans += (L - (t[n - 1] + l[n - 1])) / a;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void _print(long long t) { cerr << t; }   void _print(string t) { cerr << t; }   void _print(char t) { cerr << t; }   void _print(long double t) { cerr << t; }   void _print(double t) { cerr << t; }   void _print(unsigned long long t) { cerr << t; }   template <class T, class V>   void _print(pair<T, V> p);   template <class T>   void _print(vector<T> v);   template <class T>   void _print(set<T> v);   template <class T, class V>   void _print(map<T, V> v);   template <class T>   void _print(multiset<T> v);   template <class T, class V>   void _print(pair<T, V> p) {     cerr <<  { ;     _print(p.first);     cerr <<  , ;     _print(p.second);     cerr <<  } ;   }   template <class T>   void _print(vector<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(set<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(multiset<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T, class V>   void _print(map<T, V> v) {     cerr <<  [  ;     for (auto i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   long long n = 0;   const long long mod = 1e9 + 7;   long long tt = 0;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long power(long long x, long long y, long long m) {     if (y == 0) return 1;     if (y == 1) return x;     long long cur = power(x, y / 2, m);     cur = (cur % m * cur % m);     if ((y & 1)) cur = (cur % m * x % m) % m;     return cur;   }   long long modinv(long long x, long long m) { return power(x, m - 2, m) % m; }   void pre_solve() {}   void sol(long long tc) {     cin >> n;     vector<vector<long long> > arr(n, vector<long long>(3));     for (long long i = 0; i < n; i++) {       cin >> arr[i][0] >> arr[i][1];       arr[i][2] = i;     }     sort(arr.begin(), arr.end());     long long y = arr[0][1], idx = 0;     for (idx = 1; idx < n; idx++) {       if (arr[idx][0] > y)         break;       else {         y = max(arr[idx][1], y);       }     }     if (idx == n)       cout << -1 << endl;     else {       long long ans[n];       for (long long i = 0; i < idx; i++) {         ans[arr[i][2]] = 1;       }       for (long long i = idx; i < n; i++) ans[arr[i][2]] = 2;       for (long long i = 0; i < n; i++) cout << ans[i] <<    ;       cout << endl;     }     return;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long tc = 1;     cin >> tc;     while (tc--) {       tt++;       sol(tc);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MODULO = 1000000007;   void ftime() {}   void print_arr(int n, bool arr[]) {     for (int i = 0; i < n; i++) {       cout << arr[i] <<    ;     }     cout <<   n ;   }   void print_arr(int n, int arr[]) {     for (int i = 0; i < n; i++) {       cout << arr[i] <<    ;     }     cout <<   n ;   }   void print_vec(vector<int> &vec) {     for (auto e : vec) {       cout << e <<    ;     }     cout <<   n ;   }   void print_vec(vector<long long> &vec) {     for (auto e : vec) {       cout << e <<    ;     }     cout <<   n ;   }   void print_vec(vector<bool> &vec) {     for (auto e : vec) {       cout << e <<    ;     }     cout <<   n ;   }   static int speed_increase = []() {     std::ios::sync_with_stdio(false);     std::cin.tie(NULL);     return 0;   }();   void print_map(unordered_map<long long, long long> &comp) {     for (auto e : comp) {       cout << e.first <<   :   << e.second <<   n ;     }     cout <<   n ;   }   vector<long long> fdp(1000, -1);   long long fact(long long val) {     if (fdp[val] > 0) {       return fdp[val];     }     if (val < 2) return 1;     fdp[val] = (val * fact(val - 1)) % MODULO;     return fdp[val];   }   long long modexp(long long base, long long exponent) {     long long res = 1;     base = (base % MODULO + MODULO) % MODULO;     while (exponent) {       if (exponent & 1) res = (res * base) % MODULO;       exponent >>= 1;       base = (base * base) % MODULO;     }     return res;   }   int main() {     int n, m;     cin >> n >> m;     vector<long long> vals(m + 1, 0);     vector<long long> lights(m, 0);     for (auto &x : lights) {       cin >> x;     }     sort(lights.begin(), lights.end());     int last = 0;     int curr;     for (int i = 0; i < m; i++) {       curr = lights[i];       vals[i] = curr - last - 1;       last = curr;     }     vals[m] = n - last;     long long sum = accumulate(vals.begin(), vals.end(), 0ll);     long long ans = fact(sum) % MODULO;     for (int i = 0; i < m + 1; i++) {       if (vals[i] > 1) {         ans *= modexp(fact(vals[i]), MODULO - 2);         ans %= MODULO;       }       if (i != 0 && i != m && vals[i] > 1) {         ans *= modexp(2, vals[i] - 1);         ans %= MODULO;       }     }     cout << ans;     ftime();     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, m, z, l, k, i = 1, j = 1, p = 0, q = 0, count = 0;     scanf( %d%d%d , &n, &m, &z);     int a[10000], b[10000];     while ((i * n) <= z) {       a[p] = i * n;       i++;       p++;     }     while ((j * m) <= z) {       b[q] = j * m;       j++;       q++;     }     for (k = 0; k < p; k++) {       for (l = 0; l < q; l++) {         if (a[k] == b[l]) count++;       }     }     printf( %d n , count);     return 0;   }
#include <bits/stdc++.h>   int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }   int main() {     int a[55], b[55], m, i, j, map[55], n, x, y, s;     while (~scanf( %d , &m)) {       for (i = 0; i < m - 1; i++) {         scanf( %d , &a[i]);       }       for (i = 0; i < m - 1; i++) {         scanf( %d , &b[i]);       }       j = 0;       for (i = 0; i < m; i++) {         scanf( %d , &s);         for (x = i; x < m - 1; x++) {           s += b[x];         }         for (y = 0; y < i; y++) {           s += a[y];         }         map[j++] = s;       }       qsort(map, j, sizeof(map[0]), cmp);       printf( %d n , map[0] + map[1]);     }   }
#include <bits/stdc++.h>   using namespace std;   string to_string(string s) { return     + s +    ; }   template <typename T>   string to_string(vector<T>);   template <typename U, typename V>   string to_string(pair<U, V> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename T>   string to_string(vector<T> v) {     string r =  [ ;     for (int i = 0; i < (int)v.size() - 1; i++) r += to_string(v[i]) +  ,  ;     if (!v.empty()) r += to_string(v.back());     return r +  ] ;   }   int main() {     int a, b, c, d, k, tc;     scanf( %d , &tc);     while (tc--) {       scanf( %d%d%d%d%d , &a, &b, &c, &d, &k);       int x = (a - 1) / c + 1;       int y = (b - 1) / d + 1;       if (x + y > k)         printf( -1 n );       else         printf( %d %d n , x, y);     }   }
#include <bits/stdc++.h>   using namespace std;   int n, a;   vector<int> v1, v2;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a;       v1.push_back(a);       v2.push_back(a);     }     sort(v2.begin(), v2.end());     a = 0;     for (int i = 0; i < n; i++) {       a += v1[i] != v2[i];     }     (a < 3) ? cout <<  YES  << endl : cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 7, M = 20, MOD = 1000 * 1000 * 1000 + 7;   int sum(int a, int b) {     a += b;     if (a < 0)       a += MOD;     else if (a >= MOD)       a -= MOD;     return a;   }   void _sum(int &a, int b) { a = sum(a, b); }   int mul(int a, int b) { return 1LL * a * b % MOD; }   void _mul(int &a, int b) { a = mul(a, b); }   int power(int a, int b) {     int res = 1;     while (b) {       if (b & 1) _mul(res, a);       _mul(a, a);       b >>= 1;     }     return res;   }   int inv(int x) { return power(x, MOD - 2); }   int n, f[1 << N], p[N][N], dp[N][1 << M], pro[N][1 << N];   vector<int> vec[N];   void input() {     cin >> n;     for (int i = 1; i <= n; i++) {       for (int j = 0; j < n; j++) {         cin >> p[i][j];         _mul(p[i][j], inv(100));       }       for (int mask = 0; mask < (1 << n); mask++) {         pro[i][mask] = 1;         for (int j = 0; j < n; j++)           if (mask & (1 << j))             _mul(pro[i][mask], p[i][j]);           else             _mul(pro[i][mask], sum(1, -p[i][j]));       }     }   }   void pre_pro() {     for (int i = 0; i < (1 << n); i++) {       f[i] = vec[__builtin_popcount(i)].size();       vec[__builtin_popcount(i)].push_back(i);     }   }   void act(int i, int mask, int nei) {     int nxt = 0;     vector<int> a, b;     for (int j = 0; j < vec[i].size(); j++)       if (mask & (1 << j)) a.push_back(vec[i][j]);     for (int j = 0; j < n; j++)       if (nei & (1 << j)) b.push_back(j);     for (int x : a)       for (int y : b)         if ((x & (1 << y)) == false) nxt |= (1 << f[x | (1 << y)]);     _sum(dp[i + 1][nxt], mul(dp[i][mask], pro[i + 1][nei]));   }   void solve() {     dp[0][1] = 1;     for (int i = 0; i < n; i++)       for (int mask = 0; mask < (1 << vec[i].size()); mask++)         if (dp[i][mask])           for (int nei = 0; nei < (1 << n); nei++) act(i, mask, nei);   }   int main() {     ios::sync_with_stdio(false), cin.tie(0);     input();     pre_pro();     solve();     cout << dp[n][1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 23;   const int MOD = 1e9 + 7;   const int N = 1000 + 10;   int brow[N], bcol[N];   int main() {     ios_base::sync_with_stdio(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < (m); ++i) {       int x, y;       cin >> x >> y;       brow[x] = true;       bcol[y] = true;     }     int ans = 0;     for (int i = (2); i < (n); ++i) {       if (i == n - i + 1)         ans += !brow[i] || !bcol[i];       else {         ans += !brow[i];         ans += !bcol[i];       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int dp[100002];   int f(int x) {     if (dp[x] != -1) return dp[x];     bool nim[100] = {};     for (int i = 2; i * (i - 1) < 2 * x; i++) {       if ((2 * x - i * (i - 1)) % (2 * i) == 0) {         int tmp = 0, xx = (2 * x - i * (i - 1)) / (2 * i);         for (int j = 0; j < i; j++) tmp ^= f(xx + j);         nim[tmp] = 1;         if (tmp == 0 && x == n) {           printf( %d n , i);           return 1;         }       }     }     int ret = 0;     while (nim[ret]) ret++;     return dp[x] = ret;   }   int main() {     scanf( %d , &n);     memset(dp, -1, sizeof dp);     if (f(n))       ;     else       printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int test;     scanf( %d , &(test));     for (int t = 1; t <= test; t++) {       int n;       scanf( %d , &(n));       int a[200], cnt = 0;       int sum = 0;       for (int i = 0; i < n; i++) {         scanf( %d , &(a[i]));         if (a[i] == 0) {           a[i] = 1;           cnt++;         }         sum = sum + a[i];       }       if (sum != 0)         cout << cnt << endl;       else {         cout << cnt + 1 << endl;       }     }     return 0;   }