#C1751. Run-Length Encoding

    ID: 44991 Type: Default 1000ms 256MiB

Run-Length Encoding

Run-Length Encoding

This problem requires you to implement a run-length encoding algorithm for strings. Given an input text that may include multiple lines, you must compress each line individually by replacing consecutive occurrences of an alphabetical character (i.e. A–Z and a–z) with the character followed by the number of consecutive occurrences. Non-alphabetical characters must remain unchanged.

For example, given the line:

AAAABBB CC

the output should be:

A4B3 C2

If a line contains multiple lines, each line should be processed separately and the results printed in the same order as input.

Note: Only consecutive alphabetical characters are encoded, while digits, spaces and punctuation are printed as is.

inputFormat

The input is read from stdin and consists of one or more lines. Each line is a string which may contain any characters. Process each line until end-of-file (EOF) is reached.

outputFormat

For each input line, output the run-length encoded string on a new line to stdout.

## sample
AAAABBB CC
A4B3 C2