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

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

def gcd(x_,y_):
	x = max(x_, y_)
	y = min(x_, y_)
	if y==0:
		return x
	if x%y == 0:
		return y
	return gcd(y, x%y)

L = [0]*n
R = [0]*n
L[0] = a[0]
R[-1] = a[-1]

for i in range(1,n):
	L[i] = gcd(L[i-1], a[i])
	j = n-1-i
	R[j] = gcd(R[j+1], a[j])

L = [0]+L
R = R + [0]
M = [0]*n
for i in range(n):
	M[i] = gcd(L[i],R[i+1])
print(max(M))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

def gcd_list(numbers):
	return reduce(math.gcd, numbers)

gcds = [gcd_list(a[:i]+a[i+1:]) for i in range(n)]

print(max(gcds))
Problem p03106 (python)

Fixed submission:
a,b,k = map(int, input().split())
mn = min(a,b)
cnt = 0
for i in range(mn, 0, -1):
    if a%i==0 and b%i==0:
        cnt += 1
    if cnt >= k:
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
cnt = 0
for i in range(min(a,b),-1,0):
  if a%i == 0 and b%i == 0:
    cnt += 1
  if cnt>=k:
    print(i)
    exit()
Problem p03129 (python)

Fixed submission:
n, k = map(int, input().split())
if n>=2*k-1:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
if n>=2*k-1:
  print('YES')
else:
  print('NO')
Problem p03148 (python)

Fixed submission:
import numpy as np

n, k = map(int, input().split())
mx = {}
sushi = []
for _ in range(n):
    t, d  = map(int, input().split())
    if t not in mx:
        mx[t] = d
    elif mx[t] < d:
        mx[t] = d
    sushi.append([t,d])

# 美味しさでソート
taste_sorted_sushi = sorted(sushi, key=lambda x:x[1], reverse=True)

# 貪欲にK個選び分割する
selected_sushi = np.array(taste_sorted_sushi[:k], dtype=np.int64)

# 貪欲なK個の種類の分布を調べる
# K個の中で二つ以上あるものとそうでないものに分ける
S = set()
q = []
for s in selected_sushi:
    if s[0] in S:
        q.append(s[1])
    else:
        S.add(s[0])

q = sorted(q, reverse=True)
ans = sum(selected_sushi[:,1])+len(S)**2
tmp = ans

#print(selected_sushi, selected_sushi[:,1], 'ans', ans, S, q)

#print(S)
for i in range(k,n):
    if not q:
        break
    if taste_sorted_sushi[i][0] not in S:
        #print('ans',ans)
        #print('taste_sorted_sushi',taste_sorted_sushi[i])
        tmp = tmp-q.pop()+taste_sorted_sushi[i][1]-len(S)**2 + (len(S)+1)**2
        ans = max(ans, tmp)
        S.add(taste_sorted_sushi[i][0])

print(ans)

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

n, k = map(int, input().split())
mx = {}
for _ in range(n):
    t, d  = map(int, input().split())
    if t not in mx:
        mx[t] = d
    elif mx[t] < d:
        mx[t] = d
    sushi.append((t,d))

# 美味しさでソート
taste_sorted_sushi = sorted(sushi, key=lambda x:x[1], reverse=True)

# 貪欲にK個選び分割する
selected_sushi = taste_sorted_sushi[:k]

# 貪欲なK個の種類の分布を調べる
# K個の中で二つ以上あるものとそうでないものに分ける
S = set()
q = []
for s in selected_sushi:
    if s[0] in S:
        q.append(s)
    else:
        S.add(s[0])

q = sorted(q, key=lambda x:x[1], reverse=True)
ans = sum(selected_sushi[:][1])+len(S)**2

S = set(selected_sushi[:][0])
for i in range(k,n):
    if taste_sorted_sushi[k] not in S:
        ans = max(ans, ans-q.pop()+taste_sorted_sushi[k]-len(S)**2 + (len(S)+1)**2
        S.add(taste_sorted_sushi[k][0])

print(ans)
Problem p03161 (python)

Fixed submission:
import numpy as np

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))

cost = np.zeros(n)


for i in range(1,n):
    left = max(0,i-k)
    cost[i] = (cost[left:i]+abs(h[i]-h[left:i])).min()
     

print(int(cost[-1]))

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

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))

cost = np.zeros(n)


for i in range(1,n):
    left = max(0,i-k)
    cost[i] = cost[left:i]+abs(h[i]-h[left:i]).min()
     

print(int(cost[-1]))
Problem p03239 (python)

Fixed submission:
n, t = map(int, input().split())
cmin = float("inf")
for i in range(n):
    ci, ti = map(int, input().split())
    if ti <= t and ci < cmin:
        cmin = ci
if cmin == float("inf"):
    print("TLE")
else:
    print(cmin)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
c = []
t = []
for i in range(N):
    tmp1, tmp2 = map(int, input().split())
    c.append(tmp1)
    t.append(tmp2)

tmp_min = float('inf')

for i in range(N):
    if t[i]<=T and tmp_min>c[i]:
        tmp_min = c[i]

if tmp_min == float('inf'):
    print('TLE')
else tmp_min<=T:
    print(int(tmp_min))
Problem p03240 (python)

Fixed submission:
n = int(input())
data = []

for _ in range(n):
    x, y, h = map(int, input().split())
    data.append((x,y,h))

data.sort(key=lambda x:x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        flg = False
        # print(cx, cy)
        tmp = None
        for k in data:
            x = k[0]
            y = k[1]
            h = k[2]
            if not tmp:
                tmp = h+abs(cx-x)+abs(cy-y)
                continue
            if h == 0 and tmp>abs(cx-x)+abs(cy-y):
                flg = True
                break
            elif h == 0:
                continue
            elif tmp == h+abs(cx-x)+abs(cy-y):
                continue
            else:
                flg = True 
                break
        if flg:
            continue
        else:
            print(cx, cy, tmp)
            exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
data = [tuple(map(int, input().split())) for _ in range(n)]
ax, ay, ah = list(filter(lambda x:x[2], data))[0]

for cx in range(101):
    for cy in range(101):
        H = h + abs(ax-cx) + abs(ay-cy)
        if all(max(H-abs(d[0]-cx)-abs(d[1]-cy),0)==d[2]) for d in data):
            print(cx, cy, H)
            exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
X = []
Y = []
H = []

for _ in range(n):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for cx in range(101):
    for cy in range(101):
        flg = False
        # print(cx, cy)
        tmp = None
        for k in range(n):
            # print(tmp)
            if H[k] == 0 and tmp<abs(cx-X[k])+abs(cy-Y[k]):
                flg = True
                break
            elif H[k] == 0:
                continue
            elif not tmp:
                tmp = H[k]+abs(cx-X[k])+abs(cy-Y[k])
                continue
            elif tmp == H[k]+abs(cx-X[k])+abs(cy-Y[k]):
                continue
            else:
                flg = True 
                break
        if flg:
            continue
        else:
            print(cx, cy, tmp)
            exit()
Problem p03262 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)

from fractions import gcd

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

X = list(map(int,input().split()))
X = [abs(i-x) for i in X]
# print(X)

# def gcd(m,n):
#     mx = max(m,n)
#     mn = min(m,n)
#     tmp = mx%mn
#     if tmp == 0:
#         return mn
#     else:
#         return gcd(mn, tmp)

def gcd_list(data):
    # if len(data)==1:
    #     return data[0]
    # tmp = gcd(data[0], data[1])
    # if len(data)==2:
    #     return tmp
    # else:
    #     new_data = [tmp]+data[2:]
    #     return gcd_list(new_data)
    ret = data[0]
    for d in data[1:]:
        ret = gcd(ret, d)
    return ret
# print(gcd_list([2,4,8]))
print(gcd_list(X))

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

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

X = list(map(int,input().split()))
X = [abs(i-x) for i in X]
# print(X)

def gcd(m,n):
    mx = max(m,n)
    mn = min(m,n)
    tmp = mx%mn
    if tmp == 0:
        return mn
    else:
        return gcd(mn, tmp)

def gcd_list(data):
    if len(data)==1:
        return data[0]
    tmp = gcd(data[0], data[1])
    if len(data)==2:
        return tmp
    else:
        new_data = [tmp]+data[2:]
        return gcd_list(new_data)

# print(gcd_list([2,4,8]))
print(gcd_list(X))
Problem p03290 (python)

Fixed submission:
import numpy as np
d, g = map(int ,input().split())
points = [list(map(int,input().split())) for _ in range(d)]

def min_q(comp_flg, target_score): # comp_flag[i]=True以外の問題iについて、compポイントを無視してtarget_scoreを超えるには最低いくつの問題数が必要かを返す
    score = 0
    q_num = 0
    for i in range(d-1,-1,-1):
        if comp_flg[i]:
            continue
        if target_score>score+points[i][0]*(i+1)*100:
            score += points[i][0]*(i+1)*100
            q_num += points[i][0] 
        else:
            q_num += np.ceil((target_score-score)/(100*(i+1)))
            break
    return q_num


mn = float('inf')
for i in range(1<<d):
    complete_flg = [False]*d
    tmp_q_num = 0
    tmp_point = 0
    for j in range(d):
        if i&(2**j) != 0:
            tmp_point += points[j][0] * 100*(j+1) + points[j][1]
            complete_flg[j] = True
            tmp_q_num += points[j][0]
    if tmp_point < g:
        tmp_q_num += min_q(complete_flg, g-tmp_point)
    if mn>tmp_q_num:
        mn = tmp_q_num

print(int(mn))

Buggy submission (verdict: Runtime Error):
d, g = map(int, input().split())
p = []
c = []
for i in range(d):
    a,b = map(int, input().split())
    p.append(a)
    c.append(b)

def recursive_min(score, pi):
    # 点数と（残っている）問題の数に対してminの問題数を返す
    min = float('inf')
    for i in range(d):
        if pi[i] > 1:
            next_pi = pi[:]
            next_pi[i] += -1
            next_score = score-(i+1)*100
        elif pi[i] == 1:
            next_pi = pi[:]
            next_pi[i] += -1
            next_score = score-c[i]-(i+1)*100
        else:
            continue

        if next_score<=0:
            return 1
        cand_min = 1+recursive_min(next_score, next_pi)
        if cand_min<min:
            min = cand_min
    return min

print(recursive_min(g, p))
Problem p03455 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
if (a*b)%2 == 0:
    print("Even")
else:
    print("Odd")
Problem p03478 (python)

Fixed submission:
n, a, b = map(int, input().split())
sum = 0
for i in range(n+1):
    isum = 0
    m = i
    while m != 0:
        isum += m%10
        m = m//10
    if isum >= a and isum <= b:
        sum += i
print(sum)

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

for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i

print(ans)
Problem p03493 (python)

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

Buggy submission (verdict: Runtime Error):
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(ans)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(a) - bin(a).rfind("1")-1)
print(ans)
Problem p03494 (python)

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

min = 10**10
for e in A:
    m=0 #eが2で割り切れる回数
    while e%2==0:
        e = e/2
        m+=1
    if min>m:
        min = m
print(min)

Buggy submission (verdict: Runtime Error):
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)
Problem p03494 (python)

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

i = 0
per = True
while per == True:
    for index in range(n):
        num = a[index]
        ans = divmod(num, 2)
        if num == 0 or ans[1] != 0:
            per = False
            break
        a[index] = ans[0]
    if per == True:
        i += 1
print(i)

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

i = 0
while True:
    a_ans = divmod(a, 2)
    b_ans = divmod(b, 2)
    c_ans = divmod(c, 2)
    if a_ans[1] == 0 and b_ans[1] == 0 and c_ans[1] == 0 and a !=0 and b !=0 and c !=0:
        i += 1
        a = a_ans[0]
        b = b_ans[0]
        c = c_ans[0]
    else:
        break
print(i)

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

i = 0
while True:
    a_ans = divmod(a, 2)
    b_ans = divmod(b, 2)
    c_ans = divmod(c, 2)
    if a_ans[1] == 0 and b_ans[1] == 0 and c_ans[1] == 0:
        i += 1
        a = a_ans[0]
        b = b_ans[0]
        c = c_ans[0]
    else:
        break
print(i)
Problem p02614 (python)

Fixed submission:
h,w,k=map(int,input().split())
c=[list(input())for i in range(h)]
d=0
for i in range(2**h):
    for j in range(2**w):
        x=bin(i)[2:]
        y=bin(j)[2:]
        x="0"*(h-len(x))+x
        y="0"*(w-len(y))+y
        p=0
        for s in range(h):
            for t in range(w):
                if x[s]==y[t]=="0" and c[s][t]=="#":
                    p+=1
        if p==k:
           d+=1
print(d)

Buggy submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
c=[list(input())for i in range(h)]
d=0
for i in range(2**h):
    for j in range(2**w):
        i=bin(i)[2:]
        j=bin(j)[2:]
        i="0"*(h-len(i))+i
        j="0"*(j-len(j))+j
        p=0
        for s in range(h):
            for t in range(w):
                if i[s]==j[t]==0 and c[s][t]=="#":
                    p+=1
        if p==k
        d+=1
print(d)
Problem p02681 (python)

Fixed submission:
s=input()
print("Yes"if s==input()[:-1]else"No")

Buggy submission (verdict: Runtime Error):
n=int(input())
d=[]
e=[]
for i in range(n):
    p=[0,0]
    s=input()
    for j in s:
        if j==")":
            if p[0]!=0:
                p[0]-=1
            else:
                p[1]+=1
        else:
            p[0]+=1
    if p[0]-p[1]>=0:
        d.append(p)
    else:
        e.append(p)
d=sorted(d,key=lambda x:x[1])
e=sorted(e,key=lambda x:-x[0])
s=d+e
q=0
for i,j in s:
    if q<j:
        print("No")
        exit()
    else:
        q=q-j+i
if q==0:
    print("Yes")
else:
    print("No")
Problem p02683 (python)

Fixed submission:
import numpy as np
n,m,x=map(int,input().split())
a=2**64
b=[np.array(list(map(int,input().split())),"i8")for i in range(n)]
for i in range(2**n):
    c=bin(i)[2:]
    c="0"*(n-len(c))+c
    l=np.zeros(m)
    q=0
    for j in range(n):
        if c[j]=="1":
            q+=b[j][0]
            l+=b[j][1:]
    if np.min(l)>=x:
        a=min(a,q)
if a==2**64:
    print(-1)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m,x=map(int,input().split())
a=0
b=[[np.array(list(map(int,input().split())))]for i in range(n)]
for i in range(2**n):
    c=bin(i)
    c="0"*(n-len(c))+c
    l=np.zeros(m)
    q=0
    for j in range(n):
        if c[j]=="1":
            q+=b[j][0]
            l+=b[j]
    if np.min(l)==x:
        a=min(a,q)
if a:
    print(a)
Problem p02697 (python)

Fixed submission:
n,m=map(int,input().split())
for i in range(m):
    print(i+1,2*m-i+(n%2==0 and 2*(m-i)-1>=n//2))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a,b=n//2,n//2+1
for i in range(m):
    print(i+1,2*m-i+(n%2==0 and 2*(m-i)>=n//2)
Problem p02734 (python)

Fixed submission:
n,s=map(int,input().split())
t=[0]*(s+1)
m=998244353
a=list(map(int,input().split()))
ans=0
for i in range(n):
    d=t.copy()
    if a[i]<=s:
        for j in range(a[i],s+1):
            t[j]+=d[j-a[i]]
        t[a[i]]+=i+1
    ans+=t[-1]
    ans%=m
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,s=map(int,input().split())
t=np.zeros(s+1)
m=998244353
a=list(map(int,input().split()))
ans=0
for i in range(n):
    if a[i]<=s:
        t[a[i]:]+=t[:-a[i]]
        t[a[i]]+=i+1
    ans+=t[-1]
    ans%=m
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,s=map(int,input().split())
t=np.zeros(s+1)
m=998244353
a=list(map(int,input().split()))
ans=0
for i in range(n):
    if a[i]<=s:
        t[a[i]:]+=t[:-a[i]]
        t[a[i]]+=i+1
    ans+=t[-1]
    ans%=m
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,s=map(int,input().split())
t=np.zeros(s+1)
m=998244353
a=list(map(int,input().split()))
ans=0
for i in range(n):
    if a[i]<=s:
        t[a[i]:]+=t[:-a[i]]
        t[a[i]]+=i+1
    ans+=t[-1]
    ans%=m
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,s=map(int,input().split())
t=np.zeros(s+1)
m=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(n):
    t[a[i]:]+=t[:-a[i]]
    if a[i]<=s:
        t[a[i]]+=i+1
    ans+=t[-1]
    ans%=m
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,s=map(int,input().split())
t=np.zeros(s+1)
m=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(n):
    t[a[i]:]+=t[:-a[i]]
    if a[i]<s:
        t[a[i]]+=i+1
    ans+=t[-1]
    ans%=m
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,s=map(int,input().split())
t=np.zeros(s+1)
m=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(n):
    t[a[i]:]+=t[:-a[i]]
    t[a[i]]+=i+1
    ans+=t[-1]
    ans%=m
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,s=map(int,input().split())
t=np.zeros(s+1)
m=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(n):
    t[a[i]:]+=t[:-a[i]]
    t[a[i]]+=i+1
    ans+=t[-1]
    ans%=m
print(int(ans))
Problem p02787 (python)

Fixed submission:
h,n=map(int,input().split())
p=[float("INF")]*(h+1)
p[0]=0
for i in range(n):
    a,b=map(int,input().split())
    for j in range(h+1):
        if p[min(h,j+a)]>p[j]+b:
            p[min(j+a,h)]=p[j]+b
print(p[-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
h,n=map(int,input().split())
d=sorted([list(map(int,input().split()))for i in range(n)])
p=np.array([float("INF")]*max(h+1,2*d[-1][0]+1))
p[0]=0
s=max(h+1,2*d[-1][0]+1)
for i in range(n):
    a,b=d[i][0],d[i][1]
    j=1
    while j*a<=s:
        p[j*a:]=np.minimum(p[j*a:],p[:-j*a]+j*b)
        j+=1
print(int(min(p[h:])))
Problem p02796 (python)

Fixed submission:
n=int(input())
d=sorted([list(map(int,input().split()))for i in range(n)],key=lambda x:x[0]+x[1])
c=-float("INF")
an=0
for i,j in d:
    if i-j>=c:
        an+=1
        c=i+j
print(an)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=sorted([list(map(int,input().split()))for i in range(n)],key=lambdax:x[0]+x[1])
c=-float("INF")
an=0
for i,j in d:
    if i-j>=c:
        an+=1
        c=i+j
print(an)
Problem p02802 (python)

Fixed submission:
n,m=map(int,input().split())
s=[0]*n
t=[0]*n
for i in range(m):
    a,b=map(str,input().split())
    a,
    a=int(a)-1
    if not s[a]:
        if b=="WA":
            t[a]+=1
        else:
            s[a]=1
print(sum(s),sum(t[i] for i in range(n)if s[i]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=[0]*n
t=[0]*n
for i in range(m):
    a,b=map(str,input().split())
    a,
    a=int(a)-1
    if not s[a]:
        if b=="WA":
            t[a]+=1
        else:
            s[a]=1
print(sum(s),sum(t[i] for i in range(n)if s[a]))
Problem p02814 (python)

Fixed submission:
from fractions import gcd
n,m=map(int,input().split())
a=[i//2 for i in set(list(map(int,input().split())))]
b=[]
for i in a:
    c=i
    p=0
    while c%2==0:
        c//=2
        p+=1
    b.append(p)
l=1
if len(set(b))==1:
    for i in a:
        l=l*i//gcd(i,l)
        if m<l:
            print(0)
            break
    else:
        print((m//l+1)//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
from math import gcd
n,m=map(int,input().split())
a=[i//2 for i in set(list(map(int,input().split())))]
l=1
for i in a:
    l=l*i//gcd(i,l)
print((m//l+1)//2)
Problem p02839 (python)

Fixed submission:
h,w=map(int,input().split())
a=[list(map(int,input().split()))for i in range(h)]
b=[list(map(int,input().split()))for i in range(h)]
s=[0]*w
s[0]=p=1<<6400
for i in range(h):
    for j in range(w):
        d=abs(a[i][j]-b[i][j])
        if j>0:
            s[j]|=s[j-1]
        s[j]=(s[j]<<d)|(s[j]>>d)
t=s[-1]
for i in range(6401):
    if t&(p<<i) or t&(p>>i):
        print(i)
        break

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(map(int,input().split()))for i in range(h)]
b=[list(map(int,input().split()))for i in range(h)]
c=[[abs(a[i][j]-b[i][j])for j in range(w)]for i in range(h)]
d=[[set()for i in range(w+1)]for j in range(h+1)]
d[1][1]=set([-c[0][0],c[0][0]])
for x in range(1,w+1):
    for y in range(1,h+1):
        if not (i==1 and j==1):
            a=d[x-1][y]|d[x][y-1]
            for i in a:
                d[x][y].add(i-c[x-1][y-1])
                if i+c[x-1][y-1]<=80*(h+w-x-y+1)
                    d[x][y].add(i+c[x-1][y-1])
print(abs(min(d[h][w],key=abs)))
Problem p02843 (python)

Fixed submission:
x=int(input())
if x>=100:
    if x%100/(x//100)<=5:
        print(1)  
    else:
        print(0)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
x=int(input())
if x%100/(x//100)>5:
    print(0)
else:
    print(1)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
b=[0]*(n-1)
def f(x,y):
    r=1
    for (i,j) in a[x]:
        if r==y:
            r+=1
        b[j]=r
        f(i,r)
        r+=1
f(0,0)
print(max(b))
print(*b,sep="\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
b=[0]*(n-1)
def f(x,y):
    r=1
    for (i,j) in a[x]:
        if r==y:
            r+=1
        b[j]=r
        f(i,r)
        r+=1
f(0,0)
print(max(b))
print(*ans,sep="\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
b=[0]*(n-1)
def f(x,y):
    r=1
    for (i,j) in a[x]:
        if r==y:
            r+=1
        b[j]=r
        f(i,r)
        r+=1
f(0,0)
print(max(b))
for i in b:
    print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
c=[None]*(n-1)
def f(x,y):
    r=1
    for i in a[x]:
        if r==y:
            r+=1
        c[i[1]]=r
        f(i[0],r)
        r+=1
f(0,0)
print(max(c))
for i in c:
    print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
c=[0]*(n-1)
def f(x,y):
    r=1
    for i in a[x]:
        if r==y:
            r+=1
        c[i[1]]=r
        f(i[0],r)
        r+=1
f(0,0)
print(max(c))
for i in c:
    print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
c=[0]*(n-1)
def f(x,y):
    r=1
    for i in a[x]:
        if r==y:
            r+=1
        c[i[1]]=r
        f(i[0],r)
        r+=1
f(1,0)
print(max(c))
for i in c:
    print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n+1)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c].append([d,i])
c=[0]*(n-1)
def f(x,y):
    r=1
    for i in a[x]:
        if r==y:
            r+=1
        c[i[1]]=r
        f(i[0],r)
        r+=1
f(1,0)
print(max(c))
for i in c:
    print(i)