Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
inf =1000100001001000
dp = [inf for _ in range(H+1)]

# min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
        nj = min(h+a,H)
        dp[nj] = min([dp[nj],dp[h]+b])
        
print(int(dp[H]))

Fixed submission:
H, N = map(int, input().split())
inf =1000100001001000
dp = [inf for _ in range(H+1)]
 
# min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
        nj = min(h+a,H)
        dp[nj] = min([dp[nj],dp[h]+b])
        
print(int(dp[H]))

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())

dp = [np.inf for _ in range(H+1)]

# min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
    
        nj = min(h+a,H)
        dp[nj] = min([dp[nj],dp[h]+b])
            # if h+a<H:
            #     dp[h+a] = np.min([dp[h+a], dp[h]+b])
            # elif dp[h]+b<min_cost:
            #     min_cost = dp[h]+b
        
print(int(dp[H]))

Fixed submission:
H, N = map(int, input().split())
inf =1000100001001000
dp = [inf for _ in range(H+1)]
 
# min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
        nj = min(h+a,H)
        dp[nj] = min([dp[nj],dp[h]+b])
        
print(int(dp[H]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 
H, N = map(int, input().split())

dp = [np.inf for _ in range(H+1)]

# min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
        if dp[h]!=np.inf:
            nj = min(h+a,H)
            dp[nj] = min([dp[nj],dp[h]+b])
            # if h+a<H:
            #     dp[h+a] = np.min([dp[h+a], dp[h]+b])
            # elif dp[h]+b<min_cost:
            #     min_cost = dp[h]+b
        
print(int(dp[H]))

Fixed submission:
H, N = map(int, input().split())
inf =1000100001001000
dp = [inf for _ in range(H+1)]
 
# min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
        nj = min(h+a,H)
        dp[nj] = min([dp[nj],dp[h]+b])
        
print(int(dp[H]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 
H, N = map(int, input().split())

dp = [np.inf for _ in range(H+1)]

min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
        if dp[h]!=np.inf:
            if h+a<H:
                dp[h+a] = np.min([dp[h+a], dp[h]+b])
            elif dp[h]+b<min_cost:
                min_cost = dp[h]+b
print(int(min_cost))



Fixed submission:
H, N = map(int, input().split())
inf =1000100001001000
dp = [inf for _ in range(H+1)]
 
# min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
        nj = min(h+a,H)
        dp[nj] = min([dp[nj],dp[h]+b])
        
print(int(dp[H]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 
H, N = map(int, input().split())
a_list = []
b_list = []

best_at_a = None
best_at_b = None
best_at_c = 0

for _ in range(N):
    a,b =  map(int, input().split())
    a_list.append(a)
    b_list.append(b)
    
    c = a/b # コスパ
    if c>best_at_c:
        best_at_c=c
        best_at_a=a
        best_at_b=b
a_list = np.array(a_list)
b_list = np.array(b_list)


dp = [np.inf for _ in range(H)]

min_cost = np.inf
dp[0]=0
for h in range(H): # h はこれまで削った体力
    if dp[h]!=np.inf:
        for n in range(N):
            a= a_list[n]
            b= b_list[n]
            if h+a_list[n]<H:
                dp[h+a] = np.min([dp[h+a], dp[h]+b])
            elif dp[h]+b<min_cost:
                min_cost = dp[h]+b
print(int(min_cost))


Fixed submission:
H, N = map(int, input().split())
inf =1000100001001000
dp = [inf for _ in range(H+1)]
 
# min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
        nj = min(h+a,H)
        dp[nj] = min([dp[nj],dp[h]+b])
        
print(int(dp[H]))