Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p, q])

ar = np.zeros([N, N])
for i in range(M):
    l, r = LR[i][0], LR[i][1]
    ar[l - 1][r - 1] += 1
for i in range(Q):
    p, q = PQ[i][0]-1, PQ[i][1]
    print(int(ar[p:q, p:q].sum()))

Fixed submission:
import numpy as np
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p, q])
ar_sec = np.zeros([N, N])
for i in range(M):
    l, r = LR[i][0], LR[i][1]
    ar_sec[l-1][r-1] += 1


ar_sum = np.zeros([N+1, N+1])
for i in range(N):
    for j in range(N):
        ar_sum[i+1][j+1] = ar_sum[i][j+1]+ar_sum[i+1][j]-ar_sum[i][j]+ar_sec[i][j]

for i in range(Q):
    p, q = PQ[i][0], PQ[i][1]
    print(int(ar_sum[q][q]-ar_sum[p-1][q]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
def main():
    N, M, Q = map(int, input().split())
    LR = []
    for i in range(M):
        l, r = map(int, input().split())
        LR.append([l-1, r])
    PQ = []
    for i in range(Q):
        p, q = map(int, input().split())
        PQ.append([p-1, q-1])
    ar = np.zeros([M, N])
    for m in range(M):
        ar[m, LR[m][0]:LR[m][1]] = 1
    flags_start = [np.ones(M, dtype=np.bool)]
    flags_end = []
    for i in range(1, N):
        flags_start.append((ar[:, :i].max(axis=1)==0))# * (ar[:, i:].max(axis=1)==1))
        flags_end.append((ar[:, i:].max(axis=1)==0))# * (ar[:, :i].max(axis=1)==1))
    flags_end.append(np.ones(M, dtype=np.bool))
    for q in range(Q):
        left = PQ[q][0]
        right = PQ[q][1]
        print(sum(flags_start[left] * flags_end[right]))

if __name__=='__main__':
    main()

Fixed submission:
import numpy as np
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p, q])
ar_sec = np.zeros([N, N])
for i in range(M):
    l, r = LR[i][0], LR[i][1]
    ar_sec[l-1][r-1] += 1


ar_sum = np.zeros([N+1, N+1])
for i in range(N):
    for j in range(N):
        ar_sum[i+1][j+1] = ar_sum[i][j+1]+ar_sum[i+1][j]-ar_sum[i][j]+ar_sec[i][j]

for i in range(Q):
    p, q = PQ[i][0], PQ[i][1]
    print(int(ar_sum[q][q]-ar_sum[p-1][q]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l-1, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p-1, q-1])
    

import numpy as np
ar = np.zeros([M, N])
for m in range(M):
    ar[m, LR[m][0]:LR[m][1]] = 1
flags_start = [np.ones(M, dtype=np.bool)]
flags_end = []
for i in range(1, N):
    flags_start.append((ar[:, :i].max(axis=1)==0))# * (ar[:, i:].max(axis=1)==1))
    flags_end.append((ar[:, i:].max(axis=1)==0))# * (ar[:, :i].max(axis=1)==1))
flags_end.append(np.ones(M, dtype=np.bool))
for q in range(Q):
    left = PQ[q][0]
    right = PQ[q][1]
    print(sum(flags_start[left] * flags_end[right]))


Fixed submission:
import numpy as np
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p, q])
ar_sec = np.zeros([N, N])
for i in range(M):
    l, r = LR[i][0], LR[i][1]
    ar_sec[l-1][r-1] += 1


ar_sum = np.zeros([N+1, N+1])
for i in range(N):
    for j in range(N):
        ar_sum[i+1][j+1] = ar_sum[i][j+1]+ar_sum[i+1][j]-ar_sum[i][j]+ar_sec[i][j]

for i in range(Q):
    p, q = PQ[i][0], PQ[i][1]
    print(int(ar_sum[q][q]-ar_sum[p-1][q]))

Buggy python submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l-1, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p-1, q-1])


import numpy as np
ar = np.zeros([M, N])
for m in range(M):
    ar[m, LR[m][0]:LR[m][1]] = 1

for q in range(Q):
    left = PQ[q][0]
    right = PQ[q][1]
    if left != 0 and right!=9:
        flag = (ar[:, left-1] == 0)* (ar[:, right+1] == 0) * (ar[:, left:right+1].max(axis=1) > 0)
        print(sum(flag))
    elif left == 0 and right!=9:
        flag = (ar[:, right+1] == 0) * (ar[:, left:right+1].max(axis=1) > 0)
        print(sum(flag))
    elif left != 0 and right==9:
        flag = (ar[:, left-1] == 0) * (ar[:, left:right+1].max(axis=1) > 0)
        print(sum(flag))
    else:
        print(M)


Fixed submission:
import numpy as np
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p, q])
ar_sec = np.zeros([N, N])
for i in range(M):
    l, r = LR[i][0], LR[i][1]
    ar_sec[l-1][r-1] += 1


ar_sum = np.zeros([N+1, N+1])
for i in range(N):
    for j in range(N):
        ar_sum[i+1][j+1] = ar_sum[i][j+1]+ar_sum[i+1][j]-ar_sum[i][j]+ar_sec[i][j]

for i in range(Q):
    p, q = PQ[i][0], PQ[i][1]
    print(int(ar_sum[q][q]-ar_sum[p-1][q]))