Problem:
 Score : 300 points    Problem Statement There are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)
The state of each piece is represented by a string S of length N .
If S_i= B , the i -th piece from the left is showing black;
If S_i= W , the i -th piece from the left is showing white.  Consider performing the following operation:   Choose i ( 1 \leq i < N ) such that the i -th piece from the left is showing black and the (i+1) -th piece from the left is showing white, then flip both of those pieces. That is, the i -th piece from the left is now showing white and the (i+1) -th piece from the left is now showing black.   Find the maximum possible number of times this operation can be performed.      Constraints  1 \leq |S| \leq 2\times 10^5  S_i= B or W         Input Input is given from Standard Input in the following format:  S       Output Print the maximum possible number of times the operation can be performed.        Sample Input 1 BBW      Sample Output 1 2  The operation can be performed twice, as follows:   Flip the second and third pieces from the left.  Flip the first and second pieces from the left.        Sample Input 2 BWBWBW      Sample Output 2 6

Solution (Python):
s=input()

pos = 0
w_pos = 0
found_pos = 0
cnt = 0

while True:
    pos = s.find('W')
    if pos == -1:
        break
    cnt += (pos+found_pos - w_pos)
    w_pos+=1
    s = s[pos+1:]
    found_pos += (pos+1)
print(cnt)

Solution (Python):
S = input()
count = 0
foundB = 0
for s in S:
    if s == 'W':
        count += foundB
    elif s == 'B':
        foundB += 1
print(count)

Solution (Python):
s = input()
l = []
i = 0
n = len(s)
while i < n:
    j = 0
    while i < n and s[i] == 'B':
        j += 1
        i += 1
    l.append(j)

    j = 0
    while i < n and s[i] == 'W':
        j += 1
        i += 1
    l.append(j)

res = 0
for i in range(0, len(l), 2):
    if l[i] > 0:
        res += l[i] * l[i + 1]
    if i + 2 < len(l):
        l[i + 2] += l[i]
print(res)

Solution (Python):
S = input()

count = 0

BC = 0

for i in range(len(S)):
    S1 = S[i:i+1]
    if S1 == "B":
        BC += 1
    
    if BC > 0 and S1 == "W":
        count += BC

print(count)

Solution (Python):
s=list(input())
c=0
b=0
for i in s:
  if i=='B':
    b+=1
  if i=='W':
    c+=b
print(c)

Solution (Python):
S = input()
n = 0
k = 0
m = len(S)
for i in range(m):
    if S[i] == 'B':
        n += m - (i+1) -k
        k += 1
print(n)

Solution (Python):
s=input()
black_count=0
count = 0
for c in s:
    if c == "B":
        black_count += 1
    else:
        count += black_count

print(count)

Solution (Python):
s = list(input())
n = len(s)
pos = []
cnt = 0
for i in range(n):
  if s[i] == "W":
    pos.append(i)
    cnt += 1

print(sum(pos) - cnt * (cnt - 1) // 2)

Solution (Python):
S = list(input())
len_S = len(S)

black_count = 0
swap_count = 0

for i in range(len_S):
    if S[(len_S - 1) - i] == 'B':
        swap_count += i - black_count
        black_count += 1

print(swap_count)

Solution (Python):
s = input()
w = 0
c = 0
if s[-1] == 'W':
    w = 1
for i in range(len(s)-2, -1, -1):
    if s[i] == 'W':
        w += 1
    else:
        c += w
print(c)

Solution (Python):
b = input()
nes = []
nowb = 0
noww = 0
counter = 0
for i in b:
	if i == 'B':
		if noww == 0:
			nowb += 1
		else:
			counter += nowb * noww
			nowb += 1
			noww = 0
	else:
		if nowb != 0:
			noww += 1
		
counter += nowb * noww

print(counter)

Solution (Python):
S = list(input())
b_count = 0
ans = 0

for i in range(0,len(S)):
  if S[i] == "B":
    b_count += 1
  elif S[i] == "W":
    ans += b_count

print(ans)

Solution (Python):
S=input()
count=0
def sigma(i):
    a=[b for b in range(0,i+1)]
    return sum(a)
place=0
flag=0
start=0
for i in range(len(S)):
    if S[i]=="B":
        flag=1
    elif S[i]=="W":
        if flag == 1:
            count += 1
            place += i - start
        else:
            start+=1
ans=place-sigma(count-1)
print(ans)

Solution (Python):
S = input()
N = len(S)
countW = [0]*(N+1)
for i in range(1,N+1):
    countW[i] = countW[i-1]+(S[i-1]=='W')
ans = 0
for i in range(N):
    if S[i]=='W':
        ans += i-countW[i]
print(ans)

Solution (Python):
from sys import stdin

def main():
    A=stdin.readline()
    

    wc = A.count('W')
    indices = [i for i, x in enumerate(A) if x == 'W']
    if wc > 0:
      print(sum(indices) - 1*wc*(wc-1) //2 )
    else:
      print(sum(indices))

input = lambda: stdin.readline()
main()

Solution (Python):
S = input()
S = S[::-1]
y = -1

def x():
    global y
    y += 1
    return y

c = [i-x() for i in range(len(S)) if S[i]=="B"]
print(sum(c))

Solution (Python):


S = input()

margin = 0
for i, moji in enumerate(S):
    if moji == 'B':
        margin = i
        break

idx_list = []
for i, moji in enumerate(S[margin:]):
    if moji == 'W':
        idx_list.append(i)

q = len(idx_list) - 1
print(sum(idx_list) - int(0.5 * q * (q + 1)))

Solution (Python):
from sys import stdin

def main():
    A=stdin.readline().replace('B', '0').replace('W', '1')
    
    

    wc = A.count('1')
    indices = [i for i, x in enumerate(A) if x == '1']
    if wc > 0:
      print(sum(indices) - 1*wc*(wc-1) //2 )
    else:
      print(sum(indices))

input = lambda: stdin.readline()
main()

Solution (Python):

a = input()

b = []
w = []
for i in range(len(a)):
    b.append(a[i])

for i in  range(len(a)):
    if (b[i] == 'W') :
        w.append(i)

n = 0
for i in range(len(w)):
    n += w[i] - i

print(n)

Solution (Python):
a = list(input())

su = 0
dd = 0
co = 0
for i in range(len(a)-1,-1,-1):
	if a[i] == 'W':
		co += 1
	if co >= 1:
		if a[i] == 'B':
			su += (len(a)-1 - i) - dd
	if a[i] == 'B':
		dd += 1

print(su)

Solution (Python):
from sys import stdin

s = stdin.readline().rstrip()

count = 0
white = 0
for i, stone in enumerate(s):
    if stone == 'W':
        count += (i - white)
        white +=1
print(count)

Solution (Python):
S = input()
res = 0
count_b = 0
for i, s in enumerate(S[::-1]):
    
    if s == "B":
        res += i - count_b
        count_b += 1
print(res)

Solution (Python):
S = input()
counter = 0




















sum=0
for i in range(len(S)):
    if S[i]=='W':
        sum+=i
        counter+=1

n=counter-1
minus=n*(n+1)/2
print(int(sum-minus))

Solution (Python):
s = input()
total = 0
w_count = 0
for i in range(1, len(s)+1):
    if s[-i] == 'W':
        w_count += 1
    elif s[-i] == 'B':
        total += w_count

print(total)

Solution (Python):
import numpy as np
S = input()

S_mask = np.array([True if s=='W' else False for s in S])

W_indices = np.where(S_mask)[0]

W_num = S_mask.sum()

print(W_indices.sum() - (W_num-1)*W_num//2)

Solution (Python):
b_count = 0
count = 0
input_list = list(input())
for s in input_list:
 if s == 'B':
  b_count = b_count + 1
 if s == 'W': 
  count = count + b_count
print(count)

Solution (Python):
s=input()
n=len(s)

ans=0
j=0
for i in range(n):
    if s[i]=="W":
        ans+=(i-j)
        j+=1
print(ans)

Solution (Python):
S=list(input())
n=len(S)
ans=0
b=0

for s in S:
    if s=='B':b+=1
    else:ans+=b
    
print(ans)

Solution (Python):
S = input()
length = len(S)
soko = 1
ans = 0
for i in range(length):
    if S[-i-1] == 'B':
        ans += i + 1  - soko
        soko += 1
print(ans)

Solution (Python):
s=input()
lens=len(s)
s=list(s)
ans=0
a=[i for i, x in enumerate(s) if x == 'B']
lena=len(a)
k=0
for j in a:
    ans+=lens-(j+1)-k
    k+=1
print(ans)

Solution (Python):
arange = input()

times = 0
bottom = arange.find("B")
white_pos = arange[bottom:].find("W") + bottom

while bottom != -1 and white_pos != -1:
  times += white_pos - bottom
  bottom += 1
  
  pos = arange[white_pos+1:].find("W")
  if pos == -1:
    break
  white_pos += pos + 1
  
print(times)

Solution (Python):
S=input()
a=0
b=0
for i in range(len(S)):
    if S[-i-1]=="B":
        a+=i-b
        b+=1
print(a)

Solution (Python):


s = input()
B_num = s.count('B')
length = len(s)

target = 'B'
index = -1
num = 0
v_sum = 0
while True:
    index = s.find(target, index + 1)
    if index == -1:
        break
    num += 1
    v_sum += (length-1)-(B_num- num)-index
print (v_sum)

Solution (Python):
black = "B"
white = "W"

def move_cost(s):
    a = 0
    count = 0
    for i, c in enumerate(s):
        if c == white:
            a += i
            count += 1
    count -= 1
    return a - count*(count+1)//2


print(move_cost(input()))

Solution (Python):
S = list(input())

i = 0
answer = 0
b_count = 0

while i < len(S)-1:
	i_color = S[i]
	j_color = S[i+1]
	if i_color == 'B' and j_color == 'B':
		b_count += 1
	elif i_color == 'B' and j_color == 'W':
		S[i] = 'W'
		S[i+1] = 'B'
		answer = answer + b_count + 1
	else:
		b_count = 0

	i += 1

print(answer)

Solution (Python):
import numpy as np

S = input()
S = list(S)
S = np.array(S)

index_black = np.where(S=="B")[0]
diff = np.array([i for i in range(len(S)-len(index_black),len(S))])
count = int(np.sum(np.abs(diff-index_black)))
print(count)

Solution (Python):
s = list(input())
l = len(s)
n, psum = 0, 0
for i in range(l):
    if s[i] == 'W':
        n += 1
        psum += i

nsum = (n*(n - 1))/2

print(int(psum - nsum))

Solution (Python):
S = input()
length = len(S)
countB = 0
for c in S:
    if c == 'B':
        countB += 1
soko = 1
ans = 0
for i in range(length):
    if S[-i-1] == 'B':
        ans += i + 1  - soko
        soko += 1
print(ans)

Solution (Python):
S = list(input().strip())
is_irrversible = 0
answer = 0
position_key_sum = 0
number_of_white = 0
sigma = 0
for i in range(len(S)):
    if S[i] == 'W':
        position_key_sum += (i+1)
        number_of_white += 1
        sigma += number_of_white
answer = position_key_sum - sigma
print(answer)

Solution (Python):

import numpy as np

def main():
	s = input()
	ans = 0
	w = 0
	for i in range(len(s)):
		c = s[len(s)-1-i]
		if(c == 'B'):
			if(w > 0):
				ans += w
		else:
			w += 1
	
	print(ans)
	
main()

Solution (Python):
S = raw_input()
n = 0
wc = 0
s_pos = 0
for i, c in enumerate(S):
    if c == "W":
        n += 1
        wc += i - s_pos
        s_pos = n

n = 0
bc = 0
s_pos = 0
for i, c in enumerate(reversed(S)):
    if c == "B":
        n += 1
        bc += i - s_pos
        s_pos = n

print max(wc, bc)

Solution (Python):
S = input()

count = 0

i = 0

for j in range(len(S)):
    if S[j] == "W":
        count += j-i
        i += 1


print(count)

Solution (Python):
s = input()

w_cnt = 0
_b_cnt = 0
b_flag = False
cnt = 0
for si in list(s)[::-1]:
    if si == 'B':
        _b_cnt += 1
    if si == 'W':
        cnt += w_cnt * _b_cnt
        w_cnt += 1
        _b_cnt = 0
cnt += w_cnt * _b_cnt

print(cnt)

Solution (Python):
def main():
    s = input()
    black_site = []
    for i, c in enumerate(s):
        if c == "B":
            black_site.append(i)
    count = len(s)-1
    ans = 0
    for i in reversed(black_site):
        ans += count - i 
        count -= 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
s = [i for i in input()]
B_pos_ls = []
for i, x in enumerate(s):
    if x == 'B':
        B_pos_ls.append(i)
res = 0
B_pos_ls.sort(reverse=True)
last_B_pos = len(s) - 1
for B_pos in B_pos_ls:
    res += last_B_pos - B_pos
    last_B_pos -= 1
print(res)

Solution (Python):
s = input()

is_all_swappd = False
n_swap = 0
n_white = s.count('W')
for i in range(n_white):
    w_idx = None
    if i == 0:
        w_idx = s.find('W')
    else:
        w_idx = s[last_w_idx + 1:].find('W') + last_w_idx + 1
    n_swap += w_idx - i
    last_w_idx = w_idx

print(n_swap)

Solution (Python):
n = input()
a = [i for i in n]
ans = 0
n = len(n)
B=0
W = 0
for i in range(n):
    if a[i] == "W":
        ans += i-W
        W+=1
print(ans)

Solution (Python):
import numpy as np
S = input()

idx = []
i = 0
W_flag = False
for s in S:
    if not W_flag:
        if s == "W":
            continue
        elif s == "B":
            W_flag = True
    
    if s == "W" and W_flag:
        idx.append(i)
    i+=1
print(int(np.sum(idx) - ((0+len(idx)-1)*len(idx)/2)))

Solution (Python):
S = input()
N = len(S)
sum = 0
count = 0
flg = False
S = S[::-1]

for i in range(N):
  if S[i] == 'W':
    count += 1
    flg = True
  elif S[i] == 'B' and flg:
    sum += count
print(sum)

Solution (Python):
s = list(input())

cnt = 0
prev_cnt = 0
result = 0
for i in range(len(s)):
    if s[i] == "B":
        cnt += 1
    if s[i] == "W":
        cnt += prev_cnt
        result += cnt
        prev_cnt = cnt
        cnt = 0
print(result)

Solution (Python):
s = list("BWBWBW" * 10000)

s = list(input())
ret, counter = 0, 0
for a in s:
    if a == "B":
        counter += 1
    else:
        ret += counter
print(str(ret))

Solution (Python):
S = list(input())
N = len(S)
ans = 0
count = 0
for i in range(N):
  if S[i] == 'B':
    count+=1
  if S[i] == 'W':
    ans+=count
print(ans)

Solution (Python):
s=input()
l=[i for i in s ]
wlast=-1
ss=0
for i in range(len(s)):
    if l[i]=='W':
        ss+=(i-wlast-1)
        wlast+=1
print(ss)

Solution (Python):
s = input()
c = 0
ans = 0
for i in range(len(s)):
    if s[i] == "B":
        c += 1
    elif s[i] == "W":
        ans += c
print(ans)

Solution (Python):
s = input()

i = len(s) - 1
ans = 0
t = 0
while i >= 0:
    if s[i] == 'W':
        t += 1
    else:
        ans += t
    i -= 1

print(ans)

Solution (Python):
s = input()

ans = 0

num_B=0
num_W=0

for ele in s:
    
    if ele == 'B':
        ans += num_B*num_W
        num_B+=1
        num_W=0
    else:
        num_W+=1
ans += num_B*num_W
print(ans)

Solution (Python):
s = input()
n = len(s)

m1 = s.count('B')
m2 = s[n-m1::].count('B')

c = 0
for i in range(n):
    if s[i] == 'B':
        c += n-i-1
for i in range(m1):
    c -= i

print(c)

Solution (Python):
s=list(input())

ima=0
wNum=0
for i in range(len(s)):
  if s[i]=="W":
    ima += i
    wNum += 1

def kasan(n):
  if n==0:
    return 0
  else:
    return kasan(n-1) + n

saigo = ((wNum-1)+0)*wNum//2
print(ima-saigo)

Solution (Python):
S = input()
list = []
a,b = 0,0
for i in range(len(S)):
    list.append(S[i])

for i in range(len(list)):
    if list[i]=='W':
        a += i
        a -= b
        b += 1
print(a)

Solution (Python):
S = list(input())
def f(S):
    N = S.count("B")
    k = N
    i = len(S)-1
    res = 0
    while i >= 1:
        if S[i] == "B":
            k -= 1
        else:
            res += k
        i -= 1
    return res
print(f(S), flush=True)

Solution (Python):


from sys import stdin

def load():
    n = stdin.readline()
    return n

def calc(n):
    countup = False
    whites = 0
    total = 0

    for i,x in enumerate(n):
        if x == 'B':
            countup = True
        elif x == 'W':
            if countup:
                total += i - whites
            whites += 1
    return total

n = load()
print(calc(n))

Solution (Python):


if __name__ == '__main__':
    S = input()

    W_count = S.count('W')
    idx, count, result = 0, 0, 0

    while count < W_count:
        if S[idx] == 'W':
            result += idx - count
            count += 1
        idx += 1

    print(result)

Solution (Python):
count  = 0
ans = 0
s = list(input())

for item in s:
  if item == "W":
    ans += count
  else:
    count += 1
print(ans)

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

s=input()
v=[]
for i in range(len(s)):
  if s[i]=="B":
    v.append(i)
a=0
n=0
for i in range(len(s)-len(v),len(s))[::-1]:
  n+=i-v[a]
  a+=1
print(n)

Solution (Python):
from sys import stdin

def main():
    S = input()

    n = [0] * (len(S) + 1)
    for i, s in enumerate(S, start=1):
        if s == 'W':
            n[i] = n[i-1] + 1
        else:
            n[i] = n[i-1]
    ans = 0
    for i, s in enumerate(S, start=1):
        if s == 'B':
            ans += n[-1] - n[i]
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Solution (Python):
S = input()

N = len(S)
B_idx = []
W_idx = []

for i, s in enumerate(S):
    if s == 'B':
        B_idx.append(i)
    else:
        W_idx.append(i)

ans_B = 0
ans_W = 0

counter = 0
for w in W_idx:
    ans_W += (w - counter)
    counter += 1

counter = 0
for b in reversed(B_idx):
    ans_B += (N - b - 1 - counter)
    counter += 1
    
ans = max(ans_B, ans_W)
    
print(ans)

Solution (Python):
s = input()
s = list(s)
count_b = [0] * len(s)
for i in range(len(s)):
    if s[i] == 'B':
        if i == 0:
            count_b[i] = 1
        else:
            count_b[i] = count_b[i-1] + 1
    else:
        if i > 0:
            count_b[i] = count_b[i-1]
count = 0
for i in range(len(s)):
    if s[i] == 'W':
        count += count_b[i]
print(count)

Solution (Python):
state = input().rstrip()
ans = 0
cnt = 0
for i, s in enumerate(state):
    if s == 'B':
        cnt += 1
    else:
        ans += cnt
print(ans)

Solution (Python):
word = input()







word.count("W")

ans = 0
to_plus = word.count("W")
for i in range(len(word)):
    if word[i] == "B":
        ans += to_plus
    else:
        to_plus -= 1

    
print(ans)

Solution (Python):
S = input()
N = len(S)
cntw = 0
cnt = 0

for i in range(N):
    if S[i] == 'W':
        cnt += (i - cntw)
        cntw += 1

print(cnt)

Solution (Python):
S = input()

result = 0
w_count = 0

for i in range(len(S)):
    if S[i] == 'W':
        result += i - w_count
        w_count += 1

print(result)

Solution (Python):
S=list(input())






c=0
x=0
for i in range(len(S)):
	if S[i]=="B": x+=1
	else: c+=x

print(c)

Solution (Python):
s = list(input())
cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'B':
        cnt += 1
    else:
        ans += cnt

print(ans)

Solution (Python):
S = input()
cnt  = 0
nb = 0
for i in range(len(S)):
    if S[i] == 'B':
        nb += 1
    else:
        cnt += nb
print(cnt)

Solution (Python):
s = list(input())
ans = 0
count = 0
for i in range(len(s)):
    if s[i] == "B":
        count += 1
    if s[i] == "W":
        ans += count
print(ans)

Solution (Python):
S=raw_input()
L=[]

t=0
for x in S:
	if x=='W': t+=1
	L.append( t )
	
ans=0
for i , x in enumerate(S):
	if x=='B':
		ans+=L[-1]-L[i]

print ans

Solution (Python):
S = list(input())

cnt = 0
Bseq = 0
for i in range(len(S)-1):
    if S[i] == 'B':
        Bseq += 1
    else:
        Bseq = 0

    if S[i] == 'B' and S[i+1] == 'W':
        S[i] = 'W'
        S[i+1] = 'B'
        cnt += Bseq
        Bseq = Bseq-1

ans = cnt
print(ans)

Solution (Python):
S = input()

ans = 0
count = 0
for i, s in enumerate(S):
    if s == 'W':
        ans += i - count
        count += 1

print(ans)

Solution (Python):
s = input()
n = len(s)
op = 0
w = 0
for c in s[::-1]:
  if c is "W":
    w += 1
  else:
    op += w
    n -= 1
print(op)

Solution (Python):
s = input()
ret = 0
st = 0
for i in range(len(s)):
    if (s[i] == 'W'):
        ret += (i-st)
        st += 1
print(ret)

Solution (Python):
s=input()
ans=0
w=0
for i in range(len(s)):
  if s[i]=="W":
    ans+=i-w
    w+=1
print(ans)

Solution (Python):

s = input()



index = 0
sum = 0
for e,c in enumerate(s):
    if c == 'W':
        sum += e - index
        index += 1
        

        












print(sum)

Solution (Python):
S = input()

ans = 0
c = 0

for i in range(len(S)):
    if S[i]=='W':
        ans = ans + i - c
        c = c+1
        
print(ans)

Solution (Python):
def main():
    ss = input()
    b = 0;
    ans = 0;
    for s in ss:
        if (s == 'B'):
            b += 1
        else:
            ans += b

    print(ans)

main()

Solution (Python):
s = input()
cnt = -1
ans = 0
for i in range(len(s)):
	if s[i] == "W":
		cnt += 1
		ans += i - cnt
print(ans)

Solution (Python):
S = input()

count = 0
countB = 0
for i in range(len(S)):
    if S[i] == "B":
        countB += 1
    else:
        count += countB

print(count)

Solution (Python):
S = input()
count = 0
num = 0
for i in range(len(S)):
    if S[i] == "B":num+=1
    if S[i] == "W":count+=num
print(count)

Solution (Python):

S = input()

cnt = 0
ans = 0
for i in range(len(S)):
    if S[i]=="B":
        cnt+=1
    else:
        ans += cnt
        cnt += 0
print(ans)

Solution (Python):
s = str(input())
n = len(s)

ans = 0
temp = 0

for i in range(n):
    if  s[i] == 'B':
        temp += 1
    else:
        ans += temp

print(int(ans))

Solution (Python):
S = str(input())

count = 0

now = 0

for s in S:
    if s == 'B':
        now += 1
    else:
        count += now

print(count)

Solution (Python):
S = input().strip()

wc, bc = 0, 0
wd, bd = 0, 0
for i, s in enumerate(S):
  if s == 'W':
    wc += 1
    wd += i - wc + 1
  else:
    bc += 1
    bd += len(S) - 1 - i - bc + 1
print((wd + bd) // 2)

Solution (Python):
S = raw_input()
ans = 0
c = 0
for i in range(len(S)):
  if S[i]=="W":
    ans += i-c
    c += 1
print ans

Solution (Python):


import math
import sys
import itertools
import numpy as np


m = list(input())

answer = 0
num_b = 0
for i in range(len(m)):
    if m[i] == 'W':
        answer += num_b
    else:
        num_b += 1

print(answer)

Solution (Python):
a = input()
b = [0 if i == "W" else 1 for i in list(a)]

b_sum = sum(b)
b_aggr = 0
b_len= len(b)
for i in range(b_len):
    if b[i] == 1:
        b_aggr += (b_len - i - 1)
b_cali = b_sum * (b_sum - 1) / 2
print(int(b_aggr-b_cali))

Solution (Python):
s = list(input())

ans = 0
buffer = 1
for i in range(len(s) - 1):
    if s[i] == 'W':
        buffer = 1
        continue
    elif s[i + 1] == 'W':
        s[i] = 'W'
        s[i + 1] = 'B'
        ans += buffer
        
    else:
        buffer += 1

print(ans)

Solution (Python):
S = str(input())
bw_list = [s for s in S]

sum = 0
count = 0
for j in range(len(S)):
    if bw_list[j] == 'B':
        continue
    elif bw_list[j] == 'W':
            count += 1
            sum += (j+1) - count
print(sum)

Solution (Python):
S = input()
count = 0
nowW = 0
WB = 0
for i in range(len(S)):
    if S[i] == 'W':
        count += 1
for i in range(len(S)):
    if S[i] == 'W':
        nowW += 1
    elif S[i] == 'B':
        WB += count - nowW
print(WB)

Solution (Python):
S=list(input())
ans=0
aki=0
for i in range(len(S)):
    if S[i]=='W':
        ans+=i-aki
        aki+=1
print(ans)

Solution (Python):
s = input()

ans = 0
c=0
N = len(s)


for i in range(N):
    if s[N-i-1]=='W':
        c+=1
    else:
        ans+=c

print(ans)

Solution (Python):
s = input()
list = list(s)
count=0
b=0

for i in range(len(list)):
  if(list[i] == "W"):
    count+=b
    continue
  else:
    if(i == len(list)-1):
      break
    b += 1
      
print(count)

Solution (Python):
s = list(input())
n = len(s)
ans = 0
c = 0
if "B" in s:
    b = s.index("B")
else:
    print(0)
    exit()
for i in range(b+1, n):
    if s[i] == "W":
        ans += i - b - c
        c += 1
print(ans)

Solution (Python):
S = input()
N = len(S)
num = 0
pos = 0
for i in range(N):
    if S[i] == 'W':
        num += 1
        pos += i
print(pos - num * (num - 1) // 2)

Solution (Python):
data = list(input())

count = 0


count_b = 0
for i in range(len(data)):
    
    if data[i] == 'W':
        count += count_b
        
        
        
    else:
        count_b += 1
    
    
print(count)

Solution (Python):

S = input()
len_S = len(S)
w_num = 0
operation_num = 0
for Ind in range(len_S-1,-1,-1):
	if S[Ind] == "W":
		w_num += 1
	elif S[Ind] == "B":
		operation_num += w_num

print(operation_num)

Solution (Python):
a=list(input())
count=0
wc=0
for num,i in enumerate(a):
    if i=="W":
        count+=num-wc
        wc+=1

print(count)

Solution (Python):
s=input()
a=[]
cnt=0
for i in range (len(s)):
    if s[i]=='B':
        a.append(0)
    else:
        cnt+=len(a)        
print(cnt)

Solution (Python):
S = input()
n = 0
r = -1
x = 0
while True:
    r = S.find("W", r+1)
    if r == -1:
        break
    x += r - n
    n += 1

print(x)

Solution (Python):
S = input()
N = len(S)
flag = 0

ans = 0
ans2 = 0
Bcount = 0
Wcount = 0
for i in range(N):
    if S[i] == 'B':
        ans2 += N - 1 - i
        Bcount += 1
for i in range(N):
    if S[i] == "W":
        Wcount += 1
        ans += i + 1
for i in range(Bcount):
    ans2 -= i
for i in range(Wcount):
    ans -= i
print(min(ans,ans2))

Solution (Python):
chars = list(input())
W = chars.count('W')
base = 0
count = 0
for i, c in enumerate(chars):
    if c == 'W':
        count += i - base
        base += 1
print(count)

Solution (Python):
s=list(input())
B=0;W=0;b=0;w=0
for i in range(len(s)):
  if s[i]=='B':B+=i+1
  elif s[i]=='W':W+=i+1
x=B-W
t=sorted(s)
t.reverse()
for j in range(len(t)):
  if t[j]=='B':b+=j+1
  elif t[j]=='W':w+=j+1
y=b-w
print(int(abs(x-y)/2))

Solution (Python):

def solve(S):
    if len(S) == 1:
        return 0

    j = 0
    ans = 0
    for i in range(0, len(S)):
        if S[i] == "W":
            ans += (i - j)
            j += 1
    return ans


if __name__ == "__main__":
    print(solve(input()))

Solution (Python):
L = list(input())
memo = L.count("W")
ans = 0
for i in range(len(L)) :
    if L[i] == "W" :
        memo -= 1
    else :
        ans += memo
print(ans)

Solution (Python):
S = input()
N = len(S)

b = S.count("B")
ans = 0

for k in range(N):
    if S[k] == "B":
        ans += N-b-k
        b -= 1
print(ans)

Solution (Python):
a=input()
len_a=len(a)

point=0
howmany_w=0
for a_n in range(len(a)):
	if a[a_n]=='W':
		point+=(len_a-a_n)
		howmany_w+=1

maxpoint = (len_a - howmany_w/2 + 1/2) * (howmany_w)

kaisu=maxpoint-point
print(int(kaisu))

Solution (Python):
s = list(input())
n = len(s)
i = []
for j in range(n):
  if s[j] == "W":
    i.append(j)
c = 0
for k in range(len(i)):
  c += i[k]-k
print(c)

Solution (Python):
S = list(input())
count_B = 0
ans = 0
for i in range(len(S)):
    if S[i] == "B":
        count_B += 1
    elif S[i] == "W":
        ans += count_B
print(ans)

Solution (Python):
S = input()
S_list = []
for i in S:
    S_list.append(i)

w_count = S.count("W")
b_count = S.count("B")
c = 0

for i in range(len(S)):

    if S[i] == "B":
        c += w_count
    else:
        w_count -= 1

print(c)

Solution (Python):
N = input()
re = []
for i ,val in enumerate(N):
	if val == "W":
		re.append(i - len(re))
print( sum(re) )

Solution (Python):
xs = list(input().rstrip())
bcount = 0
count = 0
for x in xs:
  if x == 'B':
    bcount += 1
  else:
    count += bcount

print(count)

Solution (Python):
S = input()

def f(S):
    if len(S)==1 :
        return 0
    else :
        result = 0; b = 0
        for i in S :
            if i == 'B' :
                b+=1
            else:
                result += b
        return result
print(f(S))

Solution (Python):
S = input()
countW = 0
countB = 0
for i in range(len(S)):
  if S[i]=="B":
    countB+=1
  if S[i]=="W":
    countW += countB
print(countW)

Solution (Python):
S = input()

ans=0

W=0

for i in range(len(S)):
  if S[i] == "W":
    ans+=i-W
    W+=1
    
print(ans)

Solution (Python):
from itertools import groupby as gb
s = input()
g = gb(s)
flag = False
if s[0]=='W':
    flag = True
BW = []
for k,v in g:
    if flag:
        flag = False
        continue
    BW.append(len(list(v)))
if len(BW)%2==0:
    BW.append(0)
tmp = 0
res = 0
for i in range(0,len(BW)-1,2):
    a,b = BW[i]+tmp, BW[i+1]
    res += a * b
    BW[i+2] += a
    
print(res)

Solution (Python):
S = [c for c in input()]

B_count = 0
ans = 0
for i in range(len(S)):
    if S[i] == "B":
        B_count += 1
    else:
        ans += B_count

print(ans)

Solution (Python):
s = str(input())
num = 0
ans = 0
cou = 0
nu = 0
co = 0
for i in range(len(s)):
    if s[i] == "W":
        num += cou
        cou = 0
        ans += num
    else:
        cou += 1
print(ans)

Solution (Python):
s = raw_input()

sum = 0
itr = 0
for i in range(len(s)):

    if s[i] == "W":
        sum = sum - itr + i
        itr = itr + 1


print(sum)

Solution (Python):
import sys
import collections
input = sys.stdin.readline

S = input()
c = collections.Counter(S)["W"]
ans = 0

for s in S:
    if s == "B":
        ans += c
    elif s == "W":
        c -= 1

print(ans)

Solution (Python):
s = input()
a = []
for i in range(len(s)):
    if s[i] == 'W':
        a.append(i+1)
res = 0
for i in range(len(a)):
    res += a[i] - (i+1)
print(res)

Solution (Python):
S = input()
c = 0
ans = 0
for i in range(len(S)):
    if S[i] == "W":
       ans += i
       c += 1

ans -= c * (c-1)//2
print(ans)

Solution (Python):
S = str(input())

lB = 0
ret = 0
for s in S:
  if s == 'B':
    lB += 1
  else:
    ret += lB
print(ret)

Solution (Python):
s=[1 if i == 'W' else 0 for i in input()]

a = sum(s)

for i in range(len(s)):
    if s[i] == 0:
        s = s[i:]
        break


ret = 0
k = 0
for i in range(len(s)):
    if s[i] == 0:
        k +=1
        continue
    ret += k
print(ret)

Solution (Python):
S = input()
ans = 0
N = len(S)
B = [0] * (N + 1)
if S[0] == "B":
    B[0] = 1

for i in range(1, N):
    B[i] = B[i - 1] + int(S[i] == "B")

for i in range(N):
    if S[i] == "W":
        ans += B[i]

print(ans)

Solution (Python):

S = input()

ans = 0
state = 0
for i, Si in enumerate(S):
    
    if state < 1 and Si == 'B':
        state += 1
        marker = i
    elif state > 0 and Si == 'W':
        ans += i - marker
        marker += 1

print(ans)

Solution (Python):
s = input()

cnt = 0
w = 0
for i, c in enumerate(s):
    if c == 'B':
        continue
    else:
        cnt += (i-w)
        w += 1

print(cnt)

Solution (Python):
s = input()

w_count = 0
swap_count = 0
for index, stone in enumerate(s):
	if stone == 'W':
		swap_count += index - w_count
		w_count += 1


print(swap_count)

Solution (Python):
S = list(input())

wcnt=0
ans=0
for i in range(len(S)):
    if S[i]=='W':
        ans+=(i-wcnt)
        wcnt+=1

print(ans)

Solution (Python):
S = input()

len_S = len(S)

ans = 0
B_count = 0

for i in range(len_S):
    pos_from_end = len_S-i-1
    c = S[pos_from_end]
    if c == "B":
        ans += len_S-1-B_count-pos_from_end
        B_count += 1

print(ans)

Solution (Python):
S = input()

ans = 0
f = -1

for i, s in enumerate(S):
    if f != -1 and s == 'W':
        ans += i - f
        f += 1
    elif f == -1 and s == 'B':
        f = i

print(ans)

Solution (Python):
S = input()
cnt = 0
ans = 0

for i in range(len(S)):
    if S[i] == "W":
       ans += i - cnt
       cnt += 1

print(ans)

Solution (Python):
S = input()
N = len(S)
black = S[-1] == 'B'
cnt = 0
for i in range(N-2, -1, -1):
    if S[i] == 'B':
        cnt += N - 1 - i - black
        black += 1
print(cnt)

Solution (Python):
s = input()

ws = 0
res = 0
for i, c in enumerate(s):
    if c == 'W':
        res += i - ws
        ws += 1
print(res)

Solution (Python):
S = input()[::-1]
find_w = False
w_count = 0
result = 0

for i, c in enumerate(S):
    if not find_w:
        if c == "B":
            continue
        else:
            find_w = True
            w_count += 1
    else:
        if c == "B":
            result += w_count
        else:
            w_count += 1

print(result)

Solution (Python):


import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

II = lambda: int(input())
MI = lambda: map(int, input().split())




def mc(s):
    l = len(s)
    if l <= 1: return 0
    s1 = s[:l//2]
    s2 = s[l//2:]
    count = mc(s1) + mc(s2)
    count += sum(s1) * (len(s2) - sum(s2))
    return count


def main():
    s = list(input().strip())
    s = [(c == "B") for c in s]
    return mc(s)


if __name__ == "__main__":
    print(main())

Solution (Python):

s = input()
ls = []
cnt_b =0
for i in range(len(s)):
    if s[i] == "W":
        ls.append(cnt_b)
    else:
        cnt_b+=1
print (sum(ls))

Solution (Python):
s=input()
size,v=0,0

for i in range(len(s)):
  if s[i]=="B":
    size+=1
  else:
    v+=size

print(v)

Solution (Python):

S = list(input())

W_cnt = 0
ans = 0
for i,s in enumerate(S):
    if s == "W":
        ans += i - W_cnt
        W_cnt += 1
print(ans)