using
System;
using
System.Text;
class
GFG{
static
bool
isDigit(
char
ch)
{
if
(ch >=
'0'
&& ch <=
'9'
)
return
true
;
return
false
;
}
static
int
nextNonDigit(
string
str,
int
i)
{
while
(i < str.Length && isDigit(str[i]))
{
i++;
}
if
(i >= str.Length)
return
-1;
return
i;
}
static
void
appendRepeated(StringBuilder sb,
string
str,
int
times)
{
for
(
int
i = 0; i < times; i++)
sb.Append(str);
}
static
String findString(
string
str,
int
n)
{
StringBuilder sb =
new
StringBuilder(
""
);
int
startStr = nextNonDigit(str, 0);
while
(startStr != -1)
{
int
endStr = startStr;
while
((endStr + 1) < n &&
!isDigit(str[endStr + 1]))
{
endStr++;
}
int
startNum = endStr + 1;
if
(startNum == -1)
break
;
int
endNum = startNum;
while
((endNum + 1) < n &&
isDigit(str[endNum + 1]))
{
endNum++;
}
int
num = Int32. Parse(str.Substring(
startNum, endNum - startNum + 1));
appendRepeated(sb, str.Substring(
startStr, endStr - startStr + 1), num);
startStr = nextNonDigit(str, endStr + 1);
}
return
sb.ToString();
}
public
static
void
Main(
string
[] args)
{
string
str =
"g1ee1ks1for1g1e2ks1"
;
int
n = str.Length;
Console.Write(findString(str, n));
}
}