Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03472 (python)

Fixed submission:
N,H = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
A,B = zip(*AB)

a = max(A) #振る
B = [b for b in B if b > a] #投げる
B.sort(reverse = True)

answer = 0
hp = H
attack_cnt = 0

for b in B:
  if hp <= 0:
    break
  attack_cnt += 1
  hp -= b

if hp > 0:
  attack_cnt += (hp-1)//a + 1

print(attack_cnt)

Buggy submission (verdict: Runtime Error):
N,H = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(n)]
A,B = zip(*AB)

a = max(A)
B = [b for b in B if b > a] #投げる
B.sort(reverse = True)

answer = 0
hp = H
attack_cnt = 0

for b in B:
  if hp <= 0:
    break
  attack_cnt += 1
  hp -= b

if hp > 0:
  attack_cnt += (hp-1)//a + 1

print(attack_cnt)

Buggy submission (verdict: Runtime Error):
N,H = map(int,input().split())
AB = [[int(input().split())] for _ in range(N)]
A,B = zip(*AB)

a = max(A)
B = [b for b in B if b > a] #投げる
B.sort(reverse = True)

answer = 0
hp = H
attack_cnt = 0

for b in B:
  if hp <= 0:
    break
  attack_cnt += 1
  hp -= b

if hp > 0:
  attack_cnt += (hp-1)//a + 1

print(attack_cnt)

Buggy submission (verdict: Runtime Error):
N,H = map(int,input().split())
AB = [[map(int,input().split())] for _ in range(N)]
A,B = zip(*AB)

a = max(A)
B = [b for b in B if b > a] #投げる
B.sort(reverse = True)

answer = 0
hp = H
attack_cnt = 0

for b in B:
  if hp <= 0:
    break
  attack_cnt += 1
  hp -= b

if hp > 0:
  attack_cnt += (hp-1)//a + 1

print(attack_cnt)
Problem p03473 (python)

Fixed submission:
n =int(input())
print(48-n)

Buggy submission (verdict: Runtime Error):
print(48-{})
Problem p03474 (python)

Fixed submission:
a,b = map(int,input().split())
s = str(input())
if s.count('-') == 1 and s[a] == '-':
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b = map(str,input().split())
s = str(input())
if s.count('-') == 1 and s[a+1] == '-':
    print('Yes')
else:
  print('No')
Problem p03479 (python)

Fixed submission:
x,y = map(int, input().split())
cnt = 1
while x*2 ** cnt <= y:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
ans = 0
for i in range():
  if a*(i+1) <= b:
    ans += 1
  else:
    quit()
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
ans = -1
for i in range():
  if a*i <= b:
    ans += 1
  else:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
ans = 0
for i in range():
  if a*i <= b:
    ans += 1
  else:
    break
print(ans)
Problem p03493 (python)

Fixed submission:
print(input().count('1'))

Buggy submission (verdict: Runtime Error):
s = int(input())
print(s.count('1'))
Problem p03494 (python)

Fixed submission:
import math

n = input()
a = list(map(int,input().split()))
ans = float('inf')
for i in a:
    ans = min(ans,len(bin(i)) - bin(i).rfind('1') - 1)
print(round(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [map(int,input().split())]
ans = 0
While True:
  for i in range(n):
    A[i] == A[i]/2
    if A[i] % 2 !=0:
      break
  ans += 1
  
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = input()
a = list(map(int,input().split()))
ans = float('inf')
for i in a:
    ans = min(ans,len(bin(i) - bin(i).rfind('1') - 1)
              print(round(ans))
Problem p03502 (python)

Fixed submission:
N = input()
h = 0
for i in range(len(N)):
  h += int(N[i])
if int(N) % h == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = str(input())
l = len(n)
L = []
for i in range(l):
  a = n[i]
  l.append(a)
sum_L = sum(L)
if int(n) % int(sum_l) == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = str(input())
l = len(n)
L = []
for i in range(l):
  a = n[i]
  l.append(a)
sum_L = sum(L)
if int(n) % sum_l == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = str(input())
l = len(n)
L = []
for i in range(l):
  a = n[i]
  l.append(a)
sum_L = sum(L)
if n % sum_l == 0:
  print('Yes')
else:
  print('No')
Problem p03543 (python)

Fixed submission:
s = str(input())
if s[0]==s[1]==s[2] or s[1]==s[2]==s[3]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = int(input())
if s[0]==s[1]==s[2] or s[1]==s[2]==s[3]:
  print('Yes')
else:
  print('No')
Problem p03547 (python)

Fixed submission:
x,y = map(str,input().split())
if x < y:
  print('<')
elif x == y:
  print('=')
else:
  print('>')

Buggy submission (verdict: Runtime Error):
x,y = map(str,input().split())
if a < b:
  print('<')
elif a == b:
  print('=')
else:
  print('>')
Problem p03573 (python)

Fixed submission:
L = sorted(map(int,input().split()))
if L[0]==L[1]:
  print(L[2])
else:
  print(L[0])

Buggy submission (verdict: Runtime Error):
L = list(map(int,input().split()))
M =L.sort()
if M[0]==M[1]:
  print(M[2])
else:
  print(M[0])
Problem p03588 (python)

Fixed submission:
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l.sort(reverse=True)

print(l[0][0]+l[0][1])

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [map(int,input().split()) for _ in range(n)]
A.sort(key=lambda x: x[0])
most = A[0][0]
mos = A[0][1]
worst = A[-1][0]
wors = A[-1][1]
print((most-1)+(most-worst+1)+(wors+1))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [a,b = map(int,input().split()) for _ in range(n)]
A.sort(key=lambda x: x[0])
most = A[0][0]
mos = A[0][1]
worst = A[-1][0]
wors = A[-1][1]
print((most-1)+(most-worst+1)+(wors+1))
Problem p03591 (python)

Fixed submission:
s = input()
if s[:4] == 'YAKI':
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = input()
if s[:4] = 'YAKI':
  print('Yes')
else:
  print('No')
Problem p03607 (python)

Fixed submission:
n = int(input())
A = [input() for _ in range(n)]

import collections
C = collections.Counter(A)
ans = 0
for a in C.values():
    if a % 2 == 1:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
L = [int(input()) for _ in range(n)]
l = collections.Counter(L)
l_count = l.values()
ans = 0
for i in range(len(l_count)):
  if l_cpunt[i] % 2 = 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
L = [int(input()) for i in range(n)]
L.sort()
c = collections.Counter(L)
ccc = c.values()
ans = 0
for j in range(len(ccc)):
  if ccc[j] % 2 = 1:
    ans += 1
Problem p03609 (python)

Fixed submission:
x,t = map(int,input().split())
if x >= t:
  print(x-t)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
x,t = map(int,input(),split())
if x >= t:
  print(x-t)
else:
  print(0)
Problem p03623 (python)

Fixed submission:
x,a,b = map(int,input().split())
if abs(x-a) >= abs(x-b):
  print('B')
else:
  print('A')

Buggy submission (verdict: Runtime Error):
x,a,b = map(int,input(),split())
if abs(x-a) >= abs(x-b):
  print('A')
else:
  print('B')
Problem p03624 (python)

Fixed submission:
s = input()
alps = 'abcdefghijklmnopqrstuvwxyz'
for alp in alps:
    if alp not in s:
        print(alp)
        break
else:
    print('None')

Buggy submission (verdict: Runtime Error):
s = input()
alps = 'abcdefghijklmnopqrstuvwxyz'
for i in alps:
    if i not in s:
        print(alp)
        break
else:
    print('None')
Problem p03636 (python)

Fixed submission:
s = input()
a = str(len(s)-2)
print(s[0] + a + s[-1])

Buggy submission (verdict: Runtime Error):
s = input()
a = len(s)-2
print(s[0] + int(a) + s[-1])

Buggy submission (verdict: Runtime Error):
s = input()
a = len(s)-2
print(s[0] + a + s[-1])

Buggy submission (verdict: Runtime Error):
s = input()
a = s.count()
print(s[0]+a+s[-1])
Problem p03643 (python)

Fixed submission:
n = str(input())
print('ABC'+n)

Buggy submission (verdict: Runtime Error):
n = int(input())
print('ABC'+n)
Problem p03644 (python)

Fixed submission:
n = int(input())
p = 1
for i in range(10):
  p = p*2
  if(p>n):
    print(2**i)
    break

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(1,n**(0.5)):
  a = 2*i
  l.append(a)
print(l[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(1,n**(0.5)):
  a = i*i
  l.append(a)
print(l[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(1,n**(0.5)):
  l.append(i**2)
print(l[-1])
Problem p03659 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
sum_A = sum(A)
ans = 10**20
X = 0
for a in A[:-1]:
    X += a
    ans = min(ans,abs(sum_A-2*X))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A_sum = sum(A)
ans = 10**19
for i in range(n):
  x = A[:i+1]
  x_sum = sum(x)
  z = abs(A_sum - 2*x_sum)
  ans = min(ans,z)
print(b)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A_sum = sum(A)
ans = 10**19
for i in range(n):
  x = sum(A[:i+1])
  z = abs(A_sum -2*x)
  ans = min(ans,z)
print(b)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [map(int,input().split())]
ans = 10**19
for i in range(n):
  a = A[:i]
  a_sum = sum(a)
  b = abs(sum(A)-a_sum)
  ans = min(ans,b)
print(b)
Problem p03681 (python)

Fixed submission:
import math 
n,m = map(int,input().split())
nm_abs = abs(n-m)
n_lad = math.factorial(n)
m_lad = math.factorial(m)
if nm_abs >= 2:
  print(0)
elif nm_abs == 1:
  print((n_lad * m_lad) % (10**9+7))
else:
  print((n_lad * m_lad*2) % (10**9+7))

Buggy submission (verdict: Runtime Error):
import math 
n,m = map(int.input().split())
nm_abs = abs(n-m)
n_lad = math.factorial(n)
m_lad = math.factorial(m)
if nm_abs >= 2:
  print(0)
elif nm_abs == 1:
  print((n_lad * m_lad) % (10**9+7))
else:
  print((n_lad * m_lad*2) % (10**9+7))
Problem p03697 (python)

Fixed submission:
a,b = map(int,input().split())
if a+b < 10:
  print(a+b)
else:
  print('error')

Buggy submission (verdict: Runtime Error):
a,b = map(ont,input().split())
if a+b < 10:
  print(a+b)
else:
  print('error')
Problem p03698 (python)

Fixed submission:
s = input()
if len(s) == len(set(s)):
  print('yes')
else:
  print('no')

Buggy submission (verdict: Runtime Error):
s = input()
l = []
for i in range(len(s)):
    a = s[i]
    l.append(a)
ans = 0
for j in range(1,len(s)+1):
    if l[j] == l[j-1]:
        ans += 1
    else:
        ans += 0
if ans == 0:
    print('yes')
else:
    print('no')
Problem p03699 (python)

Fixed submission:
n = int(input())
s = [0]
for i in range(n):
  s.append(int(input()))
m=sum(s)
s.sort()
for x in s:
  if (m-x)%10!=0:
    print(m-x)
    exit()
print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
s =[int(input()) for i in range(n)]
s.sort()
s_sum =sum(s)
if s_sum % 10 != 0:
  print(s_sum)
i = 0
else:
  while True:
    if s[i] % 10 != 0:
      s[i] = 0
      break
    i += 1    
  print(s_sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
s =[int(input()) for i in range(n)]
s.sort()
s_sum =sum(s)
if s_sum % 10 != 0:
  print(s_sum)
a = 1
i = 0
else:
  while a:
    if s[i] % 10 != 0:
      s[i] = 0
      a = 0
    i += 1    
  print(s_sum)
Problem p03730 (python)

Fixed submission:
def gcd(a,b):
  while b:
    a,b = b,a%b
  return a

a,b,c = map(int,input().split())
g = gcd(a,b)
answer = 'YES' if c%g == 0 else 'NO'
print(answer)

Buggy submission (verdict: Runtime Error):
import math

a,b,c = map(int,input().split())
g = math.gcd(a, b)

if c%g == 0:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
import math

a,b,c = map(int,input().split())
g = math.gcd(a,b)

if c%g == 0:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
import math
a,b,c = map(int,input().split())
g = math.gcd(a,b)
if c%g == 0:
  answer = 'YES'
else:
  answer = 'NO'
print(answer)
Problem p03731 (python)

Fixed submission:
n, T = map(int, input().split())
t = list(map(int, input().split()))
ans = T
for i in range(1, n):
    ans += min(t[i] - t[i - 1], T)
print(ans)

Buggy submission (verdict: Runtime Error):
n,t = map(int,input().split())
T = list(map(int,input().split()))
U = []
for i in range(n):
  for j in range(t):
    a = T[i] + j+1
    U.append(a)
setT = set(T)
setU = set(U)
ans = set(T) | set(U)

print(ans.count())

Buggy submission (verdict: Runtime Error):
n,t = map(int,input().split())
T = list(map(int,input().split()))
U = []
for i in range(n):
  for j in range(t):
    a = T[i] + t+1
    U.append(a)
setT = set(T)
setU = set(U)
ans = set(T)|set(U)

print(ans.count())
Problem p03760 (python)

Fixed submission:
o = list(input())
e = list(input())
i = 0
ans = ""
while i < len(e):
  ans += o[i]+e[i]
  i += 1
if len(o) > len(e):
  ans += o[len(o)-1]
print(ans)

Buggy submission (verdict: Runtime Error):
o = list(input())
e = list(input())
e_ni = e.append('a')
l = []
if len(o) == len(e):
  for i in range (len(o)):
  a = o[i]
  b = e[i]
  l.append(a)
  l.append(b)
else:
  for i in range (len(o)):
  a = o[i]
  b = e[i]
  l.append(a)
  l.append(b)
  del l[-1]
s = ''.join(l)
print(s)

Buggy submission (verdict: Runtime Error):
o = list(input())
e = list(input())
l = []

for i in range (len(o)):
  a = o[i]
  b = e[i]
  l.append(a)
  l.append(b)

s = ''.join(l)

print(s)

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
l = []

for i in range (len(o)):
  a = o[i]
  b = e[i]
  l.append(a)
  l.append(b)

s = ''.join(l)

print(s)

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
l = []
for i in range (len(o)):
  l.append(o[i])
  l.append(e[i])

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
l = []
for i in range (len(o)):
  l.append(o[i])
  l.append(e[i])

s = ''.join(l)

print(s)

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
l = []
for i in range (len(o)):
  l.append(o[i])
  l.append(e[i])
s = ''.join(l)
print(s)
Problem p03795 (python)

Fixed submission:
a = int(input())
print(a*800-(a//15)*200)

Buggy submission (verdict: Runtime Error):
a = int(input)
print(a*800-(a//15)*200)
Problem p03814 (python)

Fixed submission:
s = input()
print(s.rfind("Z")-s.find("A")+1)

Buggy submission (verdict: Runtime Error):
str.rfind()
Problem p03844 (python)

Fixed submission:
a,b,c = map(str,input().split())
if b == '+':
  print(int(a)+int(c))
else:
  print(int(a)-int(c))

Buggy submission (verdict: Runtime Error):
a,b,c = map(str,input().split())
if b == '+':
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
Problem p03909 (python)

Fixed submission:
H, W = map(int, input().split())
S = [list(input().split()) for i in range(H)]

h = w = 0
for i in range(H):
    if 'snuke' in S[i]:
        h = i
        w = S[i].index('snuke')
        break
print(chr(ord('A') + w) + str(h + 1))

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
S = [map(int,input().split()) for _ in range(h)]
for i,j in range():
  if S[i][j] == 'snuke':
    print((i)*w+j+1)
    break

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
S = [input() for _ in range(h*w)]
for i in range(h*w):
  if S[i] == 'snuke':
    print(i+1)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
S = [int(input()) for _ in range(h*w)]
for i in range(h*w):
  if S[i] == 'snuke':
    print(i+1)
Problem p03937 (python)

Fixed submission:
def main():
  H, W = list(map(int, input().split()))

  count = 0

  for i in range(H):
    row = input()
    for j in range(W):
      if(row[j] == '#'):
        count += 1

  print("Possible" if W + H - 1 == count else "Impossible")

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
HW = [list(map(str,input().split())) for _ in range(h)]
sharp = 0
for i in range(w):
  for j in range(h):
    if HW[i][j] == '#':
      sharp += 1

min_root = h + w - 1
if sharp == min_root:
  print('Possible')
else:
  print('Impossible')

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
HW = [list(map(int,input().split())) for _ in range(h)]
min_root = h + w - 1
if sharp == min_root:
  print('Possible')
else:
  print('Impossible')

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
HW = [list(map(int,input().split())) for _ in range(h)]
sharp = HW.count('#')
min_root = h + w - 1
if sharp == min_root:
  print('Possible')
else:
  print('Impossible')
Problem p03958 (python)

Fixed submission:
k, t = map(int, input().split())
a = list(map(int, input().split()))
print(max(2*max(a)-k-1, 0))

Buggy submission (verdict: Runtime Error):
k,t = map(int,input().split())
A = list(map(int,input().split()))
at = max(A)
print(max(2*at−1−k,0))

Buggy submission (verdict: Runtime Error):
k,t = map(int,input().split())
A = list(map(int,input().split()))
at = max(A)
print(max(at−1−(k−at),0))
Problem p03962 (python)

Fixed submission:
a,b,c = map(int,input().split())
if a == b == c:
  print(1)
elif a == b or b == c or c == a:
  print(2)
else:
  print(3)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if a == b == c:
  print(1)
elif a == b or b == c or c == a:
  print(2)
elif:
  print(3)
Problem p03993 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n):
    if A[A[i]-1] == i+1:
        ans += 1
print(ans//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n):
  b = A[i]
  if i+1 == A[b]:
    ans += 1
print(ans//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n):
  if i+1 == A[A[i]]:
    ans += 1
print(ans//2)
Problem p04011 (python)

Fixed submission:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N > K:
    print(K*X+((N-K)*Y))
else:
    print(N*X)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if k >= n:
  print(k*x)
else:
print(k*x+(n-k)*y)
Problem p04019 (python)

Fixed submission:
S =input()
if (('N' in S) == ('S' in S)) and (('W' in S) == ('E' in S)):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
N = s.count('N')
S = s.count('S')
E = s.count('E')
W = s.count('W')
if ((N >= 1 and S == 0) or (N == 0 and S >= 1) or 
    (E >= 1 and W == 0) or (E == 0 and W >= 1):
  print('NO')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
s = input()
N = s.count('N')
S = s.count('S')
E = s.count('E')
W = s.count('W')
if ((N >= 1 and S == 0) or (N == 0 and S >= 1) or 
    (E >= 1 and W == 0) or (E == 0 and W >= 1):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = input()
N = s.count('N')
S = s.count('S')
E = s.count('E')
W = s.count('W')
if (N >= 1 and S >= 1) or (E >= 1 and W >= 1) or s ='':
  print('Yes')
else:
  print('No')
Problem p02606 (python)

Fixed submission:
l,R, d = map(int, input().split())

a =0
for i in range(l,R+1):
  if i % d == 0:
    a = a+1 

print(a)

Buggy submission (verdict: Runtime Error):
l,R, d = map(int, input()).split()

a =0
for i in range(l,R):
  if i % d == 0:
    a = a+1 

print(a)
Problem p02818 (python)

Fixed submission:
def run(a, b, k):
    ans1 = a - k
    ans2 = b
    if ans1 < 0:
        ans2 = b + ans1
        ans1 = 0
    if ans2 < 0:
        ans2 = 0
    return ans1, ans2


def main():
    a, b, k = map(int, input().split())
    ans = run(a, b, k)
    print(ans[0], ans[1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def run(a, b, k):
    ans1 = a - k
    if ans1 < 0:
        ans2 = b + ans1
        ans1 = 0
    return ans1, ans2


def main():
    a, b, k = map(int, input().split())
    ans = run(a, b, k)
    print(ans[0], ans[1])


if __name__ == '__main__':
    main()
Problem p03145 (python)

Fixed submission:
def run(a):
    return a[0] * a[1] // 2


def main():
    a = list(map(int, input().split()))
    print(run(a))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def run(a):
    return a[0] * a[1] // 2


def main():
    a = map(int, input().split())
    print(run(a))


if __name__ == '__main__':
    main()
Problem p03200 (python)

Fixed submission:
def run(S):
    '''
    Bをすべて右に、Wをすべて左に移動する回数を求める
    '''
    cnt = 0
    n = len(S)
    cnt_B = 0
    cnt_W = 0
    for i in range(len(S)):
        if S[i] == 'B':
            cnt_B += 1
            cnt += n - (i+cnt_B)
        else:
            cnt += i - cnt_W
            cnt_W += 1
    return int(cnt / 2)


def main():
    S = input()
    print(run(S))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def run(S):
    s = 0
    f = len(S) - 1
    cnt = 0
    while s < f:
        while S[s] == 'W' or S[f] == 'B':
            if S[s] == 'W':
                s += 1
            elif S[f] == 'B':
                f -= 1
        for i in range(s, f):
            if S[i] == 'B' and S[i+1] == 'W':
                cnt += 1
                S = S[:i] + 'WB' + S[i+2:]
    return cnt


def main():
    S = input()
    print(run(S))


if __name__ == '__main__':
    main()
Problem p03262 (python)

Fixed submission:
import fractions


def run(n, x, xx):
    xx.append(x)
    xx = sorted(xx)
    d = [xx[i+1]-xx[i] for i in range(n)]
    d = sorted(d)
    min_d = d[0]
    if len(d) == 1:
        pass
    else:
        for i in range(1, len(d)):
            min_d = fractions.gcd(min_d, d[i])
    return min_d


def main():
    n, x = map(int, input().split())
    xx = list(map(int, input().split()))
    print(run(n, x, xx))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def run(n, x, xx):
    xx.append(x)
    xx = sorted(xx)
    d = [xx[i+1]-xx[i] for i in range(n)]
    d = sorted(d)
    min_d = d[0]
    if len(d) == 1:
        return min_d
    for i in range(1, len(d)):
        min_d = fractions.gcd(min_d, d[i])
    return min_d


def main():
    n, x = map(int, input().split())
    xx = list(map(int, input().split()))
    print(run(n, x, xx))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math


def run(n, x, xx):
    xx.append(x)
    xx = sorted(xx)
    d = [xx[i+1]-xx[i] for i in range(n)]
    d = sorted(d)
    min_d = d[0]
    if len(d) == 1:
        return min_d
    for i in range(1, len(d)):
        min_d = math.gcd(min_d, d[i])
        if d[i] % min_d == 0:
            return min_d


def main():
    n, x = map(int, input().split())
    xx = list(map(int, input().split()))
    print(run(n, x, xx))


if __name__ == '__main__':
    main()
Problem p03292 (python)

Fixed submission:
def run(a):
    return max(a) - min(a)


def read_line():
    a = list(map(int, input().split()))
    return a


def main():
    a = read_line()
    print(run(a))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import unittest

from app.ABC103_A import run


class TestSample(unittest.TestCase):
    def test_run(self):
        self.assertEqual(run([1, 6, 3]), 5)
        self.assertEqual(run([11, 5, 5]), 6)
        self.assertEqual(run([100, 100, 100]), 0)


if __name__ == '__main__':
    unittest.main()
Problem p03309 (python)

Fixed submission:
def run(n, a):
    a = [a[i]-i-1 for i in range(len(a))]
    a.sort()
    m = a[int((n-1)/2)]
    ret = 0
    for ai in a:
        ret += abs(ai - m)
    return ret


def read_line():
    n = int(input())
    a = list(map(int, input().split()))
    return (n, a)


def main():
    n, a = read_line()
    print(run(n, a))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import unittest

from app.ABC102_C import run


class TestSample(unittest.TestCase):
    def test_run(self):
        self.assertEqual(run(5, [2, 2, 3, 5, 5]), 2)
        self.assertEqual(run(9, [1, 2, 3, 4, 5, 6, 7, 8, 9]), 0)
        self.assertEqual(run(6, [6, 5, 4, 3, 2, 1]), 18)
        self.assertEqual(run(7, [1, 1, 1, 1, 2, 3, 4]), 6)


if __name__ == '__main__':
    unittest.main()