Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil
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
for i, (x, h) in enumerate(xh):
    if h <= 0:
        continue
    num = ceil(h / a)
    xh[i][1] -= num * a
    for j in range(i + 1, len(xh)):
        if xh[j][0] > x + 2 * d:
            break
        if xh[j][1] > 0:
            xh[j][1] -= num * a
    cnt += num
print(cnt)

Fixed submission:
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)

Buggy python submission (verdict: Time Limit Exceeded):
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
for i, (x, h) in enumerate(xh):
    if h <= 0:
        continue
    num = h // a
    if h % a != 0:
        num += 1
    xh[i][1] -= num * a
    for j in range(i + 1, len(xh)):
        if xh[j][0] > x + 2 * d:
            break
        if xh[j][1] > 0:
            xh[j][1] -= num * a
    cnt += num
print(int(cnt))

Fixed submission:
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)

Buggy python submission (verdict: Time Limit Exceeded):
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
for i, (x, h) in enumerate(xh):
    if h <= 0:
        continue
    num = h // a
    if h % a != 0:
        num += 1
    xh[i][1] -= num * a
    lis = []
    for j in range(i + 1, len(xh)):
        if xh[j][1] > 0 and xh[j][0] <= x + 2 * d:
            xh[j][1] -= num * a
    cnt += num
print(int(cnt))

Fixed submission:
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)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, d, a = (int(x) for x in input().split())
xh = np.empty((0, 2))
for _ in range(n):
    x, h = (int(x) for x in input().split())
    xh = np.vstack((xh, np.array([x, h])))
xh = xh[np.argsort(xh[:, 0])]
cnt = 0
while True:
    if xh[xh[:, 1] > 0].size == 0:
        break
    xx, hh = xh[(xh[:, 1] > 0)][0]
    num = hh // a
    if hh % a != 0:
        num += 1
    xh[(xh[:, 0] >= xx) & (xh[:, 0] <= xx + 2 * d), 1] -= num * a
    cnt += num
print(int(cnt))

Fixed submission:
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)