## https://yukicoder.me/problems/no/702 import heapq MAX = 2 ** 32 - 1 class Generator: def __init__(self, seed): self.x = seed self.y = 1 self.z = 2 self.w = 3 def generate(self): t = (self.x ^ (self.x << 11)) & MAX self.x = self.y self.y = self.z self.z = self.w self.w = ((self.w ^ (self.w >> 19)) ^ (t ^ (t >> 8))) & MAX return self.w def main(): seed = int(input()) generator = Generator(seed) N = 10000001 n2 = (N - 1) // 2 n1 = n2 + 1 queue = [] for _ in range(n1): a = generator.generate() heapq.heappush(queue, a) for _ in range(n2): a = generator.generate() heapq.heappush(queue, a) heapq.heappop(queue) print(heapq.heappop(queue)) if __name__ == "__main__": main()