A. Reberland Linguistics
time limit per test
memory limit per test
input
output
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
4 letters. Then several strings with the length 2 or 3 symbols are appended to this word. The only restriction — it is not allowed to append the same string twice in a row. All these strings are considered to be suffixes of the word (this time we use word "suffix" to describe a morpheme but not the few last characters of the string as you may used to).
s. Find all distinct strings with the length 2 or 3, which can be suffixes of this word according to the word constructing rules in Reberland language.
Two strings are considered distinct if they have different length or there is a position in which corresponding characters do not match.
abacabaca is given. This word can be obtained in the following ways:
,
where the root of the word is overlined, and suffixes are marked by "corners". Thus, the set of possible suffixes for this word is {aca, ba, ca}.
Input
s (5 ≤ |s| ≤ 104) consisting of lowercase English letters.
Output
k — a number of distinct possible suffixes. On the next k
Print suffixes in lexicographical (alphabetical) order.
Examples
input
output
input
output
0
动态规划,一开始看错了题目,题目的意思是不能有连续相邻的两个后缀是相同的