Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

# インデックスはライフ 値はそれを以下にする最小MP
dp = [10**10 for i in range(H+1)]
# dp = [np.inf for i in range(H+1)]
dp[0] = 0

for i in range(1, H+1):
    # quietus_MP = np.inf
    for a, b in AB:
        # if i-a >= 0:
        dp[i] = min(dp[max(i-a, 0)] + b, dp[i])
        # 一回で倒せて一番MP使わない魔法
        # if a > i:
        #     quietus_MP = min(b, quietus_MP)
    # 一回で倒す場合
    # dp[i] = min(quietus_MP, dp[i])

print(dp[-1])

Fixed submission:
import numpy as np

H, N = map(int, input().split())
AB = np.array([list(map(int, input().split())) for i in range(N)])
A = AB[:, 0]
B = AB[:, 1]

# インデックスはライフ 値はそれを以下にする最小MP
dp = np.array([10**10 for i in range(H+1)], dtype=int)
# dp = np.array([np.inf for i in range(H+1)], dtype=int)
dp[0] = 0

for i in range(1, H+1):
    # print(np.maximum(i-A, 0))
    dp[i] = min(dp[np.maximum(i-A, 0)] + B)

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

# インデックスはライフ 値はそれを以下にする最小MP
dp = [np.inf for i in range(H+1)]
dp[0] = 0

for i in range(1, H+1):
    quietus_MP = np.inf
    for a, b in AB:
        # if i-a >= 0:
        dp[i] = min(dp[max(i-a, 0)] + b, dp[i])
        # 一回で倒せて一番MP使わない魔法
        # if a > i:
        #     quietus_MP = min(b, quietus_MP)
    # 一回で倒す場合
    # dp[i] = min(quietus_MP, dp[i])

print(dp[-1])

Fixed submission:
import numpy as np

H, N = map(int, input().split())
AB = np.array([list(map(int, input().split())) for i in range(N)])
A = AB[:, 0]
B = AB[:, 1]

# インデックスはライフ 値はそれを以下にする最小MP
dp = np.array([10**10 for i in range(H+1)], dtype=int)
# dp = np.array([np.inf for i in range(H+1)], dtype=int)
dp[0] = 0

for i in range(1, H+1):
    # print(np.maximum(i-A, 0))
    dp[i] = min(dp[np.maximum(i-A, 0)] + B)

print(dp[-1])

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

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

# インデックスはライフ 値はそれを以下にする最小MP
dp = [np.inf for i in range(H+1)]
dp[0] = 0

for i in range(1, H+1):
    quietus_MP = np.inf
    for a, b in AB:
        # if i-a >= 0:
        dp[i] = min(dp[max(i-a, 0)] + b, dp[i])
        # 一回で倒せて一番MP使わない魔法
        # if a > i:
        #     quietus_MP = min(b, quietus_MP)
    # 一回で倒す場合
    # dp[i] = min(quietus_MP, dp[i])

print(dp[-1])

Fixed submission:
import numpy as np

H, N = map(int, input().split())
AB = np.array([list(map(int, input().split())) for i in range(N)])
A = AB[:, 0]
B = AB[:, 1]

# インデックスはライフ 値はそれを以下にする最小MP
dp = np.array([10**10 for i in range(H+1)], dtype=int)
# dp = np.array([np.inf for i in range(H+1)], dtype=int)
dp[0] = 0

for i in range(1, H+1):
    # print(np.maximum(i-A, 0))
    dp[i] = min(dp[np.maximum(i-A, 0)] + B)

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

# インデックスはライフ 値はそれを以下にする最小MP
dp = [np.inf for i in range(H+1)]
dp[0] = 0

for i in range(1, H+1):
    quietus_MP = np.inf
    for a, b in AB:
        if i-a >= 0:
            dp[i] = min(dp[i-a]+b, dp[i])
        # 一回で倒せて一番MP使わない魔法
        if a > i:
            quietus_MP = min(b, quietus_MP)
    # 一回で倒す場合
    dp[i] = min(quietus_MP, dp[i])

print(dp[-1])

Fixed submission:
import numpy as np

H, N = map(int, input().split())
AB = np.array([list(map(int, input().split())) for i in range(N)])
A = AB[:, 0]
B = AB[:, 1]

# インデックスはライフ 値はそれを以下にする最小MP
dp = np.array([10**10 for i in range(H+1)], dtype=int)
# dp = np.array([np.inf for i in range(H+1)], dtype=int)
dp[0] = 0

for i in range(1, H+1):
    # print(np.maximum(i-A, 0))
    dp[i] = min(dp[np.maximum(i-A, 0)] + B)

print(dp[-1])

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

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

# インデックスはライフ 値はそれを以下にする最小MP
dp = [np.inf for i in range(H+1)]
dp[0] = 0

for i in range(1, H+1):
    quietus_MP = np.inf
    for j in AB:
        if i-j[0] >= 0:
            dp[i] = min(dp[i-j[0]]+j[1], dp[i])
        # 一回で倒せて一番MP使わない魔法
        if j[0] > i:
            quietus_MP = min(j[1], quietus_MP)
    # 一回で倒す場合
    dp[i] = min(quietus_MP, dp[i])

print(dp[-1])

Fixed submission:
import numpy as np

H, N = map(int, input().split())
AB = np.array([list(map(int, input().split())) for i in range(N)])
A = AB[:, 0]
B = AB[:, 1]

# インデックスはライフ 値はそれを以下にする最小MP
dp = np.array([10**10 for i in range(H+1)], dtype=int)
# dp = np.array([np.inf for i in range(H+1)], dtype=int)
dp[0] = 0

for i in range(1, H+1):
    # print(np.maximum(i-A, 0))
    dp[i] = min(dp[np.maximum(i-A, 0)] + B)

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

# インデックスはライフ 値はそれを以下にする最小MP
dp = [np.inf for i in range(H+1)]
dp[0] = 0

for i in range(1, H+1):
    quietus_MP = np.inf
    for j in AB:
        if i-j[0] >= 0:
            dp[i] = min(dp[i-j[0]]+j[1], dp[i])
        # 一回で倒せて一番MP使わない魔法
        if j[0] > i:
            quietus_MP = min(j[1], quietus_MP)
    # 一回で倒す場合
    dp[i] = min(quietus_MP, dp[i])

print(dp[-1])

Fixed submission:
import numpy as np

H, N = map(int, input().split())
AB = np.array([list(map(int, input().split())) for i in range(N)])
A = AB[:, 0]
B = AB[:, 1]

# インデックスはライフ 値はそれを以下にする最小MP
dp = np.array([10**10 for i in range(H+1)], dtype=int)
# dp = np.array([np.inf for i in range(H+1)], dtype=int)
dp[0] = 0

for i in range(1, H+1):
    # print(np.maximum(i-A, 0))
    dp[i] = min(dp[np.maximum(i-A, 0)] + B)

print(dp[-1])