#C6626. Decode Encoded Strings

    ID: 50407 Type: Default 1000ms 256MiB

Decode Encoded Strings

Decode Encoded Strings

You are given an encoded string. The encoding rule is defined as $k\left[encoded\_string\right]$, where the encoded_string inside the square brackets is repeated exactly $k$ times. Note that $k$ is a positive integer. You may assume that the input string is always valid and that there are no extra white spaces in the string.

Examples:

  • For the input 3[a]2[bc], the output is aaabcbc.
  • For the input 3[a2[c]], the output is accaccacc.
  • For the input 2[abc]3[cd]ef, the output is abcabccdcdcdef.

Your task is to decode the string and output the decoded version. Use appropriate algorithms to handle nested encoded expressions.

inputFormat

The input consists of a single line containing the encoded string s. The string will only contain digits, letters, and the characters [ and ] which form a valid encoding as described above.

outputFormat

Output the decoded string corresponding to the given encoded string.

## sample
3[a]2[bc]
aaabcbc