Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
memo = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    l,r = map(int,input().split())
    memo[l-1][r-1] += 1
for i in range(N):
    for j in range(N):
        if i < j:
            memo[i][j] += memo[i][j-1] + sum(memo[j-k][j] for k in range(j-i))
for i in range(Q):
    p,q = map(int,input().split())
    print(memo[p-1][q-1])

Fixed submission:
N,M,Q = map(int,input().split())
memo = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    memo[l][r] += 1
for i in range(N):
    for j in range(N):
        memo[i+1][j+1] += memo[i][j+1] + memo[i+1][j] - memo[i][j]
for i in range(Q):
    p,q = map(int,input().split())
    print(memo[q][q] - memo[p-1][q] - memo[q][p-1] + memo[p-1][p-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
Exp = [list(map(int,input().split())) for i in range(M)]
Exp.sort()
memo = [[0 for i in range(N)] for j in range(N)]
for e in Exp:
    memo[e[0]-1][e[1]-1] += 1
for i in range(N):
    for j in range(N):
        if i < j:
            memo[i][j] += memo[i][j-1] + sum(memo[j-k][j] for k in range(j-i))
Query = [list(map(int,input().split())) for i in range(Q)]
for q in Query:
    print(memo[q[0]-1][q[1]-1])

Fixed submission:
N,M,Q = map(int,input().split())
memo = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    memo[l][r] += 1
for i in range(N):
    for j in range(N):
        memo[i+1][j+1] += memo[i][j+1] + memo[i+1][j] - memo[i][j]
for i in range(Q):
    p,q = map(int,input().split())
    print(memo[q][q] - memo[p-1][q] - memo[q][p-1] + memo[p-1][p-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
Exp = [list(map(int,input().split())) for i in range(M)]
Exp.sort()
memo = [[0 for i in range(N)] for j in range(N)]
for e in Exp:
    for i in range(e[0]):
        for j in range(N-e[1]+1):
            memo[i][e[1]+j-1] += 1
Query = [list(map(int,input().split())) for i in range(Q)]
for q in Query:
    print(memo[q[0]-1][q[1]-1])

Fixed submission:
N,M,Q = map(int,input().split())
memo = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    memo[l][r] += 1
for i in range(N):
    for j in range(N):
        memo[i+1][j+1] += memo[i][j+1] + memo[i+1][j] - memo[i][j]
for i in range(Q):
    p,q = map(int,input().split())
    print(memo[q][q] - memo[p-1][q] - memo[q][p-1] + memo[p-1][p-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
Exp = [list(map(int,input().split())) for i in range(M)]
Query = [list(map(int,input().split())) for i in range(Q)]
for q in Query:
    ans = 0
    for e in Exp:
        if q[0] <= e[0] and e[1] <= q[1]:
            ans += 1
    print(ans)

Fixed submission:
N,M,Q = map(int,input().split())
memo = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    memo[l][r] += 1
for i in range(N):
    for j in range(N):
        memo[i+1][j+1] += memo[i][j+1] + memo[i+1][j] - memo[i][j]
for i in range(Q):
    p,q = map(int,input().split())
    print(memo[q][q] - memo[p-1][q] - memo[q][p-1] + memo[p-1][p-1])