malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T>   void pv(T a, T b) {     for (T i = a; i != b; ++i) cout << *i <<    ;     cout << endl;   }   template <class T>   void chmin(T &t, T f) {     if (t > f) t = f;   }   template <class T>   void chmax(T &t, T f) {     if (t < f) t = f;   }   int in() {     int x;     scanf( %d , &x);     return x;   }   int uf[110];   int root(int x) { return (uf[x] < 0) ? x : (uf[x] = root(uf[x])); }   bool conn(int x, int y) {     x = root(x);     y = root(y);     if (x == y) return 0;     if (uf[x] > uf[y]) swap(x, y);     uf[x] += uf[y];     uf[y] = x;     return 1;   }   int N, M;   int A[10010], B[10010];   int len;   int usLens[110];   int us[110][110];   int main() {     int i;     int u, v;     int j, k;     for (; ~scanf( %d%d , &N, &M);) {       for (i = 0; i < M; ++i) {         A[i] = in() - 1;         B[i] = in() - 1;       }       memset(uf, ~0, N << 2);       for (i = 0; i < M; ++i) {         conn(A[i], B[i]);       }       len = 0;       memset(usLens, 0, sizeof(usLens));       for (u = 0; u < N; ++u)         if (uf[u] < 0) {           if (-uf[u] > 3) {             goto failed;           }           if (-uf[u] < 2) {             continue;           }           for (v = 0; v < N; ++v)             if (root(v) == u) {               us[len][usLens[len]++] = v;             }           ++len;         }       if (len > N / 3) {         goto failed;       }       for (u = 0; u < N; ++u)         if (uf[u] < 0) {           if (-uf[u] < 2) {             for (j = 0; j < N / 3; ++j) {               if (usLens[j] < 3) {                 us[j][usLens[j]++] = u;                 break;               }             }           }         }       for (j = 0; j < N / 3; ++j) {         for (k = 0; k < 3; ++k) {           if (k) printf(   );           printf( %d , us[j][k] + 1);         }         puts(  );       }       continue;     failed:;       puts( -1 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dir4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};   int dir8[8][2] = {{-1, 0}, {1, 0},  {0, 1}, {0, -1},                     {-1, 1}, {1, -1}, {1, 1}, {-1, -1}};   int dir8h[8][2] = {{2, 1}, {-2, -1}, {-1, 2}, {1, -2},                      {1, 2}, {-2, 1},  {2, -1}, {-1, -2}};   long double eps = 1e-7;   const int N = 52;   long long dp[N][N];   vector<string> v[N];   int main() {     ios_base::sync_with_stdio(false);     int n;     string s;     cin >> n;     for (long long i = 0; i < n; i++) {       cin >> s;       v[i].push_back(s);       for (long long j = 1; j <= s.size() - 1; j++) {         string s1;         for (long long k = 1; k <= s.size() - 1; k++) s1 += s[k];         s1 += s[0];         v[i].push_back(s1);         s = s1;       }     }     for (long long i = 0; i < n; i++)       for (long long j = 0; j < v[0].size(); j++) dp[i][j] = 1e9;     for (long long i = 0; i < v[0].size(); i++) dp[0][i] = i;     for (long long i = 1; i <= n - 1; i++) {       for (long long j = 0; j < v[i].size(); j++) {         for (long long k = 0; k < v[i - 1].size(); k++)           if (v[i][j] == v[i - 1][k]) dp[i][j] = min(dp[i][j], j + dp[i - 1][k]);       }     }     long long mn = 1e9;     for (long long i = 0; i < v[n - 1].size(); i++) mn = min(mn, dp[n - 1][i]);     if (mn == 1e9)       cout << -1;     else       cout << mn;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t > 0) {       long long int n, s;       cin >> n >> s;       long long int a[n];       long long int sum = 0;       for (long long int i = (0); i < (n); i++) {         cin >> a[i];         sum = sum + a[i];       }       if (s >= sum) {         cout << 0 << endl;         t--;         continue;       }       long long int flag = 0;       long long int index;       long long int count = 0;       for (long long int i = (0); i < (n); i++) {         count = count + a[i];         if (count > s) {           index = i;           flag = 1;           break;         }       }       long long int m = INT_MIN;       long long int ans = 0;       for (long long int i = (0); i < (index + 1); i++) {         if (a[i] > m) {           m = a[i];           ans = i;         }       }       if (ans == index) {         if (count - a[index] + a[index + 1] <= s) {           cout << index + 1 << endl;         } else {           cout << 0 << endl;         }         t--;         continue;       } else {         cout << ans + 1 << endl;         t--;         continue;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int T = 1;     while (T--) {       int n, u;       cin >> n >> u;       vector<int> v;       for (int i = 0; i < n; i++) {         int t;         cin >> t;         v.push_back(t);       }       int I, K, J;       double ans = 0.0;       for (int i = 0; i < n - 2; i++) {         I = v[i];         J = v[i + 1];         K = lower_bound((v).begin(), (v).end(), u + I) - v.begin();         if (K == n) {           K = n - 1;         } else if (v[K] != u + I) {           K--;         }         K = v[K];         double a = double(K - J) / (K - I);         ans = max(a, ans);       }       if (ans == 0) {         cout << -1;         exit(0);       }       printf( %.20f , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b, c;     cin >> a >> b;     sort(a.begin(), a.end());     if (a.length() < b.length()) {       reverse(a.begin(), a.end());       cout << a << endl;     } else {       for (int i = 0; i < a.length(); i++) {         for (int j = a.length() - 1; j > i; j--) {           c = a;           swap(a[i], a[j]);           sort(a.begin() + i + 1, a.end());           if (a > b) {             a = c;           } else             break;         }       }       cout << a << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, M;     cin >> N >> M;     long long ans = 0;     int step = 1;     for (int i = 1; i <= M; ++i) {       int T;       cin >> T;       if (T >= step) {         ans += T - step;       } else {         ans += N - step + T;       }       step = T;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using i64 = long long;   using f64 = double;   using f80 = long double;   using pii = pair<int, int>;   using pll = pair<i64, i64>;   using ptx = pair<f64, f64>;   const int N = 3e5 + 5, LG = 20;   int f[N], conv[N], tmp[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     int n;     cin >> n;     for (int t, i = 1; i <= n; ++i) {       cin >> t;       f[t] = conv[t] = 1;       if (t == 1) {         cout <<  1 n ;         return 0;       }     }     for (int tid = 2; tid <= 7; ++tid) {       i64 drop, st, dr;       for (int i = N - 1; i >= 1; --i) {         drop = st = dr = 0;         for (int j = i; j < N; j += i) {           drop += tmp[j];           st += conv[j];           dr += f[j];         }         tmp[i] = st * dr - drop;       }       if (tmp[1]) {         cout << tid << endl;         return 0;       }       for (int i = 0; i < N; ++i) {         conv[i] = int(tmp[i] > 0);         tmp[i] = 0;       }     }     cout <<  -1 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long suf(long long a) { return (a * (a + 1)) / 2; }   const long long OO = 1e6 + 10, MOD = 1e9 + 7;   vector<vector<int> > adj, can;   int dx[]{1, -1, 0, 0, 1, -1, 1, -1};   int dy[]{0, 0, 1, -1, 1, -1, -1, 1};   int main() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long n, m, k, a, b, c, d;     string s, s1;     char ch;     while (cin >> n) {       vector<vector<int> > v(1e5 + 5);       vector<pair<int, int> > ans;       for (int i = 0; i < n; i++) {         cin >> a;         v[a].push_back(i + 1);       }       for (int i = 0; i < v.size(); i++) {         if (v[i].size() == 1)           ans.push_back({i, 0});         else if (v[i].size() > 1) {           int now = v[i][1] - v[i][0];           bool ok = true;           for (int j = 2; j < v[i].size(); j++) {             if (v[i][j] - v[i][j - 1] != now) {               ok = false;               break;             }           }           if (ok) ans.push_back({i, now});         }       }       cout << ans.size() << endl;       for (int i = 0; i < ans.size(); i++)         cout << ans[i].first <<     << ans[i].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2 * 1e5;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   int a[N];   int n;   int dfs(int h, int w, int s) {     if (s > n) return h;     int sum = 0;     for (int i = s; i <= n; i++) {       if (a[i] > a[i + 1]) sum++;       if (sum == w) return dfs(h + 1, i - s + 1, i + 1);     }     return h + 1;   }   int main() {     int T;     T = read();     while (T--) {       n = read();       for (int i = 1; i <= n; i++) a[i] = read();       printf( %d n , dfs(1, 1, 2) - 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int MAXN = 200000;   int n;   int a[MAXN];   void run() {     scanf( %d , &n);     for (int i = (0); i < (n); ++i) scanf( %d , &a[i]);     sort(a, a + n);     int ndiff = unique(a, a + n) - a;     int ret = n + 1 - ndiff;     printf( %d n , ret);   }   int main() {     run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int l, r;   } e[200010];   bool operator<(node t1, node t2) { return t1.r < t2.r; }   int n, ans;   int main() {     scanf( %d , &n);     int w, x;     for (int i = 1; i <= n; i++) {       scanf( %d%d , &x, &w);       e[i].l = x - w;       e[i].r = x + w;     }     sort(e + 1, e + n + 1);     int L = -0x7fffffff;     for (int i = 1; i <= n; i++) {       if (e[i].l >= L) {         ans++;         L = e[i].r;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using cd = complex<double>;   const double pi = acos(-1);   const double EPS = 1e-5;   void iter(vector<cd> &a, bool invert) {     int n = a.size();     for (int i = 1, j = 0; i < n; i++) {       int bit = n >> 1;       for (; j & bit; bit >>= 1) j ^= bit;       j ^= bit;       if (i < j) swap(a[i], a[j]);     }     for (int len = 2; len <= n; len <<= 1) {       double ang = 2 * pi / len * (invert ? -1 : 1);       cd wlen(cos(ang), sin(ang));       for (int i = 0; i < n; i += len) {         cd w(1);         for (int j = 0; j < len / 2; j++) {           cd u = a[i + j], v = a[i + j + len / 2] * w;           a[i + j] = u + v;           a[i + j + len / 2] = u - v;           w *= wlen;         }       }     }     if (invert)       for (cd &x : a) x /= n;   }   void iter2d(vector<vector<cd>> &a, bool invert) {     for (auto &it : a) iter(it, invert);     for (int j = 0; j < a[0].size(); j++) {       vector<cd> col(a.size());       for (int i = 0; i < a.size(); i++) col[i] = a[i][j];       iter(col, invert);       for (int i = 0; i < a.size(); i++) a[i][j] = col[i];     }   }   vector<vector<int>> mult(vector<vector<cd>> &a, vector<vector<cd>> &b) {     int nr = 1;     while (nr < a.size() + b.size()) nr <<= 1;     a.resize(nr);     b.resize(nr);     int nc = 1;     while (nc < a[0].size() + b[0].size()) nc <<= 1;     for (auto &it : a) it.resize(nc, 0);     for (auto &it : b) it.resize(nc, 0);     iter2d(a, 0);     iter2d(b, 0);     for (int i = 0; i < nr; i++)       for (int j = 0; j < nc; j++) a[i][j] *= b[i][j];     iter2d(a, 1);     vector<vector<int>> ret(nr, vector<int>(nc));     for (int i = 0; i < nr; i++)       for (int j = 0; j < nc; j++) ret[i][j] = (int)(a[i][j].real() + EPS);     return ret;   }   const int N = 401;   int n, m, r, c;   string str[N];   string pat[N];   int main() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> str[i];     cin >> r >> c;     for (int i = 0; i < r; i++) cin >> pat[i];     vector<vector<cd>> a(n + r, vector<cd>(m + c)), b(r, vector<cd>(c, 0));     for (int i = 0; i < n + r; i++)       for (int j = 0; j < m + c; j++) {         int cur = str[i % n][j % m] -  a ;         double ang = 2 * pi * cur / 26;         a[i][j] = cd(cos(ang), sin(ang));       }     int cnt = 0;     for (int i = 0; i < r; i++)       for (int j = 0; j < c; j++) {         if (pat[i][j] ==  ? ) continue;         cnt++;         int cur = pat[i][j] -  a ;         double ang = 2 * pi * cur / 26;         b[r - 1 - i][c - 1 - j] = cd(cos(ang), -sin(ang));       }     vector<vector<int>> ret;     ret = mult(a, b);     for (int i = r - 1; i < n + r - 1; i++) {       for (int j = c - 1; j < m + c - 1; j++) cout << (ret[i][j] == cnt);       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100 + 5;   int boy[maxn], girl[maxn];   int n, m;   int main() {     int b, g;     while (scanf( %d%d , &n, &m) != EOF) {       memset(boy, 0, sizeof(boy));       memset(girl, 0, sizeof(girl));       int in;       scanf( %d , &b);       for (int i = 0; i < b; i++) {         scanf( %d , &in);         boy[in] = 1;       }       scanf( %d , &g);       for (int i = 0; i < g; i++) {         scanf( %d , &in);         girl[in] = 1;       }       bool flag;       int stb = 0, stg = 0;       int cnt = maxn * maxn;       while (cnt) {         flag = true;         stb %= n;         stg %= m;         if (boy[stb] || girl[stg]) {           boy[stb] = 1;           girl[stg] = 1;         }         for (int i = 0; i < n; i++) {           if (!boy[i]) {             flag = false;             break;           }         }         for (int i = 0; i < m; i++) {           if (!girl[i]) {             flag = false;             break;           }         }         if (flag) break;         stb++;         stg++;         cnt--;       }       printf( %s n , flag ?  Yes  :  No );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = (int)1e9;   long double sqr(long double a) { return a * a; }   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   int main() {     ios_base::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     long long k;     cin >> k;     map<long long, pair<long long, long long> > sm;     for (auto i = 0; i < k; ++i) {       long long n, sum = 0;       cin >> n;       vector<long long> a(n);       for (auto &it : a) {         cin >> it;         sum += it;       }       for (auto j = 0; j < n; ++j) {         if (sm.find(sum - a[j]) != sm.end()) {           cout <<  YES n                 << sm[sum - a[j]].first <<     << sm[sum - a[j]].second <<   n                 << i + 1 <<     << j + 1;           return 0;         }       }       for (auto j = 0; j < n; ++j) {         sm[sum - a[j]] = {i + 1, j + 1};       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   int res[1100002];   int mark[1100002];   void set(int i, int L, int R, int l, int r, int x) {     int LR, RL;     if (L <= R && l <= r && L <= l && r <= R && res[i] <= 0 && mark[i] == 0) {       if (L == l && R == r) mark[i] = 1;       if (res[i] == 0 && L == l && R == r)         res[i] = x;       else {         if (res[i] >= 0) {           res[(i << 1) + 1] = res[i];           res[(i << 1) + 2] = res[i];           res[i] = -1;           mark[(i << 1) + 1] = 0;           mark[(i << 1) + 2] = 0;         }         LR = L + ((R - L) >> 1);         RL = LR + 1;         if (l <= LR) {           if (r < LR)             set((i << 1) + 1, L, LR, l, r, x);           else             set((i << 1) + 1, L, LR, l, LR, x);         }         if (r >= RL) {           if (l > RL)             set((i << 1) + 2, RL, R, l, r, x);           else             set((i << 1) + 2, RL, R, RL, r, x);         }       }     }   }   void out(int i, int L, int R) {     int j;     if (res[i] >= 0)       for (j = L; j <= R; j++) printf( %d  , res[i]);     else {       out((i << 1) + 1, L, L + ((R - L) >> 1));       out((i << 1) + 2, L + ((R - L) >> 1) + 1, R);     }   }   int main() {     int i;     int n;     int m;     int l, r, x;     scanf( %d%d , &n, &m);     res[0] = 0;     mark[0] = 0;     for (i = 0; i < m; i++) {       scanf( %d%d%d , &l, &r, &x);       if (x - 1 >= l) set(0, 1, n, l, x - 1, x);       if (x + 1 <= r) set(0, 1, n, x + 1, r, x);     }     out(0, 1, n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5;   char s[maxn];   int a[maxn];   int n, l, r, i, x;   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     for (i = 1; i <= n; i++) a[i] = s[i] -  0 ;     l = 1;     r = n;     if (a[l] != a[r]) {       a[l]--;       a[l + 1] += 10;       if (!a[l])         l++;       else if (a[l] != a[r]) {         printf( 0 );         return 0;       }     }     while (l <= r) {       if (a[l] >= a[r] + 10 && a[r] < 10) a[r - 1]--, a[r] += 10;       if (a[l] == a[r] + 1) a[l + 1] += 10, a[l]--;       if (a[l] != a[r]) break;       if (l != r) {         a[l] = a[l] - a[l] / 2;         a[r] -= a[l];       } else if ((a[l] & 1) == 0)         a[l] >>= 1;       else         break;       if (a[l] < 0 || a[l] > 9 || a[r] < 0 || a[r] > 9) break;       l++;       r--;     }     if (l <= r) {       printf( 0 );     } else {       l = 1;       if (!a[l]) l++;       while (l <= n) {         printf( %d , a[l]);         l++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Imx = 2147483647;   const long long Lbig = 2e18;   const int mod = 1e9 + 7;   struct fastio {     char s[100000];     int it, len;     fastio() { it = len = 0; }     inline char get() {       if (it < len) return s[it++];       it = 0;       len = fread(s, 1, 100000, stdin);       if (len == 0)         return EOF;       else         return s[it++];     }     bool notend() {       char c = get();       while (c ==     || c ==   n ) c = get();       if (it > 0) it--;       return c != EOF;     }   } _buff;   inline long long getnum() {     long long r = 0;     bool ng = 0;     char c;     c = _buff.get();     while (c !=  -  && (c <  0  || c >  9 )) c = _buff.get();     if (c ==  - ) ng = 1, c = _buff.get();     while (c >=  0  && c <=  9 ) r = r * 10 + c -  0 , c = _buff.get();     return ng ? -r : r;   }   template <class T>   inline void putnum(T x) {     if (x < 0) putchar( - ), x = -x;     register short a[20] = {}, sz = 0;     while (x) a[sz++] = x % 10, x /= 10;     if (sz == 0) putchar( 0 );     for (int i = sz - 1; i >= 0; i--) putchar( 0  + a[i]);   }   inline char getreal() {     char c = _buff.get();     while (c ==     || c ==   n ) c = _buff.get();     return c;   }   int n;   int head[500111], nxt[1000111], to[1000111], tot = 1;   int head2[500111], nxt2[1000111], to2[1000111], tot2 = 1;   int f[500111];   bool oc[500111], oc2[500111];   void adde(int x, int y) {     nxt[++tot] = head[x];     head[x] = tot;     to[tot] = y;   }   void adde2(int x, int y) {     nxt2[++tot2] = head2[x];     head2[x] = tot2;     to2[tot2] = y;   }   int gf(int x) { return f[x] == x ? x : f[x] = gf(f[x]); }   map<pair<int, int>, int> mpid;   int nid[500111];   void dfs(int x, int p = -1) {     for (int i = head[x]; i; i = nxt[i]) {       int u = to[i];       if (u == p) continue;       dfs(u, x);       if (oc[i >> 1]) continue;       int tmp = nid[gf(u)];       if (!tmp) continue;       putnum(u), putchar(   ), putnum(x), putchar(   );       putnum(to2[tmp]), putchar(   ), putnum(to2[tmp ^ 1]), putchar(  n );     }   }   void dfs2(int x, int p = -1) {     for (int i = head2[x]; i; i = nxt2[i]) {       int u = to2[i];       if (u == p) continue;       if (!oc2[i >> 1]) nid[gf(u)] = i;       dfs2(u, x);     }   }   int main() {     n = getnum();     for (int i = 1; i <= n; i++) f[i] = i;     for (int i = 1; i < n; i++) {       int x, y;       x = getnum(), y = getnum();       if (x > y) swap(x, y);       mpid[make_pair(x, y)] = i;       adde(x, y);       adde(y, x);     }     int cnt = n - 1;     for (int i = 1; i < n; i++) {       int x, y;       x = getnum(), y = getnum();       if (x > y) swap(x, y);       if (mpid.find(make_pair(x, y)) != mpid.end()) {         oc[mpid[make_pair(x, y)]] = 1;         oc2[i] = 1;         cnt--;         f[gf(x)] = gf(y);       }       adde2(x, y);       adde2(y, x);     }     dfs2(1);     putnum(cnt), putchar(  n );     dfs(1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, c1 = 0, c2 = 0, i1 = 0, i2 = 0, t, cou = 0;     cin >> x >> y;     if (y < x) {       t = x;       x = y;       y = t;     }     while (x != y) {       if (c1 <= c2) {         if (c1 == 0) c1 = 1;         x++;         i1++;         c1 += i1;         cou += i1;       } else {         if (c2 == 0) c2 = 1;         y--;         i2++;         c2 += i2;         cou += i2;       }     }     cout << cou;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q, w, e, r;     cin >> q >> w >> e >> r;     string s;     cin >> s;     unsigned long long int c = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  1 ) {         c += q;       }       if (s[i] ==  2 ) {         c += w;       }       if (s[i] ==  3 ) {         c += e;       }       if (s[i] ==  4 ) {         c += r;       }     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m;     cin >> n >> m;     string s;     cin >> s;     char arr[26];     map<int, int> mmap;     for (int i = 0; i < 26; i++) {       mmap[i] = i;       arr[i] = i;     }     for (int i = 0; i < m; i++) {       char pr, nx;       cin >> pr >> nx;       arr[mmap[pr -  a ]] = nx -  a ;       arr[mmap[nx -  a ]] = pr -  a ;       int temp = mmap[nx -  a ];       mmap[nx -  a ] = mmap[pr -  a ];       mmap[pr -  a ] = temp;       for (int i = 0; i < 26; i++) {         if (false)           cout << (char)( a  + i) <<   ->   << (char)(arr[i] +  a ) << endl;       }     }     string ans =   ;     for (int i = 0; i < s.length(); i++) {       ans += (char)(arr[s[i] -  a ] +  a );     }     cout << ans << endl;   }   int main() { solve(); }
#include <bits/stdc++.h>   using namespace std;   int a[222];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     int ans = m;     for (int i = 0; i < n - 1; i++)       if (a[i] - a[i + 1] > ans) ans = a[i] - a[i + 1];     cout << ans - m << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   char str[2001000], g[2001000];   int a[2001000];   int main() {     scanf( %s , str);     int m;     scanf( %d , &m);     memset((a), (0), sizeof(a));     for (int(i) = (0); (i) < (m); ++(i)) {       int x;       scanf( %d , &x);       x--;       a[x] ^= 1;     }     int n = strlen(str);     int k = 0;     for (int(i) = (0); (i) < (n / 2); ++(i)) {       k ^= a[i];       if (k) {         g[i] = str[n - 1 - i];         g[n - 1 - i] = str[i];       } else {         g[i] = str[i];         g[n - 1 - i] = str[n - 1 - i];       }     }     if (n & 1) g[n >> 1] = str[n >> 1];     g[n] = 0;     printf( %s n , g);   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e5 + 10;   char s[M];   map<char, int> mp;   int main() {     int n;     scanf( %d , &n);     scanf( %s , s);     for (int i = 0; i < n; i++) {       mp[s[i]]++;     }     int minn1 = M;     if (mp[ o ] && mp[ n ] && mp[ e ]) {       minn1 = min(minn1, mp[ o ]);       minn1 = min(minn1, mp[ n ]);       minn1 = min(minn1, mp[ e ]);       mp[ o ] -= minn1;       mp[ e ] -= minn1;     }     int minn2 = M;     if (mp[ z ] && mp[ e ] && mp[ r ] && mp[ o ]) {       minn2 = min(minn2, mp[ z ]);       minn2 = min(minn2, mp[ e ]);       minn2 = min(minn2, mp[ r ]);       minn2 = min(minn2, mp[ o ]);     }     if (minn1 == M) minn1 = 0;     if (minn2 == M) minn2 = 0;     for (int i = 1; i <= minn1; i++) printf( 1  );     for (int i = 1; i <= minn2; i++) printf( 0  );     return 0;   }