malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using VI = vector<int>;   using VVI = vector<VI>;   using VB = vector<bool>;   using VVB = vector<VB>;   using VD = vector<double>;   using VVD = vector<VD>;   using VS = vector<string>;   using PII = pair<int, int>;   using VPII = vector<PII>;   using VL = vector<long long>;   using VVL = vector<VL>;   int n;   const int MOD = (int)1e9 + 7;   const int MAXN = 300010;   VI A;   int add(int a, int b) {     a = ((a % MOD) + (b % MOD));     return (a >= MOD) ? (a - MOD) : a;   }   int sub(int a, int b) {     a -= b;     return (a < 0) ? (a + MOD) : a;   }   int mul(int a, int b) { return ((long long)a * b) % MOD; }   int powTable[MAXN];   long long sumMaxDistSubsets() {     sort(A.begin(), A.end());     powTable[0] = 1;     for (int i = 1; i <= n; ++i) powTable[i] = (powTable[i - 1] * 2ll) % MOD;     int ret = 0;     for (int i = 1; i <= n; ++i) {       int times = powTable[i - 1] - powTable[n - i];       ret = add(ret, mul(A[i], times));     }     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     A.assign(n + 1, 0);     for (int i = 1; i < (int)n + 1; ++i) cin >> A[i];     cout << sumMaxDistSubsets() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 520;   int n, m, q, s[4][N][N], id[N], s2[N / 2][N][N], Mx;   char c[N][N];   bool CK(int s[N][N], int x1, int y1, int x2, int y2, int op) {     int dat = s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1];     return op ? dat : dat == (x2 - x1 + 1) * (y2 - y1 + 1);   }   bool ck(int x, int y, int len) {     int x0 = x - len + 1, y0 = y - len + 1, x1 = x + len, y1 = y + len;     return CK(s[0], x0, y0, x, y, 0) && CK(s[1], x0, y + 1, x, y1, 0) &&            CK(s[2], x + 1, y0, x1, y, 0) && CK(s[3], x + 1, y + 1, x1, y1, 0);   }   int read() {     int x = 0, c;     while (!isdigit(c = getchar()))       ;     while (isdigit(c)) x = x * 10 + c - 48, c = getchar();     return x;   }   int main() {     id[ R ] = 0;     id[ G ] = 1;     id[ Y ] = 2;     id[ B ] = 3;     scanf( %d%d%d , &n, &m, &q);     Mx = min(n / 2, m / 2);     for (int i = 1; i <= n; i++) scanf( %s , c[i] + 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         for (int k = 0; k < 4; k++)           s[k][i][j] = s[k][i - 1][j] + s[k][i][j - 1] - s[k][i - 1][j - 1] +                        (id[c[i][j]] == k);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         int mx = min(min(i, n - i), min(j, m - j));         for (int k = 1; k <= Mx; k++)           s2[k][i][j] = s2[k][i - 1][j] + s2[k][i][j - 1] - s2[k][i - 1][j - 1];         for (int k = 1; k <= mx; k++)           if (ck(i, j, k))             s2[k][i][j]++;           else             break;       }     for (int i = 1, x1, y1, x2, y2; i <= q; i++) {       x1 = read(), y1 = read();       x2 = read();       y2 = read();       int l = 1, r = min((x2 - x1 + 1) / 2, (y2 - y1 + 1) / 2), ans = 0;       while (l <= r) {         int mid = (l + r) >> 1;         if (CK(s2[mid], x1 + mid - 1, y1 + mid - 1, x2 - mid, y2 - mid, 1))           ans = mid, l = mid + 1;         else           r = mid - 1;       }       printf( %d n , 4 * ans * ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, i, j, k, r;     cin >> n >> k >> r;     long long ar[n], arr[k];     for (i = 0; i < n; i++) {       cin >> ar[i];     }     for (i = 0; i < k; i++) {       cin >> arr[i];     }     sort(ar, ar + n);     sort(arr, arr + k);     long long a = ar[0], d, p;     long long b = arr[k - 1];     d = r / a;     p = r % a;     long long sum = b * d + p;     cout << max(sum, r) << endl;     return 0;   }
#include <bits/stdc++.h>   int getmin(int a, int b) {     if (a == -1)       return b;     else if (b == -1)       return a;     else       return a < b ? a : b;   }   int solve(int a, int b) {     int tot = 0;     while (a != 1 || b != 1) {       tot++;       if (!a || !b) return -1;       if (a > b)         a -= b;       else         b -= a;     }     return tot;   }   int main() {     int n, ans = -1;     scanf( %d , &n);     for (int a = 1; a < n; a++) ans = getmin(ans, solve(a, n));     if (ans == -1) ans++;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[1010], a[1010], p[1020];   int a1, a2, tot;   void cal() {     if (a[tot - 2] ==  . ) {       a2 += ((a[tot - 1] -  0 ) * 10 + (a[tot] -  0 ));       tot -= 3;     }     if (a2 >= 100) a2 -= 100, a1++;     int sum = 0;     for (int i = 1; i <= tot; i++)       if (a[i] !=  . ) sum = sum * 10 + a[i] -  0 ;     a1 += sum;   }   int main() {     scanf( %s , s + 1);     int len = strlen(s + 1);     for (int i = 1; i <= len; i++) {       if ((s[i] <  0  || s[i] >  9 ) && s[i] !=  . ) continue;       if ((s[i - 1] <  0  || s[i - 1] >  9 ) && s[i - 1] !=  . ) {         cal();         memset(a, 0, sizeof(a));         tot = 0;       }       a[++tot] = s[i];       if (i == len) cal();     }     int np = 0;     if (a1 == 0)       np = 1, p[1] =  0 ;     else {       int tmp = 0;       while (a1 > 0) {         p[++np] = a1 % 10 +  0 ;         tmp++;         if (tmp == 3) {           p[++np] =  . ;           tmp = 0;         }         a1 /= 10;       }     }     if (p[np] !=  . ) printf( %c , p[np]);     for (int i = np - 1; i >= 1; i--) printf( %c , p[i]);     if (a2) printf( .%02d , a2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200010;   int n, q;   struct X {     int id, val;   } s[maxn];   struct XX {     int a, b;     XX() {}     XX(int A, int B) {       a = A;       b = B;     }     bool operator<(const XX &aa) const { return b > aa.b; }   };   XX fir, sec;   vector<int> v[maxn];   set<XX> h;   int tmp[maxn], mn[maxn], mx[maxn];   bool check(int x) {     int tt = v[fir.a][x];     if (s[tt].val < sec.b) return 0;     return 1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= 200000; i++) mx[i] = 0, mn[i] = 2000000000;     for (int i = 1; i <= n; i++) {       scanf( %d%d , &s[i].id, &s[i].val);       v[s[i].id].push_back(i);       mx[s[i].id] = max(mx[s[i].id], s[i].val);       mn[s[i].id] = min(mn[s[i].id], s[i].val);     }     for (int i = 1; i <= 200000; i++) {       if (mx[i] == 0) continue;       h.insert(XX(i, mx[i]));     }     scanf( %d , &q);     for (int i = 1; i <= q; i++) {       int k;       scanf( %d , &k);       for (int j = 1; j <= k; j++) scanf( %d , &tmp[j]);       for (int j = 1; j <= k; j++) {         if (mx[tmp[j]] == 0) continue;         h.erase(XX(tmp[j], mx[tmp[j]]));       }       if (h.size() == 0) {         printf( 0 0 n );       } else if (h.size() == 1) {         XX ans = *h.begin();         printf( %d %d n , ans.a, mn[ans.a]);       } else {         set<XX>::iterator iter;         int cnt = 0;         for (iter = h.begin(); iter != h.end(); iter++) {           cnt++;           if (cnt == 1)             fir = *iter;           else if (cnt == 2) {             sec = *iter;             break;           }         }         int L = 0, R = v[fir.a].size() - 1;         int ans;         while (L <= R) {           int mid = (L + R) / 2;           if (check(mid))             ans = mid, R = mid - 1;           else             L = mid + 1;         }         int tt = v[fir.a][ans];         printf( %d %d n , s[tt].id, s[tt].val);       }       for (int j = 1; j <= k; j++) {         if (mx[tmp[j]] == 0) continue;         h.insert(XX(tmp[j], mx[tmp[j]]));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(0);     long long n;     cin >> n;     vector<long long> a;     for (long long i = 0; i < n; ++i) {       long long x;       cin >> x;       a.push_back(x);     }     sort(a.begin(), a.end());     long long c = 0;     for (long long i = 0; i < a.size() - 1; ++i) {       c += a[a.size() - 1] - a[i];     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int c[110];   int main() {     int n, i, x, y, j;     cin >> n;     for (i = 0; i < n; i++) {       cin >> x;       for (j = 0; j < x; j++) {         cin >> y;         c[y]++;         if (c[y] == n) {           cout << y <<    ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void _R(int &x) { scanf( %d , &x); }   void _R(long long &x) { scanf( %lld , &x); }   void _R(double &x) { scanf( %lf , &x); }   void _R(char &x) { scanf(  %c , &x); }   void _R(char *x) { scanf( %s , x); }   void R() {}   template <class T, class... U>   void R(T &head, U &...tail) {     _R(head);     R(tail...);   }   void _W(const int &x) { printf( %d , x); }   void _W(const long long &x) { printf( %lld , x); }   void _W(const double &x) { printf( %.16f , x); }   void _W(const char &x) { putchar(x); }   void _W(const char *x) { printf( %s , x); }   template <class T>   void _W(const vector<T> &x) {     for (auto i = x.begin(); i != x.end(); _W(*i++))       if (i != x.cbegin()) putchar(   );   }   void W() {}   template <class T, class... U>   void W(const T &head, const U &...tail) {     _W(head);     putchar(sizeof...(tail) ?     :   n );     W(tail...);   }   const int N = 3e5 + 7, M = 2e6;   const long long mod = 1e9 + 7;   inline int read() {     int ret = 0;     char ch = getchar();     bool f = 1;     for (; !isdigit(ch); ch = getchar()) f ^= !(ch ^  - );     for (; isdigit(ch); ch = getchar()) ret = (ret << 1) + (ret << 3) + ch - 48;     return f ? ret : -ret;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long ksm(long long a, long long b, long long mod) {     int ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return ans;   }   long long inv2(long long a, long long mod) { return ksm(a, mod - 2, mod); }   void TelmaZzzz() {}   struct node {     int l, r, val;   } que[N];   int a[N];   int arr[N];   int k, t, m, n;   bool check(int x) {     int minn = m + 1, maxn = -1;     for (int i = 1; i <= m + 1; i++) arr[i] = 0;     for (int i = 1; i <= k; i++) {       if (que[i].val <= a[n - x + 1]) continue;       arr[que[i].l]++;       arr[que[i].r + 1]--;     }     int ans = m + 1;     for (int i = 1; i <= m + 1; i++) {       arr[i] += arr[i - 1];       if (arr[i]) ans += 2;     }     if (ans <= t) return true;     return false;   }   int main() {     TelmaZzzz();     R(n, m, k, t);     for (int i = 1; i <= n; i++) R(a[i]);     for (int i = 1; i <= k; i++) R(que[i].l, que[i].r, que[i].val);     sort(a + 1, a + 1 + n);     int l = 1, r = n;     while (l <= r) {       int mi = (l + r) / 2;       if (check(mi))         l = mi + 1;       else         r = mi - 1;     }     W(r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, ans, a[1001];   int main() {     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 2; i < n; i++)       if ((a[i] > a[i - 1] && a[i] > a[i + 1]) ||           (a[i] < a[i - 1] && a[i] < a[i + 1]))         ans++;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Int() {     int x;     scanf( %d , &x);     return x;   }   long long Long() {     long long x;     scanf( %lld , &x);     return x;   }   void err(istream_iterator<string> it) { cout << endl; }   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a <<    ;     err(++it, args...);   }   const int N = (int)2e5 + 5;   const int maxN = (int)1e6 + 6;   const long long Mod = (long long)1e9 + 7;   vector<int> box;   int len, k, a, b;   bool vis[201][201];   string s;   void call(int cur, int last) {     if (cur > k) return;     if (last == (int)s.size()) {       if (cur != k) return;       int cnt = 0;       for (int i : box) {         for (int j = cnt; j < i + cnt; ++j) cout << s[j];         cout <<   n ;         cnt += i;       }       exit(0);     }     if (vis[cur][last]) return;     vis[cur][last] = 1;     for (int i = a; i <= b; ++i) {       if (last + i <= (int)s.size()) {         box.push_back(i);         call(cur + 1, i + last);         box.pop_back();       }     }   }   int main() {     int test = 1, tc = 0;     while (test--) {       cin >> k >> a >> b;       cin >> s;       for (int i = a; i <= b; ++i) {         if (i <= (int)s.size()) {           box.push_back(i);           call(1, i);           box.pop_back();         }       }       puts( No solution );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double vp, vd, t, f, c;   int main() {     cin >> vp >> vd >> t >> f >> c;     if (vp >= vd) {       cout <<  0 ;       return 0;     }     int numberOfBojous = 0;     double timeToHaveTheDragonBack = 0, overtakePosition = 0;     double princessPosition = vp * t;     while (princessPosition < c) {       overtakePosition = vd * princessPosition / (vd - vp);       if (overtakePosition < c) numberOfBojous++;       timeToHaveTheDragonBack = (overtakePosition / vd) + f;       princessPosition = (vp * timeToHaveTheDragonBack) + overtakePosition;     }     cout << numberOfBojous;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double EPS = 1e-10;   const int MOD = 1000000007;   const int MAXN = 110000;   const double PI = acos(-1.0);   template <class T>   T abs(T x) {     return x < 0 ? -x : x;   }   int num, kase;   int flag[22][MAXN];   long long fun() {     long long ret = 0;     for (int index = 0; index < (21); ++index) {       long long cnt = 0, t = 0;       for (int i = (1); i <= (num + 1); ++i) {         if (flag[index][i] == 1)           cnt++;         else {           t += ((cnt * cnt + cnt) >> 1);           cnt = 0;         }       }       ret += (1 << index) * t;     }     return ret;   }   void findlr(int* f, int n, int& l, int& r) {     int i = n - 1;     while (f[i] == 1) i--;     l = i + 1;     i = n + 1;     while (f[i] == 1) i++;     r = i - 1;   }   int main() {     int t, p;     while (~scanf( %d%d , &num, &kase)) {       memset(flag, 0, sizeof(flag));       for (int i = (1); i <= (num); ++i) {         scanf( %d , &t);         p = 1;         for (int ind = 0; ind < (21); ++ind) {           flag[ind][i] = ((t & p) > 0);           p <<= 1;         }       }       long long ans = fun();       int a, b, l, r;       for (int tt = 0; tt < (kase); ++tt) {         scanf( %d%d , &a, &b);         for (int ind = 0; ind < (21); ++ind) {           p = 1 << ind;           if (((b & p) > 0) != flag[ind][a]) {             findlr(flag[ind], a, l, r);             long long lenl = a - l, lenr = r - a;             ans += (1 - flag[ind][a] * 2) * (1 << ind) *                    (lenl * lenr + lenl + lenr + 1);             flag[ind][a] = !flag[ind][a];           }         }         cout << ans << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<pair<int, int> > vt;   bool cmp(pair<int, int> x, pair<int, int> y) {     return (x.first < y.first || (x.first == y.first && x.second < y.second));   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       int u;       cin >> u;       vt.push_back(make_pair(u, i));     }     sort(vt.begin(), vt.end(), cmp);     for (int i = 0; i < (int)vt.size() - 2; i++)       for (int j = i + 1; j < (int)vt.size() - 1; j++) {         int k = upper_bound(                     vt.begin(), vt.end(),                     pair<int, int>(vt[i].first + vt[j].first - 1, 1000000000)) -                 vt.begin();         if (vt[k].first == (vt[i].first + vt[j].first)) {           cout << vt[k].second <<     << vt[i].second <<     << vt[j].second;           return 0;         }       }     cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2500 + 10, MAXK = 7;   int k, sum[MAXN][MAXN], l[MAXK], r[MAXK];   long long Tohka;   vector<string> Rotate(vector<string>& a) {     vector<string> Houki;     for (int i = 0; i < (int)a[0].size(); ++i) {       string str;       for (int j = 0; j < (int)a.size(); ++j) str += a[j][i];       Houki.push_back(str);     }     return Houki;   }   int Gets(int xl, int yl, int xr, int yr) {     return sum[xr][yr] - sum[xl - 1][yr] - sum[xr][yl - 1] + sum[xl - 1][yl - 1];   }   void solve(vector<string> a) {     if (a.size() == 0 || a[0].size() == 0) return;     if (a.size() > a[0].size()) a = Rotate(a);     int n = (int)a.size(), m = (int)a[0].size();     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] +                     (a[i - 1][j - 1] ==  1 );     int mid = (m + 1) / 2;     for (int i = 1; i <= n; ++i) {       for (int j = 0; j <= k; ++j) l[j] = 1, r[j] = m;       for (int j = i; j <= n; ++j) {         for (int p = 0; p <= k; ++p) {           for (; l[p] <= mid && Gets(i, l[p], j, mid) > p; ++l[p])             ;           for (; r[p] > mid && Gets(i, mid + 1, j, r[p]) > p; --r[p])             ;         }         for (int lp = 0, rp = k; lp <= k; ++lp, --rp) {           int ls = (lp ? l[lp - 1] : (mid + 1)) - l[lp],               rs = r[rp] - (rp ? r[rp - 1] : mid - 1);           Tohka += (long long)ls * rs;         }       }     }     vector<string> lstr, rstr;     for (int i = 0; i < n; ++i) {       string ls, rs;       for (int j = 0; j < m; ++j) {         if (j + 1 < mid) ls += a[i][j];         if (j + 1 > mid) rs += a[i][j];       }       lstr.push_back(ls), rstr.push_back(rs);     }     solve(lstr), solve(rstr);   }   int main() {     int n, m;     vector<string> a;     cin >> n >> m >> k;     for (int i = 1; i <= n; ++i) {       string str;       cin >> str;       a.push_back(str);     }     solve(a);     cout << Tohka << endl;     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   using namespace std;   const int INF = 1e9;   int main() {     string s;     cin >> s;     long long n = s.length();     vector<long long> v;     long long ans = 0;     for (long long i = 0; i < n; i++) {       if (int(s[i]) < 97) {         v.push_back(1);       } else {         v.push_back(0);       }     }     vector<long long> p = vector<long long>(n, 0);     p[0] = (v[0] == 0) ? 1 : 0;     for (long long i = 1; i < n; i++) {       p[i] = p[i - 1] + ((v[i] == 0) ? 1 : 0);     }     long long mn = n - p[n - 1];     for (long long i = 0; i < n; i++) {       mn = min(mn, p[i] + (n - 1 - i - p[n - 1] + p[i]));     }     cout << mn << endl;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, vector<long long>> v;   map<long long, long long> visited, dist, pt;   long long mx = 0, nd = 0, mxd = 0, mxn = 0;   void bfs(long long u) {     visited[u] = 1;     queue<long long> q;     q.push(u);     dist[u] = 0;     while (!q.empty()) {       u = q.front();       visited[u] = 1;       q.pop();       visited[u] = 1;       for (long long i = 0; i < (long long)v[u].size(); i++) {         long long p = v[u][i];         if (!visited[p]) {           visited[p] = 1;           dist[p] = dist[u] + 1;           if (dist[p] > mxd) {             mxd = dist[p];             mxn = p;           }           pt[p] = u;           q.push(p);         }       }     }   }   int main() {     long long a, b, x, c, i, j, n, t, k, z = 0, node, edge;     scanf( %lld , &n);     for (i = 1; i <= n; i++) {       scanf( %lld %lld , &a, &b);       v[a].push_back(b);       v[b].push_back(a);       c = a;     }     bfs(c);     x = mxn;     visited.clear();     dist.clear();     pt.clear();     mxd = 0;     bfs(mxn);     vector<long long> path;     path.push_back(mxn);     long long now = mxn;     while (now != x) {       now = pt[now];       path.push_back(now);     }     for (i = 0; i < (long long)path.size(); i++) cout << path[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5;   static int comp[maxn];   static int pr[maxn];   static int n;   void make_set() {     for (int i = 0; i < n; ++i) {       pr[i] = i;       comp[i] = 1;     }   }   int find_set(int a) {     if (pr[a] == a) return a;     return pr[a] = find_set(pr[a]);   }   void union_set(int a, int b) {     a = find_set(a);     b = find_set(b);     pr[a] = b;     comp[b] += comp[a];     comp[a] = 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cin >> n;     int m;     cin >> m;     make_set();     for (int i = 0; i < m; ++i) {       int a, b;       cin >> a >> b;       a--;       b--;       if (find_set(a) != find_set(b)) union_set(a, b);     }     int k;     cin >> k;     for (int j = 0; j < k; ++j) {       int a, b;       cin >> a >> b;       a--;       b--;       if (find_set(a) == find_set(b)) {         comp[find_set(a)] = 0;       }     }     int mx = 0;     for (int l = 0; l < n; ++l) {       mx = max(mx, comp[l]);     }     cout << mx;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > G[100005];   int dp[100005], Xor[100005];   int rec(int n) {     int answer = 1e9;     for (int i = 0; i < G[n].size(); i++) {       int st = G[n][i].first;       int ed = G[n][i].second + st - 1;       int x = Xor[ed] ^ Xor[st - 1];       if (x == 0) answer = min(answer, G[n][i].second);     }     return answer;   }   int main() {     memset(dp, -1, sizeof(dp));     for (int i = 1; i <= 100000; i++) {       for (int j = i, sum = i; sum <= 100000; j++, sum += j) {         if (j - i + 1 >= 2) G[sum].push_back(make_pair(i, j - i + 1));       }     }     for (int n = 1; n <= 100000; n++) {       set<int> ST;       for (int i = 0; i < G[n].size(); i++) {         int st = G[n][i].first;         int ed = G[n][i].second + st - 1;         int x = Xor[ed] ^ Xor[st - 1];         ST.insert(x);       }       for (int i = 0;; i++) {         if (ST.find(i) == ST.end()) {           dp[n] = i;           break;         }       }       Xor[n] = Xor[n - 1] ^ dp[n];     }     int n;     cin >> n;     if (dp[n] == 0) {       cout << -1 << endl;       return 0;     }     cout << rec(n) << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool is_possible(int m, long long k, long long p[], int n, int x, int a, int y,                    int b) {     if (a != b) {       int first = 0;       int second = 0;       int third = 0;       for (int i = 1; i <= m; i++) {         if (i % a == 0 && i % b == 0)           third++;         else if (i % a == 0)           first++;         else if (i % b == 0)           second++;       }       long long ans1 = 0;       for (int i = 0; i < third; i++) {         ans1 += ((p[i] * (x + y)) / 100);       }       for (int i = third; i <= third + first - 1; i++) {         ans1 += ((p[i] * x) / 100);       }       for (int i = third + first; i <= third + first + second - 1; i++) {         ans1 += ((p[i] * y) / 100);       }       long long ans2 = 0;       for (int i = 0; i < third; i++) {         ans2 += ((p[i] * (x + y)) / 100);       }       for (int i = third; i <= third + second - 1; i++) {         ans2 += ((p[i] * y) / 100);       }       for (int i = third + second; i <= third + second + first - 1; i++) {         ans2 += ((p[i] * x) / 100);       }       if (ans1 >= k || ans2 >= k) return true;       return false;     } else {       long long ans1 = 0;       int first = 0;       for (int i = 1; i <= m; i++) {         if (i % a == 0) first++;       }       for (int i = 0; i < first; i++) {         ans1 += ((p[i] * (x + y)) / 100);       }       if (ans1 < k) return false;       return true;     }   }   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       long long aa[n];       long long p[n];       for (int i = 0; i < n; i++) {         cin >> aa[i];         p[i] = aa[i];       }       int x, a, y, b;       cin >> x >> a >> y >> b;       long long k;       cin >> k;       sort(p, p + n, greater<long long>());       int l = 1;       int h = n;       int ans = -1;       while (l <= h) {         int m = l + (h - l) / 2;         if (is_possible(m, k, p, n, x, a, y, b)) {           ans = m;           h = m - 1;         } else {           l = m + 1;         }       }       cout << ans << endl;     }   }