func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5e4 + 5, P = 1e9 + 7;   struct Trie {     int ch[2], siz, mn, mx;   } t[N * 32];   int n, a[N], cntnode = 1, s[N][33], rt[N], ans;   long long kth, m;   void Insert(int x) {     int now = 1;     t[now].siz++;     for (int i = 31; ~i; --i) {       int& nxt = t[now].ch[a[x] >> i & 1];       if (!nxt) nxt = ++cntnode, t[nxt].mn = x;       now = nxt;       ++t[now].siz;       t[now].mx = x;     }   }   int calc(int v, int l, int r) {     if (!l) return 0;     int res = 0;     for (int i = 31; ~i; --i) {       int p = v >> i & 1;       if (!p)         (res += (1LL << i) * (s[r][i] - s[l - 1][i]) % P) %= P;       else         (res += (1LL << i) * (r - l + 1 - s[r][i] + s[l - 1][i]) % P) %= P;     }     return res;   }   int main() {     scanf( %d%lld , &n, &m);     m *= 2;     for (int i = 1; i <= n; ++i) scanf( %d , a + i);     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; ++i) {       Insert(i);       for (int j = 31; ~j; --j) s[i][j] = s[i - 1][j] + (a[i] >> j & 1);     }     for (int i = 1; i <= n; ++i) rt[i] = 1;     for (int i = 31; ~i; --i) {       long long tot = 0;       int z;       for (int j = 1; j <= n; ++j) {         int p = (a[j] >> i & 1) ^ 1;         tot += t[t[rt[j]].ch[p]].siz;       }       if (tot >= m)         z = 1, kth |= 1LL << i;       else         z = 0, m -= tot;       for (int j = 1; j <= n; ++j) rt[j] = t[rt[j]].ch[(a[j] >> i & 1) ^ z];     }     for (int i = 1; i <= n; ++i) {       int now = 1;       for (int j = 31; ~j; --j) {         int p = (a[i] ^ kth) >> j & 1;         if (!(kth >> j & 1) && t[now].ch[p ^ 1])           (ans += calc(a[i], t[t[now].ch[p ^ 1]].mn, t[t[now].ch[p ^ 1]].mx)) %=               P;         now = t[now].ch[p];       }     }     printf( %lld , 1LL * (kth * m % P + ans) % P * (P + 1 >> 1) % P);     return 0;   }   