malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int oo = 3e5 + 7;   unordered_map<int, vector<int>> values[2];   int t, n, q, a[oo], p[oo];   vector<int> ans;   int psum(int l, int r) { return p[r] - (l ? p[l - 1] : 0); }   int first(vector<int>& list, int val) {     int l = 0, r = list.size();     while (l < r) {       int s = (l + r) / 2;       if (list[s] >= val)         r = s;       else         l = s + 1;     }     if (l == list.size()) return n * 2;     return list[l];   }   void problem(int l, int r) {     int sum = psum(l, r);     if (sum == 0) return;     if (sum % 2 == 0) {       ans.push_back(r);       problem(l, r - 1);       return;     }     int pl = p[l] - a[l];     int vals[2] = {pl + (sum + 1) / 2 - 1, pl + (sum - 1) / 2 + 1};     for (int i = 0; i < 2; i++) {       int pans = first(values[i][vals[i]], l);       if (pans <= r) {         ans.push_back(pans);         return;       }     }     throw 69;   }   void solve() {     cin >> n >> q;     string ss;     cin >> ss;     for (int i = 0; i < n; i++)       a[i] = (ss[i] ==  +  ? 1 : -1) * (i % 2 == 0 ? -1 : 1);     p[0] = a[0];     for (int i = 1; i < n; i++) p[i] = p[i - 1] + a[i];     for (int i = 0; i < n; i++) values[(a[i] + 1) / 2][p[i]].push_back(i);     while (q--) {       int l, r;       cin >> l >> r;       l--, r--;       problem(l, r);       cout << ans.size() << endl;       for (int e : ans) cout << e + 1 <<    ;       cout << endl;       ans.clear();     }     values[0].clear();     values[1].clear();   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int a[1050], b[1050];   int main() {     int n, m, s = 0, d = 0;     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> a[i];       b[i] = a[i];     }     for (int i = 1; i <= n; i++) {       sort(a, a + m);       for (int j = 0; j < m; j++) {         if (a[j] > 0) {           s += a[j];           a[j]--;           break;         }       }     }     for (int i = 1; i <= n; i++) {       sort(b, b + m);       for (int j = m - 1; j >= 0; j--) {         if (b[j] > 0) {           d += b[j];           b[j]--;           break;         }       }     }     cout << d <<     << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mx(long long a, long long b) { return a >= b ? a : b; }   long long mn(long long a, long long b) { return a <= b ? a : b; }   string a[3] = {( twone ), ( two ), ( one )};   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t, x;     cin >> t;     while (t--) {       string str, str2;       long long ans = 0;       vector<long long> v;       cin >> str;       if (str.size() <= 2) {         cout << 0 <<   n               <<   n ;         continue;       }       for (long long i = 0; i < str.size() - 2; i++) {         if (str[i] ==  t  and str[i + 1] ==  w  and str[i + 2] ==  o  and             str[i + 3] ==  n  and str[i + 4] ==  e )           str[i + 2] =  l , ans++, v.push_back(i + 3);         if (str[i] ==  t  and str[i + 1] ==  w  and str[i + 2] ==  o )           ans++, str[i + 1] =  l , v.push_back(i + 2);         if (str[i] ==  o  and str[i + 1] ==  n  and str[i + 2] ==  e )           ans++, str[i + 1] =  l , v.push_back(i + 2);       }       cout << ans <<   n ;       for (long long i = 0; i < v.size(); i++) cout << v[i] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     cin >> a;     int max = 0;     vector<int> b;     int x;     for (int i = 0; i < a; i++) {       cin >> x;       b.push_back(x);     }     sort(b.begin() + 1, b.end());     int count = 0;     if (b[0] > b[b.size() - 1]) {       cout <<  0 ;     } else {       while (1) {         b[b.size() - 1]--;         count++;         b[0] = b[0] + 1;         sort(b.begin() + 1, b.end());         if (b[0] > b[b.size() - 1]) {           cout << count;           break;         }       }     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int vet[1010], dp[2][1010];   const int mod = 998244353;   long long soma(long long x, long long y) {     x += y;     if (x >= mod) x -= mod;     return x;   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> vet[i];     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         dp[1][j] = dp[0][j];       }       if (vet[i] < n and vet[i] > 0) {         dp[1][vet[i]] = soma(soma(dp[0][0], 1), dp[1][vet[i]]);       }       for (int k = 0; k < n; k++) {         dp[1][k] = soma(dp[1][k], dp[0][k + 1]);       }       swap(dp[0], dp[1]);     }     cout << dp[0][0] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int vis[100005], mark[100005];   vector<int> g[100005];   int prob = 0;   void dfs(int node, int k) {     mark[node] = k;     vis[node] = 1;     for (auto i : g[node]) {       if (!vis[i]) {         dfs(i, 1 - k);       } else {         if (mark[i] == k) {           prob = 1;         }       }     }   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d , &u);       scanf( %d , &v);       g[u].push_back(v);       g[v].push_back(u);     }     for (int i = 1; i <= n; i++) {       if (!vis[i]) dfs(i, 0);     }     if (prob) {       cout <<  -1 ;       return 0;     }     int k = 0;     for (int i = 1; i <= n; i++) {       if (mark[i] == 1) k++;     }     cout << k <<   n ;     for (int i = 1; i <= n; i++) {       if (mark[i] == 1) cout << i <<    ;     }     cout <<   n ;     k = 0;     for (int i = 1; i <= n; i++) {       if (mark[i] == 0) k++;     }     cout << k <<   n ;     for (int i = 1; i <= n; i++) {       if (mark[i] == 0) cout << i <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, pd[4][10100], x, y, gox[4] = {1, 0, -1, 0}, goy[4] = {0, 1, 0, -1},                              w[16], dp[10100][8], mo = 1000000007;   char getin() {     char ch = getchar();     while (ch !=  .  && ch !=  X  && ch !=  O ) ch = getchar();     return ch;   }   int check(int k1, int k2, int k3) {     for (int i = 0; i < 3; i++) {       if (pd[i + 1][k1]) {         if (k2 & (1 << i)) return 0;       }       if (pd[i + 1][k1 - 1]) {         if (k3 & (1 << i))           return 0;         else           k3 += (1 << i);       }     }     int a[3] = {0};     for (int i = 0; i < 3; i++)       if ((k3 & (1 << i)) == 0) a[i]--;     for (int i = 0; i < 3; i++)       if (k2 & (1 << i)) a[i]++;     for (int i = 0; i < 3; i++)       if (a[i] < 0) return 0;     for (int i = 0; i < 2; i++)       if (a[i] && a[i + 1] == 0)         return 0;       else if (a[i])         a[i + 1] = 0;     if (a[2]) return 0;     return 1;   }   int solve(int k) {     memset(dp, 0x00, sizeof dp);     dp[0][7] = 1;     for (int i = 1; i <= n; i++)       for (int j = 0; j < 8; j++)         for (int k = 0; k < 8; k++)           if (check(i, j, k)) dp[i][j] = (dp[i][j] + dp[i - 1][k]) % mo;     int k1 = 0;     for (int i = 0; i < 3; i++)       if (pd[i + 1][n]) k1 += (1 << i);     return dp[n][7 ^ k1];   }   int dfs(int k1, int k2) {     if (k1 == 4) return w[k2] * solve(k2);     int flag = 0;     for (int i = 1; i <= 2; i++) {       int k3 = x + gox[k1] * i, k4 = y + goy[k1] * i;       if (k3 <= 0 || k3 > 3 || k4 <= 0 || k4 > n || pd[k3][k4]) {         flag = 1;         break;       }     }     int ans = 0;     if (flag == 0) {       for (int i = 1; i <= 2; i++) {         int k3 = x + gox[k1] * i, k4 = y + goy[k1] * i;         pd[k3][k4] = 1;       }       ans += dfs(k1 + 1, k2 + (1 << k1));       for (int i = 1; i <= 2; i++) {         int k3 = x + gox[k1] * i, k4 = y + goy[k1] * i;         pd[k3][k4] = 0;       }     }     ans = (ans + dfs(k1 + 1, k2)) % mo;     return ans;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= 3; i++)       for (int j = 1; j <= n; j++) {         char ch = getin();         if (ch ==  X )           pd[i][j] = 1;         else if (ch ==  O ) {           pd[i][j] = 2;           x = i;           y = j;         }       }     for (int i = 1; i < 16; i++) {       w[i] = 1;       for (int j = (i - 1) & i; j; j = (j - 1) & i) w[i] = w[i] - w[j];     }     cout << (dfs(0, 0) + mo) % mo << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T sqr(T x) {     return x * x;   }   template <typename T>   T abs(T x) {     return x < 0 ? -x : x;   }   template <typename T>   T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   set<vector<int> > s;   vector<pair<char, pair<int, int> > > ans;   bool rec(vector<int>& a) {     if (a.size() == 1) {       return a[0] == 24;     }     if (s.find(a) != s.end()) {       return false;     }     s.insert(a);     for (size_t i = 0; i < a.size(); ++i) {       for (size_t j = i + 1; j < a.size(); ++j) {         vector<int> b = a;         int x = a[i], y = a[j];         b.erase(b.begin() + j);         b.erase(b.begin() + i);         b.push_back(x + y);         ans.push_back(make_pair( + , make_pair(x, y)));         if (rec(b)) {           return true;         }         b.pop_back();         ans.pop_back();         b.push_back(y - x);         ans.push_back(make_pair( - , make_pair(y, x)));         if (rec(b)) {           return true;         }         b.pop_back();         ans.pop_back();         b.push_back(x - y);         ans.push_back(make_pair( - , make_pair(x, y)));         if (rec(b)) {           return true;         }         b.pop_back();         ans.pop_back();         b.push_back(x * y);         ans.push_back(make_pair( * , make_pair(x, y)));         if (rec(b)) {           return true;         }         b.pop_back();         ans.pop_back();       }     }     return false;   }   int main(int, char**) {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     if (n < 4) {       cout <<  NO  << endl;       return 0;     }     cout <<  YES  << endl;     vector<int> a;     for (int i = 1; i <= n % 2 + 4; ++i) {       a.push_back(i);     }     rec(a);     for (int i = n % 2 + 4; i < n; i += 2) {       ans.push_back(make_pair( - , make_pair(i + 2, i + 1)));       ans.push_back(make_pair( * , make_pair(24, 1)));     }     for (size_t i = 0; i < ans.size(); ++i) {       int x = ans[i].second.first;       int y = ans[i].second.second;       int r = -1;       switch (ans[i].first) {         case  - :           r = x - y;           break;         case  + :           r = x + y;           break;         case  * :           r = x * y;           break;       }       cout << x <<     << ans[i].first <<     << y <<   =   << r << endl;     }     fprintf(stderr,  Time execute: %.3lf sec n ,             clock() / (double)CLOCKS_PER_SEC);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fast();   int main() {     fast();     int k, d;     cin >> k >> d;     string ans =   ;     if ((d > (pow(10, k) - 1)) || (d == 0 && k != 1)) {       cout <<  No solution ;       return 0;     }     for (int i = 0; i < k; i++) {       if (d > 9) {         ans +=  9 ;         d -= 9;       } else {         stringstream t;         t << d;         ans += t.str();         d = 0;       }     }     cout << ans;     return 0;   }   void fast() {     ios_base::sync_with_stdio(0);     cin.tie(NULL), cout.tie(NULL);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1029384756;   const double PI = acos(-1);   const double EPS = 0.0000000304;   long long A, B, C;   int main() {     scanf( %I64d%I64d%I64d , &A, &B, &C);     if ((A % 2) == (B % 2) && (B % 2) == (C % 2)) {       printf( %I64d , A + B + C - max(A, max(B, C)) - min(A, min(B, C)));     } else if (A % 2 == B % 2) {       printf( %I64d , max(A, B));     } else if (A % 2 == C % 2) {       printf( %I64d , max(A, C));     } else {       printf( %I64d , max(B, C));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> v;   int main() {     long long int n, m, a, b, sum = 0, i, j, k;     cin >> n >> k;     long long int s[n], x[n];     for (i = 0; i < n; i++) {       cin >> a >> b;       sum += min(a, b);       v.push_back(min(2 * a, b) - min(a, b));     }     sort(v.begin(), v.end());     for (i = 0; i < n && i < k; i++) sum += v[n - i - 1];     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, neg = 1;     char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) neg = -1;       c = getchar();     }     while (isdigit(c)) x = x * 10 + c -  0 , c = getchar();     return x * neg;   }   inline int qpow(int x, int e, int _MOD) {     int ans = 1;     while (e) {       if (e & 1) ans = ans * x % _MOD;       x = x * x % _MOD;       e >>= 1;     }     return ans;   }   int n = read(), s = read(), a[200005], b[200005], c[200005], d[200005], num = 0;   vector<int> g[200005], cyc[200005];   int k = 0;   inline void dfs(int x) {     while (!g[x].empty()) {       int y = g[x].back();       g[x].pop_back();       dfs(a[y]);       cyc[k].push_back(y);     }   }   signed main() {     for (int i = 1; i <= n; i++) a[i] = read(), c[i] = a[i];     sort(c + 1, c + n + 1);     for (int i = 1; i <= n; i++)       if (c[i] != c[i - 1]) d[++num] = c[i];     for (int i = 1; i <= n; i++)       a[i] = lower_bound(d + 1, d + num + 1, a[i]) - d, b[i] = a[i];     sort(b + 1, b + n + 1);     int cnt = 0;     for (int i = 1; i <= n; i++) {       if (a[i] != b[i]) {         cnt++;         g[b[i]].push_back(i);       }     }     if (!cnt) return puts( 0 ), 0;     if (cnt > s) return puts( -1 ), 0;     for (int i = 1; i <= num; i++) {       if (!g[i].empty()) {         k++;         dfs(i);       }     }     for (int i = 1; i <= k; i++) reverse(cyc[i].begin(), cyc[i].end());     if (k == 1) {       cout << 1 << endl << cyc[1].size() << endl;       for (__typeof(cyc[1].begin()) it = cyc[1].begin(); it != cyc[1].end(); it++)         cout << *it <<    ;       return 0;     }     if (cnt <= s - k) {       cout << 2 << endl;       cout << cnt << endl;       for (int i = 1; i <= k; i++) {         for (__typeof(cyc[i].begin()) it = cyc[i].begin(); it != cyc[i].end();              it++)           cout << *it <<    ;       }       puts(  );       cout << k << endl;       for (int i = k; i >= 1; i--) cout << cyc[i][0] <<    ;       puts(  );       return 0;     } else {       int t = cnt - (s - k);       if (t == k)         cout << t << endl;       else if (t == k - 1)         cout << t + 1 << endl;       else         cout << t + 2 << endl;       for (int i = 1; i <= t; i++) {         cout << cyc[i].size() << endl;         for (__typeof(cyc[i].begin()) it = cyc[i].begin(); it != cyc[i].end();              it++)           cout << *it <<    ;         puts(  );       }       int sum = 0;       if (t != k) {         for (int i = t + 1; i <= k; i++) sum += cyc[i].size();         cout << sum << endl;         for (int i = t + 1; i <= k; i++)           for (__typeof(cyc[i].begin()) it = cyc[i].begin(); it != cyc[i].end();                it++)             cout << *it <<    ;         if (t != k - 1) {           puts(  );           cout << k - t << endl;           for (int i = k; i >= t + 1; i--) cout << cyc[i][0] <<    ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 10;   int t, n, son[maxn], root, p[maxn], rt;   vector<int> g[maxn];   void dfs(int u, int fa) {     son[u] = 1;     p[u] = fa;     for (auto it : g[u]) {       if (it == fa) continue;       dfs(it, u);       son[u] += son[it];     }   }   void getroot(int u, int fa) {     root = u;     for (auto it : g[u]) {       if (it == fa) continue;       if (son[it] > n - son[it]) getroot(it, u);     }   }   int getleaf(int u, int fa) {     if (g[u].size() == 1) return u;     for (auto it : g[u]) {       if (it == fa) continue;       return getleaf(it, u);     }   }   int main() {     scanf( %d , &t);     while (t--) {       root = rt = 0;       scanf( %d , &n);       for (int i = 1; i < n; i++) {         int u, v;         scanf( %d%d , &u, &v);         g[u].push_back(v);         g[v].push_back(u);       }       dfs(1, 0);       getroot(1, 0);       for (auto it : g[root]) {         if (it != p[root] && son[it] == n - son[it]) rt = it;       }       if (!rt) {         printf( %d %d n%d %d n , root, g[root][0], root, g[root][0]);       } else {         int l = getleaf(rt, p[rt]);         printf( %d %d n%d %d n , p[l], l, root, l);       }       for (int i = 1; i <= n; i++) g[i].clear(), p[i] = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool cmax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   const int N = 444444;   int fa[N], ch[N][26], l[N], f[N], a[N], c[N], pos[N], top[N];   char s[N];   int last = 1, cnt = 1, n, ans = 1;   void ins(int c, int k) {     int p = last, np = ++cnt;     last = np, l[np] = l[p] + 1, pos[np] = k;     for (; p && !ch[p][c]; p = fa[p]) ch[p][c] = np;     if (!p)       fa[np] = 1;     else {       int q = ch[p][c];       if (l[q] == l[p] + 1)         fa[np] = q;       else {         int nq = ++cnt;         l[nq] = l[p] + 1, pos[nq] = pos[q];         memcpy(ch[nq], ch[q], sizeof(ch[q]));         fa[nq] = fa[q], fa[np] = fa[q] = nq;         for (; ch[p][c] == q; p = fa[p]) ch[p][c] = nq;       }     }   }   void calc() {     for (int i = 1; i <= cnt; ++i) ++c[l[i]];     for (int i = 1; i <= cnt; ++i) c[i] += c[i - 1];     for (int i = 1; i <= cnt; ++i) a[c[l[i]]--] = i;   }   int L[N * 25], R[N * 25], rt[N], tot;   void modify(int &now, int l, int r, int x) {     now = ++tot;     if (l == r) return;     int mid = l + r >> 1;     if (x <= mid)       modify(L[now], l, mid, x);     else       modify(R[now], mid + 1, r, x);   }   int merge(int x, int y) {     if (!x || !y) return x | y;     int z = ++tot;     L[z] = merge(L[x], L[y]);     R[z] = merge(R[x], R[y]);     return z;   }   int query(int x, int l, int r, int ql, int qr) {     if (!x) return 0;     if (ql <= l && qr >= r) return 1;     int mid = l + r >> 1;     if (ql <= mid && query(L[x], l, mid, ql, qr)) return 1;     if (qr > mid && query(R[x], mid + 1, r, ql, qr)) return 1;     return 0;   }   int main() {     scanf( %d , &n);     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i) ins(s[i] -  a , i), modify(rt[last], 1, n, i);     calc();     for (int i = cnt; i > 1; --i) rt[fa[a[i]]] = merge(rt[fa[a[i]]], rt[a[i]]);     for (int i = 2; i <= cnt; ++i) {       int u = a[i], ff = fa[u];       if (ff == 1) {         f[u] = 1, top[u] = u;         continue;       }       int x = query(rt[top[ff]], 1, n, pos[u] - l[u] + l[top[ff]], pos[u] - 1);       if (x)         f[u] = f[ff] + 1, top[u] = u;       else         f[u] = f[ff], top[u] = top[ff];       cmax(ans, f[u]);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const long long MOD = 998244353;   const long long N = (long long)1e4 + 9;   const long long inf = 1 << 30;   template <class T>   T gcd(T a, T b) {     return (b != 0 ? gcd<T>(b, a % b) : a);   }   template <class T>   T lcm(T a, T b) {     return (a / gcd<T>(a, b) * b);   }   template <typename T>   T exp(T b, T p) {     T x = 1;     while (p) {       if (p & 1) x = (x * b);       b = (b * b);       p = p >> 1;     }     return x;   }   inline long long ones(long long n) {     long long res = 0;     while (n && ++res) n -= n & (-n);     return res;   }   inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }   long long mem[109][3];   long long n, arr[109];   long long go(long long idx, long long last) {     if (idx == n) return 0;     long long &ret = mem[idx][last];     if (ret != -1) return ret;     ret = -inf;     if (arr[idx] == 0) ret = go(idx + 1, 0);     if (arr[idx] == 3) {       if (last != 1) ret = max(ret, 1 + go(idx + 1, 1));       if (last != 2) ret = max(ret, 1 + go(idx + 1, 2));     }     if (arr[idx] == 1) {       if (last != 1)         ret = 1 + go(idx + 1, 1);       else         ret = go(idx + 1, 0);     }     if (arr[idx] == 2) {       if (last != 2)         ret = 1 + go(idx + 1, 2);       else         ret = go(idx + 1, 0);     }     return ret;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(nullptr);     cout.tie(0);     cin >> n;     for (long long i = 0; i < n; ++i) {       cin >> arr[i];     }     memset(mem, -1, sizeof(mem));     long long ans = go(0, 0);     cout << n - ans;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 3.14159265358979323846;   int a[100010], d[100010];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= n + 1; i++) d[i] = a[i] - a[i - 1];     stack<int> st;     int r = 0;     for (int i = 1; i <= n; i++) {       if (d[i] > 0) r += d[i];     }     cout << r << endl;     for (int i = 1; i <= n + 1; i++) {       if (d[i] > 0) {         for (int j = 0; j < d[i]; j++) {           st.push(i);         }       }       if (d[i] < 0) {         for (int j = 0; j > d[i]; j--) {           printf( %d %d n , st.top(), i - 1);           st.pop();         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, q, a, b, ans, t;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> q;     while (q--) {       cin >> k >> n >> a >> b;       ans = a * n;       if (b * n >= k)         cout << -1 <<   n ;       else {         if (ans < k)           cout << n <<   n ;         else {           t = a - b;           ans = (ans - k) / t + 1;           cout << n - ans <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k, x, y, z, a[5005], b[50005], ans, val;   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (long long i = 0; i < n; i++) cin >> a[i];     cin >> m;     for (long long i = 0; i < m; i++) cin >> b[i];     sort(a, a + n);     sort(b, b + m);     cout << a[n - 1] <<     << b[m - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = ~0U >> 1;   const long long INF = ~0ULL >> 1;   template <class T>   inline void read(T &n) {     char c;     int flag = 1;     for (c = getchar(); !(c >=  0  && c <=  9  || c ==  - ); c = getchar())       ;     if (c ==  - )       flag = -1, n = 0;     else       n = c -  0 ;     for (c = getchar(); c >=  0  && c <=  9 ; c = getchar()) n = n * 10 + c -  0 ;     n *= flag;   }   const int maxn = 2100000;   const int mo = 1000000007;   int N, K, M, ans, vis[1000];   char s[maxn];   int nxt[maxn][26];   int dp[maxn];   void add(int &x, int y) {     x += y;     if (x >= mo) x -= mo;   }   int main(int argc, char *argv[]) {     scanf( %d%d , &N, &K);     scanf( %s , s + 1);     M = strlen(s + 1);     string temp =   ;     for (int i = (M); i >= (1); --i)       if (!vis[s[i]]) vis[s[i]] = true, temp = s[i] + temp;     for (int i = ( a ); i <= ( a  + K - 1); ++i)       if (!vis[i]) temp = (char)i + temp;     for (int i = (0); i < (N); ++i) s[++M] = temp[i % temp.size()];     for (int j = (0); j < (K); ++j) nxt[M + 1][j] = M + 1;     for (int i = (M); i >= (1); --i) {       memcpy(nxt[i], nxt[i + 1], sizeof(nxt[i]));       nxt[i][s[i] -  a ] = i;     }     int cur = 0;     dp[0] = 1;     for (int i = (0); i < (M); ++i) {       int flag = false;       for (int j = (0); j < (K); ++j)         if (nxt[i + 1][j] <= M) add(dp[nxt[i + 1][j]], dp[i]);     }     for (int i = (0); i <= (M); ++i) add(ans, dp[i]);     printf( %d n , ans);     return 0;   }