Buggy python submission (verdict: Time Limit Exceeded):
import math
import bisect
n,d,a = map(int,input().split())
L = []
kyo = []
s = 0
for i in range(n):
    x,h = map(int,input().split())
    L.append([x,h])
    kyo.append(x)
    s += h
L.sort()
kyo.sort()
ans = 0
temp = 0
while s != 0:
    if L[temp][1] != 0:
        times = int(math.ceil(L[temp][1]/a))
        ans += times
        s -= L[temp][1]
        damage = a*times
        ran = L[temp][0]+2*d
        k = bisect.bisect_right(kyo, ran)
        next = temp+1
        for i in range(temp+1, k):
            if L[i][1] > damage:
                L[i][1] -= damage
                s -= damage
                next = min(next, i)
            else:
                s -= L[i][1]
                L[i][1] = 0
        temp = next
    else:
        for i in range(temp+1, n):
            if L[i] != 0:
                temp = i
                break
print(ans)


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

Buggy python submission (verdict: Time Limit Exceeded):
import math
import bisect
n,d,a = map(int,input().split())
L = []
kyo = []
s = 0
for i in range(n):
    x,h = map(int,input().split())
    L.append([x,h])
    kyo.append(x)
    s += h
L.sort()
kyo.sort()
ans = 0
temp = 0
while s != 0:
    if L[temp][1] != 0:
        times = int(math.ceil(L[temp][1]/a))
        ans += times
        s -= L[temp][1]
        damage = a*times
        ran = L[temp][0]+2*d
        k = bisect.bisect_right(kyo, ran)
        next = temp+1
        for i in range(temp+1, k):
            if L[i][1] > damage:
                L[i][1] -= damage
                s -= damage
                next = min(next, i)
            else:
                s -= L[i][1]
                L[i][1] = 0
        temp = next
    else:
        for i in range(temp+1, n):
            if L[i] != 0:
                temp = i
                break
print(ans)


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

Buggy python submission (verdict: Time Limit Exceeded):
import math
n,d,a = map(int,input().split())
L = []
s = 0
for i in range(n):
    t = list(map(int,input().split()))
    s += t[1]
    L.append(t)
L.sort()
ans = 0
temp = 0
while s != 0:
    if L[temp][1] != 0:
        times = int(math.ceil(L[temp][1]/a))
        ans += times
        s -= L[temp][1]
        damage = a*times
        ran = L[temp][0]+2*d
        next = temp+1
        for i in range(temp+1, n):
            if L[i][0] <= ran:
                if L[i][1] > damage:
                    L[i][1] -= damage
                    s -= damage
                    next = min(next, i)
                else:
                    s -= L[i][1]
                    L[i][1] = 0
            else:
                break
        temp = next
    else:
        for i in range(temp+1, n):
            if L[i] != 0:
                temp = i
                break
print(ans)


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

Buggy python submission (verdict: Time Limit Exceeded):
n,d,a = map(int,input().split())
L = []
s = 0
for i in range(n):
    t = list(map(int,input().split()))
    s += t[1]
    L.append(t)
L.sort()
ans = 0
temp = 0
while s != 0:
    if L[temp][1] != 0:
        if L[temp][1]%a == 0:
            times = L[temp][1]//a
        else:
            times = L[temp][1]//a+1
        ans += times
        s -= L[temp][1]
        damage = a*times
        ran = L[temp][0]+2*d
        next = temp+1
        for i in range(temp+1, n):
            if L[i][0] <= ran:
                if L[i][1] > damage:
                    L[i][1] -= damage
                    s -= damage
                    next = min(next, i)
                else:
                    s -= L[i][1]
                    L[i][1] = 0
            else:
                break
        temp = next
    else:
        temp += 1
print(ans)


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

Buggy python submission (verdict: Time Limit Exceeded):
n,d,a = map(int,input().split())
L = []
s = 0
for i in range(n):
    t = list(map(int,input().split()))
    s += t[1]
    L.append(t)
L.sort()
ans = 0
temp = 0
while s != 0:
    if L[temp][1] != 0:
        if L[temp][1]%a == 0:
            times = L[temp][1]//a
        else:
            times = L[temp][1]//a+1
        ans += times
        s -= L[temp][1]
        damage = a*times
        ran = L[temp][0]+2*d
        next = temp+1
        for i in range(temp+1, n):
            if L[i][0] <= ran:
                if L[i][1] > damage:
                    L[i][1] -= damage
                    s -= damage
                    next = min(next, i)
                else:
                    s -= L[i][1]
                    L[i][1] = 0
            else:
                break
        temp = next
    else:
        temp += 1
print(ans)


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

Buggy python submission (verdict: Runtime Error):
n,d,a = map(int,input().split())
L = []
T = []
U = []
hitpoint = []
for i in range(n):
  p,q = map(int,input().split())
  L.append([p,q,0])
  T.append(p)
  U.append(p)
  hitpoint.append(q)
U.sort()
for i in range(n):
  k = bisect.bisect_right(U,T[i]+2*d)
  L[i][2] = k
L.sort()
start = 0
ans = 0
while start != n:
  t = hitpoint[start]//a
  if hitpoint[start]%a == 0:
    attack = t
  else:
    attack = t+1
  ans += attack
  cur = attack*a
  look = L[start][2]
  flag = False
  ne = 0
  for i in range(look-start):
    if start+i <= n-1:
      if (hitpoint[start+i] - cur <= 0):
        hitpoint[start+i] = 0
      else:
        if not flag:
          ne = i
          flag = True
        hitpoint[start+i] -= cur
  if ne == 0:
    start += 1
  else:
    start += ne
print(ans)

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

Buggy python submission (verdict: Runtime Error):
n,d,a = map(int,input().split())
L = []
T = []
U = []
hitpoint = []
for i in range(n):
  p,q = map(int,input().split())
  L.append([p,q,0])
  T.append(p)
  U.append(p)
  hitpoint.append(q)
U.sort()
for i in range(n):
  k = bisect.bisect_right(U,T[i]+2*d)
  L[i][2] = k
L.sort()
start = 0
ans = 0
while start != n:
  t = hitpoint[start]//a
  if hitpoint[start]%a == 0:
    attack = t
  else:
    attack = t+1
  ans += attack
  cur = attack*a
  look = L[start][2]
  flag = False
  ne = 0
  for i in range(look-start):
    if start+i <= n-1:
      if (hitpoint[start+i] - cur <= 0):
        hitpoint[start+i] = 0
      else:
        if not flag:
          ne = i
          flag = True
        hitpoint[start+i] -= cur
  if ne == 0:
    start += 1
  else:
    start += ne
print(ans)

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