#C3390. String Transformation with Consecutive Counts
String Transformation with Consecutive Counts
String Transformation with Consecutive Counts
Given a string s, your task is to transform it by compressing each group of consecutive identical characters into a single occurrence of that character followed by the count of its occurrences. For example, the string "aaabbcccc" should be transformed into "a3b2c4".
If the input string is empty, the output should also be empty.
The transformation follows the formula:
$$\text{result} = \sum_{i=1}^{k} c_i + \text{count}(c_i)$$
where each ci is a character and \(\text{count}(c_i)\) is the number of times it appears consecutively.
inputFormat
The input consists of a single line containing a string s. The string may be empty and will consist of only printable characters.
outputFormat
Output the transformed string to standard output. If the input string is empty, output an empty string.
## sampleaaabbcccc
a3b2c4