#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ull = unsigned long long; ull seed; int next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return (seed >> 33); } void Main() { int N,Q; cin >> N >> Q >> seed; for(int i = 0;i < (int)1e4;i++) { next(); } vector A(N); for(int i = 0;i < N;i++) { A[i] = next(); } sort(A.begin(),A.end()); long long ans = 0; for(int i = 0;i < Q;i += N) { int ri = min(Q,i + N); vector> X(ri - i); for(int j = 0;j < ri - i;j++) { X[j].first = next(); X[j].second = i + j; } sort(X.begin(),X.end()); int k = 0; for(int j = 0;j < ri - i;j++) { while(k < N && A[k] < X[j].first) { k++; } ans ^= (long long) k * X[j].second; } } cout << ans << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; /* cin >> tt; */ while(tt--) Main(); }