#P7674. [COCI 2013/2014 #5] EKSPLOZIJA

[COCI 2013/2014 #5] EKSPLOZIJA

Description

Given a string and a target string, find all occurrences of the target string in the given string and delete them.

Concatenate the remaining small pieces in their original order, and then keep performing this operation on the remaining string until no more occurrences of the target string appear.

Print the remaining string. If nothing remains, output FRULA.

Input Format

The first line contains a string, which is the original string.

The second line contains a string, which is the target string.

Output Format

One line containing a string, which is the remaining string.

mirkovC4nizCC44
C4 
mirkovniz
12ab112ab2ab
12ab
FRULA

Hint

[Sample Explanation #1]

After the first deletion, the original string becomes mirkov**nizC**4 (* indicates deleted characters), i.e. mirkovnizC4.

After the second deletion, the string becomes mirkovniz**, i.e. mirkovniz.

[Sample Explanation #2]

After the first deletion, the original string becomes ****1****2ab (* indicates deleted characters), i.e. 12ab.

After the second deletion, the string becomes ****. Therefore output FRULA.

[Constraints]

For 50%50\% of the testdata, 11\le the original string length 3000\le 3000.

For 100%100\% of the testdata, 11\le the original string length 106\le 10^6, 11\le the target string length 36\le 36. All strings consist of uppercase letters, lowercase letters, and digits 0,1...90,1...9. It is guaranteed that there are no repeated characters in the target string.

[Notes]

The score of this problem follows the original COCI setting, with a full score of 100100.

Translated from COCI2013_2014 CONTEST #5 T3 EKSPLOZIJA.

Translated by ChatGPT 5