malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t;     cin >> s;     cin >> t;     long int n, m, sum;     n = s.size();     m = t.size();     long int count = 0;     if (s.size() == 0 && t.size() == 0) {       cout << 0;     } else if (s.size() == 0 && t.size() != 0) {       cout << t.size();     } else if (t.size() == 0 && s.size() != 0) {       cout << s.size();     } else if (s == t) {       cout << 0;     } else {       while (s[n - 1] == t[m - 1]) {         count++;         n--;         m--;       }       sum = (s.size() - count) + (t.size() - count);       cout << sum;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, ch;     while (!isdigit(ch = getchar()))       ;     while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();     return x;   }   const int MAXN = 500000;   const int mod = 1000000007;   int n;   int a[MAXN + 1];   int v[MAXN + 1];   int T[MAXN + 1];   inline void Add(int& a, int b) {     a += b;     a -= a >= mod ? mod : 0;   }   inline void Modify(int p, int x) {     while (p <= MAXN) Add(T[p], x), p += p & -p;   }   inline int Query(int p) {     int res = 0;     while (p) Add(res, T[p]), p ^= p & -p;     return res;   }   inline int pos(int x) { return lower_bound(v + 1, v + 1 + n, x) - v; }   int main() {     n = read();     int res = 0;     for (int i = 1; i <= n; i++)       a[i] = v[i] = read(), Add(res, 1LL * a[i] * i % mod * (n - i + 1) % mod);     sort(v + 1, v + 1 + n);     for (int i = 1; i <= n; i++) a[i] = pos(a[i]);     for (int i = 1; i <= n; i++) {       Add(res, 1LL * (n - i + 1) * (Query(n) - Query(a[i]) + mod) % mod);       Modify(a[i], 1LL * v[a[i]] * i % mod);     }     memset(T, 0, sizeof(T));     for (int i = n; i >= 1; i--) {       Add(res, 1LL * i * (Query(n) - Query(a[i]) + mod) % mod);       Modify(a[i], 1LL * v[a[i]] * (n - i + 1) % mod);     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int m = 31623;   int nim[] = {       0, 1, 2, 1, 4, 3, 2, 1, 5, 6,  2, 1, 8, 7,  5,       9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12,   };   bool isLarge[m];   int n;   int main(void) {     cin >> n;     memset(isLarge, true, sizeof(isLarge));     for (int i = 2; i < m; i++)       if (isLarge[i]) {         for (int j = i * i; j < m; j *= i) isLarge[j] = false;       }     int ans = 0;     int left = n;     for (int i = 2; i < min(n + 1, m); i++) {       if (isLarge[i]) {         int cnt = 0;         for (long long j = 1; j <= n; j *= i, cnt++)           ;         cnt--;         ans = ans ^ nim[cnt];         left -= cnt;       }     }     if (left % 2 == 1) ans = ans ^ 1;     if (ans)       cout <<  Vasya  << endl;     else       cout <<  Petya  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long f[505][505];   int main() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = 0; i <= n; i++) f[0][i] = 1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         for (int k = 0; k < j; k++) {           (f[j][i] += f[k][i - 1] * f[j - k - 1][i - 1]);         }       }     }     printf( %lld , f[n][n] - f[n][k - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   int n;   int x[300010];   int y[300010];   pair<int, int> izq, der, down, up;   int ereccion(int i, int j, int k) {     vector<int> pito, ura;     pito.push_back(x[i]);     pito.push_back(x[j]);     pito.push_back(x[k]);     ura.push_back(y[i]);     ura.push_back(y[j]);     ura.push_back(y[k]);     sort(pito.begin(), pito.end());     sort(ura.begin(), ura.end());     return pito.back() - pito[0] + ura.back() - ura[0];   }   int triangulo() {     set<int> pingo;     pingo.insert(der.second);     pingo.insert(izq.second);     pingo.insert(up.second);     pingo.insert(down.second);     if (pingo.size() != 4) {       return 2 * (der.first - izq.first) + 2 * (up.first - down.first);     }     vector<int> concha;     for (auto pito : pingo) {       concha.push_back(pito);     }     int ans = -1;     for (int i = 0; i < 4; i++) {       for (int j = i + 1; j < 4; j++) {         int u = concha[i];         int v = concha[j];         for (int k = 0; k < n; k++) {           if (k != u && k != v) {             ans = max(ans, ereccion(u, v, k));           }         }       }     }     return 2 * ans;   }   int main() {     scanf( %d , &n);     izq = make_pair(INF, 0);     down = make_pair(INF, 0);     der = make_pair(-INF, 0);     up = make_pair(-INF, 0);     for (int i = 0; i < n; i++) {       scanf( %d %d , &x[i], &y[i]);       down = min(down, make_pair(y[i], i));       up = max(up, make_pair(y[i], i));       der = max(der, make_pair(x[i], i));       izq = min(izq, make_pair(x[i], i));     }     printf( %d  , triangulo());     int anss = 2 * (der.first - izq.first) + 2 * (up.first - down.first);     for (int i = 4; i <= n; i++) {       printf( %d  , anss);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int solve() {     long long n;     cin >> n;     vector<long long int> a, b;     long long x;     for (long long int i = 0; i < n; i++) {       cin >> x;       if (x > 0)         a.push_back(x);       else         b.push_back(x);     }     long long sum1 = accumulate(a.begin(), a.end(), (long long)0);     long long sum2 = abs(accumulate(b.begin(), b.end(), (long long)0));     if (sum1 > sum2)       cout <<  first ;     else if (sum2 > sum1)       cout <<  second ;     else {       long long s = min((long long int)a.size(), (long long int)b.size());       for (long long int i = 0; i < s; i++) {         if (a[i] > abs(b[i])) {           cout <<  first ;           return 0;         } else if (a[i] < abs(b[i])) {           cout <<  second ;           return 0;         }       }       if (x > 0)         cout <<  first ;       else         cout <<  second ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int sigma_size = 26;   const int N = 100 + 50;   const int MAXN = 100000 + 50;   const int inf = 0x3fffffff;   const double eps = 1e-8;   const int mod = 1000000000 + 7;   int n, k;   int a[N];   double dp[N][N], res[N][N];   int main() {     while (~scanf( %d%d , &n, &k)) {       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       memset(dp, 0, sizeof(dp));       for (int i = 1; i <= n; i++)         for (int j = i + 1; j <= n; j++) dp[i][j] = 1;       while (k--) {         memcpy(res, dp, sizeof(dp));         memset(dp, 0, sizeof(dp));         for (int l = 1; l <= n; l++)           for (int r = l; r <= n; r++) {             for (int i = 1; i <= n; i++)               for (int j = i + 1; j <= n; j++) {                 int x = i, y = j;                 if (l <= x && x <= r) x = l + r - x;                 if (l <= y && y <= r) y = l + r - y;                 if (x > y) swap(x, y);                 if (l <= x && y <= r)                   dp[x][y] += (1 - res[i][j]) * 2.0 / (n + 1) / n;                 else                   dp[x][y] += res[i][j] * 2.0 / (n + 1) / n;               }           }       }       double ans = 0;       for (int i = 1; i <= n; i++)         for (int j = i + 1; j <= n; j++)           if (a[i] > a[j])             ans += dp[i][j];           else             ans += 1.0 - dp[i][j];       printf( %.10f n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[5001], i, j, b[5001], ans;   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);       b[i] = a[i];     }     for (i = 1; i <= n; i++)       if (a[i] == b[i])         for (j = 1; j <= n; j++)           if (a[i] != b[j] && b[i] != a[j]) swap(b[i], b[j]);     for (i = 1; i <= n; i++)       if (a[i] != b[i]) ans++;     printf( %d n , ans);     for (i = 1; i <= n; i++) printf( %d %d n , a[i], b[i]);   }
#include <bits/stdc++.h>   using namespace std;   long long a[200001], b[200001], c[200001], d[200001], s, n, cnt[200001];   int bit(int a, int j) { return (a & (1 << j)) >> j; }   int checkb() {     int mb = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 0; j <= 29; ++j) {         int x = bit(a[i], j), y = bit(b[i], j);         if (x != 0) mb += cnt[j];         if (y != mb % 2) return 0;         mb /= 2;       }     }     return 1;   }   int checkc() {     int mc = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 0; j <= 29; ++j) {         int x = bit(a[i], j), y = bit(c[i], j);         if (x != 1)           mc += cnt[j];         else           mc += n;         if (y != mc % 2) return 0;         mc /= 2;       }     }     return 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     scanf( %I64d , &n);     for (int i = 1; i <= n; ++i) scanf( %I64d , &b[i]);     for (int i = 1; i <= n; ++i) scanf( %I64d , &c[i]);     for (int i = 1; i <= n; ++i) d[i] = b[i] + c[i], s += d[i];     s = s / (2 * n);     for (int i = 1; i <= n; ++i) a[i] = (d[i] - s) / n;     for (int i = 1; i <= n; ++i) {       for (int j = 0; j <= 29; ++j) {         int x = bit(a[i], j);         if (x) cnt[j]++;       }     }     if (checkb() && checkc())       for (int i = 1; i <= n; ++i) printf( %I64d  , a[i]);     else       printf( -1 );     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   long long int t, l, r, m[200005][26];   string second;   int32_t main() {     ios_base::sync_with_stdio();     cin.tie();     cout.tie();     ;     cin >> second;     cin >> t;     for (long long int i = 0; i < second.size(); i++) {       if (i != 0) {         for (long long int j = 0; j <= 26; j++) {           m[i][j] = m[i - 1][j];         }       }       m[i][second[i] -  a ]++;     }     while (t--) {       cin >> l >> r;       if (l == r || second[l - 1] != second[r - 1]) {         cout <<  Yes  <<   n ;       } else {         long long int s1 = 0;         for (long long int i = 0; i < 26; i++) {           if (l == 1) {             if (m[r - 1][i] != 0) {               s1++;             }           } else {             if (m[r - 1][i] - m[l - 2][i] != 0) {               s1++;             }           }         }         if (s1 >= 3) {           cout <<  Yes  <<   n ;         } else           cout <<  No  <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     map<string, int> m;     int groot = 0;     string p =   ;     vector<string> vec;     for (int i = 1; i < s.size(); i++) {       p.push_back(s[i - 1]);       p.push_back(s[i]);       m[p]++;       groot = max(groot, m[p]);       vec.push_back(p);       p =   ;     }     for (int i = 0; i < vec.size(); i++) {       if (m[vec[i]] == groot) {         cout << vec[i] << endl;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n == 2)       cout << -1;     else {       cout << 15 << endl << 10 << endl << 6 << endl;       for (int i = 2; i <= n - 2; ++i) cout << 15 * i << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct A {     int fr, to, th;     long long d;     A() {}     A(int a, int b, long long c, int d) : fr(a), to(b), d(c), th(d) {}   };   const int N = 1003;   vector<A> edge, G[N], ze, all, ori;   int from[N];   long long dis[N];   void SPFA(int x) {     queue<int> q;     q.push(x);     for (int i = 0; i < N; ++i) dis[i] = 1e15;     dis[x] = 0;     bool inq[N] = {};     while (!q.empty()) {       int fr = q.front();       q.pop();       inq[fr] = 0;       for (A e : G[fr]) {         if (dis[e.to] > dis[e.fr] + all[e.th].d) {           dis[e.to] = dis[e.fr] + all[e.th].d;           if (!inq[e.to]) {             inq[e.to] = 1;             q.push(e.to);           }           from[e.to] = e.th;         }       }     }   }   int main() {     int n, m, s, t;     long long L;     scanf( %d%d%lld%d%d , &n, &m, &L, &s, &t);     for (int i = 0, x, y; i < m; ++i) {       long long d;       scanf( %d%d%lld , &x, &y, &d);       if (!d)         ze.push_back(A(x, y, d, i));       else         edge.push_back(A(x, y, d, i));       all.push_back(A(x, y, d, i));       ori.push_back(A(x, y, d, i));     }     for (auto e : edge) {       G[e.fr].push_back(e);       G[e.to].push_back(A(e.to, e.fr, e.d, e.th));     }     SPFA(s);     if (dis[t] < L) {       puts( NO );       return 0;     }     if (dis[t] == L) {       puts( YES );       for (auto e : all) {         printf( %d %d %lld n , e.fr, e.to, e.d ? e.d : (long long)(1e15));       }       return 0;     }     for (int i = 0; i < ze.size(); ++i) {       ze[i].d = 1;       A e = ze[i];       all[e.th].d = 1;       G[e.fr].push_back(e);       G[e.to].push_back(A(e.to, e.fr, e.d, e.th));     }     SPFA(s);     if (dis[t] > L) {       puts( NO );       return 0;     }     while (dis[t] != L) {       vector<int> use;       int p = t;       while (p != s) {         if (!ori[from[p]].d) {           use.push_back(from[p]);         }         A e = ori[from[p]];         p = p == e.fr ? e.to : e.fr;       }       long long di = (L - dis[t]) / use.size(), mo = (L - dis[t]) % use.size();       all[use[0]].d += di + mo;       for (int i = 1; i < use.size(); ++i) all[use[i]].d += di;       SPFA(s);     }     puts( YES );     for (auto e : all) {       printf( %d %d %lld n , e.fr, e.to, e.d);     }   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     long long n;     cin >> n;     vector<long long> a(n);     for (int i = 0; i < n - 1; ++i) {       long long u, v;       cin >> u >> v;       a[u - 1]++;       a[v - 1]++;     }     for (int i = 0; i < n; ++i) {       if (a[i] == 2) return cout <<  NO , 0;     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dp[2020][2020];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, t;     double p;     cin >> n >> p >> t;     dp[0][0] = 1;     for (int i = 1; i <= t; i++) dp[i][0] = dp[i - 1][0] * (1 - p);     for (int i = 1; i <= t; i++) {       for (int j = 1; j <= i; j++)         dp[i][j] = dp[i - 1][j] * (j >= n ? 1 : (1 - p)) + dp[i - 1][j - 1] * p;     }     double ans = 0;     for (int i = 1; i <= (n < t ? n : t); i++) ans += i * (dp[t][i]);     printf( %.10lf , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200010;   struct E {     int to, nxt;   } e[N << 1];   int n, m, head[N], cnt, l[N], r[N], ans[N], ans_cnt, fa[N];   bool b[N];   int Write[20], WRI;   void judge() {     freopen( .in ,  r , stdin);     freopen( .out ,  w , stdout);   }   int read() {     int d = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) d = d * 10 + c - 48, c = getchar();     return d * f;   }   void write(int x) {     if (!x) {       putchar( 0 );       return;     }     if (x < 0) putchar( - ), x = -x;     for (WRI = 1; x; x /= 10, WRI++) Write[WRI] = x % 10;     for (int i = WRI - 1; i; i--) putchar((char)(Write[i] + 48));   }   void add(int x, int y) {     e[++cnt] = (E){y, head[x]};     head[x] = cnt;   }   void addedge(int x, int y) {     add(x, y);     add(y, x);   }   void del(int x) {     b[x] = 1;     r[l[x]] = r[x];     l[r[x]] = l[x];   }   void bfs(int ljj) {     queue<int> q;     int sum = 1;     q.push(ljj);     while (!q.empty()) {       int u = q.front();       q.pop();       for (int i = head[u]; i; i = e[i].nxt) {         int v = e[i].to;         fa[v] = u;       }       for (int i = r[0]; i <= n; i = r[i])         if (fa[i] != u && !b[i]) {           q.push(i);           del(i);           sum++;         }     }     ans[++ans_cnt] = sum;   }   int main() {     n = read();     m = read();     for (int i = 1; i <= m; i++) addedge(read(), read());     for (int i = 0; i <= n; i++) l[i] = i - 1, r[i] = i + 1;     for (int i = 1; i <= n; i = r[i])       if (!b[i]) {         del(i);         bfs(i);       }     sort(ans + 1, ans + 1 + ans_cnt);     write(ans_cnt);     puts(  );     for (int i = 1; i <= ans_cnt; i++) write(ans[i]), putchar(   );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int l, r, n, k, m, now, tot, all;   int a[200000], s[200000];   struct fk {     int num, val;     bool operator==(const fk &b) { return (num + b.num == k && val == b.val); }   } tp[200000];   int main() {     scanf( %d%d%d , &n, &k, &m);     for (int i = 1; i <= n; ++i) scanf( %d , a + i);     all = 0;     tp[0].num = tp[0].val = -1;     for (int i = 1; i <= n; ++i) {       if (a[i] == tp[all].val) {         ++tp[all].num;         if (tp[all].num == k) --all;       } else {         tp[++all].val = a[i];         tp[all].num = 1;       }     }     n = 0;     for (int i = 1; i <= all; ++i) n += tp[i].num;     int p = 0;     for (int i = 1; i <= all; ++i) {       if (tp[i] == tp[all - i + 1])         p = i;       else         break;     }     long long ans = 0, temp;     if (p >= (all + 1) / 2) {       if (m % 2)         for (int i = 1; i <= all; ++i) ans += tp[i].num;     } else if (all % 2 == 1 && p == all / 2) {       temp = m % k * tp[p + 1].num % k;       if (temp % k == 0)         ans = 0;       else {         ans = (long long)p * k;         ans = ans + temp;       }     } else {       ans = (long long)m * n;       for (int i = 1; i <= p; ++i) ans -= (long long)p * k * (m - 1);       ans -= (tp[p + 1].val == tp[all - p].val &&               tp[p + 1].num + tp[all - p].num >= k)                  ? (long long)k * (m - 1)                  : 0;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int ans = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++)       for (int j = i; j <= n; j++) {         int k = i ^ j;         if (k <= n && k >= 1 && k >= j && i + j > k) ans++;       }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     int n, c = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> s;       c = s ==  Tetrahedron  ? c += 4 : c;       c = s ==  Cube  ? c += 6 : c;       c = s ==  Octahedron  ? c += 8 : c;       c = s ==  Dodecahedron  ? c += 12 : c;       c = s ==  Icosahedron  ? c += 20 : c;     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void imprimirVector(vector<int> v) {     if (!v.empty()) {       int p = v.size();       cout <<  [ ;       for (int i = 0; i < (int)(p - 1); i++) cout << v[i] <<  , ;       cout << v[p - 1] <<  ]  << endl;     } else       cout <<  []  << endl;   }   int toNumber(string s) {     int Number;     if (!(istringstream(s) >> Number)) Number = 0;     return Number;   }   string toString(int number) {     ostringstream ostr;     ostr << number;     return ostr.str();   }   int main() {     long long n;     cin >> n;     vector<bool> v(n + 1, false);     vector<long long> a(n);     vector<long long> ans(n);     vector<long long> faltan;     for (int i = 0; i < (int)(n); i++) {       cin >> a[i];       if (a[i] <= n && !v[a[i]]) {         ans[i] = a[i];         v[a[i]] = true;       } else         faltan.push_back(i);     }     for (int i = (1); i < (int)(n + 1); i++) {       if (!v[i]) {         long long r = faltan.back();         faltan.pop_back();         ans[r] = i;       }     }     for (int i = 0; i < (int)(n); i++) {       if (i) cout <<    ;       cout << ans[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( -Ofast ,  -funroll-all-loops ,  -ffast-math )   using namespace std;   using LL = long long;   constexpr LL mod = 1e9 + 7;   long long ex_gcd(long long a, long long b, long long &x, long long &y) {     if (!b) {       x = 1;       y = 0;       return a;     }     long long ret = ex_gcd(b, a % b, y, x);     y -= a / b * x;     return ret;   }   LL mul(LL u, LL v, LL p) {     return (u * v - LL((long double)u * v / p) * p + p) % p;   }   LL bin(LL x, LL n, LL MOD) {     LL ret = MOD != 1;     for (x %= MOD; n; n >>= 1, x = x * x % MOD)       if (n & 1) ret = ret * x % MOD;     return ret;   }   LL norm(LL x) { return x >= mod ? (x - mod) : x; }   inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }   inline long long get_inv(long long a) {     long long x, y;     ex_gcd(a, mod, x, y);     return norm(x + mod);   }   template <class T>   inline void umin(T &x, T y) {     x = x > y ? y : x;   }   template <class T>   inline void umax(T &x, T y) {     x = x < y ? y : x;   }   template <class T>   inline void dec(T &x, T y) {     x -= y;     if (x < 0) x += mod;   }   template <class T>   inline void add(T &x, T y) {     x += y;     if (x >= mod) x -= mod;   }   template <typename T>   void read(T &x) {     cin >> x;   }   template <typename T, typename... Args>   void read(T &first, Args &...args) {     read(first);     read(args...);   }   template <class T>   LL ctz(T a) {     return sizeof(T) > 2 ? __builtin_ctzll(a) : __builtin_ctz(a);   }   template <class T>   inline T gcd(T _a, T _b) {     T a = abs(_a), b = abs(_b);     LL shift = ctz(a | b);     for (b >>= ctz(b), a >>= ctz(a); a; a -= b, a >>= ctz(a))       if (a < b) swap(a, b);     return b << shift;   }   const double PI = acos(-1.0);   constexpr LL INF = 0x3f3f3f3f;   constexpr long long linf = 0x3f3f3f3f3f3f3f3f;   constexpr unsigned long long base = 2333, P_1 = 19260817, P_2 = 999998639;   constexpr LL maxn = 1e6 + 10;   LL n, ans, a[maxn], s[maxn];   vector<LL> v[maxn];   int32_t main() {     std::ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr),         cout << fixed << setprecision(10);     cin >> n;     for (LL i = (1), _i = (n + 1); i < _i; ++i)       cin >> a[i], v[a[i]].emplace_back(i);     LL mx = 0, mx_num = 0;     for (LL i = 1; i <= n; i++) {       if (int32_t(v[i].size()) > mx)         mx_num = i, mx = int32_t(v[i].size());       else if (int32_t(v[i].size()) == mx)         mx_num = -1;     }     if (mx_num == -1) {       cout << n <<   12 ;     } else {       s[0] = 0;       for (LL i = 1; i <= n; i++) {         s[i] = s[i - 1] + (a[i] == mx_num);       }       for (LL i = 1; i <= n; i++) {         if (int32_t(v[i].size()) and i != mx_num) {           vector<LL> tp(400010), p(400010);           tp[0] = 200000;           for (LL j = 1; j <= n; j++) {             tp[j] = tp[j - 1] + (a[j] == mx_num) - (a[j] == i);           }           for (LL j = n; j >= 0; j--) {             if (!p[tp[j]])               p[tp[j]] = j;             else               umax(ans, p[tp[j]] - j);           }         }       }       cout << ans <<   12 ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   string toBin(long long a) {     string res =   ;     while (a) {       res += char((a & 1) +  0 );       a >>= 1;     }     reverse(res.begin(), res.end());     return res;   }   const int mod = 1e9 + 7;   long long expo(long long base, long long pow) {     long long ans = 1;     while (pow != 0) {       if (pow & 1 == 1) {         ans = ans * base;         ans = ans % mod;       }       base *= base;       base %= mod;       pow /= 2;     }     return ans;   }   long long inv(long long x) { return expo(x, mod - 2); }   double pi = 3.141592653589793238462643;   double error = 0.0000001;   const int M = 100001;   int main() {     int k, a, b, v;     cin >> k >> a >> b >> v;     int tot = 0;     int box = 0;     while (true) {       int sect = min(b + 1, k);       b -= (sect - 1);       tot += sect * v;       box++;       if (tot >= a) break;     }     cout << box;   }