Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from math import ceil
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0], reverse=True)

ans = 0
for i,xh in enumerate(XH):
    X = xh[0]
    H = xh[1]
    if H > 0:
        num = ceil(H/A)
        for j in range(i,N):
            if XH[j][0] >= X-2*D:
                XH[j][1] -= A*num
            else:
                break
        ans += num
print(ans)


Fixed submission:
#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
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])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from math import ceil
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
for i,xh in enumerate(XH):
    X = xh[0]
    H = xh[1]
    if H > 0:
        num = ceil(H/A)
        for j in range(i,N):
            if XH[j][0] <= X+2*D:
                XH[j][1] -= A*num
            else:
                break
        ans += num
print(ans)


Fixed submission:
#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
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])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from math import ceil
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0])
X,H = map(list, zip(*XH))

ans = 0
for i,xh in enumerate(XH):
    X = xh[0]
    H = xh[1]
    if H > 0:
        num = ceil(H/A)
        for j in range(i,N):
            if XH[j][0] <= X+2*D:
                XH[j][1] -= A*num
            else:
                break
        ans += num
print(ans)


Fixed submission:
#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
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])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from math import ceil
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0])
X,H = map(list, zip(*XH))

ans = 0
for i in range(N):
    if H[i] > 0:
        num = ceil(H[i]/A)
        for j in range(i,N):
            if X[j] <= X[i]+2*D:
                H[j] -= A*num
            else:
                break
        ans += num
print(ans)


Fixed submission:
#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
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])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from math import ceil
from bisect import bisect
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0])
X,H = map(list, zip(*XH))

ans = 0
for i in range(N):
    if H[i] > 0:
        tmp = bisect(X,X[i]+2*D)
        num = ceil(H[i]/A)
        for j in range(i,tmp):
            H[j] -= A*num
        ans += num
print(ans)


Fixed submission:
#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
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])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np
    from math import ceil
    N,D,A = map(int,input().split())
    XH = [list(map(int,input().split())) for _ in range(N)]
    XH.sort(key = lambda x:x[0])
    XH = np.array(XH)
    X = XH[:,0]
    H = XH[:,1]
    ans = 0
    for i in range(N):
        if H[i] > 0:
            tmp = np.searchsorted(X,X[i]+2*D,side = "right")
            num = ceil(H[i]/A)
            H[i:tmp] -= A*num
            ans += num
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
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])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np
from math import ceil
from bisect import bisect
N,D,A = map(int,input().split())
X = list()
H = list()
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0])
XH = np.array(XH)
X = XH[:,0]
H = XH[:,1]
ans = 0
for i in range(N):
    tmp = i
    if H[i] > 0:
        tmp = bisect(X,X[i]+2*D)
        num = ceil(H[i]/A)
        H[i:tmp] -= A*num
        ans += num
print(ans)


Fixed submission:
#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
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])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np
from math import ceil
N,D,A = map(int,input().split())
X = list()
H = list()
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0])
XH = np.array(XH)
X = XH[:,0]
H = XH[:,1]
ans = 0
for i in range(N):
    tmp = i
    if H[i] > 0:
        tmp = np.searchsorted(X,X[i]+2*D,side = "right")
        num = ceil(H[i]/A)
        H[i:tmp] -= A*num
        ans += num
print(ans)


Fixed submission:
#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
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])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)