#K16051. String Compression
String Compression
String Compression
Given a string (s), compress it by replacing each sequence of consecutive repeated characters with the count of repetitions followed by the character. If a character appears only once, it is left as is. For example, if (s = \texttt{aaabbc}), the compressed string should be (\texttt{3a2bc}). Note that if the compressed string is not strictly shorter than the original string, the original string (s) must be returned.
The compression for a group where a character (c) repeats (n) times is represented as (nc) (only if (n > 1)).
inputFormat
A single line containing the string (s) to be compressed.
outputFormat
Output a single line: the compressed string if its length is less than the original string, or the original string otherwise.## sample
aaabbc
3a2bc