Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 8 点
問題文
英小文字のみからなる文字列 S が与えられます。
1 \le i \le |S|-1 を満たす全ての整数 i について、 S の i 文字目と i+1 文字目をこの順に連結した 2 文字の文字列を書き並べます。
このとき、最も多く書かれる文字列を求めてください。ただし、そのようなものが複数存在する場合、辞書順最小のものを求めてください。
制約
- 2 \le |S| \le 2 \times 10^5
- S は英小文字のみからなる。
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
abcab
出力例 1
ab
書き並べられる文字列は ab
, bc
, ca
, ab
です。
最も多く書かれる文字列は ab
です。
入力例 2
zyxwv
出力例 2
wv
入力例 3
iiiiiiiiiiiiiiiiiiiiiiiiiiiiii
出力例 3
ii
Score : 8 points
Problem Statement
You are given a string S consisting of lowercase English letters.
Now you will write, for every integer i such that 1 \le i \le |S|-1, a two-letter string obtained by concatenating the i-th and the (i+1)-th characters of S.
Find the string that you will write the most times. If there are multiple such strings, find the lexicographically smallest one.
Constraints
- 2 \le |S| \le 2 \times 10^5
- S consists of lowercase English letters.
Input
Input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
abcab
Sample Output 1
ab
You will write ab
, bc
, ca
, and ab
.
Among them, ab
is written the most times.
Sample Input 2
zyxwv
Sample Output 2
wv
Sample Input 3
iiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Sample Output 3
ii