Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0

atk = []

for i in range(n):
    for j in range(len(atk)-1,-1,-1):
        if e[i][0] <= atk[j][0]:
            e[i][1] -= atk[j][1]
        else:
            break    
    if e[i][1] <= 0:
        continue
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    e[i][1] = 0 
    atk_times_sum += atk_times
    atk.append([atk_u,a*atk_times])

print(atk_times_sum)

Fixed submission:
from operator import itemgetter
from collections import deque
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0
atk_que = deque()
atk_acm_p = 0

for i in range(n):
    while len(atk_que) > 0:
        if atk_que[0][0] < e[i][0]:
            atk_u,atk_p = atk_que.popleft()
            atk_acm_p -= atk_p
        else:
            break
    e[i][1] -= atk_acm_p
    if e[i][1] <= 0:
        continue
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    e[i][1] = 0 
    atk_times_sum += atk_times
    atk_p = a * atk_times
    atk_acm_p += atk_p
    atk_que.append([atk_u,atk_p])

print(atk_times_sum)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0

for i in range(n):
    if e[i][1] <= 0:
        continue
    #atk_l = e[i][0]
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    atk_times_sum += atk_times
    for j in range(i,n):
        #if atk_l <= e[j][0] and e[j][0] <= atk_u:
        if e[j][0] <= atk_u:
            e[j][1] -=  a * atk_times
        else:
            break

print(atk_times_sum)

Fixed submission:
from operator import itemgetter
from collections import deque
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0
atk_que = deque()
atk_acm_p = 0

for i in range(n):
    while len(atk_que) > 0:
        if atk_que[0][0] < e[i][0]:
            atk_u,atk_p = atk_que.popleft()
            atk_acm_p -= atk_p
        else:
            break
    e[i][1] -= atk_acm_p
    if e[i][1] <= 0:
        continue
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    e[i][1] = 0 
    atk_times_sum += atk_times
    atk_p = a * atk_times
    atk_acm_p += atk_p
    atk_que.append([atk_u,atk_p])

print(atk_times_sum)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0

for i in range(n):
    if e[i][1] <= 0:
        continue
    atk_l = e[i][0]
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    atk_times_sum += atk_times
    for j in range(i,n):
        if atk_l <= e[j][0] and e[j][0] <= atk_u:
            e[j][1] -=  a * atk_times
        else:
            break

print(atk_times_sum)

Fixed submission:
from operator import itemgetter
from collections import deque
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0
atk_que = deque()
atk_acm_p = 0

for i in range(n):
    while len(atk_que) > 0:
        if atk_que[0][0] < e[i][0]:
            atk_u,atk_p = atk_que.popleft()
            atk_acm_p -= atk_p
        else:
            break
    e[i][1] -= atk_acm_p
    if e[i][1] <= 0:
        continue
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    e[i][1] = 0 
    atk_times_sum += atk_times
    atk_p = a * atk_times
    atk_acm_p += atk_p
    atk_que.append([atk_u,atk_p])

print(atk_times_sum)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0

for i in range(n):
    if e[i][1] <= 0:
        continue
    atk_l = e[i][0]
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    atk_times_sum += atk_times
    for j in range(i,n):
        if atk_l <= e[j][0] and e[j][0] <= atk_u:
            e[j][1] -=  a * atk_times
        else:
            break

print(atk_times_sum)

Fixed submission:
from operator import itemgetter
from collections import deque
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0
atk_que = deque()
atk_acm_p = 0

for i in range(n):
    while len(atk_que) > 0:
        if atk_que[0][0] < e[i][0]:
            atk_u,atk_p = atk_que.popleft()
            atk_acm_p -= atk_p
        else:
            break
    e[i][1] -= atk_acm_p
    if e[i][1] <= 0:
        continue
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    e[i][1] = 0 
    atk_times_sum += atk_times
    atk_p = a * atk_times
    atk_acm_p += atk_p
    atk_que.append([atk_u,atk_p])

print(atk_times_sum)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0

while len(e) > 0:
    atk_l = e[0][0]
    atk_u = e[0][0] + d*2
    if e[0][1] % a == 0:
        atk_times = int(e[0][1] / a)
    else:
        atk_times = int(e[0][1] / a) + 1
    atk_times_sum += atk_times
    for i in range(len(e)-1,-1,-1):
        if atk_l <= e[i][0] and e[i][0] <= atk_u:
            e[i][1] -=  a * atk_times
            if e[i][1] <=  0:
                del(e[i])

print(atk_times_sum)

Fixed submission:
from operator import itemgetter
from collections import deque
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0
atk_que = deque()
atk_acm_p = 0

for i in range(n):
    while len(atk_que) > 0:
        if atk_que[0][0] < e[i][0]:
            atk_u,atk_p = atk_que.popleft()
            atk_acm_p -= atk_p
        else:
            break
    e[i][1] -= atk_acm_p
    if e[i][1] <= 0:
        continue
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    e[i][1] = 0 
    atk_times_sum += atk_times
    atk_p = a * atk_times
    atk_acm_p += atk_p
    atk_que.append([atk_u,atk_p])

print(atk_times_sum)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0

while len(e) > 0:
    atk_l = e[0][0]
    atk_u = e[0][0] + d*2
    if e[0][1] % a == 0:
        atk_times = int(e[0][1] / a)
    else:
        atk_times = int(e[0][1] / a) + 1
    atk_times_sum += atk_times
    for i in range(len(e)-1,-1,-1):
        if atk_l <= e[i][0] and e[i][0] <= atk_u:
            e[i][1] -=  a * atk_times
            if e[i][1] <=  0:
                del(e[i])

print(atk_times_sum)

Fixed submission:
from operator import itemgetter
from collections import deque
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0
atk_que = deque()
atk_acm_p = 0

for i in range(n):
    while len(atk_que) > 0:
        if atk_que[0][0] < e[i][0]:
            atk_u,atk_p = atk_que.popleft()
            atk_acm_p -= atk_p
        else:
            break
    e[i][1] -= atk_acm_p
    if e[i][1] <= 0:
        continue
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    e[i][1] = 0 
    atk_times_sum += atk_times
    atk_p = a * atk_times
    atk_acm_p += atk_p
    atk_que.append([atk_u,atk_p])

print(atk_times_sum)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0

while len(e) > 0:
    atk_l = e[0][0]
    atk_u = e[0][0] + d*2
    if e[0][1] % a == 0:
        atk_times = int(e[0][1] / a)
    else:
        atk_times = int(e[0][1] / a) + 1
    atk_times_sum += atk_times
    for i in range(len(e)):
        if atk_l <= e[i][0] and e[i][0] <= atk_u:
            e[i][1] -=  a * atk_times
        else:
            break
    for i in range(len(e)-1,-1,-1):
        if e[i][1] <= 0:
            del(e[i])

print(atk_times_sum)

Fixed submission:
from operator import itemgetter
from collections import deque
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0
atk_que = deque()
atk_acm_p = 0

for i in range(n):
    while len(atk_que) > 0:
        if atk_que[0][0] < e[i][0]:
            atk_u,atk_p = atk_que.popleft()
            atk_acm_p -= atk_p
        else:
            break
    e[i][1] -= atk_acm_p
    if e[i][1] <= 0:
        continue
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    e[i][1] = 0 
    atk_times_sum += atk_times
    atk_p = a * atk_times
    atk_acm_p += atk_p
    atk_que.append([atk_u,atk_p])

print(atk_times_sum)