#K88472. Compressed Length Calculation
Compressed Length Calculation
Compressed Length Calculation
Given a string s, the task is to determine the length of its compressed version using a basic run-length encoding scheme. In the compressed version, each group of consecutive identical characters is replaced by the character followed by the number of times it appears consecutively. For instance, for the group of character c that appears k times, its contribution to the compressed length is 1 + len(k), where len(k) denotes the number of digits in k. In mathematical notation, the formula for the overall compressed length is:
$$\text{CompressedLength} = \sum_{\text{group}} \Bigl(1 + \text{len}(k)\Bigr), $$where each group represents a maximal contiguous sequence of the same character. Note that if the string is empty, the answer is 0.
Your task is to implement an algorithm that reads several test cases from the standard input and for each string outputs the length of its compressed version to the standard output.
inputFormat
The input begins with an integer T denoting the number of test cases. Each of the following T lines contains a non-empty string s (or possibly an empty string) consisting of lowercase letters.
outputFormat
For each test case, output a single integer representing the compressed length of the string. Each answer should be printed on a new line.
## sample3
aaaabbcccaa
aabbaa
abc
8
6
6
</p>