Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    BW = {'B':[], 'W':[]}
    cnt = {'B':0, 'W':0}
    pre = S[0]
    cnt[pre] += 1
    for i in range(1, len(S)):
        now = S[i]
        if pre == now:
            cnt[pre] += 1
        else:
            BW[pre].append(cnt[pre])
            cnt[pre] = 0
            cnt[now] = 1
            pre = now
        # print(cnt)
        # print(BW)
    if cnt[pre] != 0:
        BW[pre].append(cnt[pre])

    if S[0] == 'W':
        BW['W'].pop(0)
    if S[-1] == 'B':
        BW['B'].pop(-1)
    ans = 0
    for i in range(len(BW['B'])):
        ans += sum(BW['B'][:i+1])*BW['W'][i]
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    BW = {'B':[], 'W':[]}
    cnt = {'B':0, 'W':0}
    pre = S[0]
    cnt[pre] += 1
    for i in range(1, len(S)):
        now = S[i]
        if pre == now:
            cnt[pre] += 1
        else:
            BW[pre].append(cnt[pre])
            cnt[pre] = 0
            cnt[now] = 1
            pre = now
        # print(cnt)
        # print(BW)
    if cnt[pre] != 0:
        BW[pre].append(cnt[pre])

    if S[0] == 'W':
        BW['W'].pop(0)
    if S[-1] == 'B':
        BW['B'].pop(-1)
    ans = 0
    for i in range(len(BW['B'])):
        ans += sum(BW['B'][:i+1])*BW['W'][i]
    print(ans)
if __name__ == '__main__':
    main()

#PLAN1
    # S = list(input())
    # check = 0
    # cnt = 0
    # i = 0
    # while(check == 0) :
    #     check = 1
    #     for i in range(len(S)-1):
    #         if S[i] == 'B' and S[i+1] == 'W':
    #             S[i], S[i+1] = 'W', 'B'
    #             cnt += 1
    #             check = 0
    #             break
    # print(cnt)

# PLAN2
# S = list(input())
# state = 0
# CNT = 0
# while(state != 1):
# # for x in range(50):
#     first_W = 0
#     for i in range(len(S)):
#         if state == 0:
#             if S[i] == 'B':
#                 B_cnt = 1
#                 state = 1
#             else:
#                 first_W += 1
#         elif state == 1:
#             if S[i] == 'B':
#                 B_cnt += 1
#             else:
#                 W_cnt = 1
#                 state = 2
#         elif state == 2:
#             if S[i] == 'W':
#                 W_cnt += 1
#             else:
#                 state = 0
#                 break
#     # print(state)
#     if state == 2:
#         state = 0
#         S = ['W']*(W_cnt+first_W) + ['B']*B_cnt
#     else:
#         CNT += W_cnt*B_cnt
#         S = ['W']*(W_cnt+first_W) + ['B']*B_cnt + S[i:]
#     # print(S)
# print(CNT)

Fixed submission:
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    state = 0
    CNT = 0
    while(state != 1):
    # for x in range(50):
        first_W = 0
        for i in range(len(S)):
            if state == 0:
                if S[i] == 'B':
                    B_cnt = 1
                    state = 1
                else:
                    first_W += 1
            elif state == 1:
                if S[i] == 'B':
                    B_cnt += 1
                else:
                    W_cnt = 1
                    state = 2
            elif state == 2:
                if S[i] == 'W':
                    W_cnt += 1
                else:
                    state = 0
                    break
        # print(state)
        if state == 2:
            state = 0
            S = ['W']*(W_cnt+first_W) + ['B']*B_cnt
        else:
            CNT += W_cnt*B_cnt
            S = ['W']*(W_cnt+first_W) + ['B']*B_cnt + S[i:]
        # print(S)
    print(CNT)
        
if __name__ == '__main__':
    main()

    # S = list(input())
    # check = 0
    # cnt = 0
    # i = 0
    # while(check == 0) :
    #     check = 1
    #     for i in range(len(S)-1):
    #         if S[i] == 'B' and S[i+1] == 'W':
    #             S[i], S[i+1] = 'W', 'B'
    #             cnt += 1
    #             check = 0
    #             break
    # print(cnt)

Fixed submission:
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    check = 0
    cnt = 0
    i = 0
    while(check == 0) :
        check = 1
        for i in range(len(S)-1):
            if S[i] == 'B' and S[i+1] == 'W':
                S[i], S[i+1] = 'W', 'B'
                cnt += 1
                check = 0
                break
    print(cnt)
                
if __name__ == '__main__':
    main()

Fixed submission:
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    check = 0
    cnt = 0
    i = 0
    while(check == 0) :
        check = 1
        for i in range(len(S)-1):
            if S[i] == 'B' and S[i+1] == 'W':
                S[i], S[i+1] = 'W', 'B'
                cnt += 1
                check = 0
                break
    print(cnt)
                
if __name__ == '__main__':
    main()

Fixed submission:
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()