#include using namespace std; struct BinaryTrie{ //バグあるかもよ. struct Node{ int times; long long 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; } public: void make(int b){B = b;} private: Node* insert(Node *p,long long &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(long long x){root = insert(root,x,B-1);} bool insertset(long long x){ if(find(x) == 0) insert(x); else return false; return true; } private: Node* erase(Node *p,long long &x,int b){ assert(p != nullptr); p->times--; if(p->times == 0) return nullptr; if(b < 0) return p; eval(p,b); bool one = (x&(1LL<0; p->LR[one] = erase(p->LR[one],x,b-1); return p; } public: void erase(long long x){root = erase(root,x,B-1);} bool eraseset(long long x){ if(find(x) != 0) erase(x); else return false; return true; } private: long long getkth(Node *p,int k,int b){ //0-indexed. if(b < 0) return 0; eval(p,b); int L = 0; if(p->LR[0] != nullptr) L = p->LR[0]->times; return kLR[0],k,b-1):getkth(p->LR[1],k-L,b-1)|(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(long long x){return lowerbound(root,x,B-1);} int upper_bound(long long x){x++; return lowerbound(root,x,B-1);} public: int size(){ if(root != nullptr) return root->times; else return 0; } void Xorall(long long x){if(root != nullptr) root->lazy ^= x;} int find(long long &x){ if(root == nullptr) return 0; Node *p = root; for(int i=B-1; i>=0; i--){ eval(p,i); p = p->LR[(x>>i)&1]; if(p == nullptr) return 0; } return p->times; } }; 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