Problem:
English Sentence Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters. The text includes only alphabetical characters and spaces. A word is a sequence of letters which is separated by the spaces. Input A text is given in a line. You can assume the following conditions:  The number of letters in the text is less than or equal to 1000.  The number of letters in a word is less than or equal to 32.  There is only one word which is arise most frequently in given text.  There is only one word which has the maximum number of letters in given text.  Output The two words separated by a space. Sample Input Thank you for your mail and your lectures Output for the Sample Input your lectures

Solution (Python):
words = raw_input().split()
chk = dict()
for w in words:
    if w in chk:
        chk[w] += 1
    else:
        chk[w] = 0
print max(chk.items(), key=lambda x:x[1])[0], max(words, key=len)

Solution (Python):
words = raw_input().split()
d = dict()
for w in words:
    d[w] = d.get(w,0)+1
print max(d.keys(), key=lambda i:d[i]), max(words, key=len)

Solution (Python):
mlen = 0
mexst = 0
word = map(str, raw_input().split())
setword = list(set(word))
for i in range(len(word)):
    if len(word[i]) > mlen:
        mlen  = len(word[i])
        mlenw = word[i]
for i in setword:
    if word.count(i) > mexst:
        mexst = word.count(i)
        mexstw = i

print mexstw, mlenw

Solution (Python):
s = raw_input().lower().split()
c1 = 0
c2 = 0
for w in set(s):
    c=s.count(w)
    if c>c1: c1,w1 = c,w
    c=len(w)
    if c>c2: c2,w2 = c,w
print w1, w2

Solution (Python):
def f(A):
    x = A.values()
    c = x.index(max(x))
    return A.keys()[c]

s = raw_input().lower().split()
A={}
B={}
for w in s:
    if A.has_key(w): A[w] += 1
    else:
        A[w] = 1
        B[w] = len(w)
w1 = f(A)
w2 = f(B)
print w1, w2

Solution (Python):
s = raw_input().split()
c1 = 0
c2 = 0
for w in set(s):
    c=s.count(w)
    if c>c1: c1,w1 = c,w
    c=len(w)
    if c>c2: c2,w2 = c,w
print w1, w2

Solution (Python):
s = raw_input().split()
tmp_l = 0
tmp_s = 0
for i in s:
	if len(i) > tmp_l:	
		tmp_l = len(i)
		ans2 = i
	if s.count(i) > tmp_s:
		tmp_s = s.count(i)
		ans1 = i
print "{} {}".format(ans1, ans2)

Solution (Python):
from collections import Counter

c = Counter()
strings = raw_input().lower().split()
for s in strings:
    c[s] += 1
print sorted(c.items(), key=lambda a: a[1], reverse=True)[0][0],
print sorted(c, key=lambda a: len(a), reverse=True)[0]

Solution (Python):
a = raw_input().split()
dic = {}
mx = ''
for s in a:
    dic[s] = dic.get(s, 0) + 1
    if len(s) > len(mx):
        mx = s
print max(dic.items(), key=lambda p: p[1])[0], mx

Solution (Python):
count={}
for s in raw_input().rstrip().split():
	if not count.has_key(s):
		count[s]=[len(s),0]
	count[s][1]+=1

long,mode=max([x[0] for x in count.values()]),max([x[1] for x in count.values()])
for k,v in count.items():
	if v[0]==long:
		long=k
	if v[1]==mode:
		mode=k

print mode,long

Solution (Python):
text = input().split()
print(max(text, key = lambda w: text.count(w)), max(text, key = lambda w: len(w)))

Solution (Python):
s = raw_input().split()
d = {}
w = None
mf = 0
m = None
ml = 0

for ww in s:
    if( len(ww) > ml ):
        m = ww
        ml = len(ww)
    try:
        d[ww] += 1
        if( d[ww] > mf ):
            mf = d[ww]
            w = ww
    except KeyError:
        d[ww] = 1

print w, m

Solution (Python):
a = list(input().split())
print(max(a,key=a.count),max(a,key=len))

Solution (Python):
n=list(input().split())
x=0
y=0
a=''
b=''
for i in (n):
    if x<n.count(i):
        x=n.count(i)
        a=i
    if y<len(i):
        y=len(i)
        b=i
print(a,b)

Solution (Python):
from collections import Counter 
word = list(input().split())
count = Counter(word)
x,y = 0,0
for i in word:
    if x<len(i):
        x=len(i)
        y=i
print(count.most_common()[0][0],y)

Solution (Python):
a = list(input().split())
print(max(a, key=a.count), max(a, key=len))

Solution (Python):



import collections
s = input()
counter = collections.Counter(s.split())
d = counter.most_common()

maxm = 0
maxn = 0
for i in range(len(d)):
   if d[i][1] > maxm:
      maxm = d[i][1]
   if len(d[i][0]) > maxn:
      maxn = len(d[i][0])

for i in range(len(d)):
   if d[i][1] == maxm:
      print(d[i][0], end = "")
   if len(d[i][0]) == maxn:
      print("", d[i][0])

Solution (Python):
import statistics
m = list(map(str,input().split()));
mode = statistics.mode(m)
a = "";
for i in range(0,len(m)):
    if len(a) < len(m[i]):
        a = m[i];
print(mode,a);

Solution (Python):
a = input()
a = a.split(' ')
b=[]
e=[]
for i in range(len(a)):
    b.append(len(a[i]))
    f=a.count(a[i])
    e.append(f)
c=a[b.index(max(b))]
g=a[e.index(max(e))]

print(g,c)

Solution (Python):
import collections
a=list(map(str,input().split()))
c = collections.Counter(a)
d=0
for i in range(len(a)):
    b=len(a[i])
    if d<b:
        d=b
        e=i
print(c.most_common()[0][0],a[e])

Solution (Python):
s=input().split()

moji=[]
count=[]
mojisuu=""

for i in range(len(s)):
    n=0
    if(len(mojisuu)<len(s[i])):
        mojisuu=s[i]
    
    for j in range(len(moji)):
        if(moji[j]==s[i]):
            count[j]+=1
            n+=1
            break
    if(n==0):
        moji.append(s[i])
        count.append(1)

max_count=max(count)
max_index=count.index(max_count)
shutugen=moji[max_index]

print(shutugen, mojisuu)

Solution (Python):
x = input().split()
l = ""
m = 0
Count = 0
mostword = ""

for i in range(len(x)):
    if len(x[i]) > len(l):
        l = x[i]

for j in range(len(x)):
    a = x[j]
    Count = x.count(a)
    if Count > m: 
        m = Count
        mostword = a

print(mostword, l)

Solution (Python):
s=input().split()
print(max(s,key=s.count),max(s,key=len))

Solution (Python):
n=input().split()
mx = 0
mx2 = 0
for i in n:
    if mx < len(i):
        mx = len(i)
        mxm = i
    elif mx2 < n.count(i):
        mx2 = n.count(i)
        mxh = i
print(mxh,mxm)

Solution (Python):
x=input()
A=x.split()
S=[]
L=[]
for i in A:
    s=A.count(i)
    S.append(s)
    l=len(i)
    L.append(l)
M=max(S)
m=max(L)
Y=S.index(M)
y=L.index(m)
print(A[Y],A[y])

Solution (Python):
s=input().split()
print(max(s,key=s.count),max(s,key=len))

Solution (Python):
n = input().split()
a=0
b=0
l="x"
m="x"
for i in range(len(n)):
    if n.count(n[i])>a:
        a=n.count(n[i])
        l=n[i]
for i in range(len(n)):
    if len(n[i])>b:
        b=len(n[i])
        m=n[i]
print(l,m)

Solution (Python):
ns=list(map(str,input().split()))
mp={}
for n in ns:
	if n in mp:
		mp[n]=mp[n]+1
	else:
		mp[n]=1
long_word=''
freq_word=''
max_len=0
max_fre=0

for k,v in mp.items():
	if max_len<len(k):
		long_word=k
		max_len=len(k)
	if max_fre<v:
		freq_word=k
		max_fre=v
print(freq_word,long_word)

Solution (Python):
s=input().split()
print(max(s,key=s.count),max(s,key=len))

Solution (Python):
import collections
x = input().split()
c = collections.Counter(x)
max = 0
for i in range(len(x)):
   a = len(x[i])
   if a>max:
      max = a
      M = x[i]
print(c.most_common()[0][0], M)

Solution (Python):
x=input()
A=x.split()
S=[]
L=[]
for i in A:
    s=A.count(i)
    S.append(s)
    l=len(i)
    L.append(l)
M=max(S)
m=max(L)
Y=S.index(M)
y=L.index(m)
print(A[Y],A[y])

Solution (Python):
n=list(input().split())
print(max(n,key=n.count),max(n,key=len))

Solution (Python):

a = input().split()

print(max(a,key=a.count),max(a,key=len))

Solution (Python):
word = sorted(input().split())
length = len(word)
cnt = 0
cc = ""
w = ""
wc = 0
for i in word:
    if cnt < len(i):
        cnt = len(i)
        cc = i
for i in range(length):
    if word.count(word[i]) > wc:
        wc = word.count(word[i])
        w = word[i]
print(w, cc)

Solution (Python):
x = list(input().split())
print(max(x,key=x.count), max(x,key=len))

Solution (Python):
a=input().split()
print(max(a,key=a.count),max(a,key=len))

Solution (Python):
s=list(map(str,input().split()))

m={}
l={}

for i in range(len(s)):
    t=s[i].lower()
    if t in m:
        m[t]+=1
    else:
        m.setdefault(t,1)
    
    if t in l:
        pass
    else:
        l.setdefault(t,len(t))


print(max(m,key=m.get),max(l,key=l.get))

Solution (Python):
L=[]
M=[]
A=list(map(str,input().split()))
B=len(A)

for i in range(B):
    C=A.count(A[i])
    L.append(C)
D=max(L)
E=L.index(D)
print(A[E],end=" ")

for j in range(B):
    F=len(A[j])
    M.append(F)
G=max(M)
H=M.index(G)
print(A[H])

Solution (Python):
s=input().split()
print(max(s,key=s.count),max(s,key=len))

Solution (Python):
import collections

d = input()
D = d.split()

c = collections.Counter(D)

print(c.most_common()[0][0], max(D,key=len))

Solution (Python):
sentence = list(input().split())

maxcount = 0
maxlen = 0
cs = ''
ls = ''

for i in sentence:
    if maxcount < sentence.count(i):
        maxcount = sentence.count(i)
        cs = i

    if maxlen < len(i):
        maxlen = len(i)
        ls = i

print(cs, ls)

Solution (Python):

import collections
l =[]
word = input()
words = word.split(' ')
c = collections.Counter(words)
C = c.most_common(1)

for i in words:
    l.append(len(i))
for i in words:
    if max(l) == len(i):
        print(C[0][0],i)

Solution (Python):
A=list(input().split())
L=len(A)
MAX1=0
MAX2=0
for i in range(L):
    s=A.count(A[i])
    if s>MAX1:
        MAX1=s
        x=A[i]
    else:
        pass
    
    l=len(A[i])
    if l>MAX2:
        MAX2=l
        y=A[i]
    else:
        pass
    
print(x,y)

Solution (Python):
import collections
s = str(input())
S = []
A = []
l = s.split(' ')
S.extend(l)
c = collections.Counter(S)
L = len(S)
for i in range(L):
    a = S[i]
    A.append(a)
    A.sort(key=len,reverse=True)
print(c.most_common()[0][0], A[0])

Solution (Python):
x=input()
A=x.split()
S=[]
L=[]
for i in A:
    s=A.count(i)
    S.append(s)
    l=len(i)
    L.append(l)
M=max(S)
m=max(L)
Y=S.index(M)
y=L.index(m)
print(A[Y],A[y])

Solution (Python):



import collections
s = input()
counter = collections.Counter(s.split())
d = counter.most_common()


maxm = 0
maxn = 0
for i in range(len(d)):
   if d[i][1] > maxm:
      maxm = d[i][1]
   if len(d[i][0]) > maxn:
      maxn = len(d[i][0])



for i in range(len(d)):
   if d[i][1] == maxm:
      print(d[i][0], end = "")
   if len(d[i][0]) == maxn:
      print("", d[i][0])

Solution (Python):
a = input()

a = a.split()

ans1 = max(a,key=a.count)

ans2 = max(a,key=len)

print(ans1,ans2)

Solution (Python):
import collections
n=input().split()
c=collections.Counter(n)
dic={i: len(i) for i in n}
print(c.most_common()[0][0],max(dic,key=dic.get))

Solution (Python):
n = input().split()
print(max(n, key=n.count),max(n, key=len))

Solution (Python):
l = input().split()
s = set(l)
a = 0
b = 0
J = ''
K = ''
for i in s:
    if l.count(i) > a:
        a = l.count(i)
        J = i
    if len(i) > b:
        b = len(i)
        K = i
print(J,K)

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from collections import deque,defaultdict,Counter
def main():
    S = input().split()
    S[0] = S[0].lower()
    c = Counter(S)

    often = sorted(list(c.items()),key = lambda x:-x[1])[0][0]
    longest = sorted(list(c.keys()),key = len)[-1]
    print(often,longest)
if __name__ == '__main__':
    main()

Solution (Python):
a= list(input().split())
b={}
for w in a:
    if not(w in b):
        b[w]=1
    else:
        b[w]+=1

max_word=" "
max_num= a[0]

for w in b:
    if len(max_word)< len(w):
        max_word= w
    if b[w]> b[max_num]:
        max_num= w
print(max_num,max_word)

Solution (Python):

line = list(input().split())


print(max(line,key = line.count),max(line,key = len))

Solution (Python):
a = list(input().split())
print(max(a, key=a.count), max(a, key=len))

Solution (Python):
from operator import itemgetter
sentence = list(input().split())
max_length = 0
max_sentence = ""
count = []
for i in range(len(sentence)) :
    if max_length < len(sentence[i]) :
        max_length = len(sentence[i])
        max_sentence = sentence[i]
    new_word = False
    for j in range(len(count)) :
        if count[j][0] == sentence[i] :
            new_word = True
            count[j][1] += 1
            break
    if new_word == False :
        count.append([sentence[i], 1])
count = sorted(count, key = itemgetter(1), reverse = True)
print(count[0][0], max_sentence)

Solution (Python):
text = list(input().split())

count = []
length = []

for i in range(len(text)):
    count.append(text.count(text[i]))
    length.append(len(text[i]))

c = count.index(max(count))
l = length.index(max(length))

print(text[c],text[l])

Solution (Python):
word_list = input().split(' ')

word_dict = {}

longest_word_len = 0
longest_word = ''

high_freq_word_num = 0

for word in word_list:
    if longest_word_len < len(word):
        longest_word_len = len(word)
        longest_word = word

    if word not in word_dict:
        word_dict[word] = 1
    else :
        word_dict[word] += 1

    if high_freq_word_num < word_dict[word]:
        high_freq_word_num = word_dict[word]

for word in word_list:
    if word_dict[word] == high_freq_word_num:
        print(word + ' ' + longest_word)
        break

Solution (Python):
from collections import Counter
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    s = readline()
    c = Counter(s.split())
    write("%s %s\n" % (max(c, key=lambda x: c[x]), max(c, key=len)))
solve()

Solution (Python):
S = input().split()

l = 0
n = 0
L = "a"
N = "a"

for i in range(len(S)) :
    if S.count(S[i]) > n :
        n = S.count(S[i])
        N = S[i]
    
for i in range(len(S)) :
    if len(S[i]) > l :
        l = len(S[i])
        L = S[i]
        
print(N, L)

Solution (Python):
n=list(map(str,input().split()))
s=0
t=0
p=[]
q=[]
for i in range(0,len(n)):
    d=n.count(n[i])
    if d>s:
        p.append(n[i])
        s=d
    else:
        pass
    if len(n[i])>t:
        q.append(n[i])
        t=len(n[i])
p=p[::-1]
q=q[::-1]
print(p[0],q[0])

Solution (Python):
dic = dict()
maxWords = ""
words = list(x for x in input().split())

for w in words:
    if len(w) > len(maxWords):
        maxWords = w
    value = dic.get(w)
    if not value:
        dic.setdefault(w,1)
    else:
        dic.update({w:value + 1})
dic = dict(sorted(dic.items(), key=lambda x: x[1],reverse=True))
print(list(dic.keys())[0],maxWords)

Solution (Python):
from collections import Counter
sentence = input().split()
cnt = Counter(sentence)
print(cnt.most_common(1)[0][0], max(sentence, key=lambda x: len(x)))

Solution (Python):
from collections import Counter
s=input()
s=s.lower()

s=s.split(" ")
long=sorted(s,key=lambda w:len(w),reverse=True)

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

print(freq[0][0],long[0])

Solution (Python):


import sys




def main():
    y = ""
    for x in sys.stdin: y += x
    a = list(y.strip("\n").split(" "))
    print(max(a, key=a.count), max(a, key=len))
    
if __name__ == '__main__':
    main()

Solution (Python):
dic = {}
max_num = 0 
max_word = ""
for word in input().split():
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1 

    if max_num <= len(word):
        max_num = len(word)
        max_word = word

print(max(dic, key=dic.get), max_word)

Solution (Python):
s=list(input().split())


num1=1
tmp1=0
for i in range(len(s)):
    if tmp1>num1:                                       
        
        num1=tmp1
        list1=s[i-1]
    tmp1=0
    for m in range(len(s)):
        if s[i]==s[m]:
            tmp1+=1

for l in range(len(s)-1):                               
    if len(s[l])>len(s[l+1]):
        tmp2=s[l+1]
        s[l+1]=s[l]
        s[l]=tmp2

print(list1,s[len(s)-1])

Solution (Python):
s = input().split()

len_id = 0; max_len = 0
cnt_id = 0; max_cnt = 0

for i in range(len(s)):
    l = len(s[i])
    c = s.count(s[i])
    if l > max_len:
        max_len = l
        len_id = i
    if c > max_cnt:
        max_cnt = c
        cnt_id = i
print(s[cnt_id], s[len_id])

Solution (Python):
text = input().split()
l = {}
dc = {}

for i in text:
    l[i] = len(i)
    if i in dc.keys():
        dc[i] += 1
    else:
        dc[i] = 0


print(max(dc, key=dc.get), max(l, key=l.get))

Solution (Python):
a = list(input().split())
print(max(a, key=a.count), max(a, key=len))

Solution (Python):
list = input().split()
  
print(max(list, key=list.count), max(list, key=len))

Solution (Python):
list = input().split()
 
print(max(list, key=list.count), max(list, key=len))

Solution (Python):






import sys
import math


class mymath:
    
    pi = 3.14159265358979323846264338

    
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()


class output:
    
    def list(self, l):
        l = list(l)
        
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()






































def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            
            
        except EOFError:
            break
    return N

S = [x for x in input().split()]

Z = {}

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

maxlen = 0
maxlenstr = ''

maxnum = 0
maxnumstr = ''

for z in Z:
    if maxlen < len(z):
        maxlen = len(z)
        maxlenstr = z
    if maxnum < Z[z]:
        maxnum = Z[z]
        maxnumstr = z

print(maxnumstr,maxlenstr,sep=' ')

Solution (Python):
from collections import Counter
if __name__ == '__main__':

    A = input().split()
    
    c = Counter(A)
    ans = c.most_common(1)
    print(ans[0][0],max(A,key=len))

Solution (Python):
s = list(map(str,input().split()))
dict = {}
for n in s:
    if n in dict:
        dict[n] += 1
    else:
        dict[n] = 1
long_word = ''
freq_word = ''
max_len = 0
max_fre = 0
for k,v in dict.items():
    if max_len < len(k):
        long_word = k
        max_len = len(k)
    if max_fre < v:
        freq_word = k
        max_fre = v
print(freq_word,long_word)

Solution (Python):
from collections import Counter

dic_str = {}
strings = input().split()
dic_str = Counter(strings)

key_max = 0
val_max = 0
key_str = ''
val_str = ''
for k,v in dic_str.items():
  if len(k) > key_max:
    key_max = len(k)
    key_str = k
  if v > val_max:
    val_max = v
    val_str = k

print(val_str, key_str)

Solution (Python):
wordlist = raw_input().split()
maxlength = 0
lengthindex = -1
for i in range(0, len(wordlist)):
	length = len(wordlist[i])
	if maxlength < length:
		maxlength = length
		lengthindex = i
longest = wordlist[lengthindex]
wordlist.sort()
max = 0
cnt = 0
tmp = ''
modeword = ''
for i in range(0, len(wordlist)):
	if wordlist[i] != tmp:
		tmp = wordlist[i]
		cnt = 1
	else:
		cnt += 1
		if max < cnt:
			max = cnt
			modeword = tmp
print modeword+' '+longest

Solution (Python):
from collections import Counter
seq = list(input().split())
mode_word = ''
cnt = 0
for k, v in Counter(seq).items():
    if cnt < v:
        mode_word = k
        cnt = v
max_count_word = ''
for s in seq:
    if len(max_count_word) < len(s):
        max_count_word = s
print(mode_word, max_count_word)

Solution (Python):


from collections import Counter

s = input().strip().split(" ")
most_freq = Counter(s).most_common()[0][0]
max_len = sorted([(len(x), x)for x in s], reverse=True)[0][1]

print("{} {}".format(most_freq, max_len))

Solution (Python):
import collections
s=list(map(str,input().split()))
nc=collections.Counter(s)
ans_most=nc.most_common(1)[0][0]
ans_long=""
for i in s:
    if len(ans_long)<len(i):ans_long=i
print(ans_most,ans_long)

Solution (Python):
if __name__ == '__main__':
    maxL = 0
    maxF = 0
    strlst = list(map(str, input().split()))
    for s in strlst:
        if strlst.count(s) > maxF:
            maxF = strlst.count(s)
            maxFans = s
        if len(s) > maxL:
            maxL = len(s)
            maxLans = s
    print(maxFans, maxLans)

Solution (Python):
text = input().split()
dic = dict(zip(text,[0 for i in range(len(text))]))
for i in text:
	dic[i] = dic[i] + 1
max_ = max(dic.values())
for key,value in dic.items():
	if value == max_:
		most = key
max_ = 0
for i in dic.keys():
	if len(i) > max_:
		max_ = len(i)
		amax_ = i
print(most, amax_)

Solution (Python):
from statistics import *
words = [w.lower() for w in input().split()]
words.sort(key=len, reverse=True)
print(mode(words), words[0])

Solution (Python):
import collections

slist = list(map(str, input().split()))

sc = collections.Counter(slist)

common = sc.most_common()[0][0]

max = ""

for s in slist:
    if len(max) < len(s):
        max = s

print(common, max)

Solution (Python):
s = list(input().split())
print(max(s,key=s.count), max(s,key=len))

Solution (Python):
list = input().split()

print(max(list, key=list.count), max(list, key=len))

Solution (Python):
s = list(input().split())
print(max(s, key=s.count), max(s, key=len))

Solution (Python):
from collections import Counter

def process(line):
   longest = sorted(line, key=len)
   c = Counter(line)
   count = c.most_common(1)
   return count[0][0], longest[-1]

line = input().split()
a, b = process(line)
print('{} {}'.format(a, b))

Solution (Python):
x = input().lower()

term_data = {}
for word in x.split():
  if term_data.get(word) is None:
    term_data[word] = [0, len(word)]
  term_data[word][0] += 1

term_data = [(term, data) for term, data in term_data.items() ]
print(max(term_data, key=lambda x:x[1][0])[0], max(term_data, key=lambda x:x[1][1])[0] )

Solution (Python):
from collections import Counter
sentence = input().split()
cnt = Counter(sentence)
print(cnt.most_common(1)[0][0], max(sentence, key=lambda x: len(x)))

Solution (Python):
from collections import Counter
s = list(input().split())
c = Counter(s)
n,m = 0,0
for e in s:
    if n < len(e):
        n = len(e)
        m = e
print(c.most_common()[0][0],m)

Solution (Python):
def solve():
    text = input()
    longest, length = '', 0
    dic = {}
    for word in text.split():
        if word in dic.keys():
            dic[word] += 1
        else:
            dic[word] = 1
        
        if length < len(word):
            longest = word
            length = len(word)
    
    target, cnt = '', 0
    for k, v in dic.items():
        if v > cnt:
            target = k
            cnt = v
    print(target, longest)

if __name__ == "__main__":
    solve()