malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   using min_pq = priority_queue<T, vector<T>, greater<T>>;   template <typename T>   using max_pq = priority_queue<T>;   const int inf = 2e9 + 5;   const long long l_inf = 2e18 + 5;   const int mod_v = 1e9 + 7;   const int max_n = 1e5 + 5;   const int dx[4] = {-1, 0, 1, 0};   const int dy[4] = {0, 1, 0, -1};   template <typename T>   T gcd(T a, T b) {     while (b) {       T temp = a % b;       a = b;       b = temp;     }     return a;   }   template <typename T>   tuple<T, T, T> egcd(T a, T b) {     T x1 = 1, x2 = 0, y1 = 0, y2 = 1;     while (b) {       T q = a / b, r = a % b;       T new_x = x1 - q * x2, new_y = y1 - q * y2;       x1 = x2, y1 = y2, x2 = new_x, y2 = new_y;       a = b, b = r;     }     return make_tuple(a, x1, y1);   }   inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }   template <typename T>   inline T mod(T a, T b = mod_v) {     return (a % b + b) % b;   }   template <typename T>   inline T mod_inv(T a, T b = mod_v) {     return mod(get<1>(egcd(a, b)), b);   }   template <typename T>   inline T sum(T a, T b, T m = mod_v) {     return mod(mod(a, m) + mod(b, m), m);   }   template <typename T>   inline T difference(T a, T b, T m = mod_v) {     return mod(mod(a, m) - mod(b, m), m);   }   inline long long product(long long a, long long b, long long m = mod_v) {     return mod(mod(a, m) * mod(b, m), m);   }   inline long long quotient(long long a, long long b, long long m = mod_v) {     return mod(mod(a, m) * mod_inv(b, m), m);   }   template <typename T, typename T2>   ostream &operator<<(ostream &s, const pair<T, T2> &p) {     return s << p.first <<     << p.second <<    ;   }   template <typename T, typename T2>   istream &operator>>(istream &s, pair<T, T2> &p) {     return s >> p.first >> p.second;   }   template <typename T>   ostream &operator<<(ostream &s, const vector<T> &v) {     for (auto it : v) s << it <<    ;     return s;   }   template <typename T>   istream &operator>>(istream &s, vector<T> &v) {     for (auto it = (v).begin(), it_ = (v).end(); it != it_; ++it) s >> *it;     return s;   }   template <typename T>   void read_range(T beg, T end) {     while (beg != end) cin >> *beg++;   }   template <typename T>   void print_range(T beg, T end) {     while (beg != end) cout << *beg++ <<    ;   }   struct reader {     template <typename T>     reader &operator,(T &v) {       cin >> v;       return *this;     }   } rdr;   struct debugger {     template <typename T>     debugger &operator,(const T &v) {       cerr << v <<  ,  ;       return *this;     }   } dbg;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int x[2];     cin >> x[0] >> x[1];     int a[2] = {0, 0};     for (int i = 0;; ++i) {       int n_a;       if (i / 2 % 2)         n_a = a[i % 2] - (i / 2 + 1);       else         n_a = a[i % 2] + (i / 2 + 1);       if (a[1 - i % 2] == x[1 - i % 2] and           ((x[i % 2] >= a[i % 2] and x[i % 2] <= n_a) or            (x[i % 2] <= a[i % 2] and x[i % 2] >= n_a))) {         cout << i;         return 0;       }       a[i % 2] = n_a;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int m, n, rowStart[1010], rowEnd[1010], colStart[1010], colEnd[1010],       sum[1010][1010];   int startX = -1, startY;   string a[1010];   void quit() {     cout << -1 << endl;     exit(0);   }   int getSum(int x, int y, int row, int col) {     return sum[x][y] + sum[x - row][y - col] - sum[x - row][y] - sum[x][y - col];   }   int ok(int row, int col) {     int x = startX + row - 1, y = startY + col - 1, covered = col * row;     while (1) {       if (x < m && getSum(x + 1, y, row, col) == row * col) {         x++;         covered += col;       } else if (y < n && getSum(x, y + 1, row, col) == row * col) {         y++;         covered += row;       } else         break;     }     return covered == sum[m][n];   }   void solve() {     int sideRow = colEnd[startY] - colStart[startY] + 1;     int sideCol = rowEnd[startX] - rowStart[startX] + 1;     int ans = m * n + 1;     for (int col = 1; col <= sideCol; col++)       if (ok(sideRow, col)) {         ans = min(ans, sideRow * col);         break;       }     for (int row = 1; row <= sideRow; row++)       if (ok(row, sideCol)) {         ans = min(ans, sideCol * row);         break;       }     if (ans > m * n) ans = -1;     cout << ans << endl;   }   int main() {     ios::sync_with_stdio(0);     cin >> m >> n;     for (int i = 1; i <= m; i++) {       cin >> a[i];       rowStart[i] = rowEnd[i] = -1;       int cntX = 0;       for (int j = 1; j <= n; j++) {         sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];         if (a[i][j - 1] ==  X ) {           if (startX < 0) {             startX = i;             startY = j;           }           if (rowStart[i] < 0) rowStart[i] = j;           rowEnd[i] = j;           cntX++;           sum[i][j]++;         }       }       if (rowStart[i] > 0 && cntX != rowEnd[i] - rowStart[i] + 1) quit();     }     for (int j = 1; j <= n; j++) {       colStart[j] = colEnd[j] = -1;       int cntX = 0;       for (int i = 1; i <= m; i++)         if (a[i][j - 1] ==  X ) {           if (colStart[j] < 0) colStart[j] = i;           colEnd[j] = i;           cntX++;         }       if (colStart[j] > 0 && cntX != colEnd[j] - colStart[j] + 1) quit();     }     solve();   }
#include <bits/stdc++.h>   using namespace std;   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;   }   template <typename T>   T amod(T a) {     if (a < 0) a = -a;     return a;   }   void solve() {     long long int n, s, a, sum = 0;     cin >> n >> s;     long long int maxs = 0;     for (long long int i = 0; i < n; i++) {       cin >> a;       sum += a;       maxs = max(a, maxs);     }     if ((sum - maxs) <= s) {       cout <<  YES ;     } else {       cout <<  NO ;     }   }   int main() {     long long int t;     t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ans[21][21];   int cnt[1100];   int n;   vector<int> fang, four;   void output() {     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         cout << ans[i][j] <<    ;       }       cout << endl;     }   }   bool check() {     int sum = 0;     for (int i = 0; i < fang.size(); ++i) {       if (cnt[fang[i]] >= 4) {         four.push_back(fang[i]);         sum += cnt[fang[i]] / 4;       }     }     return sum >= ((n / 2) * (n / 2));   }   int main() {     int num;     cin >> n;     for (int i = 0; i < n * n; ++i) {       cin >> num;       cnt[num]++;     }     int flag = 1, flag2 = 0, lcqi;     for (int i = 1; i <= 1000; ++i) {       if (cnt[i]) {         fang.push_back(i);         if (cnt[i] % 4) {           flag = 0;         }         if (cnt[i] & 1) flag2++, lcqi = fang.size() - 1;       } else         continue;     }     if ((n & 1) == 0) {       if (flag) {         cout <<  YES n ;         int lc = 0;         for (int i = 1; i <= n / 2; ++i) {           for (int j = 1; j <= n / 2; ++j) {             ans[i][j] = ans[n - i + 1][j] = ans[i][n - j + 1] =                 ans[n - i + 1][n - j + 1] = fang[lc];             cnt[fang[lc]] -= 4;             if (cnt[fang[lc]] == 0) {               lc++;             }           }         }         output();       } else         cout <<  NO n ;     } else {       if (flag2 != 1) {         cout <<  NO n ;         return 0;       }       ans[n / 2 + 1][n / 2 + 1] = fang[lcqi];       cnt[fang[lcqi]]--;       int ok = check();       if (!ok) {         puts( NO n );         return 0;       }       cout <<  YES n ;       int lcf = 0;       for (int i = 1; i <= n / 2; ++i) {         for (int j = 1; j <= n / 2; ++j) {           ans[i][j] = ans[n - i + 1][j] = ans[i][n - j + 1] =               ans[n - i + 1][n - j + 1] = four[lcf];           cnt[four[lcf]] -= 4;           if (cnt[four[lcf]] < 4) {             lcf++;           }         }       }       lcf = 0;       while (lcf < fang.size() && cnt[fang[lcf]] == 0) {         lcf++;       }       for (int i = 1; i <= n / 2; ++i) {         ans[i][n / 2 + 1] = ans[n - i + 1][n / 2 + 1] = fang[lcf];         cnt[fang[lcf]] -= 2;         if (cnt[fang[lcf]] == 0) {           while (lcf < fang.size() && cnt[fang[lcf]] == 0) {             lcf++;           }         }       }       for (int i = 1; i <= n / 2; ++i) {         ans[n / 2 + 1][i] = ans[n / 2 + 1][n - i + 1] = fang[lcf];         cnt[fang[lcf]] -= 2;         if (cnt[fang[lcf]] == 0) {           while (lcf < fang.size() && cnt[fang[lcf]] == 0) {             lcf++;           }         }       }       output();     }     return 0;   }
#include <bits/stdc++.h>   const int mod = 1000000007;   const int modx = 998244353;   using namespace std;   void thunder() {     long long n;     cin >> n;     vector<long long> a(n), b(n);     long long i, j;     for (i = 0; i < n; i++) cin >> a[i];     map<long long, long long> m;     for (i = 0; i < n; i++) {       long long idx = i + a[i % n];       idx %= n;       idx += n;       idx %= n;       if (m.count(idx) == 0)         m[idx]++;       else {         cout <<  NO               <<   n ;         return;       }     }     cout <<  YES           <<   n ;     return;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     cin >> t;     while (t--) thunder();   }
#include <bits/stdc++.h>   using namespace std;   long long sums[30000], dp[25][3000][25], can[3000], n, i, j, k, x, y, a[300];   int main() {     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     reverse(a, a + n);     for (i = 0; i < n; i++)       if (a[i] == 1) {         k = i;         break;       }     if (k == 0) {       if (n == 1)         cout <<  YES  << endl;       else         cout <<  NO  << endl;       return 0;     }     if (k > 11) {       cout <<  NO  << endl;       return 0;     }     for (i = 0; i < (1 << k); i++) {       long long cnt = 0;       for (j = 0; j < k; j++)         if (i & (1 << j)) sums[i] += a[j], cnt++;       can[i] = cnt;     }     dp[0][1][0] = 1;     for (i = 0; i < k; i++)       for (j = 0; j < (1 << k); j++)         if (j & ((1 << (i + 1)) - 1) == (1 << (i + 1)) - 1)           for (x = 0; x <= n - k; x++) {             long long tmp = (1 << k) - 1 - j;             for (y = tmp;; y = ((y - 1) & tmp)) {               if (a[i] - sums[y] - 1 >= 0 && can[y] + a[i] - sums[y] - 1 != 1) {                 if (dp[i][j][x] == 1 && x + a[i] - sums[y] - 1 <= n - k &&                     a[i] - sums[y] - 1 >= 0) {                   dp[i + 1][j | y][x + a[i] - sums[y] - 1] = 1;                 }               }               if (y == 0) break;             }           }     if (dp[k][(1 << k) - 1][n - k])       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int mod = 1e9 + 7;   int n, a[N];   vector<int> get_divisors(int u) {     vector<int> res;     for (int i = 1; i * i <= u; ++i) {       if (u % i == 0) {         res.push_back(i);         if (i != u / i) res.push_back(u / i);       }     }     sort(res.begin(), res.end());     return res;   }   int add(int a, int b) { return (a + b) % mod; }   int sub(int a, int b) {     long long result = a - b;     if (result < 0) result += mod;     return result;   }   long long mul(long long a, long long b) { return (a * b) % mod; }   int modpow(int base, int exp) {     long long res = 1;     while (exp > 0) {       if (exp % 2) res = (res * base) % mod;       base = (1ll * base * base) % mod;       exp /= 2;     }     return (int)res;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     long long res = 0;     for (int i = 1; i <= a[n - 1]; ++i) {       vector<int> divisors = get_divisors(i);       int prev = -1, dsz = divisors.size();       long long toAdd = 1;       for (int j = 1; j < dsz; ++j) {         int pos = lower_bound(a, a + n, divisors[j]) - a - 1;         int count = pos - prev;         toAdd = mul(toAdd, modpow(j, count));         prev = pos;       }       int count = n - 1 - prev;       assert(count > 0);       long long added_value = modpow(dsz, count);       added_value = sub(added_value, modpow(dsz - 1, count));       toAdd = mul(toAdd, added_value);       res = add(res, toAdd);     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   long int mod = 1e9 + 7;   long int i, j, n, t, m, k;   vector<pair<long int, long int> > a, b;   set<long int> c;   bool cmp(const pair<long int, long int> &l, const pair<long int, long int> &r) {     return l.first < r.first;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (long int i = 0; i < m; i++) {       cin >> j;       a.push_back(make_pair(j, i));       c.insert(j);     }     sort(a.begin(), a.end());     for (long int i = 0; i < a.size(); i++) {       if ((i + 1) < a.size()) {         long int rag = a[i].second, bha = a[i].second;         j = i + 1;         while (a[i].first == a[j].first) {           rag = max(rag, a[j].second);           bha = min(bha, a[j].second);           j++;           if (j >= a.size()) break;         }         i = j - 1;         b.push_back(make_pair(a[i].first, bha));         b.push_back(make_pair(a[i].first, rag));       } else {         b.push_back(make_pair(a[i].first, a[i].second));         b.push_back(make_pair(a[i].first, a[i].second));       }     }     for (long int i = 1; i < n + 1; i++) {       long int l, rag = -1, bha = -1, rag1 = -1, bha1 = -1;       l = lower_bound(b.begin(), b.end(), pair<long int, long int>(i, 0), cmp) -           b.begin();       if (l >= b.size()) l--;       if (b[l].first == i) {         bha = b[l].second;         rag = b[l + 1].second;       }       l = lower_bound(b.begin(), b.end(), pair<long int, long int>(i + 1, 0),                       cmp) -           b.begin();       if (l >= b.size()) l--;       if (b[l].first == i + 1) {         bha1 = b[l].second;         rag1 = b[l + 1].second;       }       if ((rag == -1 && bha == -1) && (rag1 == -1 && bha1 == -1))         continue;       else if ((rag != -1 && bha != -1) && (rag1 != -1 && bha1 != -1)) {         if (bha < rag1) t++;         if (bha1 < rag) t++;       }     }     t += c.size();     t = ((3 * n) - 2) - t;     cout << t;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<ll, ll>;   const ll MOD = 1e9 + 7, N = 1e5 + 10;   const ll LG = log2(N) + 1;   struct LCA {     vector<vector<ll>> G, parent;     vector<ll> tin, tout, depth;     ll timer;     ll n;     ll LG;     LCA(vector<vector<ll>> G, ll R = 1) {       this->G = G;       this->n = G.size();       this->LG = log2(n) + 1;       this->timer = 0;       tin.assign(n, 0);       tout.assign(n, 0);       depth.assign(n, 0);       tin[0] = ++timer;       parent = vector<vector<ll>>(n, vector<ll>(LG));       dfs(R);       tout[0] = ++timer;       compute();     }     void dfs(ll u, ll p = 0, ll d = 0) {       parent[u][0] = p;       tin[u] = ++timer;       depth[u] = d;       for (auto &v : G[u]) {         if (v != p) {           dfs(v, u, d + 1);         }       }       tout[u] = ++timer;     }     void compute() {       for (ll j = 1; j < LG; j++) {         for (ll i = 1; i < n; i++) {           if (parent[i][j - 1]) {             parent[i][j] = parent[parent[i][j - 1]][j - 1];           }         }       }     }     bool is_anc(ll u, ll v) { return tin[u] <= tin[v] and tout[v] <= tout[u]; }     ll lca(ll u, ll v) {       if (is_anc(u, v)) return u;       if (is_anc(v, u)) return v;       for (ll i = LG - 1; i >= 0; i--) {         if (!is_anc(parent[u][i], v)) {           u = parent[u][i];         }       }       u = parent[u][0];       return u;     }     ll dist(ll u, ll v) { return depth[u] + depth[v] - 2 * depth[lca(u, v)]; }   };   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ll n, q;     cin >> n >> q;     vector<vector<ll>> G(n + 1);     for (ll i = 2; i < n + 1; i++) {       ll p;       cin >> p;       G[i].push_back(p);       G[p].push_back(i);     }     LCA lc(G);     while (q--) {       ll a, b, c;       cin >> a >> b >> c;       vector<ll> A = {a, b, c};       sort(A.begin(), A.end());       ll ans = 0;       ll cn = 0;       do {         cn++;         ll s = A[0], f = A[1], t = A[2];         if (lc.lca(s, t) == lc.lca(f, t)) {           if (lc.depth[lc.lca(s, t)] <= lc.depth[t]) {             ans = max(ans, lc.depth[t] + lc.depth[lc.lca(s, f)] -                                2 * lc.depth[lc.lca(s, t)]);           }         } else {           if (lc.depth[lc.lca(s, t)] < lc.depth[t] and               lc.depth[lc.lca(f, t)] < lc.depth[t]) {             ans = max(ans, lc.depth[t] - max(lc.depth[lc.lca(s, t)],                                              lc.depth[lc.lca(f, t)]));           }         }       } while (next_permutation(A.begin(), A.end()));       cout << ans + 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 154321;   int n, m, r, k, row[N], col[N];   long long ans = 0;   struct node {     int a, b;     long long val;     bool operator<(const node &rhs) const { return val < rhs.val; }   };   priority_queue<node> pq;   int main() {     cin >> n >> m >> r >> k;     for (int i = 1; i <= n; ++i) {       int lo = max(1, i - r + 1);       int hi = min(n - r + 1, i);       row[i] = (hi - lo + 1);     }     for (int i = 1; i <= m; ++i) {       int lo = max(1, i - r + 1);       int hi = min(m - r + 1, i);       col[i] = (hi - lo + 1);     }     sort(row + 1, row + n + 1);     sort(col + 1, col + m + 1);     for (int i = 1; i <= n; ++i) {       node cur;       cur.a = i;       cur.b = m;       cur.val = (1LL * row[i] * col[m]);       pq.push(cur);     }     for (int i = 1; i <= k; ++i) {       node cur = pq.top();       pq.pop();       ans += cur.val;       if (cur.b > 1) {         --cur.b;         cur.val = (1LL * row[cur.a] * col[cur.b]);         pq.push(cur);       }     }     cout << fixed << setprecision(12);     cout << (long double)ans / (long double)(1LL * (n - r + 1) * (m - r + 1))          <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(time(0));   const long long inf = 0x3f3f3f3f3f3f3f3fLL;   const long long N = 1e5 + 10;   const long long MOD = 1e9 + 7;   long long n, m, s;   vector<vector<long long>> g(N);   bool vis[N][2];   long long par[N][2], mark[N];   void dfs(long long u, long long f) {     vis[u][f] = 1;     for (auto i : g[u]) {       if (!vis[i][f ^ 1]) {         par[i][f ^ 1] = u;         dfs(i, f ^ 1);       }     }   }   bool cyc(long long u) {     mark[u] = 1;     for (auto i : g[u]) {       if (mark[i] == 1) return true;       if (mark[i] == 0 && cyc(i)) return true;     }     mark[u] = 2;     return false;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     long long sz, x;     for (long long i = 1; i <= n; i++) {       cin >> sz;       for (long long j = 0; j < sz; j++) {         cin >> x;         g[i].push_back(x);       }     }     cin >> s;     dfs(s, 0);     for (long long i = 1; i <= n; i++) {       if ((long long)g[i].size() == 0 && vis[i][1]) {         vector<long long> res;         long long node = i, f = 1;         res.push_back(node);         while (node != s || f != 0) {           node = par[node][f];           f ^= 1;           res.push_back(node);         }         reverse(res.begin(), res.end());         cout <<  Win  <<   n ;         for (auto i : res) cout << i <<    ;         cout <<   n ;         return 0;       }     }     if (cyc(s))       cout <<  Draw  <<   n ;     else       cout <<  Lose  <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-8;   int n, t, h, s;   char road[500001];   int H[500001], S[500001];   bool time(int k) {     vector<pair<int, int> > step;     step.push_back(make_pair(-1, -1));     for (int i = 0, j = 0; i < h; i++) {       if (k) {         k--;         step.push_back(make_pair(H[i], H[i]));       } else if (H[i] > S[j]) {         step.push_back(make_pair(H[i], H[i]));         j++;       } else {         int l = (int)(step.size()) - 1;         if (H[i] < step[l].second)           step[l].second = S[j];         else           step.push_back(make_pair(H[i], S[j]));         j++;       }     }     int tt = 0;     for (int i = 1; i < (int)(step.size()); i++) {       tt +=           (step[i].second - step[i - 1].first) + (step[i].second - step[i].first);     }     tt = min(tt, (n * 2) - 1);     return tt <= t;   }   int main() {     scanf( %d %d n , &n, &t);     scanf( %s n , road);     h = 0, s = 0;     for (int i = 0; i < n; i++) {       if (road[i] ==  H ) H[h++] = i;       if (road[i] ==  S ) S[s++] = i;     }     if (H[h - 1] >= t) {       cout << -1 << endl;       return 0;     }     int r = max(h - s, 0), e = h;     while (r < e) {       int mi = (r + e) >> 1;       (time(mi)) ? e = mi : r = mi + 1;     }     cout << e << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1000500;   int n, m;   bool vis[M];   int fa[M], deg[M], in[M];   inline int read() {     int x = 0;     char ch = getchar();     while (ch >  9  || ch <  0 ) ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x;   }   inline int find(int x) {     if (x != fa[x]) return fa[x] = find(fa[x]);     return x;   }   inline void unionn(int a, int b) {     int r1 = find(a), r2 = find(b);     if (r1 != r2) fa[r2] = r1;     return;   }   inline void constt() {     for (int i = 1; i <= n; i++) fa[i] = i, vis[i] = in[i] = deg[i] = 0;     return;   }   int main() {     while (scanf( %d%d , &n, &m) != EOF) {       constt();       vis[1] = 1;       for (int i = 1; i <= m; i++) {         int u = read(), v = read();         if (u != v) {           in[u]++, in[v]++;           vis[u] = vis[v] = 1;           unionn(u, v);         } else           vis[u] = 1;       }       for (int i = 1; i <= n; i++)         if (in[i] & 1) deg[find(i)]++;       int ans = 0, que = 0, cnt = 0;       for (int i = 1; i <= n; i++)         if (vis[i] && find(i) == i) {           if (deg[i])             ans += deg[i];           else             que++;           cnt++;         }       if (cnt == 1)         printf( %d n , ans / 2);       else         printf( %d n , ans / 2 + que);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int x = 0, y = 0, z = 0, a, b, c;     for (int i = 0; i < n; i++) {       cin >> a >> b >> c;       x += a;       y += b;       z += c;     }     if (x == 0 and y == 0 and z == 0)       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }