malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int64_t Nmax = 2e5 + 10;   const int64_t mod = 1000000007;   vector<int64_t> prime;   int64_t is_power_of_two(int64_t a) { return a && (!(a & (a - 1))); }   int64_t isperfectsquare(int64_t a) {     double b = sqrt(a);     return (b - ceil(b) == 0);   }   int64_t pow(int64_t a, int64_t b, int64_t m) {     a = a % m;     int64_t res = 1;     while (b > 0) {       if (b & 1) {         res = res * a % m;       }       a = a * a % m;       b = b / 2;     }     return res;   }   int64_t mod_add(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (((a + b) % m) + m) % m;   }   int64_t mod_mul(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (((a * b) % m) + m) % m;   }   int64_t mod_sub(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (((a - b) % m) + m) % m;   }   int64_t mod_div(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (mod_mul(a, pow(b, m - 2, m), m));   }   void sieve(int64_t n) {     bool isprime[n + 1];     memset(isprime, true, sizeof(isprime));     prime.push_back(2);     for (int64_t i = 3; i <= sqrt(n); i += 2) {       if (isprime[i]) {         for (int64_t j = i * i; j <= n; j += i) {           isprime[j] = false;         }       }     }     for (int64_t i = 3; i <= n; i += 2) {       if (isprime[i]) {         prime.push_back(i);       }     }   }   vector<pair<int64_t, int64_t>> Getprimefactors(int64_t n) {     vector<pair<int64_t, int64_t>> pr;     for (int64_t i = 2; i <= sqrt(n); i++) {       int64_t cnt = 0;       while (n % i == 0) {         cnt++;         n /= i;       }       if (cnt) pr.push_back({i, cnt});     }     if (n > 1) {       pr.push_back({n, 1});     }     return pr;   }   void solve() {     int64_t n, od = 0, ev = 0, ans = 0, ans1 = 0;     cin >> n;     vector<int64_t> a(n), even, odd;     for (int64_t i = 0; i <= n - 1; i++) {       cin >> a[i];       if (a[i] & 1) {         od++;         odd.push_back(i);       } else {         ev++;         even.push_back(i);       }     }     if (abs(od - ev) > 1) {       cout <<  -1 n ;       return;     }     if (n & 1) {       int64_t p = 0;       if (od > ev) {         for (int64_t i = 0; i < n; i += 2) {           ans += abs(odd[p] - i);           p++;         }       } else {         for (int64_t i = 0; i < n; i += 2) {           ans += abs(even[p] - i);           p++;         }       }       cout << ans <<   n ;     } else {       int64_t p = 0;       for (int64_t i = 0; i < n; i += 2) {         ans += abs(odd[p] - i);         p++;       }       p = 0;       for (int64_t i = 1; i <= n; i += 2) {         ans1 += abs(odd[p] - i);         p++;       }       cout << min(ans1, ans) <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int64_t t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const int N = 2000005;   int pref[N], suf[N];   int lB[N], lW[N];   int arr[N];   int S[N][4];   int n, k;   char s[N];   int pw[N];   int value[N];   int summary;   int mPow(int x, int n, int mod) {     if (n == 0) return 1;     if (n % 2) return 1LL * x * mPow(x, n - 1, mod) % mod;     int value = mPow(x, n / 2, mod);     return 1LL * value * value % mod;   }   int get(int hsfkasfhasfuckajsfkjsaf, int ajadslfkjasdklfj, int x) {     return S[ajadslfkjasdklfj][x] -            (hsfkasfhasfuckajsfkjsaf ? S[hsfkasfhasfuckajsfkjsaf - 1][x] : 0);   }   int main() {     scanf( %d%d n , &n, &k);     scanf( %s , s);     for (int i = 0; i < n; ++i) {       if (s[i] ==  X )         arr[i + 1] = 0;       else if (s[i] ==  B )         arr[i + 1] = 1;       else         arr[i + 1] = 2;     }     int lastB = -1, lastW = -1;     for (int i = 0; i < n; ++i) {       if (arr[i + 1] == 1)         lastB = i + 1;       else if (arr[i + 1] == 2)         lastW = i + 1;       lB[i + 1] = lastB;       lW[i + 1] = lastW;     }     int cur[3] = {0, 0, 0};     for (int i = 0; i < n; ++i) {       cur[arr[i + 1]]++;       for (int j = 0; j < 3; ++j) S[i + 1][j] = cur[j];     }     if (n < k + k) {       puts( 0 );       return 0;     }     pref[0] = 1;     for (int i = 1; i <= n; ++i) {       pref[i] = pref[i - 1];       if (arr[i] == 0) pref[i] = (pref[i] + pref[i - 1]) % mod;       if (i >= k) {         if (lW[i] <= i - k && arr[i - k] != 1)           pref[i] =               (pref[i] - (i - k - 1 >= 0 ? pref[i - k - 1] : 1) + mod) % mod;       }     }     suf[n + 1] = 1;     for (int i = n; i >= 1; --i) {       suf[i] = suf[i + 1];       if (arr[i] == 0) suf[i] = (suf[i] + suf[i + 1]) % mod;       if (i + k - 1 <= n) {         if (lB[i + k - 1] <= i - 1 && arr[i + k] != 2)           suf[i] =               (suf[i] - (i + k + 1 <= n + 1 ? suf[i + k + 1] : 1) + mod) % mod;       }     }     pw[0] = 1;     for (int i = 1; i <= n; ++i) {       pw[i] = (pw[i - 1] + pw[i - 1]) % mod;     }     for (int i = k + 1; i <= n; ++i) {       if (i + k - 1 > n) continue;       value[i] = mPow(pw[get(i, n, 0)], mod - 2, mod);       value[i] = 1LL * value[i] * suf[i + k + 1] % mod;     }     int answer = 0;     int summary = 0;     for (int i = k + 1; i <= n; ++i) {       if (i + k - 1 > n || arr[i + k] == 2) continue;       summary = (summary + value[i]) % mod;     }     for (int i = 1; i <= n; ++i) {       if (i + k - 1 > n) break;       if (lW[i + k - 1] < i && arr[i - 1] != 1) {         int ret = 1LL * ((pw[get(i + k, n, 0)] - suf[i + k] + mod) % mod) *                   (i - 2 >= 0 ? pref[i - 2] : 1) % mod;         answer = (answer + ret % mod) % mod;       }       summary = (summary - value[i + k] + mod) % mod;     }     printf( %d n , answer);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NUM = 2e5 + 5;   const int mod = 998244353;   int INF = 1e6;   pair<int, int> pinf = {INF, INF};   long long bin_pow(int n) {     if (n == 0) return 1;     if (n % 2 == 0) return bin_pow(n / 2) * bin_pow(n / 2) % mod;     return 2 * bin_pow(n - 1) % mod;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int n, m;     cin >> m >> n;     string a, b;     cin >> b;     cin >> a;     reverse(a.begin(), a.end());     reverse(b.begin(), b.end());     long long s[m];     s[0] = (b[0] -  0 );     for (int i = 1; i < m; i++) {       s[i] = s[i - 1];       if (b[i] ==  1 ) s[i] += bin_pow(i);       s[i] %= mod;     }     long long ans = 0;     for (int i = 0; i < n; i++) {       if (a[i] ==  1 ) ans += s[min(i, m - 1)];       ans %= mod;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e6 + 666;   struct palindromic_tree {     int len[MAXN], link[MAXN], cnt[MAXN];     char s[MAXN];     vector<pair<char, int>> to[MAXN];     int n, last, sz;     void clear() {       fill(to, to + MAXN, vector<pair<char, int>>());       memset(len, 0, sizeof(len));       memset(link, 0, sizeof(link));       memset(cnt, 0, sizeof(cnt));       memset(s, 0, sizeof(s));       n = last = 0;       link[0] = 1;       len[1] = -1;       s[n++] = 27;       sz = 2;     }     palindromic_tree() { clear(); }     int get_link(int v) {       while (s[n - len[v] - 2] != s[n - 1]) v = link[v];       return v;     }     int tr(int v, int c) {       for (auto it : to[v])         if (it.first == c) return it.second;       return 0;     }     int add_letter(int c) {       s[n++] = c;       int cur = get_link(last);       if (!tr(cur, c)) {         len[sz] = len[cur] + 2;         link[sz] = tr(get_link(link[cur]), c);         to[cur].push_back({c, sz++});       }       last = tr(cur, c);       return cnt[last] = cnt[link[last]] + 1;     }   };   struct palindromic_tree me;   const int MOD = 51123987;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     string s;     cin >> s;     int start[n], finish[n];     for (int i = 0; i < n; i++) finish[i] = me.add_letter(s[i] -  a );     me.clear();     for (int i = 0; i < n; i++)       start[n - i - 1] = me.add_letter(s[n - i - 1] -  a );     int64_t ans = accumulate(start, start + n, 0ll) % MOD;     ans = ans * (ans - 1) / 2 % MOD;     int64_t sum = 0;     for (int i = 1; i < n; i++) {       sum = (sum + finish[i - 1]) % MOD;       ans = (ans - sum * start[i]) % MOD;       if (ans < 0) ans += MOD;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MxN = (int)15e4 + 9;   int n, Q;   int parent[MxN + 9];   vector<int> adj[MxN + 9];   int height[MxN + 9];   char label[MxN + 9];   const string YES =  Shi ;   const string NO =  Fou ;   int parent2[MxN + 9];   vector<int> adj2[MxN + 9];   array<int, 26> label2[MxN + 9];   array<int, 26> dp[MxN + 9];   int dpSum[MxN + 9];   bool valid[MxN + 9];   void noAll() {     for (int i = 0; i < Q; ++i) cout << NO <<   n ;     exit(0);   }   bool spe(const int u) { return u == 1 || 0 == (adj[u].size() & 1); }   inline void update(const int u, const int j) {     assert(0 <= j && j < 26);     assert(spe(u));     valid[u] = true;     if (adj[u].empty()) return;     dpSum[u] -= dp[u][j];     dp[u][j] = 0;     for (const int v : adj2[u]) {       valid[u] &= valid[v];       dp[u][j] = max(dp[u][j], dp[v][j] + label2[v][j]);     }     dpSum[u] += dp[u][j];     valid[u] &= dpSum[u] <= height[u];   }   inline void chainUpdate(int u, const int j) {     do {       update(u, j);       u = parent2[u];     } while (u);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr), cout.tie(nullptr);     cin >> n >> Q;     for (int i = 2; i <= n; ++i) {       cin >> parent[i] >> label[i];       adj[parent[i]].push_back(i);       assert(adj[parent[i]].size() <= 2);     }     for (int i = n; i >= 1; --i) {       if (adj[i].empty()) continue;       const int u = adj[i][0];       if (adj[i].size() == 2) {         const int v = adj[i][1];         if (height[u] != height[v]) noAll();       }       height[i] = height[u] + 1;     }     for (int i = 2; i <= n; ++i) {       if (spe(parent[i])) {         parent2[i] = parent[i];       } else {         parent2[i] = parent2[parent[i]];         label2[i] = label2[parent[i]];       }       if (label[i] !=  ? ) label2[i][label[i] -  a ]++;     }     for (int i = n; i >= 1; --i) {       for (int x : adj[i]) {         const int y = spe(x) ? x : adj2[x][0];         adj2[i].push_back(y);       }     }     for (int i = n; i >= 1; --i)       if (spe(i))         for (int j = 0; j < 26; ++j) update(i, j);     for (int rep = 0;; ++rep) {       ostream &out = rep == 0 ? cerr : cout;       if (!valid[1])         out << NO <<   n ;       else {         long long ans = 0;         for (int j = 0; j < 26; ++j)           ans += (j + 1LL) * (dp[1][j] + (height[1] - dpSum[1]));         out << YES <<     << ans <<   n ;       }       if (rep == Q) break;       int u;       char ch;       cin >> u >> ch;       const int v = spe(u) ? u : adj2[u][0];       if (label[u] !=  ? ) {         const int j = label[u] -  a ;         label2[v][j]--;         chainUpdate(v, j);       }       if (ch !=  ? ) {         const int j = ch -  a ;         label2[v][j]++;         chainUpdate(v, j);       }       label[u] = ch;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }   pair<int, int> rev[1000005];   int h[1000005];   int d[1000005];   vector<int> g[1000005];   int N, K;   void pre_dfs(int u, int p = -1) {     rev[u] = pair<int, int>(1000005, 0);     for (int v : g[u]) {       if (v == p) continue;       h[v] = h[u] + 1;       pre_dfs(v, u);       if (rev[v].first <= h[u]) {         rev[u].first = min(rev[u].first, rev[v].first);         rev[u].second += rev[v].second;       }     }     if (p >= 0 && g[u].size() == 1) {       rev[u].first = h[u] - K;       rev[u].second = 1;     }   }   void sol(int u, int p = -1) {     d[u] = p >= 0 && g[u].size() == 1;     for (int v : g[u]) {       if (v == p) continue;       sol(v, u);       int temp = rev[u].second;       if (rev[v].first <= h[u]) temp -= rev[v].second;       d[u] = max(d[u], temp + d[v]);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> N >> K;     for (int i = 1; i <= N - 1; i++) {       int u;       cin >> u;       u--;       g[i].push_back(u);       g[u].push_back(i);     }     h[0] = 0;     pre_dfs(0);     sol(0);     cout << d[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000 * 100 + 10;   int par[N], n, m, c;   unordered_map<int, int> adj[N];   unordered_set<int> adj1[N];   int getPar(int root) {     return par[root] == par[par[root]] ? par[root]                                        : par[root] = getPar(par[root]);   }   void Union(int v, int u) {     v = getPar(v), u = getPar(u);     if (v == u) return;     if (adj1[v].size() < adj1[u].size()) swap(v, u);     par[u] = par[v];     for (auto it : adj1[u]) adj1[v].insert(it);   }   void add(int v, int u, int c) {     if (adj[u][c]) Union(v, adj[u][c]);     if (adj[v][c]) Union(u, adj[v][c]);     int pv = getPar(v), pu = getPar(u);     adj[v][c] = pu, adj[u][c] = pv;     adj1[pv].insert(u), adj1[pu].insert(v);   }   bool check(int v, int u) {     int pv = getPar(v), pu = getPar(u);     return pv == pu || adj1[pv].count(u);   }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int Q;     cin >> n >> m >> c >> Q;     for (int i = 1; i <= n; i++) par[i] = i;     for (int i = 1, v, u, z; i <= m; i++) {       cin >> v >> u >> z;       add(v, u, z);     }     while (Q--) {       char c;       int x, y, z;       cin >> c >> x >> y;       if (c ==  ? )         cout << (check(x, y) ?  Yes  :  No ) <<   n ;       else {         cin >> z;         add(x, y, z);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   using V = vector<T>;   using ll = long long;   using dbl = double;   using ii = pair<int, int>;   const ll MOD = 998244353;   ll z1[2000005], z2[2000005], dp[1000005], psum[1000005];   void solveZ(string s, ll z[]) {     z[0] = 0;     ll L = 0, R = 0, n = s.size();     for (ll i = 1; i < n; i++) {       if (i > R) {         L = R = i;         while (R < n && s[R - L] == s[R]) R++;         z[i] = R - L;         R--;       } else {         ll k = i - L;         if (z[k] < R - i + 1)           z[i] = z[k];         else {           L = i;           while (R < n && s[R - L] == s[R]) R++;           z[i] = R - L;           R--;         }       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     string a, l, r;     cin >> a >> l >> r;     string la = l +  #  + a;     string ra = r +  #  + a;     solveZ(la, z1);     solveZ(ra, z2);     ll lsize = l.size();     ll rsize = r.size();     ll ls = 0, rs = 0;     for (int i = 0; i < (int)a.size(); i++) {       if (i - ls + 1 < lsize) {         dp[i] = 0;         continue;       }       while (i - ls + 1 != lsize) ls++;       while (i - rs + 1 > rsize) rs++;       if (i - rs + 1 == rsize) {         ll matched = z2[rs + rsize + 1];         if (matched != rsize && a[rs + matched] > r[matched]) rs++;       }       if (i - ls + 1 == lsize) {         ll matched = z1[ls + lsize + 1];         if (matched != lsize && a[ls + matched] < l[matched]) {           if (ls == 0)             continue;           else             ls--;         }       }       if (rs <= ls) {         if (ls - 1 < 0)           dp[i] = 1;         else if (rs - 1 < 0)           dp[i] = (dp[i] + psum[ls - 1] + 1) % MOD;         else           dp[i] = (psum[ls - 1] - (rs - 2 < 0 ? 0 : psum[rs - 2]) + MOD) % MOD;         if (a[i] ==  0  && ls == i) dp[i] = (dp[i] + dp[i - 1]) % MOD;         if (i != a.size() - 1 && a[i + 1] !=  0 )           psum[i] = (psum[i] + (i == 0 ? 0 : psum[i - 1]) + dp[i]) % MOD;         else if (i != 0)           psum[i] = psum[i - 1];         else           psum[i] = 0;       }     }     cout << dp[a.size() - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string st;   int dp[10005][4];   int n;   set<string> st_set;   int rec(int pos, int len) {     if (pos == 4 || pos == 5) {       return 1;     }     if (pos < 4) return 0;     int &ret = dp[pos][len];     if (ret != -1) return ret;     ret = 0;     if (len == 0) {       if (pos >= 7) {         ret |= rec(pos - 3, 3);         st_set.insert(st.substr(pos - 2, 3));       }       if (pos >= 6) {         ret |= rec(pos - 2, 2);         st_set.insert(st.substr(pos - 1, 2));       }     } else if (len == 2) {       if (pos >= 6 && !(st[pos] == st[pos + 2] && st[pos + 1] == st[pos - 1])) {         ret |= rec(pos - 2, 2);         st_set.insert(st.substr(pos - 1, 2));       }       if (pos >= 7) {         ret |= rec(pos - 3, 3);         st_set.insert(st.substr(pos - 2, 3));       }     } else {       if (pos >= 7 && !(st[pos] == st[pos + 3] && st[pos - 1] == st[pos + 2] &&                         st[pos - 2] == st[pos + 1])) {         ret |= rec(pos - 3, 3);         st_set.insert(st.substr(pos - 2, 3));       }       if (pos >= 6) {         ret |= rec(pos - 2, 2);         st_set.insert(st.substr(pos - 1, 2));       }     }     return ret;   }   int main() {     cin >> st;     n = st.length();     memset(dp, -1, sizeof dp);     rec(n - 1, 0);     cout << st_set.size() << endl;     for (string x : st_set) cout << x << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace io {   const int SIZE = (1 << 21) + 1;   char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,                                          qu[55];   int f, qr;   inline void flush() {     fwrite(obuf, 1, oS - obuf, stdout);     oS = obuf;   }   inline void putc(char x) {     *oS++ = x;     if (oS == oT) flush();   }   template <class I>   inline void read(I &x) {     for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                                 (iS == iT ? EOF : *iS++))                               : *iS++);          c <  0  || c >  9 ;          c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                          (iS == iT ? EOF : *iS++))                        : *iS++))       if (c ==  - ) f = -1;     for (x = 0; c <=  9  && c >=  0 ;          c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                          (iS == iT ? EOF : *iS++))                        : *iS++))       x = x * 10 + (c & 15);     x *= f;   }   template <class I>   inline void print(I &x) {     if (!x) putc( 0 );     if (x < 0) putc( - ), x = -x;     while (x) qu[++qr] = x % 10 +  0 , x /= 10;     while (qr) putc(qu[qr--]);   }   struct Flusher_ {     ~Flusher_() { flush(); }   } io_flusher_;   }  // namespace io   using io ::print;   using io ::putc;   using io ::read;   struct node {     int nxt;     long long cnt;   } s[100005];   int a[15][100005];   int main() {     int i, j, k;     int n, m;     read(n), read(m);     for (i = 1; i <= m; i++)       for (j = 1; j <= n; j++) read(a[i][j]);     for (i = 1; i < n; i++) {       s[a[1][i]].nxt = a[1][i + 1];       s[a[1][i]].cnt = 1;     }     for (int i = (int)2; i <= (int)m; i++)       for (int j = (int)1; j <= (int)n - 1; j++)         if (s[a[i][j]].nxt == a[i][j + 1]) s[a[i][j]].cnt++;     long long sum = 1, ans = 0;     for (int i = (int)1; i <= (int)n - 1; i++) {       if (s[a[1][i]].cnt != m)         ans += sum * (sum + 1) / 2, sum = 1;       else         sum++;     }     if (sum > 0) ans += sum * (sum + 1) / 2;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool cmp1(vector<int> a, vector<int> b) {     int q = a[4] + a[1] + a[2] + a[3] - a[0];     int p = b[4] + b[1] + b[2] + b[3] - b[0];     return q < p;   }   bool cmp2(vector<int> a, vector<int> b) {     int q = a[0] + a[4] + a[2] + a[3] - a[1];     int p = b[0] + b[4] + b[2] + b[3] - b[1];     return q < p;   }   bool cmp3(vector<int> a, vector<int> b) {     int q = a[0] + a[1] + a[4] + a[3] - a[2];     int p = b[0] + b[1] + b[4] + b[3] - b[2];     return q < p;   }   bool cmp4(vector<int> a, vector<int> b) {     int q = a[0] + a[1] + a[2] + a[4] - a[3];     int p = b[0] + b[1] + b[2] + b[4] - b[3];     return q < p;   }   bool cmp5(vector<int> a, vector<int> b) {     int q = a[0] + a[1] + a[2] + a[3] - a[4];     int p = b[0] + b[1] + b[2] + b[3] - b[4];     return q < p;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int T = 1;     cin >> T;     while (T--) {       int n;       cin >> n;       vector<vector<int>> fr(n, vector<int>(5, 0));       string s[n];       for (int i = 0; i < n; i++) {         cin >> s[i];         for (int j = 0; j < s[i].size(); j++) {           if (s[i][j] ==  a ) fr[i][0]++;           if (s[i][j] ==  b ) fr[i][1]++;           if (s[i][j] ==  c ) fr[i][2]++;           if (s[i][j] ==  d ) fr[i][3]++;           if (s[i][j] ==  e ) fr[i][4]++;         }       }       int ans = 0, cw = 0;       sort(fr.begin(), fr.end(), cmp1);       int cs = 0, co = 0;       for (int i = 0; i < n; i++) {         cs = cs + fr[i][0];         co = co + fr[i][1] + fr[i][2] + fr[i][3] + fr[i][4];         if (cs > co) cw++;       }       ans = max(ans, cw);       cw = 0;       cs = 0, co = 0;       sort(fr.begin(), fr.end(), cmp2);       for (int i = 0; i < n; i++) {         cs = cs + fr[i][1];         co = co + fr[i][0] + fr[i][2] + fr[i][3] + fr[i][4];         if (cs > co) cw++;       }       ans = max(ans, cw);       cw = 0;       cs = 0, co = 0;       sort(fr.begin(), fr.end(), cmp3);       for (int i = 0; i < n; i++) {         cs = cs + fr[i][2];         co = co + fr[i][1] + fr[i][0] + fr[i][3] + fr[i][4];         if (cs > co) cw++;       }       ans = max(ans, cw);       cw = 0;       cs = 0, co = 0;       sort(fr.begin(), fr.end(), cmp4);       for (int i = 0; i < n; i++) {         cs = cs + fr[i][3];         co = co + fr[i][1] + fr[i][2] + fr[i][0] + fr[i][4];         if (cs > co) cw++;       }       ans = max(ans, cw);       cw = 0;       cs = 0, co = 0;       sort(fr.begin(), fr.end(), cmp5);       for (int i = 0; i < n; i++) {         cs = cs + fr[i][4];         co = co + fr[i][1] + fr[i][2] + fr[i][3] + fr[i][0];         if (cs > co) cw++;       }       ans = max(ans, cw);       cout << ans <<   n ;     }     return 0;   }