#include using namespace std; uint32_t x = 0, y = 1, z = 2, w = 3; uint32_t seed; uint32_t generate() { uint32_t t = (x^(x<<11)); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); return w; } const int a = 10000001; void init() { x = seed; y = 1; z = 2; w = 3; } int main() { cin >> seed; long long high = UINT32_MAX, low = 0; while (high - low > 1) { const long long mid = low + (high - low) / 2; init(); int cnt = 0; bool isExist = false; for (int i = 0; i < a; i++) { if (generate() <= mid) { cnt++; } } if (cnt <= a / 2) { low = mid; } else { high = mid; } } cout << high << endl; }