Buggy python submission (verdict: Runtime Error):
h,n= map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)] 
m = 10**4
dp = [0]*(h+m+1)
for i in range(m+1,h+m+1):
  dp[i] = min(dp[i-a] + b for a,b in p)
print(dp[h+m+])

Fixed submission:
import numpy as np
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
np_ab = np.array(ab)
max_a = max(np_ab[:, 0])
dp = [0]*(h+max_a)
for i in range(1, h+max_a):
    dp[i] = min(dp[i-a] + b for a,b in ab)
print(min(dp[h:]))

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

Fixed submission:
import numpy as np
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
np_ab = np.array(ab)
max_a = max(np_ab[:, 0])
dp = [0]*(h+max_a)
for i in range(1, h+max_a):
    dp[i] = min(dp[i-a] + b for a,b in ab)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
h,n= map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
dp = [0]*(h+10**4)
for i in range(1,h+10**4):
  dp[i] = min(dp[i-a] + b for a,b in p)
print(min(dp[h:]))

Fixed submission:
import numpy as np
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
np_ab = np.array(ab)
max_a = max(np_ab[:, 0])
dp = [0]*(h+max_a)
for i in range(1, h+max_a):
    dp[i] = min(dp[i-a] + b for a,b in ab)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
h,n= map(int, input().split())
p = []
for i in range(n):
  z = list(map(int, input().split()))
  p.append(z)
dp = [0]*(h+1)
for i in range(1,h+1):
  dp[i] = min(dp[max(0,i-a)] + b for a,b in p)
print(min(dp[h:]))

Fixed submission:
import numpy as np
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
np_ab = np.array(ab)
max_a = max(np_ab[:, 0])
dp = [0]*(h+max_a)
for i in range(1, h+max_a):
    dp[i] = min(dp[i-a] + b for a,b in ab)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
h,n= map(int, input().split())
p = []
for i in range(n):
  z = list(map(int, input().split()))
  p.append(z)
dp = [0]*(h+10**4)
for i in range(1,h+10**4):
  dp[i] = min(dp[i-a] + b for a,b in p)
print(min(dp[h:]))

Fixed submission:
import numpy as np
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
np_ab = np.array(ab)
max_a = max(np_ab[:, 0])
dp = [0]*(h+max_a)
for i in range(1, h+max_a):
    dp[i] = min(dp[i-a] + b for a,b in ab)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
h,n= map(int, input().split())
p = []
for i in range(n):
  z = list(map(int, input().split()))
  p.append(z)
dp = [0]*(h+1)
for i in range(1,h+1):
  q = []
  for j in p:
    q.append(dp[max(0,i-j[0])]+j[1])
  dp[i] = min(q)
print(dp[h])

Fixed submission:
import numpy as np
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
np_ab = np.array(ab)
max_a = max(np_ab[:, 0])
dp = [0]*(h+max_a)
for i in range(1, h+max_a):
    dp[i] = min(dp[i-a] + b for a,b in ab)
print(min(dp[h:]))