malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n;   string res;   map<string, int> stv;   map<int, string> vts;   vector<string> a, s({ 1110111 ,  0010010 ,  1011101 ,  1011011 ,  0111010 ,                         1101011 ,  1101111 ,  1010010 ,  1111111 ,  1111011 });   vector<vector<int>> dp;   int cnt(string f, string t) {     int res = 0;     for (int i = 0; i < 7; i++) {       if (f[i] != t[i]) {         ++res;         if (f[i] ==  1 ) return -1;       }     }     return res;   }   int bt(int in, int k) {     if (k < 0) return 0;     if (in >= n) return k == 0;     int& dpv = dp[in][k];     if (dpv == 1) return 0;     for (int i = 9; i >= 0; i--) {       int c = cnt(a[in], vts[i]);       if (c >= 0 && bt(in + 1, k - c)) {         res.push_back(i +  0 );         return 1;       }     }     dpv = 1;     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int k;     cin >> n >> k;     a.resize(n);     dp.assign(n, vector<int>(k + 1));     for (auto& i : a) cin >> i;     for (int i = 0; i < 10; i++) {       stv[s[i]] = i;       vts[i] = s[i];     }     if (bt(0, k)) {       reverse(res.begin(), res.end());       cout << res;     } else {       cout << -1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   long long ln, lk, lm;   void et(bool f = 0) {     puts(f ?  MAGIC  :  NOT MAGIC );     exit(0);   }   int a[2505][2505];   bitset<2505> bs[2505];   void fmain() {     scanf( %d , &n);     for (int(i) = 1; (i) <= (int)(n); (i)++)       for (int(j) = 1; (j) <= (int)(n); (j)++) scanf( %d , &a[i][j]);     for (int(i) = 1; (i) <= (int)(n); (i)++)       if (a[i][i] != 0) et();     for (int(i) = 1; (i) <= (int)(n); (i)++)       for (int j = i + 1; j <= n; j++)         if (a[i][j] != a[j][i]) et();     vector<pair<int, pair<int, int>>> vp;     for (int(i) = 1; (i) <= (int)(n); (i)++)       for (int(j) = 1; (j) <= (int)(n); (j)++) vp.push_back({a[i][j], {i, j}});     int N = vp.size();     sort(vp.begin(), vp.end());     for (int i = 0, j = 0; i < N; i = j) {       for (j = i; j < N && vp[i].first == vp[j].first; j++)         ;       for (int k = i; k < j; k++) {         auto p = vp[k].second;         if ((bs[p.first] & bs[p.second]).any()) et();       }       for (int k = i; k < j; k++) {         auto p = vp[k].second;         bs[p.first][p.second] = 1;       }     }     et(1);   }   int main() {     fmain();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 100, inf = 0x3f3f3f3f, mod = 1e9 + 7, M = 1e6 + 1000;   const long long INF = 0x3f3f3f3f3f3f3f3f;   long long sp(long long a, long long b, long long d) {     if (!b) return 1;     return b % 2 ? sp(a * a, b / 2, d) * a % d : sp(a * a, b / 2, d);   }   long long sp1(long long a, long long b) {     if (!b) return 1;     return b % 2 ? sp1(a * a, b / 2) * a : sp1(a * a, b / 2);   }   long long lowbit(long long x) { return x & (-x); }   long long exgcd(long long a, long long b, long long &x, long long &y) {     if (!b) {       x = 1;       y = 0;       return a;     } else {       long long d = exgcd(b, a % b, y, x);       y -= (a / b) * x;       return d;     }   }   long long t, n;   char str[N];   long long ck(char s) {     long long l = 1, r = n, x = 0;     while (l <= r) {       if (str[l] == str[r]) {         l++;         r--;       } else {         if (str[l] == s) {           l++;           x++;         } else if (str[r] == s) {           r--;           x++;         } else {           return -1;         }       }     }     return x;   }   int main() {     cin >> t;     while (t--) {       scanf( %lld%s , &n, str + 1);       long long ans = -1;       for (int i = 0; i <= 25; i++) {         char s = i +  a ;         long long x = ck(s);         if (x == -1) continue;         if (ans == -1 || ans > x) ans = x;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[300005];   vector<long long> adjlist[1048585];   int main() {     long long n, i;     scanf( %lld , &n);     for (i = 0; i < n; i++) {       scanf( %lld , a + i);     }     for (i = 1; i < n; i++) {       a[i] = a[i - 1] ^ a[i];     }     adjlist[0].push_back(0);     for (i = 0; i < n; i++) {       adjlist[a[i]].push_back(i + 1);     }     long long ans = 0;     for (i = 0; i < 1048580; i++) {       if (adjlist[i].size() > 0) {         long long od = 0, ev = 0;         for (auto e : adjlist[i]) {           if (e % 2 == 0)             ev++;           else             od++;         }         ans += (ev * (ev - 1)) / 2;         ans += (od * (od - 1)) / 2;       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   int n, m;   int d[250000];   int h[250000];   int c[250000];   int r[250000];   int diferencias[160000];   int a[401];   bool sirve(int v, int idCamion) {     int litros = v;     int cantRecargas = r[idCamion];     for (int i = d[idCamion] + 1; i <= h[idCamion]; i++) {       if (v < a[i] - a[i - 1]) {         return false;       }       if (litros < a[i] - a[i - 1]) {         if (cantRecargas) {           litros = v;           cantRecargas--;         } else {           return false;         }       }       litros -= a[i] - a[i - 1];     }     return true;   }   int cmpfunc(const void* a, const void* b) { return (*(int*)a - *(int*)b); }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) scanf( %d , &a[i + 1]);     for (int i = 0; i < m; i++) scanf( %d %d %d %d , &d[i], &h[i], &c[i], &r[i]);     int tam2 = 0;     for (int i = 1; i <= n; i++)       for (int j = i; j <= n; j++) diferencias[tam2++] = a[j] - a[i];     qsort(diferencias, tam2, sizeof(int), cmpfunc);     int tam = 1;     for (int i = 1; i < tam2; i++)       if (diferencias[i] != diferencias[tam - 1])         diferencias[tam++] = diferencias[i];     long long minV = 0;     int ini, fin, mid;     for (int i = 0; i < m; i++) {       ini = 0;       fin = tam - 1;       while (ini + 1 < fin) {         mid = (ini + fin) / 2;         if (sirve(diferencias[mid], i))           fin = mid;         else           ini = mid;       }       if (sirve(diferencias[ini], i))         minV = (minV > ((long long)diferencias[ini]) * ((long long)c[i])                     ? minV                     : ((long long)diferencias[ini]) * ((long long)c[i]));       else         minV = (minV > ((long long)diferencias[fin]) * ((long long)c[i])                     ? minV                     : ((long long)diferencias[fin]) * ((long long)c[i]));     }     printf( %I64d n , minV);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[300010][27];   int val[300010], cost[610];   int fail[300010];   string st[610];   char s[300010], p[300010];   int main() {     int T, op, len, slen, i, j, k, x;     long long ans;     for (scanf( %d , &T); T; --T) {       scanf( %d %s , &op, s);       len = strlen(s);       if (op <= 2) {         if (len <= 500) {           for (i = 0, j = 0; i < len; ++i) {             if (!a[j][x = s[i] -  a ]) a[j][x] = ++m;             j = a[j][x];           }           val[j] += op == 1 ? 1 : -1;         } else {           st[++n] = s;           cost[n] = op == 1 ? 1 : -1;         }       } else {         ans = 0;         for (i = 0; i < len; ++i)           for (k = i, j = 0; k < len; ++k) {             if (!a[j][x = s[k] -  a ]) break;             j = a[j][x];             ans += val[j];           }         for (i = 1; i <= n; ++i) {           if ((slen = st[i].length()) > len) continue;           fail[0] = fail[1] = 0;           for (j = 1; j < slen; ++j) {             for (k = fail[j]; k && st[i][k] != st[i][j]; k = fail[k])               ;             fail[j + 1] = st[i][k] == st[i][j] ? k + 1 : 0;           }           for (j = 0, k = 0; j < len; ++j) {             while (k && st[i][k] != s[j]) k = fail[k];             if (st[i][k] == s[j]) ++k;             if (k == slen) {               ans += cost[i];               k = fail[k];             }           }         }         cout << ans << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   int n, i, x, p[1 << 20], q[1 << 20], t[1 << 20], k;   int main() {     scanf( %d , &n);     for (i = 0; i < n && 1 == scanf( %d , &p[i]); ++i)       ;     for (scanf( %d , &i); i-- > 0 && 1 == scanf( %d , &x); q[x - 1] = 1)       ;     for (i = n; i-- > 0;)       if (q[i] || !k || p[i] != t[k - 1])         t[k++] = p[i], p[i] *= -1;       else         --k;     if (k)       puts( NO );     else {       puts( YES );       for (i = 0; i < n; ++i) printf( %d  , p[i]);       puts(  );     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1234567;   vector<int> rev[N];   char foo[N];   int on_cycle[N];   int digit[N], to[N];   bool found;   void dfs(int v, int pos) {     if (pos < 0) {       found = true;     }     if (found) {       return;     }     int sz = rev[v].size();     for (int j = 0; j < sz; j++) {       int u = rev[v][j];       if (on_cycle[u] != -1) {         continue;       }       dfs(u, pos - (digit[u] == foo[pos] -  0 ));     }   }   int dx[42], dy[42];   int last[42];   bool vis[N];   const int NNN = 444;   char s[NNN][NNN];   int main() {     int n, m, q;     scanf( %d %d %d , &n, &m, &q);     for (int i = 0; i < n; i++) {       scanf( %s , s[i]);     }     for (int d = 0; d <= 9; d++) {       scanf( %d %d , dx + d, dy + d);     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         int d = s[i][j] -  0 ;         int x = i + dx[d];         int y = j + dy[d];         if (x < 0 || y < 0 || x >= n || y >= m) {           x = i;           y = j;         }         digit[i * m + j] = d;         to[i * m + j] = x * m + y;       }     }     n = n * m;     for (int i = 0; i < n; i++) {       vis[i] = false;       rev[i].clear();       on_cycle[i] = -1;     }     for (int i = 0; i < n; i++) {       rev[to[i]].push_back(i);     }     for (int i = 0; i < n; i++) {       if (vis[i]) {         continue;       }       int p = i;       vector<int> cycle;       while (!vis[p]) {         cycle.push_back(p);         vis[p] = true;         p = to[p];       }       int id = -1;       for (int i = 0; i < (int)cycle.size(); i++) {         if (cycle[i] == p) {           id = i;           break;         }       }       if (id == -1) {         continue;       }       int mask = 0;       for (int i = id; i < (int)cycle.size(); i++) {         mask |= (1 << digit[cycle[i]]);       }       for (int i = id; i < (int)cycle.size(); i++) {         on_cycle[cycle[i]] = mask;       }     }     while (q--) {       scanf( %s , foo);       int len = strlen(foo);       for (int d = 0; d <= 9; d++) {         last[d] = -1;       }       for (int i = 0; i < len; i++) {         last[foo[i] -  0 ] = i;       }       found = false;       for (int start = 0; start < n; start++) {         if (on_cycle[start] == -1) {           continue;         }         int pos = -1;         for (int d = 0; d <= 9; d++) {           if (on_cycle[start] & (1 << d)) {             continue;           }           pos = max(pos, last[d]);         }         dfs(start, pos);       }       puts(found ?  YES  :  NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     vector<int> v;     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int t;       cin >> t;       v.push_back(t);     }     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     v.erase(remove(v.begin(), v.end(), 0), v.end());     cout << v.size() <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int d, f, t;     long long c;   } a[100005];   int cmp(node a, node b) { return a.d < b.d; }   long long INF = 0x3f3f3f3f3f3f;   long long cost[100005];   int vis[100005];   int cnt1[1000006];   int cnt2[1000006];   long long sum2[1000006];   long long sum1[1000006];   int main() {     int n, m, k;     memset(cnt1, 0, sizeof(cnt1));     memset(cnt2, 0, sizeof(cnt2));     memset(vis, 0, sizeof(vis));     memset(cost, INF, sizeof(cost));     memset(sum1, 0, sizeof(sum1));     memset(sum2, 0, sizeof(sum2));     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= m; i++) {       scanf( %d%d%d%I64d , &a[i].d, &a[i].f, &a[i].t, &a[i].c);     }     sort(a + 1, a + 1 + m, cmp);     int pre = 0;     for (int i = 1; i <= m; i++) {       if (a[i].f == 0) continue;       int f = a[i].f;       int d = a[i].d;       sum1[d] = sum1[pre];       cnt1[d] = cnt1[pre];       if (cost[f] > a[i].c) {         if (vis[f] == 1)           sum1[d] = sum1[d] - cost[f] + a[i].c;         else           sum1[d] += a[i].c;         cost[f] = a[i].c;         if (vis[f] == 0) {           cnt1[d]++;           vis[f] = 1;         }       }       pre = d;     }     for (int i = 1; i <= 1000000; i++) {       if (cnt1[i] == 0) cnt1[i] = cnt1[i - 1];       if (sum1[i] == 0) sum1[i] = sum1[i - 1];     }     memset(vis, 0, sizeof(vis));     pre = 1000000;     memset(cost, INF, sizeof(cost));     for (int i = m; i >= 1; i--) {       if (a[i].t == 0) continue;       int d = a[i].d;       int t = a[i].t;       sum2[d] = sum2[pre];       cnt2[d] = cnt2[pre];       if (cost[t] > a[i].c) {         if (vis[t] == 1)           sum2[d] = sum2[d] - cost[t] + a[i].c;         else           sum2[d] += a[i].c;         cost[t] = a[i].c;         if (vis[t] == 0) {           cnt2[d]++;           vis[t] = 1;         }       }       pre = d;     }     for (int i = 1000000; i >= 0; i--) {       if (cnt2[i] == 0) cnt2[i] = cnt2[i + 1];       if (sum2[i] == 0) sum2[i] = sum2[i + 1];     }     long long ans = INF;     for (int i = 1; i <= 1000000; i++) {       if (i + k + 1 > 1000000) break;       if (cnt1[i] == n && cnt2[i + k + 1] == n)         ans = min(ans, (long long)sum1[i] + sum2[i + k + 1]);     }     if (ans == INF) {       printf( -1 n );       return 0;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 1e6;   long long n, b, s[MAXN], m[MAXN], t = 0;   long long i, j, d = 0;   bool q[MAXN];   int main() {     cin >> n >> b;     fill(q, q + n, false);     for (i = 0; i < n; i++) {       cin >> s[i] >> m[i];     }     j = 0;     for (i = 0; i < n; i++) {       if (i > 0) cout << endl;       if (j == i && q[j] == false) {         q[j] = true;         t = s[i];         d++;         j++;       }       if (q[i] == true) {         t += m[i];         d--;         cout << t;       } else         cout << -1;       while (q[j] == false && t > s[j] && j < n) {         if (d + 1 > b)           d--;         else           q[j] = true;         j++;         d++;       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     long long u, v, a, b;     scanf( %lld%lld , &u, &v);     if (v == 0)       printf( 0 n );     else if (u > v)       printf( -1 n );     else if (u == v) {       printf( 1 n );       printf( %lld n , u);     } else if ((v - u) % 2 == 0) {       a = u, b = (v - u) / 2;       if ((a ^ b) == (a + b)) {         printf( 2 n );         printf( %lld %lld n , a + b, b);       } else {         printf( 3 n );         printf( %lld %lld %lld n , a, b, b);       }     } else       printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k = 0, c = -1, x, z;     cin >> n;     while (true) {       c += 1;       x = pow(10, c);       z = 9 * x;       if (n - z > 0) {         n -= z;         k += (z * (c + 1));       } else {         n *= (c + 1);         k += n;         break;       }     }     cout << k;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[27], sum, gcd;   int odd;   int _gcd(int x, int y) {     if (x == 0 or x == y) return y;     if (x > y) swap(x, y);     while (y % x) {       y %= x;       swap(x, y);     }     return x;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , a + i);       if (a[i] & 1) odd++;       sum += a[i];       gcd = _gcd(gcd, a[i]);     }     if (odd > 1) {       printf( %d n , 0);       int k = 0;       string s(sum,  0 );       for (int i = 0; i < n; i++) {         int j = 0;         while (j < a[i]) {           s[j + k] =  a  + i;           j++;         }         k += a[i];       }       cout << s << endl;       return 0;     }     for (int i = 0; i < n; i++) a[i] /= gcd;     sum /= gcd;     printf( %d n , gcd);     if (odd) {       string s(sum,  0 );       int k = 0;       for (int i = 0; i < n; i++) {         int j = 0;         while (j < a[i] / 2) {           s[j + k] =  a  + i;           s[sum - 1 - j - k] =  a  + i;           j++;         }         if (a[i] & 1) odd = i;         k += a[i] / 2;       }       s[k] = odd +  a ;       for (int i = 0; i < gcd; i++) cout << s;       cout << endl;     } else {       string s(sum,  0 );       string t(sum,  0 );       int k = 0;       for (int i = 0; i < n; i++) {         int j = 0;         while (j < a[i]) {           s[j + k] =  a  + i;           t[sum - 1 - j - k] =  a  + i;           t[sum - 1 - j - k] =  a  + i;           j++;         }         k += a[i];       }       for (int i = 0; i < gcd / 2; i++) cout << s << t;       cout << endl;     }   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long   #define mod 1000000007   void solve()   {           int k,n,m;           cin >> k >> n >> m;           vector<int> a(n);           for(auto &i:a)           {               cin >> i;           }           vector<int> b(m);           for(auto &i:b)           {               cin >> i;           }           vector<int> res(n+m);           int i=0,j=0,ind=0;           while(i!=n && j!=m)           {               if(a[i]==0)               {                   res[ind]=0;                   ind++;                   i++;                   k++;               }               else if(b[j]==0)               {                   res[ind]=0;                   ind++;                   j++;                   k++;               }               else if(a[i]<=b[j] && a[i]<=k)               {                   res[ind]=a[i];                   ind++;                   i++;               }               else if(a[i]>=b[j] && b[j]<=k)               {                   res[ind]=b[j];                   ind++;                   j++;               }               else               {                   cout << -1 << endl;                   return;               }           }           while(i!=n)           {               if(a[i]==0)               {                   res[ind]=0;                   ind++;                   i++;                   k++;               }               else{               if(a[i]>k)               {                   cout << -1 << endl;                   return;               }               res[ind]=a[i];               ind++;               i++;               }           }           while(j!=m)           {               if(b[j]==0)               {                   res[ind]=0;                   ind++;                   j++;                   k++;               }               else{               if(b[j]>k)               {                   cout << -1 << endl;                   return;               }               res[ind]=b[j];               ind++;               j++;}           }           for(auto x:res)               cout << x <<    ;           cout << endl;   }   int main()   {       int t;       cin >> t;       while(t--)       {           solve();       }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     ;     int n;     cin >> n;     int odd = 0, even = 0;     for (int i = 0; i < n; i++) {       int val;       cin >> val;       if (val % 2)         odd++;       else         even++;     }     if (odd > even) {       cout << even + (odd - even) / 3 <<   n ;     } else       cout << odd <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct TrieNode {     TrieNode *arr[2];     TrieNode() { arr[0] = arr[1] = nullptr; }   };   void insert(TrieNode *root, int num) {     TrieNode *curr = root;     for (int i = 20; i >= 0; i--) {       if (curr->arr[(num >> i) & 1] == nullptr)         curr->arr[(num >> i) & 1] = new TrieNode();       curr = curr->arr[(num >> i) & 1];     }     return;   }   int query(TrieNode *root, int xr) {     int ans = 0;     TrieNode *curr = root;     for (int i = 20; i >= 0; i--) {       if (curr->arr[(xr >> i) & 1] == nullptr) {         ans |= (1 << i);         curr = curr->arr[((xr >> i) & 1) ^ 1];       } else {         curr = curr->arr[(xr >> i) & 1];       }     }     return ans;   }   const int N = 1 << 20 + 1;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     bool present[N];     memset(present, false, sizeof(present));     vector<int> a(n);     for (int &i : a) cin >> i, present[i] = true;     TrieNode *root = new TrieNode();     for (int i = 0; i < N; i++)       if (!present[i]) insert(root, i);     int curr_xor = 0;     while (m--) {       int x;       cin >> x;       curr_xor ^= x;       cout << query(root, curr_xor) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long bp(long long x, long long y) {     long long ans = 1;     x %= mod;     while (y) {       if (y & 1) ans = ans * x % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long mod_inverse(long long x) { return bp(x, mod - 2); }   long long gcd(long long a, long long b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   long long max(long long a, long long b) {     if (a < b) swap(a, b);     return a;   }   long long min(long long a, long long b) {     if (a > b) swap(a, b);     return a;   }   long long countSetBits(long long n) {     long long count = 0;     while (n) {       count += n & 1;       n >>= 1;     }     return count;   }   void solve() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       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 (n % 2 == 1 && a[n / 2] != b[n / 2]) {         cout <<  No  << endl;         continue;       }       map<pair<long long, long long>, long long> m;       for (long long i = 0; i < n / 2; i++) {         m[make_pair(min(a[i], a[n - 1 - i]), max(a[i], a[n - 1 - i]))]++;       }       long long flag = 0;       for (long long i = 0; i < n / 2; i++) {         pair<long long, long long> p = {min(b[i], b[n - 1 - i]),                                         max(b[i], b[n - 1 - i])};         if (m[p] <= 0) {           flag = 1;           break;         }         m[p]--;       }       if (flag == 1)         cout <<  No  << endl;       else         cout <<  yes  << endl;     }   }   signed main() { solve(); }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long int modInverse(long long int n, long long int p) {     return power(n, p - 2, p) % p;   }   void solve() {     long long int n;     cin >> n;     long long int a[n];     for (long long int i = 0; i < n; i++) cin >> a[i];     string s =   , s1 =   , s2 =   ;     for (long long int i = 0; i < 200; i++) {       s +=  a ;       s1 +=  b ;       s2 +=  a ;     }     cout << s <<   n ;     for (long long int i = 0; i < n; i++) {       if (s[a[i]] ==  a ) {         s = s.substr(0, a[i]) + s1.substr(0, 200 - a[i]);       } else {         s = s.substr(0, a[i]) + s2.substr(0, 200 - a[i]);       }       cout << s <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t;     cin >> t;     while (t--) solve();     return 0;   }