malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, k, d;     scanf( %d%d%d , &n, &k, &d);     vector<int> v(n);     for (int &x : v) {       scanf( %d , &x);     }     map<int, int> m_map;     int mn = 0, cnt = 0;     for (int i = 0; i < d; i++) {       if (m_map[v[i]] == 0) {         cnt++;       }       m_map[v[i]]++;     }     mn = cnt;     for (int i = d; i < n; i++) {       m_map[v[i - d]]--;       if (m_map[v[i - d]] == 0) cnt--;       if (m_map[v[i]] == 0) cnt++;       m_map[v[i]]++;       mn = min(mn, cnt);     }     printf( %d n , mn);   }   int main() {     int testcase;     scanf( %d , &testcase);     for (int i = 1; i <= testcase; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>      #define ll long long      using namespace std;      int t;      int main() {       ios_base::sync_with_stdio(false);       cin.tie(0);       cout.tie(0);       cin >> t;       while (t--) {           int n;           cin >> n;           vector<pair<int, int> > a(n + 1);           for (int i = 1; i <= n; i++) {               cin >> a[i].first;               a[i].second = i;           }           sort(a.begin() + 1, a.end());           if (a[1].first == a[2].first) {               cout << a[n].second << endl;           } else {               cout << a[1].second << endl;           }       }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k;     string s;     map<char, int> m1;     cin >> k >> s;     int n = s.length();     for (int i = 0; i < n; i++) {       m1[s[i]]++;     }     map<char, int>::iterator it;     int flag = 0;     for (it = m1.begin(); it != m1.end(); it++) {       if ((it->second) % k) {         flag = 1;         break;       }     }     if (flag) {       cout <<  -1 ;     } else {       it = m1.begin();       int val = k;       string s1 =   ;       for (it = m1.begin(); it != m1.end(); it++) {         int num = (it->second) / k;         while (num--) s1 += it->first;       }       while (k--) cout << s1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string dp[5001];   vector<int> win[2001];   int n;   string pow2[2001];   void multi2(string &ress, const string &p) {     int flag = 0;     ress =   ;     for (int i = 0; i < p.size(); i++) {       ress += ((p[i] -  0 ) * 2 + flag) % 10 +  0 ;       flag = ((p[i] -  0 ) * 2 + flag) / 10;     }     if (flag) ress +=  1 ;     int pos = ress.size() - 1;     for (; pos >= 0 && ress[pos] ==  0 ; pos--)       ;     ress = ress.substr(0, pos + 1);     if (ress ==   ) ress =  0 ;     return;   }   void initPow2(void) {     pow2[0] =  1 ;     for (int i = 1; i <= 2000; i++) multi2(pow2[i], pow2[i - 1]);     return;   }   void add(string &ress, string num) {     while (ress.size() < num.size()) ress +=  0 ;     while (num.size() < ress.size()) num +=  0 ;     int flag = 0;     for (int i = 0; i < ress.size(); i++) {       char tRes = (ress[i] -  0  + num[i] -  0  + flag) % 10 +  0 ;       flag = (ress[i] -  0  + num[i] -  0  + flag) / 10;       ress[i] = tRes;     }     if (flag) ress +=  1 ;     int pos = ress.size() - 1;     for (; pos >= 0 && ress[pos] ==  0 ; pos--)       ;     ress = ress.substr(0, pos + 1);     if (ress ==   ) ress =  0 ;     return;   }   bool larger(const string &str1, const string &str2) {     if (str1.size() > str2.size()) return true;     if (str1.size() < str2.size()) return false;     for (int i = str1.size() - 1; i >= 0; i--) {       if (str1[i] > str2[i]) return true;       if (str1[i] < str2[i]) return false;     }     return false;   }   int main(void) {     char enter;     char input[10];     int t;     dp[0] =  0 ;     initPow2();     for (int i = 0; i <= 2000; i++) win[i].clear();     scanf( %d%c , &n, &enter);     for (int i = 1; i <= n; i++) {       scanf( %s%c%d%c , input, &enter, &t, &enter);       if (input[0] ==  w ) {         win[t].push_back(i);         dp[i] = dp[i - 1];       } else {         dp[i] = dp[i - 1];         if (win[t].size() != 0) {           for (int j = 0; j < win[t].size(); j++) {             string temp = pow2[t];             add(temp, dp[win[t][j] - 1]);             if (larger(temp, dp[i])) dp[i] = temp;           }         }       }     }     reverse(dp[n].begin(), dp[n].end());     printf( %s n , dp[n].c_str());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s, ans;   int ar[5005];   int cnt[5005];   int ar2[5005];   vector<pair<pair<int, int>, pair<int, int> > > v;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) ar[i] = 1000000000;     for (int i = 0; i < m; i++) {       int t, l, r, x;       scanf( %d%d%d%d , &t, &l, &r, &x);       if (t == 1)         for (int j = l; j <= r; j++) cnt[j] += x;       else {         for (int j = l; j <= r; j++) ar[j] = min(ar[j], x - cnt[j]);       }       v.push_back(pair<pair<int, int>, pair<int, int> >(pair<int, int>(t, x),                                                         pair<int, int>(l, r)));     }     for (int i = 1; i <= n; i++)       if (max(ar[i], -ar[i]) > 1000000000) {         printf( NO n );         exit(0);       }     for (int i = 1; i <= n; i++) ar2[i] = ar[i];     for (int i = 0; i < m; i++) {       int t = v[i].first.first;       int x = v[i].first.second;       int l = v[i].second.first;       int r = v[i].second.second;       if (t == 1) {         for (int j = l; j <= r; j++) ar2[j] += x;       } else {         int mx = -1000000000;         for (int j = l; j <= r; j++) mx = max(mx, ar2[j]);         if (mx != x) {           printf( NO n );           exit(0);         }       }     }     printf( YES n );     for (int i = 1; i <= n; i++) printf( %d  , ar[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int pot(int n) {     if (n == (n & -n)) return n;     return (n - (n & -n));   }   int main() {     int n, b, p;     cin >> n >> b >> p;     int ans1 = 0, ans2 = p * n;     while (n != 1) {       int d = pot(n);       int e = n - d;       n -= (d / 2);       ans1 += (d * b + (d / 2));     }     cout << ans1 <<     << ans2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     char name[21];     int initials[26];     cin >> n;     memset(initials, 0, 26 * sizeof(int));     for (int i = 0; i < n; ++i) {       cin >> name;       initials[name[0] -  a ]++;     }     int total = 0;     for (int i = 0; i < 26; ++i) {       int k = initials[i];       if (k % 2)         total += ((k - 1) / 2) * ((k - 1) / 2);       else         total += k / 2 * (k / 2 - 1);     }     cout << total << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   long long ans, dp[N];   int ed, n, m;   struct node {     int w, c;     double val;     node(int a = 0, int b = 0) : w(a), c(b) {}     bool operator<(const node &b) const { return val > b.val; }   } a[N], tmp[N];   long long DP() {     for (int i = 1; i <= ed; i++) {       for (int j = m; j >= tmp[i].w; j--) {         dp[j] = max(dp[j], dp[j - tmp[i].w] + tmp[i].c);       }     }     return dp[m];   }   int main() {     scanf( %d%d , &n, &m);     ans = 0;     for (int i = 1; i <= n; i++)       scanf( %d%d , &a[i].w, &a[i].c), a[i].val = 1.0 * a[i].c / a[i].w;     sort(a + 1, a + 1 + n);     int tp[4];     memset(tp, -1, sizeof(tp));     for (int i = 1; i <= n; i++) {       if (m < 30) {         ed = 0;         while (i <= n) tmp[++ed] = a[i], i++;         for (int ii = 1; ii <= 3; ii++)           if (~tp[ii]) tmp[++ed] = node(ii, tp[ii]), m += ii, ans -= tp[ii];         ans += DP();         break;       }       ans += a[i].c;       m -= a[i].w;       tp[a[i].w] = a[i].c;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   template <class T>   inline T biton(T n, T pos) {     return n | ((T)1 << pos);   }   template <class T>   inline T bitoff(T n, T pos) {     return n & ~((T)1 << pos);   }   template <class T>   inline T ison(T n, T pos) {     return (bool)(n & ((T)1 << pos));   }   template <class T>   inline T gcd(T a, T b) {     while (b) {       a = a % b;       swap(a, b);     }     return a;   }   template <class T>   inline T bigmod(T p, T e, T m) {     T ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % m;       p = (p * p) % m;     }     return (T)ret;   };   void solve() {     string s, c;     cin >> s >> c;     if (s < c) {       cout << s << endl;       return;     }     int n = (int)s.size();     map<char, vector<int>> mn;     map<char, set<char>> st;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (s[i] >= s[j]) {           if (st[s[i]].count(s[j]) == 0) {             mn[s[i]].push_back({j});             st[s[i]].insert(s[j]);           }         }       }     }     for (int i = 0; i < n; i++) {       for (auto m : mn) {         for (auto j : m.second) {           swap(s[i], s[j]);           if (s < c) {             cout << s << endl;             return;           }           swap(s[i], s[j]);         }       }     }     cout <<  ---  << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cout.setf(ios::fixed);     cout.precision(10);     cout.tie(nullptr);     cin.tie(nullptr);     int t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t;     cin >> s;     for (int i = s.length() - 1; i >= 0; i--) {       if (t ==   ) {         t.push_back(s[i]);       } else if (t.back() <= s[i]) {         t.push_back(s[i]);       }     }     reverse(t.begin(), t.end());     cout << t;   }
#include <bits/stdc++.h>   using namespace std;   const int h = 17, N = 1 << h;   long long t[2 * N];   long long k;   long long product(int a, int b) {     if (a > b) return 1;     if (a % 2 == 1) return (t[a] * product(a + 1, b)) % k;     if (b % 2 == 0) return (t[b] * product(a, b - 1)) % k;     return product(a / 2, b / 2);   }   int main() {     int n;     scanf( %d%lld , &n, &k);     for (int i = 1; i < 2 * N; ++i) t[i] = 1;     for (int i = 0; i < n; ++i) {       scanf( %lld , &t[N + i]);       t[N + i] = t[N + i] % k;     }     for (int i = N - 1; i >= 1; --i) t[i] = (t[2 * i] * t[2 * i + 1]) % k;     long long m = 0;     for (int i = 0; i < n; ++i) {       int lo = i, hi = n - 1;       while (lo < hi) {         int mid = lo + (hi - lo) / 2;         if (product(N + i, N + mid) == 0)           hi = mid;         else           lo = mid + 1;       }       if (lo >= n || product(N + i, N + lo) != 0) break;       m += static_cast<long long>(n) - lo;     }     printf( %lld n , m);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10, mod = 1e9 + 7;   int head[N], nxt[N << 1], to[N << 1], num = 0, n, b[N], fa[N], q[N], DFN = 0,                                         k[N], in[N];   inline void link(int x, int y) {     nxt[++num] = head[x];     to[num] = y;     head[x] = num;   }   inline int qm(int x, int k) {     int sum = 1;     while (k) {       if (k & 1) sum = 1ll * sum * x % mod;       x = 1ll * x * x % mod;       k >>= 1;     }     return sum;   }   inline int inv(int x) { return qm(x, mod - 2); }   inline void dfs(int x, int last) {     q[++DFN] = x;     for (int i = head[x]; i; i = nxt[i])       if (to[i] != last) fa[to[i]] = x, dfs(to[i], x);   }   int main() {     int x, y, z;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d%d%d , &x, &y, &z);       x++;       y++;       link(x, y);       link(y, x);       k[x]++;       k[y]++;       b[x] += z;       b[y] += z;     }     for (int i = 1; i <= n; i++) in[i] = k[i];     dfs(1, 1);     for (int i = n; i >= 1; i--) {       int x = q[i];       if (in[x] == 1) continue;       k[fa[x]] = (k[fa[x]] - inv(k[x])) % mod;       b[fa[x]] = (b[fa[x]] + 1ll * inv(k[x]) * b[x]) % mod;     }     b[1] = 1ll * b[1] * inv(k[1]) % mod;     if (b[1] < 0) b[1] += mod;     printf( %d n , b[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, y;     cin >> n >> x >> y;     int a[n + 1];     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       int flag = 1;       for (int j = i - 1; j >= 1 && j >= i - x; j--) {         if (a[i] > a[j]) {           flag = 0;           break;         }       }       for (int j = i + 1; j <= n && j <= i + y; j++) {         if (a[i] > a[j]) {           flag = 0;           break;         }       }       if (flag == 1) {         cout << i << endl;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using pr = pair<int, int>;   using prll = pair<long, long>;   using V = vector<int>;   using Vll = vector<long long>;   template <typename T, typename TT>   pr operator+(pair<T, TT> a, pair<T, TT> b) {     return {a.first + b.first, a.second + b.second};   }   template <typename T, typename TT>   ostream& operator<<(ostream& s, pair<T, TT> t) {     return s <<  (  << t.first <<  ,  << t.second <<  ) ;   }   template <typename T>   ostream& operator<<(ostream& s, vector<T> t) {     for (auto itr : t) s << itr <<    ;     return s;   }   int n, m;   vector<pair<int, int>> a(200000);   vector<long long> c(100000);   int binSearch(int x) {     int beg = 0;     int last = m - 1;     while (beg < last) {       int mid = beg + (last - beg + 1) / 2;       if (a[mid].first < x)         last = mid - 1;       else         beg = mid;     }     if (a[beg].first < x) return -1;     return beg;   }   bool cmp(pr a, pr b) {     if (a.first == b.first) return a.second > b.second;     return a.first > b.first;   }   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(0);     cout.tie(0);     int T;     cin >> T;     while (T--) {       cin >> n >> m;       for (int i = 0; i < int(m); i++) {         int x, y;         cin >> x >> y;         a[i] = {x, y};       }       sort(a.begin(), a.begin() + m, cmp);       c[0] = a[0].first;       for (int i = 0; i < int(m - 1); i++) c[i + 1] = c[i] + a[i + 1].first;       ll ans = INT_MIN;       ans = c[min(n, m) - 1];       for (int i = 0; i < int(m); i++) {         int beg = binSearch(a[i].second);         int t = min(beg, n - 3);         if (beg >= i) t = min(beg, n - 2);         if (t < 0)           ans = max(ans, a[i].first + (n - 1) * 1LL * a[i].second);         else if (t >= i)           ans = max(ans, c[t] + (n - t - 1) * 1LL * a[i].second);         else           ans = max(ans, c[t] + (n - t - 2) * 1LL * a[i].second + a[i].first);       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, Q, ans[100005], t[265000];   vector<int> v[100005];   vector<pair<int, int> > vq[100005];   void build(int k, int l, int r) {     t[k] = 1e9;     if (l == r) return;     int mid = (l + r) / 2;     build(k * 2, l, mid);     build(k * 2 + 1, mid + 1, r);   }   void pushdown(int k) {     t[k * 2] = min(t[k * 2], t[k]);     t[k * 2 + 1] = min(t[k * 2 + 1], t[k]);   }   void change(int k, int l, int r, int x, int y, int v) {     if (t[k] <= v) return;     if (l == x && r == y) {       t[k] = v;       return;     }     int mid = (l + r) / 2;     pushdown(k);     if (y <= mid)       change(k * 2, l, mid, x, y, v);     else if (x > mid)       change(k * 2 + 1, mid + 1, r, x, y, v);     else       change(k * 2, l, mid, x, mid, v),           change(k * 2 + 1, mid + 1, r, mid + 1, y, v);     t[k] = max(t[k * 2], t[k * 2 + 1]);   }   int ask(int k, int l, int r, int p, int v) {     if (t[k] <= v) return -1;     if (p <= l) {       for (; l < r;) {         int mid = (l + r) / 2;         pushdown(k);         k *= 2;         if (t[k] > v)           r = mid;         else           l = mid + 1, k++;       }       return l;     }     int mid = (l + r) / 2;     int tmp = -1;     if (p <= mid) tmp = ask(k * 2, l, mid, p, v);     if (tmp != -1) return tmp;     return ask(k * 2 + 1, mid + 1, r, p, v);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       if (x < y) v[x].push_back(y);     }     scanf( %d , &Q);     for (int i = 1; i <= Q; i++) {       int x, y;       scanf( %d%d , &x, &y);       vq[x].push_back(make_pair(y, i));     }     build(1, 1, n);     for (int i = n; i; i--) {       for (int j = 0; j < v[i].size(); j++)         change(1, 1, n, i, v[i][j] - 1, v[i][j]);       for (int j = 0; j < vq[i].size(); j++)         ans[vq[i][j].second] = ask(1, 1, n, i, vq[i][j].first);     }     for (int i = 1; i <= Q; i++) printf( %d n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   long long int n, m;   vector<long long int> ar[100001];   vector<long long int> res[2];   long long int vis[100001];   long long int col[100001];   bool dfs(long long int node, long long int c) {     vis[node] = 1;     res[c].push_back(node);     col[node] = c;     for (long long int child : ar[node]) {       if (vis[child] == 0) {         if (dfs(child, c ^ 1) == false) return false;       } else if (col[node] == col[child])         return false;     }     return true;   }   void solve() {     long long int test = 1;     while (test--) {       cin >> n >> m;       while (m--) {         long long int a, b;         cin >> a >> b;         ar[a].push_back(b);         ar[b].push_back(a);       }       long long int count = 1;       vector<long long int> von;       memset(vis, 0, sizeof(vis));       for (long long int i = 1; i <= n; i++) {         if (vis[i] == 0) {           if (ar[i].empty()) continue;           if (dfs(i, 0) == false) {             cout << -1 << endl;             return;           }         }       }       for (long long int i = 0; i < 2; i++) {         cout << res[i].size() << endl;         for (auto x : res[i]) cout << x <<    ;         cout << endl;       }     }     return;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     if (a == 0 || b == 0) return a + b;     if (a < b) return gcd(b % a, a);     return gcd(a % b, b);   }   int a[111];   int main() {     int n;     cin >> n;     int g = 0, max = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       g = gcd(g, a[i]);       if (max < a[i]) max = a[i];     }     for (int i = 0; i < n; i++) {       a[i] /= g;     }     max /= g;     int moves = max - n;     if (moves % 2)       cout <<  Alice ;     else       cout <<  Bob ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   vector<long long> p;   int main() {     int n, q;     cin >> n >> q;     string s;     cin >> s;     p.resize(1e5 + 1);     p[0] = 1;     for (int i = 1; i <= 1e5; i++) {       p[i] = (p[i - 1] * 2) % MOD;     }     vector<long long> kum(n + 1);     kum[0] = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  1 ) {         kum[i + 1] = kum[i] + 1;       } else {         kum[i + 1] = kum[i];       }     }     for (int i = 0; i < q; i++) {       int l, r;       cin >> l >> r;       long long kol_1 = kum[r] - kum[l - 1];       long long kol_0 = r - l + 1 - kol_1;       long long ans_1 = p[kol_1] - 1;       long long ans_0 = ans_1 * (p[kol_0] - 1);       cout << (ans_1 + ans_0) % MOD <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   priority_queue<int> a, b;   int c = 0;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       a.push(x);     }     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       b.push(x);     }     while (!b.empty() && !a.empty()) {       if (abs(a.top() - b.top()) < 2) {         c++;         a.pop();         b.pop();         continue;       }       if (a.top() > b.top())         a.pop();       else         b.pop();     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v;   int n, k;   bool check(long long m) {     long long sum = 0;     for (int i = n / 2; i < n; i++) {       sum += max(m - v[i], 0ll);     }     if (sum <= k) {       return true;     }     return false;   }   int main() {     cin >> n >> k;     v.resize(n);     for (int i = 0; i < n; i++) {       cin >> v[i];     }     sort(v.begin(), v.end());     long long l = v[n / 2];     long long r = 1e10;     while (l + 1 < r) {       long long m = (l + r) / 2;       if (check(m)) {         l = m;       } else {         r = m;       }     }     cout << l;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void reverseStr(string& str);   void reverseQueue(queue<int>& Queue);   void print_queue(queue<int>& q);   int n, a[250], sum, num;   int main() {     cin >> n;     for (int i = 0; i < n * 2; i++) cin >> a[i];     for (int i = 0; i < n * 2; i++) {       for (int j = i + 2; j < n * 2; j++) {         if (a[i] == a[j]) {           sum += j - i - 1;           for (int l = j; l > i; l--) {             swap(a[l], a[l - 1]);           }         }       }     }     cout << sum;   }   void reverseStr(string& str) {     int n = str.length();     for (int i = 0; i < n / 2; i++) swap(str[i], str[n - i - 1]);   }   void reverseQueue(queue<int>& Queue) {     stack<int> Stack;     while (!Queue.empty()) {       Stack.push(Queue.front());       Queue.pop();     }     while (!Stack.empty()) {       Queue.push(Stack.top());       Stack.pop();     }   }   void print_queue(queue<int>& q) {     while (!q.empty()) {       cout << q.front() <<    ;       q.pop();     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 1e5 + 7;   vector<long long> v[MX];   bool vis[MX];   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long n;     cin >> n;     pair<long long, long long> p[n];     for (long long i = 0; i < n; i++) cin >> p[i].first >> p[i].second;     long double l = 0, r = 1e10;     for (long long i = 0; i < 100; i++) {       long long cnt;       long double mid = (l + r) / 2, d = -1e20;       for (cnt = 0; cnt < n; cnt++) {         if (p[cnt].second > 0)           d = max(d, p[cnt].first + mid * p[cnt].second);         else if (p[cnt].first + mid * p[cnt].second <= d)           break;       }       if (cnt < n)         r = mid;       else         l = mid;     }     if (r == 1e10)       cout << -1;     else       cout << fixed << setprecision(18) << l;   }
#include <bits/stdc++.h>   using namespace std;   int t, ans, tot, pus, a, b, c, d;   int main() {     register int i;     scanf( %d , &t);     while (t--) {       scanf( %d%d%d%d , &a, &b, &c, &d);       ans = a * (b - d - 1);       ans = ((ans) > (a * d) ? (ans) : (a * d));       ans = ((ans) > (b * (a - c - 1)) ? (ans) : (b * (a - c - 1)));       ans = ((ans) > (b * c) ? (ans) : (b * c));       printf( %d n , ans);     }   }