malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int x, y, z, inf = 1e9, f[210][210], n, m, Max[210];   pair<pair<int, int>, int> p[40010];   pair<int, int> q[210];   void read(int &x) {     char ch = getchar();     int mark = 1;     for (; ch !=  -  && (ch <  0  || ch >  9 ); ch = getchar())       ;     if (ch ==  - ) mark = -1, ch = getchar();     for (x = 0; ch >=  0  && ch <=  9 ; ch = getchar()) x = x * 10 + ch - 48;     x *= mark;   }   int main() {     read(n);     read(m);     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++) f[i][j] = f[j][i] = inf;     for (int i = 1; i <= m; i++) {       read(x);       read(y);       read(z);       f[x][y] = f[y][x] = z;       p[i] = make_pair(make_pair(x, y), z);     }     for (int k = 1; k <= n; k++)       for (int i = 1; i <= n; i++)         if (i != k)           for (int j = 1; j <= n; j++)             if (j != i && j != k) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);     double Min = 1e9;     for (int i = 1; i <= n; i++) {       double Max = 0;       for (int j = 1; j <= n; j++) Max = max(Max, (double)f[i][j]);       Min = min(Min, Max);     }     for (int i = 1; i <= m; i++) {       int x = p[i].first.first, y = p[i].first.second;       for (int j = 1; j <= n; j++) q[j] = make_pair(f[x][j], f[y][j]);       sort(q + 1, q + n + 1);       Max[n + 1] = 0;       for (int j = n; j; j--) Max[j] = max(Max[j + 1], q[j].second);       for (int j = 1; j <= n; j++) {         int l = q[j].first, r = Max[j + 1];         if (l > r) swap(l, r);         if (l + p[i].second >= r) Min = min(Min, (l + p[i].second + r) / 2.0);       }     }     printf( %.1lf n , Min);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) cin >> a[i];     multiset<int> s;     for (int v : a) s.insert(v);     int ans = 0;     for (int i = 0; i < n; ++i) {       auto it = s.upper_bound(a[i]);       if (it != s.end()) {         ++ans;         s.erase(it);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100010];   int main() {     long long n, k;     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     long long x = a[0], ans = 0;     for (int i = 1; i < n; i++) {       if ((a[i] - x) % k != 0) {         cout << -1 << endl;         return 0;       }       ans += (a[i] - x) / k;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve();   int main() {     ios::sync_with_stdio(0);     solve();     return 0;   }   int a[1000001];   void solve() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; ++i) {       int v;       cin >> v;       a[v]++;     }     for (int i = 0; i < m; ++i) {       int v;       cin >> v;       a[v]--;     }     int ans = 0;     int j = 0;     for (int i = 1; i <= 1000000; ++i) {       if (a[i] > 0) {         j = max(j, i);         bool f = 0;         while (j <= 1000000 && !f) {           if (a[j] < 0) {             a[j]++;             f = 1;           } else             j++;         }         ans += !f;       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   char s[100000];   int col[100000], dp[21][1 << 20];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) {       scanf(  %s , s);       for (int j = 0; j < m; j++) col[j] |= (s[j] -  0 ) << i;     }     for (int i = 0; i < m; i++) dp[0][col[i]]++;     for (int k = 1; k <= n; k++)       for (int mask = 0; mask < (1 << n); mask++) {         int sum = k > 1 ? (k - 2 - n) * dp[k - 2][mask] : 0;         for (int p = 0; p < n; p++) sum += dp[k - 1][mask ^ (1 << p)];         dp[k][mask] = sum / k;       }     int ans = n * m;     for (int mask = 0; mask < (1 << n); mask++) {       int cnt = 0;       for (int k = 0; k <= n; k++) cnt += min(k, n - k) * dp[k][mask];       ans = min(ans, cnt);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e11;   const int M = 1e5 + 5;   vector<pair<long long, int> > adj[M];   vector<int> ans;   long long d[M], vis[M], pre[M];   int n, m;   void Dijkstra() {     for (int i = 1; i <= n; ++i) d[i] = INF;     d[1] = 0;     priority_queue<pair<long long, int> > q;     q.push(make_pair(d[1], 1));     while (!q.empty()) {       int u = q.top().second;       q.pop();       if (vis[u]) continue;       vis[u] = 1;       for (int i = 0; i < adj[u].size(); ++i) {         int v = adj[u][i].second;         long long dist = adj[u][i].first + d[u];         if (d[v] > dist) {           d[v] = dist;           pre[v] = u;           q.push(make_pair(-d[v], v));         }       }     }   }   int main() {     int u, v, w;     cin >> n >> m;     while (m--) {       cin >> u >> v >> w;       adj[u].push_back(make_pair(w, v));       adj[v].push_back(make_pair(w, u));     }     Dijkstra();     if (d[n] == INF)       cout <<  -1  << endl;     else {       for (int i = n; pre[i]; i = pre[i]) ans.push_back(pre[i]);       for (int i = ans.size() - 1; i >= 0; --i) cout << ans[i] <<    ;       cout << n <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, x;     cin >> n;     vector<long long> a;     for (int i = 0; i < n; i++) {       cin >> x;       a.push_back(x);     }     for (int i = 0; i < n - 1; i++) {       cout << a[i] + a[i + 1] <<    ;     }     cout << a[n - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &x) {     x = 0;     char c = getchar();     int f = 0;     for (; !isdigit(c); c = getchar()) f |= c ==  - ;     for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^  0 );     if (f) x = -x;   }   template <typename T>   void write(T x, char ed =   n ) {     static short st[30];     short tp = 0;     if (x < 0) putchar( - ), x = -x;     do st[++tp] = x % 10, x /= 10;     while (x);     while (tp) putchar(st[tp--] |  0 );     putchar(ed);   }   const int N = 505000;   struct node {     long long d;     int id;     bool operator<(const node &i) const { return id < i.id; }     node(long long D = 0, int I = 0) : d(D), id(I) {}   };   vector<vector<node> > vec;   vector<node> ety;   int ne[N << 1], to[N << 1], h[N], f[N], rt, tot, n;   inline void add(int x, int y) { ne[++tot] = h[x], to[h[x] = tot] = y; }   int dep[N], L[N], R[N], cnt;   int son[N], mxd[N], rev[N];   long long ans[N];   void dfs1(int x, int fa) {     mxd[x] = dep[x] = dep[fa] + 1, L[x] = ++cnt, rev[cnt] = x;     if (dep[x] >= vec.size()) vec.push_back(ety);     vec[dep[x]].push_back(node(0, L[x]));     for (int i = h[x]; i; i = ne[i]) {       int y = to[i];       dfs1(to[i], x);       if (mxd[y] >= mxd[x]) son[x] = y, mxd[x] = mxd[y];     }     R[x] = cnt;   }   inline bool inc(int x, int l, int r) { return R[x] >= r && L[x] <= l; }   long long tab[N], t[N];   void dfs2(int x) {     int ct = 0, nw = dep[x];     long long res = 0;     t[dep[x]]++;     auto pl = lower_bound(vec[dep[x]].begin(), vec[dep[x]].end(), node(0, L[x])),          pr = pl;     ++pr;     while ( jzpakioi , true) {       res += 1ll * (ct += t[nw]) * (pr - pl) + tab[nw];       tab[nw] = t[nw] = 0, pl->d += res;       if (pr != vec[nw].end()) pr->d -= res;       if (++nw > mxd[x]) break;       pl = lower_bound(vec[nw].begin(), vec[nw].end(), node(0, L[x]));       pr = upper_bound(vec[nw].begin(), vec[nw].end(), node(0, R[x]));       if (inc(son[x], pl->id, (pr - 1)->id)) {         t[nw] += ct, tab[nw] += res;         break;       }     }     if (son[x]) dfs2(son[x]);     for (int i = h[x]; i; i = ne[i])       if (to[i] != son[x]) dfs2(to[i]);   }   int main() {     read(n), vec.push_back(ety);     for (int i = 1; i <= n; i++) read(f[i]), f[i] ? add(f[i], i), 0 : rt = i;     dfs1(rt, 0), dfs2(rt);     for (int i = 1; i <= mxd[rt]; i++) {       long long res = 0;       for (auto t : vec[i]) res += t.d, ans[rev[t.id]] += res;     }     for (int i = 1; i <= n; i++) write(ans[i] - dep[i],    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1};   int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};   vector<int> adj[300010], val(300010, 1), vis(300010, 0), dis1(300010, 0),       dis2(300010, 0);   int myrandom(int i) { return std::rand() % i; }   int dp[5010];   int n;   set<pair<int, int>> st;   int maxi = 0;   int poss[5010][5010];   void dfs(int a) {     vis[a] = 1;     int cnt = 0;     vector<int> v;     for (auto i : adj[a]) {       if (vis[i] == 0) {         dfs(i);         if (dp[i] > 0) {           v.push_back(dp[i]);         }         cnt = cnt + dp[i];       }     }     int cnt1 = n - cnt - 1;     if (cnt1 > 0) {       v.push_back(cnt1);     }     int n = (int)v.size();     int sum = accumulate((v).begin(), (v).end(), 0);     int res[sum + 1];     memset(res, 0, sizeof(res));     res[0] = 1;     for (int i = 0; i < n; i++) {       for (int j = sum; j >= 0; j--) {         if (j - v[i] >= 0) {           res[j] = res[j] | res[j - v[i]];         }       }     }     maxi = max(maxi, sum);     for (int i = 1; i < sum; i++) {       poss[i][sum - i] = poss[i][sum - i] | res[i];     }     dp[a] = 1 + cnt;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     memset(poss, 0, sizeof(poss));     dfs(1);     vector<pair<int, int>> ans;     for (int i = 1; i <= 5000; i++) {       for (int j = 1; j <= 5000; j++) {         if (i + j == maxi && poss[i][j] == 1) {           ans.push_back({i, j});         }       }     }     cout << (int)ans.size() <<   n ;     for (auto i : ans) {       cout << i.first <<     << i.second <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   struct st {     int t, p, g;     char s[30];   } a[100];   int x[3];   int y[6];   int main() {     int n, m, i, j, k;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d%s , &m, a[i].s);       for (j = 0; j < m; j++) {         scanf( %d-%d-%d , &x[0], &x[1], &x[2]);         for (k = 0; k < 3; k++) {           y[k * 2] = x[k] / 10;           y[k * 2 + 1] = x[k] % 10;         }         for (k = 0; k < 5; k++)           if (y[k] != y[k + 1]) break;         if (k == 5) {           a[i].t++;           continue;         }         for (k = 0; k < 5; k++)           if (y[k] <= y[k + 1]) break;         if (k == 5)           a[i].p++;         else           a[i].g++;       }     }     vector<int> ans;     int ma = a[0].t;     ans.push_back(0);     for (i = 1; i < n; i++) {       if (a[i].t > ma) {         ans.clear();         ans.push_back(i);         ma = a[i].t;       } else if (a[i].t == ma) {         ans.push_back(i);       }     }     printf( If you want to call a taxi, you should call:  );     printf( %s , a[ans[0]].s);     for (i = 1; i < ans.size(); i++) printf( , %s , a[ans[i]].s);     printf( . n );     ans.clear();     ma = a[0].p;     ans.push_back(0);     for (i = 1; i < n; i++) {       if (a[i].p > ma) {         ans.clear();         ans.push_back(i);         ma = a[i].p;       } else if (a[i].p == ma) {         ans.push_back(i);       }     }     printf( If you want to order a pizza, you should call:  );     printf( %s , a[ans[0]].s);     for (i = 1; i < ans.size(); i++) printf( , %s , a[ans[i]].s);     printf( . n );     ans.clear();     ma = a[0].g;     ans.push_back(0);     for (i = 1; i < n; i++) {       if (a[i].g > ma) {         ans.clear();         ans.push_back(i);         ma = a[i].g;       } else if (a[i].g == ma) {         ans.push_back(i);       }     }     printf(          If you want to go to a cafe with a wonderful girl, you should call:  );     printf( %s , a[ans[0]].s);     for (i = 1; i < ans.size(); i++) printf( , %s , a[ans[i]].s);     printf( . n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long n, x, sum(0), cnt(0), prev(INT_MAX);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x;       if (i && x == prev)         cnt++;       else         cnt = 1;       prev = x;       sum += cnt;     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<pair<int, int>, bool> mp;   bool check(int x, int y, int z) {     if (y < x) swap(x, y);     if (z < y) swap(z, y);     if (y < x) swap(x, y);     if (x + y > z && z > y && mp.count({x, y}) == 0) {       mp[{x, y}] = 1;       return 1;     } else       return 0;   }   int main() {     int n;     cin >> n;     long long ans = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         if ((i ^ j) <= n && check(i, j, (i ^ j))) ans++;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     int n;     while (t--) {       int n;       string s;       cin >> n;       cin >> s;       int flag = 1, start = 0, end = n - 1;       while (start <= end) {         char ssp = s[start] + 1;         char sep = s[end] + 1;         char sem = s[end] - 1;         char ssm = s[start] - 1;         if ((ssp == sep) || (ssp == sem) || (ssm == sep) || (ssm == sem))           flag = 1;         else {           flag = 0;           break;         }         start++;         end--;       }       if (flag == 0)         cout <<  NO  << endl;       else         cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int h, m, ti;     scanf( %d:%d , &h, &m);     scanf( %d , &ti);     int realh = ti / 60, realmin = ti % 60;     while (realh--) {       if (h == 23)         h = 0;       else         h++;     }     while (realmin--) {       if (m == 59) {         m = 0;         if (h == 23)           h = 0;         else           h++;       } else         m++;     }     if (h < 10) printf( 0 );     printf( %d: , h);     if (m < 10) printf( 0 );     printf( %d , m);     return 0;   }
#include <bits/stdc++.h>   using i64 = long long;   template <typename _Tp>   inline void chkMax(_Tp &x, const _Tp &y) {     (x < y) and (x = y);   }   namespace IOManager {   constexpr int FILESZ = 131072;   char buf[FILESZ];   const char *ibuf = buf, *tbuf = buf;   struct IOManager {     inline char gc() {       return (ibuf == tbuf) and                      (tbuf = (ibuf = buf) + fread(buf, 1, FILESZ, stdin),                       ibuf == tbuf)                  ? EOF                  : *ibuf++;     }     template <typename _Tp>     inline operator _Tp() {       _Tp s = 0u;       char c = gc();       for (; c < 48; c = gc())         ;       for (; c > 47; c = gc()) s = (_Tp)(s * 10u + c - 48u);       return s;     }   };   }  // namespace IOManager   IOManager::IOManager io;   int main() {     static std::map<i64, i64> f;     const int n = io;     for (int i = 1; i <= n; ++i) {       const i64 a = io;       if (i == 1) f[a - 1] = 0;       for (auto it = f.rbegin(); it not_eq f.rend() and it->first >= a; ++it) {         const i64 v = it->first;         chkMax(f[v % a], it->second + (v - v % a) * (i - 1ll));         chkMax(f[a - 1], it->second + ((v - a + 1ll) / a * a) * (i - 1ll));       }       f.erase(f.lower_bound(a), f.end());     }     i64 ans = 0;     for (const auto it : f) chkMax(ans, it.second + it.first * n);     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200005];   long long k1[200005];   long long k2[200005];   string ss =  first ;   string sp =  second ;   int main() {     int n;     cin >> n;     int r1 = 0;     int r2 = 0;     long long s1 = 0;     long long s2 = 0;     int l1 = 0;     int l2 = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] > 0) {         { k1[l1++] = a[i]; }         s1 += a[i];         r1 = 1;       } else {         { k2[l2++] = -a[i]; }         s2 += -a[i];         r1 = 0;       }     }     if (s1 > s2) {       cout << ss << endl;       return 0;     }     if (s1 < s2) {       cout << sp << endl;       return 0;     }     if (s1 == s2) {       for (int i = 0; i < min(l1, l2); i++) {         if (k1[i] > k2[i]) {           cout << ss << endl;           return 0;         }         if (k2[i] > k1[i]) {           cout << sp << endl;           return 0;         }       }       if (!r1) {         cout << sp << endl;         return 0;       } else {         cout << ss << endl;         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int input() {     int res = 0, m = 1;     char c =    ;     while (c <  0  && c !=  - ) c = getchar();     if (c ==  - ) m = -1, c = getchar();     while (c >=  0 ) res = res * 10 + (c -  0 ), c = getchar();     return res * m;   }   const int N = 501;   int n, k, lft[N], l_siz, fl[N], rht[N], r_siz, fr[N];   void shift() {     while (r_siz) lft[l_siz] = rht[--r_siz], ++l_siz;     if (l_siz) fl[0] = lft[0];     for (int i = 1; i < l_siz; ++i) fl[i] = max(fl[i - 1], lft[i]);   }   void push(int x) {     int prev = (r_siz ? fr[r_siz - 1] : 0);     rht[r_siz] = x, fr[r_siz] = max(prev, x), ++r_siz;   }   void pop() {     if (!l_siz) shift();     --l_siz;   }   int get() {     int res = 0;     if (l_siz) res = fl[l_siz - 1];     if (r_siz) res = max(res, fr[r_siz - 1]);     return res;   }   int a[N][N], mx[N][N], ans = 2e9;   int main() {     int n = input(), m = input(), k = input();     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) a[i][j] = 2e9;     for (int q = input(); q; --q) {       int i = input() - 1, j = input() - 1, t = input();       a[i][j] = t;     }     for (int j = 0; j < m; ++j) {       for (int i = 0; i < k; ++i) push(a[i][j]);       mx[0][j] = get();       for (int i = 0; i < n - k; ++i) {         pop(), push(a[i + k][j]);         mx[i + 1][j] = get();       }       while (l_siz + r_siz) pop();     }     for (int i = 0; i <= n - k; ++i) {       for (int j = 0; j < k; ++j) push(mx[i][j]);       ans = min(ans, get());       for (int j = 0; j < m - k; ++j) {         pop(), push(mx[i][j + k]);         ans = min(ans, get());       }       while (l_siz + r_siz) pop();     }     cout << (ans == 2e9 ? -1 : ans);   }
#include <bits/stdc++.h>   int main() {     int t, a, b, c, d, k, i, pen, pencil;     scanf( %d , &t);     for (i = 0; i < t; i++) {       scanf( %d %d %d %d %d , &a, &b, &c, &d, &k);       if (a % c != 0) {         pen = (a / c) + 1;       }       if (a % c == 0) {         pen = (a / c);       }       if (b % d != 0) {         pencil = (b / d) + 1;       }       if (b % d == 0) {         pencil = (b / d);       }       if (pen + pencil <= k) {         printf( %d %d n , pen, pencil);       } else {         printf( -1 n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int countInversions(long long int a[], long long int temp[],                                 long long int l, long long int r) {     if (l >= r) {       return 0;     }     long long int count1 = countInversions(a, temp, l, (l + r) / 2);     long long int count2 = countInversions(a, temp, (l + r) / 2 + 1, r);     long long int mergeCount = 0;     long long int indexLeft = l;     long long int endLeft = (l + r) / 2 + 1;     long long int indexRight = (l + r) / 2 + 1;     while (indexRight <= r && indexLeft < endLeft) {       while (indexLeft < endLeft && a[indexLeft] <= a[indexRight]) {         indexLeft++;       }       mergeCount += endLeft - indexLeft;       indexRight++;     }     indexLeft = l, indexRight = (l + r) / 2 + 1;     long long int idx = l;     while (indexRight <= r && indexLeft < endLeft) {       if (a[indexLeft] <= a[indexRight]) {         temp[idx++] = a[indexLeft];         indexLeft++;       } else {         temp[idx++] = a[indexRight];         indexRight++;       }     }     while (indexRight <= r) {       temp[idx++] = a[indexRight];       indexRight++;     }     while (indexLeft < endLeft) {       temp[idx++] = a[indexLeft];       indexLeft++;     }     for (long long int i = l; i <= r; i++) {       a[i] = temp[i];     }     return mergeCount + count1 + count2;   }   int main() {     ios ::sync_with_stdio(false);     cin.tie(0);     map<char, deque<long long int>> positionsOfLetters;     long long int i, n, count = 0;     cin >> n;     char s[n];     for (i = 0; i < n; i++) {       cin >> s[i];       positionsOfLetters[s[i]].push_back(i);     }     reverse(s, s + n);     long long int permuation[n];     for (i = 0; i < n; i++) {       permuation[i] = positionsOfLetters[s[i]].front();       positionsOfLetters[s[i]].pop_front();     }     long long int temp[n + 1];     cout << countInversions(permuation, temp, 0, n - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t;     cin >> s;     bool ok = false;     for (int i = 0; i < s.size(); i++) {       if (s.size() - i < 26) break;       int j = i;       vector<int> f(26);       int qq = 0;       while (j < s.size() && j - i + 1 <= 26) {         if (s[j] !=  ? )           f[s[j] -  A ]++;         else           qq++;         if (j - i + 1 == 26) break;         j++;       }       int have = 0;       queue<char> need;       for (int k = 0; k < 26; k++) {         if (f[k] > 0)           have++;         else           need.push(char(k +  A ));       }       int want = 26 - have;       if (want == qq) {         ok = true;         for (int k = i; k <= j; k++)           if (s[k] ==  ? ) {             s[k] = need.front();             need.pop();           }       }     }     if (!ok) {       puts( -1 );     } else {       for (auto c : s) {         if (c ==  ? )           cout <<  A  <<   ;         else           cout << c <<   ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[400005];   int q, x;   int main() {     int aux, cnt = 0, maxim = 0;     cin >> q >> x;     for (int i = 1; i <= q; i++) {       cin >> aux;       a[aux % x]++;       while (a[cnt] > maxim) {         cnt++;         if (cnt == x) {           cnt = 0;           maxim++;         }       }       cout << maxim * x + cnt <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[4] = {-1, 0, 0, 1};   int dy[4] = {0, -1, 1, 0};   bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {     if (a.first == b.first) return a.second < b.second;     return (a.first < b.first);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long x, y, t, c;     cin >> x >> y;     if (y == 0) {       cout <<  No  << endl;       return 0;     }     if (y == 1) {       if (x > 0) {         cout <<  No  << endl;         return 0;       }     }     t = y - 1;     t = x - t;     if (t % 2 == 0 && t >= 0) {       cout <<  Yes  << endl;       return 0;     }     cout <<  No  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[6], b[6];   int getMinWin(int idx) {     if (idx == 3) return a[0] + a[1] + a[2];     int ret = INT_MAX;     int bIdx = idx;     int bIdxPrev = (idx - 1 + 3) % 3;     int minIdxbIdx = min(a[idx], b[bIdx]);     a[idx] -= minIdxbIdx;     b[bIdx] -= minIdxbIdx;     int minIdxbIdxPrev = min(a[idx], b[bIdxPrev]);     a[idx] -= minIdxbIdxPrev;     b[bIdxPrev] -= minIdxbIdxPrev;     ret = min(ret, getMinWin(idx + 1));     a[idx] += minIdxbIdx;     b[bIdx] += minIdxbIdx;     a[idx] += minIdxbIdxPrev;     b[bIdxPrev] += minIdxbIdxPrev;     return ret;   }   int getMaxWin() { return min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0]); }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < 3; i++) scanf( %d , &a[i]);     for (int i = 0; i < 3; i++) scanf( %d , &b[i]);     int minWin = INT_MAX;     for (int i = 0; i < 3; i++) {       minWin = min(minWin, getMinWin(0));       for (int j = 0; j < 2; j++) {         swap(a[j], a[j + 1]);         swap(b[j], b[j + 1]);       }     }     printf( %d %d n , minWin, getMaxWin());   }