Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [0]*(n+1)
    bb = [0]*(n+1)
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      mp[0][j] = 0
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
        	mp[i][j] = min(mp[i][j-1], mp[max(0, i - aa[j])][j] + bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()

Fixed submission:
# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [0]*(n+1)
    bb = [0]*(n+1)
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      mp[0][j] = 0
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
        	mp[i][j] = min(mp[i][j-1], mp[max(0, i - aa[j])][j] + bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [None for _ in range(n+1)]
    bb = [None for _ in range(n+1)]
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      mp[0][j] = 0
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
        	mp[i][j] = min(mp[i][j-1], mp[max(0, i - aa[j])][j] + bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()

Fixed submission:
# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [0]*(n+1)
    bb = [0]*(n+1)
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      mp[0][j] = 0
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
        	mp[i][j] = min(mp[i][j-1], mp[max(0, i - aa[j])][j] + bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [None for _ in range(n+1)]
    bb = [None for _ in range(n+1)]
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
            if i - aa[j] >= 1:
              # print(i, j, i - aa[j])
              mp[i][j] = min(mp[i][j-1], mp[i - aa[j]][j] + bb[j])
            else:
              mp[i][j] = min(mp[i][j-1], bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()

Fixed submission:
# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [0]*(n+1)
    bb = [0]*(n+1)
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      mp[0][j] = 0
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
        	mp[i][j] = min(mp[i][j-1], mp[max(0, i - aa[j])][j] + bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import math
h,n = map(int, input().split())
aa = [None for _ in range(n+1)]
bb = [None for _ in range(n+1)]
mp = [[None for _ in range(n+1)] for _ in range(h+1)]
# 体力i 技の種類j
for j in range(1, n+1):
  aa[j], bb[j] = map(int, input().split())
for i in range(1, h+1):
    mp[i][0] = float("inf")
for j in range(1, n+1):
    for i in range(1, h+1):
        if i - aa[j] >= 1:
          # print(i, j, i - aa[j])
          mp[i][j] = min(mp[i][j-1], mp[i - aa[j]][j] + bb[j])
        else:
          mp[i][j] = min(mp[i][j-1], bb[j])
print(mp[h][n])

Fixed submission:
# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [0]*(n+1)
    bb = [0]*(n+1)
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      mp[0][j] = 0
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
        	mp[i][j] = min(mp[i][j-1], mp[max(0, i - aa[j])][j] + bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math
h,n = map(int, input().split())
aa = [None]
bb = [None]
mp = []
for _ in range(h + 1):
  	mpp = []
	for __ in range(n+1):
      mpp.append(None)
    mp.append(mpp)
# 体力i 技の種類j
for j in range(1, n+1):
  a, b = map(int, input().split())
  aa.append(a)
  bb.append(b)

for i in range(1, h+1):
    mp[i][0] = float("inf")
for j in range(1, n+1):
    for i in range(1, h+1):
        if i - aa[j] >= 1:
          # print(i, j, i - aa[j])
          mp[i][j] = min(mp[i][j-1], mp[i - aa[j]][j] + bb[j])
        else:
          mp[i][j] = min(mp[i][j-1], bb[j])
print(mp[h][n])

Fixed submission:
# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [0]*(n+1)
    bb = [0]*(n+1)
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      mp[0][j] = 0
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
        	mp[i][j] = min(mp[i][j-1], mp[max(0, i - aa[j])][j] + bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import math
h,n = map(int, input().split())
aa = [None for _ in range(n+1)]
bb = [None for _ in range(n+1)]
mp = [[None for _ in range(n+1)] for _ in range(h+1)]
# 体力i 技の種類j
for j in range(1, n+1):
  aa[j], bb[j] = map(int, input().split())
for i in range(1, h+1):
    mp[i][0] = float("inf")
for j in range(1, n+1):
    for i in range(1, h+1):
        if i - aa[j] >= 1:
          # print(i, j, i - aa[j])
          mp[i][j] = min(mp[i][j-1], mp[i - aa[j]][j] + bb[j])
        else:
          mp[i][j] = min(mp[i][j-1], bb[j])
print(mp[h][n])

Fixed submission:
# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [0]*(n+1)
    bb = [0]*(n+1)
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      mp[0][j] = 0
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
        	mp[i][j] = min(mp[i][j-1], mp[max(0, i - aa[j])][j] + bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()