Buggy python submission (verdict: Time Limit Exceeded):
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

xh.sort()

ends = []
start = 0
# loop = 0
for base in range(n):
    for start, (x, _) in enumerate(xh[start:], start):
        # loop += 1
        if x > xh[base][0] + 2 * d:
            # start -= 1 # in range
            break
    else:
        start = n
    ends.append(start)
#     print(start)
# print(ends)
# print(loop, "loop")

cnt = [0] * (n + 1)

hist = 0
ans = 0
for i, end in enumerate(ends):
    hist += cnt[i]
    atk = (max(0, xh[i][1] - hist * a) + a - 1) // a
    # print(atk, "atk", hist, end=" ")
    ans += atk
    hist += atk

    cnt[i] += atk
    cnt[end] -= atk
    # print(":", cnt)

print(ans)
# print(cnt)
#
# import functools
# import operator
# print(functools.reduce(operator.add, cnt[:-1]), ans)


Fixed submission:
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

xh.sort()

ends = [None] * n
start = 0
# loop = 0
d2 = 2 * d
for base in range(n):
    while True:
        if start >= n:
            break

        x = xh[start][0]
        # loop += 1
        if x > xh[base][0] + d2:
            # start -= 1 # in range
            break
        start += 1
    # for start, (x, _) in enumerate(xh[start:], start):
    #     loop += 1
    #     if x > xh[base][0] + 2 * d:
    #         # start -= 1 # in range
    #         break
    # else:
    #     start = n
    ends[base] = start
#     print(start)
# print(ends)
# print(loop, "loop")

cnt = [0] * (n + 1)

hist = 0
ans = 0
for i, end in enumerate(ends):
    hist += cnt[i]
    atk = (max(0, xh[i][1] - hist * a) + a - 1) // a
    # print(atk, "atk", hist, end=" ")
    ans += atk
    hist += atk

    cnt[i] += atk
    cnt[end] -= atk
    # print(":", cnt)

print(ans)
# print(cnt)
#
# import functools
# import operator
# print(functools.reduce(operator.add, cnt[:-1]), ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

xh.sort()

ends = []
start = 0
# loop = 0
for base in range(n):
    for start, (x, _) in enumerate(xh[start:], start):
        # loop += 1
        if x > xh[base][0] + 2 * d:
            # start -= 1 # in range
            break
    else:
        start = n
    ends.append(start)
#     print(start)
# print(ends)
# print(loop, "loop")

cnt = [0] * (n + 1)

hist = 0
ans = 0
for i, end in enumerate(ends):
    hist += cnt[i]
    atk = (max(0, xh[i][1] - hist * a) + a - 1) // a
    # print(atk, "atk", hist, end=" ")
    ans += atk
    hist += atk

    cnt[i] += atk
    cnt[end] -= atk
    # print(":", cnt)

print(ans)
# print(cnt)
#
# import functools
# import operator
# print(functools.reduce(operator.add, cnt[:-1]), ans)


Fixed submission:
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

xh.sort()

ends = [None] * n
start = 0
# loop = 0
d2 = 2 * d
for base in range(n):
    while True:
        if start >= n:
            break

        x = xh[start][0]
        # loop += 1
        if x > xh[base][0] + d2:
            # start -= 1 # in range
            break
        start += 1
    # for start, (x, _) in enumerate(xh[start:], start):
    #     loop += 1
    #     if x > xh[base][0] + 2 * d:
    #         # start -= 1 # in range
    #         break
    # else:
    #     start = n
    ends[base] = start
#     print(start)
# print(ends)
# print(loop, "loop")

cnt = [0] * (n + 1)

hist = 0
ans = 0
for i, end in enumerate(ends):
    hist += cnt[i]
    atk = (max(0, xh[i][1] - hist * a) + a - 1) // a
    # print(atk, "atk", hist, end=" ")
    ans += atk
    hist += atk

    cnt[i] += atk
    cnt[end] -= atk
    # print(":", cnt)

print(ans)
# print(cnt)
#
# import functools
# import operator
# print(functools.reduce(operator.add, cnt[:-1]), ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

xh.sort()

ends = []
start = 0
for base in range(n):
    for start, (x, _) in enumerate(xh[start:], start):
        if x > xh[base][0] + 2 * d:
            # start -= 1 # in range
            break
    else:
        start = n
    ends.append(start)
#     print(start)
# print(ends)

cnt = [0] * (n + 1)

hist = 0
ans = 0
for i, end in enumerate(ends):
    hist += cnt[i]
    atk = (max(0, xh[i][1] - hist * a) + a - 1) // a
    # print(atk, "atk", hist, end=" ")
    ans += atk
    hist += atk

    cnt[i] += atk
    cnt[end] -= atk
    # print(":", cnt)

print(ans)
# print(cnt)
#
# import functools
# import operator
# print(functools.reduce(operator.add, cnt[:-1]), ans)


Fixed submission:
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

xh.sort()

ends = [None] * n
start = 0
# loop = 0
d2 = 2 * d
for base in range(n):
    while True:
        if start >= n:
            break

        x = xh[start][0]
        # loop += 1
        if x > xh[base][0] + d2:
            # start -= 1 # in range
            break
        start += 1
    # for start, (x, _) in enumerate(xh[start:], start):
    #     loop += 1
    #     if x > xh[base][0] + 2 * d:
    #         # start -= 1 # in range
    #         break
    # else:
    #     start = n
    ends[base] = start
#     print(start)
# print(ends)
# print(loop, "loop")

cnt = [0] * (n + 1)

hist = 0
ans = 0
for i, end in enumerate(ends):
    hist += cnt[i]
    atk = (max(0, xh[i][1] - hist * a) + a - 1) // a
    # print(atk, "atk", hist, end=" ")
    ans += atk
    hist += atk

    cnt[i] += atk
    cnt[end] -= atk
    # print(":", cnt)

print(ans)
# print(cnt)
#
# import functools
# import operator
# print(functools.reduce(operator.add, cnt[:-1]), ans)