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()
c = 0
ans = 0
for i in s[::-1]:
  if i=="W":
    c += 1
  else:
    ans += c
print(ans)

Solution (Python):
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  

S = list(rs())
cnt_B = 0
answer = 0
for s in S:
    if s == 'B':
        cnt_B += 1
    else:
        answer += cnt_B
print(answer)

Solution (Python):
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  

S = list(rs())
W = [0] * len(S)
for i in range(len(S)):
    if S[i] == 'W':
        W[i] = 1
W = np.array(W[::-1])
W_cum = W.cumsum()[::-1]
W_cum = W_cum.tolist()
answer = 0
for i in range(len(S)):
    if S[i] == 'B':
        answer += W_cum[i]

print(answer)

Solution (Python):
S = input()
pos_W = []
for i in range(len(S)):
    if S[i] == "W":
        pos_W.append(i)
print(sum(pos_W) - len(pos_W) * (len(pos_W) - 1) // 2)

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

ans=0
accum=[0]*n
for i in range(n-1):
    if s[i]=='B':
        accum[i+1]=accum[i]+1
    else:
        accum[i+1]=accum[i]

for i in range(n):
    if s[i]=='W':
        ans+=accum[i]
print(ans)

Solution (Python):
s=input()
m=[s[i]=="B" for i in range(len(s))]
m1=[None for i in range(len(s))]
m1[0]=m[0]
for i in range(1,len(s)):
  m1[i]=m1[i-1]+m[i]
m2=[None for i in range(len(s))]
m2[len(s)-1]=m[len(s)-1]
for i in range(len(s)-1,0,-1):
  m2[i-1]=m2[i]+m[i]
  
ans1=0
ans2=0
for i in range(1,len(s)):
  if s[i]=="W":
    ans1+=m1[i]
    ans2+=m2[i]
    
print(ans1)

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

Solution (Python):
s = list(input())
n = len(s) - 1
b_count = s.count("B")
ans = 0
for i in range(len(s)):
  if s[i] == "B":
    ans += n - i
print(ans-((b_count - 1)*(b_count)//2))

Solution (Python):
a,w=0,0
for i,j in enumerate(input()):
    if j=="W":
        a+=i-w
        w+=1
print(a)

Solution (Python):
S = input()
B = S.count('B')
W = S.count('W')
es = 'W' * W + 'B'* B
bf = es.find('B')
blst = [0] * B
for i in range(B):
    blst[i] = bf + i
slst = [0] * B
bindex = 0
for i in range(len(S)):
    if S[i] == 'B':
        slst[bindex] = i
        bindex += 1

ans = 0
for i in range(B):
    ans += blst[i] - slst[i]

print(ans)

Solution (Python):
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

s = rs()
counter = collections.Counter(s)
res = 0
for i, c in enumerate(s):
    if c == 'W':
        counter['W'] -= 1
    else:
        res += counter['W']
print(res)

Solution (Python):
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

s = rs()
counter = collections.Counter(s)
n = len(s)
res = 0
for i, c in enumerate(s):
    if c == 'W':
        counter['W'] -= 1
    else:
        res += counter['W']
print(res)

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



S = sys.stdin.buffer.readline().decode().rstrip()

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

print(ans)

Solution (Python):
S = input()

bc = 0
result = 0
for i in range(len(S)):
    if S[i] == 'B':
        bc += 1
    if S[i] == 'W':
        result += bc
print(result)

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

Solution (Python):
S = input()
tmp = []
count = 1
for i, x in enumerate(S):
    if x == 'B':
        tmp.append([i, count])
        count += 1

tmp.sort(key=lambda x: x[1], reverse=True)
ans = 0
for i in range(len(tmp)):
    x = tmp[i][0]
    ans += len(S)-1-i - x
print(ans)

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

Solution (Python):

S = input()
N = len(S)
B_cnt = 0
W_cnt = 0
ans = 0
for i in range(N-1, -1, -1):
    
    if S[i] == "B":
        ans += W_cnt
    else:
        W_cnt += 1
print(ans)

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

w_cnt = 0
cnt = 0
ans = 0

for i in range(len(s)):
    if s[i] == "W":
        w_cnt += 1
        cnt += 1
        ans += cnt - w_cnt
    else:
        cnt += 1
        
print(ans)

Solution (Python):
s=input()
ans=chk=0
for i in s[::-1]:
    if i=="B":
        ans+=chk
    else:
        chk+=1
print(ans)

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

idx = [i for i in range(len(s)) if s[i] == 'W']
ans = sum(i - x for x, i in enumerate(idx))

print (ans)

Solution (Python):

S = input()
N = len(S)

STR = [s for s in S]
W_idx = [i for i,s in enumerate(S) if s == 'W']
ans = 0

for i in range(len(W_idx)):
    ans += W_idx[i]-i
print(ans)

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

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

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

Solution (Python):
import numpy as np


def main():
    s = input()

    b = []
    cnt = 0
    for i, e in enumerate(s):
        if e == "B":
            b.append(i)
            cnt += 1

    b = np.array(b)
    b_fin = np.arange(len(s) - cnt, len(s))

    ans = int(np.sum(b_fin - b))

    print(ans)


if __name__ == "__main__":
    main()

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



n = 1 if S[0] == "W" else 0
count = 0
for i in range(1, len(S)):
    if S[i] == "W":
        count += i - n
        n += 1
        
        
print(count)

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



n = 1 if S[0] == "W" else 0
count = 0
for i in range(1, len(S)):
    if S[i] == "W":
        count += i - n
        n += 1
        
        
print(count)

Solution (Python):
if __name__ == "__main__":
    S = input()
    ans = 0
    bcount = 0
    for i in range(len(S)):
        if S[i] == 'B':
            bcount += 1
        else:
            ans += bcount

    print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
b = 0
res = 0
for i in s:
    if i == 'B':
        b += 1
    else:
        res += b
print(res)

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

print(ans)

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

Solution (Python):
def f(s):
    ret = 0
    n = len(s)
    for i in range(n):
        if s[i] == "W":
            ret += i
    return ret

s = list(input())
nW = s.count("W")
ans = 0
ans += f(s)
for i in range(1, nW):
    ans -= i
print(ans)

"""
BWBWBW
WBWBWB
WWBWBB
WWWBBB

先頭までの距離（i）- 何番目のWか+1
ni - 1~nW +1
"""

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

cnt_B = S.count('B')
idx_B = N - cnt_B

for i in range(N):
    if S[i] == 'B':
        ans += idx_B - i
        idx_B += 1

print(ans)

Solution (Python):
s=str(input())
n=len(s)
ans=0
c=0
for i in range(n):
    if s[i]=='W':
        c+=1
        ans+=i+1-c
print(ans)

Solution (Python):

S = input()

ans = 0
B = 0

for i in range(len(S)):

    if S[i] == "W":
        ans += B
    else:
        B += 1

print (ans)

Solution (Python):
s = input()

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

Solution (Python):
s = input()
accum = [0]
num = 0
count = 0
for i in range(len(s)):
    if s[i] == 'B':
        num += 1
    else:
        count += accum[i]
    accum += [num]
print(count)

Solution (Python):
def main():
    s = input()
    length = len(s)-1
    count = s.count('B')
    init = sum([i for i in range(len(s)) if s[i] == "B"])
    processed = sum(range(length-count+1, length+1))

    print(processed-init)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    s = input()
    length = len(s)-1
    count = s.count('B')
    init = sum([i for i in range(len(s)) if s[i] == "B"])
    processed = sum(range(length-count+1, length+1))

    print(processed-init)


if __name__ == '__main__':
    main()

Solution (Python):
S = input()
answer = [0] * (len(S) + 1)

for i in reversed(range(len(S))):
    if S[i] == 'W':
        answer[i] = answer[i + 1] + 1
    else:
        answer[i] = answer[i + 1]

cnt = 0
for i in range(len(answer) - 1):
    if answer[i] == answer[i + 1]:
        cnt += answer[i]

print(cnt)

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

Solution (Python):
S=input()

ans=0
black=0

for c in S:
    if c=='B':
        black+=1
    else:
        ans+=black

print(ans)

Solution (Python):
s = input()

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

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

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

for i in range(cnt):
    ans -= i
print(ans)

Solution (Python):
s = input()[::-1]
ans = []
tmp = 0
for i in s:
    if i == "W":
        tmp += 1
    elif i == "B":
        ans.append(tmp)
print(sum(ans))

Solution (Python):
ans, cnt = 0, 0
for s in input()[::-1]:
    if s == "W": cnt += 1
    elif s == "B": ans += cnt
print(ans)

Solution (Python):
def resolve():
    s = input()
    ans = 0
    b = 0
    for i in range(len(s)):
        if s[i] == "W":
            ans += b
        else:
            b += 1
    print(ans)


if __name__ == "__main__":
    resolve()

Solution (Python):
def solve(s):
    ans = 0
    num = 0
    for c in s[::-1]:
        if c == "W":
            num += 1
        else:
            ans += num
    return ans

s = input()
print(solve(s))

Solution (Python):
S=input()
a=c=0
for s in S:
  if s=="B":c+=1
  else:a+=c
print(a)

Solution (Python):
s = list(input())
total_l = 0
for i in range(len(s)):
  if s[i] == "W":
    total_l += i
minus = sum(list(range(s.count("W"))))
print(total_l - minus)

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

ans = 0
pos = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += i-pos
        pos += 1

print(ans)

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

ans = 0
pos = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += i-pos
        pos += 1

print(ans)

Solution (Python):
s = input()

ans = 0
pos = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += i-pos
        pos += 1

print(ans)

Solution (Python):
S=input();w=S.count("W");print(sum(i*(S[i]>"B")for i in range(len(S)))-w*~-w//2)

Solution (Python):
S = input()
r = 0
nB = 0
for c in S:
  if c == "B":
    nB += 1
  if c == "W":
    r += nB
print(r)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    S=input()
    ans=0
    b=0
    for s in S:
        if s=="B": b+=1
        else: ans+=b
    print(ans)
resolve()

Solution (Python):
S=input();print(sum([i for i, s in enumerate(S) if s=='W'])-(S.count('W')*(S.count('W')-1))//2)

Solution (Python):
S = input()

ans = 0
right = 0

for i, s in enumerate(S[:: -1]):
    if s == 'B':
        ans += i - right
        right += 1

print(ans)

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

Solution (Python):
s = input()

n_b = 0
for i in range(len(s)):
    if s[i] == 'B':
        n_b += 1

ans = 0
j = 0
for i in range(len(s)):
    if s[i] == 'B':
        j += 1
        ans += (len(s) - j) - i

print(ans)

Solution (Python):
S = input()
lenS = len(S)
ans = 0
cnt = 0
for idx in range(lenS-1, -1, -1):
  if S[idx] == 'B':
    ans += (lenS-1) - idx - cnt
    cnt += 1
print(ans)

Solution (Python):
s = list(input())[::-1]
ans = 0
wcnt = 0
for i in s:
  if i == "W":
    wcnt += 1
  else:
    ans += wcnt
print(ans)

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

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

Solution (Python):
S=list(input())
S=S[::-1]
N=len(S)

w_n=0
ans=0
for i in range(N):
  if S[i]=="W":
    w_n+=1
  else:
    ans+=w_n
    
print(ans)

Solution (Python):
s=input()
a=0
c=0
for i in range(len(s)):
  if s[i]=="W":
    a+=i
    c+=1
b=c*(c-1)//2
print(a-b)

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

for i in S:
    if i == "W":
        W += 1

Bl = []

for i in range(W):
    if S[i] == "B":
        Bl.append(i)

Wl = []

for i in range(W, len(S)):
    if S[i] == "W":
        Wl.append(i)

N = len(Bl)
ans = 0

for i in range(N):
    ans += Wl[i] - Bl[i]

print(ans)

Solution (Python):


S=input()
N=len(S)

sum=0
k=0

for i in range(N):
    if S[i]=="W":
        sum+=(i-k)
        k+=1

print(sum)

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

ans = 0
B = 0
for s in S:
    if s == "B":
        B += 1
    else:
        ans += B

print(ans)

Solution (Python):
x=[i for i in  input()]
n=0
m=len(x)
w=0
for i in range(m):
    if x[i]=='W':
        w+=1
        n+=i-w+1
print(n)

Solution (Python):
pie = input()

sum_B = 0
wum = 0
num = 0

for i in range(0,len(pie)):
    if (pie[i]=='W'):
        wum+=1
        fl = i
        flag=i
for i in range(i-1,-1,-1):
    if (pie[i]=='B'):
        if (wum>0):
            sum_B+=(flag-i-num)
            num+=1
        else:
            break

print(sum_B)

Solution (Python):


import sys






s= input()

n=len(s)

cnt=0
total=0
for i in range(0,n):
	if(s[i]=="B"):
		cnt+=1
	else:
		total+=cnt
print(total)

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

def main():
    S = input().strip()
    w = 0
    n = 0
    for i,c in enumerate(S):
        if c == "W":
            n += i-w
            w += 1
    print(n)

if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


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


def B():
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


if __name__ == "__main__":
    A()

Solution (Python):





from sys import stdin,setrecursionlimit


setrecursionlimit(10**6)
input=stdin.readline

s=input().rstrip()
n=len(s)
now=[0]*(n+1)
for i in range(n):
    if s[i]=="B":
        now[i+1]=now[i]+1
    else:
        now[i+1]=now[i]

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

Solution (Python):
S = input()
cnt = 0
for i, s in enumerate(S):
    if s == 'W':
        cnt += i;
cnt -= S.count('W') * (S.count('W') - 1) // 2
print(cnt)

Solution (Python):
def main():
    S = input()
    ans = 0
    count = 0
    for i in range(len(S)):
        if S[i] == "B":
            count += 1
        else:
            ans += count
    return ans

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

Solution (Python):
S=list(input())
N=len(S)
cnt=0
if S[0]=="W":
    idx=1
else:
    idx=0

for i in range(1,N):
    if S[i]=="W":
        cnt+=i-idx
        idx+=1


print(cnt)

Solution (Python):
S = input()

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

Solution (Python):
s = input()

b = 0
ans = 0

for i in s:
	if i == "B":
		b += 1
	else:
		ans += b

print(ans)

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

Solution (Python):
S = input()

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

Solution (Python):

import sys, math, fractions, itertools, collections, copy, heapq


def solve(S: str):
    counter = 0
    c = 0
    for i, s in enumerate(S):
        if s == 'W':
            counter += i - c
            c += 1
    print(counter)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)

if __name__ == '__main__':
    main()

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

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

ans = 0





tmp = 1 if S[0] == 'B' else 0

for i in range(1, N):
    if S[i] == 'B':
        tmp += 1
    else:
        ans += tmp

print (ans)

Solution (Python):
S = list(input())
N = len(S)
left = [0] * N

ans = 0
if S[0] == 'B':
    left[0] = 1
for i in range(1, N):
    if S[i] == 'B':
        left[i] = left[i - 1] + 1
    else:
        left[i] = left[i - 1]
        ans += left[i]

print (ans)

Solution (Python):
S = list(input())
N = len(S)
left = [0] * N
right = [0] * N

if S[0] == 'B':
    left[0] = 1
for i in range(1, N):
    if S[i] == 'B':
        left[i] = left[i - 1] + 1
    else:
        left[i] = left[i - 1]







ans = 0
for i in range(N):
    if S[i] == 'W':
        ans += left[i]

print (ans)

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
ans,cnt = 0,0
for i in range(n):
    if s[i] == 'B':
        cnt += 1
    else:
        ans += cnt
print(ans)

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

Solution (Python):
s = input()

ans = 0
cnt = 0
for ss in s:
    if ss == 'B':
        cnt += 1
    else:
        ans += cnt
print(ans)

Solution (Python):
B = input()
lenB = len(B)

cntB = 0
checkB = [0]*lenB
indB = []
for i, b in enumerate(B):
    if b == 'B':
        cntB += 1
        indB.append(i)

dif = 0
i = 0
for j in range(lenB-cntB, lenB):
    dif += j - indB[i]
    i += 1

print(dif)

Solution (Python):
B = input()
lenB = len(B)

cntB = 0
checkB = [0]*lenB
indB = []
for i, b in enumerate(B):
    if b == 'B':
        cntB += 1
        indB.append(i)

dif = 0
i = 0
for j in range(lenB-cntB, lenB):
    dif += j - indB[i]
    i += 1

print(dif)

Solution (Python):
S = input()
b = 0
ans = 0
for s in S :
    if s == "B" :
        b += 1
    else :
        ans += b
print(ans)

Solution (Python):
S = list(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()

ans = 0
cnt = 0
for i, c in enumerate(reversed(S)):
    if c == 'B':
        ans += i - cnt
        cnt += 1
print(ans)

Solution (Python):
S = input()
bias = 0
ans = 0
for i,c in enumerate(S):
  if c == "W":
    ans += i -bias
    bias += 1
print(ans)

Solution (Python):
s=input()
ans=0
cnt=0
for i in s:
    if i=="B":cnt+=1
    else:ans+=cnt
print(ans)

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

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

S = input().rstrip()

left_B = 0
answer = 0
for x in S:
    if x == 'B':
        left_B += 1
        continue
    answer += left_B

print(answer)

Solution (Python):
S = list(input())[::-1]
a = 0
c = 0
for i in range(len(S)):
    if S[i] == 'W':
        c += 1
    else:
        a += c

print(a)

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

ans = 0
count_w = 0

for i in range(len(S)):
    if S[i] == 'W':
        count_w += 1
    else:
        ans += count_w

print(ans)

Solution (Python):


s=input()

cntB=0
ans=0
for i in range(len(s)):
    if s[i]=='B':cntB+=1
    else:ans+=cntB
print(ans)

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

Solution (Python):
import bisect
a=input()
bs=[i for i,j in enumerate(a) if j=="B"]
ws=[i for i,j in enumerate(a) if j=="W"]
cnt=0
for w in ws:
	cnt+=bisect.bisect(bs,w)
print(cnt)

Solution (Python):


s = input()
n = len(s)
w = 0
pack_w = 0
for i in range(n):
    if s[i] == "W":
        w += i - pack_w
        pack_w += 1

print(w)

Solution (Python):
def sum_n(n):
    
    ans = 0
    for i in range(n):
        ans += i
    return ans

def main():
    s = list(input())
    ans = 0
    cnt = 0
    for i,dst in enumerate(s):
        if dst=="W":
            ans += i
            cnt += 1
    ans -= sum_n(cnt)
    print(ans)
    
if __name__ == '__main__':
    main()

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

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

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

Solution (Python):

def main():
    S = input().rstrip()
    blk, ans = 0, 0
    for i in S:
        if i == "B":
            blk += 1
        else:
            ans += blk
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
S = input()
lenS = len(S)
left = 0
ans = 0
for i in range(lenS):
    if S[i] == "W":
        ans += (i-left)
        left += 1
print(str(ans))

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

Solution (Python):
from sys import stdin
S = list(stdin.readline().rstrip())
ls = len(S)
ans = 0
num_b = 0
for i in range(ls):
    if S[i] == 'B':
        num_b += 1
    else:
        ans += num_b
print(ans)

Solution (Python):
s = input()
ans = 0
tmp = 0
for c in s:
    if c == 'B':
        tmp += 1
    else:
        ans += tmp
print(ans)

Solution (Python):
S=input()
B_position=[]

for k,v in enumerate(S):
    if v=='B':
        B_position.append(k)

ans=0
L=len(S)

for i in B_position[::-1]:
    ans+=L-i-1
    L-=1

print(ans)

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

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

print(ans)

Solution (Python):
S=input()
w,a=0,0
for c in S:
    if c=='B':
        w+=1
    else:
        a+=w
print(a)

Solution (Python):
S = input()

b_l = 10**9
w_poslist = []
for i in range(len(S)):
    s = S[i]
    if s == "B" and i < b_l:
        b_l = i
    if s == "W":
        w_poslist.append(i)
if b_l == 10**9:
    print(0)
else:
    ans = 0
    for i in range(len(w_poslist)):
        if w_poslist[i] < b_l:
            continue
        ans += w_poslist[i] - b_l
        b_l += 1
    print(ans)

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

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

result = 0
wcnt = 0
for i,s in enumerate(s_list):
    if s == "W":
        result += i - wcnt
        wcnt += 1

print(result)

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

Solution (Python):
s=input()
ans=0
c=0
n=0
for i in range(len(s)):
    if s[i]=='B':
        c+=i+1
        n+=1
ans=(len(s)+len(s)-n+1)*n//2-c
print(ans)

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

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

Solution (Python):

from collections import defaultdict, deque
import math
from math import factorial
import re

BIGNUM = 10 ** 9 + 7

def main():
    
    S = list(input())

    black_index = []
    for index, s in enumerate(S):
        if s == 'B':
            black_index.append(index)

    num = 0
    for i, index in enumerate(black_index):
        right_num = len(S) - (index+1)
        n = right_num - (len(black_index) - i - 1)
        num += n
    print(num)

if __name__ == '__main__':
    main()

Solution (Python):



def main():
    s = input()[::-1]
    w_count = 0
    ans = 0

    for si in s:
        if si == 'W':
            w_count += 1
        else:
            ans += w_count

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):



def main():
    s = input()[::-1]
    w_count = 0
    ans = 0

    for si in s:
        if si == 'W':
            w_count += 1
        else:
            ans += w_count

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

S = input()
N = len(S)

w_num_arr = np.zeros(N)
b_num_arr = np.zeros(N)


if S[-1] == "W":
    w_num_arr[-1] = 1

for i in range(N-1-1, -1, -1):
    if S[i] == "W":
        w_num_arr[i] = w_num_arr[i+1] + 1
    else:
        w_num_arr[i] = w_num_arr[i+1]

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

print(ans)

Solution (Python):




def main():
    S = input()
    
    p = 0
    c = 0

    for i, s in enumerate(S):
        if s == 'W':
            c += 1
            p += i

    print(p - c*(c-1)//2)



if __name__ == '__main__':
    main()

Solution (Python):
S = input()

flag = False
cnt = 0
for i in range(len(S)):
    if S[i] == 'B' and flag == False:
        flag = True
        l = i
    if S[i] == 'W' and flag:
        cnt += i - l
        l += 1

print(cnt)

Solution (Python):
S = input()
cnt = 0
ans = 0
for c in S:
    if c == "B": cnt += 1
    else:
        ans += cnt
print(ans)

Solution (Python):

seq = 0
ans = 0
for i, s in enumerate(list(input())):
    if s == 'W':
        seq += 1
        ans += i + 1 - seq
print(ans)

Solution (Python):
s = input()
cnt_b, cnt_w = 0,0
ans = 0
for i, x in enumerate(s):
    if x == 'W':
        ans += cnt_b
        cnt_w += 1
    else:
        cnt_b += 1
print(ans)

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
INF = float("inf")
def mi(): return map(int, input().split())
def ii(): return int(input())



S = input()

prev = 0
sum = 0
for c in S:
  if c == 'B':
    prev += 1
  else:
    sum += prev
    
print(sum)

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

Solution (Python):
b = input()
white = 0
bl = []
for k in b:
    if k == 'B':
        bl.append(1)
    else:
        white += 1
        bl.append(0)
k = 0
wp = white
ans = 0
for p in bl:
    if p==1:
        ans += wp - k
        wp += 1
    k += 1

print(ans)

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


wlist=[]
for i in range(len(S)):
  if S[i]=="W":
    wlist.append(i)
    

answer=0
for i in range(len(wlist)):
  answer+=wlist[i]-i
  
print(answer)

Solution (Python):
S = input()
N = len(S)
A = []

for i, s in enumerate(S):
  if s == "W":
    A.append(i)
n = len(A)-1
print(sum(A)-(n+1)*n//2)

Solution (Python):
S = input()
N = len(S)
A = []

for i, s in enumerate(S):
  if s == "W":
    A.append(i)
n = len(A)-1
print(sum(A)-(n+1)*n//2)

Solution (Python):
S = list(input())
cumu=[0]
cnt = 0
for i in S:
    if(i=='B'):
        cumu.append(cumu[-1]+1)
    else:
        cumu.append(cumu[-1])

for ind,i in enumerate(cumu[1:]):
    if(S[ind]=='W'):
        cnt+=i

print(cnt)

Solution (Python):
s = input()

b = 0
ans = 0

for i in s:
    if i == "B":
        b += 1
    elif i == "W":
        ans += b

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()

cntB = 0
ans = 0

for ch in S:
    if ch == 'B':
        cntB += 1
    else:
        ans += cntB
print(ans)