func_code_string: #include <bits/stdc++.h>   using namespace std;   string numToBinary(int n, int digits) {     string s;     while (n) {       int bil = n % 2;       n /= 2;       s += (bil +  0 );     }     while (s.size() < digits) {       s +=  0 ;     }     reverse(s.begin(), s.end());     return s;   }   long long computeInv(const vector<int>& a) {     int sz = a.size();     int suff[sz + 1], i;     suff[sz] = 0;     for (i = sz - 1; i >= 0; i--) {       suff[i] = suff[i + 1];       if (a[i] == 0) {         suff[i]++;       }     }     long long ans = 0;     for (i = 0; i < sz; i++) {       if (a[i] == 1) {         ans += suff[i + 1];       }     }     return ans;   }   void cetak(const vector<int>& a) {     for (int i = 0; i < a.size(); i++) {       printf( %d  , a[i]);     }     printf(  n );   }   int main() {     int n, i, j;     int a[300001];     while (scanf( %d , &n) != EOF) {       for (i = 0; i < n; i++) {         scanf( %d , &a[i]);       }       vector<vector<int> > groups;       vector<int> awalMula;       for (i = 0; i < n; i++) {         awalMula.push_back(i);       }       groups.push_back(awalMula);       int sor = 0;       long long numInv = 0;       for (i = 29; i >= 0; i--) {         long long invXor = 0;         long long invOri = 0;         for (j = 0; j < groups.size(); j++) {           vector<int> inv, asli;           for (int k = 0; k < groups[j].size(); k++) {             int idx = groups[j][k];             if ((1 << i) & a[idx]) {               asli.push_back(1);               inv.push_back(0);             } else {               asli.push_back(0);               inv.push_back(1);             }           }           invOri += computeInv(asli);           invXor += computeInv(inv);         }         if (invXor < invOri) {           sor += (1 << i);           for (j = 0; j < n; j++) {             a[j] ^= (1LL << i);           }           numInv += invXor;         } else {           numInv += invOri;         }         vector<vector<int> > newGroups;         for (j = 0; j < groups.size(); j++) {           vector<int> group0, group1;           for (int k = 0; k < groups[j].size(); k++) {             int idx = groups[j][k];             int nilai;             if ((1 << i) & a[idx]) {               group1.push_back(idx);             } else {               group0.push_back(idx);             }           }           if (group1.size()) {             newGroups.push_back(group1);           }           if (group0.size()) {             newGroups.push_back(group0);           }         }         groups = newGroups;       }       printf( %lld %d n , numInv, sor);     }     return 0;   };   