malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, i, j;     string s;     cin >> s;     n = s.size();     string cur;     if (s.size() <= 6) {       cout << 0;       return 0;     }     for (i = 5; i < s.size(); i++) {       cur += s[i];     }     if (cur.size() == 2) {       cout << 1 << endl << cur;       return 0;     }     reverse(cur.begin(), cur.end());     string inf =  --- ;     vector<string> dp2(10500), dp3(10500);     vector<string> ans;     dp2[0] = inf;     dp2[1] += cur[0];     dp2[1] += cur[1];     dp3[0] = inf;     dp3[1] = inf;     dp3[2] += cur[0];     dp3[2] += cur[1];     dp3[2] += cur[2];     dp2[2] = inf;     ans.push_back(dp2[1]);     ans.push_back(dp3[2]);     for (i = 3; i < cur.size(); i++) {       bool two = true;       if (dp2[i - 2] == inf && dp3[i - 2] == inf) {         dp2[i] = inf;         two = false;       }       {         if (dp2[i - 2] != inf) {           string ss;           ss += cur[i - 1];           ss += cur[i];           if (ss != dp2[i - 2]) {             dp2[i] = ss;             ans.push_back(ss);           } else             two = false;         }         {           if (dp3[i - 2] != inf) {             two = true;             string ss;             ss += cur[i - 1];             ss += cur[i];             dp2[i] = ss;             ans.push_back(ss);           }         }       }       if (!two) dp2[i] = inf;       bool three = true;       if (dp3[i - 3] == inf && dp2[i - 3] == inf) {         dp3[i] = inf;         three = false;       }       {         if (dp3[i - 3] != inf) {           string ss;           ss += cur[i - 2];           ss += cur[i - 1];           ss += cur[i];           if (ss != dp3[i - 3]) {             dp3[i] = ss;             ans.push_back(ss);           } else             three = false;         }         {           if (dp2[i - 3] != inf) {             string ss;             ss += cur[i - 2];             ss += cur[i - 1];             ss += cur[i];             ans.push_back(ss);             dp3[i] = ss;             three = true;           }         }       }       if (!three) dp3[i] = inf;     }     for (i = 0; i < ans.size(); i++) {       reverse(ans[i].begin(), ans[i].end());     }     sort(ans.begin(), ans.end());     set<string> h;     set<string>::iterator ii;     for (i = 0; i < ans.size(); i++) h.insert(ans[i]);     cout << h.size() << endl;     for (ii = h.begin(); ii != h.end(); ii++) cout << *ii << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, k1 = 0, k2 = 0;     cin >> a;     string h;     cin >> h;     string *s = new string[a];     for (int i = 0; i < a; i++) {       cin >> s[i];       if (s[i].substr(s[i].size() - 3, 3) == h)         k1++;       else         k2++;     }     if (k1 == k2)       cout <<  home ;     else       cout <<  contest ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long p, d, i, j, tmp, res;     cin >> p >> d;     res = p;     for (i = 999999999999999999ll; i; i /= 10) {       j = i + 1;       if (i > p) continue;       if (i == p) break;       if (p % j == i) {         tmp = (p / j) * j + i;         if (p - tmp <= d) {           res = tmp;           break;         }       } else {         tmp = (p / j - 1) * j + i;         if (p - tmp <= d) {           res = tmp;           break;         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mason[] = {2,       3,       5,        7,       13,      17,                        19,      31,      61,       89,      107,     127,                        521,     607,     1279,     2203,    2281,    3217,                        4253,    4423,    9689,     9941,    11213,   19937,                        21701,   23209,   44497,    86243,   110503,  132049,                        216091,  756839,  859433,   1257787, 1398269, 2976221,                        3021377, 6972593, 13466917, 20996011},             Mod = 1000000007;   int main() {     int n;     scanf( %d , &n);     int idx = mason[n - 1] - 1;     long long ret = 1LL, val = 2LL;     while (idx) {       if (idx & 1) ret = ret * val % Mod;       val = val * val % Mod;       idx >>= 1;     }     printf( %lld n , ret - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6;   int n;   int l[maxn], c[maxn];   int gcd(int x, int y) {     if (x == 0)       return y;     else       return gcd(y % x, x);   }   map<int, int> mp;   int main() {     while (scanf( %d , &n) != EOF) {       for (int i = 1; i <= n; i++) scanf( %d , &l[i]);       for (int i = 1; i <= n; i++) scanf( %d , &c[i]);       mp.clear();       mp[0] = 0;       for (int i = 1; i <= n; i++) {         for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {           int v = gcd(it->first, l[i]);           int cc = it->second + c[i];           if (mp.count(v) > 0) {             mp[v] = min(mp[v], cc);           } else             mp[v] = cc;         }       }       if (mp.count(1) > 0)         printf( %d n , mp[1]);       else         printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, mx[400000], mn[400000];   long long seg[400000 * 4];   vector<long long> compress(vector<long long> x) {     vector<long long> ans = x;     vector<pair<long long, long long>> p;     p.push_back({0, 0});     for (long long i = 1; i < x.size(); i++) {       p.push_back({x[i], i});     }     sort(p.begin(), p.end());     ans[p[1].second] = 1;     for (long long i = 2; i < p.size(); i++) {       if (p[i].first > p[i - 1].first)         ans[p[i].second] = ans[p[i - 1].second] + 1;       else         ans[p[i].second] = ans[p[i - 1].second];     }     return ans;   }   void update(long long pos, long long val, long long l1, long long r1,               long long node) {     if (l1 == r1) {       seg[node] = val;       return;     }     long long mid = (l1 + r1) / 2;     if (pos <= mid) {       update(pos, val, l1, mid, 2 * node);     } else       update(pos, val, mid + 1, r1, 2 * node + 1);     seg[node] = max(seg[2 * node], seg[2 * node + 1]);   }   long long queri(long long l, long long r, long long l1, long long r1,                   long long node) {     if (l1 > r or r1 < l) return 0;     if (l <= l1 and r1 <= r) return seg[node];     long long mid = (l1 + r1) / 2;     return max(queri(l, r, l1, mid, 2 * node),                queri(l, r, mid + 1, r1, 2 * node + 1));   }   void solv() {     cin >> n;     vector<long long> a(n + 1);     set<long long> s;     for (long long i = 1; i < n + 1; i++) {       cin >> a[i];       s.insert(a[i]);       mx[i] = 0;       mn[i] = 400000;     }     a = compress(a);     for (long long i = 1; i < n + 1; i++) {       mx[a[i]] = i;       mn[a[i]] = min(mn[a[i]], i);     }     long long l = 1;     long long len = 0;     for (long long i = 1; i < s.size() + 1; i++) {       update(i, mx[i], 1, n, 1);     }     for (long long i = 1; i < s.size() + 1; i++) {       while (queri(l, i - 1, 1, n, 1) > mn[i] and l < i) l++;       len = max(len, i - l + 1);     }     long long c = s.size();     cout << c - len <<   n ;   }   signed main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     long long q;     cin >> q;     while (q--) solv();   }
#include <bits/stdc++.h>   int n;   long long ans = 0x7fffffffffffffff, sum, p[1000002];   int a[1000002], b[1000002], c[1000002], pcnt;   inline int abs(int x) { return x > 0 ? x : -x; }   signed main() {     scanf( %d , &n);     for (register int i = 1; i <= n; i++) scanf( %d , &a[i]), sum += a[i];     register long long temp = sum;     for (register int i = 2; (long long)i * i <= temp;)       if (sum % i == 0)         sum /= i, p[++pcnt] = i;       else         i++;     if (sum > 1) p[++pcnt] = sum;     for (register long long _k = 1, k = p[_k]; _k <= pcnt; _k++, k = p[_k]) {       if (p[_k] == p[_k - 1]) continue;       long long res = 0;       for (register int i = 1; i <= n; i++) b[i] = a[i] % k;       for (register long long i = 1, last = 1, t = 0; i <= n;) {         t += b[i];         c[i] = b[i], b[i] = 0;         if (t >= k) {           c[i] -= t - k, b[i] = t - k;           t = k;           register int mid;           register long long s = 0;           for (mid = last; mid <= i; mid++) {             s += c[mid];             if (s >= (k + 1) / 2) break;           }           for (register int j = last; j <= i; j++)             res += (long long)c[j] * abs(j - mid);           t = 0, last = i;         } else           i++;       }       if (res < ans) ans = res;     }     printf( %I64d , ans == 0x7fffffffffffffff ? -1 : ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     long long res = 0;     cin >> n;     vector<bool> v(6000, false);     for (int i = 0; i < n; ++i) {       cin >> k;       if (!v[k - 1])         v[k - 1] = true;       else         while (v[k - 1]) {           ++res;           ++k;           v[k - 2] = true;         }       v[k - 1] = true;     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1000000007;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long int n, h;     cin >> n >> h;     long long int arr[n];     for (long long int i = 0; i < n; i++) cin >> arr[i];     long long int ans = 0;     for (long long int i = 0; i < n; i++) {       vector<long long int> op;       for (long long int j = 0; j <= i; j++) op.push_back(arr[j]);       sort(op.begin(), op.end());       if (op.size() == 1) {         if (op[0] <= h) ans = i + 1;         continue;       }       long long int sum = 0;       for (long long int j = op.size() - 1; j >= 0; j -= 2) sum += op[j];       if (sum <= h)         ans = i + 1;       else         break;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, p, q, a, c = 1, b;     cin >> n;     cin >> a >> b;     p = a;     q = b;     int num = n;     n--;     int max = 1;     while (n--) {       cin >> a >> b;       if (p == a && q == b) {         c++;       } else if (c > 1) {         if (max < c) max = c;         c = 1;       }       p = a;       q = b;     }     if (c > max) max = c;     cout << max;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 2e5;   int infty = 1e9;   int p[M], t[M];   int main() {     int n, d, h;     cin >> n >> d >> h;     if (2 * h < d || (n > 2 && d == 1)) {       cout << -1 <<   n ;     } else {       int h1 = h, h2 = d - h, cur = 2;       for (int i = 0; i < h; i++) {         cout << cur - 1 <<     << cur <<   n ;         cur++;       }       if (d == h) {         for (int i = cur; i <= n; i++) {           cout << 2 <<     << i <<   n ;         }       } else {         if (h2 > 0) {           cout <<  1   << cur <<   n ;           cur++;         }         for (int i = 1; i < h2; i++) {           cout << cur - 1 <<     << cur <<   n ;           cur++;         }         for (int i = cur; i <= n; i++) {           cout << 1 <<     << i <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   int a[(100000 + 10)], cur[(100000 + 10)];   double dp[(100000 + 10)][110];   int C[110][110];   void init() {     C[0][0] = 1;     int n = 110;     for (int i = 1; i < n; ++i) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; ++j) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];     }   }   double f(int a, int b) {     double ret = 1;     for (int i = 1; i <= b; ++i) ret *= (a - i + 1.0) / i;     return ret;   }   double cal(int cur, int i, int j, int k) {     if (cur - i - j < 0 || k - j < 0 || k > cur) return 0;     if (k - j > cur - i - j) return 0;     return 1.0 * f(cur - i - j, k - j) * f(i + j, j) / f(cur, k);   }   int read() {     char c;     while ((c = getchar()) && !( 0  <= c && c <=  9 ))       ;     int ret = c -  0 ;     while ((c = getchar()) &&  0  <= c && c <=  9 ) ret = ret * 10 + c -  0 ;     return ret;   }   int main() {     int n;     init();     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       cur[i] = a[i];       dp[i][a[i]] = 1;     }     double ans = 0;     for (int i = 1; i <= n; ++i) ans += dp[i][0];     int q;     scanf( %d , &q);     while (q--) {       int u, v, k;       u = read();       v = read();       k = read();       ans -= dp[u][0];       for (int i = 0; i <= a[u]; ++i) {         dp[u][i] = dp[u][i] * cal(cur[u], i, 0, k);         for (int j = 1; i + j <= a[u] && j <= k; ++j) {           dp[u][i] += dp[u][i + j] * cal(cur[u], i, j, k);         }       }       ans += dp[u][0];       cur[u] -= k;       cur[v] += k;       printf( %.10lf n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 10, P = 1e9 + 7, U = 1e6 - 1;   long long f1[N], f2[N], f3[N], n, A[N], t[N], val[N], bit[N], ans;   int main() {     cin >> n;     for (long long i = bit[0] = 1; i <= 6; i++) bit[i] = 10 * bit[i - 1];     for (long long i = t[0] = 1; i <= n; i++) t[i] = 2ll * t[i - 1] % P;     for (long long i = 1, x; i <= n; i++)       scanf( %lld , &x), f1[x]++, (f2[x] += x) %= P,           (f3[x] += 1ll * x * x % P) %= P;     for (long long j = 0; j < 6; j++)       for (long long i = U; i >= 0; i--)         if (i / bit[j] % 10 < 9) {           f1[i] += f1[i + bit[j]];           (f2[i] += f2[i + bit[j]]) %= P;           (f3[i] += f3[i + bit[j]]) %= P;         }     for (long long i = 0; i <= U; i++) {       long long res = (f2[i] * f2[i] % P - f3[i] + P) % P * (P / 2 + 1) % P;       if (f1[i]) val[i] = (t[f1[i] - 1] * (f3[i] + res) % P + P) % P;     }     for (long long j = 0; j < 6; j++)       for (long long i = 0; i <= U; i++)         if (i / bit[j] % 10 < 9) (val[i] += P - val[i + bit[j]]) %= P;     for (long long i = 0; i <= U; i++) ans ^= val[i] * i;     cout << ans << endl;   }
#include <bits/stdc++.h>   int main() {     long long t;     scanf( %lld , &t);     long int n, x = 1;     for (int i = 0; i < t; i++) {       scanf( %ld , &n);       int k = 1, p = 1, x;       for (; p <= n;) {         k++;         p = p + pow(2, k - 1);         if (n % p == 0) {           x = n / p;           break;         }       }       printf( %ld n , x);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC omptimize( unroll-loops )   #pragma optimize( SEX_ON_THE_BEACH )   #pragma GCC optimize( no-stack-protector )   #pragma comment(linker,  /STACK:1000000000 )   using namespace std;   using ll = long long int;   using ull = unsigned long long int;   using dd = long double;   using ldd = long double;   using si = short int;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   ll get_seed(string s) {     ll ans = 0;     for (int i = 0; i < s.size(); ++i) ans += s[i];     return ans;   }   int popcount(int x) { return __builtin_popcount(x); }   ll popcountll(ll x) { return __builtin_popcount(x); }   int way[10][10];   void build(int x, int y) {     for (int i = 0; i < 10; ++i)       for (int j = 0; j < 10; ++j) way[i][j] = 1e5;     for (int i = 0; i < 10; ++i) way[i][(i + x) % 10] = way[i][(i + y) % 10] = 1;     for (int k = 0; k < 10; ++k)       for (int i = 0; i < 10; ++i)         for (int j = 0; j < 10; ++j)           way[i][j] = min(way[i][j], way[i][k] + way[k][j]);     for (int i = 0; i < 10; ++i)       for (int j = 0; j < 10; ++j)         if (way[i][j] >= (int)(1e5)) way[i][j] = -1;   }   int get_ans(int x, int y, string& s) {     build(x, y);     ll ans = 0;     int curr = 0;     for (int i = 1; i < s.size(); ++i) {       if (way[curr][s[i] -  0 ] == -1) return -1;       ans += way[curr][s[i] -  0 ] - 1;       curr = s[i] -  0 ;     }     return ans;   }   void solve(int ii) {     string s;     cin >> s;     for (int x = 0; x < 10; ++x) {       for (int y = 0; y < 10; ++y) cout << get_ans(x, y, s) <<    ;       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     int t;     t = 1;     for (int i = 0; i < t; ++i) solve(i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       std::vector<pair<long long int, long long int> > ev;       std::vector<pair<long long int, long long int> > od;       for (int i = 1; i <= 2 * n; i++) {         int x;         cin >> x;         if (x % 2 == 0)           ev.push_back({x, i});         else           od.push_back({x, i});       }       if (ev.size() % 2 == 0) {         if (ev.size() == 0) {           od.pop_back();           od.pop_back();         } else {           ev.pop_back();           ev.pop_back();         }       } else {         ev.pop_back();         od.pop_back();       }       for (int i = 0; i < ev.size(); i += 2)         cout << ev[i].second <<     << ev[i + 1].second <<   n ;       for (int i = 0; i < od.size(); i += 2)         cout << od[i].second <<     << od[i + 1].second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void FAST();   long long int big_mod(long long int val, long long int pow, long long int mod);   long long int mod_inverse(long long int val, long long int mod);   int main() {     FAST();     int m, n;     scanf( %d %d , &n, &m);     if (m < 2) {       printf( 1 );     } else {       if (n & 1 == 0) {         if (m >= n / 2) {           printf( %d , n - m);         } else {           printf( %d , m);         }       } else {         if (m > n / 2) {           printf( %d , n - m);         } else {           printf( %d , m);         }       }     }     return 0;   }   void FAST() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   long long int big_mod(long long int val, long long int pow, long long int mod) {     long long int res = 1;     val = val % mod;     while (pow > 0) {       if (pow & 1) {         res = (res * val) % mod;       }       pow = pow >> 1;       val = (val * val) % mod;     }     return res;   }   long long int mod_inverse(long long int val, long long int mod) {     long long int mod1 = mod;     if (mod == 1) {       return 0;     }     long long int y = 0;     long long int x = 1;     long long int quotient, temp;     while (val > 1) {       quotient = val / mod;       temp = mod;       mod = val % mod;       val = temp;       temp = y;       y = x - quotient * y;       x = temp;     }     if (x < 0) {       x += mod1;     }     return x;   }
#include <bits/stdc++.h>   using namespace std;   int n, d;   long long h[100001];   struct A {     long long h;     int i;     bool operator<(const A &B) const { return h < B.h || h == B.h && i < B.i; }   } H[100001];   map<long long, int> MP;   map<long long, int> MPSORT;   int N, Kn;   int st[100001 << 2];   int sti[100001 << 2];   void init() {     N = 1;     while (N < Kn + 2) N <<= 1;     memset(st, 0, sizeof(st));     memset(sti, 0, sizeof(sti));     st[N] = st[2 * N - 1] = -1;   }   int query(int L, int R, int &I) {     int MAX = 0;     I = 0;     for (int s = N + L - 1, t = N + R + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {       if (~s & 1)         if (MAX < st[s ^ 1]) MAX = st[s ^ 1], I = sti[s ^ 1];       if (t & 1)         if (MAX < st[t ^ 1]) MAX = st[t ^ 1], I = sti[t ^ 1];     }     return MAX;   }   void update(int X, int C, int Oldi) {     int s = X + N;     st[s] = C;     sti[s] = Oldi;     s >>= 1;     while (s > 0) {       if (st[s << 1] > st[s << 1 | 1])         st[s] = st[s << 1], sti[s] = sti[s << 1];       else         st[s] = st[s << 1 | 1], sti[s] = sti[s << 1 | 1];       s >>= 1;     }   }   int BS1(long long X) {     if (X < H[1].h) return 0;     int L, R, M;     L = 1, R = Kn + 1;   begin:     if (L + 1 == R) goto end;     M = (L + R) >> 1;     if (H[M].h <= X)       L = M;     else       R = M;     goto begin;   end:     return L;   }   int BS2(long long X) {     if (X > H[Kn].h) return 0;     int L, R, M;     L = 0, R = Kn;   begin:     if (L + 1 == R) goto end;     M = (L + R) >> 1;     if (H[M].h < X)       L = M;     else       R = M;     goto begin;   end:     return R;   }   int dp[100001];   int pre[100001];   int main(void) {     while (~scanf( %d%d , &n, &d)) {       MP.clear();       for (int i = 1; i <= n; ++i)         scanf( %I64d , &h[i]), H[i].h = h[i], H[i].i = i;       sort(H + 1, H + n + 1);       Kn = 0;       for (int i = 1; i <= n; ++i)         if (!MP.count(H[i].h))           MP[H[i].h] = ++Kn, H[Kn].h = H[i].h, H[Kn].i = H[i].i;       init();       for (int i = 1; i <= n; ++i) dp[i] = 1, pre[i] = i;       for (int i = 1; i <= n; ++i) {         int ANS, ANS1, ANS2, D;         int D1 = BS1(h[i] - d), D2 = BS2(h[i] + d);         if (D1)           ANS1 = query(1, D1, D1);         else           ANS1 = 0;         if (D2)           ANS2 = query(D2, Kn, D2);         else           ANS2 = 0;         if (ANS1 > ANS2)           ANS = ANS1, D = D1;         else           ANS = ANS2, D = D2;         if (ANS > 0) {           dp[i] = ANS + 1;           pre[i] = D;         }         update(MP[h[i]], dp[i], i);       }       int ANS = 0, ANSN;       for (int i = 1; i <= n; ++i)         if (dp[i] > ANS) ANS = dp[i], ANSN = i;       printf( %d n , ANS);       vector<int> V;       while (pre[ANSN] != ANSN) {         V.push_back(ANSN);         ANSN = pre[ANSN];       }       printf( %d , ANSN);       for (int i = V.size() - 1; i >= 0; --i) printf(  %d , V[i]);       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5007;   int a[maxn], b[maxn], n, m, g[maxn];   int gcd(int a, int b) {     if (a < b) return gcd(b, a);     if (b == 0) return a;     return gcd(b, a % b);   }   bool found(int v) {     int l = 1, r = m, mid;     while (l <= r) {       mid = (l + r) / 2;       if (b[mid] == v)         return 1;       else if (v < b[mid])         r = mid - 1;       else         l = mid + 1;     }     return 0;   }   int cal(int v) {     int res = 0, s;     for (int i = 2; i * i <= v; ++i)       if (v % i == 0) {         s = 0;         while (v % i == 0) {           v /= i;           ++s;         }         if (found(i)) s = -s;         res += s;       }     if (v > 1) {       s = 1;       if (found(v)) s = -s;       res += s;     }     return res;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1, _c = n; i <= _c; i++) scanf( %d , &a[i]);     for (int i = 1, _c = m; i <= _c; i++) scanf( %d , &b[i]);     g[0] = 0;     int mul = 1;     int res = 0;     for (int i = 1, _c = n; i <= _c; i++)       g[i] = gcd(g[i - 1], a[i]), res += cal(a[i]);     for (int i = n; i >= 1; i--) {       int gx = g[i] / mul;       int vx = cal(gx);       if (vx < 0) {         res -= vx * i;         mul *= gx;       }     }     printf( %d n , res);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, y;     char sex;     int m[367], f[367];     memset(m, 0, sizeof(m));     memset(f, 0, sizeof(f));     cin >> n;     for (int i = 0; i < n; i++) {       cin >> sex >> x >> y;       if (sex ==  M ) {         for (int j = x; j <= y; j++) m[j]++;       } else {         for (int j = x; j <= y; j++) f[j]++;       }     }     int res = 0;     for (int i = 1; i <= 366; i++) {       res = max(res, min(f[i], m[i]));     }     cout << 2 * res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int j = 0;     string a, b;     cin >> a;     cin >> b;     for (int i = a.length() - 1; i >= 0; i--) {       if (a[i] == b[j]) {         j++;       } else {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   bool isPrime(int n) {     if (n <= 3) {       return true;     }     if (n % 2 == 0 || n % 3 == 0) return false;     for (int i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, k;     cin >> n >> k;     int i = 1;     int sum;     while (1) {       sum = n * i;       if (sum % 10 == k || sum % 10 == 0) {         break;       }       i++;     }     cout << i;     return 0;   }