Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil
from bisect import bisect
from operator import itemgetter
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key=itemgetter(0))
X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

bit0 = BIT(N)
bit1 = BIT(N)

ans = 0
for i in range(N):
    x = H[i]
    bit0.add(i,-x*i)
    bit1.add(i,x)
    bit0.add(i+1,x*(i+1))
    bit1.add(i+1,-x)
    h = bit1.sum(i)*(i+1)+bit0.sum(i)
    if i != 0:
        h -= bit1.sum(i-1)*i+bit0.sum(i-1)
    if h>0:
        ans += ceil(h/A)
        x = -ceil(h/A)*A
        j = bisect(X,X[i]+2*D)-1
        bit0.add(i,-x*i)
        bit1.add(i,x)
        bit0.add(j+1,x*(j+1))
        bit1.add(j+1,-x)

print(ans)

Fixed submission:
from math import ceil
from bisect import bisect
from operator import itemgetter
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key=itemgetter(0))
X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

bit = BIT(N)
ans = 0
for i in range(N):
    bit.add(i+1,H[i])
    bit.add(i+2,-H[i])
    h = bit.sum(i+1)
    if h>0:
        ans += ceil(h/A)
        x = -ceil(h/A)*A
        j = bisect(X,X[i]+2*D)
        bit.add(i+1,x)
        bit.add(j+1,-x)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil
from bisect import bisect
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

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)]
H = [XH[i][1] for i in range(N)]

bit0 = BIT(N)
bit1 = BIT(N)

ans = 0
for i in range(N):
    x = H[i]
    bit0.add(i,-x*i)
    bit1.add(i,x)
    bit0.add(i+1,x*(i+1))
    bit1.add(i+1,-x)
    h = bit1.sum(i)*(i+1)+bit0.sum(i)
    if i != 0:
        h -= bit1.sum(i-1)*i+bit0.sum(i-1)
    if h>0:
        ans += ceil(h/A)
        x = -ceil(h/A)*A
        j = bisect(X,X[i]+2*D)-1
        bit0.add(i,-x*i)
        bit1.add(i,x)
        bit0.add(j+1,x*(j+1))
        bit1.add(j+1,-x)

print(ans)

Fixed submission:
from math import ceil
from bisect import bisect
from operator import itemgetter
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key=itemgetter(0))
X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

bit = BIT(N)
ans = 0
for i in range(N):
    bit.add(i+1,H[i])
    bit.add(i+2,-H[i])
    h = bit.sum(i+1)
    if h>0:
        ans += ceil(h/A)
        x = -ceil(h/A)*A
        j = bisect(X,X[i]+2*D)
        bit.add(i+1,x)
        bit.add(j+1,-x)

print(ans)