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):
from collections import Counter
s = input().split()
po = Counter(s)
s.sort(reverse=True,key=lambda x:len(x))

print(po.most_common()[0][0],s[0])

Solution (Python):



a = raw_input().lower()
a = " "+a+" "
s = a.split()
ss = ""
tmp = ""
n = 0
for i in s:
    if len(ss) < len(i):
        ss = i
for i in s:
    i = " " + i + " " 
    if a.count(i) > n:
        n = a.count(i)
        tmp = i.strip()
print tmp, ss

Solution (Python):
li = input().split()
m = (li[0], 0)
l = (li[0], len(li[0]))
for s in set(li):
    if li.count(s) > m[1]: m = (s, li.count(s))
    if l[1] < len(s): l = (s, len(s))
print(m[0], l[0])

Solution (Python):
ns=list(map(str,input().split()))
mp={}
for n in ns:
    if n in mp:
        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):
        max_len=len(k)
        long_word=k
    if max_fre<v:
        max_fre=v
        fre_word=k
print(fre_word, long_word)

Solution (Python):
ns=list(map(str,input().split()))
mp={}
for n in ns:
    if n in mp:
        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):
        max_len=len(k)
        long_word=k
    if max_fre<v:
        max_fre=v
        fre_word=k
print(fre_word, long_word)

Solution (Python):

words = raw_input().strip().split(" ")
count = {};
for word in words:
  s = count.setdefault(word, 0);
  count[word] = s + 1
print max(count.items(), key=lambda x: x[1])[0], max(words, key=lambda x: len(x))

Solution (Python):
s = raw_input().split()
maxLength = 0
word1 = ""
word2 = ""
count = {}
maxCount = 0
for i in range(len(s)):
    count[s[i]] = 0
for i in range(len(s)):
    count[s[i]] += 1
    if(len(s[i]) > maxLength):
        maxLength = len(s[i])
        word2 = s[i]
for i in range(len(s)):
    if(count[s[i]] > maxCount):
        maxCount = count[s[i]]
        word1 = s[i]
print(word1),
print(word2)

Solution (Python):



a = raw_input()
b = a.split()
c = [ i.lower() for i in b ]
e = {}
h = {}
for d in c:
  if d not in e:
    h[d] = len(d)
    e[d] = 1
  else:
    e[d] += 1
f = [ (v,k) for k,v in e.items() ]
f.sort()
f.reverse()
maxnum = f[0][0]
for g in f:
  if g[0] != maxnum:
    break
  print g[1],
i = [ (v,k) for k,v in h.items() ]
i.sort()
i.reverse()
maxnum = i[0][0]
for j in i:
  if j[0] != maxnum:
    break
  print j[1],

Solution (Python):



l = input().split()

len_m = 0
for e in l:
    if len_m < len(e):
        len_m = len(e)
        a1 = e
    
d = {}

for e in l:
    if e not in d:
        d.update({
            e: 1
        })
    else:
        t = d[e]
        d.update({
            e: (t+1)
        })
print('%s %s' % (max(d.items(), key=lambda x: x[1])[0],a1))

Solution (Python):
import collections
c = collections.Counter(input().split())
longest = ''
for word in c:
    if len(longest) < len(word):
        longest = word

print(c.most_common(1)[0][0], longest)

Solution (Python):

wordlist = []
wordlist = raw_input().split()
dic = {}       
longest = ['',0]  
m = 0
for word in wordlist:    
    
    if word not in dic:
        dic[word] = 1
    else:
        dic[word] += 1
    
    
    if m == 0:
        longest[0] = word
        longest[1] = len(word)
        m += 1
    else:
        if len(word) > longest[1]:
            longest[0] = word
            longest[1] = len(word)

mode_key = sorted(dic.items(),key = lambda x:x[1],reverse=True)[0][0]                   
print '%s %s' % (mode_key,longest[0])

Solution (Python):
L=raw_input().split(" ")
count={}
length={}
while len(L)!=0:
    word=L.pop(0).lower()
    if word in count:
        count[word]+=1
    else:
        count[word]=1
    length[word]=len(word)

most=max(count.values())
long=max(length.values())
print [k1 for k1 in count if count[k1]==most].pop(0),
print [k2 for k2 in length if length[k2]==long].pop(0)

Solution (Python):

while 1:
	try:
		ls = raw_input().split()
		dic = {}

		for word in ls:
			dic[word] = dic.get(word,0) + 1

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

		max2 = ""
		for i in ls:
			if len(max2) < len(i):
				max2 = i

		print max1[0][0] + " " + max2
	except:
		exit()

Solution (Python):
s=raw_input().split()
c={}
for l in s:c[l]=c.get(l,0)+1
print sorted(c.items(),key=lambda x:x[1])[-1][0],max(s,key=len)

Solution (Python):
string_lis = raw_input().split()

dic = {}
max_len = ''
for string in string_lis:
    if not string in dic:
        dic[string] = 1
    else:
        dic[string] = dic[string] + 1
    if len(max_len) == 0:
        max_len = string
    elif len(max_len) < len(string):
        max_len = string
        
max_count = sorted(dic.items(), key=lambda x: x[1], reverse=True)[0][0]

print max_count, max_len

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


l = raw_input().split()
c = Counter()
for i in l:
    c[i] += 1
cc = c.most_common(1)
ans = l[0]
for i in range(len(l)):
    if len(l[i]) > len(ans):
        ans = l[i]
print "{0} {1}".format(cc[0][0], ans)

Solution (Python):
words = list(map(str, input().strip().split()))
lenAndWords = [0, '']
modeWords = {}
mode = [0, '']

for s in words:
    if len(s) > lenAndWords[0]:
        lenAndWords[0] = len(s)
        lenAndWords[1] = s

    if not s in modeWords:
        d = {s:0}
        modeWords.update(d)
    else:
        modeWords[s] += 1

    if mode[0] < modeWords[s]:
        mode[0] = modeWords[s]
        mode[1] = s

print(mode[1], lenAndWords[1])

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

maxi = 0
for s in S:
    length = len(s)
    if (length > maxi):
        maxi = length
        maxs = s

S.sort()
i = 0
maxm = 0
mode = 0
while (i < len(S) - 1):
    cnt = 1
    while True:
        if (S[i] == S[i + 1]):
            i += 1
            cnt += 1
            if (i >= len(S) - 1):
                break
        else:
            break
        
    if (cnt > maxm):
        maxm = cnt
        mode = i
        
    i += 1
        
print S[mode], maxs

Solution (Python):
l=map(str,raw_input().split())
cnt={}
w=ans=""
for i in l:
    if len(i)>len(w):
        w=i
    if cnt.has_key(i):
        cnt[i]+=1
    else:
        cnt[i]=1
t=0
for i in cnt:
    if cnt[i]>t:
        t=cnt[i]
        ans=i
print ans,w

Solution (Python):


def main():
    LIST=[]

    while True:
        try:
            val=input().split()
            LIST=[]
            
            
            for v in val:
                flag=True
                for item in LIST:
                    if item[0]==v:
                        index=LIST.index(item)
                        flag=False

                if flag:
                    LIST.append([v,1])
                else:
                    LIST[index][1]+=1

            longest=""
            LIST=sorted(LIST,key=lambda x:x[1],reverse=True)
            for i in LIST:
                longest=i[0] if max(len(longest),len(i[0]))==len(i[0]) else longest

                
            ans=LIST[0][0]
            print("{0} {1}".format(ans,longest))

        except:
            break

    
if __name__ == '__main__':
    main()

Solution (Python):
x=input().split()
longestWord= ""
mostWord=0
currentCount=0
THEmostWord=""


for r in range (len(x)):
    if len(x[r])> len(longestWord):
        longestWord=x[r]

for j in range (len(x)):
    thing= x[j]
    currentCount=x.count(thing)
    if currentCount > mostWord:
        mostWord= currentCount
        THEmostWord=thing
        


print(THEmostWord, longestWord)

Solution (Python):
s = input().split()
max_c = 0
max_l = 0
c = ''
l = ''
for i in s:
  if s.count(i) > max_c:
    max_c = s.count(i)
    c = i
  if len(i) > max_l:
    max_l = len(i)
    l = i
print(c+' '+l)

Solution (Python):
sentence=input()
list=[]
list=sentence.split()
c=[]
k=0
l=0
for i in range(len(list)):
    c.append(0)
    m=len(list[i])
    if(m>k):
        k=len(list[i])
        max=list[i]
for i in range(len(list)):
    for j in range(len(list)):
        if(i!=j and list[i]==list[j]):
            c[i]=c[i]+1
for i in range(len(c)):
    if(c[i]>l):
        l=i
print("%s %s"%(list[l],max))

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

mp={}
freq=""
longest=""

mx=0
for v in a:
    
    if v in mp:
        mp[v]+=1
    else:
        mp[v]=1

    if mx<mp[v]:
        freq=v
        mx=mp[v]

    
    if len(longest)<len(v):
        longest=v

print(freq,longest)

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

max_length=0
maximum_number_of_letters=""
max_cnt=0
frequent_word=""
for i in A:
	if len(i)>max_length:
		maximum_number_of_letters=i	
		max_length=len(i)
	if A.count(i)>max_cnt:
		frequent_word=i
		max_cnt=A.count(i)
print(frequent_word,maximum_number_of_letters)

Solution (Python):
a=str(raw_input()).split(" ")
b=set(a)
c,d=[0,""],""
for i in b:
    if len(i)>len(d): d=i
    if a.count(i)>c[0]:
        c[1]=i
        c[0]=a.count(i)
print(c[1]+" "+d)

Solution (Python):
s = list(input().split())
a = [s.count(i) for i in s]
l = [len(i) for i in s]
print(s[a.index(max(a))], s[l.index(max(l))])

Solution (Python):
s = input().split()
a = [s.count(i) for i in s]
l = [len(i) for i in s]
print(s[a.index(max(a))], s[l.index(max(l))])

Solution (Python):
s = raw_input().split()
maxLength, maxCount = 0, 0
word1, word2, count = "", "", {}
for i in range(len(s)):
	count[s[i]] = 0
for i in range(len(s)):
	count[s[i]] += 1
	if(len(s[i]) > maxLength):
		maxLength = len(s[i])
		word2 = s[i]
for i in range(len(s)):
	if(count[s[i]] > maxCount):
		maxCount = count[s[i]]
		word1 = s[i]
print word1, word2

Solution (Python):


import sys

dic = {}
text = raw_input().split()
max_count = 0
max_length = 0
for i in text:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1
for i in dic:
    max_count = max(max_count, dic[i])
    max_length = max(max_length, len(i))
for i in dic:
    if max_count == dic[i]:
        a = i
    if max_length == len(i):
        b = i
print "%s %s" %(a, b)

Solution (Python):
S = input()
W = S.split()
ws = {}
for w in W:
    if not w in ws:
        ws[w] = [1, len(w)]
    else:
        ws[w][0] += 1
print(max(ws.items(), key = lambda x: x[1][0])[0], max(ws.items(), key = lambda x: x[1][1])[0])

Solution (Python):
s=raw_input().split()
maxlen=""
maxct=0
for i in s:
    if len(maxlen)<len(i):
        maxlen=i
    if maxct<s.count(i):
        maxct=s.count(i)
        maxm=i
print maxm,maxlen

Solution (Python):
st = input().split()
a = ""
b = {} 
for s in st:
    if len(s) > len(a): a = s
    b[s] = b.get(s, 0) + 1
ls = sorted(b, key=b.get)[-1]
print(ls, a)

Solution (Python):
str = input().split()
mfw = ""
mlw = ""
maxF = 0
maxL = 0
for w in str:
    if str.count(w) > maxF:
        mfw = w
        maxF = str.count(w)
    if len(w) > maxL:
        mlw = w
        maxL = len(w)
print(mfw, mlw)

Solution (Python):
from collections import Counter
max_len = None
l = 0
counter = Counter(input().split())
for ci in counter:
    if l < len(ci):
        max_len = ci
        l = len(ci)

print(counter.most_common(1)[0][0], max_len)

Solution (Python):

from collections import defaultdict

d = defaultdict(int)
_input = input()

for word in _input.split():
    d[word] += 1

times = sorted(d.items(), key=lambda item: item[1], reverse=True)
lengths = sorted(d.items(), key=lambda item: len(item[0]), reverse=True)

print(times[0][0], end=' ')
print(lengths[0][0])

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

hindo_max = 0
len_max = 0
for word in l:
	if hindo_max < l.count(word):
		hindo_max = l.count(word)
		hindo_word = word
	if len_max < len(word):
		len_max = len(word)
		len_word = word
print(hindo_word, len_word)

Solution (Python):
words = input().split(' ')
print(sorted(words, key=words.count)[-1], sorted(words, key=len)[-1])

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

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

Solution (Python):
w = raw_input().split()
c, n = [], []
for i in w:
    c.append(w.count(i))
    n.append(len(i))
print w[c.index(max(c))] + " " + w[n.index(max(n))]

Solution (Python):
targ = input().split(' ')
mostfre = {}
ansfre = ""
longest = [0,""]
for t in targ:
    if len(t) > longest[0]:
        longest[0],longest[1] = len(t),t
    mostfre[t] = mostfre.get(t,0) + 1
temp = 0
for k,v in mostfre.items():
    if v > temp:
        temp = v
        ansfre = k
print(ansfre + ' ' + longest[1])

Solution (Python):
d = {}
m = 0
mw = ''
for w in raw_input().lower().split():
    if w in d:
        d[w] += 1
    else:
        d[w] = 1
    if len(w) > m:
        m = len(w)
        mw = w
print max(d.keys(), key=lambda x:d[x]), mw

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

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):
date = list(map(str,input().split()))
Num = 0
Size = 0
for tag in sorted(set(date), key=date.index):
    if date.count(tag) > Num:
        Num = date.count(tag)
        Ooi = tag
    if len(tag) > Size:
        Size = len(tag)
        Msiz = tag
print(Ooi,Msiz)

Solution (Python):
s=input().split()
dict={}
max=""
max_num=0
max_index=""
for i in s:
    if i in dict:
        dict[i]+=1
        if max_num<dict[i]:
            max_index=i
            max_num=dict[i]
    else: dict[i]=0
    if len(i)>len(max):
        max=i
print(max_index,max)

Solution (Python):
import sys
from collections import Counter

if __name__ == '__main__':
    
    
    data = []
    for line in sys.stdin:
        data = line.strip().strip('.').lower().split(' ')

    

    
    c = Counter(data)  
    most_frequent_word = c.most_common(1)[0][0]
    
    max_length_word = ''
    for w, freq in c.most_common():
        if len(w) > len(max_length_word):
            max_length_word = w

    
    print('{0} {1}'.format(most_frequent_word, max_length_word))

Solution (Python):
text = [s for s in input().split()]
s_text = set(text)
a, b = 0, 0
for s in s_text:
    if text.count(s) > a:
        a = text.count(s)
        x = s
    if len(s) > b:
        b = len(s)
        y = s
print(x, y)

Solution (Python):
from collections import defaultdict as dd
a=dd(int)
freq=0
leng=""
seq=""
b=input().split()
for i in b:
    a[i]+=1
    if freq<a[i]:
        freq=a[i]
        seq=i
    if len(leng)<len(i):
        leng=i
print(seq,leng)

Solution (Python):
from collections import defaultdict as dd
a=dd(int)
freq=0
leng=""
seq=""
b=input().split()
for i in b:
    a[i]+=1
    if a[seq]<a[i]:
        seq=i
    if len(leng)<len(i):
        leng=i
print(seq,leng)

Solution (Python):
from collections import defaultdict as dd
a=dd(int)
leng=""
seq=""
for i in input().split():
    a[i]+=1
    if a[seq]<a[i]:
        seq=i
    if len(leng)<len(i):
        leng=i
print(seq,leng)

Solution (Python):
string = list(str(input()).split(' '))
l = [0]*len(string)
k = 0
r = 0
for i in range(len(string)):
    if len(string[i]) > k:
        k = len(string[i])
        r = i
    for j in range(len(string)):
        if string[i] == string[j]:
            l[i] += 1
m = l.index(max(l))
print(string[m],string[r],sep = ' ')

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

Solution (Python):
text = raw_input().rstrip()

words = text.split(" ")

d = {}

longest_word=""
frequency_word=""
max_count=0

for word in words:
  if len(longest_word) < len(word):
    longest_word = word
  if d.has_key(word):
    d[word] = d[word]+1
  else:
    d[word] = 1
  if max_count < d[word]:
    max_count = d[word]
    frequency_word=word

print "{} {}".format(frequency_word, longest_word)

Solution (Python):
import sys
dic = {}
txt = sys.stdin.read().strip().split()
for t in txt:
    if t in dic:
        dic[t] += 1
    else:
        dic[t] = 1
s = sorted(dic.items(),key=lambda x:x[1],reverse=1)
fre = s[0][0]
t = sorted(dic.items(),key=lambda x:len(x[0]),reverse=1)
longest = t[0][0]
print("%s %s" % (fre,longest))

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

frq = ""
mx = ""
for i in S:
    if S.count(i) > S.count(frq):
        frq = i
    if len(i) > len(mx):
        mx = i

print(frq,mx)

Solution (Python):
line = [i for i in input().split()]
a = 0
b = ""
c = 0
d = ""
for i in range(len(line)):
    if i == 0:
        a = line.count(line[i])
        b = line[i]
        c = len(line[i])
        d = line[i]
    elif line.count(line[i]) > a:
        a = line.count(line[i])
        b = line[i]
    if len(line[i]) > c:
        c = len(line[i])
        d = line[i]
print(b+" "+d)

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
w = ['']*32
for s in input().split():
    d[s] += 1
    w[len(s)-1] = s
l = sorted(((k, v) for k, v in d.items()), key=lambda x: -x[1])
print(l[0][0], next(s for s in w[::-1] if s))

Solution (Python):
from collections import Counter
instr = input().split()
ctr = Counter(instr)

print(ctr.most_common(1)[0][0], end =" ")

ans = ""
for word in instr:
    if len(word)>len(ans): ans = word
print(ans)

Solution (Python):


import sys
import os
import datetime

d = {}
words = input().split()
longest_word = ''
for word in words:
    if len(word) > len(longest_word):
        longest_word = word

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

max_value = max(d.values())

for key in d.keys():
    if d[key] == max_value:
        print(key, longest_word)

Solution (Python):
from collections import Counter
l = input().split()
print(Counter(l).most_common(1)[0][0], sorted(l, key=len)[-1])

Solution (Python):
words = input().split()
word2count={}
maxlength = 0
maxlengthword=None
for word in words:
    word2count[word] = word2count.get(word, 0) + 1
    if maxlength < len(word):
        maxlength = len(word)
        maxlengthword = word

print(sorted(word2count.items(), key=lambda x: -1*x[1])[0][0],maxlengthword)

Solution (Python):
x=input().split()
longestWord= ""
mostWord=0
currentCount=0
THEmostWord=""

for r in range (len(x)):
    if len(x[r])> len(longestWord):
        longestWord=x[r]

for j in range (len(x)):
    currentCount=x.count(x[j])
    if currentCount > mostWord:
        mostWord= currentCount
        THEmostWord=x[j]

print(THEmostWord, longestWord)

Solution (Python):
from collections import Counter
a = input().split()
long = ""
for w in a:
    if len(w) > len(long):
        long = w
counter = Counter(a)
for word, cnt in counter.most_common():
    print(word, long)
    break

Solution (Python):
s = list(input().split())
maxLen = 0
maxNum = 0
dic = {}
for word in s:
    if not (word in dic):
        dic[word] = 1
    else:
        dic[word] += 1
    if maxNum < dic[word]:
        maxNum = dic[word]
        ansNum = word
    if maxLen < len(word):
        maxLen = len(word)
        ansLen = word
print(ansNum, ansLen)

Solution (Python):
def main():
    s = input().split()
    ss = sorted(set(s), key = s.index)
    cnt = []
    ans = []

    for x in ss:
        c = 0
        for y in s:
            if x == y:
                c += 1
            else:
                pass
        else:
            cnt.append(c)

    cntcnt = sorted(cnt, reverse = True)
    hoge = cntcnt.count(cntcnt[0])

    for x in range(hoge):
        ans.append(ss[cnt.index(cntcnt[x])])


    lenc = []
    for x in range(len(ss)):
        lenc.append(len(ss[x]))

    lenclenc = sorted(lenc, reverse = True)
    fuga = lenclenc.count(lenclenc[0])

    for x in range(fuga):
        ans.append(ss[lenc.index(lenclenc[x])])

    for x in range(len(ans)):
        if x != len(ans) - 1:
            print(ans[x], end = " ")
        else:
            print(ans[x])


if __name__ == "__main__":
    main()

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


L_max = 0
counts = {}
for word in input().split():
    if len(word) > L_max:
        L_max = len(word)
        long_word = word
    counts[word] = counts.get(word, 0) + 1
    
for a in sorted([a for a in counts if counts[a] == max(counts.values())]):
    print(a, long_word)

Solution (Python):
from collections import Counter
text = input().split()
tmp = ""
for t in text:
    if len(t) > len(tmp):
        tmp = t
print(Counter(text).most_common()[0][0], tmp)

Solution (Python):
a=raw_input().split()
dawa=''
d={}
for w in a:
	if len(w)>len(dawa): dawa=w
	d[a.count(w)]=w
m=max(d.keys())
akeh=d.get(m)
print '%s %s' % (akeh,dawa)

Solution (Python):
dic = {}
max = 0
maxword = 0
word = input().strip().split(" ")
i = 1
while i <= len(word):
    if word[i-1] in dic:
        dic[word[i-1]] += 1
    else:
        dic[word[i-1]] = 1
    i += 1
for k,v in sorted(dic.items()):
    if v > max:
        max = v
        words = k
for k in dic:
    if len(k) > maxword:
        maxword = len(k)
        maxwords = k
print(words + " " + maxwords)

Solution (Python):

words = input().split()
print(max(words, key=words.count), max(words, key=len))

Solution (Python):
from collections import Counter


def main():
    inp = input().strip().split(' ')

    k = Counter()

    maxlen = 0
    maxlenword = ''
    for z in inp:
        k[z] += 1

        if len(z) > maxlen:
            maxlenword = z
            maxlen = len(z)

    maxi = k.most_common(1)[0][0]

    print(maxi, maxlenword)

if __name__ == '__main__':
    main()

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

Solution (Python):
if __name__ == '__main__':
    a = input().split()
    countWords = []
    lenWords =[]
    for x in a:
        countWords.append(a.count(x))
        lenWords.append(len(x))
    print(a[[i for i,x in enumerate(countWords) if x == max(countWords)][0]],a[[i for i,x in enumerate(lenWords) if x == max(lenWords)][0]])

Solution (Python):
sentence = input().split()
longest = sentence[0]
dictionary = {}
for word in sentence:
    if word in dictionary:
        dictionary[word] += 1
    else:
        dictionary[word] = 0
    if len(word) > len(longest):
        longest = word
mode_value = 0
mode_key = 0
for word in dictionary:
    if mode_value < dictionary[word]:
        mode_value = dictionary[word]
        mode_key = word
print(mode_key, longest)

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

Solution (Python):
d = {}
l = ''
s = input()
for i in s.split():
    if not i in d:
        d[i] = 0
    else:
        d[i] += 1
    if len(str(l)) < len(str(i)):
        l = i

print(sorted(d.items(), key=lambda x: x[1])[-1][0], l)

Solution (Python):
line = input().split()
setl = set(line)
data = list(setl)
value = [0] * len(setl)
dic = {}
i = maxlen = 0
maxstr = ""
for s in setl:
  if len(s) > maxlen:
    maxlen = len(s)
    maxstr = s
  dic.update({s: i})
  i += 1
for l in line:
  value[dic[l]] += 1
m = max(value)
for i in range(len(data)):
  if value[i] == m:
    print(data[i], maxstr)
    break

Solution (Python):
from collections import Counter
def main():
    str = Counter(input().split(" "))
    long_str = ""
    for word in str:
        if len(long_str) < len(word):
            long_str = word
    print(str.most_common(1)[0][0] , long_str)


if __name__ == '__main__':
    main()

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

len_max = 0
freq_max = 0
w_len = ""
w_freq = ""
dict_freq = {}

for i,w in enumerate(s):
    if w in dict_freq:
        dict_freq[w] += 1
    else:
        dict_freq[w] = 1
    if len(w) > len_max:
        w_len = w
        len_max = len(w)
    if dict_freq[w] > freq_max:
        w_freq = w
        freq_max = dict_freq[w]
print(w_freq, w_len)

Solution (Python):
S = input().split()
words = []
for i in range(len(S)):
    words.append(S[i])
    words.sort()

cnt = 0
maxcnt = 0
ans1 = ""
ans2 = words[0]
for i in range(1, len(words)):
    if words[i] == words[i-1]:
        cnt += 1
    else:
        cnt = 0
    if maxcnt < cnt:
        ans1 = words[i]
        maxcnt = cnt
    if len(ans2) < len(words[i]):
        ans2 = words[i]

print(ans1,ans2)

Solution (Python):
a=input().strip().split()
d,e={},{}
for w in a:d.setdefault(w,0);d[w]+=1
for w in d:
 if d[w]==max(d.values()):print(w,end='')
 e.setdefault(len(w),[]).append(w)
print('',*e[max(e)])

Solution (Python):
a=input().split()
d,e={},{}
for w in a:d.setdefault(w,0);d[w]+=1
for w in d:
 if d[w]==max(d.values()):print(w,end='')
 e.setdefault(len(w),[]).append(w)
print('',*e[max(e)])

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

Solution (Python):
word_l = input().split()
dic = {}

for w in word_l:
    try:
        dic[w] += 1
    except:
        dic[w] = 1

l_w = max(word_l, key=len)
p_w = max(dic.items(), key=lambda x:x[1])
print(p_w[0], l_w)

Solution (Python):
import statistics
sentLong = ''
sent = list(map(str,input().split(' ')))
for i in range(len(sent)):
	if len(sentLong) < len(sent[i]):
		sentLong = sent[i]
print(statistics.mode(sent), sentLong)

Solution (Python):
import collections
l=input().split()
print(sorted(collections.Counter(l).items(),key=lambda x:x[1])[-1][0],
      sorted(l,key=len)[-1])

Solution (Python):
from collections import Counter

lst = input().split()

dic = Counter(lst)
most_common = dic.most_common(1)[0][0]

length = max([len(s) for s in lst])

for s in lst:
  if len(s) == length:
    longest = s

print(most_common, longest)

Solution (Python):



import collections
from operator import itemgetter

a = list(input().split())
maxlen = 0
for i in a:
	if len(i) > maxlen:
		maxlen = len(i)
		ans_max_len = i

dict = collections.Counter(a)
print(max(dict.most_common(), key=itemgetter(1))[0], ans_max_len)

Solution (Python):



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

Solution (Python):
text = raw_input().split()
Max = 1
for i in text:
    if len(i) > Max:
        Maxstr = i
        Max = len(i)
Max = 1
for i in text:
    t = text.count(i)
    if t > Max:
        Maxcount = i
        Max = t

print Maxcount,Maxstr

Solution (Python):
import sys

sentence = sys.stdin.readline().strip()
words = sentence.split()

tmp = set()
for word in words:
    count = words.count(word)
    tmp.add((word, count))
print max(list(tmp), key=lambda x:x[1])[0],max(words, key=lambda x:len(x))

Solution (Python):
sent=raw_input()
words=sent.split()
max_f,freq_w=0,""
max_len,len_w=0,""
for word in words:
    if max_f<words.count(word):
        freq_w=word
        max_f=words.count(word)
    if max_len<len(word):
        len_w=word
        max_len=len(word)
print "%s %s"%(freq_w,len_w)

Solution (Python):
dic={}
for word in raw_input().split():
    if word not in dic:
        dic[word]=0
    dic[word]+=1
print max(dic.iterkeys(),key=lambda k:dic[k]),
print max(dic.iterkeys(),key= lambda k:len(k))

Solution (Python):
dic={}
for word in raw_input().split():
    if word not in dic:
        dic[word]=0
    dic[word]+=1
print max(dic.iterkeys(),key=lambda k:dic[k]),
print max(dic.iterkeys(),key=lambda k:len(k))

Solution (Python):
words = raw_input().split()
dict = {}
for word in words:
    try:
        dict[word] += 1
    except:
        dict[word] = 1
print max(dict.items(),key=lambda x:x[1])[0],
print max(words, key=len)

Solution (Python):
def count(sent):
    kind = list(set(sent))
    ki_cou = []
    for ki in kind:
        ki_cou.append(sent.count(ki))
    
    return kind[ki_cou.index(max(ki_cou))]


def length(sent):
    kind = list(set(sent))
    ki_len = []
    for ki in kind:
        ki_len.append(len(ki))
    return kind[ki_len.index(max(ki_len))]


sent = map(str, raw_input().split(' '))

print count(sent),length(sent)

Solution (Python):
words={}
for word in raw_input().rstrip().split():
    words.setdefault(word, 0)
    words[word]+=1

wl=sorted(words.items(),key=lambda x : x[1],reverse=True)
print wl[0][0],
wl=sorted(words.items(),key=lambda x : len(x[0]),reverse=True)
print wl[0][0]

Solution (Python):
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter

counter = Counter()
for line in stdin:
    for s in line.split():
        counter[s] += 1
print(counter.most_common()[0][0], sorted(counter.keys(), key=len)[-1])

Solution (Python):
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter

counter = Counter()
for line in stdin:
    for s in line.split():
        counter[s] += 1
print(counter.most_common()[0][0], max(counter, key=len))

Solution (Python):
a = raw_input().split()
ans = {}
for i in a:
 if i not in ans:
   ans[i] = 1
 else:
   ans[i] += 1
tt,gg,q,w=0,0,"",""
for i in ans:
   if ans[i] > tt:
     tt = ans[i]
     w = i
   if len(i) > gg:
     gg = len(i)
     q = i
print w,q

Solution (Python):
word_d={}
for word in raw_input().split():
    word_d[word]=word_d.get(word,0)+1
print max(word_d.iterkeys(), key=lambda i: word_d[i]),max(word_d.iterkeys(),key=lambda i:len(i))

Solution (Python):

import sys


def mode(hash):
    m = max(hash.values())
    for k in hash.keys():
        if hash[k] == m:
            return k

def longest(hash):
    h = {}
    for k in hash.keys():
        h[k] = len(k)
    m = max(h.values())
    l = ''
    for k in h.keys():
        if h[k] == m:
            l = k
            break
    return l


h = {}



for line in sys.stdin:
    terms = line.rstrip('\r\n').split(' ')
    for t in terms:
        if t in h:
            h[t] += 1
        else:
            h[t] = 1

print mode(h), longest(h)

Solution (Python):
dic={}
s=raw_input().lower().split()
for word in s:
    try:
        dic[word]+=1
    except:
        dic[word]=1

m=0
l=0
for word, e in dic.items():
   if e>m:
       m=e
       w1=word
   if len(word)>l:
       l=len(word)
       w2=word

print w1, w2

Solution (Python):
from collections import Counter

s = raw_input().split()
c = sorted(Counter(s).items(), key=lambda x:x[1], reverse = True)
r = sorted(s, key=lambda x:len(x), reverse = True)

print c[0][0], r[0]

Solution (Python):
data = raw_input().strip().split()

stat = {}

for w in data:
    if w in stat:
        stat[w][0] += 1
    else:
        stat[w] = [1, len(w)]

count_list = sorted(stat.items(), key=lambda x: x[1][0], reverse=True)
length_list = sorted(stat.items(), key=lambda x: x[1][1], reverse=True)

print count_list[0][0] + " " + length_list[0][0]

Solution (Python):
dic = {}
for s in raw_input().split():
	dic[s] = dic.get(s, 0) + 1
val = dic.items()
most = sorted(val, key=lambda i:i[1], reverse=True)[0][0]
length = sorted(val, key=lambda i:len(i[0]), reverse=True)[0][0]
print '{0} {1}'.format(most, length)

Solution (Python):
dic = {}
for s in raw_input().split():
	dic[s] = dic.get(s, 0) + 1
val = dic.items()
most = sorted(val, key=lambda i:i[1], reverse=True)[0][0]
length = sorted(val, key=lambda i:len(i[0]), reverse=True)[0][0]
print most, length