Problem:
 Score: 300 points    Problem Statement  We have N voting papers. The i -th vote (1 \leq i \leq N) has the string S_i written on it.  Print all strings that are written on the most number of votes, in lexicographical order.      Constraints   1 \leq N \leq 2 \times 10^5  S_i  (1 \leq i \leq N) are strings consisting of lowercase English letters.  The length of S_i  (1 \leq i \leq N) is between 1 and 10 (inclusive).         Input  Input is given from Standard Input in the following format:  N  S_1  :  S_N       Output  Print all strings in question in lexicographical order.        Sample Input 1 7
beat
vet
beet
bed
vet
bet
beet      Sample Output 1 beet
vet  beet and vet are written on two sheets each, while beat , bed , and bet are written on one vote each. Thus, we should print the strings beet and vet .       Sample Input 2 8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo      Sample Output 2 buffalo       Sample Input 3 7
bass
bass
kick
kick
bass
kick
kick      Sample Output 3 kick       Sample Input 4 4
ushi
tapu
nichia
kun      Sample Output 4 kun
nichia
tapu
ushi

Solution (Python):
import sys
from collections import Counter

TEST_INPUT = [
    """
    7
    beat
    vet
    beet
    bed
    vet
    bet
    beet
    """,
    """
    8
    buffalo
    buffalo
    buffalo
    buffalo
    buffalo
    buffalo
    buffalo
    buffalo
    """,
    """
    7
    bass
    bass
    kick
    kick
    bass
    kick
    kick
    """,
    """
    4
    ushi
    tapu
    nichia
    kun
    """
]
ANSWER = [
    "['beet', 'vet']",
    "['buffalo']",
    "['kick']",
    "['kun', 'nichia', 'tapu', 'ushi']"
]


class InputHandler:

    def __init__(self, text_lines="", is_test=False):
        self.data = list(text_lines.split("\n"))
        self.index = 0
        self.is_test = is_test

    def input(self):
        if self.is_test:
            self.index += 1
            return self.data[self.index].strip()
        else:
            return sys.stdin.readline().rstrip()


def solve(n, s_list):
    c = Counter(s_list)
    m = max(c.values())
    res_list = [k for k in c.keys() if c[k] == m]
    return list(sorted(res_list))


def input_and_solve(ih):
    n = int(ih.input())
    s_list = [ih.input() for _ in range(n)]
    res = solve(n, s_list)
    return res


def main():
    ih = InputHandler()
    res = input_and_solve(ih)
    for r in res:
        print(r)


def test():
    for test_input, ans in zip(TEST_INPUT, ANSWER):
        ih = InputHandler(test_input, True)
        res = input_and_solve(ih)
        assert str(res) == str(ans)


if __name__ == "__main__":
    test()
    main()

Solution (Python):
n = int(input())
S = [ input() for _ in range(n) ]

import collections

c = collections.Counter(S)
b = c.most_common()

ls_ans = []
ls_ans.append( b[0][0] )

a = b[0][1]

for i in range(1,len(b)):
    if b[i][1]==a:
        ls_ans.append(b[i][0])
    else:
        break
ans = sorted(ls_ans)
print("\n".join(ans))
exit()

Solution (Python):
N=int(raw_input())
S=["" for i in range(N)]
for i in range(N):
    S[i] = raw_input()


S.sort()

maxc = -1
sol = []
prev = S[0]
count = 0
S.append("")

for i in range(N+1):
    if prev == S[i]:
        count += 1
    else:
        if maxc < count:
            sol = [prev]
            maxc = count
        elif maxc == count:
            sol.append(prev)

        count = 1
        prev = S[i]

for i in range(len(sol)):
    print sol[i]

Solution (Python):
import numpy as np
import collections

N=int(input().split()[0])
A=[]
for i in range(N):
  A.append(input().split()[0])

C=collections.Counter(A)
c= C.most_common()
m=c[0][1]
x=[]
for c,n in c:
  if n==m:
    x.append(c)
  else:
    break
x=sorted(x)
for i in x:
  print(i)

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

a = sorted(d.items(), key=lambda x:x[1], reverse=True)
m = a[0][1]
l = list()
for v in a:
    if v[1] == m:
        l.append(v[0])
    else:
        break

for v in sorted(l):
    print(v)

Solution (Python):
n = int(input())
s_list = [input() for i in range(n)]

m = {}
for s in s_list:
  if s in m:
    m[s] += 1
  else:
    m[s] = 1

ans = []
maxi = 0
for k, v in m.items():
  if v > maxi:
    ans.clear()
    maxi = v
  elif v < maxi:
    continue
  ans.append(k)

ans.sort()

for a in ans:
  print(a)

Solution (Python):





def get_inv_value(item):
    return -item[1]


def solv(N, S):
    d = {}
    for s in S:
        if s in d:
            d[s] += 1
        else:
            d[s] = 1
    lst = sorted(d.items(), key=get_inv_value)
    m = lst[0][1]
    lst = sorted([l[0] for l in lst if l[1] == m])
    return "\n".join(lst)


if __name__ == "__main__":

    N = int(input())
    S = [input() for _ in range(N)]

    ans = solv(N, S)

    print(ans)

Solution (Python):
from collections import defaultdict as de

n = int(input())
x = de(int)
for i in range(n):
    s = input()
    x[s] += 1
x = sorted(x.items(), key=lambda x:x[1], reverse=True)
y = 0
z =[]
for i,j in x:
    if y > j:
        break
    z.append(i)
    y = j
z = sorted(z)
for i in z:
    print(i)

Solution (Python):
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
c=Counter(s)
c=c.most_common()
i=0
ans=[]
for i in range(len(c)):
  if c[0][1] == c[i][1]:
    ans.append(c[i][0])

ans.sort()
for i in range(len(ans)):
  print(ans[i])

Solution (Python):

import sys


def solve(N: int, S: "List[str]"):
    D=dict()
    M=1
    for s in S:
        if s in D:
            D[s] = D[s]+1
            if M < D[s]:
                M=D[s]
        else:
            D[s] = 1
    L = list()
    for d in D:
        if D[d] == M:
            L.append(d)
    LL = sorted(L)
    for ll in LL:
        print(ll)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [next(tokens) for _ in range(N)]  
    solve(N, S)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
d = dict()
for i in range(N):
    S = input()
    if S not in d:
        d[S] = 1
    else:
        d[S] += 1
max_vote = max(d.values())
ans = []
for k, v in d.items():
    if v == max_vote:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Solution (Python):
rang = int(input())
words = []
for i in range(rang):
    words.append(input())

d = {w: 0 for w in words}
m = 0
for w in words:
    d[w] += 1
    if (d[w] > m):
         m = d[w]
most = [k for k,v in d.items() if v == m]

most.sort()
for wrd in most:
    print(wrd)

Solution (Python):
from collections import Counter
def check(n):
    d = Counter([input() for _ in range(n)])
    result = d.most_common()
    max_cnt = result[0][1]
    namelist = []
    for name, cnt in result:
        if max_cnt == cnt:
            namelist.append(name)
    for name in sorted(namelist):
        print(name)
    
n = int(input())
check(n)

Solution (Python):
n = int(input())
dict = {}


for _ in range(n):
    s = input()
    if s in dict:
        dict[s] +=1
    else:
        dict[s] = 1

s = sorted(dict.items(),key=lambda x:x[1],reverse=True)

l = []

for k in dict:
    if dict[k] == s[0][1]:
        l.append(k)

ss = sorted(l)
for v in ss:
    print(v)

Solution (Python):
import collections
n = int(input())
l = []
for i in range(n):
    l.append(input())
c = collections.Counter(l)
t = sorted(c.most_common())
t.sort(key=lambda x: x[1],reverse=True)
ma = t[0][1]
for i in range(len(t)):
    if t[i][1] < ma:
        break
    print(t[i][0])

Solution (Python):
import collections
n = int(input())
wl = []
for i in range(n):
  wl.append(input())
  
s = collections.Counter(wl)
m = max(s.values())
ans = []
for k,v in s.items():
  if (v == m):
    ans.append(k)
for w in sorted(ans):
  print(w,sep=' ')

Solution (Python):
import collections
D = collections.defaultdict(int)
N = int(input())
for i in range(N):
    D[input()] += 1
high = -1
ans = dict()
for k,v in sorted(D.items(), key=lambda x:x[1], reverse=True):
    if high <= v:
        high = v
        ans[k] = v
    else:
        break
ans = sorted(ans.keys())
for a in ans:
    print(a)

Solution (Python):
from collections import Counter

n = int(input())
s = []
for i in range(n):
  s.append(input())

cnt = -1
counter_s = Counter(s)
ans = []
for word, num in counter_s.most_common():
  if cnt == -1 or cnt == num:
    ans.append(word)
    cnt = num
  else:
    break

ans.sort()
for word in ans:
  print(word)

Solution (Python):
N = int(input())
S_dic = {}
mode_list = []
mode_num = 0
for i in range(N):
    S = input()
    if S in S_dic:
        l = S_dic[S]+1
        S_dic[S] = S_dic[S]+1
    else:
        l=1
        S_dic[S]=1
    if mode_num==l:
        mode_list.append(S)
    elif mode_num<l:
        mode_list = []
        mode_list.append(S)
        mode_num = l

mode_list.sort()

for w in mode_list:
    print(w)

Solution (Python):
import collections

N = int(input())
names = [input() for s in range(N)]

c = collections.Counter(names)

max_value = max(c.values())

output_list = []
for k, v in c.items():
    if v == max_value:
        output_list.append(k)

for name in sorted(output_list):
    print(name)

Solution (Python):
from collections import Counter
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    S = [input() for _ in [0] * N]

    cnt = Counter(S).most_common()
    j = cnt[0][1]
    ans = []
    for v, i in cnt:
        if i == j:
            ans.append(v)
    ans.sort()
    print(*ans, sep='\n')


main()

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
import collections
cS=collections.Counter(S)
maxV=max(cS.values())
keys = [k for k, v in cS.items() if v == maxV]
keys.sort()
for i in  range(len(keys)):
    print(keys[i])

Solution (Python):

"""
Created on Sun Feb 16 21:10:50 2020

@author: H_Hoshigi
"""


N = int(input())
S_dict = {}
for i in range(N):
    S_i = input()
    try:
        S_dict[S_i]
    except KeyError:
        S_dict[S_i] = 1
    else:
        S_dict[S_i] += 1

S_soretd_list = sorted(S_dict.keys())
answer_list = []
max_frequency = 0
for i in S_soretd_list:
    if S_dict[i] > max_frequency:
        max_frequency = S_dict[i]
        answer_list = [i]
    elif S_dict[i] == max_frequency:
        answer_list.append(i)
    else:
        pass
for i in answer_list:
    print(i)

Solution (Python):
N = int(input())
S = []
for _ in range(N):
    S.append(input())

import collections    
C = collections.Counter(S)
M = C.most_common()[0][1]
R = [c for c in C.keys() if C[c]==M]
R.sort()

for r in R:
    print(r)

Solution (Python):
import sys
from collections import Counter

N = int(sys.stdin.readline())
S = []
uniqueS = []
for i in range(N):
    tempS = input()
    S.append(tempS)

SC = Counter(S)
max = max(SC.values())

ans_list = []
for i in SC.items():
    if i[1] == max:
        ans_list.append(i[0])
ans_list.sort()

for i in ans_list:
    print(i)

Solution (Python):
N = int(input())
S_list = []
for n in range(N):
    S_list.append(input())

dic = dict()
for s in S_list:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

dict_sorted = sorted(dic.items(), key=lambda x: x[1], reverse=True)

outs = []
max = None
for (out, num) in dict_sorted:
    if max is None:
        outs.append(out)
        max = num
    elif max == num:
        outs.append(out)
    else:
        break

for out in sorted(outs):
    print(out)

Solution (Python):
from collections import defaultdict
import heapq

n = int(input())
s_dic = defaultdict(int)
max_count = 0
for _ in range(n):
    s = input()
    s_dic[s] += 1
    max_count = max(s_dic[s], max_count)

ans = []
for key in s_dic.keys():
    if s_dic[key] == max_count:
        heapq.heappush(ans, key)
for _ in range(len(ans)):
    print(heapq.heappop(ans))

Solution (Python):
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())
sc = collections.Counter(s).most_common()
ans = []
ans.append(sc[0][0])
mn = sc[0][1]
for n in range(1, len(sc)):
    if sc[n][1] == mn:
        ans.append(sc[n][0])
    else:
        break
for anss in sorted(ans):
    print(anss)

Solution (Python):
N = int(input())
S = []
for i in range(N):
    S.append(input())
MAX = 0

import collections
c =  collections.Counter(S)
MAX = max(c.values())
SET = []
for i in range(N):
    if c[S[i]]==MAX:
        SET.append(S[i])
SET = list(set(SET))
SET.sort()
for item in SET:
    print(item)

Solution (Python):



import sys
import collections

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    c = collections.Counter()
    most_n = 0
    most_s = []
    for _ in range(N):
        s = i2s()
        c[s] += 1
        if c[s] == most_n:
            most_s.append(s)
        elif c[s] > most_n:
            most_s = [s]
            most_n = c[s]
        
    for ms in sorted(most_s):
        print(ms)
    return

main()

Solution (Python):



import collections

n = int(input())
c = collections.Counter([input() for i in range(n)])
m = max(c.values())
k = list(c.keys())
v = list(c.values())
data = []
for i in range(len(c)):
    if v[i] == m:
        data.append(k[i])
        

data.sort()

[print(i) for i in data]

Solution (Python):
N = int(input())

dic = {}
s = ""
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

max = 0
for i in dic.values():
    if (max < i):
        max = i

mojiSet = set()
for moji in dic.keys():
    if (max == dic[moji]):
        mojiSet.add(moji)

for k in sorted(mojiSet):
    print(k)

Solution (Python):
def main():
    N = int(input())
    str_dict = dict()
    for n in range(N):
        s = input()
        if s in str_dict:
            str_dict[s] += 1
        else:
            str_dict[s] = 1
    max_s = max(str_dict.values())
    result_list = list()
    for a, b in str_dict.items():
        if b == max_s:
            result_list.append(a)
    result_list.sort()
    for r in result_list:
        print(r)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for _ in range(n):
    d[input()] += 1
sorted_pairs = [(k, v) for k, v in sorted(d.items(), key=lambda item: item[1], reverse=True)]   
max_freq = sorted_pairs[0][1]

result = []
for k, v in sorted_pairs:
    if v != max_freq:
        break
    result.append(k)

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

Solution (Python):
def main(n,s):
    s.sort()
    val = s[0]
    idx = 0
    maxcount = 1
    lst = [[1, val]]
    for i in range(1,len(s)):
        if s[i] == val:
            lst[idx][0] += 1
            maxcount = max(maxcount, lst[idx][0])
        else:
            idx += 1
            val = s[i]
            lst.append([1,val])
    res = []
    for i in range(len(lst)):
        if lst[i][0] == maxcount:
            res.append(lst[i][1])
    res.sort()
    for i in range(len(res)):
        print(res[i])
    
n = int(input())
s = [input() for _ in range(n)]
main(n,s)

Solution (Python):
import collections

n = int(input())
s = [input() for i in range(n)]

c = collections.Counter(s)
count = c.most_common()[0][1]

s2 = [i[0] for i in c.items() if i[1] == count]
s2 = sorted(s2)

for i in range(len(s2)):
    print(s2[i])

Solution (Python):
n = int(input())

S = []
for i in range(n):
    S.append(input())
    
max_temp = 1
count = {}
for s in S:
    if s in count:
        count[s] += 1
        if count[s]>max_temp:
            max_temp = count[s]
    else:
        count[s] = 1
        
res = [kv[0] for kv in count.items() if kv[1] == max_temp]
res.sort()

for i in res:
    print(i)

Solution (Python):
n = int(input())

d = {}
for i in range(n):
    s = input()
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

m = max(d.values())
keys = [key for key, val in d.items() if val == m]

for i in sorted(keys):
    print(i)

Solution (Python):
N = int(input())

res = {}
for i in range(N):
    s = input()
    if not s in res:
        res[s] = 1
    else:
        res[s] += 1

m = max(res.values())
keys = [k for k, v in res.items() if v == m]
keys.sort()

for i in range(len(keys)):
  print(keys[i])

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Solution (Python):
N = int(input())

D={}
L = [0]*N
for i in range(N):
    L[i]=input()
    if D.get(L[i],None)==None:
        D[L[i]]=1
    else:
        D[L[i]]+=1
D = sorted(D.items(),reverse=True,key=lambda x:x[1])
n=D[0][1]
s=""

List=[]
for i in range(len(D)):
    if(D[i][1]==n and D[i][0]!=s):
        List.append(D[i][0])
        s=D[i][0]
List=sorted(List)

for l in List:
    print(l)

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Solution (Python):
import numpy as np

n = int(input())
s_list = [input() for i in range(n)]

new_dict = {}
for s in s_list:
    if s not in new_dict.keys():
        new_dict[s] = 1
    else:
        new_dict[s] += 1
    
values = []
keys = []    
for key in new_dict.keys():
    values.append(new_dict[key])
    keys.append(key)
    
values = np.array(values)
keys = np.array(keys)

max_index = values == np.max(values)
keys = keys[max_index].tolist()
keys = sorted(keys)

for key in keys:
    print(key)

Solution (Python):
N = int(input())
A = sorted([input() for _ in range(N)])

o = {}
for a in A:
    if a in o:
        o[a] += 1
    else:
        o[a] = 1

o_sorted = sorted(o.items(), key=lambda x:x[1], reverse=True)

max = 0
res = []
for o in o_sorted:
    if o[1] < max:
        break
    max = o[1]
    res.append(o[0])

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

Solution (Python):
import collections


class Solution:
    def solve(self, N: int, S):

        counter = collections.Counter(S)

        most_common = counter.most_common()

        num = most_common[0][1]

        answer = []

        for s in most_common:
            if s[1] == num:
                answer.append(s[0])
            else:
                break

        return sorted(answer)


if __name__ == '__main__':

    
    N = int(input())

    S = []
    for n in range(N):
        S.append(input())

    
    solution = Solution()
    ans = solution.solve(N, S)
    for s in ans:
        print(s)

Solution (Python):


n = int(input())
s_dict = {}
max_n = 0
for i in range(0, n):
    s = input()
    if s in s_dict:
        s_dict[s] += 1
        if s_dict[s] > max_n:
            max_n = s_dict[s]
    else:
        s_dict[s] = 1
        if max_n == 0:
            max_n = 1
s_list = []
for s in s_dict:
    if s_dict[s] == max_n:
        s_list.append(s)
s_list = sorted(s_list)
for s in s_list:
    print(s)

Solution (Python):
n = int(input())

dic = {}
for i in range(n):
    s_tmp = input()
    try:
        dic[s_tmp] += 1
    except KeyError:
        dic[s_tmp] = 1

s = []
for k, v in dic.items():
    s.append((k, v))
s.sort(reverse=True, key=lambda x: x[1])
max_n = s[0][1]
ans = []
for i in range(len(s)):
    if (s[i][1] == max_n):
        ans.append(s[i][0])
    else:
        break

ans.sort()
for a in ans:
    print(a)

Solution (Python):
import collections
n = int(input())
s_L = []
for _ in range(n):
    s = input()
    s_L.append(s)
c = collections.Counter(s_L)
c = sorted(c.items(),key=lambda x: x[1],reverse=True)
num = c[0][1]
c = sorted(c,key=lambda x:x[0])
for k,v in c:
    if v == num:
        print(k)

Solution (Python):
N = int(input())
S = []
L = {}
maxL = 0
maxS = []
for i in range(N):
    s = input()
    if s in L:
        L[s] += 1
    else:
        L[s] = 1
        
    if maxL < L[s]:
        maxL = L[s]
        maxS = [s]
    elif maxL == L[s]:
        maxS.append(s)

maxS.sort()
for ans in maxS:
    print(ans)

Solution (Python):
n = int(input())
d = {}
max_ = 1
for i in range(n):
    s = input()
    if d.get(s) is None:
        d[s] = 1
    else:
        d[s] += 1
        if max_ < d[s]:
            max_ = d[s]
ans = sorted(d.items())
for k, v in ans:
    if v == max_:
        print(k)

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Solution (Python):
n = input()
arr_c = [input() for i in range(int(n))]

dic = {}

for elem in arr_c:
  if elem in dic:
    dic[elem] += 1
  else:
    dic[elem] = 1

freq = max(dic.values())

sorted_dic = sorted(dic.items(), key=lambda x: x[0])

for tup in sorted_dic:
  if tup[1] == freq:
    print(tup[0])

Solution (Python):
N = int(input())
mydict = {}
max = 0
for i in range(N):
    S = input()
    if S in mydict.keys():
        mydict[S] = mydict[S] + 1
    else:
        mydict[S] = 1
        
    if max < mydict[S]:
        max = mydict[S]

keys = [k for k, v in mydict.items() if v == max]
keys.sort()
for key in keys:
    print(key)

Solution (Python):
def solve():
    N = int(input())
    s_lst = [input() for i in range(N)]
    s_lst.sort()
    a_lst = []
    s_dict = {}
    for w in s_lst:
        if not w in s_dict.keys():
            s_dict[w] = 1
        else:
            s_dict[w] += 1
    s_max = max(list(s_dict.values()))
    i = 0
    while i < len(s_lst):
        w = s_lst[i]
        if s_dict[w] == s_max:
            a_lst.append(w)
        i += s_dict[w]
    for i in range(len(a_lst)):
        print(a_lst[i])

if __name__ == '__main__':
    solve()

Solution (Python):
N = int(input())
S_dic = {}
for i in range(N):
  S = input()
  if S in S_dic.keys():
    S_dic[S] += 1
  else:
    S_dic[S] = 1
sort_dic = sorted(S_dic.items(), key=lambda x:x[1], reverse=True)
before = 0
ans = []
for i in sort_dic:
  if i[1] >= before:
    ans.append(i[0])
  else:
    break
  before = i[1]
ans.sort()
for i in ans:
  print(i)

Solution (Python):
n=int(input())
slist=[]
for i in range(n):
    slist.append(input())
slist.sort()
anslist=[]
anslist.append([slist[0],1])
kosulist=[]
for i in range(1,n):
    if slist[i]!=slist[i-1]:
        kosulist.append(anslist[-1][1])
        anslist.append([slist[i],1])
    else:
        anslist[-1][1]+=1
        if i==n-1:
            kosulist.append(anslist[-1][1])
maxkosu=max(kosulist)
answer=[]
for i in range(len(anslist)):
    if anslist[i][1]==maxkosu:
        answer.append(anslist[i][0])
for i in range(len(answer)):
    print(answer[i])

Solution (Python):


import collections

n = int(input())
s = [input() for x in range(n)]

c = collections.Counter(s)
maxC = max(c.values())
z = list(filter(lambda z: z[1] == maxC, c.most_common()))
for x in sorted([y[0] for y in z]):
    print(x)

Solution (Python):
from collections import Counter
n=int(input())
s=[]
count=[]
for i in range(n):
    s.append(input())
c=Counter(s)
freq_scores = c.most_common()
max_count = freq_scores[0][1]
modes = []
for num in freq_scores:
    if num[1] == max_count:
        modes.append(num[0])
modes.sort()
for mode in modes:
    print(mode)

Solution (Python):
N = int(input())
D = dict()
M = 0
for _ in range(N):
    s = input()
    if D.get(s) is None:
        D[s] = 1
    else:
        D[s] += 1
    M = max(M, D[s])
keys = sorted([k for k, n in D.items() if n == M])
for k in keys:
    print(k)

Solution (Python):
n = int(input())

dicN = {}
nList = []
for i in range(n):
  nList.append(input())

for i in nList:
  if not(i in dicN):
    dicN[i]=1
  else:
    dicN[i] += 1

maxN = max(dicN.values())

result = []
for i in list(dicN.items()):
  if i[1] == maxN:
    result.append(i[0])
  
  

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

Solution (Python):
n = int(input())
s = dict({})
for _ in range(n):
    data = input()
    if data not in s:
        s[data] = 1
    else:
        s[data] += 1

res_n = 0
res = []
for k, v in s.items():
    if v > res_n:
        res.clear()
        res.append(k)
        res_n = v
    elif v == res_n:
        res.append(k)

res.sort()
for r in res:
    print(r)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]

import collections
c0 = collections.Counter(s)
c1 = c0.most_common()
max = c1[0][1]
l = []
for x, i in c0.items():
    if i == max:
        l.append(x)
ans = sorted(l)
for i in ans:
    print(i)

Solution (Python):
n = int(input())
s = [ input()  for i in range(n)]


from collections import Counter
s = Counter(s)
v_max = s.most_common()[0][1]
s2 = sorted(s.items())

ans = []
for k,v in s2:
  if v_max == v:
    print(k)

Solution (Python):
N = int(input())

S = {}
ans_n = 0

for i in range(N):
    s = input()
    if s not in S:
        S[s] = 0
    else:
        S[s] += 1

    ans_n = max(ans_n, S[s])

S = sorted(S.items(), key=lambda x: x[0])


for s in S:
    if s[1] == ans_n:
        print(s[0])

Solution (Python):
num = int(input())
dict = {}
for i in range(num):
  key = input()
  if not key in dict:
    dict[key] = 1
  else:
    dict[key] += 1
max_v = max(dict.values())
keys = [k for k, v in dict.items() if v == max_v]
keys.sort()
for i in range(len(keys)):
  print(keys[i])

Solution (Python):
N = int(input())
d = {}
for _ in range(N):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1

n = max(d.values())

res = [kv[0] for kv in d.items() if kv[1] == n]

res.sort()

for s in res:
    print(s)

Solution (Python):
N = int(input())

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

S.sort()
ans = [""]
maximum = 0
hoge = S[0]
nyoro = 0
for i in S:
    if i == hoge:
        nyoro += 1
    else:
        if maximum < nyoro:
            ans = [hoge]
            maximum = nyoro
        elif maximum == nyoro:
            ans.append(hoge)
        
        hoge = i
        nyoro = 1
else:
    if maximum < nyoro:
        ans = [hoge]
    elif maximum == nyoro:
        ans.append(hoge)

ans.sort()

for i in ans:
    print(i)

Solution (Python):
n = int(input())
S = [input() for _ in range(n)]
d_S = dict()
for s in S:
    d_S[s] = d_S.get(s, 0) + 1
max_v = max(d_S.values())
most_S = []
for s in d_S.items():   
    if ( s[1] == max_v):
        most_S.append(s[0])
for s in sorted(most_S):
    print(s)

Solution (Python):

import sys
from collections import Counter

def solve(N: int, S: "List[str]"):
    counter = Counter(S).most_common()

    most_value = counter[0][1]
    answer_list = []

    for key,value in dict(counter).items():
        if value == most_value:
            answer_list.append(key)
    
    answer_list = list(set(answer_list))
    answer_list.sort()

    for i in range(len(answer_list)):
        print(answer_list[i])

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [next(tokens) for _ in range(N)]  
    solve(N, S)

if __name__ == '__main__':
    main()

Solution (Python):
import collections

n = int(input())
s = [input() for i in range(n)]
s_list = []

max_s = collections.Counter(s).most_common()[0][1]
for i, j in collections.Counter(s).most_common():
    if j == max_s:
        s_list.append(i)
print(*sorted(s_list), sep = "\n")

Solution (Python):
import collections
N = int(input())
S = []
answer = []
for _ in range(N):
    S.append(input())

S_dict = collections.Counter(S)

max_num = S_dict.most_common()[0][1]







for i in S_dict.most_common():
    
    if i[1] == max_num:
        answer.append(i[0])

answer.sort()
for v in answer:
    print(v)

Solution (Python):
from collections import Counter
N = int(input())
S = Counter([input() for _ in range(N)])
v = max(S.values())
s = sorted(S.most_common())
if len(S) == 1:
    print(list(S)[0])
    exit()
for k, val in s:
    if val == v:
        print(k)

Solution (Python):

import sys

N = int(input())  

dic = {}
for i in range(N):
    word = input()
    if word in dic:
        dic[word] = dic[word] + 1
    else:
        dic[word] = 1

max = max(dic.values())
keys = [k for k, v in dic.items() if v == max ]
for i in sorted(keys):
    print(i)

Solution (Python):
from collections import defaultdict

N = int(input())
d = defaultdict(int)
for i in range(N):
  d[input().rstrip()] += 1

d2 = sorted(d.items(), key=lambda x: -x[1])
d3 = sorted(map(lambda x: x[0], filter(lambda x: x[1] == d2[0][1], d2)))

for s in d3:
  print(s)

Solution (Python):
N = int(input())
D = dict()
for _ in range(N):
    cand = input()
    if cand not in D:
        D[cand] = 1
    else:
        D[cand] += 1
mx = max(D.values())
A = sorted(D.items(), key=lambda x: -x[1])
ans = []
for k, m in A:
    if m == mx:
        ans.append(k)
    else:
        break

B = sorted(ans)
for b in B:
    print(b)

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

N = int(input())

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

for string in S:
    d[string] += 1

sorted_d = sorted(d.items(), key=lambda x:x[1], reverse=True)

ans = []

tmp = sorted_d[0][1]
for i in range(len(sorted_d)):
    if sorted_d[i][1] == tmp:
        ans.append(sorted_d[i][0])
        tmp = sorted_d[i][1]
    else:
        break

ans_sorted = sorted(ans) 
for i in range(len(ans_sorted)):
    print(ans_sorted[i])

Solution (Python):
a = int(input())
l = [input() for i in range(a)]
d = {}
for i in range(a):
  if l[i] not in d:
    d[l[i]] = 1
  else:
    d[l[i]] += 1
max_v = max(d.values())
keys = [k for k, v in d.items() if v == max_v]
keys.sort()
for x in keys:
  print(x)

Solution (Python):
N = int(input())
dict = {}
max_count = 0
max_count_words = []

for _ in range(N):
  s = str(input())

  if(s in dict):
    dict[s] += 1
  else:
    dict[s] = 1

for key, value in dict.items():
  if(value > max_count):
    max_count = value
    max_count_words = [key]
  elif(value == max_count):
    max_count_words.append(key)

list.sort(max_count_words)
print("\n".join(map(str, max_count_words)))

Solution (Python):
N = int(input())
dictionary = {}
for i in range(N):
    S = input()
    if S not in dictionary.keys():
        dictionary[S] = 1
    else:
        dictionary[S] += 1


value_max = max(dictionary.values())

max_list = []
for k, v in dictionary.items():
    if v == value_max:
        max_list.append(k)

max_list.sort()
for i in max_list:
    print(i)

Solution (Python):
from collections import Counter

n = int(input())
words = [input() for _ in range(n)]
d = Counter(words)
m = max(d.values())
max_l = [kv[0] for kv in d.items() if kv[1] == m]
print('\n'.join(sorted(max_l)))