Link to this code:
https://cses.fi/paste/a871c74160e6983ec5e9d5/// add me on genshin impact! 607984574
// Problem: Sliding Window Minimum
// Attempted: 2025-05-19 22:44:52 EST
#pragma GCC optimize("O3,unroll-loops,inline")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#ifdef uwu
#include "C:\genshin_impact\keqing.cpp"
#else
#define debug(...) 0
#endif
using ll = long long;
const int MOD = 1e9 + 7; // 998244353;
const int MX = 2e5 + 5, INF = 1e9;
const ll INFLL = 1e18;
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORE(i,a,b) for(int i = (a); i <= (b); ++i)
#define ROF(i,a,b) for(int i = (a); i >= (b); --i)
#define trav(a,x) for(auto& a: x)
#define sz(x) (int)x.size()
#define make_unique(v) sort(all(v)); v.erase(unique(all(v)), v.end())
template<class T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<class T> int lwb(const vector<T>& a, const T& b){return int(lower_bound(all(a),b)-a.begin());}
template<class T> int upb(const vector<T>& a, const T& b){return int(upper_bound(all(a),b)-a.begin());}
template<class T> bool ckmin(T& a, const T& b){return b<a?a=b,1:0;}
template<class T> bool ckmax(T& a, const T& b){return a<b?a=b,1:0;}
template<int D, typename T>struct vt : public vector<vt<D - 1, T>> { template<typename... Args>
vt(int n = 0, Args... args) : vector<vt<D - 1, T>>(n, vt<D - 1, T>(args...)) {}};
template<typename T> struct vt<1, T> : public vector<T> { vt(int n = 0, const T& val = T()) : vector<T>(n, val) {}};
template<typename T> istream& operator>>(istream& in, vector<T>& a) {for(auto &x : a) in >> x; return in;};
template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {for(auto &x : a) out << x << ' '; return out;};
const int N = 1e7+1;
int a[N];
void solve(){
int n, k; cin >> n >> k;
cin >> a[0];
array<ll, 3> mult;
cin >> mult[0] >> mult[1] >> mult[2];
FOR(i,1,n) a[i] = (a[i-1] * mult[0] + mult[1]) % mult[2];
int ans = 0;
FOR(j,0,30){
int mx = -1;
FOR(i,0,n){
if(a[i] & (1 << j)) mx = i+k-1;
if(i >= k-1 && i <= mx) ans ^= 1<<j;
}
}
cout << ans << "\n";
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int t = 1;
//cin >> t;
for(int test = 1; test <= t; test++){
solve();
}
}
/* /\_/\
* (= ._.)
* / > \>
*/