malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T, class L>   bool smax(T& x, L y) {     return x < y ? (x = y, 1) : 0;   }   template <class T, class L>   bool smin(T& x, L y) {     return x > y ? (x = y, 1) : 0;   }   const int maxn = 2e6 + 17;   pair<int, pair<int, int> > a[maxn];   int n, m, par[maxn], mx[maxn], here[maxn];   map<pair<int, int>, int> ans;   int r(int v) { return par[v] < 0 ? v : par[v] = r(par[v]); }   void mrg(int v, int u) {     if ((v = r(v)) == (u = r(u))) return;     if (par[u] < par[v]) swap(v, u);     par[v] += par[u];     par[u] = v;     smax(mx[v], mx[u]);   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0, x; j < m; j++) cin >> x, a[i * m + j] = {x, {i, j}};     sort(a, a + n * m);     for (int l = 0; l < n * m;) {       int r = l;       while (a[r].first == a[l].first) r++;       for (int i = l; i < r; i++) {         mx[a[i].second.first] = mx[a[i].second.second + n] = 0;         par[a[i].second.first] = par[a[i].second.second + n] = -1;       }       for (int i = l; i < r; i++)         smax(mx[a[i].second.first],              max(here[a[i].second.first], here[a[i].second.second + n]) + 1);       for (int i = l; i < r; i++) mrg(a[i].second.first, a[i].second.second + n);       for (int i = l; i < r; i++) {         ans[{a[i].second.first, a[i].second.second}] = mx[::r(a[i].second.first)];         smax(here[a[i].second.first],              ans[{a[i].second.first, a[i].second.second}]);         smax(here[a[i].second.second + n],              ans[{a[i].second.first, a[i].second.second}]);       }       l = r;     }     for (int i = 0; i < n; i++, cout <<   n )       for (int j = 0; j < m; j++) cout << ans[{i, j}] <<    ;     return 0;   }
#include <bits/stdc++.h>   const long long base1 = 131;   const long long base2 = 233;   const long long mod1 = 998244353;   const long long mod2 = 1e9 + 7;   const long long MaxN = 1e6 + 50;   template <class t>   inline void read(t &s) {     s = 0;     register long long f = 1;     register char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();     s *= f;     return;   }   template <class t, class... A>   inline void read(t &x, A &...a) {     read(x);     read(a...);   }   template <class t>   inline void write(t x) {     if (x < 0) putchar( - ), x = -x;     long long buf[21], top = 0;     while (x) buf[++top] = x % 10, x /= 10;     if (!top) buf[++top] = 0;     while (top) putchar(buf[top--] ^  0 );     return;   }   inline void setIn(std::string s) {     freopen(s.c_str(),  r , stdin);     return;   }   inline void setOut(std::string s) {     freopen(s.c_str(),  w , stdout);     return;   }   inline void setIO(std::string s =   ) {     setIn(s +  .in );     setOut(s +  .out );     return;   }   template <class t>   inline bool checkmin(t &x, t y) {     if (x > y) {       x = y;       return 1;     }     return 0;   }   template <class t>   inline bool checkmax(t &x, t y) {     if (x < y) {       x = y;       return 1;     }     return 0;   }   inline long long lowbit(long long x) { return x & (-x); }   std::vector<long long> E[MaxN];   std::pair<long long, long long> f[MaxN];   long long e1[MaxN], e2[MaxN], U[MaxN], V[MaxN];   signed main(void) {     long long n, m;     read(n, m);     register long long u, v, ans = 0;     for (long long i = 1; i <= m; ++i)       read(u, v), U[i] = u, V[i] = v, E[u].push_back(v), E[v].push_back(u);     for (long long i = 1; i <= n; ++i) std::sort((E[i]).begin(), (E[i]).end());     for (long long i = 1; i <= n; ++i) {       register long long s1 = 0, s2 = 0;       for (auto v : E[i])         s1 = (s1 * base1 + v) % mod1, s2 = (s2 * base2 + v) % mod2;       f[i] = std::make_pair(s1, s2);       s1 = 0, s2 = 0;       E[i].push_back(i), std::sort((E[i]).begin(), (E[i]).end());       for (auto v : E[i])         s1 = (s1 * base1 + v) % mod1, s2 = (s2 * base2 + v) % mod2;       e1[i] = s1, e2[i] = s2;     }     std::sort(f + 1, f + n + 1);     register long long cnt = 0;     for (long long i = 2; i <= n; ans += cnt, ++i)       cnt = (f[i] == f[i - 1]) ? (cnt + 1) : 0;     for (long long i = 1; i <= m; ++i)       if (e1[U[i]] == e1[V[i]] && e2[U[i]] == e2[V[i]]) ++ans;     write(ans), std::puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2e6 + 5;   char s1[MAX], s2[MAX];   int main() {     cin >> s1 + 1;     cin >> s2 + 1;     int len1 = strlen(s1 + 1);     int len2 = strlen(s2 + 1);     int i = 1, j = 1;     for (; i <= len1 && j <= len2;) {       if (s1[i] == s2[j])         i++, j++;       else         j++;     }     if (i != len1 + 1) {       puts( 0 );       return 0;     }     int tmp1 = j - 1;     for (i = len1, j = len2; j >= 1 && i >= 1;) {       if (s1[i] == s2[j])         i--, j--;       else         j--;     }     if (i != 0) {       puts( 0 );       return 0;     }     int tmp2 = j + 1;     if (tmp2 - tmp1 >= 0) {       printf( %d n , tmp2 - tmp1);     } else       printf( 0 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MXN = 200;   const int MXK = 5;   int bans = -1;   int t[MXN][MXK];   int a[MXK];   int n;   int c[MXK];   int cc[] = {500, 1000, 1500, 2000, 2500, 3000};   int cat(int c, int n) {     if (c * 2 > n) {       return 0;     }     if (c * 4 > n && c * 2 <= n) {       return 1;     }     if (c * 8 > n && c * 4 <= n) {       return 2;     }     if (c * 16 > n && c * 8 <= n) {       return 3;     }     if (c * 32 > n && c * 16 <= n) {       return 4;     }     if (c * 32 <= n) {       return 5;     }   }   int calc(int i) {     int res = 0;     for (int j = (0); j < (MXK); j++) {       if (t[i][j] != -1) res += cc[a[j]] - t[i][j] * cc[a[j]] / 250;     }     return res;   }   bool ok(int c, int n, int tt, int j) {     return cat(c + tt * (t[0][j] != -1), n + tt) <= a[j] &&            cat(c, n + tt) >= a[j];   }   int T;   void dfs(int i) {     if (i == MXK) {       int mn = 0;       for (int j = (0); j < (MXK); j++) {         if (!ok(c[j], n, T, j)) return;       }       if (calc(0) > calc(1)) {         printf( %d , T);         exit(0);       }       return;     }     for (int j = (0); j < (6); j++) {       a[i] = j;       dfs(i + 1);     }   }   int main() {     scanf( %d , &n);     for (int i = (0); i < (n); i++) {       for (int j = (0); j < (5); j++) {         scanf( %d , &t[i][j]);         if (t[i][j] != -1) {           c[j]++;         }       }     }     for (int i = (0); i < (n * 31 + 1); i++) {       T = i;       dfs(0);     }     cout << bans;   }
#include <bits/stdc++.h>   using namespace std;   int n, l, r, id[1010][1010];   bool tag[1010][1010];   struct node {     int x, y;     pair<vector<node>, int> e() {       vector<node> v;       int c = 0;       v.push_back((node){x + 1, y});       if (x > 0)         v.push_back((node){x - 1, y});       else         c++;       if (x & 1) {         if (x > 0)           v.push_back((node){x - 1, y + 1});         else           c++;       } else {         if (y > 0)           v.push_back((node){x + 1, y - 1});         else           c++;       }       return make_pair(v, c);     }   } a[250010], q[2500010];   vector<node> V;   void dfs(node x, node la) {     if (tag[x.x][x.y]) {       puts( SICK ), exit(0);     }     V.push_back(x), tag[x.x][x.y] = 1;     vector<node> v = x.e().first;     for (int j = 0, sz = v.size(); j < sz; j++)       if (id[v[j].x][v[j].y] && (v[j].x != la.x || v[j].y != la.y)) {         dfs(v[j], x);       }   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i].x >> a[i].y;       tag[a[i].x][a[i].y] = 1;     }     l = 1, r = n;     for (int i = 1; i <= n; i++) q[i] = a[i];     while (l <= r) {       id[q[l].x][q[l].y] = l;       vector<node> u = q[l].e().first, v;       for (int j = 0, sz = u.size(); j < sz; j++) {         if (tag[u[j].x][u[j].y]) continue;         v = u[j].e().first;         for (int k = 0, Sz = v.size(); k < Sz; k++)           if (id[v[k].x][v[k].y] && id[v[k].x][v[k].y] != l) {             q[++r] = u[j], tag[u[j].x][u[j].y] = 1;             break;           }       }       l++;     }     int cnt = 0, ans = 0;     memset(tag, 0, sizeof(tag));     for (int i = 1; i <= r; i++)       if (!tag[q[i].x][q[i].y]) {         V.clear();         cnt++;         dfs(q[i], (node){-1, -1});         if (V.size() == 4) {           int cc = 0;           for (int j = 0; j < 4; j++)             if (id[V[j].x][V[j].y] > n) {               cc++;               vector<node> v = V[j].e().first;               if (v.size() == 3) {                 for (int k = 0; k < 4; k++)                   if (k != j) {                     bool tag = 0;                     for (int l = 0; l < 3; l++)                       if (V[k].x == v[l].x && V[k].y == v[l].y) tag = 1;                     if (tag) cc -= 10;                   }               }             }           if (cc == -29) cnt++;         }       }     for (int i = n + 1; i <= r; i++) id[q[i].x][q[i].y] = 0;     for (int i = 1; i <= n; i++) {       pair<vector<node>, int> v = q[i].e();       ans += v.second;       for (int u, j = 0, sz = v.first.size(); j < sz; j++)         if (!id[v.first[j].x][v.first[j].y]) {           ans++;         }     }     printf( RECOVERED n%d n , ans - 2 * cnt);   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void print(T x) {     cout << x << endl;   }   template <typename T1, typename T2>   void print2(T1 x, T2 y) {     cout << x <<     << y << endl;   }   template <typename T1, typename T2, typename T3>   void print3(T1 x, T2 y, T3 z) {     cout << x <<     << y <<     << z << endl;   }   void chandan1() {     int y = 1;     return;   }   void chandan2() {     for (long long int i = 0; i < 10; i++) {       long long int x = 1;     }     return (chandan1());   }   vector<long long int> path;   void bfs(vector<long long int> adj[], long long int v, long long int source,            long long int destin) {     bool vis[v + 1];     long long int parent[v + 1];     for (long long int i = 0; i < v + 1; i++) {       vis[i] = 0;     }     parent[source] = source;     queue<long long int> q;     q.push(source);     vis[source] = 1;     while (q.empty() == false) {       long long int u = q.front();       q.pop();       for (auto xt : adj[u]) {         if (vis[xt] == 0) {           vis[xt] = 1;           parent[xt] = u;           q.push(xt);         }       }     }     vector<long long int> temp;     while (parent[destin] != destin) {       temp.emplace_back(destin);       destin = parent[destin];     }     reverse(temp.begin(), temp.end());     for (auto xt : temp) path.emplace_back(xt);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t = 1;     chandan2();     while (t--) {       long long int v, e;       cin >> v;       vector<long long int> adj[v + 1];       for (long long int i = 0; i < v - 1; i++) {         long long int a, b;         cin >> a >> b;         adj[a].emplace_back(b);         adj[b].emplace_back(a);       }       vector<long long int> leaves;       leaves.emplace_back(1);       long long int val;       while (cin >> val) {         leaves.emplace_back(val);       }       leaves.emplace_back(1);       path.emplace_back(1);       for (long long int i = 0; i < int(leaves.size()) - 1; i++) {         long long int src = leaves[i];         long long int desti = leaves[i + 1];         bfs(adj, v, src, desti);       }       if (int(path.size()) > (2 * v - 1))         print(-1);       else {         for (auto xt : path) cout << xt <<    ;         cout <<   n ;         ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int dp[10000];     for (int i = 0; i < n; i++) cin >> dp[i];     dp[1] = min(dp[1], dp[0]);     for (int i = 2; i < n; i++) dp[i] = min(dp[i], max(dp[i - 1], dp[i - 2]));     cout << dp[n - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T max(T a, T b, T c) {     return max(a, max(b, c));   }   template <class T>   T min(T a, T b, T c) {     return min(a, min(b, c));   }   const double PI = 2.0 * acos(0.0);   const int mx[] = {0, 1, 0, -1};   const int my[] = {-1, 0, 1, 0};   int check(long long s) {     int res = 0;     while (s > 0) res += s % 10, s /= 10;     return res;   }   int main() {     vector<int> ans;     int a, b, c;     ans.clear();     scanf( %d%d%d , &a, &b, &c);     for (int i = 1; i <= 81; i++) {       long long tmp = b;       for (int j = 1; j <= a; j++) tmp *= i;       tmp += c;       if (tmp < 1e9 && check(tmp) == i) ans.push_back(tmp);     }     sort(ans.begin(), ans.end());     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); i++) {       if (i > 0) putchar(   );       printf( %d , ans[i]);     }     putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   using ll = long long;   template <typename T>   void DEBUG(string label, T value) {     cerr <<  [  << label <<   =   << value <<  ] n ;   }   map<string, int> encode;   map<int, string> decode;   int m, n;   vector<vector<int>> adj;   void solve() {     cin >> m;     n = 0;     for (int i = 0; i < m; ++i) {       string a, b;       cin >> a >> b;       if (encode.count(a) == 0) {         encode[a] = n;         decode[n] = a;         n++;       }       if (encode.count(b) == 0) {         encode[b] = n;         decode[n] = b;         n++;       }       while (adj.size() < n) {         adj.push_back(vector<int>());       }       adj[encode[a]].push_back(encode[b]);       adj[encode[b]].push_back(encode[a]);     }     cout << n <<   n ;     for (int i = 0; i < n; ++i) {       vector<bool> vis(n);       vis[i] = true;       for (int nxt : adj[i]) {         vis[nxt] = true;       }       vector<int> cnt(n);       for (int nxt : adj[i]) {         for (int k : adj[nxt]) {           if (!vis[k]) {             cnt[k]++;           }         }       }       int mx = *max_element(cnt.begin(), cnt.end());       int ans = 0;       for (int j = 0; j < n; ++j) {         ans += (!vis[j] && cnt[j] == mx);       }       cout << decode[i] <<     << ans <<   n ;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int t;     t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int p[201], bag[201];   int n, l, k;   double mem[202][202][202];   double solve(int r, int bagwon, int prizewon) {     if (mem[r][bagwon][prizewon] >= -.5) return mem[r][bagwon][prizewon];     if (r == n)       return mem[r][bagwon][prizewon] =                  bagwon + k >= prizewon && prizewon >= l ? 1 : 0;     if (bag[r] == -1)       return mem[r][bagwon][prizewon] =                  double(p[r] * solve(r + 1, bagwon, prizewon + 1) +                         (100 - p[r]) * solve(r + 1, bagwon, prizewon)) /                  100;     else       return mem[r][bagwon][prizewon] =                  double(p[r] * solve(r + 1, min(200, bagwon + bag[r] + 1),                                      prizewon + 1) +                         (100 - p[r]) * solve(r + 1, bagwon, prizewon)) /                  100;   }   int main() {     memset(mem, -1, sizeof mem);     cin >> n >> l >> k;     for (int i = 0; i < n; i++) cin >> p[i];     for (int i = 0; i < n; i++) cin >> bag[i];     cout.precision(100);     cout << fixed << solve(0, 0, 0) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1e9 + 7;   vector<string> v(100005);   long long int n, m;   long long int check(string s, string str) {     long long int count = 0;     for (long long int i = 0; i < s.size(); i++) {       if (str[i] != s[i]) count++;     }     return count;   }   bool ok(string s) {     for (long long int i = 0; i < n; i++) {       long long int x = check(s, v[i]);       if (x > 1) return false;     }     return true;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t;     cin >> t;     while (t--) {       cin >> n >> m;       string ans =  -1 ;       for (long long int i = 0; i < n; i++) {         cin >> v[i];       }       for (long long int i = 0; i < n; i++) {         for (long long int j = 0; j < v[i].size(); j++) {           for (char k =  a ; k <=  z ; k++) {             string str = v[i];             str[j] = k;             if (ok(str)) {               ans = str;             }           }         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int maxn = 1010;   int Dp[maxn][maxn], dp[maxn][maxn], f[maxn][maxn], g[maxn][maxn];   int a[maxn][maxn];   int n, m;   int main() {     while (~scanf( %d%d , &n, &m)) {       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j) scanf( %d , &a[i][j]);       memset(Dp, 0, sizeof(Dp));       memset(dp, 0, sizeof(dp));       memset(f, 0, sizeof(f));       memset(g, 0, sizeof(g));       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j)           dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];       for (int i = n; i >= 1; --i)         for (int j = m; j >= 1; --j)           Dp[i][j] = max(Dp[i + 1][j], Dp[i][j + 1]) + a[i][j];       for (int i = n; i >= 1; --i)         for (int j = 1; j <= m; ++j)           f[i][j] = max(f[i + 1][j], f[i][j - 1]) + a[i][j];       for (int i = 1; i <= n; ++i)         for (int j = m; j >= 1; --j)           g[i][j] = max(g[i - 1][j], g[i][j + 1]) + a[i][j];       int Ans = 0;       for (int i = 2; i < n; ++i)         for (int j = 2; j < m; ++j)           Ans = max(Ans,                     max(dp[i - 1][j] + Dp[i + 1][j] + f[i][j - 1] + g[i][j + 1],                         dp[i][j - 1] + Dp[i][j + 1] + f[i + 1][j] + g[i - 1][j]));       printf( %d n , Ans);     }   }
#include <bits/stdc++.h>   using namespace std;   string s;   int n, m, t, x, g;   int f[100005];   string b[15];   int l[15];   int main() {     cin >> s;     n = s.length();     scanf( %d n , &m);     for (int i = 0; i < m; i++) {       cin >> b[i];       l[i] = b[i].length();       scanf(  n );     }     f[0] = 0;     for (int i = 0; i < n; i++) {       x = f[i] + 1;       t = 0;       for (int j = 0; j < m; j++)         if (l[j] <= x) {           g = 1;           for (int w = 0; w < l[j]; w++)             if (b[j][w] != s[i - l[j] + 1 + w]) {               g = 0;               break;             }           t = g;           if (t) break;         }       if (!t) {         f[i + 1] = x;         continue;       }       x = i + 1;       t = 1000;       for (int j = 0; j < m; j++)         if (l[j] <= x) {           g = 1;           for (int w = 0; w < l[j]; w++)             if (b[j][w] != s[i - l[j] + 1 + w]) {               g = 0;               break;             }           if (g) {             if (l[j] < t) t = l[j];           }         }       f[i + 1] = t - 1;     }     t = 0;     x = -1;     for (int i = 1; i <= n; i++)       if (f[i] > t) {         t = f[i];         x = i - 1;       }     printf( %d %d n , t, x - t + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, M, k;     string in;     list<string> ret;     cin >> N >> M;     cin >> in >> k;     if (k == 0) {       for (int i = 0; i < N; i++) in[i] = ((in[i] -  0 ) ^ 1) +  0 ;       ret.push_back(in);     } else {       long long s = (1LL << k) - 1;       while (!(s & 1LL << N)) {         string c = in;         for (int i = 0; i < N; i++)           if (!(s & (1LL << i))) c[i] = ((c[i] -  0 ) ^ 1) +  0 ;         ret.push_back(c);         long long lo = s & ~(s - 1);         long long lz = (s + lo) & ~s;         s |= lz;         s &= ~(lz - 1);         s |= (lz / lo / 2) - 1;       }     }     for (int i = 1; i < M; i++) {       cin >> in >> k;       list<string>::iterator it = ret.begin();       while (it != ret.end()) {         int c = 0;         for (int j = 0; j < N; j++)           if ((*it)[j] == in[j]) c++;         if (c != k)           it = ret.erase(it);         else           it++;       }     }     cout << ret.size();     return 0;   }
#include <bits/stdc++.h>   const double eps = (1e-9);   using namespace std;   int dcmp(long double a, long double b) {     return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;   }   int getBit(long long num, int idx) { return ((num >> idx) & 1ll) == 1; }   int setBit1(int num, int idx) { return num | (1 << idx); }   long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }   long long flipBit(long long num, int idx) { return num ^ (1ll << idx); }   void M() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int countNumBit1(int mask) {     int ret = 0;     while (mask) {       mask &= (mask - 1);       ++ret;     }     return ret;   }   string st;   int n;   int main() {     M();     cin >> n >> st;     char c1, c2, c3, F, S, T;     int mi = INT_MAX;     for (int i = 1; i <= 3; i++) {       for (int j = 1; j <= 3; j++) {         for (int k = 1; k <= 3; k++) {           int cnt1 = 0, cnt2 = 0, cnt3 = 0;           if (i == j || i == k || j == k) continue;           c1 = (i == 1 ?  R  : (i == 2 ?  B  :  G ));           c2 = (j == 1 ?  R  : (j == 2 ?  B  :  G ));           c3 = (k == 1 ?  R  : (k == 2 ?  B  :  G ));           for (int l = 0; l < n; l += 3) {             if (st[l] != c1) cnt1++;           }           for (int l = 1; l < n; l += 3) {             if (st[l] != c2) cnt2++;           }           for (int l = 2; l < n; l += 3) {             if (st[l] != c3) cnt3++;           }           long long ans = cnt1 + cnt2 + cnt3;           if (ans < mi) {             mi = ans;             F = c1;             S = c2;             T = c3;           }         }       }     }     for (int l = 0; l < n; l += 3) {       st[l] = F;     }     for (int l = 1; l < n; l += 3) {       st[l] = S;     }     for (int l = 2; l < n; l += 3) {       st[l] = T;     }     cout << mi << endl << st << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 520, M = 512;   int f[N], g[N];   int a[int(1e6)];   int n;   int main() {     scanf( %d , &n);     for (register int i = 1; i <= n; ++i) scanf( %d , a + i);     for (register int i = 1; i < M; ++i) f[i] = 1e9;     f[0] = -1;     for (register int i = 1; i <= n; ++i) {       for (register int k = 0; k < M; ++k) {         g[k] = f[k];         if (f[k xor a[i]] < a[i]) g[k] = min(f[k], a[i]);       }       swap(f, g);     }     int cnt = 0;     for (register int i = 0; i < M; ++i)       if (f[i] != int(1e9)) ++cnt;     printf( %d n , cnt);     for (register int i = 0; i < M; ++i)       if (f[i] != int(1e9)) printf( %d  , i);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   int m, n, q, x;   int ans;   int a[N], b[N];   char s[N], p[N], t[N];   int main() {     int T;     scanf( %d , &T);     while (T--) {       int pt1, pt2;       pt1 = pt2 = 0;       memset(a, 0, sizeof(a));       memset(b, 0, sizeof(b));       cin >> s >> t >> p;       int f = 0;       int lens = strlen(s);       int lenp = strlen(p);       int lent = strlen(t);       for (pt2 = 0; pt2 < lent; pt2++) {         if (s[pt1] == t[pt2]) {           pt1++;         } else           b[t[pt2] -  a ]++;       }       if (pt1 < lens) {         cout <<  NO  << endl;         continue;       }       for (int i = 0; i < lenp; i++) a[p[i] -  a ]++;       for (int i = 0; i < 26; i++) {         if (b[i] > a[i]) {           f = 1;           cout <<  NO  << endl;           break;         }       }       if (f == 0) cout <<  YES  << endl;     }     return 0;   }