import java util Scanner public class StringExplosion public static vo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;
public class StringExplosion {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
StringBuilder result = new StringBuilder();
int power = 0;
for (int i = 0; i < input.length(); i++) {
char symbol = input.charAt(i);
if (symbol == '>' && Character.isDigit(input.charAt(i + 1))) {
power += Character.getNumericValue(input.charAt(i + 1));
}
if (power > 0) {
if (symbol == '>') {
result.append(symbol);
continue;
}
power--;
} else {
result.append(symbol);
}
}
System.out.println(result);
}
}