malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 110;   pair<int, int> a[N];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) scanf( %d , &a[i].first), a[i].second = i + 1;     sort(a + 1, a + n);     int Sum1 = a[0].first;     int Sum2 = 0;     for (int i = 1; i < n; i++) Sum2 += a[i].first;     vector<int> Ans({1});     for (int i = 1; i < n && Sum1 <= Sum2 && 2 * a[i].first <= a[0].first; i++) {       Sum1 += a[i].first;       Sum2 -= a[i].first;       Ans.push_back(a[i].second);     }     if (Sum1 <= Sum2) return 0 * puts( 0 );     sort(Ans.begin(), Ans.end());     cout << Ans.size() << endl;     for (int x : Ans) printf( %d  , x);   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   #pragma comment(linker,  /STACK:336777216 )   using namespace std;   int IT_MAX = 1 << 18;   const long long MOD = 1000000007;   const int INF = 0x3f3f3f3f;   const long long LL_INF = 0x3f3f3f3f3f3f3f3f;   const double PI = acos(-1);   const double ERR = 1e-10;   int ans[100050];   void aa1(int x) {     if (x == 2) {       ans[1] = 2;       ans[2] = 1;       return;     }     int i;     for (i = 2; i <= 30; i++)       if ((1 << i) > x + 2) break;     int v = i - 1;     if (x + 2 == (1 << v)) {       for (int i = 1; i <= x; i++) ans[i] = x + 1 - i;       return;     }     int nx;     for (i = (1 << v); i <= x; i++) {       int t = (1 << (v + 1)) - 1 - i;       ans[i] = t;       ans[t] = i;       nx = t;     }     aa1(nx - 1);   }   void aa2(int N) {     int v = 1;     while (v * 2 <= N) v *= 2;     int i;     for (i = 2; i < v; i += 2) {       ans[i] = i + 1;       ans[i + 1] = i;     }     vector<int> Vu;     for (i = v; i <= N; i++) Vu.push_back(i);     if (Vu.back() % 2 == 0) swap(Vu[Vu.size() - 2], Vu.back());     ans[Vu.back()] = 1;     ans[1] = Vu.back();     Vu.pop_back();     for (i = 0; i < Vu.size(); i++) ans[Vu[i]] = Vu[(i + 1) % Vu.size()];   }   int main() {     int N;     scanf( %d , &N);     if (N % 2 == 1)       printf( NO n );     else {       printf( YES n );       aa1(N);       for (int i = 1; i <= N; i++) printf( %d  , ans[i]);       printf(  n );     }     if (N <= 5)       printf( NO n );     else {       int t = 1;       while (t * 2 <= N) t *= 2;       if (t == N) return !printf( NO n );       if (t + 1 == N) {         ans[N - 1] = N;         ans[N] = N - 1;         aa2(N - 2);       } else         aa2(N);       printf( YES n );       for (int i = 1; i <= N; i++) printf( %d  , ans[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[50100];   int tmp[50100];   int ans[50100];   map<int, bool> vis;   int n;   bool Check(int mid) {     vis.clear();     for (int i = 1; i <= n; ++i) {       tmp[i] = arr[i];       while (tmp[i] > mid) tmp[i] >>= 1;       if (tmp[i] == 0) return false;       while (tmp[i] && vis[tmp[i]] == true) tmp[i] >>= 1;       if (tmp[i] == 0) return false;       vis[tmp[i]] = true;     }     return true;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &arr[i]);     int l, r;     l = 1, r = 2000000000;     while (l < r) {       int mid = l + ((r - l) >> 1);       if (Check(mid)) {         r = mid;         for (int i = 1; i <= n; ++i) ans[i] = tmp[i];       } else         l = mid + 1;     }     for (int i = 1; i <= n; ++i) {       if (i == 1)         printf( %d , ans[i]);       else         printf(  %d , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int n, x, y, i, j, l, pos1, pos2, A;   long long m, tmp1, tmp2, tmp3, ans;   struct node {     int x, y;   } a[N];   int cmp1(const node& a, const node& b) { return a.x > b.x; }   int cmp2(const node& a, const node& b) { return a.y < b.y; }   int main() {     scanf( %d%d%d%d%I64d , &n, &A, &x, &y, &m);     for (i = 1; i <= n; i++) scanf( %d , &a[i].x), a[i].y = i;     sort(a + 1, a + n + 1, cmp1);     for (tmp1 = 0, i = 1; i <= n && tmp1 + A - a[i].x <= m; i++)       tmp1 += A - a[i].x;     ans = 0;     j = n, tmp1 = m - tmp1 - A + a[i].x;     for (i--; i >= 0; i--) {       tmp1 = tmp1 + A - a[i + 1].x;       while (j > i + 1) {         tmp2 = (long long)(n - j + 1) * (a[j - 1].x - a[j].x);         if (tmp1 < tmp2)           break;         else           tmp1 -= tmp2, j--;       }       if (i < j)         tmp3 = min(tmp1 / (n - j + 1) + a[j].x, (long long)A);       else         tmp3 = A;       tmp2 = (long long)i * x + tmp3 * y;       if (tmp2 >= ans) ans = tmp2, pos1 = i, pos2 = j, l = tmp3;     }     for (i = 1; i <= pos1; i++) a[i].x = A;     for (i = pos2; i <= n; i++) a[i].x = l;     sort(a + 1, a + n + 1, cmp2);     for (printf( %I64d n , ans), i = 1; i < n; i++) printf( %d  , a[i].x);     return printf( %d n , a[n].x), 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[100001];   string s;   long long dp2[100001];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> s;     dp2[1] = 1;     dp2[2] = 2;     dp2[3] = 3;     dp2[4] = 5;     for (int i = 5; i <= 100000; i++) {       dp2[i] = dp2[i - 1] + dp2[i - 2];       dp2[i] %= (1000000007);     }     long long res = 1;     int cnt = 0, lastn = -1, lastu = -1;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  w  || s[i] ==  m ) {         cout << 0 << endl;         return 0;       }       if (s[i] ==  u ) {         if (lastu == -1) {           lastu = i;         }         if (lastn != -1) {           res *= dp2[i - lastn];           res %= (1000000007);           lastn = -1;         }       } else if (s[i] ==  n ) {         if (lastn == -1) {           lastn = i;         }         if (lastu != -1) {           res *= dp2[i - lastu];           res %= (1000000007);           lastu = -1;         }       } else {         if (lastu != -1) {           res *= dp2[i - lastu];           res %= (1000000007);           lastu = -1;         } else if (lastn != -1) {           res *= dp2[i - lastn];           res %= (1000000007);           lastn = -1;         }       }     }     if (lastu != -1) {       res *= dp2[s.length() - lastu];       res %= (1000000007);       lastu = -1;     } else if (lastn != -1) {       res *= dp2[s.length() - lastn];       res %= (1000000007);       lastn = -1;     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000100;   struct seg {     seg *fe, *fd;     int meio, l, r, xo;     seg(int x, int y) {       l = x, r = y;       meio = (x + y) / 2;       xo = 0;       if (l == r) return;       fe = new seg(x, meio);       fd = new seg(meio + 1, y);     }     void up(int pos, int novo) {       if (l == r) {         xo = novo;         return;       }       if (pos <= meio)         fe->up(pos, novo);       else         fd->up(pos, novo);       xo = (fe->xo ^ fd->xo);     }     int get(int a, int b) {       if (l >= a && r <= b) return xo;       if (l > b || r < a) return 0;       return (fe->get(a, b) ^ fd->get(a, b));     }   };   seg st(1, MAXN);   seg ss(1, MAXN);   struct query {     int l, r, id;   };   query q[MAXN];   int resp[MAXN];   int v[MAXN];   bool comp1(query a, query b) { return a.r < b.r; }   int main() {     int n;     scanf( %d , &n);     map<int, int> mapa;     for (int i = 1; i <= n; i++) scanf( %d , &v[i]), ss.up(i, v[i]);     int m;     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       scanf( %d %d , &q[i].l, &q[i].r);       q[i].id = i;     }     sort(q + 1, q + m + 1, comp1);     int p = 1;     for (int i = 1; i <= n; i++) {       int h = mapa[v[i]];       if (mapa[v[i]] != 0) st.up(h, 0);       mapa[v[i]] = i;       st.up(i, v[i]);       while (p <= m && q[p].r <= i) {         int r1 = ss.get(q[p].l, q[p].r);         int r2 = st.get(q[p].l, q[p].r);         resp[q[p].id] = (r1 ^ r2);         p++;       }     }     for (int i = 1; i <= m; i++) printf( %d n , resp[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   const double eps = 1e-8;   int n, T, cnt1, cnt2;   long double sum1;   double sum2;   struct water {     int a, t;   } A[N], B[N], Tmp[N];   bool cmp1(const water &a, const water &b) { return a.t < b.t; }   bool cmp2(const water &a, const water &b) { return a.t > b.t; }   int dcmp(long double x) { return (fabs(x) < eps) ? 0 : x < 0 ? -1 : 1; }   int main() {     scanf( %d%d , &n, &T);     for (int i = 1; i <= n; i++) scanf( %d , &Tmp[i].a);     for (int i = 1; i <= n; i++) scanf( %d , &Tmp[i].t);     for (int i = 1; i <= n; i++) {       if (Tmp[i].t <= T)         A[++cnt1] = Tmp[i];       else         B[++cnt2] = Tmp[i];       sum1 += 1ll * Tmp[i].a * Tmp[i].t;       sum2 += Tmp[i].a;     }     sort(A + 1, A + cnt1 + 1, cmp1);     sort(B + 1, B + cnt2 + 1, cmp2);     if (!dcmp(sum1 / sum2 - T)) printf( %.8lf , sum2), exit(0);     int flag = 0;     if (dcmp(sum1 / sum2 - T) < 0) {       for (int i = 1; i <= cnt1; i++) {         long double del = (sum1 - T * sum2) / (A[i].t - T);         if (dcmp(del - A[i].a) <= 0) {           sum1 -= del * A[i].t;           sum2 -= del;           flag = 1;           break;         } else           sum1 -= 1ll * A[i].a * A[i].t, sum2 -= A[i].a;       }     } else {       for (int i = 1; i <= cnt2; i++) {         long double del = (sum1 - T * sum2) / (B[i].t - T);         if (dcmp(del - B[i].a) <= 0) {           sum1 -= del * B[i].t;           sum2 -= del;           flag = 1;           break;         } else           sum1 -= 1ll * B[i].a * B[i].t, sum2 -= B[i].a;       }     }     if (flag)       printf( %.8lf n , sum2);     else       puts( 0.000000 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c *x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug &operator<<(const c &) {       return *this;     }   };   void solve() {     int n;     cin >> n;     string a, b;     cin >> a >> b;     vector<int> res;     for (int i = 0; i < a.length(); ++i) {       if (a[i] != b[i]) {         if (i > 0) res.push_back(i + 1);         res.push_back(1);         if (i > 0) res.push_back(i + 1);       }     }     cout << (int)res.size() <<    ;     for (long long i = 0; i < int((int)res.size()); i++) cout << res[i] <<    ;     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300005;   const int SIGMA_SIZE = 26;   int SZ = 0;   struct Node {     int sz, ch[SIGMA_SIZE];     Node() { memset(ch, 0, sizeof(ch)); }   } nd[maxn << 1];   int newNode() {     ++SZ;     memset(nd[SZ].ch, 0, sizeof(nd[SZ].ch));     return SZ;   }   void maintain(int u) {     nd[u].sz = 1;     for (int i = 0; i < SIGMA_SIZE; i++)       if (nd[u].ch[i]) nd[u].sz += nd[nd[u].ch[i]].sz;   }   void merge(int &a, int b) {     if (a == 0) {       a = b;     } else {       for (int i = 0; i < SIGMA_SIZE; i++) {         if (nd[b].ch[i]) merge(nd[a].ch[i], nd[b].ch[i]);       }     }     maintain(a);   }   int N;   long long C[maxn];   char S[maxn];   vector<int> G[maxn];   void init() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) {       G[i].clear();       scanf( %lld , &C[i]);     }     scanf( %s , S + 1);     int u, v;     for (int i = 1; i < N; i++) {       scanf( %d%d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);     }   }   int dfs(int u, int f) {     int p = newNode();     for (int i = 0; i < G[u].size(); i++) {       int v = G[u][i];       if (v == f) continue;       merge(p, dfs(v, u));     }     maintain(p);     int r = newNode();     nd[r].ch[S[u] -  a ] = p;     maintain(r);     C[u] += nd[r].sz - 1;     return r;   }   int main() {     init();     dfs(1, 0);     long long ans = 0, cnt;     for (int i = 1; i <= N; i++) {       if (C[i] > ans) {         ans = C[i];         cnt = 0;       }       if (C[i] == ans) {         cnt++;       }     }     printf( %I64d n%I64d n , ans, cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int p = 998244353, inv2 = 499122177;   inline void XOR(int *a, int lim, int type) {     for (register int mid = 1; mid < lim; mid <<= 1) {       for (register int i = mid << 1, j = 0; j < lim; j += i) {         for (register int k = 0; k < mid; k++) {           a[j + k] += a[j + k + mid];           if (a[j + k] >= p) a[j + k] -= p;           a[j + k + mid] = a[j + k] - a[j + k + mid] - a[j + k + mid];           if (a[j + k + mid] >= p)             a[j + k + mid] -= p;           else             while (a[j + k + mid] < 0) a[j + k + mid] += p;           if (type == -1)             a[j + k] = 1ll * a[j + k] * inv2 % p,                   a[j + k + mid] = 1ll * a[j + k + mid] * inv2 % p;         }       }     }   }   int n, m, lim;   char s[25][2000086];   int a[2000086], b[2000086];   int ans = 0x3f3f3f3f;   int main() {     scanf( %d%d , &n, &m), lim = 1 << n;     for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1);     for (int i = 1; i <= m; i++) {       int sum = 0;       for (int j = 1, k = 1; j <= n; j++, k <<= 1)         if (s[j][i] ==  1 ) sum += k;       ++a[sum];     }     for (int i = 1; i <= lim; i++) {       for (int j = i; j; j >>= 1)         if (j & 1) ++b[i];       b[i] = min(b[i], n - b[i]);     }     XOR(a, lim, 1), XOR(b, lim, 1);     for (int i = 0; i < lim; i++) a[i] = 1ll * a[i] * b[i] % p;     XOR(a, lim, -1);     for (int i = 0; i < lim; i++) ans = min(ans, a[i]);     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int ans = (n / 2) + (n & 1);     for (int i = ans; i <= n; ++i) {       if (i % m == 0) {         cout << i <<   n ;         return 0;       }     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char ch = getchar();     int w = 1, c = 0;     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) w = -1;     for (; isdigit(ch); ch = getchar()) c = (c << 1) + (c << 3) + (ch ^ 48);     return w * c;   }   const int mod = 1e9 + 7, M = 1e6 + 10;   struct node {     long long x, y, z;     node(long long _ = 1, long long __ = 0, long long ___ = 0) {       x = _;       y = __;       z = ___;     }   } a[M];   long long b[M];   node operator+(node A, node B) {     return node(A.x * B.x % mod, (A.y * B.x + B.y * A.x) % mod,                 (A.x * B.z + A.z * B.x + 2ll * A.y * B.y) % mod);   }   int n;   int main() {     n = read();     for (int i = (1); i <= (n); ++i) {       int x = read();       a[x] = a[x] + node(2, x, 1ll * x * x % mod);     }     for (int len = 1; len <= 100000; len *= 10) {       for (int j = (999999); j >= (0); --j) {         if ((j / len) % 10) {           a[j - len] = a[j - len] + a[j];         }       }     }     for (int i = (0); i <= (999999); ++i) b[i] = a[i].z;     for (int len = 1; len <= 100000; len *= 10) {       for (int j = (0); j <= (999999); ++j) {         if ((j / len) % 10) {           b[j - len] += mod - b[j];           b[j - len] %= mod;         }       }     }     long long ans = 0;     for (int i = (0); i <= (999999); ++i) {       ans ^= b[i] * i;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int m = 1000000007;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, k;     cin >> n >> k;     string s;     cin >> s;     for (int i = 0; i <= 25; i++) {       for (int j = 0; j < n and k > 0; j++) {         if (s[j] ==  a  + i) {           k--;           s[j] =  0 ;         }       }     }     for (auto &x : s) {       if (x !=  0 ) {         cout << x;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     string s, s1;     cin >> s;     int count = 0;     sort(s.begin(), s.end());     for (int i = 0; i < s.length(); ++i) {       if (s[i] ==  + ) count++;     }     std::vector<string> v(s.length());     for (int i = count; i < s.length(); ++i) {       v[i] = s[i];     }     if (count != 0)       for (int i = count; i < v.size() - 1; ++i) {         cout << v[i] <<  + ;       }     cout << v[v.size() - 1];   }   int main() { solve(); }
#include <bits/stdc++.h>   using namespace std;   int ans0[1000001];   int tail = 1;   int a[1001];   int n, m;   int ans = 0;   int main() {     int i, j, k;     int id;     int xx, yy;     int temp;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       for (j = 1; j <= n; j++) {         scanf( %d , &temp);         if (i == j) {           a[i] = temp;           if (temp == 1) {             ans = 1 - ans;           }         }       }     }     scanf( %d , &m);     for (i = 1; i <= m; i++) {       scanf( %d , &id);       if (id == 1 || id == 2) {         scanf( %d , &temp);         ans = 1 - ans;         a[temp] = 1 - a[temp];       } else {         ans0[tail] = ans;         tail++;       }     }     for (i = 1; i <= tail - 1; i++) {       printf( %d , ans0[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool b[1000050];   vector<int> v;   vector<int> v1;   int main() {     int n;     cin >> n;     int u = sqrt(n);     if (n == 1) {       cout << 1;       return 0;     }     for (int i = 2; i <= u; i++) {       if (!b[i]) {         for (int j = i * i; j <= n; j += i) b[j] = 1;       }     }     for (int i = 2; i <= n; i++)       if (!b[i]) {         v.push_back(i);       }     v1.push_back(n);     int j = 0;     while (1) {       while (n % v[j] != 0) j++;       while (n % v[j] == 0) {         n /= v[j];         v1.push_back(n);       }       if (j == v.size() - 1 || n == 1) break;     }     for (int i = 0; i < v1.size(); i++) cout << v1[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> lk;   void make(int num, int len) {     if (len == 10) return;     if (num != 0) lk.push_back(num);     make(num * 10 + 4, len + 1);     make(num * 10 + 7, len + 1);   }   double gao(int l1, int l2, int r1, int r2) {     double l = max(l1, r1), r = min(l2, r2);     return max(0.0, r - l + 1);   }   int main() {     make(0, 0);     sort(lk.begin(), lk.end());     int p1, p2, v1, v2, k;     while (cin >> p1 >> p2 >> v1 >> v2 >> k) {       int c1 = max(p1, v1), c2 = min(c2, v2);       double tot = (p2 - p1 + 1.0) * (v2 - v1 + 1.0), sum = 0;       int sz = lk.size();       for (int i = 0; i + k - 1 < sz; i++) {         int l1, l2 = lk[i], r1 = lk[i + k - 1], r2;         if (i == 0)           l1 = 0;         else           l1 = lk[i - 1] + 1;         if (i + k == sz)           r2 = 1000000000;         else           r2 = lk[i + k] - 1;         sum += gao(l1, l2, p1, p2) * gao(r1, r2, v1, v2);         sum += gao(l1, l2, v1, v2) * gao(r1, r2, p1, p2);         sum -= gao(c1, c2, max(l1, r1), min(l2, r2));       }       printf( %.12f n , sum / tot);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0),         cout.tie(0);     int n;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (j != i) {           for (int k = 0; k < n; k++) {             if (k != j) {               if (arr[i] + arr[j] == arr[k]) {                 cout << k + 1 <<     << j + 1 <<     << i + 1;                 return 0;               }             }           }         }       }     }     cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   const int N = 2e5 + 10;   const int MOD = 1e9 + 7;   const int INF = 2e9;   using namespace std;   vector<int> a;   int f[N], d[N];   int c, n;   int main() {     ios::sync_with_stdio(false);     cin >> c >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       a.push_back(x);     }     sort(a.begin(), a.end());     for (int i = 1; i <= N; i++) d[i] = -1;     for (int i = 0; i < n; i++)       if (d[a[i]] == -1) d[a[i]] = i;     vector<int>::iterator it;     for (int i = 1; i <= c; i++) {       it = lower_bound(a.begin(), a.end(), i);       if (*it == i)         f[i] = it - a.begin();       else if (it > a.begin())         f[i] = it - a.begin() - 1;       else         f[i] = -1;     }     for (int i = 1; i < c; i++) {       int tmp = c, prev = n + 1;       bool ok = true;       while (1) {         int y = f[tmp];         if (y >= prev) y = prev - 1;         if (y < 0) {           cout << i;           return 0;         }         if (y == -1) {           cout << i;           return 0;         } else if (ok && a[y] <= i && i <= tmp) {           tmp -= i;           ok = false;         } else {           int x = a[y];           int pos = d[x];           int t1 = y - pos + 1;           int t2 = tmp / x;           if (t1 > t2) {             tmp -= t2 * x;             prev = y - t2 + 1;           } else {             tmp -= t1 * x;             prev = pos;           }         }         if (tmp == 0) break;       }     }     cout <<  Greed is good ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   char A[N];   char B[N];   int buck[128];   int ans[128];   bool ok() {     for (int i =  a ; i <=  z ; ++i)       if (buck[i] > ans[i]) return false;     return true;   }   int main() {     scanf( %s , A);     scanf( %s , B);     int aa = strlen(A);     int bb = strlen(B);     for (int i = 0; i < bb; ++i) {       buck[A[i]]++;       ans[B[i]]++;     }     int cnt = 0;     for (int i = bb - 1; i < aa; ++i) {       if (ok()) cnt++;       buck[A[i - bb + 1]]--;       buck[A[i + 1]]++;     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2, left, line;     cin >> line;     bool first = true;     for (int i = 0; i < line.size(); i++) {       if (line[i] ==  | )         first = false;       else if (first)         s1 += line[i];       else         s2 += line[i];     }     cin >> left;     int l1 = s1.size();     int l2 = s2.size();     int l3 = left.size();     int m = (l1 + l2 + l3) / 2;     if ((l1 + l2 + l3) % 2 == 1 || l1 > m || l2 > m)       cout <<  Impossible  << endl;     else {       cout << s1;       int p = m - l1;       for (int i = 0; i < p; i++) cout << left[i];       cout <<  | ;       cout << s2;       for (int i = p; i < l3; i++) cout << left[i];       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     char tmp[11];     deque<string> dq;     set<string> st;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %s , &tmp);       dq.push_front(tmp);     }     for (deque<string>::iterator i = dq.begin(); i != dq.end(); i++) {       if (st.count(*i) == 0) {         printf( %s n , (*i).c_str());         st.insert(*i);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, a, b, c, d, k;     cin >> t;     while (t--) {       cin >> a >> b >> c >> d >> k;       int pen = (a + c - 1) / c;       int penc = (b + d - 1) / d;       if (pen + penc <= k)         cout << pen <<     << penc << endl;       else         cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 105;   int n, a[maxn], vis[maxn];   int gcd(int a, int b) {     while (b) {       int c = a % b;       a = b;       b = c;     }     return a;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     int flag = 0;     vector<int> ans;     for (int i = 1; i <= n; i++) {       if (vis[i]) continue;       int now = i;       int cnt = 0;       while (!vis[now]) {         vis[now] = i;         now = a[now];         cnt++;       }       if (now != i) return puts( -1 ), 0;       if (cnt % 2 == 0) cnt /= 2;       ans.push_back(cnt);     }     long long A = ans[0];     for (int i = 1; i < ans.size(); i++) A = A * ans[i] / gcd(A, ans[i]);     cout << A << endl;   }