A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder.

You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $1\leq a \leq x$ and $1 \leq b \leq y$.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases.

The only line of the description of each test case contains two integers $x$, $y$ ($1 \le x,y \le 10^9$).


-----Output-----

For each test case print the answer on a single line.


-----Examples-----

Input
9
3 4
2 100
4 3
50 3
12 4
69 420
12345 6789
123456 789
12345678 9
Output
1
0
2
3
5
141
53384
160909
36


-----Note-----

In the first test case, the only special pair is $(3, 2)$.

In the second test case, there are no special pairs.

In the third test case, there are two special pairs: $(3, 2)$ and $(4, 3)$.

Difficulty: MEDIUM_HARD
Tags: Number theory

Sorting

Mathematics

Complete search
Skill types: Sorting

Complete search

Starter code:

Solutions:
def array(f):
	return list(map(f, input().split()))

def floor_sum(X, N):
	res = 0
	for i in range(X // N, X + 1):
		if i * i > X:
			for j in range(1, N + 1):
				if X // j >= i:
					res += X // j
				else:
					break
			break
		if i == 0:
			continue
		n = min(X // i, N) - X // (i + 1)
		res += n * i
	return res

def slv():
	(x, y) = map(int, input().split())
	ans = 0
	for b in range(1, y + 1):
		if x // (b + 1) >= b - 1:
			ans += b - 1
		else:
			ans += floor_sum(x, y + 1) - floor_sum(x, b)
			break
	print(ans)
	return

def main():
	T = int(input())
	for _ in range(T):
		slv()
main()


import sys, io, os
if os.environ['USERNAME'] == 'kissz':
	inp = open('in.txt', 'r').readline

	def debug(*args):
		print(*args, file=sys.stderr)
else:
	inp = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

	def debug(*args):
		pass
for _ in range(int(inp())):
	(x, y) = map(int, inp().split())
	ans = 0
	b = min(y, x - 1)
	while b > 1:
		q = x // (b + 1)
		if q >= b - 1:
			ans += b * (b - 1) // 2
			break
		else:
			r = x - q * (b + 1)
			k = (b - r) // (q + 1) + 1
			ans += q * k
			b -= k
	print(ans)


def solve(x, y):
	res = 0
	r = 1
	while r * (r + 2) <= x:
		res += max(0, min(y, x // r - 1) - r)
		r += 1
	return res
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	print(solve(x, y))


T = int(input())
for i in range(T):
	(x, y) = map(int, input().split())
	ans = 0
	for k in range(1, int(pow(x, 1 / 2)) + 1):
		ans += max(0, min(x // k - 1, y) - k)
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ans = 0
	c = 1
	while c * c <= a:
		x = (a - c) // c
		if x > b:
			x = b
		ans += max(x - c, 0)
		c += 1
	print(ans)


import sys
input = sys.stdin.readline
import math
t = int(input())
for f in range(t):
	(x, y) = map(int, input().split())
	ok = 1
	ng = y + 1
	while ng - ok > 1:
		c = (ng + ok) // 2
		if c * c - 1 <= x:
			ok = c
		else:
			ng = c
	ans = 0
	ans += ok * (ok - 1) // 2
	if ok != y:
		divisor = 1
		while x // divisor > ng:
			ans += min(x // divisor - 1, y) - ng + 1
			divisor += 1
	print(ans)


import sys
import math
from collections import defaultdict, Counter, deque
import os
import sys
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')
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	ans = 0
	for k in range(1, int(math.sqrt(x)) + 1):
		cur = min(y, x // k - 1) - k
		ans += max(0, cur)
	print(ans)


import math
for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	ans = 0
	k = math.ceil(x ** 0.5)
	for j in range(1, k + 1):
		ans += max(0, min(y, x // j - 1) - j)
	print(ans)


import math, sys
from collections import defaultdict, Counter, deque
from bisect import bisect_left, bisect_right
INF = float('inf')
MOD = int(1000000000.0) + 7
MAX = int(1000000.0) + 1

def get(n):
	return n * (n - 1) // 2

def solve():
	(x, y) = vars()
	ans = 0
	for i in range(1, math.ceil(x ** 0.5) + 1):
		till = min(y, x // i - 1) - i
		ans += max(0, till)
	print(ans)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)
primes = [1 for i in range(MAX)]

def sieve():
	global primes
	primes[0] = primes[1] = 0
	i = 2
	while i <= MAX ** 0.5:
		j = i * i
		while primes[i] and j < MAX:
			if j % i == 0:
				primes[j] = 0
			j += i
		i += 1

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

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


import sys
input = sys.stdin.readline
from math import sqrt
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	cur = 0
	n = min(int(sqrt(x + 1)), y) - 1
	cur = (1 + n) * n // 2
	j = min(int(sqrt(x + 1)), y) + 1
	while j < min(y + 1, x + 2):
		k = x // (j + 1)
		if not k:
			break
		jj = x // k
		cur += k * (min(y + 1, jj) - j)
		j = jj
	print(cur)


for t in range(int(input())):
	(a, b) = [int(x) for x in input().rstrip().split()]
	count = 0
	for i in range(1, min(a - 1, b)):
		c = a // i - 1
		if c <= i:
			break
		else:
			count += min(c, b) - i
	print(count)


import os
import sys
from io import BytesIO, IOBase

def func(x, y):
	count = 0
	b = y
	if x == 1 and y == 1:
		return 0
	if b >= x:
		b = x
	tmp = x // b + 1
	while b > 0:
		for remainder in range(min(b - 1, tmp), 0, -1):
			if b * remainder + remainder <= x:
				if remainder == b - 1:
					count += b * (b - 1) // 2
					return count
				count += remainder
				break
		new_b = x // tmp
		if new_b < b:
			count += (b - new_b - 1) * (tmp - 1)
			b = new_b
			tmp += 1
		else:
			b -= 1
	return count

def main():
	num_test = int(parse_input())
	for _ in range(num_test):
		(x, y) = [int(i) for i in parse_input().split()]
		print(func(x, y))
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))
parse_input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for t in range(int(input())):
	(x, y) = map(int, input().split())
	res = 0
	k = 1
	while k * (k + 1) < x and k < y:
		res += min(y, x // k - 1) - k
		k += 1
	print(res)


def solve():
	(x, y) = list(map(int, input().split(' ')))
	ans = 0
	i = 1
	while i * i < x:
		ans += max(min(y, x // i - 1) - i, 0)
		i += 1
	print(ans)
t = int(input())
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	count = 0
	for x in range(1, 1000000):
		a_fits = (a - x) // x
		if a_fits < x or b < x:
			continue
		count += min(a_fits, b) - x
	print(count)


from sys import *
input = stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	for i in range(1, int(a ** 0.5) + 1):
		curr = max(0, min(b, a // i - 1) - i)
		ans += curr
	print(ans)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	s = 0
	for i in range(1, min(x - 1, y)):
		c = x // i - 1
		if c <= i:
			break
		s += min(c, y) - i
	print(s)


import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	(x, y) = map(int, input().split())
	k = 1
	ans = 0
	while k * (k + 2) <= x:
		mx = x // k
		ans += max(0, min(y + 1, mx) - (k + 2) + 1)
		k += 1
	print(ans)


import sys, io, os, math, time
from math import ceil, log, gcd, inf, floor, sqrt
from itertools import permutations
import datetime
mod = 1000000007
mod1 = 998244353

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

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

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

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

def flush():
	return sys.stdout.flush()

def power_two(x):
	return 1 << x

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

def power(a, n, p):
	res = 1
	while n:
		if n & 1:
			res = res * a
			n -= 1
		else:
			a = a * a
			n = n // 2
	return res

def solution():
	(a, b) = mulinp()
	ans = 0
	for i in range(1, int(sqrt(a)) + 1):
		ans += max(min(b, a // i - 1) - i, 0)
	print(ans)

def main():
	tc = intinp()
	while tc:
		solution()
		tc -= 1
main()


import math

def solve():
	(x, y) = map(int, input().split())
	ds = 0
	i = 1
	while i * i < x:
		ds += max(min(y, x // i - 1) - i, 0)
		i += 1
	print(ds)
	return
t = int(input())
for _ in range(t):
	solve()


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	flag = 0
	save = 0
	total = 0
	rem = 1
	while (rem + 1) * rem + rem <= x and rem < y:
		q = (x - rem) // rem
		q = min(y, q)
		total += q - (rem + 1) + 1
		rem += 1
	print(total)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	t = int(x ** 0.5)
	s = 0
	for i in range(1, t + 1):
		s += max(0, min(y, x // i - 1) - i)
	print(s)


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	a = 0
	j = 2
	while j <= y:
		if j * j - 1 <= x:
			a += j - 1
			j += 1
		else:
			k = x // j
			if k * j + k > x:
				k -= 1
			if k == 0:
				break
			l = (x - k) // k
			m = min(y, l)
			a += k * (m - j + 1)
			j = m + 1
	print(a)
	t -= 1


from io import StringIO
from sys import stdin, stdout
inp_ints = map(int, stdin.read().split())
read_int = inp_ints.__next__
output = StringIO()

def f(max_a, max_b):
	b_q = floor_sqrt(max_a)
	b_n_fst = min(b_q, max_b)
	variants_n_fst = b_n_fst * (b_n_fst + 1) // 2 + -1 * b_n_fst
	if b_q >= max_b:
		variants_n_snd = 0
	else:
		variants_n_snd = p(max_a, max_b + 2 - 1) - p(max_a, b_q + 2 - 1)
	return variants_n_fst + variants_n_snd

def p(x, max_div):
	if x == 0:
		return 0
	max_div = min(max_div, x)
	p_c = floor_sqrt(x)
	(result, next_d) = __p_fst_half(x, max_div, p_c)
	if next_d > max_div:
		return result
	min_div_res = x // max_div
	for div_res in range(min_div_res, x // p_c):
		if div_res == min_div_res:
			max_d = max_div
			min_d = 1
			while min_d != max_d:
				mid_d = (min_d + max_d) // 2
				if x // mid_d == min_div_res:
					max_d = mid_d
				else:
					min_d = mid_d + 1
			result += (max_div - min_d + 1) * min_div_res
			continue
		result += (x // div_res - x // (div_res + 1)) * div_res
	return result

def __p_fst_half(x, max_div, fst_size):
	assert max_div <= x
	result = sum((x // d for d in range(1, min(max_div, fst_size) + 1)))
	d = fst_size + 1
	while x // d == x // fst_size and d <= max_div:
		result += x // d
		d += 1
	return (result, d)

def floor_sqrt(x):
	assert x >= 0
	min_sqrt = 0
	max_sqrt = max(x, 1)
	while min_sqrt != max_sqrt:
		mid_sqrt = (min_sqrt + max_sqrt + 1) // 2
		if mid_sqrt ** 2 <= x:
			min_sqrt = mid_sqrt
		else:
			max_sqrt = mid_sqrt - 1
	return min_sqrt
t_n = read_int()
for i_t in range(t_n):
	(x, y) = (read_int(), read_int())
	result = f(x, y)
	output.write(str(result))
	output.write('\n')
stdout.write(output.getvalue())


for i in range(int(input())):
	(a, b) = map(int, input().split())
	sumo = 0
	for j in range(1, b + 1):
		if a // j <= j + 1 or b - j <= 0:
			break
		sumo = sumo + min(a // j - 1, b) - j
	print(sumo)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(ans, i) = (0, 1)
	while i * i <= x:
		(ans, i) = (ans + max(0, min(y, x // i - 1) - i), i + 1)
	print(ans)


import math
from math import sqrt
for i in range(int(input())):
	(x, y) = map(int, input().split())
	n = 0
	t = int(sqrt(x))
	for k in range(1, int(sqrt(x)) + 1):
		n += max(0, min(y, x // k - 1) - k)
	print(n)


from math import sqrt, floor
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	ans = 0
	t = min(floor(sqrt(x)), y)
	ans += t * (t - 1) // 2
	if y > t:
		l = t + 2
		r = y + 1
		i = 1
		while 1:
			r1 = x // i
			l1 = x // (i + 1) + 1
			if r >= l1 and l <= r1:
				ans += (min(r, r1) - max(l, l1) + 1) * i
			if x == i:
				break
			i = x // (x // (i + 1))
	print(ans)


def f(max_a, max_b):
	b_q = floor_sqrt(max_a)
	b_n_fst = min(b_q, max_b)
	variants_n_fst = b_n_fst * (b_n_fst + 1) // 2 + -1 * b_n_fst
	if b_q >= max_b:
		variants_n_snd = 0
	else:
		variants_n_snd = p(max_a, max_b + 2 - 1) - p(max_a, b_q + 2 - 1)
	return variants_n_fst + variants_n_snd

def p(x, max_div):
	max_div = min(max_div, x)
	min_div_result_to_take = floor_sqrt(x)
	result = __p_brute(x, max_div, min_div_result_to_take)
	min_div_result_possible = x // max_div
	if min_div_result_possible >= min_div_result_to_take:
		return result
	max_d = max_div
	min_d = 1
	while min_d != max_d:
		mid_d = (min_d + max_d) // 2
		if x // mid_d == min_div_result_possible:
			max_d = mid_d
		else:
			min_d = mid_d + 1
	result += (max_div - min_d + 1) * min_div_result_possible
	for div_res in range(min_div_result_possible + 1, min_div_result_to_take):
		result += (x // div_res - x // (div_res + 1)) * div_res
	return result

def __p_brute(x, max_div, min_res_to_take):
	max_div = min(max_div, x)
	result = 0
	for d in range(1, max_div + 1):
		div_res = x // d
		if div_res < min_res_to_take:
			break
		result += div_res
	return result

def floor_sqrt(x):
	assert x >= 0
	min_sqrt = 0
	max_sqrt = max(x, 1)
	while min_sqrt != max_sqrt:
		mid_sqrt = (min_sqrt + max_sqrt + 1) // 2
		if mid_sqrt ** 2 <= x:
			min_sqrt = mid_sqrt
		else:
			max_sqrt = mid_sqrt - 1
	return min_sqrt

def read_ints():
	return map(int, input().split())
(t_n,) = read_ints()
for i_t in range(t_n):
	(x, y) = read_ints()
	result = f(x, y)
	print(result)


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	t = 0
	for i in range(1, int(math.sqrt(x)) + 1):
		t += max(0, min(x // i - 1, y) - i)
	print(t)


def testcase():
	[X, Y] = [int(c) for c in input().split()]
	res = 0
	b = 1
	while b ** 2 - 1 <= X and b <= Y:
		res += b - 1
		b += 1
	c = 1
	while c < b:
		hi = X // c - 1
		lo = (X + c + 1) // (c + 1) - 1
		res += c * max(min(Y, hi) - max(b, lo) + 1, 0)
		c += 1
	print(res)
T = int(input())
for i in range(T):
	testcase()


for nt in range(int(input())):
	(x, y) = map(int, input().split())
	ans = 0
	for i in range(1, int(x ** 0.5) + 1):
		ans += max(min(y, x // i - 1) - i, 0)
	print(ans)


t = int(input())
for _ in range(t):

	def main():
		(x, y) = map(int, input().split())
		res = 0
		cur = 1
		while 1:
			end = min(x // cur - 1, y)
			if end < cur + 1:
				return res
			res += end - cur
			cur += 1
	print(main())


import sys
input = sys.stdin.readline
from sys import stdin, stdout
from collections import defaultdict, Counter
M = 10 ** 9 + 7

def main():
	for _ in range(int(input())):
		(x, y) = [int(s) for s in input().split()]
		k = 1
		ans = 0
		while k * k <= x:
			ans += max(0, min(y, x // k - 1) - k)
			k += 1
		print(ans)
main()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	ans = 0
	num = 0
	ok = False
	while num * (num + 2) <= x:
		num += 1
		ans += num - 1
		if y == num:
			ok = True
			break
	if ok:
		print(ans)
		continue
	t = x // (num + 2)
	now = num + 2
	while t:
		s = x // t
		if s <= y + 1:
			ans += t * (s - now + 1)
			now = s + 1
			t -= 1
		else:
			ans += t * (y + 1 - now + 1)
			break
	print(ans)


import math
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	count = 0
	for i in range(1, math.ceil(math.sqrt(x))):
		count += max(0, min(y, x // i - 1) - i)
	print(count)


import math
for tt in range(int(input())):
	(x, y) = map(int, input().split())
	ans = 0
	for i in range(1, int(math.sqrt(x)) + 1):
		ans += max(0, min(y, x // i - 1) - i)
	print(ans)


for t in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	x = int((a + 1) ** 0.5) + 2
	for i in range(1, x):
		ans += max(0, min((a - i) // i, b) - i)
	print(ans)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	ans = 0
	a = 3
	for b in range(2, y + 1):
		if x - a < 0:
			break
		z = min(y - b + 1, (x - a) // (b - 1) + 1)
		a += 2 * b + 1
		ans += z
	print(ans)


from math import ceil, floor

def func(x, y):
	if x <= 1000 or y <= 1000:
		ans = 0
		for i in range(2, y + 1):
			ans += min(x // (i + 1), i - 1)
			if i > x:
				return ans
		return ans
	ans = 0
	for i in range(2, y + 1):
		if i - 1 >= x // (i + 1):
			break
		else:
			tmp = i - 1
			ans += tmp
	if i - 1 < x // (i + 1):
		return ans
	MAX = x // (i + 1)
	MIN = x // (y + 1)
	xx = 0
	for i in range(MAX, MIN, -1):
		ans += i * (floor(x / i) - ceil(x / (i + 1)) + 1)
		if x % (i + 1) == 0:
			ans -= i
	ans += MIN * (y - floor(x / (MIN + 1)) + 1)
	return ans
n = int(input())
for i in range(n):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	print(func(x, y))


def answer():
	ans = 0
	for i in range(1, b + 1):
		val = min(a // i, b + 1) - i - 1
		if val <= 0:
			break
		ans += val
	return ans
for T in range(int(input())):
	(a, b) = map(int, input().split())
	print(answer())


from pprint import pprint
import sys
input = sys.stdin.readline

def do():
	(a, b) = map(int, input().split())
	if a == 1:
		print(0)
		return
	res = 0
	i = 1
	while True:
		init = i * (i + 2)
		rest = a - init
		if rest < 0:
			break
		cnt = rest // i + 1
		res += max(0, min(cnt, b - i))
		i += 1
	print(res)
q = int(input())
for _ in range(q):
	do()


t = int(input())
for _ in range(t):
	(x, y) = (int(i) for i in input().split())
	(k, res) = (1, 0)
	while True:
		temp = min(x // k - k - 1, y - k)
		if temp <= 0:
			break
		res += temp
		k += 1
	print(res)


from math import sqrt
t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	k = 1
	z = sqrt(x)
	total = 0
	while k < z:
		total += max(0, min(y, x // k - 1) - k)
		k += 1
	print(total)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(a, b) = map(int, stdin.readline().split())
	ans = 0
	d = 1
	while d * (d + 2) <= a:
		x = a // d - (d + 1)
		y = b - d
		ans += max(0, min(x, y))
		d += 1
	print(ans)


for test_case in range(int(input())):
	(x, y) = map(int, input().split())
	ans = 0
	for k in range(1, y):
		w = min(y, x // k - 1) - k
		if w <= 0:
			break
		ans += w
	print(ans)


from math import sqrt
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	lim = int(sqrt(x)) + 2
	ans = 0
	for i in range(1, lim):
		ans += max(0, min(y, x // i - 1) - i)
	print(ans)


t = int(input())
for lll in range(0, t):
	(x, y) = map(int, input().split())
	print(sum((max(0, min(y, x // i - 1) - i) for i in range(1, int(x ** 0.5) + 1))))


import sys
input = sys.stdin.readline

def solve():
	(x, y) = map(int, input().split())
	if x < 3 or y < 2:
		return 0
	ans = 0
	for i in range(3, min(10 ** 5 + 4, y + 2)):
		if i * (i - 2) > x:
			break
		ans += min(x // (i - 2), y + 1) - i + 1
	return ans
for _ in range(int(input())):
	print(solve())


from math import sqrt
for _ in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	(ans, fl) = (0, False)
	for k in range(1, int(sqrt(x)) + 1):
		ans += max(0, min(y, x // k - 1) - k)
	print(ans)


def db(*arg):
	print(*arg)
T = int(input())
ans_ls = [0] * T
for t in range(T):
	(A, B) = map(int, input().split())
	ans = 0
	for k in range(1, int(A ** 0.5) + 10):
		big_b = A // k - 1
		big_b = min(big_b, B)
		add = max(0, big_b - k)
		ans += add
	ans_ls[t] = ans
for ans in ans_ls:
	print(ans)


from math import ceil, sqrt
t = int(input())
for _ in range(t):
	(x, y) = [int(x) for x in input().split()]
	t = min(ceil(sqrt(x + 1.25)), y + 1)
	print((t - 2) * (t - 1) // 2 + sum([a * (min(y + 1, x // a) - max(t + 1, (x + a + 1) // (a + 1)) + 1) for a in range(max(1, x // (y + 1)), x // (t + 1) + 1)]))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	total = 0
	for i in range(1, b + 1):
		c = a // i - 1
		val = min(c, b) - i
		if val <= 0:
			break
		total += val
	print(total)


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

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(x, y) = inputnums()
	ans = 0
	i = 1
	while i * (i + 1) < x:
		ans += max(0, min(y, x // i - 1) - i)
		i += 1
	print(ans)


from sys import stdin
input = stdin.readline

def calc(n):
	return n * (n - 1) + n - 1

def cal(n, deg):
	return n * deg + deg

def bin(x):
	start = 1
	end = x
	while start <= end:
		mid = (start + end) // 2
		if calc(mid) <= x < calc(mid + 1):
			return mid
		elif calc(mid) <= x and calc(mid + 1) <= x:
			start = mid + 1
		else:
			end = mid - 1
	return start

def nbin(x, deg):
	start = 1
	end = x
	while start <= end:
		mid = (start + end) // 2
		if cal(mid, deg) <= x < cal(mid + 1, deg):
			return mid
		elif cal(mid, deg) <= x and cal(mid + 1, deg) <= x:
			start = mid + 1
		else:
			end = mid - 1
	return start
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = bin(x)
	if a >= y:
		print(y * (y - 1) // 2)
	else:
		ans = a * (a - 1) // 2
		deg = a
		while a < y and deg > 0:
			deg -= 1
			newa = nbin(x, deg)
			if newa < y:
				ans += deg * (newa - a)
			else:
				ans += deg * (y - a)
			a = newa
		print(ans)


def find():
	(x, y) = map(int, input().split())
	s = 0
	for j in range(1, int(x ** 0.5) + 1):
		s += max(0, min(y, x // j - 1) - j)
	return s
for i in range(int(input())):
	print(find())


p = lambda : list(map(int, input().split()))
for _ in '.' * p()[0]:
	(a, b) = p()
	s = j = 0
	while j < b:
		j += 1
		if a <= j * j + j or b <= j:
			break
		s += min(a // j - 1, b) - j
	print(s)


import collections
import string
import math
import copy
import os
import sys
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')
mo = 998244353

def exgcd(a, b):
	if not b:
		return (1, 0)
	(y, x) = exgcd(b, a % b)
	y -= a // b * x
	return (x, y)

def getinv(a, m):
	(x, y) = exgcd(a, m)
	return --1 if x == 1 else x % m

def comb(n, b):
	res = 1
	b = min(b, n - b)
	for i in range(b):
		res = res * (n - i) * getinv(i + 1, mo) % mo
	return res % mo

def quickpower(a, n):
	res = 1
	while n:
		if n & 1:
			res = res * a % mo
		n >>= 1
		a = a * a % mo
	return res

def dis(a, b):
	return abs(a[0] - b[0]) + abs(a[1] - b[1])

def getpref(x):
	if x > 1:
		return x * (x - 1) >> 1
	else:
		return 0

def orafli(upp):
	primes = []
	marked = [False for i in range(upp + 3)]
	for i in range(2, upp):
		if not marked[i]:
			primes.append(i)
		for j in primes:
			if i * j >= upp:
				break
			marked[i * j] = True
			if i % j == 0:
				break
	return primes
history = {}
askctr = 0

def ask(s):
	global askctr, history
	if s in history:
		return history[s]
	askctr += 1
	print(f'? {s}', flush=True)
	ret = int(input())
	hisadd(s, ret)
	chkans(s)
	return ret

def answer(s):
	print(f'! {s}', flush=True)

def getans(history, l, r):
	for i in range(l, r + 1):
		ask(i)
		history[i] = int(input())
		if i == 2:
			if 1 in history:
				if history[2] > history[1]:
					answer(1)
					return
		elif i - 1 in history and i - 2 in history:
			if history[i - 1] < history[i - 2] and history[i - 1] < history[i]:
				answer(i - 1)
				return

def chkans(i):
	global history, n
	if i == 1:
		if history.get(2, 0) > history.get(1, 999999999):
			answer(1)
			exit(0)
			return True
	elif i == n:
		if history.get(n - 1, 0) > history.get(n, 999999999):
			answer(n)
			exit(0)
			return True
	elif history.get(i - 1, 0) > history.get(i, 99999999) < history.get(i + 1, 0):
		if 0 < i <= n:
			answer(i)
			exit(0)
			return True
	return False

def hisadd(pos, val):
	global history
	if val == 1:
		answer(pos)
		exit(0)
		return True
	else:
		history[pos] = val
		return chkans(pos)

def solve():
	(A, B) = map(int, input().split())
	tot = 0
	p = B - 1 - (A - 2)
	i = 1
	while 1:
		d = min(A // i - 1 - i, B - i)
		if d > 0:
			tot += d
		else:
			break
		i += 1
	print(tot)
t = int(input())
for ti in range(t):
	solve()


t = int(input())
for i in range(t):
	l1 = input().split(' ')
	(x, y) = (int(l1[0]), int(l1[1]))
	s = 0
	for j in range(1, y):
		k = (x - j) // j
		if k <= j:
			break
		s += min(k, y) - j
		j += 1
	print(s)


import math
import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(x, y) = map(int, input().split())
		i = 2
		ans = 0
		if x > 2:
			while i ** 2 - 1 <= x and i <= y:
				if x > i ** 2 - 1 + (y - i) * (i - 1):
					ans += y - i + 1
				else:
					ans += (x - (i ** 2 - 1)) // (i - 1) + 1
				i += 1
		print(ans)
main()


from sys import stdin
input = stdin.readline
T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	res = 0
	for i in range(1, 35000):
		rb = (a - i) // i
		rb = min(rb, b) - i
		if rb > 0:
			res += rb
	print(res)


def main():
	t = int(input())
	allAns = []

	def findNext(b, x, y):
		add = y
		change = calcChange(x, b)
		while add > 0:
			while b + add <= y and calcChange(x, b + add) == change:
				b += add
			add //= 2
		return b + 1

	def calcChange(x, b):
		return x // (b + 1)
	for _ in range(t):
		(x, y) = readIntArr()
		ans = 0
		turningPoint = int((1 + x) ** 0.5)
		turningPoint = min(turningPoint, y)
		ans += (0 + turningPoint - 1) * turningPoint // 2
		b = turningPoint + 1
		while b <= y:
			nextB = findNext(b, x, y)
			change = calcChange(x, b)
			assert change <= b - 1
			assert nextB <= y + 1
			ans += change * (nextB - b)
			b = nextB
		allAns.append(ans)
	multiLineArrayPrint(allAns)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]
inf = float('inf')
MOD = 10 ** 9 + 7
main()


import os
import sys
from io import BytesIO, IOBase
from collections import deque

def solve():
	(a, b) = inLst()
	res = 0
	for k in range(1, int(a ** 0.5) + 1):
		maxVal = min(b, a // k - 1)
		minVal = k
		res += max(0, maxVal - minVal)
	return res

def main():
	for _ in range(inInt()):
		outInt(solve())
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')
inInt = lambda : int(input())
inLst = lambda : list(map(int, input().split()))
inStr = lambda : list(input())
inVar = lambda : map(int, input().split())
outInt = lambda n: sys.stdout.write(str(n) + '\n')
outLst = lambda lst: sys.stdout.write(' '.join(map(str, lst)) + '\n')
outStr = lambda s: sys.stdout.write(''.join(s) + '\n')
main()


from math import sqrt
T = int(input())
while T > 0:
	T -= 1
	d = [int(x) for x in input().split()]
	ans = 0
	for k in range(1, int(sqrt(d[0])) + 1):
		ans += max(0, min((d[0] - k) // k, d[1]) - k)
	print(ans)


def main():
	t = int(input())
	for _ in range(t):
		(x, y) = map(int, input().split())
		total = 0
		for i in range(1, int(x ** 0.5) + 1):
			maxx = min(i * y + i, x)
			total += max(0, maxx // i - (i + 1))
		print(total)
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = 0
	i = 1
	while True:
		t = min(b, (a - i) // i) - i
		if t > 0:
			s += t
		else:
			break
		i += 1
	print(s)


from math import *
t = int(input())
while t:
	xy = [int(a) for a in input().split()]
	x = xy[0]
	y = xy[1]
	ans = 0
	for i in range(1, ceil(sqrt(x))):
		ans += max(min(y, x // i - 1) - i, 0)
	print(ans)
	t = t - 1


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
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')

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

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

def N():
	return int(input())

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

def AI(n, x):
	return [x] * n

def G(n):
	return [[] for i in range(n)]

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
mod = 10 ** 9 + 7
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	fact(x, mod)
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa.reverse()

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

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

def floorsum(a, b, c, n):
	if a == 0:
		return b // c * (n + 1)
	if a >= c or b >= c:
		return floorsum(a % c, b % c, c, n) + b // c * (n + 1) + a // c * n * (n + 1) // 2
	m = (a * n + b) // c
	return n * m - floorsum(c, c - b - 1, a, m - 1)

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

def lowbit(n):
	return n & -n

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class ST:

	def __init__(self, arr):
		n = len(arr)
		mx = n.bit_length()
		self.st = [[0] * mx for i in range(n)]
		for i in range(n):
			self.st[i][0] = arr[i]
		for j in range(1, mx):
			for i in range(n - (1 << j) + 1):
				self.st[i][j] = max(self.st[i][j - 1], self.st[i + (1 << j - 1)][j - 1])

	def query(self, l, r):
		if l > r:
			return -inf
		s = (r + 1 - l).bit_length() - 1
		return max(self.st[l][s], self.st[r - (1 << s) + 1][s])

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return flag

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		seen.add(u)
		for (v, w) in graph[u]:
			if v not in d or d[v] > d[u] + w:
				d[v] = d[u] + w
				heappush(heap, (d[v], v))
	return d

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

def lis(nums):
	res = []
	for k in nums:
		i = bisect.bisect_left(res, k)
		if i == len(res):
			res.append(k)
		else:
			res[i] = k
	return len(res)

def RP(nums):
	n = len(nums)
	s = set(nums)
	d = {}
	for (i, k) in enumerate(sorted(s), 1):
		d[k] = i
	bi = BIT([0] * (len(s) + 1))
	ans = 0
	for i in range(n - 1, -1, -1):
		ans += bi.query(d[nums[i]] - 1)
		bi.update(d[nums[i]], 1)
	return ans

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def nb(i, j, n, m):
	for (ni, nj) in [[i + 1, j], [i - 1, j], [i, j - 1], [i, j + 1]]:
		if 0 <= ni < n and 0 <= nj < m:
			yield (ni, nj)

def topo(n):
	q = deque()
	res = []
	for i in range(1, n + 1):
		if ind[i] == 0:
			q.append(i)
			res.append(i)
	while q:
		u = q.popleft()
		for v in g[u]:
			ind[v] -= 1
			if ind[v] == 0:
				q.append(v)
				res.append(v)
	return res

@bootstrap
def gdfs(r, p):
	if len(g[r]) == 1 and p != -1:
		yield None
	for ch in g[r]:
		if ch != p:
			yield gdfs(ch, r)
	yield None
t = N()
for i in range(t):
	(x, y) = RL()
	ans = 0
	k = 1
	while k * (k + 2) <= x and k + 1 <= y:
		ma = min(x // k - 1, y)
		mi = k + 1
		ans += ma - mi + 1
		k += 1
	print(ans)


import sys, math
input = sys.stdin.readline

def bf(x, y):
	ans = 0
	for i in range(1, x + 1):
		for j in range(1, y + 1):
			if i // j == i % j:
				print(i, j)
				ans = ans + 1
	return ans
T = int(input())
for _ in range(T):
	(x, y) = map(int, input().split())
	ans = 0
	ct = 1
	while True:
		cnt = (x - ct) // ct
		val = min(cnt, y)
		cnt = val - ct
		if cnt <= 0:
			break
		ans = ans + cnt
		ct = ct + 1
	print(ans)


al = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	ans = 0
	for r in range(1, x):
		if r * r >= x:
			break
		cmin = r + 2
		cmax = min(x // r, y + 1)
		cnt = cmax - cmin + 1
		ans += max(0, cnt)
	al.append(ans)
for a in al:
	print(a)


import math

def spceial_numbers(x, y):
	sum = 0
	for k in range(1, int(math.sqrt(x)) + 1):
		sum += max(0, min(y, x // k - 1) - k)
	return sum
t = int(input())
for i in range(t):
	(x, y) = [int(i) for i in input().split()]
	print(spceial_numbers(x, y))


import bisect
from itertools import accumulate, count
import os
import sys
import math
from decimal import *
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	for i in range(2, len(primes)):
		if primes[i] == True:
			prime.append(i)
	return prime

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

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)

def NcR(n, r):
	p = 1
	k = 1
	if n - r < r:
		r = n - r
	if r != 0:
		while r:
			p *= n
			k *= r
			m = math.gcd(p, k)
			p //= m
			k //= m
			n -= 1
			r -= 1
	else:
		p = 1
	return p

def Log2(x):
	if x == 0:
		return False
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	ans = 0
	m = int(x ** 0.5 + 10)
	for i in range(1, min(y, m)):
		ans += min(max(x // i - (i + 1), 0), y + 1 - (i + 1))
	print(ans)


import math
t = int(input())
for _ in range(t):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	ans = 0
	for i in range(1, int(math.ceil(math.sqrt(x)))):
		ans += max(min(y, x // i - 1) - i, 0)
	print(ans)


import sys
input = sys.stdin.readline
INF = int(1000000000.0)
import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	result = 0
	c = int(math.sqrt(a + 1))
	if b < c:
		result = b * (b - 1) // 2
		print(result)
		continue
	result += c * (c - 1) // 2
	for i in range(c - 1, 0, -1):
		if a // i - 1 >= b:
			result += (b + 1 - (c + 1)) * i
			break
		result += a // i - (c + 1)
	print(result)


from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil

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

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

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

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

def pr(n):
	return stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	(n, m) = mp()
	ans = 0
	i = 1
	while i * i < n:
		ans += max(0, min(m, n // i - 1) - i)
		i += 1
	pr(ans)
for _ in range(inp()):
	solve()


for p in [*open(0)][1:]:
	(a, b) = map(int, p.split())
	s = 0
	j = 0
	while j < b:
		j += 1
		if a <= j * j + j or b <= j:
			break
		s += min(a // j - 1, b) - j
	print(s)


def solve(y, x):
	ct = 0
	for i in range(1, 100000):
		mx = i + 1
		my = i * (mx + 0)
		z = min(x - mx + 1, (y - my) // i)
		if z < 0:
			break
		ct += z
	return ct
t = int(input())
for _ in range(t):
	(x, y) = [int(i) for i in input().split()]
	print(solve(x, y))


for _ in range(int(input())):
	from math import floor
	(x, y) = map(int, input().split(' '))
	ans = 0
	for k in range(1, min(floor((x + 1) ** 0.5 - 1) + 1, y)):
		ans = ans + min(floor(x / k - 1), y) - (k + 1) + 1
	print(ans)


t = int(input())
for _ in range(t):
	(x, y) = (int(x) for x in input().split())
	ans = 0
	for i in range(1, int(x ** 0.5) + 1):
		k = min((x - i) // i - i, y - i)
		if k <= 0:
			break
		ans += k
	print(ans)


from math import sqrt
import operator
import sys
inf = sys.stdin
input = inf.readline

def read_one_int():
	return int(input().rstrip('\n'))

def read_list_of_ints():
	res = [int(val) for val in input().rstrip('\n').split(' ')]
	return res

def read_str():
	return input().rstrip()

def check_seq(x, y):
	res = 0
	if y < 2 or x < 3:
		return res
	k = 1
	while k * k <= x:
		res += max(0, min(y, x // k - 1) - k)
		k += 1
	return res

def main():
	samples = read_one_int()
	for _ in range(samples):
		(x, y) = read_list_of_ints()
		cur_res = check_seq(x, y)
		print(cur_res)
main()


import math
import sys

def inpu():
	return sys.stdin.readline().strip()
T = int(input())
for t in range(T):
	(x, y) = map(int, input().split())
	d = False
	if y - 1 < x // (y + 1):
		print(y * (y - 1) // 2)
		continue
	upper = y
	lower = 0
	while upper > lower + 1:
		middle = (upper + lower) // 2
		if middle - 1 < x // (middle + 1):
			lower = middle
		else:
			upper = middle
	if middle == x // (middle + 2):
		middle += 1
	ans = max(middle * (middle - 1) // 2, 0)
	ans2 = ans
	br = 0
	xi0 = middle + 1
	for i in range(middle - 1, 0, -1):
		ans += i * (x // i - xi0)
		br += 1
		if x // i > y:
			ans -= i * (x // i - y - 1)
			break
		xi0 = x // i
	print(ans)


import os
import sys
from io import BytesIO, IOBase
_print = print
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')

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

def mpint():
	return map(int, inp().split(' '))

def itg():
	return int(inp())

def floor_multiple(a, b):
	return a - a % abs(b)

def solve():
	(x, y) = mpint()
	k = 1
	ans = 0
	while x >= k * (k + 2):
		max_a = floor_multiple(x, k)
		max_b = min(max_a // k - 1, y)
		ans += max(max_b - k, 0)
		k += 1
	return ans

def main():
	for _ in range(itg()):
		print(solve())
DEBUG = 0
URL = 'https://codeforces.com/contest/1485/problem/C'
if DEBUG == 1:
	import requests
	from ACgenerator.Y_Test_Case_Runner import TestCaseRunner
	runner = TestCaseRunner(main, URL, 1)
	inp = runner.input_stream
	print = runner.output_stream
	runner.checking()
else:
	if DEBUG != 2:
		(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	if DEBUG:

		def print(*args, **kwargs):
			_print(*args, **kwargs)
			sys.stdout.flush()
	main()


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
from collections import defaultdict
pi = 3.141592653589793

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

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

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

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

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

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

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj

def sieve():
	li = [True] * (10 ** 3 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	(prime, cur) = ([0] * 200, 0)
	for i in range(10 ** 3 + 5):
		if li[i] == True:
			prime[cur] = i
			cur += 1
	return prime

def SPF():
	mx = 10 ** 6 + 1
	spf[1] = 1
	for i in range(2, mx):
		if spf[i] == 1000000000.0:
			spf[i] = i
			for j in range(i * i, mx, i):
				if i < spf[j]:
					spf[j] = i
	return

def prime(n, d):
	prm = set()
	while n != 1:
		prm.add(spf[n])
		n = n // spf[n]
	for ele in prm:
		d[ele] = d.get(ele, 0) + 1
	return
mod = 998244353
inf = 10000000000000000

def solve():
	(a, b) = IP()
	if a == 1 or b == 1:
		print(0)
		return
	ans = 0
	i = 1
	while True:
		if i * i >= a:
			break
		(low, high) = (1, b)
		while high - low > 1:
			mid = (low + high) // 2
			if (mid + 1) * i <= a:
				low = mid
			else:
				high = mid
		if high - low == 1:
			if (high + 1) * i <= a:
				mx = high
			else:
				mx = low
		ans += max(0, mx - i)
		i += 1
	print(ans)
	return
t = II()
for i in range(t):
	solve()


from math import isqrt

def solve(x, y):
	rmax = min(isqrt(x), y - 1)
	res = 0
	for r in range(1, rmax + 1):
		if x // r - 1 > r:
			b = min(y, x // r - 1) - r
			res += b
	return res
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	print(solve(x, y))


from collections import defaultdict
t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	ans = 0
	for r in range(1, 100000):
		temp = (a - r) // r
		ans += max(0, min(b, temp) - (r + 1) + 1)
	print(ans)


import sys, collections, bisect, random, functools, math, heapq
import os
from io import BytesIO, IOBase
from types import GeneratorType
sys.setrecursionlimit(200000)
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 = sys.stdin.readline
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().strip().split())
	cy = int((x + 1) ** 0.5)
	ans = 0
	if cy < y:
		ans += cy * (cy - 1) // 2
		i = cy + 1
		while i < y + 1:
			r = x % (i + 1)
			xx = x // (i + 1)
			if xx == 0:
				break
			c = r // xx + 1
			if i + c > y + 1:
				ans += xx * (y + 1 - i)
				break
			else:
				ans += xx * c
			i += c
	else:
		ans += y * (y - 1) // 2
	print(ans)


import sys
from sys import stdout
import bisect as bi
import math
from collections import defaultdict as dd
from types import GeneratorType
input = sys.stdin.readline
mo = 10 ** 9 + 7
MOD = 998244353

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input().strip()

def inin():
	return int(input())
for _ in range(inin()):
	(a, b) = cin()
	b = min(a - 1, b)
	if b <= 1:
		print(0)
	else:
		sqra = min(int(math.sqrt(a - 1)), b)
		ans = 0
		for i in range(1, sqra + 1):
			r = a // i
			if a % r < r:
				r -= 1
			ans += max(min(r - i, b - i), 0)
		print(ans)

def msb(n):
	n |= n >> 1
	n |= n >> 2
	n |= n >> 4
	n |= n >> 8
	n |= n >> 16
	n |= n >> 32
	n |= n >> 64
	return n - (n >> 1)

def pref(a, n, f):
	pre = [0] * n
	if f == 0:
		pre[0] = a[0]
		for i in range(1, n):
			pre[i] = a[i] + pre[i - 1]
	else:
		pre[-1] = a[-1]
		for i in range(n - 2, -1, -1):
			pre[i] = pre[i + 1] + a[i]
	return pre

def kadane(A):
	maxSoFar = maxEndingHere = start = end = beg = 0
	for i in range(len(A)):
		maxEndingHere = maxEndingHere + A[i]
		if maxEndingHere < 0:
			maxEndingHere = 0
			beg = i + 1
		if maxSoFar < maxEndingHere:
			maxSoFar = maxEndingHere
			start = beg
			end = i
	return (maxSoFar, start, end)

def modFact(n, p):
	if n < 0:
		return 0
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result

def ncr(n, r, p):
	if n < r or n < 0:
		return 0
	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 bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc


import sys
input = sys.stdin.readline
from math import sqrt, ceil
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	cur = 0
	for k in range(1, ceil(sqrt(x))):
		cur += max(0, min(y, x // k - 1) - k)
	print(cur)


import sys
input = sys.stdin.buffer.readline
for t in range(int(input())):
	(X, Y) = map(int, input().split())
	Z = min(Y, int(X ** 0.5) + 1)
	ANS = 0
	for i in range(1, min(Z + 1, Y) + 1):
		A = X // (i + 1)
		ANS += min(A, i - 1)
	if Z + 1 >= Y:
		print(ANS)
		continue
	for i in range(1, int(X ** 0.5) + 3):
		B = X // i
		if B <= Z + 1:
			break
		ANS += max(0, min(B - 1, Y) - Z - 1)
	print(ANS)


for test_case in range(int(input())):
	(x, y) = map(int, input().split())
	ans = 0
	k = 1
	while k * (k + 1) < x and k < y:
		ans += min(y, x // k - 1) - k
		k += 1
	print(ans)


from collections import Counter
from bisect import bisect_right, bisect_left
from math import ceil, floor, sqrt

def solve(x, y):
	if x >= y * y - 1:
		return y * (y - 1) // 2
	y_ = floor(sqrt(x + 1))
	cnt = solve(x, y_)
	for i in range(1, y_):
		a = y_ * i + i
		cnt += min((x - a) // i, y - y_)
	return cnt
qq = int(input())
for i in range(qq):
	(x, y) = tuple(map(int, input().split()))
	print(solve(x, y))


import math
t = int(input())
while t != 0:
	(x, y) = map(int, input().split())
	p = int(math.sqrt(x)) + 1
	ans = 0
	for i in range(1, p):
		ans += max(0, min(y, x // i - 1) - i)
	print(ans)
	t -= 1


from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log, log2
from random import seed, randint
from datetime import datetime
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353

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

def iinp():
	return int(inp())

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

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

def lmp():
	return list(mp())

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

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

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

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

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def def_value():
	return 0
for _ in range(iinp()):
	(x, y) = mp()
	l = floor(sqrt(x))
	ans = 0
	for k in range(1, l + 1):
		if min(y, x // k - 1) > k:
			ans += min(y, x // k - 1) - k
	print(ans)


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
for xyz in range(0, int(input())):
	(x, y) = map(int, input().split())
	for k in range(0, x):
		if k * (k + 1) >= x:
			maxk = k
			break
	ans = 0
	for k in range(1, maxk):
		maxb = min(y, x // k - 1)
		allowedb = max(0, maxb - k)
		ans += allowedb
	print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt, log2
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def inp():
	return sys.stdin.readline().rstrip('\r\n')

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 testcase(t):
	for pp in range(t):
		solve(pp)

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

def power(x, y, p):
	y %= p - 1
	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 ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)
mod = 10 ** 9 + 7

def solve(case):
	(x, y) = sep()
	ans = 0
	for k in range(1, y + 1):
		t = (x - k) // k
		if t < k:
			break
		ans += min(y, t) - k
	print(ans)
testcase(int(inp()))


from math import *
for i in range(int(input())):
	(x, y) = map(int, input().split())
	aa = 0
	for i in range(1, ceil(sqrt(x))):
		aa += max(0, min(y, x // i - 1) - i)
	print(aa)


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from itertools import permutations as per
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(x, y) = R()
	l = 2
	r = min(x - 1, y)
	lm = 0
	while l <= r:
		m = (l + r) // 2
		if m * (m - 1) + m - 1 <= x:
			lm = m
			l = m + 1
		else:
			r = m - 1
	if not lm:
		print(0)
		continue
	pst = lm
	mx = min(x, y + 1)
	p = lm - 1
	ans = sm(p - 1)
	while 1:
		n_pst = x // p
		ans += (min(n_pst, mx) - lm) * p
		lm = n_pst
		if n_pst >= mx:
			break
		p -= 1
	print(ans)


def main():
	t = int(input())
	allAns = []
	for _ in range(t):
		(x, y) = readIntArr()
		ans = 0
		nK = 1
		while min(x // nK - 1, y) >= nK:
			ans += min(x // nK - 1, y) - nK
			nK += 1
		allAns.append(ans)
	multiLineArrayPrint(allAns)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]
inf = float('inf')
MOD = 10 ** 9 + 7
main()


T = int(input())
for _ in range(T):
	(x, y) = [int(z) for z in input().split()]
	c = 1
	result = 0
	done = False
	while True:
		extra = max(min((x - c) // c, y) - c, 0)
		result += extra
		if extra == 0:
			done = True
			break
		c += 1
	print(result)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	count = 0
	k = int(a ** 0.5) + 1
	for i in range(1, k + 1):
		s = int(a / i)
		s = min(s, b + 1)
		count += max(0, s - i - 1)
	print(count)


import sys
input = sys.stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())

def solve():
	(x, y) = R()
	ans = 0
	i = 1
	while i * i <= x:
		temp = min(y, x // i - 1) - i
		ans += 0 if temp < 0 else temp
		i += 1
	print(ans)
for _ in range(I()):
	solve()


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if b == 1 or a == 1:
		print(0)
	else:
		k = int(a ** 0.5)
		ans = 0
		for i in range(1, k + 1):
			ans += max(0, min(b, a // i - 1) - i)
		print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	k = 2
	ost = 1
	p = min(a // ost - k, b - k + 1)
	c = 0
	while p > 0:
		k += 1
		c += p
		ost += 1
		p = min(a // ost - k, b - k + 1)
	print(c)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	n = int(a ** 0.5) + 1
	ans = 0
	for i in range(1, n + 1):
		s = a // i
		s = min(s, b + 1)
		ans += max(0, s - i - 1)
	print(ans)


import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string

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
		self.BUFSIZE = 8192

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.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, self.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')

def get_int():
	return int(input())

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

def get_int_grid(n):
	return [get_ints() for _ in range(n)]

def get_str():
	return input().split(' ')

def yes_no(b):
	if b:
		return 'YES'
	else:
		return 'NO'

def prefix_sums(a):
	p = [0]
	for x in a:
		p.append(p[-1] + x)
	return p

def solve_a():
	(a, b) = get_ints()

	def steps_via(c):
		if c < b or c == 1:
			return float('inf')
		z = a
		s = c - b
		while z > 0:
			s += 1
			z = z // c
		return s
	x = b
	while steps_via(x) >= steps_via(x + 1):
		x += 1
	return steps_via(x)

def solve_b():
	(n, q, k) = get_ints()
	a = get_ints()

	def respond(l, r):
		if l == r:
			return k - 1
		else:
			return a[l - 1] - 1 + k - a[r - 1] + 2 * (a[r - 1] - a[l - 1] - 1 - (r - l - 1))
	ans = []
	for query in range(q):
		(l, r) = get_ints()
		ans.append(respond(l, r))
	return ans

def solve_c():
	(x, y) = get_ints()
	s = 0
	k = 1
	while k * k <= x:
		s += max(0, min(y, x // k - 1) - k)
		k += 1
	return s
t = get_int()
for _ in range(t):
	print(solve_c())


from sys import stdin
import sys
tt = int(stdin.readline())
for loop in range(tt):
	(x, y) = map(int, stdin.readline().split())
	ans = 0
	for c in range(1, x):
		now = min(y, x // c - 1)
		if now > c:
			ans += now - c
		else:
			break
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(cr, ans, mn) = (b - 1, 0, 2)
	i = 1
	while mn * i + i <= a and mn <= b:
		tp = (a - i) // i
		ans += min(tp - mn + 1, cr)
		cr -= 1
		mn += 1
		i += 1
	print(ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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')

class SegmentTree:

	def __init__(self, data, default=-10 ** 6, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(200001)]
pp = [0] * 200001

def SieveOfEratosthenes(n=200000):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
T = int(input())
for _ in range(T):
	(A, B) = map(int, input().split())
	d = 1
	ans = 0
	while d * (d + 2) <= A:
		a = A // d - (d + 1)
		b = B - d
		ans += max(0, min(a, b))
		d += 1
	print(ans)


for _ in range(int(input())):
	(x, y) = map(int, input().split(' '))
	cap = int(x ** 0.5 + 1)
	ans = 0
	for k in range(1, cap):
		ans += max(0, min(y, x // k - 1) - k)
	print(ans)


import math

def CountSpecialsPairs_NT(x, y):
	count = 0
	for i in range(1, int(math.sqrt(x)) + 1):
		count += max(0, min(y, int(x / i) - 1) - i)
	return count
n = int(input())
for i in range(n):
	s = input().split()
	x = int(s[0])
	y = int(s[1])
	print(CountSpecialsPairs_NT(x, y))


def main():
	t = int(input())
	ans = []
	for _ in range(t):
		(x, y) = map(int, input().split())
		x = min(y * y, x)
		y = min(x - 1, y)
		cnt = 0
		rem = 1
		while rem * rem <= x:
			cnt += max(0, min(y, x // rem - 1) - rem)
			rem += 1
		ans.append(str(cnt))
	print('\n'.join(ans))

def tests():
	a = 10000
	b = 12
	a = min(b * b, a)
	b = min(a - 1, b)
	cnt = 0
	for cb in range(2, b + 1):
		pairs = []
		for ca in range(2, a + 1):
			x = ca // cb
			y = ca % cb
			if x == y:
				pairs.append((ca, cb))
		print(pairs)
		cnt += len(pairs)
	print(f'cnt = {cnt}')
	print(f'sum = {sum(range(b))}')
main()


from math import sqrt

def fm(a, b):
	total = 0
	for k in range(1, min(int(sqrt(a + 1)) - 1, b - 1) + 1):
		total += max(min(b, int(a / k) - 1) - k, 0)
	return total
t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	print(fm(A, B))


import sys
input = sys.stdin.readline

def binarySearch(num, highest, denom):
	low = denom
	high = highest
	floorDiv = num // denom
	best = denom
	while low <= high:
		mid = (low + high) // 2
		if num // mid == floorDiv:
			best = mid
			low = mid + 1
		else:
			high = mid - 1
	delta = best - denom + 1
	addToResult = delta * floorDiv
	return (addToResult, best + 1)
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	num = 1
	result = 0
	while num * num <= x and num <= y:
		result += num - 1
		num += 1
	denom = num + 1
	while denom <= y + 1:
		(addToResult, denom) = binarySearch(x, y, denom)
		result += addToResult
	print(result)


T = int(input())
for t in range(T):
	(x, y) = tuple([int(x) for x in input().split()])
	sqrt_x = int(x ** 0.5)
	result = 0
	for i in range(1, sqrt_x + 1):
		num_n = min(x // i, y + 1) - i - 1
		if num_n <= 0:
			break
		result += num_n
	print(result)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	for k in range(1, 31624):
		x = a // k - 1
		y = b
		result = 0
		if k + 1 <= b and k * (k + 2) <= a:
			if x < y:
				result = x - k
			else:
				result = y - k
		else:
			break
		ans += result
	print(ans)