malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using namespace std::chrono;   void solve() {     int n;     cin >> n;     int a, b, c;     cin >> a >> b >> c;     string s;     cin >> s;     int ap = 0, bp = 0, cp = 0;     for (auto i : s) {       if (i ==  R )         ap++;       else if (i ==  P )         bp++;       else         cp++;     }     int wins = min(b, ap) + min(c, bp) + min(a, cp);     if (wins >= ceil(((long double)1.0 * n / 2))) {       cout <<  YES n ;       string ans(n,  A );       for (int i = 0; i < n; ++i) {         if (s[i] ==  R ) {           if (b > 0) {             ans[i] =  P ;             b--;           } else             ans[i] =  X ;         } else if (s[i] ==  P ) {           if (c > 0) {             ans[i] =  S ;             c--;           } else             ans[i] =  X ;         } else {           if (a > 0) {             ans[i] =  R ;             a--;           } else             ans[i] =  X ;         }       }       for (int i = 0; i < n; ++i) {         if (ans[i] ==  X ) {           if (a > 0) {             ans[i] =  R ;             a--;           } else if (b > 0) {             ans[i] =  P ;             b--;           } else {             ans[i] =  S ;           }         }       }       cout << ans <<   n ;     } else       cout <<  NO n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     cin >> t;     for (int i = 1; i <= t; ++i) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   string w =   RPS ;   string s;   int t[4], n, m, a[105], ans[105];   int main() {     ios::sync_with_stdio(0);     int Q;     cin >> Q;     while (Q--) {       memset(ans, 0, sizeof(ans));       cin >> n >> t[1] >> t[2] >> t[3] >> s;       m = (n + 1) / 2;       for (int i = 0; i < n; i++) switch (s[i]) {           case  R :             a[i] = 2;             break;           case  P :             a[i] = 3;             break;           case  S :             a[i] = 1;             break;         }       for (int i = 0; i < n; i++)         if (t[a[i]]) {           t[a[i]]--;           ans[i] = a[i];         }       if (n - (t[1] + t[2] + t[3]) < (n + 1) / 2) {         cout <<  NO n ;         continue;       }       cout <<  YES n ;       for (int i = 0; i < n; i++)         if (!ans[i]) {           for (int j = 1; j <= 3; j++)             if (t[j]) {               t[j]--, ans[i] = j;               break;             }         }       for (int i = 0; i < n; i++) cout << w[ans[i]];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector )   #pragma GCC target(         sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( fast-math )   using namespace std;   const int INF = 1e9 + 9;   const long long MAXN = 2e5 + 7;   const long long MAXN1 = 1 << 10;   const long long MAXN2 = 1e6 + 7;   const long long MOD = 1e9 + 7;   const long long PW = 239;   const long long BLOCK = 316;   void solve();   mt19937 mt(1e9 + 7);   signed main() {     srand( a  +  l  +  e  +  x  +  X  +  5  +  1  +  2 );     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int q = 1;     if (0) cin >> q;     while (q--) solve();   }   long long dp[MAXN1][MAXN1];   int last[MAXN1];   void solve() {     memset(last, -1, sizeof last);     long long n, k;     string s;     cin >> n >> k >> s;     dp[0][0] = 1;     dp[0][1] = 1;     last[s[0] -  a ] = 0;     for (int i = 1; i < s.size(); ++i) {       dp[i][1] = 1;       for (int j = 2; j <= s.size(); ++j) {         for (int t = 0; t < 26; ++t) {           if (last[t] == -1) continue;           dp[i][j] += dp[last[t]][j - 1];           dp[i][j] = min<long long>(dp[i][j], 1e13);         }       }       last[s[i] -  a ] = i;     }     long long ans = 0;     for (long long i = n; i >= 0; --i) {       if (i == 0) {         long long tmp = min(k, 1ll);         ans += (n - i) * tmp;         k -= tmp;         break;       }       for (int j = 0; j < 26; ++j) {         if (last[j] == -1) continue;         long long tmp = min(k, dp[last[j]][i]);         ans += (n - i) * tmp;         k -= tmp;       }     }     if (k != 0) ans = -1;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     string s;     cin >> s;     int n = s.length();     int r = 0;     vector<int> f(3, -1);     f[0] = 0;     vector<int> z(n + 1);     for (int i = 1; i < (n + 1); ++i) {       r = (r + s[i - 1] -  0 ) % 3;       z[i] = z[i - 1];       if (f[r] != -1) z[i] = max(z[i], z[f[r]] + 1);       f[r] = i;     }     cout << z[n] <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t = 1;     for (int z = 0; z < t; z++) {       solve();     }     cerr <<  Time :   << (double)clock() / (double)CLOCKS_PER_SEC <<  s n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXA = 5e6;   int m, n, k, s, x, l, r, si[MAXA], bo[MAXA], siz[MAXA], a[MAXA], tot;   int check(int l, int r) {     l -= (l - 1) % k;     if (r - l + 1 > n + k) return 0;     int ans = r - l + 1 - k;     if (ans < 0) ans = 0;     printf( %d n , ans);     for (int i = l; i <= r; i++) {       if (ans == 0) break;       if (si[a[i]] > 0)         si[a[i]]--;       else         ans--, printf( %d  , i);     }     exit(0);   }   int main() {     scanf( %d%d%d%d , &m, &k, &n, &s);     n = m - n * k;     for (int i = 1; i <= m; i++) scanf( %d , &a[i]);     for (int i = 1; i <= s; i++) {       scanf( %d , &x);       bo[x] = 1;       siz[x]++;       si[x]++;       tot++;     }     r = 0;     l = 0;     while (r <= m && tot > 0) {       r++;       if (bo[a[r]]) {         siz[a[r]]--;         if (siz[a[r]] >= 0) tot--;       }     }     while (l <= m) {       l++;       if (bo[a[l]]) {         if (siz[a[l]] == 0) break;         siz[a[l]]++;       }     }     if (l <= m && r <= m) check(l, r);     while (r < m && l < m) {       r++;       while (a[r] != a[l] && r <= m) {         if (bo[a[r]]) siz[a[r]]--;         r++;       }       l++;       while ((!(bo[a[l]] && siz[a[l]] == 0) && l <= m)) {         if (bo[a[l]]) siz[a[l]]++;         l++;       }       if (l > m || r > m) break;       check(l, r);     }     printf( -1 );   }
#include <bits/stdc++.h>   using namespace std;   int arr[200005], arr2[200005], n, repeat = 1, maxi, mas;   long double result[200005];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &arr[i]);     }     for (int i = 0; i < n; i++) {       scanf( %d , &arr2[i]);       if (arr[i] != 0) {         result[i] = (arr2[i] / (arr[i] * 1.00000000) * -1.00);       } else if (arr2[i] == 0) {         mas++;         result[i] = -1000000004;       } else         result[i] = -1000000004;     }     sort(result, result + n);     for (int i = 1; i < n; i++) {       if (result[i] == result[i - 1] and result[i] != -1000000004)         repeat++;       else {         if (repeat > maxi and result[i - 1] != -1000000004) maxi = repeat;         repeat = 1;       }     }     if (repeat > maxi and result[n - 1] != -1000000004) {       maxi = repeat;     }     printf( %d , maxi + mas);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double EPS = 1e-10;   double EQ(double a, double b) { return abs(a - b) < EPS; }   void fast_stream() { std::ios_base::sync_with_stdio(0); }   int xs[4];   int ys[4];   int rs[4];   int Rs[4];   void solve() {     for (int i = 0; i < 2; i++) {       cin >> xs[i * 2] >> ys[i * 2] >> rs[i * 2] >> Rs[i * 2];       xs[i * 2 + 1] = xs[i * 2];       ys[i * 2 + 1] = ys[i * 2];       rs[i * 2 + 1] = Rs[i * 2];     }     int cnt = 0;     for (int i = 0; i < 4; i++) {       bool ok = true;       int soto = 0;       int naka = 0;       int hana = 0;       for (int j = 0; j < 4; j++) {         if (i == j)           continue;         else if (i == 0 && j == 1)           continue;         else if (i == 1 && j == 0)           continue;         else if (i == 2 && j == 3)           continue;         else if (i == 3 && j == 2)           continue;         int r = max(rs[i], rs[j]);         int rp = min(rs[i], rs[j]);         double d = sqrt(1.0 * (xs[i] - xs[j]) * (xs[i] - xs[j]) +                         (ys[i] - ys[j]) * (ys[i] - ys[j]));         if (!EQ(r - rp, d) && !EQ(r + rp, d) && r - rp < d && r + rp > d)           ok = false;         else if (((r - rp > d || EQ(r - rp, d)) && rs[i] > rs[j]) ||                  (r + rp < d || EQ(r + rp, d)))           soto++;         else if ((r - rp > d || EQ(r - rp, d)) && rs[i] < rs[j])           naka++;         else           hana++;       }       if (ok && ((soto == 2) || (naka == 2) || (hana == 2))) {         cnt++;       }     }     cout << cnt << endl;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int arr[m];     for (int i = 0; i < m; i++) {       int temp;       cin >> temp;       arr[i] = temp;     }     int middle = 1001;     sort(arr, arr + m);     for (int i = 0; i <= (m - n); i++) {       middle = min(arr[i + n - 1] - arr[i], middle);     }     cout << middle;   }
#include <bits/stdc++.h>   using namespace std;   int n, ans = 0;   long long int mn = int(1e9);   vector<int> c, d;   vector<vector<pair<int, int>>> g;   void dfs(int u, int p = 1) {     d[u] = 1;     for (auto v : g[u])       if (v.first != p) {         dfs(v.first, u);         d[u] += d[v.first];       }     return;   }   void dfs1(int u, int p = 1, long long int dist = 0) {     if (dist > c[u]) {       ans += d[u];       return;     }     for (auto v : g[u])       if (v.first != p) dfs1(v.first, u, max(0LL, dist + v.second));   }   void solve() {     dfs(1);     dfs1(1);     cout << ans <<   n ;     return;   }   void inp() {     cin >> n;     c.resize(n + 1), g.resize(n + 1), d.resize(n + 1);     for (int i = 1; i < n + 1; i++) cin >> c[i];     for (int i = 1; i < n; i++) {       int p, w;       cin >> p >> w;       g[i + 1].push_back(make_pair(p, w));       g[p].push_back(make_pair(i + 1, w));     }     return;   }   int main() {     clock_t beg = clock();     {       cin.tie(0);       ios_base::sync_with_stdio(false);     };     inp();     solve();     clock_t end = clock();     fprintf(stderr,  %.3f sec n , (double)(end - beg) / CLOCKS_PER_SEC);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int _ = 1e2;   const int maxn = 2e5 + _;   struct node {     int y, next;   } a[2 * maxn];   int len, last[maxn];   void ins(int x, int y) {     a[++len].y = y;     a[len].next = last[x];     last[x] = len;   }   int c[maxn];   long long s[maxn];   bool v[maxn], t[maxn];   void dfs(int x, int fr) {     v[x] = true;     for (int k = last[x]; k; k = a[k].next) {       int y = a[k].y;       if (y != fr) {         if (v[y])           t[x] = true;         else           dfs(y, x), t[x] |= t[y];       }     }     if (!t[x]) {       for (int k = last[x]; k; k = a[k].next)         if (a[k].y != fr) s[x] = max(s[x], s[a[k].y]);       s[x] += c[x];     }   }   int main() {     int n, m, x, y;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &c[i]);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &x, &y);       ins(x, y), ins(y, x);     }     int st;     scanf( %d , &st);     dfs(st, 0);     long long ans = 0, mx = 0;     for (int i = 1; i <= n; i++)       if (t[i])         ans += c[i];       else         mx = max(s[i], mx);     printf( %lld n , ans + mx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[60];   int abs(int x) { return x > 0 ? x : -x; }   int f(int x) {     int sum = 0;     for (int i = 0; i < n / 2; ++i) sum += abs(i * 2 + x - a[i]);     return sum;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n / 2; ++i) scanf( %d , a + i);     sort(a, a + n / 2);     printf( %d , min(f(1), f(2)));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-8;   const int MAXN = 10005;   const int INF = 1111111111;   struct Node {     int id, val;     bool operator<(const Node& a) const {       if (a.val == val) return a.id < id;       return a.val < val;     }   };   int du[100];   int n, p, tot, fg;   priority_queue<Node> q;   int main() {     int ca;     scanf( %d , &ca);     while (ca--) {       while (!q.empty()) q.pop();       memset(du, 0, sizeof(du));       scanf( %d%d , &n, &p);       tot = (2 * n + p) * 2;       fg = tot % n;       tot /= n;       Node ft;       for (int i = 1; i < n; i++) {         ft.id = i + 1;         ft.val = 0;         q.push(ft);       }       int cnt = 0;       for (int i = 1; i <= n; i++) {         while (1) {           if (cnt == 2 * n + p) break;           ft = q.top();           while (ft.id <= i) {             q.pop();             ft = q.top();           }           if (fg && du[i] == tot + 1) {             fg--;             break;           } else if (fg == 0 && du[i] == tot)             break;           q.pop();           du[i]++, du[ft.id]++;           ft.val++;           q.push(ft);           printf( %d %d n , i, ft.id);           cnt++;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool matrix[5205][5205];   char inp[1305];   vector<int> divivi;   int func(char c) {     if (c >=  0  && c <=  9 )       return c -  0 ;     else       return c -  A  + 10;   }   bool check(int x, int n) {     int i, j, r, c, ini;     for (r = 0; r < n / x; r++) {       for (c = 0; c < n / x; c++) {         ini = matrix[r * x][c * x];         for (i = 0; i < x; i++)           for (j = 0; j < x; j++)             if (matrix[r * x + i][c * x + j] != ini) return 0;       }     }     return 1;   }   int main() {     int n, i, j, cal;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %s n , inp);       for (j = 0; j < n / 4; j++) {         cal = func(inp[j]);         matrix[i][j * 4] = (cal & 8);         matrix[i][j * 4 + 1] = (cal & 4);         matrix[i][j * 4 + 2] = (cal & 2);         matrix[i][j * 4 + 3] = (cal & 1);       }     }     for (i = 1; i <= n; i++)       if (n % i == 0) divivi.push_back(i);     for (i = divivi.size() - 1; i >= 1; i--)       if (check(divivi[i], n)) {         printf( %d n , divivi[i]);         return 0;       }     printf( %d n , divivi[0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void _print(long long t) { cerr << t; }   void _print(int t) { cerr << t; }   void _print(string t) { cerr << t; }   void _print(char t) { cerr << t; }   void _print(long double t) { cerr << t; }   void _print(double t) { cerr << t; }   void _print(unsigned long long t) { cerr << t; }   template <class T, class V>   void _print(pair<T, V> p);   template <class T>   void _print(vector<T> v);   template <class T>   void _print(set<T> v);   template <class T, class V>   void _print(map<T, V> v);   template <class T>   void _print(multiset<T> v);   template <class T, class V>   void _print(pair<T, V> p) {     cerr <<  { ;     _print(p.first);     cerr <<  , ;     _print(p.second);     cerr <<  } ;   }   template <class T>   void _print(vector<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(set<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(multiset<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T, class V>   void _print(map<T, V> v) {     cerr <<  [  ;     for (auto i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   long long gcd(long long a, long long b) {     if (b > a) {       return gcd(b, a);     }     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   long long mexpo(long long a, long long b, long long m) {     long long res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % m;       a = (a * a) % m;       b = b >> 1;     }     return res;   }   vector<int> prime;   void seive(long long n) {     int lp[n + 1];     for (int i = 2; i <= n; ++i) {       if (lp[i] == 0) {         lp[i] = i;         prime.push_back(i);       }       for (int j = 0;            j < (int)prime.size() && prime[j] <= lp[i] && i * prime[j] <= n; ++j)         lp[i * prime[j]] = prime[j];     }   }   int main() {     clock_t begin = clock();     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int T;     cin >> T;     while (T--) {       int m;       cin >> m;       int a[m], b[m];       for (int i = 0; i <= m - 1; i++) {         cin >> a[i];       }       for (int i = 0; i <= m - 1; i++) {         cin >> b[i];       }       int sufa[m], prefb[m];       sufa[m - 1] = 0;       prefb[0] = 0;       for (int i = m - 2; i >= 0; i--) {         sufa[i] = sufa[i + 1] + a[i + 1];       }       for (int i = 1; i <= m - 1; i++) {         prefb[i] = prefb[i - 1] + b[i - 1];       }       int idx = -1;       int i = 0;       int val = 0;       int total = INT_MAX;       while (i < m) {         if (min(total, max(prefb[i], sufa[i])) != total) {           total = max(prefb[i], sufa[i]);           idx = i;         }         i++;       }       total = max(prefb[idx], sufa[idx]);       cout << total <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     char* c = new char[k];     for (int i = 0; i < k; i++) {       c[i] =  a  + i;     }     for (int i = 0; i < n; i++) {       cout << c[i % k];     }   }
#include <bits/stdc++.h>   using namespace std;   int x, cnt;   vector<int> rj;   bool good(int n) {     bool t = false;     for (int i = 20; i >= 0; i--) {       if (n & (1 << i)) t = true;       if (t && !(n & (1 << i))) return false;     }     return true;   }   int fix(int n) {     bool t = false;     for (int i = 20; i >= 0; i--) {       if (n & (1 << i)) t = true;       if (t && !(n & (1 << i))) {         int m = (1 << (i + 1)) - 1;         n ^= m;         rj.push_back(i + 1);         break;       }     }     return n;   }   void stop(int n) {     cout << n <<   n ;     for (int i = 0; i < rj.size(); i++) {       cout << rj[i] <<    ;     }     exit(0);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> x;     if (good(x)) stop(cnt);     while (true) {       x = fix(x);       cnt++;       if (good(x)) stop(cnt);       x++;       cnt++;       if (good(x)) stop(cnt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> St[5 * (int)(2e5 + 10)], arr[(int)(2e5 + 10)],       A[(int)(2e5 + 10)];   int ans[(int)(2e5 + 10)], t[(int)(2e5 + 10)], b[(int)(2e5 + 10)];   int i, j, k, n, m, x, y, z;   vector<pair<int, pair<int, int> > > v;   vector<int> v2;   map<int, int> H;   pair<int, int> que(int root, int bas, int son, int x, int y) {     if (bas > y or son < x) return make_pair(0, 0);     if (x <= bas and son <= y) return St[root];     return max(que((root << 1), bas, ((bas + son) >> 1), x, y),                que(((root << 1) | 1), ((bas + son) >> 1) + 1, son, x, y));   }   pair<int, int> upd(int root, int bas, int son, int x, pair<int, int> t) {     if (bas > x or son < x) return St[root];     if (bas == son) return St[root] = t;     return St[root] =                max(upd((root << 1), bas, ((bas + son) >> 1), x, t),                    upd(((root << 1) | 1), ((bas + son) >> 1) + 1, son, x, t));   }   int main() {     cin >> n >> m;     for (i = 1; i <= n; i++) {       scanf( %d %d %d , &arr[i].first, &arr[i].second, t + i);       v2.push_back(t[i]);       v.push_back(make_pair(arr[i].first, make_pair(0, i)));     }     for (i = 1; i <= m; i++) {       scanf( %d %d %d , &A[i].first, &A[i].second, b + i);       v2.push_back(b[i]);       v.push_back(make_pair(A[i].first, make_pair(1, i)));     }     sort(v2.begin(), v2.end());     int s = 0;     H[v2[0]] = ++s;     for (i = 1; i < v2.size(); i++) {       if (v2[i] != v2[i - 1]) H[v2[i]] = ++s;     }     sort(v.begin(), v.end());     for (i = 0; i < v.size(); i++) {       int x = v[i].second.second;       int p = v[i].second.first;       if (p) {         int bas = H[b[x]];         int son = s;         while (bas < son) {           if (que(1, 1, s, H[b[x]], ((bas + son) >> 1)).first >= A[x].second)             son = ((bas + son) >> 1);           else             bas = ((bas + son) >> 1) + 1;         }         pair<int, int> a = que(1, 1, s, H[b[x]], bas);         if (a.first >= A[x].second) ans[x] = a.second;       } else         upd(1, 1, s, H[t[x]], make_pair(arr[x].second, x));     }     for (i = 1; i <= m; i++) {       if (ans[i])         cout << ans[i] <<    ;       else         cout << -1 <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   const double eps = 1e-9;   const int maxn = 20000000 + 20;   long long dp[maxn];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n, x, y;     cin >> n >> x >> y;     memset(dp, oo, sizeof dp);     dp[1] = x;     dp[2] = x + y;     for (int i = 2; i <= n; ++i) {       dp[i] = min(dp[i], dp[i - 1] + x);       dp[i] = min(dp[i], dp[i + 1] + x);       dp[2 * i] = min(dp[2 * i], dp[i] + y);       dp[2 * i - 1] = min(dp[2 * i - 1], dp[2 * i] + x);     }     cout << dp[n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int a[N];   int cnt[N];   int need[N];   int n, m;   int getbit(int x, int i) { return (x >> i) & 1; }   void add(int x, int val) {     for (int mask = 0; mask < (1 << 6); mask++)       if (getbit(mask, x)) cnt[mask] += val;   }   bool check() {     for (int mask = 0; mask < (1 << 6); mask++)       if (cnt[mask] < need[mask]) return false;     return true;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string s;     cin >> s;     for (char c : s) add(c -  a , 1);     n = s.size();     for (int i = 1; i <= n; i++) a[i] = 63;     cin >> m;     for (int i = 1; i <= m; i++) {       int id;       string t;       cin >> id >> t;       int mask = 0;       for (char c : t) mask |= (1 << (c -  a ));       a[id] = mask;     }     for (int i = 1; i <= n; i++) need[a[i]]++;     for (int i = 0; i < 6; i++)       for (int mask = 0; mask < (1 << 6); mask++)         if (getbit(mask, i)) need[mask] += need[mask ^ (1 << i)];     string ans;     for (int i = 1; i <= n; i++) {       bool found = false;       for (int mask = a[i]; mask < (1 << 6); mask = (mask + 1) | a[i])         need[mask]--;       for (int j = 0; j <= 5; j++)         if (getbit(a[i], j)) {           add(j, -1);           if (check()) {             ans += (char)j +  a ;             found = true;             break;           }           add(j, 1);         }       if (!found) {         ans =  Impossible ;         break;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e9 + 5;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n, m, c, cost = 0;     cin >> n >> m;     for (long long i = 0; i < n; i++) {       long long temp = N;       for (long long j = 0; j < m; j++) {         cin >> c;         temp = min(temp, c);       }       cost = max(temp, cost);     }     cout << cost <<   n ;     return 0;   }