func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long somod = 1e9 + 7;   const long long maxn = 5e4 + 7;   long long cntnode = 1, m, n, a[maxn];   vector<long long> vt[maxn * 31];   long long cac[32][2];   map<long long, vector<long long>> mp;   long long Pow(long long a, long long b) {     long long ans = 1;     for (; b > 0; b >>= 1, a = a * a % somod) {       if (b & 1) ans = ans * a % somod;     }     return ans;   }   void Update(long long x, long long delta) {     for (long long i = 29; i >= 0; i--) {       cac[i][(x >> i & 1)] += delta;     }   }   long long Cal(long long x) {     long long ans = 0;     for (long long i = 29; i >= 0; i--) {       ans += cac[i][(x >> i & 1) ^ 1] * (1 << i);       ans %= somod;     }     return ans;   }   pair<long long, long long> Count(long long curval, long long lastbit) {     mp.clear();     long long f = 0, s = 0;     for (long long i = 1; i <= n; i++) {       long long val = 0;       for (long long j = 29; j >= lastbit; j--) {         val ^= (a[i] & (1 << j));       }       mp[val].push_back(a[i]);     }     for (auto i : mp) {       long long yay = i.first ^ curval;       if (mp.count(yay) == 0) continue;       s += mp[yay].size() * i.second.size();       for (auto j : i.second) Update(j, 1);       for (auto j : mp[yay]) f = f + Cal(j);       f %= somod;       for (auto j : i.second) Update(j, -1);     }     s /= 2;     f = f * Pow(2, somod - 2) % somod;     return {f, s};   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     if (fopen( test.inp ,  r )) freopen( test.inp ,  r , stdin);     cin >> n >> m;     for (long long i = 1; i <= n; i++) {       cin >> a[i];     }     long long val = 0, ans = 0;     for (long long i = 29; i >= 0; i--) {       pair<long long, long long> cc = Count(val ^ (1 << i), i);       if (cc.second <= m) {         m -= cc.second, ans += cc.first;       } else {         val ^= (1 << i);       }       if (i == 0) {         ans += (val)*m;       }     }     cout << ans % somod <<   n ;   }   