malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct Node {     int v;     int id;   } node[110];   int t[110];   bool cmp(Node x, Node y) { return x.v > y.v; }   int main() {     int n, w;     cin.sync_with_stdio(false);     while (cin >> n >> w) {       for (int i = 0; i < n; i++) {         cin >> node[i].v;         node[i].id = i;       }       bool flag = true;       for (int i = 0; i < n; i++) {         if (node[i].v & 1)           t[i] = node[i].v / 2 + 1, w -= t[i];         else           t[i] = node[i].v / 2, w -= t[i];         if (w < 0) {           flag = false;           printf( -1 n );           break;         }       }       if (!flag) continue;       sort(node, node + n, cmp);       for (int i = 0; i < n; i++) {         if (w > (node[i].v - t[node[i].id])) {           int d = node[i].v - t[node[i].id];           t[node[i].id] = node[i].v;           w = w - d;         } else {           t[node[i].id] += w;           break;         }       }       for (int i = 0; i < n - 1; i++) cout << t[i] <<    ;       cout << t[n - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 2;   int n;   struct Node {     int l, r;   };   Node a[maxn];   bool cmp(Node x, Node y) {     if (x.r == y.r) return x.l < y.l;     return x.r < y.r;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       int x, w;       scanf( %d%d , &x, &w);       a[i].l = x - w;       a[i].r = x + w;     }     sort(a + 1, a + n + 1, cmp);     int max = a[1].r, ans = 1;     for (int i = 2; i <= n; i++)       if (a[i].l >= max) {         ans++;         max = a[i].r;       }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned int dp[100100];   char s[100100];   int main() {     unsigned int n;     cin >> n;     if (n & 1) {       return !printf( 0 );     }     scanf( %s , s + 1);     int m = n / 2;     dp[0] = 1;     for (int i = 1; i <= n; i++) {       if (s[i] ==  ? ) {         for (int j = i / 2; j >= max(1, i - m); j--) dp[j] += dp[j - 1];       }     }     for (int i = 1; i <= n; i++) {       if (s[i] ==  ? ) continue;       m--;     }     for (int i = 1; i <= m; i++) dp[n / 2] *= 25;     cout << dp[n / 2] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int modInverse(int a, int m);   int gcd(int a, int b);   int power(int x, unsigned int y, unsigned int m);   void pairsort(int a[], int b[], int n);   int logint(int x, int y);   int gcd(int a, int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   int power(int x, unsigned int y, unsigned int m) {     if (y == 0) return 1;     int p = power(x, y / 2, m) % m;     p = (p * p) % m;     return (y % 2 == 0) ? p : (x * p) % m;   }   int modInverse(int a, int m) {     int m0 = m;     int y = 0, x = 1;     if (m == 1) return 0;     while (a > 1) {       int q = a / m;       int t = m;       m = a % m, a = t;       t = y;       y = x - q * y;       x = t;     }     if (x < 0) x += m0;     return x;   }   void pairsort(int a[], int b[], int n) {     pair<int, int> pairt[n];     for (int i = 0; i < n; i++) {       pairt[i].first = a[i];       pairt[i].second = b[i];     }     sort(pairt, pairt + n);     for (int i = 0; i < n; i++) {       a[i] = pairt[i].first;       b[i] = pairt[i].second;     }   }   int logint(int x, int y) {     int ans = 0;     int a = 1;     for (int i = 0; i < x; i++) {       if (x <= a) {         return ans;       }       ans++;       a *= y;     }     return -1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int mink;     int k = 0;     int a[n];     for (int i = 0; i < n; i++) {       int t;       cin >> t;       a[i] = t;       if (i == 0)         mink = t;       else         mink = min(mink, t);     }     for (int i = 0; i < n; i++) {       int t = a[i];       if (t == mink) k++;     }     if (k > (n / 2)) {       cout <<  Bob ;     } else {       cout <<  Alice ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int visit[210000];   int ans[210000];   queue<int> q;   int a[210000];   int n;   vector<int> g[210000];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++) {       if (a[i] & 1) {         q.push(i);         visit[i] = 1;       }       if (i - a[i] >= 1) g[i - a[i]].push_back(i);       if (i + a[i] <= n) g[i + a[i]].push_back(i);     }     while (!q.empty()) {       int pos = q.front();       q.pop();       for (auto p : g[pos])         if (!visit[p]) {           q.push(p);           ans[p] = visit[p] = visit[pos] + 1;         }     }     memset((visit), (0), sizeof(visit));     for (int i = 1; i <= n; i++)       if (!(a[i] & 1)) {         q.push(i);         visit[i] = 1;       }     while (!q.empty()) {       int pos = q.front();       q.pop();       for (auto p : g[pos])         if (!visit[p]) {           q.push(p);           ans[p] = visit[p] = visit[pos] + 1;         }     }     for (int i = 1; i <= n; i++) cout << ans[i] - 1 <<    ;     return ~~(0 ^ 0 ^ 0);   }
#include <bits/stdc++.h>   using namespace std;   const int P = 998244353, INF = 0x3f3f3f3f;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long qpow(long long a, long long n) {     long long r = 1 % P;     for (a %= P; n; a = a * a % P, n >>= 1)       if (n & 1) r = r * a % P;     return r;   }   long long inv(long long first) {     return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;   }   inline int rd() {     int first = 0;     char p = getchar();     while (p <  0  || p >  9 ) p = getchar();     while (p >=  0  && p <=  9 ) first = first * 10 + p -  0 , p = getchar();     return first;   }   const int N = 1e6 + 10;   int n, m, a[N], w[N], s1, s0;   int in[N];   int dp[55][55][55];   int solve(int a, int w) {     memset(dp, 0, sizeof dp);     dp[0][0][0] = 1;     int ans = 0;     if (a) {       for (int i = 1; i <= m + 1; ++i)         for (int j = 0; j <= i - 1; ++j)           for (int k = 0; k <= j; ++k)             if (dp[i - 1][j][k]) {               int &r = dp[i - 1][j][k];               int now = w + k, tot = s1 + s0 + j - (i - 1 - j),                   p = (long long)now * in[tot] % P;               dp[i][j + 1][k + 1] = (dp[i][j + 1][k + 1] + (long long)p * r) % P;               now = s1 - w + j - k, p = (long long)now * in[tot] % P;               dp[i][j + 1][k] = (dp[i][j + 1][k] + (long long)p * r) % P;               now = s0 - (i - 1 - j), p = (long long)now * in[tot] % P;               dp[i][j][k] = (dp[i][j][k] + (long long)p * r) % P;               if (i - 1 == m) ans = (ans + (long long)(w + k) * r) % P;             }       return ans;     }     for (int i = 1; i <= m + 1; ++i)       for (int j = 0; j <= i - 1; ++j)         for (int k = 0; k <= min(w, j); ++k)           if (dp[i - 1][j][k]) {             int &r = dp[i - 1][j][k];             int now = w - k, tot = s0 + s1 - j + (i - 1 - j),                 p = (long long)now * in[tot] % P;             dp[i][j + 1][k + 1] = (dp[i][j + 1][k + 1] + (long long)p * r) % P;             now = s1 + (i - 1 - j), p = (long long)now * in[tot] % P;             dp[i][j][k] = (dp[i][j][k] + (long long)p * r) % P;             now = s0 - w - j + k, p = (long long)now * in[tot] % P;             dp[i][j + 1][k] = (dp[i][j + 1][k] + (long long)p * r) % P;             if (i - 1 == m) ans = (ans + (long long)(w - k) * r) % P;           }     return ans;   }   int main() {     in[0] = 1;     for (int i = 1; i <= N - 1; ++i) in[i] = inv(i);     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , a + i);     for (int i = 1; i <= n; ++i) {       scanf( %d , w + i);       if (a[i])         s1 += w[i];       else         s0 += w[i];     }     for (int i = 1; i <= n; ++i) printf( %d n , solve(a[i], w[i]));   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int num = 0;     char c = getchar();     if (c ==  - ) return -read();     while (c >=  0  && c <=  9 ) {       num = (num << 3) + (num << 1) + c -  0 ;       c = getchar();     }     return num;   }   inline long long READ() {     long long num = 0;     char c = getchar();     if (c ==  - ) return -READ();     while (c >=  0  && c <=  9 ) {       num = (num << 3) + (num << 1) + c -  0 ;       c = getchar();     }     return num;   }   struct prob {     long long ss, sl, ts, tl;     long double ps, psl, ptl;     void input() {       cin >> ss >> sl >> ts >> tl >> ps;       ps = 1 - ps;       psl = sl * ps;       ptl = tl * ps;     }   };   int n, t;   prob pr[1007];   inline bool cmp(const prob& a, const prob& b) {     return a.tl * (1 - a.ps) / a.ps < b.tl * (1 - b.ps) / b.ps;   }   inline bool eq(const long double& a, const long double& b) {     return a - b > -1e-16 && a - b < 1e-16;   }   inline bool sm(const long double& a, const long double& b) {     return a - b < -1e-16;   }   inline bool bg(const long double& a, const long double& b) {     return a - b > 1e-16;   }   long double dps[1007][1607], dpt[1007][1607];   int main() {     scanf( %d%d , &n, &t);     for (int i = 1; i <= n; i++) pr[i].input();     sort(pr + 1, pr + n + 1, cmp);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= t; j++) dps[i][j] = -((long long)0x7f7f7f7f7f7f7f7f);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= t; j++) dpt[i][j] = ((long long)0x7f7f7f7f7f7f7f7f);     long double ansa = -((long long)0x7f7f7f7f7f7f7f7f),                 ansb = ((long long)0x7f7f7f7f7f7f7f7f);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= t; j++) {         if (sm(dps[i][j], dps[i][j - 1]) ||             (eq(dps[i][j], dps[i][j - 1]) && bg(dpt[i][j], dpt[i][j - 1]))) {           dps[i][j] = dps[i][j - 1];           dpt[i][j] = dpt[i][j - 1];         }         if (j >= pr[i].ts + pr[i].tl) {           long double wls =               dps[i - 1][j - pr[i].ts - pr[i].tl] + pr[i].ss + pr[i].psl;           long double wlt =               (1 - pr[i].ps) * (dpt[i - 1][j - pr[i].ts - pr[i].tl] + pr[i].ts) +               pr[i].ps * j;           if (sm(dps[i][j], wls) || (eq(dps[i][j], wls) && bg(dpt[i][j], wlt))) {             dps[i][j] = wls;             dpt[i][j] = wlt;           }         }         if (j >= pr[i].ts) {           long double wls = dps[i - 1][j - pr[i].ts] + pr[i].ss;           long double wlt = dpt[i - 1][j - pr[i].ts] + pr[i].ts;           if (sm(dps[i][j], wls) || (eq(dps[i][j], wls) && bg(dpt[i][j], wlt))) {             dps[i][j] = wls;             dpt[i][j] = wlt;           }         }         if (sm(dps[i][j], dps[i - 1][j]) ||             (eq(dps[i][j], dps[i - 1][j]) && bg(dpt[i][j], dpt[i - 1][j]))) {           dps[i][j] = dps[i - 1][j];           dpt[i][j] = dpt[i - 1][j];         }         if (sm(ansa, dps[i][j]) || (eq(ansa, dps[i][j]) && bg(ansb, dpt[i][j]))) {           ansa = dps[i][j];           ansb = dpt[i][j];         }       }     return printf( %.15Lf %.15Lf n , ansa, ansb), 0;   }
#include <bits/stdc++.h>   using namespace std;   long long num[505];   int n;   long long minval = 0x3f3f3f3f3f3f3f3fll;   long long check(int x) {     long long ans = 0;     for (int i = 1; i <= n; i++) {       if (num[i] % x == 0) {         ans += num[i] / x;       } else {         if (num[i] % x + num[i] / x >= x - 1) {           ans += num[i] / x + 1;         } else {           return 0;         }       }     }     return ans;   }   void solve(int x) {     long long t = check(x);     if (t) {       printf( %I64d n , t);       exit(0);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %I64d , &num[i]);       minval = min(minval, num[i]);     }     long long t = (long long)sqrt(minval);     for (long long i = 1; i <= t; i++) {       solve(minval / i + 1);       solve(minval / i);       solve(minval / i - 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double tick() {     static clock_t oldt, newt = clock();     double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;     oldt = newt;     return diff;   }   inline long long int read() {     long long int f = 1, x = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   long long int fastExpo(long long int a, long long int n) {     long long int res = 1;     while (n) {       if (n % 2) res = res * a;       n /= 2;       a = a * a;     }     return res;   }   int dx[] = {-1, 0, 1, 0};   int dy[] = {0, 1, 0, -1};   vector<int> v[200010];   int col[200010];   vector<int> l, r;   void dfs(int n, int c) {     col[n] = c;     for (int j : v[n]) {       if (col[j] == -1) dfs(j, 1 - c);     }   }   int main() {     int t = read();     while (t--) {       int n = read(), m = read();       while (m--) {         int a, b;         cin >> a >> b;         v[a].push_back(b);         v[b].push_back(a);       }       for (int i = 1; i <= n; i++) col[i] = -1;       dfs(1, 0);       long long int c1 = 0, c2 = 0;       for (int i = 1; i <= n; i++) {         if (col[i])           c1++;         else           c2++;       }       if (c1 <= n / 2) {         cout << c1 << endl;         for (int i = 1; i <= n; i++)           if (col[i]) cout << i <<    ;       } else {         cout << c2 << endl;         for (int i = 1; i <= n; i++)           if (!col[i]) cout << i <<    ;       }       cout << endl;       for (int i = 1; i <= n; i++) v[i].clear(), col[i] = -1;     }     cerr <<  execution time is:   << tick() <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int a[100100];   int main() {     int i, n;     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     int sign = 1;     for (i = 0; i < n; i++) {       if (a[i] >= sign) {         a[i] = sign;         sign++;       }     }     printf( %d n , sign);     return 0;   }
#include<bits/stdc++.h>   typedef int LL;   typedef double dl;   #define opt operator   #define pb push_back   #define pii std::pair<LL,LL>   const LL maxn=2e4+9,mod=998244353,inf=0x3f3f3f3f;   LL Read(){    LL x(0),f(1); char c=getchar();    while(c< 0  || c> 9 ){     if(c== - ) f=-1; c=getchar();    }    while(c>= 0  && c<= 9 ){     x=(x<<3ll)+(x<<1ll)+c- 0 ; c=getchar();    }return x*f;   }   void Chkmin(LL &x,LL y){    if(y<x) x=y;   }   void Chkmax(LL &x,LL y){    if(y>x) x=y;   }   LL add(LL x,LL y){    return x+=y,x>=mod?x-mod:x;   }   LL dec(LL x,LL y){    return x-=y,x<0?x+mod:x;   }   LL mul(LL x,LL y){    return 1ll*x*y%mod;   }   LL Pow(LL base,LL b){    LL ret(1); while(b){     if(b&1) ret=mul(ret,base); base=mul(base,base); b>>=1;    }return ret;   }   const LL Ul=15,Ku=30;   namespace Rmq{    LL lg[maxn];    pii mx[maxn][16];    void Init(LL *A,LL N){     for(LL i=1;i<=N;++i){      mx[i][0]=pii(A[i],i);     }     for(LL i=1;i<=15;++i){      for(LL j=1;j+(1<<i)-1<=N;++j){       mx[j][i]=std::max(mx[j][i-1],mx[j+(1<<i-1)][i-1]);      }     }     for(LL i=1;i<=N;++i) lg[i]=lg[i>>1]+1;    }    LL Query(LL l,LL r){     LL len(lg[r-l+1]-1);     return std::max(mx[l][len],mx[r-(1<<len)+1][len]).second;    }   }   LL n,q;   LL a[maxn],f[16][maxn][31];   void Init(){    n=Read(); q=Read();    for(LL i=1;i<=n;++i){     a[i]=Read();    }    for(LL i=1;i<=n+1;++i){     a[i]+=i;    }   // for(LL i=1;i<=n;++i) printf( %d  ,a[i]-i); puts(  );    Rmq::Init(a,n+1);   // puts( #1 );    for(LL j=0;j<=Ul;++j){     for(LL k=0;k<=Ku;++k) f[j][n+1][k]=n+1;    }   // puts( #2 );    for(LL i=n;i>=1;--i){   //  printf( (%d) n ,i);     for(LL k=0;k<=Ku;++k){      f[0][i][k]=std::min(a[i]+k,n+1);     }     for(LL j=1;j<=Ul;++j){      for(LL k=0;k<=Ku;++k){       LL mx(0);       for(LL k1=k;k1>=0 && mx<n;--k1){        Chkmax(mx,f[j-1][Rmq::Query(i,f[j-1][i][k1])][k-k1]);       }       f[j][i][k]=mx;      }     }    }   }   void Solve(LL l,LL r,LL K){    static LL g[31];    if(l==r){     puts( 0 );     return;    }    Chkmin(K,r-l-1);    for(LL i=0;i<=Ku;++i){     g[i]=std::min(n+1,a[l]+i);    }    LL ret(1);    for(LL i=0;i<=K;++i) if(g[i]>=r){     puts( 1 );     return;    }    for(LL i=Ul;i>=0;--i){     LL flag(0);     static LL h[31];     for(LL k=K;k>=0;--k){      LL mx(0);      for(LL k1=0;k1<=k && mx<r;++k1){       Chkmax(mx,f[i][Rmq::Query(l,g[k1])][k-k1]);      }      h[k]=mx;      if(mx>=r){       flag=1; break;      }     }     if(!flag){      for(LL k=0;k<=Ku;++k) g[k]=h[k];      ret+=(1<<i);     }    }    printf( %d n ,ret+1);   // exit(0);   }   void Solve(){    while(q--){     LL l(Read()),r(Read()),K(Read());     Solve(l,r,K);    }   }   int main(){    Init();    Solve();    return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[1001];   long long b[2001];   int main() {     long long n, k, p;     cin >> n >> k >> p;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= k; i++) cin >> b[i];     sort(a + 1, a + n + 1);     sort(b + 1, b + k + 1);     long long ans = (long long)2e15 + 1;     for (int i = 1; i <= k - n + 1; i++) {       long long maks = 0;       for (int j = 1; j <= n; j++) {         maks = max(abs(a[j] - b[i + j - 1]) + abs(b[i + j - 1] - p), maks);       }       ans = min(maks, ans);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s1, s2, t1, t2;     char ch1, ch2;     cin >> s1 >> ch1 >> s2;     cin >> t1 >> ch2 >> t2;     int a = s1 - t1;     int b = s2 - t2;     if (b < 0) {       b += 60;       a--;     }     if (a < 0) {       a += 24;     }     cout << right << setw(2) << setfill( 0 ) << a <<  : ;     cout << right << setw(2) << setfill( 0 ) << b << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a;     cin >> n >> a;     int arr[n];     int sum = 0;     for (int i = 0; i < n; i++) {       cin >> arr[i];       sum += arr[i];     }     sum += (n - 1) * 10;     if (sum > a) {       cout << -1 << endl;     } else {       cout << (n - 1) * 2 + (a - sum) / 5 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000000 + 5;   vector<int> g[N];   bool used[N];   int n, m;   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d %d , &u, &v);       u--, v--;       g[u].push_back(v);     }     for (int i = 0; i < n; i++) {       if (!used[i]) {         for (auto x : g[i]) {           if (x > i) used[x] = true;         }       }     }     for (int i = n - 1; i >= 0; i--) {       if (!used[i]) {         for (auto x : g[i]) {           used[x] = true;         }       }     }     int ans = 0;     for (int i = 0; i < n; i++) {       if (!used[i]) ans++;     }     printf( %d n , ans);     for (int i = 0; i < n; i++) {       if (!used[i]) printf( %d  , i + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 500 + 5;   const int maxM = 100000 + 5;   inline long long read() {     long long sum = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       sum = sum * 10 + ch -  0 ;       ch = getchar();     }     return f * sum;   }   int dp[maxN][maxN];   char G[maxN][maxN];   const int dr[] = {1, 0};   const int dc[] = {0, 1};   int main() {     ios::sync_with_stdio(false);     int n = read(), m = read(), len = (n + m) / 2;     for (int i = 1; i <= n; i++) scanf( %s , G[i] + 1);     if (G[1][1] != G[n][m]) {       printf( 0 n );       return 0;     }     dp[1][n] = 1;     for (int k = 2; k <= len; k++) {       for (int i = k; i >= 1; i--) {         int x1 = i, y1 = 1 + k - x1;         if (x1 > n || y1 < 1 || y1 > m) continue;         for (int j = n - k + 1; j <= n; j++) {           int x2 = j, y2 = n + m - k - x2 + 1;           if (x2 < 1 || x2 > n || y2 < 1 || y2 > m)             continue;           else if (G[x1][y1] != G[x2][y2]) {             dp[x1][x2] = 0;             continue;           }           dp[x1][x2] = (dp[x1][x2] + dp[x1][x2 + 1]) % 1000000007;           dp[x1][x2] = (dp[x1][x2] + dp[x1 - 1][x2]) % 1000000007;           dp[x1][x2] = (dp[x1][x2] + dp[x1 - 1][x2 + 1]) % 1000000007;         }       }     }     int ans = 0;     if ((n + m) % 2 == 0) {       for (int x1 = 1; x1 <= len; x1++) {         int y1 = 1 + len - x1;         if (x1 >= 1 && x1 <= n && y1 >= 1 && y1 <= m)           ans = (ans + dp[x1][x1]) % 1000000007;       }     } else {       for (int x1 = 1; x1 <= len; x1++) {         int y1 = 1 + len - x1;         if (x1 < 1 || x1 > n || y1 < 1 || y1 > m) continue;         if (y1 + 1 <= m) ans = (ans + dp[x1][x1]) % 1000000007;         if (x1 + 1 <= n) ans = (ans + dp[x1][x1 + 1]) % 1000000007;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     long int n, s, sum = 0, z, count = 0;     scanf( %ld%ld , &n, &s);     z = s;     do {       if (s >= n) {         sum = sum + (s / n) * n;         count = count + (s / n);         s = s - (s / n) * n;       } else         n = n - 1;     } while (s != 0 && n != 0);     printf( %ld , count);     return 0;   }
#include <bits/stdc++.h>   const double EPS = 0.00000001;   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     int32_t t;     std::cin >> t;     for (int32_t cs = 1; cs <= t; cs++) {       int32_t n, l;       std::cin >> n >> l;       std::vector<int32_t> a(n);       for (auto &x : a) {         std::cin >> x;       }       int32_t indL = 0, indR = n - 1, speed1 = 1, speed2 = 1;       double pos1 = 0, pos2 = l;       double currT = 0.0, ans;       while (1) {         if (indL > indR) {           ans = currT + (pos2 - pos1) / (speed1 + speed2);           break;         }         double t1 = ((double)a[indL] - pos1) / speed1;         double t2 = ((double)pos2 - a[indR]) / speed2;         if (indL == indR) {           if (fabs(t1 - t2) < EPS) {             ans = currT + t1;             break;           }         }         if (t1 < t2) {           indL++;           currT += t1;           speed1++;           pos1 = a[indL - 1];           pos2 -= t1 * speed2;         } else {           indR--;           currT += t2;           speed2++;           pos1 += t2 * speed1;           pos2 = a[indR + 1];         }       }       std::cout << std::fixed << std::setprecision(8);       std::cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {}   const long long maxn = 1050;   long long n, a, b;   long long ans[maxn][maxn];   void no() {     cout <<  NO  <<   n ;     exit(0);   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> a >> b;     if (min(a, b) > 1) no();     if ((n == 2 or n == 3) and a == 1 and b == 1) no();     long long c = 1, d = 0;     if (b != 1) {       swap(a, b);       swap(c, d);     }     for (long long i = 1; i <= n; i++) {       ans[i][i] = 0;       for (long long j = 1; j <= n; j++) {         if (i != j) {           ans[i][j] = ans[j][i] = d;         }       }     }     for (long long i = a; i + 1 <= n; i++) {       ans[i][i + 1] = ans[i + 1][i] = c;     }     cout <<  YES  <<   n ;     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= n; j++) {         cout << ans[i][j];       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, n;     int a, b, c;     int sum_a, sum_b, sum_c;     sum_a = 0;     sum_b = 0;     sum_c = 0;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a >> b >> c;       sum_a = sum_a + a;       sum_b = sum_b + b;       sum_c = sum_c + c;     }     if (sum_a == 0 && sum_b == 0 && sum_c == 0) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }     return 0;   }