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

max_a=max(a for a,_ in ab)
dp = [0] * (h+max_a)

for i in range(0,h+max_a):
    if i==0:
        d[i]=0
    else:
        dp[i]=min(dp[i-a]+b for a,b in ab)
print(min(dp[h:]))


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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        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())
ab=[list(map(int,input().split())) for _ in range(n)]

max_a=max(a for a,_ in ab)
dp = [0] * (h+max_a)

for i in range(0,h+max_a):
    if i==0:
        d[i]=0
    else:
        dp[i]=min(dp[i-a]+b for a,b in ab)
print(min(dp[h:])



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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        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())
ab=[list(map(int,input().split())) for _ in range(n)]

max_a=max(a for a,_ in ab)

for i in range(0,h+max_a):
    if i==0:
        d[i]=0
    else:
        dp[i]=min(dp[i-a]+b for a,b in ab)
print(min(dp[h:])


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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        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())
ab=[list(int,input().split()) for _ in range(n)]

max_a=max(a for a,_ in ab)

for i in range(0,h+max_a):
    if i==0:
        d[i]=0
    else:
        dp[i]=min(dp[i-a]+b for a,b in ab)
print(min(dp[h:])


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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        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())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[10**4+1]*(H+max(A)-1)#DPの箱をH+max(A)-1個用意する

for Ai,Bi in zip(A,B):#すでにあるものを埋める
    DP[Ai-1]=Bi

for dpi in range(H+max(A)-1):
    kouho=DP[dpi]
    for Ai,Bi in zip(A,B):
        if dpi-Ai>=0:
            if kouho>DP[dpi-Ai]+Bi:
                kouho=DP[dpi-Ai]+Bi
    DP[dpi]=kouho


print(min(DP[H:]))

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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        dp[i] = min(dp[i-a] + b for a,b in ab) 

print(min(dp[h:]))

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

H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[10**4+1]*(H+max(A)-1)#DPの箱をH+max(A)-1個用意する

for Ai,Bi in zip(A,B):#すでにあるものを埋める
    DP[Ai-1]=Bi

for dpi in range(H+max(A)-1):
    kouho=DP[dpi]
    for Ai,Bi in zip(A,B):
        if dpi-Ai>=0:
            if kouho>DP[dpi-Ai]+Bi:
                kouho=DP[dpi-Ai]+Bi
    DP[dpi]=kouho


print(min(DP[H:]))

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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        dp[i] = min(dp[i-a] + b for a,b in ab) 

print(min(dp[h:]))

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

H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[10**4+1]*(H+max(A)-1)#DPの箱をH+max(A)-1個用意する

for Ai,Bi in zip(A,B):#すでにあるものを埋める
    DP[Ai-1]=Bi

for dpi in range(H+max(A)-1):
    kouho=DP[dpi]
    for Ai,Bi in zip(A,B):
        if dpi-Ai>=0:
            if kouho>DP[dpi-Ai]+Bi:
                kouho=DP[dpi-Ai]+Bi
    DP[dpi]=kouho


print(min(DP[H:]))

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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        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())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[10**9]*(H+max(A)-1)#DPの箱をH+max(A)-1個用意する

for Ai,Bi in zip(A,B):#すでにあるものを埋める
    DP[Ai-1]=Bi

for dpi in range(H+max(A)-1):
    #kouho=[]
    #kouho.append(DP[dpi])
    kouho=DP[dpi]
    for Ai,Bi in zip(A,B):
        if dpi-Ai>=0:
            if kouho<DP[dpi-Ai]+Bi:
            #kouho.append(DP[dpi-Ai]+Bi)
    DP[dpi]=kouho


print(min(DP[H-1:]))

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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        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())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[10**9]*(H+max(A)-1)#DPの箱をH+max(A)-1個用意する

for Ai,Bi in zip(A,B):#すでにあるものを埋める
    DP[Ai-1]=Bi

for dpi in range(H+max(A)-1):
    #kouho=[]
    #kouho.append(DP[dpi])
    kouho=DP[dpi]
    for Ai,Bi in zip(A,B):
        if dpi-Ai>=0:
            if kouho<DP[dpi-Ai]+Bi
            #kouho.append(DP[dpi-Ai]+Bi)
    DP[dpi]=kouho


print(min(DP[H-1:]))

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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        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())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[10**9]*(H+max(A)-1)#DPの箱をH+max(A)-1個用意する

for Ai in zip(A,B):#すでにあるものを埋める
    DP[Ai-1]=Bi

for dpi in range(H+max(A)-1):
    kouho=[]
    kouho.append(DP[dpi])
    for Ai,Bi in zip(A,B):
        if dpi-Ai>=0:
            kouho.append(DP[dpi-Ai]+Bi)
    DP[dpi]=min(kouho)


print(min(DP[H-1:]))

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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        dp[i] = min(dp[i-a] + b for a,b in ab) 

print(min(dp[h:]))

Buggy python submission (verdict: Runtime Error):
import math
H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

#DP=[0]*(H+max(A)-1)#DPの箱をH+max(A)-1個用意する

DP=[math.inf]*(H+max(A)-1)#DPの箱をH+max(A)-1個用意する

for Ai in A:#すでにあるものを埋める
    DP[Ai-1]=Ai 

for dpi in range(H+max(A)-1):
    kouho=[]
    for Ai,Bi in zip(A,B):
        kouho.append(DP[dpi])
        if dpi-Ai>=0:
            kouho.append(DP[dpi-Ai]+Bi)
    DP[dpi]=min(kouho)


print(min(DP[H-1:]))

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

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        dp[i] = min(dp[i-a] + b for a,b in ab) 

print(min(dp[h:]))