PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CT0000071. Mã hóa bản tin (Message Encoding)

Bài tập này chưa được xếp vào lộ trình.

Mã hóa bản tin (Message Encoding)

Message Encoding

Version: Phuoc Hung OJ Extended

Problem Statement

A message is a string SS containing only uppercase English letters from A through Z.

To encode the message, replace every maximal group of equal consecutive characters with the character followed by the number of characters in that group. Write the count in decimal notation without leading zeros.

For instance, AAABB becomes A3B2: the first group contains three A characters, and the second contains two B characters. Even a group containing just one character must include the count 1. The groups retain their original order.

Task: Produce the encoded form of SS.

Input

One line containing SS, with no spaces and consisting only of A–Z.

Output

Print the encoded string on one line.

Subtasks

  • Subtask 1 (30 points): 1≤∣S∣≤1001\le |S|\le 100; all characters are A–Z.
  • Subtask 2 (30 points): 1≤∣S∣≤2⋅1051\le |S|\le 2\cdot10^5; all characters are A–Z; each maximal group of equal consecutive characters has length from 11 to 99.
  • Subtask 3 (40 points): 1≤∣S∣≤2⋅1051\le |S|\le 2\cdot10^5; all characters are A–Z.

Examples

Example 1

Input

AAABCCCCDDDA

Output

A3B1C4D3A1

Explanation

The consecutive groups are AAA, B, CCCC, DDD, A, with lengths 3,1,4,3,13,1,4,3,1. They contribute A3, B1, C4, D3, A1, giving A3B1C4D3A1.

Example 2

Input

XYZ

Output

X1Y1Z1

Explanation

The distinct consecutive characters X, Y, Z each form a group of length 11. As single-character groups still include a count, the result is X1Y1Z1.

Example 3

Input

AAAAAAAAAAAA

Output

A12

Explanation

All twelve A characters belong to one group. The character followed by the decimal count 12 forms A12, not twelve repetitions of A1.