malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000055;   const int inf = 0x3f3f3f3f;   const double pi = acos(-1.0);   const int mod = 1e9 + 7;   long long pow_mod(long long a, long long b) {     long long ans = 1 % mod;     for (; b; b >>= 1) {       if (b & 1) ans = (long long)ans * a % mod;       a = (long long)a * a % mod;     }     return ans;   }   long long x, n;   long long p[MAXN], c[MAXN];   int cnt;   void divide(long long n) {     cnt = 0;     int lim = sqrt(n);     for (int i = 2; i <= lim; ++i) {       if (n % i == 0) {         p[++cnt] = i, c[cnt] = 0;         while (n % i == 0) n /= i, c[cnt]++;       }     }     if (n > 1) p[++cnt] = n, c[cnt] = 1;   }   int main() {     cin >> x >> n;     divide(x);     long long ans = 1;     for (int i = 1; i <= cnt; ++i) {       long long k = 1, tmp = 0;       while ((long long)(n / (long long)pow(p[i], k))) {         tmp += (long long)(n / (long long)pow(p[i], k));         k++;       }       ans = ans * pow_mod(p[i], tmp) % mod;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-8;   const long long SZ = 1010, SSZ = 100010, APB = 26, one = 93,                   INF = 0x3f3f3f3f3f3f3f3f, mod = 1000000007;   long long n, m, bg, fn, cnt;   long long to[SSZ], wt[SSZ], head[SZ];   long long nex[SSZ], mk[SSZ];   long long dfn[SZ], low[SZ], tot;   bool vst[SZ];   void add(long long u, long long v, long long w) {     ++cnt;     nex[cnt] = head[u];     head[u] = cnt;     to[cnt] = v, wt[cnt] = w;   }   bool dfs(long long x) {     vst[x] = 1;     if (x == fn) return 1;     for (long long i = head[x]; i != -1; i = nex[i]) {       long long t = to[i];       if (!vst[t]) {         mk[i] = 1;         if (dfs(t)) return 1;         mk[i] = 0;       }     }     return 0;   }   stack<long long> stk;   void tar(long long x, long long p, long long &res2, long long &eg2) {     dfn[x] = low[x] = ++tot;     vst[x] = 1;     for (long long i = head[x]; i != -1; i = nex[i]) {       if (i != (p ^ 1) && mk[i] != 2 && mk[i ^ 1] != 2) {         long long t = to[i], w = wt[i];         if (!dfn[t]) {           tar(t, i, res2, eg2);           low[x] = min(low[x], low[t]);         } else           low[x] = min(low[x], low[t]);         if (dfn[x] < low[t] && dfn[fn] >= dfn[t]) {           if (w < res2) {             res2 = w, eg2 = i;           }         }       }     }   }   void init() {     cin >> n >> m >> bg >> fn;     cnt = -1;     memset(head, -1, sizeof(head));     for (long long i = 1; i <= m; ++i) {       long long a, b, c;       cin >> a >> b >> c;       add(a, b, c);       add(b, a, c);     }     dfs(bg);     if (vst[fn] == 0) {       cout << 0 << endl << 0;       return;     }     long long res = INF, vt1 = -1, vt2;     for (long long i = 0; i <= cnt; ++i) {       if (mk[i]) {         mk[i] = 2;         memset(vst, 0, sizeof(vst));         tot = 0;         memset(dfn, 0, sizeof(dfn));         memset(low, 0, sizeof(low));         long long res1 = wt[i], res2 = INF, eg1 = i, eg2;         tar(bg, -1, res2, eg2);         if (!vst[fn]) res2 = 0, eg2 = -5;         if (res1 + res2 < res) {           res = res1 + res2;           vt1 = eg1 / 2 + 1, vt2 = eg2 / 2 + 1;         }         mk[i] = 1;       }     }     if (vt1 == -1) {       cout << -1 << endl;       return;     }     cout << res << endl;     cout << (vt2 == -1 ? 1 : 2) << endl;     cout << vt1 <<    ;     if (vt2 != -1) cout << vt2 << endl;   }   void work() {}   int main() {     std::ios::sync_with_stdio(0);     long long casenum;     {       init();       work();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int x;     cin >> x;     vector<int> first(x);     vector<int> second(x);     int sum_f = 0;     for (int i = 0; i < x; i++) {       cin >> first[i];       sum_f += first[i];     }     int sum_s = 0;     for (int i = 0; i < x; i++) {       cin >> second[i];       sum_s += second[i];     }     if (sum_s > sum_f) {       cout <<  No ;     } else       cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int tavan(int a, int n, int mod) {     int res = 1;     while (n) res *= (n & 1) ? a : 1, res %= mod, n /= 2, a *= a, a %= mod;     return res;   }   const int MOD = ((int)81671);   const int N = ((int)40);   const int M = ((int)12);   const int X = ((int)2e6);   int n, m, p[M];   string s[M], now;   bool mark[X];   vector<string> v;   void solve(int pos, int x) {     if (x < 0) return;     if (pos == (int)s[0].size() && x != 0) return;     if (x == 0) {       for (int i = pos; i < s[0].size(); i++)         now[i] = (s[0][i] ==  0 ) ?  1  :  0 ;       v.push_back(now);       return;     }     now[pos] = s[0][pos];     solve(pos + 1, x - 1);     now[pos] = (s[0][pos] ==  0 ) ?  1  :  0 ;     solve(pos + 1, x);     now[pos] = s[0][pos];   }   int main() {     cin >> n >> m >> s[0] >> p[0];     now = s[0];     solve(0, p[0]);     int ans = v.size();     for (int i = 1; i < m; i++) {       cin >> s[i] >> p[i];       for (int j = 0; j < v.size(); j++)         if (!mark[j]) {           int num = 0;           for (int k = 0; k < v[j].size(); k++)             if (v[j][k] == s[i][k]) num++;           if (num != p[i]) mark[j] = 1, ans--;         }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int main() {     int T, t1 = 0, t2, maxn = 0, flag = 1, sum = 0, sum1 = 0;     scanf( %d , &T);     while (T--) {       scanf( %d , &t2);       if (flag && t2 == 0) {         maxn = max(maxn, sum);         sum1 = sum;         sum = 0;         flag = 0;         continue;       }       if (t2 == 0) {         maxn = max(maxn, sum);         sum = 0;         continue;       }       sum++;       if (T == 0) {         maxn = max(sum + sum1, maxn);       }     }     printf( %d n , maxn);   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[(int)2e5];   long long sum;   double d, res;   int main() {     cin >> n >> k;     for (int i = 0; i < n; ++i) {       cin >> a[i];       if (i < k) sum += a[i];     }     d = n - k + 1;     res += sum / d;     for (int i = k; i < n; ++i) {       sum -= a[i - k];       sum += a[i];       res += sum / d;     }     cout << fixed << setprecision(6) << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int a = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  a ) a++;     }     for (int i = s.size(); i >= a; i--) {       if (a > (i / 2)) {         cout << i << endl;         exit(0);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int ABS(int a) {     if (a < 0) return (-a);     return a;   }   vector<int> v[50005];   int main() {     int n, r1, r2, i;     scanf( %d , &n);     scanf( %d , &r1);     scanf( %d , &r2);     for (i = (1); i < (n + 1); ++i) {       if (r1 == i) continue;       int x;       scanf( %d , &x);       v[x].push_back(i);       v[i].push_back(x);     }     int parent[50005] = {0};     bool vis[50005] = {0};     queue<int> q;     q.push(r2);     parent[r2] = -1;     vis[r2] = 1;     while (!q.empty()) {       int x = q.front();       q.pop();       for (i = (0); i < (v[x].size()); ++i) {         int next = v[x][i];         if (!vis[next]) {           q.push(next);           parent[next] = x;           vis[next] = 1;         }       }     }     for (i = (1); i < (n + 1); ++i) {       if (i == r2) continue;       printf( %d  , parent[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   function<void(void)> ____ = []() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   };   const int MAXN = 555;   int n, m, match[MAXN];   bool mp[MAXN][MAXN], vis[MAXN];   vector<int> G[MAXN];   bool dfs(int u, int c) {     vis[u] = true;     for (int v : G[u]) {       if (v == c) continue;       if (match[v] == -1 or (!vis[match[v]] and dfs(match[v], c))) {         match[v] = u;         return true;       }     }     return false;   }   int hungary(int c) {     memset(match, 255, sizeof(match));     int mt = 0;     for (int i = 1; i <= n; i++) {       if (i == c) continue;       memset(vis, 0, sizeof(vis));       if (dfs(i, c)) mt++;     }     return mt;   }   int main() {     ____();     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int u, v;       cin >> u >> v;       G[u].push_back(v);       mp[u][v] = true;     }     int ret = MAXN * MAXN * MAXN;     for (int i = 1; i <= n; i++) {       int centeredge = 0;       for (int j = 1; j <= n; j++) {         if (i == j and mp[i][j])           centeredge++;         else if (i != j) {           if (mp[i][j]) centeredge++;           if (mp[j][i]) centeredge++;         }       }       int mt = hungary(i);       ret = min(ret, 3 * n + m - 2 - 2 * centeredge - 2 * mt);     }     cout << ret << endl;     return 0;   }
#include <bits/stdc++.h>   const int maxn = 1e6 + 10;   using namespace std;   int pre[maxn];   int main() {     string a, b;     cin >> a;     cin >> b;     int LA = a.size();     int LB = b.size();     int flag = 0, ans = 0;     for (int i = 0; i < LB; i++) {       if (b[i] ==  1 ) flag++;     }     flag %= 2;     if (a[0] ==  1 ) pre[1] = 1;     for (int i = 1; i < LA; i++) {       if (a[i] ==  1 )         pre[i + 1] = pre[i] + 1;       else         pre[i + 1] = pre[i];     }     int T = LA - LB;     for (int i = 0; i <= T; i++) {       if ((pre[i + LB] - pre[i]) % 2 == flag) {         ans++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a, b, sum = 0, sum1 = 0;     cin >> n >> m >> a >> b;     sum = n / m;     sum1 = n - (sum * m);     if (sum * b < n * a) {       cout << min((sum * b + sum1 * a), ((sum + 1) * b));     }     if (sum * b >= n * a) {       cout << n * a;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 5;   unordered_map<long long, long long> m1, mp;   long long m, k, n, s;   bool check() {     for (auto it : mp) {       if (it.second > m1[it.first]) return false;     }     return true;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       cin >> m >> k >> n >> s;       long long a[m];       long long i, j;       for (int i = 0; i <= m - 1; i++) {         cin >> a[i];       }       long long b[s];       for (int i = 0; i <= s - 1; i++) {         cin >> b[i];         mp[b[i]]++;       }       long long del = m - n * k;       long long req = del + k;       for (i = 0; i < m; i += k) {         m1.clear();         for (j = i; j < min(m, i + req); j++) {           m1[a[j]]++;         }         if (check()) {           cout << del <<   n ;           for (j = i; j < min(i + req, m); j++) {             if (del > 0 && m1[a[j]] > mp[a[j]]) {               cout << j + 1 <<    ;               del--;               m1[a[j]]--;             }           }           return 0;         }       }       cout << -1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, s, a[100005], p, w[100005], ans;   multiset<long long> st;   int main() {     cin >> n >> s;     for (int k = 1; k <= n; k++) cin >> a[k];     cin >> p;     for (int k = 1; k <= n; k++) cin >> w[k];     for (int k = 1; k <= n; k++) {       st.insert(w[k]);       while (s < a[k]) {         if (st.size() == 0) {           cout << -1;           return 0;         }         ans += *st.begin();         st.erase(st.begin());         s += p;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int limite = 1000000;   int n;   long long int a[limite];   long long int suma[limite];   map<long long int, int> cuantos;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       a[i + n] = a[i];     }     for (int i = 1; i <= 2 * n; i++) suma[i] = suma[i - 1] + a[i];     for (int i = 1; i <= n; i++) cuantos[suma[i]]++;     int sol = n;     for (int i = 1; i <= n; i++) {       sol = min(sol, n - cuantos[suma[i - 1]]);       cuantos[suma[i]]--;       cuantos[suma[i + n]]++;     }     cout << sol << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char* argv[]) {     int n, m, k;     vector<double> r1, p1, p2;     cin >> n;     while (n--) {       int hlp;       cin >> hlp;       r1.push_back(hlp);     }     cin >> m;     while (m--) {       int hlp;       cin >> hlp;       p1.push_back(hlp);     }     cin >> k;     while (k--) {       int hlp;       cin >> hlp;       p2.push_back(hlp);     }     double A, B;     cin >> A >> B;     double maxr2 = 0;     sort(r1.begin(), r1.end());     sort(p1.begin(), p1.end());     sort(p2.begin(), p2.end());     {       maxr2 = r1[r1.size() - 1] * sqrt(p1[p1.size() - 1] / p2[0] /                                        (A / B + p1[p1.size() - 1] / p2[0]));     }     char buf[256];     cout << gcvt(maxr2, 50, buf);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000000;   const int INF = 1000000001;   vector<int> G[MAXN + 1];   bool vis[MAXN + 1];   vector<int> CC;   int n, m, k;   int dfs(int v) {     vis[v] = true;     int ret = 1;     for (__typeof((G[v]).begin()) u = (G[v]).begin(); u != (G[v]).end(); ++u)       if (!vis[*u]) ret += dfs(*u);     return ret;   }   int main(int argc, char *argv[]) {     scanf( %d %d %d , &n, &m, &k);     while (m--) {       int a, b;       scanf( %d %d , &a, &b);       G[a].push_back(b);       G[b].push_back(a);     }     int t = 0;     int s = 0;     for (int i = 1; i <= n; ++i)       if (!vis[i])         CC.push_back(min(k, dfs(i))), t += CC.back() == 1 ? 0 : CC.back(),             s += CC.back() != 1;     t = t - 2 * s + 2;     if (k == 1)       printf( %d n , max(0, (int)CC.size() - 2));     else       printf( %d n , (max(0, ((int)CC.size() - s) - t + 1)) / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, b, x, y, n, ans, t;     cin >> t;     while (t--) {       ans = LLONG_MAX;       cin >> a >> b >> x >> y >> n;       if (n >= (a - x + b - y))         cout << x * y <<   n ;       else {         if ((a - n) >= x)           ans = (a - n) * b;         else {           if (b - (x - a + n) >= y) ans = min(ans, x * (b - (x - a + n)));         }         if ((b - n) >= y)           ans = min(ans, (b - n) * a);         else {           if (a - (y - b + n) >= x) ans = min(ans, y * (a - (y - b + n)));         }         cout << ans <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, l[2001], s[2001], c[4001];   int f[4001][2001];   int main() {     scanf( %d%d , &n, &m);     m += n;     for (int i = n; i >= 1; i -= 1) scanf( %d , &l[i]);     for (int i = n; i >= 1; i -= 1) scanf( %d , &s[i]);     for (int i = 1; i <= m; i += 1) scanf( %d , &c[i]);     for (int i = 1; i <= m; i += 1) {       for (int j = 1; j <= n; j += 1) f[i][j] = -1e9;     }     for (int i = 1; i <= n; i += 1) {       for (int j = n; j >= 1; j -= 1) {         f[l[i]][j] = max(f[l[i]][j], f[l[i]][j - 1] - s[i] + c[l[i]]);       }       for (int j = l[i]; j < m; j += 1) {         for (int k = 0; k <= (n >> j - l[i]); k += 1) {           f[j + 1][k >> 1] = max(f[j + 1][k >> 1], f[j][k] + c[j + 1] * (k >> 1));         }       }     }     printf( %d n , f[m][0]);     return 0;   }
#include <bits/stdc++.h>   int main() {     long long int a, b = 1, i;     scanf( %I64d , &a);     for (i = 1; i <= a; i++) {       b += 12 * (1 + i - 2);     }     if (a == 1)       printf( 1 );     else       printf( %I64d , b);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<long long int, long long int> rec(long long int n) {     long long int mini = 1e18, maxi = -1;     while (n) {       mini = min(mini, n % 10);       maxi = max(maxi, n % 10);       n /= 10;     }     return {mini, maxi};   }   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n, k;       cin >> n >> k;       k--;       while (k--) {         pair<long long int, long long int> x = rec(n);         if (x.first == 0) break;         n += (x.first * x.second);       }       cout << n << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, m, same;   string s;   int main() {     cin >> n >> m >> s;     long long ans = 1LL * n * (m - 1);     for (int i = 1; i < n; i++) {       if (s[i] == s[i - 2]) {         same++;       } else {         same = 0;       }       if (s[i] != s[i - 1]) {         ans += 1LL * n * (m - 1) - same - 1;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int i, m, j;     char a[1000], b[1000];     scanf( %s %s , &a, &b);     if (strlen(a) != strlen(b)) {       printf( NO );       return 0;     }     j = strlen(b) - 1;     for (i = 0; i < strlen(a); i++) {       if (a[i] != b[j]) {         printf( NO );         return 0;       }       j--;     }     printf( YES );   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T fetch() {     T ret;     cin >> ret;     return ret;   }   template <typename T>   inline vector<T> fetch_vec(long long sz) {     vector<T> ret(sz);     for (auto& it : ret) cin >> it;     return ret;   }   template <typename T>   inline void makeUnique(vector<T>& v) {     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());   }   template <typename T>   inline T max_(T a, T b) {     if (a > b) return a;     return b;   }   template <typename T>   inline T min_(T a, T b) {     if (a < b) return a;     return b;   }   void file() {}   void Match() {}   const long long N = 2e5 + 5;   long long son[N * 32][2], pos = 0, cnt[N * 32];   long long dfs(long long p, long long digit) {     long long p0 = son[p][0];     long long p1 = son[p][1];     if (digit == 0) return max(cnt[p0], cnt[p1]) + (cnt[p0] & cnt[p1]);     long long num0 = 0, num1 = 0;     if (p0) num0 = dfs(p0, digit - 1);     if (p1) num1 = dfs(p1, digit - 1);     return max(num0, num1) + (num0 && num1);   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     ;     file();     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       long long num, p = 0;       cin >> num;       for (long long i = 30; i >= 0; i--) {         long long& t = son[p][num >> i & 1];         if (!t) t = ++pos;         cnt[t]++;         p = t;       }     }     cout << n - dfs(0, 30) <<   n ;     Match();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, cnt, x, y, mx, tot;   int head[200005], bin[200005], V[200005 * 5], T[200005 * 5];   struct pl {     int v, nex;   } e[2 * 200005];   void add(int a, int b) {     cnt++;     e[cnt].v = b;     e[cnt].nex = head[a];     head[a] = cnt;     bin[a]++;   }   void dfs(int a, int fa, int ti) {     int fl = ti;     V[++tot] = a;     T[tot] = ti;     if (ti == mx && a != 1) {       ti -= bin[a];       V[++tot] = a;       T[tot] = ti;     }     int i = head[a];     while (i != 0) {       if (e[i].v != fa) {         dfs(e[i].v, a, ti + 1);         ti++;         V[++tot] = a;         T[tot] = ti;         if (ti == mx && a != 1) {           ti -= bin[a];           V[++tot] = a;           T[tot] = ti;         }       }       i = e[i].nex;     }     if (ti != fl - 1 && a != 1) {       ti = fl - 1;       V[++tot] = a;       T[tot] = ti;     }   }   int main() {     scanf( %d , &n);     if (n == 1) {       puts( 1 );       puts( 1 0 );       return 0;     }     for (int i = 1; i < n; i++) scanf( %d%d , &x, &y), add(x, y), add(y, x);     for (int i = 1; i <= n; i++) mx = max(mx, bin[i]);     dfs(1, 0, 0);     printf( %d n , tot);     for (int i = 1; i <= tot; i++) printf( %d %d n , V[i], T[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, t;   char a[3][200];   bool vis[3][200];   bool check(int x, int y) { return (x >= 0 && y >= 0 && x < 3 && y < 200); }   void solve(int cx, int cy) {     if (vis[cx][cy]) {       return;     }     vis[cx][cy] = true;     if (check(cx, cy + 3) && a[cx][cy + 1] ==  .  && a[cx][cy + 2] ==  . ) {       solve(cx, cy + 3);     }     if (check(cx + 1, cy + 3) && a[cx][cy + 1] ==  .  &&         a[cx + 1][cy + 1] ==  .  && a[cx + 1][cy + 2] ==  . ) {       solve(cx + 1, cy + 3);     }     if (check(cx - 1, cy + 3) && a[cx][cy + 1] ==  .  &&         a[cx - 1][cy + 1] ==  .  && a[cx - 1][cy + 2] ==  . ) {       solve(cx - 1, cy + 3);     }   }   int main() {     cin >> t;     while (t--) {       memset(vis, 0, sizeof(vis));       for (int i = 0; i < 3; i++) {         for (int j = 0; j < 200; j++) {           a[i][j] =  . ;         }       }       cin >> n >> k;       int x, y;       for (int i = 0; i < 3; i++) {         for (int j = 0; j < n; j++) {           cin >> a[i][j];           if (a[i][j] ==  s ) {             x = i, y = j;           }         }       }       solve(x, y);       bool ans = false;       for (int i = 0; i < 3; i++) {         for (int j = n - 1; j < 200; j++) {           ans |= vis[i][j];         }       }       if (ans) {         cout <<  YES n ;       } else {         cout <<  NO n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }   bool sorta(const pair<int, int> &a, const pair<int, int> &b) {     return (a.second < b.second);   }   bool sortd(const pair<int, int> &a, const pair<int, int> &b) {     return (a.second > b.second);   }   void printarr(long long arr[], long long n) {     for (int i = 0; i < n; i++) cout << arr[i] <<    ;     cout <<   n ;   }   string decToBinary(int n) {     string s =   ;     int i = 0;     while (n > 0) {       s = to_string(n % 2) + s;       n = n / 2;       i++;     }     return s;   }   long long binaryToDecimal(string n) {     string num = n;     long long dec_value = 0;     int base = 1;     int len = num.length();     for (int i = len - 1; i >= 0; i--) {       if (num[i] ==  1 ) dec_value += base;       base = base * 2;     }     return dec_value;   }   bool isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (int i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     long long i = 1;     while (t--) {       long long w, h;       cin >> w >> h;       long long arr1[4];       for (int i = 0; i < 4; i++) {         int k;         cin >> k;         long long arr[k];         for (int j = 0; j < k; j++) cin >> arr[j];         arr1[i] = arr[k - 1] - arr[0];       }       arr1[0] *= h, arr1[1] *= h;       arr1[2] *= w, arr1[3] *= w;       long long maxan = max({arr1[0], arr1[1], arr1[2], arr1[3]});       cout << maxan <<   n ;     }     return 0;   }