Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input.split())

if a > x:
	print("NO")
elif x - a > b:
	print("YES")
else:
	print("NO")


Fixed submission:
a, b, x = map(int, input().split())

if a > x:
	print("NO")
elif x - a > b:
	print("NO")
else:
	print("YES")
Buggy python submission (verdict: Runtime Error):
n = int(input())
d, x = int(input())
ans = x
for i in range(n):
	ans += (d - 1) // int(input()) + 1

print(ans)

Fixed submission:
n = int(input())
d, x = map(int, input().split())
ans = x
for i in range(n):
	ans += (d - 1) // int(input()) + 1

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
d, x = map(int(input()))
ans = x
for i in range(n):
	ans += (d - 1) // int(input()) + 1

print(ans)

Fixed submission:
n = int(input())
d, x = map(int, input().split())
ans = x
for i in range(n):
	ans += (d - 1) // int(input()) + 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [int(input()) for _ in range(n)]
m = int(input())
t = [int(input()) for _ in range(m)]

pointList = dict();

for temp in s:
  pointList[temp] = 0
for temp in t:
  pointList[temp] = 0
  
for temp in s:
  pointList[temp] += 1
for temp in t:
  pointList[temp] -= 1
  
ans = max(0, max(pointList.values()))

print(ans)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

pointList = dict();

for temp in s:
  pointList[temp] = 0
for temp in t:
  pointList[temp] = 0
  
for temp in s:
  pointList[temp] += 1
for temp in t:
  pointList[temp] -= 1
  
ans = max(0, max(pointList.values()))

print(ans)
Buggy python submission (verdict: Runtime Error):
a=raw_input()
b=raw_input()
c=raw_input()
 
print(a[0])
print(b[1])
print(c[2])

Fixed submission:
a = input()
b = input()
c = input()
 
print(a[0]+b[1]+c[2])

Buggy python submission (verdict: Runtime Error):
import sys

a = raw_input()
b = raw_input()
c = raw_input()
 
print(a[0])
print(b[1])
print(c[2])

Fixed submission:
a = input()
b = input()
c = input()
 
print(a[0]+b[1]+c[2])

Buggy python submission (verdict: Runtime Error):
a = raw_input()
b = raw_input()
c = raw_input()
 
print(a[0])
print(b[1])
print(c[2])

Fixed submission:
a = input()
b = input()
c = input()
 
print(a[0]+b[1]+c[2])

Buggy python submission (verdict: Runtime Error):
a = raw_input()
b = raw_input()
c = raw_input()
print(a[0])
print(b[1])
print(c[2])

Fixed submission:
a = input()
b = input()
c = input()
 
print(a[0]+b[1]+c[2])

Buggy python submission (verdict: Runtime Error):
a = raw_input()
b = raw_input()
c = raw_input()
 
print(a[0])
print(b[1])
print(c[2])

Fixed submission:
a = input()
b = input()
c = input()
 
print(a[0]+b[1]+c[2])

Buggy python submission (verdict: Runtime Error):
a = input_raw()
b = input_raw()
c = input_raw()
 
print(a[0])
print(b[1])
print(c[2])

Fixed submission:
a = input()
b = input()
c = input()
 
print(a[0]+b[1]+c[2])

Buggy python submission (verdict: Runtime Error):
a = raw_input()
b = raw_input()
c = raw_input()

print(a[0])
print(a[1])
print(a[2])

Fixed submission:
a = input()
b = input()
c = input()
 
print(a[0]+b[1]+c[2])
Buggy python submission (verdict: Runtime Error):
a = input()
b = a / 3
print(b)

Fixed submission:
a = int(input())
b = int(a / 3)
print(b)

Buggy python submission (verdict: Runtime Error):
a = input()
print(a/3)

Fixed submission:
a = int(input())
b = int(a / 3)
print(b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(map(int, input().split()))

for si in s:
  if si == "Y":
    print("Four")
    break
else:
  print("Three")

Fixed submission:
n = int(input())
s = input().split()

for si in s:
  if si == "Y":
    print("Four")
    break
else:
  print("Three")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
b = int(N / A)
c = N - 500 * b
if c > A:
    print("No")
else:
    print("Yes")

Fixed submission:
n = int(input())
a = int(input())

if n % 500 <= a:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort().reverse()

ans = 0
for i in range(len(a)):
  if i % 2 == 0:
    ans += a[i]
  else:
    ans -= a[i]

print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()

ans = 0
for i in range(len(a)):
  if i % 2 == 0:
    ans += a[i]
  else:
    ans -= a[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input()split())

if a + b > c + d:
	print("Left")
elif a + b == c + d:
	print("Balanced")
else:
	print("Right")

Fixed submission:
a, b, c, d = map(int, input().split())

if a + b > c + d:
	print("Left")
elif a + b == c + d:
	print("Balanced")
else:
	print("Right")
Buggy python submission (verdict: Runtime Error):
x, y = input().split()

if x > y:
	print(">")
elsif x == y:
	print("=")
else:
	print("<")

Fixed submission:
x, y = input().split()

if x > y:
	print(">")
elif x == y:
	print("=")
else:
	print("<")
Buggy python submission (verdict: Runtime Error):
c = []
for i in range(2):
	c.append(list(map(int, input().split())))

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("Yes")
else:
	print("No")

Fixed submission:
c = []
for i in range(2):
	c.append(input())

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("YES")
else:
	print("NO")

Buggy python submission (verdict: Runtime Error):
c = []
for i in range(2):
	c.append(list(map(int, input().split()))

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("Yes")
else:
	print("No")

Fixed submission:
c = []
for i in range(2):
	c.append(input())

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("YES")
else:
	print("NO")

Buggy python submission (verdict: Runtime Error):
c = [[list(map(int, input().split()))] for _ in range(2)]

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("Yes")
else:
	print("No")

Fixed submission:
c = []
for i in range(2):
	c.append(input())

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("YES")
else:
	print("NO")

Buggy python submission (verdict: Runtime Error):
c = [list(map(int, input().split())) for _ in range(2)]

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("Yes")
else:
	print("No")

Fixed submission:
c = []
for i in range(2):
	c.append(input())

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("YES")
else:
	print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())

if "9" in n:
  print("Yes")
else:
  print("No")

Fixed submission:
n = input()

if "9" in n:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = 50
big = 10 ** 16

K = int(input())

if K <= 50 * 50:
    a = [49] * 50
    a[0] += K * 50
else:
    a = [0] * 50
    index = 0 
    for i in range(K // big):
        a[i] = big
    a[i] = K % big
print(N)
print(" ".join(map(str, a)))

Fixed submission:
K = int(input())
N = 50
a = [0] * 50

if K <= 50:
    for i in range(K):
        a[i] = 50
else:
    m = (K - 1) // 50
    base = 100 + m
    r = K % 50
    big = base - r
    small = big - 50 - r

    for i in range(r):
        a[i] = big
    for i in range(r, N, 1):
        a[i] = small

print(N)
print(" ".join(map(str, a)))
Buggy python submission (verdict: Runtime Error):
import fractions

A, B, C = map(int, input().split())
ab = fractions.gcd(A, B)
if C % temp == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
import fractions

A, B, C = map(int, input().split())
ab = fractions.gcd(A, B)
temp = fractions.gcd(A, ab)
if C % temp == 0:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
import fractions

A, B, C = map(int, input().split())
ab = math.gcd(A, B)
temp = fractions.gcd(A, ab)
if C % temp == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
import fractions

A, B, C = map(int, input().split())
ab = fractions.gcd(A, B)
temp = fractions.gcd(A, ab)
if C % temp == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a,b = [x for x in input().split(' ')]
if a * b % 2 == 0:
	print('Even')
else:
	print('Odd')

Fixed submission:
a,b = [int(x) for x in input().split(' ')]
if a * b % 2 == 0:
	print('Even')
else:
	print('Odd')
Buggy python submission (verdict: Runtime Error):
import math as mt
store = []
def binarysearch(min, max):
    mid = int((max + min)/2)
    if (min == max):
        return mid
    elif count(mid) > mid:
        return binarysearch(mid+1, max)
    else:
        return binarysearch(min, mid)

def count(x):
    store = [mt.ceil((n - x*b)/a) for n in hp]
    store = [x for x in store if x > 0]
    return sum(store)

st = 0
min = 10 ** 18
max = 0
n, a, b = [int(x) for x in input().split(' ')]
hp = []
for i in range(n):
    st = int(input())
    if st < min:
        min = st
    if st > max:
        max = st
    hp.append(st)
min, max = mt.ceil(min/a), mt.ceil(max/b)
a = a - b
print(binarysearch(min,max))


Fixed submission:
n = int(input())
sum = 0
sub = 101
for i in range(n):
    store = int(input())
    sum += store
    if store % 10 != 0 and store < sub:
        sub = store
if sum % 10 != 0:
    print(sum)
else:
    if sub == 101:
        print(0)
    else:
        print(sum - sub)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(x) for x in input().split(' ')]
exist = []
storage = [0 for x in range(10 ** 5+1)]
for i in range(n):
    a, b = [int(x) for x in input().split(' ')]
    storage[a] += b
    if a not in exist:
        exist.append(a)
exist.sort()
sum = 0
for i in exist:
    sum += storage[i]
    if sum >= k:
        print(i)
        break
    else:
        continue


Fixed submission:
n, k = [int(x) for x in input().split(' ')]
exist = []
storage = [0 for x in range(10 ** 5+1)]
for i in range(n):
    a, b = [int(x) for x in input().split(' ')]
    storage[a] += b
sum = 0
for i in range(1, 10**5+1):
    sum += storage[i]
    if sum >= k:
        print(i)
        break
    else:
        continue
Buggy python submission (verdict: Runtime Error):
a=int(input()) print(a+a*a+a**3)

Fixed submission:
a=input()
a=int(a)
print(a+a*a+a*a*a)

Buggy python submission (verdict: Runtime Error):
a=input()
print(a+a*a+a*a*a)

Fixed submission:
a=input()
a=int(a)
print(a+a*a+a*a*a)
Buggy python submission (verdict: Time Limit Exceeded):
def ge():
    return map(int,input().split())
def main():
    #a,b,c,d=ge()
    #N=int(input())
    #a=list(map(int,input().split()))
    #a=input()
    N=int(input())
    x=[]
    y=[]
    for _ in range(N):
        X,Y=ge()
        x.append(X)
        y.append(Y)
    x_list=[]
    for i in range(len(x)-1):
        for j in range(i,len(x)):
            x_list.append(abs(x[i]-x[j]))
    y_list=[]
    for i in range(len(y)-1):
        for j in range(i,len(y)):
            y_list.append(abs(y[i]-y[j]))
    ans=0
    for i in range(len(x_list)):
        ans=max(ans,x_list[i]+y_list[i])
    print(ans)



main()

Fixed submission:
def ge():
    return map(int,input().split())
def main():
    #a,b,c,d=ge()
    #N=int(input())
    #a=list(map(int,input().split()))
    #a=input()
    N=int(input())
    f0=[]
    f1=[]
    for _ in range(N):
        X,Y=ge()
        f0.append(X-Y)
        f1.append(X+Y)
    ans=max(max(f0)-min(f0),max(f1)-min(f1))
    print(ans)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def ge():
    return map(int,input().split())
def main():
    #a,b,c,d=ge()
    #N=int(input())
    #a=list(map(int,input().split()))
    #a=input()
    N=int(input())
    x=[]
    y=[]
    for _ in range(N):
        X,Y=ge()
        x.append(X)
        y.append(Y)
    x_list=[]
    for i in range(len(x)-1):
        for j in range(i,len(x)):
            x_list.append(abs(x[i]-x[j]))
    y_list=[]
    for i in range(len(y)-1):
        for j in range(i,len(y)):
            y_list.append(abs(y[i]-y[j]))
    ans=0
    for i in range(len(x_list)):
        ans=max(ans,x_list[i]+y_list[i])
    print(ans)



main()

Fixed submission:
def ge():
    return map(int,input().split())
def main():
    #a,b,c,d=ge()
    #N=int(input())
    #a=list(map(int,input().split()))
    #a=input()
    N=int(input())
    f0=[]
    f1=[]
    for _ in range(N):
        X,Y=ge()
        f0.append(X-Y)
        f1.append(X+Y)
    ans=max(max(f0)-min(f0),max(f1)-min(f1))
    print(ans)
main()
Buggy python submission (verdict: Runtime Error):
def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[1]*len(A)
    for i in  range(len(A)-1):
        if ans[i]==0:
            continue
        for j in range(i+1,len(A)):
            if A[j]%A[i]==0:
                ans[j]=0
    an=0
    for i in range(len(A)-1):
        if A[i]!=A[i+1]:
            an+=ans[i]
    an+=ans[-1]
    print(an)
main1()


Fixed submission:
A=list(map(int,input().split()))
for i in range(len(A)):
  if A[i]==0:
    print(i+1)
    break
Buggy python submission (verdict: Runtime Error):
def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[0]*(10**6)
    for i in  range(len(A)-1):
        if ans[A[i]]>=2:
            continue
        if A[i]!=A[i+1]:
            ans[i]+=1
        for j in range(A[i]*2,10**6,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()

Fixed submission:
def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[0]*(10**6+1)
    if N ==1 :
        print(1)
        return 
    for i in  range(len(A)):
        ans[A[i]]+=1
        if ans[A[i]]==1:
            for j in range(A[i]*2,10**6+1,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()

Buggy python submission (verdict: Runtime Error):
def main1():
    N=int(input())
    A=map(int,input().split())
    A.sort()
    ans=[0]*(10**6)
    for i in  range(len(A)-1):
        if ans[i]>=2:
            continue
        if A[i]!=A[i+1]:
            ans[i]+=1
        for j in range(A[i]*2,10**6,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()

Fixed submission:
def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[0]*(10**6+1)
    if N ==1 :
        print(1)
        return 
    for i in  range(len(A)):
        ans[A[i]]+=1
        if ans[A[i]]==1:
            for j in range(A[i]*2,10**6+1,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()

Buggy python submission (verdict: Time Limit Exceeded):
def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[1]*len(A)
    for i in  range(len(A)-1):
        if ans[i]==0:
            continue
        for j in range(i+1,len(A)):
            if A[j]%A[i]==0:
                ans[j]=0
    an=0
    for i in range(len(A)-1):
        if A[i]!=A[i+1]:
            an+=ans[i]
    an+=ans[-1]
    print(an)
main1()


Fixed submission:
def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[0]*(10**6+1)
    if N ==1 :
        print(1)
        return 
    for i in  range(len(A)):
        ans[A[i]]+=1
        if ans[A[i]]==1:
            for j in range(A[i]*2,10**6+1,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()

Buggy python submission (verdict: Time Limit Exceeded):
def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[1]*len(A)
    for i in  range(len(A)-1):
        if ans[i]==0:
            continue
        for j in range(i+1,len(A)):
            if A[j]%A[i]==0:
                ans[j]=0
    an=0
    for i in range(len(A)-1):
        if A[i]!=A[i+1]:
            an+=ans[i]
    an+=ans[-1]
    print(an)
main1()


Fixed submission:
def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[0]*(10**6+1)
    if N ==1 :
        print(1)
        return 
    for i in  range(len(A)):
        ans[A[i]]+=1
        if ans[A[i]]==1:
            for j in range(A[i]*2,10**6+1,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()
Buggy python submission (verdict: Runtime Error):
def main():
    a,b=map(float,input().split())
    a=int(a)
    print(b*100//1)*a//100)
main()


Fixed submission:
def main():
    a,b=map(float,input().split())
    a=int(a)
    print(int((b*100+0.1)//1)*a//100)
main()

Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
print((B*100)*A//100)

Fixed submission:
def main():
    a,b=map(float,input().split())
    a=int(a)
    print(int((b*100+0.1)//1)*a//100)
main()
Buggy python submission (verdict: Runtime Error):
import sympy
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def main():
    N=int(input())
    ans=0
    if N==1:
        print(ans)
        return 
    t=prime_decomposition(N)
    if len(t)==1:
        print(1)
        return 
    dic={}
    for a in t:
        if not a in dic.keys():
            dic[a]=1
            continue
        else:
            dic[a]+=1
    ans=0
    for i in dic.keys():
        num=dic[i]
        tmp=1
        c=1
        while True:
            if num >=c:
                num-=c
                c+=1
                ans+=1
            else:
                break
    print(ans)



        


main()


Fixed submission:
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def main():
    N=int(input())
    ans=0
    if N==1:
        print(ans)
        return 
    t=prime_decomposition(N)
    if len(t)==1:
        print(1)
        return 
    dic={}
    for a in t:
        if not a in dic.keys():
            dic[a]=1
            continue
        else:
            dic[a]+=1
    ans=0
    for i in dic.keys():
        num=dic[i]
        tmp=1
        c=1
        while True:
            if num >=c:
                num-=c
                c+=1
                ans+=1
            else:
                break
    print(ans)
main()
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
index=[0]
index.append(A[0]-1)
flag=0
count=0
for _ in range(1,K):
    t=index[-1]
    if (A[t]-1) in index:
        index.append(A[t]-1)
        flag=1
        break
    index.append(A[t]-1)
if flag==0:
    print(index[-1]+1)
    exit()
check = index[-1]
for i,c in enumerate(index):
    if c==check:
        a_path=i
        break
#print(index)
#print("a_path",a_path)
K-=a_path
t=len(index)-1-a_path
#print("t",t)
print(index[a_path+K%t]+1)
#print(index)


Fixed submission:
import bisect
N,K=map(int,input().split())
A=list(map(int,input().split()))
index=[0]
index.append(A[0]-1)
tt=[A[0]-1]
flag=0
count=0
for _ in range(1,K):
    t=index[-1]
    ttt=bisect.bisect_left(tt, A[t]-1)

    if len(tt) > ttt and tt[ttt]==A[t]-1:
        index.append(A[t]-1)
        flag=1
        break
    index.append(A[t]-1)
    bisect.insort(tt,A[t]-1)
if flag==0:
    print(index[-1]+1)
    exit()
#print("a")
#print(index)
check = index[-1]
for i,c in enumerate(index):
    if c==check:
        a_path=i
        break
K-=a_path
t=len(index)-1-a_path
print(index[a_path+K%t]+1)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
ans=0
for i in range(K,N+2):
    tmp=i*N-2*sum(range(0,i))+1
    ans+=tmp
    ans%=(10**9+7)
print(ans)

Fixed submission:
N,K=map(int,input().split())
ans=0
for i in range(K,N+2):
    tmp=i*N-(i-1)*i+1
    ans+=tmp
    ans%=(10**9+7)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
ans={}
cnt=0
for i in range():
  t=input()
  if not t in ans.keys():
    ans[i]==1
  else:
    ans[i]+=1
  if cnt<ans[i]:
    cnt=ans[i]
tmp =[]
for i in ans.keys():
  if ans[i]  == cnt:
    tmp.append(i)
for i in sort(tmp):
  print(i)


Fixed submission:
N=int(input())
ans={}
cnt=0
for i in range(N):
  t=input()
  if not t in ans.keys():
    ans[t]=1
  else:
    ans[t]+=1
  if cnt<ans[t]:
    cnt=ans[t]
tmp =[]
for i in ans.keys():
  if ans[i]  == cnt:
    tmp.append(i)
tmp.sort()
for i in tmp:
  print(i)
Buggy python submission (verdict: Runtime Error):
S=input()
for i in range(len(S)):
  S[i]="x"
print(S)

Fixed submission:
S=input()
ans=""
for i in range(len(S)):
  ans+="x"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
P=list(map(int,input().split()))
ans=sum(P[0:K])
flag=0
for i in range(len(P)-K+1):
  ans=max(ans,sum(P[i:i+K]))
print((ans+K)*0.5)

Fixed submission:
N,K=list(map(int,input().split()))
P=list(map(int,input().split()))
ans=[0]
ans[0]=sum(P[0:K])
for i in range(K,len(P)):
  ans.append(ans[-1]-P[i-K]+P[i])
print((max(ans)+K)*0.5)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
P=list(map(int,input().split()))
ans=0
flag=0
for i in range(len(P)-K+1):
  ans=max(ans,sum(P[i:i+K]))
print((ans+K)*0.5)

Fixed submission:
N,K=list(map(int,input().split()))
P=list(map(int,input().split()))
ans=[0]
ans[0]=sum(P[0:K])
for i in range(K,len(P)):
  ans.append(ans[-1]-P[i-K]+P[i])
print((max(ans)+K)*0.5)
Buggy python submission (verdict: Runtime Error):
INF=10**10
def main():
  H,N=map(int,input().split())
  AB=[]
  for i in range(N):
    AB.append(list(map(int,input().split())))
  dp=[INF]*(H+1)
  dp[0]=0
  for a,b in AB:
    for k in range(H+1):
      tmp=k-a
      if tmp<0:
        tmp=0
      need_magic=dp[tmp]+b
      if need_magic<dp[k]:
        dp[k]=need_magic
  print(dp[H+1])
main()
      

Fixed submission:
INF=10**10
def main():
  H,N=map(int,input().split())
  AB=[]
  for i in range(N):
    AB.append(list(map(int,input().split())))
  dp=[INF]*(H+1)
  dp[0]=0
  for a,b in AB:
    for k in range(H+1):
      tmp=k-a
      if tmp<0:
        tmp=0
      need_magic=dp[tmp]+b
      if need_magic<dp[k]:
        dp[k]=need_magic
  print(dp[H])
main()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(len(A)):
  flag=1
  for j in range(0,i):
    if A[i]>A[j]:
      flag=0
      break
  if flag==1:
    ans+=1
print(ans)
    
      

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
tmp=[]
a=10**9
for i in A:
  if a>i:
    a=i
  tmp.append(a)
ans=0
for i in range(len(A)):
  if A[i]<=tmp[i]:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
count=0
for i in range(len(S)):
  if S[i]=="A":
    if S[i+1]=="B" and S[i+2]=="C":
      count+=1
print(count)

Fixed submission:
N=int(input())
S=input()
count=0
for i in range(len(S)-2):
  if S[i]=="A":
    if S[i+1]=="B" and S[i+2]=="C":
      count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
imoprt numpy as np 
n = int(input())
A = list(map(int,input().split()))
a=np.array(A)
mod = 10**9+7
md = len(bin(max(a)))
ans = 0
for d in range(md):
    cnt1 =np.count_nonzero(a)        
    ans += cnt1 * (n-cnt1) * (1<<d)         
    ans %= mod                              
    
print(ans%mod)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
import numpy as np
a=np.array(a)
mod = 10**9+7
md = len(bin(max(a)))
ans = 0
for d in range(md):
    cnt1 = np.count_nonzero((a>>d)&1)# a内の全ての要素の d bit目の1の個数を数える
    ans += cnt1 * (n-cnt1) * (1<<d)          # 求めるべきは (0の個数)*(1の個数)をd bit目にそのまま収めたものを足し合わせたもの (?)
    ans %= mod                               # mod 取っておく
    
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
md = len(bin(max(a)))
ans = 0
for d in range(md):
    cnt1 = sum([1 for i in a if ((i>>d)&1)]) # a内の全ての要素の d bit目の1の個数を数える
    ans += cnt1 * (n-cnt1) * (1<<d)          # 求めるべきは (0の個数)*(1の個数)をd bit目にそのまま収めたものを足し合わせたもの (?)
    ans %= mod                               # mod 取っておく
    
print(ans%mod)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
import numpy as np
a=np.array(a)
mod = 10**9+7
md = len(bin(max(a)))
ans = 0
for d in range(md):
    cnt1 = np.count_nonzero((a>>d)&1)# a内の全ての要素の d bit目の1の個数を数える
    ans += cnt1 * (n-cnt1) * (1<<d)          # 求めるべきは (0の個数)*(1の個数)をd bit目にそのまま収めたものを足し合わせたもの (?)
    ans %= mod                               # mod 取っておく
    
print(ans%mod)