CodeEff/ECCO huggingface dataset:
# Original solution
n, m, q = list(map(int, input().split()))
trnum = [[0 for _ in range(n+1)] for _ in range(n+1)]
cnum = [[0 for _ in range(n+1)] for _ in range(n+1)]
for _ in range(m):
  l, r = list(map(int, input().split()))
  trnum[l][r] += 1

for i in range(n+1):
  for j in range(n+1):
    cnum[i][j] = cnum[i][j-1] + trnum[i][j]

for _ in range(q):
  qp, qq = list(map(int, input().split()))
  s = 0
  for j in range(qp, qq+1):
    s += cnum[j][qq] - cnum[j][qp-1]
  print(s)


# Optimized solution
n, m, q = list(map(int, input().split()))
trnum = [[0 for _ in range(n+1)] for _ in range(n+1)]
cnum = [[0 for _ in range(n+1)] for _ in range(n+1)]
for _ in range(m):
  l, r = list(map(int, input().split()))
  trnum[l][r] += 1

for i in range(1, n+1):
  for j in range(1, n+1):
    trnum[i][j] += trnum[i][j-1]

for i in range(1, n+1):
  for j in range(1, n+1):
    trnum[i][j] += trnum[i-1][j]


for _ in range(q):
  l, r = list(map(int, input().split()))
  print((trnum[r][r] + trnum[l-1][l-1] - trnum[l-1][r] - trnum[r][l-1]))
# Original solution
N, M, Q = list(map(int, input().split()))
LR = [[0 for i in range(501)] for j in range(501)]
for i in range(M):
    L, R = list(map(int, input().split()))
    LR[L][R] += 1
LR2 = [[0 for i in range(501)] for j in range(501)]
for i in range(1, 501):
    for j in range(1, 501):
        LR2[i][j] = LR2[i][j - 1] + LR[i][j]
        
for i in range(Q):
    ans = 0
    p, q = list(map(int, input().split()))
    for i in range(p, q + 1):
        ans = ans + LR2[i][q] - LR2[i][p - 1]
    print(ans)


# Optimized solution
N, M, Q = list(map(int, input().split()))
LR = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    L, R = list(map(int, input().split()))
    LR[L - 1][R - 1] += 1

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

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


for i in range(Q):
    p, q = list(map(int, input().split()))
    p -= 2
    q -= 1
    if p != -1:
        ans = LR[q][q] - LR[q][p] - LR[p][q] + LR[p][p]
    elif p == -1:
        ans = LR[q][q]
    print(ans)
# Original solution
n,m,Q = list(map(int, input().split()))
train = []
for i in range(n):
  a = []
  for j in range(n):
    a.append(0)
  train.append(a)
  
for i in range(m):
  l,r = list(map(int, input().split()))
  train[l-1][r-1] += 1

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

  print(ans)


# Optimized solution
n,m,Q = list(map(int, input().split()))
train = []
for i in range(n):
  a = []
  for j in range(n):
    a.append(0)
  train.append(a)
  
for i in range(m):
  l,r = list(map(int, input().split()))
  train[l-1][r-1] += 1
cumsum = []
list1 = []
for i in range(n+1):
  list1.append(0)
cumsum.append(list1)
for i in range(n):
  lst = [0,cumsum[i][1]+train[i][0]]
  for j in range(1,n):
    lst.append(lst[j]+train[i][j]+(cumsum[i][j+1]-cumsum[i][j]))
  cumsum.append(lst)
for i in range(Q):
  p,q = list(map(int, input().split()))
  print((cumsum[q][q]-cumsum[p-1][q]-cumsum[q][p-1]+cumsum[p-1][p-1]))
# Original solution
import collections
import bisect
import copy
def main():

    N, M, Q = list(map(int, input().split()))
    train = []
    for _ in range(M):
        l, r = list(map(int, input().split()))
        train.append([l, r])
    train.sort()
    # print(train)

    end = []
    ends = []
    j = M-1
    for i in range(N, 0, -1):
        while j >= 0 and train[j][0] >= i:
            l, r = train[j]
            bisect.insort(end, r)
            j -= 1
        ends.append(copy.copy(end))
    ends.append([])
    ends = ends[::-1]
    # print(N)
    # print(ends)

    for _ in range(Q):
        p, q = list(map(int, input().split()))
        j = bisect.bisect_right(ends[p], q)
        print(j)

if __name__ == '__main__':
    main()

# Optimized solution
def main():

    N, M, Q = list(map(int, input().split()))
    train = [[0 for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        l, r = list(map(int, input().split()))
        train[l-1][r-1] += 1

    accum = [[0 for _ in range(N+1)]]
    for i in range(N):
        temp = [0]
        v = 0
        for j in range(N):
            v += train[i][j]
            temp.append(accum[-1][j+1]+v)
        accum.append(temp)
        # print(temp)

    for _ in range(Q):
        p, q = list(map(int, input().split()))
        v = accum[q][q] - accum[p-1][q] - accum[q][p-1] + accum[p-1][p-1]
        print(v)

if __name__ == '__main__':
    main()
# Original solution
N,M,Q = list(map(int,input().split()))

Section = [[0]*N for _ in range(N)]
for _ in range(M):
    L,R = list(map(int,input().split()))
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

Ans = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]

for _ in range(Q):
    p,q = list(map(int,input().split()))
    print((Ans[p-1][q-1]))

# Optimized solution
import sys
s = sys.stdin.readlines()
N,M,Q = list(map(int,s[0].split()))

Section = [[0]*N for _ in range(N)]
for L,R in (list(map(int, e.split())) for e in s[1:M+1]):
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

Ans = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]

for p,q in (list(map(int, e.split())) for e in s[M+1:]):
    print((Ans[p-1][q-1]))
# Original solution
import sys
s = sys.stdin.readlines()
N,M,Q = list(map(int,s[0].split()))

Section = [[0]*N for _ in range(N)]
for L,R in (list(map(int, e.split())) for e in s[1:M+1]):
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

Ans = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]

for p,q in (list(map(int, e.split())) for e in s[M+1:]):
    print((Ans[p-1][q-1]))

# Optimized solution
import sys
s = sys.stdin.readlines()

N,M,Q = list(map(int,s[0].split()))

Section = [[0]*N for _ in range(N)]
for L,R in (list(map(int, e.split())) for e in s[1:M+1]):
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

for p,q in (list(map(int, e.split())) for e in s[M+1:]):
    print((Sum[q][q]-Sum[p-1][q]))
# Original solution
n,m,q = list(map(int, input().split()))
mmap = [ [ 0 for j in range(n+1) ] for i in range(n+1) ]
for i in range(m):
  s,e = list(map(int, input().split()))
  mmap[s][e] += 1
for i in range(q):
  s,e = list(map(int, input().split()))
  cnt = 0
  for j in range(s,e+1):
    for k in range(s,e+1):
      cnt += mmap[j][k]
  print(cnt)

# Optimized solution
n,m,q = list(map(int, input().split()))
mmap = [ [ 0 for j in range(n+1) ] for i in range(n+1) ]
for i in range(m):
  s,e = list(map(int, input().split()))
  mmap[s][e] += 1
for i in range(n+1):
  for j in range(1,n+1):
    mmap[i][j] = mmap[i][j] + mmap[i][j-1]
for j in range(n+1):
  for i in range(n-1,0,-1):
    mmap[i][j] = mmap[i][j] + mmap[i+1][j]
for i in range(q):
  s,e = list(map(int, input().split()))
  print((mmap[s][e]))
# Original solution
# input
N, M, Q = list(map(int, input().split()))
Trains = [list(map(int, input().split())) for _ in range(M)]
Trains = sorted(Trains)
Questions = {}
for i in range(Q):
    Questions[i] = list(map(int, input().split()))

Questions = sorted(list(Questions.items()), key = lambda x: x[1])

Ans = [0 for _ in range(Q)]
left = 0

for i in range(Q):
    num = Questions[i][0]
    p = Questions[i][1][0]
    q = Questions[i][1][1]
    for j in range(left, M):
        if p <= Trains[j][0]:
            left = j
            for k in range(j, M):
                if q >= Trains[k][1]:
                    Ans[num] += 1
            break

for i in range(Q):
    print((Ans[i]))


# Optimized solution
# input
N, M, Q = list(map(int, input().split()))
train_query = {} # 対象区間とクエリを一緒にソート
for i in range(M + Q):
    train_query[i] = list(map(int, input().split()))

train_query = sorted(list(train_query.items()), key=lambda x: x[1][1])
# 辞書をソートするとリストが返ってくることに注意

StartPoints = [0 for _ in range(N)] # 対象区間の開始位置
ans = [0 for _ in range(Q)] # 各クエリに対する答え

for j in range(M + Q):
    if train_query[j][0] < M: # 対象区間
        StartPoints[train_query[j][1][0] - 1] += 1
    else: # クエリ
        ans[train_query[j][0] - M] = sum(StartPoints[(train_query[j][1][0] - 1):(train_query[j][1][1])])

for i in range(Q):
    print((ans[i]))
# Original solution
n, m, q = list(map(int,input().split()))
ways = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r = list(map(int,input().split()))
    ways[l][r] += 1

sgways = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(i,n+1):
        for k in range(i,j+1):
            sgways[i][j] += ways[k][j]


ans = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(i,n+1):
        for k in range(i,j+1):
            ans[i][j] += sgways[i][k]
for i in range(q):
    pi,qi = list(map(int,input().split()))
    print((ans[pi][qi]))


# Optimized solution
n, m, q = list(map(int,input().split()))
ways = [[0 for i in range(n+2)] for j in range(n+2)]
for i in range(m):
    l,r = list(map(int,input().split()))
    ways[l][r] += 1

sgways = [[0 for i in range(n+2)] for j in range(n+2)]
for j in range(1,n+1):
    for i in range(j):
        sgways[j-i][j] = sgways[j-i+1][j] +ways[j-i][j]

ans = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(i,n+1):
        ans[i][j] = ans[i][j-1]+sgways[i][j]
for i in range(q):
    pi,qi = list(map(int,input().split()))
    print((ans[pi][qi]))
# Original solution
N, M, Q = list(map(int, input().split()))
LR = [list(map(int, input().split())) for _ in range(M)]
pq = [list(map(int, input().split())) for _ in range(Q)]

XY = [[0 for _ in range(N)] for _ in range(N)]
for l, r in LR:
    XY[l - 1][r - 1] += 1

for i in range(N):
    for j in range(N - 1):
        XY[i][j + 1] += XY[i][j]

for p, q in pq:
    count = 0
    for i in range(p - 1, q):
        if p - 2 >= 0:
            count += XY[i][q - 1] - XY[i][p - 2]
        else:
            count += XY[i][q - 1] - 0
    print(count)


# Optimized solution
N, M, Q = list(map(int, input().split()))
LR = [list(map(int, input().split())) for _ in range(M)]
pq = [list(map(int, input().split())) for _ in range(Q)]

XY = [[0 for _ in range(N)] for _ in range(N)]
for l, r in LR:
    XY[l - 1][r - 1] += 1

for i in range(N):
    for j in range(N):
        if i == 0 and j == 0:
            pass
        elif i == 0:
            XY[i][j] += XY[i][j - 1]
        elif j == 0:
            XY[i][j] += XY[i - 1][j]
            pre_im1_j = XY[i - 1][j]
        else:
            if XY[i - 1][j] == pre_im1_j:
                XY[i][j] += XY[i][j - 1]
            else:
                XY[i][j] += XY[i][j - 1] + XY[i - 1][j] - pre_im1_j
                pre_im1_j = XY[i - 1][j]

for p, q in pq:
    if p != 1:
        print((XY[q - 1][q - 1] + XY[p - 2][p - 2] - XY[p - 2][q - 1] - XY[q - 1][p - 2]))
    else:
        print((XY[q - 1][q - 1]))
# Original solution
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M, Q = na()
dp = [[0] * (N + 3) for _ in range(N + 3)]
for i in range(M):
    l, r = na()
    for x in range(1, l+1):
        for y in range(r, N+1):
            dp[x][y] += 1

for i in range(Q):
    p, q = na()
    print((dp[p][q]))


# Optimized solution
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M, Q = na()
dp = [[0] * (N + 3) for _ in range(N + 3)]
for i in range(M):
    l, r = na()
    dp[1][r] += 1
    dp[l+1][r] -= 1
    dp[l][N+1] -= 1

for i in range(N+1):
    for j in range(N+1):
        dp[i][j+1] += dp[i][j]

for j in range(N+1):
    for i in range(N+1):
        dp[i+1][j] += dp[i][j]

for i in range(Q):
    p, q = na()
    print((dp[p][q]))
# Original solution
n, m, q = list(map(int, input().split()))

x = [[0]*n for _ in range(n)]

for i in range(m):
  l, r = list(map(int, input().split()))
  l, r = l-1, r-1
  x[l][r] += 1
  
s = [[0]*(n+1) for _ in range(n+1)]
for i in range(n):
  for j in range(n):
    s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + x[i][j]

for _ in range(q):
  a, b = list(map(int, input().split()))
  a, b = a-1, b-1
  print((s[b+1][b+1] - s[b+1][a] - s[a][b+1] + s[a][a]))

# Optimized solution
n, m, q = list(map(int, input().split()))

A = [[0]*n for i in range(n)]

for i in range(m):
    l, r = list(map(int, input().split()))
    l, r = l-1, r-1
    A[l][r] += 1

#print(A)

s = [[0]*(n+1) for _ in range(n+1)]
for i in range(n):
  for j in range(n):
    s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + A[i][j]

#print(s)

for i in range(q):
    p, q = list(map(int, input().split()))
    p, q = p-1, q-1
    ans = s[q+1][q+1] - s[p][q+1] - s[q+1][p] + s[p][p]
    print(ans)
# Original solution
from itertools import accumulate
N, M, Q = list(map(int, input().split()))
D = [[0] * (N + 1) for i in range(N + 1)]
for _ in range(M):
    L, R = list(map(int, input().split()))
    D[L][R] += 1
for i in range(N - 1, 0, -1):
    for j in range(1, N + 1):
        D[i][j] += D[i + 1][j]
for i in range(1, N + 1):
    D[i] = list(accumulate(D[i]))
for _ in range(Q):
    p, q = list(map(int, input().split()))
    print((D[p][q]))

# Optimized solution
from sys import stdin
from itertools import accumulate
input = stdin.readline
N, M, Q = list(map(int, input().split()))
D = [[0] * (N + 1) for i in range(N + 1)]
for _ in range(M):
    L, R = list(map(int, input().split()))
    D[L][R] += 1
for i in range(N - 1, 0, -1):
    for j in range(i, N + 1):
        D[i][j] += D[i + 1][j]
for i in range(1, N + 1):
    D[i] = list(accumulate(D[i]))
for _ in range(Q):
    p, q = list(map(int, input().split()))
    print((D[p][q]))
# Original solution
import sys
input = sys.stdin.readline

N, M, Q = [int(x) for x in input().split()]
L = [0] * M
R = [0] * M
p = [0] * Q
q = [0] * Q
for i in range(M):
    L[i], R[i] = [int(x) for x in input().split()]
for j in range(Q):
    p[j], q[j] = [int(x) for x in input().split()]

train = [[0 for i in range(N + 1)] for _ in range(N + 1)]
seg = [[0 for i in range(N + 1)] for _ in range(N + 2)]

for i in range(M): # すべての列車について
    train[L[i]][R[i]] += 1

for col in range(1, N + 1):
    for row in range(col, 0, -1):
        seg[row][col] = train[row][col] + seg[row][col - 1] + seg[row + 1][col] - seg[row + 1][col - 1]

for j in range(Q):
    print((seg[p[j]][q[j]]))


# Optimized solution
import sys
input = sys.stdin.readline

N, M, Q = [int(x) for x in input().split()]
L = [0] * M
R = [0] * M
p = [0] * Q
q = [0] * Q
for i in range(M):
    L[i], R[i] = [int(x) for x in input().split()]
for j in range(Q):
    p[j], q[j] = [int(x) for x in input().split()]

train = [[0 for i in range(N + 1)] for _ in range(N + 2)]

for i in range(M): # すべての列車について
    train[L[i]][R[i]] += 1

for col in range(1, N + 1):
    for row in range(col, 0, -1):
        train[row][col] += train[row][col - 1] + train[row + 1][col] - train[row + 1][col - 1]

for j in range(Q):
    print((train[p[j]][q[j]]))
# Original solution
N, M, Q = list(map( int, input().split()))
NN = [ [ 0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L, R = list(map( int, input().split()))
    NN[L][R] += 1
Sum = [ [ 0 ] for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,N+1):
        Sum[i].append(Sum[i][-1]+NN[i][j])
for _ in range(Q):
    p, q = list(map(int, input().split()))
    ans = 0
    for i in range(p,q+1):
        ans += Sum[i][q] - Sum[i][p-1]
    print(ans)

# Optimized solution
N, M, Q = list(map( int, input().split()))
NN = [ [0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L, R = list(map( int, input().split()))
    NN[L][R] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        NN[i][j] += NN[i][j-1]+NN[i-1][j]-NN[i-1][j-1]
for _ in range(Q):
    p, q = list(map( int, input().split()))
    print((NN[q][q]-NN[q][p-1]-NN[p-1][q]+NN[p-1][p-1]))
# Original solution
N,M,Q = list(map(int,input().split()))

station = [[0]*N for i in range(N)]

for i in range(M):
    L,R = list(map(int,input().split()))
    station[L-1][R-1] += 1

DP = [[0]*(N) for i in range(N)]

for i in range(N):
    for j in range(N):
        for a in range(i,j+1):
            for b in range(i,j+1):
                DP[i][j] += station[a][b]

for i in range(Q):
    p,q = list(map(int,input().split()))
    print((DP[p-1][q-1]))

# Optimized solution
N,M,Q = list(map(int,input().split()))

station = [[0]*(N+1) for i in range(N+1)]

for i in range(M):
    l,r = list(map(int,input().split()))
    station[l][r] += 1

DP = [[0]*(N+1) for i in range(N+1)]

for i in range(N+1):
    for j in range(N):
        DP[i][j+1] = DP[i][j] + station[i][j+1]

for i in range(Q):
    p,q = list(map(int,input().split()))
    ans = 0
    for i in range(p,q+1):
        ans += DP[i][q] - DP[i][p-1]
    print(ans)
# Original solution
n, m, q = list(map(int, input().split()))
tr = []
for i in range(m):
    l, r = list(map(int, input().split()))
    tr.append((l, r))

qu = []
for i in range(q):
    p, q = list(map(int, input().split()))
    qu.append((p, q))
    print((len(list([s for s in tr if p <= s[0] and s[1] <= q]))))

# Optimized solution
n, m, q = list(map(int, input().split()))
T = [[0] * n for i in range(n)]
for i in range(m):
    l, r = list(map(int, input().split()))
    T[l - 1][r - 1] += 1

for i in range(n):
    for j in range(1, n):
        T[i][j] += T[i][j - 1]

for j in range(n):
    for i in range(n - 2, -1, -1):
        T[i][j] += T[i + 1][j]

for i in range(q):
    p, q = list(map(int, input().split()))
    print((T[p - 1][q - 1]))
# Original solution
from copy import deepcopy

n, m, q = list(map(int, input().split()))
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

cnt = [[0] * (n + 1) for _ in range(n + 1)]
for l, r in lr:
    cnt[l][r] += 1

acc = deepcopy(cnt)
for i in range(n):
    for j in range(n):
        tmp = acc[i][j + 1] + acc[i + 1][j] - acc[i][j]
        acc[i + 1][j + 1] += tmp

for p, q in pq:
    p -= 1
    ans = acc[q][q] - acc[p][q] - acc[q][p] + acc[p][p]
    print(ans)


# Optimized solution
n, m, q = list(map(int, input().split()))
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

acc = [[0] * (n + 1) for _ in range(n + 1)]
for l, r in lr:
    acc[l][r] += 1
for i in range(n):
    for j in range(n):
        tmp = acc[i][j + 1] + acc[i + 1][j] - acc[i][j]
        acc[i + 1][j + 1] += tmp

for p, q in pq:
    p -= 1
    ans = acc[q][q] - acc[p][q] - acc[q][p] + acc[p][p]
    print(ans)
# Original solution
N, M, Q = list(map(int, input().split()))

X = [[0 for j in range(510)] for i in range(510)]
C = [[0 for j in range(510)] for i in range(510)]

LR = []
for i in range(M):
    L, R = list(map(int, input().split()))
    X[L][R] += 1

for i in range(1, N+1):
    for j in range(1, N+1):
        C[i][j] = C[i][j-1]+X[i][j]


for i in range(Q):
    p, q = list(map(int, input().split()))
    sum = 0
    for j in range(p, q+1):
        sum += C[j][q]-C[j][p-1]
    print(sum)


# Optimized solution
N, M, Q = list(map(int, input().split()))

# 入力
A = [[0 for j in range(N+1)] for i in range(N+1)]
for _ in range(M):
    L, R = list(map(int, input().split()))
    A[L][R] += 1


# 二次元累積和
Cum = [[0 for j in range(N+1)] for i in range(N+1)]
for i in range(N):
    for j in range(N):
        Cum[i+1][j+1] = Cum[i][j+1] + Cum[i+1][j] - Cum[i][j] + A[i+1][j+1]

# クエリ処理
for _ in range(Q):
    p, q = list(map(int, input().split()))
    print((Cum[q][q]-Cum[p-1][q]-Cum[q][p-1]+Cum[p-1][p-1]))
# Original solution
n,m,q=list(map(int,input().split()))
g=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    g[a][b]+=1
r=[[0 for i in range(n+1)] for j in range(n)]
for i in range(n):
    for j in range(1,n+1):
        r[i][j]=r[i][j-1]+g[i][j-1]
for i in range(q):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    ans=0
    for i in range(a,b+1):
        ans+=r[i][b+1]-r[i][a]
    print(ans)


# Optimized solution
n,m,q=list(map(int,input().split()))
g=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    a,b=list(map(int,input().split()))
    #a-=1
    #b-=1
    g[a][b]+=1
    
for i in range(n):
    for j in range(n+1):
        g[i+1][j]+=g[i][j]
for i in range(n+1):
    for j in range(n):
        g[i][j+1]+=g[i][j]
for i in range(q):
    a,b=list(map(int,input().split()))
    a-=1
    print((g[b][b]+g[a][a]-g[a][b]-g[b][a]))
#print(g)
# Original solution
n, m, Q = list(map(int, input().split()))
LR = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l, r = list(map(int, input().split()))
    LR[l-1][r-1] += 1

# 各Lについて累積和を取る
LR_rui = [[0] for _ in range(n)]
for i in range(n):
    for j in range(n):
        LR_rui[i].append(LR[i][j]+LR_rui[i][-1])

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



# Optimized solution
n, m, Q = list(map(int, input().split()))
LR = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l, r = list(map(int, input().split()))
    LR[l-1][r-1] += 1

# 二次元累積和の作成
LR_rui = [[0 for _ in range(n+1)] for _ in range(n+1)]
# 各Lについての累積
for i in range(n):
    for j in range(n):
        LR_rui[i+1][j+1] = LR_rui[i+1][j]+LR[i][j]
# 各Rについての累積:
for i in range(n):
    for j in range(n):
        LR_rui[i+1][j+1] = LR_rui[i+1][j+1] + LR_rui[i][j+1]

for _ in range(Q):
    p, q = list(map(int, input().split()))
    ans = LR_rui[q][q] - LR_rui[p-1][q] - LR_rui[q][p-1] + LR_rui[p-1][p-1]
    print(ans)