#K43087. Run-Length Encoding
Run-Length Encoding
Run-Length Encoding
Given a string s, compute its run-length encoding. The run-length encoding of a string is a sequence of pairs \( (c, k) \) where c is a character and k is the number of consecutive occurrences of that character in the string. For example, the string "aaabbbbcc" should be encoded as \( [('a', 3), ('b', 4), ('c', 2)] \).
If the input string is empty, output nothing.
Note: The encoding should be output with each pair on a new line, where the character and its count are separated by a space.
inputFormat
The input consists of a single line containing the string s. The string may be empty.
outputFormat
Output the run-length encoded form of s with each line containing a character and its count separated by a space. If the input string is empty, output nothing.
## sampleaaabbbbcc
a 3
b 4
c 2
</p>