The New Mutants

0

0 votes
Medium
Problem

Cypher ( Douglas Ramsey) was a genius mutant and particularly good at writing software. He was also a member of the A.I.M (Advanced Idea Mechanics). One of his ability was to understand any language, whether spoken or written.

One day, Cypher came across a rather unique kind of language. The rules of the language are as follows :

  • Each word in this language is constructed using a seed word of at least 5 characters. Then several strings of length K are appended to the seed. These strings are considered to be the smallest grammatical unit and are called ‘keys’.

  • No key can be appended twice consecutively, to a seed.

  • A string is considered different from another string if the characters at the corresponding index do not match, or they are of different length.

INPUT
Each input file consists of a single line containing a string S of lowercase English alphabets.

CONSTRAINTS
1 < |K| < 4
5 <= |S| <= 104

OUTPUT
For each input file, the first line of output should contain an integer Z – denoting the number of distinct keys possible.
On the next Z lines, print the keys in lexicographical order.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?