Buggy python submission (verdict: Time Limit Exceeded):
n, m, q = [int(x) for x in input().split()]

t_list = [[0] * (n + 1) for i in range(n + 1)]
c_list = [[0] * (n + 1) for i in range(n + 1)]

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

for i in range(1, n + 1):
    for j in range(1, n + 1):
        c_list[i][j] = t_list[i][j] + c_list[i][j - 1]

for _ in range(q):
    l, r = [int(x) for x in input().split()]
    ans = 0
    for j in range(l, r + 1):
        ans += c_list[j][r] - c_list[j][l - 1]
    print(ans)

Fixed submission:
n, m, q = [int(x) for x in input().split()]

t_list = [[0] * (n + 1) for i in range(n + 1)]
c_list = [[0] * (n + 1) for i in range(n + 1)]

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

for i in range(1, n + 1):
    for j in range(1, n + 1):
        c_list[i][j] = t_list[i][j] + c_list[i][j - 1] + c_list[i - 1][j] - c_list[i - 1][j - 1]

for _ in range(q):
    l, r = [int(x) for x in input().split()]
    print(c_list[r][r] - c_list[l - 1][r] - c_list[r][l - 1] + c_list[l - 1][l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, m, q = [int(x) for x in input().split()]

t_list = []
c_list = []
for _ in range(n + 1):
    t_list.append([0] * (n + 1))
    c_list.append([0] * (n + 1))

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

for i in range(1, n + 1):
    for j in range(1, n + 1):
        c_list[i][j] = t_list[i][j] + c_list[i][j - 1]

for _ in range(q):
    l, r = [int(x) for x in input().split()]
    ans = 0
    for j in range(l, r + 1):
        ans += c_list[j][r] - c_list[j][l - 1]
    print(ans)

Fixed submission:
n, m, q = [int(x) for x in input().split()]

t_list = [[0] * (n + 1) for i in range(n + 1)]
c_list = [[0] * (n + 1) for i in range(n + 1)]

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

for i in range(1, n + 1):
    for j in range(1, n + 1):
        c_list[i][j] = t_list[i][j] + c_list[i][j - 1] + c_list[i - 1][j] - c_list[i - 1][j - 1]

for _ in range(q):
    l, r = [int(x) for x in input().split()]
    print(c_list[r][r] - c_list[l - 1][r] - c_list[r][l - 1] + c_list[l - 1][l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right

n, m, q = [int(x) for x in input().split()]

temp_list = []
for i in range(m):
    l, r = [int(x) for x in input().split()]
    temp_list.append((l, i, 0))
    temp_list.append((r, i, 1))
temp_list.sort()

for _ in range(q):
    l, r = [int(x) for x in input().split()]

    li = bisect_left(temp_list, (l, 0, 0))
    ri = bisect_right(temp_list, (r, m, 1))

    flag = [False] * m
    ans = 0
    for j in range(li, ri):
        _, i, f = temp_list[j]
        if f == 0:
            flag[i] = True
        elif f == 1 and flag[i]:
            ans += 1
    print(ans)

Fixed submission:
n, m, q = [int(x) for x in input().split()]

t_list = [[0] * (n + 1) for i in range(n + 1)]
c_list = [[0] * (n + 1) for i in range(n + 1)]

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

for i in range(1, n + 1):
    for j in range(1, n + 1):
        c_list[i][j] = t_list[i][j] + c_list[i][j - 1] + c_list[i - 1][j] - c_list[i - 1][j - 1]

for _ in range(q):
    l, r = [int(x) for x in input().split()]
    print(c_list[r][r] - c_list[l - 1][r] - c_list[r][l - 1] + c_list[l - 1][l - 1])