#include using namespace std; uint32_t x = 0, y = 1, z = 2, w = 3; uint32_t seed; inline 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; inline void init() { x = seed; y = 1; z = 2; w = 3; } int main() { cin >> seed; uint32_t high = UINT32_MAX, low = 0; while (high - low > 1) { const uint32_t 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; }