malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int P = 1e9 + 7;   int p[11];   vector<int> operator*(const vector<int> &lhs, const vector<int> &rhs) {     vector<int> ret;     ret.resize(lhs.size() + rhs.size() - 1, 0);     for (int i = 0; i < lhs.size(); i++) {       for (int j = 0; j < rhs.size(); j++) {         ret[i + j] = (ret[i + j] + lhs[i] * 1LL * rhs[j]) % P;       }     }     return ret;   }   vector<int> operator+(const vector<int> &lhs, const vector<int> &rhs) {     vector<int> ret;     ret.resize(max(lhs.size(), rhs.size()), 0);     for (int i = 0; i < ret.size(); i++)       ret[i] =           ((i < lhs.size() ? lhs[i] : 0) + (i < rhs.size() ? rhs[i] : 0)) % P;     return ret;   }   vector<int> modExp(vector<int> &a, long long m, vector<int> &c) {     int n = a.size();     vector<int> ret(n, 0);     ret[0] = 1;     if (m == 0) return ret;     for (int i = 63 - __builtin_clz(m); i >= 0; i--) {       ret = ret * ret;       if (m >> i & 1) ret = ret * a;       for (int i = (int)ret.size() - 1; i >= n; i--)         if (ret[i]) {           for (int j = 0; j < n; j++)             if (c[j]) ret[i - j - 1] = (ret[i - j - 1] + ret[i] * 1LL * c[j]) % P;         }       ret.resize(n);     }     return ret;   }   int main() {     int F, B;     long long N;     cin >> F >> B >> N;     for (int i = 1; i <= F; i++) cin >> p[i];     vector<int> a(250, 0), b(250, 0), c(250, 0);     for (int i = 1; i <= B; i++) {       int x;       cin >> x;       c[x - 1]++;     }     b[0] = 1;     for (int i = 1; i < 250; i++) {       for (int j = 0; j < i; j++) b[i] = (b[i] + b[i - j - 1] * 1LL * c[j]) % P;     }     a[1] = 1;     vector<int> d(250, 0);     for (int i = 1; i <= F; i++) d = d + modExp(a, p[i], c);     d = modExp(d, N, c);     int ans = 0;     for (int i = 0; i < 250; i++) ans = (ans + d[i] * 1LL * b[i]) % P;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   const int inf = 0x3f3f3f3f;   const int mod = 1e9 + 7;   int con[26][26];   char str1[maxn];   char str2[maxn];   char strans[maxn];   int main() {     scanf( %s%s , str1, str2);     memset(con, inf, sizeof(con));     for (int i = 0; i < 26; i++) con[i][i] = 0;     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       getchar();       char a, b;       int w;       scanf( %c %c %d , &a, &b, &w);       int num1 = a -  a ;       int num2 = b -  a ;       if (num1 == num2) continue;       con[num1][num2] = min(w, con[num1][num2]);     }     for (int k = 0; k < 26; k++) {       for (int i = 0; i < 26; i++)         for (int j = 0; j < 26; j++) {           con[i][j] = min(con[i][k] + con[k][j], con[i][j]);         }     }     int len = strlen(str1);     int len1 = strlen(str2);     if (len != len1) {       printf( -1 n );       return 0;     }     int ans = 0;     int ff = 1;     for (int i = 0; i < len; i++) {       int sum1 = inf;       int num1 = str1[i] -  a ;       int num2 = str2[i] -  a ;       for (int j = 0; j < 26; j++) {         if (con[num1][j] + con[num2][j] < sum1) {           sum1 = con[num1][j] + con[num2][j];           strans[i] =  a  + j;         }       }       if (sum1 >= inf) {         ff = 0;         break;       }       ans += sum1;     }     strans[len] =   n ;     if (ff == 0)       printf( -1 n );     else {       printf( %d n , ans);       printf( %s n , strans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int maxn = 4;   template <class T>   struct Matrix {     int r, c;     T a[maxn][maxn];     Matrix() { memset(a, 0, sizeof a); }     Matrix(int si) {       memset(a, 0, sizeof a);       r = c = si;       for (int i = 0; i < si; i++) a[i][i] = 1;     }     Matrix operator*(Matrix &rhs) {       Matrix<T> ret;       ret.r = r;       ret.c = rhs.c;       for (int k = 0; k < c; ++k)         for (int i = 0; i < ret.r; ++i)           for (int j = 0; j < ret.c; ++j)             ret.a[i][j] = (ret.a[i][j] + (long long)a[i][k] * rhs.a[k][j]) % mod;       return ret;     }     Matrix operator^(long long b) {       Matrix<T> ret, base = *this;       int setret = 0;       while (b) {         if (b & 1) ret = (setret ? ret * base : base), setret = 1;         base = base * base;         b >>= 1;       }       return ret;     }   };   int P[1000000];   int KMP(string A, string B) {     int l = A.length();     A = A +  #  + B;     P[0] = -1;     int x = -1, ret = 0;     for (int i = (1); i < (A.length()); ++i) {       while (x >= 0 && A[x + 1] != A[i]) x = P[x];       if (A[x + 1] == A[i]) x++;       P[i] = x;       if (P[i] == l - 1) ret++;     }     return ret;   }   Matrix<int> M;   string fs[30];   string instr;   long long k;   int go() {     if (k < 30) return KMP(instr, fs[k]);     string A, B;     int I;     for (int i = 1; i < 30; i++) {       if (fs[i].length() >= instr.length()) {         B = fs[i + 1];         A = fs[i];         I = i;         break;       }     }     long long CA = KMP(instr, A);     long long CB = KMP(instr, B);     long long CBA = KMP(instr, B + A) - CB - CA;     long long CAB = KMP(instr, A + B) - CA - CB;     long long CBB = KMP(instr, B + B) - CB - CB;     Matrix<int> co, POW;     co.r = 1;     co.c = 4;     co.a[0][1] = 1;     POW = M ^ (k - I - 1);     co = co * POW;     return (co.a[0][0] * (CBA + CA) + co.a[0][1] * CB + co.a[0][2] * CAB +             co.a[0][3] * CBB) %            mod;   }   int main() {     ios_base::sync_with_stdio(0);     M.r = M.c = 4;     M.a[0][1] = M.a[0][2] = M.a[1][0] = M.a[1][1] = M.a[2][3] = M.a[3][2] = 1;     fs[1] =  a ;     fs[2] =  b ;     for (int i = 3; i < 30; ++i) fs[i] = fs[i - 1] + fs[i - 2];     int m;     cin >> k >> m;     while (m--) {       cin >> instr;       cout << go() << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N;     scanf( %d , &N);     int neg = 0, sum = 0;     int mini = 1005;     for (int i = 1; i < 2 * N; i++) {       int x;       scanf( %d , &x);       neg ^= x < 0;       x = abs(x);       mini = min(mini, x);       sum += x;     }     printf( %d n , sum - (neg && !(N % 2) ? 2 * mini : 0));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void dbg(T a) {}   template <typename T, typename... Arg>   void dbg(T a, Arg... arg) {}   const int maxn = (1e6) + 7;   const int inf = (1e9) + 7;   const long long LLinf = (1e18) + 7;   const long double eps = 1e-9;   const long long mod = 1e9 + 7;   vector<long long> wek[maxn];   long long n;   long long dwa[maxn];   long long tab[maxn];   void dodaj(int l, int p) {     while (l > n && p > n) {       l -= n;       p -= n;     }     if (l <= n && p <= n) {       wek[l].push_back(p);       wek[l + n].push_back(p + n);     } else       wek[l].push_back(p);   }   void czysc() {     for (int i = 0; i <= 3 * n; i++) wek[i].clear();   }   bool czy(long long val) {     long long l = 1;     long long p = 1;     czysc();     for (int i = n + 1; i <= 2 * n; i++) {       while (dwa[l] < tab[i] - val) l++;       while (p < l + n - 1 && dwa[p + 1] <= tab[i] + val) p++;       if (abs(dwa[l] - tab[i]) > val || abs(dwa[p] - tab[i]) > val) return 0;       dodaj(l, p);     }     priority_queue<long long> q;     for (int i = 1; i <= 2 * n; i++) {       for (auto s : wek[i]) q.push(-s);       if (((int)(q).size())) {         int a = -q.top();         q.pop();         if (a < i) return 0;       }     }     if (((int)(q).size()) > 0) return 0;     return 1;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long dl;     cin >> n >> dl;     for (int i = 1; i <= n; i++) {       cin >> tab[i];       tab[i + n] = tab[i] + dl;       tab[i + 2 * n] = tab[i] + 2 * dl;     }     sort(tab + 1, tab + n + 1 + n + n);     for (int i = 1; i <= n; i++) {       cin >> dwa[i];       dwa[i + n] = dwa[i] + dl;       dwa[i + 2 * n] = dwa[i] + 2 * dl;       dwa[i + 3 * n] = dwa[i] + 3 * dl;     }     sort(dwa + 1, dwa + n + 1 + n + n + n);     int l = -1;     int p = dl;     while (l + 1 < p) {       int sr = (l + p) / 2;       if (czy(sr) == 1)         p = sr;       else         l = sr;     }     cout << p;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a;     cin >> n;     vector<int> nums(8, 0);     for (int i = 0; i < n; i++) {       cin >> a;       nums[a]++;     }     if (nums[7] > 0 || nums[5] > 0) {       cout << -1;       return 0;     }     if (nums[2] < nums[4]) {       cout << -1;       return 0;     }     if (nums[1] == nums[2] + nums[3] && nums[1] == nums[4] + nums[6]) {       if (nums[2] - nums[4] + nums[3] != nums[6]) {         cout << -1;       } else {         while (nums[4] > 0) {           cout << 1 <<     << 2 <<     << 4 << endl;           nums[4]--;           nums[2]--;         }         while (nums[2] > 0) {           cout << 1 <<     << 2 <<     << 6 << endl;           nums[2]--;         }         while (nums[3] > 0) {           cout << 1 <<     << 3 <<     << 6 << endl;           nums[3]--;         }       }     } else {       cout << -1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> v;   int n, m;   void addOne(string &res) {     int i = (int)res.size() - 1;     while (res[i] ==  1 ) {       res[i--] =  0 ;     }     res[i] =  1 ;   }   string toBinary(long long k) {     if (k == 0) {       return string(m,  0 );     }     string res;     while (k) {       res.push_back((k % 2) +  0 );       k >>= 1;     }     while (res.size() != m) {       res.push_back( 0 );     }     reverse(res.begin(), res.end());     return res;   }   void findRes(string &res, long long k) {     long long x = max(k - 100, 0ll);     res = toBinary(x);     int a = lower_bound(v.begin(), v.end(), res) - v.begin();     long long rem = min(100ll, k) + a + (a != n && v[a] == res);     while (rem) {       addOne(res);       rem -= !binary_search(v.begin(), v.end(), res);     }   }   int main() {     int t;     cin >> t;     while (t--) {       cin >> n >> m;       v.resize(n);       for (auto &x : v) {         cin >> x;       }       sort(v.begin(), v.end());       string res(m,  0 );       findRes(res, ((1ll << m) - n - 1) / 2);       cout << res << endl;     }     cin.ignore(2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x, y;   };   node q[2][41000];   int n, k, len, b[210][2];   double p[210], dp[2][210][210];   double solve() {     if (n < len) return 0;     for (int i = 0; i < 2; ++i)       for (int j = 0; j < n + 1; ++j)         for (int k = 0; k < 201; ++k) dp[i][j][k] = -1;     int pre = 1, now = 0, cnt[2] = {0, 0};     node cur, nex;     cur.x = 0;     cur.y = k;     q[0][cnt[0]++] = cur;     dp[0][0][k] = 1;     for (int i = 1; i <= n; ++i) {       now = pre;       pre = 1 - pre;       cnt[now] = 0;       for (int j = 0; j < cnt[pre]; ++j) {         cur = q[pre][j];         if (dp[now][cur.x][cur.y] < 0) {           q[now][cnt[now]++] = cur;           dp[now][cur.x][cur.y] = dp[pre][cur.x][cur.y] * (1 - p[i]);         } else           dp[now][cur.x][cur.y] += dp[pre][cur.x][cur.y] * (1 - p[i]);         if (b[i][0] != -1) {           nex.x = cur.x + 1;           nex.y = min(cur.y + b[i][0], 200);           if (dp[now][nex.x][nex.y] < 0) {             q[now][cnt[now]++] = nex;             dp[now][nex.x][nex.y] = dp[pre][cur.x][cur.y] * p[i];           } else             dp[now][nex.x][nex.y] += dp[pre][cur.x][cur.y] * p[i];         } else if (cur.y > 0) {           nex.x = cur.x + 1;           nex.y = cur.y - 1;           if (dp[now][nex.x][nex.y] < 0) {             q[now][cnt[now]++] = nex;             dp[now][nex.x][nex.y] = dp[pre][cur.x][cur.y] * p[i];           } else             dp[now][nex.x][nex.y] += dp[pre][cur.x][cur.y] * p[i];         }         dp[pre][cur.x][cur.y] = -1;       }     }     double ans = 0;     for (int j = len; j <= n; ++j)       for (int i = 0; i <= 200; ++i)         if (dp[now][j][i] > 0) ans += dp[now][j][i];     return ans;   }   int cmp(const void *a, const void *b) {     int *c = (int *)a, *d = (int *)b;     return d[0] - c[0];   }   int main() {     scanf( %d %d %d , &n, &len, &k);     for (int i = 1; i <= n; ++i) scanf( %d , &b[i][1]);     for (int i = 1; i <= n; ++i) scanf( %d , &b[i][0]);     qsort(&b[1], n, sizeof(b[0]), cmp);     for (int i = 1; i <= n; ++i) p[i] = (b[i][1] + 0.0) / 100;     printf( %.9lf n , solve());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     cin >> a;     switch (a) {       case 0:         puts( 15 );         break;       case 1:         puts( 14 );         break;       case 2:         puts( 12 );         break;       case 3:         puts( 13 );         break;       case 4:         puts( 8 );         break;       case 5:         puts( 9 );         break;       case 6:         puts( 10 );         break;       case 7:         puts( 11 );         break;       case 8:         puts( 0 );         break;       case 9:         puts( 1 );         break;       case 10:         puts( 2 );         break;       case 11:         puts( 3 );         break;       case 12:         puts( 4 );         break;       case 13:         puts( 5 );         break;       case 14:         puts( 6 );         break;       case 15:         puts( 7 );         break;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 1;   string s[N];   vector<int> v[N];   bool cmp(string s1, string s2) {     return (s1.length() > s2.length() ||             (s1.length() == s2.length() && s1 >= s2));   }   bool solve(int n) {     for (int i = 1; i <= n; i++) {       if (cmp(s[i - 1], s[i])) return false;       if (!v[i].empty()) {         int sz = v[i].size();         for (int j = 0; j < sz; j++) {           char lim = (v[i][j] == 0) ?  1  :  0 ;           while (s[i][v[i][j]] > lim) {             s[i][v[i][j]]--;             if (cmp(s[i - 1], s[i])) {               s[i][v[i][j]]++;               break;             }           }         }       }     }     return true;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> s[i];       int len = s[i].length();       for (int j = 0; j < len; j++) {         if (s[i][j] ==  ? ) {           s[i][j] =  9 ;           v[i].push_back(j);         }       }     }     if (!solve(n))       cout <<  NO ;     else {       cout <<  YES  << endl;       for (int i = 1; i <= n; i++) cout << s[i] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long modpow(long long a, long long x) {     long long tmp = x;     long long val = a;     long long ret = 1LL;     while (tmp > 0) {       if (tmp % 2 == 1) ret = ret * val % mod;       val = val * val % mod;       tmp /= 2;     }     return ret;   }   long long modinv(long long a) { return modpow(a, mod - 2); }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     vector<long long> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     vector<vector<long long>> G(1 << n, vector<long long>(n, 1));     for (int i = 0; i < (1 << n); i++) {       for (int j = 0; j < n; j++) {         if (((i >> j) & 1) == 0) continue;         for (int k = 0; k < n; k++) {           G[i][k] = G[i][k] * a[j] % mod * modinv(a[j] + a[k]) % mod;         }       }     }     long long ans = 0LL;     vector<long long> P(1 << n);     for (int i = 1; i < (1 << n); i++) {       long long cnt = __builtin_popcount(i);       long long P_tmp = 1LL;       for (int j = i; j > 0; j = ((j - 1) & i)) {         if (j == i) continue;         long long G_tmp0 = 1LL;         for (int k = 0; k < n; k++) {           if (((j >> k) & 1) == 1) continue;           if (((i >> k) & 1) == 0) continue;           G_tmp0 = (G_tmp0 * G[j][k]) % mod;         }         P_tmp = (P_tmp - P[j] * G_tmp0 % mod + mod) % mod;       }       long long G_tmp1 = 1LL;       for (int k = 0; k < n; k++) {         if (((i >> k) & 1) == 1) continue;         G_tmp1 = (G_tmp1 * G[i][k]) % mod;       }       ans = (ans + cnt * P_tmp % mod * G_tmp1) % mod;       P[i] = P_tmp;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s[3];   int permutation[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},                            {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};   string accepted_strings[6];   string process(string str) {     string result =   ;     for (int i = 0; i < (int)str.length(); i++) {       if (str[i] ==  -  || str[i] ==  ;  || str[i] ==  _ ) {         continue;       }       if (isupper(str[i])) {         result += str[i] + 32;         continue;       }       result += str[i];     }     return result;   }   string genString(int i) {     string result =   ;     for (int j = 0; j < 3; j++) {       result += s[permutation[i][j]];     }     return result;   }   void solve() {     cin >> s[0] >> s[1] >> s[2];     s[0] = process(s[0]);     s[1] = process(s[1]);     s[2] = process(s[2]);     for (int i = 0; i < 6; i++) {       accepted_strings[i] = genString(i);     }     int n;     cin >> n;     for (int i = 0; i < n; i++) {       string t;       cin >> t;       t = process(t);       bool acc = false;       for (int j = 0; j < 6; j++) {         if (t == accepted_strings[j]) {           acc = true;           break;         }       }       if (acc) {         cout <<  ACC n ;       } else {         cout <<  WA n ;       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using lint = long long;   using pi = pair<lint, lint>;   const int MAXN = 200005;   struct kek {     int s, e, x;   } ed[MAXN];   struct edg {     int pos, cst, idx;   };   vector<edg> gph[MAXN];   int par[MAXN], pae[MAXN];   lint dist_st[MAXN], dist_ed[MAXN];   void dijk(int src, lint *dist) {     dist[src] = 0;     priority_queue<pi, vector<pi>, greater<pi> > pq;     pq.emplace(0, src);     while (((int)(pq).size())) {       auto x = pq.top();       pq.pop();       if (dist[x.second] != x.first) continue;       for (auto &i : gph[x.second]) {         if (dist[i.pos] > x.first + i.cst) {           dist[i.pos] = x.first + i.cst;           par[i.pos] = x.second;           pae[i.pos] = i.idx;           pq.emplace(dist[i.pos], i.pos);         }       }     }   }   vector<pi> sptree[MAXN];   int topo[MAXN];   void dfs(int x) {     for (auto &[j, i] : sptree[x]) {       if (!topo[i]) topo[i] = topo[x];       dfs(i);     }   }   int IN_SP[MAXN];   vector<lint> add[MAXN], del[MAXN];   multiset<lint> ms;   int n, m, q;   int main() {     memset(dist_st, 0x3f, sizeof(dist_st));     memset(dist_ed, 0x3f, sizeof(dist_ed));     scanf( %d %d %d , &n, &m, &q);     for (int i = 1; i <= m; i++) {       int s, e, x;       scanf( %d %d %d , &s, &e, &x);       ed[i] = {s, e, x};       gph[s].push_back({e, x, i});       gph[e].push_back({s, x, i});     }     dijk(n, dist_ed);     dijk(1, dist_st);     vector<int> v;     for (int i = 2; i <= n; i++) {       sptree[par[i]].emplace_back(pae[i], i);     }     for (int i = n; i != 1; i = par[i]) {       v.push_back(i);     }     v.push_back(1);     reverse((v).begin(), (v).end());     for (int i = 0; i < ((int)(v).size()); i++) {       topo[v[i]] = i + 1;       if (i) IN_SP[pae[v[i]]] = i + 1;     }     dfs(1);     for (int i = 1; i <= n; i++) {       for (auto &j : gph[i]) {         if (topo[i] < topo[j.pos] && pae[j.pos] != j.idx) {           int st = topo[i];           int ed = topo[j.pos];           lint ret = dist_st[i] + dist_ed[j.pos] + j.cst;           add[st].push_back(ret);           del[ed].push_back(ret);         }       }     }     vector<lint> tmp;     for (int i = 1; i < ((int)(v).size()); i++) {       for (int j = 0; j < del[i].size(); j++) {         ms.erase(ms.find(del[i][j]));       }       for (int j = 0; j < add[i].size(); j++) {         ms.insert(add[i][j]);       }       if (ms.empty())         tmp.push_back(1e18);       else         tmp.push_back(*ms.begin());     }     while (q--) {       int x, v;       scanf( %d %d , &x, &v);       if (!IN_SP[x]) {         lint ans = min({dist_st[n], dist_st[ed[x].s] + v + dist_ed[ed[x].e],                         dist_st[ed[x].e] + v + dist_ed[ed[x].s]});         if (ans > 1e17) ans = -1;         printf( %lld n , ans);       } else {         lint ans = min(dist_st[n] - ed[x].x + v, tmp[IN_SP[x] - 2]);         if (ans > 1e17) ans = -1;         printf( %lld n , ans);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   const int INF = 0x3f3f3f3f;   const long long llINF = 0x3f3f3f3f3f3f3f3f;   const int mod = 998244353;   long long read() {     long long x = 0, w = 1;     char ch = 0;     while (!isdigit(ch)) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + (ch -  0 );       ch = getchar();     }     return x * w;   }   int main() {     int n = read();     long long sum = 0, a;     while (n--) {       a = read();       sum += a - 1;       if (sum & 1)         puts( 1 );       else         puts( 2 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int a[1001];     for (int i = 0; i < n; i++) a[i] = s[i] -  0 ;     for (int i = 0; i < n; i++) {       int b[1001];       for (int j = i; j < n; j++) {         if (a[j] >= a[i])           b[j - i] = a[j] - a[i];         else           b[j - i] = 10 + a[j] - a[i];       }       for (int j = 0; j < i; j++) {         if (a[j] >= a[i])           b[n - i + j] = a[j] - a[i];         else           b[n - i + j] = 10 + a[j] - a[i];       }       string z;       for (int k = 0; k < n; k++) {         z += b[k] +  0 ;       }       if (s.compare(z) > 0) {         s = z;       }     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<vector<int>, int> mp;   int ig[11][6] = {       {6, 0, 0, 0, 0, 0}, {1, 5, 0, 0, 0, 0}, {2, 4, 0, 0, 0, 0},       {1, 1, 4, 0, 0, 0}, {3, 3, 0, 0, 0, 0}, {1, 2, 3, 0, 0, 0},       {1, 1, 1, 3, 0, 0}, {2, 2, 2, 0, 0, 0}, {1, 1, 2, 2, 0, 0},       {1, 1, 1, 1, 2, 0}, {1, 1, 1, 1, 1, 1},   };   int ans[11] = {1, 1, 2, 2, 2, 3, 5, 6, 8, 15, 30};   int main() {     map<vector<int>, int> mp;     for (int i = 0; i < 11; i++) {       vector<int> tmp(ig[i], ig[i] + 6);       mp[tmp] = ans[i];     }     string s;     cin >> s;     sort(s.begin(), s.end());     vector<int> t;     int mn = 0;     int i = 0;     while (i < 6) {       int r = 0;       while (i < 6 && s[mn] == s[i]) i++, r++;       mn = i;       t.push_back(r);     }     sort(t.begin(), t.end());     while (t.size() != 6) t.push_back(0);     cout << mp[t] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     ;     while (t--) {       int a, b, c, d;       cin >> a >> b >> c >> d;       if ((a == c) && (b + d == a))         cout <<  YES  << endl;       else if ((a == d) && (b + c == a))         cout <<  YES  << endl;       else if ((b == c) && (a + d == b))         cout <<  YES  << endl;       else if ((b == d) && (a + c == b))         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const int N = 1e5;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int tc, ca = 0;     cin >> tc;     while (tc--) {       int n, el;       vector<int> v;       cin >> n;       for (int i = 0; i < n + n; i++) {         cin >> el;         v.push_back(el);       }       sort(v.begin(), v.end());       cout << v[n] - v[n - 1] <<   n ;     }     return 0;   }