Buggy python submission (verdict: Runtime Error):
n_,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n_)]
"""
n_=2*1000
d=0 #pow(10,9)
a=1
xh=[[pow(10,9)//i,pow(10,9)] for i in range(1,1+n_)]
"""
xh.sort(key=lambda x:x[0])

#A1 ... AnのBIT(1-indexed)
n=xh[-1][0]
BIT = [0]*(n+1)

#A1 ~ Aiまでの和 O(logN)
def BIT_query(idx):
    res_sum = 0
    if idx==0:
      return 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

#Ai += x O(logN)
def BIT_update(idx,x):
  if idx==0:
    print('index 0!')
    return 
  while idx <= n:
      BIT[idx] += x
      idx += idx&(-idx)
  return

ans=0
for x,h in xh:
  fd=BIT_query(min(x+2*d,xh[-1][0]))-BIT_query(max(0,x-1))
  if h-fd<=0:
    pass
  else:
    c=(h-fd)//a
    BIT_update(min(x+2*d,xh[-1][0]),c*a)
    ans+=c
  pre_x=x
print(ans)

Fixed submission:
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=lambda x:x[0])
from collections import deque
minusd=deque()
nowd=0
ans=0
for x,h in xh:
  while minusd and minusd[0][1]<=x:
    d_,_=minusd.popleft()
    nowd-=d_
  tmp=max(0,(h-nowd+a-1)//a)
  ans+=tmp
  nowd+=tmp*a
  minusd.append([tmp*a,x+2*d+1])
  #print(ans,nowd)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
"""
n=2*100000
d=0
a=1
xh=[[pow(10,9)//i,pow(10,9)] for i in range(1,1+n)]
"""
xh.sort(key=lambda x:x[0])
import numpy as np
fd=np.zeros(2*d+1,np.int64) # fd[i]:ターゲットのモンスターから座標+i離れたところにいるモンスターに与えたダメージ
ans=0
pre_x=xh[0][0]
for x,h in xh:
  fdt=np.zeros(2*d+1,np.int64)
  if 0<x-pre_x and x-pre_x<2*d+1:
    fdt[:-x+pre_x]=fd[x-pre_x:]
  fd=fdt
  if h-fd[0]<=0:
    pass
  else:
    c=(h-fd[0]+a-1)//a
    fd+=c*a
    ans+=c
  pre_x=x
print(ans)

Fixed submission:
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=lambda x:x[0])
from collections import deque
minusd=deque()
nowd=0
ans=0
for x,h in xh:
  while minusd and minusd[0][1]<=x:
    d_,_=minusd.popleft()
    nowd-=d_
  tmp=max(0,(h-nowd+a-1)//a)
  ans+=tmp
  nowd+=tmp*a
  minusd.append([tmp*a,x+2*d+1])
  #print(ans,nowd)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=lambda x:x[0])
import numpy as np
fd=np.zeros(xh[-1][0]+1,np.int64) # fd[i]:座標iにいるモンスターに与えたダメージ
ans=0
for x,h in xh:
  if h-fd[x]<=0:
    continue
  else:
    c=(h-fd[x]+a-1)//a
    fd[x:min(xh[-1][0]+1,x+2*d+1)]+=c*a
    ans+=c
print(ans)


Fixed submission:
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=lambda x:x[0])
from collections import deque
minusd=deque()
nowd=0
ans=0
for x,h in xh:
  while minusd and minusd[0][1]<=x:
    d_,_=minusd.popleft()
    nowd-=d_
  tmp=max(0,(h-nowd+a-1)//a)
  ans+=tmp
  nowd+=tmp*a
  minusd.append([tmp*a,x+2*d+1])
  #print(ans,nowd)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=lambda x:x[0])
import numpy as np
fd=np.zeros(xh[-1][0]+1,np.int64) # fd[i]:座標iにいるモンスターに与えたダメージ
ans=0
for x,h in xh:
  if h-fd[x]<=0:
    continue
  else:
    c=(h-fd[x]+a-1)//a
    fd[x:x+2*d+1]+=c*a
    ans+=c
print(ans)

Fixed submission:
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=lambda x:x[0])
from collections import deque
minusd=deque()
nowd=0
ans=0
for x,h in xh:
  while minusd and minusd[0][1]<=x:
    d_,_=minusd.popleft()
    nowd-=d_
  tmp=max(0,(h-nowd+a-1)//a)
  ans+=tmp
  nowd+=tmp*a
  minusd.append([tmp*a,x+2*d+1])
  #print(ans,nowd)
print(ans)