malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long po(long long a, long long b) {     long long x = 1, y = a;     while (b > 0) {       if (b % 2) {         x = x * y;         x %= 1000000007;       }       y = y * y;       y %= 1000000007;       b /= 2;     }     return x;   }   int main() {     if (0) {       freopen( C:/Users/gold/Desktop/sublime IO/input.txt ,  r , stdin);       freopen( C:/Users/gold/Desktop/sublime IO/output.txt ,  w , stdout);     }     int T = 1;     while (T--) {       string s, s1;       cin >> s >> s1;       int n = s.length();       static int cnt[256];       for (int i = 0; i < n; i++) {         cnt[s[i]]++;       }       int m = s1.length();       int ans = 0, ans1 = 0;       for (int i = 0; i < m; i++) {         if (cnt[s1[i]] > 0) {           cnt[s1[i]]--;           ans++;           s1[i] =  1 ;         }       }       for (int i = 0; i < m; i++) {         if (s1[i] ==  1 ) {           continue;         }         if (s1[i] >=  a  && cnt[s1[i] -  a  +  A ] > 0) {           ans1++;           cnt[s1[i] -  a  +  A ]--;         } else if (cnt[s1[i] -  A  +  a ] > 0) {           ans1++;           cnt[s1[i] -  A  +  a ]--;         }       }       printf( %d %d n , ans, ans1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000100;   int n, q, s[N / 2], f[N / 2], par[N / 2], timer;   vector<int> g[N / 2];   void dfs(int x = 1, int pp = 0) {     s[x] = ++timer;     par[x] = pp;     for (auto &it : g[x])       if (it != par[x]) {         dfs(it, x);       }     f[x] = ++timer;   }   struct node {     int sum;     bool set;     void merge(node &lt, node &rt) { sum = lt.sum + rt.sum; }   } st[N << 2];   void push(int x, int lx, int rx) {     if (st[x].set) {       st[x].set = 0;       st[x].sum = rx - lx + 1;       if (lx == rx) return;       st[x << 1].set = st[x << 1 | 1].set = 1;     }   }   void bld(int x = 1, int lx = 1, int rx = n + n) {     if (lx == rx) {       st[x] = {0, 0};       return;     }     int mid = lx + rx >> 1;     bld(x << 1, lx, mid);     bld(x << 1 | 1, mid + 1, rx);     st[x].merge(st[x << 1], st[x << 1 | 1]);   }   void modify(bool z, int &u, int &v, int x = 1, int lx = 1, int rx = n + n) {     push(x, lx, rx);     if (v < lx or u > rx) return;     if (u <= lx and rx <= v) {       if (z) {         st[x].set = 1;         push(x, lx, rx);       } else {         st[x].sum = 0;       }       return;     }     int mid = lx + rx >> 1;     modify(z, u, v, x << 1, lx, mid);     modify(z, u, v, x << 1 | 1, mid + 1, rx);     st[x].merge(st[x << 1], st[x << 1 | 1]);   }   int qry(int &u, int &v, int x = 1, int lx = 1, int rx = n + n) {     push(x, lx, rx);     if (v < lx or u > rx) return 0;     if (u <= lx and rx <= v) return st[x].sum;     int mid = lx + rx >> 1;     return qry(u, v, x << 1, lx, mid) + qry(u, v, x << 1 | 1, mid + 1, rx);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int u, v, i = 1; i < n; i++) {       cin >> u >> v;       g[u].emplace_back(v);       g[v].emplace_back(u);     }     timer = 0;     dfs();     bld();     cin >> q;     int ty, v;     while (q--) {       cin >> ty >> v;       if (ty == 1) {         if (par[v] != 0 and qry(s[v], f[v]) != f[v] - s[v] + 1) {           modify(0, s[par[v]], s[par[v]]);         }         modify(1, s[v], f[v]);       } else if (ty == 2) {         modify(0, s[v], s[v]);       } else {         cout << (qry(s[v], f[v]) == f[v] - s[v] + 1) <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   int n, k, root, col[N], sz[N];   vector<int> g[N], a[N];   int dfs(int v, int pr = -1) {     int mx = col[v];     sz[v] = col[v];     for (auto& to : g[v]) {       if (to == pr) continue;       int root = dfs(to, v);       if (root != -1) return root;       sz[v] += sz[to];       mx = max(mx, sz[to]);     }     mx = max(mx, 2 * k - sz[v]);     if (mx > k) return -1;     return v;   }   void go(int v, int pr = -1) {     priority_queue<pair<int, int>> q;     if (col[v]) {       a[v].push_back(v);       q.push({1, v});     }     for (auto& to : g[v]) {       if (to == pr) continue;       go(to, v);       if (pr != -1) {         if (a[v].size() < a[to].size()) {           a[v].swap(a[to]);         }         a[v].insert(a[v].end(), a[to].begin(), a[to].end());         a[to].clear();       } else {         if (!a[to].empty()) {           q.push({(int)a[to].size(), to});         }       }     }     if (pr == -1) {       while (!q.empty()) {         auto x = q.top();         q.pop();         auto y = q.top();         q.pop();         cout << a[x.second].back() + 1 <<     << a[y.second].back() + 1 <<                  << root + 1 <<   n ;         --x.first;         --y.first;         a[x.second].pop_back();         a[y.second].pop_back();         if (x.first > 0) q.push(x);         if (y.first > 0) q.push(y);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> k;     for (int(i) = 0; (i) < (n - 1); ++(i)) {       int x, y;       cin >> x >> y;       --x;       --y;       g[x].push_back(y);       g[y].push_back(x);     }     for (int(i) = 0; (i) < (2 * k); ++(i)) {       int x;       cin >> x;       --x;       col[x] = 1;     }     root = dfs(0);     cout << 1 <<   n  << root + 1 <<   n ;     go(root);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   long long INF = 1e7;   double EPS = 1e-12;   double tick() {     static clock_t oldt;     clock_t newt = clock();     double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;     oldt = newt;     return diff;   }   long long int powP(long long int a, long long int b) {     if (b == 0) return 1 % mod;     long long int k;     k = powP(a, b / 2);     k = k * k % mod;     if (b % 2 == 0)       return k;     else       return a * k % mod;   }   bool bitSet(long long int n, long long int i) {     if ((n & (1LL << i)) != 0)       return true;     else       return false;   }   long long int findGcd(long long int a, long long int b) {     if (a == 0)       return b;     else       return findGcd(b % a, a);   }   long long int A[700005], B[700005], C[700005];   int main() {     long long int T, i, n, m, p, j, l, e, r, b, c, k, q, a, d, w, x, y, v, z, t,         curr, prev, sum, ans, pos, val, countA, secondMin, indicator;     scanf( %lld , &n);     stack<int> S;     ans = 0;     S.push(0);     B[0] = INT_MAX;     for (long long int i = (1); i <= (n); ++i) {       scanf( %lld , &A[i]);       B[i] = 1;       while (!S.empty() && A[i] > A[S.top()]) {         B[i] = max(B[i], B[S.top()] + 1);         S.pop();       }       if (B[i] < INT_MAX) ans = max(ans, B[i]);       S.push(i);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxx = 2000010;   const double pi = acos(-1.0);   const double eps = 1e-15;   map<pair<long long, long long>, long long> h, mk;   map<pair<long long, pair<long long, long long> >, long long> hh;   int t, n, m, k;   long long ans = 0, total = 0, sum = 0, cnt = 0, pos = 0, s1 = 0, s2 = 0, a1 = 0,             a2 = 0;   long long a[maxx], vis[maxx];   char c[maxx], ch[maxx];   struct nod {     long long v1, v2;   } kl[maxx];   struct node {     int num;     long long val1, val2;   } b[maxx];   bool cmp(node a, node b) {     if (a.val1 == b.val1) return a.val2 < b.val2;     return a.val1 < b.val1;   }   int main() {     scanf( %d%d , &n, &k);     n = n * k;     scanf(  %s , c + 1);     for (int i = n + 1; i <= 2 * n; i++) c[i] = c[i - n];     scanf( %d , &m);     a1 = a2 = 1;     for (int i = 1; i < k; i++)       a1 = a1 * 237 % 998244353, a2 = a2 * 237 % 1000000007;     for (int i = 1; i <= m; i++) {       scanf(  %s , ch + 1);       s1 = s2 = 0;       for (int j = 1; j <= k; j++)         s1 = (s1 * 237 % 998244353 + ch[j] -  a  + 1) % 998244353,         s2 = (s2 * 237 % 1000000007 + ch[j] -  a  + 1) % 1000000007;       h[make_pair(s1, s2)]++, b[i].val1 = s1, b[i].val2 = s2, b[i].num = i;     }     sort(b + 1, b + n + 1, cmp);     for (int i = 1; i <= n; i++) {       mk[make_pair(b[i].val1, b[i].val2)] = i;       for (int j = i; j <= n; j++) {         if (b[i].val1 != b[j].val1 || b[i].val2 != b[j].val2) {           i = j - 1;           break;         }         if (j == n) i = n + 1;       }     }     s1 = s2 = 0;     for (int i = 1; i <= k; i++)       s1 = (s1 * 237 % 998244353 + c[i] -  a  + 1) % 998244353,       s2 = (s2 * 237 % 1000000007 + c[i] -  a  + 1) % 1000000007;     kl[1].v1 = s1, kl[1].v2 = s2;     for (int i = k + 1; i <= 2 * n; i++) {       s1 = (s1 - a1 * (c[i - k] -  a  + 1) % 998244353 + 998244353) % 998244353,       s1 = (s1 * 237 % 998244353 + c[i] -  a  + 1) % 998244353;       s2 =           (s2 - a2 * (c[i - k] -  a  + 1) % 1000000007 + 1000000007) % 1000000007,       s2 = (s2 * 237 % 1000000007 + c[i] -  a  + 1) % 1000000007;       kl[i - k + 1].v1 = s1, kl[i - k + 1].v2 = s2;     }     for (int i = 1; i <= n; i++) {       int u = i % k;       if (vis[u]) continue;       hh[make_pair(u, make_pair(kl[i].v1, kl[i].v2))]++;       if (hh[make_pair(u, make_pair(kl[i].v1, kl[i].v2))] >               h[make_pair(kl[i].v1, kl[i].v2)] ||           !h.count(make_pair(kl[i].v1, kl[i].v2)))         vis[u] = 1;     }     pos = -1;     for (int i = 0; i < k; i++)       if (!vis[i]) {         pos = i;         break;       }     if (pos == -1)       printf( NO );     else {       printf( YES n );       if (!pos) pos = k;       for (int i = pos; i <= n; i += k)         printf( %d  , b[mk[make_pair(kl[i].v1, kl[i].v2)]++].num);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, K, P[105];   int main() {     scanf( %d %d %d , &N, &M, &K);     for (int i = 0; i < K; i++) scanf( %d , &P[i]);     int ans = 0;     for (int i = 0; i < N; i++) {       for (int j = 0; j < M; j++) {         int x;         scanf( %d , &x);         int idx;         for (int k = 0; k < K; k++)           if (x == P[k]) {             idx = k;             break;           }         for (int k = idx; k > 0; k--) P[k] = P[k - 1];         P[0] = x;         ans += idx + 1;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f, N = 2e5 + 5;   const long long inf = 1e18;   inline int read() {     int sum = 0, f = 1;     char c = getchar();     while (c >  9  || c <  0 ) {       if (c ==  - ) f = -f;       c = getchar();     }     while (c >=  0  && c <=  9 ) sum = sum * 10 + c - 48, c = getchar();     return sum * f;   }   int n, m, k, q, t[N][2], safe[N];   long long dp[N][2];   long long cost(int a, int b, int c, int d) {     int pos = lower_bound(safe + 1, safe + q + 1, t[a][b]) - safe;     long long ans = inf;     if (pos <= q)       ans = abs(t[a][b] - safe[pos]) + abs(t[c][d ^ 1] - safe[pos]) +             abs(t[c][d] - t[c][d ^ 1]);     pos = upper_bound(safe + 1, safe + q + 1, t[a][b]) - safe - 1;     if (pos >= 1)       ans =           min(ans, (long long)abs(t[a][b] - safe[pos]) +                        abs(t[c][d ^ 1] - safe[pos]) + abs(t[c][d] - t[c][d ^ 1]));     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m >> k >> q;     for (int i = 1; i <= k; i++) {       int r, c;       cin >> r >> c;       if (t[r][0] == 0)         t[r][0] = c;       else         t[r][0] = min(t[r][0], c);       t[r][1] = max(t[r][1], c);     }     t[1][0] = 1, t[1][1] = max(t[1][1], 1);     for (int i = 1; i <= q; i++) cin >> safe[i];     sort(safe + 1, safe + q + 1);     for (int i = 2; i <= n; i++) dp[i][0] = dp[i][1] = inf;     dp[1][0] = abs(t[1][1] - 1) * 2;     dp[1][1] = abs(t[1][1] - 1);     int pre = 1;     for (int i = 2; i <= n; i++) {       if (t[i][0] == 0) continue;       for (int j = 0; j < 2; j++) {         for (int k = 0; k < 2; k++) {           dp[i][j] = min(dp[i][j], dp[pre][k] + i - pre + cost(pre, k, i, j));         }       }       pre = i;     }     long long ans = min(dp[pre][0], dp[pre][1]);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   int main() {     char s[51];     scanf( %s , s);     int i, tf, na = 0, t1 = strlen(s);     if (t1 >= 1 && t1 <= 50) {       for (i = 0; i < t1; i++) {         if (s[i] ==  a ) {           na = na + 1;         }       }       if (2 * na > t1) {         tf = t1;       } else {         tf = (2 * na) - 1;       }       printf( %d n , tf);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 131;   int a[100002], rmp[100002], n, cnt, ans;   unsigned int h[100002], p[100002];   vector<int> v[100002];   vector<pair<int, int> > del;   map<int, int> mp;   inline bool cmp(int x, int y) {     int xe = y - 1, ye = 2 * y - x - 1;     if (ye > n) return 0;     int hx = h[xe] - h[x - 1] * p[y - x], hy = h[ye] - h[y - 1] * p[y - x];     return hx == hy;   }   inline int read() {     int t = 0;     char v = getchar();     while (v <  0 ) v = getchar();     while (v >=  0 ) t = (t << 3) + (t << 1) + v - 48, v = getchar();     return t;   }   int main() {     p[0] = 1;     n = read();     for (int i = 1; i <= n; ++i) {       int x = read();       if (mp.find(x) != mp.end())         a[i] = mp[x];       else {         mp[x] = ++cnt;         a[i] = cnt;         rmp[cnt] = x;       }       p[i] = p[i - 1] * M;       v[a[i]].push_back(i);       h[i] = h[i - 1] * M + a[i];     }     for (int i = 1; i <= cnt; ++i)       for (int j = 0; j < v[i].size(); ++j)         for (int k = j + 1; k < v[i].size(); ++k)           if (cmp(v[i][j], v[i][k]))             del.push_back(make_pair(v[i][k] - v[i][j], v[i][j]));     sort(del.begin(), del.end());     for (int i = 0; i < del.size(); ++i)       if (del[i].second > ans) ans = del[i].second + del[i].first - 1;     printf( %d n , n - ans);     for (int i = ans + 1; i <= n; ++i) printf( %d  , rmp[a[i]]);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   int N, M;   int arr[MAXN];   int dp[MAXN];   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     cin >> N >> M;     int prv;     cin >> prv;     int lft = 1;     for (int a = 2; a <= N; a++) {       int cur;       cin >> cur;       if (prv <= cur) {       } else {         lft = a;       }       if (prv >= cur) {         dp[a] = min(dp[a - 1], lft);       } else {         dp[a] = lft;       }       prv = cur;     }     while (M--) {       int l, r;       cin >> l >> r;       if (l >= dp[r]) {         cout <<  Yes n ;       } else {         cout <<  No n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int arr[100][100] = {0};     int n, x;     cin >> n >> x;     for (int i = 0; i < n; i++) {       arr[i][i] = x;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cout << arr[i][j] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int trn = 1 << (n + 1);     trn--;     int a[30000];     for (int i = 2; i <= trn; i++) cin >> a[i];     int q = 1 << n;     int mx = 0;     int leng[30000];     for (int i = q; i <= trn; i++) {       leng[i] = 0;       int j = i;       while (j > 0) {         leng[i] += a[j];         j /= 2;       }       mx = max(mx, leng[i]);     }     int add[30000];     for (int i = q; i <= trn; i++) add[i] = mx - leng[i];     for (int depth = n + 1; depth > 1; depth--) {       q = 1 << (depth - 1);       for (int i = q; i < q * 2; i += 2) {         if ((add[i] > 0) && (add[i + 1] > 0)) {           int t = min(add[i], add[i + 1]);           add[i / 2] = t;           add[i] = add[i] - t;           add[i + 1] = add[i + 1] - t;         }       }     }     int ans = 0;     for (int i = 0; i <= trn; i++) ans += add[i];     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   const int N = 1e5 + 5;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   vector<vector<int> > ans;   void solve(int n) {     int i = 1, j = 2, k = 3;     while (k <= n) {       ans.push_back({i, j, k});       i += 2;       j += 2;       k += 2;     }     i = 1, j = 2, k -= 2;     while (j < n - 1) {       ans.push_back({i, j, k});       i += 2, j += 2;     }   }   void solve() {     int n;     cin >> n;     long long a[n];     long long x = 0;     for (long long i = 0; i < n; i++) {       cin >> a[i];       x ^= a[i];     }     if (n % 2 == 0) {       if (x) {         cout <<  NO n ;         return;       } else {         solve(n - 1);       }     } else {       solve(n);     }     cout <<  YES n ;     cout << ans.size() <<   n ;     for (auto v : ans) {       printf( %d %d %d n , v[0], v[1], v[2]);     }   }   signed main() {     int t = 1;     for (long long i = 1; i < t + 1; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   const int N = 1e5 + 5;   int n, k, a[N];   int ans[N], top;   int main() {     scanf( %d%d , &n, &k);     int sum = 0;     for (int i = 1; i <= n; i++) scanf( %d , a + i), sum += a[i];     if (sum % k) return !printf( No );     int num = sum / k;     top = 0;     int now = 0, l = 1;     for (int i = 1; i <= n; i++) {       now += a[i];       if (now > num) return !printf( No );       if (now == num) {         ans[++top] = i - l + 1;         l = i + 1;         now = 0;       }     }     printf( Yes n );     for (int i = 1; i <= top; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long int n, m, t, q, a, b, c, h, d, x, y, z, i, j, k,         ans = 0, ans2 = 0, cur = 0, cur2 = 0, sum = 0, sum2 = 0, maxn;     string str =   , str2, str3;     cin >> t;     while (t--) {       cin >> n >> x >> y;       if (abs(x - y) > 1) {         cout <<  -1 n ;         continue;       } else if (x + y > n - 2) {         cout <<  -1 n ;         continue;       }       a = 1;       b = n;       if (x == y) {         cout <<  1  ;         a++;         for (i = 0; i < x; i++) {           cout << b <<     << a <<    ;           a++;           b--;         }         for (i = a; i <= b; i++) cout << i <<    ;         cout <<   n ;       } else if (x > y) {         for (i = 0; i < x; i++) {           cout << a <<     << b <<    ;           a++;           b--;         }         for (i = b; i >= a; i--) cout << i <<    ;         cout <<   n ;       } else {         for (i = 0; i < y; i++) {           cout << b <<     << a <<    ;           a++;           b--;         }         for (i = a; i <= b; i++) cout << i <<    ;         cout <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long A[100005], Nr[100005], Viz[100005];   vector<pair<long long, long long> > V[100005];   long long n;   long long ans;   long long DFSNR(long long x) {     long long nrc = 1;     Viz[x] = 1;     for (auto i : V[x])       if (!Viz[i.first]) {         nrc += DFSNR(i.first);       }     Nr[x] = nrc;     return nrc;   }   void DFS(long long x, long long dist) {     if (A[x] < dist) {       ans += Nr[x];       return;     }     Viz[x] = 1;     for (auto i : V[x])       if (!Viz[i.first]) {         DFS(i.first, max(dist + i.second, i.second));       }   }   int main() {     cin >> n;     for (long long i = 1; i <= n; i++) cin >> A[i];     for (long long i = 1; i < n; i++) {       long long x, y;       cin >> x >> y;       V[x].push_back({i + 1, y});       V[i + 1].push_back({x, y});     }     DFSNR(1);     memset(Viz, 0, sizeof(Viz));     DFS(1, 0);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   int w, n, m, c[1 << 12], id[1 << 12], f[531441];   int dfs(char* g, int s, int t) {     if (!*g) return c[s] * f[t];     s <<= 1;     t *= 3;     switch (*g++) {       case  A :         return dfs(g, s, t + 2) + dfs(g, s | 1, t);       case  O :         return dfs(g, s, t);       case  X :         return dfs(g, s, t) + dfs(g, s | 1, t + 1);       case  a :         return dfs(g, s | 1, t + 1);       case  o :         return dfs(g, s, t + 1) + dfs(g, s | 1, t + 2);       case  x :         return dfs(g, s, t + 1) + dfs(g, s | 1, t);     }   }   int main() {     scanf( %d%d%d , &w, &n, &m);     for (int i = 1; i < 1 << w; i++) id[i] = id[i / 2] * 3 + i % 2;     while (n--) {       int a;       scanf( %d , &a);       c[a]++;       f[id[a]]++;     }     for (int i = 0, lim = 1; i < w; i++, lim *= 3)       for (int s = 0; s < 1 << w; s += 1 << i + 1)         for (int t = 0, j = id[s]; t < lim; t++, j++)           f[j + lim * 2] += f[j] + f[j + lim];     while (m--) {       char g[15];       scanf( %s , g);       printf( %d n , dfs(g, 0, 0));     }   }
#include <bits/stdc++.h>   using namespace std;   string s[102];   int main() {     int n, i, cnt[27], j, k;     cin >> n;     for (i = 0; i < n; i++) cin >> s[i];     int ans = 0, temp, first, second, x, r;     for (i = 1; i <= 26; i++) {       for (j = 1; j <= 26; j++) {         temp = 0;         for (k = 0; k < n; k++) {           memset(cnt, 0, sizeof(cnt));           x = 0;           for (r = 0; r < s[k].size(); r++) {             cnt[(int)s[k][r] - 96]++;           }           for (r = 1; r <= 26; r++) {             if (cnt[r]) x++;           }           if (x <= 2) {             int flag = 0;             for (r = 1; r <= 26; r++) {               if (cnt[r]) {                 if (r != i && r != j) flag = 1;               }             }             if (flag == 0) temp += s[k].size();           }         }         ans = max(ans, temp);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string ans[10] = {  ,   ,  2 ,  3 ,  223 ,  5 ,  53 ,  7 ,  7222 ,  7332 };   int main() {     int n;     string s, a =   ;     cin >> n;     cin >> s;     for (int i = 0; i < n; i++) {       if (s[i] ==  0  || s[i] ==  1 ) continue;       a += ans[(s[i] -  0 )];     }     sort(a.begin(), a.end());     reverse(a.begin(), a.end());     cout << a << endl;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   void solve() {     ll a, b, p;     string s;     cin >> a >> b >> p >> s;     ll n = s.length();     s[n - 1] = s[n - 2];     vector<ll> cost(n, 0);     if (s[n - 1] ==  A )       cost[n - 1] = a;     else       cost[n - 1] = b;     for (int i = n - 2; i >= 0; i--) {       if (s[i] != s[i + 1]) {         if (s[i] ==  A )           cost[i] = cost[i + 1] + a;         else           cost[i] = cost[i + 1] + b;       } else         cost[i] = cost[i + 1];     }     for (int i = 0; i < n; i++)       if (cost[i] <= p) {         cout << i + 1 << endl;         return;       }     cout << n << endl;   }   int main() {     int ___T;     scanf( %d , &___T);     for (int cs = 1; cs <= ___T; cs++) {       solve();     }     return 0;   }