Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())

x = [[0 for j in range(N + 1)] for i in range(N + 1)]
c = [[0 for j in range(N + 1)] for i in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    x[L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i][j - 1]

for _ in range(Q):
    p, q = map(int, input().split())
    print(sum(x[i][q] - x[i][p - 1] for i in range(p, q + 1)))


Fixed submission:
N, M, Q = map(int, input().split())

x = [[0 for j in range(N + 1)] for i in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    x[N - L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i][j - 1]

for j in range(1, N + 1):
    for i in range(1, N + 1):
        x[i][j] += x[i - 1][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(x[N - p][q])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())

x = [[0 for j in range(N + 1)] for i in range(N + 1)]
c = [[0 for j in range(N + 1)] for i in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    x[L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        c[i][j] = sum(x[i][k] for k in range(1, j + 1))

for _ in range(Q):
    p, q = map(int, input().split())
    print(sum(c[i][q] - c[i][p - 1] for i in range(p, q + 1)))



Fixed submission:
N, M, Q = map(int, input().split())

x = [[0 for j in range(N + 1)] for i in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    x[N - L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i][j - 1]

for j in range(1, N + 1):
    for i in range(1, N + 1):
        x[i][j] += x[i - 1][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(x[N - p][q])

Buggy python submission (verdict: Time Limit Exceeded):
n, m, q = map(int, input().split())

g = [[0 for j in range(n)] for i in range(n)]

for _ in range(m):
    l, r = map(int, input().split())
    g[l - 1][r - 1] += 1

for _ in range(q):
    p, q = map(int, input().split())
    ans = 0
    for i in range(p, q + 1):
        for j in range(p, q + 1):
            ans += g[i - 1][j - 1]
    print(ans)


Fixed submission:
N, M, Q = map(int, input().split())

x = [[0 for j in range(N + 1)] for i in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    x[N - L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i][j - 1]

for j in range(1, N + 1):
    for i in range(1, N + 1):
        x[i][j] += x[i - 1][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(x[N - p][q])

Buggy python submission (verdict: Time Limit Exceeded):
n, m, q = map(int, input().split())
lr = tuple(tuple(map(int, input().split())) for _ in range(m))
pq = tuple(tuple(map(int, input().split())) for _ in range(q))

lr = sorted(lr, key=lambda x: x[1] - x[0])

for i in range(q):
    p, q = pq[i]
    c = 0
    for j in range(m):
        l, r = lr[j]
        if r - l > q - p:
            break
        if p <= l and r <= q:
            c += 1
    print(c)


Fixed submission:
N, M, Q = map(int, input().split())

x = [[0 for j in range(N + 1)] for i in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    x[N - L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i][j - 1]

for j in range(1, N + 1):
    for i in range(1, N + 1):
        x[i][j] += x[i - 1][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(x[N - p][q])

Buggy python submission (verdict: Time Limit Exceeded):
n, m, q = map(int, input().split())
lr = [tuple(map(int, input().split())) for _ in range(m)]
pq = [tuple(map(int, input().split())) for _ in range(q)]

for i in range(q):
    p, q = pq[i]
    c = 0
    for j in range(m):
        l, r = lr[j]
        if p <= l and r <= q:
            c += 1
    print(c)


Fixed submission:
N, M, Q = map(int, input().split())

x = [[0 for j in range(N + 1)] for i in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    x[N - L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i][j - 1]

for j in range(1, N + 1):
    for i in range(1, N + 1):
        x[i][j] += x[i - 1][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(x[N - p][q])