malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int temp[500000], a[500000], indices[500000], increments[500000],       previous_appearance[500000], numbers_equal_c[500000];   void mergesort(int Array[], int indices[], int first, int last) {     if (first == last) return;     int middle = (first + last) / 2;     mergesort(Array, indices, first, middle);     mergesort(Array, indices, middle + 1, last);     int i, j, k;     for (i = first, j = first, k = middle + 1; i <= last; i++) {       if (j == middle + 1)         temp[i] = indices[k++];       else if (k == last + 1)         temp[i] = indices[j++];       else if (Array[indices[k]] < Array[indices[j]])         temp[i] = indices[k++];       else         temp[i] = indices[j++];     }     for (i = first; i <= last; i++) {       indices[i] = temp[i];     }   }   int main() {     int n, i, one_counter = 0, c, maximum_increament = 0, number_equal_to_c = 0;     scanf( %d %d , &n, &c);     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       indices[i] = i;       previous_appearance[i] = -1;       numbers_equal_c[i] = 0;       increments[i] = 0;     }     mergesort(a, indices, 0, n - 1);     for (i = 1; i < n; i++) {       if (a[indices[i]] == a[indices[i - 1]]) {         previous_appearance[indices[i]] = indices[i - 1];       }     }     for (i = 0; i < n; i++) {       if (a[i] == c) {         number_equal_to_c++;       } else {         if (previous_appearance[i] == -1 ||             increments[previous_appearance[i]] - number_equal_to_c +                     numbers_equal_c[previous_appearance[i]] + 1 <=                 0)           increments[i] = 1;         else           increments[i] = increments[previous_appearance[i]] - number_equal_to_c +                           numbers_equal_c[previous_appearance[i]] + 1;         if (maximum_increament < increments[i])           maximum_increament = increments[i];       }       numbers_equal_c[i] = number_equal_to_c;     }     printf( %d , number_equal_to_c + maximum_increament);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       int ans = n;       for (int i = 1; i * i <= n; i++)         if (n % i == 0) {           if (i <= k) ans = min(ans, n / i);           if (n / i <= k) ans = min(ans, i);         }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, s, x;     scanf( %d%d%d , &t, &s, &x);     if (x < t) {       puts( NO );       return 0;     }     int temp = (x - t) % s;     if (temp == 0 || temp == 1) {       if (x == t + 1)         puts( NO );       else         puts( YES );     } else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<long long int> s;   int main() {     long long int n, m, i, ans = 0;     cin >> n >> m;     long long int a[n], c[200005] = {0};     for (i = 0; i < m; i++) s.insert(i);     for (i = 0; i < n; i++) {       long long int d, x;       cin >> a[i];       d = a[i] % m;       if (d > *s.rbegin())         x = *s.begin();       else         x = *s.lower_bound(d);       if (++c[x] == n / m) s.erase(x);       ans += (x - d + m) % m;       a[i] += (x - d + m) % m;     }     cout << ans << endl;     for (i = 0; i < n; i++) cout << a[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   const long long mod = 1e9 + 7;   inline long long add(long long a, long long b) {     return (a % mod + b % mod) % mod;   }   inline long long sub(long long a, long long b) {     return (a % mod - b % mod + mod) % mod;   }   inline long long mul(long long a, long long b) {     return (a % mod * b % mod) % mod;   }   inline long long power(long long a, long long b, long long MOD) {     long long res = 1;     while (b) {       if (b & 1) {         res *= a;         res %= MOD;       }       a = a * a;       a %= MOD;       b >>= 1;     }     return res;   }   clock_t time_p = clock();   void time() {     time_p = clock() - time_p;     cerr <<  Time elapsed :   << (long double)(time_p) / CLOCKS_PER_SEC <<   n ;   }   bool go(string a, string b) {     if (a == b) return true;     long long n1 = a.length();     long long n2 = b.length();     if (n1 & 1 || n2 & 1) return false;     string a1, a2, b1, b2;     for (long long i = 0; i < n1 / 2; i++) a1 += a[i];     for (long long i = n1 / 2; i < n1; i++) a2 += a[i];     for (long long i = 0; i < n2 / 2; i++) b1 += b[i];     for (long long i = n2 / 2; i < n2; i++) b2 += b[i];     if (go(a1, b2) && go(a2, b1)) return true;     if (go(a1, b1) && go(a2, b2)) return true;     return false;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     string a, b;     cin >> a >> b;     cout << (go(a, b) ?  YES  :  NO ) <<   n ;     time();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[200005];   int main() {     int l, t;     scanf( %d %d , &l, &t);     scanf( %s , s + 1);     s[0] =  0 ;     for (int i = 0; i <= l; i++) {       if (s[i] ==  . ) {         for (int j = i + 1; j <= l; j++)           if (s[j] >=  5 ) {             s[j] = 0;             bool roundup = true;             t--;             for (int k = j - 1; k > i; k--) {               if (roundup) {                 s[k]++;                 if (s[k] >=  5  && t) {                   s[k] = 0;                   t--;                   roundup = true;                 } else                   roundup = false;               }             }             if (roundup) {               s[i] = 0;               for (int k = i - 1; k >= 0; k--) {                 s[k]++;                 if (s[k] <=  9 )                   break;                 else                   s[k] =  0 ;               }             }             break;           }       }     }     if (s[0] !=  0 ) {       printf( %s n , s);     } else {       printf( %s n , s + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k, d[5][2][100][100], kk;   int a[100][100];   bool was[100][100], done = false, was2[100][100][2][5];   string s;   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> s;       m = s.length();       for (int j = 0; j < m; j++) {         a[i][j] = s[j] -  0 ;         if (a[i][j] == 0) was[i][j] = true;       }     }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (!was[i][j]) {           int ii = i, jj = j;           while (jj < m && a[i][jj] == a[i][j] && ii < n && a[ii][j] == a[i][j])             jj++, ii++;           while (ii < n && a[ii][j] == a[i][j]) ii++;           ii--;           while (jj < m && a[i][jj] == a[i][j]) jj++;           jj--;           for (int g = i; g <= ii; g++)             for (int h = j; h <= jj; h++) {               was[g][h] = true;               d[1][0][g][h] = ii * 100 + jj;               d[1][1][g][h] = i * 100 + jj;               d[2][0][g][h] = ii * 100 + j;               d[2][1][g][h] = ii * 100 + jj;               d[3][0][g][h] = i * 100 + j;               d[3][1][g][h] = ii * 100 + j;               d[4][0][g][h] = i * 100 + jj;               d[4][1][g][h] = i * 100 + j;             }         }     int in = 0, jn = 0, cp = 1, dp = 1, iin, jjn;     kk = k;     was2[0][0][1][1] = true;     while (k) {       bool flag = false;       k--;       iin = in, jjn = jn;       in = d[dp][cp][iin][jjn] / 100;       jn = d[dp][cp][iin][jjn] % 100;       if (dp == 1 && jn < m - 1 && a[in][jn + 1] != 0)         jn++, flag = true;       else if (dp == 2 && in < n - 1 && a[in + 1][jn] != 0)         in++, flag = true;       else if (dp == 3 && jn > 0 && a[in][jn - 1] != 0)         jn--, flag = true;       else if (dp == 4 && in > 0 && a[in - 1][jn] != 0)         in--, flag = true;       if (!flag)         if (cp == 1)           cp = 0;         else           cp = 1, dp = dp % 4 + 1;       if (was2[in][jn][cp][dp] && !done) k = k % (kk - k), done = true;     }     cout << a[in][jn];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string rep(char c, int x) {     string ret =   ;     for (int i = 0; i < x; i++) {       ret += c;     }     return ret;   }   int main() {     int n, k;     cin >> n >> k;     if (n == k) {       string ans =   ;       for (int i = 0; i < n; i++) {         ans +=  0 ;       }       cout << ans << endl;       return 0;     } else if (k == 1) {       string ans =  1  + rep( 0 , n - 1);       cout << ans << endl;       return 0;     } else {       int diff = n - k;       string repl =  1  + rep( 0 , diff / 2);       string ans =   ;       while (true) {         if (ans.size() + repl.size() > n) {           break;         }         ans += repl;       }       int rem = n - ans.size();       for (int i = 0; i < rem; i++) {         ans += repl[i];       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     int x, y, i;     if (b * c > a * d) {       x = b * c - a * d;       y = b * c;     } else {       x = a * d - b * c;       y = a * d;     }     while (1) {       int k = 0;       for (i = 2; i <= x; i++) {         if (x % i == 0 && y % i == 0) {           x = x / i;           y = y / i;           k++;         }       }       if (k == 0) break;     }     if (x == 0)       cout << x <<  /             <<  1 ;     else       cout << x <<  /  << y;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Mod = 1000000007;   int N;   struct M {     int a[250][250];     M() { memset(a, 0, sizeof(a)); }   };   M I() {     M res;     for (int i = 0; i < N; i++) res.a[i][i] = 1;     return res;   }   M operator*(const M& a, const M& b) {     M ans;     for (int i = 0; i < N; i++)       for (int j = 0; j < N; j++)         for (int k = 0; k < N; k++)           ans.a[i][j] = (ans.a[i][j] + 1ll * a.a[i][k] * b.a[k][j]) % Mod;     return ans;   }   int k, m;   int id(int x, int y) { return x * (1 << m) + y; }   M fpow(M a, int b) {     M ans = I(), t = a;     while (b) {       if (b & 1) ans = ans * t;       t = t * t;       b >>= 1;     }     return ans;   }   int cnt(int x) {     int ans = 0;     while (x) {       ans += (x & 1);       x >>= 1;     }     return ans;   }   int main() {     int n;     scanf( %d %d %d , &n, &k, &m);     N = (k + 1) * (1 << m);     M S, T;     S.a[0][0] = 1;     for (int c = 0; c <= k; c++)       for (int s = 0; s < (1 << m); s++) {         T.a[id(c, s)][id(c, s >> 1)]++;         if (c < k)           T.a[id(c, s)][id(c + 1, (s >> 1) | (1 << (m - 1)))] += cnt(s) + 1;       }     S = S * fpow(T, n);     int ans = 0;     for (int s = 0; s < (1 << m); s++) ans = (ans + S.a[0][id(k, s)]) % Mod;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, v;     cin >> n >> v;     vector<vector<int> > mat(n + 1, vector<int>(v + 1, INT_MAX));     for (int i = 1, j = 0; j <= v; j++) {       mat[i][j] = j;     }     for (int i = 2; i <= n; i++) {       for (int j = 0; j <= v; j++) {         if (j < v) {           mat[i][j] = mat[i - 1][j + 1];         } else {           mat[i][j] = mat[i][j - 1] + i;         }       }     }     cout << mat[n][0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie();     cout.tie(0);     long long n, p = 0, q = 0, l = 0, i, flag = 0, k, m, t, j, r = 0, curr = 0, d;     cin >> n >> m;     long long a[n], b[n];     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     for (long long i = 0; i < n; i++) {       cin >> b[i];     }     if (a[0] == 0) {       cout <<  NO ;       return 0;     }     if (a[0] != 0) {       if (a[m - 1] != 0) {         cout <<  YES ;         return 0;       }     }     if (a[m - 1] == 0) {       for (long long i = m; i < n; i++) {         if (a[i] == 1 && b[i] == 1) {           if (b[m - 1] == 1) {             flag = 1;             break;           }         }       }     }     if (flag == 1) {       cout <<  YES ;       return 0;     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long Mo = 1000000007LL;   long long f[60][60], g[60][60];   long long fac[70], inv[70];   int n, m;   void add(long long &a, long long b) {     a += b;     a %= Mo;   }   long long fpm(long long a, long long b) {     long long ans = 1LL;     for (; b; b >>= 1) {       if (b & 1LL) ans *= a, ans %= Mo;       a *= a;       a %= Mo;     }     return ans;   }   long long C(long long a, long long b) {     a += b - 1;     a %= Mo;     if (a < b) return 0LL;     long long ans = 1LL;     for (int i = a; i > a - b; i--) ans = ans * i % Mo;     ans *= inv[b];     return ans % Mo;   }   void solve() {     f[2][1] = 1;     for (int i = 1; i <= 52; i++) {       for (int x = 2; x <= i + 1; x++) {         int y = i + 3 - x;         for (int a = 1; a <= x; a++)           for (int b = 1; b <= y; b++) add(g[i][min(a, b)], f[x][a] * f[y][b]);       }       for (int x = 1; x <= i; x++)         for (int j = 52; j >= 2; j--) {           for (int k = 1; k * i + 2 <= j; k++) {             for (int y = x * k; y <= j; y++)               add(f[j][y], f[j - i * k][y - x * k] * C(g[i][x], k));           }         }     }   }   int main() {     fac[0] = 1;     for (int i = 1; i <= 60; i++) fac[i] = (fac[i - 1] * (long long)i) % Mo;     for (int i = 0; i <= 60; i++) inv[i] = fpm(fac[i], Mo - 2LL);     scanf( %d %d , &n, &m);     solve();     cout << f[n + 2][m] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x20202020;   const int mod = 1000000007;   inline void read(int &x) {     char ch;     bool f = 0;     int a = 0;     while (!((((ch = getchar()) >=  0 ) && (ch <=  9 )) || (ch ==  - )))       ;     if (ch !=  - )       a *= 10, a += ch -  0 ;     else       f = 1;     while (((ch = getchar()) >=  0 ) && (ch <=  9 )) a *= 10, a += ch -  0 ;     if (f) a = -a;     x = a;   }   const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   long long powmod(long long a, long long b, long long mod) {     long long res = 1;     a %= mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   const int N = 111111, M = 111111;   int l, m, n, t, tot;   struct zcc {     int x, v;   } a[N];   inline bool cmp(const zcc &a, const zcc &b) { return a.v < b.v; }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i].v), a[i].x = i, tot += a[i].v;     sort(a + 1, a + 1 + n, cmp);     if (n == 1 && m == tot) {       puts( Yes );       for (int i = 1; i <= 2 * a[1].v - 1; ++i) printf( %d  , a[1].x);       printf( %d n , a[1].x);     } else if (n >= 2 && m >= 2 && m <= tot) {       puts( Yes );       while (m > 2) {         if (a[1].v > 1)           a[1].v--, printf( %d %d  , a[1].x, a[1].x), m--;         else if (a[n].v)           a[n].v--, printf( %d %d  , a[n].x, a[n].x), m--;         else           n--;       }       if (a[2].v) {         a[2].v--;         a[1].v--;         printf( %d  , a[1].x);         for (int i = 2; i <= n; ++i)           for (int j = 1; j <= a[i].v; ++j) printf( %d %d  , a[i].x, a[i].x);         printf( %d  , a[1].x);         printf( %d  , a[2].x);         for (int i = 1; i <= a[1].v; ++i) printf( %d %d  , a[1].x, a[1].x);         printf( %d n , a[2].x);       } else {         printf( %d %d n , a[1].x, a[1].x);       }     } else if (n >= 2 && m == 1 && a[1].v == 1) {       puts( Yes );       printf( %d  , a[1].x);       for (int i = 2; i <= n; ++i)         for (int j = 1; j <= a[i].v; ++j) printf( %d %d  , a[i].x, a[i].x);       printf( %d n , a[1].x);     } else       puts( No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, j, x;   long long sum;   char s[30];   vector<int> a;   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %s , s);       if (s[0] ==  s ) {         sum = 0;         for (j = 2; j < a.size(); j += 5) {           sum += a[j];         }         cout << sum;         printf(  n );       } else {         scanf( %d , &x);         if (s[0] ==  a )           a.insert(lower_bound(a.begin(), a.end(), x), x);         else           a.erase(lower_bound(a.begin(), a.end(), x));       }     }     return 0;   }
#include <bits/stdc++.h>   const int N = 1e5 + 5;   const unsigned long long bigN = 1e18;   const long long mod9 = 1e9 + 9;   const long long mod7 = 1e9 + 7;   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     vector<int> a, b;     int n, l, r, x;     cin >> n >> l >> r;     for (int i = 1; i <= n; i++) {       cin >> x;       if (i >= l && i <= r) {         continue;       } else {         a.push_back(x);       }     }     for (int i = 1; i <= n; i++) {       cin >> x;       if (i >= l && i <= r) {         continue;       } else {         b.push_back(x);       }     }     if (a == b) {       cout <<  TRUTH ;     } else {       cout <<  LIE ;     }   }
#include <bits/stdc++.h>   using namespace std;   map<string, string> M;   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       string name, ip;       cin >> name >> ip;       M[ip] = name;     }     for (int i = 0; i < m; i++) {       string cmd, ip;       cin >> cmd >> ip;       ip.pop_back();       cout << cmd <<     << ip <<  ; #  << M[ip] << endl;     }   }
#include <bits/stdc++.h>   #define ll long long   using namespace std;   const ll N = 5005, MOD = 998244353;   vector<vector<ll>> dp(N, vector<ll>(N));   vector<vector<int>> edges(N);   vector<int> h(N);   int n, k;   void add(ll &x, ll y) {    if((x += y) >= MOD) {     x -= MOD;    }   }   void dfs(int x, int p) {    dp[x][0] = 1;     for(int to : edges[x]) {     if(to != p) {      dfs(to, x);      vector<ll> temp(N);      for(int L1 = 0; L1 <= min(h[x], k); ++L1) {       for(int L2 = 0; L2 <= h[to]; ++L2) {        ll ways = dp[x][L1] * dp[to][L2] % MOD;        if(L1 + L2 < k) add(temp[max(L1, L2+1)], ways);        add(temp[L1], ways);       }      }      dp[x] = temp;      h[x] = max(h[x], h[to]+1);     }    }   }   int main() {    ios::sync_with_stdio(0); cin.tie(0);    cin >> n >> k;    for(int i = 0; i < n - 1; ++i) {     int u, v; cin >> u >> v;     edges[u].push_back(v);     edges[v].push_back(u);    }    dfs(1, 0);    ll ans = 0;    for(int i = 0; i <= k; ++i) {     add(ans, dp[1][i]);    }    cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   const int maxn = 2e5 + 9;   int a[maxn], b[maxn];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     for (int i = 1; i <= m; i++) {       scanf( %d , &b[i]);     }     long long ans = 1;     int l = n, r = n;     for (int i = m; i >= 1; i--) {       while (a[r] > b[i]) r--;       if (a[r] != b[i] || r == 0) {         ans = 0;         break;       }       l = r;       while (a[l] >= b[i]) l--;       if (i != 1)         ans = ans * (r - l) % mod;       else if (l != 0)         ans = 0;       r = l;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[5] = {}, b[5] = {};     for (int k = 0; k < n; k++) {       int x;       cin >> x;       a[x - 1]++;     }     for (int k = 0; k < n; k++) {       int x;       cin >> x;       b[x - 1]++;     }     int cnt = 0;     for (int k = 0; k < 5; k++) {       if ((a[k] + b[k]) % 2 != 0) {         cout << -1;         return 0;       }       cnt += (max(a[k], b[k]) - min(a[k], b[k])) / 2;     }     cout << (cnt % 2 == 0 ? cnt / 2 : -1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     unordered_map<int, int> m;     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       m[x]++;     }     int ans = 0;     for (pair<int, int> x : m) ans += x.second / 2;     printf( %d n , ans / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 16;   int from[MAXN], to[MAXN], p[MAXN], q[MAXN];   bool w[MAXN][MAXN];   long long dp[1 << MAXN];   int main() {     int n, m, a, b;     long long y;     cin >> n >> y >> m;     fill(from, from + n, 0);     fill(to, to + n, 0);     fill(w[0], w[m], false);     for (int i = 0; i < m; ++i) {       cin >> a >> b;       --a;       --b;       w[a][b] = true;     }     for (int k = 0; k < n; ++k) {       for (int i = 0; i < n; ++i) {         for (int j = 0; j < n; ++j) {           w[i][j] |= w[i][k] && w[k][j];         }       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         if (w[i][j]) {           from[j] |= 1 << i;           to[i] |= 1 << j;         }       }     }     fill(dp, dp + (1 << n), 0);     dp[0] = 1;     for (int i = 1; i < (1 << n); ++i) {       for (int j = 0; j < n; ++j) {         if ((i & (1 << j)) != 0 && (i & to[j]) == 0) {           dp[i] += dp[i ^ (1 << j)];         }       }     }     y -= 2001;     m = (1 << n) - 1;     if (y >= dp[m]) {       cout <<  The times have changed  << endl;       return 0;     }     fill(p, p + n, -1);     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         if (p[j] != -1) {           continue;         }         p[j] = i;         {           fill(dp, dp + (1 << n), 0);           dp[0] = 1;           for (int i = 1; i < (1 << n); ++i) {             int k = n - __builtin_popcount(i);             if (p[k] != -1) {               int j = p[k];               if ((i & (1 << j)) != 0 && (i & from[j]) == 0) {                 dp[i] += dp[i ^ (1 << j)];               }             } else {               for (int j = 0; j < n; ++j) {                 if ((i & (1 << j)) != 0 && (i & from[j]) == 0) {                   dp[i] += dp[i ^ (1 << j)];                 }               }             }           }         }         if (y < dp[m]) {           q[i] = j;           break;         } else {           p[j] = -1;           y -= dp[m];         }       }     }     for (int i = 0; i < n; ++i) {       printf( %d%c , q[i] + 1, i == n - 1 ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 1000000 + 5;   const long long inf = 1e9;   const long long mod = 1e9 + 7;   int a[MX], k;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, p, x, y, tc;     cin >> tc;     while (tc--) {       cin >> n >> p >> k;       for (int i = 1; i <= n; i++) cin >> a[i];       sort(a + 1, a + n + 1);       int rs = 0, pre = 0;       for (int i = 1; i <= k; i++) {         int sm = pre;         if (pre > p) break;         rs = max(rs, i - 1);         for (int j = i + k - 1; j <= n; j += k) {           sm += a[j];           if (sm > p) break;           rs = max(rs, j);         }         pre += a[i];       }       cout << rs << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     unordered_map<string, long long> m;     m[ Tetrahedron ] = 4;     m[ Cube ] = 6;     m[ Octahedron ] = 8;     m[ Dodecahedron ] = 12;     m[ Icosahedron ] = 20;     long long n;     cin >> n;     long long count = 0;     while (n--) {       string str;       cin >> str;       count += m[str];     }     cout << count << endl;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   namespace Acc{    const int N = 1e2+10;    string a,b;       int n;       void work(){           queue<pair<string,int> >q;           cin>>n>>a,q.push({b,0});           while(1){               auto[u,pos]=q.front();q.pop();               u.resize(pos+1);               for(int i=0;i<26;i++){                   u[pos]=(char)( a +i);                   if(a.find(u)==string::npos)return (void)(cout<<u);                   q.push({u,pos+1});               }           }       }   }   int main(){    int T;    for(cin>>T;T--;puts(  ))Acc::work();    return 0;   }