malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int a[100005];   bool vis1[100005], vis2[100005];   vector<int> e1[100005], e2[100005];   queue<int> q1, q2;   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       e1[x].push_back(y);       e2[y].push_back(x);     }     for (int i = 1; i <= n; i++) {       if (a[i] == 1) {         vis1[i] = 1;         q1.push(i);       }     }     while (!q1.empty()) {       int now = q1.front();       q1.pop();       for (int i = 0; i < e1[now].size(); i++) {         int v = e1[now][i];         if (a[v] == 1 || vis1[v]) continue;         vis1[v] = 1;         q1.push(v);       }     }     for (int i = 1; i <= n; i++) {       if (a[i] == 2) {         vis2[i] = 1;         q2.push(i);       }     }     while (!q2.empty()) {       int now = q2.front();       q2.pop();       for (int i = 0; i < e2[now].size(); i++) {         int v = e2[now][i];         if (a[v] == 1) vis2[v] = 1;         if (a[v] == 1 || vis2[v]) continue;         vis2[v] = 1;         q2.push(v);       }     }     for (int i = 1; i <= n; i++)       if (vis1[i] && vis2[i])         printf( 1 n );       else         printf( 0 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int m;     cin >> m;     int i;     map<int, int> ipattern;     for (i = 1; i <= n; i++) {       int x;       cin >> x;       ipattern[i] = x;     }     int max = 0;     for (i = 1; i <= n; i++) {       if (ipattern[i] > max) {         max = ipattern[i];       }     }     int r = max % m;     int an = max / m;     if (r == 0)       an = an - 1;     else {       an = an;     }     int j;     if (an == 0) {       cout << n;     } else {       for (j = 1; j <= an; j++) {         for (i = 1; i <= n; i++) {           if ((ipattern[i] - m) <= 0) {             ipattern.erase(i);           } else {             ipattern[i] = ipattern[i] - m;           }         }       }       int y;       for (auto itr = ipattern.begin(); itr != ipattern.end(); ++itr) {         y = itr->first;       }       cout << y << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int w, l;     cin >> w >> l;     int a[w];     long long sum[w];     sum[0] = 0;     for (int i = 1; i < w; i++) {       cin >> a[i];       sum[i] = sum[i - 1] + a[i];     }     long long mn = 100000000000000005;     for (int i = l; i < w; i++) {       mn = min(sum[i] - sum[i - l], mn);     }     cout << mn << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   const int INF = 0x3f3f3f3f;   int arr[N];   int dq[N * 2];   int main() {     int n;     scanf( %d , &n);     int dl = N, dr = N - 1;     for (int i = 0; i < n; i++) {       scanf( %d , &arr[i]);       if (arr[i] == 1) {         dr++;         dq[dr] = i;       }     }     long long ans = 0;     int l = 0;     for (int i = n - 1; i >= 0; i--) {       int sz = dr - dl + 1;       if (arr[i] >= 3 && (arr[i] & 1)) {         ans++;         arr[i] -= 3;       }       while (dl <= dr) {         if (arr[i] <= 1) break;         if (dq[dr] >= i) {           dr--;           continue;         }         arr[dq[dr]]--;         arr[i] -= 2;         ans++;         dr--;       }       if (!arr[i]) continue;       while (l < i) {         if (!arr[l]) {           l++;           continue;         }         if (arr[l] * 2 >= arr[i]) {           ans += arr[i] / 2;           arr[l] -= arr[i] / 2;           arr[i] = 0;           if (arr[l] == 1) {             dl--;             dq[dl] = l;           }           break;         } else {           ans += arr[l];           arr[i] -= arr[l] * 2;           arr[l] = 0;           l++;         }       }       if (arr[i]) ans += arr[i] / 3;     }     printf( %I64d n , ans);     return 0;   }
#include<iostream>   using namespace std;   void func(int i,int arr[],int ans[]){    if(arr[i]>=i+1){     return ;    }    if(arr[i]==0){    ans[i]=0;        func(i-1,arr,ans);        return;   }    else{     int currpos=i;int destionation=i-(arr[i]-1);     while(currpos>=0){      if(currpos!=destionation){       if(arr[currpos]>=currpos+1)       return;       if(arr[currpos]!=0){       destionation=destionation>currpos-(arr[currpos]-1)?currpos-(arr[currpos]-1):destionation;}      }      else{       if(arr[currpos]>=currpos+1)       return;       if(arr[currpos]==0 or arr[currpos]==1){       func(currpos-1,arr,ans);return;       }       destionation=destionation>currpos-(arr[currpos]-1)?currpos-arr[currpos]+1:destionation;      }      currpos-=1;     }     return ;    }   }   int main(){    int t;cin>>t;    while(t--){     int n;cin>>n;int arr[n];int ans[n];for(int i=0;i<n;i++){      cin>>arr[i];ans[i]=1;     }     func(n-1,arr,ans);     for(int i=0;i<n;i++){      cout<<ans[i]<<   ;     }    }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   int n, z;   vector<int> x;   bool check(int p) {     for (int i = 0; i < p; i++)       if (x[n - p + i] - x[i] < z) return false;     return true;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> z;     x.resize(n);     for (int i = 0; i < n; i++) cin >> x[i];     sort((x).begin(), (x).end());     int l = 0, r = n / 2;     while (l < r) {       int m = (l + r + 1) >> 1;       if (check(m))         l = m;       else         r = m - 1;     }     cout << l;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, i, j, c;     char chr;     cin >> t;     bool first_diag, second_diag;     while (t--) {       cin >> n;       string arr[n];       vector<int> v;       c = 0;       for (i = 0; i < n; i++) cin >> arr[i];       first_diag = (arr[0][1] == arr[1][0]);       second_diag = (arr[n - 2][n - 1] == arr[n - 1][n - 2]);       if (first_diag && second_diag) {         if (arr[n - 2][n - 1] == arr[0][1]) {           c = 2;           v.push_back(1);           v.push_back(2);           v.push_back(2);           v.push_back(1);         }       } else if (first_diag) {         c = 1;         if (arr[n - 1][n - 2] == arr[0][1]) {           v.push_back(n);           v.push_back(n - 1);         } else {           v.push_back(n - 1);           v.push_back(n);         }       } else if (second_diag) {         c = 1;         if (arr[n - 1][n - 2] == arr[0][1]) {           v.push_back(1);           v.push_back(2);         } else {           v.push_back(2);           v.push_back(1);         }       } else {         c = 2;         v.push_back(1);         v.push_back(2);         if (arr[0][1] == arr[n - 2][n - 1]) {           v.push_back(n);           v.push_back(n - 1);         } else {           v.push_back(n - 1);           v.push_back(n);         }       }       cout << c <<   n ;       for (i = 0; i < c; i++) cout << v[2 * i] <<     << v[2 * i + 1] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int n, m, k;     cin >> n >> m >> k;     vector<vector<int> > edges(m, vector<int>(2));     vector<vector<int> > graph(n + 1);     vector<int> degrees(n + 1, 0);     for (int i = 0; i < m; ++i) {       scanf( %d %d , &edges[i][0], &edges[i][1]);       degrees[edges[i][0]]++;       degrees[edges[i][1]]++;       graph[edges[i][0]].push_back(edges[i][1]);       graph[edges[i][1]].push_back(edges[i][0]);     }     map<pair<int, int>, bool> sorted;     for (int i = 0; i < n; ++i)       sorted.insert(make_pair(make_pair(degrees[i + 1], i + 1), 1));     vector<int> ans(m);     for (int i = m - 1; i >= 0; --i) {       while ((!sorted.empty()) and sorted.begin()->first.first < k) {         int temp = sorted.begin()->first.second;         sorted.erase(sorted.begin());         degrees[temp] = 0;         for (int i = 0; i < graph[temp].size(); ++i) {           auto it =               sorted.find(make_pair(degrees[graph[temp][i]], graph[temp][i]));           degrees[graph[temp][i]]--;           if (it != sorted.end()) {             sorted.erase(it);             if (degrees[graph[temp][i]] >= 0)               sorted.insert(make_pair(                   make_pair(degrees[graph[temp][i]], graph[temp][i]), 1));           }         }       }       ans[i] = sorted.size();       graph[edges[i][0]].pop_back();       graph[edges[i][1]].pop_back();       if (degrees[edges[i][0]] >= k and degrees[edges[i][1]] >= k) {         auto it1 = sorted.find(make_pair(degrees[edges[i][0]], edges[i][0]));         auto it2 = sorted.find(make_pair(degrees[edges[i][1]], edges[i][1]));         degrees[edges[i][0]]--;         degrees[edges[i][1]]--;         if (it1 != sorted.end()) {           sorted.erase(it1);           sorted.insert(               make_pair(make_pair(degrees[edges[i][0]], edges[i][0]), 1));         }         if (it2 != sorted.end()) {           sorted.erase(it2);           sorted.insert(               make_pair(make_pair(degrees[edges[i][1]], edges[i][1]), 1));         }       }     }     for (int i = 0; i < m; ++i) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, a, b, res;   int main() {     cin >> n >> m;     for (a = 0; a <= 1000; a++) {       for (b = 0; b <= 1000; b++) {         if (a * a + b == n && a + b * b == m) {           res++;         }       }     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 200009;   int n, q, k, x, s;   vector<pair<int, int> > p;   vector<vector<int> > pb;   set<int> last;   void solve() {     cin >> n;     p.resize(n + 1);     pb.resize(n + 1);     for (int i = 0; i < n; i++) {       cin >> x >> s;       p[i] = {x, s};       pb[x].push_back(i);     }     for (int i = 1; i <= n; i++)       if (pb[i].size() > 0) last.insert(pb[i].back());     last.insert(-1);     for (cin >> q; q; q--) {       cin >> k;       vector<int> esc(k);       for (int i = 0; i < k; i++) {         cin >> esc[i];         if (pb[esc[i]].size() > 0) last.erase(pb[esc[i]].back());       }       pair<int, int> ans = {0, 0};       if (last.size() != 1) {         auto iw = --last.end();         int win = p[*iw].first;         auto bwin = *upper_bound(pb[win].begin(), pb[win].end(), *--iw);         ans = {win, p[bwin].second};       }       cout << ans.first <<     << ans.second << endl;       for (int i = 0; i < k; i++)         if (pb[esc[i]].size() > 0) last.insert(pb[esc[i]].back());     }   }   int main() {     ios_base::sync_with_stdio(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   vector<int> gr[300005];   int n, m;   int col[300005];   void go(int now) {     for (auto to : gr[now]) {       if (col[to]) continue;       col[to] = 3 - col[now];       go(to);     }     int cnt = 0;     for (auto to : gr[now]) {       cnt += (col[to] == col[now]);     }     if (cnt > 1) col[now] = 3 - col[now];   }   int main() {     int i, j;     scanf( %d , &n);     scanf( %d , &m);     for (i = 1; i <= m; i++) {       int u, v;       scanf( %d , &u);       scanf( %d , &v);       gr[u].push_back(v);       gr[v].push_back(u);     }     for (i = 1; i <= n; i++) {       if (col[i]) continue;       col[i] = 1;       go(i);     }     for (i = 1; i <= n; i++) printf( %d , col[i] - 1);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool M[3000][6000];   int dr[] = {-1, -1, -1, 0, 0, 1, 1, 1};   int dc[] = {-1, 0, 1, -1, 1, -1, 0, 1};   int parent[18000000];   int Find(int x) {     if (parent[x] != x) parent[x] = Find(parent[x]);     return parent[x];   }   void Union(int x, int y) {     x = Find(x);     y = Find(y);     parent[x] = y;   }   int R, C;   int id(int r, int c) { return r * 2 * C + c; }   int main() {     int N, r, c;     scanf( %d %d %d , &R, &C, &N);     if (C == 1)       printf( 0 n );     else {       for (int i = R * 2 * C - 1; i >= 0; --i) parent[i] = i;       int ans = 0;       while (N--) {         scanf( %d %d , &r, &c);         --r;         --c;         bool add = true;         for (int k1 = 0; k1 < 8; ++k1) {           int r2 = r + dr[k1], c2 = c + dc[k1];           if (c2 == -1) c2 = 2 * C - 1;           if (c2 == 2 * C) c2 = 0;           if (r2 >= 0 && r2 < R && M[r2][c2]) {             int u = id(r2, c2);             for (int k2 = 0; k2 < 8; ++k2) {               int r3 = r + dr[k2], c3 = c + C + dc[k2];               if (c3 == -1) c3 = 2 * C - 1;               if (c3 == 2 * C) c3 = 0;               if (r3 >= 0 && r3 < R && M[r3][c3]) {                 int v = id(r3, c3);                 if (Find(u) == Find(v)) add = false;               }             }           }         }         if (add) {           ++ans;           M[r][c] = M[r][c + C] = true;           for (int k = 0; k < 8; ++k) {             int r2 = r + dr[k], c2 = c + dc[k];             if (c2 == -1) c2 = 2 * C - 1;             if (c2 == 2 * C) c2 = 0;             if (r2 >= 0 && r2 < R && M[r2][c2]) Union(id(r, c), id(r2, c2));           }           for (int k = 0; k < 8; ++k) {             int r2 = r + dr[k], c2 = c + C + dc[k];             if (c2 == -1) c2 = 2 * C - 1;             if (c2 == 2 * C) c2 = 0;             if (r2 >= 0 && r2 < R && M[r2][c2]) Union(id(r, c + C), id(r2, c2));           }         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:100000000000000 )   using namespace std;   int n, vis[(1 << 21) + 1], col = 1, m, tw[22], cnt[(1 << 21) + 1];   long long dp[(1 << 21) + 1];   string st[55];   long long rep[(1 << 21) + 1];   int count_bit(long long x) {     int ret = 0;     while (x) {       ret++;       x ^= x & (-x);     }     return ret;   }   int main() {     cin >> n;     if (n == 1) {       printf( %.10lf n , 0.);       return 0;     }     for (int i = 0; i < 22; i++) tw[i] = 1 << i;     for (int i = 0; i < n; i++) cin >> st[i];     m = st[0].size();     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++)         if (i != j) {           int msk = 0;           for (int z = 0; z < m; z++)             if (st[i][z] == st[j][z]) msk |= tw[z];           rep[msk] |= 1ll << i;         }     for (int msk = tw[m] - 1; msk >= 0; msk--)       for (int i = 0; i < m; i++)         if (msk & tw[i]) {           rep[msk ^ tw[i]] |= rep[msk];         }     for (int msk = tw[m + 1] - 1; msk >= 0; msk--) cnt[msk] = count_bit(msk);     for (int msk = 0; msk < tw[m]; msk++) {       int c = cnt[msk];       for (int i = 0; i < m; i++)         if (!(msk & tw[i])) {           long long tmp = rep[msk] ^ rep[msk ^ tw[i]];           dp[c + 1] += count_bit(tmp);         }     }     double ans = 0;     for (int i = 1; i < m + 1; i++) {       double tmp = double(dp[i] * i) / (m - i + 1);       for (int j = 0; j < i - 1; j++) tmp *= double(i - 1 - j) / (m - j);       ans += tmp;     }     ans /= n;     printf( %.10lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[20005][15];   int c[15], b[20005], ans[20005];   int main() {     int n, m, k, i, j, x, y;     cin >> n >> m >> k;     for (i = 1; i <= n; ++i) {       for (j = 1; j <= m; ++j) {         scanf( %d , &a[i][j]);       }     }     for (i = 1; i <= k; ++i) {       cin >> x >> y;       --b[x];       ++c[y];     }     for (i = 1; i <= n; ++i) {       ans[i] = b[i];       for (j = 1; j <= m; ++j) {         if (!a[i][j]) continue;         ans[i] += c[j];       }     }     for (i = 1; i <= n; ++i) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using uint = unsigned int;   using ll = long long;   using ull = unsigned long long;   using pii = pair<int, int>;   using pli = pair<ll, int>;   using pil = pair<int, ll>;   using pll = pair<ll, ll>;   template <typename T>   using vec = vector<T>;   using vi = vec<int>;   using vl = vec<ll>;   template <typename T>   using que = queue<T>;   template <typename T>   using deq = deque<T>;   template <typename T>   T id(T b) {     return b;   };   template <typename T>   void chmax(T &x, T y) {     if (x < y) x = y;   }   template <typename T>   void chmin(T &x, T y) {     if (x > y) x = y;   }   template <typename S, typename K>   bool contains(S &s, K k) {     return s.find(k) != s.end();   }   void fastio() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);   }   constexpr ll TEN(int n) {     if (n == 0)       return 1LL;     else       return 10LL * TEN(n - 1);   }   int main() {     fastio();     int q;     cin >> q;     while (q--) {       int n;       cin >> n;       vi a(n);       set<int, greater<int>> s;       for (int i = 0; i < int(n); i++) {         cin >> a[i];         s.insert(a[i]);       }       map<int, int> mn, mx;       for (int i = 0; i < int(n); i++) mx[a[i]] = i;       for (int i = n - 1; i >= 0; i--) mn[a[i]] = i;       vi l((s).begin(), (s).end());       vi dp(s.size());       dp[0] = 1;       for (int i = 1; i < l.size(); i++) {         if (mn[l[i - 1]] >= mx[l[i]]) {           dp[i] = dp[i - 1] + 1;         } else {           dp[i] = 1;         }       }       cout << l.size() - *max_element((dp).begin(), (dp).end()) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = int(1e5 + 3);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     string s;     cin >> s;     int size = s.length();     int count4 = 0;     int count7 = 0;     for (int i = 0; i < size; i++) {       if (s[i] ==  7 ) count7++;       if (s[i] ==  4 ) count4++;     }     if (count4 == 0 && count7 == 0)       cout << -1 <<   n ;     else if (count4 >= count7)       cout << 4 <<   n ;     else       cout << 7 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[4], leaf;   vector<int> son[5140];   void no() {     puts( NO );     exit(0);   }   void init() {     scanf( %d , &n);     for (int i = 0; i < 4; i++) scanf( %d , &a[i]);     for (int i = 2; i <= n; i++) {       int pi;       scanf( %d , &pi);       son[pi].push_back(i);     }     for (int i = 1; i <= n; i++)       if (son[i].empty()) leaf++;     if (leaf & 1) no();   }   int sz[5140];   vector<int> items;   int go(int now) {     int who = -1;     if (son[now].empty()) {       sz[now] = 1;       for (int i = 0; i < 4; i++)         if (now == a[i]) who = i;       return who;     }     vector<int> wt;     for (int s : son[now]) {       int ret = go(s);       if (ret == -1)         wt.push_back(sz[s]);       else {         who = ret;         if (who > 1) wt.push_back(sz[s]);       }     }     if (who == -1 or who > 1) {       sz[now] = 0;       for (auto i : wt) sz[now] += i;     } else {       for (auto i : wt) items.push_back(i);     }     return who;   }   bool dp[5140];   void knapsack(int tar) {     if (tar < 0 or tar >= 5140) no();     for (int i = 0; i <= tar; i++) dp[i] = false;     dp[0] = true;     for (auto i : items)       for (int j = tar - i; j >= 0; j--) dp[j + i] |= dp[j];     if (not dp[tar]) no();   }   void solve() {     for (int _ = 0; _ < 2; _++) {       items.clear();       int cand = (leaf - 2) >> 1;       for (int s : son[1]) {         int ret = go(s);         if (ret == -1)           items.push_back(sz[s]);         else if (ret == 2)           cand -= sz[s];       }       knapsack(cand);       swap(a[0], a[2]);       swap(a[1], a[3]);     }     puts( YES );   }   int main() {     init();     solve();   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[2000];   void DFS(int v, int n) {     while (g[v].size() != 0) {       int x = g[v].back();       g[v].pop_back();       for (int k = 0; k < g[x].size(); k++)         if (g[x][k] == v) {           g[x].erase(g[x].begin() + k);           break;         }       DFS(x, n);       if (v != n + 1 && x != n + 1) cout << v <<     << x << endl;     }   }   int main() {     int t, n, m;     cin >> t;     for (int k = 0; k < t; k++) {       cin >> n >> m;       int odd[n];       memset(odd, 0, sizeof(odd));       int r = 0;       for (int x, y, i = 1; i <= m; i++) {         cin >> x >> y;         g[x].push_back(y);         g[y].push_back(x);       }       for (int l = 1; l <= n; l++)         if (g[l].size() % 2 == 1) {           odd[r] = l;           r++;         }       for (int o = 0; o < r; o++) {         g[odd[o]].push_back(n + 1);         g[n + 1].push_back(odd[o]);       }       cout << n - r << endl;       for (int q = 1; q <= n; q++) DFS(q, n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD(1000000007);   const int INF((1 << 30) - 1);   const int MAXN();   int main() {     int n;     scanf( %d , &n);     string a;     cin >> a;     int b[26];     for (int i = 0; i < 26; i++) b[i] = -1;     vector<int> d;     int cnt = 0;     for (int i = 0; i < a.size(); i++) {       if (b[a[i] -  a ] == -1) {         cnt++;         b[a[i] -  a ] = i;         if (d.size() < n) d.push_back(i);       }     }     if (cnt < n) {       printf( NO );     } else {       sort(d.begin(), d.end());       printf( YES n );       for (int i = 0; i < d.size() - 1; i++)         cout << a.substr(d[i], d[i + 1] - d[i]) << endl;       cout << a.substr(d[d.size() - 1], a.size() - d[d.size() - 1]);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(NULL);     int n, m;     cin >> n >> m;     if (n == 1)       cout << n;     else       cout << ((m - 1) >= (n - m) ? m - 1 : m + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const long double PI = acos((long double)-1);   long long cnt[32][2];   class Node {    public:     Node* child[2];     long long cnt;     Node() {       child[0] = child[1] = NULL;       cnt = 0;     }   };   class Trie {    private:     Node* root;       public:     Trie() { root = new Node(); }     void insert(long long no) {       Node* curr = root;       for (long long i = 31; i >= 0; --i) {         long long bit = (no >> i) & 1;         if (!curr->child[bit]) {           curr->child[bit] = new Node();         }         if (curr->child[0] && curr->child[1]) {           if (bit) {             cnt[i][bit] += curr->child[0]->cnt;           } else {             cnt[i][bit] += curr->child[1]->cnt;           }         }         curr = curr->child[bit];         ++curr->cnt;       }     }   };   void solve() {     long long n;     cin >> n;     Trie t;     for (long long i = 1; i <= n; ++i) {       long long x;       cin >> x;       t.insert(x);     }     long long x = 0;     long long inv = 0;     for (long long i = 31; i >= 0; --i) {       if (cnt[i][1] < cnt[i][0]) {         x += (1 << i);         inv += cnt[i][1];       } else {         inv += cnt[i][0];       }     }     cout << inv <<     << x <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }