Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import heapq
from collections import defaultdict

def solve(H: int, N: int, A: "List[int]", B: "List[int]"):
    MAX = 10**16
    minCurrent = defaultdict(lambda :MAX)
    minCurrent[0] = 0
    currentPos = [0]
    heapq.heapify(currentPos)
    visited = set()
    while len(currentPos) > 0:
        cp = heapq.heappop(currentPos)
        if cp in visited:
            continue
        if cp > H:
            break
        visited.add(cp)
        cc = minCurrent[cp]
        for i in range(N):
            heapq.heappush(currentPos, cp + A[i])
            minCurrent[cp + A[i]] = min(minCurrent[cp + A[i]],cc+B[i])
    c = MAX
    for key in minCurrent:
        if key >=H:
            c = min(c,minCurrent[key])
    print(c)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(H, N, A, B)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import heapq


def solve(H: int, N: int, A: "List[int]", B: "List[int]"):
    dp = [10**16]*(H+1)
    dp[0] = 0
    positions = [0]
    for i in range(len(dp)):
        c = dp[i]
        for j in range(N):
            ni = min(H, i+A[j])
            dp[ni] = min(dp[ni], c+B[j])
    print(dp[-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(H, N, A, B)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import heapq
from collections import defaultdict

def solve(H: int, N: int, A: "List[int]", B: "List[int]"):
    MAX = 10**16
    minCurrent = defaultdict(lambda :MAX)
    minCurrent[0] = 0
    currentPos = [0]
    heapq.heapify(currentPos)
    visited = set()
    while len(currentPos) > 0:
        cp = heapq.heappop(currentPos)
        if cp in visited:
            continue
        if cp > H:
            break
        visited.add(cp)
        cc = minCurrent[cp]
        for i in range(N):
            heapq.heappush(currentPos, cp + A[i])
            minCurrent[cp + A[i]] = min(minCurrent[cp + A[i]],cc+B[i])
    c = MAX
    for key in minCurrent:
        if key >=H:
            c = min(c,minCurrent[key])
    print(c)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(H, N, A, B)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import heapq


def solve(H: int, N: int, A: "List[int]", B: "List[int]"):
    dp = [10**16]*(H+1)
    dp[0] = 0
    positions = [0]
    for i in range(len(dp)):
        c = dp[i]
        for j in range(N):
            ni = min(H, i+A[j])
            dp[ni] = min(dp[ni], c+B[j])
    print(dp[-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(H, N, A, B)


if __name__ == '__main__':
    main()