func_code_string: #include <bits/stdc++.h>   using namespace std;   struct trie {     int s, x[2], w[30];   } t[50005 * 30];   int N, S, a[50005], p[50005];   long long M;   void ins(int x) {     for (int i = 30 - 1, c, p = 1; c = (x >> i) & 1, i >= 0; i--) {       if (!t[p].x[c]) t[p].x[c] = ++S;       p = t[p].x[c], t[p].s++;       for (int j = 0; j <= i; j++) t[p].w[j] += (x >> j) & 1;     }   }   void init() {     scanf( %d%lld , &N, &M), M *= 2, S++;     for (int i = 1; i <= N; i++) scanf( %d , &a[i]), ins(a[i]), p[i] = 1;   }   void doit() {     long long ans = 0, W = 0;     for (int i = 30 - 1; M && i >= 0; i--) {       long long s = 0;       for (int j = 1; j <= N; j++) s += t[t[p[j]].x[!(a[j] >> i & 1)]].s;       if (s <= M) {         for (int j = 1, c, q; c = (a[j] >> i) & 1, q = p[j], j <= N;              p[j++] = t[q].x[c])           if (q) {             for (int k = 0; k <= i; k++)               ans += 1ll * ((a[j] >> k) & 1 ? t[t[q].x[!c]].s - t[t[q].x[!c]].w[k]                                             : t[t[q].x[!c]].w[k])                      << k;             ans += 1ll * t[t[q].x[!c]].s * W;           }         M -= s;       } else         for (int j = 1; j <= N; j++)           p[j] = t[p[j]].x[!(a[j] >> i & 1)], W |= 1 << i;     }     printf( %d n , (ans + M * W) / 2 % 1000000007);   }   int main() {     init();     doit();     return 0;   }   