#C7881. String Compression
String Compression
String Compression
Given a string s consisting of ASCII characters, compress the string by replacing each group of consecutive identical characters with the character followed by the number of its occurrences. For example, the string aaabbccccd compresses to a3b2c4d1.
If the input string is empty, the output should also be an empty string.
More formally, if a character x appears consecutively k times, it should be replaced by the string x$\,k$ (using LaTeX format for formulas).
inputFormat
The input is provided via standard input (stdin) as a single line containing the string s.
outputFormat
Output the compressed string to standard output (stdout). For every group of consecutive identical characters, output the character followed by its count.
## sampleaaabbccccd
a3b2c4d1