Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,s=open(0)
a=0
for i in range(int(n)):
 if N-i<a:break
 a+=s[i+1:].find(s[i-a:i+1])>=0
print(a)

Fixed submission:
def Z(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = c = 0
    # c : 最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        # i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP

a = 0
n, s = open(0)
for i in range(int(n)):
    for j, l in enumerate(Z(s[i:])):
        a = max(a, min(l, j))
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
def Z(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = c = 0
    # c : 最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        # i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP

a = 0
n, s = open(0)
for i in range(int(n)):
    for j, l in enumerate(Z(s[i:])):
        a = max(a, min(l, j))
print(a)

Fixed submission:
def Z(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = c = 0
    # c : 最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        # i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP

a = 0
n, s = open(0)
for i in range(int(n)):
    for j, l in enumerate(Z(s[i:])):
        a = max(a, min(l, j))
print(a)
Buggy python submission (verdict: Runtime Error):
n, *b = map(int, open(0).read().split())
a = [0]*n
b += float("inf")
for i in range(n):
  a[i] = min(b[i-1], b[i])
print(sum(a))

Fixed submission:
n, *b = map(int, open(0).read().split())
a = [0]*n
b.append(float("inf"))
for i in range(n):
  a[i] = min(b[i-1], b[i])
print(sum(a))
Buggy python submission (verdict: Runtime Error):
print(red if int(input()) < 3200 else input())

Fixed submission:
print("red" if int(input()) < 3200 else input())
Buggy python submission (verdict: Runtime Error):
_ = input()
print(f"{(1 / sum(1 / x for x in map(int, input().split()))):.16g}")

Fixed submission:
_ = input()
print("{:.16g}".format(1 / sum(1 / x for x in map(int, input().split()))))
Buggy python submission (verdict: Runtime Error):
k = 0
s = t = ""
for i in input():
	s += i
    if s != t:
		k += 1
		s, t = "", s
print(k)


Fixed submission:
c = 0
s = f = ""
for i in input():
  s += i
  if s != f:
    c += 1
    s, f = "", s
print(c)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations as c
n, *d = map(sorted, open(0).read().split())
print(sum(d[i[0]] == d[i[1]] for i in c(range(int(*n)), 2)))

Fixed submission:
d = {}
c = 0
for i in open(0):
    i = str(sorted(i))
    t = d.get(i, 0)
    c += t
    d[i] = t + 1
print(c)
Buggy python submission (verdict: Runtime Error):
from itertools import*
for p, q in zip(*[len(list(l)) for _, l in groupby(input())]*2):
    print("0 "*~-p, -~p//2 + q//2, p//2 + -~q//2, "0 "*~-q, end="")

Fixed submission:
from itertools import*
a = [len(list(l)) for _, l in groupby(input())]
for p, q in zip(a[::2], a[1::2]):
    print("0 "*~-p, -~p//2 + q//2, p//2 + -~q//2, "0 "*~-q, end="")
Buggy python submission (verdict: Runtime Error):
n, *p = map(int, open(0).read().split())
t = 0
for i in range(n):
    t += 1 if p[i] != sorted(p)[i] 
print("YES" if t == 0 or t == 2 else "NO")

Fixed submission:
n, *p = map(int, open(0).read().split())
t = 0
for i in range(n):
    t += p[i] != sorted(p)[i]
print("YES" if t == 0 or t == 2 else "NO")
Buggy python submission (verdict: Runtime Error):
_, *a = map(int, open(0).read().split())
s = sorted(a)
for i in a:
    print(s[(i < b[-1])-2])

Fixed submission:
_, *a = map(int, open(0).read().split())
s = sorted(a)
for i in a:
    print(s[(i < s[-1])-2])
Buggy python submission (verdict: Runtime Error):
_, *a = map(int, open(0).read().split())
for b in a:z ^= b
print("YNeos"[z>0])

Fixed submission:
_, *a = map(int, open(0).read().split());z = 0
for b in a:z ^= b
print("YNeos"[z>0::2])
Buggy python submission (verdict: Runtime Error):
x, y = map(int,input().split())
print([x, -1][x%y])

Fixed submission:
l, r = map(int,input().split())
s = range(l, r+1)[:673]
print(min(i*j % 2019 for i in s for j in s if i<j))
Buggy python submission (verdict: Runtime Error):
n, *p = map(int, open(0).read().split())
for i in range(2, n):
    t = p[i-2:i+1]
    c += sorted(t)[1] == t[1]
print(c)

Fixed submission:
n, *p = map(int, open(0).read().split())
c = 0
for i in range(2, n):
    t = p[i-2:i+1]
    c += sorted(t)[1] == t[1]
print(c)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
from math import factorial as f
n, k = map(int, input().split())
mod = 10**9+7
for i in range(k):
    print(f(n - k + 1) * f(k - 1) // f(i + 1) // f(n - k - i) // f(i) // f(k - i - 1) % mod)

Fixed submission:
#!/usr/bin/env python3
from math import factorial as f
n, k = map(int, input().split())
mod = 10**9+7
for i in range(k):
    try:
        print(f(n - k + 1) * f(k - 1) // f(i + 1) // f(n - k - i) // f(i) // f(k - i - 1) % mod)
    except ValueError:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

mod = 10**9+7

dp = [0] * -~n
dp[0] = 1
dp[1] = 0 + (1 not in a)

for i in range(2, -~n):
    if i in a:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % mod

print(dp[n])

Fixed submission:
n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

mod = 10**9+7

dp = [0] * -~n
dp[0] = 1
dp[1] = 0 + (1 not in a)

for i in range(2, -~n):
    if i in a:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % mod

print(dp[n])

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, m = map(int, input().split())
a = eval("int(input()),"*m)
f = lambda j: j not in a

mod = 10**9+7

dp = [0] * -~n
dp[0] = 1
dp[1] = f(1)

for i in range(2, -~n):
    dp[i] += (dp[i - 1] + dp[i - 2]) * f(i) % mod

print(dp[n])

Fixed submission:
n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

mod = 10**9+7

dp = [0] * -~n
dp[0] = 1
dp[1] = 0 + (1 not in a)

for i in range(2, -~n):
    if i in a:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % mod

print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
s = [[*map(lambda c:c == ".", input())] for _ in [0] * h]
for i in "LRUD":
    exec(i + "= [[0] * w for _ in [0] * h]")
for i in range(h):
    for j in range(w):
        L[i][j]    = L[i][j-1] + 1 if s[i][j]    else 0
        R[i][-j-1] = R[i][-j]  + 1 if s[i][-j-1] else 0
for j in range(w):
    for i in range(h):
        U[i][j]    = U[i-1][j] + 1 if s[i][j]    else 0
        D[-i-1][j] = D[-i][j]  + 1 if s[-i-1][j] else 0
print(max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3 for i in range(h) for j in range(w)))

Fixed submission:
h, w = map(int, input().split())
s = [[*map(lambda c:c == ".", input())] for _ in [0] * h]
for i in "LRUD":
    exec(i + "= [[0] * w for _ in [0] * h]")
for i in range(h):
    for j in range(w):
        L[i][j]    = L[i][j-1] + 1 if s[i][j]    else 0
        R[i][-j-1] = R[i][-j]  + 1 if s[i][-j-1] else 0
for j in range(w):
    for i in range(h):
        U[i][j]    = U[i-1][j] + 1 if s[i][j]    else 0
        D[-i-1][j] = D[-i][j]  + 1 if s[-i-1][j] else 0
print(max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3 for i in range(h) for j in range(w)))
Buggy python submission (verdict: Runtime Error):
_, __, *d = map(int, open(0).read().split())
print(max(min(d[1::2]) - max(d[::2]) + 1), 0)

Fixed submission:
_, __, *d = map(int, open(0).read().split())
print(max(min(d[1::2]) - max(d[::2]) + 1, 0))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import*
I=lambda:map(int,input().split())
n,m=I()
a=Counter(I())
exec("b,c=I();a[c]+=b;"*m)
s=0
for k,v in sorted(a.items())[::-1]:
 if n<v:exit(print(s+k*n))
 n-=v;s+=k*v

Fixed submission:
from collections import Counter
n, m, *d = map(int, open(0).read().split())
a = Counter(d[:n])
for b, c in zip(d[n::2], d[n+1::2]):
    a[c] += b
ans = 0
for k, v in sorted(a.items())[::-1]:
    if n < v:
        exit(print(ans + k * n))
    n -= v
    ans += k * v

Buggy python submission (verdict: Runtime Error):
from collections import*
I=lambda:map(int,input().split())
n,m=I()
a=Counter(I())
exec("b,c=I();a[c]+=b"*m)
s=0
for k,v in sorted(a.items())[::-1]:
 if n<v:exit(print(s+k*n))
 n-=v;s+=k*v

Fixed submission:
from collections import Counter
n, m, *d = map(int, open(0).read().split())
a = Counter(d[:n])
for b, c in zip(d[n::2], d[n+1::2]):
    a[c] += b
ans = 0
for k, v in sorted(a.items())[::-1]:
    if n < v:
        exit(print(ans + k * n))
    n -= v
    ans += k * v

Buggy python submission (verdict: Runtime Error):
from collections import＊
n,m,*d=map(int,open(0).read().split())
a=Counter(d[:n])
for b,c in zip(d[n::2],d[n+1::2]):a[c]+=b
s=0
for k, v in sorted(a.items())[::-1]:
 if n<v:exit(print(s+k*n))
 n-=v
 s+=k*v

Fixed submission:
from collections import Counter
n, m, *d = map(int, open(0).read().split())
a = Counter(d[:n])
for b, c in zip(d[n::2], d[n+1::2]):
    a[c] += b
ans = 0
for k, v in sorted(a.items())[::-1]:
    if n < v:
        exit(print(ans + k * n))
    n -= v
    ans += k * v
Buggy python submission (verdict: Runtime Error):
_, k, s = map(int, open(0).read().split())
s[k-1] = chr(ord(s[k-1])+26)
print(s)

Fixed submission:
k = int(input()[2:])
s = list(input())
s[k-1] = chr(ord(str(s[k-1])) + 32)
print("".join(s))

Buggy python submission (verdict: Runtime Error):
_, k, s = map(int, open(0).read().split())
s[k-1] ==chr(ord(s[k-1])+26)
print(s)

Fixed submission:
k = int(input()[2:])
s = list(input())
s[k-1] = chr(ord(str(s[k-1])) + 32)
print("".join(s))

Buggy python submission (verdict: Runtime Error):
_, k, s = map(int, open(0).read().split())
s[k-1] == chr(ord(s[k-1])+26)
print(s)

Fixed submission:
k = int(input()[2:])
s = list(input())
s[k-1] = chr(ord(str(s[k-1])) + 32)
print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, n = map(int, input().split())
a, s = range(n+1), 0
for r in a:
  for g in a:
    b = (n-r*R-g*G)/B
    s += b.is_integer() and b >= 0
print(s)

Fixed submission:
R, G, B, n = map(int, input().split())
a, s = range(n+1), 0
for r in a:
  for g in a:
    b = (n-r*R-g*G)/B
    s += b.is_integer() and b >= 0
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, n = map(int, input().split())
a, s = range(n+1), 0
for r in a:
  for g in a:
    b = (n-r*R-g*G)/B
    s += b.is_integer() and b >= 0
print(s)

Fixed submission:
R, G, B, n = map(int, input().split())
a, s = range(n+1), 0
for r in a:
  for g in a:
    b = (n-r*R-g*G)/B
    s += b.is_integer() and b >= 0
print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = [map(int, input().split())]
c = [map(int, input().split())]
print(sum([max(v[i] - c[i], 0) for i in range(n)]))

Fixed submission:
n, *d = map(int, open(0).read().split())
print(sum([max(d[i] - d[i+n], 0) for i in range(n)]))
Buggy python submission (verdict: Runtime Error):
from itertools as f;from fractions import*;c=lambda l:list(f.accumulate([0]+l,gcd));_,a=open(0);*a,=map(int,a.split());print(max(gcd(s,t)for s,t in zip(c(a),c(a[::-1])[-2::-1])))

Fixed submission:
#!/usr/bin/env python3
from itertools import*
from fractions import*
ac = lambda l: list(accumulate([0] + l, gcd))
n, *a = map(int, open(0).read().split())
print(max(gcd(s, t) for s, t in zip(ac(a), ac(a[::-1])[::-1][1:])))
Buggy python submission (verdict: Runtime Error):
_, *a = map(int, open(0).read().split())
t = map(abs, a)
s = sum(t)
print(s if len([i for i in a if i<0])%2==0 or 0 in a else s-min(t))

Fixed submission:
_, *a = map(int, open(0).read().split())
*z, = map(abs, a)
s = sum(z)
print(s if len([i for i in a if i<0])%2==0 or 0 in a else s-min(z)*2)
Buggy python submission (verdict: Runtime Error):
*t, = map(int, open(0).read().split())
try:
    m = 10 - min([i%10 for i in t if i%10])
except Value Error:
    m = 0
print(sum([-(-j // 10) for j in t])*10 - m)

Fixed submission:
*t, = map(int, open(0).read().split())
try:
    m = 10 - min([i%10 for i in t if i%10])
except ValueError:
    m = 0
print(sum([-(-j // 10) for j in t])*10 - m)

Buggy python submission (verdict: Runtime Error):
*t, = map(int, open(0).read().split())
m = min([i%10 for i in t if i%10])
print(sum([-(-j // 10) for j in t])*10-10+m)

Fixed submission:
*t, = map(int, open(0).read().split())
try:
    m = 10 - min([i%10 for i in t if i%10])
except ValueError:
    m = 0
print(sum([-(-j // 10) for j in t])*10 - m)
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
t = [0] * n
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i:i+2] == "AC" else 0)
for _ in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Fixed submission:
#!/usr/bin/env python3
n, q = map(int, input().split())
s = input()
t = [0] * -~n
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i:i+2] == "AC" else 0)
for _ in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
l = [0]*10**6
l[0] = input()
i = 1

while True:
    l[i] = l[i-1].replace("10", "").replace("01","")
    if "10" not in l[i] and "01" not in l[i]:
        print(len(l[0]) - len(l[i]))
        exit()
    i += 1

Fixed submission:
s = input()
print(min(s.count("1"), s.count("0")) *2)
Buggy python submission (verdict: Runtime Error):
print(eval("".join(open(0).readlines()[1:]).replace(" JPY", "").replace(" BTC","*380000").replace("\n", "+")))

Fixed submission:
print(sum(eval(input().replace(" JPY", "").replace(" BTC","*380000")) for _ in range(int(input()))))

Buggy python submission (verdict: Runtime Error):
print(eval("".join(open(0).readlines()[1:]).replace(" JPY", "").replace(" BTC","*380000").replace("\n", "+")))

Fixed submission:
print(sum(eval(input().replace(" JPY", "").replace(" BTC","*380000")) for _ in range(int(input()))))
Buggy python submission (verdict: Runtime Error):
from collections import*
print("YNEOS"[Counter(open(0).read().split()).most_comon()[0][1]!=3::2])

Fixed submission:
from collections import*
print("YNEOS"[Counter(open(0).read().split()).most_common()[0][1]==3::2])
Buggy python submission (verdict: Time Limit Exceeded):
n, *d = map(int, open(0).read().split())
s = [b-a for a,b in zip(d[:n],d[n:]) if b>a]
m = c = 0
if s:
  for i in sorted(a-b for a,b in zip(d[:n],d[n:]) if a>=b)[::-1]:
    m += i
    c += 1
    if sum(s)<=m:
      print(len(s)+c)
      exit()
  print(-1)
else:
  print(0)

Fixed submission:
n,*d=map(int,open(0).read().split())
f=[d[i]-d[n+i]for i in range(n)]
m=[v for v in f if v<0];p=sorted(v for v in f if v>0)
c=len(m);s=sum(m)
while s<0and p:s+=p.pop();c+=1
print([c,-1][s<0])
Buggy python submission (verdict: Runtime Error):
n, k, *h = map(int, open(0).read().split())
dp = [0] + [float("inf")] * 100200
for i in range(1, n):
  dp[i] = min(dp[i-a] + abs(h[i] - h[i-a]) for a in range(1, k + 1))
print(dp[n - 1])

Fixed submission:
n, k, *h = map(int, open(0).read().split())
h += [0] * 200
dp = [0] + [float("inf")] * 100200
for i in range(1, n):
  dp[i] = min(dp[i-a] + abs(h[i] - h[i-a]) for a in range(1, k + 1))
print(dp[n - 1])
Buggy python submission (verdict: Time Limit Exceeded):
(N, W), *D = [list(map(int, o.split())) for o in open(0)]
w, v = 0, 1
dp = [[0]*-~W for _ in [0]*-~N]
for i in range(N):
  for j in range(W + 1):
    dp[i + 1][j] = max(dp[i][j], (dp[i][j - D[i][w]] + D[i][v])*(j >= D[i][w]))
print(dp[N][W])

Fixed submission:
(N, W), *D = [list(map(int, o.split())) for o in open(0)]
w, v = 0, 1
dp = [[0]*-~W for _ in [0]*-~N]
for i in range(N):
  for j in range(W + 1):
    dp[i + 1][j] = max(dp[i][j], (dp[i][j - D[i][w]] + D[i][v])*(j >= D[i][w]))
print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
s, t = input(), input()
n, m = len(s), len(t)
dp = [[0]*-~m for _ in [0]*-~n]
for i in range(n):
  for j in range(m):
    dp[i+1][j+1] = dp[i][j] + 1 if s[i] == t[j] else max(dp[i][j+1], dp[i+1][j])
R = ""
while n and m:
  if   dp[n][m] == dp[n-1][m]:n -= 1
  elif dp[n][m] == dp[n][m-1]:m -= 1
  else:n -= 1;m -= 1;R = s[n] + R
print(R)

Fixed submission:
s, t = input(), input()
n, m = len(s), len(t)
dp = [[0]*-~m for _ in [0]*-~n]
for i in range(n):
  for j in range(m):
    dp[i+1][j+1] = dp[i][j] + 1 if s[i] == t[j] else max(dp[i][j+1], dp[i+1][j])
R = ""
while n and m:
  if   dp[n][m] == dp[n-1][m]:n -= 1
  elif dp[n][m] == dp[n][m-1]:m -= 1
  else:n -= 1;m -= 1;R = s[n] + R
print(R)

Buggy python submission (verdict: Runtime Error):
s, t = input(), input()
n, m = len(s), len(t)
dp = [[0]*-~m for _ in [0]*-~n]
for i in range(n):
  for j in range(m):
    dp[i+1][j+1] = dp[i][j] + 1 if s[i] == t[j] else max(dp[i][j+1], dp[i+1][j])
R = ""
while n and m:
  n -= dp[n][m] != dp[n][m-1]
  m -= dp[n][m] != dp[n-1][m]
  R = s[n] + R
print(R)

Fixed submission:
s, t = input(), input()
n, m = len(s), len(t)
dp = [[0]*-~m for _ in [0]*-~n]
for i in range(n):
  for j in range(m):
    dp[i+1][j+1] = dp[i][j] + 1 if s[i] == t[j] else max(dp[i][j+1], dp[i+1][j])
R = ""
while n and m:
  if   dp[n][m] == dp[n-1][m]:n -= 1
  elif dp[n][m] == dp[n][m-1]:m -= 1
  else:n -= 1;m -= 1;R = s[n] + R
print(R)
Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int,input().split());a=1;print(n<2and p or exec("for i in range(2,int(p**.5)+1):\n while p%(i**n)<1:a*=i;p//=i**n")or a)

Fixed submission:
n,p=map(int,input().split());a=1
print(n<2and p or exec("for i in range(2,int(p**(1./n))+1):\n while p%(i**n)<1:a*=i;p//=i**n")or a)

Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int,input().split());a=1
for i in range(2,int(p**(1./n))+1):
 while p%(i**n)<1:a*=i;p//=i**n
print(a)

Fixed submission:
n,p=map(int,input().split());a=1
print(n<2and p or exec("for i in range(2,int(p**(1./n))+1):\n while p%(i**n)<1:a*=i;p//=i**n")or a)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n, p = map(int, input().split())
k = c = f = 1
while f <= p:
    if p % f == 0:
        k = c
    c += 1
    f = c**n
print(k)

Fixed submission:
n,p=map(int,input().split());a=1
print(n<2and p or exec("for i in range(2,int(p**(1./n))+1):\n while p%(i**n)<1:a*=i;p//=i**n")or a)
Buggy python submission (verdict: Runtime Error):
_, *a = open(0)
print(["second","first"][any(int(b)%2 for b in a)]

Fixed submission:
_, *a = open(0)
print(["second","first"][any(int(b)%2 for b in a)])
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
print(sum(s[:i].count("B") for i in range(len(s)) if s[i]=="W"))

Fixed submission:
c = b = 0
for s in input():
  c += b*(s=="W")
  b += s=="B"
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
print(sum(s[:i].count("B") for i in range(len(s)) if s[i]=="W"))

Fixed submission:
c = b = 0
for s in input():
  c += b*(s=="W")
  b += s=="B"
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
print(sum(s[:i].count("B") for i in range(len(s)) if s[i]=="W"))


Fixed submission:
c = b = 0
for s in input():
  c += b*(s=="W")
  b += s=="B"
print(c)

Buggy python submission (verdict: Runtime Error):
s = input()
print(sum(s[:i].count("B") for i in range(len(s)) if s[i]=="W")

Fixed submission:
c = b = 0
for s in input():
  c += b*(s=="W")
  b += s=="B"
print(c)
Buggy python submission (verdict: Runtime Error):
print(eval(input().replace(" ", +) + "//2"))

Fixed submission:
print(eval(input().replace(" ", "+") + "//2"))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
N = int(input())
a = sorted(int(input()) for _ in [0]*N)
n = N//2 - 1
print(2*sum(a[n+2:]) - 2*sum(a[:n]) + a[n+1] - a[n] - [0, min(a[n]+a[n+2], 2*a[n+1])][N%2])

Fixed submission:
#!/usr/bin/env python3
N, *a = map(int, open(0))
n = N//2 - 1
a.sort()
print(2*sum(a[n+2:]) - 2*sum(a[:n]) + a[n+1] - a[n] - (min(a[n]+a[n+2], 2*a[n+1]) if N%2 else 0))

Buggy python submission (verdict: Runtime Error):
N,*a=map(int,open(0));n=N//2-1;a.sort();print(2*sum(a[n+2:])-2*sum(a[:n])+a[n+1]-a[n]-[0,min(a[n]+a[n+2],2*a[n+1])][N%2])

Fixed submission:
#!/usr/bin/env python3
N, *a = map(int, open(0))
n = N//2 - 1
a.sort()
print(2*sum(a[n+2:]) - 2*sum(a[:n]) + a[n+1] - a[n] - (min(a[n]+a[n+2], 2*a[n+1]) if N%2 else 0))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
N, *a = map(int, open(0))
n = N//2 - 1
a.sort()
print(2*sum(a[n+2:]) - 2*sum(a[:n]) + a[n+1] - a[n] - [0, min(a[n]+a[n+2], 2*a[n+1])][N%2])

Fixed submission:
#!/usr/bin/env python3
N, *a = map(int, open(0))
n = N//2 - 1
a.sort()
print(2*sum(a[n+2:]) - 2*sum(a[:n]) + a[n+1] - a[n] - (min(a[n]+a[n+2], 2*a[n+1]) if N%2 else 0))

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0));n=n//2-1;a.sort();print(2*sum(a[n+2:])-2*sum(a[:n])+a[n+1]-a[n]-[0,min(a[n]+a[n+2],2*a[n+1])][n%2])

Fixed submission:
#!/usr/bin/env python3
N, *a = map(int, open(0))
n = N//2 - 1
a.sort()
print(2*sum(a[n+2:]) - 2*sum(a[:n]) + a[n+1] - a[n] - (min(a[n]+a[n+2], 2*a[n+1]) if N%2 else 0))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, *a = map(int, open(0))
n = n//2 - 1;a.sort()
print(2*sum(a[n+2:]) - 2*sum(a[:n]) + a[n+1] - a[n] - [0, min(a[n]+a[n+2], 2*a[n+1])][n%2])

Fixed submission:
#!/usr/bin/env python3
N, *a = map(int, open(0))
n = N//2 - 1
a.sort()
print(2*sum(a[n+2:]) - 2*sum(a[:n]) + a[n+1] - a[n] - (min(a[n]+a[n+2], 2*a[n+1]) if N%2 else 0))
Buggy python submission (verdict: Runtime Error):
A=abs
h,y,x=max([list(map(int,t.split()[::-1]))for t in open(0)][1:])
r=range(101)
for i in r:
 for j in r:H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for u,t,s in p))

Fixed submission:
#!/usr/bin/env python3
a = abs
z = [list(map(int, input().split())) for _ in range(int(input()))]
z.sort(key = lambda x: x[2])
x, y, h = z[-1]
r = range(101)
for c in r:
    for d in r:
        H = h + a(c-x) + a(d-y)
        if all(u == max(H - a(s-c) - a(t-d), 0) for s, t, u in z):
            print(c, d, H)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split());print(next(v for v in range(m//n,-1,-1)if m%v<1))

Fixed submission:
#!/usr/bin/env python3
n, m = map(int, input().split())
print(next(v for v in range(m // n, -1, -1) if m % v == 0))
Buggy python submission (verdict: Runtime Error):
from collections import*
n, *v = map(int, open(0).read().split())
a, b = [Counter(v[i::2]).most_common() + [(0,0)] for i in (0,1)]
s, x = a[0]
t, y = b[0]
print(n - [x+y, max(x+b[1][1], y+a[1][1])][s==t])

Fixed submission:
print(1110 - int(input()))
Buggy python submission (verdict: Runtime Error):
from collections import*
n, v = map(int, open(0).read().split())
def l(x):
    o = Counter(x).most_common()
    return [o[0][0], o[0][1], o[1][1]]
a, b = map(l, [v[::2], v[1::2]])
print(n-a[1]-b[1] if a[0]!=a[0] else n - max(a[1]+b[2], a[2]+b[1])


Fixed submission:
from collections import*
n, *v = map(int, open(0).read().split())
a, b = [Counter(v[i::2]).most_common() + [(0,0)] for i in (0,1)]
s, x = a[0]
t, y = b[0]
print(n - [x+y, max(x+b[1][1], y+a[1][1])][s==t])
Buggy python submission (verdict: Runtime Error):
n, *l = open(0).read().split()
print("Yes" if len(set(l)) == len(l) and all(l[i][-1] == l[i+1][0] for i in range(n)) else "No")

Fixed submission:
n, *l = open(0).read().split()
print("Yes" if len(set(l)) == len(l) and all(l[i][-1] == l[i+1][0] for i in range(int(n)-1)) else "No")