malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1000005;   int n, t1, t2, cnt;   vector<int> mem[N];   int imp[N], hgt[N], res[N];   int p[N], noww[2 * N], goal[2 * N];   void link(int f, int t) {     noww[++cnt] = p[f];     goal[cnt] = t, p[f] = cnt;   }   void DFS(int nde, int fth) {     for (int i = p[nde]; i; i = noww[i])       if (goal[i] != fth) {         DFS(goal[i], nde);         if (hgt[nde] <= hgt[goal[i]])           hgt[nde] = hgt[goal[i]] + 1, imp[nde] = goal[i];       }     if (!imp[nde])       mem[nde].push_back(1);     else {       swap(mem[nde], mem[imp[nde]]), res[nde] = res[imp[nde]];       for (int i = p[nde]; i; i = noww[i])         if (goal[i] != fth && goal[i] != imp[nde]) {           int s1 = mem[nde].size(), s2 = mem[goal[i]].size();           for (int j = 0; j < s2; j++) {             mem[nde][s1 - s2 + j] += mem[goal[i]][j];             if (mem[nde][res[nde]] <= mem[nde][s1 - s2 + j])               res[nde] = s1 - s2 + j;           }         }       mem[nde].push_back(1);       if (mem[nde][res[nde]] == 1) res[nde] = mem[nde].size() - 1;     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d%d , &t1, &t2);       link(t1, t2), link(t2, t1);     }     DFS(1, 0);     for (int i = 1; i <= n; i++) printf( %d n , hgt[i] - res[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) f = ch ==  -  ? -1 : f, ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   const int N = 200050;   int sta[3][N], f[3][N], F[3];   int n, m, s, e;   int pos[N];   void dp() {     for (int t = 0; t < 3; t++)       for (int i = sta[t][0] - 1; i >= 1; i--)         f[t][i] = f[t][i + 1] + max(sta[t][i + 1] - sta[t][i] - s, 0);   }   int binary_search(int t, int x) {     int ret, l = 1, r = sta[t][0], mid;     while (l <= r) {       mid = l + r >> 1;       if (sta[t][mid] >= x)         ret = mid, r = mid - 1;       else         l = mid + 1;     }     return ret;   }   int main() {     pos[0] = e = read(), s = read(), n = read(), m = read();     for (int i = 0; i < 3; i++) sta[i][++sta[i][0]] = pos[0];     for (int i = 1, tp; i <= n; i++) {       tp = read(), pos[i] = read();       if (pos[i] >= e) continue;       switch (tp) {         case 3:           sta[2][++sta[2][0]] = pos[i];         case 2:           sta[1][++sta[1][0]] = pos[i];         case 1:           sta[0][++sta[0][0]] = pos[i];       }     }     sort(sta[0] + 1, sta[0] + sta[0][0] + 1),         sort(sta[1] + 1, sta[1] + sta[1][0] + 1),         sort(sta[2] + 1, sta[2] + sta[2][0] + 1);     dp();     for (int i = 1, x; i <= m; i++) {       x = read();       for (int t = 0; t < 3; t++) {         int y = binary_search(t, x);         F[t] = f[t][y] + max(sta[t][y] - x - s, 0);       }       if (F[0] > 0)         printf( -1 -1 n );       else         printf( %d %d n , F[1], F[2] - F[1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct ans {     int s, t;   };   const int nmax = 100006;   int n, v[nmax], s1[nmax], s2[nmax], rasp, acts, fp1[nmax], fp2[nmax];   ans vrasp[nmax];   bool ver;   int compar(ans a, ans b) {     if (a.t != b.t)       return a.t < b.t;     else       return a.s < b.s;   }   int main() {     int player_unu = 0;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> v[i];       s1[i] = s1[i - 1];       s2[i] = s2[i - 1];       if (v[i] == 1) {         s1[i]++;         fp1[s1[i]] = i;       } else {         s2[i]++;         fp2[s2[i]] = i;       }     }     if (v[n] == 2)       for (int i = 1; i <= n; i++) {         v[i] = 3 - v[i];         swap(s1[i], s2[i]);         swap(fp1[i], fp2[i]);       }     for (int i = n; i > 0; i--) {       if (s1[n] - s1[i - 1] > s2[n] - s2[i - 1] && v[i] == 1) {         acts = s1[n] - s1[i - 1];         int nrs1 = 0, nrs2 = 0, pozact = i;         ver = 0;         for (int j = 0; j < n;) {           if (s1[j] + acts > s1[n] && s2[j] + acts > s2[n]) {             ver = 1;             break;           }           if (s2[j] + acts > s2[n]) {             nrs1++;             j = fp1[s1[j] + acts];             continue;           }           if (s1[j] + acts > s1[n]) {             nrs2++;             j = fp2[s2[j] + acts];             continue;           }           if (fp1[s1[j] + acts] < fp2[s2[j] + acts]) {             nrs1++;             j = fp1[s1[j] + acts];           } else {             nrs2++;             j = fp2[s2[j] + acts];           }         }         if (ver == 0 && nrs1 > nrs2) {           vrasp[rasp].s = acts;           vrasp[rasp].t = nrs1;           rasp++;         }       }     }     sort(vrasp, vrasp + rasp, compar);     cout << rasp <<   n ;     for (int i = 0; i < rasp; i++)       cout << vrasp[i].t <<     << vrasp[i].s <<   n ;     return player_unu;   }
#include <bits/stdc++.h>   using namespace std;   int o, trues, Bruh, YO;   bool levls[696969];   int main() {     int n, X;     cin >> n;     for (int a = 0; a < 2; a++) {       cin >> Bruh;       for (int AL = 0; AL < Bruh; AL++) {         cin >> YO;         levls[YO] = true;       }     }     for (int x = 1; x <= n; x++) {       if (levls[x] == true) trues++;     }     if (trues == n)       cout <<  I become the guy.  << endl;     else       cout <<  Oh, my keyboard!  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   const int N = 1000040;   long long fact[N], invf[N];   vector<long long> primes;   long long add(long long x, long long y) { return (x + y) % mod; }   long long mul(long long x, long long y) { return (x % mod) * (y % mod) % mod; }   long long powll(long long x, long long y) {     long long res = 1LL;     while (y) {       if (y & 1LL) res *= x;       res %= mod;       x = (x * x) % mod;       y >>= 1LL;     }     return res;   }   long long divll(long long x, long long y) {     return (x * powll(y, mod - 2)) % mod;   }   long long nPr(long long n, long long r) {     if (n < r || r < 0) return 0;     return mul(fact[n], invf[n - r]);   }   long long nCr(long long n, long long r) {     if (n < r || r < 0) return 0;     return mul(mul(fact[n], invf[r]), invf[n - r]);   }   long long solve() {     long long x, y;     scanf( %lld %lld , &x, &y);     vector<long long> c;     for (long long p : primes) {       int k = 0;       while (x % p == 0) {         k++;         x /= p;       }       if (k) c.push_back(k);     }     if (x > 1) c.push_back(1);     long long ret = powll(2, y - 1);     for (long long a : c) {       ret = (ret * nCr(y + a - 1, a)) % mod;     }     return ret;   }   int main() {     int q;     cin >> q;     fact[0] = invf[0] = 1;     for (int i = 1; i <= N - 1; ++i) {       fact[i] = (fact[i - 1] * i) % mod;       invf[i] = divll(invf[i - 1], i);     }     long long lim = 1000;     vector<int> check(lim, 1);     for (int i = 2; i <= lim - 1; ++i) {       if (!check[i]) continue;       primes.push_back(i);       for (int j = 2 * i; j < lim; j += i) check[j] = 0;     }     while (q--) {       printf( %lld n , solve());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, y;     cin >> t;     while (t--) {       int n;       cin >> n;       long long a[n];       for (int i = 0; i < n; i++) cin >> a[i];       long long res, mx = 0;       for (int i = 0; i < n - 1; i++) {         res = a[i] * a[i + 1];         mx = max(res, mx);       }       cout << mx << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     cin >> n;     if (n == 0) {       printf( a );       return 0;     }     for (char c =  a ; c <=  z  && n; c++) {       int sum = 0, i;       for (i = 0; i <= n; i++) {         n -= i;         cout << c;       }     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long mult(long long a, long long b, long long mod) {     if (b == 0) return 0;     if (b % 2 == 1) return (mult(a, b - 1, mod) + a) % mod;     return (mult(a, b / 2, mod) * 2) % mod;   }   inline long long BinPow(long long a, long long b, long long mod) {     if (b == 0) return 1;     if (b == 1) return a;     if (b % 2 == 1) return (mult(BinPow(a, b - 1, mod), a, mod)) % mod;     long long res = BinPow(a, b / 2, mod);     return mult(res, res, mod);   }   int n, m, k, w, kol, kol1, w1, sum1;   char a[150][140][130];   int sum;   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         for (int t = 1; t <= k; t++) cin >> a[i][j][t];     for (int l = 1; l <= n; l++)       for (int j = 1; j <= m; j++)         for (int t = 1; t <= k; t++) {           if (a[l][j][t] ==  1 ) {             if (a[l - 1][j][t] ==  1 )               if (a[l + 1][j][t] ==  1 ) w = 1;             if (a[l][j - 1][t] ==  1 )               if (a[l][j + 1][t] ==  1 ) w = 1;             if (a[l][j][t - 1] ==  1 )               if (a[l][j][t + 1] ==  1 ) w = 1;             if (a[l - 1][j][t] ==  1 ) {               if (a[l - 1][j + 1][t] ==  0 )                 if (a[l][j + 1][t] ==  1 ) w1 = 1;               if (a[l - 1][j][t + 1] ==  0 )                 if (a[l][j][t + 1] ==  1 ) w1 = 1;             }             if (a[l][j - 1][t] ==  1 ) {               if (a[l][j - 1][t + 1] ==  0 )                 if (a[l][j][t + 1] ==  1 ) w1 = 1;               if (a[l + 1][j - 1][t] ==  0 )                 if (a[l + 1][j][t] ==  1 ) w1 = 1;             }             if (a[l][j][t - 1] ==  1 ) {               if (a[l][j + 1][t - 1] ==  0 )                 if (a[l][j + 1][t] ==  1 ) w1 = 1;               if (a[l + 1][j][t - 1] ==  0 )                 if (a[l + 1][j][t] ==  1 ) w1 = 1;             }             if (w || w1) sum++;             w1 = w = 0;           }         }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T max(T a, T b, T c) {     return max(a, max(b, c));   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     long long a, b, c;     cin >> a >> b >> c;     cout << 2 * min(a + c, min(b + c, (a + b + c) / 2)) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int x, y, z;     cin >> x >> y >> z;     if (x > y) {       if (x > y + z)         cout <<  + ;       else         cout <<  ? ;     } else if (x < y) {       if (y > x + z)         cout <<  - ;       else         cout <<  ? ;     } else if (z != 0)       cout <<  ? ;     else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)2e9;   const long long INFL = (long long)9e18;   const int MAXINT = ((~0) ^ (1 << 31));   const long long MAXLL = ((~0) ^ ((long long)1 << 63));   template <class T>   inline T pow2(T a) {     return a * a;   }   template <class T>   inline bool mineq(T& a, T b) {     return (a > b) ? (a = b, true) : false;   }   template <class T>   inline bool maxeq(T& a, T b) {     return (a < b) ? (a = b, true) : false;   }   const int maxn = (int)2222;   ;   char grid[maxn][maxn];   int v[maxn][maxn], h[maxn][maxn], t[maxn][maxn], n, m;   long long ans0() {     long long ans = 0;     for (int i = 2; i < (int)(n); i++) {       ans += (v[i][m] == 0);     }     return ans;   }   long long ans1() {     long long ans = 0;     for (int i = 2; i < (int)(n); i++) {       for (int j = 2; j < (int)(m); j++) {         if (grid[i][j] ==  # ) continue;         ans += (h[i][j] == 0 && v[i][j] == 0);         ans += (h[i][j] == h[n][j] && v[i][j] == 0);         ans += (h[i][j] == 0 && v[i][j] == v[i][m]);         ans += (h[i][j] == h[n][j] && v[i][j] == v[i][m]);       }     }     return ans;   }   long long ans2() {     long long ans = 0;     int up[maxn] = {}, down[maxn] = {};     for (int i = 2; i < (int)(n); i++) {       int l = 2, r;       while (l < m) {         if (grid[i][l] ==  # ) {           l++;           continue;         }         r = l;         while (r < m && v[i][l] == v[i][r]) r++;         for (int j = l; j < (int)(r); j++) {           up[j] = (h[i][j] == 0);           down[j] = (h[i][j] == h[n][j]);           if (j - 2 >= l) ans += up[j] * up[j - 2] + down[j] * down[j - 2];           if (j - 1 >= l) ans += up[j] * down[j - 1] + down[j] * up[j - 1];           if (j != l) up[j] += up[j - 1];           if (j != l) down[j] += down[j - 1];         }         l = r;       }     }     return ans;   }   void pre() {     for (int i = 1; i < (int)(n + 1); i++) {       for (int j = 1; j < (int)(m + 1); j++) {         v[i][j] = v[i][j - 1] + (grid[i][j] ==  # );         h[i][j] = h[i - 1][j] + (grid[i][j] ==  # );       }     }   }   void reversegrid() {     for (int i = 1; i < (int)(n + 1); i++)       for (int j = 1; j < (int)(m + 1); j++) t[j][i] = grid[i][j];     for (int i = 1; i < (int)(m + 1); i++)       for (int j = 1; j < (int)(n + 1); j++) grid[i][j] = t[i][j];     swap(n, m);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = 1; i < (int)(n + 1); i++)       for (int j = 1; j < (int)(m + 1); j++) cin >> grid[i][j];     pre();     long long ans = ans0() + ans1() + ans2();     reversegrid();     pre();     cout << ans + ans0() + ans2();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, h, m;     int mo, md, ho, hd;     string t;     cin >> t;     n = t.size();     m = (t[n - 2] -  0 ) * 10 + t[n - 1] -  0 ;     h = (t[n - 5] -  0 ) * 10 + t[n - 4] -  0 ;     for (;;) {       m = (m + 1) % 60;       if (m == 0) {         h = (h + 1) % 24;       }       ho = h % 10;       hd = h / 10;       mo = m % 10;       md = m / 10;       if (hd == mo && ho == md) {         cout << hd << ho <<  :  << md << mo << endl;         break;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(NULL);     int n;     cin >> n;     priority_queue<int, vector<int>, greater<int>> servers;     priority_queue<pair<int, int>, vector<pair<int, int>>,                    greater<pair<int, int>>>         pq;     for (int i = 0; i < n; i++) {       servers.push(i + 1);     }     int q, t, k, d;     cin >> q;     for (int i = 0; i < q; i++) {       cin >> t >> k >> d;       while (pq.empty() == false) {         pair<int, int> top = pq.top();         if (top.first < t) {           servers.push(top.second);           pq.pop();         } else {           break;         }       }       if (servers.size() >= k) {         int total = 0, serverId;         int endTime = t + d - 1;         for (int j = 0; j < k; j++) {           serverId = servers.top();           servers.pop();           total += serverId;           pq.push(make_pair(endTime, serverId));         }         cout << total <<   n ;       } else {         cout <<  -1 n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[30];   string s[100010];   char aver[300010];   long long f(int p, int ch, int si) {     int mi = 99999999;     if (v[ch].size() == 0) return s[si].size();     for (int i = 0; i < v[ch].size(); i++) mi = min(mi, abs(p - v[ch][i]));     return mi;   }   int main() {     long long n, k;     cin >> n >> k;     cin >> aver;     for (int i = 1; i <= n; i++) cin >> s[i];     for (long long i = 0; i < k; i++) v[aver[i] -  a ].push_back(i);     for (int i = 1; i <= n; i++) {       long long F = 0;       for (int j = 0; j < s[i].size(); j++) {         if (s[i][j] != aver[j]) {           F += f(j, s[i][j] -  a , i);         }       }       cout << F << endl;     }   }
#include <bits/stdc++.h>   char a[1111];   int main() {     int i, j, k, l, s, flag;     while (~scanf( %s , a + 2)) {       a[0] = a[1] =  0 ;       s = 0;       l = strlen(a);       flag = 0;       for (i = 0; i < l - 2; i++) {         if (flag) break;         for (j = i + 1; j < l - 1; j++) {           if (flag) break;           for (k = j + 1; k < l; k++) {             s = (a[i] -  0 ) * 100 + (a[j] -  0 ) * 10 + a[k] -  0 ;             if (s % 8 == 0) {               flag = 1;               break;             }           }         }       }       if (flag)         printf( YES n%d n , s);       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 510;   const int INF = 0x3f3f3f3f;   const int MOD = (int)1e9 + 7;   int n;   long long ans;   void dfs(int a, int b, int c) {     if (a == n) {       ++ans;       return;     }     for (int i = 0; i < n; ++i) {       if (b & (1 << i)) continue;       if (c & (1 << ((a + i) % n))) continue;       dfs(a + 1, b | (1 << i), c | (1 << ((a + i) % n)));     }     return;   }   int main() {     cin >> n;     if (n % 2 == 0) {       cout << 0 << endl;       return 0;     }     if (n == 15) {       cout << 150347555 << endl;       return 0;     }     dfs(0, 0, 0);     for (int i = 1; i <= n; ++i) {       ans = (ans * i) % MOD;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c;     while (cin >> a >> b >> c) {       if (b == a / 2 && c == a / 2)         cout <<  NO  << endl;       else if (b == a / 2 && c == a / 2 + 1)         cout <<  NO  << endl;       else if (b == a / 2 + 1 && c == a / 2 + 1)         cout <<  NO  << endl;       else if (b == a / 2 + 1 && c == a / 2)         cout <<  NO  << endl;       else         cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a[100000], p[100000], i, ans = 0, price = INT_MAX;     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %d %d , &a[i], &p[i]);     for (i = 0; i < n; i++) {       price = min(price, p[i]);       ans += (a[i] * price);     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long h12, h13, h14, h23, h24, h34;   long long k1, k2, k3;   long long x1, x2, x3, x4, x5, x6, x7;   long long min_x7, max_x7, best_x7;   long long good = 0;   long long len = -1;   void fail() {     printf( -1 n );     exit(0);   }   int main() {     cin >> h12 >> h13 >> h14 >> h23 >> h24 >> h34;     if ((h12 + h13 + h23) % 2 != 0) fail();     k1 = (h12 + h13 - h23) / 2;     k2 = (h12 + h23 - h13) / 2;     k3 = (h13 + h23 - h12) / 2;     if (k1 < 0 || k2 < 0 || k3 < 0) fail();     if ((h14 + h34 - k1 - k3) % 2 != 0) fail();     max_x7 = (h14 + h34 - k1 - k3) / 2;     if ((k2 + k3 - h24 - h34) % 2 != 0) fail();     min_x7 = -k1 - (k2 + k3 - h24 - h34) / 2;     max_x7 = min(max_x7, -(k2 + k3 - h24 - h34) / 2);     min_x7 = max(min_x7, (h14 + h34 - k1 - k3) / 2 - k2);     if ((h14 + h24 - k1 - k2) % 2 != 0) fail();     max_x7 = min(max_x7, (h14 + h24 - k1 - k2) / 2);     min_x7 = max(min_x7, (h14 + h24 - k1 - k2) / 2 - k3);     if (min_x7 > max_x7) fail();     for (int i = (max(0ll, min_x7)); i < (int)(min(1000000ll, max_x7 + 1)); ++i) {       x7 = i;       x3 = (h14 + h34 - k1 - k3) / 2 - x7;       x1 = k1 + x7 + (k2 + k3 - h24 - h34) / 2;       x5 = k1 - x1 + x3 + k3 + x7 - h34;       x6 = k3 - x5;       x4 = k2 - x3;       x2 = k1 - x1;       if (x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 || x5 < 0 || x6 < 0 || x7 < 0)         continue;       good = 1;       if (len == -1 || len > x1 + x2 + x3 + x4 + x5 + x6 + x7) {         len = x1 + x2 + x3 + x4 + x5 + x6 + x7;         best_x7 = x7;       }     }     if (!good) fail();     x7 = best_x7;     x3 = (h14 + h34 - k1 - k3) / 2 - x7;     x1 = k1 + x7 + (k2 + k3 - h24 - h34) / 2;     x5 = k1 - x1 + x3 + k3 + x7 - h34;     x6 = k3 - x5;     x4 = k2 - x3;     x2 = k1 - x1;     cout << x1 + x2 + x3 + x4 + x5 + x6 + x7 <<   n ;     for (int(i) = 0; (i) < (int)(x1 + x2 + x3 + x4 + x5 + x6 + x7); ++(i))       printf( a );     printf(  n );     for (int(i) = 0; (i) < (int)(x1 + x2 + x3 + x4); ++(i)) printf( b );     for (int(i) = 0; (i) < (int)(x5 + x6 + x7); ++(i)) printf( a );     printf(  n );     for (int(i) = 0; (i) < (int)(x1 + x2); ++(i)) printf( b );     for (int(i) = 0; (i) < (int)(x3 + x4); ++(i)) printf( a );     for (int(i) = 0; (i) < (int)(x5 + x6); ++(i)) printf( b );     for (int(i) = 0; (i) < (int)(x7); ++(i)) printf( a );     printf(  n );     for (int(i) = 0; (i) < (int)(x1); ++(i)) printf( b );     for (int(i) = 0; (i) < (int)(x2); ++(i)) printf( a );     for (int(i) = 0; (i) < (int)(x3); ++(i)) printf( b );     for (int(i) = 0; (i) < (int)(x4); ++(i)) printf( a );     for (int(i) = 0; (i) < (int)(x5); ++(i)) printf( b );     for (int(i) = 0; (i) < (int)(x6); ++(i)) printf( a );     for (int(i) = 0; (i) < (int)(x7); ++(i)) printf( b );     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool used[1005];   vector<int> v;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, k, a, b, c, d;     cin >> n >> k >> a >> b >> c >> d;     if (n == 4 or k <= n) {       cout << -1;       return 0;     }     used[a] = used[b] = used[c] = used[d] = true;     for (int i = 1; i <= n; i++) {       if (!used[i]) {         v.push_back(i);       }     }     cout << a <<     << c <<     << v[0] <<     << d <<    ;     for (int i = 1; i <= n - 5; i++) {       cout << v[i] <<    ;     }     cout << b <<   n ;     cout << c <<     << a <<     << v[0] <<     << b <<    ;     for (int i = n - 5; i >= 1; i--) {       cout << v[i] <<    ;     }     cout << d;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int i, j, n, k, m, t, x = 0, y, c = 0, sum = 0, maxx, t1, t2, x1,                                     x2, y1, y2, m1, m2;     double ans1, ans2, ans = 1000000000000000000;     cin >> t2 >> t1 >> x2 >> x1 >> t;     if (t1 == t2 && t == t1)       cout << x2 <<     << x1;     else if (t >= t1)       cout <<  0   << x1;     else if (t <= t2)       cout << x2 <<   0 ;     else {       for (i = 1; i < x1 + 1; i++) {         y1 = i;         y2 = min(y1 * (t1 - t) / (t - t2), x2);         ans1 = (t1 * y1 + t2 * y2) * 1.0 / (y1 + y2);         if (ans1 >= t &&             ((ans1 - t) <= ans || abs(ans1 - t - ans) <= 0.0000001)) {           m1 = y1;           m2 = y2;           ans = ans1 - t;         }         if (y2 < x2) {           y2++;           ans2 = (t1 * y1 + t2 * y2) * 1.0 / (y1 + y2);           if (ans2 >= t &&               ((ans2 - t) <= ans || abs(ans2 - t - ans) <= 0.0000001)) {             m1 = y1;             m2 = y2;             ans = ans2 - t;           }         }       }       cout << m2 <<     << m1;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, h, m, i, j, x, y, z, ans;     cin >> n >> h >> m;     long long int a[n + 10];     for (i = 1; i <= n; i++) {       a[i] = h;     }     for (i = 1; i <= m; i++) {       cin >> x >> y >> z;       for (j = x; j <= y; j++) {         a[j] = min(a[j], z);       }     }     ans = 0;     for (i = 1; i <= n; i++) {       ans += a[i] * a[i];     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, q, p;   long long* pt;   long long a[200000], k, sum = 0LL;   int main() {     cin >> n >> q;     for (int i = (0); i < (n); i++) {       cin >> a[i];       if (i) a[i] += a[i - 1];     }     for (int i = (0); i < (q); i++) {       cin >> k;       sum += k;       pt = upper_bound(a, a + n, sum);       p = pt - a;       if (p == n) {         p = 0;         sum = 0LL;       }       cout << n - p <<   n ;     }   }