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

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

ans = 0
zero = 0

for h in H:
    if h == 0:
        zero += 1

while zero < N:
    flg = False
    cnt = 0

    for i in range(N):
        if H[i] > 0:
            flg = True
            H[i] -= 1

            if H[i] == 0:
                zero += 1
        else:
            if flg:
                cnt += 1
                flg = False

    if flg:
        cnt  += 1

    ans += cnt


print(ans)

Buggy submission (verdict: Runtime Error):
H = [0] + H
cnt = 0
for i in range(1, N + 1):
    cnt += max(H[i] - H[i - 1], 0)


print(cnt)
Problem p03262 (python)

Fixed submission:
import math

N, X = map(int, input().split())
X_lst = list(map(int, input().split()))

if len(X_lst) == 1:
    print(abs(X_lst[0] - X))
    exit()

u = 0
if X_lst[0] == X:
    u = float('inf')

for i, x in enumerate(X_lst[1:], start=1):
    if x == X:
        u = float('inf')

    if X_lst[i - 1] < X < x:
        u = [X - X_lst[-1], x - X]

    if i == 1:
        g = X_lst[1] - X_lst[0]
    else:
        g = math.gcd(g, x - X_lst[i - 1])


if u == 0:
    u = [X - X_lst[-1]]
elif u != float('inf'):
    g = max(math.gcd(g, u[0]), math.gcd(g, u[1]))

print(g)

Buggy submission (verdict: Runtime Error):
import math

N, X = map(int, input().split())
X_lst = list(map(int, input().split()))

if len(X_lst) == 1:
    print(abs(X_lst[0] - X))
    exit()

u = 0
if X_lst[0] == X:
    u = float('inf')

for i, x in enumerate(X_lst[1:], start=1):
    if x == X:
        u = float('inf')

    if X_lst[i - 1] < X < x:
        u = [X - u, x - X]

    if i == 1:
        g = X_lst[1] - X_lst[0]
    else:
        g = math.gcd(g, x - X_lst[i - 1])


if u == 0:
    u = [X - X_lst[-1]]
elif u != float('inf'):
    g = max(math.gcd(g, u[0]), math.gcd(g, u[1]))

print(g)
Problem p02603 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
money = 1000
peak = []
botom = []
kabu = 0

if a[0] < a[1]:
    botom.append(0)
if a[n-1] >= a[n-2]:
    peak.append(n-1)
for i in range(1, n-1):
    if a[i] >= a[i-1] and a[i] > a[i+1]:
        peak.append(i)
    if a[i] <= a[i-1] and a[i] < a[i+1]:
        botom.append(i)

for i in range(n):
    if i in botom:
        kabu += money//a[i]
        money %= a[i]
    if i in peak:
        money += kabu*a[i]
        kabu = 0

print(money)

Buggy submission (verdict: Runtime Error):
if a[n-1] >= a[n-2]:
    peak.append(n-1)
for i in range(1, n-1):
    if a[i] >= a[i-1] and a[i] > a[i+1]:
        peak.append(i)
    if a[i] <= a[i-1] and a[i] < a[i+1]:
        botom.append(i)

for i in range(n):
    if i in botom:
        kabu = money//a[i]
        money %= a[i]
    if i in peak:
        money += kabu*a[i]
        kabu = 0

print(money)
Problem p02743 (python)

Fixed submission:
a, b, c = map(int, input().split())

if a+b > c:
    print("No")
elif (c-a-b)**2 > 4*a*b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

if a+b > c:
    print("No"):
elif (c-a-b)**2 > 4*a*b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from math import sqrt
a, b, c = map(int, input().split())

if a+b > c:
    print("No"):
elif (c-a-b)/2 > sqrt(a*b):
    print("Yes")
else:
    print("No")
Problem p02756 (python)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten == True:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten == True:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atn + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)
Problem p02760 (python)

Fixed submission:
a = []
for i in range(3):
    ai = list(map(int, input().split()))
    a.append(ai)
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = 0

ans = "No"
if sum(a[0]) == 0:
    ans = "Yes"
elif sum(a[1]) == 0:
    ans = "Yes"
elif sum(a[2]) == 0:
    ans = "Yes"
elif a[0][0] + a[1][0] + a[2][0] == 0:
    ans = "Yes"
elif a[0][1] + a[1][1] + a[2][1] == 0:
    ans = "Yes"
elif a[0][2] + a[1][2] + a[2][2] == 0:
    ans = "Yes"
elif a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
elif a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
a = []
b = []
for i in range(3):
    ai = list(map(int, input().split()))
    a.append(ai)
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = 0

for i in range(3):
    if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0:
        print("Yes")
        break
else:
    for i in range(3):
        if a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0:
            print("Yes")
            break
    else:
        if c[0][0] == 0 and c[1][1] == 0 and c[2][2] == 0:
            print("Yes")
        elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
            print("Yes")
        else:
            print("No")
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
ans = 0
s = set()
keta = set()
for i in range(m):
    preans = sc[i][1]*(10**(n-sc[i][0]))
    if sc[i][0] in keta and preans not in s:
        print(-1)
        break
    elif sc[i][0]  not in keta:
        ans += preans
        s.add(preans)
        keta.add(sc[i][0])
else:
    if n == 1 and m == 0:
        print(0)
    elif 1 not in keta:
        print(ans + 10**(n-1))
    elif len(str(ans)) == n:
        print(ans)
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
ans = 0
s = set()
keta = set()
for i in range(m):
    preans = sc[i][1]*(10**(n-sc[i][0]))
    if sc[i][0] in keta and preans not in s:
        print(-1)
        break
    elif sc[i][0]  not in keta:
        ans += preans
        s.add(preans)
        keta.add(sc[i][0])
else:
    if n not in keta::
        print(ans + 10**(n-1))
    elif len(str(ans)) == n:
        print(ans)
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
ans = 0
s = set()
keta = set()
for i in range(m):
    preans = sc[i][1]*(10**(n-sc[i][0]))
    if sc[i][0] in keta and preans not in s:
        print(-1)
        break
    elif sc[i][0]  not in keta:
        ans += preans
        s.add(preans)
        keta.add(sc[i][0])
else:
    if n not in keta::
        print(ans + 10**(n-1))
    elif len(str(ans)) == n:
        print(ans)
    else:
        print(-1)
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
  
m = sum(p[0: k])
sump = m

for i in range(1, n-k+1):
  sump = sump - p[i-1] + p[i+k-1]
  if m < sump:
    m = sump

ans = (m + k) / 2

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
  
s = []
sump = 0
for i in range(n):
  sump += (p[i] + 1) / 2
  s.append(sump)
  
ans = set()
for i in range(k, n):
  ans.add(s[i]-s[i-k])
  
if n == 1:
  print(s[0])
else:
  print(max(ans))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
  
s = []
sump = 0
for i in range(n):
  sump += (p[i] + 1) / 2
  s.append(sump)
  
ans = set()
for i in range(k, n):
  ans.add(s[i]-s[i-1])
  
if n == 1:
  print(s[0])
else:
  print(max(ans))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
  
s = []
sump = 0
for i in range(n):
  sump += (p[i] + 1) / 2
  s.append(sump)
  
ans = set()
for i in range(k, n):
  ans.add(s[i]-s[i-k])
  
print(max(ans))
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())

ac = 0
wa = 0
dwa = {}
d = {}

for i in range(m):
  p, s = input().split()
  if d.get(p) == "AC":
    continue
  if p not in dwa:
    dwa[p] = 0
  if s == "WA":
    dwa[p] += 1
  else:
    ac += 1
    wa += dwa[p]
  d[p] = s
  
print(ac, wa)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans1 = 0
ans2 = 0
preans2 = 0
check = 0
t = []
pret = []

for i in range(m):
  pret = list(map(str, input().split()))
  t.append(pret)
  
for i in range(m):
  if t[i][1] == "WA":
    if check = 0:
      preans2 += 1
  else:
    if check = 0:
      ans1 += 1
      ans2 += preans2
      preans2 = 0
      check += 1
    else:
      ans1 += 1
      check += 1
  if i > 0:
    if t[i][0] != t[i-1][0]:
      check = 0
      
print(ans1, ans2)
Problem p02921 (python)

Fixed submission:
s = list(input())
t = list(input())

cnt = 0
for i in range(3):
  if s[i] == t[i]:
    cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
S = input().rstrip().split("")
T = input().rstrip().split("")
 
tekichu = 0
 
for i in range(3):
	if S[i] == T[i]:
		tekichu += 1
 
print(tekichu)

Buggy submission (verdict: Runtime Error):
yohou = input().rstrip().split("")
tenki = input().rstrip().split("")
 
tekichu = 0
 
for i in range(3):
	if yohou[i] == tenki[i]:
		tekichu += 1
 
print(tekichu)

Buggy submission (verdict: Runtime Error):
yohou = input().rstrip().split("")
tenki = input().rstrip().split("")
 
tekichu = 0
 
for i in range(3):
	if yohou[i] == tenki[i]:
	tekichu += 1
 
print(tekichu)

Buggy submission (verdict: Runtime Error):
yohou = input().split("")
tenki = input().split("")
 
tekichu = 0
 
for i in range(0,3):
  if yohou[i] == tenki[i]:
    tekichu += 1
 
print(tekichu)

Buggy submission (verdict: Runtime Error):
yohou[] = input().split("")
tenki[] = input().split("")

tekichu = 0

for i in range(0,3):
  if yohou[i] == tenki[i]:
    tekichu += 1

print(tekichu)
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split())

cnt = 1
k = a

while k < b:
  k += a-1
  cnt += 1

if b == 1:
  print(0)
else:
  print(cnt)

Buggy submission (verdict: Runtime Error):
line = input().split(" ")
 
n = 0
 
while n >= 0:
	if n*(int(line[0])-1) >= int(line[1])-int(line[0]):
		break
	else:
		n += 1
 
input(str(n+1))

Buggy submission (verdict: Runtime Error):
ab = input().split(" ")

n = 0

while n >= 0:
	if n*(ab[0]-1) >= ab[1]-ab[0]:
		break
	else:
		n += 1

input(n+1)
Problem p02639 (python)

Fixed submission:
x=list(map(int,input().split()))

i=1
while i<=len(x):
    
    if x[i-1]==0:
        print(i)
    
    i+=1

Buggy submission (verdict: Runtime Error):
x=list(map(int,input().split()))

i=1
while i<=len(x):
    
    if x[i]==0:
        print(i)
    
    i+=1
Problem p02657 (python)

Fixed submission:
a, b = map(int, input().split())

print(a*b)

Buggy submission (verdict: Runtime Error):
import numpy as np

n = input()

a = list(map(int, input().split()))

res = np.prod(a)

if res > 10**18 :
    print('-1')

else:
    print(res)
Problem p02681 (python)

Fixed submission:
s = input()

t = input()

str = s + t[-1]

if str == t:
  print('Yes')
  
else :
  print('No')

Buggy submission (verdict: Runtime Error):
# 入力をintにして変数に格納
a, b, c, k = map(int, input().split())

# KとA,Bの大きさに応じて場合分けして最大値計算
if( a+b >= k ):
    max = k

elif( a+b <= k ):
    max = a - ( k - a - b )

# 結果を出力
print(max)

Buggy submission (verdict: Runtime Error):
# 入力をintにして変数に格納
a, b, c, k = map(int, input().split())

# KとA,Bの大きさに応じて場合分けして最大値計算
if( a+b >= k ):
    max = k

elif( a+b <= k ):
    max = a - ( k - a - b )

else:
    sys.exit(1)

# 結果を出力
print(max)
Problem p03005 (python)

Fixed submission:
n,k=map(int,input().split())

if k==1:
    print('0')

else:

    ans=n-k
    print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())

if k=1:
    print('0')

else:

    ans=n-k
    print(ans)
Problem p03145 (python)

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

l.sort()

print(l[0]*l[1]//2)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input()))

l.sort()

print(l[0]*l[1]//2)
Problem p02705 (python)

Fixed submission:
import math
R = int(input())
print(2*R*math.pi)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
b=[]
for i in range(1,N+1):
    b.append(A.count(i))
for i in b:
    print(i)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
b=[]
for i in range(1,N+1):
    b.append(A.count(i))
for i in b:
    print(i)
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

if 0 in a:
  print(0)
  
else:
  ans = 1
  for val in a:
    ans *= val
    if ans > 10**18:
      print(-1)
      exit()
      
  print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 1
for i in range(0, n):
  b = int(input())
  ans *= b
if a > 10**18:
   print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 1
for i in range(n):
  b = int(input())
  ans *= b
if a > 10**18:
   print(-1)
else:
  print(ans)
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())
print((abs(x-a) > abs(x-b)) ? "A" : "B")
Problem p03773 (python)

Fixed submission:
a, b = map(int, input().split())
print((a + b) % 24)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split)
print((a + b) % 24)
Problem p03813 (python)

Fixed submission:
rate = int(input())
if rate < 1200:
  print("ABC")
else:
  print("ARC")

Buggy submission (verdict: Runtime Error):
rate = int(input())
if rate < 1200:
  print("ABC")
else:
  print("ARC)
Problem p02640 (python)

Fixed submission:
X,Y = map(int,input().split())
count = 0
for i in range(X+1):
  for j in range(X+1):
    if 2*i + 4*j == Y and i+j ==X:
      count +=1
if count == 0:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
MM = input().split()
total = 1
for i in MM:
  total = total*int(i)

  if total > 10**18:
    break
for i in MM:
  if int(i) == 0:
    total = 0
if total > 10**18:
  print(-1)
else:
  print(total)
Problem p02646 (python)

Fixed submission:
A,V = map(int,input().split())
B,W = map(int,input().split())
N = int(input())
if W > V:
  print('NO')
else:
  if abs(A-B) <= N*(V-W):
    print('YES')
  else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
N = int(input())
if W > V:
  print('No')
else:
  if abs(A-B) <= N*(V-W):
    print('Yes')
  else:
    print('No)
Problem p03273 (python)

Fixed submission:
MM = input().split()
A = int(MM[0])
B = int(MM[1])
list1 =[]
for i in range(A):
  aa = input()
  if '.'*B == aa:
    pass
  else:
    list1.append(list(aa))


for i in range(B):
  count = 0
  for j in range(len(list1)):
    if list1[j][i] == '#':
      count +=1
  if count == 0:
    for j in range(len(list1)):
     
      list1[j][i] = 'a'

for i in list1:
  if 'a' in i:
    i.remove('a')

for i in list1:
  for j in i:
    if j != 'a':
      print(j,end='')
  print()

Buggy submission (verdict: Runtime Error):
MM = input().split()
A = int(MM[0])
B = int(MM[1])
list1 =[]
for i in range(A):
  aa = input()
  if '.'*B == aa:
    pass
  else:
    list1.append(list(aa))


for i in range(B):
  count = 0
  for j in range(len(list1)):
    if list1[j][i] == '#':
      count +=1
  if count == 0:
    for j in range(len(list1)):
     
      list1[j][i] = 'a'

for i in list1:
  i.remove('a')

for i in list1:
  for j in i:
    print(j,end='')
  print()
Problem p04012 (python)

Fixed submission:
NN = input()
total = 0
for i in NN:
  a = NN.count(i)
  if a%2 ==0:
    pass
  else:
    total +=1
if total ==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
NN = input()
total = 0
for i in NN:
  a = NN.count(i)
  if a%2 ==0:
    pass
  else:
    totaL +=1
if total ==0:
  print('Yes')
else:
  print('No')
Problem p02641 (python)

Fixed submission:
X, N = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
if len(l) == 0:
    print(X)
elif X not in l:
    print(X)
else:
    for i in range(1, 1000):
        if X - i not in l:
            print(X - i)
            break
        elif X + i not in l:
            print(X + i)
            break

Buggy submission (verdict: Runtime Error):
from math import ceil

X, N = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l2 = [abs(int(x)-X) for x in l]
l2.sort()
for i in range(N):
    if ceil(i/2) != l2[i]:
        t = ceil(i/2)
        break
if X - t in l:
    print(X + t)
else:
    print(X - t)
Problem p02642 (python)

Fixed submission:
N = int(input())
l = [int(x) for x in input().split()] + [1000001]
l.sort()
ans = 0
t = 0
M = [False] * 10 ** 6
for i in range(N):
    if not M[l[i]-1]:
        if l[i] != l[i+1]:
            ans += 1
        t = l[i]
        while t <= 10 ** 6:
            M[t-1] = True
            t += l[i]
print(ans)

Buggy submission (verdict: Runtime Error):
from math import ceil

X, N = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l2 = [abs(int(x)-X) for x in l]
l2.sort()
for i in range(N):
    if ceil(i/2) != l2[i]:
        t = ceil(i/2)
        break
if X - t in l:
    print(X + t)
else:
    print(X - t)
Problem p02687 (python)

Fixed submission:
S = input()
if S == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
S = input()
if S = "ABC":
  print("ARC")
else:
  print("ABC")
Problem p02983 (python)

Fixed submission:
import sys

L, R = map(int, input().split())
if L + (673 - L % 673) <= R or L % 673 == 0:
  if L + (3 - L % 3) <= R or L % 3 == 0:
    print(0)
    sys.exit()
ans = 2019
a = L % 2019
b = R % 2019
for i in range(a, b):
  for j in range(i+1, b+1):
    ans = min(ans, i * j % 2019)
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
if L + (673 - L % 673) <= R or L % 673 == 0:
  if L + (3 - L % 3) <= R or L % 3 == 0:
    print(0)
    sys.exit()
ans = 2019
a = L % 2019
b = R % 2019
for i in range(a, b):
  for j in range(i+1, b+1):
    ans = min(ans, i * j % 2019)
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
a = L % 2019
if a == 0:
  print(0)
else:
  if L + (673 - L % 673) <= R or L % 673 == 0:
    if L + (3 - L % 3) <= R or L % 3 == 0:
      print(0)
      sys.exit()
  ans = 2019
  b = R % 2019
  for i in range(a, b):
    for j in range(i+1, b+1):
      ans = min(ans, i * j % 2019)
  print(ans)
Problem p02993 (python)

Fixed submission:
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
  print('Bad')
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
s = input()
if s[0] == s[1] or s[1] == s[2] 0r s[2] == s[3]:
  print('Bad')
else:
  print('Good')
Problem p03047 (python)

Fixed submission:
n, k = map(int, input().split())
print(n - k + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
print(N-k+1)
Problem p03062 (python)

Fixed submission:
import numpy as np
import sys
 
n = int(input())
l = np.array([int(x) for x in input().split()])
ans = 0
if 0 in l:
  for i in range(n):
    ans += abs(l[i])
  print(ans)
  sys.exit()
m = abs(l[0])
p = 0
for i in range(n):
  if l[i] < 0:
    p += 1
  if m > abs(l[i]):
    m = abs(l[i])
for i in range(n):
  ans += abs(l[i])
if p % 2 == 0:
  print(ans)
else:
  print(ans - m*2)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
 
n = int(input())
l = np.array([int(x) for x in input().split()])
ans = 0
if 0 in l:
  for i in range(n):
    ans += abs(l[i])
  print(ans)
  sys.exit()
m = abs(l[0])
for i in range(n):
  if l[i] < 0:
    p += 1
  if m < abs(l[i]):
    m = abs(l[i])
for i in range(n):
  ans += abs(l[i])
if p % 2 == 0:
  print(ans)
else:
  print(ans - m*2)

Buggy submission (verdict: Runtime Error):
import numpy as np

n = int(input())
l = np.array([int(x) for x in input().split()])
ans = 0
if 0 in l:
  for i in range(n):
    ans += abs(l[i])
  sys.exit()
m = abs(l[0])
for i in range(n):
  if l[i] < 0:
    p += 1
  if m < abs(l[i])
for i in range(n):
  ans += abs(l[i])
if p % 2 == 0:
  print(ans)
else:
  print(ans - m*2)
Problem p03074 (python)

Fixed submission:
import sys

n, k = [int(x) for x in input().split()]
s = input()
l = [0]
a = '1'
for i in range(n):
  if s[i] != a:
    l.append(i)
    a = s[i]
l.append(n)
if s[-1] == '0':
  l.append(n)
if len(l) < 2 * k + 2:
  print(n)
  sys.exit()
a, ans = 0, 0
while a + 2 * k + 1 < len(l):
  b = l[a+2*k+1] - l[a]
  if ans < b:
    ans = b
  a += 2
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

n, k=[int(x) for x in input().split()]
s=input()
l=[]
a='1'
for i in range(len(s)):
  if a != s[i]:
    l.append(i)
    a = s[i]
l.append(len(s))
if s[-1]=='0':
  l.append(0)
if len(l) <= 2*k+1:
  print(len(s))
  sys.exit()
m=0
ans=0
while m+ 2*k < len(s)-1:
  b = l[m+2*k]-l[m]
  if b>ans:
    ans=b
  m+=2
print(ans)
Problem p03086 (python)

Fixed submission:
s = input()
set = {'A', 'T', 'G', 'C'}
l, ans = 0, 0
for i in range(len(s)):
  if s[i] in set:
    l += 1
  else:
    ans = max(l, ans)
    l = 0
ans = max(l, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
set = {'A', 'T', 'G', 'C'}
l, ans = 0, 0
for i in len(s):
  if s[i] in set:
    l += 1
  else:
    ans = max(l, ans)
    l = 0
print(ans)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))

ans_enable = [True] * 102

for pi in p:
    ans_enable[pi] = False

diff = 0

check_ok = ans_enable[X]

ans_small = True

while not check_ok:
    diff += 1
    if ans_enable[X - diff]:
        check_ok = True
        ans_small = True
    elif ans_enable[X + diff]:
        check_ok = True
        ans_small = False

print(X - diff if ans_small else X + diff)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
p = list(input().split())

ans_enable = [True] * 102
for pi in p:
    ans_enable[pi] = False

diff = 0

check_ok = ans_enable[X]

ans_small = True

while not check_ok:
    diff += 1
    if ans_enable[X - diff]:
        check_ok = True
        ans_small = True
    elif ans_enable[X + diff]:
        check_ok = True
        ans_small = False

print(X - diff if ans_small else X + diff)
Problem p02691 (python)

Fixed submission:
import bisect

N = int(input())

border = N * 2

A = list(map(int, input().split()))

b = [A[0] + 1]

C = [0] * (border + 1)

ans = 0

for i, a in enumerate(A, 1):
    if 0 <= i - a <= border:
        ans += C[i - a]
    if i + a <= border:
        C[i + a] += 1
    #br = bisect.bisect_right(b, i - a)
    #bl = bisect.bisect_left(b, i - a)
    #ans += br - bl
    #b.index(bl, i + a)

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

N = int(input())

border = N * 2

A = list(map(int, input().split()))

b = [A[0] + 1]

C = [0] * (border + 1)

ans = 0

for i, a in enumerate(A, 1):
    ans += C[i - a]
    if i + a <= border:
        C[i + a] += 1
    #br = bisect.bisect_right(b, i - a)
    #bl = bisect.bisect_left(b, i - a)
    #ans += br - bl
    #b.index(bl, i + a)

print(ans)
Problem p02705 (python)

Fixed submission:
print(int(input()) * 3.1415 * 2)

Buggy submission (verdict: Runtime Error):
print(int(input) * 3.1415 * 2)