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 collections
N = int(input())
a=[]
ans=[]
max =0
for i in range(N):
    a.append(input())
c = collections.Counter(a)
score_sorted = sorted(c.items(), key=lambda x:x[1], reverse=True)
for i in range(len(score_sorted)):
    max=score_sorted[0][1]
    if score_sorted[i][1] == max:
        ans.append(score_sorted[i][0])
    else:
        break
ans.sort()
for j in range(len(ans)):
    print(ans[j])

Solution (Python):
import collections

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

c = collections.Counter(s)
max = 0
for i in c.values():
  if max < i:
    max = i

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

for i in keys:
  print(i)

Solution (Python):
n=int(input())
l=[input() for i in range(n)]
l.sort()
ll=list(set(l))
ll.sort()
m=len(ll)
ans=[0]*m
count=0
j=0
for i in range(len(l)-1):
  if l[i]==l[i+1]:
    count+=1
    if i+1==n-1:
      ans[j]+=count
  else:
    ans[j]+=count
    count=0
    j+=1
g=max(ans)
for i in range(m):
  if ans[i]==g:
    print(ll[i])

Solution (Python):
import collections
import itertools

n = int(input())
l = [input() for _ in [0] * n]

counter = collections.Counter(l)

a = counter.most_common()[0][-1]
b = itertools.takewhile(
    lambda kv: kv[-1] == a, counter.most_common()
)

c = sorted(list(k for k, v in b))
print(*c,sep='\n')

Solution (Python):


n=int(input())  
i=0
lst ={}
while i < n: 
    s = input()
    if s not in lst:
        lst[s]=1
    else:
        lst[s]+=1
    i+=1
maxi = max(lst.values())
res = []
for i,j in lst.items():
    if j == maxi:
       res.append(i) 
res.sort()
for i in res:
     print(i)

Solution (Python):
N = int(input())
S_list = [input() for i in range(N)]
 
S_count = {}
for Si in S_list:
    if Si in S_count:
        S_count[Si] += 1
    else:
        S_count[Si] = 1

S_max = max(S_count.values())
S_count_sorted = sorted([key for key, val in S_count.items()\
                  if val == S_max])
 
print('\n'.join(S_count_sorted))

Solution (Python):
from collections import Counter

if __name__=="__main__":
    n = int(input())
    s=[]
    for i in range(n):
        s.append(input())
        
    s_most = Counter(s).most_common()

    ans_list = [s_most[0][0]]
    for i in range(1,len(s_most)):
        if s_most[i][1]==s_most[0][1]:
            ans_list.append(s_most[i][0])
        else:
            break

    ans_list.sort()

    for i in range(len(ans_list)):
        print(ans_list[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())
s = [input().strip() for i in range(N)]

dic = {}
for moji in s:
    if moji in dic.keys():
        dic[moji] += 1 
    else: dic[moji] = 1
max_dic = max(dic.values())
ans_list= [k for k, v in dic.items() if v == max_dic]  
ans_list = sorted(ans_list)
for al in ans_list:
    print(al)

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

M = {}
for x in L:
    if((x in M) != True):
        M[x] = 1
    else:
       
        M[x] = M[x] + 1

max_m = max(M.values())

ans = []
for x,y in M.items():
    if(max_m == y):
        ans.append(x)

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

Solution (Python):


import os
import datetime

def main():

    str_dict = {}
    val_1 = int(input())
    for i in range(val_1):
        val_x = input()

        if not val_x in str_dict:
            str_dict[val_x] = 1
        else:
            num = str_dict.get(val_x)
            str_dict[val_x] = num + 1

    max_count = max(str_dict.values())
    max_list = []

    for k, v in sorted(str_dict.items(), key=lambda x: -x[1]):
        if max_count == v:
            max_list.append(k)

    new_list = sorted(max_list)

    for key in new_list:
        print(key)





if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
input_int = int(input())
input_list = []

for i in range(input_int):
    input_line = input()
    input_list.append(input_line)

counter = Counter(input_list)

max_val = max(counter.values())
keys_of_max_val = [key for key in counter if counter[key] == max_val]

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

Solution (Python):

from collections import defaultdict
from operator import itemgetter

def main():
    n = int(input())
    a = [input() for _ in range(n)]
    s = defaultdict(int)
    for i in a:
        s[i]+=1  
    
    t = []
    for i, j in s.items():
        t.append((i, j))

    t.sort(reverse=True,key=itemgetter(1))
    MAX = t[0][1]
    ans = []
    for i, j in t:
        if j == MAX:
            ans.append(i)
    ans.sort()
    for i in ans:
        print(i)
main()

Solution (Python):
import collections

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

C = collections.Counter(S).most_common()
M = C[0][1]

ans = []
for c in C:
    if c[1] == M:
        ans.append(c[0])
    else:
        break

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

Solution (Python):
import collections

N = int(input())

data = []
val = [0]*N

for i in range(N):
    data.append(input())

data.sort()
c = collections.Counter(data)

mostc = c.most_common()
mostv = mostc[0][1]

ans = []
for x in mostc:
    if x[1] == mostv:
        ans.append(x[0])

ans.sort()

for y in ans:
    print(y)

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

l = [kv[0] for kv in s.items() if kv[1] == m]

l.sort()

for i in l:
  print(i)

Solution (Python):
from collections import Counter

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

c = Counter(S).most_common()

l = list(filter(lambda v: v[1] == c[0][1], c))
l.sort()

a = l[0][1]
for s in l:
    if s[1] != a: break
    print(s[0])

Solution (Python):
N = int(input())
A = dict()
for i in range(N):
    tmp = input()
    if(tmp in A): A[tmp] += 1
    else: A[tmp] = 1

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



B = dict()

MAX = 0

c = 0


for i in A:
    if(c == 0):
        MAX = i[1]
        B[i[0]] = i[1]
        c += 1
    else:
        if(i[1] == MAX):
            B[i[0]] = i[1]
        else:
            break




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

for i in B_sorted:
    print(i[0])

Solution (Python):
from collections import Counter
n = int(input())

l = [input() for i in range(n)]
l.sort()
c = Counter(l)

max = c.most_common()[0][1]
outs = []
for k, v in c.most_common():
    if v == max:
        outs.append(k)

outs.sort()
for out in outs:
    print(out)

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())
a={}
b=[]
for i in range(n):
    s=input()
    if s in a:
        a[s]=a[s]+1
    else:
        a[s]=int(1)
        b.append(s)
c=0
print()
for i in b:
    if c < a[i]:
        c=a[i]
b.sort()
for i in b:
    if a[i]==c:
        print(i)

Solution (Python):
import collections

N = int(input())
S = []

for i in range(N):
    S.append(input())

c = collections.Counter

max_cnt = max(c(S).values())

max_list = [k for k, v in c(S).items() if v == max_cnt]

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

Solution (Python):
import collections

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

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


while(i<n):
  if(c[s[i]] == max):
    rlist.append(s[i])
  i+=1

r2list=list(set(rlist))
r2list.sort()

len= len(r2list)
j=0

while(j<len):
  print(r2list[j])
  j+=1

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

dic = {}
m = 1
for i in range(N):
    st = input()
    if st not in dic:
        dic[st] = 1
    else:
        dic[st] += 1
        if dic[st] > m:
            m = dic[st]

ans = []
for s in dic:
    if dic[s] == m:
        ans.append(s)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
def main():
  n=int(input())
  poll=[input() for i in range(n)]

  dic={}
  for string in poll:
    if string not in dic:
      dic[string]=1
    else:
      dic[string]+=1
  
  x=max(dic.values()) 
  max_k=[k for k, v in dic.items() if v==x]
  max_k.sort()
  print(*max_k,sep='\n')
  
if __name__=='__main__':
  main()

Solution (Python):
from collections import Counter
from itertools import takewhile
N = int(input())
A_list = []
for i in range(N):
	A = str(input())
	A_list.append(A)
A_cnt = Counter(A_list)
mode_A = A_cnt.most_common()[0][-1]

it = takewhile(lambda x: x[-1]== mode_A, A_cnt.most_common())
re_it = sorted(it, key = lambda x: x[0])
for k,v in re_it:
	print(k)

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())
ss = {}

for i in range(n):
  s = str(input()).rstrip('\n')
  if s in ss:
    ss[s] = ss[s]+1
  else:
    ss[s] = 1

m = max(list(ss.values()))
ss1 = sorted({k:v for k,v in ss.items() if v == m}.items())

for k,v in ss1:
  print(k)

Solution (Python):
from collections import Counter
n = int(input())
a = [input() for i in range(n)]

c = Counter(a)
d = c.most_common()
ans = []
for i in c.items():
   if i[1] == d[0][1]:
     ans.append(i[0])
for i in sorted(ans):
  print(i)

Solution (Python):

N = int(input())
memo = {}
max_word = 1
for i in range(N):
    Si = input()
    try:
        memo[Si] += 1
        max_word = max(max_word, memo[Si])
    except:
        memo[Si] = 1
        
keys = [k for k, v in memo.items() if v == max_word]
keys.sort()
for item in keys:
  print(item)

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())
S = []
for i in range(N):
    s = input()
    S.append(s)

from collections import Counter
c = Counter()

for si in S:
    c[si] += 1

ca = []
for name, cnt in c.items():
    ca.append([name, cnt])

ca.sort(key=lambda x:x[0])
ca.sort(key=lambda x:x[1], reverse=True)

max_c = ca[0][1]
for name, cnt in ca:
    if cnt == max_c:
        print(name)

Solution (Python):
import numpy as np
N = input()

N = int(N)
strs = []
for ii in range(N):
  stri = input()
  strs.append(stri)
strs = np.sort(strs)

ustr, idx = np.unique(strs,return_index=True)
cnts = []
for ii in range(len(idx)-1):
  c = idx[ii+1] - idx[ii]
  cnts.append(c)

cnts.append(N - idx[len(idx)-1]) 
maxcnt = np.max(cnts)

ans = []

for ii in range(len(idx)):
  if cnts[ii] == maxcnt:
    ans.append(ustr[ii])

for ii in range(len(ans)):
  print(ans[ii])

Solution (Python):
N = int(input())
paper = [input() for i in range(N)]

D = {}
for p in paper:
    if p not in D:
        D[p] = 1
    else:
        D[p] += 1

key = 0
max_value = 0
k = []

for i in D:
    if D[i] > max_value:
        max_value = D[i]
        key = i
        k = []
    elif D[i] == max_value:
        k.append(i)

if len(k) == 0:
    print(key)
else:
    k.append(key)
    for j in sorted(k):
        print(j)

Solution (Python):

import sys
from collections import defaultdict

def solve(N: int, S: "List[str]"):
    d = defaultdict(int)
    cnt_common = 0
    commons = []

    for s in S:
        d[s] += 1
        if cnt_common < d[s]:
            cnt_common=d[s]
            commons = [s]
        elif cnt_common == d[s]:
            commons.append(s)

    return '\n'.join(sorted(commons))


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)]  
    print(solve(N, S))

if __name__ == '__main__':
    main()

Solution (Python):
from collections import OrderedDict
import sys
input = sys.stdin.readline

def resolve():
    n = int(input())

    count = OrderedDict()
    for _ in range(n):
        name = input()
        if name not in count.keys():
            count[name] = 1

        else:
            count[name] += 1

    count = OrderedDict(
        sorted(count.items(), key=lambda x: x[0])
    )
    max_polls = max(count.values())

    for k, v in count.items():
        if v == max_polls:
            print(k)
            
resolve()

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

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

max_val = max(d.values())
keys_of_max_val = [key for key in d if d[key] == max_val]


l = sorted(keys_of_max_val)
for i in l:
    print(i)

Solution (Python):
import sys
import collections
n = int(input())
s = [input() for i in range(n)]
s = sorted(s)
c = collections.Counter(s)
li = []
max_v = -1
for k,j in c.items():
    li.append([k,j])
    if max_v<j:
        max_v = j
li = sorted(li)
for i in range(len(li)):
    if li[i][1] == max_v:
        print(li[i][0])

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

for m in range(n):
    s = input()
    if s:
        if not s in sDict:
            sDict[s] = 1
        else:
            sDict[s] += 1
    else:
        break

sDict = sorted(sDict.items(), key=lambda x:x[1])

tempValue = ""
tempList = []

for key, value in reversed(sDict):
    if tempValue:
        if tempValue != value:
            break   
    else:
        tempValue = value
    
    tempList.append(key)

for element in sorted(tempList):
    print(element)

Solution (Python):
import collections

N = int(input())
a = []
for i in range(N):
  a.append(str(input()))
a = collections.Counter(a)
b = max(a.values())
max_k_list = [kv[0] for kv in a.items() if kv[1] == b]
max_k_list = sorted(max_k_list)
for i in max_k_list:
  print(i)

Solution (Python):
import collections
import itertools
N=int(input())
di = dict()
l = list()
for i in range(N):
    l.append( input())

c = collections.Counter(l)
ct = c.most_common()
m = ct[0][1]
li = list()
for t in ct:
    if m == t[1]:
        li.append(t[0]) 
    else:
        break
lis = sorted(li)
for s in lis:
    print(s)

Solution (Python):

N = int(input())

words = {}
max_count = 0
for i in range(N):
  word = input()

  count = words.get(word, 0) + 1
  words[word] = count

  if max_count < count:
    max_count = count

results = []
for k, v in words.items():
  if v == max_count:
    results.append(k)

for answer in sorted(results):
  print(answer)

Solution (Python):
n = int(input())
s = []
count = [0] * n
count[0] = 1

for i in range(n):
    s_e = str(input())
    s.append(s_e)
s.sort()

last = s[0]
s_max = 1

for i in range(1, n):
    if last == s[i]:
        count[i] = count[i-1] + 1       
    else:
        s_max = max(s_max, count[i-1])
        last = s[i]
        count[i] = 1

s_max = max(s_max, count[n-1])

for i in range(n):
    if s_max == count[i]:
        print(s[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):
from collections import Counter

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

sc = Counter(s)
maxNum = sc.most_common()[0][1]
keys = [k for k , v in sc.most_common() if v == maxNum]
keys.sort()
for word in keys:
    print(word)

Solution (Python):
from collections import defaultdict
import sys

def main():
    input = sys.stdin.readline
    n=int(input())
    dic=defaultdict(int)
    st=set([])
    for i in range(n):
        s=input().strip('\n')
        st.add(s)
        dic[s]+=1
    maxv=max(dic.values())
    l=sorted(st)
    for i in range(len(l)):
        if dic[l[i]]==maxv:
            print(l[i])
        
    

if __name__ == '__main__':
    main()

Solution (Python):
import collections
N = int(input())
counter = collections.Counter([input() for _ in range(N)])
maximum = max(counter.values())
answers = [k for k, v in counter.items() if v == maximum]
answers.sort()
for x in answers:
  print(x)

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

ans = []
l.sort()
num = 1
max_num = 0

for i in range(1,N):
    if l[i] == l[i-1]:
        num += 1
    else:
        if num > max_num:
            max_num = num
            ans = [l[i-1]]
        elif num == max_num:
            ans.append(l[i-1])
        num = 1
if num > max_num:
        max_num = num
        ans = [l[i]]
elif num == max_num:
    ans.append(l[i])

for i in ans:
    print(i)

Solution (Python):
n = int(input())
s = {}
for i in range(n):
  x = input()
  if x not in s.keys():
    s[x] = 1
  else:
    s[x] += 1
x = max(list(s.values()))
keys = sorted([k for k, v in s.items() if v == x])
for i in keys:
  print(i)

Solution (Python):
N = int(input())
dic = {}

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


max_val = max(dic.values())
keys_of_max_val = [key for key in dic if dic[key] == max_val]

keys_of_max_val.sort()

for k in keys_of_max_val:
    print(k)

Solution (Python):
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
S.append("A")
B = []
M = 1
T = 1
for i in range(N):
    if S[i] == S[i+1]:
        T += 1
    elif T < M:
        T = 1
    elif T == M:
        T = 1
        B.append(S[i])
    else:
        M = T
        T = 1
        B = [S[i]]

for i in range(len(B)):
    print(B[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())
a = list(input() for i in range(N))
a.sort()
count = 1
max = 0
ls = []
for i in range(N - 1):
  if a[i] == a[i + 1]:
    count += 1
  else:
    if count > max:
      ls = []
      ls.append(a[i])
      max = count
    elif count == max:
      ls.append(a[i])
    count = 1
if count > max:
  ls = []
  ls.append(a[N - 1])
elif count == max:
  ls.append(a[N - 1])
ls.sort()
for i in range(len(ls)):
  print(ls[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 collections



N = int(input())
S = [0] * N

for ii in range(N):
    S[ii] = input()



c = collections.Counter(S)

maxv=max(c.values())



ans = [k for k, v in c.items() if v == maxv]

ans=sorted(ans)


for ii in range(len(ans)):
    print(ans[ii])

Solution (Python):
import collections

n = int(input())
l = [input() for _ in range(n)]
c = collections.Counter(l)

ans = []
count_max = max(c.values())
for i in c.items():
    if list(i)[1] == count_max:
        ans.append(list(i)[0])

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

Solution (Python):
from collections import defaultdict
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
N = int(input())
S = defaultdict(int)
S2 = []
max = 0
for _ in range(N):
    s = input()
    S[s] += 1
    if max < S[s]:
        max = S[s]
for k, v in sorted(S.items(), key=lambda x: -x[1]):
    if max == v:
        S2.append(k)
    else:
        break
for s in sorted(S2):
    print(s)

Solution (Python):
import collections
N=int(input())
L=[]
for i in range(N):
  L.append(input())
S=collections.Counter(L)
MS= max(S.values())
ans=[]
for k,v in S.items():
  if v==MS:
    ans.append(k)
ans.sort()
print(' '.join(ans))

Solution (Python):
import collections

n = int(input())
s = [input() for _ in range(n)]
a = list(set(s))
ans = []

t = collections.Counter(s)
v = list(t.most_common())[0][1]

for i,j in list(t.most_common()):
	if v == j:
		ans.append(i)

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

Solution (Python):

n= int(input())
from collections import Counter
S = []
for _ in range(n):
  s = input()
  S.append(s)

c= Counter(S)
ans =[]
maxvalue =0

for values, counts in c.most_common():
  if maxvalue > counts:
    break
  else:
    maxvalue = counts
  ans.append(values)
  
  
for i in sorted(ans):
  print(i)

Solution (Python):
N = int(input())
S = list(input() for _ in range(N))

import collections
a = collections.Counter(S).most_common()
ans = []
for i in range(len(a)):
  if i == 0:
    ans.append(a[i][0])
  elif a[i - 1][1] == a[i][1]:
    ans.append(a[i][0])
  else:
    break
ans.sort()

for j in ans:
  print(j)

Solution (Python):
from collections import Counter

N = int(input())
S = [0]*N
for i in range(N):
  S[i] = input()  
S.sort()
c = Counter(S)
m_num = c.most_common()[0][1]

for s in sorted(list(set(S))):
  if c[s] == m_num:
    print(s)

Solution (Python):
d = {}
for i in range(int(input())):
  tmp = input()
  if tmp in d.keys():
    d[tmp]+=1
  else:
    d[tmp]=1
max_value = max(d.values())
keys = [k for k,v in d.items() if v == max_value]
for i in sorted(keys):
  print(i)

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

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

s_set = set(dic.keys())
s_set = sorted(s_set)

max = 0
for si in s_set:
  if dic[si] > max:
    max = dic[si]

for si in s_set:
  if dic[si] == max:
    print(si)

Solution (Python):
n = int(input())
si = []
s = ""

for i in range(n):
    s = input()
    si.append(s)

li = sorted(si)
li.append("S")
str_li = []
int_li = []
num = 1


for j in range(n):
    if li[j] == li[j+1]:
        num += 1
    else:
        str_li.append(li[j])
        int_li.append(num)
        num = 1
    t = li[j]

n_ma = max(int_li)

for j in range(len(int_li)):
    if int_li[j] == n_ma:
        print(str_li[j])

Solution (Python):
import numpy as np
N=int(input())
S=[]
ans={}

pri=[]

for i in range(N):
    tmp=input()
    if(tmp.isdecimal()==0):
        S.append(tmp)

for i in S:
    if(ans.get(i)==None):
        ans[i]=1
    else:
        ans[i]+=1
a=np.max(np.array(list(ans.values())))

for i,j in ans.items():
    if(j==a):
        pri.append(i)
        
pri=sorted(pri)


for i in pri:
    print(i)

Solution (Python):
n = int(input())
str_dic = {}
for _ in range(n):
    inp = input()
    if inp in str_dic:
        str_dic[inp] += 1
    else:
        str_dic[inp] = 1

max_num = max(str_dic.values())

max_str = [s[0] for s in str_dic.items() if s[1] == max_num]

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

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

from collections import Counter
X=Counter(S)
Y=X.most_common()
Z=sorted([i[0] for i in X.items() if i[1] == Y[0][1]])

for i in Z:
    print(i)

Solution (Python):
import collections
N=int(input())
L=[]
NL=[]
cL={}
for _ in range(N):
  L.append(str(input()))

cL=collections.Counter(L)
v,c=zip(*cL.most_common())

for i in range(len(v)):
           if c[0]==c[i]:
           	NL.append(v[i])
NL.sort()
for j in range(len(NL)):
           print(NL[j])

Solution (Python):
import collections
n = int(input())
s_list = []
for _ in range(n):
    i = input()
    s_list.append(i)
c = collections.Counter(s_list)

values, counts = zip(*c.most_common())
index = 0
for i in range(len(counts)-1):
    if counts[i] == counts[i+1]:
        index += 1
    else:
        break
        
ans_list = []
for j in range(index+1):
    ans_list.append(values[j])
ans_list.sort()
for ans in ans_list:
    print(ans)

Solution (Python):
import collections

N = int(input())
S = []
for _ in range(N):
  S += [input()]
d = collections.Counter(S).most_common()

for i in sorted([k for k, v in d if v == d[0][1]]):
  print(i)

Solution (Python):
import collections


N = int(input())
S = []

for _ in range(N):
  S.append(input())

cnt = collections.Counter(S)
cnt_sorted = sorted(cnt.items(), key=lambda x:x[1], reverse=True)


max = 0
pre = 0
ans = []
for v in cnt_sorted:
  max = v[1]
  if max >= pre:
    ans.append(v[0])
    pre = max
  else:
    break

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

Solution (Python):
import sys
import math
import itertools as it
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n = i()
s = [input() for _ in range(n)]
s.sort()
ss = list(set(s))
ss.sort()
a = [0]*len(ss)
i = 0
j = 0
while n-1 > i:
    if s[i] == s[i+1]:
        a[j] += 1
        i += 1
    else:
        i += 1
        j += 1
m = max(a)
for k in range(len(a)):
    if m == a[k]:
        print(ss[k])

Solution (Python):

my_dict = dict()
n = int(input())
for i in range(n):
    my_input = input()
    if my_input in my_dict:
        my_dict[my_input] += 1
    else:
        my_dict[my_input] = 1

max_val = max(my_dict.values())
keys_of_max_val = [key for key in my_dict if my_dict[key] == max_val]

keys_of_max_val.sort()

print("\n".join(keys_of_max_val))

Solution (Python):
n = int(input())
d = {}
ans = []
for i in range(n):
  s = input()
  if s not in d:
    d[s] = 1
  else:
    d[s] += 1
d = sorted(d.items(), key=lambda x:x[1])
score = d[-1][1]
ans = []
for i in range(len(d)):
  if d[i][1] == score:
    ans.append(d[i][0])
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
n = int(input())
s = {}
for _ in range(n) :
    s_sub = input()
    if s_sub in s.keys() :
        s[s_sub] += 1
    else :
        s[s_sub] = 1


s_sorted1 = sorted(s.items(), key = lambda value: -value[1])
max = s_sorted1[0][1]
ans = []
for j,k in s_sorted1 :
    if k == max :
        ans.append(j)
    else:
        break

for x in sorted(ans):
    print(x)

Solution (Python):
from collections import Counter


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

SC=Counter(S)
values, counts = zip(*SC.most_common())

most_counts=list(counts)[0]

most_counts_len=len([i for i in list(counts) if i ==most_counts])

output_values=values[:most_counts_len]
output_values=sorted(output_values)
for i in output_values:
    print(i)

Solution (Python):
from collections import defaultdict

n = int(raw_input())
d = defaultdict(int)
for _ in range(n):
    s = raw_input()
    d[s] += 1

ordered_d = sorted(d.items(), key=lambda x: x[1], reverse=True)
res = []
last_cnt = 0
for i, (name, cnt) in enumerate(ordered_d):
    if i == 0:
        last_cnt = cnt
    if last_cnt != cnt:
        break
    res.append((name, cnt))
        
for name, _ in sorted(res, key=lambda r: r[0]):
    print name

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

max_val = max(Slist.values())
keys_of_max_val = [key for key in Slist if Slist[key] == max_val]

result=sorted(keys_of_max_val)
[print(i) for i in result]

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
d = {}
for i in s:
    if i in d.keys():
        d[i]=d[i]+1
    else:
        d[i]=1
d_sorted = sorted(d.items(), key=lambda x:x[1])
d_name = [x[0] for x in d_sorted if x[1] == d_sorted[-1][1]]
d_name.sort()
print("\n".join(d_name))

Solution (Python):

n=int(input())
s=dict()
for i in range(n):
    x=input()
    if x not in s:
        s[x]=1
    else:
        s[x]+=1


max_value=max(s.values())
ans=sorted(s.items(),key=lambda x:x[0])

for i in ans:
    if max_value==i[1]:
        print(i[0])

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

arr = collections.Counter(words)
_max = arr.most_common()[0][1]
for word in sorted([i[0] for i in arr.items() if i[1] == _max]):
  print(word)

Solution (Python):
N = int(input())
s= {}
max_keep=0
for i in range(N):
    key=input()
    s.setdefault(key,0)
    s[key]+=1
    if s[key]>max_keep:
        max_keep=s[key]

max_list=[]
for value in s.values():
  if value==max_keep:
    max_list.append(s)

keys = [k for k, v in s.items() if v==max_keep]
keys.sort()

string = "\n".join(keys)
print(string)

Solution (Python):
n = int(input())
data = [input() for x in range(n)]

temp_list = {}


for x in list(set(data)):
    temp_list[x] = 0

for x in data:
    temp_list[x] += 1

max_value = max(temp_list.values())
sort_keys = sorted(temp_list.keys())

for x in sort_keys:
    if temp_list[x] == max_value:
        print(x)

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


inin = []
for i in range(N):
    inin.append(str(input()))
    
dic = {}
for i in inin:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] = dic[i]+1

l = dic.items()
max = 0
for i in l:
    if i[1] > max:
        max = i[1]

result = []
for i in l:
    if i[1] == max:
        result.append(i[0])

result.sort()

for i in result:
    print(i)