malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   void err() { cout << endl; }   template <template <typename...> class T, typename t, typename... Args>   void err(T<t> a, Args... args) {     for (auto x : a) cout << x <<    ;     err(args...);   }   template <typename T, typename... Args>   void err(T a, Args... args) {     cout << a <<    ;     err(args...);   }   struct P {     int a, b, item;   };   const int N = 1E5 + 100;   int n, m, dm[N];   set<int> S[N];   int orders[N];   int main() {     cin >> n >> m;     int tot = 0;     for (decay<decltype(n + 1)>::type i = (1), _i = (n + 1); i < _i; ++i) {       int sz;       scanf( %d , &sz);       for (decay<decltype(sz)>::type j = (0), _j = (sz); j < _j; ++j) {         int x;         scanf( %d , &x);         S[i].insert(x);       }       tot += sz;     }     for (decay<decltype(n + 1)>::type i = (1), _i = (n + 1); i < _i; ++i)       orders[i] = i;     sort(orders + 1, orders + n + 1,          [](const int& x, const int& y) { return S[x].size() > S[y].size(); });     int ll = 1, rr = n;     int at_least = tot / n;     for (decay<decltype(n + 1)>::type i = (1), _i = (n + 1); i < _i; ++i) {       if (i <= tot % n)         dm[orders[i]] = at_least + 1;       else         dm[orders[i]] = at_least;     }     vector<P> gather;     while (ll < rr) {       vector<P> adds;       int rrrrrrrrr = orders[rr], lllllllll = orders[ll];       ;       if (int((S[rrrrrrrrr]).size()) >= dm[rrrrrrrrr] &&           int((S[lllllllll]).size()) <= dm[lllllllll])         break;       vector<set<int>::iterator> vs;       vs.push_back(S[lllllllll].begin());       for (int v : S[rrrrrrrrr]) {         auto it = S[lllllllll].upper_bound(v);         if (it != S[lllllllll].end()) vs.push_back(it);       }       vector<int> dec;       for (auto it : vs)         while (int((S[lllllllll]).size()) - int((dec).size()) > dm[lllllllll] &&                int((S[rrrrrrrrr]).size()) < dm[rrrrrrrrr] &&                S[rrrrrrrrr].find(*it) == S[rrrrrrrrr].end()) {           S[rrrrrrrrr].insert(*it);           dec.push_back(*it++);         }       for (int v : dec) {         S[lllllllll].erase(v);         gather.push_back({lllllllll, rrrrrrrrr, v});       };       if (int((S[lllllllll]).size()) == dm[lllllllll]) ll++;       if (int((S[rrrrrrrrr]).size()) == dm[rrrrrrrrr]) rr--;     }     cout << gather.size() << endl;     for (decay<decltype(gather.size())>::type i = (0), _i = (gather.size());          i < _i; ++i)       printf( %d %d %d n , gather[i].a, gather[i].b, gather[i].item);   }
#include <bits/stdc++.h>   using namespace std;   int n, head[100005], tot, de[100005], le[100005], lf[100005];   struct node {     int to, next;   } edge[100005 * 2];   void add_edge(int u, int v) {     de[u]++;     edge[tot].to = v;     edge[tot].next = head[u];     head[u] = tot++;   }   void dfs(int cnt, int pre) {     lf[cnt] = 1;     for (int i = head[cnt]; i != -1; i = edge[i].next) {       int j = edge[i].to;       if (j == pre) continue;       if (de[j] <= 2) dfs(j, cnt);     }   }   int main() {     while (cin >> n) {       tot = 0;       memset(head, -1, sizeof(head));       memset(de, 0, sizeof(de));       memset(lf, 0, sizeof(lf));       memset(le, 0, sizeof(le));       for (int i = 1; i < n; i++) {         int u, v;         cin >> u >> v;         add_edge(u, v);         add_edge(v, u);       }       for (int i = 1; i <= n; i++) {         if (de[i] == 1) dfs(i, 0);       }       for (int i = 1; i <= n; i++) {         for (int j = head[i]; j != -1; j = edge[j].next) {           int k = edge[j].to;           if (lf[k]) le[i]++;         }       }       int flag = 0;       for (int i = 1; i <= n && !flag; i++) {         if (lf[i]) continue;         int cn = 0;         for (int j = head[i]; j != -1; j = edge[j].next) {           int k = edge[j].to;           if (lf[k] == 0 && de[k] - min(2, le[k]) >= 2) cn++;           if (cn > 2) {             flag = 1;             break;           }         }       }       if (flag)         cout <<  NO n ;       else         cout <<  YES n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 10;   long long n, a, d[MAXN], v[MAXN], P[MAXN];   vector<pair<int, long long> > vc;   long long ans;   int main() {     cin >> n >> a;     vc.push_back({0, 0});     P[0] = -1e18;     for (int i = 0; i < n; i++) {       cin >> d[i] >> v[i];       ans = max(ans, a - v[i]);       v[i] -= a;       if (i == 0) continue;       v[i] += v[i - 1];       long long mn;       if (i >= 2)         mn = v[i - 2];       else         mn = 0;       while (!vc.empty() && vc.back().first <= d[i] - d[i - 1])         mn = max(mn, vc.back().second), vc.pop_back();       vc.push_back({d[i] - d[i - 1], mn});       mn -= (d[i] - d[i - 1]) * (d[i] - d[i - 1]);       P[vc.size()] = max(P[vc.size() - 1], mn);       ans = max(ans, -v[i] + P[vc.size()]);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long n;     cin >> n;     long long ans = 0;     long long L = -4 * 45, R = 45;     map<long long, long long> vls;     for (long long i = L; i <= R; i++) vls[i] = 1e18;     for (long long i = 0; i < 100; i++) {       for (long long j = 0; j < 100; j++) {         for (long long k = 0; k < 100; k++) {           long long nm = -4 * i + 5 * j + 45 * k;           if (nm >= L && nm <= R) vls[nm] = min(vls[nm], i + j + k);         }       }     }     for (long long i = L; i <= R; i++) {       if (vls[i] <= n) {         ans++;       }     }     for (long long i = L; i < L + 4; i++) {       long long op = vls[i];       if (op < n) ans += n - op;     }     for (long long i = R - 44; i <= R; i++) {       long long op = vls[i];       if (op < n) ans += n - op;     }     cout << ans;     return 0;   }
// #include<bits/stdc++.h>   #include<iostream>   #include<algorithm>   #include<cmath>   /*   #include<vector>   #include<set>   #include<map>   #include<unordered_map>   #define umap unordered_map   #include<unordered_set>   #define uset unordered_set   */   #define pii pair<int,int>   #define F first   #define S second   #define fr(i,n) for(int i=0;i<n;++i)   #define pr cout<<   #define en <<  n    #define sp <<      using namespace std;   typedef long long ll;      int ar[200001];         int main()   {    // ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);    int t=1,n,a ;    cin>>t;    while(t--)    {     cin>>n;     int no=0, cnt=0,ans=0;     fr(i,n){      cin>>a;      if(a==no) cnt++;      else{       ans=max(ans,cnt);       cnt=1;       no =a;      }     }     ans=max(ans,cnt);     pr ans en;    }   }
#include <bits/stdc++.h>   using namespace std;   bool cmp(int a, int b) { return a > b; }   const int maxen = 1e5 + 5, minn = 1e-5;   string a[1005];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     int res = 0, mn = 13;     for (int i = 0; i < n - 1; i++) {       for (int j = i + 1; j < n; j++) {         string b = a[i];         string c = a[j];         res = 0;         for (int k = 0; k < 6; k++)           if (b[k] != c[k]) res++;         mn = min(mn, res);       }     }     cout << (mn - 1) / 2 << endl;     return 0;   }
#include <bits/stdc++.h>   #define pb push_back   #define mp make_pair   #define ll long long   #define mod 1000000007   using namespace std;   void factorial(ll int *fact)   {    fact[0]=1;       for(ll int i=1;i<=200000;i++)       {        fact[i]=(fact[i-1]*i)%mod;    }   }   int main()    {      int t=1;      cin>>t;      ll int fact[200001];      factorial(fact);      while(t--)      {       ll int n;     cin>>n;     ll int i,j,a[n];     ll int mi=INT_MAX;     for(i=0;i<n;i++)     {      cin>>a[i];      mi=min(mi,a[i]);     }     ll int c=0;     ll int an=mi;     for(i=0;i<n;i++)     {      if(a[i]==mi)      c++;      an=an&a[i];     }     if(an!=mi && c>=2)     {      cout<<0<<endl;     }     else     {      cout<<((((((c*(c-1))/2)%mod)*fact[n-2])%mod)*2)%mod<<endl;     }    }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n, i, t, j, p, q, a, b, m;     cin >> t;     while (t--) {       cin >> n >> m;       string s[n];       bool ck = true;       ;       p = (n * m);       if (p % 2 == 0)         a = (p / 2) - 1;       else         a = p / 2;       for (i = 0; i < n; i++) {         for (j = 0; j < m; j++) {           if (!ck && a) {             s[i] +=  W ;             a--;             ck = true;             continue;           } else {             s[i] +=  B ;             ck = false;             continue;           }         }       }       if (p % 2 == 0) {         s[n - 2][m - 2] =  W ;         s[n - 2][m - 1] =  B ;       }       for (i = 0; i < n; i++) cout << s[i] << endl;     }     return;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > arr;   double ans = 0;   void dfs(int x, int h, int p) {     ans += 1.0 / h;     for (int i = 0; i < arr[x].size(); i++) {       if (arr[x][i] != p) dfs(arr[x][i], h + 1, x);     }   }   int main() {     int n;     cin >> n;     int x, y;     arr.resize(n + 1);     for (int i = 0; i < n - 1; i++) {       cin >> x >> y;       arr[x].push_back(y);       arr[y].push_back(x);     }     dfs(1, 1, -1);     printf( %0.7f , ans);   }
#include <bits/stdc++.h>   using namespace std;   int MOD = 1e9 + 7;   long long int power(long long int a, long long int b) {     long long int res = 1;     a = a % MOD;     while (b > 0) {       if (b & 1) {         res = (res * a) % MOD;         b--;       }       a = (a * a) % MOD;       b >>= 1;     }     return res;   }   long long int fermat_inv(long long int y) { return power(y, MOD - 2); }   long long int gcd(long long int a, long long int b) {     return (b == 0) ? a : gcd(b, a % b);   }   long long int min(long long int a, long long int b) { return (a > b) ? b : a; }   long long int max(long long int a, long long int b) { return (a > b) ? a : b; }   using cd = complex<double>;   const double PI = acos(-1);   void fft(vector<cd> &a, bool invert) {     int n = a.size();     for (int i = 1, j = 0; i < n; i++) {       int bit = n >> 1;       for (; j & bit; bit >>= 1) j ^= bit;       j ^= bit;       if (i < j) swap(a[i], a[j]);     }     for (int len = 2; len <= n; len <<= 1) {       double ang = 2 * PI / len * (invert ? -1 : 1);       cd wlen(cos(ang), sin(ang));       for (int i = 0; i < n; i += len) {         cd w(1);         for (int j = 0; j < len / 2; j++) {           cd u = a[i + j], v = a[i + j + len / 2] * w;           a[i + j] = u + v;           a[i + j + len / 2] = u - v;           w *= wlen;         }       }     }     if (invert) {       for (cd &x : a) x /= n;     }   }   vector<int> mult(vector<int> &a, vector<int> &b) {     int n = 1;     while (n < 2 * max(a.size(), b.size())) n <<= 1;     vector<cd> A((a).begin(), (a).end()), B((b).begin(), (b).end());     A.resize(n);     B.resize(n);     fft(A, false);     fft(B, false);     vector<cd> C(n);     for (int i = 0; i < n; i++) C[i] = A[i] * B[i];     fft(C, true);     vector<int> ans(n);     for (int i = 0; i < n; i++) ans[i] = round(C[i].real());     return ans;   }   int f[1000005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int te = 1;     while (te--) {       int n, x, y;       cin >> n >> x >> y;       vector<int> a(x + 1), b(x + 1);       for (int i = 0; i <= n; i++) {         int z;         cin >> z;         a[z] = 1;         b[x - z] = 1;       }       vector<int> v = mult(a, b);       fill(f, f + 1000005, -1);       for (int i = x + 1; i < v.size(); i++) {         if (v[i]) {           int val = 2 * (i - x) + 2 * y;           for (int j = val; j <= 1000000; j += val) f[j] = val;         }       }       int q;       cin >> q;       for (int i = 0; i < q; i++) {         int l;         cin >> l;         cout << f[l] <<    ;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> tree[2010];   int cs[2010], ps[2010];   int numDesc(int node) {     int descendants = 0;     for (int x : tree[node]) {       descendants += 1 + numDesc(x);     }     if (descendants < cs[node]) return 10000;     return descendants;   }   void solve(int node, vector<int>& order) {     ps[node] = order[cs[node]];     order.erase(order.begin() + cs[node]);     for (int x : tree[node]) solve(x, order);   }   int main() {     int n;     cin >> n;     int root;     for (int i = 1; i <= n; i++) {       int p, c;       cin >> p >> c;       cs[i] = c;       if (p == 0) {         root = i;         continue;       }       tree[p].push_back(i);     }     if (numDesc(root) > 5000)       cout <<  NO ;     else {       vector<int> order(n);       order[0] = 1;       for (int i = 1; i < n; i++) order[i] = order[i - 1] + 1;       solve(root, order);       cout <<  YES n ;       for (int i = 1; i < n; i++) cout << ps[i] <<    ;       cout << ps[n];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   char s[110];   int main() {     while (~scanf( %s , s) && s[0] !=  e ) {       char op[10];       int x = 0, y = 0, p, ans = 0;       for (int i = 0; i <= 30; i++) {         x = (i == 0 ? 0 : 1 << (i - 1));         y = 1 << i;         cout <<  ?   << x <<     << y << endl;         cin >> op;         if (op[0] ==  x ) {           p = i - 1;           break;         }       }       if (p != -1) {         ans = 1 << p;         for (int i = p - 1; i >= 0; i--) {           y = 1 << i;           cout <<  ?   << ans <<     << ans + y << endl;           cin >> op;           if (op[0] ==  y ) ans += y;         }       }       cout <<  !   << ans + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, m, u, v, cnt = 0;   long long head[400005], depth[200005], visited[200005];   vector<long long> ve[5];   struct edge {     long long next;     long long to;   } e[400005];   queue<long long> q;   inline void add_edge(long long u, long long v) {     cnt++;     e[cnt].to = v;     e[cnt].next = head[u];     head[u] = cnt;   }   inline void bfs() {     q.push(1);     depth[1] = 0;     visited[1] = 1;     while (!q.empty()) {       long long now = q.front();       for (long long i = head[now]; i; i = e[i].next) {         if (visited[e[i].to] == 0) {           depth[e[i].to] = depth[now] + 1;           q.push(e[i].to);           visited[e[i].to] = 1;         }       }       visited[now] = 1;       q.pop();     }   }   signed main() {     cin >> t;     while (t--) {       cin >> n >> m;       cnt = 0;       for (long long i = 0; i <= 1; i++) ve[i].clear();       for (long long i = 1; i <= n; i++) visited[i] = 0;       for (long long i = 1; i <= 2 * n; i++) head[i] = e[i].next = e[i].to = 0;       for (long long i = 1; i <= m; i++) {         cin >> u >> v;         add_edge(u, v);         add_edge(v, u);       }       bfs();       for (long long i = 1; i <= n; i++) ve[depth[i] % 2].push_back(i);       if (ve[0].size() <= ve[1].size()) {         cout << ve[0].size() << endl;         for (long long i = 0; i < ve[0].size(); i++) cout << ve[0][i] <<    ;         cout << endl;       } else {         cout << ve[1].size() << endl;         for (long long i = 0; i < ve[1].size(); i++) cout << ve[1][i] <<    ;         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 2e18;   const long long INFINT = 2e9;   const int N = 1000006;   const int NN = 1006;   const int MOD = 1000000007;   int main() {     ios_base::sync_with_stdio(0);     long double n, h;     cin >> n >> h;     long double s = 1.0 * 1 * h / 2;     long double k = 1.0 * s / n;     long double mda = k;     for (int i = 0; i < n - 1; i++) {       long double l = 0;       long double r = h;       for (int it = 0; it < 10000; it++) {         long double mid = 1.0 * (l + r) / 2;         if ((1.0 * mid / h) * mid / 2 < k) {           l = mid;         } else {           r = mid;         }       }       cout << fixed << setprecision(9) << l <<    ;       k = mda * (i + 2);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e5 + 9;   long long power(long long x, long long y) {     if (y == 0) return 1;     long long temp = power(x, y / 2);     if (y % 2 == 1)       return temp * temp * x;     else       return temp * temp;   }   bool check(string a, string b) {     sort(a.begin(), a.end());     sort(b.begin(), b.end());     if (a == b) return true;     return false;   }   string solve(string x) {     int n = x.length();     if (n % 2) return x;     string a = solve(x.substr(0, n / 2));     string b = solve(x.substr(n / 2, n));     return a < b ? (a + b) : (b + a);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string a, b;     cin >> a >> b;     if (solve(a) == solve(b))       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, p, q, c, x, y, mod, lo[100000], z[3005][3005];   long long ans;   struct segment_tree {     int a[3005][13];     void update(int x, int y) { a[x][0] = y; }     void build(int n) {       for (int i = 1; i <= lo[n]; i++)         for (int j = 1; j + (1 << i) - 1 <= n; j++)           a[j][i] = min(a[j][i - 1], a[j + (1 << (i - 1))][i - 1]);     }     long long find(int x, int y) {       int len = lo[y - x + 1];       return min(a[x][len], a[y - (1 << len) + 1][len]);     }   } a;   int main() {     scanf( %d%d%d%d , &n, &m, &p, &q);     scanf( %d%d%d%d , &c, &x, &y, &mod);     a.update(1, c);     for (int i = 2; i <= 10000; i++) lo[i] = lo[i >> 1] + 1;     for (int i = 2; i <= m; i++) c = (1ll * c * x + y) % mod, a.update(i, c);     a.build(m);     for (int i = 1; i <= m - q + 1; i++) z[1][i] = a.find(i, i + q - 1);     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= m; j++) c = (1ll * c * x + y) % mod, a.update(j, c);       a.build(m);       for (int j = 1; j <= m - q + 1; j++) z[i][j] = a.find(j, j + q - 1);     }     for (int i = 1; i <= m - q + 1; i++) {       for (int j = 1; j <= n; j++) a.update(j, z[j][i]);       a.build(n);       for (int j = 1; j <= n - p + 1; j++) ans = ans + a.find(j, j + p - 1);     }     printf( %lld , ans);   }
#include <bits/stdc++.h>   using namespace std;   int t, k;   int main() {     cin >> t;     while (t--) {       vector<vector<pair<int, int>>> graph;       cin >> k;       graph.resize(2 * k);       for (int i = 0; i < 2 * k - 1; ++i) {         int a, b, c;         cin >> a >> b >> c;         a--;         b--;         graph[a].emplace_back(b, c);         graph[b].emplace_back(a, c);       }       vector<int> parent(2 * k, -1);       vector<long long> cost(2 * k);       vector<int> que(1, 0);       parent[0] = 0;       for (int i = 0; i < que.size(); ++i) {         int t = que[i];         for (auto it : graph[t]) {           if (parent[it.first] == -1) {             parent[it.first] = t;             cost[it.first] = it.second;             que.emplace_back(it.first);           }         }       }       long long mn = 0, mx = 0;       vector<int> size(2 * k, 1);       reverse(que.begin(), que.end());       for (int i : que) {         size[parent[i]] += size[i];         mx += cost[i] * min(2 * k - size[i], size[i]);         mn += cost[i] * (size[i] & 1);       }       cout << mn <<     << mx << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int bit[200050];   int n;   int lowbit(int x) { return x & (-x); }   int sum(int x) {     int sum = 0;     while (x > 0) {       sum += bit[x];       x -= lowbit(x);     }     return sum;   }   void push(int pos, int num) {     while (pos <= n) {       bit[pos] += num;       pos += lowbit(pos);     }   }   int kth(int k) {     int num = 0;     int x = 0;     for (int i = 1 << 18; i > 0; i >>= 1) {       num += i;       if (num >= n || x + bit[num] >= k)         num -= i;       else         x += bit[num];     }     return num + 1;   }   int main() {     scanf( %d , &n);     int a[200050];     int x;     memset((bit), (0), sizeof((bit)));     for (int i = 0; i < n; i++) {       scanf( %d , &x);       push(x + 1, 1);       a[i] = x - sum(x);     }     memset((bit), (0), sizeof((bit)));     for (int i = 0; i < n; i++) {       scanf( %d , &x);       push(x + 1, 1);       a[i] += x - sum(x);     }     for (int i = n - 1; i > 0; i--) {       if (a[i] >= n - i) {         a[i - 1]++;         a[i] -= n - i;       }     }     if (a[0] >= n) a[0] -= n;     for (int i = 0; i < n; i++) {       int num = kth(a[i] + 1);       printf( %d  , num - 1);       push(num, -1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long T, n, k, a, b;     cin >> T;     while (T--) {       cin >> n >> k >> a >> b;       n -= k;       bool flag = 0;       if (a < b) swap(a, b);       if ((2 * a + b) <= n && (n - 2 * a - b) % 3 == 0 && (2 * b + a) <= k &&           (k - 2 * b - a) % 3 == 0)         flag = 1;       if (2 * b + a <= n && (n - 2 * b - a) % 3 == 0 && (2 * a + b) <= k &&           (k - 2 * a - b) % 3 == 0)         flag = 1;       if (2 * a - b <= n && (n - 2 * a + b) % 3 == 0 && (a + b) <= k &&           (k - a - b) % 3 == 0)         flag = 1;       if (a + b <= n && (n - a - b) % 3 == 0 && (2 * a - b) <= k &&           (k - 2 * a + b) % 3 == 0)         flag = 1;       if (flag)         cout <<  yes  << endl;       else         cout <<  no  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool prime(long long x) {     if (x == 2) return 1;     if (x % 2 == 0) return 0;     for (long long j = 3; j * j <= x; j += 2) {       if (x % j == 0) return 0;     }     return 1;   }   int main() {     long long t;     cin >> t;     while (t--) {       long long n, m;       cin >> n >> m;       if (n - m > 1) {         cout <<  NO  << endl;       } else {         if (prime(n + m)) {           cout <<  YES  << endl;         } else {           cout <<  NO  << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(time(0));   const long long inf = 0x3f3f3f3f3f3f3f3fLL;   const long long N = 35;   const long long MOD = 1e9 + 7;   long long n, u, r, ans = -inf;   long long a[N], b[N], k[N], p[N], dp[N][N];   void go(long long pos, long long lst) {     if ((u - pos) % 2 == 0) {       long long cur = 0;       for (long long i = 1; i <= n; i++) cur += dp[pos][i] * k[i];       ans = max(ans, cur);       if (pos == u) return;     }     if (!lst) {       for (long long i = 1; i <= n; i++) dp[pos + 1][i] = dp[pos][i] ^ b[i];       go(pos + 1, 1);     }     for (long long i = 1; i <= n; i++) dp[pos + 1][i] = dp[pos][p[i]] + r;     go(pos + 1, 0);   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> u >> r;     for (long long i = 1; i <= n; i++) cin >> a[i], dp[0][i] = a[i];     for (long long i = 1; i <= n; i++) cin >> b[i];     for (long long i = 1; i <= n; i++) cin >> k[i];     for (long long i = 1; i <= n; i++) cin >> p[i];     go(0, 0);     cout << ans;     return 0;   }
#include <iostream>   #include <algorithm>   #define int long long   using namespace std;   void solve () {    int a, b, c, d;    cin >> a >> b >> c >> d;    int arr[4] = {a,b,c,d};    sort (arr, arr+4);    int max1 = arr[4-1];    int max2 = arr[4-2];    int win1 = max (a, b);    int win2 = max (c, d);    if (win1 == max1 && win2 == max2){     cout <<  YES  <<   n ;     return;    }    if (win1 == max2 && win2 == max1){     cout <<  YES  <<   n ;     return;    }    cout <<  NO  <<   n ;   }   signed main () {    ios_base::sync_with_stdio (0);cin.tie (0);    int t; cin >> t;    while (t--) {     solve ();    }    }