Maybe replace search() with print(search())? That was a joke, but when I tried to submit this code, i got WA1. The test is ok, but your code is not optimal. Your code calculates max(tmp.values()) every time, and it is a costly operation. And here is my optimized (WA23, because there is another drawback in your solution) version of it: from sys import stdin from collections import Counter
def search(): tmp = Counter(map(int, stdin)) on2_to_on = max(tmp.values()) print(next((i for i in tmp.keys() if tmp[i] == on2_to_on))) search() Or: [code deleted] But with 1 additional line I got AC. Btw, the Python is relatively slow and uses a bit more memory too.