malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m, y, Y, it = 1, x1[100001], x2[100001], d[100001], u[100001];   int dist(int x, int y) { return abs(x - y); }   int main() {     scanf( %d%d%d%d , &n, &m, &y, &Y);     for (int i = 1; i <= n; i++) scanf( %d , &x1[i]);     for (int i = 1; i <= m; i++) {       scanf( %d , &x2[i]);       d[i] = 100000000;     }     x2[0] = -100000000;     x2[m + 1] = 100000000;     int ans = 0;     for (int i = 1; i <= n; i++) {       while (dist(x1[i], x2[it]) > dist(x1[i], x2[it + 1])) it++;       if (u[it] == 0 || d[it] == dist(x1[i], x2[it])) {         ans++;         u[it] = 1;       } else if (dist(x1[i], x2[it]) == dist(x1[i], x2[it + 1])) {         ans++;         u[it + 1] = 1;       }       d[it] = min(d[it], dist(x1[i], x2[it]));       d[it + 1] = min(d[it + 1], dist(x1[i], x2[it + 1]));     }     printf( %d n , n - ans);     return 0;   }
#include <iostream>   #include <algorithm>   using namespace std;   typedef long long ll;   const ll mod = 1e9+7;   const int SZ = 1e5+10;      ll fact[SZ];   void buildFact(){       fact[0] = 1;       for(int i = 1; i < SZ; i++){           fact[i] = fact[i-1] * i;           fact[i] %= mod;       }   }      ll powe(ll x, ll p){       ll ans = 1;       for(; p > 0; x = (x*x)%mod, p >>= 1){           if (p&1){ ans *= x; ans %= mod; }       }       return ans;   }      ll modinv(ll n){       return powe(n, mod-2);   }      ll choose(ll n, ll k){       if (k > n){ return 0; }              ll ans = fact[n];       ll den = fact[n-k] * fact[k]; den %= mod;       ans *= modinv(den); ans %= mod;              return ans;   }      int main(){       buildFact();              int t; cin >> t;       while (t--){           int n, k; cin >> n >> k;           ll ans = 1;                      for(ll p = 1; n-(k-1)*(p-1) >= p-1; p++){               ans += choose(n-(k-1)*(p-1), p) * modinv(choose(n, p));               ans %= mod;           }                      cout << ans <<   n ;       }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long N, P;     cin >> N >> P;     vector<long long> l(N), r(N);     for (long long i = 0; i < N; ++i) cin >> l[i] >> r[i];     double exp_val = 0;     for (long long i = 0; i < N; ++i) {       long long j = (i + 1) % N;       double tot = (r[i] - l[i] + 1) * (r[j] - l[j] + 1);       double a = floor(((double)r[i]) / P);       double b = ceil(((double)l[i]) / P);       double c = a - b + 1;       double e = floor(((double)r[j]) / P);       double f = ceil(((double)l[j]) / P);       double g = e - f + 1;       double good = (c * (r[j] - l[j] + 1)) + (g * (r[i] - l[i] + 1)) - c * g;       exp_val += good * 2000 / tot;     }     cout << fixed << setprecision(9) << exp_val << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   int a[100010], b[100010];   int main() {     int n, k, m;     scanf( %d%d , &n, &k);     int val = 1;     for (int i = 0; i < k; i++) val *= 10;     m = n / k;     for (int i = 0; i < m; i++) scanf( %d , &a[i]);     for (int i = 0; i < m; i++) scanf( %d , &b[i]);     long long ans = 1;     for (int i = 0; i < m; i++) {       int t = (val - (val % a[i])) / a[i];       if (val % a[i]) t++;       int num = (a[i] - (val / 10 * b[i]) % a[i]) % a[i];       if ((val / 10) <= num) {         ans = ans * t % mod;         continue;       }       int tt = ((val / 10 - num) - ((val / 10 - num) % a[i])) / a[i];       if ((val / 10 - num) % a[i]) tt++;       ans = ans * (t - tt) % mod;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, s, i, a, b, t, j, v, f, c;     int candy = -1, d;     scanf( %d%d , &n, &s);     s = s * 100;     while (n--) {       scanf( %d%d , &a, &b);       d = (a * 100) + b;       if (d <= s) {         f = s - d;         c = f % 100;         if (c > candy) candy = c;       }     }     if (c != -1)       printf( %d , candy);     else       printf( -1 );   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 3;   const int M = 26;   char s1[N], s2[N];   int z1[N][M], z2[N][M];   int n;   bool check(int l1, int r1, int l2, int r2) {     int l, i, t1, t2;     for (i = 0; i < M; ++i) {       t1 = z1[r1 - 1][i];       if (l1) t1 -= z1[l1 - 1][i];       t2 = z2[r2 - 1][i];       if (l2) t2 -= z2[l2 - 1][i];       if (t1 != t2) return false;     }     l = r1 - l1;     if (l & 1) {       for (i = 0; i < l; ++i)         if (s1[l1 + i] != s2[l2 + i]) return false;       return true;     }     l >>= 1;     if (check(l1, l1 + l, l2, l2 + l) && check(l1 + l, r1, l2 + l, r2))       return true;     if (check(l1, l1 + l, l2 + l, r2) && check(l1 + l, r1, l2, l2 + l))       return true;     return false;   }   int main() {     if (0) {       freopen( input.txt ,  w , stdout);       int n, i;       n = 8192;       for (i = 0; i < n; ++i) printf( a );       printf(  n );       for (i = 0; i < n; ++i) printf( a );       printf(  n );       return 0;     }     int i, j;     scanf( %s , s1);     scanf( %s , s2);     n = strlen(s1);     ++z1[0][s1[0] -  a ];     ++z2[0][s2[0] -  a ];     for (i = 1; i < n; ++i) {       for (j = 0; j < M; ++j) z1[i][j] += z1[i - 1][j], z2[i][j] += z2[i - 1][j];       ++z1[i][s1[i] -  a ];       ++z2[i][s2[i] -  a ];     }     printf( %s n , (check(0, n, 0, n)) ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int N = 1e6 + 5;   int dp[N][2];   int main() {     int n, x;     scanf( %d , &n);     dp[0][0] = dp[0][1] = 1;     for (int i = 1; i <= n; ++i) {       scanf( %d , &x);       for (int j = 1; j * j <= x; ++j) {         if (x % j) continue;         dp[j][1] = (dp[j][1] + dp[j - 1][0]) % mod;         if (j * j != x) dp[x / j][1] = (dp[x / j][1] + dp[x / j - 1][0]) % mod;       }       for (int j = 1; j * j <= x; ++j) {         if (x % j) continue;         dp[j][0] = dp[j][1] % mod;         if (j * j != x) dp[x / j][0] = dp[x / j][1] % mod;       }     }     int sum = 0;     for (int i = 1; i <= n; ++i) {       sum = sum + dp[i][0];       sum %= mod;     }     printf( %d n , sum);   }
#include <bits/stdc++.h>   using namespace std;   int n, ans[110];   int main() {     scanf( %d , &n);     for (int i = n; i > 0; i--) {       printf( ?  );       for (int j = 1; j < n; j++) printf( 1  );       printf( %d n , i);       fflush(stdout);       int k;       scanf( %d , &k);       if (k) {         ans[n] = n - i + 1;         ans[k] = n;         break;       }     }     if (!ans[n]) ans[n] = n;     for (int i = ans[n] + 1; i <= n; i++) {       printf( ?  );       for (int j = 1; j < n; j++) printf( 1  );       printf( %d n , i - ans[n] + 1);       fflush(stdout);       int k;       scanf( %d , &k);       ans[k] = i;     }     for (int i = 1; i < ans[n]; i++) {       printf( ?  );       for (int j = 1; j < n; j++) printf( %d  , ans[n] - i + 1);       printf( 1 n );       fflush(stdout);       int k;       scanf( %d , &k);       ans[k] = i;     }     printf( !  );     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     bool o[100];     int n, k1, k2;     int a[100];     int b[100];     for (int j = 0; j < t; j++) {       cin >> n >> k1 >> k2;       for (int i = 0; i < k1; i++) cin >> a[i];       for (int i = 0; i < k2; i++) cin >> b[i];       o[j] = 0;       for (int i = 0; i < k1; i++)         if (a[i] == n) o[j] = 1;     }     for (int j = 0; j < t; j++) {       if (o[j])         cout <<  YES n ;       else         cout <<  NO n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7, N = 3e5 + 7, M = 998244353;   vector<int> G[N], add[N], del[N];   long long f[N], fi[N], inv[N];   int cans[41], dp[1 << 20][21];   int C(int n, int k) { return f[n] * fi[k] % M * fi[n - k] % M; }   void ADD(int& a, int b) {     a += b;     if (a >= M) a -= M;   }   signed main() {     std::ios::sync_with_stdio(0);     std::cin.tie(0);     ;     f[0] = 1;     for (int i = 1; i < N; i++) f[i] = f[i - 1] * i % M;     inv[1] = 1;     for (int i = 2; i < N; i++) inv[i] = M - M / i * inv[M % i] % M;     fi[0] = 1;     for (int i = 1; i < N; i++) fi[i] = fi[i - 1] * inv[i] % M;     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       int l, r;       cin >> l >> r;       add[l].push_back(i);       del[r + 1].push_back(i);     }     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       G[u].push_back(i);       G[v].push_back(i);     }     long long ans = 0, cnt = 0, cnt1 = 0;     dp[0][0] = cans[0] = 1;     for (int i = 1; i <= n; i++) {       bool change = false;       for (int j : add[i]) {         if (G[j].size()) {           int mask = 0;           for (int k : G[j]) mask |= 1 << k;           for (int k = 0; k < (1 << m); k++)             for (int l = 1; l <= 20; l++)               if ((k & mask) == mask) ADD(dp[k][l], dp[k ^ mask][l - 1]);           change = true;           cnt1++;         } else           cnt++;       }       for (int j : del[i]) {         if (G[j].size()) {           int mask = 0;           for (int k : G[j]) mask |= 1 << k;           for (int k = 0; k < (1 << m); k++)             for (int l = 1; l <= 20; l++)               if ((k & mask) == mask)                 ADD(dp[k][l],                     M - (dp[k ^ mask][l - 1] ? dp[k ^ mask][l - 1] : M));           change = true;           cnt1--;         } else           cnt--;       }       if (change) {         memset(cans, 0, sizeof cans);         for (int mask = 0; mask < (1 << m); mask++)           for (int j = 0; j <= 20; j++) ADD(cans[j], dp[mask][j]);       }       for (int j = 0; j <= cnt1; j++) {         if (i - j < 0 || i - j > cnt) continue;         ans = (ans + (long long)C(cnt, i - j) * cans[j]) % M;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int e[1010][1010];   int main(void) {     int n, a, b;     scanf( %d%d%d , &n, &a, &b);     if (a > 1 && b > 1) {       printf( NO n );       return 0;     }     int x = n - max(a, b) + 1;     if (x <= 0 || ((n == 2 || n == 3) && x == n)) {       printf( NO n );       return 0;     }     printf( YES n );     for (int i = 0; i < x - 1; i++) e[i][i + 1] = e[i + 1][i] = 1;     if (b != 1)       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++)           if (i != j) e[i][j] = 1 - e[i][j];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) printf( %d , e[i][j]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   int main(int argc, char const *argv[]) {     int T;     scanf( %d , &T);     while (T--) {       int n, m;       scanf( %d%d , &n, &m);       std::vector<short> vertices(3 * n, 0);       std::vector<int> edges;       for (int i = 0; i < m; i++) {         int u, v;         scanf( %d%d , &u, &v);         if (!vertices[u - 1] && !vertices[v - 1]) {           vertices[u - 1] = 1;           vertices[v - 1] = 1;           edges.push_back(i + 1);         }       }       if (edges.size() >= n) {         printf( Matching n );         for (int i = 0; i < n; i++) printf( %d n , edges[i]);       } else {         printf( IndSet n );         for (int i = 0, cnt = 0; i < 3 * n && cnt < n; i++) {           if (!vertices[i]) {             cnt++;             printf( %d n , i + 1);           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int L, R, i;   } q[100001];   bool cmp(node x, node y) {     if (x.L / 555 != y.L / 555) {       return x.L / 555 < y.L / 555;     }     return x.R < y.R;   }   map<int, int> mpp;   int ans = 0, I;   int arr[100000 + 1], ct[100001], arr2[100001];   void add(int p) {     ct[arr2[p]]++;     if (ct[arr2[p]] == arr[p]) {       ans++;     }     if (ct[arr2[p]] == arr[p] + 1) ans--;   }   void rem(int p) {     if (ct[arr2[p]] == arr[p]) ans--;     if (ct[arr2[p]] == arr[p] + 1) ans++;     ct[arr2[p]]--;   }   int main() {     int n, m;     cin >> n >> m;     vector<pair<int, int> > V;     for (int i = 1; i <= n; i++) {       cin >> arr[i];       V.push_back(make_pair(arr[i], i));     }     sort(V.begin(), V.end());     int r = 0;     for (int i = 0; i < V.size(); i++) {       if (i && V[i].first != V[i - 1].first) r++;       arr2[V[i].second] = r;     }     int x, y;     for (int i = 0; i < m; i++) {       cin >> q[i].L >> q[i].R;       q[i].i = i;     }     sort(q, q + m, cmp);     x = q[0].L, y = q[0].R;     for (int i = x; i <= y; i++) {       ct[arr2[i]]++;       if (ct[arr2[i]] == arr[i]) ans++;       if (ct[arr2[i]] == arr[i] + 1) ans--;     }     int out[m];     out[q[0].i] = ans;     for (I = 1; I < m; I++) {       int l = q[I].L, r = q[I].R;       while (x < l) {         rem(x);         x++;       }       while (x > l) {         x--;         add(x);       }       while (y < r) {         y++;         add(y);       }       while (y > r) {         rem(y);         y--;       }       out[q[I].i] = ans;     }     for (int i = 0; i < m; i++) {       cout << out[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-10;   const int inf = 1 << 28;   int in() {     int x;     scanf( %d , &x);     return x;   }   long long In() {     long long x;     cin >> x;     return x;   }   double inreal() {     double x;     scanf( %lf , &x);     return x;   }   string instr() {     char buf[1001];     scanf( %s , buf);     return (string)buf;   }   struct UF {     vector<int> p, r;     UF(int n) {       n++;       p.resize(n, ~0), r.resize(n, 0);     }     int root(int x) { return ~p[x] ? p[x] = root(p[x]) : x; }     bool conn(int x, int y) {       x = root(x), y = root(y);       if (x == y) return 0;       if (r[x] < r[y])         p[x] = y;       else {         p[y] = x;         if (r[x] == r[y]) r[x]++;       }       return 1;     }     bool same(int x, int y) { return root(x) == root(y); }   };   const long long M = 1000000009LL;   long long resget(long long x) {     x = x - 1;     if (x < 0) return M - 1;     return x;   }   int main() {     int i, j, k, n = in(), m = in(), u, v;     UF uf(n);     long long res = 1;     for ((i) = (0); (i) < (int)(m); (i)++) {       u = in() - 1, v = in() - 1;       if (uf.conn(u, v)) {         cout << resget(res) << endl;       } else {         res = res * 2 % M;         cout << resget(res) << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, m;   long long a, k, ak;   char c;   unordered_map<long long, bool> ma;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> t;     for (int ti = 1; ti <= t; ++ti) {       ma.clear();       cin >> n >> m;       k = (1ll << m) - n;       for (int i = 1; i <= n; ++i) {         a = 0;         for (int j = m - 1; j >= 0; --j) {           cin >> c;           a |= (c ==  1  ? (1ll << j) : 0ll);         }         ma[a] = 1;       }       a = (k - 1) / 2;       ak = k = a + 1;       for (pair<long long, bool> tw : ma) {         if (tw.first <= a) --ak;       }       while (ak < k) {         if (!ma[++a]) ++ak;       }       for (int i = m - 1; i >= 0; --i) {         cout << (a & (1ll << i) ? 1 : 0);       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool flag;   long long Max = -1e18, tpMax = -1e18, dep[600005], a[600005];   int n, m, sz[600005], In[600005], TOT, LA[600005], NE[600005 << 1],       EN[600005 << 1];   long long LE[600005 << 1];   void Link(int x, int y, int z) {     EN[++TOT] = y;     LE[TOT] = z;     NE[TOT] = LA[x];     LA[x] = TOT;     EN[++TOT] = x;     LE[TOT] = z;     NE[TOT] = LA[y];     LA[y] = TOT;   }   void pre_dfs(int x, int fa) {     if (x == n) In[x] = x;     int i, y;     sz[x] = 1;     long long tp = -1e18, ttp = -1e18;     for (i = LA[x]; i; i = NE[i]) {       y = EN[i];       if (y == fa) continue;       dep[y] = dep[x] + LE[i];       pre_dfs(y, x);       sz[x] += sz[y];       if (In[y])         In[x] = y;       else         a[x] = LE[i];       if (a[y] && In[y]) tp = max(tp, a[y] - dep[y]);       if (In[y]) ttp = max(ttp, a[y] - dep[y]);     }     if (sz[x] - sz[In[x]] > 2) flag = 1;     if (x == n && sz[x] > 2) flag = 1;     if (In[x]) {       Max = max(Max, a[x] + dep[x] + max(tpMax, tp));       if (a[x]) Max = max(Max, a[x] + dep[x] + ttp);       for (i = LA[x]; i; i = NE[i]) {         y = EN[i];         if (y == fa) continue;         if (In[y]) tpMax = max(tpMax, a[y] - dep[y]);       }     }   }   int main() {     int i, j, k, x, y, z;     long long t;     scanf( %d%d , &n, &m);     for (i = 1; i < n; i++) {       scanf( %d%d%d , &x, &y, &z);       Link(x, y, z);     }     pre_dfs(1, 0);     for (i = 1; i <= m; i++) {       scanf( %I64d , &t);       if (flag || t + Max >= 0)         printf( %I64d n , dep[n]);       else         printf( %I64d n , dep[n] + t + Max);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void pfill(T* pst, const T* ped, T val) {     for (; pst != ped; *(pst++) = val)       ;   }   const double pi = acos(-1);   const double eps = 0;   typedef class Point {    public:     int x, y, deg, id;     Point() : x(0), y(0), deg(0), id(0) {}     Point(Point p, int ndeg) : x(p.x), y(p.y), deg(ndeg), id(p.id) {}     Point(int x, int y, int deg) : x(x), y(y), deg(deg), id(0) {}   } Point;   typedef class Event {    public:     int val, id;     bool add;     double theta;     Event() {}     Event(int val, int id, bool add, double theta)         : val(val), id(id), add(add), theta(theta) {}     bool operator<(Event e) const { return theta < e.theta; }   } Event;   const int N = 6e3 + 6;   int T;   int n, m;   int rs[N];   int tp = 0;   bool onleft[N];   Event events[N << 1];   vector<Point> ps;   inline void init() {     scanf( %d%d , &n, &m);     ps.clear();     ps = vector<Point>(n + m);     for (int i = 0; i < m; i++) scanf( %d , rs + i);     for (int i = 0; i < n; i++)       scanf( %d%d , &ps[i].x, &ps[i].y), ps[i].deg = 0, ps[i].id = i + 1;     for (int i = 0; i < m; i++)       scanf( %d%d , &ps[i + n].x, &ps[i + n].y), ps[i + n].deg = rs[i],                                                         ps[i + n].id = i + 1;   }   void solve(vector<Point>& ps) {     int r = 0, mxid = -1;     for (int i = 0; i < (signed)ps.size(); i++)       if (ps[i].deg > r) r = ps[i].deg, mxid = i;     if (r == 1) {       int cnt = 0;       for (int i = 0; i < (signed)ps.size(); i++)         if (!ps[i].deg) mxid = i, cnt++;       assert(cnt == 1 || ps.size() == 1);       for (int i = 0; i < (signed)ps.size(); i++)         if (i ^ mxid) printf( %d %d n , ps[i].id, ps[mxid].id);       return;     }     int dx, dy;     double theta;     tp = 0;     int sum = 0;     for (int i = 0; i < (signed)ps.size(); i++) {       if (i == mxid) continue;       dx = ps[i].x - ps[mxid].x, dy = ps[i].y - ps[mxid].y;       theta = atan2(dy, dx);       if (theta > 0 || fabs(theta) < eps) {         sum += ps[i].deg - 1, onleft[i] = true;         events[tp++] = Event(1 - ps[i].deg, i, false, theta);       } else         events[tp++] = Event(ps[i].deg - 1, i, true, theta + pi);     }     sort(events, events + tp);     for (int i = 0; i < tp && (sum < 1 - r || sum > -1); i++) {       sum += events[i].val;       onleft[events[i].id] = events[i].add;     }     assert(sum >= 1 - r && sum <= -1);     vector<Point> pl, pr;     for (int i = 0; i < (signed)ps.size(); i++) {       if (i == mxid) continue;       if (onleft[i])         pl.push_back(ps[i]);       else         pr.push_back(ps[i]);     }     pfill(onleft, onleft + ps.size(), false);     pl.push_back(Point(ps[mxid], -sum));     pr.push_back(Point(ps[mxid], r + sum));     solve(pl);     solve(pr);   }   inline void solve() {     puts( YES );     solve(ps);   }   int main() {     scanf( %d , &T);     while (T--) {       init();       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int N = 1050;   const long long mod = 1e9 + 7;   int l, r, n, id = 1;   int a[N];   bool vis[N];   char ans[N][N];   void work(int now, int i) {     bool flag = true;     while (!vis[i]) {       vis[i] = 1;       if (flag) {         if (a[i] > i)           ans[id][i] = ans[id][a[i]] =  / ;         else {           ans[id][i] = ans[id][r] =  / ;           ++id;           ans[id][r] = ans[id][a[i]] =     ;           flag = 0;         }       } else {         if (a[i] < i)           ans[id][i] = ans[id][a[i]] =     ;         else {           ans[id][i] = ans[id][now] =     ;           ++id;           ans[id][now] = ans[id][a[i]] =  / ;           flag = 1;         }       }       i = a[i];     }   }   int main() {     cin >> n;     l = inf, r = 0;     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 1; i <= n; ++i) {       if (a[i] != i) l = min(l, i), r = max(r, i);     }     if (l == inf) {       printf( %d n , n);       for (int i = 1; i <= n; ++i, puts(  ))         for (int j = 1; j <= n; ++j) printf( . );       return 0;     }     int pre = 1, nxt = a[r];     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j) ans[i][j] =  . ;     for (int i = l; i <= r; ++i)       if (a[i] == r) pre = i;     a[pre] = a[r];     a[r] = r;     for (int i = l; i < r; ++i) {       if (a[i] == i || vis[i]) continue;       work(i, i);       id++;     }     ans[id][nxt] = ans[id][r] =  / ;     cout << n - 1 << endl;     for (int i = n; i >= 1; --i) {       printf( %s n , ans[i] + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   void solve() {     long long w, h;     cin >> w >> h;     int l1;     cin >> l1;     vector<long long> row1(l1);     for (int i = 0; i < l1; i++) {       cin >> row1[i];     }     int l2;     cin >> l2;     vector<long long> row2(l2);     for (int i = 0; i < l2; i++) {       cin >> row2[i];     }     sort(row1.begin(), row1.end());     sort(row2.begin(), row2.end());     long long gap = max(row1[l1 - 1] - row1[0], row2[l2 - 1] - row2[0]);     int h1;     cin >> h1;     vector<long long> col1(h1);     for (int i = 0; i < h1; i++) {       cin >> col1[i];     }     int h2;     cin >> h2;     vector<long long> col2(h2);     for (int i = 0; i < h2; i++) {       cin >> col2[i];     }     sort(col1.begin(), col1.end());     sort(col2.begin(), col2.end());     long long gap2 = max(col1[h1 - 1] - col1[0], col2[h2 - 1] - col2[0]);     long long area = max(h * gap, w * gap2);     cout << area <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int t = 1;     cin >> t;     while (t--) solve();     return 0;   }