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

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

if a == b:
 print('H')
else:
 print('D')

Buggy submission (verdict: Runtime Error):
import numpy as np
from itertools import product as p
N, K = map(int, input().split())
a = np.array(list(map(int, input().split())))
bs = np.array(list(p((True, False), repeat=N)))

z = np.zeros(N, dtype=int)
ids = np.arange(N)
if sum(a) < K:
 print(0)
else:
 for i in range(N):
  Si = sum(a[bs[i,:]])
  if Si < K: continue
  for j in ids[bs[i,:]]:
   if Si - a[j] < K: z[j] = 1
 print(N-sum(z))

Buggy submission (verdict: Runtime Error):
import numpy as np
from itertools import product as p
N, K = map(int, input().split())
a = np.array(list(map(int, input().split())))
bs = np.array(list(p((True, False), repeat=N)))

z = np.zeros(N, dtype=int)
ids = np.arange(N)
if sum(a) < K:
 print(0)
else:
 for i in range(N):
  Si = sum(a[bs[i,:]])
  if Si < K: continue
  for j in ids[bs[i,:]]:
   if Si - a[j] < K: z[j] = 1
 print(N-sum(z))

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

if a == b:
 print('H')
else:
 print('D')s
Problem p03779 (python)

Fixed submission:
X = int(input())

i=0
while(i*(i+1)<2*X):
 i+=1

print(i)

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

def move(i, x):
 if x == X:
  return i
 elif i > X:
  return X+1
 else:
  if x > X:
   return min([move(i+1, x-(i+1)), move(i+1, x)])
  else:
   return min([move(i+1, x+(i+1)), move(i+1, x)])

print((move(0,0)))
Problem p03795 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10000)


def main():
    # 入力処理
    N = int(input())

    # アルゴリズム本体
    x = 800 * N
    y = 200 * int(N / 15)

    # 出力
    print(x-y)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import math
# sys.setrecursionlimit(10000)


def main():
    # 入力処理
    N, M = map(int, input().split())

    # アルゴリズム本体
    K = int(M / 2)

    # 出力
    print(K)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import math
# sys.setrecursionlimit(10000)


def main():
    # 入力処理
    N, M = map(int, input().split())

    # アルゴリズム本体
    K = N + int((M - 2 * N) / 4)

    # 出力
    print(K)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import math
# sys.setrecursionlimit(10000)


def main():
    # 入力処理
    N, M = map(int, input().split())

    # アルゴリズム本体
    if N >= 2 * M:
        K = int(M / 2)
    else:
        K = N + int((M - 2 * N) / 4)

    # 出力
    print(K)


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

Fixed submission:
x, a = input().split()
if x < a:
  print("0")
else:
  print("10")

Buggy submission (verdict: Runtime Error):
bound = 0
length = 0

n, x = input().split()
l = input().split()

for i in range(int(n)):
  if length <= int(x):
    length += int(l[i])
    bound += 1
  else:
    break

print(bound)
Problem p03000 (python)

Fixed submission:
N, X_MAX=input().split()
L = input().split()
count_i = 1
X = 0

for L_n in L:
    X += int(L_n)
    if int(X_MAX) < X:
        break
    count_i += 1
print(count_i)

Buggy submission (verdict: Runtime Error):
N, X_MAX=input().split()
L = input().split()
i = 0
X = 0

while int(X_MAX) >= X:
    X += int(L[i])
    i+=1
print(i)

Buggy submission (verdict: Runtime Error):
N, X_MAX=input().split()
L = input().split()
i = 0
X = 0

while int(X_MAX) >= X:
    X += int(L[i])
    i+=1
print(i)
Problem p02983 (python)

Fixed submission:
import sys
import numpy as np 
def minimize():
    L, R=map(int,input().split())
    lis=[]
    if (L+2019) >= R:
        
        for i in range(L,R):
            for j in range(i+1, R+1):
                x=(i*j) %2019
                lis.append(x)
        lis=np.array(lis)
        ans=lis.min()
        print(ans)
    
    else :
        for i in range(L,(L+2019)):
            for j in range(i+1, L+2020):
                x=(i*j) %2019
                lis.append(x)
        lis=np.array(lis)
        ans=lis.min()
        print(ans)


minimize()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np 
def minimize():
    L, R=map(int,input().split())
    lis=[]
    for i in range(L,R):
        for j in range(i+1, R+1):
            x=(i*j) %2019
            lis.append(x)
        if len(np.uniq(lis))==2018:
            break
    lis=np.array(lis)
    ans=lis.min()
    print(ans)

minimize()
Problem p03720 (python)

Fixed submission:
import numpy as np
n, m = map(int, input().split())
road = [0]*n
a = [0]*m
a = np.array(a)
b = [0]*m
b = np.array(b)
for i in range(m):
  x, y = input().split()
  a[i] = (int(x))
  b[i] = (int(y))
for i in range(m):
  road[int(a[i]) - 1] += 1
  road[int(b[i]) - 1] += 1
for i in road:
    print(i)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, m = map(int, input().split())
road = [0]*n
a = [0]*m
a = np.array(a)
b = [0]*m
b = np.array(b)
for i in range(m):
  x, y = input().split()
  a[i] = (int(x))
  b[i] = (int(y))
for i in road:
  road[int(a[i]) - 1] += 1
  road[int(b[i]) - 1] += 1
for i in road:
    print(i)
Problem p02981 (python)

Fixed submission:
nab = input().split()
n = int(nab[0])
a = int(nab[1])
b = int(nab[2])

if n*a > b:
  print(b)
else:
  print(n*a)

Buggy submission (verdict: Runtime Error):
nab = input().split()
n = nab[0]
a = nab[1]
b = nab[2]

if n*a > b:
  print(n*a)
else:
  print(b)
Problem p02983 (python)

Fixed submission:
import sys
lr = list(map(int, input().split()))
l = lr[0]
r = lr[1]
lmod = l%2019

def minfunc(x, y):
    if x > y:
        return y
    else:
        return x

if r - l >= 2019:
    print(0)
elif 2019 <= r - l + lmod:
    print(0)
else:
    min = 9999999
    modlist = list(map(lambda x: x%2019,range(l,r+1)))
    for i in range(r-l):
        for j in range(i+1, r-l+1):
            min = minfunc((modlist[i]*modlist[j])%2019,min)
    print(min)

Buggy submission (verdict: Runtime Error):
lr = list(map(int, input().split()))
l = lr[0]
r = lr[1]
lmod = l%2019

def minfunc(x, y):
    if x > y:
        return y
    else:
        return x

if r - l >= 2019:
    print(0)
elif 2019 <= r - l + lmod:
    print(0)
else:
    min = 9999999
    for i in list(map(lambda x: x%2019,range(l,r)):
        for j in list(map(lambda x: x%2019, range(i,r+1))):
            min = minfunc(minfunc(i,j),min)
    print(min)

Buggy submission (verdict: Runtime Error):
lr = list(map(int, input().split()))
l = lr[0]
r = lr[1]
lmod = l%2019

def minfunc(x, y):
    if x > y:
        return y
    else:
        return x

if r - l >= 2019:
    print(0)
elif 2019 <= r - l + lmod:
    print(0)
else:
    min = 9999999
    for i in list(map(lambda x: x%2019,range(l,r)):
        for j in list(map(lambda x: x%2019, range(i,r+1))):
            min = minfunc(minfunc(i,j),min)

Buggy submission (verdict: Runtime Error):
lr = list(map(int, input().split()))
l = lr[0]
r = lr[1]
lmod = l%2019

if r - l >= 2019:
    print(0)
elif 2019 <= r - l + lmod:
    print(0)
else:ß
    print((lmod * (lmod + 1)) % 2019)
Problem p02994 (python)

Fixed submission:
NL = input().split()
N = int(NL[0])
L = int(NL[1])
apple = []
apple_abs = []
sum = 0
for i in range(1,N+1):
  apple.append(L+i-1)
  apple_abs.append(abs(L+i-1))

apple_min = min(apple_abs)

for i in apple:
  if abs(i) == apple_min:
    continue
  sum += i
print(sum)

Buggy submission (verdict: Runtime Error):
NL = input()
N = int(NL[0])
L = int(NL[2])
apple = []
apple_abs = []
sum = 0
for i in range(1,N+1):
  apple.append(L+i-1)
  apple_abs.append(abs(L+i-1))
 
apple_min = min(apple_abs)
 
for i in apple:
  if abs(i) == apple_min:
    continue
  sum += i
print(sum)

Buggy submission (verdict: Runtime Error):
NL = input()
N = int(NL[0])
L = int(NL[2])
apple = []
apple_abs = []
sum = 0
for i in range(1,N+1):
  apple.append(L+i-1)
  apple_abs.append(abs(L+i-1))

apple_min = min(apple_abs)

for i in apple:
  if abs(i) = apple_min:
    continue
  sum += i
print(sum)
Problem p02993 (python)

Fixed submission:
strings = list(input())
before_number = 100000
flag = False
for number in strings:
  #前の番号と今の番号が一致したら
  if before_number == int(number):
    flag = True
  else:
    before_number = int(number)

if flag == True:
  print("Bad")
else:
  print("Good")

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

list = [L + (i+1)-1 for i in range(N)]

list.sort(key=lambda x:abs(x))

del list[0]
print(list)

Buggy submission (verdict: Runtime Error):
str = input()
p = ""
resut = "Good"
for s in str:
  if p == s:
    result = "Bad"
  p = s
print(result)

Buggy submission (verdict: Runtime Error):
str = input()
p = ""
resut = "Good"
for s in str:
  if p == s:
    result = "Bat"
  p = s
print(result)

Buggy submission (verdict: Runtime Error):
str = input()
p = ""
resut = "Good"
for s in str:
  if p == s:
    result = "Bat"
print(result)
Problem p02994 (python)

Fixed submission:
#N個のりんごの数　L:味の基準
N, L = map(int, input().split())

#普通のアップルパイの味
nomal_sum = 0
for number in range(1,N+1):
  nomal_sum = nomal_sum + (L + number -1)
#print("普通のアップルパイ",nomal_sum)
  
#一つ欠けたアップルパイのパターンを作る
#lost_sum = 0
#for number in range(1,N+1):
#  if number == 1:
#    print("1だよ")
#  else:
#    lost_sum = lost_sum + (L + number -1)
#print(lost_sum)

#一つ欠けたアップルパイのリストをつくる
list = []
lost_sum = 0
for number in range(1,N+1):
  for number2 in range(1,N+1):
    if number != number2:
      lost_sum = lost_sum + (L + number2 -1)
  list.insert(number, lost_sum)
  lost_sum = 0
#print("list",list)

# 差の絶対値を取る
minimal1 = 100000
ans = 0
for list_aji in list:
  #print("list_aji",list_aji)
  #print("minimal1",minimal1)
  #print("abs(list_aji - nomal_sum)",abs(list_aji - nomal_sum))
  if minimal1 >= abs(list_aji - nomal_sum):
    minimal1 = abs(list_aji - nomal_sum)
    ans = list_aji
print(ans)

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

list = [L+(i+1)-1 for i in range(N)]

print(list)
list.sort(key=lambda x: abs(x))

del list[0]
print(sum(list))
Problem p02981 (python)

Fixed submission:
import sys

for line in sys.stdin:
  N, A, B = map(int, line.split())

print min(N*A, B)

Buggy submission (verdict: Runtime Error):
import sys

N, A, B = sys.argv[1:]

print min(N*A, B)

Buggy submission (verdict: Runtime Error):
import sys

N, A, B = map(int, sys.argv[1:])
return min(N*A, B)

Buggy submission (verdict: Runtime Error):
import sys

N, A, V = map(int, sys.argv[1:])
return (N*A) + V
Problem p03037 (python)

Fixed submission:
N,M=map(int,input().split())
L,H=map(int,input().split())
c=0
w=1
while c<M-1:
    l,h=map(int,input().split())
    if L<=l<=H:
        L=l
    elif l>H:
        w=0
        break
    if L<h<H:
        H=h
    c+=1
if w!=0:
    print(H-L+1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
L,H=map(int,input().split())
c=0

while c<M-1:
    l,h=map(int,input().split())
    if L<=l<=H:
        L=l
    elif l>H:
        print(0)
        continue
    if L<h<H:
        H=h
    c+=1
print(H-L+1)
Problem p03062 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
count=0
B=[]
for i in range(N):
    if A[i]<0:
        B.append((-1)*A[i])
        count+=1
    else:
        B.append(A[i])
if count%2==0:
    print(sum(B))
else:
    print(sum(B)-2*min(B))

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split()))
count=0
B=[]
for i in range(N):
    if A[i]<0:
        B.append((-1)*A[i])
        count+=1
    else:
        B.append(A[i])
if count%2==0:
    print(sum(B))
else:
    print(sum(B)-2*min(B))
Problem p03076 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
T=[a,b,c,d,e]
A=list(map(lambda x:x%10,T))
S=list(map(lambda y:y//10,T))
count=0
B=[]
for j in range(5):
    if A[j]!=0:
        count+=1
        B.append(A[j])
if len(B)==0:
    print(10*(sum(S)+count))
else:
    print(10*(sum(S)+count-1)+min(B))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
T=[a,b,c,d,e]
A=list(map(lambda x:x%10,T))
S=list(map(lambda y:y//10,T))
count=0
B=[]
for j in range(5):
    if A[j]!=0:
        count+=1
        B.append(A[j])
print(10*(sum(S)+count-1)+min(B))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
T=[a,b,c,d,e]
A=list(map(lambda x:x%10,T))
S=list(map(lambda y:y//10,T))
count=0
B=[]
for j in range(5):
    if A[j]!=0:
        count+=1
        B.append(A[j])
print(10*(sum(S)+count-1)+min(B))

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()
d=input()
e=input()
T=[a,b,c,d,e]
A=list(map(lambda x:x%10,T))
S=list(map(lambda y:y//10,T))
count=0
B=[]
for j in range(5):
    if A[j]!=0:
        count+=1
        B.append(A[j])
print(10*(sum(S)+count-1)+min(B))

Buggy submission (verdict: Runtime Error):
T=[]
for i in range(5):
    T.append(int(input()))
A=list(map(lambda x:x%10,T))
S=list(map(lambda y:y//10,T))
count=0
B=[]
for j in range(5):
    if A[j]!=0:
        count+=1
        B.append(A[j])
print(10*(sum(S)+count-1)+min(B))
Problem p03105 (python)

Fixed submission:
A,B,C = map(int,input().split())
if B//A < C:
    print(B//A)
else:
    print(C)

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
T=[]
for i in range(1,101):
    if A%i==0 and B%i==0:
        T.append(i)
T=sorted(T,reverse=True)
print(T[K-1])
Problem p03126 (python)

Fixed submission:
N,M=map(int,input().split())
A=[]
for i in range(N):
    B=list(input().split())
    for j in range(1,int(B[0])+1):
        A.append(B[j])
count=0
for k in range(M+1):
    if A.count(str(k))==N:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
C=[0]*M
for i in range(N):
    A=list(map(int,input().split()))
    for j in range(1,A[0]+1):
        C[A[j]]+=1
print(C.count(N))
Problem p03288 (python)

Fixed submission:
a=int(input())
if a<1200:
  print("ABC")
elif 1199<a<2800:
  print("ARC")
else:
  print("AGC")

Buggy submission (verdict: Runtime Error):
a=int(input())
if a<1200:
  print(ABC)
elif 1199<a<2800:
  print(ARC)
else:
  print(AGC)

Buggy submission (verdict: Runtime Error):
a=input()
if a<1200:
  print(ABC)
elif 1199<a<2800:
  print(ARC)

Buggy submission (verdict: Runtime Error):
a=input()
if a<1200:
  print(ABC)
else:
  print(ARC)
Problem p03455 (python)

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

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

Fixed submission:
a,b = input().split()
ab = int(a+b)
count = 0
for i in range(1,317):
    if ab/i == i:
        print('Yes')
        count += 1
if count == 0:
    print('No')

Buggy submission (verdict: Runtime Error):
A=list(input().spllit())
#A=["a","b"]
a="".join(A)
n=int(a)
if n**(0.5)==int:
    print("Yes")
else:
    print("No")
Problem p03494 (python)

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

count=-1
while len(A)==N:
    count+=1
    for i in range(N):
        if A[i]%2==0:
            A[i]=A[i]/2
        else:
            A.remove(A[i])
            break
print(count)

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

count=-1
while len(A)==N:
    count+=1
    for i in range(N-1):
        if A[i]%2==0:
            A[i]=A[i]/2
        else:
            A.remove(A[i])
print(count)
Problem p03074 (python)

Fixed submission:
N, K = map(int, input().split())
S = input().replace('\n', '')


def solve(S, K):
    record = []
    temp = []
    for i in range(len(S) - 1):
        if S[i:i+2] == '01':
            temp.append(i + 1)
        elif S[i:i+2] == '10':
            if not temp: temp = [0, i]
            else: temp.append(i)
            record.append(temp)
            temp = []
    if len(temp) > 0:
        temp.append(len(S) - 1)
        record.append(temp)
    if S[0] == '0':
        record = [[0, 0]] + record
    if S[-1] == '0':
        record = record + [[len(S) - 1, len(S) - 1]]
    if len(record) <= K + 1: return(len(S))
    else:
        cnt = 0
        for i in range(len(record) - K):
            cnt = max(cnt, record[i + K][1] - record[i][0] + 1)
        return(cnt)
print(solve(S, K))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input().replace('\n', '')


def solve(S, K):
    record = []
    temp = []
    for i in range(len(S) - 1):
        if S[i:i+2] == '01':
            temp.append(i + 1)
        elif S[i:i+2] == '10':
            if not temp: temp = [0, i]
            else: temp.append(i)
            record.append(temp)
            temp = []
    if len(temp) > 0:
        temp.append(len(S) - 1)
        record.append(temp)
    if S[0] == '0':
        record = [[0, record[0][0] - 1]] + record
    if S[-1] == '0':
        record = record + [[record[-1][-1] + 1, len(S) - 1]]
    if len(record) <= K + 1: return(len(S))
    else:
        cnt = 0
        for i in range(len(record) - K):
            cnt = max(cnt, record[i + K][1] - record[i][0] + 1)
        return(cnt)
print(solve(S, K))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input().replace('\n', '')


def solve(S, K):
    record = []
    temp = []
    for i in range(len(S) - 1):
        if S[i:i+2] == '01':
            temp.append(i + 1)
        elif S[i:i+2] == '10':
            if not temp: temp = [0, i]
            else: temp.append(i)
            record.append(temp)
            temp = []
    if len(temp) > 0:
        temp.append(len(S) - 1)
        record.append(temp)
    if S[0] == '0':
        record = [[0, record[0][0] - 1]] + record
    if S[-1] == '0':
        record = record + [[record[-1][-1] + 1, len(S) - 1]]
    print(record)
    if len(record) <= K + 1: return(len(S))
    else:
        cnt = 0
        for i in range(len(record) - K):
            cnt = max(cnt, record[i + K][1] - record[i][0] + 1)
        return(cnt)
print(solve(S, K))
Problem p03076 (python)

Fixed submission:
dish, time = [], 0
for i in range(5):
    temp = int(input())
    if temp % 10 == 0:
        time += temp
    else:
        dish.append(temp)
if dish:
    left = 10 - min([x % 10 for x in dish])
    time = time + sum([x + 10 - x % 10 for x in dish]) - left
print(time)

Buggy submission (verdict: Runtime Error):
dish = []
time = 0
for i in range(5):
    temp = int(input())
    if temp % 10:
        dish.append(temp)
    else:
        time += temp
left = 10 - min([x % 10 for x in dish])
for i in range(len(dish)):
    dish[i] = dish[i] + 10 - dish[i] % 10
time = time + sum(dish) - left
print(time)
Problem p03078 (python)

Fixed submission:
import heapq
X, Y, Z, K = map(int, input().split())
candy = [[],[],[]]
for i in range(3):
    temp = list(map(int, input().split()))
    candy[i] = temp

for i in range(3):
    candy[i] = sorted(candy[i], reverse=True)
i, j, k = 0, 0, 0
heap = [(-(candy[0][i] + candy[1][j] + candy[2][k]), i, j, k)]
cnt = 0
visit = {(i, j, k)}
while cnt < K:
    s, ii, jj, kk = heapq.heappop(heap)
    print(-s)
    cnt += 1
    if ii < len(candy[0]) - 1 and (ii+1, jj, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii + 1] + candy[1][jj] + candy[2][kk]), ii + 1, jj, kk))
        visit.add((ii+1, jj, kk))
    if jj < len(candy[1]) - 1 and (ii, jj+1, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj + 1] + candy[2][kk]), ii, jj + 1, kk))
        visit.add((ii, jj+1, kk))
    if kk < len(candy[2]) - 1 and (ii, jj, kk+1) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj] + candy[2][kk + 1]), ii, jj, kk + 1))
        visit.add((ii, jj, kk+1))

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
candy = [[],[],[]]
for i in range(3):
    temp = list(map(int, input().split()))
    candy[i] = temp

for i in range(3):
    candy[i] = sorted(candy[i], reverse=True)
i, j, k = 0, 0, 0
heap = [(-(candy[0][i] + candy[1][j] + candy[2][k]), i, j, k)]
cnt = 0
visit = {(i, j, k)}
while cnt < K:
    s, ii, jj, kk = heapq.heappop(heap)
    print(-s)
    cnt += 1
    if ii < len(candy[0]) - 1 and (ii+1, jj, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii + 1] + candy[1][jj] + candy[2][kk]), ii + 1, jj, kk))
        visit.add((ii+1, jj, kk))
    if jj < len(candy[1]) - 1 and (ii, jj+1, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj + 1] + candy[2][kk]), ii, jj + 1, kk))
        visit.add((ii, jj+1, kk))
    if kk < len(candy[2]) - 1 and (ii, jj, kk+1) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj] + candy[2][kk + 1]), ii, jj, kk + 1))
        visit.add((ii, jj, kk+1))

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
candy = [[],[],[]]
for i in range(3):
    temp = list(map(int, input().split()))
    candy[i] = temp

for i in range(3):
    candy[i] = sorted(candy[i], reverse=True)
i, j, k = 0, 0, 0
heap = [(-(candy[0][i] + candy[1][j] + candy[2][k]), i, j, k)]
cnt = 0
visit = {(i, j, k)}
while cnt < K:
    print(heap)
    s, ii, jj, kk = heapq.heappop(heap)
    print(-s)
    cnt += 1
    if ii < len(candy[0]) - 1 and (ii+1, jj, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii + 1] + candy[1][jj] + candy[2][kk]), ii + 1, jj, kk))
        visit.add((ii+1, jj, kk))
    if jj < len(candy[1]) - 1 and (ii, jj+1, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj + 1] + candy[2][kk]), ii, jj + 1, kk))
        visit.add((ii, jj+1, kk))
    if kk < len(candy[2]) - 1 and (ii, jj, kk+1) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj] + candy[2][kk + 1]), ii, jj, kk + 1))
        visit.add((ii, jj, kk+1))
Problem p02983 (python)

Fixed submission:
norg, korg = tuple([int(s) for s in input().split()])

n = norg % 2019
k = korg % 2019

min_val = 2019

if norg // 2019 == korg // 2019:
    for i in range(n, k):
        for j in range(i+1, k+1):
            if (i*j) % 2019 < min_val:
                min_val = (i*j) % 2019
else:
    min_val = 0

print(min_val)

Buggy submission (verdict: Runtime Error):
n, k = tuple([int(s) for s in input().split()])

n = n % 2019
k = k % 2019

a = n
b = n+1

print(a*b)%2019
Problem p02982 (python)

Fixed submission:
import itertools
import math

N, D = [int(x) for x in input().strip().split()]
if D == 1:
    print(int(N*(N-1)/2))
else:
    points = []
    for data in range(N):
        points.append([int(x) for x in input().strip().split()])

    result = 0
    for p1,p2 in itertools.combinations(points, 2):
        distance = 0
        for y,z in zip(p1,p2):
            distance += (y - z) ** 2
        
        distance = math.sqrt(distance)
        if distance.is_integer(): result += 1    
    print(result)

Buggy submission (verdict: Runtime Error):
import itertools
import math

N, D = [int(x) for x in input().strip().split()]
if D == 1:
    print(int(N*(N-1)/2)
else:    
    points = []
    for data in range(N):
        points.append([int(x) for x in input().strip().split()])

    result = 0
    for p1,p2 in itertools.combinations(points, 2):
        distance = 0
        for y,z in zip(p1,p2):
            distance += (y - z) ** 2
        
        distance = math.sqrt(distance)
        if distance.is_integer(): result += 1    
    print(result)

Buggy submission (verdict: Runtime Error):
import itertools
import math

N, D = [int(x) for x in input().strip().split()]
if D == 1:
    print(int(N*(N-1)/2))
    exit(1)
    
points = []
for data in range(N):
    points.append([int(x) for x in input().strip().split()])

result = 0
for p1,p2 in itertools.combinations(points, 2):
    distance = 0
    for y,z in zip(p1,p2):
        distance += (y - z) ** 2
        
    distance = math.sqrt(distance)
    if distance.is_integer(): result += 1
        
print(result)