malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline long long getint() {     long long _x = 0, _tmp = 1;     char _tc = getchar();     while ((_tc <  0  || _tc >  9 ) && _tc !=  - ) _tc = getchar();     if (_tc ==  - ) _tc = getchar(), _tmp = -1;     while (_tc >=  0  && _tc <=  9 ) _x *= 10, _x += (_tc -  0 ), _tc = getchar();     return _x * _tmp;   }   inline long long add(long long _x, long long _y,                        long long _mod = 1000000007ll) {     long long _ = _x + _y;     if (_ >= _mod) _ -= _mod;     return _;   }   inline long long sub(long long _x, long long _y,                        long long _mod = 1000000007ll) {     long long _ = _x - _y;     if (_ < 0) _ += _mod;     return _;   }   inline long long mul(long long _x, long long _y,                        long long _mod = 1000000007ll) {     long long _ = _x * _y;     if (_ >= _mod) _ %= _mod;     return _;   }   long long mypow(long long _a, long long _x, long long _mod) {     if (_x == 0) return 1ll;     long long _tmp = mypow(_a, _x / 2, _mod);     _tmp = mul(_tmp, _tmp, _mod);     if (_x & 1) _tmp = mul(_tmp, _a, _mod);     return _tmp;   }   long long mymul(long long _a, long long _x, long long _mod) {     if (_x == 0) return 0ll;     long long _tmp = mymul(_a, _x / 2, _mod);     _tmp = add(_tmp, _tmp, _mod);     if (_x & 1) _tmp = add(_tmp, _a, _mod);     return _tmp;   }   inline bool equal(double _x, double _y) {     return _x > _y - 1e-9 && _x < _y + 1e-9;   }   int __ = 1, _cs;   void build() {}   int n, q;   void init() {     n = getint();     q = getint();   }   set<pair<int, int> > S;   set<int> v[303030];   void solve() {     int cnt = 0;     while (q--) {       int cmd = getint();       int xi = getint();       if (cmd == 1) {         v[xi].insert(++cnt);         S.insert({cnt, xi});       } else if (cmd == 2) {         for (int ii : v[xi]) S.erase({ii, xi});         v[xi].clear();       } else {         while (S.size() && S.begin()->first <= xi) {           v[S.begin()->second].erase(S.begin()->first);           S.erase(S.begin());         }       }       printf( %d n , (int)S.size());     }   }   int main() {     build();     while (__--) {       init();       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   char str[50][30];   char p[30];   char t[30];   int n;   int solve() {     for (int i = 0; i < n; i++) {       if (strstr(str[i], t) != NULL) {         return 0;       }     }     return 1;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %s , &str[i]);     }     p[0] =  a  - 1;     p[1] = 0;     int len = 1;     for (int i = 1;; i++) {       p[0]++;       int j = 0;       while (p[j] ==  z  + 1) {         p[j] =  a ;         j++;         if (p[j] == 0) {           p[j] =  a ;           p[j + 1] = 0;           len = j + 1;         } else {           p[j]++;         }       }       for (int k = 0; k < len; k++) {         t[k] = p[len - k - 1];       }       t[len] = 0;       if (solve() == 1) {         break;       }     }     printf( %s n , t);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   int main() {     ios_base::sync_with_stdio(0);     long long cnt1, cnt2, cnt3, cnt4;     cin >> cnt1 >> cnt2 >> cnt3 >> cnt4;     cnt3 = (cnt3 != 0 ? 1 : 0);     cnt1 -= cnt3;     cnt4 -= cnt3;     if (cnt1 >= 0 && cnt4 >= 0 && cnt1 == cnt4) {       cout << 1;     } else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, long long int y) {     long long int res = 1;     while (y) {       if (y & 1ll) {         res *= x;       }       x *= x;       y >>= 1ll;     }     return res;   }   int main() {     long long int l, r, k;     cin >> l >> r >> k;     vector<long long int> v;     for (long long int i = 0; i <= 64; i++) {       long long int pw = power(k, i);       if (pw >= l && pw <= r) {         v.push_back(pw);       }       long long int rem = r / pw;       if (rem < k || pw > r) {         break;       }     }     if (v.size() == 0) {       cout << -1 << endl;     } else {       for (auto i : v) {         cout << i <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> v(n);       for (int i = 0; i < n; ++i) cin >> v[i];       bool notfine = true;       for (int i = 0; i < n - 1; ++i) {         if (v[i] <= v[i + 1]) {           notfine = false;           break;         }       }       if (!notfine)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <unordered_set>   #include <unordered_map>   #include <algorithm>   #include <iostream>   #include <string>   #include <vector>   #include <stack>   #include <queue>   #include <deque>   #include <cmath>   #include <set>   #include <map>       using namespace std;       typedef long long ll;       const int Z = (int) 2e3 + 228;   const int N = (int) 1e5 + 228;   const int INF = (int) 1e9 + 228;   const ll LLINF = (ll) 1e18 + 228;       int main() {       ios_base::sync_with_stdio(0);       cin.tie(0);       cout.tie(0);       int tst;       cin >> tst;       while (tst--) {           string s;           cin >> s;           int n = s.size();           if (n == 1) {               cout << 0 <<   n ;               continue;           }           if (n == 2) {               if (s[0] != s[1]) {                   cout << 0 <<   n ;               } else {                   cout << 1 <<   n ;               }               continue;           }           set<char> mn;           for (char c =  a ; c <=  z ; ++c) {               mn.insert(c);           }           int ans = 0;           for (int i = 0; i + 2 < n; ++i) {               set<char> kek = mn;               for (int j = i - 1; j >= max(0, i - 8); --j) {                   kek.erase(s[j]);               }               for (int j = i; j < min(n, i + 8); ++j) {                   kek.erase(s[j]);               }               if (s[i] == s[i + 1] && s[i + 1] == s[i + 2]) {                   kek.erase(s[i]);                   s[i + 1] = *kek.begin();                   s[i + 2] = *++kek.begin();                   ans += 2;               } else if (s[i] == s[i + 1]) {                   s[i + 1] = *kek.begin();                   ++ans;               } else if (s[i + 1] == s[i + 2]) {                   s[i + 2] = *kek.begin();                   ++ans;               } else if (s[i] == s[i + 2]) {                   s[i + 2] = *kek.begin();                   ++ans;               }           }           cout << ans <<   n ;       }       return 0;   }   /*   1   hthtqqqqmnmnososeaeaaa   */
#include <bits/stdc++.h>   using namespace std;   long long ans[2];   int z[100], zn;   int main() {     int n;     scanf( %d , &n);     int m, x;     for (int i = 1; i <= n; i++) {       scanf( %d , &m);       for (int i = 0; i < m; i++) {         scanf( %d , &x);         if (m % 2 && i == m / 2) {           z[zn++] = x;           continue;         }         if (i < m / 2) ans[1] += x;         if (i >= m / 2) ans[0] += x;       }     }     sort(z, z + zn);     bool gamer = 1;     while (--zn >= 0) {       ans[gamer] += z[zn];       gamer ^= 1;     }     printf( %I64d %I64d , ans[1], ans[0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool pr(int x) {     bool p = 0;     if (x % 2 == 0)       p = (x == 2);     else {       long long d = 3;       while (d * d <= x && x % d != 0) {         d += 2;       }       if (d * d > x) p = (x != 1);     }     return p;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     bool fl;     int n, m;     cin >> n >> m;     fl = pr(m);     for (int i = n + 1; i < m; ++i) {       if (pr(i)) {         fl = 0;       }     }     if (fl) {       cout <<  YES ;     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   const int N = 1005;   int size[N], to[N << 1], edge, Next[N << 1], last[N], G, siz, cnt, w[N << 1], n,       x, y, tag[N];   void add(int x, int y) {     to[++edge] = y;     Next[edge] = last[x];     last[x] = edge;   }   void dfs(int x, int fa) {     size[x] = 1;     int mx = 0;     for (int i = last[x]; i; i = Next[i]) {       int u = to[i];       if (u == fa) continue;       dfs(u, x);       size[x] += size[u];       mx = std::max(mx, size[u]);     }     mx = std::max(mx, n - size[x]);     if (mx <= n / 2) G = x;   }   void dfs2(int x, int fa) {     size[x] = 1;     for (int i = last[x]; i; i = Next[i])       if (to[i] != fa) dfs2(to[i], x), size[x] += size[to[i]];   }   void dfs3(int x, int fa, int t, int lstdis) {     for (int i = last[x]; i; i = Next[i]) {       int u = to[i];       if (u == fa) continue;       ++cnt;       w[i] = cnt * t - lstdis;       dfs3(u, x, t, lstdis + w[i]);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d%d , &x, &y);       add(x, y), add(y, x);     }     dfs(1, 0);     dfs2(G, 0);     siz = 0, cnt = 0;     for (int i = last[G]; i; i = Next[i])       if (siz < n / 3 && siz + size[to[i]] <= 2 * n / 3) {         tag[to[i]] = 1;         siz += size[to[i]];       }     for (int i = last[G]; i; i = Next[i])       if (tag[to[i]]) w[i] = ++cnt, dfs3(to[i], G, 1, cnt);     cnt = 0;     for (int i = last[G]; i; i = Next[i])       if (!tag[to[i]])         ++cnt, w[i] = cnt * (siz + 1), dfs3(to[i], G, siz + 1, cnt * (siz + 1));     for (int i = 1; i <= edge; i += 2)       printf( %d %d %d n , to[i], to[i + 1], w[i] | w[i + 1]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned long long int q;     cin >> q;     vector<unsigned long long int> V;     for (unsigned long long int i = 2; i * i <= q; i++)       while (q % i == 0) {         V.push_back(i);         q /= i;       }     if (q != 1) V.push_back(q);     if (V.size() <= 1) {       cout <<  1  << endl;       cout <<  0 ;       return (0);     }     if (V.size() == 2) {       cout <<  2 ;       return (0);     }     cout <<  1  << endl;     cout << V[0] * V[1];     return (0);   }
#include <bits/stdc++.h>   using namespace std;   template <typename elemType>   inline void Read(elemType &T) {     elemType X = 0, w = 0;     char ch = 0;     while (!isdigit(ch)) {       w |= ch ==  - ;       ch = getchar();     }     while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();     T = (w ? -X : X);   }   long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); }   const int maxn = 100010;   const long long MOD = 1000000007LL;   struct Graph {     struct edge {       int Next, to;     };     edge G[maxn << 1];     int head[maxn];     int cnt;     Graph() : cnt(2) {}     void clear(int node_num = 0) {       cnt = 2;       if (node_num == 0)         memset(head, 0, sizeof(head));       else         fill(head, head + node_num + 5, 0);     }     void add_edge(int u, int v) {       G[cnt].to = v;       G[cnt].Next = head[u];       head[u] = cnt++;     }   };   Graph G;   long long Value[maxn];   map<long long, long long> Hash[maxn];   long long Ans = 0;   int N;   void DFS(int u, int fa) {     ++Hash[u][Value[u]];     for (auto it : Hash[u]) Ans = (Ans + it.first * it.second % MOD) % MOD;     for (int i = G.head[u]; i; i = G.G[i].Next) {       int v = G.G[i].to;       if (v == fa) continue;       for (auto it : Hash[u]) {         long long x = GCD(Value[v], it.first);         Hash[v][x] += it.second;       }       DFS(v, u);     }     return;   }   int main() {     Read(N);     for (register int i = 1; i <= N; ++i) Read(Value[i]);     for (register int i = 1; i <= N - 1; ++i) {       int u, v;       Read(u);       Read(v);       G.add_edge(u, v);       G.add_edge(v, u);     }     DFS(1, 0);     printf( %I64d n , Ans);     return 0;   }
#include <bits/stdc++.h>   inline long long read() {     char c = getchar();     while (c !=  -  && (c <  0  || c >  9 )) c = getchar();     long long k = 1, kk = 0;     if (c ==  - ) c = getchar(), k = -1;     while (c >=  0  && c <=  9 ) kk = kk * 10 + c -  0 , c = getchar();     return kk * k;   }   using namespace std;   void write(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x / 10) write(x / 10);     putchar(x % 10 +  0 );   }   void writeln(long long x) {     write(x);     puts(  );   }   long long n, rd[1000010], ans, sum, z[1000010], d, x, y;   signed main() {     n = read();     if (n == 2) {       puts( Yes );       puts( 1 );       puts( 1 2 );       return 0;     }     for (long long i = 1; i < n; i++) x = read(), y = read(), rd[x]++, rd[y]++;     for (long long i = 1; i <= n; i++) {       if (rd[i] > 2) ans++;       if (rd[i] == 1) z[++d] = i;       if (rd[i] > rd[sum]) sum = i;     }     if (ans > 1) return puts( No ), 0;     puts( Yes );     writeln(d);     for (long long i = 1; i <= d; i++) write(z[i]), putchar(   ), writeln(sum);   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 320;   const int inf = 2147483647;   const int mod = 1000000007;   int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();     return x * f;   }   void upd(int &x, int y) {     x += y;     if (x >= mod) x -= mod;   }   int n, m, X, f[2][Maxn][Maxn];   int main() {     n = read(), m = read(), X = read();     if (n > m) return puts( 0 ), 0;     int now = 0;     memset(f[now], 0, sizeof(f[now]));     f[0][0][0] = 1;     for (int i = 0; i < m; i++) {       now ^= 1;       for (int j = 0; j <= min(i, n) + 1; j++)         for (int k = 0; k <= min(i, n) + 1; k++) f[now][j][k] = 0;       for (int j = 0; j <= min(i, n); j++)         for (int k = 0; k <= min(i, n); k++)           if (f[now ^ 1][j][k]) {             int t = f[now ^ 1][j][k];             if (i + 1 == X) {               upd(f[now][j + 1][k], t);               upd(f[now][j + 1][k + 1], t);             } else {               upd(f[now][j][k], t);               upd(f[now][j + 1][k], t);               if (j > k) upd(f[now][j][k + 1], t);               upd(f[now][j + 1][k + 1], t);             }           }     }     int ans = f[now][n][n];     for (int i = 1; i <= n; i++) ans = (long long)ans * i % mod;     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1000005;   const int P = 1e9 + 9;   int Hash[2][M];   int base[M];   int getHash(int *h, int L, int R) {     return (h[R] - 1LL * h[L - 1] * base[R - L + 1] % P + P) % P;   }   char A[M], B[M], C[M];   int main() {     int n;     cin >> n;     n--;     scanf( %s%s , A + 1, C + 1);     for (int i = 1; i <= n; ++i) B[i] = C[n - i + 1];     for (int i = 1; i <= n; ++i) {       char k = B[i];       if (k ==  N ) B[i] =  S ;       if (k ==  S ) B[i] =  N ;       if (k ==  W ) B[i] =  E ;       if (k ==  E ) B[i] =  W ;     }     base[0] = 1;     for (int i = 1; i <= n; ++i) base[i] = 1LL * base[i - 1] * 233 % P;     for (int i = 1; i <= n; ++i) {       Hash[0][i] = (1LL * Hash[0][i - 1] * 233 % P + A[i]) % P;       Hash[1][i] = (1LL * Hash[1][i - 1] * 233 % P + B[i]) % P;     }     for (int i = 1; i <= n; ++i) {       if (getHash(Hash[0], n - i + 1, n) == getHash(Hash[1], 1, i)) {         puts( NO );         return 0;       }     }     puts( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void main0();   int main() {     clock_t start, end;     ios::sync_with_stdio(false);     cin.tie(0);     main0();     return 0;   }   const int dx[8] = {0, 1, -1, 0, 1, 1, -1, -1};   const int dy[8] = {1, 0, 0, -1, 1, -1, -1, 1};   const int N = 2e5 + 5;   const int M = 1e5;   const int INF = 0x3f3f3f3f;   const long long INFF = 0x3f3f3f3f3f3f3f3f;   const int mod = 998244353;   const double eps = 1e-6;   mt19937 rnd(       (unsigned int)chrono::steady_clock::now().time_since_epoch().count());   template <typename T>   bool chkmin(T &x, T y) {     return y < x ? x = y, 1 : 0;   }   template <typename T>   bool chkmax(T &x, T y) {     return y > x ? x = y, 1 : 0;   }   int n, k;   string s;   int lc[N], rc[N];   int ord[N];   int idx[N];   int p = 0;   int flag[N];   void dfs1(int u) {     if (lc[u]) dfs1(lc[u]);     ord[++p] = u;     idx[u] = p;     if (rc[u]) dfs1(rc[u]);   }   int rep[N];   int dfs2(int u, int k) {     if (k == 0) return 0;     int cost = 0;     if (lc[u]) cost += dfs2(lc[u], k - 1);     if (flag[u] || cost) {       rep[u] = 1, cost++;       if (rc[u]) cost += dfs2(rc[u], k - cost);     }     return cost;   }   void main0() {     cin >> n >> k >> s;     s =  $  + s;     for (int i = 1; i <= n; ++i) {       cin >> lc[i] >> rc[i];     }     dfs1(1);     flag[ord[n]] = 0;     for (int i = n - 1; i >= 1; --i) {       int cur = ord[i];       int nxt = ord[i + 1];       flag[cur] = (s[cur] == s[nxt] ? flag[nxt] : s[cur] < s[nxt]);     }     dfs2(1, k);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= rep[ord[i]] + 1; ++j) {         cout << s[ord[i]];       }     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxx = 2e5 + 20, mod = 1e9 + 7;   int main() {     int t;     cin >> t;     while (t--) {       string s;       int n, sum = 0, ans = 0;       cin >> n >> s;       for (int i = 0; i < n; i++) {         if (s[i] ==  ( )           sum++;         else           sum--;         if (sum < 0) {           while (s[i] ==  ) ) {             ans++;             i++;           }           sum = 1;         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int res[2000000];   int main() {     ios::sync_with_stdio(false);     int n, q;     scanf( %d%d , &n, &q);     int re = 0, ro = 0;     bool sw = 0;     for (int i = 0; i < q; ++i) {       int t;       scanf( %d , &t);       if (t == 1) {         int x;         scanf( %d , &x);         re += x;         ro += x;         if (x % 2 != 0) {           sw ^= 1;         }       } else {         if (sw) {           --ro;           ++re;         } else {           ++ro;           --re;         }         sw ^= 1;       }       re = (re % n + n) % n;       ro = (ro % n + n) % n;     }     for (int i = 0; i < n; ++i) {       res[(((i + ((i % 2 == 1) ? re : ro)) % n + n) % n)] = i;     }     for (int i = 0; i < n; ++i) {       printf( %d  , res[i] + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, a, b, ans = 0;   int main() {     scanf( %lld , &t);     while (t--) {       scanf( %lld%lld , &a, &b);       ans = 0;       if (b >= 9) ans++;       if (b >= 99) ans++;       if (b >= 999) ans++;       if (b >= 9999) ans++;       if (b >= 99999) ans++;       if (b >= 999999) ans++;       if (b >= 9999999) ans++;       if (b >= 99999999) ans++;       if (b >= 999999999) ans++;       printf( %lld n , a * ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int s = 0, c = 0;     int a[120];     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       c += a[i];     }     while (1) {       s = 0;       sort(a, a + n);       if (a[n - 1] == a[0]) {         break;       }       for (int j = n - 1; j > 0; j--) {         if (a[j] != a[j - 1]) {           a[j] = a[j] - a[j - 1];         } else {           continue;         }       }       for (int i = 0; i < n; i++) {         s += a[i];       }       c = s;     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > data;   vector<bool> used;   vector<int> cycle;   void dfs(int vertex, int last, vector<int> &path) {     used[vertex] = true;     path.push_back(vertex);     for (int i = 0; i < data[vertex].size(); ++i) {       int to = data[vertex][i];       if (to == last) continue;       if (used[to]) {         if (!cycle.size()) {           int index = path.size() - 1;           while (path[index] != to) {             cycle.push_back(path[index--]);           }           cycle.push_back(path[index]);         }         continue;       }       dfs(to, vertex, path);     }     path.pop_back();   }   vector<bool> if_cycle;   vector<int> sz, tree_ans, ans, szs;   int dfs2(int vertex, int last, int number) {     sz[number]++;     szs[vertex] = 1;     int tut = 1;     for (int i = 0; i < data[vertex].size(); ++i) {       int to = data[vertex][i];       if (if_cycle[to] || to == last) continue;       tut += dfs2(to, vertex, number);       szs[vertex] += szs[to];     }     tree_ans[number] += tut;     return tut;   }   int n;   void dfs3(int vertex, int last, int number, int cur) {     ans[number] = max(ans[number], cur);     for (int i = 0; i < data[vertex].size(); ++i) {       int to = data[vertex][i];       if (if_cycle[to] || to == last) continue;       dfs3(to, vertex, number, cur + n - 2 * szs[to]);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     data.assign(n, {});     for (int i = 0; i < n; ++i) {       int u, v;       cin >> u >> v;       data[u].push_back(v), data[v].push_back(u);     }     used.assign(n, false);     vector<int> p;     dfs(0, -1, p);     if_cycle.assign(n, false);     for (int i = 0; i < cycle.size(); ++i) {       if_cycle[cycle[i]] = true;     }     int S = cycle.size();     sz.assign(S, 0);     tree_ans.assign(S, 0);     szs.assign(n, 0);     for (int i = 0; i < cycle.size(); ++i) {       tree_ans[i] -= dfs2(cycle[i], -1, i);     }     ans.assign(S, 0);     for (int i = 0; i < cycle.size(); ++i) {       dfs3(cycle[i], -1, i, tree_ans[i] + n);     }     int dp[S], dp2[S], sums[S];     for (int i = 0; i < S; ++i) dp[i] = ans[i];     for (int len = 2; len <= S; len++) {       sums[0] = 0;       for (int i = 0; i < len - 1; ++i) sums[0] += sz[i];       int B = len - 1;       for (int i = 1; i < S; ++i) {         sums[i] = sums[i - 1] - sz[i - 1] + sz[B++];         if (B == S) B = 0;       }       int A = len - 1;       for (int i = 0; i < S - 1; ++i) {         dp2[i] = max(dp[i] + tree_ans[A++] + n - sums[i],                      tree_ans[i] + dp[i + 1] + n - sums[i + 1]);         if (A == S) A = 0;       }       dp2[S - 1] =           max(dp[S - 1] + tree_ans[A], tree_ans[S - 1] + dp[0] + n - sums[0]);       for (int i = 0; i < S; ++i) {         dp[i] = dp2[i];       }     }     int A = 0;     for (int i = 0; i < S; ++i) A = max(A, dp[i]);     cout << A;   }
#include <bits/stdc++.h>   using namespace std;   long long a[4];   vector<int> order, to;   bool cmp(int x, int y) { return a[x] < a[y]; }   int main() {     cin >> a[1] >> a[2] >> a[3];     order = {1, 2, 3};     sort(order.begin(), order.end(), cmp);     to = order;     cout <<  First  << endl;     for (;;) {       long long w = 2 * a[to[2]] - a[to[1]] - a[to[0]];       cout << w << endl;       int ps;       cin >> ps;       if (ps == 0) return 0;       a[ps] += w;       if (ps == to[0]) {         w = a[to[2]] - a[to[1]];         cout << w << endl;         cin >> ps;         if (ps == 0) return 0;         a[ps] += w;       } else if (ps == to[1]) {         w = a[to[2]] - a[to[0]];         cout << w << endl;         cin >> ps;         if (ps == 0) return 0;         a[ps] += w;       }     }     return 0;   }