Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
C = {i:{} for i in range(1,N+1)}
for _ in range(M):
    L,R = map(int,input().split())
    if L not in C[R]:
        C[R][L] = 0
    C[R][L] += 1
for _ in range(Q):
    p,q = map(int,input().split())
    A = {i:0 for i in range(1,N+1)}
    for i in range(1,q+1):
        for a in C[i]:
            A[a] += C[i][a]
    cnt = 0
    for a in range(p,N+1):
        cnt += A[a]
    print(cnt)

Fixed submission:
N,M,Q = map(int,input().split())
A = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L,R = map(int,input().split())
    A[L][R] += 1
B = [[0 for _ in range(N+2)] for _ in range(N+2)]
for i in range(N,0,-1):
    for j in range(1,N+1):
        B[i][j] = A[i][j]+B[i+1][j]+B[i][j-1]-B[i+1][j-1]
for _ in range(Q):
    p,q = map(int,input().split())
    print(B[p][q])

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
N,M,Q = map(int,input().split())
C = {i:[] for i in range(1,N+1)}
for _ in range(M):
    L,R = map(int,input().split())
    C[R].append(L)
for _ in range(Q):
    p,q = map(int,input().split())
    A = []
    for i in range(1,q+1):
        A += C[i]
    A = sorted(A)
    ind = bisect_left(A,p)
    print(len(A[ind:]))

Fixed submission:
N,M,Q = map(int,input().split())
A = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L,R = map(int,input().split())
    A[L][R] += 1
B = [[0 for _ in range(N+2)] for _ in range(N+2)]
for i in range(N,0,-1):
    for j in range(1,N+1):
        B[i][j] = A[i][j]+B[i+1][j]+B[i][j-1]-B[i+1][j-1]
for _ in range(Q):
    p,q = map(int,input().split())
    print(B[p][q])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N,M,Q = map(int,input().split())
I = {}
for _ in range(M):
    L,R = map(int,input().split())
    if L not in I:
        I[L] = []
    bisect.insort_right(I[L],R)
for x in I:
  I[x] = sorted(I[x])
A = sorted(list(I.keys()))
for _ in range(Q):
    p,q = map(int,input().split())
    indL = bisect.bisect_left(A,p)
    indR = bisect.bisect_right(A,q)
    cnt = 0
    for i in range(indL,indR):
        a = A[i]
        ind = bisect.bisect_right(I[a],q)
        cnt += ind
    print(cnt)

Fixed submission:
N,M,Q = map(int,input().split())
A = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L,R = map(int,input().split())
    A[L][R] += 1
B = [[0 for _ in range(N+2)] for _ in range(N+2)]
for i in range(N,0,-1):
    for j in range(1,N+1):
        B[i][j] = A[i][j]+B[i+1][j]+B[i][j-1]-B[i+1][j-1]
for _ in range(Q):
    p,q = map(int,input().split())
    print(B[p][q])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N,M,Q = map(int,input().split())
I = {}
for _ in range(M):
    L,R = map(int,input().split())
    if L not in I:
        I[L] = []
    I[L].append(R)
for x in I:
  I[x] = sorted(I[x])
A = sorted(list(I.keys()))
for _ in range(Q):
    p,q = map(int,input().split())
    indL = bisect.bisect_left(A,p)
    indR = bisect.bisect_right(A,q)
    cnt = 0
    for i in range(indL,indR):
        a = A[i]
        ind = bisect.bisect_right(I[a],q)
        cnt += ind
    print(cnt)

Fixed submission:
N,M,Q = map(int,input().split())
A = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L,R = map(int,input().split())
    A[L][R] += 1
B = [[0 for _ in range(N+2)] for _ in range(N+2)]
for i in range(N,0,-1):
    for j in range(1,N+1):
        B[i][j] = A[i][j]+B[i+1][j]+B[i][j-1]-B[i+1][j-1]
for _ in range(Q):
    p,q = map(int,input().split())
    print(B[p][q])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N,M,Q = map(int,input().split())
I = {}
for _ in range(M):
    L,R = map(int,input().split())
    if L not in I:
        I[L] = []
    I[L].append(R)
A = sorted(list(I.keys()))
for _ in range(Q):
    p,q = map(int,input().split())
    indL = bisect.bisect_left(A,p)
    indR = bisect.bisect_right(A,q)
    cnt = 0
    for i in range(indL,indR):
        for y in I[A[i]]:
            if y<=q:
                cnt += 1
    print(cnt)

Fixed submission:
N,M,Q = map(int,input().split())
A = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L,R = map(int,input().split())
    A[L][R] += 1
B = [[0 for _ in range(N+2)] for _ in range(N+2)]
for i in range(N,0,-1):
    for j in range(1,N+1):
        B[i][j] = A[i][j]+B[i+1][j]+B[i][j-1]-B[i+1][j-1]
for _ in range(Q):
    p,q = map(int,input().split())
    print(B[p][q])