#C13701. String Compression
String Compression
String Compression
You are given a string S. The goal is to compress the string by replacing each sequence of consecutive identical characters with the character followed by the number of its occurrences. For example, the string aabcccccaaa
should be compressed to a2b1c5a3
. However, if the resulting compressed string is not strictly shorter than the original string, you should output the original string.
In other words, if the compressed string has length \(L_c\) and the original string has length \(L_o\), you must output the compressed string only if \(L_c < L_o\); otherwise, output the original string.
The string may contain alphabetic characters, digits, and special symbols.
inputFormat
The input consists of a single line containing the string S that you need to compress.
outputFormat
Output a single line containing the compressed string if its length is shorter than the original string; otherwise, output the original string.
## sampleaabcccccaaa
a2b1c5a3