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):
from sys import stdin




def ii(): return int(stdin.readline())


def fi(): return float(stdin.readline())


def mi(): return map(int, stdin.readline().split())


def fmi(): return map(float, stdin.readline().split())


def li(): return list(mi())


def lsi():
    x=list(stdin.readline())
    x.pop()
    return x


def si(): return stdin.readline()


def sieve(x):
    a=[True]*(x+1)
    sq=floor(sqrt(x))
    for i in range(3, sq+1, 2):
        if a[i]:
            for j in range(i*i, x+1, i):
                a[j]=False
    if x>1:
        p=[2]
    else:
        p=[]
    for i in range(3, x+1, 2):
        if a[i]:
            p.append(i)
    return p
def prime_factor(x):
    c=1
    i=0
    while p[i]*p[i]<=x:
        if not x%p[i]:
            c+=1
            while not x%p[i]:
                x//=p[i]
        i+=1
    if x>1:
        c+=1
    return c
res=['APPROVED', 'DENIED']



d={}
mx=1
a=[]
for i in range(ii()):
    s=si()
    if s in d:
        d[s]+=1
        mx=max(mx, d[s])
    else:
        d[s]=1
for i in d:
    if d[i]==mx:
        a.append(i)
a.sort()
for i in a:
    print(i[:-1])

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 = {}
max = 0
 
for i in range(N):
  word = input()
  if word in S:
  	S[word] += 1
  else:
    S[word] = 1
  if S[word] > max:
    S_list = []
    max = S[word]
    S_list.append(word)
  elif S[word] == max:
    S_list.append(word)
    
S_list.sort()
for out in S_list:
  print(out)

Solution (Python):
N = int(input())
S = []

for i in range(N):
    tmp = input()
    S.append(tmp)
S.sort()
if N == 1:
    print(S[0])
    exit()
ans = []
SS = []
count = 1

for i in range(N-1):
    if i == N-2:
        if S[i] == S[i+1]:
            count += 1
            ans.append(count)
            SS.append(S[i])
        else:
            ans.append(count)
            SS.append(S[i])
            ans.append(1)
            SS.append(S[i+1])
    elif S[i] == S[i+1]:
        count += 1
    else:
        ans.append(count)
        SS.append(S[i])
        count = 1

m = max(ans)

for i in range(len(SS)):
    if ans[i] == m:
        print(SS[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
def main(N,S):
    counterS = collections.Counter(S)
    maxcount = max(counterS.values())
    keys = [k for k, v in counterS.items() if v == maxcount]
    keys.sort()
    for j in keys:
        print(j)

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

Solution (Python):
import collections
import itertools
N=int(input())

st=[]
for i in range(N):
    s=str(input())
    st.append(s)
c = collections.Counter(st)
count=c.most_common()
max=count[0][1]
min=count[-1][1]
if max==min:
    st=list(set(st))
    st.sort()
    for k in st:
        print(k)
    exit()
ret=[]
for letter,cou in count:

     if cou == max:
         ret.append(letter)
     else:
         break
ret.sort()
for r in ret:
    print(r)

Solution (Python):
from collections import OrderedDict
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):
import collections
n=int(input())
s = []
sort=[]
for i in range(n):
    s.append(input())
ans=collections.Counter(s).most_common()
oldnum=ans[0][1]
for i in range(len(ans)):
    if oldnum == ans[i][1]:
        sort.append(ans[i][0])
        oldnum=ans[i][1]
    else:
        break
sort.sort()
for i in range(len(sort)):
    print(sort[i])

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
S.sort()
h = {}
name = set(S)
for n in name:
    h[n] = 0

for s in S:
    h[s] += 1

max_h = max(h.values())
l = []
for s in set(S):
    if h[s] == max_h:
        l.append(s)

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

Solution (Python):
N=int(input())
S=[]
L=[]
C=[]

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

S.sort()
L.append(S[0])
C.append(1)
cur=0

for i in range(1,N):
    if S[i]!=S[i-1]:
        L.append(S[i])
        C.append(1)
        cur+=1
    else:
        C[cur]+=1
count_max=max(C)
for i in range(len(L)):
    if C[i]==count_max:
        print(L[i])

Solution (Python):
import queue
import collections

N = int(input())
Ss = [input() for i in range(N)]

mc = collections.Counter(Ss).most_common()
_, prev = mc[0]
q = queue.PriorityQueue()
for k, v in mc:
    if prev != v:
        break
    q.put(k)
    prev = v

while not(q.empty()):
    print(q.get())

Solution (Python):
n = int(input())
l_d = {}
max_n = 0
max_w = []
for i in range(n):
    n = str(input())
    if n in l_d:
        l_d[n] += 1
        if l_d[n] > max_n:
            max_w = []
            max_w.append(n)
            max_n = l_d[n]
        elif l_d[n] == max_n:
            max_w.append(n)
    else:
        l_d[n] = 1
        if max_n <= 1:
            max_w.append(n)
            
max_w.sort()
for j in max_w:
    print(j)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
S.sort()
maxi = 0
tmp = 1
ans = []
for i in range(N-1):
  if S[i] == S[i+1]:
    tmp += 1
  else:
    if tmp > maxi:
      maxi = tmp
      ans.clear()
      ans.append(S[i])
    elif tmp == maxi:
      ans.append(S[i])
    tmp = 1
  if i == N-2:
      if S[i] == S[i+1]:
        if tmp > maxi:
          maxi = tmp
          ans.clear()
          ans.append(S[i])
        elif tmp == maxi:
          ans.append(S[i])
      else:
        if maxi == 1:
          ans.append(S[N-1])
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
import collections
n =int(input())
ss = []
ans = []
for i in range(n):
    ss.append(input())
a = collections.Counter(ss)

m = max(a.values())

for i,s in a.items():

    if s == m:
        ans.append(i)
ans = sorted(ans)

for i in ans:
    print(i)

Solution (Python):


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

S.sort()
count = list()
now = 0
for i in range(N - 1):
    if S[i] != S[i + 1]:
        count.append([now, i - now + 1])
        now = i + 1
    if i + 1 == N - 1:
        count.append([now, len(S) - now])

m = max([c[1] for c in count])
for c in count:
    if c[1] == m:
        print(S[c[0]])

Solution (Python):
N = int(input())
D = {}
for n in range(N):
    w = input()
    if w not in D:
        D[w] = 1
    else:
        D[w] += 1
m = max(D.values())
l = []
for (key, value) in D.items():
    if value == m:
        l.append(key)
for s in sorted(l):
	print(s)

Solution (Python):
import sys

N = int(input())
S = [None]*N
counter = {}
for i in range(N):
    tmp = input()
    if tmp in counter:
        counter[tmp] += 1
    else:
        counter[tmp] = 1


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

tmp = counter_sorted[0][1]
output = []
L = len(counter)
for i in range(L):
    if tmp == counter_sorted[i][1]:
        output.append(counter_sorted[i][0])
    else:
        break


output = sorted(output)
for i in output:
    print(i)

Solution (Python):
N = int(input())
dic = {}
for i in range(0,N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] +=1

m = max(dic.values())

keys = [k for k,v in dic.items() if v == m]

keys.sort()

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

Solution (Python):
import collections
import itertools

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

counted = collections.Counter(S)


m = max(counted.values())


chars = [key for key, value in counted.items()
             if value == m]
chars=sorted(chars)
for a in chars:
  print(a)

Solution (Python):
from collections import  Counter
N = int(input())
votes = [input() for i in range(N)]
count = dict(Counter(votes))
max_vote = max(count.values())
res = []
for i in count:
    if count[i] == max_vote:
        res.append(i)
        continue
res.sort()
for i in res:
    print(i)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
import collections
c = collections.Counter(s)
d = c.most_common()

e = [d[0][0]]
for i in range(len(d)-1):
    if d[i][1] == d[i+1][1]:
        e.append(d[i+1][0])
    else:
        break

f = sorted(e)

[print(i) for i in f]

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):

import sys


def solve(N: int, S: "List[str]"):
    
    word = {}

    for s in S:
        if s not in word.keys():
            word[s] = 1
        else:
            word[s] = word[s] + 1

    max_n = max(word.values())

    max_w = [key for key in word.keys() if word[key] == max_n]

    max_w.sort()

    for st in max_w:
        print(st)

    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().strip())
words = []
for i in range(N):
  word = input().strip()
  words.append(word)
  
c = collections.Counter(words)
num = c.most_common()[0][1]


ans = []
for name, freq in c.most_common():
  if freq == num:
    ans.append(name)
  else:
    break
    
for i in sorted(ans):
  print(i)

Solution (Python):
n = int(input())
poll = {}
m = 0
for i in range(n):
    word = input()
    if word in poll:
        poll[word] += 1
    else:
        poll[word] = 1
    
    if poll[word] > m:
        m = poll[word]

words = [k for k, v in poll.items() if v == m]
words = sorted(words)
for word in words:
    print(word)

Solution (Python):
import collections

N = int(input().strip())
words = []
for i in range(N):
  word = input().strip()
  words.append(word)
  
c = collections.Counter(words)
num = c.most_common()[0][1]


ans = []
for name, freq in c.most_common():
  if freq == num:
    ans.append(name)
  else:
    break
    
for i in sorted(ans):
  print(i)

Solution (Python):
import sys
n = int(input())
a_dict = {}
max_val = 1
max_key_list = []
for s in sys.stdin:
  s = s.rstrip()
  if s not in a_dict:
    a_dict[s] = 1
    if max_val == 1:
      max_key_list.append(s)
  else:
    a_dict[s] += 1
    if a_dict[s] > max_val:
      max_val = a_dict[s]
      max_key_list = [s]
    elif a_dict[s] == max_val:
      max_key_list.append(s)
max_key_list.sort()
for s in max_key_list:
  print(s)

Solution (Python):
N = int(input())
T = []
L = []
for i in range(0,N):
    S = str(input())
    L.append(S)

L = sorted(L)
k = 0
T.append([L[0],1])  
for i in range(1,N):
    for j in range(k,len(T)):
        if L[i] == T[j][0]:
            T[j][1] += 1
        else:
            k = j + 1
            T.append([L[i],1])
            break

Max = 0
for i in range(0,len(T)):
    if T[i][1] > Max:
        Max = T[i][1]

ans = []
for i in range(0,len(T)):
    if T[i][1] == Max:
        ans.append(T[i][0])

ans = sorted(ans)

for i in range(0,len(ans)):
    print(ans[i])

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
a = [0]*n
count=m=0;

s.sort()

for i in list(range(1,n)):
    if(s[i]==s[i-1]):
        count+=1
    else:
        count=0
    a[i]=count
    if(m<count):m=count

for i in range(n):
    if(a[i]==m):
        print(s[i])

Solution (Python):
from collections import Counter

def print_cnt(l):
    counter = Counter(l)
    max_cnt = counter.most_common(1)[0][1]
    ret = [v for v,c in counter.most_common() if c == max_cnt] 
    ret=sorted(ret)
    for a in ret:
        print(a)


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

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

info.sort()


ans = [info[0]]
record = 1
tem_record = 1
for i in range(n-1):
    if info[i] == info[i+1]:
        tem_record += 1
        if i == n-2:
            if tem_record > record:
                record = tem_record
                ans = [info[i]]
            elif tem_record == record and i != 0:
                ans.append(info[i])
    else:
        if tem_record > record:
            record = tem_record
            ans = [info[i]]
        elif tem_record == record and i != 0:
            ans.append(info[i])

        tem_record = 1

if record == 1 and info[n-1] != info[n-2]:
    ans.append(info[n-1])


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

Solution (Python):
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    ss = [cc[0] for cc in c.most_common() if cc[1] == max_num]
    ss.sort()
    for s in ss:
        print(s,end="")

if __name__ == "__main__":
    main()

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

import collections

c = collections.Counter(S)


mx = c.most_common()[0][1]


L = set()
for s in S:
    if c[s] == mx:
        L.add(s)

L = list(L)
L.sort()
for l in L:
    print(l)

Solution (Python):
from collections import defaultdict
import pprint
n = int(input())
d1 = defaultdict(int)
for i in range(n):
  d1[input()]+=1
max1 = max(d1.values())
for x in sorted([k for k,v in d1.items() if v == max1]):
  print(x)

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

word_count = {}

for index in range(len(S)):
    word = S[index]
    if word in word_count:
        word_count[word] = word_count[word] + 1
    else:
        word_count[word] = 1

max = 0
for key in word_count.keys():
    count = word_count[key]
    if count > max:
        max = count

max_words = []
for key in word_count.keys():
    count = word_count[key]
    if count == max:
        max_words.append(key)

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

Solution (Python):
num=int(input())
dic={}
for i in range(num):
  s=input()
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1
sorteddic=sorted(dic.items(),reverse=True,key=lambda x:x[1])
res = []
cnt=0
temp = 0
for i in sorteddic:
  if cnt ==0 or temp == i[1]:
    res.append(i[0])
    temp = i[1]
  else:
    break
  cnt+=1  
for i in sorted(res):
  print(i)

Solution (Python):
N = int(input())
name = [input() for i in range(N)]
import collections
'''
name = ""
dic = {}
for i in range(N):
  name = input()
  dic[name] += 1
print(dic)
'''
c = collections.Counter(name)
values, counts = zip(*c.most_common(N))
maxim = counts[0]
answer = []
for val, cnt in zip(values,counts):
  if ( cnt == maxim):
    answer.append(val)
  else:
    break
answer = sorted(answer)
for i in answer:
  print(i)

Solution (Python):
import collections

N = int(input())
S = []
A = []
m=0

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

c = collections.Counter(S)

for k, v in c.most_common(2*10**5):

  if v>=m:

    A.append(k)
    m=v
  else:
    break
A.sort()
for j in range(0,len(A)):
  print(A[j])

Solution (Python):


n = int(input())

dic = {}
for _ in range(n):
    key = input()
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1
        

max_v = max(dic.values())
li = []


for key in dic:
    if max_v == dic[key]:
        li.append(key)
        
li = sorted(li)
for v in li:
    print(v)

Solution (Python):
import collections
import itertools

N=int(input())
A=[]
B=[]


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

counter = collections.Counter(A)

mode_v = counter.most_common()[0][-1]

it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

for k,v in it:
  B.append(k)
B.sort()

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

Solution (Python):
import collections

n=int(input())
s = []
max = 0

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

c = collections.Counter(s)

for i in c.items():
    if i[1] > max:
        max = i[1]

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

s2.sort()

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

Solution (Python):
import collections

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

c = collections.Counter(s)
c_s = c.most_common()
m = c.most_common()[0][1]
ans = []
for j in range(len(c_s)):
    if c_s[j][1] != m:
        break
    else:
        ans.append(c_s[j][0])
ans.sort()
for t in ans:
    print(t)

Solution (Python):
import collections
N = int(input())
S = [input() for _ in range(N)]
C = collections.Counter(S)
max_cnt = C.most_common()[0][1]
tmp = sorted([k for k,v in C.items() if v == max_cnt])
for ans in tmp:
    print(ans)

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

S_set= sorted(list(set(S)))

dic = dict(zip(S_set, [0 for _ in range(len(S_set))]))

for s in S: dic[s] += 1

K_max = max(list(dic.values()))
        
for (i,s) in enumerate(sorted(S_set)): 
    if dic[s] == K_max: 
        print(s)

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

maxv = max(poll.values())
a = [k for k, v in poll.items() if v == maxv]
a.sort()

for el in a:
    print(el)

Solution (Python):
n=int(input())
string_list=[input() for i in range(n)]
import collections
import numpy as np
c = collections.Counter(string_list)
d=c.most_common()
x=int(d[0][1])
z=[]
for i in range(len(d)):
  y=int(d[i][1])
  if x==y:
    z.append(str(d[i][0]))
    
z.sort()
for i in range(len(z)):
  print(z[i])

Solution (Python):
def main():
    n = int(input())
    s = {}
    for _ in range(n):
        string = input()
        if string in s:
            s[string] += 1
        else:
            s[string] = 1
    s = sorted(list(s.items()), key=lambda x: (x[1], x[0]), reverse=True)
    lst = []
    max_num = s[0][1]
    if n == len(s):
        for string, num in reversed(s):
            print(string)
    else:
        for string, num in s:
            if num != max_num:
                break
            lst.append(string)
    for l in reversed(lst):
        print(l)


if __name__ == "__main__":
    main()

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

S.sort()
a = S[0]
c = 0
moji = []

for i in S:
    if a != i:
        moji.append([c,a])
        a = i
        c = 0
    c += 1
if c > 0:
    moji.append([c,a])

moji.sort(reverse=True)
maxc = moji[0][0]
x = []
for j in moji:
    if j[0] < maxc: break
    x.append(j[1])
x.sort()
for j in x:
    print(j)

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

def calculate_mode(data):
    c = Counter(data)
    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()
    return(modes)

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

modes = calculate_mode(data)

for mode in modes:
    print(mode)

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

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

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

c_word = [i[0] for i in c.items() if i[1] == c_max]

dic = sorted(c_word)

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

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

Solution (Python):
n = int(input())
s = []
for i in range(0,n):
    s.append(input())
s.sort()
b = [0] * (n - 1)
for i in range(0,n-1):
    if s[i] == s[i+1]:
        b[i] = 1
j = n-2
while j > 0:
    if b[j-1] != 0:
        b[j-1] += b[j]
    j-=1
max = 0
for i in range(0,n-1):
    if b[i] > max:
        max = b[i]
for i in range(0,n-1):
    if b[i] == max:
        print(s[i])
if b[n-2] == 0:
    print(s[n-1])

Solution (Python):
def main():
    N = int(input())
    S = [0]*N
    count=[1]*N
    for i in range(N):
        S[i] = input()
    ss=sorted(S)
    ss.append("zettainai")
    flag=0
    for i in range(N):
        if ss[i]==ss[i+1]:
            flag= flag+1
        else:
            count[i]=count[i]+flag
            flag=0
    maxx=max(count)
    for i in range(N):
        if count[i]==maxx:
            print(ss[i])
main()

Solution (Python):
from collections import Counter
n=int(input())
s=[]
for i in range(n):
  s.append(input())
c=list(Counter(s).items())
t=[]
for i in range(len(c)):
  t.append(c[i][1])
m=max(t)
a=[]
for i in range(len(c)):
  if c[i][1]==m:
    a.append(c[i][0])
a.sort()
for i in range(len(a)):
  print(a[i])

Solution (Python):
N = int(input())
S = list(str(input()) for _ in range(N))
S2 = sorted(S)
cnt1 = [0,]
cnt2 = [0,]*N
word = [0,]
for i in range(N-1):
    if S2[i] != S2[i+1]:
        cnt1.append(i+1)
        word.append(S2[i])
cnt2 = [0,]*len(cnt1)
for i in range(1,len(cnt1)):
    cnt2[i] = cnt1[i] - cnt1[i-1]
cnt2.append(N-sum(cnt2))
word.append(S2[N-1])
X = max(cnt2)
for i in range(len(cnt2)):
    if cnt2[i] == X:
        print(word[i])

Solution (Python):
n = int(input())
S = []
for i in range(n):
    s = input()
    S.append(s)
S.sort()
A = list(set(S))
A.sort()


NUM =[0]*len(A)
j = 0
for i in range(len(S)):
    if(i+1<len(S)):
        if (S[i] == S[int(i)+1]):
            NUM[j] = NUM[j]+ 1
        else:
            j += 1
import numpy as np
b = np.argmax(NUM)

for e,i in enumerate(NUM):
    
    if (i == NUM[b]):
        print(A[e])

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

hash = {}
for i in range(N):
    if S[i] in hash:
        hash[S[i]] += 1
    else:
        hash[S[i]] = 1

max_value = max(hash.values())

result = {}
for key in hash.keys():
    if hash[key] == max_value:
        result[key] = True

for key in sorted(result.keys()):
    print(key)

Solution (Python):
import sys
from collections import defaultdict

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007



def main():
	n = int(input())
	dd=defaultdict(lambda :0)
	for i in range(n):
		s = input()
		dd[s]+=1
		
	maxv=0
	mml=[]
	for k in dd.keys():
		if dd[k]==maxv:
			mml.append(k)
		elif dd[k]>maxv:
			maxv=dd[k]
			mml=[k]
		else:
			pass
			
	mml.sort()
	for k in mml:
		print(k)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
def inverse_lookup(d, x):
    a = []
    for k,v in d.items():
        if x == v:
          a.append(k)
    return sorted(a)

n = int(input())
w = {}
for _ in range(n):
  i = input()
  if i in w:
    w[i] += 1
  else:
    w[i] = 1
m = max(w.values())
for j in inverse_lookup(w,m):
  print(j)

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

c = collections.Counter(ss)
d_=c.most_common()
mx = d_[0][1]
d_.sort()

m=len(d_)
for i in range(m):
  if d_[i][1] == mx:
    print(d_[i][0])
  else:
    pass

Solution (Python):
from collections import Counter

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

mycounter = Counter(S).most_common()[::1]
result = []
maxcount = mycounter[0][1]
for i in range(len(mycounter)):
    if maxcount == mycounter[i][1]:
        result.append(mycounter[i][0])

result.sort()
for j in range(len(result)):
    print(result[j])

Solution (Python):
import collections

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


s = collections.Counter(S)

s = s.most_common()

pri_l = [s[0][0]]
for i in range(1,len(s)):
	if s[0][1] == s[i][1]:
		pri_l.append(s[i][0])

	else:
		break

pri_l = sorted(pri_l)

for i in range(len(pri_l)):
	print(pri_l[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())
string_list = [input() for i in range(n)]
str_counter = Counter(string_list)
most_count = 0
l = []
for v in str_counter.values():
  if v > most_count:
    most_count = v

for k,v in str_counter.items():
  if v == most_count:
    l.append(k)
l.sort()
for i in l:
  print(i)

Solution (Python):
n = int(input())
s = []
for i in range(n):
    s.append(input())
sort_s = sorted(s)
x = [0] * n
y = [0] * n
count = 1
ans = []
max_c = 1
for i in range(n-1):
    if sort_s[i] == sort_s[i + 1]:
        count += 1
    else:
        x[i] = sort_s[i]
        y[i] = count
        count = 1
x[n-1] = sort_s[n-1]
y[n-1] = count
m = max(y)
ans = []
for i in range(n):
    if y[i] == m:
        ans.append(i)
for i in ans:
    print(x[i])

Solution (Python):
import collections

N = int(input())

S = [0] * N

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

c= collections.Counter(S)

mc = c.most_common()
mxf = mc[0][1]

ans = []
for i in range(len(c)):
    if(mc[i][1] == mxf):
        ans.append(mc[i][0])

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

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

m = max(dic.values())
l = []
for v in dic.items():
  if v[1] == m:
    l.append(v[0])
sortl = sorted(l)
for i in range(len(sortl)):
  print(sortl[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 = {}
for i in range(n):
	s = input()
	if s in d:
		d[s] += 1
	else:
		d[s] = 1
l = list(d.items())
l = sorted(l, key=lambda x:x[1])
nn = len(l)
m = l[nn-1][1]
i = nn - 1
ll = []
while l[i][1] == m:
	ll.append(l[i][0])
	i -= 1
	if i == -1:
		break
ll.sort()
for i in range(len(ll)):
	print(ll[i])

Solution (Python):
from collections import Counter

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res


N = n_in()
S = []
counter = Counter()

for i in range(N):
    counter[s_in()] += 1


t = counter.most_common()[0][1]
for s in sorted((map(lambda a: a[0], filter(lambda a: a[1] == t,  counter.most_common())))):
    print(s)

Solution (Python):
import collections

n = int(input())
words = [input() for _ in range(n)]
c = collections.Counter(words)
max_c = c.most_common()
ans = [max_c[0][0]]

for i in range(1, len(max_c)):
    if max_c[i][1] == max_c[i-1][1]:
        ans.append(max_c[i][0])
    else:
        break

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

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

import collections

Ss_counted = collections.Counter(Ss)
max_val = max(Ss_counted.values())



result = []
for k, v in Ss_counted.items():
    if v == max_val:
        result.append(k)

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

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

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

s_dict={}
for word in s:
    if word in s_dict:
        s_dict[word] += 1
    else:
        s_dict[word] = 1

Ms = max(s_dict.values())

keys = [k for k, v in s_dict.items() if v == Ms]


for i in sorted(keys):
    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)