Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s_len = int(len(s))
count = 0
n = int(s_len*(s_len+1)/4)
for _ in range(n):
  num = s.count('BW')
  if num == 0:
    break
  s = s.replace('BW','WB',int(s_len/2))
  count += num
print(count)

Fixed submission:
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s_len = int(len(s))
count = 0
n = int(s_len*(s_len+1)/4)
for _ in range(n):
  num = s.count('BW')
  s = s.replace('BW','WB')
  count += num
print(count)

Fixed submission:
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s_len = int(len(s))
count = 0
n = int(s_len*(s_len+1)/4)
for _ in range(n):
  num = s.count('BW')
  if num == 0:
    break
  s = s.replace('BW','WB')
  count += num
print(count)

Fixed submission:
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s_len = int(len(s))
count = 0
n = int(s_len*(s_len+1)/2)
for _ in range(n):
  num = s.count('BW')
  if num == 0:
    break
  s = s.replace('BW','WB')
  count += num
print(count)

Fixed submission:
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
s = input()
count = 0
num = 1
for _ in range(math.factorial(len(s))):
  num = s.count('BW')
  if num == 0:
    break
  s = s.replace('BW','WB')
  count += num
  
print(count)

Fixed submission:
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
count = 0
num = 1
while(num != 0):
  num = s.count('BW')
  s = s.replace('BW','WB')
  count += num
print(count)

Fixed submission:
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s_list = list(s)
s_len = len(s)
count = 0
num = 1
while(num != 0):
  num = s.count('BW')
  s = s.replace('BW','WB')
  count += num
print(count)



Fixed submission:
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s_list = list(s)
s_len = len(s)
count = 0
while(1):
  ind = s.find('BW')
  if ind == -1:
    break
  s_list[ind] = 'W'
  s_list[ind+1] = 'B'
  s = ''.join(s_list)
  count += 1
print(count)



Fixed submission:
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s_list = list(s)
s_len = len(s)
count = 0
count_cur = 0
count_before = None
while(count != count_before):
  count_cur = 0
  for i in range(s_len-1):
    if s_list[i] == 'B' and s_list[i+1] == 'W':
      count_cur += 1
      s_list[i] = 'W'
      s_list[i+1] = 'B'
  count_before = count
  count += count_cur 

print(count)



Fixed submission:
S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)