#K4266. String Compression

    ID: 27137 Type: Default 1000ms 256MiB

String Compression

String Compression

Given a string consisting of alphabetic characters, your task is to implement a string compression algorithm. The algorithm should compress the string by replacing each contiguous group of the same character with the character followed by the number of times it appears consecutively.

For example, the string "aabcccccaaa" would become "a2b1c5a3". However, if the compressed string is not strictly shorter than the original string, you must output the original string.

The compression is case-sensitive, meaning that uppercase and lowercase letters are treated as distinct characters.

Note: Let \(s\) be the input string and \(c_i\) be the i-th character in the string then the compressed form is formed as follows:

\(compressed = \bigoplus_{\text{group } G} (\text{character} + \text{count\_in\_group})\)

If \(|compressed| \ge |s|\), then the output should be \(s\).

inputFormat

The input consists of a single line containing a string of alphabetic characters.

Input is provided via standard input (stdin).

outputFormat

Output the compressed string if its length is strictly less than the original string; otherwise, output the original string. The result should be printed to the standard output (stdout).

## sample
aabcccccaaa
a2b1c5a3