Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
da, cost = [0] * N, [0] * N
for i in range(N):
    da[i],cost[i]=map(int, input().split())

max_da=max(da)*10  
dp = [float("inf") for i in range(H+max_da)]
dp[0]=0

for j in range(N):
    for i in range(H+max_da):
        if i-da[j]>=0:
            dp[i]=min(dp[i],dp[i-da[j]]+cost[j])

print(min(dp[H:]))

Fixed submission:
H, N = map(int, input().split())
da, cost = [0] * N, [0] * N
for i in range(N):
    da[i],cost[i]=map(int, input().split())

max_da=max(da) 
dp = [float("inf") for i in range(H+max_da)]
dp[0]=0

for i in range(H+max_da):
    for j in range(N):
        if i-da[j]>=0:
            dp[i]=min(dp[i],dp[i-da[j]]+cost[j])

print(min(dp[H:]))

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
da, cost = [0] * N, [0] * N
for i in range(N):
    da[i],cost[i]=map(int, input().split())
max_da=max(da)  
dp = [float("inf") for i in range(H*1000)]
dp[0]=0

for j in range(N):
    for i in range(H*1000):
        if i-da[j]>=0:
            dp[i]=min(dp[i],dp[i-da[j]]+cost[j])

ans=0
for i in range(H,H*1000):
    if dp[i]!=float("inf"):
        ans=dp[i]
        break
print(ans)

Fixed submission:
H, N = map(int, input().split())
da, cost = [0] * N, [0] * N
for i in range(N):
    da[i],cost[i]=map(int, input().split())

max_da=max(da) 
dp = [float("inf") for i in range(H+max_da)]
dp[0]=0

for i in range(H+max_da):
    for j in range(N):
        if i-da[j]>=0:
            dp[i]=min(dp[i],dp[i-da[j]]+cost[j])

print(min(dp[H:]))

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
da, cost = [0] * N, [0] * N
for i in range(N):
    da[i],cost[i]=map(int, input().split())
max_da=max(da)  
dp = [float("inf") for i in range(H*1000)]
dp[0]=0

for j in range(N):
    for i in range(H*1000):
        if i-da[j]>=0:
            dp[i]=min(dp[i],dp[i-da[j]]+cost[j])

ans=0
for i in range(H,H*1000):
    if dp[i]!=float("inf"):
        ans=dp[i]
        break
print(ans)

Fixed submission:
H, N = map(int, input().split())
da, cost = [0] * N, [0] * N
for i in range(N):
    da[i],cost[i]=map(int, input().split())

max_da=max(da) 
dp = [float("inf") for i in range(H+max_da)]
dp[0]=0

for i in range(H+max_da):
    for j in range(N):
        if i-da[j]>=0:
            dp[i]=min(dp[i],dp[i-da[j]]+cost[j])

print(min(dp[H:]))

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
da, cost = [0] * N, [0] * N
for i in range(N):
    da[i],cost[i]=map(int, input().split())
max_da=max(da)  
dp = [float("inf") for i in range(H*10000)]
dp[0]=0

for j in range(N):
    for i in range(H*10000):
        if i-da[j]>=0:
            dp[i]=min(dp[i],dp[i-da[j]]+cost[j])

ans=0
for i in range(H,H*10000):
    if dp[i]!=float("inf"):
        ans=dp[i]
        break
print(ans)

Fixed submission:
H, N = map(int, input().split())
da, cost = [0] * N, [0] * N
for i in range(N):
    da[i],cost[i]=map(int, input().split())

max_da=max(da) 
dp = [float("inf") for i in range(H+max_da)]
dp[0]=0

for i in range(H+max_da):
    for j in range(N):
        if i-da[j]>=0:
            dp[i]=min(dp[i],dp[i-da[j]]+cost[j])

print(min(dp[H:]))

Buggy python submission (verdict: Runtime Error):
from mypulp import *

model = Model('aaa')
a=[int(i) for i in input().split()]
b=[input().split() for i in range(a[1])]
x={}
for j in range(1,a[1]+1):
    x[j]=model.addVar(vtype='I',name=f'x({j})')
model.update()
model.addConstr(quicksum(int(b[j-1][0])*x[j] for j in range(1,a[1]+1))>=a[0])
a=quicksum(int(b[j-1][1])*x[j] for j in range(1,a[1]+1))
model.setObjective(a, GRB.MINIMIZE )
model.optimize()
print(int(model.ObjVal)) 


Fixed submission:
H, N = map(int, input().split())
da, cost = [0] * N, [0] * N
for i in range(N):
    da[i],cost[i]=map(int, input().split())

max_da=max(da) 
dp = [float("inf") for i in range(H+max_da)]
dp[0]=0

for i in range(H+max_da):
    for j in range(N):
        if i-da[j]>=0:
            dp[i]=min(dp[i],dp[i-da[j]]+cost[j])

print(min(dp[H:]))