malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     cin >> n >> m;     long long k[n];     pair<long long, long long> dt[m];     for (int i = 0; i < n; i++) cin >> k[i];     for (int i = 0; i < m; i++) cin >> dt[i].first >> dt[i].second;     long long total = 0;     for (int i = 0; i < n; i++) total += k[i];     long long start = 1;     long long end = 2 * total;     long long ans = 2 * total;     while (start <= end) {       long long check = start + (end - start) / 2;       pair<long long, long long> last[n];       for (int i = 0; i < n; i++) {         last[i].first = LONG_MAX;         last[i].second = i;       }       for (int i = 0; i < m; i++) {         if (dt[i].first <= check) {           if (last[dt[i].second - 1].first == LONG_MAX)             last[dt[i].second - 1].first = dt[i].first;           else             last[dt[i].second - 1].first =                 max(dt[i].first, last[dt[i].second - 1].first);         }       }       sort(last, last + n);       int point = 0;       long long money = 0;       long long count = 0;       for (int i = 1; i <= check; i++) {         money++;         while (last[point].first == i) {           long long deduce = min(money, k[last[point].second]);           count += deduce;           money -= deduce;           point++;         }       }       money -= 2 * (total - count);       if (money < 0) {         start = check + 1;       } else {         ans = check;         end = check - 1;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char c[1005], s[55], t[55];   int ns[55], nt[55];   int tos[55][30], tot[55][30];   int lenc, lens, lent;   int dp[1005][55][55];   void init() {     lenc = strlen(c + 1), lens = strlen(s + 1), lent = strlen(t + 1);     ns[1] = 0, nt[1] = 0;     for (int i = 2, j = 0; i <= lens; i++) {       while (j && s[j + 1] != s[i]) j = ns[j];       if (s[j + 1] == s[i]) j++;       ns[i] = j;     }     for (int i = 2, j = 0; i <= lent; i++) {       while (j && t[j + 1] != t[i]) j = nt[j];       if (t[j + 1] == t[i]) j++;       nt[i] = j;     }     for (int i = 0; i <= lens; i++) {       for (int k = 0; k < 26; k++) {         int j = i;         while (j && s[j + 1] != k +  a ) j = ns[j];         if (s[j + 1] == k +  a ) j++;         tos[i][k] = j;       }     }     for (int i = 0; i <= lent; i++) {       for (int k = 0; k < 26; k++) {         int j = i;         while (j && t[j + 1] != k +  a ) j = nt[j];         if (t[j + 1] == k +  a ) j++;         tot[i][k] = j;       }     }   }   int main() {     scanf( %s%s%s , c + 1, s + 1, t + 1);     init();     int n = strlen(c + 1);     for (int i = 0; i <= n; i++)       for (int j = 0; j <= 50; j++)         for (int k = 0; k <= 50; k++) dp[i][j][k] = -1000000;     dp[0][0][0] = 0;     for (int i = 1; i <= n; i++) {       if (c[i] ==  * ) {         for (int j = 0; j <= lens; j++) {           for (int k = 0; k <= lent; k++) {             if (dp[i - 1][j][k] <= -1000000) continue;             for (int q = 0; q < 26; q++) {               int temp1 = tos[j][q], temp2 = tot[k][q];               dp[i][temp1][temp2] =                   max(dp[i][temp1][temp2],                       dp[i - 1][j][k] + (temp1 == lens) - (temp2 == lent));             }           }         }       } else {         for (int j = 0; j <= lens; j++) {           for (int k = 0; k <= lent; k++) {             if (dp[i - 1][j][k] <= -1000000) continue;             int q = c[i] -  a ;             int temp1 = tos[j][q], temp2 = tot[k][q];             dp[i][temp1][temp2] =                 max(dp[i][temp1][temp2],                     dp[i - 1][j][k] + (temp1 == lens) - (temp2 == lent));           }         }       }     }     int res = -1000000;     for (int i = 0; i <= lens; i++)       for (int j = 0; j <= lent; j++) res = max(res, dp[n][i][j]);     cout << res << endl;   }
#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 = 1000;   const int MAXK = 1000;   int n, K;   char s[MAXN + 1];   int act[MAXN + 1][2 * MAXK + 1];   char ret[MAXN + 1];   void run() {     scanf( %d%d%s , &n, &K, s);     memset(act, -1, sizeof(act));     act[0][MAXK] = 1;     for (int i = (0); i < (n); ++i) {       int mxb = min(i, K - 1);       for (int k = (-mxb); k <= (+mxb); ++k)         if (act[i][MAXK + k] != -1) {           for (int a = (-1); a <= (+1); ++a) {             if (s[i] ==  L  && a != -1) continue;             if (s[i] ==  D  && a != 0) continue;             if (s[i] ==  W  && a != +1) continue;             act[i + 1][MAXK + k + a] = a + 1;           }         }     }     for (int k = -K; k <= +K; k += 2 * K)       if (act[n][MAXK + k] != -1) {         for (int i = n - 1; i >= 0; --i) {           ret[i] =  LDW [act[i + 1][MAXK + k]];           k -= act[i + 1][MAXK + k] - 1;         }         ret[n] =   0 ;         printf( %s , ret);         return;       }     printf( NO n );   }   int main() {     run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string nameOne, nameTwo, tmpOne, tmpTwo;     cin >> nameOne >> nameTwo;     int n;     cin >> n;     cout << nameOne <<     << nameTwo << endl;     for (int i = 0; i < n; i++) {       cin >> tmpOne;       cin >> tmpTwo;       if (tmpOne == nameOne)         nameOne = tmpTwo;       else         nameTwo = tmpTwo;       cout << nameOne <<     << nameTwo << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve(long long int arr[], long long int n, long long int l) {     for (int i = 1; i < n; i++) {       arr[i] = min(arr[i], 2 * arr[i - 1]);     }     long long int exp[n];     for (int i = 0; i < n; i++) {       exp[i] = 1LL << i;     }     long long int ans = LLONG_MAX;     long long int val = 0;     for (int i = n - 1; i >= 0; i--) {       long long int currentAns = val + (l + exp[i] - 1) / exp[i] * arr[i];       ans = min(ans, currentAns);       long long int x = l / exp[i];       l -= x * exp[i];       val += x * arr[i];     }     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t = 1;     while (t--) {       long long int n, l;       cin >> n >> l;       long long int arr[n];       for (int i = 0; i < n; i++) {         cin >> arr[i];       }       solve(arr, n, l);     }   }
#include <bits/stdc++.h>   using namespace std;   bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {     return (a.second < b.second);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m, i, j, c;     string s, f =  YES ;     vector<string> v;     cin >> n >> m;     for (i = 0; i < n; i++) {       cin >> s;       v.push_back(s);     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (v[i][j] ==  * ) continue;         c = 0;         if (i - 1 >= 0 && v[i - 1][j] ==  * ) c++;         if (i - 1 >= 0 && j - 1 >= 0 && v[i - 1][j - 1] ==  * ) c++;         if (i - 1 >= 0 && j + 1 < m && v[i - 1][j + 1] ==  * ) c++;         if (j - 1 >= 0 && v[i][j - 1] ==  * ) c++;         if (j + 1 < m && v[i][j + 1] ==  * ) c++;         if (i + 1 < n && v[i + 1][j] ==  * ) c++;         if (i + 1 < n && j - 1 >= 0 && v[i + 1][j - 1] ==  * ) c++;         if (i + 1 < n && j + 1 < m && v[i + 1][j + 1] ==  * ) c++;         if (c > 0 && c != v[i][j] -  0 ) f =  NO ;         if (!c && v[i][j] !=  . ) f =  NO ;       }     }     cout << f;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fastPrime(long long n) {     if (n == 2) return true;     if (n % 2 == 0) return false;     for (long long i = 3; i * i <= n; i++) {       if (n % i == 0) return false;     }     return true;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, val;     cin >> n;     for (long long i = 0; i < n; i++) {       cin >> val;       long long sr = sqrt(val);       if (val != 1 && fastPrime(sr) && sr * sr == val)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e5 + 5;   template <typename T>   void chkmax(T& x, T y) {     if (y > x) x = y;   }   template <typename T>   void chkmin(T& x, T y) {     if (y < x) x = y;   }   int N, Q, a[1 << 18];   long long sum;   int main() {     scanf( %d%d , &N, &Q);     for (int i = 0; i < (1 << N); ++i) scanf( %d , &a[i]), sum += a[i];     printf( %.7f n , sum / (double)(1 << N));     while (Q--) {       int p, x;       scanf( %d%d , &p, &x), sum -= a[p], a[p] = x, sum += a[p];       printf( %.7f n , sum / (double)(1 << N));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int maxm = 1e5 + 80;   const int maxn = 5e3 + 80;   const int up = 20;   template <class T>   void read(T &x) {     x = 0;     char c = getchar();     int f = 1;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) f = -1;     for (;  0  <= c && c <=  9 ; c = getchar()) x = x * 10 + (c ^ 48);     x *= f;   }   unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();   mt19937 rand_num(seed);   uniform_int_distribution<int> dist(0, 10000000);   mt19937 rnd(time(NULL));   int e[maxm][2], cnt[maxm];   int f[maxm], flag, nxt;   int get_rand(int from, int to) {     int x = dist(rand_num) % (to - from + 1);     return x + from;   }   bool solve(int n, int m) {     shuffle(f + 1, f + 1 + n, rnd);     for (int i = 2; i <= m; i++) {       int u = f[i - 1], v = f[i], ti = 0;       bool wa = (e[u][0] == v | e[u][1] == v);       if (wa && i == n) return false;       while (wa && ti < up) {         int t = get_rand(i + 1, n);         ti++;         swap(f[i], f[t]);         v = f[i];         wa = (e[u][0] == v | e[u][1] == v);       }       if (ti == up) return false;     }     nxt = 0;     if (m == 2 || m == 1) nxt = 1;     if (e[f[m]][0] == f[1] || e[f[m]][1] == f[1]) nxt = 1;     if (nxt == 1 && n == m) return false;     if (nxt == 1) {       int u = f[m], v = f[m + 1], ti = 0;       bool wa = (e[u][0] == v | e[u][1] == v);       while (wa && ti < up) {         int t = get_rand(m + 1, n);         ti++;         swap(f[m + 1], f[t]);         v = f[m + 1];         wa = (e[u][0] == v | e[u][1] == v);       }       if (ti == up) return false;     }     flag = 1;     return true;   }   void MC() {     int n, m;     read(n);     read(m);     for (int i = 1; i <= m; i++) {       int u, v;       read(u);       read(v);       e[u][cnt[u]++] = v;       e[v][cnt[v]++] = u;     }     if (n == 2 && m == 2 || m > n) {       printf( -1 n );       return;     }     flag = 0;     for (int i = 1; i <= n; i++) f[i] = i;     for (int i = 1; i <= up + up; i++)       if (solve(n, m)) break;     if (!flag) {       printf( -1 n );       return;     }     for (int i = 2; i <= m; i++) printf( %d %d n , f[i - 1], f[i]);     if (!nxt)       printf( %d %d n , f[m], f[1]);     else       printf( %d %d n , f[m], f[m + 1]);   }   int main() {     MC();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int nmax = 1e7 + 5;   int cnt[2][nmax];   int valu[100005];   vector<int> g[100005];   int liflevel;   int koyta[2];   void dfs(int u, int level = 0) {     cnt[level % 2][valu[u]]++;     koyta[level % 2]++;     for (int v : g[u]) dfs(v, level + 1);     if (g[u].empty()) liflevel = level % 2;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> valu[i];     for (int i = 2; i <= n; i++) {       int p;       cin >> p;       g[p].push_back(i);     }     dfs(1);     int jor = 0;     long long ans = 0;     for (int i = 0; i < nmax; i++)       if (cnt[liflevel][i] % 2) jor ^= i;     if (jor) {       for (int i = 0; i < nmax; i++) {         int tmp = jor ^ i;         if (tmp < nmax) ans += 1LL * cnt[liflevel][i] * cnt[liflevel ^ 1][tmp];       }     } else {       ans += 1LL * koyta[0] * (koyta[0] - 1) / 2 +              1LL * koyta[1] * (koyta[1] - 1) / 2;       for (int i = 0; i < nmax; i++) ans += 1LL * cnt[0][i] * cnt[1][i];     }     cout << ans;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   const int MX = 1 << 23;   int a, b, c, d, i, j, n, m, k;   int lenl[MX + 1], lenr[MX + 1], cnt[MX + 1], len[MX + 1], num[MX + 1];   pair<int, int> sm[MX + 1];   map<int, int> onwork;   inline int create(int l, int r) {     sm[k] = make_pair(-1, -1);     cnt[k] = 0;     len[k] = lenl[k] = lenr[k] = r - l;     num[k] = l;     return k++;   }   inline int getcnt(int l, int r, int a, int b, int v) {     if (l >= r || a > b) return 0;     if (l == a && b == r - 1) return cnt[v];     int xx = (r + l) / 2;     if (b < xx) {       if (sm[v].first == -1) sm[v].first = create(l, xx);       return getcnt(l, xx, a, b, sm[v].first);     }     if (a >= xx) {       if (sm[v].second == -1) sm[v].second = create(xx, r);       return getcnt(xx, r, a, b, sm[v].second);     }     if (sm[v].first == -1) sm[v].first = create(l, xx);     if (sm[v].second == -1) sm[v].second = create(xx, r);     return getcnt(l, xx, a, xx - 1, sm[v].first) +            getcnt(xx, r, xx, b, sm[v].second);   }   void add(int l, int r, int first, int cc, int v) {     if (l >= r || first >= r || first < l) return;     if (l == r - 1) {       cnt[v] = cc;       num[v] = l;       lenl[v] = lenr[v] = len[v] = cc ^ 1;       return;     }     int xx = (r + l) / 2;     if (sm[v].first == -1) sm[v].first = create(l, xx);     if (sm[v].second == -1) sm[v].second = create(xx, r);     if (first < xx) {       add(l, xx, first, cc, sm[v].first);     } else {       add(xx, r, first, cc, sm[v].second);     }     lenl[v] = lenr[v] = len[v] = 0;     cnt[v] = 0;     {       lenl[v] = lenl[sm[v].first];       len[v] = len[sm[v].first];       num[v] = num[sm[v].first];       cnt[v] = cnt[sm[v].first];     }     {       if (lenl[v] == xx - l) lenl[v] += lenl[sm[v].second];       lenr[v] = lenr[sm[v].second];       if (lenr[v] == r - xx) lenr[v] += lenr[sm[v].first];       if (lenr[sm[v].first] + lenl[sm[v].second] >= len[v]) {         len[v] = lenr[sm[v].first] + lenl[sm[v].second];         num[v] = xx - lenr[sm[v].first];       }       if (len[sm[v].second] >= len[v]) {         len[v] = len[sm[v].second];         num[v] = num[sm[v].second];       }       cnt[v] += cnt[sm[v].second];     }   }   int main() {     scanf( %d%d , &n, &m);     sm[0] = make_pair(-1, -1);     lenl[0] = lenr[0] = len[0] = n;     num[0] = 1;     k = 1;     for (int _n((m)-1), i(0); i <= _n; i++) {       scanf( %d , &a);       if (!a) {         scanf( %d%d , &a, &b);         printf( %d n , getcnt(1, n + 1, a, b, 0));       } else {         if (onwork.count(a)) {           add(1, n + 1, onwork[a], 0, 0);           onwork.erase(onwork.find(a));         } else {           int l = num[0], r = num[0] + len[0];           add(1, n + 1, (r + l) / 2, 1, 0);           onwork[a] = (r + l) / 2;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   long long Bpow(long long a, long long s) {     if (s == 0) {       return 1;     }     long long u = Bpow(a, s / 2);     if (s & 1)       return u * u % mod * a % mod;     else       return u * u % mod;   }   int32_t main() {     long long n;     cin >> n;     vector<long long> a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     long long ans = 0;     for (long long i = 0; i < n - 2; i++) {       long long now = a[i + 1];       for (long long j = i + 2; j < n; j++) {         if (now > a[i] * 2) break;         if ((a[i] ^ a[j]) == now && a[i] > a[j]) ++ans;         now += a[j];       }     }     for (long long i = n - 1; i > 1; i--) {       long long now = a[i - 1];       for (long long j = i - 2; j >= 0; j--) {         if (now > a[i] * 2) break;         if ((a[i] ^ a[j]) == now && a[i] > a[j]) ++ans;         now += a[j];       }     }     cout << ans;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   const double pi = acos(-1.0);   const int inf = (int)1e9;   const double eps = 1e-4;   const int ss = (int)1e6 + 3;   const int base = inf;   bool pred(const pair<int, int>& i, const pair<int, int>& j) {     if (i.first == j.first) {       return i.second > j.second;     } else {       return i.first > j.first;     }   }   int a[2000005];   int main() {     int k;     scanf( %d , &k);     long long int res = 0;     for (int i = 0; i < k; ++i) {       scanf( %d , &a[i]);       res += a[i];     }     if (k == 1) {       cout << res;       return 0;     }     sort(a, a + k);     int z = k / 4;     while (z != 0) {       for (int i = k - 1; i >= k - z; --i) {         res += a[i];       }       z /= 4;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned int INF = 2000000001;   const long long INF0 = 2000000001000000001;   const bool DEBUG_OUTPUT = false;   const int modulo = 1000000007;   const int go[8][2] = {{0, 1}, {0, -1},  {1, 0},  {-1, 0},                         {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};   int main() {     long long n, k;     int p;     cin >> n >> k >> p;     long long a = (n >> 1) + (n & 1);     long long b = 0;     if (k >= a) {       b = k - a;     } else       a = k;     if ((n - 2 * a + 1) >= 0 && ((n - 2 * a + 1) & 1) == 0 && k > 0) {       b = a - 1;       a = k - b;     }     for (int i = 0; i < p; i++) {       long long q;       cin >> q;       q = n - q;       if (q & 1) {         cout << ((q >> 1) < b ?  X  :  . );       } else         cout << ((q >> 1) < a ?  X  :  . );     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 11;   int n;   int a[MAXN][MAXN];   void read() {     cin >> n;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) cin >> a[i][j];     }   }   const int INF = 1e9 + 7;   const int MAXANS = MAXN * MAXN * 2;   int dp[MAXANS][MAXN * MAXN][MAXN][MAXN][3];   bool ch(int i, int j) { return 0 <= i && i < n && 0 <= j && j < n; }   inline bool check(int i, int j, int ni, int nj, int k) {     if (k == 0) {       return (abs(i - ni) == 1 && abs(j - nj) == 2) ||              (abs(i - ni) == 2 && abs(j - nj) == 1);     } else if (k == 1) {       return abs(i - ni) == abs(j - nj);     } else {       return (i == ni || j == nj);     }   }   pair<int, int> ans = {INF, INF};   pair<int, int> pos[MAXN * MAXN];   vector<pair<int, int> > go[MAXN][MAXN][3];   void solve() {     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         pos[a[i][j]] = {i, j};       }     }     for (int i = 0; i < MAXANS; ++i) {       for (int j = 0; j < MAXN * MAXN; ++j) {         for (int x = 0; x < MAXN; ++x) {           for (int y = 0; y < MAXN; ++y) {             for (int k = 0; k < 3; ++k) {               dp[i][j][x][y][k] = INF;             }           }         }       }     }     for (int i = 0; i < 3; ++i) {       dp[0][1][pos[1].first][pos[1].second][i] = 0;     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         for (int ni = 0; ni < n; ++ni) {           for (int nj = 0; nj < n; ++nj) {             for (int k = 0; k < 3; ++k) {               if (check(i, j, ni, nj, k)) {                 go[i][j][k].push_back({ni, nj});               }             }           }         }       }     }     for (int op = 0; op < MAXANS - 1; ++op) {       for (int num = 1; num <= n * n; ++num) {         for (int i = 0; i < n; ++i) {           for (int j = 0; j < n; ++j) {             for (int k = 0; k < 3; ++k) {               if (num == n * n && dp[op][num][i][j][k] != INF) {                 ans = min(ans, {op, dp[op][num][i][j][k]});               }               for (auto t : go[i][j][k]) {                 int ni = t.first, nj = t.second;                 if (check(i, j, ni, nj, k)) {                   bool ch =                       (pos[num + 1].first == ni && pos[num + 1].second == nj);                   dp[op + 1][num + ch][ni][nj][k] =                       min(dp[op + 1][num + ch][ni][nj][k], dp[op][num][i][j][k]);                 }               }               for (int nk = 0; nk < 3; ++nk) {                 if (nk != k) {                   dp[op + 1][num][i][j][nk] =                       min(dp[op + 1][num][i][j][nk], dp[op][num][i][j][k] + 1);                 }               }             }           }         }       }     }   }   void print() { cout << ans.first <<     << ans.second <<   n ; }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     read();     solve();     print();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int Read() {     int x = 0, f = 1, c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     return x * f;   }   const int MAXN = 1000005;   const int mod = 1e9 + 7;   int n, m, k, ans, minp, maxp, a[MAXN], bin[MAXN];   int main() {     n = Read(), m = Read(), k = Read(), minp = n + 1, bin[0] = 1;     for (int i = 1, x, y; i <= m; i++) {       x = Read(), y = Read();       if (y == x + k + 1)         a[x]++, minp = min(minp, x), maxp = max(maxp, x);       else if (y ^ x + 1)         return puts( 0 ), 0;     }     if (maxp - minp > k) return puts( 0 ), 0;     n -= k + 1;     for (int i = 1; i <= n; i++)       a[i] += a[i - 1], bin[i] = (bin[i - 1] << 1) % mod;     if (!maxp) {       ans = 1;       for (int i = 1; i <= n; i++) ans = (ans + bin[min(i + k, n) - i]) % mod;     } else       for (int i = max(maxp - k, 1); i <= minp; i++)         ans = (ans + bin[min(i + k, n) - i - (a[min(i + k, n)] - a[i])]) % mod;     return printf( %d n , ans), 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     {       long long i, j, n, a, b, c, d, mx, mn;       cin >> n >> a >> b >> c >> d;       mx = max(a + b, a + c);       mx = max(mx, b + d);       mx = max(mx, c + d);       mn = min(a + b, a + c);       mn = min(mn, b + d);       mn = min(mn, c + d);       if (mx + 1 <= mn + n) {         i = min(a + b + n, mn + n);         j = max(mx + 1, a + b + 1);         cout << n * (i - j + 1);       } else         cout <<  0 ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, ans, x, y, sum, res, day1, day2, moun1, moun2, year1, year2;   bool l;   char a[100];   string s, s1, s2;   vector<int> v;   int main() {     cin >> n;     if (!(n & 1)) {       cout << -1;       return 0;     }     for (int i = 0; i < n; i++) printf( %d  , i);     cout << endl;     for (int i = 0; i < n; i++) printf( %d  , i);     cout << endl;     for (int i = 0; i < n; i++) printf( %d  , (i + i) % n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, long long> m;   void solve() {     long long n;     cin >> n;     map<long long, long long>::iterator itr;     long long x, maxm = INT_MIN;     for (long long i = 0; i < n; i++) {       cin >> x;       m[x - (i + 1)] += x;     }     for (auto &it : m) {       maxm = max(maxm, it.second);     }     cout << maxm;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isVowel(char c) {     if (c ==  a  or c ==  e  or c ==  i  or c ==  o  or c ==  u  or c ==  y )       return true;     return false;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     long long n;     cin >> n;     string s;     cin >> s;     string ans =   ;     for (long long i = 0; i < n; i++) {       ans += s[i];       if (!isVowel(s[i])) continue;       long long j = i;       while (j < n && isVowel(s[j])) j++;       i = j - 1;     }     cout << ans << endl;   }