Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
LR = [[0 for x in range(N+1)] for y in range(N+1)]
for i in range(M):
    L,R = map(int,input().split())
    LR[L][R] += 1

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

pq = []
for i in range(Q):
    pq.append(list(map(int,input().split())))
for i in range(Q):
    p,q = pq[i]
    ans = 0
    for i in range(p,q+1):
        ans += LRsum[i][q] - LRsum[i][p-1]
    print(ans)


Fixed submission:
N,M,Q = map(int,input().split())
LR = [[0 for x in range(N+1)] for y in range(N+1)]
for i in range(M):
    L,R = map(int,input().split())
    LR[L][R] += 1

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

pq = []
for i in range(Q):
    pq.append(list(map(int,input().split())))
for i in range(Q):
    p,q = pq[i]
    ans = 0
    for i in range(p,q+1):
        ans += LRsum[i][q] - LRsum[i][p-1]
    print(ans)

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

N,M,Q = map(int,input().split())
LR = []
for i in range(M):
    L,R = map(int,input().split())
    LR.append((L,R))
LR = sorted(LR)
L = [t[0] for t in LR]
R = [t[1] for t in LR]
#print(LR)
pq = []
for i in range(Q):
    pq.append(list(map(int,input().split())))
for i in range(Q):
    p,q = pq[i]
    left = bisect.bisect_left(L,p)
    #print(left,M)
    #print(R[left:M])
    ans = len(list(filter(lambda t:t <= q, R[left:M])))
    print(ans)


Fixed submission:
N,M,Q = map(int,input().split())
LR = [[0 for x in range(N+1)] for y in range(N+1)]
for i in range(M):
    L,R = map(int,input().split())
    LR[L][R] += 1

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

pq = []
for i in range(Q):
    pq.append(list(map(int,input().split())))
for i in range(Q):
    p,q = pq[i]
    ans = 0
    for i in range(p,q+1):
        ans += LRsum[i][q] - LRsum[i][p-1]
    print(ans)

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

N,M,Q = map(int,input().split())
LR = []
for i in range(M):
    L,R = map(int,input().split())
    LR.append((L,R))
LR = sorted(LR)
L = [t[0] for t in LR]
R = [t[1] for t in LR]
#print(LR)
pq = []
for i in range(Q):
    pq.append(list(map(int,input().split())))
for i in range(Q):
    p,q = pq[i]
    left = bisect.bisect_left(L,p)
    #print(left,M)
    #print(R[left:M])
    ans = len(list(filter(lambda t:t <= q, R[left:M])))
    print(ans)


Fixed submission:
N,M,Q = map(int,input().split())
LR = [[0 for x in range(N+1)] for y in range(N+1)]
for i in range(M):
    L,R = map(int,input().split())
    LR[L][R] += 1

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

pq = []
for i in range(Q):
    pq.append(list(map(int,input().split())))
for i in range(Q):
    p,q = pq[i]
    ans = 0
    for i in range(p,q+1):
        ans += LRsum[i][q] - LRsum[i][p-1]
    print(ans)