Here is the translation of the programming task text from Russian to English: String compression with recovery using the rule of repeating segments
JavaScript
Hard
strings
Task «Here is the translation of the programming task text from Russian to English: String compression with recovery using the rule of repeating segments»
Given a string consisting of Latin letters and digits. The string represents a compressed format: each digit indicates how many times the following character should be repeated, and if a digit appears before a group of characters in parentheses, the entire group is repeated. If there is no digit, the character is repeated once. Restore the original string. It is guaranteed that the parentheses are balanced and the nesting depth does not exceed 5 levels. The length of the compressed string is up to 1000 characters, and the length of the restored string does not exceed 10^6.
Input Format
One line containing the compressed representation.
Output Format
One line — the restored line.
Examples
Example 1
INPUT
10a
OUTPUT
aaaaaaaaaa
main.js