#K46572. Run-Length Encoding Compression
Run-Length Encoding Compression
Run-Length Encoding Compression
This problem asks you to compress a given string using run-length encoding. In run-length encoding, consecutive repeating characters are replaced by a single instance of the character followed by the count (if greater than 1).
For example, for an input string \(S = \texttt{aaabccccddddd}\), the output should be \(\texttt{a3bc4d5}\).
Your task is to implement an efficient algorithm to perform this compression. The input string may be empty or contain only alphabetic or other printable characters.
inputFormat
The input is provided via stdin as a single line string \(S\). The string may be empty. There are no extra inputs.
outputFormat
Output the compressed string to stdout using run-length encoding rules as described in the problem statement.
## sampleaaabccccddddd
a3bc4d5