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

Fixed submission:
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for l in da:
    if l in db:
    	dc.append(l)

dc.sort(reverse = True)
print(dc[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for l in da:
    if l in db:
    	dc.append(l)

dc.sort(reverse = True)
print(dc[k])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in da:
    if k in db:
    	dc.append(k)

dc.sort(reverse = True)
print(dc[k])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in da:
    if k in db:
    	dc.append(k)

dc.sort(reverse = True)
print(dc[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in da:
    if k in db:
    	dc.append(k)

if dc:
    dc.sort(reverse = True)
    print(dc[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in da:
    if k in db:
    	dc.append(k)

if dc:
    dc.sort(reverse = True)
    print(dc[k-1])

else:
    print(0)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in range da:
    if k in db:
    	dc.append(k)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in range da:
    if k in db:
    	dc.append(k)

if dc:
    dc.sort(reverse = True)
    print(dc[k-1])

else:
    print(0)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%1 == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in range da:
    if k in db:
    	dc.append(k)

if dc:
    dc.sort(reverse = True)
    print(dc[k-1])

else:
    print(0)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%1 == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in range da:
    if k in db:
    	dc.append(k)

dc.sort(reverse = True)
print(dc[k-1])
Problem p03110 (python)

Fixed submission:
import numpy as np
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i]= map(str, input().split())
    
x_int = [float(j) for j in x]
u_replace = [1 if k =="JPY" else 380000.0 for k in u]

x_arr = np.array(x_int)
u_arr = np.array(u_replace).reshape(N, 1)

ans = np.dot(x_arr, u_arr)
print(ans[0])

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i]= map(input().split())

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i]= map(input().split())
    
x_int = [float(j) for j in x]

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i]= map(input().split())
    
x_int = [float(j) for j in x]
u_replace = [1 if k =="JPY" else 380000.0 for k in u]

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i]= map(input().split())
    
x_int = [float(j) for j in x]
u_replace = [1 if k =="JPY" else 380000.0 for k in u]

x_arr = np.array(x_int)
u_arr = np.array(u_replace).reshape(N, 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i]= map(input().split())
    
x_int = [float(j) for j in x]
u_replace = [1 if k =="JPY" else 380000.0 for k in u]

x_arr = np.array(x_int)
u_arr = np.array(u_replace).reshape(N, 1)

ans = np.dot(x_arr, u_arr)
print(ans)
Problem p03136 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
x = max(l)
s = sum(l)
if x < (s-x):
    print("Yes")
else:
    print("No")

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

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

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

Buggy submission (verdict: Runtime Error):
n = int(input)
l = list(map(int, input().split()))
x = max(l)
s = sum(l)
if x < (s-x):
    print("Yes")
else:
    print("No")
Problem p03434 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = a.sort(reverse = True)
print(sum(a[::2])-sum(a[1::2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = a.sort(reverse = True)
print(sum(b[::2])-sum(b[1::2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = a.sort(reverse = True)
print(sum(b[::2])-sum(b[1::2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
data = sorted(list(map(int, input.split())), reverse=True)
a = sum(data[::2])
b = sum(data[1::2])
print(a - b)

Buggy submission (verdict: Runtime Error):
n = int(input())
data = list(map(int, input.split()))
datad = data.sort(reverse = True)
a = sum(datad[::2])
b = sum(datad[1::2])
print(a - b)

Buggy submission (verdict: Runtime Error):
n = int(input())
data = list(map(int, input.split()))
data_d = data.sort(reverse = True)
a = sum(data_d[::2])
b = sum(data_d[1::2])
print(a - b)

Buggy submission (verdict: Runtime Error):
n = int(input())
data = list(map(int, input().split()))
data_d = data.sort(reverse = True)
a = sum(data_d[::2])
b = sum(data_d[1::2])
print(a - b)

Buggy submission (verdict: Runtime Error):
n = int(input())
data = list(map(int, input().split()))
data_d = data.sort(reverse = True)
a = sum(data_d[: : 2])
b = sum(data_d[1: : 2])
ans = a-b
print(ans)
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(0, a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

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

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

Fixed submission:
a,b = map(int, input().split())
c = a*b
if c%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 p03457 (python)

Fixed submission:
n = int(input())
for i in range(n):
    t,x,y = map(int, input().split())
    if x+y>t or (x+y+t)%2 :
    	print("No")
    	exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
    t,x,y = map(int, input(),split())
    if x+y>t or (x+y+t)%2 :
    	print("No")
    	break
print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input)
for i in range(n):
    t,x,y = map(int, input(),split())
    if x+y>t or (x+y+t)%2 :
    	print("No")
    	exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input)
for i in range(n):
    t,x,y = map(int, input(),split())
    if x+y>t or (x+y+t)%2 :
    	print("No")
    	break
print("Yes")
Problem p03471 (python)

Fixed submission:
n, y = map(int, input().split())
ans = (-1, -1, -1)
for i in range(0, n+1):
    for j in range(0, n+1-i):
    	if 10000*i+5000*j+1000*(n-i-j) == y:
    		ans = (i, j, n-i-j)
print(ans[0], ans[1], ans[2])

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(0, n+1):
    for j in range(0, n+1-i):
    	if 10000*i+5000*j+1000*(n-i-j) == y:
    			print(i, j, n-i-j)
    		else:
    			print(-1, -1, -1)
Problem p03493 (python)

Fixed submission:
s = input()
ans = 0
if s[0]=="1":
    ans += 1
    
if s[1]=="1":
    ans += 1

if s[2]=="1":
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
print(input().count(1))

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
if s[0]=="1":
    ans  += 1
elif s[1]=="1":
    ans  += 1
else s[2]=="1":
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
if s[0]=="1":
    ans  += 1
if s[1]=="1":
    ans  += 1
if s[2]=="1"
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
if s[0]=="1":
    ans = += 1
if s[1]=="1":
    ans = += 1
if s[2]=="1"
    ans += 1
print(ans)
Problem p03494 (python)

Fixed submission:
n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for i in a]
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for in a]
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for in a]
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
cnt=0
while all(i%2==0 for i in a) :
    a = [i/2 for in a]
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
cnt=0
while all(i%2==0 for i in a):
    a = [i/2 for in a]
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
cnt=0
while all(i%2==0 for i in a):
    a = [i/2 for in a]
    cnt += 1
    
print(cnt)
Problem p02732 (python)

Fixed submission:
def n_c_2(n):
    if n < 1:
        return 0
    else:
        return n * (n - 1) // 2

N = int(input())
A = [int(x) for x in input().split()]

n_balls = [0 for _ in A]
for a_i in A:
    n_balls[a_i - 1] += 1

n_combinations = [n_c_2(n) for n in n_balls]
total_combinations = sum(n_combinations)

for i, a_i in enumerate(A):
    diff = n_c_2(n_balls[a_i - 1]) - n_c_2(n_balls[a_i - 1] - 1)
    print(total_combinations - diff)

Buggy submission (verdict: Runtime Error):
import copy
import numpy as np
from math import factorial

def num_choice_2(N):
    if N > 1:
        return factorial(N) // (factorial(N - 2)* 2)
    else:
        return 0

N = int(input())
A = [int(x) for x in input().split()]

nums = np.zeros(N, dtype=int)
for a_i in A:
    nums[a_i - 1] += 1

for i in range(N):
    nums[A[i] - 1] -= 1
    ans = np.sum([num_choice_2(x) for x in tmp_nums])
    nums[A[i] - 1] += 1
    print(ans)
Problem p02761 (python)

Fixed submission:
import math

N, M = [int(x) for x in input().split()]
s, c = [], []

for i in range(M):
    s_i, c_i = [int(x) for x in input().split()]
    s.append(s_i)
    c.append(c_i)

for num in range(10 ** N):
    num = str(num)
    if len(num) != N:
        continue
    for i in range(M):
        if num[s[i] - 1] != str(c[i]):
            break
    else:
        print(int(num))
        exit()

print(-1)

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]
s, c = [], []
ans_array = [None for _ in range(N)]

for i in range(M):
    s_i, c_i = [int(x) for x in input().split()]
    s.append(s_i)
    c.append(c_i)

for i in range(M):
    if ans_array[s[i] - 1] is None:
        ans_array[s[i] - 1] = c[i]
    else:
        if ans_array[s[i] - 1] != c[i]:
            print(-1)
            exit()

if ans_array[-1] is not None:
    ans_array = [0 if num is None else num for num in ans_array]
elif len(ans_array) == 1:
    print(0)
else:
    print(-1)
    exit()

ans = int("".join([str(num) for num in ans_array]))
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]
s, c = [], []
ans_array = [0 for _ in range(M)]

for i in range(M):
    s_i, c_i = [int(x) for x in input().split()]
    s.append(s_i)
    c.append(c_i)

for i in range(M):
    if ans_array[s[i] - 1] == 0:
        ans_array[s[i] - 1] = c[i]
    else:
        if ans_array[s[i] - 1] != c[i]:
            print(-1)
            exit()

ans_num = int("".join([str(num) for num in ans_array]))
if ans_num == 0:
    for num in ans_array[:-1]:
        if num != 0:
            break
    print(-1)
else:
    print(ans_num)
Problem p02957 (python)

Fixed submission:
import numpy

A, B = [int(x) for x in input().split(" ")]
if (A - B) % 2 == 0:
    print(abs(A + B) // 2)
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split(" ")]
B = [int(x) for x in input().split(" ")]

count = 0
for i in range(N):
    n_defeat = min(A[i], B[i])
    A[i] -= n_defeat
    B[i] -= n_defeat
    count += n_defeat
    n_defeat = min(A[i + 1], B[i])
    A[i + 1] -= n_defeat
    B[i] -= n_defeat
    count += n_defeat

print(count)

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

N = int(input())
p = [int(x) for x in input().split(" ")]

sorted_p = sorted(p)
count = 0
for i in range(N):
    if sorted_p[i] != p[i]: count += 1

if count == 0 or count == 2:
    print("YES")
else:
    print("NO")
Problem p02995 (python)

Fixed submission:
import numpy as np
from fractions import gcd

def lcm(x, y):
    return x * y // gcd(x, y)
A, B, C, D = [int(x) for x in input().split(" ")]
n_targets = B - A + 1

n_compC = n_targets - (B // C - (A - 1) // C)
n_compD = n_targets - (B // D - (A - 1) // D)
n_compCandD = n_targets - (B // lcm(C, D) - (A - 1) // lcm(C, D))

print(n_compC + n_compD - n_compCandD)

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

W, H, x, y = [int(x) for x in input().split(" ")]
max_area =  W * H / 2.0
eps = 1e-6
if x + x = W and y + y == H:
    flag = 1
else:
    flag = 0

print(max_area, flag)

Buggy submission (verdict: Runtime Error):
import numpy as np
from math.fraction import gcd

def lcm(x, y):
    return x * y // gcd(x, y)
A, B, C, D = [int(x) for x in input().split(" ")]
n_targets = B - A + 1

n_compC = n_targets - (B // C - (A - 1) // C)
n_compD = n_targets - (B // D - (A - 1) // D)
n_compCandD = n_targets - (B // lcm(C, D) - (A - 1) // lcm(C, D))

print(n_compC + n_compD - n_compCandD)

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

def lcm(x, y):
    return x * y // math.gcd(x, y)
A, B, C, D = [int(x) for x in input().split(" ")]
n_targets = B - A + 1

n_compC = n_targets - (B // C - (A - 1) // C)
n_compD = n_targets - (B // D - (A - 1) // D)
n_compCandD = n_targets - (B // lcm(C, D) - (A - 1) // lcm(C, D))

print(n_compC + n_compD - n_compCandD)

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

def lcm(x, y):
    return x * y // math.gcd(x, y)
A, B, C, D = [int(x) for x in input().split(" ")]
n_targets = B - A + 1

n_compC = n_targets - (B // C - (A - 1) // C)
n_compD = n_targets - (B // D - (A - 1) // D)
n_compCandD = n_targets - (B // lcm(C, D) - (A - 1) // lcm(C, D))

print(n_compC + n_compD - n_compCandD)
Problem p03001 (python)

Fixed submission:
import numpy as np

W, H, x, y = [int(x) for x in input().split(" ")]
max_area =  W * H / 2.0
eps = 1e-6
if x + x == W and y + y == H:
    flag = 1
else:
    flag = 0

print(max_area, flag)

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

W, H, x, y = [int(x) for x in input().split(" ")]
max_area =  W * H / 2.0
eps = 1e-6
if x + x = W and y + y == H:
    flag = 1
else:
    flag = 0

print(max_area, flag)
Problem p03035 (python)

Fixed submission:
age, cost = [int(x) for x in input().split()]

if age <= 5:
  print(0)
elif age <= 12:
  print(int(cost / 2))
else:
  print(cost)

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

n_ID, n_gates = [int(data) for data in input().split()]
L = np.empty(n_gates, dtype = int)
R = np.empty(n_gates, dtype = int)

for i in range(n_gates):
  L[i], R[i] = [int(data) for data in input().split()]

ID_gate_matrix = np.zeros((n_ID, n_gates))

for j in range(n_gates):
  for i in range(L[j] - 1, R[j]):
    ID_gate_matrix[i][j] = 1

Card_Counter = 0
for i in range(n_ID):
  for j in range(n_gates):
    if ID_gate_matrix[i][j] != 1:
      break
  else:
    Card_Counter += 1

print(Card_Counter)
Problem p03125 (python)

Fixed submission:
A, B = [int(i) for i in input().split()]
if B % A == 0:
	print(A + B)
else:
	print(B - A)

Buggy submission (verdict: Runtime Error):
    A, B = [int(i) for i in input().split()]
     
    if B % A == 0:
      print(A + B)
    else:
      print(B - A)
Problem p02684 (python)

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

l = [1]
s = {1}

while True:
    next = list_A[l[-1] - 1]

    if not next in s:
        l.append(next)
        s.add(next)

    else:
        start = l.index(next)
        roop = len(l) - start
        break

if len(l) == 1:
    print(1)
    exit()

elif len(l) > K:
    print(l[K])
    exit()

else:
    roop_remainder = (K + 1 - start) % roop
    if roop_remainder == 0:
        print(l[-1])
    else:
        print(l[start + roop_remainder -1])

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

l = [1]
s = {1}

while True:
    next = list_A[l[-1] - 1]

    if not next in s:
        l.append(next)
        s.add(next)

    else:
        start = l.index(next)
        roop = len(l) - start
        break

if len(l) == 1:
    print(1)
    exit()

elif len(l) >= K:
    print(l[K])
    exit()

else:
    roop_remainder = (K + 1 - start) % roop
    if roop_remainder == 0:
        print(l[-1])
    else:
        print(l[start + roop_remainder -1])

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

l = [1]

flag = True

while flag:
    next = list_A[l[-1] - 1]

    if not next in l:
        l.append(next)

    else:
        start = l.index(next)
        roop = len(l) - start
        flag = False

if len(l) == 1:
    print(1)
    exit()

elif len(l) >= K:
    print(l[K])
    exit()

else:
    roop_remainder = (K + 1 - start) % roop
    if roop_remainder == 0:
        print(l[-1])
    else:
        print(l[start + roop_remainder -1])
Problem p02787 (python)

Fixed submission:
h, n = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

#dp[i][j] := i番目までの物でjの価値を実現するのに必要な最小コスト
dp = [[0] * (h+1) for _ in range(n+1)]
for j in range(1, h+1):
    dp[0][j] = float("inf")

for i in range(n):
    for j in range(h+1):
        if j < items[i][0]:
            dp[i+1][j] = min(dp[i][j], items[i][1])
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-items[i][0]] + items[i][1])

print(dp[n][h])

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

#dp[i][j] := i番目までの物でjの価値を実現するのに必要な最小コスト
dp = [[0] * 1001 for _ in range(n+1)]
for j in range(1, 1001):
    dp[0][j] = float("inf")

for i in range(n):
    for j in range(1001):
        if j < items[i][0]:
            dp[i+1][j] = min(dp[i][j], items[i][1])
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-items[i][0]] + items[i][1])

print(dp[n][h])

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

#dp[i][j] := i番目までの物ででjまでのコストで実現できる最大値
dp = [[0] * 100000001 for _ in range(n+1)]

for i in range(n):
    for j in range(1001):
        if j < items[i][1]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i+1][j-items[i][1]] + items[i][0])

m = 0
while True:
    if dp[n][m] >= h:
        print(m)
        exit()
    m += 1

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

#dp[i][j] := i番目までの物ででjまでのコストで実現できる最大値
dp = [[0] * 1001 for _ in range(n+1)]

for i in range(n):
    for j in range(1001):
        if j < items[i][1]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i+1][j-items[i][1]] + items[i][0])

m = 0
while True:
    if dp[n][m] >= h:
        print(m)
        exit()
    m += 1
Problem p03997 (python)

Fixed submission:
a, b, h = [int(input()) for i in range(3)]

print(round((a + b) * h / 2))

Buggy submission (verdict: Runtime Error):
a, b, h = [int(input()) for i in range(4)]

print(round((a + b) * h / 2))
Problem p03166 (python)

Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
v,e=map(int,input().split())
m=defaultdict(list)

for i in range(e):
    x,y=map(int,input().split())
    m[x].append(y)
dp=defaultdict(lambda:-1)
def longestPath():
    
    def findLongestPath(vtx):
        if(dp[vtx]!=-1):
            return dp[vtx]
        res=0
        for i in m[vtx]:
            res=max(res,1+findLongestPath(i))
        dp[vtx]=res
        return res
        
        
    
    ans=0
    for i in range(1,v+1):
        ans=max(ans,findLongestPath(i))
    
    return ans;

print(longestPath())

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
v,e=map(int,input().split())
m=defaultdict(list)

for i in range(e):
    x,y=map(int,input().split())
    m[x].append(y)
dp=defaultdict(lambda:-1)
def longestPath():
    
    def findLongestPath(vtx):
        if(dp[vtx]!=-1):
            return dp[vtx]
        res=0
        for i in m[vtx]:
            res=max(res,1+findLongestPath(i))
        dp[vtx]=res
        return res
        
        
    
    ans=0
    for i in range(1,v+1):
        ans=max(ans,findLongestPath(i))
    
    return ans;

print(longestPath())
Problem p02719 (python)

Fixed submission:
N, K = map(int, input().split())
n_1 = N - (K * (N // K))
n_2 = abs(n_1 - K)
print(min(n_1, n_2))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
n_1 = N - (K * (N // K))
n_2 = abs(n - K)
print(min(n_1, n_2))
Problem p02756 (python)

Fixed submission:
from collections import deque

S = list(input())
S = deque(S)
Q = int(input())
reverse = 1
query = [input().split() for i in range(Q)]
for i in query:
    if len(i) == 1:
        reverse *= -1
    elif (i[1]=='1' and reverse == 1) or (i[1]=='2' and reverse==-1):
        S.appendleft(i[2])
    else:
        S.append(i[2])
if reverse == -1:
   S.reverse() 
print(''.join(list(S)))

Buggy submission (verdict: Runtime Error):
S = list(input())
Q = int(input())
query = [input().split() for i in range(Q)]
print(query)
for i in query:
    # print(i)
    if i[0] == '1':
        
        S = list(reversed(S))
        print(S)
    elif i[0]=='2' and i[1]=='1':
        S.insert(0, i[2])
        print(S)
    elif i[0]=='2' and i[1]=='2':
        S.append(i[2])
        print(S)
print(''.join(S))
Problem p02817 (python)

Fixed submission:
S, T = input().split()
print(T+S)

Buggy submission (verdict: Runtime Error):
S, T = input().split()
print(f'{T}{S}')