malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<long long> foo;   long long add = 0;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int k;       cin >> k;       foo.push_back(k);     }     cout << n + 1 <<   n ;     for (int i = foo.size() - 1; i >= 0; i--) {       foo[i] += add;       foo[i] %= n;       int q = i - foo[i] + n;       add += q;       cout << 1 <<     << i + 1 <<     << q <<   n ;     }     cout << 2 <<     << n <<     << n;     return 0;   }
#include <bits/stdc++.h>   int main() {     int a, b, c, d, num, e;     int flag = 1;     scanf(  %d , &num);     num++;     while (1) {       e = num;       a = num % 10;       num = num / 10;       b = num % 10;       num = num / 10;       c = num % 10;       d = num / 10;       if (a != b && a != c && a != d && b != c && b != d && c != d) {         break;       } else {         e++;         num = e;       }     }     printf( %d , e);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const int MMAX = 1e4 + 7;   const int MAXDEG = 55;   long long v[MAXDEG][MMAX];   vector<long long int> revs = {0};   void rev_begin() {     vector<long long int> y;     long long t = MOD - 2;     while (t > 0) {       y.push_back(t % 2);       t /= 2;     }     for (int i = 1; i < MAXDEG; i++) {       vector<long long int> a;       long long s = i;       for (int j = 0; j < 100; j++) {         a.push_back(s % MOD);         s = s * s;         s %= MOD;       }       long long ansy = 1;       for (int j = 0; j < y.size(); j++) {         if (y[j] == 1) {           ansy *= a[j];           ansy %= MOD;         }       }       revs.push_back(ansy);     }   }   void clr() {     for (int i = 0; i < MMAX; i++)       for (int j = 0; j < MAXDEG; j++) v[j][i] = 0;   }   void show() {     for (int i = 0; i < 10; i++) {       for (int j = 0; j < 5; j++) {         cout << v[i][j] <<    ;       }       cout << endl;     }   }   void doit(long long int u, int alpha) {     clr();     long long p = 1;     for (int j = 0; j < alpha + 1; j++) {       v[j][0] = p % MOD;       p *= u;       p %= MOD;     }     for (int i = 1; i < MMAX; i++) {       for (int j = 0; j < alpha + 1; j++) {         for (int l = 0; l <= j; l++) {           v[j][i] += (v[l][i - 1] * revs[j + 1]) % MOD;           v[j][i] %= MOD;         }       }     }   }   int main() {     long long n, k;     rev_begin();     cin >> n >> k;     long long ans = 1;     long long t = 2;     while (t * t <= n) {       while (t * t <= n && n % t != 0) t++;       if (n % t == 0) {         int alpha = 0;         while (n % t == 0) {           alpha++;           n /= t;         }         doit(t, alpha);         ans *= v[alpha][k];         ans %= MOD;       }     }     if (n > 1) {       t = n;       doit(t, 1);       ans *= v[1][k];       ans %= MOD;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long ans = 0;     int n;     cin >> n;     char str[65000];     cin >> str;     for (int i = 0; i < n; i++) {       if ((str[i] -  0 ) % 2 == 0) {         ans += i + 1;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a[2000007];   vector<int> deg(2000007, 0);   vector<pair<int, int>> ans;   int n, m;   void bfs(int node) {     vector<bool> used(n);     used[node] = true;     queue<int> q;     q.push(node);     while (!q.empty()) {       int currnode = q.front();       q.pop();       for (auto x : a[currnode]) {         if (used[x]) continue;         ans.push_back({x, currnode});         used[x] = true;         q.push(x);       }     }   }   void solve() {     cin >> n >> m;     int u, v;     for (int i = 0; i < m; i++) {       cin >> u >> v;       u--;       v--;       a[u].push_back(v);       a[v].push_back(u);       deg[u]++;       deg[v]++;     }     int maxnode = 0;     for (int i = 0; i < n; i++) {       if (deg[maxnode] < deg[i]) maxnode = i;     }     bfs(maxnode);     for (auto x : ans) {       cout << x.first + 1 <<     << x.second + 1 << endl;     }   }   int main() {     int t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<pair<int, int> > s0, s;   int K;   long long xx[200010], yy[200010];   void func(long long x, long long y) {     while (K > 0 && yy[K - 1] < y) K--;     while (K >= 2) {       long long tmp = (x - xx[K - 2]) * (yy[K - 1] - yy[K - 2]) -                       (xx[K - 1] - xx[K - 2]) * (y - yy[K - 2]);       if (tmp < 0)         K--;       else         break;     }     xx[K] = x;     yy[K] = y;     K++;   }   int main(void) {     int N, M, x, y, i;     cin >> N >> M >> x >> y;     for ((i) = 0; (i) < (int)(N); (i)++) {       scanf( %d%d , &x, &y);       s0.insert(make_pair(x, y));       s.insert(make_pair(x, -y));     }     for ((i) = 0; (i) < (int)(M); (i)++) {       scanf( %d%d , &x, &y);       s.insert(make_pair(x, -y));     }     for (__typeof((s).begin()) itr = (s).begin(); itr != (s).end(); itr++) {       x = (*itr).first;       y = (*itr).second;       func(x, -y);     }     int tp;     string ans =  Min ;     for ((i) = 0; (i) < (int)(K); (i)++) {       if (s0.find(make_pair(xx[i], yy[i])) != s0.end()) ans =  Max ;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int main(void) {     char s[1001];     char t[1001];     scanf( %s %s , s, t);     int idx = 0;     while (s[idx] !=   0 ) {       if (t[idx] ==   0 ) {         puts( No );         return 0;       }       char cs = s[idx];       char ct = t[idx];       int cvowel = 0;       int tvowel = 0;       if (cs ==  a  || cs ==  e  || cs ==  i  || cs ==  o  || cs ==  u )         cvowel = 1;       if (ct ==  a  || ct ==  e  || ct ==  i  || ct ==  o  || ct ==  u )         tvowel = 1;       if (cvowel != tvowel) {         puts( No );         return 0;       }       idx++;     }     if (t[idx] !=   0  && s[idx] ==   0 ) {       puts( No );       return 0;     }     puts( Yes );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int kolvo = 0;     int kolvo1 = 0;     for (int i = 0; i < n; i++) {       if (a[i] == 5) {         kolvo++;       }       if (a[i] == 0) {         kolvo1++;       }     }     sort(a.rbegin(), a.rend());     if ((kolvo / 9) > 0 and kolvo1 > 0) {       for (int i = 0; i < (kolvo / 9) * 9; i++) {         cout << a[i];       }       sort(a.begin(), a.end());       for (int i = 0; i < kolvo1; i++) {         cout << a[i];       }     } else {       if (kolvo1 > 0) {         cout << 0;       } else {         cout << -1;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200200;   vector<long long int> g[N], e[N];   set<pair<long long int, long long int> > S;   int n, m;   long long int d[N];   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     for (int i = 1; i <= m; i++) {       long long int x, y, z;       cin >> x >> y >> z;       g[x].push_back(y);       e[x].push_back(z);       g[y].push_back(x);       e[y].push_back(z);     }     for (int i = 1; i <= n; i++) {       cin >> d[i];       S.insert(make_pair(d[i], i));     }     while (S.size() != 0) {       int u = S.begin()->second;       S.erase(S.begin());       for (int i = 0; i < g[u].size(); i++) {         long long int v = g[u][i];         long long int cost = e[u][i];         if (cost * 2 + d[u] < d[v]) {           S.erase(make_pair(d[v], v));           d[v] = cost * 2 + d[u];           S.insert(make_pair(d[v], v));         }       }     }     for (int i = 1; i <= n; i++) {       cout << d[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, h, m, h0, m0, c(1), cash(1);     scanf( %d , &n);     scanf( %d%d , &h0, &m0);     while (--n) {       scanf( %d%d , &h, &m);       if (h == h0 && m == m0) {         c += 1;         if (c > cash) {           cash = c;         }       } else {         c = 1;       }       h0 = h;       m0 = m;     }     printf( %d n , cash);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     int count = 0;     vector<long long> ans;     int k = 0;     for (int i = 0; i < n; i++) {       int u;       scanf( %d , &u);       if (count > 0 && u != 0) {         if (k != 0)           ans.push_back(count + 1);         else {           ans.push_back(1);           k = 1;         }         count = 0;       } else if (count > 0 && u == 0) {         count++;       } else if (u == 0) {         count++;       } else {         k = 1;       }     }     if (count > 0 && k != 0) {       ans.push_back(1);     } else if (count > 0 && k == 0) {       ans.push_back(0);     }     long long ans1 = 1;     for (int i = 0; i < ans.size(); i++) {       ans1 = ans1 * (ans[i]);     }     printf( %lld n , ans1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     for (; ~scanf( %d%d , &n, &m);) {       if (n == 1) {         if (m == 1)           puts( 0 );         else {           for (int i = 1; i <= m; ++i) printf( %d  , i + 1);           puts(  );         }       } else {         if (m == 1)           for (int i = 1; i <= n; ++i) printf( %d n , i + 1);         else           for (int i = 1; i <= n; ++i) {             for (int j = 1; j <= m; ++j) printf( %d  , i * (j + n));             puts(  );           }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > V1, V2;   int n, s;   int main() {     while (~scanf( %d%d , &n, &s)) {       V1.clear();       V2.clear();       long long sum1 = 0;       long long sum2 = 0;       long long ans = 0;       for (int i = 0; i < n; i++) {         long long a, b, c;         scanf( %lld%lld%lld , &c, &a, &b);         if (a > b) {           sum1 += c;           ans += c * a;           V1.push_back(make_pair(a - b, c));         } else {           sum2 += c;           ans += c * b;           V2.push_back(make_pair(b - a, c));         }       }       sum1 %= s;       sum2 %= s;       if (sum1 + sum2 > s) {         cout << ans << endl;         continue;       } else {         sort(V1.begin(), V1.end());         sort(V2.begin(), V2.end());         long long tmp1 = 0;         long long tmp2 = 0;         int len = V1.size();         for (int i = 0; i < len; i++) {           tmp1 += min(sum1, V1[i].second) * V1[i].first;           sum1 -= min(sum1, V1[i].second);         }         len = V2.size();         for (int i = 0; i < len; i++) {           tmp2 += min(sum2, V2[i].second) * V2[i].first;           sum2 -= min(sum2, V2[i].second);         }         cout << ans - min(tmp1, tmp2) << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, k;     cin >> n >> k;     vector<long long> a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     vector<long long> step(100, 0);     for (long long i = 0; i < n; i++) {       long long x = 0;       while (a[i] > 0) {         step[x] += a[i] % k;         a[i] /= k;         x++;       }     }     for (long long i = 0; i < 100; i++) {       if (step[i] > 1) {         cout <<  NO  << endl;         return;       }     }     cout <<  YES  << endl;   }   signed main() {     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     map<int, int> m;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       m[a[i]] = i;     }     long long int b[n];     map<int, int> freq;     for (int i = 0; i < n; i++) {       cin >> b[i];       int shift = m[b[i]] - i;       if (m[b[i]] - i < 0) shift = (n - i + m[b[i]]);       freq[shift]++;     }     int ans = 0;     for (auto i : freq) {       ans = max(ans, i.second);     }     cout << ans <<   n ;     cerr <<  time taken :   << (float)clock() / CLOCKS_PER_SEC <<   secs           <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int size[3010], fa[3010], sum[3010], head[10010];   struct node {     int x, y, next;   } e[3010];   int find(int x) {     if (x != fa[x]) fa[x] = find(fa[x]);     return fa[x];   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y, w;       scanf( %d%d%d , &x, &y, &w);       e[i].x = x;       e[i].y = y;       e[i].next = head[w];       head[w] = i;     }     int s = 0;     for (int i = 1; i <= n; i++) {       fa[i] = i;       size[i] = 1;       scanf( %d , &sum[i]);       s += sum[i];     }     for (int i = 1; i <= 10000; i++) {       int p = head[i];       while (p) {         int x = find(e[p].x), y = find(e[p].y);         fa[y] = x;         size[x] += size[y];         sum[x] += sum[y];         if (size[x] + sum[x] > s) {           printf( %d n , i);           return 0;         }         p = e[p].next;       }     }     puts( 0 );     return 0;   }
#include <bits/stdc++.h>   const int maxx = 2e6 + 5;   using namespace std;   long long a[maxx];   long long biaoji[maxx] = {0};   int main() {     long long t, i, j, m, n;     cin >> n;     long long maxl = 0;     for (i = 1; i <= n; i++) {       scanf( %lld , &a[i]);       maxl = max(maxl, a[i]);       biaoji[a[i]]++;     }     long long sum1 = 0, sum2 = 0;     long long cishu = 0;     long long weizhi = 0;     for (i = 1; i <= maxl + 1; i++) {       if (biaoji[i] > 0) {         if (biaoji[i + 1] > 0 && biaoji[i + 2] > 0) {           sum1++;           i += 2;         } else if (biaoji[i + 1] > 0) {           sum1++;           i++;         } else if (biaoji[i + 2] > 0) {           sum1++;           i += 2;         } else {           sum1++;           i += 2;         }       }     }     for (i = 0; i <= maxl + 1; i++) {       if (i >= 1 && biaoji[i - 1] >= 1) {         sum2++;       } else if (biaoji[i] == 0) {         if (biaoji[i + 1] >= 1) {           biaoji[i + 1]--;           sum2++;         }       } else if (biaoji[i] >= 1) {         biaoji[i]--;         sum2++;       }     }     printf( %lld %lld n , sum1, sum2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     long long val, sum = 0, minOdd = 1000000001;     for (int i = 0; i < n; i++) {       scanf( %lld , &val);       if (val & 1) minOdd = min(minOdd, val);       sum += val;     }     printf( %lld n , (sum & 1) ? sum - minOdd : sum);     return 0;   }
#include <bits/stdc++.h>   namespace pb_ds {   namespace io {   const int MaxBuff = 1 << 15;   const int Output = 1 << 23;   char B[MaxBuff], *S = B, *T = B;   char Out[Output], *iter = Out;   inline void flush() {     fwrite(Out, 1, iter - Out, stdout);     iter = Out;   }   }  // namespace io   template <class Type>   inline Type Read() {     using namespace io;     register char ch;     register Type ans = 0;     register bool neg = 0;     while (ch = ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T)                      ? 0                      : *S++),            (ch <  0  || ch >  9 ) && ch !=  - )       ;     ch ==  -  ? neg = 1 : ans = ch -  0 ;     while (ch = ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T)                      ? 0                      : *S++),             0  <= ch && ch <=  9 )       ans = ans * 10 + ch -  0 ;     return neg ? -ans : ans;   }   template <class Type>   inline void Print(register Type x, register char ch =   n ) {     using namespace io;     if (!x)       *iter++ =  0 ;     else {       if (x < 0) *iter++ =  - , x = -x;       static int s[100];       register int t = 0;       while (x) s[++t] = x % 10, x /= 10;       while (t) *iter++ =  0  + s[t--];     }     *iter++ = ch;   }   }  // namespace pb_ds   using namespace pb_ds;   using namespace std;   const int N = 55;   const int inf = 2e9;   struct edge {     int next, to;   } a[N << 1];   int head[N], cnt;   inline void add(int u, int v) {     a[++cnt].to = v;     a[cnt].next = head[u];     head[u] = cnt;   }   int n, m, st, now, ans = inf;   int w[N][N], c[N], deg[N];   int dp[N][N][N][N], f[2][N];   void dfs(int x, int fa) {     for (int i = head[x]; i; i = a[i].next) {       int y = a[i].to;       if (y == fa) continue;       dfs(y, x), c[x] += c[y];     }   }   int solve(int u, int v, int s1, int s2) {     if (!s1) return s2 ? inf : 0;     if (~dp[u][v][s1][s2]) return dp[u][v][s1][s2];     if (deg[v] == 1) return dp[u][v][s1][s2] = (solve(v, u, s2, 0) + w[u][v]);     for (int i = head[v]; i; i = a[i].next) {       int y = a[i].to;       if (y == u) continue;       for (int j = 0; j <= s1; ++j) solve(v, y, j, s1 + s2 - j);     }     memset(f[0], 0, sizeof(f[0])), f[now = 0][0] = inf;     for (int i = head[v]; i; i = a[i].next) {       int y = a[i].to;       if (y == u) continue;       now ^= 1;       memset(f[now], 0, sizeof(f[now]));       for (int j = 0; j <= s1; ++j) {         for (int k = 0; j + k <= s1; ++k) {           f[now][j + k] =               max(f[now][j + k], min(f[now ^ 1][j], solve(v, y, k, s1 + s2 - k)));         }       }     }     return (dp[u][v][s1][s2] = (f[now][s1] + w[u][v]));   }   int main() {     n = Read<int>();     for (int i = 1; i < n; ++i) {       int u = Read<int>(), v = Read<int>();       w[u][v] = w[v][u] = Read<int>();       add(u, v), add(v, u);       ++deg[u], ++deg[v];     }     st = Read<int>(), m = Read<int>();     for (int i = 1; i <= m; ++i) ++c[Read<int>()];     dfs(st, 0), memset(dp, -1, sizeof(dp));     for (int i = head[st]; i; i = a[i].next)       ans = min(ans, solve(st, a[i].to, c[a[i].to], m - c[a[i].to]));     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   const double pi = std::acos(-1);   using namespace std;   const long long int mod = 1000000000 + 7;   long long int power(long long int x, long long int y, long long int md) {     long long int res = 1;     x = x % md;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % md;       y = y >> 1;       x = (x * x) % md;     }     return res;   }   long long int m_mul(long long int a, long long int b) {     a = a % mod;     b = b % mod;     return (a * b + mod) % mod;   }   long long int m_add(long long int a, long long int b) {     a = a % mod;     b = b % mod;     return (a + b + mod) % mod;   }   int main() {     long long int tc;     cin >> tc;     while (tc--) {       long long int n, x;       cin >> n >> x;       long long int arr[n];       for (long long int i = 0; i < n; i++) cin >> arr[i];       sort(arr, arr + n, greater<long long int>());       long long int a1 = 1;       long long int k = 0;       for (long long int i = 0; i < n; i++) {         if (arr[i] * a1 >= x) {           a1 = 1;           k++;         } else {           a1++;         }       }       cout << k <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int a, long long int b) {     long long int result = 1;     while (b > 0) {       int lastbit = (b & 1);       if (lastbit) {         result = (result * a);       }       a = (a * a);       b = b >> 1;     }     return result;   }   long long int power2(long long int a, long long int b, long long int p) {     long long int result = 1;     while (b > 0) {       int lastbit = (b & 1);       if (lastbit) {         result = (result * a) % p;       }       a = (a * a) % p;       b = b >> 1;     }     return result % p;   }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   vector<int> SieveOfEratosthenes(int n) {     bool prime[n + 1];     memset(prime, true, sizeof(prime));     for (int p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (int i = p * p; i <= n; i += p) prime[i] = false;       }     }     vector<int> v;     v.push_back(0);     for (int p = 2; p <= n; p++)       if (prime[p]) v.push_back(p);     return v;   }   void InverseofNumber(long long int p) {     long long int n[1000001];     n[0] = n[1] = 1;     for (int i = 2; i <= 1000000; i++) n[i] = n[p % i] * (p - p / i) % p;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int xxx;     cin >> xxx;     for (int tt = 1; tt <= xxx; tt++) {       long long int n;       cin >> n;       long long int t = ceil(sqrt(n));       long long int x = n / t;       if (n % t == 0) {         x--;       }       cout << t + x - 1;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     string s, t;     cin >> n;     vector<vector<int> > DP(26, vector<int>(26, -10000000));     for (int i = 0; i < n; i++) {       t = s;       cin >> s;       if (i > 0)         DP[t[0] -  a ][t[t.length() - 1] -  a ] =             max(DP[t[0] -  a ][t[t.length() - 1] -  a ], (int)t.length());       for (int j = 0; j < 26; j++)         DP[j][s[s.length() - 1] -  a ] = max(DP[j][s[s.length() - 1] -  a ],                                              DP[j][s[0] -  a ] + (int)s.length());     }     t = s;     DP[t[0] -  a ][t[t.length() - 1] -  a ] =         max(DP[t[0] -  a ][t[t.length() - 1] -  a ], (int)t.length());     int Ans = 0;     for (int i = 0; i < 26; i++) Ans = max(Ans, DP[i][i]);     cout << Ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long int w, x[200005];   int main() {     cin >> n >> w;     for (int i = 0; i < n * 2; i++) cin >> x[i];     sort(x, x + n * 2);     double mid;     mid = min((double)x[n] / 2, (double)x[0]);     mid = (mid + mid * 2) * n;     mid = min(mid, (double)w);     printf( %.6f n , mid);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, t, f, k, y = 0, w, j = 0, x = 0;     cin >> a >> t >> f >> k;     w = t;     for (;;) {       if (x == 0) {         if (j % 2 == 1) j++;         if (j == k) break;         if (w >= f) {           x = f;           w -= f;         } else {           cout << -1;           return 0;         }       } else if (x == f) {         if (j % 2 == 0) {           if (w >= (a - f) * 2) {             x = a;             w -= (a - f);           } else if (w >= a - f) {             if (j == k - 1) {               x = a;               w -= (a - f);             } else {               w = t;               x = a;               w -= (a - f);               y++;             }           } else {             if (t >= a - f) {               w = t;               x = a;               w -= (a - f);               y++;             } else {               cout << -1;               return 0;             }           }         } else {           if (w >= f * 2) {             x = 0;             w -= f;           } else if (w >= f) {             if (j == k - 1) {               x = 0;               w -= f;             } else {               w = t;               x = 0;               w -= f;               y++;             }           } else {             if (t >= f) {               w = t;               x = 0;               w -= f;               y++;             } else {               cout << -1;               return 0;             }           }         }       } else if (x == a) {         if (j % 2 == 0) j++;         if (j == k) break;         if (w >= a - f) {           x = f;           w -= (a - f);         } else {           cout << -1;           return 0;         }       }       if (j == k) break;     }     cout << y;   }