malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int add(int x, int y) {     x += y;     while (x >= 1000000007) x -= 1000000007;     while (x < 0) x += 1000000007;     return x;   }   int mul(int x, int y) { return (x * 1ll * y) % 1000000007; }   int binpow(int x, int y) {     int z = 1;     while (y) {       if (y & 1) z = mul(z, x);       x = mul(x, x);       y >>= 1;     }     return z;   }   int inv(int x) { return binpow(x, 1000000007 - 2); }   int divide(int x, int y) { return mul(x, inv(y)); }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     vector<pair<long long int, long long int> > v;     for (int i = 0; i < n; i++) {       long long int a, b;       cin >> a >> b;       v.push_back({a, b});     }     vector<pair<long long int, long long int> > sol, sols;     for (int i = 0; i < n; i++) {       long long int a = v[i].first, b = v[i].second + a - 1;       int flag = 0;       for (int j = 0; j < sols.size(); j++) {         if (max(sols[j].first, a) <= min(sols[j].second, b)) flag = 1;       }       long long int pa = 1, push_back = v[i].second;       for (int j = 0; j < sols.size(); j++) {         if (max(sols[j].first, pa) <= min(sols[j].second, push_back)) {           pa = sols[j].second + 1;           push_back = pa + v[i].second - 1;         }       }       if (flag == 0)         sol.push_back({a, b});       else         sol.push_back({pa, push_back});       sols = sol;       sort(sols.begin(), sols.end());     }     for (int i = 0; i < n; i++)       cout << sol[i].first <<     << sol[i].second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = int(1e9) + 7;   int debug = 1;   int main() {     int a, b, c, l;     cin >> a >> b >> c >> l;     int cnt = 0;     int m;     long long n, total = 0;     for (int i = 0; i < l + 1; i++) {       n = i;       n = ((n + 2) * (n + 1)) / 2;       total += n;     }     long long x = 0, sub = 0;     int r;     for (int i = 0; i <= l; i++) {       int aa = a + i;       r = l - i;       if (b + c > aa) continue;       r = min(r, aa - (b + c));       x = r;       x = ((x + 2) * (x + 1)) / 2;       sub += x;     }     for (int i = 0; i <= l; i++) {       int bb = b + i;       r = l - i;       if (a + c > bb) continue;       r = min(r, bb - (a + c));       x = r;       x = ((x + 2) * (x + 1)) / 2;       sub += x;     }     for (int i = 0; i <= l; i++) {       int cc = c + i;       r = l - i;       if (b + a > cc) continue;       r = min(r, cc - (a + b));       x = r;       x = ((x + 2) * (x + 1)) / 2;       sub += x;     }     cout << total - sub << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       long long n, k, a, ans, y;       cin >> n >> k;       long long s[n + 10];       vector<long long> v;       for (int i = 0; i < n; i++) cin >> a, v.push_back(a);       sort(v.begin(), v.end());       s[0] = 0;       for (int i = 1; i < n; i++) s[i] = s[i - 1] + v[i];       s[n] = s[n - 1] + v[0];       if (s[n] <= k) {         cout << 0 << endl;         continue;       }       ans = s[n] - k;       for (int i = 1; i < n; i++) {         y = v[0] * (n - i + 1) + s[i - 1] - k;         if (y < 0) y = 0;         if (y % (n - i + 1))           y /= (n - i + 1), y++;         else           y /= (n - i + 1);         ans = min(ans, y + (n - i));       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long int n;   map<pair<long long int, long long int>, long long int> val;   long long int get_lca(long long int x, long long int y) {     vector<long long int> a, b;     a.clear();     b.clear();     while (x > 0) {       a.push_back(x);       x >>= 1;     }     while (y > 0) {       b.push_back(y);       y >>= 1;     }     reverse(a.begin(), a.end());     reverse(b.begin(), b.end());     long long int j = 0;     for (j = 0; j < a.size() && j < b.size(); j++) {       if (a[j] != b[j]) break;     }     return a[j - 1];   }   void upd(long long int x, long long int l, long long int w) {     long long int y = x % 2;     x >>= 1;     while (x > 0) {       val[{x, y}] += w;       y = x % 2;       x >>= 1;     }     y = l % 2;     l >>= 1;     while (l > 0) {       val[{l, y}] -= w;       y = l % 2;       l >>= 1;     }   }   long long int get(long long int x, long long int l) {     long long int an = 0;     long long int y = x % 2;     x >>= 1;     while (x > 0 && x >= l) {       an += val[{x, y}];       y = x % 2;       x >>= 1;     }     return an;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       long long int t, u, v, w;       cin >> t >> u >> v;       if (t == 1) {         cin >> w;         long long int l = get_lca(u, v);         upd(u, l, w);         upd(v, l, w);       } else {         long long int l = get_lca(u, v);         long long int an = get(u, l) + get(v, l);         cout << an <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   char s[maxn];   int n;   long long ans;   namespace SAM {   int fa[maxn], ch[maxn][26], mxlen[maxn], cend[maxn], cnode, root, lst;   vector<int> g[maxn];   vector<int> len[maxn];   inline int getnewnode() {     fa[cnode] = -1;     memset(ch[cnode], -1, sizeof(ch[0]));     cend[cnode] = 0;     return cnode++;   }   void init(int m) {     for (int i = 0; i <= m; i++) len[i].clear();     cnode = 0;     lst = root = getnewnode();     mxlen[root] = 0;   }   void extend(int c) {     int cur = getnewnode();     mxlen[cur] = mxlen[lst] + 1;     len[mxlen[cur]].push_back(cur);     cend[cur]++;     int p;     for (p = lst; p != -1 && ch[p][c] == -1; p = fa[p]) ch[p][c] = cur;     lst = cur;     if (p == -1) {       fa[cur] = root;       return;     }     int q = ch[p][c];     if (mxlen[q] == mxlen[p] + 1) {       fa[cur] = q;       return;     }     int clone = getnewnode();     mxlen[clone] = mxlen[p] + 1;     len[mxlen[clone]].push_back(clone);     fa[clone] = fa[q];     for (int i = 0; i < 26; i++) ch[clone][i] = ch[q][i];     fa[q] = fa[cur] = clone;     for (; p != -1 && ch[p][c] == q; p = fa[p]) ch[p][c] = clone;   }   void build() {     for (int i = 0; i < n; i++) extend(s[i] -  a );     for (int l = n; l >= 1; l--) {       for (int i = 0; i < len[l].size(); i++) {         int x = len[l][i];         int cnt = mxlen[x] - mxlen[fa[x]];         cend[fa[x]] += cend[x];         ans += cnt * 1ll * cend[x] * 1ll * cend[x];       }     }   }   }  // namespace SAM   int main() {     int t;     scanf( %d , &t);     while (t--) {       scanf( %s , s);       n = strlen(s);       ans = 0;       SAM::init(n);       SAM::build();       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[1005], b[1005];   int main() {     int n, i;     scanf( %d , &n);     scanf( %s , a + 1);     scanf( %s , b + 1);     int ans1 = n, ans2 = 0;     sort(a + 1, a + 1 + n);     sort(b + 1, b + 1 + n);     int lab = 1, cnt = 1;     while (lab <= n) {       if (a[cnt] < b[lab]) {         cnt++;         ans2++;       }       lab++;     }     lab = cnt = n;     while (lab >= 1) {       if (b[cnt] >= a[lab]) {         ans1--;         cnt--;       }       lab--;     }     cout << ans1 << endl;     cout << ans2 << endl;     return 0;   }
#include <bits/stdc++.h>   int inf = 0x3f3f3f3f;   using namespace std;   int n, m, x, y, f[200010], degree, cnt;   vector<pair<int, int>> ans, edge1, wron;   vector<pair<int, int>> edge;   vector<pair<int, int>> v[200010];   int find(int x) {     if (f[x] == x) return x;     return f[x] = find(f[x]);   }   int jihe(int x, int y) {     x = find(x);     y = find(y);     if (x != y) {       f[x] = y;       return 1;     }     return 0;   }   int main() {     cin >> n >> m >> degree;     for (int i = 1; i <= m; i++) {       scanf( %d%d , &x, &y);       if (x == 1 || y == 1)         edge1.push_back(make_pair(x, y));       else         edge.push_back(make_pair(x, y));     }     if (edge1.size() < degree) {       cout <<  NO  << endl;       return 0;     }     for (int i = 1; i <= n; i++) f[i] = i;     for (auto it : edge) jihe(it.first, it.second);     for (auto it : edge1) {       if (jihe(it.first, it.second)) {         cnt++;         ans.push_back(it);       } else         wron.push_back(it);     }     if (cnt > degree) {       cout <<  NO  << endl;       return 0;     }     for (int i = 0; i < degree - cnt; i++) {       ans.push_back(wron[i]);     }     for (int i = 1; i <= n; i++) f[i] = i;     for (auto it : ans) {       jihe(it.first, it.second);     }     for (auto it : edge)       if (jihe(it.first, it.second)) ans.push_back(it);     cout <<  YES  << endl;     for (auto it : ans) cout << it.first <<     << it.second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool sortcol(const vector<int>& v1, const vector<int>& v2) {     return v1[0] < v2[0];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     ;     int n, m;     cin >> n >> m;     int a[n + 1], b[m + 1];     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= m; i++) cin >> b[i];     for (int i = 0; i <= 512; i++) {       int br = 0;       for (int j = 1; j <= n; j++) {         bool found = false;         for (int k = 1; k <= m; k++) {           if ((i & (a[j] & b[k])) == (a[j] & b[k])) {             found = true;           }         }         if (found) {           br++;         }       }       if (br == n) {         cout << i;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 500008;   int n, m, cnt;   int day[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int get(int x) {     int ret = 0;     for (int i = 0; i < x; ++i) ret += day[i];     return ret;   }   struct Node {     int year, month, date;     int hour, minute, second;     int dis;     Node() {}     Node(int Y, int M, int D, int H, int Mi, int S) {       year = Y, month = M, date = D;       hour = H, minute = Mi, second = S;       dis = second + minute * 60 + hour * 3600;       if (date - 1 == 0) {         dis += day[month - 1] * 24 * 3600 + get(month - 1) * 24 * 3600;       } else         dis += (date - 1) * 24 * 3600 + get(month) * 24 * 3600;     };   } node[maxn];   int main() {     cin >> n >> m;     string str;     cnt = 0;     while (cin >> str) {       int y = 2012, m = (str[5] -  0 ) * 10 + str[6] -  0 ,           d = (str[8] -  0 ) * 10 + str[9] -  0 ;       cin >> str;       int h = (str[0] -  0 ) * 10 + str[1] -  0 ,           mi = (str[3] -  0 ) * 10 + str[4] -  0 ,           s = (str[6] -  0 ) * 10 + str[7] -  0 ;       node[++cnt] = Node(y, m, d, h, mi, s);       getline(cin, str,   n );     }     bool ff = 0;     int i;     for (i = m; i <= cnt; ++i) {       if (node[i].dis - node[i - m + 1].dis + 1 <= n) {         ff = 1;         break;       }     }     if (ff) {       printf( %02d-%02d-%02d  , node[i].year, node[i].month, node[i].date);       printf( %02d:%02d:%02d n , node[i].hour, node[i].minute, node[i].second);     } else       puts( -1 );   }
#include <bits/stdc++.h>   using namespace std;   const int DN = 3e5 + 5;   int n, m, sol, f, cnt, mi = 1e9, sum;   char ch[6], a[5][5], car;   string s[DN], r[DN];   void solve1() {     cnt++;     sum = 0;     int f, mi;     for (int i = 1; i <= n; i++) {       f = 0;       for (int j = 1; j <= m; j++) {         car = a[i % 2][j % 2];         if (s[i][j] != car) f++;         r[i][j] = car;       }       mi = f;       f = 0;       for (int j = 1; j <= m; j++) {         car = a[i % 2][1 - j % 2];         if (s[i][j] != car) f++;       }       if (f < mi) {         mi = f;         for (int j = 1; j <= m; j++) {           car = a[i % 2][1 - j % 2];           r[i][j] = car;         }       }       sum += mi;     }   }   void solve2() {     cnt++;     sum = 0;     int f, mi;     for (int j = 1; j <= m; j++) {       f = 0;       for (int i = 1; i <= n; i++) {         car = a[i % 2][j % 2];         if (s[i][j] != car) f++;         r[i][j] = car;       }       mi = f;       f = 0;       for (int i = 1; i <= n; i++) {         car = a[1 - i % 2][j % 2];         if (s[i][j] != car) f++;       }       if (f < mi) {         mi = f;         for (int i = 1; i <= n; i++) {           car = a[1 - i % 2][j % 2];           r[i][j] = car;         }       }       sum += mi;     }   }   void solve() {     cnt = 0;     ch[1] =  A ;     ch[2] =  G ;     ch[3] =  C ;     ch[4] =  T ;     do {       a[0][0] = ch[1];       a[0][1] = ch[2];       a[1][0] = ch[3];       a[1][1] = ch[4];       solve1();       if (sum < mi) {         mi = sum;         f = cnt;       }       if (sum == sol) return;       solve2();       if (sum < mi) {         mi = sum;         f = cnt;       }       if (sum == sol) return;     } while (next_permutation(ch + 1, ch + 5));     sol = mi;   }   int main() {     cin.sync_with_stdio(false);     cout.sync_with_stdio(false);     cin >> n >> m;     for (int i = 0; i <= n; i++) getline(cin, s[i]);     for (int i = 1; i <= n; i++) {       s[i] =     + s[i];       r[i] = s[i];     }     solve();     solve();     for (int i = 1; i <= n; i++) r[i].erase(r[i].begin());     for (int i = 1; i <= n; i++) cout << r[i] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long int md = 1e9 + 7;   const long long int N = 55;   long long int a[N];   long long int dp[N][N];   vector<pair<long long int, long long int>> v;   long long int mask;   long long int rec(long long int n, long long int k) {     long long int s = 0;     if (dp[n][k] != -1) return dp[n][k];     v.emplace_back(pair<long long int, long long int>{n, k});     if (k == 1) {       for (long long int i = 1; i <= n; i++) s += a[i];       return dp[n][k] = ((s & mask) == mask);     }     for (long long int i = n; i >= k; i--) {       s += a[i];       if ((s & mask) == mask)         if (rec(i - 1, k - 1)) return dp[n][k] = 1;     }     return dp[n][k] = 0;   }   signed main() {     ios::sync_with_stdio(0);     long long int n, k;     cin >> n >> k;     for (long long int i = 1; i <= n; i++) cin >> a[i];     long long int ans = 0;     long long int c = pow(2, 56);     for (long long int i = 0; i < N; i++)       for (long long int j = 0; j < N; j++) dp[i][j] = -1;     for (long long int i = 56; i >= 0; i--) {       mask = ans + c;       if (rec(n, k)) ans += c;       c >>= 1;       for (auto it : v) dp[it.first][it.second] = -1;       v.clear();     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, temp, count = 0;     cin >> a >> b;     while (a >= 1 && b >= 1) {       if (a > b) {         count += a / b;         a %= b;       } else if (b > a) {         count += b / a;         b %= a;       } else {         count++;         break;       }     }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 55, inF = 1e9 + 100;   int n, h, m, l[N], r[N], x[N], c[N], dp[N][N][N];   int get(int i, int j, int dex, int h) {     int res = 0;     for (int q = 0; q < m; q++)       if (l[q] <= dex && l[q] >= i && r[q] <= j && r[q] >= dex && x[q] < h)         res += c[q];     return res;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0);     cin >> n >> h >> m;     for (int i = 0; i < m; i++) cin >> l[i] >> r[i] >> x[i] >> c[i];     for (int k = 1; k <= h; k++)       for (int l = 1; l <= n; l++)         for (int i = 1; i + l - 1 <= n; i++) {           int j = i + l - 1;           dp[i][j][k] = dp[i][j][k - 1];           for (int dex = i; dex <= j; dex++)             dp[i][j][k] =                 max(dp[i][j][k], dp[i][dex - 1][k - 1] + dp[dex + 1][j][k] +                                      k * k - get(i, j, dex, k));         }     cout << dp[1][n][h];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned mod = 3853518419u;   const unsigned base = 85429482u;   int n;   string s;   basic_string<int> e[300005];   int p[19][300005], du[300005];   unsigned bp[300005];   unsigned hu[19][300005], hd[19][300005];   void dfs(int x, int par) {     p[0][x] = par;     hu[0][x] = hd[0][x] = s[x];     for (int i = 1; i < 19; i++) {       int y = p[i - 1][x];       p[i][x] = p[i - 1][y];       hu[i][x] = (1ull * hu[i - 1][x] * bp[1 << (i - 1)] + hu[i - 1][y]) % mod;       hd[i][x] = (1ull * hd[i - 1][y] * bp[1 << (i - 1)] + hd[i - 1][x]) % mod;     }     for (int y : e[x]) {       if (y != par) {         du[y] = du[x] + 1;         dfs(y, x);       }     }   }   int dizi(int x, int k) {     for (int i = 0; i < 19; i++) {       if ((1 << i) & k) {         x = p[i][x];       }     }     return x;   }   int lca(int x, int y) {     if (du[x] > du[y]) swap(x, y);     y = dizi(y, du[y] - du[x]);     if (x == y) return x;     for (int i = 18; i >= 0; i--) {       int xx = p[i][x], yy = p[i][y];       if (xx != yy) {         x = xx;         y = yy;       }     }     return p[0][x];   }   int resi(int a, int b, int c, int d) {     int p = lca(a, b), q = lca(c, d), l = 0;     int h = min(du[a] - du[p], du[c] - du[q]);     for (int i = 18; i >= 0; i--) {       if ((1 << i) <= h) {         if (hu[i][a] == hu[i][c]) {           l += 1 << i;           h -= 1 << i;           a = ::p[i][a];           c = ::p[i][c];         }       }     }     if (h > 0) return l;     if (a != p) {       swap(a, c);       swap(b, d);       swap(p, q);     }     h = min(du[c] - du[q], du[b] - du[p]);     for (int i = 18; i >= 0; i--) {       if ((1 << i) <= h) {         int t = dizi(b, du[b] - du[p] - (1 << i));         if (hu[i][::p[0][t]] == hd[i][c]) {           l += 1 << i;           h -= 1 << i;           p = t;           c = ::p[i][c];         }       }     }     if (h > 0) return l;     if (b == p) return l + (s[p] == s[c]);     h = min(du[d] - du[q], du[b] - du[p]);     for (int i = 18; i >= 0; i--) {       if ((1 << i) <= h) {         int t1 = dizi(b, du[b] - du[p] - (1 << i));         int t2 = dizi(d, du[d] - du[q] - (1 << i));         if (hu[i][::p[0][t1]] == hu[i][::p[0][t2]]) {           l += 1 << i;           h -= 1 << i;           p = t1;           q = t2;         }       }     }     if (h > 0) return l;     return l + (s[p] == s[q]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cerr.tie(nullptr);     cin >> n >> s;     s = string(   ) + s;     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       e[u] += v;       e[v] += u;     }     bp[0] = 1;     for (int i = 1; i < 300005; i++) bp[i] = bp[i - 1] * 1ull * base % mod;     dfs(1, 1);     int q;     cin >> q;     while (q--) {       int a, b, c, d;       cin >> a >> b >> c >> d;       cout << resi(a, b, c, d) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int N, X, ans;   int A[100002];   int B[100002];   int main() {     scanf( %d%d , &N, &X);     for (int i = 1; i <= N; i++) scanf( %d , &A[i]);     for (int i = 1; i <= N; i++) scanf( %d , &B[i]);     sort(A + 1, A + N + 1);     sort(B + 1, B + N + 1);     for (int i = 1, j = N; i <= N && j >= 1; i++)       if (A[i] + B[j] >= X) j--, ans++;     printf( 1 %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int qpow(int b, long long e) {     int a = 1;     for (; e; e >>= 1, b = (long long)b * b)       if (e & 1) a = (long long)a * b;     return a;   }   const int maxn = 2222;   int a[maxn];   vector<int> odd, even;   void solve() {     int n;     cin >> n;     odd.clear();     even.clear();     for (int i = 1; i <= (2 * n); ++i) {       cin >> a[i];       if (a[i] & 1)         odd.push_back(i);       else         even.push_back(i);     }     int cnt = n - 1;     while (cnt--) {       if (odd.size() >= 2) {         cout << *odd.rbegin() <<     << *++odd.rbegin() << endl;         odd.pop_back();         odd.pop_back();       } else if (even.size() >= 2) {         cout << *even.rbegin() <<     << *++even.rbegin() << endl;         even.pop_back();         even.pop_back();       }     }   }   int main() {     int T;     cin >> T;     while (T--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long n;   map<pair<long long, long long>, pair<long long, long long> > mp;   pair<long long, long long> count(long long x, long long y) {     if (mp.find(make_pair(x, y)) != mp.end()) return mp[make_pair(x, y)];     long long temp = 1;     while (x / 10 >= temp) temp *= 10;     if (temp == 1) return mp[make_pair(x, y)] = make_pair(1, max(0ll, y - x));     pair<long long, long long> a = count(x % temp, max(y, x / temp));     pair<long long, long long> b = count(x / temp * temp - a.second, y);     return mp[make_pair(x, y)] = make_pair(a.first + b.first, b.second);   }   int main() {     cin >> n;     if (n == 0) {       cout << 0 << endl;       return 0;     }     cout << count(n, 0).first << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s;     cin >> s;     int dp[10][10][10][10];     for (int i = 0; i < 10; i++)       for (int j = 0; j < 10; j++)         for (int k = 0; k < 10; k++)           for (int l = 0; l < 10; l++) {             dp[i][j][k][l] = INT_MAX;             for (int t1 = 0; t1 <= 10; t1++) {               for (int t2 = 0; t2 <= 10; t2++) {                 if ((t1 * i + t2 * j) % 10 == (l - k + 10) % 10 &&                     (t1 != 0 || t2 != 0)) {                   dp[i][j][k][l] = min(dp[i][j][k][l], t1 + t2);                 }               }             }           }     for (int i = 0; i < 10; i++) {       for (int j = 0; j < 10; j++) {         int ans = 0;         for (int k = 0; k < s.length() - 1; k++) {           if (dp[i][j][s[k] -  0 ][s[k + 1] -  0 ] == INT_MAX) {             ans = -1;             break;           } else {             ans += max(0, dp[i][j][s[k] -  0 ][s[k + 1] -  0 ] - 1);           }         }         cout << ans <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2 * 1e9;   const double PI = acos(-1);   vector<int> a;   int p[10000001];   int m = 10000000;   int main() {     int n;     cin >> n;     for (int i = 2; i * i <= m; i++) {       if (!p[i]) {         for (int j = i * i; j <= m; j += i) p[j] = 1;       }     }     for (int i = 2; i <= m; i++)       if (!p[i]) a.push_back(i);     for (int i = 0; i < n; i++) cout << a[i] <<    ;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   long long cntPair(long long v) { return v * (v - 1) / 2LL; }   int main() {     int n, d;     cin >> n >> d;     vector<pair<int, int> > v(n);     for (int i = 0; i < n; i++) {       cin >> v[i].first;       v[i].second = i + 1;     }     sort(v.begin(), v.end());     vector<int> ans;     for (int i = 0; i < v.size(); i++) {       if (d >= v[i].first) {         d -= v[i].first;         ans.push_back(v[i].second);       } else         break;     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> al[100001];   long long vis[100001];   long long no(long long num) {     long long min = num % 10, max = num % 10;     while (num > 0) {       long long a = num % 10;       num /= 10;       if (min > a) min = a;       if (max < a) max = a;     }     return min * max;   }   int main() {     long long t;     cin >> t;     while (t--) {       long long a, k;       cin >> a >> k;       for (long long i = 0; i < k - 1; i++) {         long long b = no(a);         if (b == 0) break;         a += b;       }       cout << a << endl;     }   }