Buggy python submission (verdict: Time Limit Exceeded):
import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)
result = []

max_k, mx = max(count.items(), key=lambda x : x[1])

result.append(max_k)
del count[max_k]
for i in range(len(count)):
    max_k, max_v = max(count.items(), key=lambda x : x[1])
    if max_v == mx:
        result.append(max_k)
        del count[max_k]
    else:
        break
print("\n".join(sorted(result)))

Fixed submission:
import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)


mx = max(count.values())

result = [key for key, val in count.items() if val == mx]
print("\n".join(sorted(result)))

Buggy python submission (verdict: Time Limit Exceeded):
import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)
result = []

max_k, mx = max(count.items(), key=lambda x : x[1])

result.append(max_k)
del count[max_k]
for i in range(len(count)):
    max_k, max_v = max(count.items(), key=lambda x : x[1])
    if max_v == mx:
        result.append(max_k)
        del count[max_k]
    else:
        break

for r in sorted(result):
    print(r)

Fixed submission:
import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)


mx = max(count.values())

result = [key for key, val in count.items() if val == mx]
print("\n".join(sorted(result)))

Buggy python submission (verdict: Time Limit Exceeded):
import collections


N = int(input())

S = [input() for i in range(N)]

result = collections.Counter(S)

result_max = sorted([i for i in result.keys() if result[i] == max(result.values())])

for r in result_max:
    print(r)

Fixed submission:
import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)


mx = max(count.values())

result = [key for key, val in count.items() if val == mx]
print("\n".join(sorted(result)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

S = [input() for i in range(N)]
kinds = set(S)
result = {}

for i in kinds:
    result[i] = S.count(i)
result_max = sorted([i for i in result.keys() if result[i] == max(result.values())])

for r in result_max:
    print(r)

Fixed submission:
import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)


mx = max(count.values())

result = [key for key, val in count.items() if val == mx]
print("\n".join(sorted(result)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

result = {}

for i in range(N):
    s = input()
    if s in result.keys():
        result[s] += 1
    else:
        result[s] = 0
result_max = sorted([i for i in result.keys() if result[i] == max(result.values())])

for r in result_max:
    print(r)

Fixed submission:
import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)


mx = max(count.values())

result = [key for key, val in count.items() if val == mx]
print("\n".join(sorted(result)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

S = [input() for i in range(N)]

result = {}

for s in S:
    if s in result.keys():
        result[s] += 1
    else:
        result[s] = 0
result_max = sorted([i for i in result.keys() if result[i] == max(result.values())])

for r in result_max:
    print(r)

Fixed submission:
import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)


mx = max(count.values())

result = [key for key, val in count.items() if val == mx]
print("\n".join(sorted(result)))