Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a = input().split()
A = int(a[0])
B = int(a[1])
C = int(a[2])
youki1 = B
youki2 = C
youki21 = A-B
youki2 = youki2 - youki21
print(youki2)a = input().split()
A = int(a[0])
B = int(a[1])
C = int(a[2])
print(C-(A-B))

Fixed submission:
a = input().split()
A = int(a[0])
B = int(a[1])
C = int(a[2])
if C-(A-B) >= 0:
    print(C-(A-B))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N = input()
import math
count = 0
for i in range(1,N+1):
    if int(math.log10(i)) %2 ==1:
        count+= 1
print(count)

Fixed submission:
N = int(input())
import math
count = 0
for i in range(1,N+1):
    if int(math.log10(i)) %2 ==0:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
suuretsu_str = input().split()
suuretsu = [int(i) for i in suuretsu_str]
suuretsu_order = [i for i in range(1,N+1)]
count = 0
for i in range(N):
    if suuretsu[i] != suuretsu_order[i]
    count += 1
if count == 2:
    print("YES")
else:
    print("NO")

Fixed submission:
N = int(input())
suuretsu_str = input().split()
suuretsu = [int(i) for i in suuretsu_str]
suuretsu_order = [i for i in range(1,N+1)]
count = 0
for i in range(N):
    if suuretsu[i] != suuretsu_order[i]:
        count += 1
if count == 2 or count == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a, b = [int(i) for i in input().split("")]
if (a*b)%2 == 1:
    print("Odd")
else:
    print("Even")

Fixed submission:
S = input().split(" ")
a, b = [int(i) for i in S]
if (a*b)%2 == 1:
    print("Odd")
else:
    print("Even")
Buggy python submission (verdict: Runtime Error):
even = input()
odd = input()
if (even - odd) % 2 == 0:
    for i in range(len(even)):
        print(even[i], odd[i], sep="", end="")
else:
    for i in range(len(even)-1):
        print(even[i], odd[i], sep="", end="")
    print(even[-1])

Fixed submission:
even = input()
odd = input()
if (len(even) - len(odd)) % 2 == 0:
    for i in range(len(even)):
        print(even[i], odd[i], sep="", end="")
else:
    for i in range(len(even)-1):
        print(even[i], odd[i], sep="", end="")
    print(even[-1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

#素集合 無向グラフ
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return False

    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
    return True

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)
for i in range(m):
  x,y=map(int,input().split())
  uf.union(x,y)
print(uf.group_count()-1)

Fixed submission:
n,m=map(int,input().split())

#素集合 無向グラフ
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return False

    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
    return True

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)
for i in range(m):
  x,y=map(int,input().split())
  uf.union(x-1,y-1)
print(uf.group_count()-1)
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int, input().split()))
b = [0] + a
b = list(accumulate(b))

ans = []
for i in range(n-k):
    ans.append(b[i+k]-b[i])
index = ans.index(max(ans))

a=a[index:index+k]
total=0
for i in a:
  total+=sum(range(i+1))/i
print(total)

Fixed submission:
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int, input().split()))
b = [0] + a
b = list(accumulate(b))

ans = []
for i in range(n-k+1):
    ans.append(b[i+k]-b[i])
index = ans.index(max(ans))
a=a[index:index+k]
total=0
for i in a:
  total+=(1+i)/2
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int, input().split()))
max=0
index=0
for i in range(len(a)-k+1):
  if max<sum(a[i:i+k]):
    max= sum(a[i:i+k])
    index=i
a=a[index:index+k]
total=0
for i in a:
  total+=sum(range(i+1))/i
print(total)

Fixed submission:
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int, input().split()))
b = [0] + a
b = list(accumulate(b))

ans = []
for i in range(n-k+1):
    ans.append(b[i+k]-b[i])
index = ans.index(max(ans))
a=a[index:index+k]
total=0
for i in a:
  total+=(1+i)/2
print(total)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
point=0
l=[]
point_list=[r,s,p]
kind=['r','s','p','r']
for i in range(n):
  for j in range(len(kind)-1):
    if t[i]==kind[j]:
      if i-k>=0 and t[i]==kind[l[i-k]+1]:
        if i+k<n and t[i+k]==kind[j+1]:
          if j==2:j=-1
          l.append(j+1)
        else:
          l.append(j)
      else:
        point+=point_list[j-1]
        if j==0:j=3
        l.append(j-1)
      break
print(point)

Fixed submission:
str1,str2=input().split()
print(str2+str1)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=input().split()
a=int(a)
b=int(b)
k=int(k)
f=True
if a<0 or 10**12<a:
  f=False
if b<0 or 10**12<b:
  f=False
if k<0 or 10**12<k:
  f=False
if not f:
  a=0
  b=0
  print(a,b)
  exit(0)

for i in range(k):
  if a>=1:
    a-=1
  elif b >=1:
    b-=1
print(a,b)

Fixed submission:
a,b,k=map(int,input().split())
if k>=a:
  k-=a
  a=0
else:
  a-=k
  k=0
if k>0:
  b-=k
if b<0:
  b=0
print(a,b)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=input().split()
a=int(a)
b=int(b)
for i in range(int(k)):
  if a>=1:
    a-=1
  elif b >=1:
    b-=1
print(a,b)

Fixed submission:
a,b,k=map(int,input().split())
if k>=a:
  k-=a
  a=0
else:
  a-=k
  k=0
if k>0:
  b-=k
if b<0:
  b=0
print(a,b)
Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
l=[[] for i in range(n)]
ans=[0]*(n-1)

def dfs(v,c,p):
  k=1
  for i in range(len(l[v])):
    u=l[v][i][0]
    id=l[v][i][1]
    if(u==p):continue
    if(k==c):k+=1
    ans[id]=k
    k+=1
    dfs(u,ans[id],v)
for i in range(n-1):
  a,b=map(int,input().split())
  l[a-1].append((b-1,i))
  l[b-1].append((a-1,i))
dfs(0,-1,-1)
print(max(ans))
for i in ans:
  print(i)

Fixed submission:
import sys
sys.setrecursionlimit(500000)

n=int(input())
l=[[] for i in range(n)]
ans=[0]*(n-1)

def dfs(v,c,p):
  k=1
  for i in range(len(l[v])):
    u=l[v][i][0]
    id=l[v][i][1]
    if(u==p):continue
    if(k==c):k+=1
    ans[id]=k
    dfs(u,ans[id],v)
    k+=1
for i in range(n-1):
  a,b=map(int,input().split())
  l[a-1].append((b-1,i))
  l[b-1].append((a-1,i))
dfs(0,-1,-1)
print(max(ans))
for i in ans:
  print(i)
Buggy python submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
if (a*a*b)>=2*x:
  h=x/(b*(a/2))
  print(90-math.degrees(math.atan(h/b)))
else:
  h=(((x/a)*2)/a)-b
  b-=h
  print(90-math.degrees(math.atan(a/b)))

Fixed submission:
import math
a,b,x=map(int,input().split())
if (a*a*b)>=2*x:
  h=x/(b*(a/2))
  print(90-math.degrees(math.atan(h/b)))
else:
  h=(((x/a)*2)/a)-b
  b-=h
  if b!=0:
    print(90-math.degrees(math.atan(a/b)))
  else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
ll=list(map(int, input().split()))
ll=np.array(sorted(ll))

  
ans=0
for i in range(len(ll)-1):
  for j  in range(i+1,len(ll)):
    tmp=ll[j+1:]
    ans+=len(tmp[tmp<(ll[i]+ll[j])])
print(ans)

Fixed submission:
import bisect
n=int(input())
ll=list(map(int, input().split()))
ll=sorted(ll)

  
ans=0
for i in range(len(ll)-1):
  for j  in range(i+1,len(ll)):
    a,b=ll[i],ll[j]
    ans+=bisect.bisect_left(ll,a+b)-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ll=list(map(int, input().split()))
ll=sorted(ll)
def f(a,b):
  l=a
  r=len(ll)
  x=0
  while l+1<r:
    x=(l+r)//2
    if ll[x]<b:
      l=x
    else:
      r=x
  return len(ll[a+1:r])
  
ans=0
for i in range(len(ll)-1):
  for j  in range(i+1,len(ll)):
    ans+=f(j,ll[i]+ll[j])
print(ans)

Fixed submission:
import bisect
n=int(input())
ll=list(map(int, input().split()))
ll=sorted(ll)

  
ans=0
for i in range(len(ll)-1):
  for j  in range(i+1,len(ll)):
    a,b=ll[i],ll[j]
    ans+=bisect.bisect_left(ll,a+b)-(j+1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
a=list(map(int, input().split()))
if len(a)==1:
  print(int(a[0]/(2**m)))
  exit(0)
a=sorted(a)
for i in range(m):
  x=a.pop(-1)
  bisect.insort_right(a, int(x//2))
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for _ in range(m):
  tmp_min = heapq.heappop(a)
  heapq.heappush(a, (-1)*(-tmp_min//2))
print(-sum(a))

Buggy python submission (verdict: Runtime Error):
import bisect
n,m=map(int,input().split())
a=list(map(int, input().split()))
if len(a)==1:
  print(int(a[0]/(2**m)))
  exit(0)
a=sorted(a)
while 0<m:
  x=a.pop(-1)
  y=x//a[-1]
  if y>m:
    y=m
  x=int(x/(2**y))
  bisect.insort_right(a, x)
  m-=y
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for _ in range(m):
  tmp_min = heapq.heappop(a)
  heapq.heappush(a, (-1)*(-tmp_min//2))
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
l=[[] for i in range(m)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(-b)
tmp=[]
ans=0
for i in range(m):
  tmp+=l[i]
  heapq.heapify(tmp)
  if len(tmp)>0:
    ans+= heapq.heappop(tmp)
print(-ans)

Fixed submission:
import heapq
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
l=[[] for i in range(m)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(-b)
tmp=[]
heapq.heapify(tmp)
ans=0
for i in range(m):
  for j in l[i]:
    heapq.heappush(tmp,j)
  if len(tmp)>0:
    ans+= heapq.heappop(tmp)
print(-ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n,m=map(int,input().split())
l=[[] for i in range(m)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(-b)
tmp=[]
ans=0
for i in range(m):
  tmp+=l[i]
  heapq.heapify(tmp)
  if len(tmp)>0:
    ans+= heapq.heappop(tmp)
print(-ans)

Fixed submission:
import heapq
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
l=[[] for i in range(m)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(-b)
tmp=[]
heapq.heapify(tmp)
ans=0
for i in range(m):
  for j in l[i]:
    heapq.heappush(tmp,j)
  if len(tmp)>0:
    ans+= heapq.heappop(tmp)
print(-ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ans=[0]*len(s)
rl_list=[]
rl=s[0]
c=0
for ts in s[1:]:
  c+=1
  if rl!=ts:
    rl_list.append(c)
    rl=ts
    c=0
rl_list.append(c+1)
for i in range(0,len(rl_list),2):
  index=sum(rl_list[:i+1])
  num=rl_list[i]//2
  if rl_list[i]%2==0:
    ans[index]+=num
    ans[index-1]+=num
  else:
    ans[index-1]+=num+1
    ans[index]+=num
  num=rl_list[i+1]//2
  if rl_list[i+1]%2==0:
    ans[index-1]+=num
    ans[index]+=num
  else:
    ans[index]+=num+1
    ans[index-1]+=num
print(*ans)
    

Fixed submission:
s=input()
ans=[0]*len(s)
rl_list=[]
ind=[]
rl=s[0]
c=0
for i,ts in enumerate(s[1:]):
  c+=1
  if rl!=ts:
    rl_list.append(c)
    if ts=='L':
      ind.append(i+1)
    rl=ts
    c=0
rl_list.append(c+1)
for i in range(0,len(rl_list),2):
  index=ind[i//2]
  num=rl_list[i]//2
  if rl_list[i]%2==0:
    ans[index]+=num
    ans[index-1]+=num
  else:
    ans[index-1]+=num+1
    ans[index]+=num
  num=rl_list[i+1]//2
  if rl_list[i+1]%2==0:
    ans[index-1]+=num
    ans[index]+=num
  else:
    ans[index]+=num+1
    ans[index-1]+=num
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ans=[0]*len(s)
rl_list=[]
rl=s[0]
c=0
for ts in s[1:]:
  c+=1
  if rl!=ts:
    rl_list.append(c)
    rl=ts
    c=0
rl_list.append(c+1)
for i in range(0,len(rl_list),2):
  index=sum(rl_list[:i+1])
  num=rl_list[i]//2
  if rl_list[i]%2==0:
    ans[index]+=num
    ans[index-1]+=num
  else:
    ans[index-1]+=num+1
    ans[index]+=num
for i in range(1,len(rl_list),2):
  index=sum(rl_list[:i])
  num=rl_list[i]//2
  if rl_list[i]%2==0:
    ans[index-1]+=num
    ans[index]+=num
  else:
    ans[index]+=num+1
    ans[index-1]+=num
print(*ans)
    

Fixed submission:
s=input()
ans=[0]*len(s)
rl_list=[]
ind=[]
rl=s[0]
c=0
for i,ts in enumerate(s[1:]):
  c+=1
  if rl!=ts:
    rl_list.append(c)
    if ts=='L':
      ind.append(i+1)
    rl=ts
    c=0
rl_list.append(c+1)
for i in range(0,len(rl_list),2):
  index=ind[i//2]
  num=rl_list[i]//2
  if rl_list[i]%2==0:
    ans[index]+=num
    ans[index-1]+=num
  else:
    ans[index-1]+=num+1
    ans[index]+=num
  num=rl_list[i+1]//2
  if rl_list[i+1]%2==0:
    ans[index-1]+=num
    ans[index]+=num
  else:
    ans[index]+=num+1
    ans[index-1]+=num
print(*ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
mod=10**9+7
com=[]
def comb(n=10):
  def c(n,k): 
    return 1 if(k<=0 or n<=k) else c(n-1, k-1) + c(n-1, k)
  for i in range(n):
      com.append([c(i,j) for j in range(i+1)])
def nCr(n,r):
    return com[n][r]
comb()
def f(x,y):
  return nCr(x-1,y-1)
r=n-k+2
for i in range(1,k+1):
  bule=f(k,i)
  red=f(r,i+1)
  print((bule*red)%mod)

Fixed submission:
n,k=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
def f(x,y):
  return nCr_mod(x-1,y-1)
r=n-k+2
for i in range(1,k+1):
  bule=f(k,i)
  red=f(r,i+1)
  print((bule*red)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
def f2(x,y):
  return nCr_mod(x+y-1,y-1)
def f(x,y):
  return f2(x-y,y)
r=n-k
for i in range(1,k+1):
  bule=f(k,i)
  red=f(r,i-1)
  red+=(f(r,i)*2)
  red+=f(r,i+1)
  if i==1:
    print((bule*red)%mod-1)
  else:
    print((bule*red)%mod)

Fixed submission:
n,k=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
def f(x,y):
  return nCr_mod(x-1,y-1)
r=n-k+2
for i in range(1,k+1):
  bule=f(k,i)
  red=f(r,i+1)
  print((bule*red)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

MAX = 1000000000000000000
ans = 1

for i in range(n) :
    ans *= a[i]

if (ans > MAX) :
    print(-1)
else :
    print(ans)


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

MAX = 1000000000000000000
ans = 1

for i in range(n) :
    if (a[i] == 0) :
        print(0)
        exit()

for i in range(n) :
    ans *= a[i]
    if (ans > MAX) :
        print(-1)
        exit()

if (ans > MAX) :
    print(-1)
else :
    print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(lambda x :-int(x), input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

p = p[:x]
q = q[:y]

pq = p+q
pq.sort(reverse=True)

heapq.heapify(r)
ans = 0

for i in range(x+y) :
    print(i, pq[i], -r[0])
    if len(r) != 0 :
        if  pq[i] < -r[0] :
            ans += -heapq.heappop(r)
        else :
            ans += pq[i]

print(ans)


Fixed submission:
import heapq

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
pq = p[:x]+q[:y]
heapq.heapify(pq)

for e in r :
    heapq.heappushpop(pq, e)

print(sum(pq))
Buggy python submission (verdict: Time Limit Exceeded):
import math

def combinations_count(n, r):
    if n < 2 :
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
a = input().split()

dic = {}
for i in range(len(a)) :
    if a[i] in dic :
        dic[a[i]] = dic[a[i]] + 1
    else :
        dic[a[i]] = 1

#print(dic)
dicSum = {}
total = 0

for key in dic:
    dicSum[key] = combinations_count(dic[key], 2)
    total += dicSum[key]

#print(dicSum, total)

for i in range(n) :
    #print(total, dicSum[a[i]], combinations_count(dic[a[i]]-1, 2))
    print(total - dicSum[a[i]] + combinations_count(dic[a[i]]-1, 2))


Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    if n < 2 :
        return 0
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

import math

'''
def combinations_count(n, r):
    if n < 2 :
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
'''

n = int(input())
a = input().split()

dic = {}
for i in range(len(a)) :
    if a[i] in dic :
        dic[a[i]] = dic[a[i]] + 1
    else :
        dic[a[i]] = 1

#print(dic)
dicSum = {}
total = 0

for key in dic:
    dicSum[key] = cmb(dic[key], 2)
    total += dicSum[key]

#print(dicSum, total)

for i in range(n) :
    #print(total, dicSum[a[i]], combinations_count(dic[a[i]]-1, 2))
    print(total - dicSum[a[i]] + cmb(dic[a[i]]-1, 2))
Buggy python submission (verdict: Runtime Error):
INF = 100100100

h, n = map(int, input().split())
ab = []
maxA = -1
for i in range(n) :
    a, b = map(int, input().split())
    ab.append([a, b])
    maxA = max(maxA, a)

#dp = [[INF for i in range(h+1)] for j in range(n+1)]
dp = [INF for i in range(h+maxA+1)]
dp[0] = 0
for i in range(n) :
    for j in range(h+1) :
        dp[j+ab[i][0]] = min(dp[j+ab[i][0]], dp[j]+ab[i][1])

print(min(dp[h:]))


'''
for i in range(n) :
    for j in range(h+1) :
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][min(j+ab[i][0], h)] = min(dp[i+1][min(j+ab[i][0], h)], dp[i+1][j]+ab[i][1])
'''
#for i in range(n+1) :
#    print(dp[i])


Fixed submission:
h, a = map(int, input().split())
print(-(-h//a))
Buggy python submission (verdict: Runtime Error):
import queue

dx = [0, 0, -1, 1]
dy = [1, -1, 0, 0]

h, w = map(int, input().split())
s = []
for i in range(h) :
    s.append(input())

ans = 0

for i in range(h) :
    for j in range(w) :
        #print(i,j)
        if s[i][j] == '#' :
            continue
        dist = [[-1 for i in range(w)] for j in range(h)]
        q = queue.Queue()
        q.put([i,j])
        dist[i][j] = 0
        cnt = 0
        while not q.empty() :
            xy = q.get()
            for k in range(4) :
                y = xy[0] + dx[k]
                x = xy[1] + dy[k]
                if y < 0 or y >= h or x < 0 or x >= w :
                    continue
                if s[y][x] == '#' :
                    continue
                if dist[y][x] != -1 :
                    continue
                q.put([x, y])
                dist[y][x] = dist[xy[0]][xy[1]] + 1
        for k in range(h) :
            for l in range(w) :
                ans = max(ans, dist[k][l])
        #print(dist)


print(ans)


Fixed submission:
import queue

dx = [0, 0, -1, 1]
dy = [1, -1, 0, 0]

h, w = map(int, input().split())
s = []
for i in range(h) :
    s.append(input())

ans = 0

for i in range(h) :
    for j in range(w) :
        if s[i][j] == '#' :
            continue
        dist = [[-1 for i in range(w)] for j in range(h)]
        q = queue.Queue()
        q.put([j,i])
        dist[i][j] = 0
        cnt = 0
        while not q.empty() :
            xy = q.get()
            for k in range(4) :
                x = xy[0] + dx[k]
                y = xy[1] + dy[k]
                if y < 0 or y >= h or x < 0 or x >= w :
                    continue
                if s[y][x] == '#' :
                    continue
                if dist[y][x] != -1 :
                    continue
                q.put([x, y])
                dist[y][x] = dist[xy[1]][xy[0]] + 1
        for k in range(h) :
            for l in range(w) :
                ans = max(ans, dist[k][l])


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
AB = []
for i in range(N) :
    AB.append(list(map(int, input().split())))

AB = sorted(AB, key=lambda x:(x[0],x[1]))

ans = 0
#print(AB)
for i in range(1, M + 1) :
    maxIncome = 0
    anker = -1
    for j in range(len(AB)) :
        #print(AB[j][0])
        if AB[j][0] <= i :
            if AB[j][1] > maxIncome :
                maxIncome = AB[j][1]
                anker = j
                #print('A', j, maxIncome)
                continue
        else :
            break
    ans += maxIncome
    if len(AB) == 0 :
        break
    if anker != -1:
        AB.pop(anker)

print(ans)

Fixed submission:
from heapq import heappush, heappop

N, M = map(int, input().split())
AB = [[] for _ in range(M)]

for i in range(N) :
    A, B = map(int, input().split())
    if A <= M :
        AB[A-1].append(B)

#print(AB)
queue = []
ans = 0
for i in range(M) :
    for j in range(len(AB[i])) :
        heappush(queue, -AB[i][j])

    if len(queue) != 0 :
        ans += -heappop(queue)

print(ans)


'''
ans = 0
#print(AB)
for i in range(1, M + 1) :
    maxIncome = 0
    anker = -1
    for k in ABkeys :
        #print(AB[j][0])
        if k <= i :
            if heappop(AB[k]) > maxIncome :
                maxIncome = AB[j][0]
                anker = k
                #print('A', j, maxIncome)
                continue
        else :
            break
    ans += maxIncome
    if len(AB) == 0 :
        break
    if anker != -1:
        AB[anker].pop(0)
        if len(AB[anker]) == 0 :
            AB.remove


print(ans)
'''
'''
N, M = map(int, input().split())
AB = []
for i in range(N) :
    AB.append(list(map(int, input().split())))

AB = sorted(AB, key=lambda x:(x[0],x[1]))

ans = 0
#print(AB)
for i in range(1, M + 1) :
    maxIncome = 0
    anker = -1
    for j in range(len(AB)) :
        #print(AB[j][0])
        if AB[j][0] <= i :
            if AB[j][1] > maxIncome :
                maxIncome = AB[j][1]
                anker = j
                #print('A', j, maxIncome)
                continue
        else :
            break
    ans += maxIncome
    if len(AB) == 0 :
        break
    if anker != -1:
        AB.pop(anker)

print(ans)
'''