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 math

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

    ans = 0
    for amari in range(k, n):
        max_shou = (n - amari) // (amari + 1)
        if amari > 0:
            ans += n - amari
        for shou in range(1, max_shou + 1):
            start = (amari + 1) * shou + amari
            nokori = n - start + 1
            ans += math.ceil(nokori / shou)

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,k=IL()
ans=0
for i in range(1,n+1):
    ans+=max(i-k,0)*(n//i)
    ans+=max(0,n%i-k+1)
if k==0:
    ans=n*n
print(ans)

Solution (Python):

from sys import *
N,K=map(int,raw_input().split())

b=K+1
ans=0
if K==0:
    print(N*N)
    exit(0)

while b<=N:
    s=0
    bNum=(N+1)/b
    s+=bNum*(b-K)
    if (N+1)%b!=0:
        s+=max(0,((N)%b)-K+1)
    ans+=s
    b+=1

print(ans)

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

if (K!=0):
  s=0
  for b in range(K+1,N+1):
    w = N//b
    a = N%b
    ds = 0
    ds+= max(a-K+1,0)
    ds+= w*(b-K)

    s+=ds
    
  print (s)
else:
  print (N*N)

Solution (Python):


import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


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

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

    res = 0
    for b in range(1, n + 1):
        p, r = divmod(n, b)
        ok = max(0, b - k)
        res += ok * p + max(0, r - k + 1)

    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
	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__':
    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) + max(0,N%i - K+1)
print(ans)

Solution (Python):
import sys
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+=(N//i)*(i-K)
    if N%i>K-1: ans+=N%i-K+1

print(ans)

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

        x = N // b
        y = N % b

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

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

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

print(ans)

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

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

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

for b in range(1, n+1):
    if b <= k:
        continue
    ans += (b-k)*(n//b)
    if n%b >= k:
        if k != 0:
            ans += n%b - k + 1
        else:
            ans += n%b - k
print(ans)

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

ans = 0
for b in range(1,n+1):
  if b <= k:
    continue
  ans += (b - k) * (n // b)
  if n % b >= k:
    if k != 0:
      ans += n % b - k + 1
    else:
      ans += n % b - k
print(ans)

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

Solution (Python):



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

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

res = 0
for b in range(k+1,n):
    kk = b-k
    
    r = n//b
    kkk = n%b
    if r > 0:
        res += kk*r
    if k == 0:
        res += kkk
    elif kkk>=k:
        res += kkk-k+1
res += n-k
print(res)

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

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

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

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

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

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

Solution (Python):



def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m)]*n 
def getIntLines(n): return [int(input()) for i in range(n)]
def getIntMat(n, m):  
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat
class Debug():
    def __init__(self):
        self.debug = True

    def off(self):
        self.debug = False

    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K),'N,K')
    count = 0
    for b in range(K+1, N+1):
        q = N // b 
        r = N % b
        d.dmp((b, q, r),'b * q + r')
        count += q*(b-K)
        d.dmp((count),'count 1')
        if r > 0:
            if K == 0:
                count += r
            else:
                count += max(0, r-K+1)
        d.dmp((count),'count 2')
    d.dmp((count),'count')
    return count


ans = prob()
if ans is None:
    pass
elif type(ans) == list and ans[0] == 'col':
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Solution (Python):
from math import sqrt
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)
    r = n%i
    ans += max(r-k+1, 0)
print(ans)

Solution (Python):
def remainder_reminder(N: int, K: int) -> int:
    if K == 0:
        return N * N

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


if __name__ == "__main__":
    N, K = map(int, input().split())
    ans = remainder_reminder(N, K)
    print(ans)

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


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

if K == 0:
    ans -= N
print(ans)

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

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

Solution (Python):


import itertools
import collections
import bisect


def main():
    N, K = map(int, input().split())
    ans = 0
    for b in range(K+1, N+1):
        p = N // b
        r = N - b * p
        tmp = p * (b - K) + (max(0, r - K + 1) if K != 0 else max(0, r - K))  
        
        ans += tmp

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):


import itertools
import collections
import bisect


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

    if K == 0:
        ans -= N

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

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


ans = 0



for b in range(k+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)

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys

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


if __name__ == '__main__':
    main()

Solution (Python):

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

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

ans = 0
if k == 0 :
    print(n*n)
else:
    for b in range(k+1,n+1):
        la = int((n+1)/b)
        ans += (la)*(b-k)
        if  (la*b+k) <= n:
            ans += n-(la*b+ k) + 1

    print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

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

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N,K=rl()
a,b=0,0
ans=0
if K==0:
    ans = N*N
else:
    for b in range(K+1,N+1):
        n = N%b
        ans += b-K
        if n < K:
            ans +=(N//b-1)*(b-K)
        elif K<=n and n<b:
            ans += N//b*(b-K) - (b-n-1)



print(ans)

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

Solution (Python):











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

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

for num in range(k, n + 1):
    
    group = n // num
    mod = n % num

    
    
    res += group * max(0, num - k) + max(mod - k+1, 0)
print(res)

Solution (Python):
N, K = map(int, input().split())
def main():
  for a in range(K+1, N+1):
    s = (a-K)*(N//a)+max(N%a-K, 0)
    s = s-1 if K==0 else s
    s = s+1 if N%a>=K else s
    yield s
print(sum(main()))

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

ans = 0

for i in range(k+1,n+1):
    d = (n+1) // i
    m = (n+1) % i
    p = d*(i-k) + max(0,m-k)
    
    ans += p
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 b in range(K+1,N+1):
    i1 = 0; i2= 0
    Q = (N-K)//b
    i1 = Q*(b-K) 
    left = K; right = min(N-b*Q,b-1)
    
    i2 = max(right - left + 1,0)
    ans += i1 + i2
    
print(ans)

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

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

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

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

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

ans = 0
if k == 0:
    ans = n * n
else:
    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 b in range(k+1,n+1):
    case = (n//b)*(b-k)
    if n%b >=k:
        if k==0:
            case += n%b
        else:
            case += n%b-k+1

    ans += case
print(ans)

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

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

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

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

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

    ans+=p*(b-K)
    if q>=0:
        ans+=q+1
    if K==0:
        ans-=1

print(ans)

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

if k == 0:
    print(n**2)
else:
    total = 0
    for i in range(k+1,n+1):
        d,m = divmod(n,i)
        
        if (i-k) > 0:
            total += d*(i-k)
        if (m-k+1) > 0:
            total += m-k+1

    print(total)

Solution (Python):

import math

def main():
    s = input().split()
    N, K = int(s[0]), int(s[1])

    c = 0
    for b in range(K + 1, N + 1):
        db, mb = int(N / b), N % b
        if mb == 0 or mb < K:
            c += (b - K) * db
        else:
            c += (b - K) * db
            if K == 0:
                c += N - (b * db + K)
            else:
                c += N - (b * db + K) + 1


    print(c)


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

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

Solution (Python):
n,k = map(int, input().split())
ans = 0
for mod in range(k+1,n+1):
  ans += (mod - k) * (n // mod)
  if n % mod >= k:
    ans += n % mod - 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 += (b - K) * (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
bit=0 if K==0 else 1
for b in range(K+1,N+1):
  ans+=N//b*(b-K)+max(0,N%b-K+bit)
print(ans)

Solution (Python):


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

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

if k == 0:
    count += n * n

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

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

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

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):
        a,b=n//i,n%i
        if b<k:
            ans+=a*(i-k)
        else:
            ans+=a*(i-k)+(b-k+1)
print(ans)

Solution (Python):
N,K=map(int,input().split());print(N*(N+(K!=0))-sum(min(b,K,N-a+1)for b in range(1,N+1)for a in range(0,N+1,b)))

Solution (Python):
N, K = map(int, input().split())
print(N * (N + (K != 0)) - sum(min(b, K, N - a + 1) for b in range(1, N + 1) for a in range(0, N + 1, b) ))

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

ans = N * (N + (K != 0))
ans -= sum(min(b, K, N - a + 1) for b in range(1, N + 1) for a in range(0, N + 1, b) )
print(ans)

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

ans = N * (N + (K != 0))
for b in range(1, N + 1):
    for a_ in range(0, N + 1, b):
        ans -= min(b, K, N - a_ + 1)

print(ans)

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

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

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

print(ans)

Solution (Python):

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

ans = 0
for b in reversed(range(1, N+1)):
    s = N//b
    tmp = ( max([0,b-K]))* s
    tmp2 = max([0,N - b * s - max([0,(K-1)]) ]) 
    ans += tmp + tmp2

print(ans)

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

Solution (Python):
def ans(N, M):
    if M == 0: return(N * N)
    cnt = 0
    for i in range(1,N+1):
        p, q = divmod(N,i)
        cnt += p * max(i-M,0) + max((q-M)+1,0)
    return(cnt)

N, M = list(map(int, input().split()))
print(ans(N, M))

Solution (Python):
def ans(N, M):
    if M == 0: return(N * N)
    ans = 0
    for i in range(1,N+1):
        p, q = divmod(N,i)
        ans += p * max(i-M,0) + max((q-M)+1,0)
    return(ans)

N, M = list(map(int, input().split()))
print(ans(N, M))

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

res = 0

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

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

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

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

print(ans)

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

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

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

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

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

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):
N,K = map(int,input().split())
if K == 0:
    print(N*N)
    exit()

ans = 0
for b in range(K+1,N+1):
    d,m = divmod(N,b)
    ans += (b-K)*d + max(0, m+1-K)
print(ans)

Solution (Python):
import sys

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









if K==0:
    print(N**2)
    sys.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):
N, K = map(int, input().split())
num = 0
if K == 0:
    print(N * N)
else:
    for b in range(1, N + 1):
        p, r = N // b, N % b
        num += p * max(0, b - K)
        num += max(0, r - K + 1)

    print(num)

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

ans = 0
for b in range(1, n + 1):
    
    p, r = divmod(n, b)
    ans += p * max(b - k, 0) + max(r - k + 1, 0)
    if k == 0:
        ans -= 1

print(ans)

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)
print(ans - (N if K == 0 else 0))

Solution (Python):
"""
r>=kのものを調べる
bがN以下、aがb以下でfor loop
K

for loopを1重にしたい->0~Nまで動かすとどうなるか考える
bを固定する
N=b*p+r (r:あまり)

あるbについてaを0~Nまで動かすと、a%b=0,1,2,...,b-1,0,...
(0~b-1)がp回繰り返され、最後に0,1,...,r-1,rがつけ加わった形になる

あまりの数は、(b-K)*p + (r-K+1)
"""
N, K = map(int, input().split())

ans = 0

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


if K==0:
  ans -=N

print(ans)

Solution (Python):
ans = 0
N,K = map(int,input().split())
for b in range(K+1,N+1):
    x1,y1 = divmod(N-K,b)
    x2,y2 = divmod(N-b+1,b)
    if x1==x2:
        ans += (x1+1)*(y1-y2+1)
    else:
        ans += (x1+1)*(y1+1) + (x2+1)*(b-y2)+b*(x1+x2+2)*(x1-x2-1)//2
if K == 0:
    print(N*N)
else:
    print(ans)

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

if k == 0:
    print(n**2)
    exit()
    
ans = 0
for b in range(k+1, n+1):
    ans_bk = (n-k)//b+1
    ans_b = ans_bk*(b-k)
    
    mod_k_max = ((n-k)//b)*b+k
    if n-mod_k_max+1 < b-k:
        ans_b -= ((b-k) - (n-mod_k_max+1))
    
    ans += ans_b
            
print(ans)

Solution (Python):
N,K=map(int, input().split())
A=[0]*(N+1)
count=0
for i in range(1, N+1):
	A[i]=int(N/i)
	
for i in range(K+1,N+1):
	count += A[i]*(i-K)
	if N-A[i]*i >= K :
		if K==0:
			count += N-A[i]*i
		else:
			count += N-A[i]*i-K+1

print(count)

Solution (Python):
import math

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

def solve():
    if k == 0:
        return n ** 2
    
    ans = 0
    for b in range(k + 1, n + 1):
        mmin = (n - b) // b + 1
        mmax = (n - k) // b
        ans += (b - k) * mmin
        ans += (n - k + 1) * (mmax - mmin + 1) - b * (mmax * (mmax + 1) - (mmin - 1) * mmin) // 2
    return ans

print(solve())

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

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

print(ans)

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

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

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

print(ans)

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

if N < K:
    print(0)
elif K == 0:
    print(N**2)
else:
    cnt = 0
    b_min = K+1 if K > 0 else 1
    for b in range(b_min, N+1):
        
        cnt += (N//b) * (b-K) + max(0, N%b-K+1)

    print(cnt)

Solution (Python):
def iin(): return int(input())
def nl(): return list(map(int, input().split()))

n, k = nl()

ans = 0
for b in range(1, n + 1):
    ans += (n // b) * max(0, b - k)
    if k == 0:
        ans -= 1
    ans += max(0, (n % b) - k + 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):
    p = N // b
    r = N % b
    cnt += p * (b - K)
    if r >= K:
        cnt += r - K + 1
print(cnt)

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):
    p, r = divmod(N, b)
    cnt += p * (b - K)
    if r >= K:
        cnt += r - K + 1
print(cnt)

Solution (Python):
N, K = map(int, input().split())
ans = 0
for b in range(1, N + 1):
    p, r = divmod(N, b)
    ans += p * max(0, b - K) + 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 * N)
    exit()
cnt = 0
for b in range(K + 1, N + 1):
    p, r = divmod(N, b)
    cnt += p * (b - K) + max(r - K + 1, 0)
print(cnt)

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

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

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

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

Solution (Python):


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

count = 0
if k == 0:
    count = n**2
else:
    for i in range(k, n+1):
        count += int(n/i)*(i-k)
        if (n%i-k >= 0):
            count += n%i-k+1
print(count)

Solution (Python):


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

count = 0
if k == 0:
    count = n**2
else:
    for i in range(k, n+1):
        count += int(n/i)*(i-k)
        if (n%i-k >= 0):
            count += n%i-k+1
print(count)

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def solve(N, K):
    if K == 0:
        return N * N

    ans = 0
    for b in range(1, N + 1):
        now = K
        while K <= b and now <= N:
            ans += min(N, now + (b - K) - 1) - now + 1
            now += b
    return ans

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

    print(solve(N, K))

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

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

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

Solution (Python):

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 = map(int, input().split())
print(find_ans(N,K))

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

def calc(n, k, b):
    if k == 0:
        return n
    q, r = divmod(n, b)
    s = q * max(0, b-k) + max(0, r-k+1)
    return s


count = 0
b = 1
while b <= n:
    count += calc(n, k, b)
    b += 1

print(count)

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+1)//b)*(b-K) + max(0, N - ((N+1)//b)*b-(K -1))
print(int(ans))

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

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

Solution (Python):

def number_of_a(b):
	if K == 0:
		return N
	q, r = divmod(N,b)
	
	
	s = q * max(0,b-K) + max(0,r-K+1)
	
	return s
 
N, K = map(int,input().split())
s = 0; b = 1;
while b <= N:
	s += number_of_a(b)
	b += 1
print(s)

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 else (n % b))
print(ans)

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

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

Solution (Python):
def As(b):
	if K==0:
		return N
	q = N//b
	
	s = (b-K) * q
	if q*b+K <= N:
		s += min((q+1)*b-1,N) - (q*b+K-1)
	return s

N, K = map(int,input().split())
s = 0; b = K+1;
while b <= N:
	s += As(b)
	b += 1
print(s)

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())
c=0
if k==0:
 print(n**2)
else:
  for b in range(k,n+1):
    p=int(n/b)
    r=n%b
    c+=(b-k)*p
    if r>=k:
      c+=r-k+1
  print(c)

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

ans = 0
for i in range(k+1, n+1):
    a, b = divmod(n, i)
    ans += a * (i-k)
    ans += max(0, b + 1 - k)
    ans -= k == 0
print(ans)

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

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

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

print(result)

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

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):
    t,r = divmod(N,i)
    ans += t * (i-K) + ((r-K+1) if r-K+1 > 0 else 0)
print(ans)

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

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

if K > 0:
    count = 0

    for b in range(K+1, N+1):
        p = N // b
        r = N % b
        count = count + p*(b-K)
        if r >= K:
            count = count + r-K+1
    
    print(count)
else:
    print(N*N)