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

table = [[0 for _i in range(N+1)] for _j in range(N+1)]
accum = [[0 for _i in range(N+1)] for _j in range(N+1)]
ans = [[0 for _i in range(N+1)] for _j in range(N+1)]

for line in LR:
    table[line[0]][line[1]] += 1
for i in range(1, N+1):
    for j in range(i, N+1):
        accum[i][j] = accum[i][j-1] + table[i][j]
for i in range(1, N+1):
    for j in range(i, N+1):
        ans[i][j] = sum([accum[k][j] - accum[k][i-1] for k in range(i, j+1)])

for question in pq:
    p = question[0]
    q = question[1]
    print(ans[p][q])

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

table = [[0 for _i in range(N+1)] for _j in range(N+1)]
accum = [[0 for _i in range(N+1)] for _j in range(N+1)]
accum2 = [[0 for _i in range(N+1)] for _j in range(N+1)]

for line in LR:
    table[line[0]][line[1]] += 1
# よこ
for i in range(1, N+1):
    for j in range(1, N+1):
        accum[i][j] = accum[i][j-1] + table[i][j]
# 縦
for i in range(1, N+1):
    for j in range(1, N+1):
        accum2[i][j] = accum2[i-1][j] + accum[i][j]

# for i in range(1, N+1):
#     for j in range(i, N+1):
#         ans[i][j] = sum([accum[k][j] - accum[k][i-1] for k in range(i, j+1)])

for question in pq:
    p = question[0]
    q = question[1]
    print(accum2[q][q] - accum2[p-1][q] - accum2[q][p-1] + accum2[p-1][p-1])

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

table = [[0 for _i in range(N+1)] for _j in range(N+1)]
for line in LR:
    table[line[0]][line[1]] += 1
for question in pq:
    p = question[0]
    q = question[1]
    ans = 0
    for i in range(p, q+1):
        ans += sum(table[i][p:q+1])
    print(ans)

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

table = [[0 for _i in range(N+1)] for _j in range(N+1)]
accum = [[0 for _i in range(N+1)] for _j in range(N+1)]
accum2 = [[0 for _i in range(N+1)] for _j in range(N+1)]

for line in LR:
    table[line[0]][line[1]] += 1
# よこ
for i in range(1, N+1):
    for j in range(1, N+1):
        accum[i][j] = accum[i][j-1] + table[i][j]
# 縦
for i in range(1, N+1):
    for j in range(1, N+1):
        accum2[i][j] = accum2[i-1][j] + accum[i][j]

# for i in range(1, N+1):
#     for j in range(i, N+1):
#         ans[i][j] = sum([accum[k][j] - accum[k][i-1] for k in range(i, j+1)])

for question in pq:
    p = question[0]
    q = question[1]
    print(accum2[q][q] - accum2[p-1][q] - accum2[q][p-1] + accum2[p-1][p-1])

Buggy python submission (verdict: Runtime Error):
N, M, Q = map(int, raw_input().split())
for _ in range(M):
LR = [map(int, raw_input().split()) for _ in range(M)]
pq = [map(int, raw_input().split()) for _ in range(Q)]

table = [[0 for _i in range(N+1)] for _j in range(N+1)]
for line in LR:
    table[LR[0]][LR[1]] += 1
for question in pq:
    p = question[0]
    q = question[1]
    ans = 0
    for j in range(p, q+1):
        ans += table[p][j]
    print(ans)

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

table = [[0 for _i in range(N+1)] for _j in range(N+1)]
accum = [[0 for _i in range(N+1)] for _j in range(N+1)]
accum2 = [[0 for _i in range(N+1)] for _j in range(N+1)]

for line in LR:
    table[line[0]][line[1]] += 1
# よこ
for i in range(1, N+1):
    for j in range(1, N+1):
        accum[i][j] = accum[i][j-1] + table[i][j]
# 縦
for i in range(1, N+1):
    for j in range(1, N+1):
        accum2[i][j] = accum2[i-1][j] + accum[i][j]

# for i in range(1, N+1):
#     for j in range(i, N+1):
#         ans[i][j] = sum([accum[k][j] - accum[k][i-1] for k in range(i, j+1)])

for question in pq:
    p = question[0]
    q = question[1]
    print(accum2[q][q] - accum2[p-1][q] - accum2[q][p-1] + accum2[p-1][p-1])