#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } constexpr int E = 18; void hadamard(vector<__int128_t> &fs) { for (int e = 0; e < E; ++e) { for (int h = 0; h < 1 << E; ++h) { if (!(h & 1 << e)) { const __int128_t tmp = fs[h] - fs[h | 1 << e]; fs[h] += fs[h | 1 << e]; fs[h | 1 << e] = tmp; } } } } int N, X; vector A; int main() { for (; ~scanf("%d%d", &N, &X); ) { A.resize(N); // if(N==200'000){A.assign(N,(1< fs0(1 << E), fs1(1 << E); for (int i = 0; i < N; ++i) { fs0[A[i]] += 1; fs1[A[i]] += A[i]; } hadamard(fs0); hadamard(fs1); vector<__int128_t> gs0(1 << E), gs1(1 << E); for (int h = 0; h < 1 << E; ++h) { gs0[h] = fs0[h] * fs0[h]; gs1[h] = fs0[h] * fs1[h]; } hadamard(gs0); hadamard(gs1); for (int h = 0; h < 1 << E; ++h) { gs0[h] >>= E; gs1[h] >>= E; } __int128_t ans = 0; // or = (xor + sum) / 2 for (int h = 0; h < 1 << E; ++h) { if (h < X) { ans += gs0[h] * h; ans += gs1[h] * 2; } } ans /= 2; for (int i = 0; i < N; ++i) { if ((A[i] ^ A[i]) < X) { ans -= (A[i] | A[i]); } } ans /= 2; printf("%lld\n", (Int)ans); } return 0; }