import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Main {
public static void main(String[] args) {
String str = "@3X,@2Z,@2R,@5V,@2W";
String result = Arrays.stream(str.split(","))
.map(s -> {
String symbol = String.valueOf(s.charAt(s.length() - 1));
int count = Integer.parseInt(s.replaceAll("@", "").replaceAll(symbol, ""));
return Stream.generate(() -> symbol).limit(count).collect(Collectors.joining());
})
.collect(Collectors.joining());
System.out.println(result);
}
}
public class Main
{
public static void main(String[] args)
{
String str = "@3X,@2Z,@2R,@5V,@2W";
String result = "";
int count = 0;
char letter = 0;
for (int i = 0; i < str.length(); i++)
{
char ch = str.charAt(i);
if (Character.isDigit(ch))
{
count = count * 10 + (int) (ch - '0');
} else {
if (count > 0) {
for (int j = 0; j < count; j++)
{
result += letter;
}
count = 0;
}
letter = ch;
}
}
if (count > 0) {
for (int j = 0; j < count; j++) {
result += letter;
}
}
System.out.println(result);
}
}