malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long dx[] = {1, 0, -1, 0};   long long dy[] = {0, 1, 0, -1};   long long gcd(long long x, long long y) {     if (y == 0)       return x;     else       return gcd(y, x % y);   }   long long expo(long long n, long long m, long long p) {     long long r = 1;     n = n % p;     while (m > 0) {       if (m % 2) r = (r * n) % p;       n = (n * n) % p;       m = m / 2;     }     return r % p;   }   bool isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n;     cin >> n;     map<double, long long> p;     vector<string> v(n);     for (long long j = 0; j < n; j++) {       string s;       cin >> s;       v[j] = s;       long long a = 0, b = 0, c = 0;       long long i = 1;       while (s[i] !=  + ) {         a = a * 10 + s[i] -  0 ;         i++;       }       i++;       while (s[i] !=  ) ) {         b = b * 10 + s[i] -  0 ;         i++;       }       i++;       i++;       while (i != s.size()) {         c = c * 10 + s[i] -  0 ;         i++;       }       double aa = (a * 1.0 + b) / c;       p[aa]++;     }     for (long long j = 0; j < n; j++) {       string s = v[j];       long long a = 0, b = 0, c = 0;       long long i = 1;       while (s[i] !=  + ) {         a = a * 10 + s[i] -  0 ;         i++;       }       i++;       while (s[i] !=  ) ) {         b = b * 10 + s[i] -  0 ;         i++;       }       i++;       i++;       while (i != s.size()) {         c = c * 10 + s[i] -  0 ;         i++;       }       double aa = (a * 1.0 + b) / c;       cout << p[aa] <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;       mt19937_64 rng(time(0));   const long double eps = 1e-15;   #define rep(i, a, b) for(int i = a; i < (b); ++i)   #define trav(a, x) for(auto& a : x)   #define all(x) x.begin(), x.end()   #define sz(x) (int)(x).size()   typedef long long ll;   typedef pair<int, int> pii;   typedef pair<ll,ll> pll;   typedef vector<int> vi;   const int mn=300+10;   const ll mod=1e9+7;      ll po(ll a,ll b=mod-2){    ll ans=1;    for(;b;b>>=1,a*=a,a%=mod)if(b&1)ans*=a,ans%=mod;    return ans;   }      ll c[mn],b[mn];   ll ans[mn*2];   ll dp[2][10100];      int main() {    cin.tie(0);    cin.sync_with_stdio(0);    int n;    cin>>n;    for(int i=0;i<n;i++)cin>>c[i];    for(int i=1;i<n;i++)cin>>b[i],b[i]+=b[i-1];    for(int i=1;i<n;i++)b[i]+=b[i-1];    int ma=INT_MAX,mi=INT_MAX,sa=0,si=0;    for(int i=0;i<n;i++){     sa+=c[i];     si+=0;     ma=min(ll(ma),(sa-b[i])/(i+1)+1);     mi=min(ll(mi),(si-b[i])/(i+1)-1);    }    //cerr<<mi<<   <<ma<<endl;        for(int m=mi;m<=ma;m++){     memset(dp,0,sizeof(dp));     dp[0][0]=1;     for(int i=0;i<n;i++){      ll lim = m*(i+1)+b[i];      //cerr<<lim<<endl;      for(int j=1;j<10100;j++)dp[0][j]+=dp[0][j-1],dp[0][j]%=mod;      for(int j=0;j<10100;j++){       dp[1][j]=(dp[0][j]-((j>=c[i]+1)?dp[0][j-c[i]-1]:0))%mod;      }      for(int j=0;j<min(lim,ll(10100));j++)dp[1][j]=0;      memcpy(dp[0],dp[1],sizeof(dp[0]));      memset(dp[1],0,sizeof(dp[1]));     }     for(int i=0;i<10100;i++)ans[m-mi]+=dp[0][i],ans[m-mi]%=mod;     if(ans[m-mi]<0)ans[m-mi]+=mod;    }    int q;    cin>>q;    ll aa=1;    for(int i=0;i<n;i++)aa*=c[i]+1,aa%=mod;    for(int i=0;i<q;i++){     ll x;     cin>>x;     if(x<mi){      printf( %lld n ,aa);     }     else if(x>ma)printf( 0 n );     else printf( %lld n ,ans[x-mi]);    }   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   int main() {     long long s = 0;     cin >> n >> k;     for (int i = 0; i < n; i++) {       int a, b;       cin >> a >> b;       s += b - a + 1;     }     s %= k;     if (s) s = k - s;     cout << s << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 9;   const int MAXN = 3e5 + 1;   int l[MAXN], r[MAXN];   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> v(n);       for (int i = (int)(0); i < (int)(n); ++i) {         l[i] = INF;         r[i] = -INF;       }       for (int i = (int)(0); i < (int)(n); ++i) {         cin >> v[i];         --v[i];         l[v[i]] = min(l[v[i]], i);         r[v[i]] = max(r[v[i]], i);       }       sort(v.begin(), v.end());       v.erase(unique(v.begin(), v.end()), v.end());       vector<int> dp(n, 0);       int ans = n;       for (int i = 0; i < v.size(); ++i) {         if (!i || l[v[i]] <= r[v[i - 1]])           dp[i] = 1;         else           dp[i] = dp[i - 1] + 1;         ans = min(ans, (int)(v.size() - dp[i]));       }       cout << ans <<   n ;     }     return 0;   }
#include<iostream>   #include<map>   #include<cstring>   #include<cmath>   #include<algorithm>   #include <queue>   #include<map>   using namespace std;   typedef long long ll;   inline ll gcd(ll a,ll b) {       return b>0 ? gcd(b,a%b):a;   }   int main()   {    ll T,m1,m,k,a,b;    cin>>T;    while(T--){     int a[30]={0},n;     cin>>n;     string str;     cin>>str;     int num=-1,f=1;     for(int i=0;i<str.length();i++){      int tmp=str[i]- A ;      if(tmp!=num)      {       if(a[tmp])       f=0;       else       {        num=tmp;        a[tmp]++;       }       }     }     if(f)     cout<< YES n ;     else     cout<< NO n ;    }    }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, c, ans[4010];     scanf( %d %d %d %d , &n, &a, &b, &c);     memset(ans, -1, sizeof(ans));     ans[0] = 0;     for (int i = 0; i <= n; i++) {       if (i >= a && ans[i - a] != -1) ans[i] = ans[i - a] + 1;       if (i >= b && ans[i - b] != -1) ans[i] = max(ans[i], ans[i - b] + 1);       if (i >= c && ans[i - c] != -1) ans[i] = max(ans[i], ans[i - c] + 1);     }     printf( %d n , ans[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int M = 1e18 + 7;   const long long int mod = 1e9 + 7;   const long long int infi = LLONG_MAX;   long long int i, j, ans, k, n, x, y, m, mymax = LLONG_MIN, mymin = LLONG_MAX, b,                                           c, z, sum;   int main() {     long long int x1, x2, s, p, t1, t2, d;     scanf( %lld %lld %lld , &s, &x1, &x2);     scanf( %lld %lld , &t1, &t2);     scanf( %lld %lld , &p, &d);     if (x2 < x1) {       ans = (x1 - x2) * t2;       if (d == 1) {         if (p <= x2) {           ans = min(ans, (2 * s - x2 - p) * t1);         } else if (p > x2 && p <= x1) {           ans = min(ans, (2 * s - x2 - p) * t1);         } else {           ans = min(ans, (2 * s - p - x2) * t1);         }       } else {         if (p < x2) {           ans = min(ans, (2 * s - x2 + p) * t1);         } else if (p >= x2 && p < x1) {           ans = min(ans, (2 * s - x2 + p) * t1);         } else {           ans = min(ans, (p - x2) * t1);         }       }       printf( %lld n , ans);       return 0;     }     ans = (x2 - x1) * t2;     if (d == 1) {       if (p <= x1) {         ans = min(ans, (x2 - p) * t1);       } else if (p > x1 && p <= x2) {         ans = min(ans, (2 * s + x2 - p) * t1);       } else {         ans = min(ans, (2 * s - p + x2) * t1);       }     } else {       if (p < min(x1, x2)) {         ans = min(ans, (x2 + p) * t1);       } else if (p >= x1 && p <= x2) {         ans = min(ans, (p + x2) * t1);       } else {         ans = min(ans, (p + x2) * t1);       }     }     printf( %lld n , ans);     return 0;   }
#include <iostream>   #include <algorithm>   #include <vector>   #include <string>   #include <set>   // #include <stdlib.h>   // #include <stdio.h>   // #include <ctype.h>      using namespace std;      int main(void){          int n = 0;       cin >> n;       for(; n > 0; n--){           int num;           cin >> num;           int input, last = -1;           int count = 1, max = 1;           if(num == 0){               cout <<  0  << endl;               continue;           }           for(; num > 0; num--){               cin >> input;               if(input == last){                   count++;                   if(count > max){                       max = count;                   }               }               else{                   count = 1;               }               last = input;           }           cout << max << endl;                     }             return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 20;   const int maxn = (1 << maxN) + 20;   int t[maxn], r[maxn][maxN + 3], x[maxn][maxN + 3];   string s[maxN];   void cal(int n, int k) {     if (!n) return;     cal(n - 1, k);     cal(n - 1, k + (1 << (n - 1)));     for (int i = 0; i < (1 << n); i++)       for (int j = 0; j <= n; j++) x[k + i][j] = r[k + i][j];     for (int i = 0; i < (1 << (n - 1)); i++)       for (int j = 1; j <= n; j++) {         r[k + i][j] += x[k + i + (1 << (n - 1))][j - 1];         r[k + i + (1 << (n - 1))][j] += x[k + i][j - 1];       }   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < m; i++) {       for (int j = 0; j < n; j++) t[i] = (t[i] * 2 + (s[j][i] ==  1 ));       r[t[i]][0]++;     }     cal(n, 0);     int ans = 1e9;     for (int mask = 0; mask < (1 << n); mask++) {       int res = 0;       for (int j = 0; j <= n; j++) res += r[mask][j] * min(j, n - j);       ans = min(ans, res);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int n, bar;     vector<int> choco;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> bar;       choco.push_back(bar);     }     if (n == 1)       cout <<  1 0 n ;     else {       auto l = choco.begin();       auto r = choco.end() - 1;       int diff = 0;       int l_count = 0;       int r_count = 0;       while (true) {         if ((l + 1) == r) {           ++l_count;           ++r_count;           break;         }         diff = (*l) - (*r);         if (diff < 0) {           (*r) -= (*l);           ++l_count;           ++l;         } else if (diff > 0) {           (*l) -= (*r);           ++r_count;           --r;         } else {           ++l_count;           (*l) = 0;           if ((l + 2) == r)             ++l;           else {             ++r_count;             (*r) = 0;             ++l;             --r;           }         }       }       cout << l_count <<     << r_count <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   int f[1 << 23], pre[1 << 23], zt[1 << 23], tot, ans[23];   int n, fn[23], fri[23][23];   int tans[23], Ans[23][23];   void Solve(int o) {     int ni, st = 1 << (o - 1), ed = (1 << n) - 1;     for (int i = (1); i <= (int)(fn[o]); ++i) st |= 1 << (fri[o][i] - 1);     memset(f, oo, sizeof(f));     f[st] = 1;     for (int i = (st); i <= (int)(ed); ++i) {       if (f[i] == oo) continue;       for (int j = (1); j <= (int)(n); ++j)         if (i & (1 << (j - 1))) {           ni = i;           for (int k = (1); k <= (int)(fn[j]); ++k) ni |= 1 << (fri[j][k] - 1);           if (f[ni] > f[i] + 1) {             f[ni] = f[i] + 1;             pre[ni] = i;             zt[ni] = j;           }         }     }     int now = ed, tp = 0;     while (now != st) {       ans[++tp] = zt[now];       now = pre[now];     }     Ans[o][tans[o] = 1] = o;     while (tp) Ans[o][++tans[o]] = ans[tp--];   }   int main() {     int m, u, v;     scanf( %d%d , &n, &m);     if (m == n * (n - 1) / 2) {       puts( 0 );       puts(  );       return 0;     }     int mx = 0;     for (int i = (1); i <= (int)(m); ++i) {       scanf( %d%d , &u, &v);       fri[u][++fn[u]] = v;       fri[v][++fn[v]] = u;       mx = max(mx, max(fn[u], fn[v]));     }     int mn = n + 1, id;     for (int i = (1); i <= (int)(n); ++i) {       Solve(i);       if (fn[i] < mx - 6) continue;       if (tans[i] < mn) mn = tans[i], id = i;     }     printf( %d n , tans[id]);     for (int i = (1); i <= (int)(tans[id]); ++i)       printf( %d%c , Ans[id][i], i == tans[id] ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, m, q;   long long int gcd(long long int t, long long int u) {     if (u == 0) {       return t;     }     return gcd(u, t % u);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m >> q;     long long int gcd_nm = gcd(n, m);     long long int a, b;     a = n / gcd_nm;     b = m / gcd_nm;     for (int i = 1; i <= q; i++) {       long long int sx, sy, ex, ey;       cin >> sx >> sy >> ex >> ey;       sy--;       ey--;       if (sx == 1) {         sy /= a;       } else {         sy /= b;       }       if (ex == 1) {         ey /= a;       } else {         ey /= b;       }       if (sy == ey) {         cout <<  YES  << endl;       } else {         cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int sz = 105;   long long int r[sz], a[sz][sz], b[sz][sz], ans[sz][sz], m;   void multiply(long long int a[][sz], long long int b[][sz]) {     for (int i = 0; i < m; i++) {       for (int j = 0; j < m; j++) {         ans[i][j] = 0;         for (int k = 0; k < m; k++) {           ans[i][j] += a[i][k] * b[k][j] % 1000000007;           ans[i][j] %= 1000000007;         }       }     }     for (int i = 0; i < m; i++) {       for (int j = 0; j < m; j++) {         a[i][j] = ans[i][j];       }     }   }   void power(long long int a[][sz], long long int n) {     if (n <= 1) {       return;     }     power(a, n / 2);     multiply(a, a);     if (n % 2 == 1) {       multiply(a, b);     }   }   int main() {     long long int n;     cin >> n >> m;     r[0] = 1;     for (int i = 1; i <= m; i++) {       r[i] = r[i - 1];       if (i - m >= 0) {         r[i] += r[i - m];       }       r[i] %= 1000000007;     }     for (int i = 1; i < m; i++) {       a[i][i - 1] = b[i][i - 1] = 1;     }     a[0][m - 1] = b[0][m - 1] = 1;     a[m - 1][m - 1] = b[m - 1][m - 1] = 1;     power(a, n);     long long int res = 0;     for (int k = 0; k < m; k++) {       res += r[k] * a[k][0] % 1000000007;       res %= 1000000007;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int A1, A2, A3, A4;   int main() {     int i;     scanf( %d%d%d%d , &A1, &A2, &A3, &A4);     if (abs(A3 - A4) > 1)       printf( -1 );     else {       if (A3 == A4) {         if ((((A1) > (A2) ? (A1) : (A2)) - A3 - 1 < 0) ||             (((A1) < (A2) ? (A1) : (A2)) < A3))           printf( -1 );         else {           if (A1 - A3 - 1 < 0) {             for (i = 1; i <= A3; ++i) printf( 74 );             for (i = A2 - A3; i >= 1; --i) printf( 7 );           } else {             for (i = A1 - A3 - 1; i >= 1; --i) printf( 4 );             for (i = 1; i <= A3; ++i) printf( 47 );             for (i = A2 - A3; i >= 1; --i) printf( 7 );             printf( 4 );           }         }       } else {         if (A3 > A4) {           if ((A1 - A3 < 0) || (A2 - A3 < 0))             printf( -1 );           else {             for (i = A1 - A3; i >= 1; --i) printf( 4 );             for (i = 1; i <= A3; ++i) printf( 47 );             for (i = A2 - A3; i >= 1; --i) printf( 7 );           }         } else {           if ((A1 - A3 - 1 < 0) || (A4 - 2 < 0) || (A2 - A3 < 0))             printf( -1 );           else {             printf( 74 );             for (i = A1 - A3 - 1; i >= 1; --i) printf( 4 );             for (i = A4 - 2; i >= 1; --i) printf( 74 );             for (i = A2 - A3; i >= 1; --i) printf( 7 );             printf( 4 );           }         }       }     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long modexpo(long long x, long long p) {     long long res = 1;     x = x % 1000000007;     while (p) {       if (p % 2) res = res * x;       p >>= 1;       x = x * x % 1000000007;       res %= 1000000007;     }     return res;   }   long long max(long long a, long long b) { return (a > b ? a : b); }   long long min(long long a, long long b) { return (a < b ? a : b); }   struct edge {     long long u, v, w;     edge(long long a, long long b, long long c) {       u = a;       v = b;       w = c;     }   };   struct compare {     bool operator()(const edge a, const edge b) const {       if (a.u == b.u) {         if (a.v == b.v) {           return a.w < b.w;         }         return a.v < b.v;       }       return a.u < b.u;     }   };   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) {       long long l, r, d;       cin >> l >> r >> d;       if (d < l) {         cout << d <<   n ;       } else if (r % d == 0) {         cout << r + d <<   n ;       } else {         long long x = ceil((long double)r / (long double)d);         cout << x * d <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int Comb[2015][2015], Fact[2015], used[2015], a[2015];   int main() {     cin.sync_with_stdio(false);     int n, m = 0, k = 0;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       if (a[i] != -1) used[a[i]] = 1;     }     Fact[0] = 1;     for (int i = 1; i <= n; ++i) {       if (used[i] == 0) {         ++m;         if (a[i] == -1) ++k;       }       Fact[i] = 1LL * Fact[i - 1] * i % MOD;     }     for (int i = 0; i <= n; ++i) {       Comb[i][0] = 1;       for (int j = 1; j <= i; ++j)         Comb[i][j] = (Comb[i - 1][j] + Comb[i - 1][j - 1]) % MOD;     }     int sol = 0;     for (int i = 1; i <= k; ++i) {       int x = (1LL * Comb[k][i] * Fact[m - i]) % MOD;       if (i & 1)         sol = (sol + x) % MOD;       else         sol = (0LL + sol + MOD - x) % MOD;     }     cout << (0LL + Fact[m] + MOD - sol) % MOD;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int r, g, b;     cin >> r >> g >> b;     int ans = 0;     ans = r / 3 + g / 3 + b / 3;     if (min(r, min(g, b)) >= 1)       ans = max(ans, (r - 1) / 3 + (g - 1) / 3 + (b - 1) / 3 + 1);     if (min(r, min(g, b)) >= 2)       ans = max(ans, (r - 2) / 3 + (g - 2) / 3 + (b - 2) / 3 + 2);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   constexpr long double pi{3.1415926535897932384};   constexpr long long mod{1000000007};   long long power(long long x, long long y) {     long long res = 1;     x = x % mod;     while (y > 0) {       if (y & 1) res = (res * x) % mod;       y = y >> 1;       x = (x * x) % mod;     }     return res;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }   pair<long long, long long> v[3001];   long long n, dp[3001][3001];   const long long INF = 1000000000000000;   long long getAns(long long pos, long long pre) {     if (pos > n) return 0;     if (dp[pos][pre] != -INF) return dp[pos][pre];     long long x = v[pos].second + getAns(pos + 1, pos);     long long y = v[pos].first - v[pre].first + getAns(pos + 1, pre);     return dp[pos][pre] = min(x, y);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> v[i].first >> v[i].second;     }     sort(v + 1, v + n + 1);     for (long long i = 0; i <= n; i++) {       for (long long j = 0; j <= n; j++) {         dp[i][j] = -INF;       }     }     long long ans = getAns(2, 1) + v[1].second;     cout << ans <<   n ;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long   #define endl   n    const unsigned int mod = 1000000007;               int main(){        ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);        bool prime[1000001];    memset(prime, true, sizeof(prime));         for(int p=2; p*p<=1000000; p++) {            // If prime[p] is not changed, then it is a prime            if (prime[p] == true)            {                  for (int i=p*p; i<=1000000; i += p)                    prime[i] = false;            }    }           ll t;     cin>>t;     while(t--){       int a;       cin>>a;       int ans = 1;       for(int i=a+1;i<1000001;i++){         if (prime[i]){           ans*=i;break;         }       }       for(int i=ans+a;i<1000001;i++){         if (prime[i]){           ans*=i;break;         }       }       cout<<ans<<endl;     }           return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void print_container(ostream& os, const T& c) {     const char* _s =    ;     if (!c.empty()) {       __typeof__(c.begin()) last = --c.end();       for (__typeof__((c).begin()) it = (c).begin(); it != (c).end(); ++it) {         os << *it;         if (it != last) os << _s;       }     }   }   template <typename T>   ostream& operator<<(ostream& os, const vector<T>& c) {     print_container(os, c);     return os;   }   template <typename T>   ostream& operator<<(ostream& os, const set<T>& c) {     print_container(os, c);     return os;   }   template <typename T>   ostream& operator<<(ostream& os, const multiset<T>& c) {     print_container(os, c);     return os;   }   template <typename T>   ostream& operator<<(ostream& os, const deque<T>& c) {     print_container(os, c);     return os;   }   template <typename T, typename U>   ostream& operator<<(ostream& os, const map<T, U>& c) {     print_container(os, c);     return os;   }   template <typename T, typename U>   ostream& operator<<(ostream& os, const pair<T, U>& p) {     os <<  (  << p.first <<  ,   << p.second <<  ) ;     return os;   }   template <typename T>   void print(T a, int n, const string& split =    ) {     for (int i = 0; i < n; i++) {       cout << a[i];       if (i + 1 != n) cout << split;     }     cout << endl;   }   template <typename T>   void print2d(T a, int w, int h, int width = -1, int br = 0) {     for (int i = 0; i < h; ++i) {       for (int j = 0; j < w; ++j) {         if (width != -1) cout.width(width);         cout << a[i][j] <<    ;       }       cout << endl;     }     while (br--) cout << endl;   }   template <typename T>   void input(T& a, int n) {     for (int i = 0; i < n; ++i) cin >> a[i];   }   template <typename T, typename U>   void upmin(T& a, const U& b) {     a = min<T>(a, b);   }   template <typename T, typename U>   void upmax(T& a, const U& b) {     a = max<T>(a, b);   }   template <typename T>   void uniq(T& a) {     sort(a.begin(), a.end());     a.erase(unique(a.begin(), a.end()), a.end());   }   template <class T>   string to_s(const T& a) {     ostringstream os;     os << a;     return os.str();   }   template <class T>   T to_T(const string& s) {     istringstream is(s);     T res;     is >> res;     return res;   }   void fast_io() {     cin.tie(0);     ios::sync_with_stdio(false);   }   bool in_rect(int x, int y, int w, int h) {     return 0 <= x && x < w && 0 <= y && y < h;   }   const int dx[] = {0, 1, 0, -1};   const int dy[] = {1, 0, -1, 0};   int main() {     int n;     cin >> n;     int c[6666] = {};     for (int i = 0; i < (int)(n); ++i) {       int a;       cin >> a;       ++c[a];     }     int res = 0;     for (int i = 0; i < (int)(6600); ++i) {       if (c[i] > 1) {         res += c[i] - 1;         c[i + 1] += c[i] - 1;       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const int N = 200500;   void solve() {     long long n, k;     cin >> n >> k;     if ((n + k) % 2 == 0 && n >= k && (n + k) / 2 >= (k * (k + 1)) / 2) {       cout <<  YES n ;     } else       cout <<  NO n ;   }   int main() {     ios::sync_with_stdio(false);     int q = 1;     cin >> q;     for (int i = 1; i <= q; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     int count = 1;     a[0] = 0;     a[1] = 2;     for (int i = 2; i < n; i++) {       count++;       a[i] = a[i - 1] + count;       if (a[i] > n) {         int rem = a[i] - n;         a[i] = a[0] + rem;       }     }     for (int i = 1; i < n; i++) cout << a[i] <<    ;     return 0;   }