func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long linf = 1e18 + 5;   const int mod = (int)1e9 + 7;   const int logN = 17;   const int inf = 1e9;   const int N = 1e6 + 5;   int way[N][2], size[N], all[N][30][2], n, m, a[N], S = 1;   void insert(int x) {     int node = 1;     for (int i = 29; i >= 0; i--) {       int t = (x >> i) & 1;       if (!way[node][t]) way[node][t] = ++S;       node = way[node][t];       size[node]++;       for (int j = 0; j <= 29; j++) all[node][j][((x & (1 << j)) != 0)]++;     }   }   int hm(int x, int big) {     int node = 1;     int ans = 0;     for (int i = 29; i >= 0; i--) {       if (!node) break;       int t = 0;       if ((x & (1 << i)) ^ (big & (1 << i))) t = 1;       if (big & (1 << i))         ;       else         ans += size[way[node][!t]];       node = way[node][t];     }     ans += size[node];     return ans;   }   int molla(int node, int x) {     long long ans = 0;     for (int i = 0; i <= 29; i++) {       ans += (long long)all[node][i][!(x & (1 << i))] * (1 << i) % mod;       ans %= mod;     }     return ans;   }   long long sum(int x, int big) {     int node = 1;     long long ans = 0;     for (int i = 29; i >= 0; i--) {       if (!node) break;       int t = 0;       if ((x & (1 << i)) ^ (big & (1 << i))) t = 1;       if (big & (1 << i))         ;       else {         ans += molla(way[node][!t], x);         ans %= mod;       }       node = way[node][t];     }     ans += (long long)size[node] * big % mod;     ans %= mod;     return ans;   }   int get(int x) {     long long cur = 0;     for (int i = 1; i <= n; i++) cur += hm(a[i], x);     return cur / 2;   }   long long sum(int x) {     long long cur = 0;     for (int i = 1; i <= n; i++) cur = (cur + sum(a[i], x)) % mod;     if (cur & 1) cur += mod;     return cur / 2LL;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       insert(a[i]);     }     int bas = 0, son = (1 << 30) - 1;     if (!m) {       cout << 0 <<   n ;       return 0;     }     while (bas < son) {       int orta = bas + son >> 1;       if (bas == orta) orta++;       if (get(orta) >= m)         bas = orta;       else         son = orta - 1;     }     long long ans =         (sum(bas + 1) + (m - get(bas + 1)) * (long long)bas % mod) % mod;     cout << ans <<   n ;     return 0;   }   