Skip to main content
Back to problems
Codeforces
Easy
Strings
Arrays
Dubstep

Recover the original song by collapsing repeated remix separators into single word separators.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

Dubstep

A song was remixed by inserting the word WUB many times into the original lyrics. To restore the original song, remove every occurrence of WUB and place a single space between consecutive words that were separated by one or more WUBs.

Given the remixed string, output the original lyrics with words separated by single spaces only.

Notes

  • The remixed string consists only of uppercase Latin letters.
  • The substring WUB may appear at the beginning, middle, or end of the string.
  • Consecutive occurrences of WUB should still result in just one space between adjacent words.

Input Format

A single string s representing the remixed song.

Output Format

Print the restored original song with words separated by single spaces and no leading or trailing spaces.

Constraints

  • 1 <= |s| (length is finite and manageable for standard string processing)
  • s contains only uppercase Latin letters
  • The substring WUB may appear multiple times
Examples
Sample cases returned by the problem API.

Example 1

Input

WUBWUBABCWUB

Output

ABC

Explanation

All WUB blocks are removed, leaving a single word.

Example 2

Input

WUBWUBABCWUBWUBDEFWUB

Output

ABC DEF

Explanation

The remaining words are ABC and DEF, separated by a single space.

Show 1 more example

Example 3

Input

WUBABCWUBDEFWUBGHI

Output

ABC DEF GHI

Explanation

Each run of WUB acts as one separator between words.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.