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

letter = []
num_letter = []
letter.append(input())
num_letter.append(1)
max_num_letter = 1

for i in range(1,N):
  S = input()
  flag = 0
  for j in range(len(letter)):
    if letter[j] == S:
      num_letter[j]+=1
      flag = 1
      break
  if flag == 0:
    letter.append(S)
    num_letter.append(1)

max_num_letter = max(num_letter)
max_letter = []

max_letter = [letter[i] for i in range(len(letter)) if num_letter[i] == max_num_letter]
max_letter = sorted(max_letter)
for i in range(len(max_letter)):
  print(max_letter[i])


Fixed submission:
N = int(input())
S = []
for i in range(N):
  S.append(input())
S = sorted(S)
#print(S)

max_letter = []
max_count = 0
tmp_S = S[0]
count = 0

for i in range(len(S)):
  if i == 0:
    count=1
    max_letter.append(S[i])
    tmp_S = S[i]
  elif tmp_S != S[i]:
    if max_count < count:
      max_count = count
      max_letter = []
      max_letter.append(tmp_S)
    elif max_count == count:
      max_letter.append(tmp_S)
    tmp_S = S[i]
    count=1
  else:
    count+=1
if max_count < count:
  max_letter = list([tmp_S])
elif max_count == count:
  max_letter.append(tmp_S)
  
for i in range(len(max_letter)):
  print(max_letter[i])

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

letter = []
num_letter = []
letter.append(input())
num_letter.append(1)
max_num_letter = 1

for i in range(1,N):
  S = input()
  flag = 0
  for j in range(len(letter)):
    if letter[j] == S:
      num_letter[j]+=1
      flag = 1
      break
  if flag == 0:
    letter.append(S)
    num_letter.append(1)

max_num_letter = max(num_letter)
max_letter = []
for i in range(len(letter)):
  if num_letter[i] == max_num_letter:
    max_letter.append(letter[i])
max_letter = sorted(max_letter)
for i in range(len(max_letter)):
  print(max_letter[i])


Fixed submission:
N = int(input())
S = []
for i in range(N):
  S.append(input())
S = sorted(S)
#print(S)

max_letter = []
max_count = 0
tmp_S = S[0]
count = 0

for i in range(len(S)):
  if i == 0:
    count=1
    max_letter.append(S[i])
    tmp_S = S[i]
  elif tmp_S != S[i]:
    if max_count < count:
      max_count = count
      max_letter = []
      max_letter.append(tmp_S)
    elif max_count == count:
      max_letter.append(tmp_S)
    tmp_S = S[i]
    count=1
  else:
    count+=1
if max_count < count:
  max_letter = list([tmp_S])
elif max_count == count:
  max_letter.append(tmp_S)
  
for i in range(len(max_letter)):
  print(max_letter[i])

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

letter = []
num_letter = []
letter.append(input())
num_letter.append(1)
max_num_letter = 1

for i in range(1,N):
  S = input()
  flag = 0
  for j in range(len(letter)):
    if letter[j] == S:
      num_letter[j]+=1
      if num_letter[j] > max_num_letter:
        max_num_letter = num_letter[j]
      flag = 1
      break
  if flag == 0:
    letter.append(S)
    num_letter.append(1)

max_letter = []
for i in range(len(letter)):
  if num_letter[i] == max_num_letter:
    max_letter.append(letter[i])
max_letter = sorted(max_letter)
for i in range(len(max_letter)):
  print(max_letter[i])

Fixed submission:
N = int(input())
S = []
for i in range(N):
  S.append(input())
S = sorted(S)
#print(S)

max_letter = []
max_count = 0
tmp_S = S[0]
count = 0

for i in range(len(S)):
  if i == 0:
    count=1
    max_letter.append(S[i])
    tmp_S = S[i]
  elif tmp_S != S[i]:
    if max_count < count:
      max_count = count
      max_letter = []
      max_letter.append(tmp_S)
    elif max_count == count:
      max_letter.append(tmp_S)
    tmp_S = S[i]
    count=1
  else:
    count+=1
if max_count < count:
  max_letter = list([tmp_S])
elif max_count == count:
  max_letter.append(tmp_S)
  
for i in range(len(max_letter)):
  print(max_letter[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
  S.append(input())

letter = []
num_letter = []

letter.append(S[0])
num_letter.append(1)
max_num_letter = 1
for i in range(1,N):
  flag = 0
  for j in range(len(letter)):
    if letter[j] == S[i]:
      num_letter[j]+=1
      if num_letter[j] > max_num_letter:
        max_num_letter = num_letter[j]
      flag = 1
      break
  if flag == 0:
    letter.append(S[i])
    num_letter.append(1)

max_letter = []
for i in range(len(letter)):
  if num_letter[i] == max_num_letter:
    max_letter.append(letter[i])
max_letter = sorted(max_letter)
for i in range(len(max_letter)):
  print(max_letter[i])


Fixed submission:
N = int(input())
S = []
for i in range(N):
  S.append(input())
S = sorted(S)
#print(S)

max_letter = []
max_count = 0
tmp_S = S[0]
count = 0

for i in range(len(S)):
  if i == 0:
    count=1
    max_letter.append(S[i])
    tmp_S = S[i]
  elif tmp_S != S[i]:
    if max_count < count:
      max_count = count
      max_letter = []
      max_letter.append(tmp_S)
    elif max_count == count:
      max_letter.append(tmp_S)
    tmp_S = S[i]
    count=1
  else:
    count+=1
if max_count < count:
  max_letter = list([tmp_S])
elif max_count == count:
  max_letter.append(tmp_S)
  
for i in range(len(max_letter)):
  print(max_letter[i])