Problem E

Statement
Copy Copied
Description:
Some time ago Lesha found an entertaining string $$$s$$$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.

Lesha chooses an arbitrary (possibly zero) number of pairs on positions $$$(i, i + 1)$$$ in such a way that the following conditions are satisfied:

- for each pair $$$(i, i + 1)$$$ the inequality $$$0 \le i < |s| - 1$$$ holds;
- for each pair $$$(i, i + 1)$$$ the equality $$$s_i = s_{i + 1}$$$ holds;
- there is no index that is contained in more than one pair.

Lesha is interested in the lexicographically smallest strings he can obtain by applying the algorithm to the suffixes of the given string.

Input Format:
The only line contains the string $$$s$$$ ($$$1 \le |s| \le 10^5$$$) β€” the initial string consisting of lowercase English letters only.

Output Format:
In $$$|s|$$$ lines print the lengths of the answers and the answers themselves, starting with the answer for the longest suffix. The output can be large, so, when some answer is longer than $$$10$$$ characters, instead print the first $$$5$$$ characters, then "...", then the last $$$2$$$ characters of the answer.

Note:
Consider the first example.

- The longest suffix is the whole string "abcdd". Choosing one pair $$$(4, 5)$$$, Lesha obtains "abc".
- The next longest suffix is "bcdd". Choosing one pair $$$(3, 4)$$$, we obtain "bc".
- The next longest suffix is "cdd". Choosing one pair $$$(2, 3)$$$, we obtain "c".
- The next longest suffix is "dd". Choosing one pair $$$(1, 2)$$$, we obtain "" (an empty string).
- The last suffix is the string "d". No pair can be chosen, so the answer is "d".

In the second example, for the longest suffix "abbcdddeaaffdfouurtytwoo" choose three pairs $$$(11, 12)$$$, $$$(16, 17)$$$, $$$(23, 24)$$$ and we obtain "abbcdddeaadfortytw"

Submissions

IDLanguageExit CodeTimestampCodeStdoutStderrRetry
5508 go 0 2026-03-15T06:21:44.316411Z View View View Retry
5501 go 1 2026-03-15T06:14:52.289765Z View View View Retry
4970 go 0 2026-03-07T10:15:14.981726Z View View View Retry

Evaluations

Eval IDRun IDProviderModelLangSuccessTimestampPromptResponseStdoutStderrRetry
2602 20260315-020006 openai gpt-5.4 go false 2026-03-15T05:49:41.408743Z View View View View Retry
1706 20260307-080824 gemini gemini-3-pro-preview go false 2026-03-07T09:38:49.575129Z View View View View Retry