#include using namespace std; struct BinaryTrie{ //バグあるかもよ. struct Node{ int times; int lazy; Node *LR[2]; Node():times(0),lazy(0),LR{nullptr,nullptr}{} }; private: int B = 30; //2^B未満の数のみ. Node *root = nullptr; void eval(Node *p,int &b){ if(p->lazy&(1LL<LR[0],p->LR[1]); if(p->LR[0] != nullptr) p->LR[0]->lazy ^= p->lazy; if(p->LR[1] != nullptr) p->LR[1]->lazy ^= p->lazy; p->lazy = 0; } private: Node* insert(Node *p,int &x,int b){ if(p == nullptr) p = new Node; p->times++; if(b < 0) return p; eval(p,b); bool one = (x&(1LL<0; p->LR[one] = insert(p->LR[one],x,b-1); return p; } public: void insert(int x){root = insert(root,x,B-1);} private: int lowerbound(Node *p,int &x,int b){ if(p == nullptr || b < 0) return 0; eval(p,b); bool one = (x&(1LL<0; if(one && p->LR[0] != nullptr) return p->LR[0]->times+lowerbound(p->LR[one],x,b-1); return lowerbound(p->LR[one],x,b-1); } public: int lower_bound(int x){return lowerbound(root,x,B-1);} int upper_bound(int x){x++; return lowerbound(root,x,B-1);} public: void Xorall(int x){if(root != nullptr) root->lazy ^= x;} }; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); long long N,K; cin >> N >> K; vector A(N); for(auto &a : A) cin >> a; int low = -1,high = (1<<30)-1; while(high-low > 1){ int mid = (high+low)/2; long long now = 0; BinaryTrie Z; for(int i=0; i