While working at DTL, Ela is very aware of her physical and mental health. She started to practice various sports, such as Archery, Yoga, and Football.

Since she started engaging in sports activities, Ela switches to trying a new sport on days she considers being "Luxury" days. She counts the days since she started these activities, in which the day she starts is numbered as day $1$. A "Luxury" day is the day in which the number of this day is a luxurious number.

An integer $x$ is called a luxurious number if it is divisible by ${\lfloor \sqrt{x} \rfloor}$.

Here $\lfloor r \rfloor$ denotes the "floor" of a real number $r$. In other words, it's the largest integer not greater than $r$.

For example: $8$, $56$, $100$ are luxurious numbers, since $8$ is divisible by $\lfloor \sqrt{8} \rfloor = \lfloor 2.8284 \rfloor = 2$, $56$ is divisible $\lfloor \sqrt{56} \rfloor = \lfloor 7.4833 \rfloor = 7$, and $100$ is divisible by $\lfloor \sqrt{100} \rfloor = \lfloor 10 \rfloor = 10$, respectively. On the other hand $5$, $40$ are not, since $5$ are not divisible by $\lfloor \sqrt{5} \rfloor = \lfloor 2.2361 \rfloor = 2$, and $40$ are not divisible by $\lfloor \sqrt{40} \rfloor = \lfloor 6.3246 \rfloor = 6$.

Being a friend of Ela, you want to engage in these fitness activities with her to keep her and yourself accompanied (and have fun together, of course). Between day $l$ and day $r$, you want to know how many times she changes the activities.


-----Input-----

Each test contains multiple test cases. The first line has the number of test cases $t$ ($1 \le t \le 10\ 000$). The description of the test cases follows.

The only line of each test case contains two integers $l$ and $r$ ($1 \le l \le r \le 10^{18}$) — the intervals at which you want to know how many times Ela changes her sports.


-----Output-----

For each test case, output an integer that denotes the answer.


-----Examples-----

Input
5
8 19
8 20
119 121
1 100000000000000000
1234567891011 1000000000000000000
Output
5
6
2
948683296
2996666667


-----Note-----

In the first test case, $5$ luxury numbers in range $[8, 19]$ are: $8, 9, 12, 15, 16$.

Difficulty: EASY

Solutions:
import math
f = lambda x: 3 * (i := math.isqrt(x)) + (i * i + i <= x) + (i * (i + 2) <= x)
for s in [*open(0)][1:]:
	(l, r) = map(int, s.split())
	print(f(r) - f(l - 1))


import math
q = math.isqrt

def f(x):
	i = j = q(x)
	while j * j + j > x:
		j -= 1
	return i + j + q(x + 1)
for s in [*open(0)][1:]:
	(l, r) = map(int, s.split())
	print(f(r) - f(l - 1))


import math
a = lambda z: z < 1 or (i := math.isqrt(z)) * 2 + z // i - 1
for s in [*open(0)][1:]:
	(p, g) = map(int, s.split())
	print(a(g) - a(p - 1))


import math
j = lambda x: x < 1 or (i := math.isqrt(x)) * 2 + x // i - 1
for s in [*open(0)][1:]:
	(l, r) = map(int, s.split())
	print(j(r) - j(l - 1))


import sys
import math
t = int(sys.stdin.readline())

def f(x):
	y = math.floor(x ** 0.5)
	while y * y + y * 2 + 1 <= x:
		y += 1
	while y * y > x:
		y -= 1
	res = y * 3
	if y * y + y > x:
		res -= 1
	if y * y + y + y > x:
		res -= 1
	return res
for _ in range(t):
	(l, r) = map(int, sys.stdin.readline().split())
	print(f(r) - f(l - 1))


import math
q = math.isqrt
f = lambda x: q(x) + int((x + 0.25) ** 0.5 - 0.5) + q(x + 1)
for s in [*open(0)][1:]:
	(l, r) = map(int, s.split())
	print(f(r) - f(l - 1))


import sys, math
input = sys.stdin.readline
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	a = math.isqrt(l)
	b = math.isqrt(r)
	ans = 0
	if a == b:
		if r >= a ** 2 >= l:
			ans += 1
		if r >= a ** 2 + 2 * a >= l:
			ans += 1
		if r >= a ** 2 + a >= l:
			ans += 1
	else:
		if a + 1 <= b - 1:
			ans += 3 * (b - 1 - a)
		if a ** 2 >= l:
			ans += 1
		if a ** 2 + 2 * a >= l:
			ans += 1
		if a ** 2 + a >= l:
			ans += 1
		if b ** 2 <= r:
			ans += 1
		if b ** 2 + 2 * b <= r:
			ans += 1
		if b ** 2 + b <= r:
			ans += 1
	print(ans)


import sys
import math
for _ in range(int(sys.stdin.readline())):
	(l, r) = map(int, sys.stdin.readline().split())
	l1 = int(math.isqrt(l))
	r1 = int(math.isqrt(r))
	lcount = 0
	for k in range(3):
		if l1 * l1 + k * l1 >= l and l1 * l1 + k * l1 <= r:
			lcount += 1
	rcount = 0
	if r1 * r1 > l1 * l1 + 2 * l1:
		for k in range(3):
			if r1 * r1 + k * r1 <= r:
				rcount += 1
	mid = 0
	if r1 > l1 + 1:
		mid = r1 - l1 - 1
	print(lcount + rcount + mid * 3)


t = int(input())
import math
for _ in range(t):
	[l, r] = list(map(int, input().strip().split()))
	temp = math.isqrt(r)
	a = (temp - 1) * 3 + 1 + (r - temp * temp) // temp
	ans = a
	if l > 1:
		temp = math.isqrt(l - 1)
		b = (temp - 1) * 3 + 1 + (l - 1 - temp * temp) // temp
		ans -= b
	print(ans)


import math

def count_luxurious_numbers(n):
	if n == 0:
		return 0
	i_sqrt = math.isqrt(n)
	count = (i_sqrt - 1) * 3
	d = n - i_sqrt * i_sqrt
	count += d // i_sqrt
	return count + 1

def main():
	t = int(input())
	for i in range(t):
		(n1, n2) = map(int, input().split())
		c1 = count_luxurious_numbers(n1 - 1)
		c2 = count_luxurious_numbers(n2)
		print(c2 - c1)
main()


from math import isqrt

def numtaghsim(x, y):
	x1 = isqrt(x)
	y1 = isqrt(y)
	count = (y1 - x1 + 1) * 3
	if x > x1 * x1:
		count -= 1
	if x > x1 * x1 + x1:
		count -= 1
	if x > x1 * x1 + 2 * x1:
		count -= 1
	if y < y1 * y1:
		count -= 1
	if y < y1 * y1 + y1:
		count -= 1
	if y < y1 * y1 + 2 * y1:
		count -= 1
	print(count)
t = int(input())
for i in range(t):
	(x, y) = [int(i) for i in input().split()]
	numtaghsim(x, y)


import math

def ira(w):
	if w <= 4:
		return w
	else:
		stop = int(w ** 0.5)
		if w - stop ** 2 < 0:
			stop -= 1
		return 3 + (stop - 2) * 3 + 1 + (w - stop ** 2) // stop
t = int(input())
for _ in range(t):
	(l, r) = [int(i) for i in input().split()]
	print(ira(r) - ira(l - 1))


import math
for _ in range(int(input())):
	(a, b) = input().split(' ')
	(a, b) = (int(a), int(b))

	def f(a):
		if a == 0:
			return 0
		ans = math.sqrt(a + 0.1)
		ans = int(ans)
		if a < ans * ans:
			ans -= 1
		ans2 = a - ans * ans
		return (ans - 1) * 3 + 1 + ans2 // ans
	print(f(b) - f(max(0, a - 1)))


from math import *

def ff(x):
	if x == 0:
		return 0
	a = isqrt(x)
	ans = (a - 1) * 3 + (x - a * a) // a
	ans += 1
	return ans
t = int(input())
for _ in range(t):
	(l, r) = map(int, input().split())
	print(ff(r) - ff(l - 1))


import math
t = int(input())
for _ in range(t):
	(l, r) = map(int, input().split())
	ll = math.isqrt(l)
	rr = math.isqrt(r)
	al = 0
	ar = 0
	for i in range(3):
		if ll * (ll + i) >= l:
			al += 1
		if rr * (rr + i) <= r:
			ar += 1
	ans = al + 3 * (rr - ll - 1) + ar
	print(ans)


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

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

def si():
	return str(input())

def ni():
	return int(input())
from math import ceil
import math

def solve(n):
	if n == 0:
		return 0
	i_sqrt = math.isqrt(n)
	count = (i_sqrt - 1) * 3
	d = n - i_sqrt * i_sqrt
	count += d // i_sqrt
	return count + 1
for _ in range(int(input())):
	(l, r) = mi()
	if l == r and pow(l, 0.5) == int(pow(l, 0.5)):
		print(1)
		continue
	print(int(solve(r) - solve(l - 1)))


import math
t = int(input())
for i in range(t):
	(l, r) = map(int, input().strip().split())
	l -= 1
	count = 0
	xl = math.floor(math.isqrt(l))
	xr = math.floor(math.isqrt(r))
	if r != 0:
		count = count + (xr - 1) * 3 + (r - xr * xr) // xr
	if l != 0:
		count = count - (l - xl * xl) // xl - (xl - 1) * 3
	if l == 0 and r != 0:
		print(count + 1)
	else:
		print(count)


from math import isqrt

def luxury_number(l, r):
	r_l = isqrt(l)
	r_r = isqrt(r)
	r_l = r_l + 1
	ans = 0
	ans += (r_r - r_l) * 3
	if (r_l - 1) ** 2 == l:
		ans += 3
	elif l <= r_l ** 2 - r_l:
		ans += 2
	else:
		ans += 1
	if r == (r_r + 1) ** 2 - 1:
		ans += 3
	elif r >= r_r ** 2 + r_r:
		ans += 2
	else:
		ans += 1
	return ans
for i in range(int(input())):
	[l, r] = list(map(int, input().split()))
	print(luxury_number(l, r))


import math
t = int(input())

def f(x) -> int:
	if x == 0:
		return 0
	k = math.floor(math.sqrt(x))
	if x < k * k:
		k -= 1
	if x >= (k + 1) * (k + 1):
		k += 1
	ans = 3 * (k - 1)
	if x >= k * k:
		ans += 1
	if x >= k * (k + 1):
		ans += 1
	if x >= k * (k + 2):
		ans += 1
	return ans
for _ in range(t):
	(l, r) = map(int, input().split())
	print(f(r) - f(l - 1))


def f(x):
	s = int(x ** 0.5)
	if s * s > x:
		s -= 1
	if s * s + 2 * s + 1 <= x:
		s += 1
	if s * s + 2 * s <= x:
		return s * 3
	if s * s + s <= x:
		return s * 3 - 1
	return s * 3 - 2
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(f(r) - f(l - 1))


import os
import math
import collections
import bisect
import functools
import itertools
import heapq

def solve(l, r):

	def count(x):
		if x == 0:
			return 0
		y = int(x ** 0.5)
		while y * y > x:
			y -= 1
		while (y + 1) * (y + 1) <= x:
			y += 1
		res = (y - 1) * 3
		return res + (x - y ** 2) // y + 1
	return count(r) - count(l - 1)
t = int(input())
for _ in range(t):
	arr = input().split(' ')
	(l, r) = (int(arr[0].strip()), int(arr[1].strip()))
	print(solve(l, r))


from math import ceil, floor, gcd, exp, log, isqrt
from functools import lru_cache, reduce
from itertools import combinations, permutations, product, combinations_with_replacement, count, cycle, tee, islice
from collections import Counter
for t in range(int(input())):
	(l, r) = [int(a) for a in input().split()]
	if l == r:
		if l % isqrt(l) == 0:
			print('1')
		else:
			print('0')
		continue
	ll = isqrt(l)
	rr = isqrt(r) + 1
	o = (rr - ll) * 3
	if (rr - 1) ** 2 + (rr - 1) > r:
		o -= 2
	elif (rr - 1) ** 2 + (rr - 1) * 2 > r:
		o -= 1
	if ll ** 2 + ll < l:
		o -= 2
	elif ll ** 2 < l:
		o -= 1
	print(o)


from math import isqrt

def cal(a):
	if a == 0:
		return 0
	if a < 4:
		return a
	t = isqrt(a)
	ans = 3 * (t - 1)
	i = 0
	while t ** 2 + t * i <= a:
		i += 1
	return ans + i
for jj in range(int(input())):
	(l, r) = [int(i) for i in input().split()]
	print(cal(r) - cal(l - 1))


from math import isqrt

def f(n):
	if n == 0:
		return 0
	q = isqrt(n)
	ans = (q - 1) * 3
	i = 0
	while q ** 2 + q * i <= n:
		i += 1
	return ans + i
for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	print(f(y) - f(x - 1))


from math import isqrt

def checkEdgesDown(l, r):
	jump = isqrt(r) - 1
	diff = r - l
	if diff == 0:
		return 1
	if diff < 1 + jump:
		return 2
	return 3

def checkEdgesUp(l, r):
	jump = isqrt(l)
	diff = r - l
	if diff < jump:
		return 1
	if diff < 2 * jump:
		return 2
	return 3

def func1():
	(l, r) = map(int, input().split())
	ans = 0
	above_i = isqrt(l)
	if above_i ** 2 != l:
		above_i += 1
	above_l = above_i ** 2
	under_i = isqrt(r)
	under_r = under_i ** 2
	ans += checkEdgesDown(l, above_l) + checkEdgesUp(under_r, r)
	ans += 2 * (under_i - above_i)
	ans += under_i - above_i - 1
	return ans

def main():
	t = int(input())
	for i in range(t):
		print(func1())
main()


def f(n: int):
	t = int(n ** 0.5)
	if t * t > n:
		t = t - 1
	res = (t - 1) * 3
	if n >= t * t:
		res = res + 1
	if n >= t * t + t:
		res = res + 1
	if n >= t * t + 2 * t:
		res = res + 1
	return res
T = int(input())
for _ in range(T):
	(l, r) = map(int, input().split())
	print(f(r) - f(l - 1))


import math

def f(n):
	if n == 0:
		return 0
	q = math.isqrt(n)
	ans = (q - 1) * 3
	i = 0
	while q ** 2 + q * i <= n:
		i += 1
	return ans + i
t = int(input())
while t:
	t -= 1
	(l, r) = map(int, input().split())
	print(f(r) - f(l - 1))


import math
t = int(input())
for i in range(t):
	(m, n) = list(map(int, input().split()))
	rangem = math.isqrt(m)
	rangen = math.isqrt(n)
	if m == rangem ** 2:
		start = 3
	elif rangem ** 2 < m <= rangem ** 2 + rangem:
		start = 2
	elif rangem ** 2 + rangem < m <= rangem ** 2 + 2 * rangem:
		start = 1
	if rangen ** 2 <= n < rangen ** 2 + rangen:
		end = 1
	elif rangen ** 2 + rangen <= n < rangen ** 2 + 2 * rangen:
		end = 2
	elif rangen ** 2 + 2 * rangen == n:
		end = 3
	if rangem == rangen:
		print(end + start - 3)
	else:
		print(end + start + 3 * (rangen - rangem - 1))


def mysqr(n):
	m = int(n ** 0.5)
	if m * m <= n:
		return m
	return m - 1

def func(n):
	if n == 0:
		return 0
	sn = mysqr(n)
	total = sn * 3 - 2
	if sn * (sn + 1) <= n:
		total += 1
	if sn * (sn + 2) <= n:
		total += 1
	return total
t = int(input())
for _ in range(t):
	(l, r) = map(int, input().split())
	ans = func(r) - func(l - 1)
	print(ans)


import math

def fn(x):
	t = math.floor(x ** 0.5)
	while (t + 1) ** 2 <= x:
		t += 1
	while t ** 2 > x:
		t -= 1
	ans = t * 3
	if t * t + t > x:
		ans -= 1
	if t * t + 2 * t > x:
		ans -= 1
	return ans
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(fn(r) - fn(l - 1))


import math

def sol(l, r):
	(f, s) = (int(math.isqrt(l)), int(math.isqrt(r)))
	c = (s - f - 1) * 3
	c *= c > 0
	if f == s:
		for i in range(3):
			if l <= f * (f + i) <= r:
				c += 1
		return c
	for i in range(3):
		if f * (f + i) >= l:
			c += 1
		if r >= s * (s + i):
			c += 1
	return c
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(sol(l, r))


from math import isqrt

def luxury_number(n):
	if n == 0:
		return 0
	r = isqrt(n)
	ans = (r - 1) * 3
	i = 0
	while r ** 2 + i * r <= n:
		i += 1
	ans += i
	return ans
for i in range(int(input())):
	[l, r] = list(map(int, input().split()))
	print(luxury_number(r) - luxury_number(l - 1))


import math

def intsqrt(n):
	isq = int(math.sqrt(n))
	if isq * isq > n:
		return isq - 1
	else:
		return isq
t = int(input())
for i in range(t):
	(l, r) = input().split()
	l = int(l)
	r = int(r)
	if l == r:
		if l % intsqrt(l) == 0:
			res = 1
		else:
			res = 0
	else:
		a = intsqrt(l)
		b = intsqrt(r)
		res = 0
		if a == b:
			i = a * a
			while i <= r:
				if i >= l:
					res += 1
				i += a
		else:
			aa = a + 1
			bb = b
			res += (bb - aa) * 3
			i = a * a
			while i < (a + 1) ** 2:
				if i >= l:
					res += 1
				i += a
			i = b * b
			while i <= r:
				res += 1
				i += b
	print(res)


from math import isqrt
f = lambda x, r: r * 3 + (x >= (r + 1) * r) + (x >= (r + 2) * r) - 2
for _ in range(int(input())):
	print(sum(((-1) ** i * f(x - i, isqrt(x - i)) for (i, x) in enumerate(map(int, reversed(input().split()))))))


t = eval(input())
import math
for i in range(t):
	(l, r) = map(int, input().split())
	(l1, r1) = (math.floor(math.sqrt(l)), math.floor(math.sqrt(r)))
	if l1 ** 2 > l:
		l1 -= 1
	if r1 ** 2 > r:
		r1 -= 1
	sum = (r1 - l1) * 3
	for i in range(l1 ** 2, l, l1):
		if i % l1 == 0:
			sum -= 1
	for i in range(r1 ** 2, r + 1, r1):
		if i % r1 == 0:
			sum += 1
	print(sum)


def solve(x):
	aa = int(x ** 0.5)
	if aa * aa > x:
		aa -= 1
	if aa * aa + 2 * aa + 1 <= x:
		aa += 1
	if aa * aa + 2 * aa <= x:
		return aa * 3
	if aa * aa + aa <= x:
		return aa * 3 - 1
	return aa * 3 - 2
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(solve(r) - solve(l - 1))


from math import isqrt

def f(x):
	if x == 0:
		return 0
	y = isqrt(x)
	return 3 * (y - 1) + 1 + (x - y ** 2) // y

def solution():
	(l, r) = map(int, input().split())
	return f(r) - f(l - 1)
for case in range(int(input())):
	print('%s' % solution())


def solve(ele):
	ref = int(ele ** 0.5)
	for i in range(ref - 3, ref + 3):
		if i * i <= ele and (i + 1) ** 2 > ele:
			ref = i
	r = -1 if ref * (ref + 1) > ele else 0
	r -= 1 if ref * (ref + 2) > ele else 0
	return ref * 3 + r
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(solve(b) - solve(a - 1))


import math

def floor_sqrt(x):
	r = int(math.floor(math.sqrt(x)))
	r -= 1
	while r * r <= x:
		r += 1
	return r - 1
for t in range(int(input())):
	(l, r) = map(int, input().split())
	(ls, rs) = map(floor_sqrt, [l, r])
	s = [ls ** 2, ls ** 2 + ls, ls ** 2 + 2 * ls, rs ** 2, rs ** 2 + rs, rs ** 2 + 2 * rs]
	s = [si for si in s if l <= si <= r]
	n = len(set(s))
	if rs - ls - 1 > 0:
		n += (rs - ls - 1) * 3
	print(n)


import math

def count(a):
	if a == 0:
		return 0
	if a == 1:
		return 1
	if a == 2:
		return 2
	if a == 3:
		return 3
	if a == 4:
		return 4
	thing = math.floor(math.sqrt(a))
	while (thing + 1) ** 2 <= a:
		thing += 1
	while thing ** 2 > a:
		thing -= 1
	ans = thing ** 2 - max(0, (thing - 2) * (thing - 1))
	if (a - thing ** 2) // thing > 2:
		a = 1 / 0
	ans += (a - thing ** 2) // thing
	return ans
for i in range(int(input())):
	(q, w) = map(int, input().split())
	print(count(w) - count(q - 1))


import math

def f(n):
	if n < 1:
		return 0
	a = max(math.floor(n ** 0.5) - 10, 0)
	while a ** 2 <= n:
		a += 1
	a -= 1
	ans = 3 * a - 2
	if n >= a ** 2 + a:
		ans += 1
	if n >= a ** 2 + a * 2:
		ans += 1
	return ans
t = int(input())
for _ in range(t):
	(l, r) = map(int, input().split())
	print(f(r) - f(l - 1))


from decimal import *
getcontext().prec = 20
num_testcases = int(input())
for _ in range(num_testcases):
	(left, right) = list(map(int, input().split()))
	ans = 0
	k_l = int(Decimal(left).sqrt())
	k_l_squared = k_l ** 2
	if k_l_squared >= left:
		ans += 3
	elif k_l_squared + k_l >= left:
		ans += 2
	else:
		ans += 1
	k_r = int(Decimal(right).sqrt())
	ans += 3 * (k_r - k_l - 1)
	k_r_squared = k_r * k_r
	if k_r_squared + k_r + k_r <= right:
		ans += 3
	elif k_r_squared + k_r <= right:
		ans += 2
	else:
		ans += 1
	print(ans)


import sys
import math

def sqrt(x):
	l = 0
	r = 1000000002
	while r - l > 1:
		c = (l + r) // 2
		if c * c > x:
			r = c
		else:
			l = c
	return l

def f(x):
	if x <= 0:
		return 0
	v = sqrt(x)
	r = v * 3 - 2
	if v * (v + 1) <= x:
		r += 1
		if v * (v + 2) <= x:
			r += 1
	return r

def solve():
	inp = sys.stdin.readline
	(l, r) = map(int, inp().split())
	print(f(r) - f(l - 1))

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


from math import sqrt, floor
from decimal import Decimal

def main():
	t = int(input())
	for i in range(t):
		(l, r) = map(int, input().split())
		k = floor(Decimal(l).sqrt())
		p = floor(Decimal(r).sqrt())
		if k != p:
			s = 3 * (p - k - 1)
			if k ** 2 >= l:
				s += 1
			if k * (k + 1) >= l:
				s += 1
			if k * (k + 2) >= l:
				s += 1
			if p ** 2 <= r:
				s += 1
			if p * (p + 1) <= r:
				s += 1
			if p * (p + 2) <= r:
				s += 1
		else:
			s = 0
			if r >= k ** 2 >= l:
				s += 1
			if r >= k * (k + 1) >= l:
				s += 1
			if r >= k * (k + 2) >= l:
				s += 1
		print(s)
main()


import math
t = eval(input())

def countdays(s):
	if s == 0:
		return 0
	s1 = math.isqrt(s)
	count = 3 * s1 - 2 + s // s1 - s1
	return count
for i in range(t):
	lb = input().split()
	r = eval(lb[0])
	l = eval(lb[1])
	print(countdays(l) - countdays(r - 1))


from math import sqrt, floor

def get_sqrt(n):
	(l, r) = (1, 10 ** 9)
	while l < r:
		mid = (l + r) // 2
		if mid * mid <= n:
			l = mid + 1
		else:
			r = mid - 1
	if l * l <= n:
		return l
	else:
		return l - 1

def get_num(n):
	nn = get_sqrt(n)
	if nn * (nn + 1) > n:
		return (nn - 1) * 3 + 1
	elif nn * (nn + 2) > n:
		return (nn - 1) * 3 + 2
	else:
		return nn * 3
t = int(input())
for _ in range(t):
	(l, r) = input().split()
	(l, r) = (int(l), int(r))
	_sum = get_num(r)
	if l > 1:
		_sum -= get_num(l - 1)
	print(_sum)


def count1(N):
	s = 0
	for n in range(1, N + 1):
		r = int(n ** 0.5)
		if n % r == 0:
			s += 1
	return s

def intsqrt(n):
	if n == 0:
		return 0
	x = n
	while True:
		y = x + n // x >> 1
		if x == y or y == x + 1:
			break
		x = y
	x = min(x, y)
	assert x ** 2 <= n < (x + 1) ** 2
	return x

def count2(N):
	k = intsqrt(N)
	if N >= k * (k + 2):
		return 3 * k
	if N >= k * (k + 1):
		return 3 * k - 1
	return 3 * k - 2
t = int(input())
for i in range(t):
	(l, r) = [int(x) for x in input().split()]
	print(count2(r) - count2(l - 1))


def root(n):
	(left, right) = (0, 10 ** 10)
	ans = 0
	while left <= right:
		mid = (left + right) // 2
		if mid * mid <= n:
			ans = mid
			left = mid + 1
		else:
			right = mid - 1
	return ans
for t in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 1:
		left = 0
	else:
		left_root = root(a - 1)
		left = left_root + 2 * (left_root - 1)
		left += (a - 1 - left_root ** 2) // left_root
	right_root = root(b)
	right = right_root + 2 * (right_root - 1)
	right += (b - right_root ** 2) // right_root
	print(right - left)


t = int(input())
m = 1000000000.0 + 7

def sqrAns(n):
	l = int(0)
	r = int(1000000000.0 + 10)
	while r - l > 1:
		mid = (l + r) // 2
		if mid * mid > n:
			r = mid
		else:
			l = mid
	ans = l * 3 - 2
	for i in range(0, 3):
		if l * (l + i) <= n:
			ans += 1
	return ans

def solve():
	(l, r) = map(int, input().split())
	print(sqrAns(r) - sqrAns(l - 1))
for _ in range(t):
	solve()


import math

def fff(x):
	(l, r) = (1, 1000000001)
	while l < r:
		m = (l + r + 1) // 2
		if m * m <= x:
			l = m
		else:
			r = m - 1
	return l

def ff(x):
	if x == 0:
		return 0
	y = fff(x)
	yy = y * y
	a = (y - 1) * 3 + 1
	if x == yy:
		return a
	elif x < yy + y:
		return a
	elif x != yy + y + y:
		return a + 1
	else:
		return a + 2
t = int(input())
for _ in range(t):
	lr = [int(ii) for ii in input().split()]
	(l, r) = (lr[0], lr[1])
	print(ff(r) - ff(l - 1))


import math

def sqrt(n: int) -> int:
	x = math.floor(math.sqrt(n))
	delta = math.inf
	for i in range(x - 1, x + 1):
		if abs(i * i - n) < delta and i * i <= n:
			delta = abs(i * i - n)
			res = i
	return res

def count(n: int) -> int:
	i = int(sqrt(n) ** 2)
	k = 0
	for _ in range(3):
		if i > n:
			k += 1
		i += sqrt(n)
	return sqrt(n) * 3 - k
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(count(b) - count(a - 1))


import math

def binary_search(x):
	left = 0
	right = 2000000123
	while right > left:
		mid = (left + right) // 2
		if mid * mid > x:
			right = mid
		else:
			left = mid + 1
	return left - 1

def luxury_numbers(l, r):
	left = binary_search(l)
	right = binary_search(r)
	ans = 0
	if left != right:
		ans += (right - left - 1) * 3
	for i in range(3):
		if left * (left + i) >= l and left * (left + i) <= r:
			ans += 1
		if left != right:
			if right * (right + i) >= l and right * (right + i) <= r:
				ans += 1
	print(ans)
T = int(input())
for _ in range(T):
	(l, r) = tuple(map(int, input().split()))
	luxury_numbers(l, r)


import math

def sqrt(n):
	(i, j) = (1, min(n, 1000000000.0 + 1))
	r = 1
	while i < j:
		m = int((i + j) // 2)
		if m * m > n:
			j = m
		else:
			r = m
			i = m + 1
	return r

def solve():
	t = int(input())
	for _ in range(t):
		(I, J) = map(int, input().split())
		i = sqrt(I)
		j = sqrt(J)
		ans = (j - i + 1) * 3
		for k in range(3):
			aux = i * (i + k)
			if aux < I:
				ans -= 1
		for k in range(2, -1, -1):
			aux = j * (j + k)
			if aux > J:
				ans -= 1
		print(ans)
solve()


def sq_root(x):
	(left, right) = (0, 2000000100)
	while right > left:
		mid = left + (right - left) // 2
		if mid * mid > x:
			right = mid
		else:
			left = mid + 1
	return left - 1
test = int(input())
while test:
	(l, r) = map(int, input().split())
	(left, right) = (sq_root(l), sq_root(r))
	range_l = [max(l, left * left), (left + 1) * (left + 1) - 1]
	range_r = [right * right, min(r, (right + 1) * (right + 1))]
	ans = (right - left - 1) * 3
	for i in range(left, left + 3):
		if range_l[0] <= left * i <= range_l[1]:
			ans += 1
	for i in range(right, right + 3):
		if range_r[0] <= right * i <= range_r[1]:
			ans += 1
	print(ans)
	test -= 1


for _ in range(int(input())):
	(l, r) = map(int, input().split())

	def get(x):
		(l, r) = (0, 10 ** 9)
		while l < r:
			mid = (l + r + 1) // 2
			if (mid + 1) * (mid + 1) - 1 <= x:
				l = mid
			else:
				r = mid - 1
		res = 3 * l
		l += 1
		if l * l <= x:
			res += 1
			if l * l + l <= x:
				res += 1
		return res
	print(get(r) - get(l - 1))


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
import math
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

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

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

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

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

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def sqrt1(n):
	a = 1
	b = n
	while a <= b:
		m = a + (b - a) // 2
		if m * m <= n:
			ans = m
			a = m + 1
		else:
			b = m - 1
	return ans
t = inp()
for i in range(t):
	(l, r) = mp()
	l1 = int(sqrt1(l))
	r1 = int(sqrt1(r))
	s = (r1 - l1 - 1) * 3
	if l1 * l1 >= l:
		s += 1
	if l1 * l1 + l1 >= l:
		s += 1
	if l1 * l1 + 2 * l1 >= l:
		s += 1
	if r1 * r1 <= r:
		s += 1
	if r1 * r1 + r1 <= r:
		s += 1
	if r1 * r1 + 2 * r1 <= r:
		s += 1
	print(s)


import sys
input = sys.stdin.readline

def g(x):
	(l, r) = (1, 10 ** 10)
	ans = 0
	while l <= r:
		mid = (l + r) // 2
		if mid ** 2 <= x:
			l = mid + 1
			ans = mid
		else:
			r = mid - 1
	p = 3 * ans
	if x < ans * ans + 2 * ans:
		p -= 1
	if x < ans * ans + ans:
		p -= 1
	return p
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	l -= 1
	print(g(r) - g(l))


from math import comb, perm
import sys
input = sys.stdin.readline

def f(x):
	(l, r) = (1, 10 ** 10)
	ans = 0
	while l <= r:
		mid = (l + r) // 2
		if mid ** 2 <= x:
			l = mid + 1
			ans = mid
		else:
			r = mid - 1
	p = 3 * ans
	if x < ans * ans + 2 * ans:
		p -= 1
	if x < ans * ans + ans:
		p -= 1
	return p
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(f(r) - f(l - 1))


import math

def mySqrt(l):
	low = 0
	high = 10000000000
	while low < high:
		mid = int((low + high) / 2)
		if mid * mid > l:
			high = mid
		else:
			low = mid + 1
	return low - 1

def solve(l, r):
	if l == r:
		temp = mySqrt(l)
		if l % temp == 0:
			print(1)
		else:
			print(0)
	else:
		low = mySqrt(l)
		high = mySqrt(r)
		cnt = 0
		if high == low:
			for i in range(3):
				if low * (low + i) >= l and low * (low + i) <= r:
					cnt = cnt + 1
		else:
			dif = high - low - 1
			for i in range(3):
				if low * (low + i) >= l and low * (low + i) <= r:
					cnt = cnt + 1
			for i in range(3):
				if high * (high + i) >= l and high * (high + i) <= r:
					cnt = cnt + 1
			cnt = cnt + dif * 3
		print(cnt)
t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	solve(l[0], l[1])