malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int log(int x) { return 32 - __builtin_clz(x) - 1; }   int log(long long x) { return 64 - __builtin_clzll(x) - 1; }   int n;   int main() {     cin >> n;     if (n % 2 == 0) {       cout <<  NO ;       return 0;     }     cout <<  YES n ;     bool add = false;     for (int i = 1; i < 2 * n; i += 2, add = !add) cout << i + add <<    ;     add = true;     for (int i = 1; i < 2 * n; i += 2, add = !add) cout << i + add <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 5e5 + 100;   const long long maxN = 6e6;   const long long oo = 1e18;   const long long mod = 998244353;   long long n, m;   long long a[N], b[N], cost[N], equalpos[N];   long long IT[20 * N], lazy[20 * N];   map<long long, long long> mp;   void updmin(long long &x, long long y) { x = min(x, y); }   void addlazy(long long node, long long nlef, long long nrig) {     if (nlef > nrig || !lazy[node]) return;     if (nlef == nrig && IT[node] < oo) IT[node] += lazy[node];     if (nlef < nrig) {       lazy[2 * node] += lazy[node];       lazy[2 * node + 1] += lazy[node];     }     lazy[node] = 0;   }   void upd(long long node, long long nlef, long long nrig, long long lef,            long long rig, long long val, bool flag) {     addlazy(node, nlef, nrig);     if (nlef > rig || nrig < lef || nlef > nrig) return;     if (lef <= nlef && nrig <= rig) {       if (!flag) {         lazy[node] += val;         addlazy(node, nlef, nrig);       } else         IT[node] = val;       return;     }     long long mid = (nlef + nrig) / 2;     upd(2 * node, nlef, mid, lef, rig, val, flag);     upd(2 * node + 1, mid + 1, nrig, lef, rig, val, flag);   }   long long get(long long node, long long nlef, long long nrig, long long pos) {     addlazy(node, nlef, nrig);     if (nlef > pos || pos > nrig) return oo;     if (nlef == nrig) {       return IT[node];     }     long long mid = (nlef + nrig) / 2;     return min(get(2 * node, nlef, mid, pos),                get(2 * node + 1, mid + 1, nrig, pos));   }   signed main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin >> n;     for (long long i = 1; i <= n; ++i) cin >> a[i];     for (long long i = 1; i <= n; ++i) cin >> cost[i];     cin >> m;     for (long long i = 1; i <= m; ++i) cin >> b[i], mp[b[i]] = i;     for (long long i = 1; i <= n; ++i)       if (mp.find(a[i]) != mp.end()) equalpos[i] = mp[a[i]];     for (long long i = 0; i <= 20 * N - 1; ++i) IT[i] = oo;     if (a[1] < b[1])       upd(1, 0, m, 0, 0, cost[1], 1);     else if (a[1] == b[1]) {       upd(1, 0, m, 0, 0, cost[1], 1);       upd(1, 0, m, 1, 1, 0, 1);     } else       upd(1, 0, m, 0, 0, cost[1], 1);     for (long long i = 2; i <= n; ++i) {       long long pos = equalpos[i];       if (pos) {         long long val = get(1, 0, m, pos - 1);         long long tmp = get(1, 0, m, pos);         if (cost[i] < 0 && tmp < oo) updmin(val, tmp + cost[i]);         updmin(val, get(1, 0, m, pos));         upd(1, 0, m, pos, pos, val, 1);       }       pos = lower_bound(b + 1, b + m + 1, a[i]) - b - 1;       if (pos >= 0)         upd(1, 0, m, 0, pos, cost[i], 0);       else         pos = 0;       while (pos <= m && b[pos] <= a[i]) pos += 1;       if (cost[i] < 0 && pos <= m) upd(1, 0, m, pos, m, cost[i], 0);     }     long long ans = get(1, 0, m, m);     if (ans < oo) return cout <<  YES n  << ans, 0;     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   mt19937_64 rnd;   const long long maxn = 1e6 + 10;   const long long mod = 998244353;   const long long base = 500;   long long gt[maxn];   long long gtv[maxn];   long long mu(long long a, long long n) {     if (n == 0) return 1;     if (n == 1) return a;     long long t = mu(a, n / 2);     if (n % 2 == 0) return (t * t) % mod;     return ((t * t) % mod * a) % mod;   }   void setup() {     gt[0] = 1;     for (int i = 1; i < maxn; i++) {       gt[i] = (gt[i - 1] * i) % mod;     }     gtv[maxn - 1] = mu(gt[maxn - 1], mod - 2);     for (int i = maxn - 2; i >= 0; i--) {       gtv[i] = (gtv[i + 1] * (i + 1)) % mod;     }   }   long long nck(long long n, long long k) {     if (n < k) return 0;     return ((gt[n] * gtv[k]) % mod * gtv[n - k]) % mod;   }   long long f[maxn];   long long f1[maxn];   long long f2[maxn];   long long dp[maxn][2];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     if (fopen( t.inp ,  r )) {       freopen( test.inp ,  r , stdin);       freopen( test.out ,  w , stdout);     }     setup();     string s;     cin >> s;     long long n = s.length();     s =     + s;     for (int i = 1; i <= n; i++) {       f[i] = f[i - 1] + (s[i] ==  ( );       f1[i] = f1[i - 1] + (s[i] ==  ? );       f2[i] = f2[i - 1] + (s[i] ==  ) );     }     long long all = f1[n];     for (int j = 0; j <= min(all, 1ll); j++) {       for (int i = 0; i <= n; i++) {         dp[i][j] = ((i > 0 ? dp[i - 1][j] : 0) + nck(all - j, i)) % mod;       }     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       if (s[i] ==  ) ) continue;       long long a = f[i - 1];       long long b = f2[n] - f2[i];       long long c = f1[i - 1];       long long d = f1[n] - f1[i];       if (d + b - a > 0) ans = (ans + dp[d + b - a - 1][s[i] ==  ? ]) % mod;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     string a, b;     cin >> a >> b;     int one[2];     one[0] = one[1] = 0;     for (char ch : a) one[0] += ch ==  1  ? 1 : 0;     for (char ch : b) one[1] += ch ==  1  ? 1 : 0;     if (one[0] + (one[0] & 1) >= one[1])       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int arr[100005];     int pos[100005], pr[100005] = {0};     int i, j, ans = 0;     for (i = 0; i < n; i++) {       cin >> arr[i];       if (pr[arr[i]] == 0) ans++;       pr[arr[i]]++;       pos[arr[i]] = i;       if (ans == k) {         j = i;         break;       }     }     for (i = j + 1; i < n; i++) cin >> arr[i];     if (ans < k)       cout <<  -1 -1 ;     else {       int min = j + 1;       for (i = 0; i < j; i++) {         if (pos[arr[i]] < min) min = pos[arr[i]];       }       if (j != 0)         cout << min + 1 <<     << j + 1;       else         cout <<  1 1 ;     }     return (0);   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, T, x, y, x2, y2, a, b, sol = 1;   char c;   string s;   bool t;   vector<int> V;   vector<int> V2;   int p, p2, mn = INT_MAX;   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> x;       V.push_back(x);     }     for (int i = 0; i < m; i++) {       cin >> x;       V2.push_back(x);     }     p = n - 1;     for (int i = 0; i < m - 1; i++) {       x = V2[m - i - 1];       while (p >= 0 && V[p] > x) {         p--;       }       if (p < 0) {         cout << 0;         return 0;       }       if (V[p] < x) sol = 0;       p2 = p;       while (p >= 0 && V[p2] >= x) {         p2--;       }       if (p2 < 0) {         cout << 0;         return 0;       }       sol *= p - p2;       sol %= 998244353;       p = p2;     }     x = V2[0];     for (int i = 0; i <= p; i++) {       mn = min(V[i], mn);     }     if (mn != x) sol = 0;     cout << sol;   }
#include <bits/stdc++.h>   using namespace std;   int s[400], n, ret = 360;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       int t;       cin >> t;       s[i] = s[i - 1] + t;     }     for (int i = 0; i < n; i++) {       for (int j = i + 1; j <= n; j++) {         ret = min(ret, abs(360 - 2 * (s[j] - s[i])));       }     }     cout << ret << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   const int M = 1e4 + 5;   const int Max = (1 << 26) + 5;   short a[Max];   int n, m, b[M], ans[M];   char str[N], sets[30];   int main() {     scanf( %s , str + 1);     n = strlen(str + 1);     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       scanf( %s , sets);       int len = strlen(sets);       for (int j = 0; j < len; j++) b[i] |= 1 << (sets[j] -  a );       a[b[i]] = i;     }     for (int i = 1; i <= n; i++)       for (int j = i, s = 0; j <= n; j++) {         if (str[j] == str[i - 1]) break;         s |= 1 << (str[j] -  a );         if (!(s >> (str[j + 1] -  a ) & 1)) ans[a[s]]++;       }     for (int i = 1; i <= m; i++) printf( %d n , ans[a[b[i]]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, d, h;     cin >> n >> d >> h;     if (h * 2 < d) {       cout << -1;       return 0;     }     if (d == 1) {       if (n >= 3) {         cout << -1;         return 0;       }       if (n == 2) {         cout << 1 <<     << 2;         return 0;       }     }     for (int i = 2; i <= h + 1; i++) {       cout << i <<     << i - 1 << endl;     }     int b = d - h;     if (b > 0) {       cout << 1 <<     << h + 2 << endl;       for (int i = h + 3; i <= d + 1; i++) {         cout << i <<     << i - 1 << endl;       }     }     int hd = 1;     if (b == 0) {       hd = 2;     }     for (int i = d + 2; i <= n; i++) {       cout << hd <<     << i << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     vector<int> vec(1, 0);     vector<vector<int> > list;     int counter = 0, i, j;     for (i = 0; i < s.length(); i++) {       if (s[i] ==  0 ) {         if (list.size() > counter) {           list[counter].push_back(i);         } else {           vec[0] = i;           list.push_back(vec);         }         counter++;       } else if (s[i] ==  1 ) {         if (counter - 1 < 0) {           cout << -1;           return 0;         } else {           list[--counter].push_back(i);         }       }     }     if (counter < list.size()) {       cout << -1;       return 0;     }     cout << list.size() <<   n ;     for (i = 0; i < list.size(); i++) {       cout << list[i].size() <<    ;       for (j = 0; j < list[i].size(); j++) {         cout << list[i][j] + 1 <<    ;       }       cout <<   n ;     }     return 0;   }
// minako   #include <bits/stdc++.h>   using namespace std;      #define endl   n    #define f first   #define s second   #define pb push_back   #define pii pair<int,int>   #define ll long long   #define pll pair <ll,ll>   #define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);      const ll M = 1e9 + 7;   const int N = 2e5 + 5;   const ll INF = 1e9;   const ll INF2 = 1e18;   const int K = 750;      ll  n,u,v,a[N],q;      int main() {    faster    cin >> q;    while (q--) {     cin >> n >> u >> v;     bool eq = 1,can = 0;     for (int i = 1; i <= n; i++) {      cin >> a[i];      if (a[i] != a[i - 1] && i > 1) eq = 0;      if (abs(a[i] - a[i - 1]) > 1 && i > 1) can = 1;     }     if (can) cout << 0 << endl;     else if (eq) cout << v + min(u,v) << endl;     else cout << min(u,v) << endl;;    }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double EPS = 1E-9;   const int INF = (int)1E9;   const long long INF64 = (long long)1E18;   const long double PI = 2 * acos(.0);   int main() {     string num;     cin >> num;     int a[11];     fill(a, a + 11, 0);     for (int i = 0; i < (int)((num).size()); i++) {       a[num[i] -  0 ]++;     }     int cont = 0;     string temp1 = num;     string temp2 = num;     int a2[11];     int a3[11];     bool cent = 1;     for (int i = 1; i < (int)(10); i++) {       int temp = 0;       char kk1 =  s , kk2 =  s ;       vector<pair<char, int> > t1;       vector<pair<char, int> > t2;       for (int j = 0; j < (int)(10); j++) a2[j] = a3[j] = a[j];       if (a2[i] > 0 && a3[10 - i] > 0) {         a2[i]--;         a3[10 - i]--;         kk1 =  0  + i;         kk2 =  0  + (10 - i);       } else         continue;       temp = 1;       for (int j = 0; j < (int)(10); j++) {         int mini = min(a2[j], a3[9 - j]);         temp += mini;         a2[j] -= mini;         a3[9 - j] -= mini;         t1.push_back(make_pair( 0  + j, mini));         t2.push_back(make_pair( 0  + (9 - j), mini));       }       temp += min(a2[0], a3[0]);       int conta = min(a2[0], a3[0]);       a2[0] -= conta;       a3[0] -= conta;       if (temp > cont) {         cent = 0;         temp1 =   ;         temp2 =   ;         for (int j = 0; j < (int)(10); j++) {           if (a2[j] > 0) temp1.append(a2[j],  0  + j);           if (a3[j] > 0) temp2.append(a3[j],  0  + j);         }         for (int j = 0; j < (int)((t1).size()); j++) {           temp1.append(t1[j].second, t1[j].first);           temp2.append(t2[j].second, t2[j].first);         }         temp1 += kk1;         temp2 += kk2;         temp1.append(conta,  0 );         temp2.append(conta,  0 );         cont = temp;       }     }     if (cent) {       temp1 =   ;       temp2 =   ;       for (int j = 1; j < (int)(10); j++) {         if (a[j] > 0) temp1.append(a[j],  0  + j);         if (a[j] > 0) temp2.append(a[j],  0  + j);       }       temp1.append(a[0],  0 );       temp2.append(a[0],  0 );     }     cout << temp1 << endl << temp2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string presidents[41] = {         ,          Washington ,  Adams ,      Jefferson ,  Madison ,        Monroe ,    Adams ,       Jackson ,    Van Buren ,  Harrison ,        Tyler ,     Polk ,        Taylor ,     Fillmore ,   Pierce ,        Buchanan ,  Lincoln ,     Johnson ,    Grant ,      Hayes ,        Garfield ,  Arthur ,      Cleveland ,  Harrison ,   Cleveland ,        McKinley ,  Roosevelt ,   Taft ,       Wilson ,     Harding ,        Coolidge ,  Hoover ,      Roosevelt ,  Truman ,     Eisenhower ,        Kennedy ,   Johnson ,     Nixon ,      Ford ,       Carter ,        Reagan ,   };   int main() {     int n;     cin >> n;     cout << presidents[n] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     cin >> n >> m;     long long t = 1;     if (n < 30) {       for (int i = 0; i < n; i++) {         t *= 2;       }       cout << m % t;     } else {       cout << m;     }     return 0;   }
//Shrey Dubey         #include<iostream>   #include<string>   #include<algorithm>   #include<map>   #include<unordered_map>   #include<vector>   #include<set>   #include<list>   #include<iomanip>   #include<queue>   #include<stack>   #include <math.h>   #include<climits>   #include<bitset>   #include<cstring>   #include<numeric>   #include<array>         using namespace std;   typedef long long ll;   typedef long double ld;      #define YES cout<< YES n    #define Yes cout<< Yes n    #define NO cout<< NO n    #define No cout<< No n    #define prDouble(x) cout<<fixed<<setprecision(10)<<x //to print decimal numbers   #define pb push_back   #define ff first   #define sec second   #define umap unordered_map   #define mp make_pair   #define KOBE ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)   #define fo(n) for(ll i = 0; i<n; i++)   #define fnd(stl, data) find(stl.begin(), stl.end(), data)   #define forn(x,n) for(ll x = 0; x<n; x++)   #define imax INT_MAX   #define lmax LLONG_MAX   #define imin INT_MIN   #define lmin LLONG_MIN   #define vi vector<int>   #define vl vector<ll>   #define vp vector<pair<ll,ll> >   #define vb vector<bool>   #define pr(t) cout<<t<<  n    #define int long long   #define ql queue<ll>   #define qp queue<pair<ll,ll> >   #define endl   n    #define nl cout<<  n    #define re cin >>   #define pll pair<ll,ll>   #define FOR(a,b) for(ll i = a; i<=b; i++)   #define all(x) x.begin(),x.end()      // ll dx[] = {1,0,-1,0};   // ll dy[] = {0,1,0,-1};      ll mod = 1e9 + 7;      ll cl(ld a){       if(a>(ll) a){           return (ll)a+1;       }       else{           return (ll)a;       }   }      ll flr(ld a){       return (ll) a;   }            //code starts here      const ll M = 2e5+100;   ll s[M];      ll n,m,a,b;   bool check(ll pos){       ll diff = abs(b - a);       ll t = diff;       if(diff > pos){           if(a > b){               t += (n - a);           }else{               t += (a - 1);           }       }       // if(pos == 1) cout<<t<< () n ;       while(pos > 0){           if(s[pos] >= t) return false;           t--;           pos--;       }       return true;   }      void solve(){       re n; re m; re a; re b;       fo(m) re s[i+1];       sort(s+1,s+m+1);       // fo(m) cout<<s[i+1]<<   ;nl;       ll ans = 0;       ll s = 0, e = m;       while(s <= e){           // cout<<s<< () <<e<<  n ;           ll mid = (s+e)/2;           if(check(mid)){               ans = mid;               s = mid+1;           }else{               e = mid-1;           }       }       pr(ans);   }      int32_t main(){       KOBE;       ll t;       t = 1;       re t;       while(t--) solve();   }         //common errors   // row - n, col - m always and loop var   // see the freq of numbers carefully   // see if there s array overflow   // use map for large inputs         //problem ideas   //check piegonhole wherever possible   //there might be many instances of limited answers like 0,1,2 only   // see suffix and prefix   //don t be obsessed with binary search   // try to find repeating pattern in matrices
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int MAXN = 1000000;   int n;   char s[MAXN + 1];   int pac[MAXN], npac;   int ast[MAXN], nast;   int prvpac[MAXN], prvast[MAXN];   int mxpos[MAXN];   bool canrgt[MAXN];   int calcmxpos(int i, int t) {     int x = i - t >= 0 ? prvast[i - t] : -1;     if (x == -1) return prvpac[i] == -1 ? i : max(i, prvpac[i] + t);     if (prvpac[i] == -1 || prvpac[i] <= x) return canrgt[x] ? i : -1;     if (prvpac[prvpac[i]] != -1 && prvpac[prvpac[i]] > x)       return mxpos[prvpac[prvpac[i]]] != -1 ? max(i, prvpac[i] + t) : -1;     return canrgt[x] ? max(i, prvpac[i] + t) : mxpos[prvpac[i]] != -1 ? i : -1;   }   bool calccanrgt(int x, int t) {     int i = prvpac[x];     if (i == -1 || x - i > t) return false;     int y = prvast[i];     return mxpos[i] != -1 && mxpos[i] >= x || y == -1 ||            (prvpac[i] != -1 && prvpac[i] > y && mxpos[prvpac[i]] != -1) ||            canrgt[y];   }   bool canall(int t) {     for (int i = (0); i < (n); ++i) {       if (s[i] ==  P ) {         mxpos[i] = calcmxpos(i, t);       }       if (s[i] ==  * ) {         canrgt[i] = calccanrgt(i, t);       }     }     int idx = max(pac[npac - 1], ast[nast - 1]);     if (s[idx] ==  P )       return mxpos[idx] != -1;     else if (s[idx] ==  * )       return canrgt[idx];     else {       assert(false);       return false;     }   }   pair<int, int> solve() {     npac = nast = 0;     for (int i = (0); i < (n); ++i) {       prvast[i] = nast == 0 ? -1 : ast[nast - 1];       prvpac[i] = npac == 0 ? -1 : pac[npac - 1];       if (s[i] ==  P )         pac[npac++] = i;       else if (s[i] ==  * )         ast[nast++] = i;     }     assert(npac > 0 && nast > 0);     if (npac == 1) {       int nleft = 0, tleft = 0, nright = 0, tright = 0;       for (int i = (0); i < (nast); ++i)         if (ast[i] < pac[0]) {           ++nleft;           tleft = max(tleft, pac[0] - ast[i]);         } else {           ++nright;           tright = max(tright, ast[i] - pac[0]);         }       if (nleft > nright || nleft == nright && tleft <= tright)         return make_pair(nleft, tleft);       else         return make_pair(nright, tright);     }     int l = 0, r = n - 1;     while (l + 1 < r) {       int m = l + (r - l) / 2;       if (canall(m))         r = m;       else         l = m;     }     return make_pair(nast, r);   }   void run() {     scanf( %d , &n);     scanf( %s , s);     pair<int, int> ans = solve();     printf( %d %d n , ans.first, ans.second);   }   int main() {     run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   const long long llinf = 1ll * inf * inf;   const double eps = 1e-12;   const int N = 1e5 + 10;   int f[N], h[N], g[N];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= int(n); ++i) scanf( %d , &f[i]);     map<int, vector<int> > uf;     for (int i = 1; i <= int(n); ++i) uf[f[i]].push_back(i);     int m = uf.size();     auto itr = uf.begin();     for (int x = 1; x <= m; ++x) {       h[x] = itr->first;       vector<int> nv = itr->second;       itr++;       for (int y : nv) g[y] = x;     }     int bad = 0;     for (int x = 1; x <= m; ++x)       if (g[h[x]] != x) bad = 1;     for (int x = 1; x <= n; ++x)       if (h[g[x]] != f[x]) bad = 1;     if (bad)       puts( -1 );     else {       printf( %d n , m);       for (int x = 1; x <= int(n); ++x) printf( %d%c , g[x], x == n ?   n  :    );       for (int x = 1; x <= int(m); ++x) printf( %d%c , h[x], x == m ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (scanf( %d , &n) != EOF) {       int a[n][n];       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           scanf( %d , &a[i][j]);         }       }       if (n == 1) {         printf( %d n , a[0][0]);         break;       }       int sum = 0;       for (int i = 1; i < n - 1; i++) {         for (int j = 1; j < n - 1; j++) {           sum += a[i][j];         }       }       sum += a[0][0] + a[0][n - 1] + a[n - 1][n - 1] + a[n - 1][0];       sum += a[0][(n - 1) / 2] + a[n - 1][(n - 1) / 2] + a[(n - 1) / 2][0] +              a[(n - 1) / 2][n - 1];       printf( %d n , sum);     }   }
#include <bits/stdc++.h>   using namespace std;   const long long S = (1 << 19);   long long x, y, a, q, pref_x[S], pref_y[S], ans[S];   pair<long long, long long> tab[S];   vector<pair<pair<long long, long long>, pair<long long, long long> > > X;   int main() {     ios_base::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     cin >> a >> q;     for (int i = 1; i <= a; i++) {       cin >> x >> y;       tab[i] = {x, y};       X.push_back({{x - y, i}, {x, y}});     }     sort(X.begin(), X.end());     for (int i = 1; i <= X.size(); i++)       pref_x[i] = pref_x[i - 1] + X[i - 1].second.first,       pref_y[i] = pref_y[i - 1] + X[i - 1].second.second;     for (int i = 0; i < X.size(); i++) {       ans[X[i].first.second] += pref_x[i] + i * X[i].second.second;       ans[X[i].first.second] += pref_y[X.size()] - pref_y[i + 1] +                                 (X.size() - 1 - i) * X[i].second.first;     }     for (int i = 0; i < q; i++) {       cin >> x >> y;       long long res =           min(tab[x].first + tab[y].second, tab[x].second + tab[y].first);       ans[x] -= res;       ans[y] -= res;     }     for (int i = 1; i <= X.size(); i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long b[n], c[n];     for (int i = 0; i < n; i++) cin >> b[i];     for (int i = 0; i < n; i++) cin >> c[i];     long long d[n], a[n], sum = 0;     for (int i = 0; i < n; i++) {       d[i] = b[i] + c[i];       sum += d[i];     }     sum /= (2 * n);     bool flag = true;     long long k[64];     for (int j = 0; j < 63; j++) k[j] = 0;     for (int i = 0; i < n; i++) {       a[i] = (d[i] - sum) / n;       if (a[i] < 0) {         flag = false;         break;       }       for (int j = 0; j < 63; j++)         if (a[i] & (1LL << j)) k[j]++;     }     for (int i = 0; i < n && flag; i++) {       long long num1 = 0, num2 = 0;       for (int j = 0; j < 63; j++) {         long long tmp = 1LL << j;         if (a[i] & tmp) {           num1 += k[j] << j;           num2 += n << j;         } else {           num2 += k[j] << j;         }       }       if (num1 != b[i] || num2 != c[i]) {         flag = false;         break;       }     }     if (flag) {       for (int i = 0; i < n; i++) cout << a[i] <<    ;       cout << endl;     } else       cout <<  -1 n ;     return 0;   }