Buggy python submission (verdict: Time Limit Exceeded):
N, M, QN = [int(x) for x in input().split()]

MAT0 = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(M):
    l, r = [int(x) for x in input().split()]
    MAT0[l][r] += 1

MAT = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(0, N + 1):
        MAT[i][j] = MAT[i][j - 1] + MAT0[i][j]

for i in range(QN):
    p, q = [int(x) for x in input().split()]
    ret = 0
    for j in range(p, q + 1):
        ret = ret + MAT[j][q] - MAT[j][p - 1]
    print(ret)


Fixed submission:
N, M, QN = [int(x) for x in input().split()]

MAT0 = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(M):
    l, r = [int(x) for x in input().split()]
    MAT0[l][r] += 1

MAT = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        MAT[i][j] = MAT[i][j - 1] + MAT0[i][j]

MM = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        MM[i][j] = MM[i - 1][j] + MAT[i][j]

for i in range(QN):
    p, q = [int(x) for x in input().split()]
    ret = 0
    ret = ret + MM[q][q] - MM[q][p - 1] - MM[p - 1][q] + MM[p - 1][p - 1]
    print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, QN = [int(x) for x in input().split()]

L = [None] * M
R = [None] * M

MAT0 = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(M):
    l, r = [int(x) for x in input().split()]
    L[i] = l
    R[i] = r
    MAT0[l][r] += 1

MAT = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(0, N + 1):
        MAT[i][j] = MAT[i][j - 1] + MAT0[i][j]

for i in range(QN):
    p, q = [int(x) for x in input().split()]
    ret = 0
    for j in range(p, q + 1):
        ret = ret + MAT[j][q] - MAT[j][p - 1]
    print(ret)


Fixed submission:
N, M, QN = [int(x) for x in input().split()]

MAT0 = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(M):
    l, r = [int(x) for x in input().split()]
    MAT0[l][r] += 1

MAT = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        MAT[i][j] = MAT[i][j - 1] + MAT0[i][j]

MM = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        MM[i][j] = MM[i - 1][j] + MAT[i][j]

for i in range(QN):
    p, q = [int(x) for x in input().split()]
    ret = 0
    ret = ret + MM[q][q] - MM[q][p - 1] - MM[p - 1][q] + MM[p - 1][p - 1]
    print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, QNUM = [int(x) for x in input().split()]

L = [None] * M
R = [None] * M

for i in range(M):
    l, r = [int(x) for x in input().split()]
    L[i] = l
    R[i] = r

P = [None] * QNUM  # P
Q = [None] * QNUM  # Q

for i in range(QNUM):
    p, q = [int(x) for x in input().split()]
    P[i] = p
    Q[i] = q

T = [[0] * (N + 1) for _ in range((N + 1))]

for i in range(M):
    for s in range(1, L[i] + 1):
        for e in range(R[i], N + 1):
            T[s][e] += 1


for i in range(QNUM):
    print(T[P[i]][Q[i]])


Fixed submission:
N, M, QN = [int(x) for x in input().split()]

MAT0 = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(M):
    l, r = [int(x) for x in input().split()]
    MAT0[l][r] += 1

MAT = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        MAT[i][j] = MAT[i][j - 1] + MAT0[i][j]

MM = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        MM[i][j] = MM[i - 1][j] + MAT[i][j]

for i in range(QN):
    p, q = [int(x) for x in input().split()]
    ret = 0
    ret = ret + MM[q][q] - MM[q][p - 1] - MM[p - 1][q] + MM[p - 1][p - 1]
    print(ret)