Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline

h, n = map(int, input().split())
a = map(int, read().split())
ab = zip(a, a)

INF = 10 ** 18
dp = [INF] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        if dp[i + a] > dp[i] + b:
            dp[i + a] = dp[i] + b
print(min(dp[h:]))

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

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline

h, n = map(int, input().split())
a = map(int, read().split())
ab = zip(a, a)

dp = [10 ** 18] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        if dp[i + a] > dp[i] + b:
            dp[i + a] = dp[i] + b
print(min(dp[h:]))

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

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline

h, n = map(int, input().split())
a = map(int, read().split())
ab = zip(a, a)

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        if dp[i + a] > dp[i] + b:
            dp[i + a] = dp[i] + b
print(min(dp[h:]))

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

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline

h, n = map(int, input().split())
ab = tuple(tuple(map(int, input().split())) for _ in range(n))

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        if dp[i + a] > dp[i] + b:
            dp[i + a] = dp[i] + b
print(min(dp[h:]))

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

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
ab = tuple(tuple(map(int, input().split())) for _ in range(n))

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        if dp[i + a] > dp[i] + b:
            dp[i + a] = dp[i] + b
print(min(dp[h:]))

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

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]

dp = [10 ** 18] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

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

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]

dp = [10 ** 20] * 10 ** 5
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

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

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))