malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T>   T abs(T x) {     if (x < 0) return -x;     return x;   }   template <class T>   T sqr(T a) {     return a * a;   }   const double pi = acos(-1.0);   const double eps = 1e-8;   char str1[2000010];   char str2[2000010];   int main() {     int cross, cnt1, cnt2, sum1, sum2, n, f, i;     while (1 == scanf( %d , &n)) {       cnt1 = cnt2 = sum1 = sum2 = cross = 0;       scanf( %s%s , str1, str2);       for (i = 0; i < 2 * n; i++) {         if (str1[i] ==  1  && str2[i] ==  1 )           cross++;         else if (str1[i] ==  1 )           cnt1++;         else if (str2[i] ==  1 )           cnt2++;       }       f = 1;       while (cross) {         if (f)           sum1++, f = 0;         else           sum2++, f = 1;         cross--;       }       if ((cnt1 == 0 && cnt2 == 0 && cross == 0) || (cross == 2 * n) ||           (cross % 2 == 0 && cnt1 == 0 && cnt2 == 0))         printf( Draw n );       else if (cnt2 == 0 && sum1 + cnt1 - 1 == sum2 && cnt1 != 1)         printf( Draw n );       else if (sum2 + cnt2 - 1 == sum1 + cnt1 || sum2 + cnt2 == sum1 + cnt1)         printf( Draw n );       else if (sum1 + cnt1 > sum2 + cnt2)         printf( First n );       else         printf( Second n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ii = int;   int main() {     ii n, i;     cin >> n;     ii* ar = (ii*)malloc(sizeof(ii) * n);     for (i = 0; i < n; i++) {       cin >> ar[i];     }     ii max = *max_element(ar, ar + n);     if (n == 1)       cout << max - max << endl;     else {       ii count = 0;       for (i = 0; i < n; i++) {         count = count + max - ar[i];       }       cout << count << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<int> balance(n, 0);     for (int i = 0; i < m; i++) {       int a, b, c;       cin >> a >> b >> c;       balance[a - 1] -= c;       balance[b - 1] += c;     }     int total = 0;     for (int i = 0; i < n; i++) {       total += balance[i] > 0 ? balance[i] : 0;     }     cout << total << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char ch = getchar();     int x = 0, f = 1;     while (ch <  0  || ch >  9 ) f = ch ==  -  ? -1 : 1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   inline int sqr(int x) { return x * x; }   inline int dis(int x1, int y1, int x2, int y2) {     return sqr(x2 - x1) + sqr(y2 - y1);   }   const int N = 24, MAXN = N + 10;   int xo, yo;   int x[MAXN], y[MAXN];   int dp[1 << N], pre[1 << N], w[MAXN][MAXN];   int main(int argc, char *argv[]) {     ios::sync_with_stdio(false);     cin.tie(0);     xo = read(), yo = read();     int n = read(), msk = (1 << n) - 1;     for (int i = (0); i <= (n - 1); i += (1)) x[i] = read(), y[i] = read();     x[n] = xo, y[n] = yo;     for (int i = (0); i <= (n); i += (1))       for (int j = (i + 1); j <= (n); j += (1))         w[i][j] = w[j][i] = dis(x[i], y[i], x[j], y[j]);     memset(dp, 0x3f, sizeof(dp));     dp[0] = 0;     for (int s = (0); s <= (msk); s += (1))       if (dp[s] != 0x3f3f3f3f)         for (int i = (0); i <= (n - 1); i += (1))           if (((s >> i) & 1) == 0) {             int k = s | (1 << i);             if (dp[s] + w[n][i] + w[i][n] < dp[k])               dp[k] = dp[s] + w[n][i] + w[i][n], pre[k] = s;             for (int j = (i + 1); j <= (n - 1); j += (1))               if (((k >> j) & 1) == 0) {                 int l = k | (1 << j);                 if (dp[s] + w[n][i] + w[i][j] + w[j][n] < dp[l])                   dp[l] = dp[s] + w[n][i] + w[i][j] + w[j][n], pre[l] = s;               }             break;           }     printf( %d n , dp[msk]);     printf( 0  );     for (int x = msk; x; x = pre[x]) {       for (int i = (0); i <= (n - 1); i += (1))         if (((x ^ pre[x]) >> i) & 1) printf( %d  , i + 1);       printf( 0  );     }     putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   const double eps = 1e-12;   const int maxn = 1e5 + 5;   const int INF = 1e9;   long long n, m;   long long ma = 0, mi = 0;   void pre() {     for (int i = 0; i < n; i++) ma += i;     if (n & 1) {       mi = n / 2 * (n / 2 + 1);     } else {       mi = n / 2 * n / 2;     }   }   int main() {     long long ans = 0, x, d;     scanf( %lld%lld , &n, &m);     pre();     for (int i = 0; i < m; i++) {       scanf( %lld %lld , &x, &d);       if (d < 0) {         ans += x * n + d * mi;       } else {         ans += x * n + d * ma;       }     }     printf( %lf n , (double)1.0 * ans / n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int K = 30;   const int MOD = 1e9 + 7;   long long n, power[K + 1];   int k;   __inline void add(int &a, int b) {     if ((a += b) >= MOD) {       a -= MOD;     }   }   struct Matrix {     int trans[K][K];     int go[K];     Matrix() {       memset(trans, 0, sizeof(trans));       memset(go, 0, sizeof(go));     }     int all() {       int result = 0;       for (int i = 0; i < k; i++) {         add(result, go[i]);         for (int j = 0; j < k; j++) {           add(result, trans[i][j]);         }       }       return result;     }   };   map<long long, Matrix> mp;   Matrix search(long long n) {     if (mp.count(n)) {       return mp[n];     }     Matrix ret;     if (k >= n) {       for (int i = 0; i < n; i++) {         ret.go[i] = 0;         ret.trans[i][i] = 1;         for (int j = i + 1; j < n; j++) {           ret.trans[i][j] = power[j - i - 1];         }       }       return ret;     }     long long unit = 1;     int length = 1;     while (unit <= n / k && unit * k < n) {       unit *= k;       length++;     }     Matrix base = search(unit);     ret = base;     long long remaind = n % unit;     Matrix extra = search(remaind);     static int reach[K][K], _reach[K][K];     for (int i = 0; i < k; i++) {       ret.go[i] = base.go[i];       for (int j = 0; j < k; j++) {         reach[i][j] = base.trans[i][j];       }     }     for (int i = 1; i <= n / unit; i++) {       if (i == n / unit && remaind == 0) {         break;       }       Matrix &nxt = (i < n / unit) ? base : extra;       int lead = i;       for (int j = 0; j < k; j++) {         for (int l = 0; l < k; l++) {           _reach[j][l] = reach[j][l];           add(ret.go[j], reach[j][l]);           reach[j][l] = 0;         }       }       int t = ((k - 1) * (length - 2) + i - 1) % k;       for (int start = 0; start < k; start++) {         int sum = 0;         for (int prev = k - 1; prev >= 0; prev--) {           int pv = (prev + t) % k;           add(sum, _reach[start][pv]);           int succ = prev;           int sv = (succ + t) % k, temp = ((sv - i) % k + k) % k;           add(ret.go[start], 1LL * sum * nxt.go[temp] % MOD);           for (int end = 0; end < k; end++) {             add(reach[start][end],                 1LL * sum * nxt.trans[temp][((end - i) % k + k) % k] % MOD);           }         }       }       for (int i = 0; i < k; i++) {         for (int j = 0; j < k; j++) {           ret.trans[i][j] = reach[i][j];         }       }     }     return mp[n] = ret;   }   int main() {     power[0] = 1;     for (int i = 1; i <= K; i++) {       power[i] = power[i - 1] * 2;     }     cin >> n >> k;     Matrix answer = search(n);     cout << (answer.all() + 1) % MOD << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10;   int n;   int a[N], sum[N], b[65][N], cnt[65];   long long ans;   int t[2];   long long find(int l, int r, int lim) {     int i, j;     long long ret = 0;     if (l > r) return 0;     j = l - 1;     t[0] = t[1] = 0;     for (i = l; i <= r; ++i) {       while (sum[i] - sum[j] >= lim) {         ++t[sum[j] & 1];         ++j;       }       ret += (long long)t[sum[i] & 1];     }     return ret;   }   void dfs(int l, int r, int mx) {     if (r - l - 1 < 1) return;     if (!mx) return;     int i, tmx = 0;     cnt[mx] = 1;     b[mx][cnt[mx]] = l;     for (i = l + 1; i <= r - 1; ++i)       if (a[i] == mx) b[mx][++cnt[mx]] = i;     b[mx][++cnt[mx]] = r;     if (cnt[mx] > 2) {       ans += find(l + 1, r - 1, mx + mx);       for (i = 1; i <= cnt[mx] - 1; ++i) {         ans -= find(b[mx][i] + 1, b[mx][i + 1] - 1, mx + mx);       }     }     for (i = 1; i <= cnt[mx] - 1; ++i) dfs(b[mx][i], b[mx][i + 1], mx - 1);   }   int main() {     int i, mx = 0;     long long x;     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %lld , &x);       for (; x; x >>= 1)         if (x & 1ll) ++a[i];       mx = max(mx, a[i]);       sum[i] = sum[i - 1] + a[i];     }     dfs(0, n + 1, mx);     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int test;     cin >> test;     while (test--) {       int bun, beef, chicks, hp, cp, count1 = 0, count2 = 0;       cin >> bun >> beef >> chicks >> hp >> cp;       bun /= 2;       if (hp >= cp) {         count1 = min(bun, beef);         bun -= count1;         if (bun != 0) {           count2 = min(bun, chicks);         }       } else {         count2 = min(bun, chicks);         bun -= count2;         if (bun != 0) {           count1 = min(bun, beef);         }       }       cout << count1 * hp + count2 * cp << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   const long long mod = 998244353;   long long p[N];   int main() {     int n;     long long ans;     scanf( %d , &n);     p[0] = 1;     for (int i = 1; i <= n; i++) p[i] = p[i - 1] * (n - i + 1) % mod;     ans = p[1];     for (int i = 2; i <= n; i++) {       ans += (p[i] - p[i - 1] + mod) % mod * i % mod;       ans %= mod;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, in, ans = 0, asum = 0, bsum = 0;     vector<int> a, b;     vector<int>::iterator minit, it2;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &in);       a.push_back(in);     }     b = a;     sort(b.begin(), b.end());     for (int i = 0; i < n; i++) {       asum += a[i];       bsum += b[i];       if (asum == bsum) {         ans++;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct state {     state(int a, int b, int c, int d) : num(a), ind1(b), ind2(c), oper(d){};     int num;     int ind1, ind2;     int oper;   };   vector<state> ansState;   int n, ans = 100000;   map<set<int>, int> m;   vector<state> v;   void dfs() {     if (v[v.size() - 1].num == n) {       if (v.size() < ans) {         ans = v.size();         ansState = v;       }       return;     }     if (v.size() >= ans || v.size() > 5) return;     set<int> s;     for (int i = 0; i < v.size(); ++i) s.insert(v[i].num);     if (m[s]) return;     m.insert(make_pair(s, 1));     for (int i = 0; i < v.size(); ++i) {       for (int j = 1; j <= 3; ++j) {         int x = v[i].num * (1 << j);         if (x > n) break;         int flag = 1;         for (int k = 0; k < v.size(); ++k)           if (v[k].num == x) {             flag = 0;             break;           }         if (!flag) continue;         v.push_back(state(x, i, -1, j));         dfs();         v.pop_back();       }       for (int j = 0; j < v.size(); ++j)         for (int k = 0; k <= 3; ++k) {           int x = v[i].num + (1 << k) * v[j].num;           if (x > n) break;           int flag = 1;           for (int t = 0; t < v.size(); ++t)             if (v[t].num == x) {               flag = 0;               break;             }           if (flag) {             v.push_back(state(x, i, j, 4 + k));             dfs();             v.pop_back();           }         }     }   }   int Solution() {     cin >> n;     v.push_back(state(1, -1, -1, -1));     dfs();     cout << ans - 1 << endl;     for (int i = 1; i < ansState.size(); ++i) {       cout <<  lea e  << (char)( a  + i) <<  x, [ ;       if (ansState[i].oper < 4) {         cout << (1 << ansState[i].oper) <<  *e  << (char)( a  + ansState[i].ind1)              <<  x]  << endl;       }       if (ansState[i].oper == 4) {         cout <<  e  << (char)( a  + ansState[i].ind1) <<  x +                <<  e  << (char)( a  + ansState[i].ind2) <<  x]  << endl;       }       if (ansState[i].oper > 4) {         cout <<  e  << (char)( a  + ansState[i].ind1) <<  x +                << (1 << (ansState[i].oper - 4)) <<  *               <<  e  << (char)( a  + ansState[i].ind2) <<  x]  << endl;       }     }     return 0;   }   int main() {     Solution();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 2 * 1e9;   const int mod = 1e9 + 7;   const int maxn = 200005;   int n, m;   int arr[maxn], ob[maxn], fact[maxn], obr[maxn];   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> arr[1];     ob[1] = fact[1] = obr[1] = 1;     for (int i = 2; i <= n; ++i) {       cin >> arr[i];       ob[i] = (mod - 1LL * (mod / i) * ob[mod % i] % mod) % mod;       fact[i] = (1LL * i * fact[i - 1]) % mod;       obr[i] = (1LL * obr[i - 1] * ob[i]) % mod;     }     int ans = 0;     if (n % 4 == 0) {       for (int i = 1; i <= n; i += 2) {         int p1 = (n - 2) / 2, p2 = (i - 1) / 2;         int c =             (((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod + mod) % mod;         if (c == 0) c = 1;         ans = (1LL * ans + (1LL * c * (arr[i] - arr[i + 1])) % mod) % mod;       }     } else if (n % 4 == 1) {       for (int i = 1; i <= n; i += 2) {         int p1 = (n - 1) / 2, p2 = (i - 1) / 2;         int c = ((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod;         if (c == 0) c = 1;         ans = (1LL * ans + (1LL * c * arr[i]) % mod) % mod;       }     } else if (n % 4 == 2) {       for (int i = 1; i <= n; ++i) {         int p1 = (n - 2) / 2, p2 = (i - 1) / 2;         int c = ((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod;         if (c == 0) c = 1;         ans = (1LL * ans + (1LL * c * arr[i]) % mod) % mod;       }     } else {       ans = arr[1];       for (int i = 2; i <= n; i += 2) {         int p1 = (n - 3) / 2, p2 = (i - 2) / 2;         int c1 = ((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod;         p2 += 1;         int c2 = ((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod;         if (c1 == 0)           c1 = 1;         else if (c2 == 0)           c2 = 1;         ans = (1LL * ans + (1LL * arr[i] * 2 * c1) % mod +                (1LL * arr[i + 1] * (c2 - c1)) % mod) %               mod;       }     }     ans = (ans + mod) % mod;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &x) {     x = 0;     T f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -f;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     x *= f;   }   int max(int x, int y) { return x > y ? x : y; }   int min(int x, int y) { return x < y ? x : y; }   char s[500010], t[500010];   int m, n, cnt0, cnt1;   int nxt[500010], ans[500010];   void Get_Next() {     nxt[0] = -1;     int j = 0, k = -1;     while (j <= n) {       if (k == -1 || t[j] == t[k])         nxt[++j] = ++k;       else         k = nxt[k];     }   }   bool fl;   int main() {     scanf( %s , s), scanf( %s , t), m = strlen(s), n = strlen(t);     t[n] =  $ ;     for (int i = 1; i <= m; ++i)       if (s[i - 1] ==  0 )         cnt0++;       else         cnt1++;     Get_Next();     for (int i = 0; i < n; ++i) {       if (t[i] ==  0  && cnt0 == 0) {         fl = 1;         break;       }       if (t[i] ==  1  && cnt1 == 0) {         fl = 1;         break;       }       ans[i] = t[i] -  0 ;       if (t[i] ==  0 )         cnt0--;       else         cnt1--;     }     if (fl) {       cout << s <<   n ;       return 0;     }     int now = n, kk = n;     while (1) {       if (now == n) now = nxt[n];       if (t[now] ==  0  && cnt0 == 0) {         for (int i = 1; i <= cnt1; ++i) ans[kk + i - 1] = 1;         break;       }       if (t[now] ==  1  && cnt1 == 0) {         for (int i = 1; i <= cnt0; ++i) ans[kk + i - 1] = 0;         break;       }       ans[kk++] = t[now] -  0 ;       if (t[now] ==  0 )         cnt0--;       else         cnt1--;       now++;       if (kk > m) break;     }     for (int i = 0; i < m; ++i) cout << ans[i];     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, ch;     while (!isdigit(ch = getchar()))       ;     while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();     return x;   }   template <typename T>   inline T gcd(T a, T b) {     return !b ? a : gcd(b, a % b);   }   struct Node {     int len, pos, id;   };   struct prime {     int p, c;   };   const int MAXN = 100000;   vector<Node> a[MAXN + 1];   vector<prime> d[41];   int pri[45][10];   long long pw[45][10];   int main() {     int n = read(), m = read();     for (int i = 1; i <= n; i++) {       int len = read();       for (int j = 0; j < len; j++) {         int x = read();         a[x].push_back((Node){len, j, i});       }     }     for (int i = 2; i <= 40; i++) {       int tmp = i;       for (int j = 2; j <= i; j++) {         if (tmp % j) continue;         int c = 0;         while (tmp % j == 0) tmp /= j, ++c;         d[i].push_back((prime){j, c});       }       long long mul = 1;       for (int j = 0; j < 10; j++) pw[i][j] = mul, mul *= i;     }     for (int i = 1; i <= m; i++) {       int si = a[i].size(), res = 1, l = 0;       if (!si) {         puts( 0 );         continue;       }       long long lcm = a[i][0].len, pos = a[i][0].pos, las = a[i][0].id;       int s = d[lcm].size();       for (int j = 0; j < s; j++) {         prime z = d[lcm][j];         pri[z.p][z.c]++;       }       for (int r = 1; r < si; r++) {         Node x = a[i][r], y = a[i][l];         if (x.id != las + 1) {           l = r, lcm = x.len, pos = x.pos;           memset(pri, 0, sizeof(pri));         } else {           long long g = gcd(lcm, (long long)x.len);           while (l < r && abs(pos - x.pos) % g) {             s = d[y.len].size();             for (int j = 0; j < s; j++) {               prime z = d[y.len][j];               pri[z.p][z.c]--;               if (!pri[z.p][z.c]) {                 int flag = 0;                 for (int k = z.c + 1; k < 10; k++) flag |= pri[z.p][k];                 if (!flag) {                   lcm /= pw[z.p][z.c];                   for (int k = z.c; k >= 1; k--)                     if (pri[z.p][k]) {                       lcm *= pw[z.p][k];                       break;                     }                 }               }             }             g = gcd(lcm, (long long)x.len);             y = a[i][++l];             pos %= lcm;           }           long long tpos = x.pos;           while (pos != tpos) {             if (pos < tpos)               pos += (tpos - pos + lcm - 1) / lcm * lcm;             else               tpos += (pos - tpos + x.len - 1) / x.len * x.len;           }           lcm = lcm / g * x.len;         }         las = x.id;         s = d[x.len].size();         for (int j = 0; j < s; j++) {           prime z = d[x.len][j];           pri[z.p][z.c]++;         }         res = max(res, r - l + 1);       }       printf( %d n , res);       memset(pri, 0, sizeof(pri));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 2e5 + 5;   void solve() {     long long int n, x;     cin >> n >> x;     vector<long long int> v(n);     for (auto &it : v) cin >> it;     ;     sort(v.begin(), v.end());     long long int ans = 0;     vector<long long int> a;     for (long long int i = 0; i < n; i++) {       if (v[i] >= x) {         ans++;       } else {         a.push_back(v[i]);       }     }     reverse(a.begin(), a.end());     for (long long int i = 0; i < a.size(); i++) {       long long int mini = a[i];       long long int count = 1;       while (mini * count < x) {         i++;         if (i >= a.size()) {           break;         }         mini = min(mini, a[i]);         count++;       }       if (mini * count >= x) {         ans++;       }     }     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   vector<int> c[2];   int main() {     int n, k, p, x, m1 = 0, m2 = 0;     scanf( %d%d%d , &n, &k, &p);     for (int i = 0; i < n; ++i) {       scanf( %d , &x);       if (x & 1) {         c[0].push_back(x);         m1++;       } else {         c[1].push_back(x);         m2++;       }     }     if (m1 >= k - p && (m1 - (k - p)) % 2 == 0 &&         (m2 + (m1 - (k - p)) / 2) >= p) {       puts( YES );       int i, j;       if (p > 0) {         for (i = 0; i < k - p; i++) printf( 1 %d n , c[0][i]);         for (j = 0; j < p - 1;) {           if (j < m2) {             printf( 1 %d n , c[1][j]);             j++;           } else {             printf( 2 %d %d n , c[0][i], c[0][i + 1]);             i += 2;             p--;           }         }         if (m1 - i + m2 - j > 0) {           printf( %d , m1 - i + m2 - j);           for (; j < m2; j++) printf(  %d , c[1][j]);           for (; i < m1; i++) printf(  %d , c[0][i]);           putchar(  n );         }       } else {         for (i = 0; i < k - 1; i++) printf( 1 %d n , c[0][i]);         if (m1 - i + m2 > 0) {           printf( %d , m1 - i + m2);           for (; i < m1; i++) printf(  %d , c[0][i]);           for (j = 0; j < m2; j++) printf(  %d , c[1][j]);           putchar(  n );         }       }     } else {       puts( NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x;   char s[100005];   bool flag[500];   int cnt[500];   vector<char> f;   int main() {     scanf( %d , &x);     scanf( %s , s);     int len = strlen(s);     for (int i = 0; i < len; i++) cnt[s[i]]++;     for (int i =  a ; i <=  z ; i++) {       if (cnt[i] == 0) continue;       flag[i] = 1;       int pre = -1;       bool tag = 0;       f.push_back(char(i));       for (int j = 0; j < len; j++) {         if (flag[s[j]]) {           pre = j;           continue;         }         int y = j - pre;         if (y >= x) {           tag = 1;           break;         }       }       if (tag)         continue;       else {         cnt[i] = 0;         flag[i] = 0;         int pos = -1;         int pre = -1;         for (int j = 0; j < len; j++) {           if (s[j] == i) {             pos = max(pos, j);           }           if (flag[s[j]]) {             pre = j;             continue;           }           int y = j - pre;           if (y >= x) {             pre = pos;             cnt[i]++;           }         }         break;       }     }     string ans =   ;     int p = f.size();     for (int i = 0; i < p; i++) {       for (int j = 1; j <= cnt[f[i]]; j++) ans += f[i];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200005], b[200005];   int x[200005];   int main() {     int n;     long long t;     scanf( %d%I64d , &n, &t);     for (int i = 1; i <= n; i++) scanf( %I64d , a + i);     for (int i = 1; i <= n; i++) {       scanf( %d , x + i);       if (x[i] < x[i - 1] || x[i] < i) {         puts( No );         return 0;       }     }     for (int i = 1; i <= n; i++) b[x[i]] = -1;     for (int i = 1; i <= n; i++) b[i] += b[i - 1];     for (int i = 1; i <= n; i++)       if (b[x[i] - 1] - b[i - 1]) {         puts( No );         return 0;       }     for (int i = n; i; i--) b[i] -= b[i - 1];     for (int i = 1; i < n; i++) b[i] += a[i + 1] + t;     b[n] = a[n] + t + 1;     for (int i = 1; i <= n; i++)       if (b[i] < a[i] + t || b[i] <= b[i - 1]) {         puts( No );         return 0;       }     puts( Yes );     for (int i = 1; i <= n; i++) printf( %I64d  , b[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int tests;     scanf( %d , &tests);     while (tests--) {       int item;       cin >> item;       vector<int> v;       set<int> s;       int temp;       for (int i = 0; i < item; i++) {         scanf( %d , &temp);         v.push_back(temp);         s.insert(temp);       }       int distinct = 0;       cout << s.size() <<   n ;     }     return 0;   }