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

Fixed submission:
s = input()
counter = [0]*2019
counter[0] = 1
ans = 0
res, d = 0, 1
for i in range(len(s)-1, -1, -1):
    res = (res+int(s[i])*d)%2019
    counter[res] += 1
    d = d*10%2019
for count in counter:
    ans += count*(count-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
dp = [0]*(len(s)-3)
for i in range(4, len(s)):
    dp[i-3] = dp[i-4]
    for j in range(i-3):
        if not int(s[j:i+1])%2019: dp[i-3]+=1
print(dp[-1])
Problem p02708 (python)

Fixed submission:
n, k = map(int, input().split())
mod = 10**9+7
mina = [0]*(n-k+2)
maxa = [0]*(n-k+2)
mina[0] = (k-1)*k//2
for i in range(k):
    maxa[0] += n-i
for i in range(1, n-k+2):
    mina[i] = mina[i-1]+i+k-1
    maxa[i] = maxa[i-1]+(n-k-i+1)
    if mina[i]>=mod and maxa[i]>=mod:
        mina[i] %= mod
        maxa[i] %= mod
ans = 0
for i in range(n-k+2):
    ans += maxa[i]-mina[i]+1
    ans %= mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10**9+7
mina = [0]*(n-k+2)
maxa = [0]*(n-k+2)
mina[0] = (k-1)*k//2
for i in range(k):
    maxa[0] += n-i
for i in range(1, n-k+2):
    mina[i] = mina[i-1]+i+k-1
    maxa[i] = maxa[i-1]+(n-k-i+1)
    if mina[i-k+1]>=mod and maxa[i-k+1]>=mod:
        mina[i-k+1] %= mod
        maxa[i-k+1] %= mod
ans = 0
for i in range(n-k+2):
    ans += maxa[i]-mina[i]+1
    ans %= mod
print(ans)
Problem p02720 (python)

Fixed submission:
K = int(input())

def cal():
    count = 9
    d = [[1,2,3,4,5,6,7,8,9]]
    for i in range(10**9):
        d_ = []
        for j in range(len(d[i])):
            a = str(d[i][j])
            if a[-1]=="0":
                for k in [0, 1]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            elif a[-1]=="9":
                for k in [8, 9]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return 
            else:
                for k in [-1, 0, 1]:
                    d_.append(int(a)*10+int(a[-1])+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
        d.append(d_)
if K <= 9:
    print(K)
else:
    cal()

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

def cal():
    count = 9
    d = [[1,2,3,4,5,6,7,8,9]]
    for i in range(10**9):
        d_ = []
        for j in range(len(d[i])):
            a = str(d[i][j])
            if a[-1]=="0":
                for k in [0,1]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            elif a[-1]=="9":
                for k in [8,9]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return 
            else:
                for k in [-1, 0, 1]:
                    d_.append(int(a)*10+int(a[-1])+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            d.append(d_)
if k <= 9:
    print(K)
else:
    cal()

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

def cal():
    count = 9
    d = [[1,2,3,4,5,6,7,8,9]]
    for i in range(10**9):
        d_ = []
        for j in range(len(d[i])):
            a = str(d[i][j])
            if a[-1]=="0":
                for k in [0,1]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            elif a[-1]=="9":
                for k in [8,9]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return 
            else:
                for k in [-1, 0, 1]:
                    d_.append(int(a)*10+int(a[-1])+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            d.append(d_)
if k <= 9:
    print(k)
else:
    cal()
Problem p02727 (python)

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
ans = r
for i in range(x):
    ans.append(p[i])
for i in range(y):
    ans.append(q[i])
r.sort(reverse=True)
print(sum(ans[:x+y]))

Buggy submission (verdict: Runtime Error):
IN = iter(Input.split('\n')).__next__
def input():
    return IN()

# 入力
from collections import deque
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
p += [0]
q = list(map(int, input().split()))
q += [0]
r = list(map(int, input().split()))
r += [0]
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
n, m, l = 0, 0, 0
ans = 0
for i in range(x+y):
    if (p[n] >= r[l] or q[n] >= r[l]) and n < x and m < y:
        if p[n] >= q[m]:
            ans += p[n]
            n += 1
        else:
            ans += q[m]
            m += 1
    elif n == x:
        if q[m] >= r[l]:
            ans += q[m]
            m += 1
        else:
            ans += r[l]
            m += 1
            l += 1
    elif m == y:
        if p[n] >= r[l]:
            ans += p[n]
            n += 1
        else:
            ans += r[l]
            n += 1
            l += 1    
    else:
        if p[n] >= q[m]:
            ans += r[l]
            m += 1
            l += 1
        else:
            ans += r[l]
            n += 1
            l += 1
print(ans)
Problem p02733 (python)

Fixed submission:
h, w, k = map(int, input().split())
s = [[int(i) for i in input()] for _ in range(h)]
ans = (h-1)+(w-1)
for i in range(2**(h-1)):
    d = [(i >> j) & 1 for j in range(h-1)]
    count, count_tmp = [0]*(sum(d)+1), [0]*(sum(d)+1)
    ans_, res = 0, 0
    flag = False
    for w_ in range(w):
        count[0] += s[0][w_]
        count_tmp[0] += s[0][w_]
        res += 1
        tmp = 0
        for h_ in range(1, h):
            if d[h_-1]: tmp += 1
            if s[h_][w_]:
                count[tmp] += 1
                count_tmp[tmp] += 1
        for j in count:
            if j > k:
                if res==1:
                    flag = True
                    break
                else:
                    for idx in range(sum(d)+1):
                        count[idx] = count_tmp[idx]
                    ans_ += 1
                    res = 1
                    break
        if flag: break
        count_tmp = [0]*(sum(d)+1)
    if flag: continue
    ans_ += sum(d)
    ans = min(ans, ans_)
print(ans)

Buggy submission (verdict: Runtime Error):
IN = iter(Input.split('\n')).__next__
def input():
    return IN()

# 入力
h, w, k = map(int, input().split())
s = []
for _ in range(h):
    s_ = [int(i) for i in input()]
    s.append(s_)
ans = float("INF")
for i in range(2**(h-1)):
    d = [(i >> j) & 1 for j in range(h-1)]
    count, count_tmp = [0]*(sum(d)+1), [0]*(sum(d)+1)
    ans_, res = 0, 0
    flag = False
    for w_ in range(w):
        count[0] += s[0][w_]
        count_tmp[0] += s[0][w_]
        res += 1
        tmp = 0
        for h_ in range(1, h):
            if d[h_-1]: tmp += 1
            if s[h_][w_]:
                count[tmp] += 1
                count_tmp[tmp] += 1
        for j in count:
            if j > k:
                if res==1:
                    flag = True
                    break
                else:
                    for idx in range(sum(d)+1):
                        count[idx] = count_tmp[idx]
                    ans_ += 1
                    res = 0
                    break
        if flag: break
        count_tmp = [0]*(sum(d)+1)
    ans_ += sum(d)
    ans = min(ans, ans_)
print(ans)
Problem p02743 (python)

Fixed submission:
a,b,c=map(int,input().split())
if c-a-b>0 and (c-a-b)**2>4*a*b:  
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(float, input().split())
if c-a-b>0 and 4*ab<(c-a-b)**2
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(float, input().split())
if c-a-b>0 and 4ab<(c-a-b)**2
    print("Yes")
else:
    print("No")
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
m = 10**9+7
def cmb(r):
    N = 1
    R = 1
    for i in range(r):
        N = N*(n - i) % m
        R = R*(i+1) % m
    return N*pow(R, m-2, m)%m

ans = (pow(2, n, m) - ((cmb(a) + cmb(b) + 1)%m))%m
print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
mod = 10**9+7
ans = 2**n-1%mod
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**4
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
a = 0
a += cmb(n,b,mod) 
a += cmb(n,b,mod) 
print((ans-a)%mod)
Problem p02783 (python)

Fixed submission:
h, a = map(int, input().split())
count = 1
count += h // a
if h % a == 0:
    count -= 1
print(count)

Buggy submission (verdict: Runtime Error):
n, d, a = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
A.sort()
count = 0
for i in range(n):
    if A[i][1] > 0:
        sx = A[i][0]
        if A[i][1] % a == 0:
            count_a = A[i][1] // a
        else:
            count_a = A[i][1] // a +1
        A[i][1] -= count_a * a
        count += count_a
        for j in range(i+1, n):
            if A[j][1] > sx + d*2:
                break
            else:
                A[j][1] -= count_a * a
print(count)
Problem p02787 (python)

Fixed submission:
h, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(k)]
maxa = max(a for a,b in ab)
dp = [0 for i in range(h+maxa)]
for i in range(1, h+maxa):
    dp[i] = min(dp[i - a]+b for a,b in ab)
print(min(dp[h:]))

Buggy submission (verdict: Runtime Error):
h, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(k)]
dp = [0 for i in range(h+1)]
for i in range(1, h+1):
    dp[i] = min(dp[i - a]+b for a,b in ab)
print(min(dp[h:]))

Buggy submission (verdict: Runtime Error):
h, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(k)]
dp = [0 for i in range(10**3+1)]
for i in range(1, h+1):
    dp[i] = min(dp[i - a]+b for a,b in ab)
print(dp[h])

Buggy submission (verdict: Runtime Error):
h, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(k)]
dp = [0 for i in range(h+1)]
for i in range(1, h+1):
    dp[i] = min(dp[i - a]+b for a,b in ab)
print(dp[h])

Buggy submission (verdict: Runtime Error):
h, k = map(int, input().split())
a = []
b = []
for i in range(k):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
dp = [0 for _ in range(h+1)]

for i in range(1, h+1):
    m0 = dp[i-a[0]] + b[0]
    for j in range(1, len(a)):
        m = dp[i-a[j]] + b[j]
        m0 = min(m, m0)
    dp[i] = m0

print(dp[h])

Buggy submission (verdict: Runtime Error):
h, k = map(int, input().split())
a = []
b = []
for i in range(k):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
dp = [0 for _ in range(h+1)]

for i in range(h+1):
    m0 = dp[i-a[0]] + b[0]
    for j in range(1, len(a)):
        m = dp[i-a[j]] + b[j]
        m0 = min(m, m0)
    dp[i] = m0

print(dp[h])
Problem p02788 (python)

Fixed submission:
from collections import deque
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for i in range(n)]
xh.sort()
que = deque()
ans = 0
atk = 0
for x, h in xh:
    while que and que[0][0] <= x:
        atk -= que.popleft()[1]
    h -= a*atk
    if h <= 0:
        continue
    count = -(-h//a)
    ans += count
    atk += count
    que.append((x+2*d+1, count))
print(ans)

Buggy submission (verdict: Runtime Error):
n, d, a = map(int, input().split())
x = []
h = []
for i in range(n):
    x_, h_ = map(int, input().split())
    x.append(x_)
    h.append(h_)
n_list = range(max(x))

count = 0
j = 0

for i in range(n):
    if x[i] > 0:
        print(h)
        s = x[i]
        bakuha = (h[i]//a)
        h[i] = 0
        count += bakuha
        if i < n-1:
            j = i+1
            while x[j] <= s+(2*d):
                h[j] -= bakuha*a
                if j < n-1:
                    j += 1
                    if h[j] <= 0:
                        h[j] = 0
                        break
                else:
                    break
print(count)
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
a_list = []
b_list = ["f"] * (10**5+1)
count_ac = 0
count_wa = 0
for i in range(m):
    a,b = map(str, input().split())
    a_list.append((int(a),b))
for i in range(m):
    if a_list[i][1] == "WA" and b_list[a_list[i][0]] == "f":
        count_wa += 1
    if a_list[i][1] == "AC":
        if b_list[a_list[i][0]] == "f":
            count_ac += 1
        b_list[a_list[i][0]] = "t"
for i in range(m):
    if b_list[a_list[i][0]] == "f" and a_list[i][1] == "WA":
        count_wa -= 1
print(count_ac,count_wa)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a_list = []
b_list = ["f"] * (10**5+1)
count_ac = 0
count_wa = 0
for i in range(m):
    a,b = map(str, input().split())
    a_list.append((int(a),b))
for i in range(m):
    if a_list[i][1] == "WA" and b_list[a_list[i][0]] == "f":
        count_wa += 1
    if a_list[i][1] == "AC":
        if b_list[a_list[i][0]] == "f":
            count_ac += 1
        b_list[a_list[i][0]] = "t"
for i in range(m):
    if b_list[a_list[i][0]] == "f" and b_list[a_list[i][1]] == "WA":
        count_wa -= 1
print(count_ac,count_wa)
Problem p02803 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
c = [input() for _ in range(h)]
ans = -1

def bfs(sx, sy):
    que = deque([[sy, sx]])
    d = [[-1] * w for _ in range(h)]
    d[sy][sx] = 0
    res = 0
    while que:
        y, x = que.popleft()
        res = max(res, d[y][x])
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            nx, ny = x+i, y+j
            if 0 <= nx and nx < w and 0 <= ny and ny < h and d[ny][nx] == -1 and c[ny][nx] != "#":
                nx_, ny_ = nx-i, ny-j
                d[ny][nx] = d[ny_][nx_] + 1
                que.append([ny, nx])
    return res

for i_ in range(h):
    for j_ in range(w):
        if c[i_][j_] != "#":
            ans = max(ans, bfs( j_, i_))

print(ans)

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

h, w = map(int, input().split())
c = [list(input()) for i in range(h)]
ans = -1

def bfs(sx, sy):
    que = deque([[sy, sx]])
    d = [["."] * w for _ in range(h)]
    count = 0
    d[sy][sx] = 0
    while que:
        y, x = que.popleft()
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            nx, ny = x+i, y+j
            if 0 <= nx and nx < w and 0 <= ny and ny < h and d[ny][nx] == "." and c[ny][nx] != "#":
                nx_, ny_ = nx-i, ny-j
                d[ny][nx] = d[ny_][nx_] + 1
                que.append([ny, nx])
    return max(max(d))

for i_ in range(h):
    for j_ in range(w):
        if c[i_][j_] == "#":
            continue
        ans = max(ans, bfs( j_, i_))

print(ans)
Problem p02814 (python)

Fixed submission:
import fractions
import sys
n, m = map(int, input().split())
a = list(map(int, input().split()))
lcm = a[0]
for i in range(1, len(a)):
    lcm = lcm*a[i]//fractions.gcd(lcm,a[i])
for i in a:
    if(lcm//i)%2 == 0:
        print(0)
        sys.exit()
lcm //= 2
print(m//lcm-(m//(lcm*2)))

Buggy submission (verdict: Runtime Error):
import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
    b_ = i//2
    b.append(b_)
count = 0
flag = True

while res % 2 != 0:
    res = a[0]/2
    count += 1
for i in a:
    if i % 2**count != 0:
        flag = False
        break
if flag:    
    lcm = b[0]
    for i in range(1, len(b)):
        lcm = lcm*b[i]//fractions.gcd(lcm,b[i])
    ans = m // lcm - (m//(lcm*2))
    print(ans)
else:
    print(0)
Problem p02823 (python)

Fixed submission:
n, a, b = map(int, input().split())
if abs(a-b)%2:
    if b>a: a, b = b, a
    print(min(a-1, n-b)+1+(b-a-1)//2)
else:
    print(abs(a-b)//2)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
ans = 0
if abs(a-b)%2:
    if max(a, b)-1 >  n-min(a, b):
        if a > b:
            pirnt(n-a+abs(n-(b+n-a)))
        else:
            pirnt(n-b+abs(n-(a+n-b)))
    else:
        if a > b:
            print(b-1+abs(1-(a-b+1)))
        else:
            print(a-1+abs(1-(b-a+1)))
else:
    print(abs(a-b)//2)
Problem p02838 (python)

Fixed submission:
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()] , dtype=np.int64)
m = 10**9+7
ans = 0
for k in range(60):
    b = (a>>k) & 1
    res = np.count_nonzero(b)
    ans += res*(n-res)*2**k
print(ans%m)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()] , dtype=np.int64)
a_ = list(map(int, input().split()))
m = 10**9+7
ans = 0
for k in range(60):
    b = (a>>k) & 1
    res = np.count_nonzero(b)
    ans += res*(n-res)*2**k
print(ans%m)
Problem p02848 (python)

Fixed submission:
n = int(input())
s = input()
d = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
print(''.join([d[(d.index(i) + n) % 26] for i in s]))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
d = "ABCDEFGHIJKLMNOPQRSTUVXYZ"
print(''.join([d[(d.index(i) + n) % 26] for i in s]))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
d = "ABCDEFGHIJKLMNOPQRSTUVXYZ"
print("".join([d[(d.index(i)+n)%26] for i in s]))
Problem p02900 (python)

Fixed submission:
def prime_factorize(n):
    res = []
    while n % 2 == 0:
        res.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            res.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        res.append(n)
    return res
from fractions import gcd
a, b = map(int, input().split())
print(len(set(prime_factorize(gcd(a, b))))+1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
al = [1]
bl = [1]
for i in range(2, min(int(a**0.5+1), int(b**0.5+1))):
    if a%i==0:
        resa, resb = a, b
        while resa%i==0:
            resa //= i
        al.append(i)
    if b%i==0:
        while resb%i==0:
            resb //= i
        bl.append(i)
print(len(set(al)&set(bl)))
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
ans = []
res = 0
nh = h[0]
for i in range(1, n):
    if nh >= h[i]:
        res += 1
        nh = h[i]
    else:
        ans.append(res)
        res = 0
        nh = h[i]
ans.append(res)
print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
ans = []
res = 0
nh = h[0]
for i in range(1, n):
    if nh >= h[i]:
        res += 1
        nh = h[i]
    else:
        res = 0
        nh = h[i]
    ans.append(res)
print(max(ans))
Problem p02936 (python)

Fixed submission:
from collections import deque
n, q = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
count = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    count[p-1] += x
q = deque([0])
d = [0]*n
while q:
    v = q.popleft()
    d[v] = 1
    for i in g[v]:
        if d[i]:
            continue
        count[i] += count[v]
        q.append(i)
print(*count)

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
edge = [[] for _ in range(n)]
counter = [0]*n
for _ in range(n-1):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
for _ in range(q):
    a, b = map(int, input().split())
    counter[a-1] += b
def dfs(start, prev=-1):
    for i in edge[start]:
        if i == prev: continue
        counter[i] += counter[start]
        dfs(i, start)
dfs(0)
print(*counter)

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
edge = [[] for _ in range(n)]
counter = [0]*n
for _ in range(n-1):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
for _ in range(q):
    a, b = map(int, input().split())
    counter[a-1] += b
def dfs(start, prev):
    for i in edge[start]:
        if i == prev: continue
        counter[i] += counter[start]
        dfs(i, start)
dfs(0, -1)
print(*counter)

Buggy submission (verdict: Runtime Error):
#26　AtCoder Beginner Contest 138 D - Ki
n, q = map(int, input().split())
edge = [[] for _ in range(n)]
counter = [[] for _ in range(n)]
ans_list = [0]*n

def dfs(start, count):
    ans_list[start] += count
    for c in edge[start]:
        dfs(c, count)

for _ in range(n-1):
    u, v = map(int, input().split())
    edge[u-1].append(v-1)
for _ in range(q):
    u, v = map(int, input().split())
    dfs(u-1, v)
print(*ans_list)

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

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

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

def dfs(x, d, s):
    for y in v[x]:
        if d[y]:
            s += f[y]
            ans[y] = s
            d[y] = 0
            dfs(y, d, s)
            s -= f[y]

ans = [0]*n
d = [1]*n
d[0] = 0
ans[0] = f[0]
s = f[0]
dfs(0, d, s)
print(*ans)
Problem p02971 (python)

Fixed submission:
n = int(input())
a1 = int(input())
a2 = int(input())
if a1 >= a2:
    maxa1 = a1
    maxa2 = a2
    res = 0
else:
    maxa1 = a2
    maxa2 = a1
    res = 1

for i in range(2, n):
    a_ = int(input())
    if maxa1 <= a_:
        maxa2 = maxa1
        maxa1 = a_
        res = i
    elif maxa2 <= a_:
        maxa2 = a_

for i in range(n):
    if i == res:
        print(maxa2)
    else:
        print(maxa1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a1 = int(input())
a2 = int(input())
if a[0] >= a[1]:
    maxa1 = a1
    maxa2 = a2
    res = 0
else:
    maxa1 = a2
    maxa2 = a1
    res = 1

for i in range(2, n):
    a_ = int(input())
    if maxa1 <= a_:
        maxa2 = maxa1
        maxa1 = a_
        res = i
    elif maxa2 <= a_:
        maxa2 = a_

for i in range(n):
    if i == res:
        print(maxa2)
    else:
        print(maxa1)
Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())
if (r-l) >= 2019:
    print(0)
    exit()
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)
print(ans)

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())
if (r-l) >= 2019:
    print(0
    exit()
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)
print(ans)