Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list_S = [input() for i in range(N)]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
A = newlist_a[0]
n = newlist_a.count(A)
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(A)):
        t += list_a[i]
    if N == 1:
        ans = list_S[t]
    else:
        ans = list_S[t+1]
else:
    if A==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        b = 0
        for i,x in enumerate(list_a):
            if x == A:
                list_t.append(sum(list_a[0:i]))
                ans += list_S[list_t[b]]
                ans += "\n"
                b += 1
print(ans)

Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list_S = [input() for i in range(N)]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(newlist_a[0])):
        t += list_a[i]
    if N == 1:
        ans = list_S[t]
    else:
        ans = list_S[t+1]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        b = 0
        for i,x in enumerate(list_a):
            if x == newlist_a[0]:
                list_t.append(sum(list_a[0:i]))
                ans += list_S[list_t[b]]
                ans += "\n"
                b += 1
print(ans)

Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(newlist_a[0])):
        t += list_a[i]
    if N == 1:
        ans = list_S[t]
    else:
        ans = list_S[t+1]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        a = 0
        for i,x in enumerate(list_a):
            if x == newlist_a[0]:
                list_t.append(sum(list_a[0:i]))
                ans += list_S[list_t[a]]
                ans += "\n"
                a += 1
print(ans)


Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(newlist_a[0])):
        t += list_a[i]
    if N == 1:
        ans = list_S[t]
    else:
        ans = list_S[t+1]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        for i,x in enumerate(list_a):
            if x == newlist_a[0]:
                list_t.append(sum(list_a[0:i]))
                ans += list_S[list_t[i]]
                ans += "\n"
print(ans)

Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(newlist_a[0])):
        t += list_a[i]
    if N == 1:
        ans = list_S[t]
    else:
        ans = list_S[t+1]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        for i,x in enumerate(list_a):
            if x == newlist_a[0]:
                list_t.append(sum(list_a[0:i]))
                ans += list_S[list_t[i-1]]
                ans += "\n"
print(ans)

Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
while a < N :
    list_a.append(list_S.count(list_S[a]))
    a += list_S.count(list_S[a])
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(newlist_a[0])):
        t += list_a[i]
    ans = list_S[t+1]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        for i,x in enumerate(list_a):
            if x == newlist_a[0]:
                list_t.append(sum(list_a[0:i]))
                ans += list_S[list_t[i-1]]
                ans += "\n"
print(ans)


Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

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

N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = list_a.index(newlist_a[0])
    m = 0
    for i in range(t):
        m += list_a[i]
    ans +=list_S[m+t]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_A = copy.copy(list_a)
        list_t = []
        list_t.append(list_A.index(newlist_a[0]))
        for i in range(n-1):
            list_A.remove(newlist_a[i])
            m = 0
            for j in range(list_A.index(newlist_a[i])+i+1):
                m += list_a[j]
            list_t.append(m)
        for i in range(len(list_t)):
            ans += list_S[list_t[i]]
            ans += "\n"
print(ans)

Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
while a < N :
    list_a.append(list_S.count(list_S[a]))
    a += list_S.count(list_S[a])
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])

ans = ""
if n == 1:
    t = list_a.index(newlist_a[0])
    m = 0
    for i in range(t):
        m += list_a[i]
    ans +=list_S[m+t]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_A = []
        for i in range(len(list_a)):
            list_A.append(list_a[i])
        list_t = []
        list_t.append(list_A.index(newlist_a[0]))
        for i in range(n-1):
            list_A.remove(newlist_a[i])
            m = 0
            for j in range(list_A.index(newlist_a[i])+i+1):
                m += list_a[j]
            list_t.append(m)
        for i in range(len(list_t)):
            ans += list_S[list_t[i]]
            ans += "\n"
print(ans)


Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
while a < N :
    list_a.append(list_S.count(list_S[a]))
    a += list_S.count(list_S[a])
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(newlist_a[0])):
        t += list_a[i]
    ans = list_S[t+1]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        for i,x in enumerate(list_a):
            if x == newlist_a[0]:
                list_t.append(sum(list_a[0:i]))
        for i in range(len(list_t)):
            ans += list_S[list_t[i]]
            ans += "\n"
print(ans)

Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])

ans = ""
if n == 1:
    t = list_a.index(newlist_a[0])
    m = 0
    for i in range(t):
        m += list_a[i]
    ans +=list_S[m+t]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_A = []
        for i in range(len(list_a)):
            list_A.append(list_a[i])
        list_t = []
        list_t.append(list_A.index(newlist_a[0]))
        for i in range(n-1):
            list_A.remove(newlist_a[i])
            m = 0
            for j in range(list_A.index(newlist_a[i])+i+1):
                m += list_a[j]
            list_t.append(m)
        for i in range(len(list_t)):
            ans += list_S[list_t[i]]
            ans += "\n"
print(ans)


Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])

list_ans = []
if n == 1:
    t = list_a.index(newlist_a[0])
    m = 0
    for i in range(t):
        m += list_a[i]
    list_ans.append(list_S[m+t])
else:
    list_A = []
    for i in range(len(list_a)):
        list_A.append(list_a[i])
    list_t = []
    list_t.append(list_A.index(newlist_a[0]))
    for i in range(newlist_a.count(newlist_a[0])-1):
        list_A.remove(newlist_a[i])
        list_t.append(list_A.index(newlist_a[i])+i+1)
        
    for i in range(len(list_t)):
        m = 0
        for j in range(list_t[i]):
            m += list_a[j]
        if newlist_a[0]==1:
            list_ans.append(list_S[m])
        else:
            list_ans.append(list_S[m+list_t[i]])
list_ans.sort()
ans = ""
for i in range(len(list_ans)):
    ans += list_ans[i]
    ans += "\n"
print(ans)


Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
#　文字列の並べ替え
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
#　同一文字列の回数を数える
list_a = []
a = 1
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a)
        a = 1
list_a.append(a)

#　最大回数がわかりやすくなるように並べ替え
newlist_a = sorted(list_a,reverse=True)

# 最大回数の個数で場合分け
n = newlist_a.count(newlist_a[0])

list_ans = []
if n == 1:
# list_aにおける最大回数のインデックスを調べる
    t = list_a.index(newlist_a[0])
# list_aにおけるインデックスtまでの要素の数を調べて再頻出の文字列を書き出す
    m = 0
    for i in range(t):
        m += list_a[i]
    list_ans.append(list_S[m+t])
else:
# list_aにおける最大回数のインデックスを把握
    list_A = []
    for i in range(len(list_a)):
        list_A.append(list_a[i])
    list_t = []
    list_t.append(list_A.index(newlist_a[0]))
    for i in range(newlist_a.count(newlist_a[0])-1):
        list_A.remove(newlist_a[i])
        list_t.append(list_A.index(newlist_a[i])+i+1)
        
    for i in range(len(list_t)):
        m = 0
        for j in range(list_t[i]):
            m += list_a[j]
        if newlist_a[0]==1:
            list_ans.append(list_S[m])
        else:
            list_ans.append(list_S[m+list_t[i]])
list_ans.sort()
print(list_ans)


Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])