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

Solution code:
# coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    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

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

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

    ### Mat Multiplication
    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()

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

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

# def printA(A):
#     for i, n in enumerate(A):
#         print(n, end='')
#         if i != N-1:
#             print(' ', end='')
#     print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

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())
            #N.append(int(input()))
            #N.append(float(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=' ')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Runtime Error

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.trip()
print tmp, ss

Submission status: Runtime Error

Solution code:
while True:
  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: Runtime Error

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

import sys

dic = {}
for s in sys.stdin:
  d = [ e.lower() for e in map(str,s.split()) ]
  for e in d:
    if e in dic:
      dic[e] += 1
    else:
      dic[e] = 1


sdict = sorted(dic.items(),key=lambda x:-x[1])
maxnum = sdict[0][1]
for i in range(len(sdict)):
  if sdict[i][1] == maxnum:
    print sdict[i][0],
  else:
    break


maxlen = max([len(e) for e in d])
longterm = [ e for e in d if len(e) == maxlen ]
for e in longterm:
  print e,

Submission status: Runtime Error

Solution code:
import sys
f = sys.stdin

rhombus = oblong = 0
for line in f:
    a, b, c = map(int, line.split(','))
    if a == b:
        rhombus += 1
    if a * a + b * b == c * c:
        oblong += 1

print(oblong)
print(rhombus)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
while True:
    try:
        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)
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
while True:
    try:
        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)
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
from math import *
PI = 3.1415926535898
while True:
	try:
		arr = map(str, raw_input().strip().split())
		ans1 = arr[0]
		ans2 = arr[0]
		for s in arr:
			if arr.count(s) > arr.count(ans1):
				ans1 = s
			if len(s) > len(ans2):
				ans2 = s
		print "%s %s" % (ans1, ans2)
	except EOFError:
		break

Submission status: Runtime Error

Solution code:
#encoding=utf-8

import statistics as st
word1 = []
word = raw_input().split()
print st.mode(word)
for i in xrange(len(word)):
	word1.append(len(word[i]))
for i in xrange(len(word)):
	if len(word[i]) == max(word1):
		print word[i]

Submission status: Runtime Error

Solution code:
import statistics as st
word1 = []
word = raw_input().split()
for i in xrange(len(word)):
	word1.append(len(word[i]))
for i in xrange(len(word)):
	if len(word[i]) == max(word1):
		print st.mode(word), word[i]
		break

Submission status: Runtime Error

Solution code:
import statistics as st
word1 = []
word = raw_input().split()
for i in xrange(len(word)):
	word1.append(len(word[i]))
for i in xrange(len(word)):
	if len(word[i]) == max(word1):
		print(st.mode(word), word[i])
		break

Submission status: Runtime Error

Solution code:
import sys 
def main():
    input_line = []
    test_line = 'Thank you for your mail and your lectures'
    
#     for line in test_line.split():
#         input_line.append(line)
        
    

    for line in sys.stdin:
        input_line.append(line.split())
    
    #print(input_line.count('your'))
    number_len = {}
    number_fre = {}
    for i in input_line: 
        number_len.update({i:len(i)})
        number_fre.update({i:test_line.count(i)})
        



        
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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)
   
    number_len = {}
    number_fre = {}
    for i in input_line: 
        number_len.update({i:len(i)})
        number_fre.update({i:input_line.count(i)})
        
    sorted_x = sorted(number_len.items(), key=operator.itemgetter(1))
    sorted_y = sorted(number_fre.items(), key=operator.itemgetter(1))
    print(sorted_x[-1][0],sorted_y[-1][0])


        
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from collections import Counter
def most_arise(s):
    c = Counter(s.split())
    maxone = sorted(s.split(),key=lambda x:len(x))[-1]
    print("{0} {1}".format(c.most_common()[0][0],maxone))

s = raw_input()
most_arise(s)

Submission status: Runtime Error

Solution code:
from collections import Counter    
s = raw_input()
c = Counter(s.split())
maxone = sorted(s.split(),key=lambda x:len(x))[-1]
print("{0} {1}".format(c.most_common()[0][0],maxone))

Submission status: Runtime Error

Solution code:
s = raw_input()
c = Counter(s.split())
maxone = sorted(s.split(),key=lambda x:len(x))[-1]
print("{0} {1}".format(c.most_common()[0][0],maxone))

Submission status: Runtime Error

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

Solution code:
import datetime, sys

wday_lst = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

for s in sys.stdin:
  m,d = map(int, s.split())
  if m == 0 or d == 0: break
  str = '2004-%d-%d 00:00:00'%(m,d)
  day = datetime.datetime.strptime(str, '%Y-%m-%d %H:%M:%S')
  print wday_lst[day.weekday()]

Submission status: WA: Presentation Error

Solution code:
from math import *
PI = 3.1415926535898
while True:
	try:
		arr = map(str, raw_input().strip().split())
		ans1 = ""
		ans2 = ""
		for s in arr:
			if arr.count(s) > arr.count(ans1):
				ans1 = s
			if len(s) > len(ans2):
				ans2 = s
		print ans1+" "+ans2
	except EOFError:
		break

Submission status: WA: Presentation Error

Solution code:
from math import *
PI = 3.1415926535898
while True:
	try:
		arr = map(str, raw_input().strip().split())
		ans1 = ""
		ans2 = ""
		for s in arr:
			if arr.count(s) > arr.count(ans1):
				ans1 = s
			if len(s) > len(ans2):
				ans2 = s
		print "%s %s" % (ans1, ans2)
	except EOFError:
		break