//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 0xccccccc; const ll LINF = 0xcccccccccccccccLL; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} #pragma GCC target ("sse4") //head int main() { ios::sync_with_stdio(false); cin.tie(0); int n, t; cin >> n >> t; vi a(n); rep(i, n) cin >> a[i]; vector

pre(31, P(-1, 0)), now(31, P(-1, 0)); pre[__builtin_popcount(t)] = P(t, 0); rep(i, n) { fill(now.begin(), now.end(), P(-1, 0)); rep(j, 31) { auto [x, u] = pre[j]; if(x == -1) continue; int t = x&a[i]; chmax(now[__builtin_popcount(t)], P(t, u+abs(x-t))); t = x|a[i]; chmax(now[__builtin_popcount(t)], P(t, u+abs(x-t))); } now.swap(pre); } int z = 0; rep(i, 31) if(pre[i].first != -1) { chmax(z, pre[i].second); } cout << z << endl; }