malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MaxN = 200010, MaxB = 500, MaxA = 1000010, mod = 1000000007;   struct Query {     int l, r, id;     bool operator<(const Query &a) const { return r < a.r; }   } q[MaxN];   int n, m, a[MaxN];   vector<pair<int, int> > f[MaxN];   int last[MaxA];   int prime[MaxA], ptot, minp[MaxA];   int inv[MaxA];   bool notp[MaxA];   void init(int n) {     for (int i = 2; i <= n; ++i) {       if (!notp[i]) {         prime[++ptot] = i;         minp[i] = i;       }       for (int j = 1; j <= ptot && prime[j] * i <= n; ++j) {         notp[prime[j] * i] = 1;         minp[prime[j] * i] = prime[j];         if (i % prime[j] == 0) break;       }     }     inv[1] = 1;     for (int i = 2; i <= n; ++i)       inv[i] = mod - 1ll * (mod / i) * inv[mod % i] % mod;   }   int ans[MaxN];   int c[MaxN];   void modify(int x, int v) {     for (; x <= n; x += (x & -x)) c[x] = 1ll * c[x] * v % mod;   }   int query(int x) {     int ret = 1;     for (; x; x -= (x & -x)) ret = 1ll * ret * c[x] % mod;     return ret;   }   int main() {     scanf( %d , &n);     int mx = 0;     for (int i = 1; i <= n; ++i) {       scanf( %d , a + i);       mx = max(mx, a[i]);     }     init(mx);     for (int i = 1; i <= n; ++i) {       int x = a[i];       while (x != 1) {         int prod = 1, t = minp[x];         while (x % t == 0) {           x /= t;           prod *= t;         }         f[i].push_back(make_pair(t, prod));       }     }     scanf( %d , &m);     for (int i = 1; i <= m; ++i) {       scanf( %d%d , &q[i].l, &q[i].r);       q[i].id = i;     }     sort(q + 1, q + m + 1);     for (int i = 0; i <= n; ++i) c[i] = 1;     int node = 0;     for (int i = 1; i <= n; ++i) {       for (auto t : f[i]) {         modify(1, t.second);         modify(last[t.first] + 1, 1ll * (t.first - 1) * inv[t.first] % mod);         modify(i + 1, inv[t.second / t.first * (t.first - 1)]);         last[t.first] = i;       }       while (node < m && q[node + 1].r == i) {         ++node;         ans[q[node].id] = query(q[node].l);       }     }     for (int i = 1; i <= m; ++i) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void splay(int &v) {     v = 0;     char c = 0;     int p = 1;     while (c <  0  || c >  9 ) {       if (c ==  - ) p = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       v = (v << 3) + (v << 1) + c -  0 ;       c = getchar();     }     v *= p;   }   const int N = 800010;   int v[N], a[N], n, m, mi;   vector<int> vv[N];   void build(int l, int r, int w) {     if (l == r) return v[w] = a[l], void();     int mid = l + r >> 1;     build(l, mid, w << 1);     build(mid + 1, r, w << 1 | 1);     v[w] = min(v[w << 1], v[w << 1 | 1]);   }   void get(int l, int r, int w, int L, int R) {     if (L <= l && r <= R) {       mi = min(mi, v[w]);       return;     }     int mid = l + r >> 1;     if (L <= mid) get(l, mid, w << 1, L, R);     if (R > mid) get(mid + 1, r, w << 1 | 1, L, R);   }   int getmi(int l, int r) {     mi = 1 << 30;     if (l > r) return mi;     get(1, n, 1, l, r);     return mi;   }   int now = -1;   int main() {     splay(n), splay(m);     a[0] = 1;     for (int i = 1; i <= n; i++) {       splay(a[i]);       if (!a[i]) {         a[i] = a[i - 1];         now = i;       }       vv[a[i]].push_back(i);     }     build(1, n, 1);     for (int i = 1; i <= m; i++) {       for (int j = 0; j < (int)(vv[i].size()) - 1; j++) {         int x = getmi(vv[i][j] + 1, vv[i][j + 1] - 1);         if (x < i) puts( NO ), exit(0);       }     }     bool flag = 0;     for (int i = 1; i <= n; i++) {       if (a[i] == m) flag = 1;     }     if (!flag) {       if (now != -1)         a[now] = m;       else         puts( NO ), exit(0);     }     puts( YES );     for (int i = 1; i <= n; i++) {       printf( %d%c , a[i],    n [i == n]);     }   }
#include <bits/stdc++.h>   using LL = long long;   const int maxn = 1011000;   const LL mod = 1e9 + 7;   int seed = 29, n;   char str[maxn];   LL base[maxn], Hash[maxn];   int ans[maxn];   void init() {     memset(base, 0, sizeof(base));     base[0] = 1;     for (int i = 1; i < maxn; i++) {       base[i] = base[i - 1] * seed;       base[i] %= mod;     }   }   void init_hash() {     memset(Hash, 0, sizeof(Hash));     for (int i = n - 1; i >= 0; i--) {       Hash[i] = Hash[i + 1] * seed + str[i] -  a  + 1;       Hash[i] %= mod;     }   }   LL get_hash(int i, int len) {     auto ans = Hash[i] - Hash[i + len] * base[len];     ans %= mod;     if (ans < 0) ans += mod;     return ans;   }   int main() {     init();     while (std::cin >> n) {       std::cin >> str;       init_hash();       memset(ans, -1, sizeof(ans));       int cur = -1;       for (int i = (n - 1) / 2; i >= 0; i--) {         cur += 2;         if (2 * i == n - 1) {           cur = -1;         }         while (cur != -1 && get_hash(i, cur) != get_hash(n - i - cur, cur))           cur -= 2;         ans[i] = cur;       }       for (int i = 0; i <= (n - 1) / 2; i++) {         std::cout << ans[i] <<    ;       }       std::cout << std::endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long sum = 0, ff = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) ff = -1;       ch = getchar();     }     while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();     return sum * ff;   }   const long long N = 5005;   long long A, B, n, lcs[N][N], f[N];   char ch[N];   signed main() {     n = read();     A = read();     B = read();     scanf( %s , ch + 1);     for (long long i = 1; i <= n; i++)       for (long long j = 1; j <= n; j++)         if (ch[i] == ch[j])           lcs[i][j] = lcs[i - 1][j - 1] + 1;         else           lcs[i][j] = 0;     for (long long i = 1; i <= n; i++) {       f[i] = f[i - 1] + A;       for (long long j = 1; j < i; j++)         if (lcs[i][j] <= i - j) f[i] = min(f[i], f[i - lcs[i][j]] + B);     }     printf( %lld n , f[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gi() {     char cc = getchar();     long long cn = 0, flus = 1;     while (cc <  0  || cc >  9 ) {       if (cc ==  - ) flus = -flus;       cc = getchar();     }     while (cc >=  0  && cc <=  9 ) cn = cn * 10 + cc -  0 , cc = getchar();     return cn * flus;   }   const long long P = 998244353;   long long fpow(long long x, long long k) {     long long ans = 1, base = x;     while (k) {       if (k & 1) ans = 1ll * ans * base % P;       base = 1ll * base * base % P, k >>= 1;     }     return ans;   }   const long long N = 3e5 + 5;   long long m, n, a[N], fac[N], inv[N];   long long C(long long x, long long y) {     return fac[x] * inv[y] % P * inv[x - y] % P;   }   signed main() {     m = gi(), n = m * 2;     for (register long long i = (1); i <= (n); ++i) a[i] = gi();     sort(a + 1, a + n + 1);     fac[0] = inv[0] = 1;     for (register long long i = (1); i <= (n); ++i) fac[i] = fac[i - 1] * i % P;     for (register long long i = (1); i <= (n); ++i) inv[i] = fpow(fac[i], P - 2);     long long ans = 0;     for (register long long i = (1); i <= (n); ++i) {       long long z = a[i] * C(n - 1, m - 1);       if (i <= m)         ans = (ans - z + P) % P;       else         ans = (ans + z + P) % P;     }     cout << ans * 2 % P << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   const int M = (1e5 + 10 + N) * 2;   const int inf = 0x3f3f3f3f;   int n, m, S, T;   struct node {     int u, v, w;   } Edge[N];   bool cmp(node &a, node &b) { return a.w < b.w; }   int h[N], tot, e[M], f[M], ne[M];   int d[N], cur[N];   void add(int u, int v, int w) {     e[tot] = v, f[tot] = w, ne[tot] = h[u], h[u] = tot++;     e[tot] = u, f[tot] = 0, ne[tot] = h[v], h[v] = tot++;   }   bool bfs() {     queue<int> q;     q.push(S);     memset(d, -1, sizeof d);     d[S] = 0;     cur[S] = h[S];     while (!q.empty()) {       int u = q.front();       q.pop();       for (int i = h[u]; ~i; i = ne[i]) {         int v = e[i];         if (d[v] == -1 && f[i]) {           d[v] = d[u] + 1;           cur[v] = h[v];           if (v == T) return true;           q.push(v);         }       }     }     return false;   }   int dfs(int u, int limit) {     if (u == T) return limit;     int flow = 0;     for (int i = cur[u]; ~i && flow < limit; i = ne[i]) {       cur[u] = i;       int v = e[i];       if (d[v] == d[u] + 1 && f[i]) {         int t = dfs(v, min(f[i], limit - flow));         flow += t;         f[i] -= t;         f[i ^ 1] += t;       }     }     return flow;   }   int dinic() {     int flow, res = 0;     while (bfs()) {       while (flow = dfs(S, inf)) res += flow;     }     return res;   }   bool check(int mid) {     S = 0, T = 2 * n + 1;     for (int i = 0; i <= T; i++) h[i] = -1;     tot = 0;     for (int i = 1; i <= n; i++) add(S, i, 1);     for (int j = 1; j <= n; j++) add(n + j, T, 1);     for (int i = 1; i <= m; i++) {       if (Edge[i].w > mid) break;       add(Edge[i].u, n + Edge[i].v, Edge[i].w);     }     return dinic() == n;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++)       scanf( %d%d%d , &Edge[i].u, &Edge[i].v, &Edge[i].w);     sort(Edge + 1, Edge + 1 + m, cmp);     int l = 1, r = Edge[m].w;     int ans = -1;     while (l <= r) {       int mid = (l + r) / 2;       if (check(mid)) {         r = mid - 1;         ans = mid;       } else         l = mid + 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 1000 + 5;   int n;   int mat[NMAX][NMAX];   vector<pair<int, int> > sol;   void DEI(int l, int r, int insert_type) {     if (r - l + 1 < 3) return;     int k;     for (k = l + 1; k <= r - 1; ++k)       if (mat[l][k] && mat[k][r]) break;     if (insert_type == 0) sol.push_back(make_pair(l, r));     mat[l][r] = mat[r][l] = false;     mat[1][k] = mat[k][1] = true;     DEI(l, k, insert_type);     DEI(k, r, insert_type);     if (insert_type == 1) sol.push_back(make_pair(1, k));   }   void solve(int type) {     memset(mat, 0, sizeof mat);     vector<int> graph1;     for (int i = 1; i < n - 2; ++i) {       int a, b;       cin >> a >> b;       mat[a][b] = mat[b][a] = true;     }     for (int i = 1; i <= n; ++i) mat[i][i % n + 1] = mat[i % n + 1][i] = true;     for (int i = 1; i <= n; ++i)       if (mat[1][i]) graph1.push_back(i);     for (int i = 1; i < graph1.size(); ++i) DEI(graph1[i - 1], graph1[i], type);   }   int main() {     cin >> n;     solve(0);     solve(1);     cout << sol.size() <<   n ;     for (auto it : sol) cout << it.first <<     << it.second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename C>   void ma(C& a, C b) {     if (a < b) a = b;   }   template <typename C>   void mi(C& a, C b) {     if (a > b) a = b;   }   int cas, n, l[251], r[251], w[251], roz[251];   void licz_roz(int nr) {     if (w[nr] == -1) {       licz_roz(l[nr]);       licz_roz(r[nr]);       if (roz[r[nr]] & 1) swap(l[nr], r[nr]);       roz[nr] = 1 + roz[l[nr]] + roz[r[nr]];     } else       roz[nr] = 0;   }   int dp[251][2][3];   int ak[251][2][3];   inline int mima(int a, int b, bool jak) { return ((a > b) ^ jak) ? a : b; }   inline int mima3(int a, int b, int c, bool jak) {     return mima(mima(a, b, jak), c, jak);   }   int dfs(int nr, bool kto, int pas) {     if (w[nr] != -1) return w[nr];     if (roz[nr] == 1) return mima(w[l[nr]], w[r[nr]], kto ^ (pas == 2));     int& res = dp[nr][kto][pas];     if (ak[nr][kto][pas] == cas) return res;     ak[nr][kto][pas] = cas;     if (pas) {       if (roz[nr] & 1) {         res = dfs(nr, !kto, 0);         if (roz[l[nr]] & 1) {           int pom =               mima(dfs(l[nr], kto, 0),                    dfs(r[nr], !kto, roz[l[nr]] == 1 && pas == 1 ? 2 : 1), !kto);           res = mima(res, pom, kto);           pom = mima(dfs(r[nr], kto, 0),                      dfs(l[nr], !kto, roz[r[nr]] == 1 && pas == 1 ? 2 : 1), !kto);           res = mima(res, pom, kto);         } else {           if (roz[r[nr]]) {             int pom =                 mima(dfs(l[nr], !kto, 0),                      dfs(r[nr], kto, roz[l[nr]] == 0 && pas == 1 ? 2 : 1), !kto);             res = mima(res, pom, kto);           }           if (roz[l[nr]]) {             int pom =                 mima(dfs(r[nr], !kto, 0),                      dfs(l[nr], kto, roz[r[nr]] == 0 && pas == 1 ? 2 : 1), !kto);             res = mima(res, pom, kto);           }         }       } else {         res = mima(dfs(r[nr], kto, 0),                    dfs(l[nr], kto, roz[r[nr]] == 0 && pas == 1 ? 2 : 1), kto);       }     } else {       if (roz[nr] & 1) {         if (roz[l[nr]] & 1)           res = mima(dfs(l[nr], kto, 1), dfs(r[nr], kto, 1), kto);         else           res = mima(dfs(l[nr], kto, 0), dfs(r[nr], kto, 0), kto);       } else {         int pom = mima(dfs(l[nr], kto, 0), dfs(r[nr], !kto, 0), !kto);         int pom2 = mima(dfs(l[nr], !kto, 1), dfs(r[nr], kto, 1), !kto);         res = mima(pom, pom2, kto);       }     }     return res;   }   void test() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &w[i]);       if (w[i] == -1) {         scanf( %d , &l[i]);         scanf( %d , &r[i]);       }     }     licz_roz(0);     printf( %d n , dfs(0, 0, 0));   }   int main() {     int _;     scanf( %d , &_);     for (cas = 1; cas <= _; cas++) test();   }
#include <bits/stdc++.h>   using namespace std;   int cost[15][2][2];   string a[15];   int dp[15][2], topFloor;   int memoize(int floor, int dir) {     if (floor > topFloor) {       return 0;     }     if (floor == topFloor) {       return cost[floor][dir][dir];     }     if (dp[floor][dir] != -1) return dp[floor][dir];     int ans = 2000000000;     ans = min(memoize(floor + 1, dir ^ 1) + 1 + cost[floor][dir][dir ^ 1],               memoize(floor + 1, dir) + 1 + cost[floor][dir][dir]);     return dp[floor][dir] = ans;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     reverse(a, a + n);     m += 2;     topFloor = -1;     for (int i = 0; i < n; i++) {       bool present = false;       int mini = m + 5, maxi = -1;       for (int j = 0; j < m; j++) {         if (a[i][j] ==  1 ) {           present = true;           mini = min(mini, j);           maxi = max(maxi, j);         }       }       if (present) {         topFloor = i;         cost[i][0][0] = maxi * 2;         cost[i][1][1] = (m - 1 - mini) * 2;       }       cost[i][0][1] = m - 1;       cost[i][1][0] = m - 1;     }     if (topFloor != -1) {       cost[topFloor][0][0] /= 2;       cost[topFloor][1][1] /= 2;     }     memset(dp, -1, sizeof(dp));     int ans = memoize(0, 0);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<string> S;   string rotate1(string s) {     string s1 = s;     s1[1] = s[2];     s1[2] = s[4];     s1[4] = s[5];     s1[5] = s[1];     return s1;   }   string rotate2(string s) {     string s1 = s;     s1[0] = s[1];     s1[1] = s[3];     s1[3] = s[4];     s1[4] = s[0];     return s1;   }   set<pair<string, bool> > poszlo;   void go(string s, bool sel) {     if (!poszlo.insert(make_pair(s, sel)).second) return;     S.insert(s);     if (sel) {       s = rotate2(s);       go(s, 0);       s = rotate2(s);       go(s, 0);       s = rotate2(s);       go(s, 0);     } else {       s = rotate1(s);       go(s, 1);       s = rotate1(s);       go(s, 1);       s = rotate1(s);       go(s, 1);     }   }   int main() {     string s;     cin >> s;     sort(s.begin(), s.end());     int res = 0;     do {       if (S.insert(s).second) res++;       poszlo.clear();       go(s, 0);       go(s, 1);     } while (next_permutation(s.begin(), s.end()));     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int INF = 0x3f3f3f3f;   int INF2 = 0x7fffffff;   long long LNF = 0x3f3f3f3f3f3f3f3f;   long long LNF2 = 0x7fffffffffffffff;   long long n, k, M, D;   long long ans;   int main() {     scanf( %I64d%I64d%I64d%I64d , &n, &k, &M, &D);     for (int i = (1); i <= (D); ++i) {       if (i * k - k + 1 > n) break;       long long c = n / (i * k - k + 1);       c = min(c, M);       ans = max(ans, c * i);     }     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, r;     cin >> n >> m >> r;     int min1 = 1001;     int max1 = 0;     int a, b;     for (int i = 0; i < n; i++) {       cin >> a;       min1 = min(a, min1);     }     for (int i = 0; i < m; i++) {       cin >> b;       max1 = max(b, max1);     }     int d = r / min1;     if (min1 > max1) {       cout << r << endl;       return 0;     }     int cost = (d * max1 + r % min1);     if (cost > r) {       cout << cost << endl;     } else {       cout << r << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     float square = sqrt(n);     float csquare = ceil(square);     if ((csquare == square) || (csquare - square <= 0.5)) {       cout << 4 * csquare;     } else if (csquare - square > 0.5) {       cout << 2 * (csquare + (csquare - 1));     }     return 0;   }
#include <bits/stdc++.h>   const int Mod = (int)1e9 + 7;   const int MX = 1073741822;   const long long MXLL = 4611686018427387903;   const int Sz = 2e5 + 1;   using namespace std;   inline void Read_rap() {     ios_base ::sync_with_stdio(0);     cin.tie(0);   }   int n;   int a[Sz];   long long dp[Sz][20][2], lca[Sz][20][2], sum[Sz][20][2];   vector<int> g[Sz];   void dfs(int v, int pr) {     for (int i = 0; i < 20; i++) dp[v][i][((a[v] & (1 << i)) > 0)]++;     for (auto to : g[v]) {       if (to != pr) {         dfs(to, v);         for (int i = 0; i < 20; i++) {           for (int j = 0; j < 2; j++) {             bool bit = (a[v] & (1 << i)) > 0;             bool b = (j ^ bit);             dp[v][i][b] += dp[to][i][j];           }         }       }     }     for (auto to : g[v]) {       if (to != pr) {         for (int i = 0; i < 20; i++) {           for (int j = 0; j < 2; j++) {             for (int k = 0; k < 2; k++) {               bool bit = (a[v] & (1 << i)) > 0;               bool b = (j ^ k ^ bit);               lca[v][i][b] += sum[v][i][j] * dp[to][i][k];             }           }           for (int j = 0; j < 2; j++) sum[v][i][j] = sum[v][i][j] + dp[to][i][j];         }       }     }   }   int main() {     Read_rap();     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i < n; i++) {       int x, y;       cin >> x >> y;       g[x].push_back(y);       g[y].push_back(x);     }     dfs(1, 1);     long long ans = 0;     for (int i = 0; i < 20; i++)       for (int v = 1; v <= n; v++)         ans = (ans + (dp[v][i][1] + lca[v][i][1]) * (1ll << i));     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[55][55];   int main() {     int cs;     scanf( %d , &cs);     while (cs--) {       int n, m;       scanf( %d %d , &n, &m);       int col = 0, row = 0;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           scanf( %d , &a[i][j]);         }       }       for (int i = 0; i < n; i++) {         bool flag = true;         for (int j = 0; j < m; j++) {           if (a[i][j] & 1) {             flag = false;             break;           }         }         if (flag) row++;       }       for (int i = 0; i < m; i++) {         bool flag = true;         for (int j = 0; j < n; j++) {           if (a[j][i] & 1) {             flag = false;             break;           }         }         if (flag) col++;       }       if (min(col, row) % 2)         puts( Ashish );       else         puts( Vivek );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[500000], o, ans;   int main() {     cin >> n;     ans = 1;     for (int i = 2; i <= n + 1; i++) {       if (a[i] == 0) {         a[i] = 1;         o = 1;         for (int j = i + i; j <= n + 1; j += i) {           o = 2;           ans = max(ans, o);           a[j] = o;         }       }     }     cout << ans << endl;     for (int i = 2; i <= n + 1; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dat[2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2];   int main() {     int t, i;     scanf( %d , &t);     long long var;     char str[20];     char ch =  + ;     int arr[18];     while (t--) {       cin >> ch;       for (i = 0; i <= 17; i++) {         arr[i] = 0;       }       if (ch ==  + ) {         scanf( %I64d , &var);         i = 0;         while (var != 0) {           arr[i] = (var % 10) % 2;           var /= 10;           i++;         }         dat[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]]            [arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]]            [arr[16]][arr[17]]++;       } else if (ch ==  - ) {         scanf( %I64d , &var);         i = 0;         while (var != 0) {           arr[i] = (var % 10) % 2;           var /= 10;           i++;         }         dat[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]]            [arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]]            [arr[16]][arr[17]]--;       } else {         scanf( %s , &str);         i = 0;         while (str[i] !=   0 ) {           i++;         }         int j = 0;         while (j < i) {           arr[j] = str[i - j - 1] -  0 ;           j++;         }         printf( %d  , dat[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]]                          [arr[7]][arr[8]][arr[9]][arr[10]][arr[11]][arr[12]]                          [arr[13]][arr[14]][arr[15]][arr[16]][arr[17]]);         printf(  n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   char s[200];   int main() {     int T;     scanf( %d , &T);     for (int t = 1; t <= T; t++) {       bool num = 0, xx = 0, dx = 0;       vector<int> res;       scanf( %s , s + 1);       int len = strlen(s + 1);       for (int i = 1; i <= len; i++) {         if (isdigit(s[i])) {           if (!num)             num = 1;           else             res.push_back(i);         }         if (isalpha(s[i])) {           if (s[i] == tolower(s[i])) {             if (!xx)               xx = 1;             else               res.push_back(i);           } else {             if (!dx)               dx = 1;             else               res.push_back(i);           }         }       }       int cnt = 1;       if (num == 0) s[res.back()] =  1 , res.pop_back();       if (xx == 0) s[res.back()] =  a , res.pop_back();       if (dx == 0) s[res.back()] =  A , res.pop_back();       printf( %s n , s + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k;     cin >> n;     long long int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     int sum = 0;     for (int i = 0; i < n - 1; i++) sum += (a[n - 1] - a[i]);     cout << sum;   }
#include <bits/stdc++.h>   void swap(int *, int *);   int main() {     int i, j, k;     int n;     scanf( %d , &n);     int arr[n];     for (i = 0; i < n; i++) {       scanf( %d , &arr[i]);     }     int limit = n / 2;     for (i = 0; i < limit; i++) {       if (i % 2 == 0) {         swap(&arr[i], &arr[n - i - 1]);       }     }     for (i = 0; i < n; i++) {       printf( %d  , arr[i]);     }   }   void swap(int *a, int *b) {     int t;     t = *a;     *a = *b;     *b = t;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d %d , &n, &m);     int a, b, a_min, b_min;     scanf( %d %d , &a_min, &b_min);     for (int i = 1; i < n; i++) {       scanf( %d %d , &a, &b);       if (a * b_min < a_min * b) {         a_min = a;         b_min = b;       }     }     double c = m * a_min / (b_min * 1.0f);     printf( %f n , c);     return 0;   }