Buggy python submission (verdict: Runtime Error):
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    H,N = map(int,input().split())
    # AB = [list(map(int,input().split())) for _ in range(N)]
    A = []
    B = []
    for i in range(N):
        temp = list(map(int,input().split()))
        A.append(temp[0])
        B.append(temp[1])

    A = np.array(A)
    B = np.array(B)

    maxA = max(A)
    INF = 10 ** 4 + 1

    dp = [[INF for j in range(H+maxA+1)] for i in range(N)]
    dp[0][0] = 0
    for j in range(1,H+maxA+1):
        time = (j+A[0]-1)//A[0]
        dp[0][j] = B[0] * time

    for i in range(N-1):
        for j in range(H+maxA+1):
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-A[i+1]]+B[i+1])

    res = min(dp[N-1][H:])
    print(res)





main()


Fixed submission:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    H,N = map(int,input().split())
    # AB = [list(map(int,input().split())) for _ in range(N)]
    A = []
    B = []
    for i in range(N):
        temp = list(map(int,input().split()))
        A.append(temp[0])
        B.append(temp[1])

    # A = np.array(A)
    # B = np.array(B)

    maxA = max(A)
    INF = 10 ** 4 + 1

    dp = [[INF for j in range(H+maxA+1)] for i in range(N)]
    dp[0][0] = 0
    for j in range(1,H+maxA+1):
        time = (j+A[0]-1)//A[0]
        dp[0][j] = B[0] * time

    for i in range(N-1):
        for j in range(H+maxA+1):
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-A[i+1]]+B[i+1])

    res = min(dp[N-1][H:])
    print(res)





main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    H,N = map(int,input().split())
    # AB = [list(map(int,input().split())) for _ in range(N)]
    A = []
    B = []
    for i in range(N):
        temp = list(map(int,input().split()))
        A.append(temp[0])
        B.append(temp[1])

    A = np.array(A)
    B = np.array(B)

    maxA = max(A)
    INF = 10 ** 4 + 1

    dp = [[INF for j in range(H+maxA+1)] for i in range(N)]
    dp[0][0] = 0
    for j in range(1,H+maxA+1):
        time = (j+A[0]-1)//A[0]
        dp[0][j] = B[0] * time

    for i in range(N-1):
        for j in range(H+maxA+1):
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-A[i+1]]+B[i+1])

    res = min(dp[N-1][H:])
    print(res)





main()


Fixed submission:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    H,N = map(int,input().split())
    # AB = [list(map(int,input().split())) for _ in range(N)]
    A = []
    B = []
    for i in range(N):
        temp = list(map(int,input().split()))
        A.append(temp[0])
        B.append(temp[1])

    # A = np.array(A)
    # B = np.array(B)

    maxA = max(A)
    INF = 10 ** 4 + 1

    dp = [[INF for j in range(H+maxA+1)] for i in range(N)]
    dp[0][0] = 0
    for j in range(1,H+maxA+1):
        time = (j+A[0]-1)//A[0]
        dp[0][j] = B[0] * time

    for i in range(N-1):
        for j in range(H+maxA+1):
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-A[i+1]]+B[i+1])

    res = min(dp[N-1][H:])
    print(res)





main()