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



Sample input:
Thank you for your mail and your lectures


Sample output:
your lectures

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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+=" " 
    if a.count(i) > n:
        n = a.count(i)
        tmp = i.strip()
print tmp, ss

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !

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),a1))

Submission status: Wrong Answer

Solution code:
import sys
f = sys.stdin

import collections
c = collections.Counter(f.readline().lower().split())

longest = ''
for word in c:
    if len(longest) < len(word):
        longest = word

print(max(c), longest)

Submission status: Wrong Answer

Solution code:
import sys
f = sys.stdin

import collections
c = collections.Counter(f.readline().split())

longest = ''
for word in c:
    if len(longest) < len(word):
        longest = word

print(max(c), longest)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
ls = []
dic = {}# {'your' : [出現回数,単語長]}

ls = raw_input().split()
for k in range(len(ls)):
    if ls[k] not in dic.keys():
        dic[ls[k]] = []
        dic[ls[k]].append(1)
        dic[ls[k]].append(len(ls[k]))
    else:
        dic[ls[k]][0] += 1

a=max(dic) # value[0]
b=max(dic.items(), key=lambda x: x[1][1])[0]
print "%s %s" % (a,b)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
ls = []
dic = {}# {'your' : [appeared,len]}

ls = raw_input().split()
for k in range(len(ls)):
    if ls[k] not in dic.keys():
        dic[ls[k]] = []
        dic[ls[k]].append(1)
        dic[ls[k]].append(len(ls[k]))
    else:
        dic[ls[k]][0] += 1

a=max(dic) # value[0]
b=max(dic.items(), key=lambda x: x[1][1])[0]
print "%s %s" % (a,b)

Submission status: Wrong Answer

Solution code:
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) < i:
		max2 = i

print max1[0][0] + " " + max2

Submission status: Wrong Answer

Solution code:

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) < i:
				max2 = i

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import Counter


l = raw_input().split()
print l
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)

Submission status: Wrong Answer

Solution code:
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 maxs, S[mode]

Submission status: Wrong Answer

Solution code:
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
print(c[1]+" "+d)

Submission status: Wrong Answer

Solution code:
s=raw_input().split()
maxlen=""
for i in s:
    if len(maxlen)<len(i):
        maxlen=i
print max(s),maxlen

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict

d = defaultdict(int)
_input = input()
sentence = [e for e in _input.split()]
l = []

for word in sentence:
    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][1], end=' ')
print(lengths[0][0])

Submission status: Wrong Answer

Solution code:
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
print(mostfre)
for k,v in mostfre.items():
    if v > temp:
        temp = v
        ansfre = k
print(ansfre + ' ' + longest[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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
    else: dict[i]=0
    if len(i)>len(max):
        max=i
print(max_index,max)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

if __name__ == '__main__':
    # ??????????????\???
    # line = 'Thank you for your mail and your lectures'
    data = []
    for line in sys.stdin:
        data = line.strip().lower().split(' ')

    print(data)

    # ??????????¢??????????
    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))

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

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

Submission status: Wrong Answer

Solution code:
memo = {}
many, length = '', ''
max_val, max_len = 0, 0

word = input().split()

for _ in word :
    if _ in memo :
        memo[_] = memo[_] + 1
        if max_val < memo[_] : 
            max_val == memo[_]
            many = _
    else :
        memo[_] = 1
        if max_len < len(_) :
            max_len = len(_)
            length = _

print(many, length)

Submission status: Wrong Answer

Solution code:
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):
        ansLen = word
print(ansNum, ansLen)

Submission status: Wrong Answer

Solution code:
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)
print(dic)

Submission status: Wrong Answer

Solution code:
import sys 

def main():
    
    input_line = []
#     with open('test_data') as f:
#         for line in f.readline().split():
#             input_line.append(line)
            
    for line in sys.stdin.readline().split():
        input_line.append(line)
    #print(input_line)
   



        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
x=input().split()
x_len=[len(i) for i in x ]
counter=Counter(x)
for i in range(len(x)):
    if max(x_len)==x_len[i]:
        print(max(counter),x[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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: [i]),max(word_d.iterkeys(),key=lambda i:len(i))

Submission status: Wrong Answer

Solution code:
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 len(word)>l:
       l=len(word)
       w1=word
   if e>m:
       m=e
       w2=word

print w1, w2

Submission status: Wrong Answer

Solution code:
dic={}
s=raw_input().lower().split()
print s
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

Submission status: Wrong Answer

Solution code:
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]
print length_list[0][0]

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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],

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

wordlist = []
wordlist = raw_input().split()
dic = {}       
longest = ['',0]  
m = 0
for word in wordlist:    
    # mode
    if word not in dic:
        dic[word] = 1
    else:
        dic[word] += 1
    
    # word_length    
    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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A=list(map(str,input().split()))
#print(A)
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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))])

Submission status: Accepted

Solution code:
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))])

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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)

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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])

Submission status: Accepted

Solution code:
l = input().split()
#print(l.count("your"))
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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))]

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

if __name__ == '__main__':
    # ??????????????\???
    # line = 'Thank you for your mail and your lectures'
    data = []
    for line in sys.stdin:
        data = line.strip().strip('.').lower().split(' ')

    # print(data)

    # ??????????¢??????????
    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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 = ' ')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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