cswork / OAOpen practice workspace

ReevoOA #1

Compression (Run-Length Encoding)

Estimated EasyJudge-ready

Topics (AI-labelled)Strings

Merge adjacent runs of the same letter from left to right: a run of length 1 outputs only the letter, and a run longer than 1 outputs the letter followed by the run length.

Input

One line containing a non-empty string of lowercase letters, length ≤100000.

Output

Output the compressed result.

Example 1

Input:

aabbccca

Output:

a2b2c3a

Example notes

Derive a linear scan/dynamic programming solution directly from the problem rules; the examples have been checked one by one against an independently built oracle.

Editorial

Loading solution…