#include #include using namespace std; long long N, K, ans, a; vector el; vector uj; long long hat[31]; int main() { ios_base::sync_with_stdio(false); cin >> N >> K; for(int i=0; i> a; el.push_back(a); } hat[0] = 1; for(int i=1; i<=30; i++) hat[i] = 2*hat[i-1]; for(int i=30; i>=0; i--){ uj.clear(); for(long long j:el){ if((j&hat[i])!=0) uj.push_back(j); } if(uj.size()>=K){ ans += hat[i]; el.clear(); for(long long j:uj) el.push_back(j); } } cout << ans << endl; return 0; }