Buggy python submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

#DP[i] = i までの魔法でモンスターの体力を減らすため消耗する魔力の最小値
dp = [0] * h

for i in range(h):
    dp[i] = min(dp[i-a] + b for a, b in ab)
print(dp[h-1])


Fixed submission:
import numpy as np
H,N=map(int, input().split())
A = [None]*N
B = [None]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
dp=[10**8]*(H+1)
A = np.array(A)
B = np.array(B)
dp = np.array(dp)
dp[0]=0
for i in range(1,H+1):
  x=np.amin((dp[np.maximum(0,i-A)]+B))
  dp[i]=min(x,dp[i])
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

#DP[i] = i までの魔法でモンスターの体力を減らすため消耗する魔力の最小値
dp = [0] * h

for i in range(h):
    nw = 10**10
    for a, b in ab:
        nw = min(nw ,dp[i-a] + b)
    dp[i] = nw
print(dp[h-1])


Fixed submission:
import numpy as np
H,N=map(int, input().split())
A = [None]*N
B = [None]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
dp=[10**8]*(H+1)
A = np.array(A)
B = np.array(B)
dp = np.array(dp)
dp[0]=0
for i in range(1,H+1):
  x=np.amin((dp[np.maximum(0,i-A)]+B))
  dp[i]=min(x,dp[i])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
ab = set([])
for _ in range(n):
    ab.add(tuple(map(int,input().split())))
l = h + max(a for a, _ in ab)

#DP[i] = i までの魔法でモンスターの体力を減らすため消耗する魔力の最小値
dp = [10**8+1] * l
dp[0] = 0

for i in range(l):  #最大L回繰り返せばよい
    for a, b in ab:
        dp[i] = min(dp[i-a] + b, dp[i])
print(min(dp[h:]))


Fixed submission:
import numpy as np
H,N=map(int, input().split())
A = [None]*N
B = [None]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
dp=[10**8]*(H+1)
A = np.array(A)
B = np.array(B)
dp = np.array(dp)
dp[0]=0
for i in range(1,H+1):
  x=np.amin((dp[np.maximum(0,i-A)]+B))
  dp[i]=min(x,dp[i])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
l = h + max(a for a, _ in ab)

#DP[i] = i までの魔法でモンスターの体力を減らすため消耗する魔力の最小値
dp = [10**8+1] * l
dp[0] = 0

for i in range(l):  #最大L回繰り返せばよい
    for a, b in ab:
        dp[i] = min(dp[i-a] + b, dp[i])
print(min(dp[h:]))


Fixed submission:
import numpy as np
H,N=map(int, input().split())
A = [None]*N
B = [None]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
dp=[10**8]*(H+1)
A = np.array(A)
B = np.array(B)
dp = np.array(dp)
dp[0]=0
for i in range(1,H+1):
  x=np.amin((dp[np.maximum(0,i-A)]+B))
  dp[i]=min(x,dp[i])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
H,N=map(int, input().split())
AB = [list(map(int,input().split())) for i in range(N)]
dp=[10**8]*(H+1)
dp[0]=0
for i in range(1,H+1):
  for ab in AB:
    dp[i]=min(dp[max(0,i-ab[0])] + ab[1], dp[i])
print(dp[-1])

Fixed submission:
import numpy as np
H,N=map(int, input().split())
A = [None]*N
B = [None]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
dp=[10**8]*(H+1)
A = np.array(A)
B = np.array(B)
dp = np.array(dp)
dp[0]=0
for i in range(1,H+1):
  x=np.amin((dp[np.maximum(0,i-A)]+B))
  dp[i]=min(x,dp[i])
print(dp[-1])