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

Fixed submission:
import numpy as np

def main():
    #n = int(input())
    x,n = map( int, input().split())
    if n == 0:
        print(x)
    else:
        p = list(map( int, input().split()))

        l = []
        for i in range(-100,120):
            if i not in p:
                l.append(i)
        
        l2 = []
        if x not in p:
            print(x)
        else:
            for j in range(1,101):
                nump = x+j
                numm = x-j
                if numm in l:
                    l2.append(numm)
                if nump in l:
                    l2.append(nump)
                if len(l2)>0:
                    break
            print(l2[0])

        
    
if __name__ == '__main__':
    main()

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

def main():
    #n = int(input())
    x,n = map( int, input().split())
    if n == 0:
        print(x)
    else:
        p = list(map( int, input().split()))

        l = []
        for i in range(1,101):
            if i not in p:
                l.append(i)
        
        l2 = []
        for j in range(1,101):
            nump = x+j
            numm = x-j
            if nump in l:
                l2.append(nump)
            if numm in l:
                l2.append(numm)
            if len(l2)>0:
                break
        print(np.min(l2))

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

Fixed submission:
import copy

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            sum = sum * i
            if sum > 1000000000000000000:
                print(-1)
                exit()
        print(sum)
    
if __name__ == '__main__':
    main()

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

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    for i in a:
        sum = sum * i
    if np.log10(sum) >= 18:
        print(-1)
    else:
       print(sum)
    
if __name__ == '__main__':
    main()
Problem p02687 (python)

Fixed submission:
def main():
    a = input()
    if a == "ABC":
        print("ARC")
    else:
        print("ABC")
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    a = input()
    if a == "ABC"
        print("ARC")
    else:
        print("ABC")
if __name__ == '__main__':
    main()
Problem p02705 (python)

Fixed submission:
def main():
    pi = 3.14159265
    r = int(input())
    print(2*pi*r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
a = int(input())
b = list(map(int, input().split()))
for i in range(1,a+1):
  n = 0
  for j in b:
    if i == j:
      n = n + 1
      print(n)
Problem p02760 (python)

Fixed submission:
import numpy as np

grid = []
for i in range(3):
    array = list(map(int,input().strip().split()))
    grid.append(array)
    
grid = np.array(grid)

N = int(input())
s = [int(input()) for i in range(N)]

for i in s:
    grid = np.where(grid==i,0,grid)
    
#print(grid)
    
if grid[0][0]==0 and grid[0][1]==0 and grid[0][2]==0:
    han = "Yes"
elif grid[1][0]==0 and grid[1][1]==0 and grid[1][2]==0:
    han = "Yes"
elif grid[2][0]==0 and grid[2][1]==0 and grid[2][2]==0:
    han = "Yes"
elif grid[0][0]==0 and grid[1][0]==0 and grid[2][0]==0:
    han = "Yes"
elif grid[0][1]==0 and grid[1][1]==0 and grid[2][1]==0:
    han = "Yes"
elif grid[0][2]==0 and grid[1][2]==0 and grid[2][2]==0:
    han = "Yes"
elif grid[0][0]==0 and grid[1][1]==0 and grid[2][2]==0:
    han = "Yes"
elif grid[0][2]==0 and grid[1][1]==0 and grid[2][0]==0:
    han = "Yes"
else:
    han = "No"
print(han)

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

grid = []
for i in range(3):
    array = list(map(int,input().strip().split()))
    grid.append(array)
    
grid = np.array(grid)

N = int(input().split())
s = [int(input()) for i in range(N)]

for i in s:
    b = np.where(grid==i,0,grid)
    
if grid[0][0]==0 & grid[0][1]==0 & grid[0][2]==0:
    han = "Yes"
elif grid[1][0]==0 & grid[1][1]==0 & grid[1][2]==0:
    han = "Yes"
elif grid[2][0]==0 & grid[2][1]==0 & grid[2][2]==0:
    han = "Yes"
elif grid[0][0]==0 & grid[1][0]==0 & grid[2][0]==0:
    han = "Yes"
elif grid[0][1]==0 & grid[1][1]==0 & grid[2][1]==0:
    han = "Yes"
elif grid[0][2]==0 & grid[1][2]==0 & grid[2][2]==0:
    han = "Yes"
elif grid[0][0]==0 & grid[1][1]==0 & grid[2][2]==0:
    han = "Yes"
elif grid[0][2]==0 & grid[1][1]==0 & grid[2][0]==0:
    han = "Yes"
else:
    han = "No"
print(han)
Problem p02641 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
import bisect


def solve(X: int, N: int, p: "List[int]"):
    sortp = sorted(p)
    if(N == 0):
        print(X)
        exit()

    for i in range(100):
        # 左側
        l = X - i
        index = bisect.bisect_left(sortp,l)
        if(index == N or sortp[index] != l):
            print(l)
            exit()

        # 右側
        r = X + i
        index = bisect.bisect_left(sortp,r)
        if(index == N or sortp[index] != r):
            print(r)
            exit()

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(X, N, p)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import bisect


def solve(X: int, N: int, p: "List[int]"):
    sortp = sorted(p)
    if(N == 0):
        print(X)
        exit()

    for i in range(100):
        # 左側
        l = X - i
        index = bisect.bisect_left(sortp,l)
        if(sortp[index] != l):
            print(l)
            exit()

        # 右側
        r = X + i
        index = bisect.bisect_left(sortp,r)
        if(sortp[index] != r):
            print(r)
            exit()

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(X, N, p)

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

Fixed submission:
from sys import stdin
import collections
import math
import itertools

n,m,r   = [int(x) for x in stdin.readline().rstrip().split()]
r_arr = [int(x) for x in stdin.readline().rstrip().split()]

ways = [[int(c)  for c in stdin.readline().rstrip().split()] for _ in range(m)]
inf = float('inf')
cost = [[inf] * n for _ in range(n)]
for i in range(n):
    cost[i][i] = 0

for way in ways:
    cost[way[0]-1][way[1]-1] = way[2]
    cost[way[1]-1][way[0]-1] = way[2]


# ワーシャルフロイド
for k in range(n):
    for i in range(n):
        for j in range(n):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

# rの訪れ方を全パターン試して、最小の距離のものを答えにする。
tours = []
for perm in itertools.permutations(r_arr):
    d = 0
    for i in range(r-1):
        d += cost[perm[i]-1][perm[i+1]-1]
    tours.append(d)
print(min(tours))

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

n,m,r   = [int(x) for x in stdin.readline().rstrip().split()]
r_arr = [int(x) for x in stdin.readline().rstrip().split()]

ways = [[int(c)  for c in stdin.readline().rstrip().split()] for _ in range(m)]

cost = [[float("inf") for j in range(n)] for i in range(n)]
for i in range(n):
    cost[i][i] = 0

for way in ways:
    cost[way[0]-1][way[1]-1] = way[2]
    cost[way[1]-1][way[0]-1] = way[2]


# ワーシャルフロイド
for k in range(n):
    for i in range(n):
        for j in range(n):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

# rの訪れ方を全パターン試して、最小の距離のものを答えにする。
tours = []
for perm in itertools.permutations(r_arr):
    d = 0
    for i in range(r-1):
        d += cost[perm[i]][perm[i+1]]
    tours.append(d)
print(min(tours))
Problem p02628 (python)

Fixed submission:
n,m=map(int, input().split())
l=list(map(int, input().split()))
ans=0
l.sort()
for i in range(m):
    ans=ans+l[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
l=list(map(int, input().split()))
ans=0
l.sort()
for i in range(k):
    ans=ans+l[k]
print(ans)
Problem p02719 (python)

Fixed submission:
n,k=map(int, input().split())
if n>k:
    num=n%k
    print(min(num,k-num))
elif n==k:
    print(0)
else:
    print(min(n,k-n))

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
num=abs(n-k)
if num>k:
    print(num%k)
else:
    print(k%num)
Problem p02639 (python)

Fixed submission:
i = input().split(' ')
l_si_i = [int(s) for s in i]
p = l_si_i.index(0) + 1
print(p)

Buggy submission (verdict: Runtime Error):
i = input()
p = i.index(0) + 1
print(p)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
print('Even' if a * b % 2 == 0 else 'Odd')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print('Even' if num % 2 == 0 else 'Odd')
Problem p02641 (python)

Fixed submission:
import numpy as np
x,n=map(int,input().split())
p=np.array(list(map(int,input().split())))
p_abs=sorted(list(map(lambda k:abs(k-x),p)))
#print(p_abs)

if(len(p_abs)==0 or p_abs[0]!=0):
    print(x)
else:
    i=1
    while(True):
        if(2*i>=len(p)):
            if(x-i not in p):
                print(x-i)
            else:
                print(x+i)
            break
        elif(p_abs[2*i-1]!=i or p_abs[2*i]!=i):
            if(x-i not in p):
                print(x-i)
            else:
                print(x+i)
            break
        else:
            i+=1

Buggy submission (verdict: Runtime Error):
import numpy as np
x,n=map(int,input().split())
p=np.array(list(map(int,input().split())))
p_abs=sorted(list(map(lambda k:abs(k-x),p)))
#print(p_abs)

if(len(p_abs)==0 or p_abs[0]!=0):
    print(x)
else:
    i=1
    while(True):
        if(p_abs[2*i-1]!=i or p_abs[2*i]!=i):
            if(x-i not in p):
                print(x-i)
            else:
                print(x+i)
            break
        else:
            i+=1
Problem p02683 (python)

Fixed submission:
import numpy as np
n,m,x=map(int,input().split())
MAX=9999999999

c=[]
a=[]
for i in range(n):
    ca=list(map(int,input().split()))
    c.append(ca[0])
    a.append(ca[1:])

c=np.array(c)
a=np.array(a)

pat=2**n
ans=MAX
for i in range(pat):
    pat_i=bin(i)[2:].zfill(n)
    ai=np.array([0 for _ in range(m)])
    ansi=0

    for j in range(len(pat_i)):
        if(pat_i[j]=='1'):
            ansi+=c[j]
            ai+=a[j]

    if(min(ai)>=x):
        ans=min(ans,ansi)

if(ans!=MAX):
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m,x=map(int,input().split())
MAX=9999999999

c=[]
a=[]
for i in range(n):
    ca=list(map(int,input().split()))
    c.append(ca[0])
    a.append(ca[1:])

c=np.array(c)
a=np.array(a)

pat=2**n
ans=MAX
for i in range(pat):
    pat_i=bin(i)[2:].zfill(3)
    ai=np.array([0 for _ in range(m)])
    ansi=0

    for j in range(len(pat_i)):
        if(pat_i[j]=='1'):
            ansi+=c[j]
            ai+=a[j]

    if(min(ai)>=x):
        ans=min(ans,ansi)

if(ans!=MAX):
    print(ans)
else:
    print(-1)
Problem p02690 (python)

Fixed submission:
x=int(input())

b=0
while(True):
    bi=b**5
    ai=x+bi
#    print(ai,bi,(ai**(1/5))%1.0)
    #X-B^5 は整数を５乗した数か判定
    if(int((ai**(1/5))%1.0) == 0):

        aj=int((ai**(1/5))//1)
#        print(ai,aj,bi,b)
        if((aj**5)==ai):
            print(aj,b)
            break
    b*=-1

    bi=b**5
    ai=x+bi

    if(ai>=0 and int((ai**(1/5))%1.0) == 0):
        aj=int((ai**(1/5))//1)
#        print(ai,aj,bi,b)
        if((aj**5)==ai):
            print(aj,b)
            break
    b*=-1

    b+=1

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

b=0
while(True):
    bi=b**5
    ai=x+bi
    aj=int(ai**(1/5))
#    print(ai,aj,bi,b)
    if((aj**5)==ai):
        print(aj,b)
        break
    b*=-1

    bi=b**5
    ai=x+bi
    aj=int(ai**(1/5))
#    print(ai,aj,bi,b)
    if((aj**5)==ai):
        print(aj,b)
        break
    b*=-1

    b+=1
Problem p02696 (python)

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

def f(x):
    return (a*x)//b - a*(x//b)

print(f(min(b-1,n)))

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

def f(a,b,x):
    return (a*x)//b - a*(x//b)

print(f(min(b-1,n)))
Problem p02806 (python)

Fixed submission:
n=int(input())
s=[]
t=[]
for i in range(n):
	st=list(input().split())
	s.append(st[0])
	t.append(int(st[1]))
x=input()

print(sum(t[s.index(x)+1:]))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[]
t=[]
for i in range(n):
	st=list(input())
	s.append(st[0])
	t.append(st[1])
x=input()

print(sum(t[s.index(x):]))
Problem p02845 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
MOD=1000000007
hats=[0,0,0]
ans=1
for i in range(n):
    ai=a[i]
    ans=((ans%MOD)*hats.count(ai))%MOD
    if(ans==0):
        break
    hats[hats.index(ai)]+=1
#    print(ai,ans,hats)
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
MOD=1000000007
hats=[0,0,0]
ans=1
for i in range(n):
    ai=a[i]
    ans=((ans%MOD)*(hats.count(ai)%MOD))%MOD
    hats[hats.index(a[i])]+=1
print(ans)
Problem p02850 (python)

Fixed submission:
from collections import deque
n=int(input())
g=[[] for _ in range(n+1)]
e=[]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    e.append(b-1)

q=deque([0])

color=[0 for _ in range(n)]
while(len(q)>0):
    ei=q.popleft()
    c=1
    for x in g[ei]:
        if c == color[ei]:
            c+=1

        color[x]=c
        c+=1
        q.append(x)

print(max(color))
for i in e:
    print(color[i])

Buggy submission (verdict: Runtime Error):
from collections import deque
n=int(input())
g=[[] for _ in range(n+1)]
e=[]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)
    e.append(b)

q=deque([0])

color=[0 for _ in range(n)]
while(len(q)>0):
    ei=q.popleft()
    c=1
    for x in g[ei]:
        if c == color[ei]:
            c+=1

        color[x]=c
        c+=1
        q.append(x)

print(max(color))
for i in e:
    print(color[i])
Problem p02854 (python)

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

sum_a=sum(a)
left_a=0
right_a=sum_a
ans=200002*2020202020

for i in range(n):
    left_a+=a[i]
    right_a-=a[i]
    if(ans>abs(left_a-right_a)):
        ans=abs(left_a-right_a)
print(ans)

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

sum_a=sum(a)
left_a=0
right_a=sum_a
ans=math.inf

for i in range(n):
    left_a+=a[i]
    right_a-=a[i]
    if(ans>abs(left_a-right_a)):
        ans=abs(left_a-right_a)
print(ans)
Problem p02900 (python)

Fixed submission:
import fractions
a,b=map(int,input().split())
gcd_ab=fractions.gcd(a, b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

ans=1
ans+=len(set(prime_factorize(gcd_ab)))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
gcd_ab=math.gcd(a, b)
i=2
d={}
ans=1
while(gcd_ab!=1):
    if(gcd_ab%i == 0):
        val=d.get(i, 0)
        val+=1
        d[i]=val
        gcd_ab//=i
    else:
        i+=1
ans+=len(list(d.keys()))
print(ans)
Problem p02903 (python)

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

if(a>(w//2) and b>(h//2)):
    print('No')
else:
    for i in range(h):
        if(i<b):
            print(''.join(['0' for _ in range(a)]) + ''.join(['1' for _ in range(w-a)]))
        else:
            print(''.join(['1' for _ in range(a)]) + ''.join(['0' for _ in range(w-a)]))

Buggy submission (verdict: Runtime Error):
n=int(input())
print(10**n + 7)
Problem p02936 (python)

Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10**9)

n,q=map(int,input().split())

link=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

v_counter=[0 for _ in range(n)]
for _ in range(q):
    p,x=map(int,input().split())
    v_counter[p-1]+=x

point=[0 for _ in range(n)]
que=deque()
que.append(0)
used=set()
used.add(0)
point[0] += v_counter[0]

while(len(que)>0):
    ind=que.popleft()
    relate=link[ind]
    for i in relate:
        if(i in used):
            continue
        else:
            point[i] += point[ind] + v_counter[i]
            que.append(i)
            used.add(i)

print(*point)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
child=[[] for _ in range(n)]
point=[0 for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    child[a-1].append(b-1)

for i in range(q):
    p,x=map(int,input().split())
    point[p-1]+=x

ans=[0 for _ in range(n)]
def dfs(vertex,pt):
    pt_v=pt+point[vertex]
    ans[vertex]=pt_v
    child_v=child[vertex]
    for i in range(len(child_v)):
        dfs(child_v[i],pt_v)


dfs(0,0)

for i in range(n):
    print(ans[i],end=" ")

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
child=[[] for _ in range(n)]
point=[0 for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    child[a-1].append(b-1)

for i in range(q):
    p,x=map(int,input().split())
    point[p-1]+=x

ans=[0 for _ in range(n)]
def dfs(vertex,pt):
    pt_v=pt+point[vertex]
    ans[vertex]=pt_v
    child_v=child[vertex]
    for i in range(len(child_v)):
        dfs(child_v[i],pt_v)


dfs(0,0)

for i in range(n):
    print(ans[i],end=" ")

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
child=[[] for _ in range(n+1)]
point=[0 for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    child[a].append(b)

for i in range(q):
    p,x=map(int,input().split())
    point[p]+=x

ans=[0 for _ in range(n+1)]
def dfs(vertex,pt):
    pt_v=pt+point[vertex]
    ans[vertex]=pt_v
    child_v=child[vertex]
    for i in range(len(child_v)):
        dfs(child_v[i],pt_v)


dfs(1,0)

for i in range(1,n+1):
    print(ans[i],end=" ")

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
v_counter=[0 for _ in range(n+1)]
v_parent=[0 for _ in range(n+1)]

v_depth=[0 for _ in range(n+1)]
v_depth[1]=1
depth=[[] for _ in range(n+1)]
depth[1].append(1)

for i in range(n-1):
    a,b=map(int,input().split())
    v_parent[b]=a
    v_depth[b]=v_depth[a]+1
    depth[v_depth[b]].append(b)

for i in range(q):
    p,x=map(int,input().split())
    v_counter[p]+=x

v_list=[]
i=1
while(len(depth[i])!=0):
    v_list.extend(depth[i])
    i+=1

for i in range(n):
    vi=v_list[i]
    v_counter[vi]+=v_counter[v_parent[vi]]

for i in range(1,n+1):
    print(v_counter[i],end=" ")
print()
Problem p03149 (python)

Fixed submission:
a=''.join(list(sorted(list(input().split()))))
if(a=='1479'):
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
a=''.join(list(sorted(list(map(int,input().split())))))
if(a=='1479'):
	print('YES')
else:
	print('NO')
Problem p03160 (python)

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

mincost = [-1] * N
mincost[0] = 0
mincost[1] = abs(h[1] - h[0])

for i in range(2,N):
    a = mincost[i-2] + abs(h[i] - h[i-2])
    b = mincost[i-1] + abs(h[i] - h[i-1])
    mincost[i] = a if a < b else b

print(mincost[N-1])

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

mincost = [-1] * N

def calcMinCost(n):
#    print("calcMinCost(" + str(n) + ")")
#    print(mincost)
    if(n == 0):
        mincost[0] = 0
        return 0
    elif(n == 1):
        mincost[1] = abs(h[1] - h[0])
        return abs(h[1] - h[0])
    elif(mincost[n-1] != -1 and mincost[n-2] != -1):
        a = mincost[n-1] + abs(h[n-1] - h[n])
        b = mincost[n-2] + abs(h[n-2] - h[n])
        mincost[n] = a if a < b else b
        return mincost[n]
    elif(mincost[n-1] != -1):
        a = mincost[n-1] + abs(h[n-1] - h[n])
        b = calcMinCost(n-2) + abs(h[n-2] - h[n])
        mincost[n] = a if a < b else b
        return mincost[n]
    elif(mincost[n-2] != -1):
        a = calcMinCost(n-1) + abs(h[n-1] - h[n])
        b = mincost[n-2] + abs(h[n-2] - h[n])
        mincost[n] = a if a < b else b
        return mincost[n]
    else:
        a = calcMinCost(n-1) + abs(h[n-1] - h[n])
        b = calcMinCost(n-2) + abs(h[n-2] - h[n])
        mincost[n] = a if a < b else b
        return mincost[n]


print(calcMinCost(N-1))
Problem p03263 (python)

Fixed submission:
h,w=map(int,input().split())
a=[]
used=[[False for _ in range(w)] for _ in range(h)]
ans=[]
for i in range(h):
    ai=list(map(int,input().split()))
    for j in range(w):
        if(ai[j]%2!=0):
            if(j<w-1 and ai[j]>0 and ai[j]%2!=0 and not used[i][j]):
                used[i][j]=True
                ai[j]-=1
                ai[j+1]+=1
                ans.append([i+1,j+1,i+1,j+2])
    a.append(ai)

for i in range(h):
    if(i<h-1 and a[i][w-1]>0 and a[i][w-1]%2!=0 and not used[i][w-1]):
        used[i][w-1]=True
        a[i][w-1]-=1
        a[i+1][w-1]+=1
        ans.append([i+1,w,i+2,w])

print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(map(int,input().split())))

ans=[]
for i in range(h):
    for j in range(w):
        if(j==w-1 and i!=h-1 and a[i][j]%2!=0):
            a[i][j]-=1
            a[i+1][j]+=1
            ans.append([i,j,i+1,j])
        elif(a[i][j]%2!=0):
            a[i][j]-=1
            a[i][j+1]+=1
            ans.append([i,j,i,j+1])

print(len(ans))
for i in range(len(ans)):
    print(*ans[i])
Problem p03319 (python)

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

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
h.sort()

ans=9999999999999
for i in range(n-k+1):
    ans=min(ans,h[i+k-1]-h[i])
print(ans)
Problem p03323 (python)

Fixed submission:
a,b=map(int,input().split())
if(a+b%2==0):
    print('Yay!')
elif(a < 9 and b < 9):
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())
if(a+b%2==0):
    print('Yay!')
elif(a < 9 and b < 9):
    print('Yay!')
else:
    print(':(')
Problem p03380 (python)

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

def mid(a):
    if(a%2!=0):
        return (a+1)//2
    else:
        return a//2

ai=a[0]
temp=list(map(lambda x:abs(x-mid(ai)),a[1:]))
bi=a[temp.index(min(temp))+1]
print(str(ai)+" "+str(bi))

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

def mid(a):
    if(a%2!=0):
        return (a+1)//2
    else:
        return a//2
ai=a[0]
temp=list(map(lambda x:abs(x-mid(ai)),a[1:]))
bi=a[temp.index(min(temp))+1]
print(str(ai)+" "+str(ans[bi]))
Problem p03424 (python)

Fixed submission:
n=int(input())
s=list(input().split())
if('Y' in s):
	print("Four")
else:
	print("Three")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(map(int,input().split()))
if('Y' in s):
	print("Four")
else:
	print("Three")