Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
PQ = [[int(_) for _ in input().split()] for _ in range(Q)]

dp = [[0] * N for _ in range(N)]
for lr in LR:
    dp[lr[0] - 1][lr[1] - 1] += 1
for pq in PQ:
    print(sum([sum(dp[i][i:pq[1]]) for i in range(pq[0] - 1, pq[1])]))


Fixed submission:
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
PQ = [[int(_) for _ in input().split()] for _ in range(Q)]

cumsum = [[0] * (N+2) for _ in range(N+1)]
for lr in LR:
    cumsum[lr[0]][lr[0]] += 1
    if lr[1] < N:
        cumsum[lr[0]][lr[1]+1] -= 1
for i in range(N+1):
    for j in range(i, N):
        cumsum[i][j+1] += cumsum[i][j]
for pq in PQ:
    print(sum([cumsum[i][i]-cumsum[i][pq[1]+1]
               for i in range(pq[0], pq[1]+1)]))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
pq = [[int(_) for _ in input().split()] for _ in range(Q)]

cumsum = [[0] * (N + 1) for _ in range(N + 1)]
for l, r in LR:
    cumsum[l][r] += 1
for i, j in itertools.product(range(N + 1), range(N)):
    cumsum[i][j + 1] += cumsum[i][j]
for p, q in pq:
    print(sum([cumsum[i][q] - cumsum[i][p - 1] for i in range(p, q + 1)]))

Fixed submission:
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
PQ = [[int(_) for _ in input().split()] for _ in range(Q)]

cumsum = [[0] * (N+2) for _ in range(N+1)]
for lr in LR:
    cumsum[lr[0]][lr[0]] += 1
    if lr[1] < N:
        cumsum[lr[0]][lr[1]+1] -= 1
for i in range(N+1):
    for j in range(i, N):
        cumsum[i][j+1] += cumsum[i][j]
for pq in PQ:
    print(sum([cumsum[i][i]-cumsum[i][pq[1]+1]
               for i in range(pq[0], pq[1]+1)]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
pq = [[int(_) for _ in input().split()] for _ in range(Q)]

LR_bin = [2 ** (1 + _[1] - _[0]) - 1 << (_[0] - 1) for _ in LR]
pq_bin = [2 ** (1 + _[1] - _[0]) - 1 << (_[0] - 1) for _ in pq]

for i in pq_bin:
    print(sum([_ == i & _ for _ in LR_bin]))

Fixed submission:
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
PQ = [[int(_) for _ in input().split()] for _ in range(Q)]

cumsum = [[0] * (N+2) for _ in range(N+1)]
for lr in LR:
    cumsum[lr[0]][lr[0]] += 1
    if lr[1] < N:
        cumsum[lr[0]][lr[1]+1] -= 1
for i in range(N+1):
    for j in range(i, N):
        cumsum[i][j+1] += cumsum[i][j]
for pq in PQ:
    print(sum([cumsum[i][i]-cumsum[i][pq[1]+1]
               for i in range(pq[0], pq[1]+1)]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
pq = [[int(_) for _ in input().split()] for _ in range(Q)]

memo = [[0 for _ in range(N)] for _ in range(N)]
for l, r in LR:
    memo[l - 1][r - 1] += 1
for p, q in pq:
    print(sum([sum(memo[_][p - 1:q]) for _ in range(p - 1, q)]))

Fixed submission:
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
PQ = [[int(_) for _ in input().split()] for _ in range(Q)]

cumsum = [[0] * (N+2) for _ in range(N+1)]
for lr in LR:
    cumsum[lr[0]][lr[0]] += 1
    if lr[1] < N:
        cumsum[lr[0]][lr[1]+1] -= 1
for i in range(N+1):
    for j in range(i, N):
        cumsum[i][j+1] += cumsum[i][j]
for pq in PQ:
    print(sum([cumsum[i][i]-cumsum[i][pq[1]+1]
               for i in range(pq[0], pq[1]+1)]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
pq = [[int(_) for _ in input().split()] for _ in range(Q)]

dp = [[0 for j in range(N - i)]for i in range(N)]
for k in range(M):
    for i in range(N):
        for j in range(N - i):
            dp[i][j] += 1 if i + 1 <= LR[k][0] and LR[k][1] <= i + j + 1 else 0
for l in range(Q):
    print(dp[pq[l][0] - 1][pq[l][1] - pq[l][0]])

Fixed submission:
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
PQ = [[int(_) for _ in input().split()] for _ in range(Q)]

cumsum = [[0] * (N+2) for _ in range(N+1)]
for lr in LR:
    cumsum[lr[0]][lr[0]] += 1
    if lr[1] < N:
        cumsum[lr[0]][lr[1]+1] -= 1
for i in range(N+1):
    for j in range(i, N):
        cumsum[i][j+1] += cumsum[i][j]
for pq in PQ:
    print(sum([cumsum[i][i]-cumsum[i][pq[1]+1]
               for i in range(pq[0], pq[1]+1)]))