malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:16777216 )   const char DEBUG = 0;   mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());   struct pp {     int pos, id;   };   long long pos[200000];   int type[200000];   int res[100000];   vector<int> arr;   int get_id1(int x) {     int l = 0, r = arr.size();     while (r - l > 1) {       int m = (l + r) / 2;       if (arr[m] >= x)         r = m;       else         l = m;     }     return l;   }   int get_id2(int x) {     int l = -1, r = arr.size() - 1;     while (r - l > 1) {       int m = (l + r) / 2;       if (arr[m] <= x)         l = m;       else         r = m;     }     return r;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin.sync_with_stdio(0);     cout.tie(0);     cout.sync_with_stdio(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n + m; i++) cin >> pos[i];     for (int i = 0; i < n + m; i++) cin >> type[i];     for (int i = 0; i < n + m; i++)       if (type[i]) arr.push_back(pos[i]);     for (int i = 0; i < n + m; i++) {       if (type[i]) continue;       long long d1 = 1000000000000000000LL, d2 = 1000000000000000000LL;       int p1 = get_id1(pos[i]);       int p2 = get_id2(pos[i]);       d1 = abs(arr[p1] - pos[i]);       d2 = abs(arr[p2] - pos[i]);       if (d1 < d2)         res[p1]++;       else if (d2 < d1)         res[p2]++;       else {         if (arr[p1] < arr[p2])           res[p1]++;         else           res[p2]++;       }     }     for (int i = 0; i < m; i++) cout << res[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int base1 = 115019, mod1 = 1e9 + 13;   vector<int> pos[100005];   int n, t[100005], a[100005];   long long p1[100005], sum1[100005];   struct node {     int st, len;     bool operator<(const node &A) const {       if (len == A.len) return st < A.st;       return len < A.len;     }   };   vector<node> S;   bool check(int x, int y) {     if (y + (y - x) - 1 > n) return false;     long long sx1 =         ((sum1[y - 1] - sum1[x - 1] * p1[y - x]) % mod1 + mod1) % mod1;     long long sy1 =         ((sum1[y + y - x - 1] - sum1[y - 1] * p1[y - x]) % mod1 + mod1) % mod1;     return sx1 == sy1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]), t[i] = a[i];     sort(t + 1, t + n + 1);     int m = unique(t + 1, t + n + 1) - t - 1;     p1[0] = 1;     for (int i = 1; i <= n; ++i) {       a[i] = lower_bound(t + 1, t + m + 1, a[i]) - t;       pos[a[i]].push_back(i);       p1[i] = p1[i - 1] * base1 % mod1;       sum1[i] = (sum1[i - 1] * base1 + a[i]) % mod1;     }     for (int i = 1; i <= m; ++i)       for (int j = 0; j < pos[i].size(); ++j)         for (int k = j + 1; k < pos[i].size(); ++k) {           int x = pos[i][j], y = pos[i][k];           if (check(x, y)) S.push_back((node){x, y - x});         }     sort(S.begin(), S.end());     int now = 1;     for (int i = 0; i < S.size(); ++i) {       node p = S[i];       if (p.st < now)         continue;       else         now = p.st + p.len;     }     printf( %d n , n - now + 1);     for (int i = now; i <= n; ++i) printf( %d  , t[a[i]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, p;     string s, number;     cin >> n;     string name[n];     int taxi[n], pizza[n], cg[n], tax, pizz, cgc, taxmax = -1, pizzmax = -1,                                                   cgcmax = -1;     int taxifinal[n], pizzafinal[n], cgcfinal[n], ct = 0, cp = 0, cc = 0;     for (int i = 0; i < n; i++) {       cin >> p >> name[i];       tax = 0;       pizz = 0;       cgc = 0;       for (int j = 0; j < p; j++) {         cin >> number;         if (((number[0] == number[3]) && (number[3] == number[6])) &&             ((number[0] == number[1]) && (number[3] == number[4]) &&              (number[6] == number[7]))) {           tax++;         } else if ((int(number[0]) > int(number[1])) &&                    (int(number[1]) > int(number[3])) &&                    (int(number[3]) > int(number[4])) &&                    (int(number[4]) > int(number[6])) &&                    (int(number[6]) > int(number[7]))) {           pizz++;         } else {           cgc++;         }       }       taxi[i] = tax;       pizza[i] = pizz;       cg[i] = cgc;     }     for (int i = 0; i < n; i++) {       taxmax = max(taxmax, taxi[i]);       pizzmax = max(pizzmax, pizza[i]);       cgcmax = max(cgcmax, cg[i]);     }     for (int i = 0; i < n; i++) {       if (taxmax == taxi[i]) {         taxifinal[ct] = i;         ct++;       }       if (pizzmax == pizza[i]) {         pizzafinal[cp] = i;         cp++;       }       if (cgcmax == cg[i]) {         cgcfinal[cc] = i;         cc++;       }     }     cout <<  If you want to call a taxi, you should call: ;     if (ct > 1) {       for (int j = 0; j < ct - 1; j++) {         cout <<     << name[taxifinal[j]] <<  , ;       }       cout <<     << name[taxifinal[ct - 1]] <<  .  << endl;     } else {       cout <<     << name[taxifinal[ct - 1]] <<  .  << endl;     }     cout <<  If you want to order a pizza, you should call: ;     if (cp > 1) {       for (int j = 0; j < cp - 1; j++) {         cout <<     << name[pizzafinal[j]] <<  , ;       }       cout <<     << name[pizzafinal[cp - 1]] <<  .  << endl;     } else {       cout <<     << name[pizzafinal[cp - 1]] <<  .  << endl;     }     cout <<  If you want to go to a cafe with a wonderful girl, you should call: ;     if (cc > 1) {       for (int j = 0; j < cc - 1; j++) {         cout <<     << name[cgcfinal[j]] <<  , ;       }       cout <<     << name[cgcfinal[cc - 1]] <<  .  << endl;     } else {       cout <<     << name[cgcfinal[cc - 1]] <<  .  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     string s[10];     for (int i = 0; i < 8; i++) {       cin >> s[i];     }     bool ans = 1;     for (int i = 0; i < 8 && ans; i++) {       for (int k = 1; k < 8; k++) {         if (s[i][k - 1] == s[i][k]) {           ans = 0;           break;         }       }     }     if (ans) {       cout <<  YES  << endl;     } else       cout <<  NO  << endl;     return 0;   }
/* Clearink */      #include <queue>   #include <cstdio>   #include <algorithm>      #define rep( i, l, r ) for ( int i = l, repEnd##i = r; i <= repEnd##i; ++i )   #define per( i, r, l ) for ( int i = r, repEnd##i = l; i >= repEnd##i; --i )      inline int rint() {    int x = 0, f = 1, s = getchar();    for ( ; s <  0  ||  9  < s; s = getchar() ) f = s ==  -  ? -f : f;    for ( ;  0  <= s && s <=  9 ; s = getchar() ) x = x * 10 + ( s ^  0  );    return x * f;   }      template<typename Tp>   inline void wint( Tp x ) {    if ( x < 0 ) putchar(  -  ), x = -x;    if ( 9 < x ) wint( x / 10 );    putchar( x % 10 ^  0  );   }      const int MAXN = 1.5e3;   int n, m, a[MAXN + 5][MAXN + 5], b[MAXN + 5][MAXN + 5];   int d[MAXN + 5], ocnt, opt[MAXN + 5], p[MAXN + 5], q[MAXN + 5], tmp[MAXN + 5];   bool era[MAXN + 5];   std::queue<int> que;      int main() {    n = rint(), m = rint();    rep ( i, 1, n ) rep ( j, 1, m ) a[i][j] = rint();    rep ( i, 1, n ) rep ( j, 1, m ) b[i][j] = rint();    rep ( i, 2, n ) rep ( j, 1, m ) d[j] += b[i - 1][j] > b[i][j];    rep ( i, 1, m ) if ( !d[i] ) que.push( i );    while ( !que.empty() ) {     int c = que.front(); que.pop();     opt[++ocnt] = c;     rep ( i, 2, n ) if ( b[i - 1][c] < b[i][c] && !era[i] ) {      era[i] = true;      rep ( j, 1, m ) if ( b[i - 1][j] > b[i][j] && !--d[j] ) {       que.push( j );      }     }    }    rep ( i, 1, n ) q[i] = i;    per ( k, ocnt, 1 ) {     rep ( i, 1, n ) p[i] = i;     std::sort( p + 1, p + n + 1, [=]( const int i, const int j ) {      int u = a[q[i]][opt[k]], v = a[q[j]][opt[k]];      return u != v ? u < v : i < j;     } );     rep ( i, 1, n ) tmp[i] = q[i];     rep ( i, 1, n ) q[i] = tmp[p[i]];    }    rep ( i, 1, n ) rep ( j, 1, m ) if ( a[q[i]][j] != b[i][j] ) {     return puts(  -1  ), 0;    }    wint( ocnt ), putchar(   n  );    per ( i, ocnt, 1 ) wint( opt[i] ), putchar( i > 1 ?     :   n  );    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     long long int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     map<long long int, long long int> m;     m[0] = 0;     long long int sum = 0, ans = 0, k = (-1);     for (int i = 0; i < n; i++) {       sum += a[i];       if (m.count(sum)) {         if (m[sum] >= k) {           ans++;           k = (i - 1);         }       }       m[sum] = i;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int loc[200000 + 10];   int n;   int ans[4];   int fnext(int y) {     int l = 1, r = n + 1, mid = (l + r) / 2;     while (l < r) {       if (loc[mid] <= y)         l = mid + 1;       else         r = mid;       mid = (l + r) / 2;     }     return mid;   }   int ok(int x) {     int i, j;     int z = 1;     for (i = 1; i <= 3; i++) {       z = fnext(loc[z] + x);       ans[i] = z;       if (z >= n + 1) return 1;     }     return 0;   }   int main() {     while (scanf( %d , &n) != EOF) {       int i, j, k;       for (i = 1; i <= n; i++) {         scanf( %d , &loc[i]);       }       sort(loc + 1, loc + n + 1);       int r = (loc[n] - loc[1]);       int l = 0, mid;       while (l < r) {         mid = (r + l) / 2;         if (ok(mid))           r = mid;         else           l = mid + 1;       }       ok(l);       double radius = l * 1.0 / 2.0;       double radar1 = (loc[ans[1] - 1] + loc[1]) * 1.0 / 2.0;       double radar2 = (loc[ans[2] - 1] + loc[ans[1]]) / 2.0;       double radar3 = (loc[ans[3] - 1] + loc[ans[2]]) / 2.0;       printf( %.6f n , radius);       printf( %.6f  , radar1);       printf( %.6f  , radar2);       printf( %.6f n , radar3);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   using ii = long long;   int main() {     int n, k;     scanf( %d%d , &n, &k);     vector<int> v(n);     vector<ii> s(n);     for (int &x : v) {       scanf( %d , &x);     }     for (int i = n - 2; i + 1; --i) {       s[i] = v[i + 1] + s[i + 1];     }     s.pop_back();     ii r = v[0] + (n > 1 ? s[0] : 0);     sort(s.begin(), s.end(), greater<ii>());     r += accumulate(s.begin(), s.begin() + k - 1, 0ll);     printf( %lld n , r);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 55, MAXM = 20020;   int n, m, k, acc[MAXN][MAXM], dp[MAXN][MAXM], ans;   struct no {     int beg, end, mid, mx, lz;     no *l, *r;     no(int beg, int end)         : beg(beg), end(end), mid((beg + end) >> 1), mx(0), lz(0) {       if (beg != end) l = new no(beg, mid), r = new no(mid + 1, end);     }     void refresh() {       if (!lz) return;       mx += lz;       if (beg != end) l->lz += lz, r->lz += lz;       lz = 0;     }     void upd(int a, int b, int inc) {       refresh();       if (end < a || b < beg) return;       if (a <= beg && end <= b) return lz += inc, refresh();       l->upd(a, b, inc), r->upd(a, b, inc);       mx = max(l->mx, r->mx);     }     void set(int pos, int val) {       refresh();       if (beg == end) return void(mx = val);       (pos <= mid ? l : r)->set(pos, val);       mx = max(l->mx, r->mx);     }     int get(int a, int b) {       refresh();       if (end < a || b < beg) return 0;       if (a <= beg && end <= b) return mx;       return max(l->get(a, b), r->get(a, b));     }     void print() {       refresh();       if (beg == end) return printf( %d  , mx), void();       l->print(), r->print();     }   };   int main() {     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         scanf( %d , &acc[i][j]), acc[i][j] += acc[i][j - 1];     no seg(1, m - k + 1);     for (int i = n; i >= 1; --i) {       for (int j = 1; j <= k; ++j)         seg.upd(1, j, -(acc[i + 1][j] - acc[i + 1][j - 1]));       for (int j = 1; j <= m - k + 1; ++j) {         int aux = acc[i][j + k - 1] - acc[i][j - 1] + acc[i + 1][j + k - 1] -                   acc[i + 1][j - 1];         if (i == n) {           dp[i][j] = aux;           continue;         }         dp[i][j] = max(dp[i][j], seg.get(j - k + 1, j + k - 1));         if (j > k) dp[i][j] = max(dp[i][j], seg.get(1, j - k));         if (j + k <= m - k + 1)           dp[i][j] = max(dp[i][j], seg.get(j + k, m - k + 1));         dp[i][j] += aux;         seg.upd(max(1, j - k + 1), j, (acc[i + 1][j] - acc[i + 1][j - 1]));         seg.upd(j + 1, j + k, -(acc[i + 1][j + k] - acc[i + 1][j + k - 1]));       }       for (int j = 1; j <= m - k + 1; ++j) seg.set(j, dp[i][j]);     }     printf( %d n , seg.get(1, m - k + 1));   }
#include <bits/stdc++.h>   using namespace std;   int n;   int d[262144][4];   map<int, int> comp;   int r[262144], R, pr[262144];   vector<int> vec;   bool cmp(int a, int b) { return d[a][1] > d[b][1]; }   struct BIT {     int m[262144 * 2];     vector<int> v[262144];     void init() {       int i;       for (i = 0; i < n; i++) v[comp[d[i][0]]].push_back(i);       for (i = 0; i < 262144; i++) {         if (v[i].size()) {           sort(v[i].begin(), v[i].end(), cmp);           m[262144 + i] = d[v[i].back()][1];         } else           m[262144 + i] = 2147483647;       }       for (i = 262144 - 1; i >= 1; i--)         m[i] = m[i * 2] < m[i * 2 + 1] ? m[i * 2] : m[i * 2 + 1];     }     void gohelp(int p, int i) {       if (m[p] > d[i][3]) return;       if (p < 262144) {         gohelp(p * 2, i);         gohelp(p * 2 + 1, i);       } else {         while (v[p - 262144].size()) {           int j = v[p - 262144].back();           if (d[j][1] <= d[i][3]) {             vec.push_back(j);             r[j] = R;             pr[j] = i;             v[p - 262144].pop_back();           } else             break;         }         if (v[p - 262144].size())           m[p] = d[v[p - 262144].back()][1];         else           m[p] = 2147483647;         for (p /= 2; p; p /= 2)           m[p] = m[p * 2] < m[p * 2 + 1] ? m[p * 2] : m[p * 2 + 1];       }     }     void go(int p, int i) {       p += 262144;       gohelp(p, i);       for (; p > 1; p /= 2) {         if (p & 1) gohelp(p - 1, i);       }     }   } bit;   int main() {     int i;     scanf( %d , &n);     comp[0] = 1;     for (i = 0; i < n; i++) {       scanf( %d%d%d%d , &d[i][0], &d[i][1], &d[i][2], &d[i][3]);       comp[d[i][0]] = comp[d[i][2]] = 1;     }     i = 0;     for (auto& it : comp) it.second = i++;     bit.init();     memset(r, -1, sizeof(r));     vector<int> vecpr;     vecpr.push_back(n);     while (vecpr.size()) {       vec.clear();       R++;       for (int i : vecpr) bit.go(comp[d[i][2]], i);       vecpr = vec;     }     printf( %d n , r[n - 1]);     if (r[n - 1] != -1) {       vector<int> path;       for (i = n - 1; r[i] > 1; i = pr[i]) path.push_back(i);       path.push_back(i);       for (i = path.size() - 1; i >= 0; i--) printf( %d  , path[i] + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e5 + 5;   bool mark[MAX_N];   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n;     cin >> n;     for (int i = 0; i < n - 1; i++) {       int a;       cin >> a;       mark[a - 1] = true;     }     for (int i = 0; i < n; i++)       if (!mark[i]) cout << i + 1;   }
#include <bits/stdc++.h>   using namespace std;   char a[100];   int main() {     int i, l, c = 0;     scanf( %s , a);     l = strlen(a);     for (i = 1; i < l; i++) {       if (a[i] <=  Z ) {         c++;       }     }     int t = 0;     if (a[1] <=  Z  && c >= l - 1) t++;     if (t != 0) {       for (i = 0; i < l; i++) {         if (a[i] >=  a ) {           a[i] = a[i] -  a  +  A ;         } else {           a[i] = a[i] -  A  +  a ;         }       }     }     printf( %s , a);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 105;   const int mod = 998244353;   const double Pi = acos(-1.0);   const long long INF = 1e18;   const int G = 3, Gi = 332748118;   long long qpow(long long a, long long b) {     long long res = 1;     while (b) {       if (b) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   int T, n, m;   long long dp[105][105], a[105][105];   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d%d , &n, &m);       for (int i = 1; i <= n; ++i) {         for (int j = 1; j <= m; ++j) scanf( %lld , &a[i][j]);       }       long long res = INF;       for (int x = 1; x <= n; ++x) {         for (int y = 1; y <= m; ++y) {           for (int i = 0; i <= n; ++i)             for (int j = 0; j <= m; ++j) dp[i][j] = INF;           dp[1][0] = 0;           for (int i = 1; i <= n; ++i) {             for (int j = 1; j <= m; ++j) {               long long dis = abs(x - i) + abs(y - j);               if (i <= x && j <= y && a[i][j] >= a[x][y] - dis) {                 dp[i][j] =                     min(dp[i - 1][j], dp[i][j - 1]) + a[i][j] - (a[x][y] - dis);               }               if (i >= x && j >= y && a[i][j] >= a[x][y] + dis) {                 dp[i][j] =                     min(dp[i - 1][j], dp[i][j - 1]) + a[i][j] - (a[x][y] + dis);               }             }           }           res = min(res, dp[n][m]);         }       }       printf( %lld n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int from, to, next, w, dir, id;   } e[1500000];   int head[350000];   int in[350000];   int out[350000];   int ans[350000];   int n, m, cont;   void add(int from, int to, int w, int dir, int id) {     e[cont].from = from;     e[cont].to = to;     e[cont].w = w;     e[cont].dir = dir;     e[cont].id = id;     e[cont].next = head[from];     head[from] = cont++;   }   void Top() {     queue<int> s;     s.push(1);     in[1] = out[1] = 0;     while (!s.empty()) {       int u = s.front();       s.pop();       for (int i = head[u]; i != -1; i = e[i].next) {         int v = e[i].to;         int w = e[i].w;         int dir = e[i].dir;         if (v == 1 || (in[v] == out[v] && v != n)) continue;         if (u == 1 || v == n) {           if (u == 1) {             ans[e[i].id] = dir;             in[v] += w;           } else {             ans[e[i].id] = dir;           }         } else {           if (in[v] != out[v]) {             in[v] += w;             ans[e[i].id] = dir;           } else             ans[e[i].id] = 1 - dir;         }         if (in[v] == out[v] && v != n) {           s.push(v);         }       }     }     for (int i = 1; i <= m; i++) printf( %d n , ans[i]);   }   int main() {     while (~scanf( %d%d , &n, &m)) {       cont = 0;       memset(in, 0, sizeof(in));       memset(out, 0, sizeof(out));       memset(head, -1, sizeof(head));       for (int i = 1; i <= m; i++) {         int x, y, w;         scanf( %d%d%d , &x, &y, &w);         add(x, y, w, 0, i);         add(y, x, w, 1, i);         out[y] += w;         out[x] += w;       }       for (int i = 1; i <= n; i++) out[i] = out[i] / 2;       Top();     }   }
#include <bits/stdc++.h>   using namespace std;   void solution() {     int n, k;     cin >> n >> k;     vector<long long> v(n * k + 1, 0), brr(n * k + 1, 0);     long long sum = 0;     for (int i = 1; i <= n * k; i++) {       cin >> v[i];       brr[i] = v[i];     }     brr[0] = INT_MAX;     sort(brr.rbegin(), brr.rend());     if (n % 2 == 0) {       int right = n / 2 + 1;       int i = right;       int j = 0;       while (j < k) {         sum = sum + brr[i];         i = i + right;         j++;       }     } else {       int right = n / 2 + n % 2;       int i = right;       int j = 0;       while (j < k) {         sum = sum + brr[i];         i = i + right;         j++;       }     }     cout << sum << endl;   }   int main() {     int t;     cin >> t;     while (t--) {       solution();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MXN = 80 + 10;   const long long MX5 = 4e5 + 10;   const long long MX6 = 1e6 + 10;   const long long LOG = 20;   const long long INF = 8e18;   const double eps = 1e-9;   const long long MOD = 1e9 + 7;   long long power(long long a, long long b, long long md) {     return (!b ? 1                : (b & 1 ? a * power(a * a % md, b / 2, md) % md                         : power(a * a % md, b / 2, md) % md));   }   long long bmm(long long a, long long b) {     return (a % b == 0 ? b : bmm(b, a % b));   }   string base2(long long n) {     string a =   ;     while (n >= 2) {       a += (char)(n % 2 +  0 );       n /= 2;     }     a += (char)(n +  0 );     reverse((a).begin(), (a).end());     return a;   }   long long n;   long long PS[MX5], Ans[MX5], ex[MX5];   vector<long long> second, T;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       long long x;       cin >> x;       second.push_back(x);     }     for (int i = 0; i < n; i++) {       long long x;       cin >> x;       T.push_back(x);     }     PS[0] = T[0];     for (int i = 1; i < n; i++) PS[i] = PS[i - 1] + T[i];     PS[n] = INF;     for (int i = 0; i < n; i++) {       long long men = (i - 1 < 0 ? 0 : PS[i - 1]);       if (second[i] <= T[i]) {         ex[i] += second[i];         continue;       }       long long l = i, r = n;       while (r - l > 1) {         long long mid = (l + r) / 2;         if (PS[mid] - men <= second[i]) {           l = mid;         } else {           r = mid;         }       }       Ans[l + 1]--, Ans[i]++;       if (PS[l] - men < second[i]) {         ex[l + 1] += second[i] - PS[l] + men;       }     }     for (int i = 1; i < n; i++) Ans[i] += Ans[i - 1];     for (int i = 0; i < n; i++) {       cout << Ans[i] * T[i] + ex[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int points(int p, int t) {     int first = 75 * p;     int second = 250 * p - p * t;     return max(first, second);   }   int main() {     int a, b, c, d;     scanf( %d %d %d %d , &a, &b, &c, &d);     int misha = points(a, c);     int vasia = points(b, d);     if (misha > vasia) {       cout <<  Misha  << endl;     } else if (vasia > misha) {       cout <<  Vasya  << endl;     } else {       cout <<  Tie  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 6000 + 10;   int n, t, arr[MAXN][MAXN];   void dfs(int i, int j, int val) {     arr[i][j] += val;     if (arr[i][j] < 4) return;     int me = arr[i][j] / 4;     arr[i][j] %= 4;     dfs(i + 1, j, me);     dfs(i - 1, j, me);     dfs(i, j + 1, me);     dfs(i, j - 1, me);     return;   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> t;     dfs(MAXN / 2, MAXN / 2, n);     for (int i = 0; i < t; i++) {       int l, r;       cin >> l >> r;       l += MAXN / 2;       r += MAXN / 2;       if (l < 0 || r < 0 || l > MAXN || r > MAXN) {         cout << 0 << endl;         continue;       }       cout << arr[l][r] << endl;     }     cin >> n;     return 0;   }