#include int main() { uint32_t seed, inf = 0, sup = ~0U; std::cin >> seed; constexpr uint32_t HALF = 5000001, ALL = 2 * HALF - 1; auto ok = [&](const uint32_t m) { uint32_t x = seed, y = 1, z = 2, w = 3, l = 0, e = 0, u = 0; auto gen = [&]() { const uint32_t t = (x ^ (x << 11)); return x=y,y=z,z=w,w=(w^(w>>19))^(t^(t>>8)); }; for (uint32_t i = 0, v; i < ALL; i++) { v = gen(), (v < m ? l : v == m ? e : u)++; } return l >= HALF ? 1 : u >= HALF ? -1 : 0; }; while (sup - inf > 1) { const uint32_t mid = (sup + inf) / 2; if (ok(mid) == 0) { return std::cout << mid << std::endl, 0; } (ok(mid) == -1 ? inf : sup) = mid; } }