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

Fixed submission:
a=int(input())
s=input()
if a>=3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
from collections import deque

n, q = map(int, input().split())
G = [[] for yy in range(n)]
count = [0]*n
flag=[False]*n
stack = deque([0])

for _ in range(n-1):
  a, b = map(int, input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)
  
for _ in range(q):
  p, x = map(int, input().split())
  count[p-1] += x

stack.append(0)
while stack:
  v = stack.pop()
  flag[v] = True
  for e in G[v]:
    if flag[e]:
      continue
    count[e] += count[v]
    stack.append(e)

print(*count)
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
if a>=3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
a=int(input())
s=input()
if a>=3200:a
    print("s")
else:
    print("red")
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
if s[k-1]=="A":
	print(s[0:k-1]+"a"+s[k:n])
elif s[k-1]=="B":
	print(s[0:k-1]+"b"+s[k:n])
else:
	print(s[0:k-1]+"c"+s[k:n])

Buggy submission (verdict: Runtime Error):
s=input()
first=int(s[0]+s[1])
second=int(s[2]+s[3])
if 1<=first<=12 and 1<=second<=12:
	print("AMBIGUOUS")
elif 1<=first<=12 and (second==0 or second>=13):
		print("MMYY")
elif (first==0 or first>=13) or 1<=second<=12:
		print("YYMM")
else:
		print("NA")
Problem p03135 (python)

Fixed submission:
T,X=map(int,input().split())
print(T/X)

Buggy submission (verdict: Runtime Error):
N=int(input())
l=list(map(int,input().split()))
if max(l)<sum(l)-max(l):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
l=list(map(int,input().split()))
if max(l)<sum(l)-max(l):
	print("Yes")
else:
	print("NO")
Problem p03327 (python)

Fixed submission:
n=int(input())
if 0<n<1000:
	print("ABC")
else:
	print("ABD")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
n=b-a
print(n*(n+1)//2-b)
Problem p02897 (python)

Fixed submission:
n = int(input())

a = int(n / 2)
b = n % 2

c = a + b

print(c/n)

Buggy submission (verdict: Runtime Error):
n = input()

a = int(n / 2)
b = n % 2

c = a + b

print(c)

Buggy submission (verdict: Runtime Error):
n = input()

a = n / 2
b = n % 2

c = a + b

print(c)
Problem p02933 (python)

Fixed submission:
a = int(input())
s=input()
if a < 3200:
    print('red')
else:
    print(s)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
 
N,Q = (int(i) for i in input().split())
hen = {}
value = [0] * N

for _ in range(0,N-1):
    a,b = (int(i) for i in input().split())
    if a in hen:
        hen[a].append(b)
    else:
        hen[a] = [b]

for _ in range(0,Q):
    p,x = (int(i) for i in input().split())
    value[p-1] = value[p-1] + x

def add(p,x):
        for node in hen[p]:
            value[node-1] = value[node-1] + x
            if node in hen:
                add(node,value[node-1])

#add(1,value[0])
for i in range(0,n):
    if i+1 in hen:
        for node in hen[i+1]:
            value[node-1] += value[i]

print(' '.join(map(str,value)))

Buggy submission (verdict: Runtime Error):

N,Q = (int(i) for i in input().split())
hen = {}
value = [0] * N
flag = [0] * N
for i in range(0,N-1):
    a,b = (int(i) for i in input().split())
    if a in hen:
        hen[a].append(b)
    else:
        hen[a] = [b]
#print(hen)

def add(p,x):
    if p in hen:
        for i in hen[p]:
            value[i-1] = value[i-1] + x
            add(i,value[i-1])

for i in range(0,Q):
    p,x = (int(i) for i in input().split())
    value[p-1] = value[p-1] + x


add(1,value[0])
print(' '.join(map(str,value)))
Problem p02916 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=sum(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n-1):
    if a[i]+1==a[i+1]:
        b+=c[a[i]-1]
print(b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = sum(map(int,input().split()))
c = kist(map(int,input().split()))
for i in range(n-1):
  if a[i+1] == a[i] + 1:
    b += a[i+1]
print(b)
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

sat = 0
for a,b in zip(A,A[1:]):
  if b == a+1:
    sat += C[a-1]
    
print( sum(B) + sat )

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())

if A >= B:
  print(1)
  
else:
 
  for i in list(range(1,21)):
    if (A-1) * i + A >= B:
      print(i+1)
      break
Problem p03327 (python)

Fixed submission:
N = int(input())

if N <= 999:
  print("ABC")
else:
  print("ABD")

Buggy submission (verdict: Runtime Error):
N = int(input())
if N <= 999:
  print(ABC)
else:
  print(ABD)
Problem p02990 (python)

Fixed submission:
import sys
import re
import math
from collections import Counter

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N,K=(int(x) for x in input().split())

for i in range(1,K+1):
    if i < min(K+1,N-K+2):
        print((combinations_count(N-K+1, i)*combinations_count(K-1, i-1))%1000000007)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import sys
import re
import math
from collections import Counter

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N,K=(int(x) for x in input().split())

for i in range(1,K+1):
    print((combinations_count(N-K+1, i)*combinations_count(K-1, i-1))%1000000007)

Buggy submission (verdict: Runtime Error):
import sys
import re
import math
from collections import Counter

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N,K=(int(x) for x in input().split())

for i in range(1,K+1):
    print(combinations_count(N-K+1, i)*combinations_count(K-1, i-1))
Problem p02984 (python)

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

m=[0]*n

for i in range(n):
  if i%2 == 0:
    m[0]+=a[i]
  else:
    m[0]-=a[i]
for i in range(1,n):
  m[i] =(a[i-1]-m[i-1]/2)*2
  
for i in range(n):
  print(int(m[i]),end=" ")

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
a=[]
a=list(map(int, input().split()))
m=[0]*n
for i in list(reversed(range(a[0])):
  mn=0
  for j in range(n-1):
    if j==0:
      m[n-1]=i*2
      m[j]=(a[j]-m[n-1]/2)*2
    else:
      m[j]=(a[j]-m[j-1]/2)*2

  if m[n-2]/2+m[n-1]/2 ==a[n-1]:
    print(int(m[n-1]),sep=" ",end=" ")
    for i in range(n-1):
      print(int(m[i]),sep=" ",end=" ")


    sys.exit()
Problem p03835 (python)

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

count=0
for i in range(k+1):
  for j in range(k+1):
    if i+j>s:
      break
    if s-i-j<=k:
      count+=1

print(count)

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

count=0
for i in range(k):
  for j in range(k):
    if s-i-j=k:
      count+=1
      break
print(count)
Problem p03075 (python)

Fixed submission:
antennas = []

for _ in range(5):
  antennas.append(int(input()))

k = int(input())

available = True

for send in range(5):
  if not available:
    break
  for receive in range(5):
    if antennas[receive] - antennas[send] > k:
      available = False
      break

if available:
  print("Yay!")
else:
  print(":(")

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

antennas = []

for _ in range(5):
  antennas.append(int(input()))

k = int(input())

available = True

for send in range(5):
  if not available:
    break
  for receive in range(5):
    if antennas[receive] - antennas[send] > k:
      available = False
      break

if available:
  print("Yay!")
else:
  print(":(")
Problem p03127 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=A[0]
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
for i in range(1,N):
  B=gcd(B,A[i])
print(B)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=A[0]
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
for i in range(1,N):
  B=gcd(B,A[i])
prnt(B)
Problem p03135 (python)

Fixed submission:
t,x=map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
t,x=int(input().split())
print(t/x)
Problem p03207 (python)

Fixed submission:
n=int(input())
A=[int(input()) for i in range(n)]
cnt=0

for i in range(n):
  cnt+=A[i]
cnt-=max(A)*0.5
print(int(cnt))

Buggy submission (verdict: Runtime Error):
n=int(input())
A=[int,input() for i in range(n)]
cnt=0

for i in range(n):
  cnt+=A[i]
cnt-=max(A)*0.5
print(cnt)
Problem p03834 (python)

Fixed submission:
S = list(map(str, input().split(",")))
ans = ""
for i in S:
    ans += i + " "
print(ans)

Buggy submission (verdict: Runtime Error):
K, S = map(int, input().split())
count = 0
if K*3 < S:
    print(count)
else:
    for i in range(K, -1, -1):
        X = i
        YZ = S - X
        for j in range(K, -1, -1):
            Y = j
            Z = YZ - Y
            if Z > K:
                continue
            elif Z < 0:
                continue
            else:
                count += 1
                #print(X,Y,Z)
print(count)
Problem p02916 (python)

Fixed submission:
n = input()
n = int(n)
a = input().split()
b = input().split()
c = input().split()
a = [int(i) for i in a]
b = [int(i) for i in b]
c = [int(i) for i in c]

d = 0
for i in b:
  d += i

for i in range(n):
  if i + 1 < n:
    if a[i] +1  == a[i+1]:
      p = a[i]-1
      d += c[p]
  
print(d)

Buggy submission (verdict: Runtime Error):
n = int(n)
a = input().split()
b = input().split()
c = input().split()
a = [int(i) for i in a]
b = [int(i) for i in b]
c = [int(i) for i in c]

d = 0
for i in b:
  d += i

for i in range(n):
  if i + 1 < n:
    if a[i] +1  == a[i+1]:
      d += c[i-1]
  
print(d)
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
A=set([int(input()) for _ in range(M)])
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
	dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
	if i in A:
		dp[i]=0
print(dp[N])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(50000)
N,M=map(int,input().split())
L=[int(input()) for _ in range(M)]
ans=0

def dfs(i):
	global ans
	if i==N:
		ans+=1
		return True
	if i>N:return False
	if i in L:return True
	if dfs(i+1)==False:return True
	if dfs(i+2)==False:return True

dfs(0)
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
N,M=map(int,input().split())
L=[int(input()) for _ in range(M)]
ans=0

def dfs(i):
	global ans
	if i==N:
		ans+=1
		return True
	if i>N:return False
	if i in L:return True
	if dfs(i+1)==False:return True
	if dfs(i+2)==False:return True

dfs(0)
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
L=[int(input()) for _ in range(M)]
ans=0
dp=[]
def dfs(i):
	global ans
	if i==N:
		ans+=1
		# print(i)
		return True
	if i>N:return False
	if i in L:return True
	if dfs(i+1)==False:return True
	if dfs(i+2)==False:return True

dfs(0)
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
L=[int(input()) for _ in range(M)]
ans=0
def dfs(i):
	global ans
	if i==N:
		ans+=1
		# print(i)
		return True
	if i>N:return False
	if i in L:return False
	dfs(i+1)
	dfs(i+2)

dfs(0)
print(ans%1000000007)
Problem p03042 (python)

Fixed submission:
# -*- coding: utf-8 -*-

S=list(str(input()))
S1=int("".join(S[0:2]))
S2=int("".join(S[2:4]))

if 1 <= S1 <= 12:
    s1="MM"
else:
    s1="YY"
    
if 1 <= S2 <= 12:
    s2="MM"
else:
    s2="YY"


if s1 != s2:
    print(s1+s2)
else:
    if s1 == "MM" and s2 == "MM":
        print("AMBIGUOUS")
    elif S1 == 0 and s2 =="MM":
        print("YYMM")
    elif s1 == "MM" and S1 == 0:
        print("MMYY")
    else:
        print("NA")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

S=list(str(input()))
S1=int("".join(S[0:2]))
S2=int("".join(S[2:4]))

if S1 > 12  and 1 <= S2 <= 12 :    
    print("YYMM")
elif S2 > 12 and 1 <= S1 <= 12 :
    print("MMYY")
elif S1 == 0 and 1 <= S2 <= 12:
    print("YYMM")
elif S2 == 0 and 1 <= S1 <= 12:
    pirnt("MMYY")    
elif 1 <= S1 <= 12 and 1 <= S2 <= 12  :
    print("AMBIGUOUS")
else:
    print("NA")
Problem p02951 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a-b>=c:
  print(0)
else:
  print(c-(a-b))

Buggy submission (verdict: Runtime Error):
a,b,c=int(input())
if a-b>=c:
  print(0)
else:
  print(c-(a-b))
Problem p03011 (python)

Fixed submission:
a,b,c =input().split(" ")
mylist = [int(a),int(b),int(c)]
mylist.sort()
print(sum(mylist[0:2]))

Buggy submission (verdict: Runtime Error):
a,b,c =input().split(",")
mylist = [int(a),int(b),int(c)]
mylist.sort()
print(sum(mylist[0:2]))
Problem p03127 (python)

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


n=int(input())
a=list(map(int, input().split()))
prv=a[0]
for ai in a[1:]:
  prv=gcd(ai,prv)
print(prv)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int, input().split()))
prv=a[0]
for ai in a[1:]:
  prv=math.gcd(ai,prv)
print(prv)
Problem p02933 (python)

Fixed submission:
a = input()
a = int(a)
if a >= 3200:
  s = input()
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
N = int(input().rstrip())
v = input().rstrip().split(" ")
v.sort()
#print(v)
a = (int(v[0])+int(v[1])) / 2
i = 2
while i <= (N-1):
  a = (a + int(v[i])) / 2
  i += 1
print(':.6f'.format(a))

Buggy submission (verdict: Runtime Error):
N = int(input().rstrip())
v = input().rstrip().split(" ")
v.sort()
#print(v)
a = (int(v[0])+int(v[1])) / 2
i = 2
while i <= (N-1):
  a = (a + int(v[i])) / 2
  i += 1
print(a)

Buggy submission (verdict: Runtime Error):
N = int(input().rstrip())
A = input().rstrip().split(" ")
a = 0
for i in range(N):
  a += 1 / int(A[i])
b = 1 / a
print(b)

Buggy submission (verdict: Runtime Error):
a = input()
a = int(a)
if a >= 3200:
  s = input()
  print(s)
 else:
  print('red')

Buggy submission (verdict: Runtime Error):
a = int(input())
if a >= 3200:
  s = input()
  print(s)
 else:
  print('red')

Buggy submission (verdict: Runtime Error):
a = int(input().rstrip())
if a >= 3200:
  print(input())
 else:
  print("red")
Problem p02959 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0
for i in range(n):
    if a[i] < b[i]:
        count += a[i]
        b[i] -= a[i]
        a[i] = 0
    else:
        count += b[i]
        a[i] -= b[i]
        b[i] = 0
    if a[i+1] < b[i]:
        count += a[i+1]
        b[i] -= a[i+1]
        a[i+1] = 0
    else:
        count += b[i]
        a[i+1] -= b[i]
        b[i] = 0
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0
for i in range(n-1,-1,-1):
    # i+1の討伐
    if a[i+1] < b[i]:
        count += a[i+1]
        b[i] -= a[i+1]
        a[i+1] = 0
    else:
        count += b[i]
        a[i+1] -= b[i]
        b[i] = 0

    # iの討伐
    if a[i] < b[i]:
        count += a[i]
        b[i] -= a[i]
        a[i] = a
    else:
        count += b[i]
        a[i] -= b[i]
        b[i] = 0

print(count)
Problem p03011 (python)

Fixed submission:
p,q,r = map(int,input().split())

mintime = p + q + r - max(p,q,r)

print(mintime)

Buggy submission (verdict: Runtime Error):
p,q,r = map(int,input().split())


mintime = p + q
if(mintime > q + r):
    mintime = q + r
elif(mintime > p + r):
    mintime = P + r
print(mintime)

Buggy submission (verdict: Runtime Error):
p,q,r = map(int,input().split())

min = p + q
if(min > q + r):
    min = q + r
elif(min > p + r):
    min = P + r
print(min)
Problem p03036 (python)

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

for i in range(0,10):
    result = r * x - D
    print(result)
    x = result

Buggy submission (verdict: Runtime Error):
r = int(input())
D = int(input())
x = int(input())

for i in range(0,10):
    result = r * x - D
    print(result)
    x = result
Problem p02915 (python)

Fixed submission:
N = int(input())

anc = N**3
print(anc)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = sum(B)

now = 0
for i in A:
  pre = now
  now = i
  if now == (pre+1):
    ans += C[pre-1]
print(ans)
Problem p02933 (python)

Fixed submission:
N = int(input())
s = input()
 
if N >= 3200:
  print(s)
else:
  print('red')

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

def ave(c1,c2):
  av = (c1 + c2)/2
  return av

for i in range(N-1):
  for j in range(i+1,N):
    if a[j] <= a[i]:
      tmp = a[i]
      a[i] = a[j]
      a[j] =tmp
print(a)

for i in range(N-1):
  average = ave(a[0],a[1])
  a.pop(0)
  a.pop(0)
  a.insert(0,average)

print(int(a[0]))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = input()

if N >= 3200:
  print(s)
else:
  print(red)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = input()

if N >= 3200:
  print(s)
else:
  print(red)
Problem p02951 (python)

Fixed submission:
a,b,c = list(map(int, input().split()))
d = c-(a-b)
if d >= 0:
  print(d)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
a,b,c = list(map(int, input().split()))
d = c-(a-b)
if d >= 0:
  print(d)
else if:
  print(0)
Problem p02912 (python)

Fixed submission:
import sys
import heapq
input = sys.stdin.readline
 
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] *= -1
heapq.heapify(a)
 
for cnt in range(m):
    temp = heapq.heappop(a)*(-1)
    if temp == 0:
        break
    heapq.heappush(a, (temp//2)*(-1))
    
print(sum(a)*(-1))

Buggy submission (verdict: Runtime Error):
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    a[i] *= -1
heapq.heapify(a)

for cnt in range(m):
    temp = heapq.heappop(a)*(-1)
    if temp == 0:
        break
    heapq.heappush(a, (temp//2)*(-1))

print(sum(a)*(-1))

Buggy submission (verdict: Runtime Error):
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    a[i] *= -1
heapq.heapify(a)

for cnt in range(m):
    temp = heapq.heappop(a)*(-1)
    if temp == 0:
        break
    heapq.heappush(a, (temp//2)*(-1))

print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)

for cnt in range(m):
    if a[0] == 0:
        break
    a[0] = a[0] // 2
    if a[0] < a[1]:
         a.sort(reverse = True)

print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)

for cnt in range(m):
    a[0] = a[0] // 2
    if a[0] < a[1]:
         a.sort(reverse = True)

print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)

for cnt in range(m):
    a[0] = a[0] // 2
    if a[0] // 2 < a[1]:
         a.sort(reverse = True)

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)

cnt = 0
while cnt < m:
    if a[0] // 2 < a[1]:
        a[0] = a[0] // 2
        cnt += 1
        a.sort(reverse = True)
    else:
        a[0] = a[0] // 2
        cnt += 1
print(sum(a))
Problem p02989 (python)

Fixed submission:
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
s=0
N=int(n/2)
k=int(abs(d[N]-d[N-1]))
K=(d[N]+d[N-1])/2
for i in range(n):
    if d[i]>=K:
        s=s+1
    else:
        s=s
if s==N:
    print(k)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
s=0
N=int(n/2)
k=int(abs(d[N]-d[N-1]))
K=(d[N]+d[N-1])/2)
for i in range(n):
    if d[i]>=K:
        s=s+1
    else:
        s=s
if s==N:
    print(k)
else:
    print(0)
Problem p03012 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S=sum(A)
i=0
X=0
while X<S/2:
    X=X+A[i]
    i=i+1
k=i
ka=0
ja=0
wa=0
ya=0
za=0
for l in range(k+1):
    ka=ka+A[l]
for l in range(k):
    wa=wa+A[l]
for l in range(k-1):
    za=za+A[l]
Z=[]

Z.append(abs(S-ka-ka))
Z.append(abs(S-wa-wa))

Z.append(abs(S-za-za))
print(min(Z))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
S=sum(A)
i=0
X=0
while X<S/2:
    X=X+A[i]
    i=i+1
k=i
ka=0
ja=0
wa=0
ya=0
za=0
for l in range(k+2):
    ja=ja+A[l]
for l in range(k+1):
    ka=ka+A[l]
for l in range(k):
    wa=wa+A[l]
for l in range(k-2):
    ya=ya+A[l]
for l in range(k-1):
    za=za+A[l]
Z=[]
Z.append(abs(S-ja-ja))
Z.append(abs(S-ka-ka))
Z.append(abs(S-wa-wa))
Z.append(abs(S-ya-ya))
Z.append(abs(S-za-za))
print(min(Z))
Problem p03013 (python)

Fixed submission:
N,M = (int(i) for i in input().split())
ban=[False]*(N+1)
for i in range(M):
    a=int(input())
    ban[a]='True'
    
dp=[0]*(N+1)
dp[0]=1
if ban[1]=='True':
    dp[1]=0
else:
    dp[1]=1

for i in range(2,N+1):
    if(ban[i]):
        dp[i]=0
    else:
        dp[i]=dp[i-2]+dp[i-1]
print(dp[N]%1000000007)

Buggy submission (verdict: Runtime Error):
def p(boundary):
    step=[0]*(boundary+1)
    step[0]=0
    step[1]=1
    step[2]=2
    for i in range(2,boundary-1):
        step[i+1]=step[i]+step[i-1]
    d=step[boundary]
    return d


N,M = (int(i) for i in input().split())
a = [int(input()) for i in range(M)] 
b=[]
for i in range(0,M-2):
    b.append(a[i+1]-a[i]-2)
b.append(N-a[M-1]-1)
ans=p(a[0]-1)
for i in range(M):
    c=b[i]
    ans=p(c)*ans
print(ans)
Problem p02925 (python)

Fixed submission:
import sys
from collections import deque

n = int(input())
matches = [[a - 1 for a in map(int, line.split())] for line in sys.stdin]
#print(matches)
q = deque(range(n))
#print(q)
depth = [0] * n
waiting = [-1] * n

while q:
    a = q.popleft()
    b = matches[a].pop()
    #print(a, b)
    if waiting[b] == a:
        depth[a] = depth[b] = max(depth[a], depth[b]) + 1
        if matches[a]:
            q.append(a)
        if matches[b]:
            q.append(b)
    else:
        waiting[a] = b

if any(matches):
    print(-1)
else:
    print(max(depth))

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

for i in range(N):
  b.append(a[i][0])
print(b)
for j in range(N*(N-1)//2):
  for i in range(N):
    if i==b[b[i]-1]-1:
      c[i]+=1
      c[b[i]-1]+=1
  print(c)
  for i in range(N):
    b[i]=a[i][c[i]//2]
  print(b)
  cnt+=1
print('-1')
Problem p03834 (python)

Fixed submission:
s=input()
print(s.replace(',',' '))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
K,S=map(int,input().split())
crt=0
for x in range(0,K+1):
  for y in range(0,K+1):
    z=S-x-y
    if 0<=z<=K:
      crt+=1
print(crt)