CodeEff/ECCO huggingface dataset:
# Original solution
N, M, Q = list(map(int, input().split()))

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

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

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

# 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)]

acc = [[0 for i in range(N+1)] for i in range(N+1)]  # acc[i][j] = i以下からスタートしてj以下で終了する電車の数
coordinate = [[0 for i in range(N)] for i in range(N)]
for l, r in LR:
    l -= 1
    r -= 1
    coordinate[l][r] += 1

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

for p, q in PQ:
    p -= 1
    ans = acc[N][q] - acc[p][q]
    print(ans)
# Original solution
from bisect import bisect

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

G = [[] for _ in range(N+1)]

for _ in range(M):
  L, R = list(map(int, input().split()))
  G[L].append(R)

for i in range(N+1):
  G[i].sort()

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

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

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

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

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

for _ in range(Q):
  p, q = list(map(int, input().split()))
  ans = 0
  for i in range(p, q+1):
    ans += G[i][q]
  print(ans)
# Original solution
N, M, Q = list(map(int, input().split()))
city = [[0] * (N+1) for i in range(N+1)]
for i in range(M):
  l, r = list(map(int, input().split()))
  city[l][r] += 1

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

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

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

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

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

for i in range(Q):
  p, q = list(map(int, input().split()))
  print((city[q][q] - city[p-1][q] - city[q][p-1] + city[p-1][p-1]))
# Original solution
from operator import itemgetter

N, M, Q = list(map(int, input().split()))
LR = sorted([list(map(int, input().split())) for i in range(M)], key=itemgetter(0))

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

for l in range(1, N+1):
    flag = [1 for i in range(len(LR))]
    for r in range(1, N+1):
        count = 0
        for idx, lr in enumerate(LR):
            if flag[idx] and l <= lr[0] and lr[1] <= r:
                count += 1
                flag[idx] = 0
        route[l][r] = route[l][r-1] + count
        
    while len(LR):
        if LR[0][0] == l:
            LR.pop(0)
        else:
            break
for i in range(Q):
    p, q = list(map(int, input().split()))
    print((route[p][q]))
    
                

# Optimized solution
import itertools

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

route = [[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()))
    route[L][R] += 1

for i in range(1, N):
    route[i] = list(itertools.accumulate(route[i]))

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

for i in range(Q):
    p, q = list(map(int, input().split()))
    print((route[q][q]-route[p-1][q]-route[q][p-1]+route[p-1][p-1]))
# Original solution
I=lambda:list(map(int,input().split()))
n,m,q=I()
k=n+2
l=[0]*k**2
for _ in range(m):
  s,g=I()
  l[s*k+g]+=1
for i in range(1,n+1):
  for j in range(1,n+1):
    l[i*k+j]+=l[i*k+j-1]
for i in range(1,n+1):
  for j in range(1,n+1):
    l[i*k+j]+=l[(i-1)*k+j]
for _ in range(q):
  s,g=I()
  print((l[g*k+g]-l[(s-1)*k+g]-l[g*k+s-1]+l[(s-1)*k+s-1]))

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

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

arr = [[0 for j in range(n)] for i in range(n)]
arr_sum = [[0 for j in range(n)] for i in range(n)]
arr_sum2 = [[0 for j in range(n)] for i in range(n)]

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

for i in range(n):
    for j in range(n):
        if i <= j:
            arr_sum[i][j] = sum(arr[i][:j+1])

for i in range(n):
    for j in range(n):
        if i <= j:
            for k in range(i,j+1):
                arr_sum2[i][j] += arr_sum[k][j]


ans_arr = []
for k in range(q):
    p, q = list(map(int, input().split()))
    ans = arr_sum2[p-1][q-1]
    ans_arr.append(ans)

for i in ans_arr:
    print(i)

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

arr = [[0 for j in range(n)] for i in range(n)]
arr_sum = []
arr_sum2 = []

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


for i in range(n):
    s = 0
    arr_tmp = []
    for j in range(n):
            s += arr[i][j]
            arr_tmp.append(s)
    arr_sum.append(arr_tmp)


for j in range(n):
    s = 0
    arr_tmp2 = []
    for i in range(n-1,-1,-1):
            s += arr_sum[i][j]
            arr_tmp2.append(s)
    arr_sum2.append(arr_tmp2)

arr_sum3 = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        arr_sum3[i][j] = arr_sum2[j][n-i-1]

ans_arr = []
for k in range(q):
    p, q = list(map(int, input().split()))
    ans = arr_sum3[p-1][q-1]
    ans_arr.append(ans)

for i in ans_arr:
    print(i)
# Original solution
N,M,Q = list(map(int,input().split()))
s = [[0 for j in range(501)] for i in range(501)]

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

# 二次元累積和
for i in range(1,501):
    for j in range(1,501):
        s[i][j] += s[i-1][j] + s[i][j-1] - s[i-1][j-1]

# クエリに対してO(1)で求める
for _ in range(Q):
    p,q = list(map(int,input().split()))
    print((s[q][q]-s[p-1][q]-s[q][p-1]+s[p-1][p-1]))


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

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


# 二次元累積和の計算
for i in range(N):
    for j in range(N):
        c_sum[i+1][j+1] += c_sum[i+1][j] + c_sum[i][j+1] - c_sum[i][j]

for _ in range(Q):
    p,q = list(map(int,input().split()))
    print((c_sum[q][q] - c_sum[p-1][q] - c_sum[q][p-1] + c_sum[p-1][p-1]))
# Original solution
N,M,Q = map(int,input().split())
src = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
src.sort(reverse=True)
qs = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(Q)]

q_arr = [[] for i in range(N)]
for i,(l,r) in enumerate(qs):
    q_arr[l].append((r,i))

bit = [0] * (N+2)
def bit_add(a,w):
    x = a
    while x <= N:
        bit[x] += w
        x += (x & -x)

def bit_sum(a):
    x = a
    ret = 0
    while x > 0:
        ret += bit[x]
        x -= (x & -x)
    return ret

ans = [None] * Q

last_l = N-1
for l,r in src:
    while last_l > l:
        for qr,qi in q_arr[last_l]:
            ans[qi] = bit_sum(qr+1)
        last_l -= 1
    bit_add(r+1, 1)
while last_l >= 0:
    for qr,qi in q_arr[last_l]:
        ans[qi] = bit_sum(qr+1)
    last_l -= 1

print(*ans, sep='\n')


# Optimized solution
N,M,Q = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]
qs = [tuple(map(int,input().split())) for i in range(Q)]

imos = [[0]*(N+1) for i in range(N+1)]
for l,r in src:
    imos[l][r] += 1
for i in range(N+1):
    for j in range(N):
        imos[i][j+1] += imos[i][j]
for i in range(N):
    for j in range(N+1):
        imos[i+1][j] += imos[i][j]

ans = []
for p,q in qs:
    ans.append(imos[q][q] - imos[q][p-1] - imos[p-1][q] + imos[p-1][p-1])
print(*ans, sep='\n')
# Original solution
N,M,Q = list(map(int,input().split()))
src = [tuple(map(int,input().split())) for i in range(M)]
qs = [tuple(map(int,input().split())) for i in range(Q)]

imos = [[0]*(N+1) for i in range(N+1)]
for l,r in src:
    imos[l][r] += 1

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

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

# Optimized solution
import sys
input = sys.stdin.readline
N,M,Q = map(int,input().split())
LR = [tuple(map(int,input().split())) for i in range(M)]
PQ = [tuple(map(int,input().split())) for i in range(Q)]

imos = [[0]*(N+1) for _ in range(N+1)]
for l,r in LR:
    imos[l][r] += 1
for i in range(N+1):
    for j in range(N):
        imos[i][j+1] += imos[i][j]
for j in range(N+1):
    for i in range(N):
        imos[i+1][j] += imos[i][j]

ans = []
for p,q in PQ:
    p -= 1
    a = imos[q][q] + imos[p][p] - imos[p][q] - imos[q][p]
    ans.append(a)
print(*ans, sep='\n')
# Original solution
def main():
    N, M, Q = list(map(int, input().split()))
    S = [[0] * (N+1) for _ in range(N+1)]
    for i in range(M):
        L, R = list(map(int, input().split()))
        S[L][R] += 1

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

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



main()

# Optimized solution
import sys
def input():
    return sys.stdin.readline()[:-1]

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

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

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



main()
# Original solution
from operator import itemgetter
import bisect

n, m, Q = list(map(int, input().split()))
train = [list(map(int, input().split())) + [i] for i in range(m)]
train_L = []
train_R = []
L_n = []
R_n = []
for i in sorted(train, key=itemgetter(0)):
    train_L.append(i[0])
    L_n.append(i[2])
for i in sorted(train, key=itemgetter(1)):
    train_R.append(i[1])
    R_n.append(i[2])
for i in range(Q):
    p, q = list(map(int, input().split()))
    p_set = set(L_n[bisect.bisect_left(train_L, p):])
    q_set = set(R_n[:bisect.bisect_right(train_R, q)])
    print((len(p_set & q_set)))

# Optimized solution
def getSumRange(L, R):
    ans = sum[R][R] - sum[R][L - 1] - sum[L - 1][R] + sum[L - 1][L - 1]
    return ans

n, m, Q = list(map(int, input().split()))
L = [0] * m
R = [0] * m
for i in range(m):
    L[i], R[i] = list(map(int, input().split()))
p = [0] * Q
q = [0] * Q
for i in range(Q):
    p[i], q[i] = list(map(int, input().split()))

sum = [[0] * (n + 1) for i in range(n + 1)]
for i in range(m):
    sum[L[i]][R[i]] += 1
for i in range(n + 1):
    for j in range(n + 1):
        sum[i][j] += sum[i - 1][j]
        sum[i][j] += sum[i][j - 1]
        sum[i][j] -= sum[i - 1][j - 1]

for i in range(Q):
    ans = getSumRange(p[i], q[i])
    print(ans)
# Original solution
from itertools import islice


def main():
    city_count, express_count, query_count = list(map(int, input().split()))

    city_list = [(set(), set()) for _ in range(city_count + 1)]

    for express_index in range(1, express_count + 1):
        l, r = list(map(int, input().split()))
        for city in islice(city_list, 1, l + 1):
            city[0].add(express_index)
        for city in islice(city_list, r, None):
            city[1].add(express_index)

    for _ in range(query_count):
        p, q = list(map(int, input().split()))
        city_p = city_list[p][0]
        city_q = city_list[q][1]
        print((len(city_p & city_q)))


if __name__ == '__main__':
    main()


# Optimized solution
from itertools import islice


def main():
    city_count, express_count, query_count = list(map(int, input().split()))

    city_list = [[[], []] for _ in range(city_count + 1)]

    for express_index in range(1, express_count + 1):
        l, r = list(map(int, input().split()))
        for city in islice(city_list, 1, l + 1):
            city[0].append(express_index)
        for city in islice(city_list, r, None):
            city[1].append(express_index)

    for city in city_list:
        city[0] = frozenset(city[0])
        city[1] = frozenset(city[1])

    for _ in range(query_count):
        p, q = list(map(int, input().split()))
        city_p = city_list[p][0]
        city_q = city_list[q][1]
        print((len(city_p & city_q)))


if __name__ == '__main__':
    main()
# Original solution
import bisect
n, m, q = list(map(int, input().split()))
edges = []
for i in range(m):
    L, R = list(map(int, input().split()))
    edges.append((L, R, i))

L_sorted = sorted(edges)
L_sorted_bi = [L for L, R, i in L_sorted]
L_cum_set = [set()for _ in range(m+1)]
for i in reversed(list(range(m))):
    L_cum_set[i] = L_cum_set[i+1] | {L_sorted[i][2]}


R_sorted = sorted(edges, key=lambda x: x[1])
R_sorted_bi = [R for L, R, i in R_sorted]
R_cum_set = [set()for _ in range(m+1)]
for i in range(m):
    R_cum_set[i+1] = R_cum_set[i] | {R_sorted[i][2]}


for _ in range(q):
    p, q = list(map(int, input().split()))
    idx = bisect.bisect_left(L_sorted_bi, p)
    s = L_cum_set[idx]

    idx = bisect.bisect_left(R_sorted_bi, q+1)
    t = R_cum_set[idx]
    print((len(s & t)))


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

for _ in range(m):
    L, R = [int(x)-1 for x in input().split()]
    edges[L][R] += 1


for _ in range(q):
    p, q = list(map(int, input().split()))
    lines = edges[p-1:q]
    print((sum(sum(row[p-1:q]) for row in lines)))
# Original solution
n, m, q = list(map(int, input().split()))
edges = [[0]*n for _ in range(n)]

for _ in range(m):
    L, R = [int(x)-1 for x in input().split()]
    edges[L][R] += 1


for _ in range(q):
    p, q = list(map(int, input().split()))
    lines = edges[p-1:q]
    print((sum(sum(row[p-1:q]) for row in lines)))

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

for _ in range(m):
    L, R = [int(x)-1 for x in input().split()]
    edges[L][R] += 1


S = [[0]*(n+1)for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        S[i][j+1] = S[i][j] + edges[i][j]

for _ in range(q):
    p, q = list(map(int, input().split()))
    lines = S[p-1:q]
    ans = 0
    for row in lines:
        ans += row[q]-row[p-1]
    print(ans)
# Original solution
n, m, q = list(map(int, input().split()))
edges = [[0]*n for _ in range(n)]

for _ in range(m):
    L, R = [int(x)-1 for x in input().split()]
    edges[L][R] += 1


S = [[0]*(n+1)for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        S[i][j+1] = S[i][j] + edges[i][j]

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

# Optimized solution
n, m, q = list(map(int, input().split()))
edges = [[0]*(n+1) for _ in range(n+1)]

for _ in range(m):
    L, R = list(map(int, input().split()))
    edges[L][R] += 1

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

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


for _ in range(q):
    p, q = list(map(int, input().split()))
    ans = edges[q][q]-edges[q][p-1]-edges[p-1][q]+edges[p-1][p-1]
    print(ans)
# Original solution
class Ruiseki2D:
    """二次元累積和を構築する"""
    def __init__(self, matrix):
        self.h = len(matrix)
        self.w = len(matrix[0])
        self.ru = [[0] * (self.w + 1) for _ in range(self.h + 1)]

        for i in range(self.h):
            for j in range(self.w):
                self.ru[i + 1][j + 1] = self.ru[i + 1][j] + matrix[i][j]
        for i in range(self.h):
            for j in range(self.w):
                self.ru[i + 1][j + 1] += self.ru[i][j + 1]

    def get_sum(self, hl, hr, wl, wr):
        """[hl, hr), [wl, wr) で囲まれた部分の和を求める"""
        return (self.ru[hr][wr] + self.ru[hl][wl]
                - self.ru[hr][wl] - self.ru[hl][wr])


n, m, q = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]
query = [list(map(int, input().split())) for i in range(q)]

matrix = [[0] * (n + 1) for i in range(n + 1)]
for l, r in info:
    matrix[l][r] += 1
ru = Ruiseki2D(matrix)

for l, r in query:
    ans = ru.get_sum(l, r + 1, l, r + 1)
    print(ans)

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


class Ruiseki2D:
    """二次元累積和を構築する"""
    def __init__(self, matrix):
        self.h = len(matrix)
        self.w = len(matrix[0])
        self.ru = [[0] * (self.w + 1) for _ in range(self.h + 1)]

        for i in range(self.h):
            for j in range(self.w):
                self.ru[i + 1][j + 1] = self.ru[i + 1][j] + matrix[i][j]
        for i in range(self.h):
            for j in range(self.w):
                self.ru[i + 1][j + 1] += self.ru[i][j + 1]

    def get_sum(self, hl, hr, wl, wr):
        """[hl, hr), [wl, wr) で囲まれた部分の和を求める"""
        return (self.ru[hr][wr] + self.ru[hl][wl]
                - self.ru[hr][wl] - self.ru[hl][wr])


n, m, q = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]
query = [list(map(int, input().split())) for i in range(q)]

matrix = [[0] * (n + 1) for i in range(n + 1)]
for l, r in info:
    matrix[l][r] += 1
ru = Ruiseki2D(matrix)

for l, r in query:
    ans = ru.get_sum(l, r + 1, l, r + 1)
    print(ans)
# Original solution
n,m,q = list(map(int,input().split()))
c=[[0 for i in range(n+1)] for j in range(n+1)]
x=[[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()))
    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
import sys
input = sys.stdin.readline

n,m,q = list(map(int,input().split()))
c=[[0 for i in range(n+1)] for j in range(n+1)]
x=[[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()))
    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)
# Original solution
n, m, q = [int(x) for x in input().split()]

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

for _ in range(m):
    l, r = [int(x) for x in input().split()]
    t_list[l][r] += 1

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

for _ in range(q):
    l, r = [int(x) for x in input().split()]
    ans = 0
    for j in range(l, r + 1):
        ans += c_list[j][r] - c_list[j][l - 1]
    print(ans)

# Optimized solution
n, m, q = [int(x) for x in input().split()]

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

for _ in range(m):
    l, r = [int(x) for x in input().split()]
    t_list[l][r] += 1

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

for _ in range(q):
    l, r = [int(x) for x in input().split()]
    print((c_list[r][r] - c_list[l - 1][r] - c_list[r][l - 1] + c_list[l - 1][l - 1]))
# Original solution

from collections import Counter
from itertools import product

n,m,q  = list(map(int,input().split()))
rails=[tuple(map(int,input().split())) for i in range(m)]
qs=[tuple(map(int,input().split())) for i in range(q)]

xlist = [[0 for j in range(n)] for i in range(n)]
sumlist = [[0 for j in range(n+1)] for i in range(n)]
sumsumlist = [[0 for j in range(n+1)] for i in range(n+1)]
for (l,r),i in list(Counter(rails).items()):
    xlist[l-1][r-1]=i


for (i,j) in product(list(range(n)),list(range(n))):
    sumlist[i][j+1]=sum(xlist[i][0:j+1])

for (i,j) in product(list(range(n)),list(range(n))):
    sumsumlist[i+1][j+1] = sum([sumlist[l][j+1] for l in range(0,i+1)])



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


# Optimized solution
from collections import Counter
from itertools import product

n,m,q  = list(map(int,input().split()))
rails=[tuple(map(int,input().split())) for i in range(m)]
qs=[tuple(map(int,input().split())) for i in range(q)]

xlist = [[0 for j in range(n)] for i in range(n)]
sumlist = [[0 for j in range(n+1)] for i in range(n)]
sumsumlist = [[0 for j in range(n+1)] for i in range(n+1)]
for (l,r),i in list(Counter(rails).items()):
    xlist[l-1][r-1]=i


for (i,j) in product(list(range(n)),list(range(n))):
    sumlist[i][j+1]=sum(xlist[i][0:j+1])

for (i,j) in product(list(range(n)),list(range(n))):
    sumsumlist[i+1][j+1] = sum([x[j+1] for x in sumlist[0:i+1]])



for (p,q) in qs:
    ans = sumsumlist[q][q]- sumsumlist[q][p-1] -sumsumlist[p-1][q] + sumsumlist[p-1][p-1]
    print(ans)
# Original solution
n, m, q = list(map(int, input().split()))
image = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = list(map(int, input().split()))
    image[l - 1][r - 1] += 1
sumimage = [[0] * n for _ in range(n)]
for l in range(n - 1, -1, -1):
    for r in range(l, n):
        if l == r:
            sumimage[l][r] = image[l][r]
        else:
            sumimage[l][r] = image[l][r] + sumimage[l + 1][r] + sumimage[l][r - 1] - sumimage[l + 1][r - 1]
for _ in range(q):
    a, b = list(map(int, input().split()))
    c = sumimage[a - 1][b - 1]
    print(c)

# Optimized solution
n, m, q = list(map(int, input().split()))
image = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = list(map(int, input().split()))
    image[l - 1][r - 1] += 1
for l in range(n - 1, -1, -1):
    for r in range(l + 1, n):
        image[l][r] += image[l + 1][r] + image[l][r - 1] - image[l + 1][r - 1]
for _ in range(q):
    a, b = list(map(int, input().split()))
    c = image[a - 1][b - 1]
    print(c)