P23710 [AtCoder] [ABC019B] Takahashi's String Compression
普及-
题目描述

Problem Description

Takahashi has a certain string $ s $. Interested in shortening the representation of strings, Takahashi decided to try the following compression method:

  1. Divide the string $ s $ into substrings where the same character appears consecutively. (Divide)
  2. Convert each divided substring into a new string consisting of the character and the length of its consecutive occurrence. (Convert)
  3. Finally, concatenate the converted substrings in order from the beginning. (Concatenate)

Applying this compression method to the string aabbbaad results in:

  1. Dividing aabbbaad into aa bbb aa d
  2. Converting aa bbb aa d into a2 b3 a2 d1
  3. Concatenating a2 b3 a2 d1 into a2b3a2d1

Thus, we obtain a2b3a2d1.

Given the string $ s $, write a program to find the compressed string using the above method on behalf of Takahashi.

Input Format

The input is given from the standard input in the following format:

$ s $

  • The string to be compressed $s\ (1\ ≦\ |s|\ ≦\ 1,000)$ is given ($ |s| $ represents the length of the string $ s $).
  • It is guaranteed that $ s $ is a string consisting of lowercase English letters.

Output Format

Output the compressed string created from $ s $ to the standard output.

Do not forget the trailing newline.

Sample Input and Output

Sample Input #1

aabbbaad

Sample Output #1

a2b3a2d1

Sample Input #2

aabbbbbbbbbbbbxyza

Sample Output #2

a2b12x1y1z1a1

Sample Input #3

edcba

Sample Output #3

e1d1c1b1a1

Notes/Hints

Sample Explanation 1

This is the example given in the problem statement.

Sample Explanation 2

Lengths are represented in decimal notation.

Sample Explanation 3

The compressed result may be longer than the original string.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
aabbbaad
样例输出
a2b3a2d1