#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; long long k; cin >> n >> k; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } k--; int ans = 0; for (int i = 30; i >= 0; i--) { map cnt; int msk = ~((1 << i) - 1); for (int j = 0; j < n; j++) { cnt[a[j] & msk]++; } long long cur = 0; for (auto [key, val] : cnt) { if ((key ^ ans) > key && cnt.count(key ^ ans)) { cur += val * cnt[key ^ ans]; } else if (ans == 0) { cur += val * (val - 1) / 2; } } if (cur <= k) { ans |= 1 << i; k -= cur; } } cout << ans << endl; }