CodeEff/ECCO huggingface dataset:
# Original solution
n,m,q = list(map(int,input().split()))

lr = [[0 for i in range(n+1)] for j in range(n+1)]
#lr = [[int(i) for i in input().split()]for j in range(m)]

st = [0] * (n+1)
ed = [0] * (n+1)

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

pq = [[int(i) for i in input().split()]for j in range(q)]

dp = [[0 for i in range(n+1)] for j in range(n+1)]

#print(lr)

for i in range(1,n+1):
    #print(i)
    for j in range(i,n+1):
        #print(i,j)
        dp[i][j] = dp[i][j-1]+lr[i][j]

for i in range(q):
    st = pq[i][0]
    ed = pq[i][1]
    tmp = 0
    for j in range(ed-st+1):
        tmp += dp[st+j][ed]
    print(tmp)
#print(dp)

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

lr = [[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()))
    lr[l][r] += 1

pq = [[int(i) for i in input().split()]for j in range(q)]

dp = [[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):
        dp[i][j] = dp[i][j-1]+lr[i][j]

ans_dp = [[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):
        tmp = 0
        for k in range(j-i+1):
            tmp += dp[i+k][j]
        ans_dp[i][j] = tmp

for i in range(q):
    print((ans_dp[pq[i][0]][pq[i][1]]))
# Original solution
N,M,Q=list(map(int,input().split()))
Town=[[int(i) for i in input().split()] for i in range(M)]
Town.sort(key=lambda x:x[0])

def BS_left(x,L,s):
  L_copy=L[:]
  left=0
  if L[s-1]<x:
    return s-1
  else:
    while s>2:
      if L_copy[s//2]<x:
        L_copy=L_copy[s//2:s]
        left+=s//2
        s=s-s//2
      else:
        L_copy=L_copy[0:s//2+1]
        s=s//2+1
    if L[left]>=x:
      return left-1
    else:
      return left

def BS_right(x,L,s):
  L_copy=L[:]
  right=s-1
  if L[0]>x:
    return 0
  else:
    while s>2:
      if L_copy[s//2]<=x:
        L_copy=L_copy[s//2:s]
        s=s-s//2
      else:
        L_copy=L_copy[0:s//2+1]
        right+=-s//2+1
        s=s//2+1
    if L[right]<=x:
      return right+1
    else:
      return right

ans=[0]*Q
for i in range(Q):
  p,q=list(map(int,input().split()))
  for i in zip(*Town):
    TownL=i
    break
  a=BS_left(p,TownL,M)+1
  newTown=Town[a:]
  if M-a==0:
    print((0))
  else:
    newTown.sort(key=lambda x:x[1])
    e=0
    for i in zip(*newTown):
      if e==0:
        e+=1
      else:
        TownR=i
        break
    b=BS_right(q,TownR,M-a)
    if b==1 and TownR[0]>q:
      print((0))
    else:
      print(b)


# Optimized solution
N,M,Q=list(map(int,input().split()))
Train=[[int(i) for i in input().split()] for i in range(M)]
Map=[[0]*(N+1) for i in range(N+1)]
for i in Train:
  x,y=i[0],i[1]
  Map[y][x]+=1
for a in range(1,N+1):
  for b in range(1,N+1):
    if b<=N-1:
      Map[a][b+1]=Map[a][b]+Map[a][b+1]
    if a>=2:
      Map[a][b]=Map[a-1][b]+Map[a][b]
for i in range(Q):
  p,q=list(map(int,input().split()))
  print((Map[q][q]-Map[q][p-1]-Map[p-1][q]+Map[p-1][p-1]))
# Original solution
N, M, Q = list(map(int, input().split()))
A = [[0] * N for _ in range(N)]
for _ in range(M):
    l, m = list(map(int, input().split()))
    A[l - 1][m - 1] += 1

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


D = []
for l in range(N):
    s = 0
    d = []
    for r in range(N):
        s += A[l][r]
        d.append(s)
    D.append(d)

for question in questions:
    print((sum([D[i][question[1]] for i in range(question[0], N)])))


# Optimized solution
N, M, Q = list(map(int, input().split()))
A = [[0] * N for _ in range(N)]
for _ in range(M):
    l, m = list(map(int, input().split()))
    A[l - 1][m - 1] += 1

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


D = []
for l in range(N):
    s = 0
    d = []
    for r in range(N):
        s += A[l][r]
        d.append(s)
    D.append(d)

T = []
for r in range(N):
    s = 0
    t = [0]
    for l in range(N):
        s += D[l][r]
        t.append(s)
    T.append(t)

for question in questions:
    print((T[question[1]][N] - T[question[1]][question[0]]))
# Original solution

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

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


D = []
for l in range(N):
    s = 0
    d = []
    for r in range(N):
        s += A[l][r]
        d.append(s)
    D.append(d)

for question in questions:
    print((sum([D[i][question[1]]
               for i in range(question[0], question[1] + 1)])))


# Optimized solution
N, M, Q = list(map(int, input().split()))
A = [[0] * N for _ in range(N)]
for _ in range(M):
    l, m = list(map(int, input().split()))
    A[l - 1][m - 1] += 1

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


D = []
for l in range(N):
    s = 0
    d = []
    for r in range(N):
        s += A[l][r]
        d.append(s)
    D.append(d)

T = []
for r in range(N):
    s = 0
    t = []
    for l in range(N):
        s += D[N - l - 1][r]
        t.append(s)
    T.append(t)

for question in questions:
    print((T[question[1]][N - question[0] - 1]))
# Original solution
n, m, Q = list(map(int, input().split()))

imos = [[0 for i in range(n)] for j in range(n)]

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

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

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

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


# Optimized solution
n, m, q = list(map(int, input().split()))
imos = [[0 for i in range(n)] for j in range(n)]

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

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

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

for i in range(q):
    l, r = list(map(int, input().split()))
    l -= 1
    r -= 1
    if l == 0:
        print((imos[r][r]))
    else:
        print((imos[r][r] - imos[l - 1][r] - imos[r][l - 1] + imos[l - 1][l - 1]))
# Original solution
#横にn個入力
n, m, q = list(map(int, input().split()))
#行列
s = []
for i in range(m):#h:高さ
    s.append([int(m) for m in input().split()] + [i])
# 行列
t = []
for i in range(q):  # h:高さ
    t.append([int(m) for m in input().split()])

lin = []
li0 = []
for i in range(n):
    lin.append(set())
    li0.append(set())
for i in range(m):
    lin[s[i][0] - 1].add(s[i][2])
    li0[s[i][1] - 1].add(s[i][2])
for i in range(n - 1):
    li0[i + 1] = li0[i + 1] | li0[i]
for i in range(n - 1, 0, -1):
    lin[i - 1] = lin[i] | lin[i - 1]
for i in range(q):
    ans = len(lin[t[i][0] - 1] & li0[t[i][1] - 1])
    print(ans)

# Optimized solution
#横にn個入力
n, m, q = list(map(int, input().split()))
#行列
s = []
for i in range(m):#h:高さ
    s.append([int(m) for m in input().split()] + [i])
# 行列
t = []
for i in range(q):  # h:高さ
    t.append([int(m) for m in input().split()])

LR = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for v in range(m):
     LR[s[v][0]][s[v][1]] += 1
for j in range(1, n + 1):
    for i in range(1, n + 1):#Lについての累積和
        LR[i][j] += LR[i - 1][j]

for k in range(q):
    tmp = 0
    for j in range(t[k][0], t[k][1] + 1):#Rについてみていく
        tmp += LR[t[k][1]][j] - LR[t[k][0] - 1][j]

    print(tmp)
# Original solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M, Q = MAP()
LR = [LIST() for _ in range(M)]
pq = [LIST() for _ in range(Q)]

x = [[0]*(N+1) for _ in range(N+1)]

for L, R in LR:
	x[L][R] += 1

for l in range(N+1):
	x[l] = list(accumulate(x[l]))
		
for p, q in pq:
	ans = 0
	for i in range(p, q+1):
		ans += x[i][q] - x[i][p-1]
	print(ans)




# Optimized solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M, Q = MAP()
LR = [LIST() for _ in range(M)]
pq = [LIST() for _ in range(Q)]

x = [[0]*(N+1) for _ in range(N+1)]

for L, R in LR:
	x[L][R] += 1

for l in range(N+1):
	x[l] = list(accumulate(x[l]))

for l in range(1, N+1):
	for r in range(N+1):
		x[l][r] += x[l-1][r]
		
for p, q in pq:
	print((x[q][q] - x[q][p-1] - x[p-1][q] + x[p-1][p-1]))
# Original solution
from bisect import bisect
n,m,q=(int(i) for i in input().strip().split(" "))
from collections import defaultdict
d=defaultdict(list)
for _ in range(m):
    a,b=(int(i) for i in input().strip().split(" "))
    d[a].append(b)
for i in list(d.keys()):
    d[i].sort()
for i in range(q):
    l,r=(int(i) for i in input().strip().split(" "))
    c=0
    for j in range(l,r+1):
        c+=bisect(d[j],r)
        c-=bisect(d[j],l-1)
    print(c)


# Optimized solution

n,m,q=(int(i) for i in input().strip().split(" "))
from collections import defaultdict
d=defaultdict(int)
for _ in range(m):
    a,b=(int(i) for i in input().strip().split(" "))
    d[(a,b)]+=1
for i in range(1,n+1):
    for j in range(1,n+1):
        d[(i,j)]+=d[(i,j-1)]

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

for i in range(q):
    l,r = (int(i) for i in input().strip().split(" "))
    print((d[(r,r)]+d[(l-1,l-1)]-d[(l-1,r)]-d[(r,l-1)]))
# Original solution
num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]
for i in range(0, num_train):
    start, arrive = [int(j) for j in input().split()]
    trains[start][arrive] += 1

#累積和表を作る
trains_cumulative_sum = [[0] * (num_city + 1) for i in range(0, num_city  + 1)]
for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        trains_cumulative_sum[start][arrive] = trains_cumulative_sum[start][arrive - 1] + trains[start][arrive]

for i in range(0, num_question):
    start, arrive = [int(j) for j in input().split()]
    result = 0
    for j in range(start, arrive + 1):
        result += trains_cumulative_sum[j][arrive]
    print(result)


# Optimized solution
num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]
for i in range(0, num_train):
    start, arrive = [int(j) for j in input().split()]
    trains[start][arrive] += 1

#累積和表を作る
cumlative_sum = [[0] * (num_city + 1) for i in range(0, num_city  + 1)]
for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] = cumlative_sum[start][arrive - 1] + trains[start][arrive]

for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] += cumlative_sum[start - 1][arrive]

for i in range(0, num_question):
    start, arrive = [int(j) for j in input().split()]
    result = cumlative_sum[arrive][arrive] - cumlative_sum[start - 1][arrive] - cumlative_sum[arrive][start - 1] + cumlative_sum[start - 1][start - 1]
    print(result)
# Original solution
N, M, Q = list(map(int,input().split()))
m =  [[0 for y in range(N+1)] for x in range(N+1)]
m2 =  [[0 for y in range(N+1)] for x in range(N+1)]

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

for i in range(1,N+1):
    s=m[i][i]
    m2[i][i]=s
    for j in range(i+1,N+1):
        for k in range(i,j+1):
            s+=m[k][j]
        m2[i][j]=s


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


# Optimized solution
N, M, Q = list(map(int,input().split()))
m =  [[0 for y in range(N+1)] for x in range(N+1)]
m2 =  [[0 for y in range(N+1)] for x in range(N+1)]
m3 =[[0 for y in range(N+1)] for x in range(N+1)]

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

for j in range(1, N+1):
    s=0
    for i in range(1, N+1):
        s+=m[i][j]
        m2[i][j]=s

for i in range(1, N+1):
    s=0
    for j in range(i, N+1):
        s+=m2[j][j]-m2[i-1][j]
        m3[i][j]=s

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

for i in range(q):
  left, right = list(map(int, input().split()))
  train_num = 0
  for j in range(left, right+1):
    for k in range(left, right+1):
      train_num += Arr[j][k]
  print(train_num)

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

B = []
for i in range(n+1):
  B_line = [0]
  for j in range(1, n+1):
    B_line.append(B_line[-1] + Arr[i][j])
  B.append(B_line)
#print(B)
  
for x in range(q):
  left, right = list(map(int, input().split()))
  train_num = 0
  for i in range(left, right+1):
    train_num += B[i][right] - B[i][left-1]
  print(train_num)
# Original solution
N, M, Q = list(map(int, input().split()))
Mi = [list(map(int, input().split())) for i in range(M)]
Qi = [list(map(int, input().split())) for i in range(Q)]
qi = [Qi[i].extend([0, i]) for i in range(Q)]
Mi.sort()
Qi.sort()

for mi in Mi:
    for i in range(Q):
        if mi[0] < Qi[i][0]:
            continue
        if mi[0] >= Qi[i][0] and mi[1] <= Qi[i][1]:
            Qi[i][2] += 1
Qi.sort(key=lambda x: x[3])
for a in Qi:
    print((a[2]))

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

# 二次元累積和をとる
LR_sum = [[0] * (N+1) for _ in range(N+1)]
LR_sum[1][1] = LR[1][1]
## 初期化
for i in range(1, N+1):
    LR_sum[1][i] = LR_sum[1][i-1] + LR[1][i]
    LR_sum[i][1] = LR_sum[i-1][1] + LR[i][1]
## 累積和をとる
for i in range(2, N+1):
    for j in range(2, N+1):
        LR_sum[i][j] = LR_sum[i-1][j] + LR_sum[i][j-1] - LR_sum[i-1][j-1] + LR[i][j]

for q in range(Q):
    l, r = list(map(int, input().split()))
    print((LR_sum[r][r] - LR_sum[r][l-1] - LR_sum[l-1][r] + LR_sum[l-1][l-1]))
# Original solution
N,M,Q = list(map(int, input().split()))

LR = [list(map(int, input().split())) for i in range(M)]
pq = [list(map(int, input().split())) for i in range(Q)]

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

def lsadd(L,R):
    L-=1
    R-=1
    for i in range(0,L+1):
        for j in range(R,N):    
            res[i][j] += 1

for l,r in LR:
    lsadd(l,r)

for p,q in pq:
    print((res[p-1][q-1]))


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

LR = [list(map(int, input().split())) for i in range(M)]
pq = [list(map(int, input().split())) for i in range(Q)]

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

def lsadd(L,R):
    L-=1
    R-=1
    for i in range(0,L+1):  
        res[i][R] += 1

for l,r in LR:
    lsadd(l,r)

for p,q in pq:
    print((sum(res[p-1][:q])))
# Original solution
from itertools import accumulate

n, m, q = list(map(int, input().split()))
rails = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = list(map(int, input().split()))
    rails[l - 1][r - 1] += 1
rails = [list(accumulate(s)) for s in rails]
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(*rails)]
buf = []
for _ in range(q):
    p, q = list(map(int, input().split()))
    buf.append(rails[q - 1][p - 1])
print(('\n'.join(map(str, buf))))


# Optimized solution
import sys
from itertools import accumulate

n, m, q = list(map(int, input().split()))
ipt = sys.stdin.readlines()
rails = [[0] * n for _ in range(n)]
for l, r in (list(map(int, line.split())) for line in ipt[:m]):
    rails[l - 1][r - 1] += 1
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(*(accumulate(s) for s in rails))]
print(('\n'.join(str(rails[q - 1][p - 1]) for p, q in (list(map(int, line.split())) for line in ipt[m:]))))
# Original solution
import sys
from itertools import accumulate

n, m, q = list(map(int, input().split()))
ipt = sys.stdin.readlines()
rails = [[0] * n for _ in range(n)]
for l, r in (list(map(int, line.split())) for line in ipt[:m]):
    rails[l - 1][r - 1] += 1
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(*(accumulate(s) for s in rails))]
print(('\n'.join(str(rails[q - 1][p - 1]) for p, q in (list(map(int, line.split())) for line in ipt[m:]))))


# Optimized solution
import sys
from itertools import accumulate, islice

n, m, q = list(map(int, input().split()))
ipt = (list(map(int, line.split())) for line in sys.stdin.readlines())
rails = [[0] * n for _ in range(n)]
for l, r in islice(ipt, m):
    rails[l - 1][r - 1] += 1
rails = [list(accumulate(reversed(s))) for s in zip(*(accumulate(s) for s in rails))]
print(('\n'.join(str(rails[q - 1][n - p]) for p, q in ipt)))
# Original solution
import sys
from itertools import accumulate, islice

n, m, q = list(map(int, input().split()))
ipt = (list(map(int, line.split())) for line in sys.stdin.readlines())
rails = [[0] * n for _ in range(n)]
for l, r in islice(ipt, m):
    rails[l - 1][r - 1] += 1
rails = [list(accumulate(reversed(s))) for s in zip(*(accumulate(s) for s in rails))]
print(('\n'.join(str(rails[q - 1][n - p]) for p, q in ipt)))


# Optimized solution
import sys
from itertools import accumulate, islice

n, m, q = list(map(int, input().split()))
ipt = (list(map(int, line.split())) for line in sys.stdin.readlines())
rails = [[0] * n for _ in range(n)]
for l, r in islice(ipt, m):
    rails[l - 1][r - 1] += 1
rails = [list(accumulate(reversed(s))) for s in zip(*(accumulate(s) for s in rails))]
print(('\n'.join(map(str, (rails[q - 1][n - p] for p, q in ipt)))))
# Original solution
import bisect
N,M,Q=list(map(int,input().split()))
Rli=[[] for _ in range(N)]
for i in range(M):
  l,r=list(map(int,input().split()))
  Rli[l-1].append(r)
for i in range(N):
  Rli[i].sort()
  
for i in range(Q):
  ans=0
  p,q=list(map(int,input().split()))
  for j in range(p-1,N):
    ans+=bisect.bisect_right(Rli[j],q)
  print(ans)

# Optimized solution
import bisect
N,M,Q=list(map(int,input().split()))
LR=[[0]*(N+1) for _ in range(N)]
for i in range(M):
  l,r=list(map(int,input().split()))
  LR[l-1][r]+=1
for i in range(N):
  for j in range(1,N+1):
    LR[i][j]+=LR[i][j-1]
  
for _ in range(Q):
  ans=0
  p,q=list(map(int,input().split()))
  for i in range(p-1,q):
    ans+=LR[i][q]-LR[i][p-1]
  print(ans)
# Original solution
# 累積和
# PyPy なら通る
N, M, Q = list(map(int, input().split()))

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

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

result = []
for _ in range(Q):
    p, q = list(map(int, input().split()))
    result.append(sum(t[i][q] - t[i][i - 1] for i in range(p, q + 1)))
print(('\n'.join(str(v) for v in result)))
#print(*result, sep='\n')


# Optimized solution
# 累積和
# PyPy なら通る
N, M, Q = map(int, input().split())

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

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

result = []
for _ in range(Q):
    p, q = map(int, input().split())
    result.append(sum(t[i][q] - t[i][i - 1] for i in range(p, q + 1)))
#print('\n'.join(str(v) for v in result))
print(*result, sep='\n')
# Original solution
from bisect import bisect_left

n,m,q=list(map(int,input().split())) #0-indexed
tree=[[] for i in range(n)]
lentree=[0]*n

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

for i in range(n):
  if tree[i]!=[]:
    tree[i].sort()


for i in range(n):
  lentree[i]+=len(tree[i])


for i in range(q):
  l,r=list(map(int,input().split()))
  l-=1
  r-=1
  ans=0

  for j in range(l,r+1):
    xxx=tree[j]
    ans+=bisect_left(xxx,r+1)

  print(ans)

# Optimized solution
import itertools

n,m,q=list(map(int,input().split())) #0-indexed

LR=[[0]*(n+1) for i in range(n+1)]

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

for i in range(n):
  LR[i]=list(itertools.accumulate(LR[i]))


for i in range(q):
  l,r=list(map(int,input().split()))
  ans=0
  for j in range(l,r+1):
    ans+=LR[j][r]-LR[j][l-1]

  print(ans)
# Original solution
# https://atcoder.jp/contests/abc106/tasks/abc106_d

'''
N が小さいので、N^2 を考えると良いことが分かる。
'''

from collections import defaultdict

N, M, Q = list(map(int, input().split()))        # N, M: リストの長さ

edges = [list(map(int, input().split())) for _ in range(M)]

data = defaultdict(int)                  # defaultdict は 初期化の際のに value の type を指定する必要あり

for i, j in edges:
    i -= 1
    j -= 1
    data[(i,j)] += 1

cum = [[0]*(N+1) for _ 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] + data[(i,j)]

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







# Optimized solution
N, M, Q = list(map(int, input().split()))
C = [[0]*N for _ in range(N)]
for _ in range(M):
    L, R = list(map(int, input().split()))
    C[L-1][R-1] += 1
S = [[0]*(N+1) for _ in range(N+1)]
for r in range(N):
    for l in reversed(list(range(N))):
        S[l][r] = S[l+1][r] + C[l][r]
D = [[0]*(N+1) for _ in range(N+1)]
for l in range(N):
    for r in range(N):
        D[l][r] = D[l][r-1] + S[l][r]
for _ in range(Q):
    p, q = list(map(int, input().split()))
    print((D[p-1][q-1]))