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):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

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

cnt=0

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

if K>0:
    print(cnt)
else:
    print(N*N)

Solution (Python):
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)

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



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

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)

Solution (Python):
N,K=map(int,input().split())
if K==0:
    print(N*N)
else:
    no=N*K+(N-K)*(K-1)
    for b in range(K+1,N+1):
        q=N//b
        r=N%b
        no+=q*K
        if r>=K-1:
            no+=0
        else:
            no-=(K-r-1)
 
    print(N*N-no)

Solution (Python):
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)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, K = getNM()
sum = 0
for b in range(1, N + 1):
    opt1 = (N // b) * max(0, (b - K))
    if K == 0:
        opt2 = N % b
    else:
        opt2 = max(0, (N % b) - K + 1)
    sum += (opt1 + opt2)
print(sum)

Solution (Python):
import sys


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


def main():
    N, K = 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)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
n, k = map(int, input().split())
if k == 0:
  print(n * n)
  sys.exit()
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)

Solution (Python):
import sys
readline = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Solution (Python):
import bisect
import collections
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline

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

Solution (Python):

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
    else:
        if K != 0:
            ans += (N // b) * (b - K) + max((N % b) - K + 1, 0)
        else:
            ans += N
print(ans)

Solution (Python):
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)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

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 = N*N
print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)


if __name__ == '__main__':
    main()

Solution (Python):
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)

Solution (Python):
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)

if __name__=="__main__":
    main()

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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




def warshall_floyd(d, n):
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d



def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    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 lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)






def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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

Solution (Python):

import sys


def f(n, N, K):
    '''
    >>> f(2, 10, 2)
    0
    >>> f(1, 10, 0)
    10
    >>> f(1, 10, 1)
    0
    >>> f(2, 10, 1) 
    5
    >>> f(3, 10, 0) 
    10
    >>> f(3, 10, 1) 
    7
    >>> f(3, 10, 2) 
    3
    >>> f(5, 5, 2)
    3
    '''
    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()

if __name__ == '__main__':
    test()
    main()

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


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

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

print(cnt)

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time

def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]


yn = ['Yes', 'No']
YN = ['YES', 'NO']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False



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

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

    
    
    

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


if __name__ == '__main__':
    main()

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

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

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

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)

print(ans if K > 0 else ans - N)

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

if __name__ == '__main__':
    solve()

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

Solution (Python):
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)

Solution (Python):
def main():
    n, k = map(int, input().split())
    if k == 0:
        print(n ** 2)
        exit()
    cnt = 0
    for i in range(1, n+1):
        p, r = divmod(n, i)
        cnt += max(0, p * (i - k)) + max(0, r - k + 1)
    
    print(cnt)
if __name__=='__main__':
    main()

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

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

Solution (Python):
N,K=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)

Solution (Python):
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)

Solution (Python):
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)

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):
    div=n//b  
    ans+=(b-k)*div
    rem=n%b
    ans+=max(0,rem-k+1)
print(ans)

Solution (Python):


import io
import sys
import math

nim, mike = map(int, input().split())

if mike==0:
    print(nim*nim)
    exit()

b = mike+1

counter = 0

while b<=nim:
    counter += (nim//b)*(b-mike)+max(nim%b-mike+1, 0)
    b += 1

print(counter)

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

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(K, 1) + 1)
print(ans)

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

ans = 0

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

Solution (Python):
from math import floor

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

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

ans = 0
for b in range(1, N + 1):
    
    num = N // b
    rem = N % b
    
    
    fact = b - 1 - K + 1
    if fact > 0:
        ans += num * fact
    
    
    ans += max(0, rem - K + 1)
    
print(ans)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

co = 0

n,k = m()

for i in range(1,n+1):
    p = n//i
    q = n%i
    co += p*(max(0,i-k))
    co += max(0,q-k+1)
if k == 0:
    co -= n
print(co)

Solution (Python):
N,K=map(int,input().split())
if K==0:
    print(N*N)
else:
    no=N*K+(N-K)*(K-1)
    for b in range(K+1,N+1):
        q=N//b
        r=N%b
        no+=q*K
        if r>=K-1:
            no+=0
        else:
            no-=(K-r-1)

    print(N*N-no)

Solution (Python):
import sys

IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n, k = MII()
    cnt = 0
    for b in range(k+1, n+1):
        p = n//b
        r = n%b
        if k==0:
            cnt += p*(b-k)+max(0, (r-k))
        else:
            cnt += p*(b-k)+max(0, (r-k+1))
    print(cnt)

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for b in range(1,N+1):
    p = N//b
    ans += p*max(b-K,0)
    r = N % b
    ans += max(r-K+1,0)
if K == 0:
    ans = N**2
print(ans)

Solution (Python):






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

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

    return ans


print(main())

Solution (Python):

import sys
input = sys.stdin.readline









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 -= 1

print(ans)

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

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

Solution (Python):

import sys


def solve(N: int, K: int):
    print(sum(
        N // b * (b - K) + max(0, N % b - max(0, K - 1))
        for b in range(K + 1, N + 1)
    ))


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))  
    solve(N, K)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

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

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n,k = map(int,input().split())
    s = 0
    if k==0:
        s = n*n
    else:
        for k_ in range(k,n):
            for q in range((n-k_)//(k_+1)+1):
                if q==0:
                    s += n-k_
                else:
                    s += (n-k_)//q-k_
    print(s)
            
if __name__ == "__main__":
    main()

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

    count += x
print(count)

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

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

print(ans)

Solution (Python):


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

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

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

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

cnt = 0
for j in range(K+1, N+1):
    block = N // j
    R = N % j
    cnt += block * (j-1-K+1)
    if R:
        cnt += max(0, R - max(K,1) +1)
    
print(cnt)

Solution (Python):
n, k = map(int, input().split())
ans = n**2
for b in range(1, n+1):
  if b > k:
    ans -= (n//b)*k+min([n%b, max([k-1, 0])])
  else:
    ans -= n
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))
    val = n % i
    

    ans += max(0, val - max(0,(k-1)))
    
print(ans)

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

def main():
    ans = 0
    if k!= 0:
        for b in range(k+1,n+1):
            for q in range((n-k)//b+1):
                ans += min(b-k,n-b*q-k+1)
        print(ans)
        return
    else:
        print(n*n)
        return

if __name__ == "__main__":
    main()

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

Solution (Python):

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

    b = k + 1
    ans = 0
    while b <= n:
        
        block = (n + 1) // b
        rest = (n + 1) - block * b
        ans += (b - k) * block
        ans += max(0, rest - k)
        if k == 0:
            ans -= 1
        b += 1
    print(ans)


submit()

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

ans = 0

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

print(ans if k!=0 else n**2)

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

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

answer = 0
for i in range(k + 1, n + 1):
    q = n // i; r = n % i
    answer += (i - k) * q
    if r >= k:
        answer += r - k + 1

print(answer)

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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

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

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

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*max(0,i-k)+max(0,n%i-k+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):
    p=n//i
    q=n%i
    ans +=p*max(0,i-k)+max(0,q-k+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):
    p=n//i
    q=n%i
    ans +=p*max(0,i-k)+max(0,q-k+1)
print(ans)

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

if k == 0:
    count -= n
print(count)

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

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

Solution (Python):
n, k = map(int, input().split())
ans = 0
for i in range(k+1, n+1):
        d, m = divmod(n, i)
        ans += d*(i-k) + max(0, m-k+1) - (k==0)
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)
    if n%i>=k:
        ans+=(n%i)-k+1
print(ans)

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

cnt = 0
for b in range(K + 1, N + 1):
    x, y = divmod(N, b)

    k = b - K
    cnt += k * x - (K == 0) + max(0, y - (K - 1))

print(cnt)

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

print(cnt)

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))
print(ans if k > 0 else n ** 2)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

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

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

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


if __name__ == '__main__':
    solve()

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

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

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

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

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

print(ans)