D. Дабстеп

public
yeskendir.sultanov Apr 26, 2024 Never 166
Clone
Python 14.py 17 lines (13 loc) | 415 Bytes
1
s = input()
2
s = 'WUB' + s + 'WUB'
3
4
ans = []
5
6
for i in range(len(s) - 2):
7
if s[i:i+3] == 'WUB':
8
for j in range(i + 3, len(s) - 2):
9
if s[j:j+3] == 'WUB':
10
# s[i] s[i+1] s[i+2] == 'WUB'
11
# s[j] s[j+1] s[j+2] == 'WUB'
12
13
if j > i + 3:
14
ans.append(s[i+3:j])
15
break
16
17
print(' '.join(ans))