#K83672. String Compression
String Compression
String Compression
Given a string s, compress it by replacing sequences of the same consecutive characters with the character followed by the count of its consecutive occurrences.
For example, the string "aabcccccaaa" becomes "a2b1c5a3". However, if the compressed string is not shorter than the original string, the original string should be returned.
This problem tests your ability to efficiently process strings and handle edge cases.
Note: If the input string is empty, simply output an empty string.
The compression algorithm uses the formula: \( compressed = c_1n_1c_2n_2\ldots \), where \( c_i \) is a character and \( n_i \) is the count of consecutive occurrences of \( c_i \).
inputFormat
The input consists of a single line containing the string s to be compressed. The string can be composed of any characters and may be empty. The input is provided via standard input (stdin).
outputFormat
Output a single line containing the compressed string if its length is strictly less than the original string; otherwise, output the original string. The output should be printed to standard output (stdout).
## sampleaabcccccaaa
a2b1c5a3