#C10372. Remove Pattern

    ID: 39570 Type: Default 1000ms 256MiB

Remove Pattern

Remove Pattern

Given a string s and a pattern p, remove all non-overlapping occurrences of p from s. If p is an empty string, the string remains unchanged. You need to read the input from stdin and write the output to stdout.

Details:

  • Overlapping occurrences are removed in a non-overlapping manner. That is, after an occurrence of p is removed from s, the search continues from the position right after the removed substring.
  • For example, if s = "aabbcc" and p = "ab", then the output should be "abcc".
  • Another example: if s = "aaa" and p = "aa", the output is "a" because the removal happens in one non-overlapping pass.

inputFormat

The input consists of two lines:

  1. The first line contains the string s.
  2. The second line contains the pattern string p.

outputFormat

Output a single line containing the modified string after all occurrences of p have been removed from s.

## sample
aabbcc
ab
abcc

</p>