Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    n,k = IL()
    a = list(IL())
    l = n-k+1
    pre = b = 0
    for i in range(l):
        result = 1
        for rep in a[i:i+k]:
            result = result*rep
        pre = b
        b = result
        if 0<i:
            if pre<b:
                print('Yes')
            else:
                print('No')
    exit()

Fixed submission:
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    n,k = IL()
    a = list(IL())
    l = n-k
    pre = b = 0
    for i in range(l):
        if a[i]<a[i+k]:
            print('Yes')
        else:
            print('No')
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    n,k = IL()
    a = list(IL())
    l = n-k+1
    b = []
    ans = []
    for i in range(l):
        tmp = a[i:i+k]
        result = 1
        for rep in tmp:
            result = result*rep
        b.append(result)
        if 0<i:
            if b[i-1]<result:
                ans.append('Yes')
            else:
                ans.append('No')
    
    for rep in ans:
        print(rep)
    exit()

Fixed submission:
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    n,k = IL()
    a = list(IL())
    l = n-k
    pre = b = 0
    for i in range(l):
        if a[i]<a[i+k]:
            print('Yes')
        else:
            print('No')
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    n,k = IL()
    a = list(IL())
    l = n-k+1
    b = [1]*(l)
    for i in range(l):
        for j in range(k):
            b[i]*=a[j+i]
    for i in range(1,l):
        if b[i-1]<b[i]:
            print('Yes')
        else:
            print('No')
    exit()

Fixed submission:
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    n,k = IL()
    a = list(IL())
    l = n-k
    pre = b = 0
    for i in range(l):
        if a[i]<a[i+k]:
            print('Yes')
        else:
            print('No')
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def s(n):
  l = [0]*n
  ans = 0
  for i in range(n):
    for j in range(i,n,(i+1)):
      l[j] += 1
    ans += (i+1)*l[i]
  print(ans)
  
n = int(sys.stdin.readline().rstrip())
s(n)

Fixed submission:
import sys  

if __name__=='__main__':
  n = int(sys.stdin.readline().rstrip())
  l = [0]*n
  ans = 0
  for i in range(n):
    for j in range(i,n,(i+1)):
      ans += j+1
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
import numpy as np
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = np.array(list(IL()),dtype='int64')
    q = I()
    s = deque()
    for rep in range(q):
        b,c = IL()
        a[a==b] = c
        s.append(sum(a))
    for _ in range(q):
        print(s.popleft())
    return

if __name__=='__main__':
    Main()

Fixed submission:
import sys
from collections import deque, Counter
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = list(IL())
    C = Counter(a)
    m = sum(a)
    q = I()
    s = []
    for rep in range(q):
        b,c = IL()
        if b in C:
            m += (c-b)*C[b]
            C[c] += C[b]
            C[b] = 0
        s.append(m)
    for rep in s:
        print(rep)
    return

if __name__=='__main__':
    Main()
Buggy python submission (verdict: Runtime Error):
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def main():
    x = LS()
    for i in len(x):
        if x[i] == '0':
            print(i)
            exit()
    return

if __name__=='__main__':
    main()

Fixed submission:
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def main():
    x = LI()
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)
            exit()
    return

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def main():
    x = SL()
    ans = 0
    for i in len(x):
        if x[i] == '0':
            print(i)
            exit()
    return

if __name__=='__main__':
    main()

Fixed submission:
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def main():
    x = LI()
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)
            exit()
    return

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from copy import deepcopy

def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
def R(x):
    r = round(x)
    if r+0.5 <= x:
        r += 1
    return r

a,b = I(),I()

print(a*b)

Fixed submission:
from sys import stdin
from copy import deepcopy

def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
def R(x):
    r = round(x)
    if r+0.5 <= x:
        r += 1
    return r

tmp = LI()

print(tmp[0]*tmp[1])
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
from sys import stdin
def LD(): return list(map(Decimal,stdin.readline().rstrip().split()))
 
tmp = LD()
ans = int(a*b)
print(ans)

Fixed submission:
from decimal import Decimal
from sys import stdin
def LD(): return list(map(Decimal,stdin.readline().rstrip().split()))
 
tmp = LD()
ans = int(tmp[0]*tmp[1])
print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from math
def LF(): return list(map(float,stdin.readline().rstrip().split()))

tmp = LF()
ans = tmp[0]*tmp[1]
print(math.floor(ans))

Fixed submission:
from decimal import Decimal
from sys import stdin
def LD(): return list(map(Decimal,stdin.readline().rstrip().split()))
 
tmp = LD()
ans = int(tmp[0]*tmp[1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from collections import deque
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
 
def end():
    print(-1)
    exit()
 
def main():
    n = I()
    a = deque(LI())
    if n==0:
        if a[0] == 1:
            print(1)
            exit()
        else:
            end()
    elif a[0]!=0:
        end()

    b = [0]*(n+1)
    for i in range(n,-1,-1):
        if i == n:
            b[i] = a[i]
        else:
            b[i] = min(b[i+1]+a[i],2**i)

    for i in range(n+1):
        if i!=0:
            b[i] = min(2*(b[i-1]-a[i-1]),b[i])
        if b[i]<a[i]:
            end()
    print(sum(b))
    return
 
if __name__=='__main__':
    main()

Fixed submission:
from sys import stdin
from collections import deque
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
 
def end():
    print(-1)
    exit()
 
def main():
    n = I()
    a = deque(LI())
    if n==0:
        if a[0] == 1:
            print(1)
            exit()
        else:
            end()
    elif a[0]!=0:
        end()

    b = [0]*(n+1)
    for i in range(n,-1,-1):
        if i == n:
            b[i] = a[i]
        else:
            b[i] = min(b[i+1]+a[i],2**i)

    for i in range(n+1):
        if i!=0:
            b[i] = min(2*(b[i-1]-a[i-1]),b[i])
        if b[i]<a[i]:
            end()
    print(sum(b))
    return
 
if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from collections import deque
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
 
def end():
    print(-1)
    exit()
 
def main():
    n = I()
    deq = deque(LI())
    if n==0:
        if deq[0] == 0:
            print(1)
            exit()
    if deq[0]!=0:
        end()
    max = deque()
    for i in range(n,-1,-1):
        if 2**i<deq[i]:
            end()
        if i == n:
            max.appendleft(deq[i])
        else:
            max.appendleft(max[0]+deq[i])
    for i in range(n+1):
        max[i] = min(2**i,max[i])
        if i!=n and i!=0:
            max[i] = min(2*(max[i-1]-deq[i-1]),max[i])
    	if max[i]<deq[i]:
          end()
    print(sum(max))
    return
 
if __name__=='__main__':
    main()

Fixed submission:
from sys import stdin
from collections import deque
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
 
def end():
    print(-1)
    exit()
 
def main():
    n = I()
    a = deque(LI())
    if n==0:
        if a[0] == 1:
            print(1)
            exit()
        else:
            end()
    elif a[0]!=0:
        end()

    b = [0]*(n+1)
    for i in range(n,-1,-1):
        if i == n:
            b[i] = a[i]
        else:
            b[i] = min(b[i+1]+a[i],2**i)

    for i in range(n+1):
        if i!=0:
            b[i] = min(2*(b[i-1]-a[i-1]),b[i])
        if b[i]<a[i]:
            end()
    print(sum(b))
    return
 
if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(10**6)
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def BFS(n,m,table,dist):
    next = deque([0])
    while next:
        tmp = next.popleft()
        for j in range(n):
            if table[tmp][j] and dist[j]==-1:
                table[tmp][j] = table[j][tmp] = 0
                dist[j] = tmp+1
                next.append(j)
    return not -1 in dist

def main():
    n,m = IL()
    table = [[0]*n for _ in range(n)]
    for _ in range(m):
        a,b = IL()
        table[a-1][b-1] = table[b-1][a-1] = 1
    dist = [-1]*n
    dist[0] = 0
    if BFS(n,m,table,dist):
        print('Yes')
        for i in range(1,len(dist)):
            print(dist[i])
    else:  print('No')
    return

if __name__=='__main__':
    main()

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10**6)
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def BFS(n,m,table,dist):
    next = deque([0])
    while next:
        tmp = next.popleft()
        for rep in table[tmp]:
            if dist[rep]==-1:
                dist[rep] = tmp+1
                next.append(rep)
    return not -1 in dist

def main():
    n,m = IL()
    table = [[] for _ in range(n)]
    for _ in range(m):
        a,b = IL()
        table[a-1].append(b-1)
        table[b-1].append(a-1)
    dist = [-1]*n
    dist[0] = 0
    if BFS(n,m,table,dist):
        print('Yes')
        for i in range(1,len(dist)):
            print(dist[i])
    else:  print('No')
    return

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    a,b,c,k = IL()
    l = [1]*a+[0]*b+[-1]*c
    print(sum(l[:k]))
    return

if __name__=='__main__':
    Main()

Fixed submission:
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    a,b,c,k = IL()
    ta = min(k,a)
    tb = min(k-ta,b)
    if tb<0:    tb = 0
    tc = k-ta-tb
    print(ta-tc)
    return

if __name__=='__main__':
    Main()

Buggy python submission (verdict: Runtime Error):
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    a,b,c,k = IL()
    l = [1]*a+[0]*b+[-1]*c
    print(sum(l[:k]))
    return

if __name__=='__main__':
    Main()

Fixed submission:
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    a,b,c,k = IL()
    ta = min(k,a)
    tb = min(k-ta,b)
    if tb<0:    tb = 0
    tc = k-ta-tb
    print(ta-tc)
    return

if __name__=='__main__':
    Main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,x,y = IL()
    x -= 1
    y -= 1
    dist = np.zeros(n-1,dtype='int32')
    for i in range(n):
        for j in range(i+1,n):
            tmp = min(abs(j-i),abs(j-x)+abs(x-i),abs(y-j)+abs(x-i)+1)
            dist[tmp-1] += 1
    for rep in dist:
        print(rep)
    return

if __name__=='__main__':
    Main()

Fixed submission:
import sys
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,x,y = IL()
    x -= 1
    y -= 1
    dist = [0]*(n-1)
    for i in range(n):
        for j in range(i+1,n):
            dist[min(abs(j-i),abs(j-x)+abs(x-i),abs(y-j)+abs(x-i)+1)-1] += 1
    for rep in dist:
        print(rep)
    return

if __name__=='__main__':
    Main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    f = math.ceil(m/1.08)
    if math.floor(f*1.08)==n:
        print(f)
    else:
        print(':(')
    return

if __name__=='__main__':
    n = I()
    solve()

Fixed submission:
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    f = math.ceil(n/1.08)
    if math.floor(f*1.08)==n:
        print(f)
    else:
        print(':(')
    return

if __name__=='__main__':
    n = I()
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()
ls = list(s)
l = []

tmp = ''
for i in range(len(ls)):
    if len(l)<1:
        l.append(ls.pop(0))
    else:
        tmp += ls.pop(0)
        if tmp != l[len(l)-1]:
            l.append(tmp)
            tmp = ''
        else:
            if i == len(l)-1:
                a = l.pop()
                l.append(a+tmp)

print(len(l))

Fixed submission:
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()
ls = list(s)
l = []

tmp = ''
k = 0
for i in ls:
    k += 1
    if len(l)<1:
        l.append(i)
    else:
        tmp += i
        if tmp != l[len(l)-1]:
            l.append(tmp)
            tmp = ''
        else:
            if k == len(ls):
                a = l.pop()
                tmp = a+tmp
                l.append(tmp)

print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()
ls = list(s)
l = []

while 0<len(ls):
    if len(l)<1:
        l.append(ls.pop(0))
    else:
        tmp = ls.pop(0)
        while tmp == l[len(l)-1]:
            if 0<len(ls):
                tmp += ls.pop(0)
            else:
                a = l.pop()
                tmp = a + tmp
                break
        l.append(tmp)

print(len(l))

Fixed submission:
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()
ls = list(s)
l = []

tmp = ''
k = 0
for i in ls:
    k += 1
    if len(l)<1:
        l.append(i)
    else:
        tmp += i
        if tmp != l[len(l)-1]:
            l.append(tmp)
            tmp = ''
        else:
            if k == len(ls):
                a = l.pop()
                tmp = a+tmp
                l.append(tmp)

print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()
ls = list(s)
l = []

while 0<len(ls):
    if len(l)<1:
        l.append(ls.pop(0))
    else:
        tmp = ls.pop(0)
        while tmp == l[len(l)-1]:
            if 0<len(ls):
                tmp += ls.pop(0)
            else:
                a = l.pop()
                tmp = a + tmp
                break
        l.append(tmp)

print(len(l))

Fixed submission:
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()
ls = list(s)
l = []

tmp = ''
k = 0
for i in ls:
    k += 1
    if len(l)<1:
        l.append(i)
    else:
        tmp += i
        if tmp != l[len(l)-1]:
            l.append(tmp)
            tmp = ''
        else:
            if k == len(ls):
                a = l.pop()
                tmp = a+tmp
                l.append(tmp)

print(len(l))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def S(): return sys.stdin.readline().rstrip()

def Main():
    s = S()
    n = len(s)
    times = 10**100
    ans = [0]*n
    for i in range(n):
        current = i
        char = s[i]
        if char=='R':
            vec = 1
        else:
            vec = -1

        for rep in range(times):
            if s[current+vec] != char:  break
            current += vec
            
        nx = (times-rep)%2
        ans[current+vec*nx] += 1
    print(*ans)
    return

if __name__=='__main__':
    Main()

Fixed submission:
import sys
def S(): return sys.stdin.readline().rstrip()

def Main():
    s = S()
    n = len(s)
    times = 10**100
    ans = [0]*n
    i = 0
    while i<n:
        if s[i]=='L':
            i += 1
            continue
        save = [i]
        while s[i+1]!='L':
            i += 1
            save.append(i)
        flg = save.pop()
        ans[flg] += 1
        for j in range(len(save)):
            tmp = save.pop()
            ans[flg+abs(flg-tmp)%2] += 1
        i += 1
    
    i = n-1
    while 0<=i:
        if s[i]=='R':
            i -= 1
            continue
        save = [i]
        while s[i-1]!='R':
            i -= 1
            save.append(i)
        flg = save.pop()
        ans[flg] += 1
        for j in range(len(save)):
            tmp = save.pop()
            ans[flg-abs(flg-tmp)%2] += 1
        i -= 1
    print(*ans)
    return

if __name__=='__main__':
    Main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def S(): return sys.stdin.readline().rstrip()

def Main():
    s = S()
    n = len(s)
    times = 10**100
    ans = [0]*n
    for i in range(n):
        current = i
        char = s[i]
        if char=='R':
            vec = 1
        else:
            vec = -1

        for rep in range(times):
            if s[current+vec] != char:  break
            current += vec
            
        nx = (times-rep)%2
        ans[current+vec*nx] += 1
    print(*ans)
    return

if __name__=='__main__':
    Main()

Fixed submission:
import sys
def S(): return sys.stdin.readline().rstrip()

def Main():
    s = S()
    n = len(s)
    times = 10**100
    ans = [0]*n
    i = 0
    while i<n:
        if s[i]=='L':
            i += 1
            continue
        save = [i]
        while s[i+1]!='L':
            i += 1
            save.append(i)
        flg = save.pop()
        ans[flg] += 1
        for j in range(len(save)):
            tmp = save.pop()
            ans[flg+abs(flg-tmp)%2] += 1
        i += 1
    
    i = n-1
    while 0<=i:
        if s[i]=='R':
            i -= 1
            continue
        save = [i]
        while s[i-1]!='R':
            i -= 1
            save.append(i)
        flg = save.pop()
        ans[flg] += 1
        for j in range(len(save)):
            tmp = save.pop()
            ans[flg-abs(flg-tmp)%2] += 1
        i -= 1
    print(*ans)
    return

if __name__=='__main__':
    Main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def S(): return sys.stdin.readline().rstrip()

if __name__=='__main__':
    sl = list(S())
    flag = True
    c = 0
    while flag:
        flag = False
        for i in range(0,len(sl)-1):
            if sl[i]=='B' and sl[i+1]=='W':
                sl[i],sl[i+1] = 'W','B'
                c += 1
                flag = True

    print(c)
    exit()

Fixed submission:
import sys
def S(): return sys.stdin.readline().rstrip()

if __name__=='__main__':
    sl = list(S())
    ans = 0
    c = 0
    for i,item in enumerate(sl):
        if item=='W':
            ans += c
        else:
            c += 1

    print(ans)
    exit()