Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/string-siqish

String compression

Medium 1000 ms 128 MB 55%
Share

A string $s$ of lowercase Latin letters is given. Compress it: every block of identical consecutive letters is replaced by that letter followed by the length of the block.

Turning runs of identical characters into character-and-number pairs

Input

One line containing the string $s$.

Output

The compressed string on one line (the length is written even when it is $1$).

Note

$1 \le |s| \le 10^{5}$
$s$ consists of lowercase Latin letters (a–z) only

Examples

Input #1
aaabccdddd
Output #1
a3b1c2d4
Input #2
xyz
Output #2
x1y1z1

Sign in to submit a solution

Signing up is free and takes a minute.