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

Submission status: Accepted

Solution code:
# Aizu Problem 0029: English Sentence
#
import sys, math, os

# read input:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AOJ 0029 English Sentence
# Python3 2018.6.12 bal4u

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)

Submission status: Accepted

Solution code:
# AOJ 0029 English Sentence
# Python3 2018.6.12 bal4u

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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 = {}

#input_file = open(sys.argv[1], 'r')

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)

Submission status: Accepted

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

print w1, w2

Submission status: Accepted

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

Submission status: Accepted

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] + " " + length_list[0][0]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input().split()
print(max(s,key=s.count),max(s,key=len)) 
#max()はkeyに別の関数を指定してその返り値が最大となる要素を返す

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

a = input().split()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(D)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

#print(maxm, maxn)

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

Submission status: Accepted

Solution code:
a = input()

a = a.split()

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

ans2 = max(a,key=len)

print(ans1,ans2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#標準入力
line = list(input().split())

#max関数を使いkeyを引数に設定し、最瀕の単語と、文字数の長い単語を出力する
print(max(line,key = line.count),max(line,key = len))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ライブラリのインポート
#import re #正規表現
import sys
#import heapq
#import collections
#import math

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

Submission status: Accepted

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

Submission status: Accepted

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


num1=1
tmp1=0
for i in range(len(s)):
    if tmp1>num1:                                       #出現頻度が高い
        #print("tmp1",tmp1)
        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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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