malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, sd, i, j, top, s, ans[100005], pos[100005], a[100005];   bitset<100005> f[62], g[62];   void read(long long &p) {     p = 0;     char x = getchar();     while (x <  0  || x >  9 ) x = getchar();     while (x >=  0  && x <=  9 ) {       p = p * 10 + x -  0 ;       x = getchar();     }   }   int main() {     read(n);     for (i = 1; i <= n; ++i) {       read(a[i]);       s ^= a[i];       for (j = 0; j <= 60; ++j)         if ((a[i] >> j) & 1) f[j][i] = 1;     }     for (sd = 0; sd <= 1; ++sd)       for (i = 60; i >= 0; --i)         if (((s >> i) & 1) == sd) {           top++;           g[top] = f[i];           g[top][n + 1] = (!sd);           for (j = 1; j <= top - 1; ++j)             if (g[top][pos[j]]) g[top] ^= g[j];           pos[top] = n + 2;           for (j = 1; j <= n; ++j)             if (g[top][j]) {               pos[top] = j;               break;             }           if (pos[top] > n) {             top--;             continue;           }           for (j = 1; j <= top - 1; ++j)             if (g[j][pos[top]]) g[j] ^= g[top];         }     for (i = 1; i <= top; ++i)       if (g[i][n + 1]) ans[pos[i]] = 1;     for (i = 1; i <= n; ++i) {       if (ans[i])         putchar( 1 );       else         putchar( 2 );       if (i == n)         putchar(  n );       else         putchar(   );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   void solve() {     long long p, q;     cin >> p >> q;     long long g = p;     long long t = q;     map<long long, long long> f, l;     for (long long i = 2; i * i <= t; i++) {       if (t % i == 0) {         while (g % i == 0) {           g /= i;           f[i]++;         }         while (t % i == 0) {           t /= i;           l[i]++;         }       }     }     if (t != 1) {       while (g % t == 0) {         g /= t;         f[t]++;       }       l[t]++;       t = 1;     }     long long ans = g;     for (auto x : l) {       long long u = p;       for (int i = 0; i < max(0ll, f[x.first] - x.second + 1); i++) u /= x.first;       ans = max(ans, u);     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int q = 1;     cin >> q;     for (; q > 0; q--) {       solve();       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename Kausi>   void debug(vector<Kausi> v) {     cerr <<  v = [  ;     long long n = v.size();     for (int i = 0; i < n; i++) {       cerr << v[i];       if (i < n - 1) cerr <<  ,  ;     }     cerr <<   ] length =   << v.size() <<   n ;   }   long long stringToLong(string s) {     stringstream raaz(s);     long long x = 0;     raaz >> x;     return x;   }   string longToString(long long k) {     stringstream ss;     ss << k;     string s;     ss >> s;     return s;   }   bool isPowerOfTwo(int n) {     if (n == 0) return false;     return (ceil(log2(n)) == floor(log2(n)));   }   void scanArr(int *arr, int n) {     for (int i = 0; i < n; i++) cin >> arr[i];   }   void printArr(int *arr, int n) {     for (int i = 0; i < n; i++) cout << arr[i] <<    ;     cout <<   n ;   }   template <typename Kausi>   void scanVector(vector<Kausi> &v, int n) {     for (int i = 0; i < n; i++) {       Kausi temp;       cin >> temp;       v.push_back(temp);     }   }   template <typename Kausi>   void printVector(vector<Kausi> v) {     for (auto x : v) cout << x <<    ;     cout <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<vector<char>> v(n, vector<char>(n,  = ));       string s;       cin >> s;       for (int i = 0; i < n; i++) v[i][i] =  X ;       bool ans = true;       for (int i = 0; i < n; i++) {         if (s[i] ==  2 ) {           bool flg = true;           for (int j = 0; j < n; j++) {             if (j != i) {               if (v[i][j] ==  =  and v[j][i] ==  =  and s[j] !=  1 ) {                 v[i][j] =  + ;                 v[j][i] =  - ;                 flg = false;                 break;               }             }           }           if (flg) {             cout <<  NO                   <<   n ;             ans = false;             break;           }         }       }       if (ans) {         cout <<  YES               <<   n ;         for (int i = 0; i < n; i++) {           for (int j = 0; j < n; j++) cout << v[i][j];           cout <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long d, k, a, b, t;   void solve() {     cin >> d >> k >> a >> b >> t;     if (d <= k) {       cout << d * a;       return;     }     long long ans = k * a + d * b - k * b;     long long mult = t + k * a - k * b;     if (mult >= 0) {       cerr << 1 <<   n ;       cout << ans;     } else {       mult = abs(mult);       long long low = 0;       long long high = d / k - 1;       long long n = ans / mult;       long long ans2 =           min(d * b, d * a + (long long)ceil(((double)d) / k - 1) * t);       if (n >= low && n <= high) {         cout << min(ans2, ans - n * mult);       } else if (n > high) {         cout << min(ans2, ans - high * mult);       } else         cout << min(ans2, ans);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &x) {     x = 0;     bool f = 0;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = 1;     for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);     if (f) x = -x;   }   template <typename F>   inline void write(F x, char ed =   n ) {     static short st[30];     short tp = 0;     if (x < 0) putchar( - ), x = -x;     do st[++tp] = x % 10, x /= 10;     while (x);     while (tp) putchar( 0  | st[tp--]);     putchar(ed);   }   template <typename T>   inline void Mx(T &x, T y) {     x < y && (x = y);   }   template <typename T>   inline void Mn(T &x, T y) {     x > y && (x = y);   }   const long long inf = 1ll << 60;   const int N = 200050;   long long ans[N][3], q;   set<long long> s;   long long a[N], bit[N], n;   inline bool oper(long long x, long long y, bool op) {     if (x + y >= inf) return 0;     long long t = op ? (x ^ y) : (x + y);     if (s.find(t) != s.end()) return 0;     s.insert(t);     a[++n] = t;     ans[++q][0] = x, ans[q][1] = y, ans[q][2] = op;     return 1;   }   bool chk(long long x) {     for (int i = 60; i >= 0; i--) {       if (x >> i & 1) {         if (bit[i])           x ^= bit[i];         else           return 1;       }     }     return 0;   }   void insert(long long x) {     for (int i = 60; i >= 0; i--) {       if (x >> i & 1) {         if (bit[i])           oper(bit[i], x, 1), x ^= bit[i];         else {           bit[i] = x;           break;         }       }     }   }   int main() {     srand((long long)new char);     read(a[1]), s.insert(a[1]), insert(a[1]), n = 1;     for (int i = 2; i <= 20; i++)       if (oper(a[n], a[n], 0) && chk(a[n])) insert(a[n]);     while (s.find(1) == s.end()) {       int x = rand() % n + 1, y = rand() % n + 1;       if (oper(a[x], a[y], 0) && chk(a[n])) insert(a[n]);     }     write(q);     for (int i = 1; i <= q; i++)       write(ans[i][0],    ), putchar(ans[i][2] ?  ^  :  + ), putchar(   ),           write(ans[i][1]);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( -Ofast ,  -funroll-all-loops )   using namespace std;   const int N = 5e3 + 10;   int n, m, k, deg[N], dp[N][N], res, pre[N][N];   int head[N], nex[N], to[N], w[N], tot;   inline void add(int a, int b, int c) {     to[++tot] = b;     nex[tot] = head[a];     w[tot] = c;     head[a] = tot;   }   void Top() {     queue<int> q;     dp[1][1] = 0;     for (int i = 1; i <= n; i++)       if (!deg[i]) q.push(i);     while (q.size()) {       int u = q.front();       q.pop();       for (int i = head[u]; i; i = nex[i]) {         if (--deg[to[i]] == 0) q.push(to[i]);         for (int j = 1; j <= n; j++)           if (dp[u][j] + w[i] < dp[to[i]][j + 1]) {             dp[to[i]][j + 1] = dp[u][j] + w[i];             pre[to[i]][j + 1] = u;           }       }     }   }   void dfs(int x, int y) {     if (x && y) dfs(pre[x][y], y - 1);     if (x) printf( %d  , x);   }   signed main() {     cin >> n >> m >> k;     memset(dp, 0x3f, sizeof dp);     for (int i = 1, a, b, c; i <= m; i++)       cin >> a >> b >> c, add(a, b, c), deg[b]++;     Top();     for (int i = 1; i <= n; i++)       if (dp[n][i] <= k) res = i;     cout << res <<   n ;     dfs(n, res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s1[10], s2[10], name[10], score[10];   map<string, int> mp;   int a[10][10];   bool better(int x, int y) {     int i;     int px = 0, py = 0, mx = 0, sx = 0, sy = 0, my = 0;     for (i = 0; i < 4; i++) {       if (i != x) {         if (a[x][i] > a[i][x])           sx += 3;         else if (a[x][i] == a[i][x])           sx++;         px += a[x][i];         mx += a[i][x];       }     }     for (i = 0; i < 4; i++) {       if (i != y) {         if (a[y][i] > a[i][y])           sy += 3;         else if (a[y][i] == a[i][y])           sy++;         my += a[i][y];         py += a[y][i];       }     }     if (sx != sy) return (sx > sy);     if (px - mx != py - my) return (px - mx > py - my);     if (px != py) return (px > py);     return (x < y);   }   bool check(int x, int y) {     int i, c;     int b = mp[ BERLAND ];     for (i = 0; i < 4; i++)       if (i != b && a[b][i] == -1) c = i;     a[b][c] = x;     a[c][b] = y;     int rank = 1;     for (i = 0; i < 4; i++) {       if (i != b && better(i, b)) rank++;     }     a[b][c] = a[c][b] = -1;     return (rank <= 2);   }   int main() {     int d, i, j;     for (i = 0; i < 5; i++) cin >> s1[i] >> s2[i] >> score[i];     for (i = 0; i < 5; i++) mp[s1[i]] = mp[s2[i]] = 0;     i = 0;     for (__typeof((mp).begin()) itr = (mp).begin(); itr != (mp).end(); itr++) {       (itr->second) = i;       name[i] = (itr->first);       i++;     }     for (i = 0; i < 4; i++)       for (j = 0; j < 4; j++) a[i][j] = -1;     for (i = 0; i < 5; i++) {       int x = mp[s1[i]], y = mp[s2[i]];       for (j = 0; j < score[i].length(); j++)         if (score[i][j] ==  : ) score[i][j] =    ;       istringstream ss(score[i]);       ss >> a[x][y] >> a[y][x];     }     for (d = 1; d < 100; d++)       for (i = 0; i < 100; i++) {         j = i + d;         if (check(j, i)) {           cout << j <<  :  << i << endl;           return 0;         }       }     cout <<  IMPOSSIBLE  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   uint64_t getSeed() {     auto ptr = new char;     delete ptr;     return (uint64_t)ptr +            chrono::high_resolution_clock::now().time_since_epoch().count();   }   mt19937 rnd(getSeed());   ll rndVal(uint64_t a, uint64_t b) {     return uniform_int_distribution<uint64_t>(a, b)(rnd);   }   constexpr uint64_t MOD = (1ull << 61) - 1;   inline uint64_t mod(uint64_t x) {     x++;     x = (x & MOD) + (x >> 61);     x = (x & MOD) + (x >> 61);     return x - 1;   }   uint64_t mulmod(const uint64_t a, const uint64_t b) {     uint64_t ha = a >> 32, la = uint32_t(a), hb = b >> 32, lb = uint32_t(b);     uint64_t h = ha * hb, m = ha * lb + la * hb, l = la * lb;     return mod((l & MOD) + (l >> 61) + (m >> 29) + (m << 35 >> 3) + (h << 3));   }   struct Hash {     vector<uint64_t> h;     vector<uint64_t> p;     void build(const string& s, const uint64_t base) {       int n = s.size();       h.resize(n + 1);       p.resize(n + 1);       h[0] = 1;       p[0] = 1;       for (int i = 0; i < n; i++) {         h[i + 1] = mod(mulmod(h[i], base) + s[i] + 130);         p[i + 1] = mulmod(p[i], base);       }     }     void build(const string& s) { build(s, rndVal(258, MOD - 1)); }     uint64_t query(int l, int r) {       return mod(h[r + 1] + MOD - mulmod(h[l], p[r - l + 1]));     }   };   string s, t;   int main() {     ios::sync_with_stdio(false);     cin >> s >> t;     int ns = s.size(), nt = t.size();     uint64_t base = rndVal(258, MOD - 1);     Hash hash;     hash.build(t, base);     int rep = 0;     for (int i = 0; i < nt - 1; i++) {       if (hash.query(0, i) == hash.query(nt - i - 1, nt - 1)) rep = i + 1;     }     int has[2] = {0, 0};     for (auto c : s) has[c -  0 ]++;     int needs[2] = {0, 0};     for (auto c : t) needs[c -  0 ]++;     if (needs[0] > has[0] or needs[1] > has[1]) {       cout << s << endl;       return 0;     }     cout << t;     has[0] -= needs[0];     has[1] -= needs[1];     for (int i = 0; i < rep; i++) needs[t[i] -  0 ]--;     while (has[0] >= needs[0] and has[1] >= needs[1]) {       for (int i = rep; i < nt; i++) {         cout << t[i];         has[t[i] -  0 ]--;       }     }     while (has[0]) {       cout <<  0 ;       has[0]--;     }     while (has[1]) {       cout <<  1 ;       has[1]--;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T gcd(T a, T b) {     if (a < 0) return gcd(-a, b);     if (b < 0) return gcd(a, -b);     return (b == 0) ? a : gcd(b, a % b);   }   const double EPS = 1e-10;   const double PI = acos(-1.0);   const int INF = 1 << 30;   const int mod = 1000000007;   const int maxm = 1 + 5;   const int maxn = 1000000 + 5;   char cat[4][100000];   char s[4][100000];   int n, k;   bool bj;   bool fit(char ch) {     if (ch ==  a  || ch ==  e  || ch ==  i  || ch ==  u  || ch ==  o )       return true;     return false;   }   void fun(int x) {     int len = strlen(s[x]);     int kk = 0, start = -1;     for (int i = len - 1; i >= 0; i--) {       if (fit(s[x][i])) kk++;       if (kk == k) {         start = i;         break;       }     }     if (kk != k)       bj = false;     else       bj = true;     for (int i = start; bj && i < len; i++) {       cat[x][i - start] = s[x][i];     }     if (bj) cat[x][len - start] =   0 ;   }   bool same(int i, int j) {     if (strcmp(cat[i], cat[j]) == 0) return true;     return false;   }   int cmp() {     if (bj == false) return -1;     if (same(0, 1) && same(1, 2) && same(2, 3)) return 0;     if (same(0, 1) && same(2, 3)) return 1;     if (same(0, 2) && same(1, 3)) return 2;     if (same(0, 3) && same(1, 2)) return 3;     return -1;   }   int main() {     int ans = -2;     scanf( %d %d , &n, &k);     for (int i = (0), _b(n); i < _b; ++i) {       for (int j = (0), _b(4); j < _b; ++j) {         scanf( %s , s[j]);         fun(j);       }       int p = cmp();       if (ans == -1)         continue;       else if (ans == -2)         ans = p;       else if (ans == 0)         ans = p;       else {         if (p == 0)           continue;         else if (ans != p)           ans = -1;       }     }     if (ans == -1)       cout <<  NO  << endl;     else if (ans == 0)       cout <<  aaaa  << endl;     else if (ans == 1)       cout <<  aabb  << endl;     else if (ans == 2)       cout <<  abab  << endl;     else if (ans == 3)       cout <<  abba  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int r, x1, y1, x2, y2;     cin >> r >> x1 >> y1 >> x2 >> y2;     long long int xd = x2 - x1, yd = y2 - y1;     double dist = sqrt(xd * xd + yd * yd);     long long int int_part = (int)dist;     double frac_part = dist - int_part;     long long int ans;     ans = int_part / (2 * r);     if (int_part % (2 * r) == 0 && frac_part == 0) ans--;     ans++;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int toInt(string s) {     int r = 0;     istringstream sin(s);     sin >> r;     return r;   }   long long toInt64(string s) {     long long r = 0;     istringstream sin(s);     sin >> r;     return r;   }   double toDouble(string s) {     double r = 0;     istringstream sin(s);     sin >> r;     return r;   }   string toString(long long n) {     string s, s1;     while (n / 10 > 0) {       s += (char)((n % 10) + 48);       n /= 10;     }     s += (char)((n % 10) + 48);     n /= 10;     s1 = s;     for (long long i = 0; i < s.length(); i++) s1[(s.length() - 1) - i] = s[i];     return s1;   }   bool isUpperCase(char c) { return c >=  A  && c <=  Z ; }   bool isLowerCase(char c) { return c >=  a  && c <=  z ; }   bool isLetter(char c) { return c >=  A  && c <=  Z  || c >=  a  && c <=  z ; }   bool isDigit(char c) { return c >=  0  && c <=  9 ; }   char toLowerCase(char c) { return (isUpperCase(c)) ? (c + 32) : c; }   char toUpperCase(char c) { return (isLowerCase(c)) ? (c - 32) : c; }   int main() {     ios::sync_with_stdio(0);     int n;     cin >> n;     long long count = 1;     int a = 12;     for (long long i = 0; i < n - 1; i++) {       count += a;       a += 12;     }     cout << count << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long int n, x, count = 0, sum = 0;       cin >> n >> x;       long long int a[n];       for (int i = 0; i < n; i++) {         cin >> a[i];         sum = sum + a[i];       }       sort(a, a + n);       int k = n, m;       for (int i = 0; i < n; i++) {         if (sum / k < x) {           m = 1;           sum = sum - a[i];           k--;         } else {           m = 0;           cout << k << endl;           break;         }       }       if (m) cout << 0 << endl;     }   }
#include <bits/stdc++.h>   const int N = 100005;   long long a[N], s[N];   long long max;   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %I64d , &a[i]);     }     std::sort(a + 1, a + n + 1);     for (int i = 1; i <= n; i++) {       s[i] = s[i - 1] + a[i];       max += s[i];     }     int m, k;     scanf( %d , &m);     for (int i = 0; i < m; i++) {       scanf( %d , &k);       if (i) putchar(   );       if (k == 1)         printf( %I64d n , max - s[n]);       else {         long long ans = 0, t = n - 1, d = 1;         while (t >= 0) {           ans += s[t];           d *= k;           t -= d;         }         printf( %I64d , ans);       }     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n, i;     cin >> n;     vector<long long int> a(n), mini(n);     for (i = 0; i < (n); i++) cin >> a[i];     mini[n - 1] = a[n - 1];     for (i = n - 2; i >= 0; i--) {       mini[i] = min(mini[i + 1], a[i]);     }     for (i = 0; i < n; i++) {       long long int l = i, r = n - 1;       long long int ans = -1;       while (l <= r) {         long long int m = l + (r - l) / 2;         if (mini[m] < a[i]) {           l = m + 1;           ans = m;         } else           r = m - 1;       }       if (ans == -1)         cout << -1 <<    ;       else         cout << ans - i - 1 <<    ;     }     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d;   int a[105];   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> d;     for (int i = 0; i < n; i++) cin >> a[i];     int dp[n][n];     sort(a, a + n);     for (int i = 0; i < n; i++) {       for (int j = i; j < n; j++) dp[i][j] = a[j] - a[i];     }     int ans = 0;     for (int i = 0; i < n; i++) {       for (int j = i; j < n; j++) {         if (dp[i][j] <= d) ans = max(ans, j - i + 1);       }     }     cout << n - ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, ll>;   int n, m;   vector<pii> coupons;   bool comp(pii a, pii b) { return a.second > b.second; }   ll getlen(ll x) {     if (x % 2 == 1) return x * (x - 1) / 2 + 1;     return x * (x - 1) / 2 + x / 2;   }   int main() {     cin >> n >> m;     ll low = 0, high = n;     while (low < high) {       ll mid = (low + high + 1) / 2;       if (getlen(mid) <= n) {         low = mid;       } else {         high = mid - 1;       }     }     for (int i = 0; i < m; i++) {       ll q, w;       cin >> q >> w;       coupons.push_back({q, w});     }     sort(coupons.begin(), coupons.end(), comp);     ll ans = 0;     for (int i = 0; i < low && i < m; i++) {       ans += coupons[i].second;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int MOD = 1e9 + 7;   string ans =        What are you doing at the end of the world? Are you busy? Will you save          us? ;   string a =  What are you doing while sending   ;   string b =   ? Are you busy? Will you send   ;   string c =   ? ;   vector<long long int> dp(N, 1e18 + 1);   char get(long long int n, long long int k) {     if (k >= dp[n]) return  . ;     if (n == 0) return ans[k];     if (k < a.size()) return a[k];     if (k < a.size() + dp[n - 1]) return get(n - 1, k - a.size());     if (k < a.size() + dp[n - 1] + b.size()) return b[k - a.size() - dp[n - 1]];     if (k < a.size() + dp[n - 1] + b.size() + dp[n - 1])       return get(n - 1, k - a.size() - dp[n - 1] - b.size());     if (k < a.size() + dp[n - 1] + b.size() + dp[n - 1] + c.size())       return c[k - a.size() - dp[n - 1] - b.size() - dp[n - 1]];     return  . ;   }   void solve() {     dp[0] = ans.size();     for (int i = 1; i < 60; ++i) {       long long int k = (2 * dp[i - 1]) + a.size() + b.size() + c.size();       dp[i] = min(k, (long long int)1e18 + 1);     }     int q;     cin >> q;     while (q--) {       long long int n, k;       cin >> n >> k;       cout << get(n, k - 1);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n, m;     cin >> n >> m;     if (m > n)       cout << -1;     else if (m == n)       cout << n;     else {       long long int x, y;       for (y = (n / 2); y >= 0; y--) {         if (n - y >= 0) {           x = n - 2 * y;           if ((x + y) % m == 0) {             cout << x + y;             break;           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 55;   int n, m;   int sz, inp;   long long ans[N];   long long sum[N];   long long suf[N];   long long pre[N];   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; ++i) {       scanf( %d , &sz);       ans[i] = pre[i] = -1e9;       while (sz--) {         scanf( %d , &inp);         sum[i] += inp;         suf[i] = max(0LL, suf[i]) + inp;         ans[i] = max(ans[i], suf[i]);         pre[i] = max(pre[i], sum[i]);       }     }     ans[0] = -1e15;     while (m--) {       scanf( %d , &inp);       ans[0] = max(ans[0], max(0LL, ans[n + 1]) + pre[inp]);       ans[n + 1] = max(suf[inp], sum[inp] + max(0LL, ans[n + 1]));       ans[0] = max(ans[0], max(ans[inp], ans[n + 1]));     }     printf( %lld n , ans[0]);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double eps = 1e-8;   const int mod = 1e9 + 7;   const int P = 1e9 + 7;   const int N = 2e7;   const int maxn = 1e6 + 5;   long long t, a, b, x, y, n, minn;   int main() {     ios::sync_with_stdio(false);     cin >> t;     while (t--) {       cin >> a >> b >> x >> y >> n;       long long temp1 = max(x, a - n);       long long temp2 = max(y, b - n);       if (temp1 >= temp2) {         swap(a, b);         swap(x, y);       }       minn = min(n, a - x);       n -= minn;       a -= minn;       minn = min(n, b - y);       b -= minn;       cout << a * b << endl;     }   }