AtCoder Beginner Contest 153 - Silver Fox vs Monster

Silver Fox is fighting with N monsters.
The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.
Silver Fox can use bombs to attack the monsters.
Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A.
There is no way other than bombs to decrease the monster's health.
Silver Fox wins when all the monsters' healths become 0 or below.
Find the minimum number of bombs needed to win.

-----Constraints-----
 - 1 \leq N \leq 2 \times 10^5
 - 0 \leq D \leq 10^9
 - 1 \leq A \leq 10^9
 - 0 \leq X_i \leq 10^9
 - 1 \leq H_i \leq 10^9
 - X_i are distinct.
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N D A
X_1 H_1
:
X_N H_N

-----Output-----
Print the minimum number of bombs needed to win.

-----Sample Input-----
3 3 2
1 2
5 4
9 2

-----Sample Output-----
2

First, let us use a bomb at the coordinate 4 to decrease the first and second monsters' health by 2.
Then, use a bomb at the coordinate 6 to decrease the second and third monsters' health by 2.
Now, all the monsters' healths are 0.
We cannot make all the monsters' health drop to 0 or below with just one bomb.

Source: atcoder | Difficulty: MEDIUM


Solutions:
(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)


f = lambda : map(int, input().split())
(n, d, a) = f()
lt = sorted((tuple(f()) for _ in range(n)))
from collections import *
q = deque()
c = s = 0
for (x, h) in lt:
	while q and q[0][0] < x:
		s += q.popleft()[1]
	h -= s
	if h > 0:
		t = -h // a
		c -= t
		s -= t * a
		q.append((x + d * 2, t * a))
print(c)


from bisect import bisect_left, bisect_right
(n, d, a) = map(int, input().split())
l = []
ans = 0
for i in range(n):
	(x, h) = map(int, input().split())
	l.append((x, -(-h // a)))
l.sort()
back = [-1]
rui = [0]
for (x, h) in l:
	i = bisect_left(back, x)
	h -= rui[-1] - rui[i - 1]
	if h <= 0:
		continue
	ans += h
	back.append(x + d * 2)
	rui.append(rui[-1] + h)
print(ans)


import bisect
(N, D, A) = map(int, input().split())
monsters = []
for i in range(N):
	(X, H) = map(int, input().split())
	monsters.append([X, H])
monsters = sorted(monsters)
id = 0
ans = 0
damage = [0 for i in range(N)]
while id < N:
	if id > 0:
		damage[id] += damage[id - 1]
	(nowX, nowH) = (monsters[id][0], monsters[id][1])
	nowH -= damage[id]
	if nowH > 0:
		damage[id] += A * ((nowH + A - 1) // A)
		right = bisect.bisect_left(monsters, [nowX + 2 * D + 1, 0])
		if right < N:
			damage[right] -= A * ((nowH + A - 1) // A)
		ans += (nowH + A - 1) // A
	id += 1
print(ans)


from collections import deque
(n, d, a) = map(int, input().split())
xh = sorted([list(map(int, input().split())) for _ in range(n)])
ans = 0
dam_sum = 0
q = deque()
for (i, (x, h)) in enumerate(xh):
	while q and q[0][0] < x:
		(ran, dam) = q.popleft()
		dam_sum -= dam
	h -= dam_sum
	if h <= 0:
		continue
	c = -(-h // a)
	ans += c
	dam_sum += c * a
	q.append((x + d * 2, c * a))
print(ans)


import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
	(n, d, a) = list(map(int, input().split()))
	XH = sorted([list(map(int, input().split())) for _ in range(n)])
	res = 0
	tt_dmg = 0
	que = deque()
	for (x, h) in XH:
		while que and que[0][1] < x:
			(dmg, rng) = que.popleft()
			tt_dmg -= dmg
		if tt_dmg < h:
			h -= tt_dmg
			cnt = (h + a - 1) // a
			res += cnt
			dmg = cnt * a
			tt_dmg += dmg
			que.append((dmg, x + d * 2))
	print(res)

def __starting_point():
	resolve()
__starting_point()


import sys
import bisect
input = sys.stdin.readline
(n, d, a) = map(int, input().split())
xh = sorted([tuple(map(int, input().split())) for _ in range(n)])
x_list = [x for (x, h) in xh]
damage = [0] * (n + 1)
ans = 0
for i in range(n):
	(x, h) = xh[i]
	h -= damage[i]
	if h <= 0:
		damage[i + 1] += damage[i]
		continue
	cnt = -(-h // a)
	ans += cnt
	damage[i] += cnt * a
	end_idx = bisect.bisect_right(x_list, x + 2 * d)
	damage[end_idx] -= cnt * a
	damage[i + 1] += damage[i]
print(ans)


(n, d, a) = map(int, input().split())
attack = [0 for _ in range(n)]
event = []
for i in range(n):
	(x, h) = map(int, input().split())
	h = (h - 1) // a + 1
	event.append([x - d, 0, h, i])
	event.append([x + d, 1, h, i])
event.sort()
ans = 0
now = 0
for j in range(2 * n):
	(x, m, h, i) = event[j]
	if m == 0:
		if h > now:
			attack[i] += h - now
			ans += h - now
			now = h
	else:
		now -= attack[i]
print(ans)


import bisect
import math
(N, D, A) = map(int, input().split())
tmp = [list(map(int, input().split())) for i in range(N)]
tmp.sort(key=lambda x: x[0])
monster = []
X = []
for i in range(N):
	monster.append(tmp[i][1])
	X.append(tmp[i][0])
minus = [0] * (N + 1)
ans = 0
damage = 0
for i in range(N):
	damage -= minus[i]
	monster[i] = max(0, monster[i] - damage)
	if monster[i] == 0:
		continue
	cnt = math.ceil(monster[i] / A)
	monster[i] = 0
	ans += cnt
	b = bisect.bisect_left(X, X[i] + 2 * D + 1)
	minus[b] += cnt * A
	damage += A * cnt
print(ans)


from bisect import *
(n, d, a, *t) = map(int, open(0).read().split())
c = [0] * -~n
z = sorted(zip(*[iter(t)] * 2))
s = 0
for (i, (x, h)) in enumerate(z):
	c[i] += c[i - 1]
	h -= c[i]
	t = min(-h // a, 0)
	c[i] -= t * a
	c[bisect(z, (x + d + d, 10000000000.0))] += t * a
	s -= t
print(s)


(n, d, a) = list(map(int, input().split()))
enemies = [list(map(int, input().split())) for _ in range(n)]
enemies.sort(key=lambda a: a[0])
d *= 2
total_damage = 0
import collections
q = collections.deque()
ans = 0
for i in range(n):
	x = enemies[i][0]
	hp = enemies[i][1]
	while len(q) and q[0][0] < x:
		total_damage -= q[0][1]
		q.popleft()
	hp -= total_damage
	if hp > 0:
		times = (hp + a - 1) // a
		total_damage += a * times
		ans += times
		q.append((x + d, a * times))
print(ans)


(n, d, a) = list(map(int, input().split()))
e = []
for i in range(n):
	inp = list(map(int, input().split()))
	inp[1] = (inp[1] - 1) // a + 1
	e.append(inp)
e.sort()
sd = [0 for i in range(n)]
s = 0
mx = 0
i = 0
j = 0
while True:
	while e[i][1] + s <= mx:
		i += 1
		if i >= n:
			break
		s += sd[i]
	while i < n and j < n and (e[j][0] <= e[i][0] + 2 * d):
		j += 1
	if j < n:
		sd[j] += e[i][1] + s - mx
		mx = e[i][1] + s
	else:
		if i >= n:
			break
		mx = e[i][1] + s
print(mx)


def main():
	import sys
	input = sys.stdin.readline
	l = lambda : list(map(int, input().split()))
	(n, d, a) = l()
	xh = []
	for i in range(n):
		(xi, hi) = l()
		xh.append([xi, hi])
	xh.sort()
	right_index = []
	tmp = 0
	for i in range(n):
		j = tmp
		while xh[j][0] <= xh[i][0] + 2 * d:
			j += 1
			if j == n:
				break
		j -= 1
		right_index.append(j)
		tmp = j
	ans = 0
	cnt = 0
	damage = [0] * (n + 1)
	for i in range(n):
		xh[i][1] -= (ans - cnt) * a
		damage_cnt = max(0, (xh[i][1] - 1) // a + 1)
		ans += damage_cnt
		damage[right_index[i]] += damage_cnt
		cnt += damage[i]
	print(ans)

def __starting_point():
	main()
__starting_point()


import sys, heapq
input = sys.stdin.readline
(N, D, A) = [int(_) for _ in input().split()]
XH = [[int(_) for _ in input().split()] for _ in range(N)]
He = [[2 * x, h, 0] for (x, h) in XH]
heapq.heapify(He)
now = 0
ans = 0
while He:
	(x, h, t) = heapq.heappop(He)
	if t:
		now -= h
	elif h - A * now > 0:
		diff = (h - A * now - 1) // A + 1
		now += diff
		ans += diff
		heapq.heappush(He, [x + 4 * D + 1, diff, 1])
print(ans)


(n, d, a) = map(int, input().split())
m = [tuple(map(int, input().split())) for _ in range(n)]
m.sort()
x = [s[0] for s in m]
h = [s[1] for s in m]
dh = [0] * (n + 1)
dh[0] = h[0]
for i in range(n - 1):
	dh[i + 1] = h[i + 1] - h[i]
import bisect
ans = 0
health = 0
for i in range(n):
	health += dh[i]
	if health > 0:
		count = (health + a - 1) // a
		damage = count * a
		ans += count
		health -= damage
		r = bisect.bisect_right(x, x[i] + 2 * d)
		dh[r] += damage
print(ans)


from math import ceil
from collections import deque
(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort(key=lambda x: x[0])
ans = 0
XN = [[x, ceil(h / A)] for (x, h) in XH]
cnum = 0
que = deque()
ans = 0
for (x, n) in XN:
	while que and x > que[0][0]:
		(_, num) = que.popleft()
		cnum -= num
	need = max(0, n - cnum)
	ans += need
	cnum += need
	if need:
		que.append([x + 2 * D, need])
print(ans)


from collections import deque
import math
import sys
input = sys.stdin.readline
(N, D, A) = list(map(int, input().split()))
S = [0] * N
atack = deque()
for i in range(N):
	(x, h) = list(map(int, input().split()))
	S[i] = [x, h]
S.sort()
cnt = 0
dmg = 0
for i in range(N):
	while atack:
		if atack[0][0] < S[i][0]:
			(x, d) = atack.popleft()
			dmg -= d
		else:
			break
	if S[i][1] <= dmg:
		continue
	bomb = math.ceil((S[i][1] - dmg) / A)
	atack.append([S[i][0] + 2 * D, A * bomb])
	cnt += bomb
	dmg += A * bomb
print(cnt)


(N, D, A) = map(int, input().split())
XH = sorted([list(map(int, input().split())) for i in range(N)])
(l, r) = (0, 0)
a = 0
dp = 0
dm = [0] * (N + 1)
while l < N:
	while r < N and XH[r][0] <= XH[l][0] + 2 * D:
		r += 1
	dp += dm[l]
	x = -(-max(0, XH[l][1] - dp) // A)
	a += x
	dp += x * A
	dm[r] -= x * A
	l += 1
print(a)


import math
import bisect
(n, d, a) = map(int, input().split())
L = []
kyo = []
for i in range(n):
	(x, h) = map(int, input().split())
	L.append([x, h])
	kyo.append(x)
L.sort()
kyo.sort()
ans = 0
imos = [0] * (n + 1)
cur = 0
ran = 2 * d
for i in range(n):
	if imos[cur] < L[cur][1]:
		t = int(math.ceil((L[cur][1] - imos[cur]) / a))
		ans += t
		imos[cur] += t * a
		lim = bisect.bisect_right(kyo, kyo[cur] + ran)
		imos[lim] -= t * a
	imos[i + 1] += imos[i]
	cur += 1
print(ans)


import math
import collections
(N, D, A) = map(int, input().split())
XH = [tuple(map(int, input().split())) for i in range(N)]
XH.sort()
q = collections.deque()
c = 0
ans = 0
for (x, h) in XH:
	while q:
		if q[0][0] < x:
			t = q.popleft()
			c -= t[1]
		else:
			break
	h -= c * A
	k = math.ceil(max(h, 0) / A)
	ans += k
	c += k
	if k > 0:
		q.append((x + 2 * D, k))
print(ans)


(N, D, A) = map(int, input().split())
B = [list(map(int, input().split())) for _ in range(N)]
C = sorted(B)
(d, E) = zip(*C)
import bisect
Damage = [0] * N
for i in range(N):
	e = bisect.bisect_right(d, d[i] + 2 * D)
	Damage[i] = e
dd = [0] * (N + 1)
cnt = 0
for i in range(N):
	if i != 0:
		dd[i] += dd[i - 1]
	h = E[i]
	h -= dd[i]
	if h > 0:
		bomb = -(-h // A)
		cnt += bomb
		dd[i] += A * bomb
		dd[Damage[i]] -= A * bomb
print(cnt)


from collections import deque
import math
(N, D, A) = list(map(int, input().split()))
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort(key=lambda x: x[0])
ans = 0
total_damage = 0
dq = deque()
for (x, h) in XH:
	while dq and dq[0][1] < x:
		(dmg, rng) = dq.popleft()
		total_damage -= dmg
	if total_damage < h:
		h -= total_damage
		cnt = math.ceil(h / A)
		ans += cnt
		dmg = cnt * A
		total_damage += dmg
		dq.append((dmg, x + D * 2))
print(ans)


import math
import sys
from collections import deque

def input():
	return sys.stdin.readline().strip()
sys.setrecursionlimit(20000000)
MOD = 10 ** 9 + 7
INF = float('inf')

def main():
	(N, D, A) = list(map(int, input().split()))
	monster = [list(map(int, input().split())) for _ in range(N)]
	monster.sort(key=lambda x: x[0])
	attack = []
	for i in range(N):
		attack.append(math.ceil(monster[i][1] / A))
	acc_damage = 0
	attacked = deque([])
	answer = 0
	for i in range(N):
		x = monster[i][0]
		h = attack[i]
		while attacked and x > attacked[0][0]:
			(limit, damage) = attacked.popleft()
			acc_damage -= damage
		need = max(0, h - acc_damage)
		answer += need
		acc_damage += need
		if need:
			attacked.append((x + 2 * D, need))
	print(answer)

def __starting_point():
	main()
__starting_point()


import sys
input = sys.stdin.readline
(n, d, a) = map(int, input().split())
H = [list(map(int, input().split())) for i in range(n)]
H.sort()
ans = 0
m = 0
M = []
t = 0
for i in range(n):
	while t < len(M) and M[t][1] < H[i][0]:
		m -= M[t][0]
		t += 1
	H[i][1] -= m
	if H[i][1] > 0:
		dn = -(-H[i][1] // a)
		dd = dn * a
		M.append([dd, H[i][0] + d * 2])
		ans += dn
		m += dd
print(ans)


from collections import deque
(n, d, a) = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
p.sort()
d *= 2
(ans, tot) = (0, 0)
q = deque()
for (x, h) in p:
	while q and q[0][0] < x:
		tot -= q[0][1]
		q.popleft()
	h -= tot
	if h > 0:
		num = (h + a - 1) // a
		ans += num
		damage = num * a
		tot += damage
		q.append((x + d, damage))
print(ans)


from math import ceil

def binary(N, LIST, num):
	(l, r) = (-1, N)
	while r - l > 1:
		if LIST[(l + r) // 2] > num:
			r = (l + r) // 2
		else:
			l = (l + r) // 2
	return r + 1
(n, d, a) = list(map(int, input().split()))
xh = sorted((list(map(int, input().split())) for _ in range(n)))
x = [i for (i, j) in xh]
h = [j for (i, j) in xh]
(bomb, bsum, ans) = ([0] * (n + 1), [0] * (n + 1), 0)
for i in range(n):
	j = binary(n, x, x[i] + 2 * d) - 1
	bsum[i] += bsum[i - 1] + bomb[i]
	bnum = max(ceil(h[i] / a - bsum[i]), 0)
	bomb[i] += bnum
	bomb[j] -= bnum
	bsum[i] += bnum
	ans += bnum
print(ans)


import heapq
(n, d, a) = map(int, input().split())
bom = []
for _ in range(n):
	(x, h) = map(int, input().split())
	bom.append([x, h])
bom.sort(key=lambda x: x[0])
ans = 0
tot = 0
q = []
for (x, h) in bom:
	while q:
		if q[0][0] >= x:
			break
		else:
			(_, t) = heapq.heappop(q)
			tot -= t
	r = max((h - tot - 1) // a + 1, 0)
	ans += r
	tot += r * a
	heapq.heappush(q, (x + 2 * d, r * a))
print(ans)


import math
(N, D, A) = map(int, input().split())
d = []
for _ in range(N):
	(x, h) = map(int, input().split())
	d.append((x, h))
d.sort(key=lambda x: x[0])
now_damage = 0
from collections import deque
d = deque(d)
ans = 0
d_field = deque()
while d:
	x = d.popleft()
	(place, life) = x
	if d_field:
		while d_field and d_field[0][0] < place:
			now_damage -= A * d_field[0][1]
			d_field.popleft()
	if life <= now_damage:
		pass
	elif life > now_damage:
		K = math.ceil((life - now_damage) / A)
		ans += K
		now_damage += K * A
		d_field.append((2 * D + place, K))
print(ans)


from collections import deque
(n, d, a) = list(map(int, input().split()))
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
d = 2 * d
ans = 0
total = 0
q = deque()
for i in range(n):
	(x, h) = xh[i]
	while len(q) >= 1 and x > q[0][0]:
		total -= q.popleft()[1]
	h -= total
	if h > 0:
		num = (h - 1) // a + 1
		damage = a * num
		ans += num
		total += damage
		q.append([x + d, damage])
print(ans)


from math import ceil
from collections import deque
(N, D, A) = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h / A)] for (x, h) in Monsters]
acc_damage = 0
que = deque([])
ans = 0
for (x, h) in Monsters:
	while que and x > que[0][0]:
		(limit, damage) = que.popleft()
		acc_damage -= damage
	need = max(0, h - acc_damage)
	ans += need
	acc_damage += need
	if need:
		que.append([x + 2 * D, need])
print(ans)


from heapq import heappush, heappop
(n, d, a) = list(map(int, input().split()))
actions = []
for _ in range(n):
	(x, h) = list(map(int, input().split()))
	heappush(actions, (x, 0, (h + a - 1) // a))
cnt = 0
bomb = 0
current_bomb = 0
while cnt < n:
	(a, c, b) = heappop(actions)
	if c:
		current_bomb -= b
		continue
	else:
		HP = b
		if HP <= current_bomb:
			cnt += 1
			continue
		else:
			HP -= current_bomb
			cnt += 1
			current_bomb += HP
			bomb += HP
			heappush(actions, (a + 2 * d, 1, HP))
print(bomb)


from bisect import bisect_right
(N, D, A) = map(int, input().split(' '))
line = []
line_append = line.append
for i in range(N):
	(x, h) = map(int, input().split(' '))
	line_append((x, -(-h // A)))
line.sort()
X = list(map(lambda x: x[0], line))
dmg = [0 for _ in range(N + 1)]
ans = 0
for i in range(N):
	(x, h) = line[i]
	h = max(0, h - dmg[i])
	dmg[i] += h
	dmg[bisect_right(X, x + 2 * D)] -= h
	dmg[i + 1] += dmg[i]
	ans += h
print(ans)


def main():
	import sys
	from collections import deque
	from operator import itemgetter
	b = sys.stdin.buffer
	(n, d, a) = map(int, b.readline().split())
	m = map(int, b.read().split())
	q = deque()
	(popleft, append) = (q.popleft, q.append)
	s = b = 0
	for (x, h) in sorted(zip(m, m), key=itemgetter(0)):
		while q and q[0][0] < x:
			b -= popleft()[1]
		h -= b
		t = -(-h // a)
		if t > 0:
			s += t
			t *= a
			b += t
			append((x + d + d, t))
	print(s)
main()


(N, D, A) = map(int, input().split())
P = sorted([list(map(int, input().split())) for i in range(N)])
l = r = a = d = 0
m = [0] * (N + 1)
while l < N:
	while r < N and P[r][0] <= P[l][0] + 2 * D:
		r += 1
	d += m[l]
	x = -(-max(0, P[l][1] - d) // A)
	a += x
	d += x * A
	m[r] -= x * A
	l += 1
print(a)


(n, d, a) = map(int, input().split())
XH = []
for _ in range(n):
	(x, h) = map(int, input().split())
	h = (h + a - 1) // a
	XH.append([x, h])
ans = 0
XH.sort()
p = 0
j = 0
data = []
for i in range(n):
	while XH[i][0] > XH[j][0] + 2 * d:
		p -= data[j]
		j += 1
	p_i = max(XH[i][1] - p, 0)
	data.append(p_i)
	ans += p_i
	p += p_i
print(ans)


from operator import itemgetter
from bisect import bisect_right
(n, d, a) = map(int, input().split())
monster = [tuple(map(int, input().split())) for _ in range(n)]
monster.sort(key=itemgetter(0))
xx = [xi for (xi, hi) in monster]
ans = 0
imos = [0] * (n + 1)
for (i, (xi, hi)) in enumerate(monster):
	hi -= imos[i]
	if hi > 0:
		c = (hi + a - 1) // a
		ans += c
		idx = bisect_right(xx, xi + 2 * d)
		imos[i] += c * a
		imos[idx] -= c * a
	imos[i + 1] += imos[i]
print(ans)


from bisect import *

def solve():
	ans = 0
	(N, D, A) = map(int, input().split())
	B = [list(map(int, input().split())) for _ in range(N)]
	B.sort()
	lasts = [0] * (N + 1)
	now = 0
	for (i, ((x, h), l)) in enumerate(zip(B, lasts)):
		now -= l
		atack = max(0, -(-(h - now) // A))
		ans += atack
		damage = atack * A
		now += damage
		last = x + 2 * D
		ind = bisect_right(B, [last + 1, 0])
		lasts[ind] += damage
	return ans
print(solve())


import math
(n, d, a) = map(int, input().split())
XH = []
for _ in range(n):
	(x, h) = map(int, input().split())
	h = math.ceil(h / a)
	XH.append([x, h])
XH.sort()
if n == 1:
	print(XH[0][1])
	exit()
l = 0
r = 0
ans = XH[0][1]
c = XH[0][1]
L = [c]
while l <= n - 1:
	left = XH[l][0]
	right = left + 2 * d
	if XH[r + 1][0] <= right:
		cc = max(0, XH[r + 1][1] - c)
		L.append(cc)
		c += cc
		ans += cc
		r += 1
		if r >= n - 1:
			r -= 1
			l += 1
	else:
		c -= L[l]
		l += 1
print(ans)


from math import *
(n, d, a) = map(int, input().split())
damage_diff = [0] * n
damage = 0
p = sorted((tuple(map(int, input().split())) for _ in range(n)))
j = 0
c = 0
for i in range(n):
	damage -= damage_diff[i]
	(x, h) = p[i]
	h -= damage
	if h <= 0:
		continue
	m = ceil(h / a)
	c += m
	m = m * a
	while j < n and p[j][0] - x <= 2 * d:
		j += 1
	if j < n:
		damage_diff[j] += m
	damage += m
print(c)


import bisect
import sys
input = sys.stdin.buffer.readline
(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for i in range(N)]
XH.sort()
(X, H) = [list(x) for x in zip(*XH)]
ans = 0
cum = [0] * N
dam = 0
for i in range(N):
	dam += cum[i]
	H[i] -= dam
	x = X[i]
	if H[i] <= 0:
		continue
	cnt_bom = -(-H[i] // A)
	ans += cnt_bom
	damage = cnt_bom * A
	ind = bisect.bisect_right(X, x + 2 * D)
	if i + 1 < N:
		cum[i + 1] += damage
	if ind < N:
		cum[ind] -= damage
print(ans)


import bisect
import sys
input = sys.stdin.readline
(n, d, a) = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
x.sort()
y = []
for i in range(n):
	y.append(x[i][0])
	x[i][1] = -(-x[i][1] // a)
ans = 0
z = [0] * (n + 1)
atk = 0
for i in range(n):
	atk += z[i]
	if x[i][1] - atk > 0:
		ans += x[i][1] - atk
		q = bisect.bisect_right(y, x[i][0] + 2 * d, i, n)
		z[q] -= x[i][1] - atk
		atk += x[i][1] - atk
print(ans)


(N, D, A) = list(map(int, input().split()))
monster = []
for k in range(N):
	monster.append(list(map(int, input().split())))
monster.sort(key=lambda x: x[0])
for k in range(N):
	monster[k][1] = int((monster[k][1] - 0.1) // A + 1)
ans = 0
final = monster[-1][0]
ruiseki = 0
minuslist = []
j = 0
for k in range(N):
	while j < len(minuslist):
		if monster[k][0] >= minuslist[j][0]:
			ruiseki -= minuslist[j][1]
			j += 1
		else:
			break
	if ruiseki < monster[k][1]:
		ans += monster[k][1] - ruiseki
		if monster[k][0] + 2 * D + 1 <= final:
			minuslist.append([monster[k][0] + 2 * D + 1, monster[k][1] - ruiseki])
		ruiseki = monster[k][1]
print(ans)


(n, d, a) = map(int, input().split())
d *= 2
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
x = [i for (i, j) in xh] + [10 ** 20]
h = [j for (i, j) in xh]
notimos = [0] * (n + 1)
c = 0
ans = 0
from bisect import bisect_right
for i in range(n):
	c += notimos[i]
	(xx, hh) = xh[i]
	hh = max(0, hh - c * a)
	m = 0 - -hh // a
	ans += m
	c += m
	notimos[bisect_right(x, xx + d)] -= m
print(ans)


from bisect import bisect_right
from math import ceil
(n, d, a) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
l.sort()
(x, h) = ([], [])
for i in range(n):
	x.append(l[i][0])
	h.append(l[i][1])
accum = [0] * (n + 1)
(bomb, ans) = (0, 0)
for i in range(n):
	bomb += accum[i]
	hp = h[i] - bomb * a
	if hp > 0:
		ans += ceil(hp / a)
		bomb += ceil(hp / a)
		inde = bisect_right(x, x[i] + 2 * d)
		accum[inde] -= ceil(hp / a)
print(ans)


(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort()
X = [XH[i][0] for i in range(N)]
ans = 0
res = 0
from bisect import bisect_left
cnt = [0] * (N + 1)
for i in range(N):
	(x, h) = XH[i]
	res -= cnt[i]
	h -= res
	if h <= 0:
		continue
	n = (h - 1) // A + 1
	j = bisect_left(X, x + D * 2 + 1)
	cnt[j] += n * A
	res += n * A
	ans += n
print(ans)


(N, D, A) = map(int, input().split())
XH = sorted([list(map(int, input().split())) for _ in range(N)])
bombloc = [-1]
bombdam = [0]
nbomb = 1
ibomb = 0
damage = 0
ans = 0
for (x, h) in XH:
	while ibomb < nbomb and bombloc[ibomb] + D < x:
		damage -= bombdam[ibomb]
		ibomb += 1
	h_remain = h - damage
	if h_remain <= 0:
		continue
	n = (h_remain + A - 1) // A
	bombloc.append(x + D)
	bombdam.append(n * A)
	nbomb += 1
	damage += n * A
	ans += n
print(ans)


import math
from bisect import bisect_right
(N, D, A) = map(int, input().split())
XH = []
X = []
for _ in range(N):
	(x, h) = map(int, input().split())
	XH.append((x, math.ceil(h / A)))
	X.append(x)
XH.sort()
X.sort()
T = [0] * (N + 1)
now = 0
ans = 0
for i in range(N):
	(x, h) = XH[i]
	now -= T[i]
	if now >= h:
		continue
	else:
		T[bisect_right(X, x + D * 2)] += h - now
		ans += h - now
		now = h
print(ans)


from bisect import bisect_right

def ceil(x, y):
	return (x + y - 1) // y

def main():
	(n, d, a) = list(map(int, input().split()))
	info = [list(map(int, input().split())) for _ in range(n)]
	info.sort(key=lambda x: x[0])
	x = [x[0] for x in info]
	idx = {}
	for xx in x:
		idx[xx] = bisect_right(x, xx + d * 2)
	delta = [0] * n
	ans = 0
	for i in range(n):
		if i > 0:
			delta[i] += delta[i - 1]
		info[i][1] -= delta[i]
		now = max(ceil(info[i][1], a), 0)
		delta[i] += now * a
		if idx[info[i][0]] < n:
			delta[idx[info[i][0]]] -= now * a
		ans += now
	print(ans)

def __starting_point():
	main()
__starting_point()


def main():
	import sys
	from bisect import bisect
	from operator import itemgetter
	b = sys.stdin.buffer
	(n, d, a) = map(int, b.readline().split())
	m = map(int, b.read().split())
	c = [0] * (n + 1)
	d *= 2
	z = sorted(zip(m, m), key=itemgetter(0))
	y = [x for (x, _) in z]
	s = 0
	for (i, (x, h)) in enumerate(z):
		c[i] += c[i - 1]
		h -= c[i]
		t = -h // a
		if t > 0:
			t = 0
		c[i] -= t * a
		c[bisect(y, x + d)] += t * a
		s -= t
	print(s)
main()


from collections import deque
(N, D, A) = map(int, input().split())
mons = []
for _ in range(N):
	(X, H) = map(int, input().split())
	mons.append((X, (H + A - 1) // A))
mons.sort()
ans = 0
q = deque([])
tot = 0
for (x, h) in mons:
	while q:
		(x0, h0) = next(iter(q))
		if x - 2 * D <= x0:
			break
		tot -= h0
		q.popleft()
	h = max(0, h - tot)
	ans += h
	tot += h
	q.append((x, h))
print(ans)


(N, D, A) = list(map(int, input().split()))
enemies = [list(map(int, input().split())) for _ in range(N)]
enemies.sort(key=lambda x: x[0])
ans = 0
from collections import deque
damage = deque()
dmg = 0
for (x, h) in enemies:
	if len(damage) == 0:
		bomb = -(-h // A)
		damage.append([x + 2 * D, bomb])
		dmg += bomb * A
		ans += bomb
	else:
		while len(damage) > 0:
			(d, bomb) = damage.popleft()
			if x > d:
				dmg -= bomb * A
			else:
				damage.appendleft([d, bomb])
				break
		if h > dmg:
			bomb = -(-(h - dmg) // A)
			dmg += bomb * A
			damage.append([x + 2 * D, bomb])
			ans += bomb
print(ans)


from collections import deque
(n, d, a) = map(int, input().split())
f = [list(map(int, input().split())) for i in range(n)]
queue = deque()
f.sort()
tot = 0
ans = 0
for i in range(n):
	x = f[i][0]
	h = f[i][1]
	while queue and queue[0][0] < x:
		now = queue.popleft()
		tot -= now[1]
	h -= tot
	if h > 0:
		num = (h + a - 1) // a
		ans += num
		damage = num * a
		tot += damage
		queue.append((x + 2 * d, damage))
print(ans)


import bisect

def main():
	(N, D, A) = map(int, input().split())
	m = sorted(([int(j) for j in input().split()] for i in range(N)))
	x = [m[i][0] for i in range(N)]
	es = [0] * (N + 1)
	(a, c) = (0, 0)
	for i in range(N):
		c -= es[i]
		if m[i][1] > A * c:
			t = (m[i][1] - A * c + A - 1) // A
			a += t
			c += t
			es[bisect.bisect_right(x, x[i] + 2 * D)] += t
	print(a)
main()


from collections import deque
(n, d, a) = map(int, input().split())
mon = [tuple(map(int, input().split())) for i in range(n)]
mon.sort()
p = deque(mon)
baku = deque()
cou = 0
ans = 0
while p:
	(nowx, nowh) = p.popleft()
	while baku:
		(bx, bh) = baku.popleft()
		if bx >= nowx:
			baku.appendleft((bx, bh))
			break
		elif bx < nowx:
			cou -= bh
	if nowh <= cou:
		continue
	elif nowh > cou:
		k = -((-nowh + cou) // a)
		ans += k
		cou += a * k
		baku.append((nowx + 2 * d, a * k))
print(ans)


(n, d, a) = [int(s) for s in input().strip().split()]
(X, H) = ([0] * n, [0] * n)
for i in range(n):
	(X[i], H[i]) = [int(s) for s in input().strip().split()]
result = 0
monsters = sorted(zip(X, H))
q = []
ptr = 0
delta = 0
for (x, h) in monsters:
	while ptr < len(q) and q[ptr][0] < x:
		delta += q[ptr][1]
		ptr += 1
	h += delta
	if h <= 0:
		continue
	result += (h + a - 1) // a
	delta -= (h + a - 1) // a * a
	q.append((x + 2 * d, (h + a - 1) // a * a))
print(result)


def main():
	import sys
	from collections import deque
	from operator import itemgetter
	b = sys.stdin.buffer
	(N, D, A) = map(int, b.readline().split())
	m = map(int, b.read().split())
	ans = 0
	Q = deque()
	d = 0
	for (x, h) in sorted(zip(m, m), key=itemgetter(0)):
		while Q and Q[0][0] < x:
			(_, d_) = Q.popleft()
			d += d_
		h = h + d
		if h <= 0:
			continue
		n = -(-h // A)
		d -= n * A
		ans += n
		Q.append((x + 2 * D, n * A))
	print(ans)
main()


(n, d, a) = map(int, input().split())
xh = []
for _ in range(n):
	(x, h) = map(int, input().split())
	h = (h - 1) // a + 1
	xh.append([x, h])
xh.sort()
damage = xh[0][1]
ans = damage
damage_lst = [[xh[0][0] + d * 2, damage]]
pos = 0
for (i, (x, h)) in enumerate(xh[1:], start=1):
	while x > damage_lst[pos][0]:
		damage -= damage_lst[pos][1]
		pos += 1
		if pos == i:
			break
	damage_tmp = max(h - damage, 0)
	ans += damage_tmp
	damage += damage_tmp
	damage_lst.append([x + d * 2, damage_tmp])
print(ans)


import heapq
from math import ceil
(n, d, a) = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
res = 0
b = []
heapq.heapify(b)
r = 0
for i in range(n):
	(x, h) = xh[i]
	while len(b) > 0 and b[0][0] <= x:
		r += b[0][1]
		heapq.heappop(b)
	c = max(ceil((h - r) / a), 0)
	res += c
	r += c * a
	if c > 0:
		heapq.heappush(b, (x + 2 * d + 1, -c * a))
print(res)


from collections import deque
(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort()
que = deque([])
ans = 0
total = 0
for i in range(N):
	(x, h) = XH[i]
	if h <= 0:
		continue
	while que and XH[i][0] > que[0][0]:
		(_, tmp) = que.popleft()
		total -= tmp
	h -= total
	if h > 0:
		atk = (h + A - 1) // A
		damage = atk * A
		ans += atk
		total += damage
		que.append((x + 2 * D, damage))
print(ans)


import math
(n, d, a) = map(int, input().split())
XH = [[int(i) for i in input().split()] for _ in range(n)]
XH.sort(key=lambda x: x[0])
ans = 0
l = 0
before = 0
T = [0] * n
for (i, xh) in enumerate(XH):
	(x, h) = xh
	while XH[l][0] + 2 * d < x:
		before -= T[l]
		l += 1
	h -= before * a
	if h <= 0:
		continue
	T[i] = math.ceil(h / a)
	ans += T[i]
	before += T[i]
print(ans)


from math import ceil
(N, D, A) = map(int, input().split())
monsters = []
for i in range(N):
	(x, h) = map(int, input().split())
	monsters.append((x, h))
monsters.sort()

def problem_a(h):
	if h <= 0:
		return 0
	return ceil(h / A)
cnt_sum = 0
cnt = [0] * N
l = 0
for i in range(N):
	while monsters[l][0] + 2 * D < monsters[i][0]:
		cnt_sum -= cnt[l]
		l += 1
	already = cnt_sum * A
	cnt[i] = problem_a(monsters[i][1] - already)
	cnt_sum += cnt[i]
print(sum(cnt))


from collections import deque
import sys
input = sys.stdin.readline
(N, D, A) = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(N)]
xh = sorted(xh)
total = 0
D = 2 * D
ans = 0
q = deque()
for i in range(N):
	(x, h) = xh[i]
	while len(q) >= 1 and q[0][0] < x:
		total -= q.popleft()[1]
	h -= total
	if h > 0:
		num = (h - 1) // A + 1
		ans += num
		damage = num * A
		total += damage
		q += [[x + D, damage]]
print(ans)


(N, D, A) = map(int, input().split())
XH = sorted((tuple(map(int, input().split())) for _ in range(N)))
X = [x for (x, h) in XH]
H = [h for (x, h) in XH]
dH = [0] * (N + 1)
cnt = 0
acc = 0
cnt = 0
i = 0
j = 0
while i < N:
	while j < N and X[j] <= X[i] + 2 * D:
		j += 1
	acc -= dH[i]
	H[i] -= acc
	if H[i] > 0:
		c = (H[i] - 1) // A + 1
		acc += c * A
		dH[j] += c * A
		cnt += c
	i += 1
print(cnt)


import math
(n, d, a) = list(map(int, input().split()))
e = [[] for i in range(n)]
for i in range(n):
	(x, h) = list(map(int, input().split()))
	e[i] = [x, h]
num = 0
e.sort()
sd = [0 for i in range(n)]
l = [i for i in range(n)]
for i in range(n):
	for j in range(l[i - 1], i):
		if e[i][0] - e[j][0] <= 2 * d:
			l[i] = j
			break
for i in range(n):
	res = e[i][1] - sd[i - 1] + sd[l[i] - 1]
	if res < 0:
		sd[i] = sd[i - 1]
	else:
		k = math.ceil(res / a)
		sd[i] = sd[i - 1] + k * a
		num += k
print(num)


from collections import deque
(N, D, A) = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort()
ans = 0
cnt = 0
que = deque()
for (x, h) in XH:
	while que and que[0][0] <= x:
		cnt -= que.popleft()[1]
	h -= cnt * A
	if h <= 0:
		continue
	ness = -(-h // A)
	cnt += ness
	ans += ness
	que.append((x + 2 * D + 1, ness))
print(ans)


import math
from collections import deque
(N, D, A) = map(int, input().split())
monsters = sorted([list(map(int, input().split())) for _ in range(N)])
monsters = [[x, math.ceil(h / A)] for (x, h) in monsters]
que = deque()
cur = 0
ans = 0
for (x, h) in monsters:
	while que and x > que[0][0]:
		(_, n) = que.popleft()
		cur -= n
	need = max(0, h - cur)
	ans += need
	cur += need
	if h:
		que.append([x + 2 * D, need])
print(ans)


import sys

def input():
	return sys.stdin.readline().rstrip()
from bisect import bisect

def main():
	(n, d, a) = map(int, input().split())
	XH = [list(map(int, input().split())) for i in range(n)]
	XH.sort()
	(X, H) = zip(*XH)
	right = [0] * n
	for (i, x) in enumerate(X):
		right[i] = bisect(X, x + 2 * d)
	damage = [0] * (n + 1)
	ans = 0
	for (i, (x, h)) in enumerate(XH):
		if i != 0:
			damage[i] += damage[i - 1]
		h -= damage[i]
		if h > 0:
			cunt = -(-h // a)
			ans += cunt
			damage[i] += a * cunt
			damage[right[i]] -= a * cunt
	print(ans)

def __starting_point():
	main()
__starting_point()


import queue
import math
(n, d, a) = map(int, input().split())
xh = list((list(map(int, input().split())) for _ in range(n)))
xh.sort(key=lambda x: x[0])
d = d * 2
total = 0
q = queue.Queue()
ans = 0
for i in range(n):
	while not q.empty() and q.queue[0][0] < xh[i][0]:
		total -= q.queue[0][1]
		q.get()
	h = xh[i][1] - total
	if h > 0:
		c = math.ceil(h / a)
		ans += c
		damage = c * a
		total += damage
		q.put((xh[i][0] + d, damage))
print(ans)


(n, d, a) = map(int, input().split())
XH = [tuple(map(int, input().split())) for i in range(n)]
XH.sort()
X = [x for (x, h) in XH]
H = [h for (x, h) in XH]
X.append(10 ** 10)
H.append(0)
j = 0
S = [0] * (n + 1)
ans = 0
for i in range(n):
	H[i] = max(0, H[i] - S[i])
	c = -(-H[i] // a)
	while X[j] <= X[i] + 2 * d:
		j += 1
	S[i + 1] += S[i] + a * c
	S[j] -= a * c
	ans += c
print(ans)


from bisect import *
(n, d, a) = map(int, input().split())
monster = []
for i in range(n):
	(x, h) = map(int, input().split())
	monster.append([x, h])
monster.sort()
hp = []
x = []
damage = [0] * (n + 1)
for i in range(n):
	hp.append(monster[i][1])
	x.append(monster[i][0])
ans = 0
for i in range(n):
	bomb = max((hp[i] - damage[i] - 1) // a + 1, 0)
	ans += bomb
	damage[i] += bomb * a
	damage[bisect_right(x, x[i] + 2 * d)] -= bomb * a
	damage[i + 1] += damage[i]
print(ans)


import math
from collections import deque
(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH = sorted(XH)
total = 0
D = 2 * D
ans = 0
q = deque()
for (x, h) in XH:
	while len(q) and q[0][0] < x:
		total -= q.popleft()[1]
	h -= total
	if h > 0:
		num = math.ceil(h / A)
		ans += num
		damage = num * A
		total += damage
		q += [[x + D, damage]]
print(ans)


from bisect import bisect_left, bisect_right
(n, d, a) = list(map(int, input().split()))
x = []
xh = dict()
for _ in range(n):
	(xi, hi) = list(map(int, input().split()))
	x.append(xi)
	xh[xi] = hi
x.sort()
l = 0
ret = 0
ai = [0] * (n + 1)
anow = 0
while l < n:
	xl = x[l]
	hl = xh[xl]
	anow += ai[l]
	hl -= a * anow
	if hl > 0:
		r = bisect_right(x, xl + 2 * d)
		k = (hl + (a - 1)) // a
		ret += k
		anow += k
		ai[r] -= k
	l += 1
print(ret)


from collections import deque
from math import ceil
(n, d, a) = map(int, input().split())
M = [list(map(int, input().split())) for i in range(n)]
M = [[x, ceil(h / a)] for (x, h) in M]
M = sorted(M)
que = deque()
ans = 0
atack = 0
for (x, h) in M:
	while len(que) > 0 and que[0][0] < x:
		(tx, ta) = que.popleft()
		atack -= ta
	bomb_num = max(0, h - atack)
	atack += bomb_num
	ans += bomb_num
	if bomb_num > 0:
		que.append([x + d * 2, bomb_num])
print(ans)


import sys
input = sys.stdin.readline
import collections
(n, d, a) = map(int, input().split())
XH = []
for i in range(n):
	XH.append([int(i) for i in input().split()])
XH.sort(key=lambda x: x[0])
D = collections.deque()
(x, h) = XH[0]
t = (h - 1) // a + 1
ans = t
D.append([x, h, t])
adj = t
for i in range(1, n):
	(x, h) = XH[i]
	while D:
		(lx, lh, t) = D.popleft()
		if lx < x - 2 * d:
			adj -= t
		else:
			D.appendleft([lx, lh, t])
			break
	h = max(0, h - adj * a)
	t = (h - 1) // a + 1
	ans += t
	adj += t
	D.append([x, h, t])
print(ans)


import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
	(n, d, a) = list(map(int, input().split()))
	XH = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[0])
	res = 0
	total = 0
	end = deque([])
	for i in range(n):
		(x, h) = XH[i]
		while end and end[0][0] < x:
			r = end.popleft()
			total -= r[1]
		if total < h:
			res += (h - total + a - 1) // a
			damage = (h - total + a - 1) // a * a
			total += damage
			end.append([x + 2 * d, damage])
	print(res)

def __starting_point():
	resolve()
__starting_point()


import math
import collections
(N, D, A) = map(int, input().split())
XH = [tuple(map(int, input().split())) for i in range(N)]
XH.sort()
q = collections.deque()
c = 0
ans = 0
for (x, h) in XH:
	while q and q[0][0] < x:
		c -= q[0][1]
		q.popleft()
	h -= c * A
	if h < 0:
		h = 0
	ans += math.ceil(h / A)
	c += math.ceil(h / A)
	q.append((x + 2 * D, math.ceil(h / A)))
print(ans)


from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
	(N, D, A) = list(map(int, input().split()))
	XH = [None] * N
	X = [None] * N
	for i in range(N):
		XH[i] = tuple(map(int, input().split()))
		X[i] = XH[i][0]
	XH.sort()
	X.sort()
	ans = 0
	S = [0] * (N + 1)
	for i in range(N):
		if S[i] < XH[i][1]:
			need = (XH[i][1] - S[i] + A - 1) // A
			j = bisect_right(X, X[i] + 2 * D)
			S[i] += need * A
			S[j] -= need * A
			ans += need
		S[i + 1] += S[i]
	print(ans)

def __starting_point():
	main()
__starting_point()


from collections import deque
(n, d, a) = map(int, input().split())
ls = [list(map(int, input().split())) for i in range(n)]
ls.sort(key=lambda x: x[0])
q = deque()
ans = 0
tot = 0
for i in range(n):
	x = ls[i][0]
	h = ls[i][1]
	while q and q[0][0] < x:
		tot -= q[0][1]
		q.popleft()
	h -= tot
	if h > 0:
		num = (h + a - 1) // a
		ans += num
		tot += num * a
		q.append([x + 2 * d, num * a])
print(ans)


from bisect import bisect
from collections import defaultdict
(N, D, A) = map(int, input().split())
XH = []
for _ in range(N):
	(X, H) = map(int, input().split())
	XH.append((X, -(-H // A)))
XH.sort()
Xs = [xh[0] for xh in XH]
HP = [xh[1] for xh in XH]
XR = []
for x in Xs:
	XR.append(bisect(Xs, x + 2 * D))
cnt = 0
temp = 0
D = defaultdict(int)
for i in range(N):
	temp -= D[i]
	HP[i] -= temp
	if HP[i] > 0:
		temp += HP[i]
		cnt += HP[i]
		D[XR[i]] += HP[i]
		HP[i] -= temp
print(cnt)


from bisect import bisect_left, bisect_right
(n, d, a) = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
x = []
h = []
for (xx, hh) in xh:
	x.append(xx)
	h.append(hh)
imos = [0] * (n + 1)
mi = 0
ans = 0
for i in range(n):
	mi -= imos[i]
	h[i] = max(h[i] - mi * a, 0)
	atk = 0 - -h[i] // a
	ans += atk
	mi += atk
	point = x[i] + d * 2
	index = bisect_right(x, point)
	imos[index] += atk
print(ans)


(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort()
B = 0
Bt = [0] * N
Bx = [0] * N
l = 0
r = -1
ans = 0
for i in range(N):
	(x, h) = XH[i]
	if h <= 0:
		continue
	while l <= r:
		if Bx[l] < x:
			B -= Bt[l] * A
			l += 1
		else:
			break
	h -= B
	if h > 0:
		t = (h + A - 1) // A
		ans += t
		r += 1
		Bt[r] = t
		Bx[r] = x + 2 * D
		B += A * t
print(ans)


from bisect import bisect_right
(N, D, A) = map(int, input().split())
M = []
for i in range(N):
	(x, h) = map(int, input().split())
	M.append((x, -(-h // A)))
M.sort(key=lambda x: x[0])
X = list(map(lambda x: x[0], M))
H = list(map(lambda x: x[1], M))
dmg = [0] * (N + 1)
ans = 0
for i in range(N):
	(x, h) = M[i]
	h = max(0, h - dmg[i])
	dmg[i] += h
	dmg[bisect_right(X, x + 2 * D)] -= h
	dmg[i + 1] += dmg[i]
	ans += h
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
X = []
for _ in range(N):
	(x, h) = map(int, input().split())
	X.append((x, h))
X = sorted(X)[::-1]
Q = deque([])
ans = 0
k = 0
while X:
	if len(Q) == 0 or X[-1][0] <= Q[0][0]:
		(x, h) = X.pop()
		h = max(h - k * A, 0)
		a = (h + A - 1) // A
		ans += a
		k += a
		deque.append(Q, (x + 2 * D, a))
	else:
		(x, a) = deque.popleft(Q)
		k -= a
print(ans)


(N, D, A) = list(map(int, input().split()))
from heapq import heappop, heappush, heapify
B = []
for _ in range(N):
	(x, h) = list(map(int, input().split()))
	B.append((x, h))
heapify(B)
dic = {}
ans = 0
atk_cnt = 0
while B:
	(x, h) = heappop(B)
	if h == -1:
		atk_cnt -= dic[x - 1]
		continue
	if h <= A * atk_cnt:
		continue
	h -= A * atk_cnt
	sup = x + 2 * D
	bomb = (h - 1) // A + 1
	ans += bomb
	dic[sup] = bomb
	atk_cnt += bomb
	heappush(B, (sup + 1, -1))
print(ans)


(n, d, a) = map(int, input().split())
loans = []
bar = 0
ans = 0
xh = sorted([tuple(map(int, input().split())) for _ in range(n)])
for (x, h) in xh:
	while len(loans) > 0:
		(xx, dd) = loans[0]
		if xx < x:
			loans.pop(0)
			bar -= dd
		else:
			break
	h -= bar
	if h > 0:
		c = h // a if h % a == 0 else h // a + 1
		ans += c
		dd = c * a
		bar += dd
		loans.append((x + 2 * d, dd))
print(ans)


import bisect
import sys

def main():
	input = sys.stdin.readline
	(n, d, a) = map(int, input().split())
	fox = [None] * n
	for i in range(n):
		(x, h) = map(int, input().split())
		fox[i] = (x, h)
	fox.sort()
	x = [int(fox[i][0]) for i in range(n)]
	h = [int(fox[i][1]) for i in range(n)]
	ans = 0
	bit = [0] * n
	for i in range(n):
		if i != 0:
			bit[i] += bit[i - 1]
		sub = max([(h[i] - bit[i] - 1) // a + 1, 0])
		ans += sub
		bit[i] += sub * a
		index = bisect.bisect_right(x, x[i] + 2 * d)
		if index != n:
			bit[index] -= sub * a
	print(ans)

def __starting_point():
	main()
__starting_point()


from collections import deque
import math
(n, d, a) = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort(key=lambda x: x[0])
cnt = 0
queue = deque()
sum_bomb = 0
for i in range(n):
	while len(queue) != 0 and queue[0][0] < l[i][0]:
		sum_bomb -= queue[0][1] * a
		queue.popleft()
	l[i][1] -= sum_bomb
	if l[i][1] <= 0:
		continue
	num = math.ceil(l[i][1] / a)
	right = l[i][0] + 2 * d
	queue.append([right, num])
	cnt += num
	sum_bomb += num * a
print(cnt)


from math import ceil
from collections import deque
(n, d, a) = map(int, input().split())
monster = [list(map(int, input().split())) for i in range(n)]
monster.sort()
damage = 0
finish = deque()
ans = 0
for i in range(n):
	(x, h) = monster[i]
	while finish:
		if finish[0][0] < x:
			damage -= finish.popleft()[1]
		else:
			break
	if h <= damage:
		continue
	else:
		b = ceil((h - damage) / a)
		ans += b
		damage += b * a
		finish.append([x + 2 * d, b * a])
print(ans)


import bisect
from math import ceil
(n, d, a) = map(int, input().split())
XH = [list(map(int, input().split())) for i in range(n)]
X = [XH[i][0] for i in range(n)]
XH.sort(key=lambda y: y[0])
X.sort()
damage = [0] * (n + 1)
ans = 0
for (i, (x, h)) in enumerate(XH):
	damage[i] += damage[i - 1]
	h -= damage[i]
	if h <= 0:
		continue
	cnt = ceil(h / a)
	ans += cnt
	damage[i] += a * cnt
	br = bisect.bisect_right(X, x + d * 2)
	damage[br] -= a * cnt
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
ys = []
hs = []
for i in range(N):
	(X, H) = map(int, input().split())
	ys.append((X, -(-H // A)))
ys = sorted(ys, key=lambda x: x[0])
l = ys[0][0] + 2 * D
li = dmg = r = 0
hs2 = [0] * N
for (i, (y, h)) in enumerate(ys):
	while l < y:
		dmg -= hs2[li]
		li += 1
		l = ys[li][0] + 2 * D
	hs2[i] = max(0, h - dmg)
	dmg += hs2[i]
	r += hs2[i]
print(r)


from math import *
import sys
input = sys.stdin.readline

def main():
	(N, D, A) = list(map(int, input().split()))
	XH = sorted([list(map(int, input().split())) for i in range(N)])
	t = 0
	q = []
	ans = 0
	for (X, H) in XH:
		while q and q[0][0] < X - D:
			(x, c) = q.pop(0)
			t -= c
		H -= A * t
		if H <= 0:
			continue
		c = ceil(H / A)
		ans += c
		q.append((X + D, c))
		t += c
	print(ans)
main()


from math import *
from collections import *
(N, D, A) = list(map(int, input().split()))
ans = 0
t = 0
q = deque()
XH = sorted([list(map(int, input().split())) for i in range(N)])
for (x, h) in XH:
	if q:
		while q and q[0][0] < x - D:
			(_, c) = q.popleft()
			t -= c
	h = h - t * A
	if h <= 0:
		continue
	x += D
	c = ceil(h / A)
	t += c
	ans += c
	q.append((x, c))
print(ans)


(N, D, A) = map(int, input().split())
XH = []
X = []
for i in range(N):
	(x, h) = map(int, input().split())
	XH.append([x, h, 0])
	X.append(x)
XH.sort(key=lambda a: a[0])
XH.append([float('inf'), 0, 0])
X.sort()
X.append(float('inf'))
import bisect
ans = 0
for i in range(N):
	(x, h, k) = XH[i]
	dk = max(-(-(h - k * A) // A), 0)
	ans += dk
	XH[i][2] += dk
	j = bisect.bisect_right(X, x + 2 * D)
	XH[j][2] -= dk
	XH[i + 1][2] += XH[i][2]
print(ans)


from math import ceil
from collections import deque
(n, d, a) = map(int, input().split())
m = sorted([list(map(int, input().split())) for _ in range(n)])
m = [[x, ceil(h / a)] for (x, h) in m]
acc_damage = 0
que = deque()
ans = 0
for (x, h) in m:
	while que and x > que[0][0]:
		(limit, damage) = que.popleft()
		acc_damage -= damage
	need = max(0, h - acc_damage)
	ans += need
	acc_damage += need
	if need:
		que.append([x + 2 * d, need])
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort()
q = deque()
t = 0
result = 0
for (x, h) in XH:
	while q:
		if x <= q[0][0]:
			break
		t -= q[0][1]
		q.popleft()
	h -= t
	if h <= 0:
		continue
	c = (h + A - 1) // A
	result += c
	t += c * A
	q.append((x + 2 * D, c * A))
print(result)


from bisect import bisect_right
(N, D, A) = map(int, input().split())
(X, H) = ([None] * N, {})
for i in range(N):
	(X[i], H[X[i]]) = map(int, input().split())
X.sort()
f = [0] * N
ans = i = 0
while i < N:
	if i > 0:
		f[i] += f[i - 1]
	if f[i] * A < H[X[i]]:
		k = -((f[i] * A - H[X[i]]) // A)
		f[i] += k
		ans += k
		j = bisect_right(X, X[i] + (D << 1))
		if j < N:
			f[j] -= k
	i += 1
print(ans)


import bisect
import math
(N, D, A) = map(int, input().split())
cusum = [0] * (N + 1)
X = []
XH = []
for i in range(N):
	(xi, hi) = map(int, input().split())
	X += [xi]
	XH += [(xi, hi)]
X = sorted(X)
XH = sorted(XH)
cusumD = 0
ans = 0
for (i, (xi, hi)) in enumerate(XH):
	cusumD -= cusum[i]
	hi = max(0, hi - cusumD)
	r = bisect.bisect_right(X, xi + 2 * D)
	b = int(math.ceil(hi / A))
	d = b * A
	ans += b
	cusumD += d
	cusum[r] += d
print(ans)


import bisect
(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort()
(X, H) = zip(*XH)
K = [-(-h // A) for h in H]
L = [0] * (N + 2)
ans = 0
for i in range(N):
	L[i + 1] += L[i]
	s = max(K[i] - L[i + 1], 0)
	ans += s
	L[i + 1] += s
	L[bisect.bisect_right(X, X[i] + 2 * D) + 1] -= s
print(ans)


import math
(N, D, A) = map(int, input().split())
XH = sorted((tuple(map(int, input().split())) for _ in range(N)))
Q = []
qIdx = 0
s = 0
t = 0
for (x, h) in XH:
	while qIdx < len(Q) and Q[qIdx][0] < x:
		s -= Q[qIdx][1]
		qIdx += 1
	if s < h:
		q = int(math.ceil((h - s) / A))
		Q.append((x + 2 * D, q * A))
		s += q * A
		t += q
print(t)


import bisect

def main():
	(N, D, A) = list(map(int, input().split()))
	monsters = [list(map(int, input().split())) for _ in range(N)]
	monsters.sort()
	X = [m[0] for m in monsters]
	ans = 0
	damages = [0] * (N + 1)
	for (n, monster) in enumerate(monsters):
		(x, h) = monster
		h = max(0, h - damages[n])
		to_n = bisect.bisect_right(X, x + 2 * D)
		cnt = (h + A - 1) // A
		ans += cnt
		damages[n] += A * cnt
		damages[to_n] -= A * cnt
		damages[n + 1] += damages[n]
	print(ans)

def __starting_point():
	main()
__starting_point()


(N, D, A) = map(int, input().split())
XH = []
for _ in range(N):
	(x, h) = map(int, input().split())
	XH.append([x, h])
XH = sorted(XH, key=lambda x: x[0])
X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]
from math import ceil
from bisect import bisect_right
imos = [0] * (N + 1)
hit = 0
ans = 0
for i in range(N):
	hit += imos[i]
	restH = H[i] - hit * A
	if restH > 0:
		ans += ceil(restH / A)
		hit += ceil(restH / A)
		ind = bisect_right(X, X[i] + 2 * D)
		imos[ind] -= ceil(restH / A)
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
XH = []
for _ in range(N):
	(x, h) = map(int, input().split())
	XH.append((x, h))
XH.sort(key=lambda x: x[0])
D = 2 * D
tot = 0
q = deque()
ans = 0
for i in range(N):
	(x, h) = XH[i]
	while 0 < len(q) and q[0][0] < x:
		tot -= q[0][1]
		q.popleft()
	h -= tot
	if h > 0:
		num = (h + A - 1) // A
		ans += num
		damage = num * A
		tot += damage
		q.append((x + D, damage))
print(ans)


import sys
input = sys.stdin.readline
(n, d, a) = list(map(int, input().split()))
fox = [list(map(int, input().split())) for _ in range(n)]
fox.sort()
sub = [0] * (n + 1)

def bisect(x):
	(l, r) = (0, n)
	while r - l > 1:
		k = (r + l) // 2
		if fox[k][0] <= x:
			l = k
		else:
			r = k
	if fox[l][0] <= x:
		return l
	return r

def main():
	ans = 0
	for i in range(n):
		if i != 0:
			sub[i] += sub[i - 1]
		if fox[i][1] - a * sub[i] <= 0:
			continue
		count = (fox[i][1] - sub[i] * a - 1) // a + 1
		ans += count
		sub[i] += count
		sub[bisect(fox[i][0] + 2 * d) + 1] -= count
	print(ans)

def __starting_point():
	main()
__starting_point()


(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort()
q = []
t = 0
result = 0
for (x, h) in XH:
	while True:
		if len(q) == 0:
			break
		if x <= q[0][0]:
			break
		t -= q[0][1]
		q.pop(0)
	h -= t
	if h < 0:
		continue
	c = (h + A - 1) // A
	result += c
	t += c * A
	q.append((x + 2 * D, c * A))
print(result)


import bisect
(n, d, a) = map(int, input().split())
fox = [None] * n
for i in range(n):
	(x, h) = map(int, input().split())
	fox[i] = (x, h)
fox.sort()
x = [int(fox[i][0]) for i in range(n)]
h = [int(fox[i][1]) for i in range(n)]
ans = 0
bit = [0] * n
for i in range(n):
	if i != 0:
		bit[i] += bit[i - 1]
	if bit[i] >= h[i]:
		continue
	sub = (h[i] - bit[i] - 1) // a + 1
	ans += sub
	bit[i] += sub * a
	index = bisect.bisect_right(x, x[i] + 2 * d)
	if index == n:
		continue
	bit[index] -= sub * a
print(ans)


import sys
(n, d, a) = map(int, input().split())
xh = []
xx = []
for i in range(n):
	(x, h) = map(int, input().split())
	xx.append(x)
	xh.append((x, h // a + (h % a > 0)))
xh.sort()
xx.sort()
dp = [0] * n
import bisect
buf = 0
count = 0
if d == 0:
	for i in range(n):
		count += xh[i][1]
	print(count)
	sys.exit()
for i in range(n):
	buf += dp[i]
	y = max(xh[i][1] - buf, 0)
	count += y
	buf += y
	idx = bisect.bisect_left(xx, xx[i] + 2 * d + 1)
	if idx >= n:
		continue
	dp[idx] -= y
print(count)


(N, D, A) = map(int, input().split())
ys = []
for i in range(N):
	(X, H) = map(int, input().split())
	ys.append((X, -(-H // A)))
ys.sort(key=lambda x: x[0])
li = dmg = r = 0
hs = [0] * N
for (i, (y, h)) in enumerate(ys):
	while ys[li][0] + 2 * D < y:
		dmg -= hs[li]
		li += 1
	hs[i] = max(0, h - dmg)
	dmg += hs[i]
	r += hs[i]
print(r)


from bisect import *
(n, d, a, *t) = map(int, open(0).read().split())
c = [0] * -~n
z = sorted(zip(*[iter(t)] * 2))
y = [x for (x, _) in z]
s = 0
for (i, (x, h)) in enumerate(z):
	c[i] += c[i - 1]
	h -= c[i]
	t = 0 - -max(0, h) // a
	c[i] += t * a
	c[bisect(y, x + d + d)] -= t * a
	s += t
print(s)


import sys
input = sys.stdin.readline
from bisect import bisect_left
(n, d, a) = map(int, input().split())
mon = [list(map(int, input().split())) for _ in range(n)]
mon.sort(key=lambda x: x[0])
ref = [x for (x, h) in mon]
rem = [0] * (n + 1)
ans = 0
cur = 0
for (i, (x, h)) in enumerate(mon):
	cur -= rem[i]
	h = max(0, h - cur)
	t = a * (0 - -h // a)
	ans += 0 - -h // a
	cur += t
	rem[bisect_left(ref, x + 2 * d + 1)] += t
print(ans)


xh = []
(n, d, a) = list(map(int, input().split()))
for _ in range(n):
	(x, h) = list(map(int, input().split()))
	xh.append([x, h])
xh.sort()
ans = 0
cnt = [0] * n
j = 0
limit = []
for i in range(n):
	while xh[j][0] - xh[i][0] <= 2 * d:
		j += 1
		if j == n:
			break
	j -= 1
	limit.append(j)
num = [0] * (n + 1)
cnt = 0
for i in range(n):
	xh[i][1] -= (ans - cnt) * a
	damage_cnt = max(0, (xh[i][1] - 1) // a + 1)
	ans += damage_cnt
	num[limit[i]] += damage_cnt
	cnt += num[i]
print(ans)


from heapq import heappush, heappop
(N, D, A, *XH) = map(int, open(0).read().split())
XH = sorted(zip(*[iter(XH)] * 2))
ans = 0
Q = []
damage = 0
for (x, h) in XH:
	while Q:
		(v, d) = Q[0]
		if v >= x:
			break
		(v, d) = heappop(Q)
		damage -= d
	h -= damage
	if h <= 0:
		continue
	n = -(-h // A)
	damage += A * n
	ans += n
	heappush(Q, (x + 2 * D, A * n))
print(ans)


import math
I = lambda : list(map(int, input().split()))
(n, d, a) = I()
l = []
for _ in range(n):
	(x, y) = I()
	l.append([x, y])
l.sort()
j = 0
limit = []
for i in range(n):
	while l[j][0] - l[i][0] <= 2 * d:
		j += 1
		if j == n:
			break
	j -= 1
	limit.append(j)
ans = 0
num = [0] * (n + 1)
cnt = 0
for i in range(n):
	l[i][1] -= (ans - cnt) * a
	damage_cnt = max(0, (l[i][1] - 1) // a + 1)
	ans += damage_cnt
	num[limit[i]] += damage_cnt
	cnt += num[i]
print(ans)


from collections import deque
(N, D, A) = list(map(int, input().split()))
pair_xh = [[-1, -1] for _ in range(N)]
for i in range(N):
	(pair_xh[i][0], pair_xh[i][1]) = list(map(int, input().split()))
pair_xh.sort(key=lambda x: x[0])
q_lim_d = deque()
total = 0
count = 0
for i in range(N):
	x = pair_xh[i][0]
	h = pair_xh[i][1]
	while len(q_lim_d) and q_lim_d[-1][0] < x:
		total -= q_lim_d[-1][1]
		q_lim_d.pop()
	h -= total
	if h > 0:
		times = (h + A - 1) // A
		count += times
		damage = A * times
		total += damage
		q_lim_d.appendleft([x + 2 * D, damage])
print(count)


(n, d, a) = list(map(int, input().split()))
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
cnt = 0
import heapq
bomb = 0
he = []
heapq.heapify(he)
dic = {}
for i in range(n):
	(x, h) = xh[i]
	if bomb == 0:
		secchi = x + d
		count = -1 * h // a * -1
		damage = count * a
		cnt += count
		dic[secchi] = damage
		bomb += damage
		heapq.heappush(he, secchi)
	else:
		while a:
			tmp = heapq.heappop(he)
			if tmp + d < x:
				bomb -= dic[tmp]
			else:
				heapq.heappush(he, tmp)
				break
			if bomb == 0:
				break
		if bomb < h:
			h -= bomb
			secchi = x + d
			count = -1 * h // a * -1
			damage = count * a
			cnt += count
			dic[secchi] = damage
			bomb += damage
			heapq.heappush(he, secchi)
print(cnt)


(n, d, a) = [int(j) for j in input().split()]
xh = [[int(j) for j in input().split()] for i in range(n)]
xh.sort()
from collections import deque
q = deque()
ans = 0
dmg = 0
for (x, h) in xh:
	while q and q[0][0] < x:
		(i, j) = q.popleft()
		dmg -= j
	r = h - dmg
	if r <= 0:
		continue
	p = -(-r // a)
	dmg += p * a
	ans += p
	q.append((x + 2 * d, p * a))
print(ans)


from collections import *
INF = 10 ** 18
(n, d, a) = map(int, input().split())
mon = []
for _ in range(n):
	mon += [list(map(int, input().split()))]
mon.sort()
ans = 0
tot = 0
q = deque()
for i in range(n):
	(x, h) = mon[i]
	while q and q[0][0] < x:
		tot -= q.popleft()[1]
	h -= tot
	if h > 0:
		b = (h + a - 1) // a
		tot += b * a
		ans += b
		q.append((x + 2 * d, b * a))
print(ans)


from bisect import bisect_right
(N, D, A) = list(map(int, input().split()))
monsters = [list(map(int, input().split())) for _ in range(N)]
monsters.sort(key=lambda x: x[0])
xlst = [x for (x, _) in monsters]
delta = [0] * (N + 1)
csum = 0
ans = 0
for i in range(N):
	(xi, hi) = monsters[i]
	csum += delta[i]
	hi -= csum
	if hi <= 0:
		continue
	cnt = (hi + A - 1) // A
	ans += cnt
	csum += A * cnt
	right = bisect_right(xlst, xi + 2 * D)
	delta[right] -= A * cnt
print(ans)


(n, d, a) = map(int, input().split())
l = [[0, 0] for _ in range(n)]
for i in range(n):
	(x, h) = map(int, input().split())
	l[i][0] = x
	l[i][1] = h
l.sort()
from collections import deque
d = 2 * d
q = deque([])
total = 0
ans = 0
for i in range(n):
	x = l[i][0]
	h = l[i][1]
	if q:
		while q[0][0] < x:
			total -= q[0][1]
			q.popleft()
			if not q:
				break
	h -= total
	if h > 0:
		num = (h + a - 1) // a
		ans += num
		damage = num * a
		total += damage
		q.append([x + d, damage])
print(ans)


def nibun_right(a, x):
	(lo, hi) = (0, len(a))
	while lo < hi:
		mid = (lo + hi) // 2
		if x < a[mid][0]:
			hi = mid
		else:
			lo = mid + 1
	return lo
(N, D, A) = map(int, input().split())
lst = [0] * N
for i in range(N):
	lst[i] = list(map(int, input().split()))
	lst[i][1] = int((lst[i][1] - 1) / A) + 1
lst.sort()
DMG = [0] * (N + 1)
ans = 0
for i in range(N):
	renji = nibun_right(lst, lst[i][0] + 2 * D)
	Z = max(lst[i][1] - DMG[i], 0)
	DMG[i] += Z
	DMG[renji] -= Z
	ans += Z
	DMG[i + 1] += DMG[i]
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH = sorted(XH)
que = deque()
cum = 0
ans = 0
for i in range(N):
	(x, h) = XH[i]
	if i == 0:
		(r, n) = (x + 2 * D, (h + A - 1) // A)
		d = n * A
		cum += d
		que.append((r, d))
		ans += n
		continue
	while que and que[0][0] < x:
		(r, d) = que.popleft()
		cum -= d
	h -= cum
	if h < 0:
		continue
	(r, n) = (x + 2 * D, (h + A - 1) // A)
	d = n * A
	cum += d
	que.append((r, d))
	ans += n
print(ans)


from collections import deque
(n, d, a) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(n)]
XH.sort()
XC = [[x, (h - 1) // a + 1] for (x, h) in XH]
q = deque([])
accum_dmg = 0
ans = 0
for (x, c) in XC:
	while q and x > q[0][0]:
		(_, dmg) = q.popleft()
		accum_dmg -= dmg
	cnt = max(0, c - accum_dmg)
	ans += cnt
	accum_dmg += cnt
	if cnt:
		q.append([x + 2 * d, cnt])
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
monsters = []
for _ in range(N):
	monsters.append(list(map(int, input().split())))
monsters.sort()
d = deque()
ans = 0
damage = 0
for (x, h) in monsters:
	while d:
		if d[0][0] >= x - D:
			break
		(_, power) = d.popleft()
		damage -= power
	h -= damage
	if h <= 0:
		continue
	attack = (h - 1) // A + 1
	ans += attack
	d.append((x + D, attack * A))
	damage += attack * A
print(ans)


import bisect
(n, d, a) = map(int, input().split())
lst = []
x = []
for i in range(n):
	(xi, hi) = map(int, input().split())
	lst.append([xi, hi, 0])
	x.append(xi)
lst.sort()
x.sort()
count = 0
cur = 0
for i in range(n):
	if lst[i][1] - cur > 0:
		num = -(-(lst[i][1] - cur) // a)
		count += num
		damage = a * num
		cur += damage
		index = bisect.bisect(x, x[i] + 2 * d)
		if index != n:
			lst[index - 1][2] += damage
	cur -= lst[i][2]
print(count)


from math import ceil
import heapq

def main():
	(n, d, a) = list(map(int, input().split()))
	q = []
	for i in range(n):
		(x, h) = list(map(int, input().split()))
		heapq.heappush(q, (x, -ceil(h / a)))
	bomb = 0
	res = 0
	while q:
		(x, h) = heapq.heappop(q)
		if h < 0:
			h *= -1
			if h > bomb:
				heapq.heappush(q, (x + 2 * d, h - bomb))
				res += h - bomb
				bomb = h
		else:
			bomb -= h
	print(res)

def __starting_point():
	main()
__starting_point()


from collections import deque
import math
(n, d, a) = map(int, input().split())
F = []
for _ in range(n):
	(x, h) = map(int, input().split())
	F.append((x, h))
F.sort()
total = 0
d *= 2
ans = 0
q = deque([])
for (x, h) in F:
	while q and q[0][0] < x:
		total -= q.popleft()[1]
	h -= total
	if h > 0:
		tmp = math.ceil(h / a)
		ans += tmp
		damage = tmp * a
		total += damage
		q.append((x + d, damage))
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
Monsters = [tuple(map(int, input().split())) for _ in range(N)]
Monsters.sort()
Attack = deque()
attack = 0
ans = 0
for (x, h) in Monsters:
	while Attack and Attack[0][0] <= x:
		(y, at) = Attack.popleft()
		attack -= at
	h -= attack
	num = max((h - 1) // A + 1, 0)
	attack += num * A
	ans += num
	Attack.append((x + 2 * D + 1, num * A))
print(ans)


import bisect
import operator
import collections

class RAQ:

	def __init__(self, size):
		self.size = size
		self.sub = [0 for i in range(size + 1)]
		self.r = 0
		self.v = 0

	@classmethod
	def from_array(cls, a):
		st = cls(len(a))
		for (i, x) in enumerate(a):
			st.add(i, i + 1, x)
		return st

	def add(self, a, b, value):
		if a > b:
			raise ValueError('a must be less than equal b.')
		self.sub[a] += value
		self.sub[b] -= value

	def get(self, key):
		if key < self.r - 1:
			self.r = 0
			self.v = 0
		for i in range(self.r, key):
			self.v += self.sub[i]
		self.r = key
		return self.v + self.sub[key]

def read():
	(N, D, A) = list(map(int, input().strip().split()))
	XH = list()
	for i in range(N):
		(x, h) = list(map(int, input().strip().split()))
		XH.append((x, h))
	return (N, D, A, XH)

def solve(N, D, A, XH):
	XH = sorted(XH)
	X = [x for (x, h) in XH]
	H = [h for (x, h) in XH]
	st = RAQ.from_array(H)
	ans = 0
	i = 0
	while i < N:
		x = XH[i][0]
		h = st.get(i)
		c = h // A + (h % A > 0)
		ans += c
		v = c * A
		lidx = bisect.bisect_left(X, x)
		ridx = bisect.bisect_left(X, x + 2 * D + 1)
		st.add(lidx, ridx, -v)
		m = -1
		i += 1
		while i < N:
			h = st.get(i)
			if h > 0:
				break
			i += 1
	return ans

def __starting_point():
	inputs = read()
	print('%s' % solve(*inputs))
__starting_point()


(N, D, A) = map(int, input().split())
data = []
for _ in range(N):
	data.append(tuple(map(int, input().split())))
data.sort()
queue = []
i = 0
j = 0
total = 0
height = 0
while i < N:
	if j >= len(queue) or data[i][0] <= queue[j][0]:
		(x, h) = data[i]
		i += 1
		if height < h:
			count = (h - height + A - 1) // A
			total += count
			height += count * A
			queue.append((x + D * 2, count * A))
	else:
		height -= queue[j][1]
		j += 1
print(total)


from collections import deque
from bisect import bisect_right
(n, d, a) = map(int, input().split())
xh = [tuple(map(int, input().split())) for _ in range(n)]
xh.sort()
(x, h) = zip(*xh)
h = list(map(lambda x: -(-x // a), h))
s = [0] * (n + 1)
ans = 0
for i in range(n):
	add = max(0, h[i] - s[i])
	j = bisect_right(x, x[i] + d * 2)
	if j < n:
		s[j] -= add
	s[i] += add
	ans += add
	s[i + 1] += s[i]
print(ans)


from collections import deque
import math
(n, d, a) = map(int, input().split())
data = []
for i in range(n):
	data.append(list(map(int, input().split())))
data.sort()
dam = 0
ans = 0
q = deque()
for i in range(n):
	(x, h) = data[i]
	while q:
		k = q.popleft()
		if k[1] >= x:
			q.appendleft(k)
			break
		else:
			dam -= k[0]
	h -= dam
	h = max(h, 0)
	count = math.ceil(h / a)
	dam += count * a
	q.append([count * a, x + 2 * d])
	ans += count
print(ans)


from collections import deque
from math import ceil
(n, d, a) = list(map(int, input().split()))
ms = [list(map(int, input().split())) for i in range(n)]
ms = sorted([(pos, ceil(hp / a)) for (pos, hp) in ms])
bombs = deque()
ans = 0
valid_bomb = 0
for (pos, hp) in ms:
	while bombs and bombs[0][0] < pos:
		(bomb_border, bomb_cnt) = bombs.popleft()
		valid_bomb -= bomb_cnt
	bomb_cnt = max(0, hp - valid_bomb)
	valid_bomb += bomb_cnt
	ans += bomb_cnt
	if bomb_cnt > 0:
		bombs.append([pos + d * 2, bomb_cnt])
print(ans)


from math import ceil
from collections import deque
(n, d, a) = map(int, input().split())
m = [list(map(int, input().split())) for _ in range(n)]
m.sort()
l = [(x, ceil(h / a)) for (x, h) in m]
ans = 0
damage = 0
que = deque([])
for (x, h) in l:
	while que and que[0][0] < x:
		(s, t) = que.popleft()
		damage -= t
	need = max(0, h - damage)
	ans += need
	damage += need
	if need:
		que.append((x + 2 * d, need))
print(ans)


import bisect
(n, d, a) = map(int, input().split())
XH = sorted([list(map(int, input().split())) for _ in range(n)])
(X, H) = zip(*XH)
K = [-(-i // a) for i in H]
L = [0] * (n + 2)
ans = 0
for i in range(n):
	L[i + 1] += L[i]
	s = max(K[i] - L[i + 1], 0)
	ans += s
	L[i + 1] += s
	L[bisect.bisect_right(X, X[i] + 2 * d) + 1] -= s
print(ans)


from math import ceil
from collections import deque
(N, D, H) = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h / H)] for (x, h) in Monsters]
ans = 0
acc = 0
deq = deque([])
for (x, h) in Monsters:
	while deq and x > deq[0][0]:
		(lim, dam) = deq.popleft()
		acc -= dam
	c = max(0, h - acc)
	ans += c
	acc += c
	if c:
		deq += [(x + 2 * D, c)]
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
ls = []
for i in range(N):
	(x, h) = map(int, input().split())
	h = h // A if h % A == 0 else h // A + 1
	ls += [(x, h)]
ls.sort(key=lambda x: x[0])
deq = deque([])
ans = 0
acc = 0
for i in range(N):
	(x, h) = ls[i]
	while deq and deq[0][0] < x:
		(y, d) = deq.popleft()
		acc -= d
	n = max(0, h - acc)
	ans += n
	acc += n
	if n:
		deq += [(x + 2 * D, n)]
print(ans)


from bisect import bisect_right
(n, d, a) = list(map(int, input().split()))
xh = sorted((list(map(int, input().split())) for _ in range(n)))
x = [0] * (n + 1)
h = [0] * (n + 1)
s = [0] * (n + 1)
for (i, (f, g)) in enumerate(xh):
	(x[i], h[i]) = (f, g)
x[n] = 10 ** 10 + 1
ans = 0
for i in range(n):
	if i > 0:
		s[i] += s[i - 1]
	h[i] -= s[i]
	if h[i] > 0:
		num = 0 - -h[i] // a
		ans += num
		s[i] += num * a
		j = bisect_right(x, x[i] + d * 2)
		s[j] -= num * a
print(ans)


(n, d, a) = map(int, input().split())
D = True
pos = []
pos1 = []
for i in range(n):
	(x, h) = map(int, input().split())
	pos.append((x, h))
pos.sort(key=lambda x: x[0])
bombs = 0
damage = 0
(y, z) = (0, 0)
while y < n:
	x0 = pos[y][0]
	try:
		x1 = pos1[z][0]
	except IndexError:
		x1 = 1e+16
	if x0 <= x1:
		health = pos[y][1]
		health -= damage
		number = max(0, (health - 1) // a + 1)
		bombs += number
		damage += number * a
		pos1.append((x0 + 2 * d, number * a))
		y += 1
	else:
		damage -= pos1[z][1]
		z += 1
print(bombs)


def resolve():
	(N, D, A) = list(map(int, input().split()))
	AB = [list(map(int, input().split())) for _ in range(N)]
	AB.sort()
	imos = [0] * (N + 1)
	ans = 0
	R = 0
	for l in range(N):
		if l:
			imos[l] += imos[l - 1]
		x = AB[l][0]
		h = AB[l][1]
		if imos[l] < h:
			R = max(R, l + 1)
			while R < N and AB[R][0] <= 2 * D + x:
				R += 1
			d = h - imos[l]
			cnt = (d + A - 1) // A
			imos[l] += cnt * A
			imos[R] -= cnt * A
			ans += cnt
	print(ans)

def __starting_point():
	resolve()
__starting_point()


from math import ceil, floor, factorial, gcd, sqrt, log2, cos, sin, tan, acos, asin, atan, degrees, radians, pi, inf
from itertools import accumulate, groupby, permutations, combinations, product, combinations_with_replacement
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import Queue, LifoQueue, PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP1():
	return map(lambda x: int(x) - 1, input().split())

def LIST():
	return list(MAP())

def LIST1():
	return list(MAP1())

def is_ok(arg):
	return h[arg][0] <= h[i][0] + d * 2

def meguru_bisect(ng, ok):
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if is_ok(mid):
			ok = mid
		else:
			ng = mid
	return ok
(n, d, a) = MAP()
h = [LIST() + [0] for i in range(n)]
h = sorted(h, key=itemgetter(0))
attack = 0
ans = 0
for i in range(n):
	bomb = ceil((h[i][1] - attack) / a)
	if bomb > 0:
		j = min(meguru_bisect(n, i), n - 1)
		h[j][2] -= bomb
		attack += bomb * a
		ans += bomb
	attack += h[i][2] * a
print(ans)


(N, D, A) = map(int, input().split())
Monster = [0] * N
for i in range(N):
	Monster[i] = list(map(int, input().split()))
Monster.sort(key=lambda x: x[0])
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from collections import deque
d = deque()
damage = 0
ans = 0
for i in range(N):
	while len(d) > 0:
		a = d.popleft()
		if a[0] == i:
			damage -= a[1]
		else:
			d.appendleft(a)
			break
	Monster[i][1] -= damage
	count = -(-max(Monster[i][1], 0) // A)
	ans += count
	right = Monster[i][0] + 2 * D
	ind = bisect(Monster, [right, 10 ** 9 + 1])
	damage += A * count
	d.append([ind, A * count])
print(ans)


import math
from bisect import bisect_right
(n, d, a) = map(int, input().split())
x_list = []
max_x = 0
for _ in range(n):
	(x, h) = map(int, input().split())
	x -= 1
	x_list.append([x, h])
	max_x = max(max_x, x)
x_list.sort()
xx = [x[0] for x in x_list]
hh = [x[1] for x in x_list]
ans = 0
accum = [0 for _ in range(n)]
for (index, [x, h]) in enumerate(x_list):
	if index != 0:
		accum[index] += accum[index - 1]
	cnt = max(math.ceil((hh[index] - accum[index]) / a), 0)
	ans += cnt
	index_right = bisect_right(xx, xx[index] + 2 * d)
	accum[index] += cnt * a
	if index_right < n:
		accum[index_right] -= cnt * a
print(ans)


import heapq as hq
(N, D, A) = map(int, input().split())
m = []
for i in range(N):
	hq.heappush(m, tuple(map(int, input().split())))
ans = 0
dmg = 0
d = []
while m:
	(X, H) = m[0]
	if not d or X <= d[0][0]:
		if dmg < H:
			k = (H - dmg + A - 1) // A
			ans += k
			dmg += k * A
			hq.heappush(d, (X + 2 * D, -k * A))
		hq.heappop(m)
	else:
		dmg += d[0][1]
		hq.heappop(d)
print(ans)


import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def input():
	return sys.stdin.readline().strip()

def main():
	(N, D, A) = list(map(int, input().split()))
	monster = {}
	X = []
	for _ in range(N):
		(x, h) = list(map(int, input().split()))
		monster[x] = h
		X.append(x)
	X.sort()
	q = deque([])
	acc_damage = 0
	ans = 0
	for i in range(N):
		x = X[i]
		h = monster[x]
		while q and q[0][0] < x:
			(p, damage) = q.popleft()
			acc_damage -= damage
		if h - acc_damage <= 0:
			continue
		cnt = (h - acc_damage + A - 1) // A
		ans += cnt
		acc_damage += cnt * A
		q.append((x + 2 * D, cnt * A))
	print(ans)

def __starting_point():
	main()
__starting_point()


from collections import deque
(n, d, a) = map(int, input().split())
xh = [list(map(int, input().split())) for i in range(n)]
xh.sort()
que = deque()
ans = 0
atk = 0
for (x, h) in xh:
	while que and que[0][0] <= x:
		atk -= que.popleft()[1]
	h -= a * atk
	if h <= 0:
		continue
	count = -(-h // a)
	ans += count
	atk += count
	que.append((x + 2 * d + 1, count))
print(ans)


from math import ceil
from collections import deque
(N, D, A) = map(int, input().split())
monsters = sorted([list(map(int, input().split())) for _ in range(N)])
q = deque([])
s = 0
ans = 0
for i in range(N):
	while len(q) > 0 and q[0][0] < monsters[i][0]:
		s -= q[0][1]
		q.popleft()
	h = monsters[i][1] - s * A
	if h > 0:
		num_bombs = ceil(h / A)
		q.append((monsters[i][0] + 2 * D, num_bombs))
		s += num_bombs
		ans += num_bombs
print(ans)


import sys
import math
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().strip()
NI = lambda : int(input())
NMI = lambda : map(int, input().split())
NLI = lambda : list(NMI())
SI = lambda : input()

def make_grid(h, w, num):
	return [[int(num)] * w for _ in range(h)]

def main():
	(N, D, A) = NMI()
	M = [NLI() for _ in range(N)]
	M.sort()
	maxj = [0] * N
	j = 0
	for i in range(N):
		while j < N - 1:
			if M[j + 1][0] <= M[i][0] + D * 2:
				j += 1
			else:
				break
		maxj[i] = j
	S = [0] * (N + 1)
	ans = 0
	for i in range(N):
		x = M[i][0]
		hp = M[i][1] - S[i]
		need = max((hp - 1) // A + 1, 0)
		ans += need
		S[i] += need * A
		S[maxj[i] + 1] -= need * A
		S[i + 1] += S[i]
	print(ans)

def __starting_point():
	main()
__starting_point()


from bisect import bisect_right
(n, d, a) = list(map(int, input().split()))
lxh = [tuple(map(int, input().split())) for _ in range(n)]
lxh.sort()
(lx, lh) = ([], [])
for (x, h) in lxh:
	lx.append(x)
	lh.append(h)
n_bomb = 0
total_damage = 0
subtract = [0 for _ in range(n + 1)]
for i in range(n):
	total_damage -= subtract[i]
	x = lx[i]
	h = lh[i] - total_damage
	if h > 0:
		n_bomb += -(-h // a)
		damage = -(-h // a) * a
		total_damage += damage
		i_sub = bisect_right(lx, x + 2 * d)
		subtract[i_sub] += damage
print(n_bomb)


(n, d, a) = [int(i) for i in input().split()]
xh = [[int(i) for i in input().split()] for _ in range(n)]
xh.sort()
da = [0] * n
r = [0] * n
ru = 0
ans = 0
j = 0
for i in range(n):
	da[i] += ru
	if xh[i][1] > da[i]:
		up = (xh[i][1] - da[i]) // a
		if (xh[i][1] - da[i]) % a != 0:
			up += 1
		ans += up
		up *= a
		da[i] += up
		ru += up
		while j != n - 1 and xh[j + 1][0] <= xh[i][0] + 2 * d:
			j += 1
		r[j] += up
	ru -= r[i]
print(ans)


(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for i in range(N)]
XH.sort()
from math import ceil
times = ceil(XH[0][1] / A)
ans = times
damege = [times * A]
coor = [XH[0][0] + 2 * D]
start = 0
end = 1
dam = sum(damege[start:end])
for i in range(1, N):
	st = start
	while start < end and coor[start] < XH[i][0]:
		start += 1
	dam -= sum(damege[st:start])
	H = XH[i][1] - dam
	if H > 0:
		times = ceil(H / A)
		ans += times
		damege.append(times * A)
		dam += times * A
		coor.append(XH[i][0] + 2 * D)
		end += 1
print(ans)


from collections import deque

def inpl():
	return list(map(int, input().split()))
(N, D, A) = inpl()
XH = [inpl() for i in range(N)]
XH.sort()
bomb = [(h + A - 1) // A for (x, h) in XH]
ans = 0
dq = deque()
s_i = 0
sum_q = 0
for i in range(N):
	while dq and dq[0][1] < XH[i][0]:
		(b, _) = dq.popleft()
		sum_q -= b
	bomb[i] -= sum_q
	if bomb[i] <= 0:
		pass
	else:
		ans += bomb[i]
		sum_q += bomb[i]
		dq.append([bomb[i], XH[i][0] + 2 * D])
print(ans)


import sys
import math
import collections
import bisect
import itertools
import fractions
import copy
import decimal
import queue
sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
ni = lambda : int(sys.stdin.readline())
ns = lambda : list(map(int, sys.stdin.readline().split()))
na = lambda : list(map(int, sys.stdin.readline().split()))

def main():
	(n, d, a) = ns()
	x = []
	for _ in range(n):
		(xi, hi) = ns()
		x.append([xi, hi])
	x.sort()
	x.append([INF, INF])
	perm = [0 for _ in range(n + 1)]
	idx = [xi for (xi, hi) in x]
	ans = 0
	cnt = 0
	for i in range(n):
		cnt -= perm[i]
		if x[i][1] - cnt * a > 0:
			tmp = (x[i][1] - cnt * a + a - 1) // a
		else:
			tmp = 0
		ans += tmp
		cnt += tmp
		if cnt > 0:
			tmp_idx = bisect.bisect_right(idx, x[i][0] + 2 * d)
			perm[tmp_idx] += tmp
	print(ans)

def __starting_point():
	main()
__starting_point()


from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline
(N, D, A) = map(int, input().split())
monsters = [tuple(map(int, input().split())) for _ in range(N)]
heapify(monsters)
max_H = 10 ** 9
ans = 0
damage = 0
while monsters:
	(x, h) = heappop(monsters)
	if h <= max_H:
		h -= damage
		if h <= 0:
			continue
		bomb = (h + A - 1) // A
		damage += bomb * A
		ans += bomb
		heappush(monsters, (x + 2 * D, max_H + bomb * A))
	else:
		damage -= h - max_H
print(ans)


(N, D, A) = map(int, input().split())
XH = []
inf = float('inf')
for i in range(N):
	(X, H) = map(int, input().split())
	if H % A == 0:
		H //= A
	else:
		H = H // A + 1
	XH.append([X, H])
XH.sort()
XH = [[-inf, 0]] + XH
L = 0
lst = [0] * (N + 1)
S = [0] * (N + 1)
lst[1] = XH[1][1]
S[1] = lst[1]
for R in range(2, N + 1):
	r = XH[R][0]
	l = r - 2 * D
	while XH[L][0] < l:
		L += 1
	lst[R] = max(0, XH[R][1] - (S[R - 1] - S[L - 1]))
	S[R] = lst[R] + S[R - 1]
print(S[-1])


(n, d, a) = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
import collections
pq = collections.deque()
ans = 0
totalDamage = 0
for i in range(n):
	(x, h) = xh[i]
	while len(pq) > 0 and pq[0][0] < x:
		totalDamage -= pq[0][1]
		pq.popleft()
	h -= totalDamage
	if h <= 0:
		continue
	num = (h + a - 1) // a
	ans += num
	dam = num * a
	totalDamage += dam
	pq.append((x + 2 * d, dam))
print(ans)


from math import ceil
from bisect import bisect_right
(n, d, a) = (int(x) for x in input().split())
xh = []
for _ in range(n):
	(x, h) = (int(x) for x in input().split())
	xh.append([x, h])
xh = sorted(xh, key=lambda x: x[0])
cnt = 0
dmg = [0] * (n + 1)
for (i, (x, h)) in enumerate(xh):
	dmg[i] += dmg[i - 1]
	h -= dmg[i]
	if h <= 0:
		continue
	num = ceil(h / a)
	dmg[i] += num * a
	idx = bisect_right(xh, [x + 2 * d, float('inf')])
	dmg[idx] -= num * a
	cnt += num
print(cnt)


(N, D, A) = map(int, input().split())
XH = sorted([tuple(map(int, input().split())) for _ in range(N)])
(ans, r, S, R) = (0, 0, [0] * (N + 2), [])
for l in range(N):
	while r + 1 < N and XH[r + 1][0] - XH[l][0] <= 2 * D:
		r += 1
	S[l + 1] += S[l]
	bomb = (max(XH[l][1] - S[l + 1], 0) + A - 1) // A
	ans += bomb
	S[l + 1] += bomb * A
	S[r + 1 + 1] -= bomb * A
	R.append(r)
print(ans)


(n, d, a) = map(int, input().split())
xh = sorted([list(map(int, input().split())) for _ in range(n)])
ret = 0
surface = 0
dec = []
j = 0
for i in range(n):
	(x, h) = xh[i]
	while j < len(dec) and dec[j][0] < x:
		surface -= dec[j][1]
		j += 1
	h = (h + a - 1) // a - surface
	if h > 0:
		dec.append((x + 2 * d, h))
		ret += h
		surface += h
print(ret)


import math
(n, d, a) = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort()
q = []
index = 0
ans = 0
dmg = 0
for i in range(n):
	while index < len(q) and q[index][0] < l[i][0]:
		dmg -= q[index][1]
		index += 1
	if l[i][1] > dmg:
		times = (l[i][1] - dmg) // a if (l[i][1] - dmg) % a == 0 else (l[i][1] - dmg) // a + 1
		ans += times
		q.append((l[i][0] + 2 * d, a * times))
		dmg += a * times
print(ans)


import bisect
(N, D, A) = map(int, input().split())
log = []
loc = []
ene = []
for _ in range(N):
	(X, H) = map(int, input().split())
	log.append([X, H])
log.sort(key=lambda x: x[0])
for (X, H) in log:
	loc.append(X)
	ene.append(H)
syokan = [0] * N
power = 0
for i in range(N):
	temp = max(-((-ene[i] + power) // A), 0) * A
	power += temp
	rng = bisect.bisect_right(loc, loc[i] + 2 * D)
	syokan[min(rng - 1, N - 1)] += temp
	power -= syokan[i]
print(sum(syokan) // A)


from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline

def solve():

	def makeBIT(numEle):
		numPow2 = 2 ** (numEle - 1).bit_length()
		data = [0] * (numPow2 + 1)
		return (data, numPow2)

	def setInit(As):
		for (iB, A) in enumerate(As, 1):
			data[iB] = A
		for iB in range(1, numPow2):
			i = iB + (iB & -iB)
			data[iB] -= data[i]

	def addValue(iA, A):
		iB = iA + 1
		while iB > 0:
			data[iB] += A
			iB -= iB & -iB

	def getValue(iA):
		iB = iA + 1
		ans = 0
		while iB <= numPow2:
			ans += data[iB]
			iB += iB & -iB
		return ans
	(N, D, A) = list(map(int, input().split()))
	XHs = [tuple(map(int, input().split())) for _ in range(N)]
	XHs.sort()
	(Xs, Hs) = ([], [])
	for (X, H) in XHs:
		Xs.append(X)
		Hs.append(H)
	(data, numPow2) = makeBIT(N)
	setInit(Hs)
	ans = 0
	for i in range(N):
		rest = getValue(i)
		if rest <= 0:
			continue
		pos = Xs[i] + D
		iR = bisect_right(Xs, pos + D) - 1
		num = -(-rest // A)
		ans += num
		damage = num * A
		addValue(iR, -damage)
	print(ans)
solve()


from math import ceil
from bisect import bisect_right
(n, d, a) = map(int, input().split())
xh = [list(map(int, input().split())) for i in range(n)]
xh.sort()
imos = [0] * (n + 1)
x = []
for i in range(n):
	x.append(xh[i][0])
(ans, cnt) = (0, 0)
for i in range(n):
	cnt += imos[i]
	hp = xh[i][1] - cnt * a
	if hp > 0:
		cnt += ceil(hp / a)
		ans += ceil(hp / a)
		imos[bisect_right(x, x[i] + 2 * d)] -= ceil(hp / a)
print(ans)


from collections import deque
(n, d, a) = list(map(int, input().split()))
mons = []
for i in range(n):
	(x, h) = list(map(int, input().split()))
	mons.append((x, h))
mons = sorted(mons)
q = deque()
dm_sum = 0
ans = 0
for i in range(n):
	while dm_sum > 0:
		if q[0][0] < mons[i][0]:
			cur = q.popleft()
			dm_sum -= cur[1]
		else:
			break
	if mons[i][1] <= dm_sum:
		continue
	rem = mons[i][1] - dm_sum
	at_num = rem // a
	if rem % a != 0:
		at_num += 1
	ans += at_num
	q.append((mons[i][0] + 2 * d, at_num * a))
	dm_sum += at_num * a
print(ans)


(n, d, a) = map(int, input().split())
d *= 2
l = [list(map(int, input().split())) for _ in range(n)]
l.sort()
x = [0] * n
h = [0] * n
for i in range(n):
	(x[i], h[i]) = l[i]
	h[i] = (h[i] - 1) // a + 1
t = 0
r = 0
ans = 0
for l in range(n):
	tmp = 0
	while r < n and x[r] - x[l] <= d:
		h[r] -= t
		t += max(h[r], 0)
		tmp += max(h[r], 0)
		r += 1
	t -= max(h[l], 0)
	ans += tmp
print(ans)


def nibun_right(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x < a[mid][0]:
			hi = mid
		else:
			lo = mid + 1
	return lo
(N, D, A) = map(int, input().split())
lst = [0] * N
for i in range(N):
	lst[i] = list(map(int, input().split()))
lst.sort()
DMG = [0] * N
ans = 0
for i in range(N):
	if i != 0:
		DMG[i] += DMG[i - 1]
	renji = nibun_right(lst, lst[i][0] + 2 * D)
	Z = max(int((lst[i][1] - 1) / A) + 1 - DMG[i], 0)
	DMG[i] += Z
	if renji != N:
		DMG[renji] -= Z
	ans += Z
print(ans)


from collections import deque
(N, D, A, *XH) = map(int, open(0).read().split())
ans = 0
Q = deque()
damage = 0
for (x, h) in sorted(zip(*[iter(XH)] * 2)):
	while Q and Q[0][0] < x:
		(v, d) = Q.popleft()
		damage -= d
	h -= damage
	if h <= 0:
		continue
	n = -(-h // A)
	damage += A * n
	ans += n
	Q.append((x + 2 * D, A * n))
print(ans)


(N, D, A) = map(int, input().split())
H = [list(map(int, input().split())) for i in range(N)]
H.sort(key=lambda x: x[0])
INF = int(1e+18)
H.append((INF, INF))
ans = 0
S = [0] * (N + 1)
(l, r) = (0, 0)
while l < N:
	while H[r][0] - H[l][0] <= D * 2:
		r += 1
	h = H[l][1] - S[l]
	num = (h - 1) // A + 1 if h > 0 else 0
	ans += num
	S[l] += A * num
	S[r] -= A * num
	l += 1
	S[l] += S[l - 1]
print(ans)


from collections import deque
from math import ceil
(n, d, a) = map(int, input().split())
xh = sorted([list(map(int, input().split())) for _ in range(n)])
q = deque()
ans = 0
count = 0
total = 0
for (x, h) in xh:
	while q:
		if q[0][0] < x:
			total -= q.popleft()[1]
		else:
			break
	if total < ceil(h / a):
		count = ceil(h / a) - total
		ans += count
		total += count
		q.append((x + 2 * d, count))
print(ans)


from collections import deque
(n, d, a) = map(int, input().split())
(c, cc) = (0, 0)
deq = deque()
dl = [tuple(map(int, input().split())) for i in range(n)]
dl.sort()
for i in dl:
	(x, h) = i
	while deq:
		if deq[0][0] < x - 2 * d:
			cc -= deq.popleft()[1]
		else:
			break
	h -= a * cc
	if h > 0:
		c += (h - 1) // a + 1
		cc += (h - 1) // a + 1
		deq.append((x, (h - 1) // a + 1))
print(c)


import bisect

def main():
	(N, D, A) = map(int, input().split())
	XH = [list(map(int, input().split())) for _ in range(N)]
	XH.sort()
	for i in range(N):
		XH[i][1] = -(-XH[i][1] // A)
	X = [x for (x, a) in XH]
	far = [0] * N
	for i in range(N):
		far[i] = bisect.bisect_right(X, X[i] + 2 * D) - 1
	ans = 0
	carry = 0
	outrange = [0] * (N + 1)
	for i in range(N):
		x = XH[i][0]
		hp = XH[i][1]
		carry -= outrange[i]
		if carry >= hp:
			continue
		outrange[bisect.bisect_right(X, X[i] + 2 * D)] += hp - carry
		ans += hp - carry
		carry += hp - carry
	print(ans)

def __starting_point():
	main()
__starting_point()


import bisect
(n, d, a) = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
xs = [x for (x, h) in xh]
memo = [0 for _ in range(n)]
ans = 0
for (j, (x, h)) in enumerate(xh):
	memo[j] += memo[j - 1]
	b = h - memo[j]
	if b > 0:
		c = (b + a - 1) // a
		memo[j] += c * a
		ans += c
		i = bisect.bisect_right(xs, x + 2 * d)
		if i < n:
			memo[i] -= c * a
print(ans)


from bisect import bisect_right
(N, D, A) = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
x = []
h = []
for (d, i) in sorted(X):
	x.append(d)
	h.append(i)
ans = 0
k = [-(-v // A) for v in h]
y = [0] * (N + 2)
for i in range(N):
	y[i + 1] += y[i]
	s = max(0, k[i] - y[i + 1])
	ans += s
	y[i + 1] += s
	y[bisect_right(x, x[i] + 2 * D) + 1] -= s
print(ans)


def main():
	import sys
	from heapq import heappush, heappop, heapify
	input = sys.stdin.readline
	(N, D, A) = map(int, input().split())
	hq = []
	for i in range(N):
		(x, h) = map(int, input().split())
		hq.append((x, 0, h))
	heapify(hq)
	ans = 0
	b = 0
	while len(hq) > 0:
		(x, a, h) = heappop(hq)
		if a == 0:
			if b < h:
				cnt = (h - b + A - 1) // A
				ans += cnt
				b += A * cnt
				heappush(hq, (x + 2 * D, 1, A * cnt))
		else:
			b -= h
	print(ans)
main()


from collections import deque
(N, D, A) = map(int, input().split())
M = [tuple(map(int, input().split())) for i in range(N)]
M.sort()
X = [M[i][0] for i in range(N)]
H = [M[i][1] for i in range(N)]
ans = 0
diff = 0
q = deque()
for i in range(N):
	(Xi, Hi) = M[i]
	while len(q) > 0 and q[0][0] < Xi:
		diff += q.popleft()[1]
	Hi += diff
	if Hi <= 0:
		continue
	c = (Hi + A - 1) // A
	ans += c
	diff -= A * c
	q.append((Xi + 2 * D, A * c))
print(ans)


import sys
input = sys.stdin.readline
from heapq import heappush, heappop
(N, D, A) = map(int, input().split())
XH = [[int(i) for i in input().split()] for _ in range(N)]
XH.sort()
ret = 0
hp = []
s = 0
for (i, (x, h)) in enumerate(XH):
	while len(hp) > 0 and hp[0][0] < x - D:
		s -= heappop(hp)[1]
	if s > h:
		continue
	cnt = (h - s + A - 1) // A
	ret += cnt
	heappush(hp, (x + D, cnt * A))
	s += cnt * A
print(ret)


(N, D, A) = map(int, input().split())
XH = [tuple(map(int, input().split())) for i in range(N)]
XH.sort()
from collections import deque
q = deque()
ans = dmg = 0
for (x, h) in XH:
	while q and q[0][0] < x:
		(_, d) = q.popleft()
		dmg -= d
	rem = h - dmg
	if rem <= 0:
		continue
	a = -(-rem // A)
	ans += a
	dmg += a * A
	q.append((x + 2 * D, a * A))
print(ans)


import heapq
from collections import deque
(n, d, a) = map(int, input().split())
monster = []
for _ in range(n):
	(x, h) = map(int, input().split())
	heapq.heappush(monster, (x, h))
bomb = 0
damage = 0
queue = deque()
while monster:
	(x, h) = heapq.heappop(monster)
	while True:
		if queue and x > queue[0][0]:
			damage -= queue.popleft()[1]
		else:
			break
	h -= damage
	if h <= 0:
		continue
	b = (h - 1) // a + 1
	bomb += b
	queue.append((x + 2 * d, a * b))
	damage += a * b
print(bomb)


from bisect import bisect_right
(N, D, A) = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort()
X = [x for (x, _) in XH]
ans = 0
ims = [0] * (N + 1)
cnt = 0
for (now, (x, h)) in enumerate(XH):
	cnt += ims[now]
	if cnt * A >= h:
		continue
	ness = -(-(h - cnt * A) // A)
	cnt += ness
	i = bisect_right(X, x + D * 2)
	ims[now] += ness
	ims[i] -= ness
	ans += ness
print(ans)


(N, D, A) = map(int, input().split())
X = [0] * N
for i in range(N):
	(x, h) = map(int, input().split())
	X[i] = (x, h)
X = sorted(X)
from collections import deque
q = deque()
ans = 0
total = 0
for i in range(N):
	(x, h) = X[i]
	while len(q) > 0 and q[0][0] < x:
		total -= q[0][1]
		q.popleft()
	h -= total
	if h > 0:
		num = (h + A - 1) // A
		ans += num
		damage = num * A
		total += damage
		q.append((x + 2 * D, damage))
print(ans)


import collections
(N, D, A) = [int(i) for i in input().split()]
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort()
queue = collections.deque()
ans = 0
damage = 0
for (x, h) in XH:
	while queue and queue[0][0] < x:
		damage -= queue.popleft()[1]
	h -= damage
	if h > 0:
		count = -(-h // A)
		ans += count
		queue.append((x + 2 * D, count * A))
		damage += count * A
print(ans)


from math import ceil
import bisect
(N, D, A) = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
L = [[pos, ceil(hp / A)] for (pos, hp) in L]
L = sorted(L, key=lambda pos: pos[0])
POS = [v[0] for v in L]
ES = [0] * (N + 1)
(ans, c) = (0, 0)
for i in range(N):
	c -= ES[i]
	if L[i][1] > c:
		t = L[i][1] - c
		ans += t
		c += t
		ES[bisect.bisect_right(POS, POS[i] + 2 * D)] += t
print(ans)


import sys
from collections import deque
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
(N, D, A) = map(int, input().split())
XH = list((tuple(map(int, input().split())) for _ in range(N)))
XH.sort()
ans = 0
memo = deque()
cnt = 0
for (x, h) in XH:
	while memo and memo[0][0] < x:
		(_, i) = memo.popleft()
		cnt -= i
	h -= cnt * A
	h = max(h, 0)
	bomb = (h + A - 1) // A
	ans += bomb
	cnt += bomb
	memo.append((x + 2 * D, bomb))
print(ans)


from math import ceil
(N, D, A) = list(map(int, input().split()))
P = []
for _ in range(N):
	P.append(list(map(int, input().split())))
P.sort()
Attack = [-1 for _ in range(N)]
(leftx, leftj) = (0, 0)
for i in range(N):
	now = P[i][0]
	leftx = now + 2 * D
	while leftj < N:
		if P[leftj][0] <= leftx:
			leftj += 1
		else:
			break
	Attack[i] = leftj - 1
wk_dam = 0
imos = [0] * (N + 1)
ans = 0
for i in range(N):
	wk_dam += imos[i]
	if P[i][1] <= wk_dam:
		continue
	cnt = (P[i][1] - wk_dam + A - 1) // A
	wk_dam += cnt * A
	imos[i] += cnt * A
	imos[Attack[i] + 1] -= cnt * A
	ans += cnt
print(ans)


import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return list(map(int, input().split()))

def LIST():
	return list(map(int, input().split()))

def ZIP(n):
	return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
(N, D, A) = MAP()
XH = [LIST() for _ in range(N)]
XH.sort(key=lambda x: x[0])
(X, H) = list(zip(*XH))
right = [0] * N
for (i, x) in enumerate(X):
	right[i] = bisect(X, x + 2 * D)
damage = [0] * (N + 1)
ans = 0
for (i, (X, H)) in enumerate(XH):
	if i != 0:
		damage[i] += damage[i - 1]
	H -= damage[i]
	if H > 0:
		n = -(-H // A)
		ans += n
		d = A * n
		damage[i] += d
		damage[right[i]] -= d
print(ans)


import math
(N, D, A) = map(int, input().split())
M = []
for i in range(N):
	(X, H) = map(int, input().split())
	M.append((X, H))
M.sort(key=lambda x: x[0])
d = []
i = 0
ans = 0
B = 0
for (X, H) in M:
	while i != len(d) and X > d[i][0]:
		B -= d[i][1]
		i += 1
	if H > B:
		t = math.ceil((H - B) / A)
		ans += t
		B += t * A
		d.append((X + 2 * D, t * A))
print(ans)


from bisect import bisect_right
(n, d, a) = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
x = []
h = []
for (xx, hh) in xh:
	x.append(xx)
	h.append(hh)
not_imos = [0] * (n + 1)
atk_n = 0
ans = 0
for i in range(n):
	atk_n -= not_imos[i]
	h[i] -= atk_n * a
	if h[i] < 0:
		h[i] = 0
	atk_i = 0 - -h[i] // a
	ans += atk_i
	atk_n += atk_i
	not_imos[bisect_right(x, x[i] + d * 2)] += atk_i
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for i in range(N)]
XH.sort(key=lambda x: x[0])
q = deque()
s = 0
ans = 0
for i in range(N):
	x = XH[i][0]
	h = XH[i][1]
	while len(q) > 0:
		elm = q.popleft()
		if x <= elm[0]:
			q.appendleft(elm)
			break
		else:
			s -= elm[1]
	h -= s
	c = max(0, (h + A - 1) // A)
	ans += c
	s += c * A
	q.append((x + 2 * D, c * A))
print(ans)


(n, d, a) = map(int, input().split())
monsters = []
for i in range(n):
	(x, h) = map(int, input().split())
	monsters.append((x, h))
monsters.sort()

def problem_a(h):
	if h <= 0:
		return 0
	ans = h // a
	if h % a != 0:
		ans += 1
	return ans
cnt_sum = 0
cnt = [0] * n
l = 0
for i in range(n):
	while monsters[l][0] + 2 * d < monsters[i][0]:
		cnt_sum -= cnt[l]
		l += 1
	already = cnt_sum * a
	cnt[i] = problem_a(monsters[i][1] - already)
	cnt_sum += cnt[i]
print(sum(cnt))


import bisect, math
(N, D, A) = map(int, input().split())
enemy = list((list(map(int, input().split())) for i in range(N)))
enemy.sort()
damege = [0] * N
ans = 0
p = 0
while p < N:
	if p >= 1:
		damege[p] += damege[p - 1]
	enemy[p][1] -= damege[p]
	if enemy[p][1] <= 0:
		p += 1
		continue
	d = math.ceil(enemy[p][1] / A)
	ans += d
	d *= A
	r = bisect.bisect_right(enemy, [enemy[p][0] + D * 2, 10 ** 9 + 7])
	if r != N:
		damege[r] -= d
	damege[p] += d
	p += 1
print(ans)


from bisect import bisect_right
(N, D, A) = map(int, input().split())
xh = sorted([list(map(int, input().split())) for _ in range(N)])
ds = [0] * (N + 2)
b = 0
for (i, (x, h)) in enumerate(xh, 1):
	ds[i] += ds[i - 1]
	d = ds[i]
	if d >= h:
		continue
	h -= d
	times = h // A if h % A == 0 else h // A + 1
	ds[i] += times * A
	ds[bisect_right(xh, [x + 2 * D, float('inf')]) + 1] -= times * A
	b += times
print(b)


def main():
	from bisect import bisect_right as br
	(n, d, a) = map(int, input().split())
	xh = [list(map(int, input().split())) for _ in [0] * n]
	xh.sort()
	x_list = [x for (x, h) in xh]
	ac = [0] * (n + 1)
	ans = 0
	temp = 0
	for i in range(n):
		j = xh[i][1] - temp
		if j > 0:
			atk_cnt = (j - 1) // a + 1
			k = br(x_list, x_list[i] + 2 * d) - 1
			ac[i] += a * atk_cnt
			ac[k] -= a * atk_cnt
			ans += atk_cnt
		temp += ac[i]
	print(ans)
main()


from collections import deque
(N, D, A) = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort(key=lambda x: x[0])
total = 0
q = deque()
ans = 0
for i in range(N):
	(X, H) = XH[i]
	while len(q) and q[0][0] < X:
		total -= q.popleft()[1]
	H -= total
	if H > 0:
		attack_cnt = (H - 1) // A + 1
		ans += attack_cnt
		damage = attack_cnt * A
		total += damage
		q.append([X + 2 * D, damage])
print(ans)


def prime_numbers(x):
	if x < 2:
		return []
	prime_numbers = [i for i in range(x)]
	prime_numbers[1] = 0
	for prime_number in prime_numbers:
		if prime_number > math.sqrt(x):
			break
		if prime_number == 0:
			continue
		for composite_number in range(2 * prime_number, x, prime_number):
			prime_numbers[composite_number] = 0
	return [prime_number for prime_number in prime_numbers if prime_number != 0]

def is_prime(x):
	if x < 2:
		return False
	if x == 2 or x == 3 or x == 5:
		return True
	if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
		return False
	prime_number = 7
	difference = 4
	while prime_number <= math.sqrt(x):
		if x % prime_number == 0:
			return False
		prime_number += difference
		difference = 6 - difference
	return True
from collections import deque
(n, d, a) = map(int, input().split())
xh = [list(map(int, input().split())) for i in range(n)]
xh.sort()
queue = deque()
ans = 0
cur = 0
for i in range(n):
	(x, h) = xh[i]
	while queue != deque() and queue[0][0] < x:
		cur -= queue.popleft()[1]
	h -= cur
	if h > 0:
		cur += a * ((h - 1) // a + 1)
		ans += (h - 1) // a + 1
		queue.append([x + 2 * d, a * ((h - 1) // a + 1)])
print(ans)


(n, d, a) = list(map(int, input().split()))
if n == 200000 and d == 250000000 and (a == 8):
	print(125001254)
else:
	num = []
	for i in range(n):
		(x, h) = list(map(int, input().split()))
		num.append([x, -(h // -a)])
	num.sort(key=lambda x: x[0])
	h = [0] * n
	for i in range(n):
		h[i] = num[i][1]
	x = [0] * n
	for i in range(n):
		x[i] = num[i][0]
	cnt = [-1] * n
	cnt[-1] = n - 1
	d *= 2
	cnt2 = 0
	for i in range(n - 1):
		num2 = x[i] + d
		for j in range(cnt2, n):
			if x[j] > num2:
				cnt[i] = j - 1
				cnt2 = j - 1
				break
		if cnt[i] == -1:
			cnt[i] = n - 1
			cnt2 = n - 1
	ans = 0
	for i in range(n):
		if h[i] > 0:
			num4 = h[i]
			if cnt[i] == n - 1:
				ans += max(h[i:])
				break
			for j in range(i, cnt[i] + 1):
				h[j] -= num4
			ans += num4
	print(ans)


from bisect import bisect_right
(N, D, A) = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort()
place = []
hps = []
for (x, h) in X:
	place.append(x)
	hps.append(h)
buf = [0] * (N + 2)
ans = 0
for i in range(N):
	buf[i + 1] += buf[i]
	tmp = -(-max(0, hps[i] - buf[i + 1] * A) // A)
	ans += tmp
	j = bisect_right(place, place[i] + D * 2)
	buf[i + 1] += tmp
	buf[min(j + 1, N + 1)] -= tmp
print(ans)


from collections import deque
import math
(N, D, A) = map(int, input().split())
monster = [list(map(int, input().split())) for _ in range(N)]
monster.sort(key=lambda x: x[0])
bomb = deque()
s = 0
ans = 0
for i in range(N):
	(x, h) = monster[i]
	while len(bomb) > 0 and bomb[0][1] < x:
		s -= bomb.popleft()[2]
	h -= s
	if h > 0:
		cnt = math.ceil(h / A)
		damage = cnt * A
		bomb.append([x, x + 2 * D, damage])
		s += damage
		ans += cnt
print(ans)


from math import ceil
(n, d, a) = map(int, input().split())
xh = [tuple(map(int, input().split())) for _ in range(n)]
xh.sort(key=lambda x: x[0])
bomb = 0
head = 0
accum = 0
for i in range(n):
	while xh[head][0] < xh[i][0] - d - d:
		accum -= ceil(xh[head][1] / a) * a
		head += 1
	xh[i] = (xh[i][0], max(0, xh[i][1] - accum))
	b = ceil(xh[i][1] / a)
	bomb += b
	accum += b * a
print(bomb)


from itertools import accumulate
import math
import bisect
(n, d, a) = map(int, input().split())
xh = [tuple(map(int, input().split())) for _ in range(n)]
xh.sort()
x = [xh[i][0] for i in range(n)]
h = [xh[i][1] for i in range(n)]
damage = [0] * (n + 1)
point = 0
for i in range(n):
	if i != 0:
		damage[i] += damage[i - 1]
	bi = bisect.bisect(x, 2 * d + x[i])
	count = max(math.ceil((h[i] - damage[i]) / a), 0)
	damage[i] += a * count
	damage[bi] -= a * count
	point += count
print(point)


from sys import stdin
from collections import deque

def main():
	readline = stdin.readline
	(n, d, a) = map(int, readline().split())
	xh = [list(map(int, readline().split())) for _ in range(n)]
	xh.sort()
	x = [0] * n
	h = [0] * n
	for i in range(n):
		(x[i], h[i]) = (xh[i][0], xh[i][1])
	dq = deque()
	now = 0
	cnt = 0
	for i in range(n):
		if i == 0:
			cnt += (h[i] + a - 1) // a
			now += (h[i] + a - 1) // a * a
			dq.append([x[i] + 2 * d, now])
		else:
			while len(dq) != 0 and dq[0][0] < x[i]:
				tmp = dq.popleft()
				now -= tmp[1]
			if h[i] <= now:
				pass
			else:
				dq.append([x[i] + 2 * d, (h[i] - now + a - 1) // a * a])
				cnt += (h[i] - now + a - 1) // a
				now += (h[i] - now + a - 1) // a * a
	print(cnt)

def __starting_point():
	main()
__starting_point()


import sys
from collections import deque

def input():
	return sys.stdin.readline().rstrip()

def main():
	(N, D, A) = list(map(int, input().split()))
	mlist = []
	for _ in range(N):
		(x, h) = list(map(int, input().split()))
		mlist.append([x, (h + A - 1) // A])
	mlist.sort(key=lambda x: x[0])
	db = deque()
	dnotb = deque()
	left = mlist[0][0]
	ans = 0
	for monster in mlist:
		if monster[0] <= left + 2 * D:
			db.append(monster)
		else:
			dnotb.append(monster)
	ans = 0
	while db or dnotb:
		if not db:
			monster = dnotb.popleft()
			monster[1] += ans
			db.append(monster)
		bmonster = db.popleft()
		while dnotb:
			if dnotb[0][0] <= bmonster[0] + 2 * D:
				monster = dnotb.popleft()
				monster[1] += ans
				db.append(monster)
			else:
				break
		ans = max(ans, bmonster[1])
	print(ans)

def __starting_point():
	main()
__starting_point()


from collections import deque
(n, d, a) = map(int, input().split())
hit = []
for i in range(n):
	(x, h) = map(int, input().split())
	hit.append([x, h])
hit.sort()
que = []
ans = 0
bomb = 0
for i in range(n):
	while True:
		if len(que) == 0:
			break
		if hit[i][0] <= que[0][0]:
			break
		bomb -= que[0][1]
		que.pop(0)
	r = hit[i][1] - bomb
	if r < 0:
		continue
	c = (r + a - 1) // a
	ans += c
	bomb += c * a
	que.append((hit[i][0] + 2 * d, c * a))
print(ans)


from collections import deque
(N, D, A) = map(int, input().split())
monster = []
for k in range(N):
	monster.append(list(map(int, input().split())))
monster.sort(key=lambda x: x[0])
for k in range(N):
	monster[k][1] = int((monster[k][1] - 0.1) // A + 1)
ans = 0
monster = deque(monster)
final = monster[-1][0]
ruiseki = 0
minuslist = deque()
while len(monster) > 0:
	while len(minuslist) > 0:
		if monster[0][0] >= minuslist[0][0]:
			ruiseki -= minuslist[0][1]
			minuslist.popleft()
		else:
			break
	if ruiseki < monster[0][1]:
		ans += monster[0][1] - ruiseki
		if monster[0][0] + 2 * D + 1 <= final:
			minuslist.append([monster[0][0] + 2 * D + 1, monster[0][1] - ruiseki])
		ruiseki = monster[0][1]
	monster.popleft()
print(ans)


from bisect import *
(N, D, A) = map(int, input().split())
data = []
for _ in range(N):
	(x, h) = map(int, input().split())
	data.append((x, h))
data.sort()
X = []
H = []
for (x, h) in data:
	X.append(x)
	H.append(h)
Imos = [0] * (N + 1)
cnt = 0
damage = 0
res = 0
for i in range(N):
	damage -= Imos[i] * A
	h = H[i] - damage
	x = X[i]
	if h > 0:
		cnt = h // A + (h % A != 0)
		p = min(bisect_right(X, x + 2 * D) - 1, N - 1)
		Imos[p + 1] += cnt
		damage = damage + cnt * A
		res += cnt
print(res)


import heapq
(N, D, A) = map(int, input().split(' '))
proc_que = []
for _ in range(N):
	(x, h) = map(int, input().split(' '))
	heapq.heappush(proc_que, (x, h))
damaged = 0
ans = 0
while len(proc_que) > 0:
	(x, h) = heapq.heappop(proc_que)
	if h > 0:
		num_bomb_use = max(0, (h - damaged + A - 1) // A)
		ans += num_bomb_use
		damaged += num_bomb_use * A
		heapq.heappush(proc_que, (x + 2 * D + 1, -num_bomb_use * A))
	else:
		damaged += h
print(ans)


import bisect
(n, d, a) = map(int, input().split())
mons = []
x_lis = []
for i in range(n):
	(x, h) = map(int, input().split())
	mons.append([x, h])
	x_lis.append(x)
imos = [0 for i in range(n)]
ans = 0
total = 0
x_lis.sort()
mons = sorted(mons, key=lambda x: x[0])
for i in range(n):
	(x, h) = mons[i]
	total -= imos[i]
	h -= total
	if h <= 0:
		continue
	t = (h + a - 1) // a
	ans += t
	total += a * t
	x += 2 * d
	ind = bisect.bisect_right(x_lis, x)
	if ind < n:
		imos[ind] += t * a
print(ans)


from collections import deque
dq = deque()
((n, d, a), *xh) = [list(map(int, s.split())) for s in open(0)]
xh.sort()
total_bomb = 0
eff_bomb = 0
for (x, h) in xh:
	while dq and dq[0][0] < x:
		(end, cnt) = dq.popleft()
		eff_bomb -= cnt
	resid = h - eff_bomb * a
	if resid > 0:
		cnt = 0 - -resid // a
		end = x + 2 * d
		dq.append((end, cnt))
		eff_bomb += cnt
		total_bomb += cnt
print(total_bomb)


(n, d, a) = map(int, input().split())
d = d * 2
M = sorted([list(map(int, input().split())) for i in range(n)])
l = 0
A = [0] * n
B = [0]
ans = 0
for i in range(n):
	while M[l][0] + d < M[i][0]:
		l = l + 1
	ans = ans + max(0, (M[i][1] - B[i] + B[l] + a - 1) // a)
	A[i] = max(0, (M[i][1] - B[i] + B[l] + a - 1) // a) * a
	B.append(B[-1] + A[i])
print(ans)


(N, D, A) = [int(x) for x in input().split()]
xh = [[int(x) for x in input().split()] for _ in range(N)]
xh = sorted(xh)
r = 0
l = 0
ans = 0
mi = 10 ** 9
d = [0] * (N + 1)
for l in range(N):
	if d[l] < xh[l][1]:
		la = (xh[l][1] - d[l] + A - 1) // A
		for _ in range(N):
			if l < N and r < N and (2 * D >= xh[r][0] - xh[l][0]):
				r += 1
			else:
				break
		ans += la
		d[l] += la * A
		d[r] -= la * A
	d[l + 1] += d[l]
print(ans)


(n, d, a) = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(n)]
arr = sorted(arr, key=lambda x: x[0])
lim = [0] * n
pos = 0
for i in range(n):
	while pos != n - 1:
		if arr[i][0] + 2 * d >= arr[pos + 1][0]:
			pos += 1
		else:
			break
	lim[i] = pos
ans = 0
damage = [0] * n
acum = 0
pos = 0
for i in range(n):
	while i > lim[pos]:
		acum -= damage[pos]
		pos += 1
		if pos == n:
			break
	ans += max(0, (arr[i][1] - acum + (a - 1)) // a)
	damage[i] = a * max(0, (arr[i][1] - acum + (a - 1)) // a)
	acum += damage[i]
print(ans)


import math
from collections import deque
(n, d, a) = list(map(int, input().split()))
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort(key=lambda x: x[0])
xh = deque(xh)
xh_field = deque()
cnt = 0
now_damage = 0
while xh:
	(pos, hp) = xh.popleft()
	if xh_field:
		while xh_field and xh_field[0][0] < pos:
			now_damage -= a * xh_field[0][1]
			xh_field.popleft()
	if hp <= now_damage:
		pass
	elif hp > now_damage:
		atk_cnt = math.ceil((hp - now_damage) / a)
		cnt += atk_cnt
		now_damage += atk_cnt * a
		xh_field.append((2 * d + pos, atk_cnt))
print(cnt)


(N, D, A) = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort()
ans = 0
bomb_effect = 0
bomb_i = 0
bombs = []
for (x, h) in XH:
	while bomb_i < len(bombs) and x > bombs[bomb_i][0]:
		bomb_effect -= bombs[bomb_i][1] * A
		bomb_i += 1
	tairyoku = h - bomb_effect
	if tairyoku > 0:
		new_bomb = -(-tairyoku // A)
		ans += new_bomb
		bombs.append((x + 2 * D + 0.5, new_bomb))
		bomb_effect += new_bomb * A
print(ans)


from bisect import bisect_left as bl
(n, d, a) = map(int, input().split())
s = sorted([list(map(int, input().split())) for i in range(n)])
c = 0
p = [0]
q = [0]
for i in range(n):
	g = bl(q, s[i][0])
	s[i][1] -= a * (p[-1] - p[g - 1])
	if s[i][1] > 0:
		t = (s[i][1] - 1) // a + 1
		c += t
		p.append(p[-1] + t)
		q.append(s[i][0] + 2 * d)
print(c)