https://www.acmicpc.net/problem/9935
import sys
read = sys.stdin.readline
string = read().rstrip()
bomb = read().rstrip()
while True:
result = []
finished = True
while True:
i = string.find(bomb)
if i < 0:
result.append(string)
break
else:
result.append(string[:i])
string = string[i+len(bomb):]
finished = False
string = ''.join(result)
if finished:
break
if string:
print(string)
else:
print('FRULA')
import sys
read = sys.stdin.readline
string = read().rstrip()
bomb = read().rstrip()
# 초기화
stack = []
i = 0
while True:
# 길이가 넘고 같을 때 pop
if len(stack) >= len(bomb):
if ''.join(stack[len(stack) - len(bomb):len(stack)]) == bomb:
for _ in range(len(bomb)):
stack.pop()
if i >= len(string):
break
# 다음거 append
stack.append(string[i])
i += 1
# 출력
if stack:
print(''.join(stack))
else:
print('FRULA')