Problem:
 Score : 400 points    Problem Statement 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 1 5 2      Sample Output 1 7  There are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5) .       Sample Input 2 10 0      Sample Output 2 100       Sample Input 3 31415 9265      Sample Output 3 287927211

Solution (Python):






N,K = map(int, input().split())





if K == 0:
    ans = N*N
else:
    ans = 0
    cnt = 1
    for b in range(K+1,N+1):
        mod = N%b
        x = N//b
        ans += x*cnt
        if mod >= K:
            ans += mod-K+1
        cnt += 1
print(ans)

Solution (Python):
def main():
    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+1-K) - (K==0)
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
n, k = map(int, input().split())

ans = 0
for b in range(1, n+1):
  ans += n//b * max(0, b-k) + max(0, n%b -k + 1)
  if k == 0:
    ans -= 1
print(ans)

Solution (Python):
N, K = map(int, input().split())

ans = 0
for b in range(K+1, N+1):
    ans += N//b*(b-K)
    ans += max(N-N//b*b-max(K-1, 0), 0)

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    resolve()

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

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

Solution (Python):

def resolve():
    N, K = map(int, input().split())

    if K == 0:
        print(N ** 2)
        return

    ans = 0
    for b in range(1, N + 1):
        ans += N // b * max(0, b - K)
        ans += max(0, N % b + 1 - K)

    print(ans)


if __name__ == "__main__":
    resolve()

Solution (Python):
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))



N,K=mint()
if K==0:
    print(N**2)
    exit()
ans=0
for b in range(K+1,N+1):
    ans+=(N//b)*(b-K)+max(0,N%b-(K-1))
print(ans)

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


sys.setrecursionlimit(10**7)









INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    N, K = map(int, sysread().split())
    ans = 0
    for b in range(K+1, N+1):
        if K == 0:
            ans -= 1
        count = b-1 -K + 1
        alpha = (N-b+1) % b
        prim_add = (N-b+1) // b + 1
        prim = b-1 - alpha + 1
        if count <= prim:
            ans += count * prim_add
            continue
        ans += prim * prim_add
        L = (count - prim) // b
        resid = (count - prim) % b
        ans += ((prim_add + 1 + (L+prim_add)) * L // 2) * b
        ans += (L+ prim_add + 1) * resid

    print(ans)
if __name__ == "__main__":
    run()

Solution (Python):
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    N, K = map(int, input().split())
    ans = K - N if K == 0 else 0
    for b in range(K + 1, N + 1):
        c = (N - K) // b
        ans += (b - K) * c + min(N - c * b + 1, b) - K
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())

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

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

Solution (Python):
N, K = map(int,input().split())
total = 0
num = 1
for i in range(K+1,N+1):
    total += N//i*num
    num += 1
    if K == 0:
        total += max(N%i-K,0)
    else:        
        total += max(N%i-K+1,0)

print(total)

Solution (Python):
import sys



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


def input_int():
    return int(input())


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


def main():
    n, k = input_int_list()
    ans = 0
    if k == 0:
        print(n * n)
        return
    

    for b in range(k + 1, n + 1):
        ans += (b - k) * (n // b)
        if n % b >= k:
            ans += n % b - (k - 1)

    print(ans)
    return


if __name__ == "__main__":
    main()

Solution (Python):
def num_divisors_cnt(n):
    table = [0] * (n + 1)
    
    for i in range(1, n+1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

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


if __name__ == "__main__":
    main()

Solution (Python):
N,K=[int(x) for x in input().split()]
counter=0
for b in range(max(1,K),N+1):
	tobeadded=(N//b)*(b-K) + max(0,N%b+1-K)
	counter+=tobeadded
if K==0:
	counter-=N
print(counter)

Solution (Python):
n, k = map(int, input().split())
ans = 0

for i in range(1, n + 1):
    ans += max((n//i)*(i - k), 0) + max((n%i - k + 1), 0)

if k == 0:
    ans = n**2

print(ans)

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

Solution (Python):
n,k=map(int,input().split())

ans=0
for mod in range(1,n+1):
    ans+=(n//mod)*max(0,mod-k)
    ans+=max(0,n%mod-k+1) if k>0 else n%mod

print(ans)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

print(ans)

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

Solution (Python):
N,K=map(int,input().split())

if K==0:
    print(N*N)
    exit()

X=0
for b in range(1,N+1):
    if b<=K:
        X+=N+1
    else:
        q,r=divmod(N,b)
        X+=K*q+min(r+1,K)
print(N*(N+1)-X)

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

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

Solution (Python):
import sys
n,k = map(int,input().split())
ans = 0
if k == 0:
    print(n**2)
    sys.exit()
for b in range(k+1,n+1):
    ans_per_loop = b - k
    loop, r = divmod(n,b)
    new = ans_per_loop*loop
    if r >= k:
        new += r-k+1
    ans += new
print(ans)

Solution (Python):
n, k = map(int, input().split())
print(sum([n // i * (i - k) + max(0, n % i - k + 1)
           for i in range(k + 1, n + 1)]) - (k == 0) * n)

Solution (Python):
N, K = [int(x) for x in input().split()]

count = 0

if K == 0:
    print(N**2)
    exit()

for i in range(K+1, N+1):
    count += (i - K) * (N // i)
    count += max(0, N - ((N // i) * i) - K + 1)
print(count)

Solution (Python):
import math
N, K = map(int, input().split())
if K == 0:
    ans = N*N
else:
    ans = 0
    j = 1
    for i in range(K+1, N+1):
        mod = N % i
        x = N//i
        ans += x*j
        if mod>=K:
            ans+=mod-K+1
        j += 1
print(ans)

Solution (Python):
n, k = map(int, input().split())

ans = 0
if k == 0:
    print(n * n)
    exit()

for i in range(k + 1, n + 1):
    
    
    

    
    
    m = n
    m -= i - 1
    ans += i - k

    full = m // i * (i - k)
    amari = m % i  
    ans += full + max(0, amari - k)
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()

ans = 0
for b in range(K+1, N+1):
    cnt = 0
    while b*(cnt+1)<=N:
        ans += b*(cnt+1)-(b*cnt+K)
        cnt += 1
    if K!=0:
        ans += max(0, N-b*cnt-K+1)
    else:
        ans += max(0, N-b*cnt-K)
print(ans)

Solution (Python):
import sys

N, K = map(int, sys.stdin.readline().split())

if K == 0:
    print(N*N)
    sys.exit()

ans = 0
for b in range(K+1, N+1):
    r = N // b
    
    
    
    tmp = (b - K) * r + max(0, N % b + 1 - K)
    ans += tmp

print(ans)

Solution (Python):
N,K = map(int,input().split())

if K == 0:
    print(N**2)
    exit()

ans = 0

for b in range(K+1,N+1):
    ans += (N//b)*max((b-K),0)

    ans += max(0, N%b-K+1)

print(ans)

Solution (Python):
N, K = map(int, input().split())
ans = 0
for b in range(K+1, N+1):
    q, r = divmod(N, b)
    ans += q * (b-K) + max(r - K + 1, 0)
    if K == 0:
        ans -= 1 
    

print(ans)

Solution (Python):
N, K = map(int, input().split())

res = 0

for b in range(1,N+1):
    if b <= K: continue
    res += (N//b) * (b-K)
    if K == 0:
        res += N%b
    else:
        res += max(0, N%b-K+1)
print(res)

Solution (Python):
N,K = map(int,input().split())
ans = 0
if K == 0:
  print(N**2)
  exit()
for b in range(K+1,N+1): 
  amari = b-K
  loop = N//b
  nokori = max(N%b+1-K,0)
  temp = loop*amari + nokori
  
  ans += temp
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
if K == 0:
  print(N ** 2)
  exit(0)
res = 0
for i in range(1, N + 1):
  if i <= K: continue
  res += i - K
  for j in range(i, N + 1, i):
    res += min(N + 1, j + i) - min(N + 1, j + K)
print(res)

Solution (Python):



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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    ans = 0
    for i in range(K + 1, N + 1):
        ans += N // i * (i - K)
        if N % i > 0:
            if K == 0:
                ans += N % i
            else:
                ans += max(0, N % i - K + 1)
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    n, k = mi()
    ans = 0
    for i in range(k+1, n+1):
        ans += (n//i)*(i-k)
        if k == 0:
            ans -= 1
        ans += max(n%i-k+1, 0)
    print(ans)



    
        
if __name__ == '__main__':
    main()

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

Solution (Python):

def read_int():
    return int(input().strip())


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


def solve():
    N, K = read_ints()
    answer = 0
    if K == 0:
        return N*N
    for b in range(K+1, N+1):
        answer += (N//b)*(b-K)+max(0, N%b-(K)+1)
    return answer


if __name__ == '__main__':
    print(solve())

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

    
    
    

    ans = 0
    for b in range(K + 1, N + 1):
        
        ans += (b - K) * (N // b)
        
        ans += max(N % b - max(K - 1, 0), 0)

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
import sys

N, K = map(int, sys.stdin.readline().split())

if K == 0:
    print(N*N)
    sys.exit()



ans = 0
for i in range(1, N+1):
    
    tmp = (N // i) * max(i - K, 0) + max(N % i + 1 - K, 0)
    ans += tmp

print(ans)

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, k = MAP()
ans = 0
if k == 0:
    ans = n**2
else:
    for b in range(k+1, n+1):
        x = n//b
        y = n % b
        ans += (b-k)*x + (y-k+1 if y >= k else 0)
print(ans)

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

Solution (Python):
n,k=map(int,input().split())
b=[i for i in range(k+1,n+1)]
ans=0
if k==0:
    for i in range(len(b)):
        t=b[i]
        j=t-k
        ii=n//t
        ans+=ii*j
        ans+=max(n-ii*t-k,0)
    print(ans)
    exit()
for i in range(len(b)):
    t=b[i]
    j=t-k
    ii=n//t
    ans+=ii*j
    ans+=max(n-ii*t-k+1,0)
print(ans)

Solution (Python):
n,k=map(int,input().split())

ans=0
for i in range(k+1,n+1):
    ans+=n//i*(i-k)
    if n%i>0:
        if k==0:
            ans+=n%i
        else:
            ans+=max(0,n%i-k+1)
    

print(ans)

Solution (Python):
n, k = map(int, input().split())

ans = 0
for b in range(1, n + 1):
    ans += max(b - k, 0) * (n // b)
    ans += max(0, n % b - k + 1)

if k == 0:
    ans -= n

print(ans)

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

Solution (Python):
import sys

input = sys.stdin.readline


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

    ans = 0
    for b in range(K + 1, N + 1):
        q, r = divmod(N, b)
        ans += (b - K) * q
        ans += max(0, min(b - 1, r) - max(1, K) + 1)

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n,k=map(int,input().split())
ans=0
if k==0:
    print(n**2)
    exit()

for b in range(1,n+1):
    if k>b-1:
        continue
    ans+=n//b*(b-k)
    ans+=max(n-n//b*b+1-k,0)

print(ans)

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

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def dd(b, n, k):
	if k==0:
		return n
	if b <= k:
		return 0
	ret = 0
	na = n // b
	ret += na * (b-k)
	
	nb = n % b
	ret += max(nb - k + 1, 0)
	
	return ret

def main():
	
	n, k = tin()
	
	ret = 0
	for b in range(1, n+1):
		ret += dd(b,n, k)
	print(ret)
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
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:
    print(ans - N)
else:
    print(ans)

Solution (Python):
n,k = map(int,input().split())
print(n**2 if not k else sum([(i-k)*(n//i)+max(0,n%i-k+1) for i in range(k+1,n+1)]))

Solution (Python):
n,k = map(int,input().split())
print(sum([(i-k)*(n//i)+max(0,n%i-max(0,k-1)) for i in range(k+1,n+1)]))

Solution (Python):


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

Solution (Python):


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

Solution (Python):
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    
    p,r = divmod(n, i)
    
    
    
    ans += p*max(0,i-k)+max(0,r-k+1)
print(ans if k != 0 else ans - n)

Solution (Python):
N, K = map(int, input().split())

rlt = 0
for b in range(K+1, N+1):
  if K > 0:
    rlt += (N//b)*(b-K) + max(0, N%b - K +1)  
  else:
    rlt += (N//b)*(b-K) + max(0, N%b)  
print(rlt)

Solution (Python):
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    p,r = divmod(n, i)
    ans += p*max(0,i-k)+max(0,r-k+1)
print(ans if k != 0 else ans - n)

Solution (Python):

n, k = map(int, input().split())
"""
bを固定して、aの数を数える
(b-k) * (N//b) + min(0,n%b - k +1)
注意するのは、k >= b なら0 
"""
ans = 0

for b in range(k + 1, n + 1):
    ans += (b - k) * (n // b) + max(0, n % b - k + 1)
    
if k == 0:
    print(n ** 2)
else:
    print(ans)

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, K = in_nn()

    ans = 0
    for b in range(K + 1, N + 1):
        q, r = divmod(N, b)
        ans += q * (b - K) + max(0, r - K + 1)
        if K == 0:
            ans -= 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n,k = map(int,input().split())


    ans = 0

    for b in range(k+1,n+1):
        ans += ((n//b)*max(0,b-k)+max(0,(n%b)-k+1))
    if k == 0:
        ans -= n
    print(ans)


main()

Solution (Python):

from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def prime_factorize(N):
    prime_list = []
    while N % 2 == 0:
        prime_list.append(2)
        N //= 2
    f = 3
    while f**2 <= N:
        if N % f == 0:
            prime_list.append(f)
            N //= f
        else:
            f += 2
    if N != 1:
        prime_list.append(N)
    return prime_list

def main():
    N, K = map(int, input().split())
    if K == 0:
        print(N*N)
        exit()
    ans = 0
    for i in range(1,N+1):
        if i <= K:
            ans += N
        else:
            ans += K * (N//i) + min(K,N%i+1) - 1
        
    print(N*N - ans)

if __name__ == "__main__":
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    if k == 0:
        print(n ** 2)
        exit()

    res = 0
    for b in range(1, n + 1):
        res += (n // b) * max(0, (b - k))
        res += max(0, (n % b) - (k - 1))
    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
n, k = (int(x) for x in input().split())
ans = 0
for b in range(k + 1, n + 1):
    m = n // b
    ans += m * (b - k)  
    ans += max(0, (n % b) - max(0, k - 1))
print(ans)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, k = LI()
if k == 0:
    print(n ** 2)
    quit()
ans = 0
for b in range(1, n+1):
    x, y = divmod(n, b)
    z = b - k
    if z < 0:
        continue
    if y - k + 1 < 0:
        ans += z * x
    else:
        ans += z * x + (y - k + 1)
print(ans)

Solution (Python):
n, k = [int(i) for i in input().split()]

ans = 0
if k == 0:
    ans = n ** 2
else:
    for b in range(1, n+1):
        if b > k:
            loop_num = n // b 
            loop_last = n - loop_num * b 
            ans += (b-k) * loop_num + max(0, loop_last - k + 1)

print(ans)

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
ans = 0
for b in range(k+1,n+1):
    count = b-k
    num = n//b
    amari = n%b
    if k == 0:
        amari-=1
    ans+=(count*num+max(0,amari-k+1))
print(ans)

Solution (Python):
N, K = map(int, input().split())

ans = 0
for mod in range(1, N + 1):
    q, r = divmod(N, mod)
    ans += max(0, mod - K) * q + max(0, r - K + 1)
if K == 0:
    ans -= N
print(ans)

Solution (Python):
N, K = map(int, input().split())

if K == 0:
    print(N ** 2)
    exit()

ans = 0
for mod in range(1, N + 1):
    q, r = divmod(N, mod)
    ans += max(0, mod - K) * q + max(0, r - K + 1)
print(ans)

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    if k == 0:
        print(n ** 2)
        exit()

    res = 0
    for b in range(1, n + 1):
        res += n // b * max(0, b - k)
        res += max(0, n % b + 1 - k)
    print(res)


if __name__ == '__main__':
    resolve()

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

Solution (Python):
N,K=map(int,input().split())

if K==0:
    print(N**2)
    exit()

ans=0
for i in range(K+1,N+1):
    ans+=N//i*(i-K)+max(0,N%i-(K-1))
print(ans)

Solution (Python):
import sys


def solve(x):
    return (x - k) * (n // x) + max(0, n % x - k + 1)


n, k = map(int, input().split())

if k == 0:
    print(n**2)
    sys.exit()


ans = 0
for i in range(k + 1, n + 1):
    ans += solve(i)

print(ans)

Solution (Python):
n, k = map(int, input().split())
ans = 0
i = 0
if k == 0:
    ans = n ** 2
else:
    while i <= n:
        if i >= k:
            ans += n // (i + 1) * (i - k + 1)
        if k <= n % (i + 1) < n:
            ans += n % (i + 1) - (k - 1)
        i += 1
print(ans)

Solution (Python):
import sys

n,k=map(int,input().split())

if k==0:
    print(n*n)
    sys.exit()

s=0
for b in range(k+1,n+1):
    sb=0
    sb+=(n//b)*(b-k)
    c=n%b
    if c>=k:
        sb+=c-k+1
    s+=sb

print(s)

Solution (Python):
n, k = map(int, input().split())

ans = 0
for b in range(max(1,k), n+1):
    ans += n//b * max(0, b-k) + max(0, n%b+1-k)
    if k == 0: ans -= 1

print(ans)

Solution (Python):
N, K = map(int, input().split(' '))
ans = (N-K)*(N-K+1)//2
if K==0:
    print(N**2)
    exit()
for n, i in enumerate(list(range(K+1,N+1))):
    ans += (n+1)*((N-i+1)//i)+max(0,(N-i+1)%i-K)
print(ans)

Solution (Python):
N, K = map(int, input().split())
ans = 0

for b in range(1, N+1):
    
    times = (N//b)
    
    last = N % b
    ans += times * max(0, b-K) + max(0, last - K + 1)
if K == 0:
    print(N*N)
else:
    print(ans)

Solution (Python):
n,k=map(int,input().split())
if k==0:
    print(n**2);exit()
def f(b):
    return (b-k)*(n//b)+max(0,1+n-(n//b)*b-k)
print(sum(f(i)for i in range(k+1,n+1)))

Solution (Python):
n,k=map(int,input().split())
if k==0:
    print(n**2);exit()
def f(b):
    return (b-k)*(n//b)+(max(0,1+n-(n//b)*b-k) if n%b else 0)
print(sum(f(i)for i in range(k+1,n+1)))

Solution (Python):
n, k = map(int, input().split())

ans = 0
for b in reversed(range(1, n+1)):
    if b == k:
        break
    y_cnt = b-k
    p, q = divmod(n, b)
    ans += y_cnt*p
    if k <= q:
        ans += q-max(k-1, 0)
print(ans)

Solution (Python):
n, k = map(int, input().split())

ans = 0
for b in reversed(range(1, n+1)):
    if b == k:
        break
    y_cnt = b-k
    p, q = divmod(n, b)
    ans += y_cnt*p
    if q == 0:
        continue
    if k <= q:
        ans += q-max(k-1, 0)
print(ans)

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

Solution (Python):

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, K = ZZ()
    output = 0
    for b in range(1, N+1):
        output += N//b * max(0, b-K)
        output += max(0, N%b-K+1)
        if K == 0: output -= 1
    print(output)

    return

if __name__ == '__main__':
    main()

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

Solution (Python):
n, k = map(int, input().split())

res = 0
if k == 0:
    print(n*n)
    exit()

for i in range(k+1, n+1):
    cnt = (i-1)-k+1
    add = n // i * cnt
    if n % i >= k:
        add += (n % i) - k + 1
    res += add

print(res)

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    n, k = ns()

    lim = 10 ** 5

    ans = 0
    for i in range(max(1, k + 1), n + 1):
        tmp1 = (i - k) * (n // i)
        tmp2 = max(n % i - max(k - 1, 0), 0) if n % i else 0
        ans += tmp1 + tmp2
        
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    n, k = ns()

    lim = 10 ** 5

    ans = 0
    for i in range(max(1, k + 1), n + 1):
        tmp1 = (i - k) * (n // i)
        tmp2 = max(n % i - max(k - 1, 0), 0) if n % i else 0
        ans += tmp1 + tmp2
        
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n,k= map(int, input().split())

if k==0:
    print(pow(n,2))
    exit()

ans=0

for i in range(k,n+1):
    ans+=n-i
    for j in range(1,int(pow(n-i,0.5))+1):
        ans+=max((n-i)//j-i,0)
        if j>i:
            ans+=max((n-i)//j-int(pow(n-i,0.5)),0)


print(ans)