Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.
He remembers that the remainder of a divided by b was greater than or equal to K.
Find the number of possible pairs that he may have had.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - 0 \leq K \leq N-1
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N K

-----Output-----
Print the number of possible pairs that he may have had.

-----Sample Input-----
5 2

-----Sample Output-----
7

There are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).

Difficulty: MEDIUM_HARD

Starter code:

Solutions:
(N, K) = map(int, input().split())
ans = 0
if K == 0:
	print(N ** 2)
	return
for r in range(K, N):
	for q in range((N - r) // (r + 1) + 1):
		if q == 0:
			ans += N - r
		else:
			ans += max(0, (N - r) // q - r)
print(ans)


(n, k) = map(int, input().split())
ans = 0
if k == 0:
	print(n ** 2)
	return
for b in range(k + 1, n + 1):
	div = n // b
	ans += (b - k) * div
	rem = n % b
	ans += max(0, rem - k + 1)
print(ans)


(N, K) = (5, 2)
(N, K) = list(map(int, input().split()))

def calculate(n, k):
	result = 0
	for b in range(1, N + 1):
		p = n // b
		s1 = p * max(0, b - 1 - (k - 1))
		s2 = max(0, n % b - (k - 1))
		res = s1 + s2
		if k == 0:
			result = result + res - 1
		else:
			result = result + res
	print(result)
calculate(N, K)


(n, k) = map(int, input().split())
ans = 0
for i in range(k + 1, n + 1):
	ans += n // i * (i - k)
	if k == 0:
		m = n % i
	else:
		m = n % i - k + 1
	ans = max(ans, ans + m)
print(ans)


import sys
sr = lambda : sys.stdin.readline().rstrip()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
(N, K) = lr()
total = N * N
for b in range(1, N + 1):
	if b <= K:
		total -= N
	else:
		total -= K * (N // b) + max(0, min(N % b, K - 1))
answer = total
print(answer)


import sys

def f(n, N, K):
	if n <= K:
		return 0
	if K == 0:
		return N
	ans = max(N % n - (K - 1), 0)
	ans += N // n * (n - K)
	return ans

def solve(N: int, K: int):
	ans = 0
	for b in range(N + 1):
		ans += f(b, N, K)
	return ans

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	N = int(next(tokens))
	K = int(next(tokens))
	print(solve(N, K))

def test():
	import doctest
	doctest.testmod()

def __starting_point():
	test()
	main()
__starting_point()


(n, k) = map(int, input().split())
res = 0
for i in range(k + 1, n + 1):
	res += n // i * (i - k)
	if n % i != 0:
		res += max(n % i - max(k - 1, 0), 0)
print(res)


(N, K) = list(map(int, input().split()))
t = 0
for b in range(K + 1, N + 1):
	t += N // b * (b - K) + ((N % b - K + (1 if K > 0 else 0) if N % b >= K else 0) if N % b else 0)
print(t)


(N, K) = map(int, input().split())
ans = 0
for p in range(K + 1, N + 1):
	k = N // p
	l = N % p
	a = k * (p - K) + max(l - K + 1, 0)
	if K == 0:
		a -= 1
	ans += a
print(ans)


(N, K) = map(int, input().split())
if not K:
	print(N ** 2)
	return
ans = 0
for b in range(1, N + 1):
	if b - 1 < K:
		continue
	_before = N // b
	_before_n = b - K
	ans += _before * _before_n
	_after = N % b
	if _after + 1 < K:
		continue
	ans += _after - K + 1
print(ans)


import math
from math import gcd, pi, sqrt
INF = float('inf')
MOD = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 6)
import itertools
import bisect
from collections import Counter, deque

def i_input():
	return int(input())

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

def i_list():
	return list(i_map())

def i_row(N):
	return [i_input() for _ in range(N)]

def i_row_list(N):
	return [i_list() for _ in range(N)]

def s_input():
	return input()

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

def s_list():
	return list(s_map())

def s_row(N):
	return [s_input for _ in range(N)]

def s_row_str(N):
	return [s_list() for _ in range(N)]

def s_row_list(N):
	return [list(s_input()) for _ in range(N)]

def main():
	(N, K) = i_map()
	if K == 0:
		print(N ** 2)
		return
	cnt = 0
	for i in range(1, N + 1):
		b = N // i
		one = i - K
		if one > 0:
			cnt += one * b
		amari = N % i
		if amari >= K:
			cnt += amari - K + 1
	print(cnt)

def __starting_point():
	main()
__starting_point()


(N, K) = map(int, input().split())
cnt = 0
for i in range(K + 1, N + 1):
	cnt += N // i * (i - K)
	if N % i >= K:
		cnt += N % i - K + 1
if K == 0:
	cnt -= N
print(cnt)


(N, K) = map(int, input().split())
ans = 0
if K == 0:
	print(N ** 2)
	return
for b in range(K + 1, N + 1):
	per = N // b
	rem = N % b
	if rem >= K:
		ans += (per + 1) * (rem - K + 1) + per * (b - 1 - rem)
	else:
		ans += per * (b - K)
print(ans)


import sys
readline = sys.stdin.readline

def main():
	(N, K) = map(int, readline().rstrip().split())
	if K == 0:
		print(N ** 2)
		return
	ans = 0
	for b in range(K, N + 1):
		r = (N + 1) % b
		p = (N + 1) // b
		ans += (b - K) * p + max(0, r - K)
	print(ans)

def __starting_point():
	main()
__starting_point()


(N, K) = map(int, input().split())
ans = 0
for b in range(1, N + 1):
	if b <= K:
		continue
	ans += (N + 1) // b * (b - K)
	ans += max((N + 1) % b - K, 0)
	if K == 0:
		ans -= 1
print(ans)


(n, k) = map(int, input().split())
ans = 0
for b in range(1, n + 1):
	ans += n // b * max(0, b - k) + max(n % b + 1 - k, 0)
	if k == 0:
		ans -= 1
print(ans, flush=True)


(N, K) = map(int, input().split())
ans = 0
if K == 0:
	print(N ** 2)
else:
	for b in range(K + 1, N + 1):
		ans += N // b * (b - K) + max(0, N % b - K + 1)
	print(ans)


import math
(n, k) = map(int, input().split())
sum = 0
if k == 0:
	print(n ** 2)
else:
	for b in range(1, n + 1):
		if n % b == 0:
			sum += math.floor(n / b) * max(b - k, 0)
		else:
			sum += math.floor(n / b) * max(b - k, 0) + max(n % b - k + 1, 0)
	print(sum)


(n, k) = map(int, input().split())
ans = 0
if k == 0:
	print(n ** 2)
else:
	for i in range(k + 1, n + 1):
		if n % i < k:
			ans += n // i * (i - k)
		else:
			ans += n // i * (i - k) + n % i - (k - 1)
	print(ans)


(n, k) = map(int, input().split())
ans = 0
if k == 0:
	print(n ** 2)
	return
for i in range(1, n + 1):
	if i <= k:
		continue
	ans += max(i - k, 0) * (n // i) + max(n % i - (k - 1), 0)
print(ans)


(N, K) = map(int, input().split())
ans = 0
for i in range(1, N + 1):
	(p, r) = divmod(N, i)
	ans += max(0, i - K) * p + max(0, r - K + 1)
	if K == 0:
		ans -= 1
print(ans)


def main():
	(N, K) = list(map(int, input().split(' ')))
	ans = 0
	for b in range(K + 1, N + 1):
		ans += N // b * (b - K)
		ans += max([0, N % b - K + 1])
		if K == 0:
			ans -= 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, k) = list(map(int, input().split()))
ans = n * n
if k != 0:
	ans -= k * n
	for b in range(k + 1, n + 1):
		tmp = n // b * k + min(n % b, k - 1)
		ans -= tmp
print(ans)


(n, k) = map(int, input().split())
count = 0
if k == 0:
	print(n ** 2)
	return
for i in range(k + 1, n + 1):
	count += n // i * (i - k)
	m = n % i
	count += max(m - k + 1, 0)
print(count)


(N, K) = map(int, input().split())
ans = 0
if K == 0:
	print(N * N)
	return
else:
	for i in range(K + 1, N + 1):
		ans = ans + N // i * max(0, i - K) + max(0, N % i - K + 1)
	print(ans)


(N, K) = map(int, input().split())
a = [i for i in range(1, N + 1)]
ans = 0
for b in range(1, N + 1):
	if K >= b:
		continue
	elif K != 0:
		ans += N // b * (b - K) + max(N % b - K + 1, 0)
	else:
		ans += N
print(ans)


import sys

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

def main():
	(N, K) = list(map(int, input().split()))
	answer = 0
	for b in range(1, N + 1):
		p = N // b
		q = N % b
		answer += p * max(0, b - K)
		answer += max(0, q - K + 1)
	if K == 0:
		answer -= N
	print(answer)

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
sum = 0
for b in range(k + 1, n + 1):
	re = n // b
	sum += re * (b - k)
	if k <= n % b:
		sum += n % b - k + 1
if k == 0:
	sum -= n
print(sum)


(n, k) = map(int, input().split())
ans = 0
if k == 0:
	print(n * n)
else:
	g = 0
	for b in range(k + 1, n + 1):
		t = n // b
		g += t * (b - k)
		if t * b + k <= n < (t + 1) * b:
			g += n - (t * b + k) + 1
	print(g)


def main():
	(n, k) = list(map(int, input().split()))
	if k == 0:
		print(n * n)
		return
	ans = 0
	for i in range(k + 1, n + 1):
		(p, q) = divmod(n, i)
		ans += p * (i - k) + max(q - k + 1, 0)
	print(ans)

def __starting_point():
	main()
__starting_point()


import sys
sys.setrecursionlimit(10 ** 8)

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

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

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

def li2(N):
	return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

def dp2(ini, i, j):
	return [[ini] * i for _ in range(j)]

def dp3(ini, i, j, k):
	return [[[ini] * i for _ in range(j)] for _ in range(k)]
(N, K) = mi()
cnt = 0
for b in range(K + 1, N + 1):
	for x in range((N - K) // b + 1):
		if b * x + K == 0:
			cnt -= 1
		cnt += min(N - (b * x + K) + 1, b - K)
print(cnt)


(n, k) = map(int, input().split())
print(sum((n // b * (b - k) + max(n % b - k + 1, 0) - (k < 1) for b in range(k + 1, n + 1))))


import sys
(n, k) = list(map(int, input().split()))
if k == 0:
	print(n * n)
	return
ans = n * n
for b in range(1, n + 1):
	if b <= k:
		ans -= n
		continue
	ans -= (n + 1) // b * k - 1
	ans -= min((n + 1) % b, k)
print(ans)


(n, k) = map(int, input().split())
ans = 0
for b in range(1, n + 1):
	p = n // b
	r = n % b
	ans += p * max(0, b - k) + max(0, r - k + 1)
if k == 0:
	ans -= n
print(ans)


(n, k) = list(map(int, input().split()))
ans = 0
for b in range(k + 1, n + 1):
	s = n // b
	a = n % b
	ans += s * (b - k)
	ans += max(a - k + 1, 0)
	if k == 0:
		ans -= 1
print(ans)


(N, K) = map(int, input().split())
ans = 0
if K == 0:
	print(N * N)
	return
for b in range(K + 1, N + 1):
	_ = N // b * (b - K) + max(0, N % b - K + 1)
	ans += _
print(ans)


(n, k) = list(map(int, input().split()))
ans = 0
for b in range(k + 1, n + 1):
	res = (n - k) % b
	quo = (n - k) // b
	if b - k - 1 > res:
		ans += (b - k) * quo + res + 1
	else:
		ans += (b - k) * (quo + 1)
	ans -= k == 0
print(ans)


(n, k) = list(map(int, input().split()))
if k == 0:
	ans = (1 + n - 1) * (n - 1) // 2
else:
	ans = (1 + n - k) * (n - k) // 2
if k == 0:
	for i in range(1, n + 1):
		ans += n // i
for i in range(k, n):
	if i == 0:
		continue
	for j in range(1, n // i + 1):
		if j * (i + 1) + i <= n:
			ans += (n - (j * (i + 1) + i)) // j + 1
		if j * (i + 1) + i > n:
			break
print(ans)


(n, k) = map(int, input().split())
if k == 0:
	print(n * n)
	return
ans = 0
for i in range(k + 1, n + 1):
	(quo, rem) = divmod(n, i)
	ans += quo * (i - k)
	if rem >= k:
		ans += rem - k + 1
print(ans)


(N, K) = map(int, open(0).read().split())
ans = 0
if K == 0:
	print(pow(N, 2))
else:
	for b in range(K + 1, N + 1):
		(d, m) = divmod(N, b)
		ans += d * (b - K) + max(0, m - K + 1)
	print(ans)


(n, k) = map(int, input().split())
s = 0
for i in range(1, n + 1):
	(q, r) = divmod(n + 1, i)
	s += q * max(i - k, 0) + max(r - k, 0)
s -= n * (k == 0)
print(s)


(n, k) = map(int, input().split())
if k == 0:
	print(n ** 2)
else:
	c = 0
	for b in range(k + 1, n + 1):
		c += n // b * (b - k) + max(n % b - k + 1, 0)
	print(c)


from sys import stdin

def main():
	readline = stdin.readline
	(n, k) = map(int, readline().split())
	if k == 0:
		print(n ** 2)
	else:
		res = 0
		for b in range(1, n + 1):
			if b <= k:
				continue
			else:
				m = n // b
				l = n % b
				res += (b - k) * m
				res += max(0, l - k + 1)
		print(res)

def __starting_point():
	main()
__starting_point()


(N, K) = list(map(int, input().split()))
count = 0
for b in range(K + 1, N + 1):
	x = N // b
	y = N % b
	count += x * (b - K)
	count += max(0, y - max(1, K) + 1)
print(count)


def main():
	(n, k) = list(map(int, input().split()))
	ans = 0
	for b in range(1, n + 1):
		(q, r) = divmod(n, b)
		ans += q * max(0, b - k)
		ans += max(0, r - k + 1)
	if k == 0:
		ans -= n
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, k) = list(map(int, input().split()))
if k == 0:
	print(n ** 2)
	return
ans = 0
for i in range(k, n + 1):
	p = n // i
	r = n % i
	ans += p * (i - k) + max(0, r - k + 1)
print(ans)


(n, k) = map(int, input().split())
ans = 0
if k == 0:
	print(n * n)
	return
for b in range(k, n + 1):
	x = n // b
	y = n % b
	ans += (b - k) * x
	if y >= k:
		ans += y + 1 - k
print(ans)


(N, K) = map(int, input().split())
cnt = 0
if K == 0:
	cnt = N * N
else:
	for b in range(1, N + 1):
		p = N // b
		q = N % b
		cnt += p * max(0, b - K)
		cnt += max(0, q - K + 1)
print(cnt)


(n, k) = map(int, input().split())
a = 0
for b in range(1, n + 1):
	(p, q) = divmod(n, b)
	a += max(0, b - k) * p + max(0, q - k + 1)
print(a if k else n * n)


from math import floor
(N, K) = map(int, input().split())
ans = 0
for b in range(K + 1, N + 1):
	(p, r) = (N // b, N % b)
	ans += p * max(0, b - K) + max(0, r - K + 1)
print(ans if K != 0 else ans - max(0, b - K))


(n, k) = list(map(int, input().split()))
s = 0
if k == 0:
	print(n ** 2)
else:
	for i in range(k + 1, n + 1):
		if n % i < k:
			s += n // i * (i - k)
		else:
			s += n // i * (i - k) + n % i - (k - 1)
	print(s)


(n, k) = map(int, open(0).read().split())
ans = 0
for b in range(k + 1, n + 1):
	c = n // b * (b - k)
	if k:
		d = max(0, n % b - k + 1)
	else:
		d = n % b
	ans += c
	ans += d
print(ans)


(N, K) = list(map(int, input().split()))
ans = 0
if K == 0:
	print(N * N)
else:
	for b in range(K + 1, N + 1):
		x = N // b
		ans += (b - K) * x
		y = N % b
		ans += max(0, y - K + 1)
	print(ans)


(n, k) = map(int, input().split())
ans = 0
for b in range(k + 1, n + 1):
	temp = n // b
	temp2 = n % b
	ans += temp * (b - k) + max(temp2 - max(0, k - 1), 0)
print(ans)


(n, k) = map(int, input().split())
if k == 0:
	print(n ** 2)
	return
res = 0
for i in range(k + 1, n + 1):
	a = n // i
	res += (i - k) * a
	b = n % i
	res += max(0, b - k + 1)
print(res)


import numpy as np
(n, k) = list(map(int, input().split()))
a = np.array([0] * n, dtype='int64')
a[0] += n
for i in range(1, n):
	c = n // (1 + i)
	d = n % (1 + i)
	a[1:i + 1] += c
	a[0] += c
	if d > 0:
		a[1:d + 1] += 1
print(np.sum(a[k:]))


def solve(N, K):
	if K == 0:
		return N ** 2
	else:
		ans = 0
		for b in range(K + 1, N + 1):
			(q, r) = (N // b, N % b)
			ans += q * (b - K) + max(0, r - K + 1)
		return ans

def main():
	(N, K) = list(map(int, input().split()))
	print(solve(N, K))

def __starting_point():
	main()
__starting_point()


(N, K) = map(int, input().split())
ans = 0
for n in range(K + 1, N + 1):
	ans += N // n * (n - K) + max(N % n - max(K - 1, 0), 0)
print(ans)


(N, K) = map(int, input().split())
ans = 0
for b in range(K + 1, N + 1):
	n = b - K
	t = N // b
	r = N % b
	ans += n * t + max(0, r - max(K - 1, 0))
print(ans)


(N, K) = list(map(int, input().split()))
cnt = 0
for i in range(K + 1, N + 1):
	k = int(N / i)
	l = N % i
	if K == 0:
		cnt += k * (i - K) + max(0, l - K)
	else:
		cnt += k * (i - K) + max(0, l - K + 1)
print(cnt)


def find_ans(N, K):
	if K == 0:
		return N ** 2
	else:
		ans = 0
		for i in range(K + 1, N + 1):
			ans += N // i * (i - K) + max(N % i - (K - 1), 0)
		return ans
(N, K) = list(map(int, input().split()))
print(find_ans(N, K))


(n, k) = map(int, input().split())
ans = 0
for b in range(k + 1, n + 1):
	r = n % b
	q = n // b
	ans += (b - k) * q + max(r - max(k - 1, 0), 0)
print(ans)


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(N, K) = list(map(int, readline().split()))
	if K == 0:
		ans = N * N
	else:
		ans = 0
		for b in range(K + 1, N + 1):
			ans += N // b * (b - K) + max(N % b - K + 1, 0)
	print(ans)
	return

def __starting_point():
	main()
__starting_point()


(N, K) = list(map(int, input().split()))
ans = 0
for b in range(K + 1, N + 1):
	ans += N // b * (b - K)
	if N % b >= K:
		ans += N % b - K + 1
if K == 0:
	ans -= N
print(ans)


(n, k) = map(int, input().split())
ans = 0
for b in range(1, n + 1):
	loop = n // b
	ans += max(0, b - k) * loop + max(0, n % b - k + 1)
if k == 0:
	ans -= n
print(ans)


(N, K) = list(map(int, input().split()))
if K == 0:
	print(N ** 2)
else:
	res = 0
	for b in range(1, N + 1):
		L = max(b - K, 0)
		res += L * (N // b) + max(0, N % b + 1 - K)
	print(res)


(n, k) = map(int, input().split())
cnt = 0
if k == 0:
	print(n ** 2)
	return
for b in range(k + 1, n + 1):
	(p, r) = divmod(n, b)
	cnt += p * (b - k) + max(0, r - k + 1)
print(cnt)


(N, K) = map(int, input().split())
if K == 0:
	answer = -N
else:
	answer = 0
for b in range(K + 1, N + 1):
	answer += N // b * (b - K)
	answer += max(0, N % b - K + 1)
print(answer)


def resolve():
	(N, K) = list(map(int, input().split()))
	cnt = 0
	for b in range(1, N + 1):
		cnt += N // b * max(0, b - K) + max(0, N % b - K + 1)
	print(cnt if K != 0 else cnt - N)
if '__main__' == __name__:
	resolve()


(n, k) = list(map(int, input().split()))
ans = 0
for i in range(k + 1, n + 1):
	num = n // i
	ans_tmp = num * (i - k)
	ans_tmp += max(0, n % i - k + 1)
	if k == 0:
		ans_tmp -= 1
	ans += ans_tmp
print(ans)


import sys
(n, k) = list(map(int, input().split()))
if k == 0:
	print(n * n)
	return
icnt = 0
for ki in range(k + 1, n + 1):
	qki = n // ki
	icnt += qki * (ki - k) + max(n % ki - (k - 1), 0)
print(icnt)


(n, k) = [int(x) for x in input().split()]
if k == 0:
	print(n ** 2)
	return
ans = 0
for b in range(k + 1, n + 1):
	(q, mod) = divmod(n, b)
	ans += q * (b - k)
	if mod >= k:
		ans += mod - k + 1
print(ans)


(N, K) = map(int, input().split())
ans = 0
if K == 0:
	print(N ** 2)
else:
	for i in range(K + 1, N + 1):
		ans += N // i * (i - K)
		if N % i - K + 1 > 0:
			ans += N % i - K + 1
	print(ans)


(N, K) = map(int, input().split())
if K == 0:
	print(N * N)
	return
print(sum([N // b * (b - K) + max(N % b - K + 1, 0) for b in range(K + 1, N + 1)]))


(n, k) = list(map(int, input().split()))
if k == 0:
	print(n ** 2)
	return
cnt = 0
for b in range(k + 1, n + 1):
	ux = n // b
	if n % b == 0:
		umod = 0
	else:
		umod = max(0, n % b - k + 1)
	dmod = max(0, b - k)
	cnt += umod + dmod * ux
print(cnt)