Buggy python submission (verdict: Time Limit Exceeded):
N,D,A = map(int,input().split())
X = []
for _ in range(N):
    x,h = map(int,input().split())
    X.append([x,h])
X.sort()
ans = 0
for i in range(N):
    h = int(X[i][1])
    if h != 0:
        x = int(X[i][0])
        if h % A == 0:
            count = h // A
        else:
            count = h // A + 1
        ans += count
        dmg = A * count
    #print(ans,dmg)
        for j in range(i+1,N):
            x2 = int(X[j][0])
            h2 = int(X[j][1])
            if  x + (2 * D) < x2:
                break
            else:
                X[j][1] = max(0,h2-dmg)
                #print(X[j])
print(ans)

Fixed submission:
N,D,A = map(int,input().split())
X = []
for _ in range(N):
    x,h = map(int,input().split())
    X.append([x,h])
X.sort()
if X[-1][0] - X[0][0] < 2 * D:
    ans = 0 
    max = 0
    for i in range(N):
        if X[i][1] > max:
            max = X[i][1]
    if max % A == 0:
        ans = max // A
    else:
        ans = max // A + 1
else:
    ans = 0
    for i in range(N):
        h = int(X[i][1])
        if h != 0:
            x = int(X[i][0])
            if h % A == 0:
                count = h // A
            else:
                count = h // A + 1
            ans += count
            dmg = A * count
    #print(ans,dmg)
            for j in range(i+1,N):
                x2 = int(X[j][0])
                h2 = int(X[j][1])
                if  x + (2 * D) < x2:
                    break
                else:
                    X[j][1] = max(0,h2-dmg)
                    #print(X[j])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,D,A = map(int,input().split())
X = []
for _ in range(N):
    x,h = map(int,input().split())
    X.append([x,h])
X.sort()
ans = 0
for i in range(N):
    x = int(X[i][0])
    h = int(X[i][1])
    if h % A == 0:
        count = h // A
    else:
        count = h // A + 1
    ans += count
    dmg = A * count
    #print(ans,dmg)
    for j in range(i+1,N):
        x2 = int(X[j][0])
        h2 = int(X[j][1])
        if  x + (2 * D) < x2:
            break
        else:
            X[j][1] = max(0,h2-dmg)
            #print(X[j])
print(ans)

Fixed submission:
N,D,A = map(int,input().split())
X = []
for _ in range(N):
    x,h = map(int,input().split())
    X.append([x,h])
X.sort()
if X[-1][0] - X[0][0] < 2 * D:
    ans = 0 
    max = 0
    for i in range(N):
        if X[i][1] > max:
            max = X[i][1]
    if max % A == 0:
        ans = max // A
    else:
        ans = max // A + 1
else:
    ans = 0
    for i in range(N):
        h = int(X[i][1])
        if h != 0:
            x = int(X[i][0])
            if h % A == 0:
                count = h // A
            else:
                count = h // A + 1
            ans += count
            dmg = A * count
    #print(ans,dmg)
            for j in range(i+1,N):
                x2 = int(X[j][0])
                h2 = int(X[j][1])
                if  x + (2 * D) < x2:
                    break
                else:
                    X[j][1] = max(0,h2-dmg)
                    #print(X[j])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,D,A = map(int,input().split())
X = []
for _ in range(N):
    x,h = map(int,input().split())
    X.append([x,h])
X.sort()
ans = 0
for i in range(N):
    x = X[i][0]
    h = X[i][1]
    if h % A == 0:
        count = h // A
    else:
        count = h // A + 1
    ans += count
    dmg = A * count
    #print(ans,dmg)
    for j in range(i+1,N):
        if  x + (2 * D) < X[j][0]:
            break
        else:
            X[j][1] = max(0,X[j][1]-dmg)
            #print(X[j])
print(ans)

Fixed submission:
N,D,A = map(int,input().split())
X = []
for _ in range(N):
    x,h = map(int,input().split())
    X.append([x,h])
X.sort()
if X[-1][0] - X[0][0] < 2 * D:
    ans = 0 
    max = 0
    for i in range(N):
        if X[i][1] > max:
            max = X[i][1]
    if max % A == 0:
        ans = max // A
    else:
        ans = max // A + 1
else:
    ans = 0
    for i in range(N):
        h = int(X[i][1])
        if h != 0:
            x = int(X[i][0])
            if h % A == 0:
                count = h // A
            else:
                count = h // A + 1
            ans += count
            dmg = A * count
    #print(ans,dmg)
            for j in range(i+1,N):
                x2 = int(X[j][0])
                h2 = int(X[j][1])
                if  x + (2 * D) < x2:
                    break
                else:
                    X[j][1] = max(0,h2-dmg)
                    #print(X[j])
print(ans)