import numpy as np

limit = 10**5

def Eratosthenes(limit):

	is_prime = np.full(limit+1, True)

	is_prime[:2] = False

	for p in range(2,limit+1):

		if p**2 > limit:

			break

		if is_prime[p]:

			is_prime[p**2::p] = False



	return is_prime



is_prime = Eratosthenes(limit)



fullfill = np.zeros(limit+1,np.int32)



for p in range(limit+1):

	if p*2+1 > limit:

		break

	elif is_prime[p] and is_prime[2*p-1]:

		fullfill[2*p-1] = 1



ans = np.cumsum(fullfill)



Q = int(eval(input()))

A = []

for _ in range(Q):

	l,r = list(map(int, input().split()))

	A.append(ans[r]-ans[l-1])



print((*A))
flg = [1] * (10**5+1)

flg[0], flg[1] = 0, 0

for i in range(2,10**5+1):

	if flg[i] == 1:

		for j in range(2*i, 10**5+1, i):

			flg[j] = 0



cnt = [0,0]

tmp = 0

for i in range(2,10**5+1):

	if flg[i] == 1:

		if flg[(i+1)//2] == 1:

			tmp += 1

			cnt.append(tmp)

		else:

			cnt.append(tmp)

	else:

		cnt.append(tmp)



Q = int(eval(input()))

ans = []



for _ in range(Q):

	tl,tr = list(map(int, input().split()))

	ans.append(cnt[tr] - cnt[tl-1])



for a in ans:

	print(a)
import numpy as np

limit = 10**5


def Eratosthenes(limit):
    is_prime = np.full(limit + 1, True)
    is_prime[:2] = False
    for p in range(2, limit + 1):
        if p**2 > limit:
            break
        if is_prime[p]:
            is_prime[p**2 :: p] = False
    return is_prime


is_prime = Eratosthenes(limit)
fullfill = np.zeros(limit + 1, np.int32)
for p in range(limit + 1):
    if p * 2 + 1 > limit:
        break
    elif is_prime[p] and is_prime[2 * p - 1]:
        fullfill[2 * p - 1] = 1
ans = np.cumsum(fullfill)
Q = int(eval(input()))
A = []
for _ in range(Q):
    l, r = list(map(int, input().split()))
    A.append(ans[r] - ans[l - 1])
print((*A))

flg = [1] * (10**5 + 1)
flg[0], flg[1] = 0, 0
for i in range(2, 10**5 + 1):
    if flg[i] == 1:
        for j in range(2 * i, 10**5 + 1, i):
            flg[j] = 0
cnt = [0, 0]
tmp = 0
for i in range(2, 10**5 + 1):
    if flg[i] == 1:
        if flg[(i + 1) // 2] == 1:
            tmp += 1
            cnt.append(tmp)
        else:
            cnt.append(tmp)
    else:
        cnt.append(tmp)
Q = int(eval(input()))
ans = []
for _ in range(Q):
    tl, tr = list(map(int, input().split()))
    ans.append(cnt[tr] - cnt[tl - 1])
for a in ans:
    print(a)

-import numpy as np - -limit = 10**5 - - -def Eratosthenes(limit): -    is_prime = np.full(limit + 1, True) -    is_prime[:2] = False -    for p in range(2, limit + 1): -        if p**2 > limit: -            break -        if is_prime[p]: -            is_prime[p**2 :: p] = False -    return is_prime - - -is_prime = Eratosthenes(limit) -fullfill = np.zeros(limit + 1, np.int32) -for p in range(limit + 1): -    if p * 2 + 1 > limit: -        break -    elif is_prime[p] and is_prime[2 * p - 1]: -        fullfill[2 * p - 1] = 1 -ans = np.cumsum(fullfill) +flg = [1] * (10**5 + 1) +flg[0], flg[1] = 0, 0 +for i in range(2, 10**5 + 1): +    if flg[i] == 1: +        for j in range(2 * i, 10**5 + 1, i): +            flg[j] = 0 +cnt = [0, 0] +tmp = 0 +for i in range(2, 10**5 + 1): +    if flg[i] == 1: +        if flg[(i + 1) // 2] == 1: +            tmp += 1 +            cnt.append(tmp) +        else: +            cnt.append(tmp) +    else: +        cnt.append(tmp) -A = [] +ans = [] -    l, r = list(map(int, input().split())) -    A.append(ans[r] - ans[l - 1]) -print((*A)) +    tl, tr = list(map(int, input().split())) +    ans.append(cnt[tr] - cnt[tl - 1]) +for a in ans: +    print(a)