Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  int H,N,A,B;
  cin >> H >> N;
  vector<int> dp(H+1,100000001);
  dp[0] = 0;
  for(int n=0; n<N; n++){
    cin >> A >> B;
    for(int h=1; h<H+1; h++){
      dp[h] = min(dp[h],dp[max(0,h-A)]+B);
    }
  }
  cout << dp[H] << endl;
}

Fixed submission:
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(int argc, char* argv[])
{
  int H,N,A,B;
  cin >> H >> N;
  vector<int> dp(H+1,1000000000);
  dp[0] = 0;
  for(int n=0; n<N; n++){
    cin >> A >> B;
    for(int h=1; h<H+1; h++){
      dp[h] = min(dp[h],dp[max(0,h-A)]+B);
    }
  }
  cout << dp[H];
  return 0;
}

Fixed submission:
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(int argc, char* argv[])
{
  int H,N,A,B;
  cin >> H >> N;
  vector<int> dp(H+1,1000000000);
  dp[0] = 0;
  for(int n=0; n<N; n++){
    cin >> A >> B;
    for(int h=1; h<H+1; h++){
      dp[h] = min(dp[h], dp[max(0,h-A)]+B);
    }
  }
  cout << dp[H] << endl;
  return 0;
}

Fixed submission:
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Fixed submission:
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int, input().split())
dp = [0]+[float("inf")]*H
for n in range(N):
  A,B = map(int, input().split())
  for h in range(1,H+1):
    dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Fixed submission:
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int, input().split())
DP = [0]*(H+1)
dp_ = [0]+[float("inf")]*H
for n in range(N):
  A,B = map(int, input().split())
  dp = list(DP)
  for h in range(1,H+1): dp[h] = min(dp_[h], dp[max(0,h-A)]+B)
  dp_ = dp
print(dp[-1])

Fixed submission:
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int, input().split())
dp_ = [0]+[float("inf")]*H
for n in range(N):
  A,B = map(int, input().split())
  dp = [0]*(H+1)
  for h in range(1,H+1): dp[h] = min(dp_[h], dp[max(0,h-A)]+B)
  dp_ = dp
print(dp[-1])

Fixed submission:
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int, input().split())
dp_ = [0]+[float("inf")]*H
for n in range(N):
  dp = [0]+[float("inf")]*H
  A,B = map(int, input().split())
  for h in range(1,H+1):
    h_ = max(0,h-A)
    dp[h] = min(dp_[h], dp[h_]+B)
  dp_ = dp
print(dp[-1])

Fixed submission:
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
dp = [[0 if i == 0 else float("inf") for i in range(H+1)] for j in range(N+1)]
for n in range(N):
  for h in range(1,H+1):
    if h < AB[n][0]:
      dp[n+1][h] = min([dp[n][h], AB[n][1]])
    else:
      dp[n+1][h] = min([dp[n][h], dp[n+1][h-AB[n][0]]+AB[n][1]])
print(dp[-1][-1])

Fixed submission:
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])