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


for _ in range(M):
    l, r = list(map(int, input().split()))
    X[l-1][r-1] += 1
C = []
for line in X:
    tmp = [0, ]
    for c in line:
        tmp.append(tmp[-1] + c)
    C.append(tmp)
query = [map(int, input().split()) for _ in range(Q)]
# print(X)
# print(C)

for p, q in query:
    ans = 0
    for i, line in enumerate(C):
        if p-1 <= i and i <= q-1:
            ans += line[q] - line[p-1]
    print(ans)


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


for _ in range(M):
    l, r = list(map(int, input().split()))
    X[l-1][r-1] += 1
C = []
for line in X:
    tmp = [0, ]
    for c in line:
        tmp.append(tmp[-1] + c)
    C.append(tmp)
query = [map(int, input().split()) for _ in range(Q)]
# print(X)
# print(C)

for p, q in query:
    ans = 0
    for i, line in enumerate(C):
        if p-1 <= i and i <= q-1:
            ans += line[q] - line[p-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import bisect


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

trains = [list(map(int, input().split())) for _ in range(M)]
trains = sorted(trains)
trains1 = []
trains2 = []
for l, r in trains:
    trains1.append(l)
    trains2.append(r)
query = [map(int, input().split()) for _ in range(Q)]
bleft = bisect.bisect_left
bright = bisect.bisect_right
ans = []

for p, q in query:
    li = bleft(trains1, p)
    # print(trains[:li])
    tmpTrains = sorted(trains2[li:])
    ri = bright(tmpTrains, q)
    ans.append(ri)
print("\n".join(map(str, ans)))


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


for _ in range(M):
    l, r = list(map(int, input().split()))
    X[l-1][r-1] += 1
C = []
for line in X:
    tmp = [0, ]
    for c in line:
        tmp.append(tmp[-1] + c)
    C.append(tmp)
query = [map(int, input().split()) for _ in range(Q)]
# print(X)
# print(C)

for p, q in query:
    ans = 0
    for i, line in enumerate(C):
        if p-1 <= i and i <= q-1:
            ans += line[q] - line[p-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import bisect


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

trains = [list(map(int, input().split())) for _ in range(M)]
trains = sorted(trains)
trains1 = []
trains2 = []
for l, r in trains:
    trains1.append(l)
    trains2.append(r)
query = [map(int, input().split()) for _ in range(Q)]
bleft = bisect.bisect_left
bright = bisect.bisect_right
ans = []

for p, q in query:
    li = bleft(trains1, p)
    # print(trains[:li])
    tmpTrains = sorted(trains2[li:])
    ri = bright(tmpTrains, q)
    ans.append(ri)
print("\n".join(map(str, ans)))


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


for _ in range(M):
    l, r = list(map(int, input().split()))
    X[l-1][r-1] += 1
C = []
for line in X:
    tmp = [0, ]
    for c in line:
        tmp.append(tmp[-1] + c)
    C.append(tmp)
query = [map(int, input().split()) for _ in range(Q)]
# print(X)
# print(C)

for p, q in query:
    ans = 0
    for i, line in enumerate(C):
        if p-1 <= i and i <= q-1:
            ans += line[q] - line[p-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import bisect
import numpy as np

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

trains = [list(map(int, input().split())) for _ in range(M)]
trains = np.array(sorted(trains, key=itemgetter(0)))
query = [map(int, input().split()) for _ in range(Q)]
bleft = bisect.bisect_left
bright = bisect.bisect_right
ans = []
for p, q in query:
    li = bleft(trains[:, 0].ravel(), p)
    # print(trains[:li])
    tmpTrains = sorted(trains[li:, 1].ravel())
    ri = bright(tmpTrains, q)
    ans.append(ri)
print("\n".join(map(str, ans)))


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


for _ in range(M):
    l, r = list(map(int, input().split()))
    X[l-1][r-1] += 1
C = []
for line in X:
    tmp = [0, ]
    for c in line:
        tmp.append(tmp[-1] + c)
    C.append(tmp)
query = [map(int, input().split()) for _ in range(Q)]
# print(X)
# print(C)

for p, q in query:
    ans = 0
    for i, line in enumerate(C):
        if p-1 <= i and i <= q-1:
            ans += line[q] - line[p-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import bisect
import numpy as np
N, M, Q = map(int, input().split())

trains = [list(map(int, input().split())) for _ in range(M)]
trains = np.array(sorted(trains, key=itemgetter(0)))
query = [map(int, input().split()) for _ in range(Q)]
bleft = bisect.bisect_left
bright = bisect.bisect_right
for p, q in query:
    li = bleft(trains[:, 0].ravel(), p)
    #print(trains[:li])
    tmpTrains = np.array(sorted(trains[li:, 1].ravel()))
    ri = bright(tmpTrains, q)
    print(ri)


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


for _ in range(M):
    l, r = list(map(int, input().split()))
    X[l-1][r-1] += 1
C = []
for line in X:
    tmp = [0, ]
    for c in line:
        tmp.append(tmp[-1] + c)
    C.append(tmp)
query = [map(int, input().split()) for _ in range(Q)]
# print(X)
# print(C)

for p, q in query:
    ans = 0
    for i, line in enumerate(C):
        if p-1 <= i and i <= q-1:
            ans += line[q] - line[p-1]
    print(ans)