To stay woke and attentive during classes, Karen needs some coffee! [Image] 

Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe".

She knows n coffee recipes. The i-th recipe suggests that coffee should be brewed between l_{i} and r_{i} degrees, inclusive, to achieve the optimal taste.

Karen thinks that a temperature is admissible if at least k recipes recommend it.

Karen has a rather fickle mind, and so she asks q questions. In each question, given that she only wants to prepare coffee with a temperature between a and b, inclusive, can you tell her how many admissible integer temperatures fall within the range?


-----Input-----

The first line of input contains three integers, n, k (1 ≤ k ≤ n ≤ 200000), and q (1 ≤ q ≤ 200000), the number of recipes, the minimum number of recipes a certain temperature must be recommended by to be admissible, and the number of questions Karen has, respectively.

The next n lines describe the recipes. Specifically, the i-th line among these contains two integers l_{i} and r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ 200000), describing that the i-th recipe suggests that the coffee be brewed between l_{i} and r_{i} degrees, inclusive.

The next q lines describe the questions. Each of these lines contains a and b, (1 ≤ a ≤ b ≤ 200000), describing that she wants to know the number of admissible integer temperatures between a and b degrees, inclusive.


-----Output-----

For each question, output a single integer on a line by itself, the number of admissible integer temperatures between a and b degrees, inclusive.


-----Examples-----
Input
3 2 4
91 94
92 97
97 99
92 94
93 97
95 96
90 100

Output
3
3
0
4

Input
2 1 1
1 1
200000 200000
90 100

Output
0



-----Note-----

In the first test case, Karen knows 3 recipes.  The first one recommends brewing the coffee between 91 and 94 degrees, inclusive.  The second one recommends brewing the coffee between 92 and 97 degrees, inclusive.  The third one recommends brewing the coffee between 97 and 99 degrees, inclusive. 

A temperature is admissible if at least 2 recipes recommend it.

She asks 4 questions.

In her first question, she wants to know the number of admissible integer temperatures between 92 and 94 degrees, inclusive. There are 3: 92, 93 and 94 degrees are all admissible.

In her second question, she wants to know the number of admissible integer temperatures between 93 and 97 degrees, inclusive. There are 3: 93, 94 and 97 degrees are all admissible.

In her third question, she wants to know the number of admissible integer temperatures between 95 and 96 degrees, inclusive. There are none.

In her final question, she wants to know the number of admissible integer temperatures between 90 and 100 degrees, inclusive. There are 4: 92, 93, 94 and 97 degrees are all admissible.

In the second test case, Karen knows 2 recipes.  The first one, "wikiHow to make Cold Brew Coffee", recommends brewing the coffee at exactly 1 degree.  The second one, "What good is coffee that isn't brewed at at least 36.3306 times the temperature of the surface of the sun?", recommends brewing the coffee at exactly 200000 degrees. 

A temperature is admissible if at least 1 recipe recommends it.

In her first and only question, she wants to know the number of admissible integer temperatures that are actually reasonable. There are none.

Difficulty: MEDIUM
Tags: Sorting

Data structures

Implementation
Skill types: Sorting

Data structures

Starter code:

Solutions:
(n, k, q) = map(int, input().split())
c = [0] * 200002
p = [0] * 200002
for i in range(n):
	(a, b) = map(int, input().split())
	p[a] += 1
	p[b + 1] -= 1
for i in range(1, 200002):
	p[i] += p[i - 1]
	c[i] = c[i - 1] + (p[i] >= k)
l = []
for i in range(q):
	(a, b) = map(int, input().split())
	print(c[b] - c[a - 1])


import sys
(n, k, q) = map(int, sys.stdin.readline().strip().split(' '))
(minR, maxR) = (10 ** 9, -10 ** 9)
tmp = 0
re = []
for i in range(n):
	(l, r) = map(int, sys.stdin.readline().strip().split(' '))
	minR = min(minR, l)
	maxR = max(maxR, r)
	re.append((l, r))
interval = [0 for _ in range(maxR - minR + 2)]
for r in re:
	interval[r[0] - minR] += 1
	interval[r[1] - minR + 1] -= 1
L = len(interval)
for i in range(1, L):
	interval[i] += interval[i - 1]
res = [0 for _ in range(L + 1)]
for i in range(L):
	if interval[i] >= k:
		res[i + 1] = 1
for i in range(1, L + 1):
	res[i] += res[i - 1]
for i in range(q):
	(l, r) = map(int, sys.stdin.readline().strip().split(' '))
	if r < minR or l > maxR:
		print(0)
		continue
	print(res[min(r + 1 - minR, L)] - res[max(0, l - minR)])


(n, k, q) = map(int, input().split())
c = [0] * 200003
p = [0] * 200003
for i in range(n):
	(a, b) = map(int, input().split())
	p[a] += 1
	p[b + 1] -= 1
for i in range(200003):
	p[i] += p[i - 1]
	c[i] = c[i - 1] + (p[i] >= k)
l = []
for i in range(q):
	(a, b) = map(int, input().split())
	l.append(c[b] - c[a - 1])
print(*l, sep='\n')


(n, k, q) = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(n)]
qs = [list(map(int, input().split())) for i in range(q)]

def answer(q):
	(a, b) = q
	if a == 1:
		print(l3[b - 1])
	else:
		print(l3[b - 1] - l3[a - 2])
l2 = [0] * 200000
l3 = [0] * 200000
adds = [0] * 200000
mins = [0] * 200000
for r in l:
	adds[r[0] - 1] += 1
	mins[r[1] - 1] += 1
l2[0] = adds[0] - mins[0]
if adds[0] >= k:
	l3[0] = 1
for i in range(1, 200000):
	l2[i] = l2[i - 1] + adds[i]
	if l2[i] >= k:
		l3[i] = 1
	l2[i] -= mins[i]
for i in range(1, 200000):
	l3[i] = l3[i - 1] + l3[i]
for q in qs:
	answer(q)


(n, k, q) = list(map(int, input().split()))
MAX_TEMP = 200000 + 10
temps = [0 for x in range(MAX_TEMP)]
for i in range(n):
	(l, r) = list(map(int, input().split()))
	temps[l] += 1
	temps[r + 1] -= 1
sums = [0 for x in range(MAX_TEMP)]
count = 0
for i in range(1, MAX_TEMP):
	count += temps[i]
	if count >= k:
		sums[i] = 1
	sums[i] += sums[i - 1]
answers = []
for i in range(q):
	(a, b) = list(map(int, input().split()))
	answers.append(sums[b] - sums[a - 1])
for ans in answers:
	print(ans)


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def solve():
	(n, k, q) = sep()
	pre = [0] * 200002
	for i in range(0, n):
		(l, r) = sep()
		pre[l] += 1
		pre[r + 1] -= 1
	for i in range(1, 200002):
		pre[i] = pre[i] + pre[i - 1]
	cnt = [0] * 200002
	for i in range(0, 200002):
		if i == 0:
			if pre[i] >= k:
				cnt[0] = 1
		elif pre[i] >= k:
			cnt[i] = cnt[i - 1] + 1
		else:
			cnt[i] = cnt[i - 1]
	for i in range(0, q):
		(l, r) = sep()
		print(cnt[r] - cnt[l - 1])
testcase(1)


from sys import stdin

def main():
	test = stdin.readlines()
	(n, k, q) = map(int, test[0].split())
	recipes = [0] * 200003
	for i in range(1, n + 1):
		(li, ri) = map(int, test[i].split())
		recipes[li] += 1
		recipes[ri + 1] -= 1
	rec = [0]
	for e in recipes:
		rec.append(rec[-1] + e)
	for (i, e) in enumerate(rec):
		if e < k:
			rec[i] = 0
		else:
			rec[i] = 1
	sugg = [0]
	for e in rec:
		sugg.append(sugg[-1] + e)
	ans = 0
	out = []
	for i in range(1 + n, n + q + 1):
		(li, ri) = map(int, test[i].split())
		ans = sugg[ri + 2] - sugg[li + 1]
		out.append(ans)
	print('\n'.join(map(str, out)))
main()


from sys import stdin, stdout

def read_ints():
	return list(map(int, stdin.readline().split()))
(n, k, q) = read_ints()
MAX_TEMP = 200000 + 10
temps = [0 for x in range(MAX_TEMP)]
for i in range(n):
	(l, r) = read_ints()
	temps[l] += 1
	temps[r + 1] -= 1
sums = [0 for x in range(MAX_TEMP)]
count = 0
for i in range(1, MAX_TEMP):
	count += temps[i]
	if count >= k:
		sums[i] = 1
	sums[i] += sums[i - 1]
for i in range(q):
	(a, b) = read_ints()
	print(sums[b] - sums[a - 1])


input = __import__('sys').stdin.readline
(n, k, q) = map(int, input().split())
arr = [0] * 200003
for i in range(n):
	(l, r) = map(int, input().split())
	arr[l] += 1
	arr[r + 1] -= 1
ans = [0] * 200003
for i in range(1, len(arr)):
	arr[i] += arr[i - 1]
	ans[i] = ans[i - 1] + (1 if arr[i] >= k else 0)
for i in range(q):
	(l, r) = map(int, input().split())
	print(ans[r] - ans[l - 1])


import sys

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
(n, k, q) = read_int_line()
c = [0] * 200010
for i in range(n):
	(li, ri) = read_int_line()
	c[li] += 1
	c[ri + 1] -= 1
summ = 0
for i in range(len(c)):
	summ += c[i]
	c[i] = summ
for i in range(len(c)):
	if c[i] >= k:
		c[i] = 1
	else:
		c[i] = 0
summ = 0
for i in range(len(c)):
	summ += c[i]
	c[i] = summ
for i in range(q):
	(a, b) = read_int_line()
	print(c[b] - c[a - 1])


MAX_BOUNDRY = 200002
interval = [0] * MAX_BOUNDRY
optimal = [0] * MAX_BOUNDRY
(num_of_recipes, admision, num_of_question) = map(int, input().split())
recipes = []
questions = []
for i in range(num_of_recipes):
	recipes.append(list(map(int, input().split())))
for i in range(num_of_question):
	questions.append(list(map(int, input().split())))
for i in range(num_of_recipes):
	interval[recipes[i][0]] += 1
	interval[recipes[i][1] + 1] -= 1
optimal[0] = interval[0]
for i in range(1, MAX_BOUNDRY):
	optimal[i] = interval[i] + optimal[i - 1]
for i in range(MAX_BOUNDRY):
	if optimal[i] >= admision:
		optimal[i] = 1
	else:
		optimal[i] = 0
for i in range(1, MAX_BOUNDRY):
	optimal[i] += optimal[i - 1]
for question in questions:
	res = optimal[question[1]] - optimal[question[0] - 1]
	print(res)


(n, k, q) = map(int, input().split())
recipe_in = []
for i in range(n):
	(l, r) = map(int, input().split())
	recipe_in.append((l, r))
query_in = []
for i in range(q):
	(l, r) = map(int, input().split())
	query_in.append((l, r))
MAX = 200000 + 10
recipes = [0 for i in range(MAX)]
for recipe in recipe_in:
	(l, r) = recipe
	recipes[l] += 1
	recipes[r + 1] -= 1
for i in range(1, MAX):
	recipes[i] += recipes[i - 1]
cnts = [0 for i in range(MAX)]
for i in range(MAX):
	if recipes[i] >= k:
		cnts[i] += 1
for i in range(1, MAX):
	cnts[i] += cnts[i - 1]
for query in query_in:
	(l, r) = query
	ans = cnts[r] - cnts[l - 1]
	print(ans)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
(n, k, q) = mapi()
diff = [0] * 200002
mn = 200002
mx = 0
for i in range(n):
	(a, b) = mapi()
	diff[a] += 1
	diff[b + 1] -= 1
	mn = min(mn, a)
	mx = max(mx, b)
for i in range(1, 200002):
	diff[i] += diff[i - 1]
for i in range(200002):
	diff[i] = 1 * (diff[i] >= k)
for i in range(1, 200002):
	diff[i] += diff[i - 1]
for i in range(q):
	(a, b) = mapi()
	print(diff[b] - diff[a - 1])


import sys
input = sys.stdin.readline
(n, k, q) = map(int, input().split())
t = [0] * 200002
b = [0] * 200002
for j in range(n):
	(x, y) = map(int, input().split())
	t[x] += 1
	t[y + 1] -= 1
for j in range(1, 200002):
	t[j] += t[j - 1]
	if t[j] >= k:
		b[j] = 1
	b[j] += b[j - 1]
while q > 0:
	(a, r) = map(int, input().split())
	print(b[r] - b[a - 1])
	q -= 1


import sys
import math
input = sys.stdin.readline
(n, k, q) = map(int, input().split())
arr = [0] * 200005
for i in range(n):
	(l, r) = map(int, input().split())
	arr[l] += 1
	arr[r + 1] -= 1
for i in range(1, 200005):
	arr[i] = arr[i - 1] + arr[i]
for i in range(1, 200005):
	if arr[i] >= k:
		arr[i] = 1
	else:
		arr[i] = 0
for i in range(1, 200005):
	arr[i] = arr[i - 1] + arr[i]
for i in range(q):
	(l, r) = map(int, input().split())
	print(arr[r] - arr[l - 1])


import math
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
(n, k, q) = invr()
mxn = 2 * 10 ** 5 + 5
l = []
for i in range(n):
	l.append(inlt())
qr = []
for i in range(q):
	qr.append(inlt())
s = [0 for i in range(mxn)]
for i in range(n):
	(lf, r) = l[i]
	s[lf] += 1
	s[r + 1] -= 1
act = [0 for i in range(mxn)]
flg = [0 for i in range(mxn)]
for i in range(mxn):
	act[i] = act[i - 1] + s[i]
	if act[i] >= k:
		flg[i] = 1
prfx = [0 for i in range(mxn)]
for i in range(mxn):
	if prfx[i - 1]:
		prfx[i] = prfx[i - 1] + flg[i]
	else:
		prfx[i] = flg[i]
for i in range(q):
	(l, r) = qr[i]
	print(prfx[r] - prfx[l - 1])


import sys
input = sys.stdin.readline
(n, k, q) = list(map(int, input().split()))
a = [0] * 200007
c = [0] * 200007
for i in range(0, n):
	(l, r) = list(map(int, input().split()))
	a[r + 1] -= 1
	a[l] += 1
for i in range(1, 200007):
	a[i] += a[i - 1]
	if a[i] >= k:
		c[i] = 1
	c[i] += c[i - 1]
while q > 0:
	(l, r) = list(map(int, input().split()))
	print(c[r] - c[l - 1])
	q -= 1


(n, k, q) = map(int, input().split())
x = 200005
li = [0] * x
for _ in range(n):
	(l, r) = map(int, input().split())
	li[l] += 1
	li[r + 1] -= 1
for i in range(1, x):
	li[i] += li[i - 1]
for i in range(x):
	li[i] = li[i] >= k
for i in range(1, x):
	li[i] += li[i - 1]
for __ in range(q):
	(a, b) = map(int, input().split())
	print(li[b] - li[a - 1])


from itertools import accumulate
(n, s, q) = map(int, input().split())
prefix_ranges = [0] * 200002
for i in range(n):
	(x, y) = map(int, input().split())
	prefix_ranges[x] += 1
	prefix_ranges[y + 1] -= 1
prefix_ranges = list(accumulate(prefix_ranges))
prefix_ranges = list(accumulate([prefix_ranges[i] >= s for i in range(len(prefix_ranges))]))
ans = [0] * q
for i in range(q):
	(x, y) = map(int, input().split())
	ans[i] = prefix_ranges[y] - prefix_ranges[x - 1]
for i in range(q):
	print(ans[i])


from sys import stdin, stdout

def rint():
	return list(map(int, stdin.readline().split()))
(n, k, q) = rint()
r = [0 for i in range(200001)]
l = [0 for i in range(200001)]
for i in range(n):
	(ll, rr) = rint()
	r[rr] += 1
	l[ll] += 1
f = [0 for i in range(200001)]
for i in range(1, 200001):
	f[i] = f[i - 1] + l[i] - r[i - 1]
ss = [0 for i in range(200002)]
for i in range(200000, 0, -1):
	if f[i] >= k:
		ss[i] = ss[i + 1] + 1
	else:
		ss[i] = ss[i + 1]
for i in range(q):
	(ll, rr) = rint()
	print(ss[ll] - ss[rr + 1])


from queue import PriorityQueue
from queue import Queue
import math
from collections import *
import sys
import operator as op
from functools import reduce
MOD = int(1000000000.0 + 7)
input = sys.stdin.readline

def ii():
	return list(map(int, input().strip().split()))

def ist():
	return list(input().strip().split())
(n, k, q) = ii()
ran = [0] * 200002
for j in range(n):
	(l, r) = ii()
	ran[l] += 1
	ran[r + 1] -= 1
for j in range(1, 200002):
	ran[j] += ran[j - 1]
for j in range(1, 200002):
	ran[j] = ran[j] >= k
	ran[j] += ran[j - 1]
for _ in range(q):
	(l, r) = ii()
	print(ran[r] - ran[l - 1])


from sys import stdin, stdout
MN = 200005
inp = stdin.readline().split()
n = int(inp[0])
k = int(inp[1])
q = int(inp[2])
dod = [0] * MN
pref = [0] * MN
cnt = 0
for i in range(0, n):
	inp = stdin.readline().split()
	dod[int(inp[0])] += 1
	dod[int(inp[1]) + 1] -= 1
for i in range(1, MN):
	cnt += dod[i]
	pref[i] = pref[i - 1]
	if cnt >= k:
		pref[i] += 1
for i in range(0, q):
	inp = stdin.readline().split()
	stdout.write(str(pref[int(inp[1])] - pref[int(inp[0]) - 1]) + '\n')


(ranges, maps, strs) = (range, map, str)
fout = ''
count = 0
(n, k, q) = maps(int, input().split())
rangeArr = []
for i in ranges(200002):
	rangeArr.append(0)
for recipe in ranges(n):
	(left, right) = maps(int, input().split())
	rangeArr[left] += 1
	rangeArr[right + 1] -= 1
for recipe in ranges(1, len(rangeArr)):
	rangeArr[recipe] += rangeArr[recipe - 1]
	if rangeArr[recipe - 1] < k:
		rangeArr[recipe - 1] = 0
	else:
		rangeArr[recipe - 1] = 1
for i in ranges(1, len(rangeArr)):
	rangeArr[i] += rangeArr[i - 1]
for question in ranges(q):
	(left, right) = maps(int, input().split())
	fout += strs(rangeArr[right] - rangeArr[left - 1]) + '\n'
print(fout)


import math
(n, k, q) = [int(x) for x in input().split()]
c = [0] * 200002
p = [0] * 200002
for i in range(n):
	(a, b) = map(int, input().split())
	p[a] += 1
	p[b + 1] -= 1
for i in range(1, 200002):
	p[i] += p[i - 1]
	c[i] += c[i - 1] + (p[i] >= k)
l = []
for _ in range(q):
	(a, b) = map(int, input().split())
	l.append(c[b] - c[a - 1])
print(*l, sep='\n')


nl = '\n'
import sys
input = sys.stdin.readline
print = sys.stdout.write
c = [0] * 200003
(n, k, q) = [int(x) for x in input().split()]
for i in range(n):
	(l, r) = [int(x) for x in input().split()]
	c[l] += 1
	c[r + 1] -= 1
clen = len(c)
for i in range(1, clen):
	c[i] += c[i - 1]
for i in range(clen):
	c[i] = c[i] >= k
for i in range(1, clen):
	c[i] += c[i - 1]
for i in range(q):
	(a, b) = [int(x) for x in input().split()]
	print(str(c[b] - c[a - 1]) + nl)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def seive():
	prime = [1 for i in range(10 ** 6 + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(10 ** 6 + 1):
		if prime[i]:
			for j in range(2 * i, 10 ** 6 + 1, i):
				prime[j] = 0
	return prime
(n, k, q) = L()
pref = [0 for i in range(200000 + 2)]
for i in range(n):
	(x, y) = L()
	pref[x] += 1
	pref[y + 1] -= 1
for i in range(1, 200000 + 2):
	pref[i] += pref[i - 1]
for i in range(len(pref)):
	pref[i] = int(pref[i] >= k)
	pref[i] += pref[max(0, i - 1)]
for i in range(q):
	(a, b) = L()
	print(pref[b] - pref[a - 1])
endtime = time.time()


import sys
from itertools import accumulate

def main():
	(n, k, q) = list(map(int, sys.stdin.readline().split()))
	ary = [0] * 2000001
	num_valid = [0] * 2000001
	max_temp = -1
	for __ in range(n):
		(s, t) = list(map(int, sys.stdin.readline().split()))
		ary[s - 1] += 1
		ary[t] -= 1
	tot = 0
	for indx in range(len(num_valid) - 1):
		tot += ary[indx]
		num_valid[indx + 1] = num_valid[indx] + (tot >= k)
	for __ in range(q):
		(s, t) = list(map(int, sys.stdin.readline().split()))
		print(num_valid[t] - num_valid[s - 1])

def __starting_point():
	main()
__starting_point()


import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inf = float('inf')
en = lambda x: list(enumerate(x))
ceil_ = lambda a, b: (a + b - 1) // b
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(n, k, q) = r()
MAXN = 2 * 10 ** 5 + 2
arr = [0] * MAXN
for _ in ' ' * n:
	(a, b) = r()
	arr[a] += 1
	arr[b + 1] -= 1
for i in range(1, MAXN):
	arr[i] += arr[i - 1]
for i in range(MAXN):
	arr[i] = 1 if arr[i] >= k else 0
arr = list(accumulate(arr, add))
for _ in ' ' * q:
	(a, b) = r()
	print(arr[b] - arr[a - 1])


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	ps = [0] * (2 * 10 ** 5 + 3)
	c = [0] * (2 * 10 ** 5 + 3)
	(n, k, q) = map(int, input().split())
	(minim, maxim) = (INF, 0)
	for i in range(n):
		(l, r) = map(int, input().split())
		minim = min(minim, min(l, r))
		maxim = max(maxim, max(l, r))
		ps[l] += 1
		ps[r + 1] -= 1
	for i in range(len(ps)):
		if i < 0 or i >= len(ps):
			continue
		ps[i] += ps[i - 1]
		c[i] = c[i - 1] + (ps[i] >= k)
	for i in range(q):
		(l, r) = map(int, input().split())
		print(c[r] - c[l - 1])
for _ in range(1):
	solve()


a = [0 for i in range(2 * 10 ** 5 + 1)]
x = []
x = input().split()
x[0] = int(x[0])
x[1] = int(x[1])
x[2] = int(x[2])
for i in range(x[0]):
	y = []
	y = input().split()
	a[int(y[0]) - 1] += 1
	a[int(y[1])] -= 1
ps = []
sum = 0
for i in range(2 * 10 ** 5 + 1):
	sum += a[i]
	if sum >= x[1]:
		ps.append(1)
	else:
		ps.append(0)
ps1 = [0 for i in range(2 * 10 ** 5 + 1)]
ps1[0] = ps[0]
for i in range(1, 2 * 10 ** 5):
	ps1[i] = ps1[i - 1] + ps[i]
sol = []
for i in range(x[2]):
	y = []
	y = input().split()
	if int(y[0]) > 0:
		sol.append(ps1[int(y[1]) - 1] - ps1[int(y[0]) - 2])
	else:
		sol.append(ps1[int(y[1]) - 1])
for i in range(x[2]):
	print(sol[i])


def main():
	(n, m, k) = map(int, input().split())
	size = int(200000.0 + 5)
	cnt = [0] * size
	for i in range(n):
		(x, y) = map(int, input().split())
		cnt[x] += 1
		cnt[y + 1] -= 1
	for i in range(1, size):
		cnt[i] += cnt[i - 1]
		cnt[i - 1] = 1 if cnt[i - 1] >= m else 0
	for i in range(1, size):
		cnt[i] += cnt[i - 1]
	res = ''
	for i in range(k):
		(x, y) = map(int, input().split())
		res += str(cnt[y] - cnt[x - 1]) + '\n'
	print(res)
main()


from sys import stdin, stdout
readline = stdin.readline
write = stdout.write
(n, k, q) = map(int, readline().split())
A = [0 for _ in range(200002)]
for i in range(n):
	(l, r) = map(int, readline().split())
	A[l] += 1
	A[r + 1] -= 1
for i in range(1, 200002):
	A[i] += A[i - 1]
for i in range(1, 200002):
	A[i] = 1 if A[i] >= k else 0
for i in range(1, 200002):
	A[i] += A[i - 1]
for i in range(q):
	(a, b) = map(int, readline().split())
	write(str(A[b] - A[a - 1]) + '\n')


import sys
input = sys.stdin.readline
print = sys.stdout.write
(n, k, q) = map(int, input().split())
ar = [0] * (200000 + 2)

def f(l, r):
	ar[l] += 1
	ar[r + 1] -= 1
for x in range(n):
	(a, b) = map(int, input().split())
	f(a, b)
for x in range(1, 200000 + 1):
	ar[x] += ar[x - 1]
for x in range(1, 200000 + 1):
	ar[x] = ar[x] >= k
for x in range(1, 200000 + 1):
	ar[x] += ar[x - 1]
for el in range(q):
	(a, b) = map(int, input().split())
	print(str(ar[b] - ar[a - 1]) + '\n')


import sys
input = lambda : sys.stdin.readline()
MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, k, q) = f()
lsf = [0] * 200009
ldp = [0] * 200009
for _ in range(n):
	(a, b) = f()
	lsf[a] += 1
	lsf[b + 1] -= 1
for i in range(1, 200007):
	lsf[i] += lsf[i - 1]
	ldp[i] = ldp[i - 1] + (lsf[i] >= k) * 1
for _ in range(q):
	(a, b) = f()
	sys.stdout.write(str(ldp[b] - ldp[a - 1]) + '\n')


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict
import math
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m, k) = map(int, input().split(' '))
l = [0] * 200002
for i in range(n):
	(x, y) = map(int, input().split(' '))
	l[x] += 1
	l[y + 1] -= 1
for i in range(1, 200002):
	l[i] += l[i - 1]
ans = [0] * 200002
la = 0
for i in range(200001):
	if l[i] >= m:
		ans[i] = 1
	ans[i] += la
	la = ans[i]
for i in range(k):
	(x, y) = map(int, input().split(' '))
	print(ans[y] - ans[x - 1])


from sys import stdin, stdout
(n, k, q) = [int(i) for i in stdin.readline().split()]
sm = [0] * 200001
st = [0] * 200001
nd = [0] * 200001
for i in range(n):
	(l, r) = [int(i) for i in stdin.readline().split()]
	st[l] += 1
	nd[r] += 1
b = 0
for t in range(1, 200001):
	b += st[t]
	sm[t] = sm[t - 1]
	if b >= k:
		sm[t] += 1
	b -= nd[t]
for i in range(q):
	(l, r) = [int(i) for i in stdin.readline().split()]
	stdout.write(str(sm[r] - sm[l - 1]))
	stdout.write('\n')


(n, k, q) = map(int, input().split())
a = [0] * 200002
b = [0] * 200002
c = [0] * 200002
s = 0
for i in range(n):
	(l, r) = map(int, input().split())
	a[l] = a[l] + 1
	a[r + 1] = a[r + 1] - 1
for i in range(1, 200002):
	s = s + a[i]
	if s >= k:
		b[i] = 1
for i in range(1, 200002):
	c[i] = c[i - 1] + b[i]
for i in range(q):
	(l, r) = map(int, input().split())
	print(c[r] - c[l - 1])


import bisect
(n, k, q) = map(int, input().split())
numRec_temp_i = [0 for i in range(200001)]
for i in range(n):
	(l, r) = map(int, input().split())
	numRec_temp_i[l] += 1
	if r < 200000:
		numRec_temp_i[r + 1] -= 1
l = []
for i in range(1, 200001):
	numRec_temp_i[i] += numRec_temp_i[i - 1]
	if numRec_temp_i[i] >= k:
		l.append(i)
l.sort()
z = []
for i in range(q):
	(a, b) = map(int, input().split())
	x1 = bisect.bisect_left(l, a)
	x2 = bisect.bisect(l, b)
	z.append(str(x2 - x1))
print('\n'.join(z))


import sys
input = sys.stdin.readline

def prefix_sum(arr):
	for i in range(1, len(arr)):
		arr[i] += arr[i - 1]
(n, k, q) = map(int, input().split())
maxi = 0
arr = []
for _ in range(n):
	(a, b) = map(int, input().split())
	arr.append([a, b])
	maxi = max(maxi, a, b)
diff = [0] * (maxi + 2)
for i in range(n):
	diff[arr[i][0]] += 1
	diff[arr[i][1] + 1] -= 1
prefix_sum(diff)
count_two = [0] * (maxi + 2)
for i in range(1, maxi + 2):
	if diff[i] >= k:
		count_two[i] = 1 + count_two[i - 1]
	else:
		count_two[i] = count_two[i - 1]
for i in range(q):
	(a, b) = map(int, input().split())
	if a - 1 < 0:
		a = 0
	elif a > maxi:
		a = maxi + 1
	print(max(0, count_two[min(maxi, b)] - count_two[max(0, a - 1)]))


import sys

def prefix_sums(array):
	res = [array[0]]
	for v in array[1:]:
		res.append(res[-1] + v)
	return res

class FastIntervalSummer:

	def __init__(self, array):
		self._prefix_sums = [0] + prefix_sums(array)

	def interval_sum(self, l, r):
		return self._prefix_sums[r + 1] - self._prefix_sums[l]

def read_ints(line):
	return list(map(int, line.split()))
lines = sys.stdin.read().strip().split('\n')
(n, k, q) = read_ints(lines[0])
lines = lines[1:]
recipies = [read_ints(line) for line in lines[:n]]
lines = lines[n:]
queries = [read_ints(line) for line in lines]
max_t = max(map(max, recipies))
diff_recipies = [0] * (max_t + 2)
for (l, r) in recipies:
	diff_recipies[l] += 1
	diff_recipies[r + 1] -= 1
t_to_num_recipies = prefix_sums(diff_recipies)
t_to_admissible = [1 if n_recipies >= k else 0 for n_recipies in t_to_num_recipies]
t_to_admissible_ps = FastIntervalSummer(t_to_admissible)
for (l, r) in queries:
	l = min(l, len(t_to_admissible) - 1)
	r = min(r, len(t_to_admissible) - 1)
	print(t_to_admissible_ps.interval_sum(l, r))


(n, k, q) = list(map(int, input().split()))
from itertools import accumulate
count = [0 for _ in range(200002)]
for _ in range(n):
	(l, r) = list(map(int, input().split()))
	count[l] += 1
	count[r + 1] -= 1
ok = 0
count2 = [0 for _ in range(200002)]
for (i, v) in enumerate(count):
	ok += v
	if ok >= k:
		count2[i] = 1
	else:
		count2[i] = 0
prefixe = list(accumulate(count2))
res = []
for _ in range(q):
	(l, r) = list(map(int, input().split()))
	res.append(str(prefixe[r] - prefixe[l - 1]))
print('\n'.join(res))


from itertools import accumulate
(nums, temp, out) = ([0] * 200002, 0, [])
(n, k, q) = map(int, input().split(' '))
for i in range(n):
	(l, r) = map(int, input().split(' '))
	nums[l] += 1
	nums[r + 1] -= 1
for i in range(1, 200002):
	temp += nums[i]
	nums[i] = temp >= k
for i in range(1, 200002):
	nums[i] += nums[i - 1]
for i in range(q):
	(a, b) = map(int, input().split(' '))
	out.append(str(nums[b] - nums[a - 1]))
print('\n'.join(out))


import sys

def main():
	(n, k, q) = list(map(int, sys.stdin.readline().split()))
	maxtemp = 200001
	deltatemp_plus = [0] * maxtemp
	deltatemp_minus = [0] * maxtemp
	for i in range(n):
		(li, ri) = list(map(int, sys.stdin.readline().split()))
		deltatemp_plus[li] += 1
		deltatemp_minus[ri] += 1
	temp = [0] * maxtemp
	cumsum = 0
	for i in range(maxtemp):
		cumsum += deltatemp_plus[i]
		temp[i] = cumsum
		cumsum -= deltatemp_minus[i]
	goodtemp = [0] * maxtemp
	goodtemp[0] = 1 if temp[0] >= k else 0
	for i in range(1, maxtemp):
		adder = 1 if temp[i] >= k else 0
		goodtemp[i] = goodtemp[i - 1] + adder
	for iq in range(q):
		(ai, bi) = list(map(int, sys.stdin.readline().split()))
		if ai == 0:
			result = goodtemp[bi]
		else:
			result = goodtemp[bi] - goodtemp[ai - 1]
		sys.stdout.write(str(result) + '\n')
main()


(recipes, min_recipes, questions) = map(int, input().split())
recipes_temp = [0] * 200002
for _ in range(recipes):
	(l, r) = map(int, input().split())
	recipes_temp[l] += 1
	recipes_temp[r + 1] -= 1
for i in range(1, 200002):
	recipes_temp[i] = recipes_temp[i - 1] + recipes_temp[i]
for i in range(1, 200002):
	recipes_temp[i] = 1 if recipes_temp[i] >= min_recipes else 0
for i in range(1, 200002):
	recipes_temp[i] = recipes_temp[i - 1] + recipes_temp[i]
resp = list()
for _ in range(questions):
	(l, r) = map(int, input().split())
	resp.append(recipes_temp[r] - recipes_temp[l - 1])
print(*resp, sep='\n')


(n, k, q) = map(int, input().split(' '))
dp = [0] * 200003
for N in range(n):
	(l, h) = map(int, input().split(' '))
	dp[l] += 1
	dp[h + 1] -= 1
for i in range(1, 200003):
	dp[i] += dp[i - 1]
	dp[i - 1] = int(dp[i - 1] >= k)
for i in range(1, 200003):
	dp[i] += dp[i - 1]
answer = ''
for query in range(q):
	(l, h) = map(int, input().split(' '))
	answer += str(dp[h] - dp[l - 1]) + '\n'
print(answer, end='')


def main():
	n_k_q_list = list(map(int, str(input()).split()))
	n = n_k_q_list[0]
	k = n_k_q_list[1]
	q = n_k_q_list[2]
	temp_list = []
	queries = []
	min_temp = 200001
	max_temp = 0
	for i in range(n):
		temp_list.append(tuple(map(int, str(input()).split())))
		if temp_list[i][0] < min_temp:
			min_temp = temp_list[i][0]
		if temp_list[i][1] > max_temp:
			max_temp = temp_list[i][1]
	size = max_temp - min_temp + 1
	temp_marker = [0 for i in range(size)]
	for i in range(n):
		temp_marker[temp_list[i][0] - min_temp] += 1
		if temp_list[i][1] - min_temp + 1 <= size - 1:
			temp_marker[temp_list[i][1] - min_temp + 1] -= 1
	admissible_temp_freq = get_admissible_temp_freq(temp_marker, size, k)
	ans_list = []
	for i in range(q):
		queries.append(tuple(map(int, str(input()).split())))
		start_idx = queries[i][0] - min_temp
		end_idx = queries[i][1] - min_temp
		if start_idx < 0:
			start_idx = 0
		if end_idx > size - 1:
			end_idx = size - 1
		if start_idx > size - 1 or end_idx < 0:
			ans_list.append(0)
			continue
		if start_idx - 1 >= 0:
			ans_list.append(admissible_temp_freq[end_idx] - admissible_temp_freq[start_idx - 1])
		else:
			ans_list.append(admissible_temp_freq[end_idx])
	for i in range(q):
		print(ans_list[i])

def get_admissible_temp_freq(given_arr, size, k=0):
	prefix = [given_arr[0]]
	admissible_temps_freq = []
	freq = 0
	if given_arr[0] >= k:
		freq += 1
	admissible_temps_freq.append(freq)
	for i in range(1, size):
		prefix.append(prefix[i - 1] + given_arr[i])
		if prefix[i] >= k:
			freq += 1
		admissible_temps_freq.append(freq)
	return admissible_temps_freq
main()


from sys import stdin, stdout
(n, k, q) = map(int, stdin.readline().rstrip().split())
c = [0] * 200002
for i in range(n):
	(a, b) = map(int, input().split(' '))
	c[a] += 1
	c[b + 1] -= 1
for i in range(1, len(c)):
	c[i] = c[i] + c[i - 1]
for i in range(0, len(c)):
	c[i] = 1 if c[i] >= k else 0
for i in range(1, len(c)):
	c[i] = c[i] + c[i - 1]
for i in range(q):
	(a, b) = map(int, stdin.readline().rstrip().split())
	stdout.write(str(c[b] - c[a - 1]) + '\n')


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k, q) = map(int, input().split())
a = [0] * 200007
c = [0] * 200007
for i in range(0, n):
	(l, r) = list(map(int, input().split()))
	a[r + 1] -= 1
	a[l] += 1
for i in range(1, 200007):
	a[i] += a[i - 1]
	if a[i] >= k:
		c[i] = 1
	c[i] += c[i - 1]
while q > 0:
	(l, r) = list(map(int, input().split()))
	print(c[r] - c[l - 1])
	q -= 1


import sys
from itertools import accumulate

def main():
	itr = iter(sys.stdin)
	(n, s, q) = map(int, next(itr).split())
	prefix_ranges = [0] * 200002
	for i in range(n):
		(x, y) = map(int, next(itr).split())
		prefix_ranges[x] += 1
		prefix_ranges[y + 1] -= 1
	prefix_ranges = list(accumulate(prefix_ranges))
	prefix_ranges = list(accumulate([prefix_ranges[i] >= s for i in range(len(prefix_ranges))]))
	ans = [0] * q
	for i in range(q):
		(x, y) = map(int, next(itr).split())
		ans[i] = str(prefix_ranges[y] - prefix_ranges[x - 1])
	print('\n'.join(ans))
main()


(n, k, q) = map(int, input().split())
pref = [0] * 200002
for _ in range(n):
	(l, r) = map(int, input().split())
	pref[l] += 1
	pref[r + 1] -= 1
cnt = 0
s = 0
for i in range(200002):
	cnt += pref[i]
	if cnt >= k:
		s += 1
	pref[i] = s
for _ in range(q):
	(a, b) = map(int, input().split())
	print(pref[b] - pref[a - 1])


import sys
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, k, q) = Ri()
arr = [0] * (200000 + 2)
for i in range(n):
	(a, b) = Ri()
	arr[a] += 1
	arr[b + 1] -= 1
for i in range(1, len(arr)):
	arr[i] = arr[i - 1] + arr[i]
for i in range(1, len(arr)):
	arr[i] = 1 if arr[i] >= k else 0
for i in range(1, len(arr)):
	arr[i] = arr[i - 1] + arr[i]
for _ in range(q):
	(a, b) = Ri()
	print(arr[b] - arr[a - 1])


import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def binomial_coefficient(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0
(n, k, q) = list(map(int, input().split()))
tmp = [0] * 200002
for _ in range(n):
	(t1, t2) = list(map(int, input().split()))
	tmp[t1] += 1
	tmp[t2 + 1] -= 1
i = 0
prev = 0
for j in range(len(tmp)):
	current = prev + tmp[j]
	if current >= k:
		i += 1
	tmp[j] = i
	prev = current
for _ in range(q):
	(l, r) = list(map(int, input().split()))
	print(tmp[r] - tmp[l - 1])


import sys
input = sys.stdin.readline
l = list(map(int, input().split()))
r = l[0]
k = l[1]
q = l[2]
count = [0] * 200002
for i in range(r):
	l1 = list(map(int, input().split()))
	count[l1[0]] += 1
	count[l1[1] + 1] -= 1
check = [0] * 200002
for i in range(1, 200002):
	count[i] += count[i - 1]
for i in range(200001):
	if count[i] >= k:
		check[i] = 1
for i in range(1, 200002):
	check[i] += check[i - 1]
for i in range(q):
	l1 = list(map(int, input().split()))
	print(check[l1[1]] - check[l1[0] - 1])


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
INF = 99999999999999999999999999999999

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(n, k, q) = ria()
		temprang = [0] * 200005
		prefsum = [0] * 200005
		z = []
		for i in range(n):
			(l, r) = ria()
			z.append([l, r])
			temprang[l] += 1
			temprang[r + 1] -= 1
		for i in range(1, len(temprang)):
			temprang[i] += temprang[i - 1]
			if temprang[i] >= k:
				prefsum[i] += 1
			prefsum[i] += prefsum[i - 1]
		for i in range(q):
			(a, b) = ria()
			print(prefsum[b] - prefsum[a - 1])
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
(n, k, q) = (int(i) for i in input().split())
temp = [0] * 200001
for i in range(n):
	(l, r) = (int(i) for i in input().split())
	temp[l - 1] += 1
	temp[r] -= 1
pref = [temp[0]]
for i in range(1, 200001):
	pref.append(pref[i - 1] + temp[i])
if pref[0] >= k:
	pref2 = [1]
else:
	pref2 = [0]
for i in range(1, 200001):
	if pref[i] >= k:
		pref2.append(pref2[i - 1] + 1)
	else:
		pref2.append(pref2[i - 1])
for i in range(q):
	(a, b) = (int(i) for i in input().split())
	if a == 1:
		print(pref2[b - 1])
	else:
		print(pref2[b - 1] - pref2[a - 2])


(n, k, q) = map(int, input().split())
c = [0] * 200003
for i in range(n):
	(a, b) = map(int, input().split())
	c[a] += 1
	c[b + 1] -= 1
for i in range(1, len(c)):
	c[i] += c[i - 1]
c[0] = 1 if c[0] >= k else 0
for i in range(1, len(c)):
	c[i] = 1 if c[i] >= k else 0
	c[i] += c[i - 1]
ans = ''
for i in range(q):
	(a, b) = map(int, input().split())
	ans += str(c[b] - c[a - 1]) + '\n'
print(ans, end='')


(n, k, q) = map(int, input().split())
ps = [0] * 200002
for _ in range(n):
	(a, b) = map(int, input().split())
	ps[a] += 1
	ps[b + 1] -= 1
for i in range(1, 200002):
	ps[i] += ps[i - 1]
psum = []
for i in range(200002):
	if ps[i] >= k:
		psum.append(1)
	else:
		psum.append(0)
for i in range(1, 200002):
	psum[i] += psum[i - 1]
ans = []
for _ in range(q):
	(a, b) = map(int, input().split())
	ans.append(psum[b] - psum[a - 1])
for i in ans:
	print(i)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def pref_sum(s):
	t = 0
	for i in range(200002):
		t += s[i]
		s[i] = t
(n, k, q) = map(int, input().split())
s = [0] * 200002
for _ in range(n):
	(l, r) = map(int, input().split())
	s[l] += 1
	s[r + 1] -= 1
pref_sum(s)
for i in range(200002):
	s[i] = 1 if s[i] >= k else 0
pref_sum(s)
for _ in range(q):
	(l, r) = map(int, input().split())
	print(s[r] - s[l - 1])


(n, k, q) = map(int, input().split())
rec = [0 for i in range(200005)]
ques = []
for i in range(n):
	(l, r) = map(int, input().split())
	rec[l] += 1
	rec[r + 1] -= 1
for i in range(1, len(rec)):
	rec[i] += rec[i - 1]
for i in range(1, len(rec)):
	if rec[i] >= k:
		rec[i] = 1
	else:
		rec[i] = 0
	rec[i] += rec[i - 1]
for i in range(q):
	(l, r) = map(int, input().split())
	ques.append(rec[r] - rec[l - 1])
ques = map(str, ques)
print('\n'.join(ques))


(n, k, q) = map(int, input().split())
tem = [0] * 200002
for i in range(n):
	(l, r) = map(int, input().split())
	tem[l] += 1
	tem[r + 1] -= 1
for i in range(1, len(tem)):
	tem[i] += tem[i - 1]
pref = [0] * 200002
for i in range(1, len(tem)):
	if tem[i] >= k:
		pref[i] += 1
for i in range(1, len(tem)):
	pref[i] += pref[i - 1]
for i in range(q):
	(l, r) = map(int, input().split())
	print(pref[r] - pref[l - 1])


from sys import stdin, stdout
(n, k, q) = map(int, stdin.readline().split())
length = 2 * 10 ** 5 + 2
a = [0 for i in range(length)]
for i in range(n):
	(l, r) = map(int, stdin.readline().split())
	a[l - 1] += 1
	a[r] -= 1
for i in range(1, length):
	a[i] += a[i - 1]
for i in range(length):
	if a[i] >= k:
		a[i] = 1
	else:
		a[i] = 0
for i in range(1, length):
	a[i] += a[i - 1]
for i in range(q):
	(l, r) = map(int, stdin.readline().split())
	if l - 2 < 0:
		stdout.write(str(a[r - 1]) + '\n')
	else:
		stdout.write(str(a[r - 1] - a[l - 2]) + '\n')


from sys import stdin, stdout
maxN = 200200
(n, k, q) = [int(item) for item in stdin.readline().strip().split()]
a = [0] * maxN
b = [0] * maxN
for i in range(n):
	(l, r) = [int(item) for item in stdin.readline().strip().split()]
	a[l] += 1
	a[r + 1] -= 1
for i in range(1, maxN):
	a[i] += a[i - 1]
for i in range(maxN):
	if a[i] >= k:
		b[i] = 1
	b[i] += b[i - 1]
for j in range(q):
	(u, v) = [int(item) for item in stdin.readline().strip().split()]
	stdout.write(str(b[v] - b[u - 1]))
	stdout.write('\n')


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
(n, k, q) = rinput()
nums = [0] * 200002
for _ in range(n):
	(l, r) = rinput()
	nums[l] += 1
	nums[r + 1] -= 1
for i in range(200001):
	if i != 0:
		nums[i] = nums[i] + nums[i - 1]
nums = [1 if n >= k else 0 for n in nums]
for i in range(200001):
	if i != 0:
		nums[i] = nums[i] + nums[i - 1]
ans = []
for _ in range(q):
	(l, r) = rinput()
	ans.append(nums[r] - nums[l - 1])
for a in ans:
	print(a)


M = 200002
arr = [0] * M
(n, k, q) = list(map(int, input().split()))
narr = [list(map(int, input().split())) for _ in range(n)]
qarr = [list(map(int, input().split())) for _ in range(q)]
for (i, j) in narr:
	arr[i] += 1
	arr[j + 1] += -1
for i in range(1, M):
	arr[i] = arr[i] + arr[i - 1]
arr = [1 if i >= k else 0 for i in arr]
for i in range(1, M):
	arr[i] = arr[i] + arr[i - 1]
for (qs, qd) in qarr:
	print(arr[qd] - arr[qs - 1])


(n, k, q) = map(int, input().split())
x = [0] * 200005
for _ in range(n):
	(l, r) = map(int, input().split())
	x[l] += 1
	x[r + 1] -= 1
for i in range(1, 200005):
	x[i] += x[i - 1]
	x[i - 1] = [0, 1][x[i - 1] >= k]
for i in range(1, 200005):
	x[i] += x[i - 1]
res = ''
for _ in range(q):
	(l, r) = map(int, input().split())
	res += str(x[r] - x[l - 1]) + '\n'
print(res, end='')


from itertools import accumulate
MAX = 200002
(n, k, q) = map(int, input().split())
info = [0] * MAX
for i in range(n):
	(l, r) = map(int, input().split())
	info[l] += 1
	info[r + 1] -= 1
acc = 0
for (ind, diff) in enumerate(info):
	acc += diff
	if acc >= k:
		info[ind] = 1
	else:
		info[ind] = 0
pref = list(accumulate(info))
ans = []
for i in range(q):
	(l, r) = map(int, input().split())
	ans.append(str(pref[r] - pref[l - 1]))
print('\n'.join(ans))


from sys import stdin, stdout
MAX = 200000
a = [0] * (MAX + 1)
(n, mn, nQ) = map(int, stdin.readline().split())
for _ in range(n):
	(l, r) = map(lambda x: int(x) - 1, stdin.readline().split())
	a[l] += 1
	a[r + 1] -= 1
psums = [0]
d = 0
for i in range(MAX):
	d += a[i]
	a[i] = d
	a[i] = 0 if a[i] < mn else 1
	psums.append(psums[-1] + a[i])
sumRange = lambda l, r: psums[r + 1] - psums[l]
for _ in range(nQ):
	(l, r) = map(lambda x: int(x) - 1, stdin.readline().split())
	stdout.write('%d\n' % sumRange(l, r))


def solve():
	(n, k, q) = map(int, input().split())
	pre = [0] * 200002
	for i in range(0, n):
		(l, r) = map(int, input().split())
		pre[l] += 1
		pre[r + 1] -= 1
	for i in range(1, 200002):
		pre[i] = pre[i] + pre[i - 1]
	cnt = [0] * 200002
	for i in range(0, 200002):
		if i == 0:
			if pre[i] >= k:
				cnt[0] = 1
		elif pre[i] >= k:
			cnt[i] = cnt[i - 1] + 1
		else:
			cnt[i] = cnt[i - 1]
	for i in range(0, q):
		(l, r) = map(int, input().split())
		print(cnt[r] - cnt[l - 1])
solve()


import sys
input = sys.stdin.readline
(n, k, q) = list(map(int, input().split()))
leng = 200002
c = [0] * leng
pre_s = [0] * leng
for i in range(n):
	(a, b) = list(map(int, input().split()))
	c[a] += 1
	c[b + 1] -= 1
for i in range(1, leng):
	c[i] += c[i - 1]
	pre_s[i] = pre_s[i - 1] + (c[i] >= k)
for i in range(q):
	(a, b) = list(map(int, input().split()))
	print(pre_s[b] - pre_s[a - 1])


import random, math
from copy import deepcopy as dc
MAXN = 200001

def randomNumber(s, e):
	return random.randint(s, e)

def randomArray(s, e, s_size, e_size):
	size = random.randint(s_size, e_size)
	arr = [randomNumber(s, e) for i in range(size)]
	return arr

def testcase():
	pass

def brute():
	pass

def effe():
	pass

def solution(k, st, en, mini, maxi):
	rep = [0] * (maxi - mini + 1)
	cur = 0
	for i in range(mini, maxi + 1):
		if i in st:
			cur += st[i]
		if i - 1 in en:
			cur -= en[i - 1]
		rep[i - mini] = dc(cur)
	count = 0
	for i in range(mini, maxi + 1):
		if rep[i - mini] >= k:
			count += 1
		rep[i - mini] = dc(count)
	return rep

def input_test():
	(n, k, q) = map(int, input().strip().split(' '))
	st = {}
	en = {}
	mini = float('inf')
	maxi = float('-inf')
	for i in range(n):
		(s, e) = map(int, input().strip().split(' '))
		st[s] = st.get(s, 0) + 1
		en[e] = en.get(e, 0) + 1
		mini = min(mini, s)
		maxi = max(maxi, e)
	qe = []
	for i in range(q):
		(s, e) = map(int, input().strip().split(' '))
		qe.append([s, e])
		mini = min(mini, s)
		maxi = max(maxi, e)
	mini -= 1
	maxi += 1
	out = solution(k, st, en, mini, maxi)
	for i in qe:
		(s, e) = (i[0], i[1])
		if s - mini - 1 <= 0:
			s = mini + 1
		if e - mini >= maxi - mini:
			e = maxi
		print(out[e - mini] - out[s - mini - 1])

def test():
	pass
input_test()


(n, k, q) = [int(x) for x in input().split()]
seg = [0] * 200010
par = [0] * 200010
for i in range(n):
	(li, ri) = [int(x) for x in input().split()]
	seg[li] += 1
	seg[ri + 1] -= 1
s = 0
for i in range(1, 200001):
	s += seg[i]
	seg[i] = s
	par[i] = par[i - 1] + (1 if s >= k else 0)
for i in range(q):
	(ai, bi) = [int(x) for x in input().split()]
	print(par[bi] - par[ai - 1])


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k, q) = map(int, input().split())
lim = 2 * 10 ** 5 + 1
pas = []
dif_arr = [0] * lim
for i in range(n):
	(s, e) = map(int, input().split())
	dif_arr[s] += 1
	if e + 1 < len(dif_arr):
		dif_arr[e + 1] -= 1
t = 0
for i in range(lim):
	t += dif_arr[i]
	pas.append(t)
pas2 = []
t = 0
for i in pas:
	if i >= k:
		t += 1
	pas2.append(t)
for i in range(q):
	(s, e) = map(int, input().split())
	if s - 1 > -1:
		print(pas2[e] - pas2[s - 1])
	else:
		print(pas2[e])


from array import array
from itertools import repeat, accumulate
(n, k, q) = map(int, input().split(' '))
c = array('i', repeat(0, 200000 + 10))
temp_map = array('i', repeat(0, 200000 + 10))
for _ in range(n):
	(l, r) = map(int, input().split(' '))
	c[l] += 1
	c[r + 1] -= 1
v = 0
for (i, e) in enumerate(c):
	if v >= k:
		temp_map[i - 1] = 1
	v += e
temp_acc = list(accumulate(temp_map))
res = []
for _ in range(q):
	(l, r) = map(int, input().split(' '))
	res.append(temp_acc[r] - temp_acc[l - 1])
res = map(str, res)
print('\n'.join(res))


import sys
input = sys.stdin.readline
(n, k, q) = list(map(int, input().split()))
P = [0] * 200002
for _ in range(n):
	(a, b) = map(int, input().split())
	P[a] += 1
	P[b + 1] -= 1
for i in range(1, len(P)):
	P[i] = P[i] + P[i - 1]
for i in range(1, len(P)):
	P[i] = 1 if P[i] >= k else 0
for i in range(1, len(P)):
	P[i] += P[i - 1]
for _ in range(q):
	(a, b) = map(int, input().split())
	print(P[b] - P[a - 1])


from collections import *
from sys import stdin

def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return list(stdin.readline()[:-1])

class segmenttree:

	def __init__(self, arr, n):
		(self.tree, self.n) = ([0] * (2 * n), n)
		if arr:
			for i in range(2 * n - 1, 0, -1):
				if i >= n:
					self.tree[i] = arr[i - n]
				else:
					self.tree[i] = self.tree[i << 1] + self.tree[(i << 1) + 1]

	def query(self, l, r):
		res = 0
		l += self.n
		r += self.n
		while l < r:
			if l & 1:
				res += self.tree[l]
				l += 1
			if r & 1:
				r -= 1
				res += self.tree[r]
			l >>= 1
			r >>= 1
		return res

	def update(self, ix, val):
		ix += self.n
		self.tree[ix] = val
		while ix > 1:
			self.tree[ix >> 1] = self.tree[ix] + self.tree[ix ^ 1]
			ix >>= 1
(cum, all) = (defaultdict(int), [])
(n, k, q) = arr_inp(1)
for i in range(n):
	(l, r) = arr_inp(1)
	cum[l] += 1
	cum[r + 1] -= 1
for i in range(1, 200001):
	cum[i] += cum[i - 1]
	all.append(1 if cum[i] >= k else 0)
tree = segmenttree(all, len(all))
for i in range(q):
	(l, r) = arr_inp(1)
	print(tree.query(l - 1, r))


N = 200002
f = [0] * N
ans = [0] * N
res = []
(n, k, q) = map(int, input().split(' '))
while n:
	(l, r) = map(int, input().split(' '))
	f[l] += 1
	f[r + 1] -= 1
	n -= 1
for i in range(1, N):
	f[i] += f[i - 1]
	ans[i] += ans[i - 1] + (f[i] >= k)
while q:
	(l, r) = map(int, input().split(' '))
	res.append(ans[r] - ans[l - 1])
	q -= 1
print(*res, sep='\n')


a = [int(x) for x in input().split()]
receptek = []
kerdesek = []
for x in range(a[0]):
	receptek.append([int(y) for y in input().split()])
for x in range(a[2]):
	kerdesek.append([int(y) for y in input().split()])
nagy = 200002
jo = [0] * nagy
for x in range(len(receptek)):
	b = receptek[x][0]
	c = receptek[x][1]
	jo[b] += 1
	jo[c + 1] -= 1
for x in range(1, len(jo)):
	jo[x] += jo[x - 1]
adm = [0] * nagy
for x in range(1, len(jo)):
	if jo[x] >= a[1]:
		adm[x] += 1
	adm[x] += adm[x - 1]
mo = []
for x in range(len(kerdesek)):
	mo.append(adm[kerdesek[x][1]] - adm[kerdesek[x][0] - 1])
for m in mo:
	print(m)


import os
import sys
from io import BytesIO, IOBase
import math
import itertools
import bisect
import heapq

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	for i in range(2, n + 1):
		if primes[i]:
			for j in range(i + i, n + 1, i):
				primes[j] = False
	p = []
	for i in range(0, n + 1):
		if primes[i]:
			p.append(i)
	return p

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def chk(n, d):
	if str(d) in str(n):
		return True
	return False
(n, k, q) = map(int, input().split())
cnt = [0] * 200001
for i in range(0, n):
	(l, r) = map(int, input().split())
	cnt[l - 1] += 1
	cnt[r] -= 1
for i in range(1, 200001):
	cnt[i] += cnt[i - 1]
pref = [0] * 200001
for i in range(0, 200001):
	if cnt[i] >= k:
		pref[i] = 1
for i in range(1, 200001):
	pref[i] += pref[i - 1]
pref.insert(0, 0)
for i in range(0, q):
	(l, r) = map(int, input().split())
	print(pref[r] - pref[l - 1])


import sys
(n, k, q) = map(int, sys.stdin.readline().split())
check = [0] * 200012
for i in range(n):
	(l, r) = map(int, sys.stdin.readline().split())
	check[l] += 1
	check[r + 1] -= 1
for i in range(200001):
	check[i + 1] += check[i]
	if check[i] >= k:
		check[i] = 1
	else:
		check[i] = 0
for i in range(200000):
	check[i + 1] += check[i]
for i in range(q):
	count = 0
	(a, b) = map(int, sys.stdin.readline().split())
	sys.stdout.write(str(check[b] - check[a - 1]) + '\n')


import sys
input = sys.stdin.readline
(n, k, q) = map(int, input().split())
start = {}
end = {}
for i in range(n):
	(x, y) = map(int, input().split())
	if x not in start:
		start[x] = 1
	else:
		start[x] += 1
	if y not in end:
		end[y] = 1
	else:
		end[y] += 1
c = [0] * 200002
if 0 in start:
	c[0] += start[0]
if 0 in end:
	c[1] -= end[0]
for i in range(1, 200001):
	c[i] += c[i - 1]
	if i in start:
		c[i] += start[i]
	if i in end:
		c[i + 1] -= end[i]
for i in range(200001):
	if c[i] >= k:
		c[i] = 1
	else:
		c[i] = 0
for i in range(1, 200001):
	c[i] += c[i - 1]
for i in range(q):
	(a, b) = map(int, input().split())
	if a == 0:
		print(c[b])
	else:
		print(c[b] - c[a - 1])


(n, k, q) = map(int, input().split())
l = [0] * (2 * 10 ** 5 + 2)
for _ in range(n):
	(a, b) = map(int, input().split())
	l[a] += 1
	l[b + 1] -= 1
prefix = []
temp = 0
for i in l:
	temp += i
	prefix.append(temp)
ar = [0] * (2 * 10 ** 5 + 2)
for i in range(2 * 10 ** 5 + 2):
	if prefix[i] >= k:
		ar[i] = 1
prefixarray = []
temp = 0
for i in ar:
	temp += i
	prefixarray.append(temp)
for i in range(q):
	(a, b) = map(int, input().split())
	print(prefixarray[b] - prefixarray[a - 1])


def main():
	(n, k, q) = list(map(int, input().split()))
	(l, res) = ([0] * 200002, [])
	for _ in range(n):
		(a, b) = list(map(int, input().split()))
		l[a] += 1
		l[b + 1] -= 1
	a = 0
	for (i, b) in enumerate(l):
		a += b
		l[i] = a >= k
	a = 0
	for (i, b) in enumerate(l):
		if b:
			a += 1
		l[i] = a
	for _ in range(q):
		(a, b) = list(map(int, input().split()))
		res.append(l[b] - l[a - 1])
	print('\n'.join(map(str, res)))

def __starting_point():
	main()
__starting_point()


(n, k, q) = list(map(int, input().split()))
recipes = [0] * (200000 + 2)
res = []
for _ in range(n):
	(l, r) = list(map(int, input().split()))
	recipes[l] += 1
	recipes[r + 1] -= 1
for i in range(1, len(recipes)):
	recipes[i] += recipes[i - 1]
for i in range(1, len(recipes)):
	recipes[i] = 1 if recipes[i] >= k else 0
	recipes[i] += recipes[i - 1]
for _ in range(q):
	(a, b) = list(map(int, input().split()))
	res.append(recipes[b] - recipes[a - 1])
print('\n'.join(map(str, res)))


from sys import stdin, stdout

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline()
(n, k, q) = mi()
l1 = [0] * 200002
pf = [0] * 200002
for _ in range(n):
	(a, b) = mi()
	l1[a] += 1
	l1[b + 1] -= 1
pf[0] = l1[0]
for i in range(1, 200002):
	pf[i] = pf[i - 1] + l1[i]
for i in range(200002):
	if pf[i] >= k:
		pf[i] = 1
	else:
		pf[i] = 0
for i in range(1, 200002):
	pf[i] += pf[i - 1]
for _ in range(q):
	(a, b) = mi()
	print(pf[b] - pf[a - 1])


(n, m, k1) = map(int, input().split())
l1 = [0] * 200003
for i in range(n):
	(a, b) = map(int, input().split())
	l1[a] += 1
	l1[b + 1] -= 1
for i in range(1, 200003):
	l1[i] = l1[i - 1] + l1[i]
l1[0] = 0
for i in range(1, len(l1)):
	if l1[i] >= m:
		l1[i] = l1[i - 1] + 1
	else:
		l1[i] = l1[i - 1]
V = ''
for i in range(k1):
	(a, b) = map(int, input().split())
	V += str(l1[b] - l1[a - 1]) + '\n'
print(V, end='')


from sys import stdin
inp = stdin.readline
(n, k, q) = map(int, inp().split())
temps = [0] * 200005
for i in range(n):
	(l, r) = map(int, inp().split())
	temps[l] += 1
	temps[r + 1] -= 1
cur_sum = 0
cur_max = 0
for i in range(200005):
	cur_sum += temps[i]
	if cur_sum >= k:
		cur_max += 1
	temps[i] = cur_max
for i in range(q):
	(a, b) = map(int, inp().split())
	print(temps[b] - temps[a - 1])


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k, q) = value()
bounds = []
Count = [0 for i in range(2 * 10 ** 5 + 2)]
for i in range(n):
	(l, r) = value()
	bounds.append((l, r))
	Count[l] += 1
	Count[r + 1] -= 1
for i in range(1, 2 * 10 ** 5 + 1):
	Count[i] = Count[i] + Count[i - 1]
for i in range(1, 2 * 10 ** 5 + 1):
	Count[i] = int(Count[i] >= k)
for i in range(1, 2 * 10 ** 5 + 1):
	Count[i] += Count[i - 1]
for i in range(q):
	(l, r) = value()
	print(Count[r] - Count[l - 1])


import sys

class FastInput:

	def __init__(self, file=sys.stdin):
		self._lines = file.read().strip().split('\n')
		self._index = 0

	def next_line(self):
		ret = self._lines[self._index]
		self._index += 1
		return ret

	def line_of_ints(self):
		return list(map(int, self.next_line().split()))

def prefix_sums(array):
	res = [array[0]]
	for v in array[1:]:
		res.append(res[-1] + v)
	return res

class FastIntervalSummer:

	def __init__(self, array):
		self._prefix_sums = [0] + prefix_sums(array)

	def interval_sum(self, l, r):
		return self._prefix_sums[r + 1] - self._prefix_sums[l]
data = FastInput()
(n, k, q) = data.line_of_ints()
recipies = [data.line_of_ints() for _ in range(n)]
queries = [data.line_of_ints() for _ in range(q)]
max_t = max(map(max, recipies))
diff_recipies = [0] * (max_t + 2)
for (l, r) in recipies:
	diff_recipies[l] += 1
	diff_recipies[r + 1] -= 1
t_to_num_recipies = prefix_sums(diff_recipies)
t_to_admissible = [1 if n_recipies >= k else 0 for n_recipies in t_to_num_recipies]
t_to_admissible_ps = FastIntervalSummer(t_to_admissible)
for (l, r) in queries:
	l = min(l, len(t_to_admissible) - 1)
	r = min(r, len(t_to_admissible) - 1)
	print(t_to_admissible_ps.interval_sum(l, r))


(recipesNum, recipesMin, questionsNum) = map(int, input().split())
recipes = [0] * 200003
pref = [0] * 200003
for i in range(recipesNum):
	(l, r) = map(int, input().split())
	recipes[l] += 1
	recipes[r + 1] -= 1
for i in range(1, len(recipes)):
	recipes[i] += recipes[i - 1]
	pref[i] = pref[i - 1] + (recipes[i] >= recipesMin)
for i in range(questionsNum):
	(a, b) = map(int, input().split())
	print(pref[b] - pref[a - 1])


(n, k, q) = map(int, input().split())
nums = [0] * (200000 + 9)
for _ in range(n):
	(l, r) = map(int, input().split())
	nums[l] += 1
	nums[r + 1] -= 1
for i in range(1, len(nums)):
	nums[i] = nums[i] + nums[i - 1]
if nums[0] >= k:
	nums[0] = 1
else:
	nums[0] = 0
for i in range(1, len(nums)):
	if nums[i] >= k:
		nums[i] = nums[i - 1] + 1
	else:
		nums[i] = nums[i - 1]
for _ in range(q):
	count = 0
	(l, r) = map(int, input().split())
	count = nums[r] - nums[l - 1]
	print(count)


def prefix_sum(a):
	b = [a[0]]
	n = len(a)
	for i in range(1, n, 1):
		b.append(b[i - 1] + a[i])
	return b

def pre_process(a, k):
	n = len(a)
	for i in range(1, n, 1):
		if a[i] >= k:
			a[i] = 1
		else:
			a[i] = 0
	return a

def main():
	(n, k, q) = input().split(' ')
	(n, k, q) = [int(x) for x in [n, k, q]]
	c = [0 for i in range(200002)]
	for i in range(n):
		temp = [int(j) for j in input().split(' ')]
		c[temp[0]] += 1
		c[temp[1] + 1] -= 1
	c = prefix_sum(c)[:]
	sol = pre_process(c, k)
	sol = prefix_sum(sol)[:]
	res = []
	for i in range(q):
		temp = [int(j) for j in input().split(' ')]
		a = temp[0]
		b = temp[1]
		res.append(sol[b] - sol[a - 1])
	for i in res:
		print(i)
main()


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k, q) = map(int, input().split())
arr = [0] * 200009
for i in range(n):
	(l, r) = map(int, input().split())
	arr[l] += 1
	arr[r + 1] -= 1
for i in range(1, len(arr)):
	arr[i] += arr[i - 1]
for i in range(len(arr)):
	if arr[i] >= k:
		arr[i] = 1
	else:
		arr[i] = 0
for i in range(1, len(arr)):
	arr[i] += arr[i - 1]
for i in range(q):
	(a, b) = map(int, input().split())
	print(arr[b] - arr[a - 1])


(n, k, q) = map(int, input().split())
numRec_temp_i = [0 for i in range(200001)]
for i in range(n):
	(l, r) = map(int, input().split())
	numRec_temp_i[l] += 1
	if r < 200000:
		numRec_temp_i[r + 1] -= 1
for i in range(1, 200001):
	numRec_temp_i[i] += numRec_temp_i[i - 1]
for i in range(1, 200001):
	if numRec_temp_i[i] >= k:
		numRec_temp_i[i] = 1 + numRec_temp_i[i - 1]
	else:
		numRec_temp_i[i] = numRec_temp_i[i - 1]
z = []
for i in range(q):
	(a, b) = map(int, input().split())
	z.append(str(numRec_temp_i[b] - numRec_temp_i[a - 1]))
print('\n'.join(z))


(n, k, q) = map(int, input().split())
l = [0] * 200001
for i in range(n):
	(li, ri) = map(int, input().split())
	l[li - 1] += 1
	l[ri] -= 1
l1 = []
if l[0] >= k:
	l1.append(1)
else:
	l1.append(0)
la = []
lb = []
for i in range(q):
	(a, b) = map(int, input().split())
	la.append(a)
	lb.append(b)
d = max(lb)
for i in range(1, d + 1):
	l[i] = l[i] + l[i - 1]
	if l[i] >= k:
		l1.append(l1[len(l1) - 1] + 1)
	else:
		l1.append(l1[len(l1) - 1])
for j in range(q):
	(a, b) = (la[j], lb[j])
	if a == 1:
		print(l1[b - 1])
	else:
		print(l1[b - 1] - l1[a - 2])


(n, k, q) = map(int, input().split())
m = [0] * 200001
a = 0
for i in range(n):
	(a, b) = map(int, input().split())
	m[a - 1] += 1
	m[b] -= 1
mk = []
for i in range(q):
	mk.append(list(map(int, input().split())))
a = 0
pre = []
for i in range(200001):
	a = a + m[i]
	if a >= k:
		pre.append(1)
	else:
		pre.append(0)
pre2 = []
a = 0
pre2.append(0)
for i in range(200001):
	a = a + pre[i]
	pre2.append(a)
for i in range(q):
	out = pre2[mk[i][1]] - pre2[mk[i][0] - 1]
	print(out)


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, k, q) = M()

def update(D, l, r, x):
	D[l] += x
	D[r + 1] -= x

def printArray(A, D):
	for i in range(0, len(A)):
		if i == 0:
			A[i] = D[i]
		else:
			A[i] = D[i] + A[i - 1]
A = [0] * 200100
D = [0] * 200101
for i in range(n):
	(a, b) = M()
	update(D, a, b, 1)
printArray(A, D)
x = [0]
for i in range(len(A)):
	if A[i] >= k:
		x.append(x[-1] + 1)
	else:
		x.append(x[-1])
x.append(x[-1])
for i in range(q):
	(a, b) = M()
	print(x[b + 1] - x[a])


(recipes, admisionNums, questions) = list(map(int, input().split()))
recipeList = []
questionList = []
partialSum = [0] * 200002
preSum = [0] * 200002
partialSum2 = [0] * 200002
preSum2 = [0] * 200002
counter = 0
for i in range(recipes):
	recipeList.append(list(map(int, input().split())))
for i in range(questions):
	questionList.append(list(map(int, input().split())))
for i in range(recipes):
	partialSum[recipeList[i][0]] += 1
	partialSum[recipeList[i][1] + 1] -= 1
preSum[0] = partialSum[0]
for i in range(1, 200002):
	preSum[i] = preSum[i - 1] + partialSum[i]
for i in range(200002):
	if preSum[i] >= admisionNums:
		partialSum2[i] = 1
	else:
		partialSum2[i] = 0
preSum2[0] = partialSum2[0]
for i in range(1, 200002):
	preSum2[i] = preSum2[i - 1] + partialSum2[i]
for question in questionList:
	print(preSum2[question[1]] - preSum2[question[0] - 1])


import itertools as it
import sys
c = [0] * 200002
(n, k, q) = map(int, input().split())
itr = iter(sys.stdin)
for i in range(n):
	(l, r) = map(int, next(itr).split())
	c[l] += 1
	c[r + 1] -= 1
c = list(it.accumulate(c))
c = list(it.accumulate([int(c[i] >= k) for i in range(len(c))]))
ans = []
for i in range(q):
	(l, r) = map(int, input().split())
	ans.append(str(c[r] - c[l - 1]))
print('\n'.join(ans))


(n, k, q) = [int(x) for x in input().split()]
(mainL, x, c) = ([0] * 200002, 0, 0)
for i in range(n):
	(left, right) = [int(x) for x in input().split()]
	mainL[left] += 1
	mainL[right + 1] -= 1
for i in range(200002):
	x += mainL[i]
	if x >= k:
		c += 1
		mainL[i] = c
	else:
		mainL[i] = c
for i in range(q):
	(start, end) = [int(x) for x in input().split()]
	print(mainL[end] - mainL[start - 1])


import math
from sys import stdin, stdout
input = stdin.readline

class N:

	def __init__(self, il, ir, val, l, r):
		self.il = il
		self.ir = ir
		self.val = val
		self.l = l
		self.r = r

	def __str__(self):
		return ' il = ' + str(self.il) + ' ir = ' + str(self.ir) + ' val = ' + str(self.val)

	def get_amount(self, left, right, func):
		if self.il == left and self.ir == right:
			return self.val
		elif self.l.il <= left and self.l.ir >= right:
			return self.l.get_amount(left, right, func)
		elif self.r.il <= left and self.r.ir >= right:
			return self.r.get_amount(left, right, func)
		else:
			return func(self.l.get_amount(left, self.l.ir, func), self.r.get_amount(self.r.il, right, func))

class ST:

	def __init__(self, arr, threshold):
		t1 = []
		t2 = []
		for (i, val) in enumerate(arr):
			t1.append(N(i, i, int(val >= threshold), None, None))
		while len(t1) + len(t2) > 1:
			while len(t1) >= 2:
				a = t1.pop()
				b = t1.pop()
				t2.append(self.__get_next(a, b))
			if len(t1) > 0:
				t2.append(t1.pop())
			(t1, t2) = (t2, t1)
		self.r = t1[0]

	def __get_next(self, a, b):
		if a.il > b.il:
			(a, b) = (b, a)
		n = N(a.il, b.ir, self.__func(a.val, b.val), a, b)
		return n

	def __func(self, a, b):
		return a + b

	def request(self, l, r):
		root = self.r
		answ = 0
		if l == r:
			while not (root.il == l and root.ir == r):
				if l >= root.l.il and r <= root.l.ir:
					root = root.l
				else:
					root = root.r
			answ = self.__func(answ, root.val)
			return answ
		if root.il == l and root.ir == r:
			return root.val
		f = True
		while f:
			if root.l.il <= l and root.l.ir >= r:
				root = root.l
			elif root.r.il <= l and root.r.ir >= r:
				root = root.r
			else:
				f = False
		left = root.l
		right = root.r
		while not left.il == l:
			if l < left.r.il:
				answ = self.__func(answ, left.r.val)
				left = left.l
			else:
				left = left.r
		answ = self.__func(answ, left.val)
		while not right.ir == r:
			if r > right.l.ir:
				answ = self.__func(answ, right.l.val)
				right = right.r
			else:
				right = right.l
		answ = self.__func(answ, right.val)
		return answ

	def req(self, l, r):
		return self.r.get_amount(l, r, self.__func)
gradus = [0 for i in range(200002)]
(recipes, min_r, questions) = list(map(int, input().split()))
adds = []
for i in range(recipes):
	(l, r) = list(map(int, input().split()))
	if l == r:
		adds.append(l)
	else:
		gradus[l] -= 1
		gradus[r + 1] += 1
counter = 0
for i in range(0, len(gradus)):
	if gradus[i] < 0:
		counter += abs(gradus[i])
	elif gradus[i] > 0:
		counter -= gradus[i]
	gradus[i] = counter
for i in adds:
	gradus[i] += 1
tree = ST(gradus, min_r)
res = []
for i in range(questions):
	(l, r) = list(map(int, input().split()))
	res.append(str(tree.request(l, r)))
print('\n'.join(res))


(numberofRecipes, min_numberofRecipes, numberofQuestions) = map(int, input().split())
recipes = [0] * 200009
for i in range(numberofRecipes):
	(low, high) = map(int, input().split())
	recipes[low] += 1
	recipes[high + 1] -= 1
for i in range(1, len(recipes)):
	recipes[i] += recipes[i - 1]
for i in range(1, len(recipes)):
	if recipes[i] >= min_numberofRecipes:
		recipes[i] = 1 + recipes[i - 1]
	else:
		recipes[i] = recipes[i - 1]
for i in range(numberofQuestions):
	(a, b) = map(int, input().split())
	print(recipes[b] - recipes[a - 1])


(n, k, q) = map(int, input().split())
d = [0] * 200002
for i in range(n):
	(x, y) = map(int, input().split())
	d[x] += 1
	d[y + 1] -= 1
t = [0] * 200002
for i in range(1, 200002):
	d[i] += d[i - 1]
	if d[i] >= k:
		t[i] = t[i - 1] + 1
	else:
		t[i] = t[i - 1]
for i in range(q):
	(x, y) = map(int, input().split())
	print(t[y] - t[x - 1])


(noOfrecipes, minrecipes, quest) = map(int, input().split())
lst = [0] * 200005
count = 0
for i in range(noOfrecipes):
	(l, r) = map(int, input().split())
	lst[l] += 1
	lst[r + 1] -= 1
for j in range(1, len(lst)):
	lst[j] = lst[j - 1] + lst[j]
for i in range(len(lst)):
	if lst[i] >= minrecipes:
		count += 1
	lst[i] = count
for i in range(quest):
	(a, b) = map(int, input().split())
	print(lst[b] - lst[a - 1])


import sys
input = sys.stdin.readline
(n, k, q) = map(int, input().split())
recommended = [0] * 200002
for _ in range(n):
	(a, b) = map(int, input().split())
	recommended[a] += 1
	recommended[b + 1] -= 1
cum = 0
for i in range(200002):
	cum += recommended[i]
	recommended[i] = cum
prefix_sum = [0]
for i in range(1, 200002):
	if recommended[i] >= k:
		prefix_sum.append(prefix_sum[-1] + 1)
	else:
		prefix_sum.append(prefix_sum[-1])
for _ in range(q):
	(a, b) = map(int, input().split())
	print(prefix_sum[b] - prefix_sum[a - 1])


(n, k, q) = map(int, input().split())
max_degree = 2 * 10 ** 5 + 2
suggest_v = [0] * max_degree
for i in range(0, n):
	(l, r) = map(int, input().split())
	suggest_v[l] += 1
	suggest_v[r + 1] -= 1
qq = []
for i in range(0, q):
	(a, b) = map(int, input().split())
	qq.append([a, b])
for i in range(1, max_degree):
	suggest_v[i] += suggest_v[i - 1]
for i in range(0, max_degree):
	suggest_v[i] = int(suggest_v[i] >= k)
for i in range(1, max_degree):
	suggest_v[i] += suggest_v[i - 1]
for i in range(0, q):
	a = qq[i][0]
	b = qq[i][1]
	print(suggest_v[b] - suggest_v[a - 1])


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	return [[default for j in range(m)] for i in range(n)]

def arr3D(n, m, r, default=0):
	return [[[default for k in range(r)] for j in range(m)] for i in range(n)]

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

class DSU:

	def __init__(self, length):
		self.length = length
		self.parent = [-1] * self.length

	def getParent(self, node, start):
		if node >= self.length:
			return False
		if self.parent[node] < 0:
			if start != node:
				self.parent[start] = node
			return node
		return self.getParent(self.parent[node], start)

	def union(self, node1, node2):
		parent1 = self.getParent(node1, node1)
		parent2 = self.getParent(node2, node2)
		if parent1 == parent2:
			return False
		elif self.parent[parent1] <= self.parent[parent2]:
			self.parent[parent1] += self.parent[parent2]
			self.parent[parent2] = parent1
		else:
			self.parent[parent2] += self.parent[parent1]
			self.parent[parent1] = parent2
		return True

	def getCount(self, node):
		return -self.parent[self.getParent(node, node)]

def countIntervals(arr, N):
	minimum = float('inf')
	maximum = 0
	freq = [0] * 200010
	for i in range(0, N):
		li = arr[i][0]
		freq[li] = freq[li] + 1
		ri = arr[i][1]
		freq[ri + 1] = freq[ri + 1] - 1
		if li < minimum:
			minimum = li
		if ri > maximum:
			maximum = ri
	for i in range(minimum - 3, maximum + 2):
		freq[i] = freq[i] + freq[i - 1]
	return freq
(n, k, q) = list(map(int, input().split()))
lst = []
for i in range(n):
	lst.append(list(map(int, input().split())))
qu = []
for i in range(q):
	qu.append(list(map(int, input().split())))
freq = countIntervals(lst, n)
from math import ceil, log2

def getMid(s, e):
	return s + (e - s) // 2

def getSumUtil(st, ss, se, qs, qe, si):
	if qs <= ss and qe >= se:
		return st[si]
	if se < qs or ss > qe:
		return 0
	mid = getMid(ss, se)
	return getSumUtil(st, ss, mid, qs, qe, 2 * si + 1) + getSumUtil(st, mid + 1, se, qs, qe, 2 * si + 2)

def updateValueUtil(st, ss, se, i, diff, si):
	if i < ss or i > se:
		return
	st[si] = st[si] + diff
	if se != ss:
		mid = getMid(ss, se)
		updateValueUtil(st, ss, mid, i, diff, 2 * si + 1)
		updateValueUtil(st, mid + 1, se, i, diff, 2 * si + 2)

def updateValue(arr, st, n, i, new_val):
	if i < 0 or i > n - 1:
		print('Invalid Input', end='')
		return
	diff = new_val - arr[i]
	arr[i] = new_val
	updateValueUtil(st, 0, n - 1, i, diff, 0)

def getSum(st, n, qs, qe):
	if qs < 0 or qe > n - 1 or qs > qe:
		print('Invalid Input', end='')
		return -1
	return getSumUtil(st, 0, n - 1, qs, qe, 0)

def constructSTUtil(arr, ss, se, st, si):
	if ss == se:
		st[si] = arr[ss]
		return arr[ss]
	mid = getMid(ss, se)
	st[si] = constructSTUtil(arr, ss, mid, st, si * 2 + 1) + constructSTUtil(arr, mid + 1, se, st, si * 2 + 2)
	return st[si]

def constructST(arr, n):
	x = int(ceil(log2(n)))
	max_size = 2 * int(2 ** x) - 1
	st = [0] * max_size
	constructSTUtil(arr, 0, n - 1, st, 0)
	return st
for i in range(len(freq)):
	freq[i] = int(freq[i] >= k)
arr = freq
n = len(arr)
st = constructST(arr, n)
for i in qu:
	print(getSum(st, n, i[0], i[1]))