malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     int fu = 1;     char c = getchar();     while (c > 57 || c < 48) {       if (c == 45) fu = -1;       c = getchar();     }     while (c <= 57 && c >= 48) {       x = (x << 3) + (x << 1) + c - 48;       c = getchar();     }     x *= fu;   }   template <typename T>   inline void fprint(T x) {     if (x < 0) putchar(45), x = -x;     if (x > 9) fprint(x / 10);     putchar(x % 10 + 48);   }   template <typename T>   inline void fprint(T x, char ch) {     fprint(x);     putchar(ch);   }   inline char next_char() {     char ch = getchar();     while (ch == 9 || ch == 10 || ch == 32) ch = getchar();     return ch;   }   template <typename T>   inline T mn(T x, T y) {     return x < y ? x : y;   }   template <typename T>   inline T mx(T x, T y) {     return x > y ? x : y;   }   template <typename T>   inline void chmin(T &x, T y) {     (x > y) && (x = y);   }   template <typename T>   inline void chmax(T &x, T y) {     (x < y) && (x = y);   }   long long x, y;   inline void MAIN() {     read(x);     read(y);     if (x % y != 0) {       fprint(x, 10);       return;     } else {       long long mem = x, ans = 1;       for (register long long i = 2; i * i <= y; i++) {         x = mem;         if (y % i == 0) {           while (x % i == 0) x /= i;           while (y % i == 0) {             y /= i;             x *= i;           }           x /= i;           chmax(ans, x);         }       }       x = mem;       if (y > 1) {         while (x % y == 0) x /= y;         chmax(ans, x);       }       fprint(ans, 10);     }   }   int main() {     int T;     read(T);     while (T--) MAIN();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long n;     cin >> n;     string s =  ROYGBIV ;     long long x = n - 7;     string st =  GBIV ;     long long i = 0;     while (i < x) {       s += st[(i % 4)];       i++;     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, s, a[500009], b[500009];   int chk[500009];   bool ok(int p) {     vector<int> c(500009);     for (int i = 0; i <= p; i++) c[a[i]]++;     for (int i = 0; i < 500009; i++)       if (c[i] < chk[i]) return false;     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     cin >> m >> k >> n >> s;     for (int i = 0; i < m; i++) cin >> a[i];     for (int i = 0; i < s; i++) cin >> b[i], chk[b[i]]++;     int l = 0, r = m - 1;     if (!ok(r)) {       cout << -1;       return 0;     }     while (l < r) {       int mid = (l + r) >> 1;       if (ok(mid)) {         r = mid;       } else {         l = mid + 1;       }     }     vector<pair<int, int>> cut;     vector<int> chkk(500009);     r = max(r, k - 1);     for (int i = 0; i <= r; i++) chkk[a[i]]++;     for (int i = 0; i < m; i++) {       cut.push_back(make_pair(i, r));       chkk[a[i]]--;       while (r + 1 < m && (chkk[a[i]] < chk[a[i]] || r - i < k)) {         chkk[a[++r]]++;       }       if (chkk[a[i]] < chk[a[i]] || r - i < k) {         break;       }     }     int fid = -1;     for (int i = 0; i < cut.size(); i++) {       if (cut[i].first / k + 1 + (m - cut[i].second - 1) / k >= n) {         fid = i;         break;       }     }     if (fid == -1) {       cout << -1;       return 0;     }     vector<int> ans;     for (int i = cut[fid].first; i <= cut[fid].second; i++) {       if (chk[a[i]] != 0) {         chk[a[i]]--;       } else {         ans.push_back(i);       }     }     cout << cut[fid].second - cut[fid].first + 1 - k + (cut[fid].first % k)          <<   n ;     for (int i = 0; i < cut[fid].first % k; i++) cout << i + 1 <<    ;     for (int i = 0; i < cut[fid].second - cut[fid].first + 1 - k; i++) {       cout << ans[i] + 1 <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1005;   char s[MAXN][MAXN];   int n, m, pre[MAXN], nex[MAXN];   bool check[MAXN];   int main() {     scanf( %d%d n , &n, &m);     for (int i = 1; i <= n; ++i) gets(s[i] + 1);     for (int j = 0; j <= m + 1; ++j) pre[j] = j - 1, nex[j] = j + 1;     int res = 0;     for (int j = nex[0]; j <= m; j = nex[j]) {       bool ok = 1;       for (int i = 1; i <= n - 1; ++i) {         if (!check[i] && s[i][j] > s[i + 1][j]) {           ok = 0;           break;         }       }       if (!ok) {         int prevpos = pre[j], nextpos = nex[j];         nex[prevpos] = nextpos;         pre[nextpos] = prevpos;         ++res;       } else {         for (int i = 1; i <= n - 1; ++i)           if (s[i][j] < s[i + 1][j]) check[i] = 1;       }     }     printf( %d , res);   }
#include <bits/stdc++.h>   using namespace std;   const int SIZE = 1000009;   char s[SIZE];   long long int dsum[SIZE];   int dtotal;   long long int usum[SIZE];   int utotal;   int main() {     int N;     scanf( %d%s , &N, s + 1);     for (int i = 1; i <= N; i++) {       if (s[i] ==  U ) {         ++utotal;         usum[utotal] = i + usum[utotal - 1];       } else {         ++dtotal;         dsum[dtotal] = i + dsum[dtotal - 1];       }     }     int meetd = 0;     int meetu = 0;     for (long long int i = 1; i <= N; i++) {       meetd += s[i] ==  D ;       int lu = meetu;       int rd = dtotal - meetd;       int mn = min(lu, rd);       long long int ans =           (dsum[meetd + mn] - dsum[meetd] - (usum[meetu] - usum[meetu - mn])) * 2;       if (s[i] ==  U ) {         if (lu >= rd)           ans += N + 1 - i;         else           ans += (dsum[meetd + mn + 1] - dsum[meetd + mn] - i) * 2 + i;       } else {         if (rd >= lu)           ans += i;         else           ans += (i - usum[meetu - mn] + usum[meetu - mn - 1]) * 2 + N + 1 - i;       }       meetu += s[i] ==  U ;       printf( %lld  , ans);     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   int n, hitung, arr[212];   void swap(int x, int y) {     for (int i = y; i > x; i--) {       int tmp = arr[i - 1];       arr[i - 1] = arr[i];       arr[i] = tmp;       hitung += 1;     }   }   int main() {     cin >> n;     for (int i = 1; i <= 2 * n; i++) {       cin >> arr[i];     }     int i = 1;     while (i <= 2 * n) {       if (arr[i] == arr[i + 1]) {       } else {         for (int j = i + 2; j <= 2 * n; j++) {           if (arr[i] == arr[j]) {             swap(i + 1, j);             break;           }         }       }       i += 2;     }     cout << hitung <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int A[110][110];   char buf[3];   bool mark[110][110][30][2];   bool memo[110][110][30][2];   bool win(int u, int v, int prev, int turn) {     bool& ans = memo[u][v][prev][turn];     if (mark[u][v][prev][turn]) return ans;     mark[u][v][prev][turn] = true;     ans = true;     for (int i = 1; i <= n && ans; i++) {       if (turn == 0) {         if (A[u][i] < prev) continue;         ans = !win(i, v, A[u][i], 1 - turn);       } else {         if (A[v][i] < prev) continue;         ans = !win(u, i, A[v][i], 1 - turn);       }     }     return ans;   }   int main() {     memset(A, -1, sizeof(A));     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d %d %s , &x, &y, buf);       A[x][y] = buf[0] -  a  + 1;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (win(i, j, 0, 0))           printf( B );         else           printf( A );       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   constexpr int mod = 1e9 + 7;   int main() {    using namespace std;    ios_base::sync_with_stdio(false), cin.tie(nullptr);    int tt; cin >> tt;    while (tt--) {     int n, k; cin >> n >> k;     vector<uint16_t> a(n);     for (uint16_t &x : a) cin >> x;     sort(a.begin(), a.end(), greater<uint16_t> ());     int N = 1, M = 1;     for (int i = k - 2; i >= 0 && a[i] == a[k - 1]; --i) ++N, ++M;     for (int i = k; i < n && a[i] == a[k - 1]; ++i) ++N;     auto qpow = [&](int a, int b) -> int {      int res = 1;      while (b) {       if (b & 1) res = 1ll * res * a % mod;       a = 1ll * a * a % mod, b >>= 1;      }      return res;     };     auto C = [&](int N, int M) -> int {      int res = 1;      for (int i = 0; i < M; ++i)       res = 1ll * res * (N - i) % mod * qpow(i + 1, mod - 2) % mod;      return res;     };     cout << C(N, M) <<   n ;    }   }
#include <bits/stdc++.h>   const int maxn = 300010;   int n, m, cnt, go_far;   int not_read[maxn], clr[maxn];   int a[maxn];   int main() {     int i, op, x, t, zz;     scanf( %d%d , &n, &m);     cnt = 0;     a[0] = 0;     go_far = 0;     for (zz = 1; zz <= m; zz++) {       scanf( %d%d , &op, &x);       if (op == 1) {         a[++a[0]] = x;         cnt++;         not_read[x]++;       } else if (op == 2) {         cnt -= not_read[x];         clr[x] += not_read[x];         not_read[x] = 0;       } else {         t = x;         for (i = go_far + 1; i <= t; i++) {           x = a[i];           if (clr[x])             clr[x]--;           else             cnt--, not_read[x]--;         }         if (t > go_far) go_far = t;       }       printf( %d n , cnt);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 55;   int v[N][N], x[N << 1], y[N << 1], n, m, q;   int main() {     scanf( %d , &n);     v[1][1] = 1;     v[1][2] = v[n][n] = 0;     m = n * 2 - 4;     for (int i = 3; i <= n; i += 2) {       printf( ? %d %d %d %d n , i - 2, 1, i, 1);       fflush(stdout);       scanf( %d , &q);       v[i][1] = q ^ 1 ^ v[i - 2][1];       printf( ? %d %d %d %d n , i - 2, 2, i, 2);       fflush(stdout);       scanf( %d , &q);       v[i][2] = q ^ 1 ^ v[i - 2][2];     }     for (int i = 2; i <= n; i += 2) {       printf( ? %d %d %d %d n , i, 1, i + 1, 2);       fflush(stdout);       scanf( %d , &q);       v[i][1] = q ^ 1 ^ v[i + 1][2];       printf( ? %d %d %d %d n , i - 1, 1, i, 2);       fflush(stdout);       scanf( %d , &q);       v[i][2] = q ^ 1 ^ v[i - 1][1];     }     for (int i = 1; i <= n; ++i) {       for (int j = 3; j <= n; ++j) {         printf( ? %d %d %d %d n , i, j - 2, i, j);         fflush(stdout);         scanf( %d , &q);         v[i][j] = q ^ 1 ^ v[i][j - 2];       }     }     for (int i = 1; i <= n; ++i) x[i] = i, y[i] = 1;     for (int i = n + 1; i < (n << 1); ++i) x[i] = n, y[i] = i + 1 - n;     for (int i = 1; i <= m; ++i) {       q = 0;       for (int j = 0; j < 4; ++j) q ^= v[x[i + j]][y[i + j]];       if (q == 0) {         printf( ? %d %d %d %d n , x[i], y[i], x[i + 3], y[i + 3]);         fflush(stdout);         scanf( %d , &q);         if (v[x[i]][y[i]] ^ v[x[i + 3]][y[i + 3]] ^ q) break;         for (int j = 1; j <= n; ++j) {           for (int k = 1; k <= n; ++k) {             if ((j + k) % 2 == 0) continue;             v[j][k] ^= 1;           }         }         break;       }     }     printf( ! n );     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) printf( %d , v[i][j]);       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   int a[200005];   int f[200005];   int main() {     ios::sync_with_stdio(false);     int t, n;     cin >> t;     for (int i = 0; i < t; i++) {       cin >> n;       int maxx = 0;       int minx = 999999999;       for (int j = 0; j < n; j++) {         cin >> a[j];         f[a[j]] = j;       }       for (int j = 1; j <= n; j++) {         maxx = max(maxx, f[j]);         minx = min(minx, f[j]);         if (maxx - minx == j - 1) {           cout << 1;         } else           cout << 0;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int p[1001000];   int main() {     int a, b, k;     cin >> a >> b >> k;     for (int i = 2; i <= b + 20; i++) p[i] = 1;     for (int i = 2; i <= b + 20; i++)       if (p[i])         for (int j = i + i; j <= b + 10; j = j + i) p[j] = 0;     for (int i = 1; i < b + 10; i++) p[i] = p[i] + p[i - 1];     int lo, hi, m;     lo = 0;     hi = b - a + 2;     while (lo < hi) {       int f = 1;       m = (lo + hi) / 2;       for (int i = a - 1; i + m <= b; i++) {         if (p[i + m] - p[i] < k) {           f = 0;           break;         }       }       if (f == 1) {         hi = m;       } else         lo = m + 1;     }     if (lo > b - a + 1) {       cout <<  -1  << endl;     } else       cout << lo << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   #pragma GCC optimize(3)   #pragma GCC optimize(4)   using namespace std;   const int N = 9;   const int C = 840;   int n;   long long dp[C * N];   long long cnt[N], M;   int main() {     scanf( %lld , &M);     for (int i = 1; i < N; ++i) scanf( %lld , &cnt[i]);     memset(dp, -1, sizeof(dp));     dp[0] = 0;     for (int i = 1; i < N; ++i) {       for (int j = C * N - 1; j >= 0; --j) {         int c = C / i;         if (cnt[i] < c) c = cnt[i];         for (int k = 1; k <= c; ++k) {           if (j - k * i >= 0) {             if (~dp[j - k * i])               dp[j] = max(dp[j], dp[j - k * i] + (cnt[i] - k) / (C / i));           }         }       }     }     long long ans = 0;     for (int i = 0; i < (N - 1) * C; ++i) {       if (~dp[i]) {         if (M >= i) ans = max(ans, i + min(dp[i], (M - i) / C) * C);       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long n, f = 0;       cin >> n;       vector<char> v1, v2;       for (int i = 0; i < n; i++) {         char a;         cin >> a;         v1.push_back(a);       }       for (int i = 0; i < n; i++) {         char b;         cin >> b;         v2.push_back(b);       }       for (int i = 0; i < n; i++) {         if (v1[i] ==  1  && v2[i] ==  1 ) {           f = 1;           break;         }       }       if (f == 1) {         cout <<  No  << endl;       } else {         cout <<  Yes  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x, y, m;   long long ans;   int main() {     cin >> x >> y >> m;     if (x >= m || y >= m) {       cout << 0;       return 0;     }     if (x <= 0 && y <= 0) {       cout << -1;       return 0;     }     if (y < 0) swap(x, y);     if (x < 0) {       ans += ceil((double)-x / y);       x += y * ans;     }     if (x < y) swap(x, y);     while (x < m) {       y = y + x;       if (x < y) swap(x, y);       ans++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int memo[5001][501];   int k;   int h[11];   long long distribute(int cards, int players) {     if (cards <= 0 or players <= 0) return 0;     if (cards >= k * players) return players * h[k];     if (memo[cards][players] != -1) {       return memo[cards][players];     }     int min_cards = max(0, cards - k * (players - 1));     long long best = 0;     for (int c = min_cards; c <= min(k, cards); ++c) {       best = max(best, h[c] + distribute(cards - c, players - 1));     }     return memo[cards][players] = best;   }   void solve() {     memset(memo, -1, sizeof memo);     int n;     cin >> n >> k;     vector<int> c, f;     c.reserve(n * k);     copy_n(istream_iterator<int>(cin), n * k, back_inserter(c));     f.reserve(n);     copy_n(istream_iterator<int>(cin), n, back_inserter(f));     h[0] = 0;     for (int i = 1; i <= k; ++i) cin >> h[i];     sort(begin(c), end(c));     sort(begin(f), end(f));     long long joy = 0;     auto itf = begin(f);     auto itc = begin(c);     while (itf != end(f)) {       int x = *itf;       auto foo = equal_range(itf, end(f), x);       auto bar = equal_range(itc, end(c), x);       joy += distribute(bar.second - bar.first, foo.second - foo.first);       itf = foo.second;       itc = bar.second;     }     cout << joy << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e5 + 10;   int n, S;   long long tot;   struct Node {     long long val;     long long num;     long long sum;     bool operator<(const Node &rhs) const { return num < rhs.num; }   };   vector<Node> a, b;   long long work(long long ls, vector<Node> &a) {     int id = upper_bound(a.begin(), a.end(), Node{0, ls}) - a.begin();     long long ret = 0;     if (--id >= 0) {       ret = a[id].sum;     }     if (id + 1 != a.size()) {       long long left = ls - (id == -1 ? 0 : a[id].num);       ret += left * a[id + 1].val;     }     return ret;   }   long long cal(long long x) {     long long ret = work(x * S, a);     ret += work((tot - x) * S, b);     return ret;   }   long long solve(long long l, long long r) {     while (r > l) {       long long m1 = (2 * l + r) / 3;       long long m2 = (2 * r + l + 2) / 3;       long long ret1 = cal(m1);       long long ret2 = cal(m2);       if (ret1 > ret2)         r = m2 - 1;       else         l = m1 + 1;     }     return cal(l);   }   int main() {     scanf( %d%d , &n, &S);     long long cnt = 0;     long long now = 0;     for (int i = 0; i < n; ++i) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       cnt += x;       now += 1ll * x * min(y, z);       if (y > z)         a.emplace_back(Node{1ll * y - z, 1ll * x, 1ll * (y - z) * x});       else if (y < z)         b.emplace_back(Node{1ll * z - y, 1ll * x, 1ll * (z - y) * x});     }     sort(a.begin(), a.end(), [](Node x, Node y) { return x.val > y.val; });     sort(b.begin(), b.end(), [](Node x, Node y) { return x.val > y.val; });     tot = cnt / S + (cnt % S > 0);     for (int i = 0; i < a.size(); ++i) {       if (i) a[i].sum += a[i - 1].sum, a[i].num += a[i - 1].num;     }     for (int i = 0; i < b.size(); ++i) {       if (i) b[i].sum += b[i - 1].sum, b[i].num += b[i - 1].num;     }     printf( %I64d n , solve(0, tot) + now);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dd[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};   vector<vector<int>> mat(1000, vector<int>(1000));   int n, m, si, sj;   void bfs() {     mat[si][sj] = 1;     queue<pair<int, int>> q;     q.push({si, sj});     while (!q.empty()) {       auto p = q.front();       q.pop();       for (int i = 0; i < 4; i++) {         int ti = p.first + dd[i][0];         int tj = p.second + dd[i][1];         if (ti >= 0 && tj >= 0 && ti < n && tj < m && !mat[ti][tj]) {           mat[ti][tj] = mat[p.first][p.second] + 1;           q.push({ti, tj});         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     int ei, ej;     vector<pair<int, pair<int, int>>> v;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (int j = 0; j < m; j++) {         if (s[j] ==  E ) {           si = i, sj = j;           mat[i][j] = 0;         } else {           if (s[j] ==  T )             mat[i][j] = -1;           else {             mat[i][j] = 0;             if (s[j] ==  S )               ei = i, ej = j;             else               v.push_back({s[j] -  0 , {i, j}});           }         }       }     }     bfs();     int ans = 0;     int my = mat[ei][ej];     for (auto i : v) {       int cur = mat[i.second.first][i.second.second];       if (cur && cur <= my) {         ans += i.first;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC optimize( fast-math )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native )   mt19937 rnd(51);   const int N = 1010;   vector<int> g[N];   vector<bool> used(N);   vector<int> d(N);   void ask(vector<int> v) {     cout <<  ?           <<     << v.size() <<    ;     for (auto to : v) {       cout << to <<    ;     }     cout << endl;   }   void dfs(int v) {     used[v] = 1;     for (auto to : g[v]) {       if (!used[to]) {         d[to] = d[v] + 1;         dfs(to);       }     }   }   void solve() {     vector<int> kek;     int n, need = 0;     cin >> n;     for (int i = 1; i <= n; i++) {       kek.push_back(i);     }     for (int i = 0; i < N; i++) {       g[i].clear();       used[i] = 0;       d[i] = 0;     }     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     ask(kek);     cin >> need >> need;     dfs(1);     int mx = 0;     for (int i = 1; i <= n; i++) {       mx = max(mx, d[i]);     }     int l = -1, r = mx + 1, j = 0;     while (r - l > 1) {       int mid = (r + l) / 2;       vector<int> lol;       for (int i = 1; i <= n; i++) {         if (d[i] >= mid) {           lol.push_back(i);         }       }       ask(lol);       int i, mn;       cin >> i >> mn;       if (mn == need) {         l = mid;         j = i;       } else {         r = mid;       }     }     kek.clear();     kek.push_back(1);     ask(kek);     int d1;     cin >> d1 >> d1;     d1 = (d1 - need) / 2;     int d2 = d1 + (need - (d[j] - d1));     kek.clear();     for (int i = 1; i <= n; i++) {       if (d[i] == d2) {         kek.push_back(i);       }     }     ask(kek);     int v, lol;     cin >> v >> lol;     bool x = 0;     deque<int> q;     q.push_back(v);     while (q.size() > 0) {       int u = q.front();       q.pop_front();       if (u == j) x = 1;       for (auto to : g[u]) {         if (d[to] > d[u]) {           q.push_back(to);         }       }     }     if (x) {       int last = v;       vector<int> kek1;       for (auto to : kek) {         if (to != v) {           kek1.push_back(to);         }       }       if (kek1.size() != 0) {         ask(kek1);         cin >> v >> lol;         if (lol != need) {           v = last;         }       }     }     cout <<  !  <<     << v <<     << j << endl;     return;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       solve();       string s;       cin >> s;       if (s ==  Correct )         continue;       else {         exit(0);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mod = 1e9 + 7;   long long binpow(long long a, long long b) {     long long res = 1;     while (b > 0) {       if (b & 1) res = (res % mod) * (a % mod), res %= mod;       a = (a % mod) * (a % mod);       a %= mod;       b >>= 1;     }     return res;   }   long long divide(long long a, int b) {     return ((a % mod) * binpow(b, mod - 2) % mod) % mod;   }   long long nCr(long long n, long long k) {     long long res = 1;     if (k > n - k) k = n - k;     for (int i = 0; i < k; ++i) {       res = ((res % mod) * ((n - i) % mod)) % mod;       res = divide(res, i + 1);     }     return res;   }   int main() {     ios ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, k;     cin >> n;     k = n;     bool can = (n == 1);     multiset<long long> st;     for (long long i = 2; i * i <= n; i++) {       while (n % i == 0) {         n /= i;         st.insert(i);       }     }     if (n > 1) st.insert(n);     if (n == k) can = 1;     if (can) {       return cout <<  1 n0 n , 0;     }     if (st.size() == 2) {       cout <<  2 n ;     } else {       cout <<  1 n ;       int cnt = 0;       long long mul = 1;       for (auto i : st) {         mul *= i;         cnt++;         if (cnt == 2) break;       }       cout << mul;     }   }
#include <bits/stdc++.h>   using namespace std;   void FastInputOutput() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int main() {     int n, temp;     map<int, int> idx;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , &temp);       idx[temp] = i;     }     int q;     long long l = 0, r = 0;     scanf( %d , &q);     while (q--) {       scanf( %d , &temp);       l += idx[temp], r += n - idx[temp] + 1;     }     printf( %lld %lld , l, r);     return 0;   }