malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void Read(T &x) {     int f = 1;     char t = getchar();     while (t <  0  || t >  9 ) {       if (t ==  - ) f = -1;       t = getchar();     }     x = 0;     while (t >=  0  && t <=  9 ) {       x = x * 10 + t -  0 ;       t = getchar();     }     x *= f;   }   template <class T>   inline void chkmin(T &x, T y) {     if (x > y) x = y;   }   template <class T>   inline void chkmax(T &x, T y) {     if (x < y) x = y;   }   const int maxn = 200005;   const double inf = 2e18;   const double pi = acos(-1.0);   struct point {     long double x, y;     point() {}     point(long double x, long double y) : x(x), y(y) {}     void read() { cin >> x >> y; }   };   point operator+(const point &a, const point &b) {     return point(a.x + b.x, a.y + b.y);   }   point operator-(const point &a, const point &b) {     return point(a.x - b.x, a.y - b.y);   }   point operator*(const point &a, long double v) {     return point(a.x * v, a.y * v);   }   point operator/(const point &a, long double v) {     return point(a.x / v, a.y / v);   }   long double operator^(const point &a, const point &b) {     return a.x * b.y - a.y * b.x;   }   int n;   point P, g[maxn];   long double dis(point &a, point &b) {     return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);   }   long double maxr = -inf, minr = inf;   void calc(point &a, point &b) {     long double A = dis(a, P), B = dis(b, P), C = dis(a, b);     long double area = (a - P) ^ (b - P);     long double Height = area * area / C;     if (A < B) swap(A, B);     if (A > B + C) return;     chkmax(maxr, Height);     chkmin(minr, Height);   }   void input() {     Read(n);     P.read();     for (register int i = 1; i <= n; i++) g[i].read();     g[0] = g[n];     for (register int i = 1; i <= n; i++) calc(g[i], g[i - 1]);   }   void solve() {     for (register int i = 1; i <= n; i++) {       chkmax(maxr, dis(g[i], P));       chkmin(minr, dis(g[i], P));     }     printf( %.18lf n , (double)(maxr - minr) * pi);   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   #pragma GCC optimize( unroll-loops )   using namespace std;   long long power(long long a, long long b, long long md) {     return (!b ? 1                : (b & 1 ? a * power(a * a % md, b / 2, md) % md                         : power(a * a % md, b / 2, md) % md));   }   const int xn = 1e3 + 10;   const int xm = 2e4 + 10;   const int sq = 300;   const int inf = 1e9 + 10;   const long long INF = 1e18 + 10;   const int mod = 1e6 + 7;   const int base = 257;   const int SIG = 26;   int n, k, tb[1 << 20], dp[xn][xm], ptr, a[xm], C[xm][SIG], ans = inf;   string S;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> S >> k, n = int(S.size());     if (k == 1) {       ans = 0;       for (int i = 0; i < n; ++i) ans += (S[i] ==  1 );       return cout << ans <<   n , 0;     }     for (int mask = 0; mask < (1 << k); ++mask) {       bool flag = true;       for (int i = 0; i < k; ++i)         flag &= (!((mask & (1 << i))) | !(mask & (1 << (i + 1))));       flag &= !(mask & 1), flag &= !(mask & 2);       if (flag) tb[mask] = ptr, a[ptr++] = mask;     }     for (int t = 0; t < ptr; ++t) {       int mask = a[t] + 1;       for (int i = 2; i < 10; ++i) {         for (int bit = i; bit <= k; ++bit)           if ((mask & (1 << (bit - i)))) C[t][i] += (1 << bit);         bool flag = !(C[t][i] & (1 << k));         for (int j = 1; j < k; ++j)           if (k % j == 0) flag |= (C[t][i] & (1 << j));         for (int b1 = 2; b1 < k; ++b1)           for (int b2 = b1 + 1; b2 <= k; ++b2)             if ((C[t][i] & (1 << b1)) && (C[t][i] & (1 << b2)))               flag |= (k % (b2 - b1) == 0);         C[t][i] = (C[t][i] & (C[t][i] ^ (1 << k)));         if (!flag) C[t][i] = -1;       }     }     for (int i = 0; i < xn; ++i)       for (int j = 0; j < ptr; ++j) dp[i][j] = inf;     dp[0][0] = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < ptr; ++j) {         int mask = a[j];         if (S[i] ==  1 )           dp[i + 1][0] = min(dp[i + 1][0], dp[i][j]);         else {           dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);           int x = C[j][S[i] -  0 ];           if (x != -1) dp[i + 1][tb[x]] = min(dp[i + 1][tb[x]], dp[i][j]);         }       }     }     for (int i = 0; i < ptr; ++i) ans = min(ans, dp[n][i]);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 109;   int a[MAX], n, k, t = 1e9, s;   int main() {     cin >> n;     for (int i = 0; i < 2 * n - 1; i++) {       cin >> a[i], s += abs(a[i]), t = min(t, abs(a[i]));       if (a[i] < 0) k++;     }     if (k % 2 && n % 2 == 0) s -= 2 * t;     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   int nor[200100 * 2], n, t, m, a[200100], b[200100], sola, solb, sol, pcta, pctb;   int main() {     cin >> n;     nor[++t] = 0;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       nor[++t] = a[i];     }     cin >> m;     for (int i = 1; i <= m; ++i) {       cin >> b[i];       nor[++t] = b[i];     }     sort(nor + 1, nor + t + 1);     sort(a + 1, a + n + 1);     sort(b + 1, b + m + 1);     nor[++t] = max(a[n], b[n]) + 1;     sol = -(1 << 30);     for (int i = 1; i <= t; ++i) {       int mij;       int st = 1, dr = n;       while (st <= dr) {         mij = (st + dr) >> 1;         if (a[mij] <= nor[i])           st = mij + 1;         else           dr = mij - 1;       }       pcta = (st - 1) * 2 + (n - (st - 1)) * 3;       st = 1, dr = m;       while (st <= dr) {         mij = (st + dr) >> 1;         if (b[mij] <= nor[i])           st = mij + 1;         else           dr = mij - 1;       }       pctb = (st - 1) * 2 + (m - (st - 1)) * 3;       if (pcta - pctb > sol) {         sol = pcta - pctb;         sola = pcta;         solb = pctb;       } else if (pcta - pctb == sol && pcta > sola) {         sola = pcta;         solb = pctb;       }     }     cout << sola <<  :  << solb;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   std::vector<int> Edge[510];   std::vector<int> Current[510];   int Right[510];   int Left[510];   int Vis[510];   int N, M;   bool dfs(int idx) {     if (Vis[idx]) return false;     Vis[idx] = 1;     for (int i = 0; i < Current[idx].size(); i++) {       int v = Current[idx][i];       if (Left[v] == -1 || dfs(Left[v])) {         Left[v] = idx;         Right[idx] = v;         return true;       }     }     return false;   }   int bpm() {     int Ans = 0;     memset(Left, -1, sizeof(Left));     memset(Right, -1, sizeof(Right));     for (int i = 0; i < N; i++) {       memset(Vis, false, sizeof(Vis));       Ans += dfs(i);     }     return Ans;   }   int main() {     cin >> N >> M;     int u, v;     for (int i = 0; i < M; i++) {       cin >> u >> v;       u -= 1, v -= 1;       Edge[u].push_back(v);     }     int Ans = 1e9;     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) Current[j].clear();       int cnt = 0, other = 0;       for (int j = 0; j < N; j++) {         for (int k = 0; k < Edge[j].size(); k++) {           if (j == i || Edge[j][k] == i) {             cnt += 1;             continue;           }           other += 1;           Current[j].push_back(Edge[j][k]);         }       }       int max_match = bpm();       Ans = min(Ans, 2 * N - 1 + other - cnt - 2 * max_match + N - 1);     }     cout << Ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     int n, t1, t2;     double k;     cin >> n >> t1 >> t2 >> k;     k /= 100;     k = 1 - k;     double c[n + 1];     for (int i = 1; i <= n; i++) {       int a, b;       cin >> a >> b;       int tema = a;       int temb = b;       a = max(a, temb);       b = min(tema, b);       if (t1 * k >= t2) {         c[i] = t1 * a * k + t2 * b;       } else {         c[i] = t1 * b * k + t2 * a;       }     }     int g[n + 1];     for (int i = 1; i <= n; i++) {       g[i] = i;     }     for (int i = 1; i <= n; i++) {       for (int j = i; j <= n; j++) {         if (c[j] > c[i] || (c[j] == c[i] && g[j] < g[i])) {           double temb = c[i];           c[i] = c[j];           c[j] = temb;           int temb2 = g[i];           g[i] = g[j];           g[j] = temb2;         }       }     }     for (int i = 1; i <= n; i++) {       cout << g[i] <<     << fixed << setprecision(2) << c[i] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100 * 1000 + 10;   vector<int> u[N], v[N], v2[N];   vector<pair<int, int> > q[N];   int t, st[N], fi[N], di[N], g[N], par[N];   int root(int u) { return (par[u] == u) ? u : par[u] = root(par[u]); }   void merge1(int x, int y) {     int dx = root(x), dy = root(y);     if (dx == dy) return;     par[dy] = dx;   }   bool mark[N], ans[N];   void dfs(int u) {     mark[u] = true;     st[u] = t++;     for (int i = 0; i < v[u].size(); i++) {       if (!mark[v[u][i]]) dfs(v[u][i]);     }     fi[u] = t++;   }   int main() {     int n, m, p = 1, j = 1;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b, c;       cin >> a;       u[i].push_back(a);       if (a == 1) {         cin >> b >> c;         u[i].push_back(b);         u[i].push_back(c);         v[c].push_back(b);         di[b]++;       }       if (a == 2) {         cin >> b;         u[i].push_back(b);         u[i].push_back(p);         p++;       }       if (a == 3) {         cin >> b >> c;         u[i].push_back(b);         u[i].push_back(c);         q[c].push_back({b, j++});       }     }     for (int i = 1; i <= n; i++) par[i] = i;     for (int i = 1; i <= n; i++) {       if (di[i] == 0) dfs(i);     }     for (int i = 1; i <= n; i++) {     }     for (int i = 0; i < m; i++) {       int a = u[i][0], b = u[i][1], c = u[i][2];       if (u[i][0] == 1) merge1(b, c);       if (u[i][0] == 2) {         for (int i = 0; i < q[c].size(); i++) {           int qu = q[c][i].first, kj = q[c][i].second;           if (st[qu] <= st[b] && fi[qu] >= fi[b] && root(qu) == root(b))             ans[kj] = true;           else             ans[kj] = false;         }       }     }     for (int i = 1; i < j; i++) {       if (ans[i])         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     int b;     cin >> a >> b;     cout.precision(13);     if (b > a) {       cout << -1;     } else if ((a % b == 0) && ((a / b) % 2 == 1)) {       cout << b;     } else {       int k = a / b;       if (k % 2 == 0) {         k--;       }       int dist = a - k * b;       double x1 = b;       double x2 = (double)dist / (double)k + (double)b;       double x = x1;       double ang;       double x_old;       for (int i = 0; i < 50; i++) {         ang = (x - b) / (k * x - a);         x_old = x;         if (ang > -1) {           x = (x + x2) / 2.0;           x1 = x_old;         } else if (ang < -1) {           x = (x + x1) / 2.0;           x2 = x_old;         } else {           cout << x;           return 0;         }       }       cout << x;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const long long maxn = 3e6;   const long long mod = 1e9 + 7;   const long double PI = acos((long double)-1);   long long pw(long long a, long long b, long long md = mod) {     long long res = 1;     while (b) {       if (b & 1) {         res = (a * res) % md;       }       a = (a * a) % md;       b >>= 1;     }     return (res);   }   string s[4];   bool hor(int x, int y) {     if (x < 1 or x > 2) return (0);     int cnt = 0;     if (s[x][y] ==  o ) return (0);     if (s[x][y] ==  . ) cnt++;     if (s[x - 1][y] ==  o ) return (0);     if (s[x - 1][y] ==  . ) cnt++;     if (s[x + 1][y] ==  o ) return (0);     if (s[x + 1][y] ==  . ) cnt++;     return (cnt < 2);   }   bool ver(int x, int y) {     if (y < 1 or y > 2) return (0);     int cnt = 0;     if (s[x][y] ==  o ) return (0);     if (s[x][y] ==  . ) cnt++;     if (s[x][y - 1] ==  o ) return (0);     if (s[x][y - 1] ==  . ) cnt++;     if (s[x][y + 1] ==  o ) return (0);     if (s[x][y + 1] ==  . ) cnt++;     return (cnt < 2);   }   bool dia(int x, int y) {     int cnt = 0;     if (x < 1 or x > 2) return (0);     if (y < 1 or y > 2) return (0);     if (s[x][y] ==  o ) return (0);     if (s[x][y] ==  . ) cnt++;     if (s[x - 1][y - 1] ==  o ) return (0);     if (s[x - 1][y - 1] ==  . ) cnt++;     if (s[x + 1][y + 1] ==  o ) return (0);     if (s[x + 1][y + 1] ==  . ) cnt++;     return (cnt < 2);   }   bool diag(int x, int y) {     int cnt = 0;     if (x < 1 or x > 2) return (0);     if (y < 1 or y > 2) return (0);     if (s[x][y] ==  o ) return (0);     if (s[x][y] ==  . ) cnt++;     if (s[x - 1][y + 1] ==  o ) return (0);     if (s[x - 1][y + 1] ==  . ) cnt++;     if (s[x + 1][y - 1] ==  o ) return (0);     if (s[x + 1][y - 1] ==  . ) cnt++;     return (cnt < 2);   }   bool chk(int x, int y) {     if (ver(x, y)) return (1);     if (hor(x, y)) return (1);     if (dia(x, y)) return (1);     if (diag(x, y)) return (1);     return (0);   }   int32_t main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     for (int i = 0; i < 4; i++) cin >> s[i];     for (int i = 0; i < 4; i++)       for (int j = 0; j < 4; j++)         if (chk(i, j)) cout <<  YES , exit(0);     cout <<  NO ;     return (0);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, sy, sx;     cin >> n >> m >> sy >> sx;     int up = sy;     int down = sy + 1;     int l = sx;     int r = sx + 1;     int k = 2;     while (up >= 1) {       while (l >= 1) {         cout << up <<     << l << endl;         l--;       }       while (r <= m) {         cout << up <<     << r << endl;         r++;       }       up--;       if (k % 2 == 0)         l = m;       else         r = 1;       k++;     }     while (down <= n) {       while (l >= 1) {         cout << down <<     << l << endl;         l--;       }       while (r <= m) {         cout << down <<     << r << endl;         r++;       }       down++;       if (k % 2 == 0)         l = m;       else         r = 1;       k++;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<pair<int, int> > a_sent;   vector<pair<int, int> > b_sent;   set<pair<int, int> > a_possible;   set<pair<int, int> > b_possible;   int vis[10];   bool certain(pair<int, int> a, vector<pair<int, int> > sent) {     bool can_x = false;     bool can_y = false;     for (pair<int, int> b : sent) {       if (0) {         printf( has: [%d, %d], try: [%d, %d] n , a.first, a.second, b.first,                b.second);       }       if (a.first == b.first && a.second == b.second) continue;       if (a.first == b.second && a.second == b.first) continue;       if (a.first != b.first && a.second != b.second && a.first != b.second &&           a.second != b.first)         continue;       if (a.first == b.first || a.first == b.second) can_x = true;       if (a.second == b.first || a.second == b.second) can_y = true;     }     if (0) printf( can_x: %d, can_y: %d n , can_x, can_y);     return (can_x && !can_y) || (can_y && !can_x);   }   int main() {     cin >> n >> m;     while (n--) {       pair<int, int> pair;       cin >> pair.first >> pair.second;       if (pair.first < pair.second) swap(pair.first, pair.second);       a_sent.push_back(pair);     }     while (m--) {       pair<int, int> pair;       cin >> pair.first >> pair.second;       if (pair.first < pair.second) swap(pair.first, pair.second);       b_sent.push_back(pair);     }     for (pair<int, int> a : a_sent) {       for (pair<int, int> b : b_sent) {         if (a.first == b.first && a.second == b.second) continue;         if (a.first == b.second && a.second == b.first) continue;         if (a.first != b.first && a.second != b.second && a.first != b.second &&             a.second != b.first)           continue;         if (a.first == b.first) vis[a.first]++;         if (a.second == b.second) vis[a.second]++;         if (a.first == b.second) vis[a.first]++;         if (a.second == b.first) vis[a.second]++;         a_possible.insert(a);         b_possible.insert(b);       }     }     int cnt = 0;     for (int i = 1; i <= 9; ++i) {       cnt += vis[i] >= 1;       if (0) printf( vis[%d] = %d n , i, vis[i]);     }     if (0) cout << cnt << endl;     if (cnt == 1) {       for (int i = 1; i <= 9; ++i) {         if (vis[i] >= 1) {           cout << i << endl;           return 0;         }       }     }     for (pair<int, int> a : a_possible) {       if (!certain(a, b_sent)) {         cout << -1 << endl;         return 0;       }     }     for (pair<int, int> b : b_possible) {       if (!certain(b, a_sent)) {         cout << -1 << endl;         return 0;       }     }     cout << 0 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, x, y, z, e, s, max1, max2, max3, max4;     cin >> a >> b >> c;     x = a + b * c;     y = a * (b + c);     z = a * b * c;     e = (a + b) * c;     s = a + b + c;     max1 = (x + y + abs(x - y)) / 2;     max2 = (max1 + z + abs(max1 - z)) / 2;     max3 = (max2 + e + abs(max2 - e)) / 2;     max4 = (max3 + s + abs(max3 - s)) / 2;     cout << max4 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 10;   const int SZ = 2e5 + 10;   const int mod = 1e9 + 7;   long long read() {     long long n = 0;     char a = getchar();     bool flag = 0;     while (a >  9  || a <  0 ) {       if (a ==  - ) flag = 1;       a = getchar();     }     while (a <=  9  && a >=  0 ) {       n = n * 10 + a -  0 , a = getchar();     }     if (flag) n = -n;     return n;   }   int a[SZ], b[SZ], p[SZ], pri[SZ], vis[SZ];   int main() {     int n = read(), x = read();     for (int i = 1, j = 0; i < (1 << n); i++) {       if (i == x)         continue;       else {         if (x < (1 << n)) {           int ii = x ^ i;           if (ii < i) a[++a[0]] = i;         } else           a[++a[0]] = i;       }     }     for (int i = a[0]; i >= 2; i--) a[i] ^= a[i - 1];     printf( %d n , a[0]);     for (int i = 1; i <= a[0]; i++) printf( %d  , a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100;   long long f[N + 5][N + 5][N + 5];   long long fac[N + 5], C[N + 5][N + 5];   long long mod;   long long dfs(int n, int m, int k) {     if (n == 0) return k == 0;     if (m == 1) return k == 1 ? fac[n] : 0;     if (n == 1) return k == 0;     if (2 * k > n + 1) return 0;     if (m > n) return k == 0 ? fac[n] : 0;     if (f[n][m][k] != -1) return f[n][m][k];     long long ans = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j <= k; j++)         ans = (ans + C[n - 1][i] * dfs(i, m - 1, j) % mod *                          dfs(n - i - 1, m - 1, k - j) % mod) %               mod;     return f[n][m][k] = ans;   }   int main() {     memset(f, 0xff, sizeof(f));     int n, m, k;     scanf( %d%d%d%lld , &n, &m, &k, &mod);     for (int i = 0; i <= N; i++) C[i][0] = C[i][i] = 1;     for (int i = 1; i <= N; i++)       for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;     fac[0] = fac[1] = 1;     for (int i = 1; i <= N; i++) fac[i] = fac[i - 1] * i % mod;     printf( %lld , dfs(n, m, k));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 5;   int P[N], I[N];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &P[i]);     }     int id = 1;     for (int i = 1; i <= n; i++) {       int cur = i;       while (I[cur] != id) {         I[cur] = id;         cur = P[cur];       }       id++;       printf( %d  , cur);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18;   const long long maxu = 200005;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long i, j, k = 0, n, t = 1, m, l = 0;     cin >> t;     while (t--) {       cin >> n;       long long a[n];       long long b[n + 2];       long long cnt = 0;       long long idx = -1;       for (i = 0; i < n; i++) {         cin >> a[i];         if (a[i] != i + 1) {           if (idx == -1) {             idx = i;           }           b[i] = 0;           cnt++;         } else           b[i] = 1;       }       if (cnt == 0) {         cout << 0 <<   n ;         continue;       }       if (cnt == n) {         cout << 1 <<   n ;         continue;       }       long long ans = 0;       for (i = idx; i <= idx + cnt - 1; i++) {         if (b[i] == 0) ans++;       }       if (ans == cnt) {         cout << 1 <<   n ;       } else         cout << 2 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, k, op, val1, val2;     while (cin >> x >> k) {       int mini = 0, maxi = 0;       maxi = x - 1;       vector<int> T(4005);       for (int i = 0; i < k; ++i) {         cin >> op;         if (op == 2) {           cin >> val1;           T[val1] = 1;         } else {           cin >> val1 >> val2;           T[val1] = T[val2] = 1;         }         if (op == 2)           maxi--;         else           maxi -= 2;       }       T[x] = 1;       for (int i = 1; i <= x; ++i)         if (T[i] == 0) {           int ind;           for (int j = i; j <= x; ++j)             if (T[j] == 0)               ind = j;             else               break;           mini += ((ind - i + 1) - 1) / 2 + 1;           i = ind;         }       cout << mini <<     << maxi << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   void file() {}   using lli = long long int;   using pii = pair<int, int>;   using vi = vector<int>;   using vvi = vector<vi>;   void solve() {     string s;     cin >> s;     string res =   ;     int z = 0, ones = 0, two = s.size();     for (int i = 0; i < s.size(); i++) {       int x = s[i] -  0 ;       if (x == 1) ones++;       if (x == 2 && two == s.size()) two = i;       if (x == 0 && two == s.size()) z++;     }     res += string(z,  0 );     res += string(ones,  1 );     for (int i = two; i < s.size(); i++) {       int x = s[i] -  0 ;       if (x == 1) continue;       res += s[i];     }     cout << res << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, i, ans, m, j, k;     string s;     cin >> n >> s;     ans = 0;     char ch;     for (i = 25; i >= 0; i--) {       ch = i +  a ;       for (j = 1; j < (long long)s.size(); j++) {         if (s[j] == ch and s[j - 1] + 1 == ch) {           s.erase(s.begin() + j);           ans++;           j--;         }       }       for (j = 0; j < (long long)s.size() - 1; j++) {         if (s[j] == ch and s[j + 1] + 1 == ch) {           s.erase(s.begin() + j);           ans++;           j -= 2;         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long ara[20], ara1[20];     for (long long i = 1; i <= 14; i++) {       scanf( %I64d , &ara[i]);     }     long long maxi = 0;     long long sum, c;     for (long long i = 1; i <= 14; i++) {       if (ara[i] == 0) {         continue;       }       long long d = ara[i] / 14;       long long e = ara[i] % 14;       memset(ara1, 0, sizeof(ara1));       sum = 0, c = 0;       if (d > 0) {         for (long long j = i + 1;; j++) {           if (j > 14) {             j = j % 14;             if (j == 0) {               j = 14;             }           }           if (i == j) {             ara1[j] = d;             break;           }           ara1[j] = ara[j] + d;         }       }       for (long long j = i + 1;; j++) {         if (j > 14) {           j = j % 14;           if (j == 0) {             j = 14;           }         }         if (d == 0) {           ara1[j] = ara[j] + 1;         } else {           ara1[j] = ara1[j] + 1;         }         c++;         if (c >= e) {           break;         }       }       for (int j = 1; j <= 14; j++) {         if (ara1[j] % 2 == 0) {           sum = sum + ara1[j];         }       }       if (sum > maxi) {         maxi = sum;       }     }     printf( %I64d n , maxi);   }