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



Sample input:
5 2


Sample output:
7

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]
ans = 0
if k == 0:
    ans = n*n
else:
    for b in range(k+1, n+1):
        # number of perfect cycle
        ans += n // b * (b-k)
        r = n % b
        ans += max(r - k+1, 0)
print(ans)

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]
ans = 0
if k == 0:
    ans = n*n
else:
    for b in range(k+1, n+1):
        # number of perfect cycle
        ans += max(n // b, 0) * (b-k)
        r = n % b
        ans += max(r - k+1, 0)
print(ans)

Submission status: Accepted

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
if k==0:
    print(n*n)
    exit()
sm = 0
for i in range(k+1,n+1):
    sm += (i-k)*(n//i)+max(0,n+1-(n//i)*i-k)
    #ddprint(f"sm {sm} i {i} n//i {n//i} t1 {(i-k)*(n//i)} t2 {n+1-k-(n//i)*i}")
print(sm)

Submission status: Accepted

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

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

Submission status: Accepted

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

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


if K == 0:
    ans -= N

print(ans)


# ans = 0
# for b in range(1, N+1):
#     for k in range(K, b):
#         for a in range(k, N+1, b):
#             if a > 0:
#                 ans += 1
#                 print(a, b)
#             else:
#                 pass
#                 # print(a, b)

# print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 5 + 10)


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


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

    if K == 0:
        print(N ** 2)
    else:
        for b in range(K + 1, N + 1):
            p, mod = divmod((N + 1), b)

            cnt += p * (b - K)
            if mod != 0:
                if N >= K + p * b:
                    cnt += N - (K + p * b)+1

        print(cnt)


resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


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

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

    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

    print(ans)

Submission status: Accepted

Solution code:
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)
  ans+=max(0,r-K+1)
if(K==0):
  ans-=N
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    ans+=(p*max(0, i-k))
    ans+=(max(0, n%i-k+1))
print(int(ans))

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
#aをbで割った余りがK以上
#b>a bがK+1以上　bーK
#a=b K=0 Nこ
#a>b bがK+1以上 bをずらしてく　a: N-bこ　（N-b）//b*(b-K)+
ans=0
if K==0:
    ans+=N
for b in range(K+1,N+1):
    if b<=N-1:
        ans+=( (N-b)//b )*(b-K)
        if (N-b)%b!=0:
            if K==0:
                X=1
            else:
                X=K
            ans+=max((N-b)%b-X+1,0)
    if b>=2:
        if K==0:
            X=1
        else:
            X=K
        ans+=b-X
    
print(ans)
#3  6   2

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 + (1 - K if K!=0 else 0))
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

if K == 0:
    print(N ** 2)
else:
    # b を固定？
    for b in range(1, N + 1):
        if b - 1 < K: continue
        ans += (b - K) * (N // b)
        ans += max(N % b - K + 1, 0)
        # print(b, ans)

    print(ans)

Submission status: Accepted

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

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

ans = 0
for b in range(1, n+1):
    if b <= k:
        continue
    q, r = divmod(n, b)
    if r < k:
        ans += ((b-1)-k+1)*q
    else:
        ans += ((b-1)-k+1)*q + r-k+1
print(ans)

Submission status: Accepted

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

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
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+1,b)
    ans += (b-K)*d
    ans += max(0, (m-1)-K+1)
print(ans)

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    answer = 0
    for i in range(1, n + 1):
        answer += max(0, i - k) * (n // i) + max(0, n % i - k + 1)
    print(answer if k > 0 else n ** 2)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def solve():
    n,k = map(int,input().split())
    res = 0
    for i in range(k+1,n+1):
        res+=(i-k)*(n//i)
        if n%i>=k:
            if k==0:
                res+=n%i
            else:
                res+=n%i-k+1
    print(res)
if __name__=='__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

answer=0
for i in range(1,N+1):
  p=N//i
  r=N%i
  a1=p*max(0,i-K)
  a2=max(0,r-K+1)
  answer+=a1+a2
  #print(i,a1,a2)
  
if K==0:
  answer-=N
print(answer)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
sum = 0
for b in range(1,N+1):
    q = N % b
    p = (N - q) //  b
    sum += p * max(0,b-K)
    sum += max(0,q-K+1)

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

Submission status: Accepted

Solution code:
def f(n, m, k):
    return (n + 1) // m * (m - k) + max(0, (n + 1) - (n + 1) // m * m - k) - (1 if k == 0 else 0)

n, k = [int(x) for x in input().split()]
print(sum(f(n, m, k) for m in range(k + 1, n + 1)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

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


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N, K = Scanner.map_int()
    ans = 0
    for b in range(1, N+1):
        ans += N // b * max(0, b - K)
        ans += max(0, N % b - K + 1)
    if K == 0:
        ans -= N
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if k == 0:
    print(n**2)
else:
    print(count)

Submission status: Accepted

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

if k == 0:
    print(n**2)
else:
    print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
ans = 0
for i in range(k + 1, n + 1):
    cnt = 0
    max_x = n // i
    cnt += max_x * (i - k)
    low = max_x * i + k
    if low <= n:
        high = min((max_x + 1) * i - 1, n)
        cnt += high - low + 1
    ans += cnt
if k == 0:
    ans -= n
print(ans)

Submission status: Accepted

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

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

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


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

# a % b >= K

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
解説AC=True

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
point = 0
for b in range(1,n+1):
    kaisu = n//b
    kosuu = max(0,b-k)
    point += kaisu*kosuu
    point += max(0,n%b+1-k)
if k == 0:
    point -= n
print(point)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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+=max(0,N%b-(K-1))
    else:
        res+=N%b
print(res)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

ans=0
for n in range(K+1,N+1):
    coff=(n)-(K)
    quan=(N)//n
    ans+=coff*quan
    temp=N-quan*n
    if K!=0:
        temp-=(K-1)
    
    ans+=max(temp,0)
    #print(n,coff,quan,max(temp,0))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N, K = map(int, input().split())
if K == 0:
    print(N*N)
    sys.exit()

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
if k==0:
    print(n**2)
    exit(0)
ans=0
for i in range(k+1,n+1):
    q,r=divmod(n,i)
    ans+=q*(i-k)
    if r>=k:
        ans+=max(r-k+1,0)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    if k == 0:
        print(n**2)
        return
    ans = 0
    for b in range(k+1,n+1):
        s = n//b
        ans += s*(b-k)
        ans += max(0,n-s*b-k+1)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

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 SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n,k=MI()
    if k==0:
        print(n*n)
        exit()
    ans=0
    for b in range(k+1,n+1):
        w=b-k
        c=(n+b)//b
        over=b*c-(n+1)
        ans+=w*c-min(w,over)
    print(ans)

main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ret = 0
for b in range(1, n+1):
    if b<k+1:
        continue
    else:
        m = n//b
        l = n%b
        ret += (b-k)*m
        if k!=0 and l>=k:
            ret += l-k+1
        elif k==0:
            ret += l
print(ret)

Submission status: Accepted

Solution code:
#template
from collections import Counter
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
if K == 0:
    print(N**2)
    exit()
ans = 0
for i in range(K+1,N+1):
    indexa = i-K
    sub = N-i+1
    ans += indexa
    if sub // i != 0:
        ans += (sub//i)*indexa

    mod = sub % i
    ans += max(0,mod-K)

print(ans)

Submission status: Accepted

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    if K == 0:
        return print(N**2)
    ans = 0
    for b in range(2, N+1):
        if K > b-1:
            continue
        pat = N//b
        ans += pat*(b-K)
        m = N % b
        if K <= m:
            ans += m-K+1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    answer = 0
    for i in range(k + 1, n + 1):
        answer += (n // i) * (i - k)
        add = 1
        if k == 0:
            add = 0
        answer += max(n % i - k + add, 0)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
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 debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(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()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

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

Submission status: Accepted

Solution code:
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):
    peri, res = divmod(N,b)
    ans += (b-K)*peri + max(0,res-K+1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()
N,K=map(int,input().split())
if K==0:
    print(N**2)
    exit()
count=0
for b in range(K+1,N+1):
    count+=(N//b)*(b-K)
    count+=max(N%b-(K-1),0)
print(count)

Submission status: Accepted

Solution code:
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
N,K = inputlist()
ans = 0
if K == 0:
    print(N**2)
    exit()
for i in range(K+1,N+1):
    d = i-K
    l = N // i
    m = N % i
    ans += d*l
    ans += max(0,m-K+1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem D - Remainder Reminder

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

# initialization
class_count = 0

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

# output
if K==0:
    class_count -= N
print(class_count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 解説AC
N,K = map(int, input().split())

cnt = 0
for b in range(1, N+1):
    p,r = divmod(N, b)
    cnt += p * max(0, b - K)
    cnt += max(0, r - K + 1)

# a = 0のとき
if K == 0:
    cnt -= N

print(cnt)

Submission status: Accepted

Solution code:
import math

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

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

print(res)

Submission status: Accepted

Solution code:
# Problem D - Remainder Reminder

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

# initialization
class_count = 0
for i in range(1, N+1):
    c_1 = (N//i) * max(0, i-K)
    c_2 = max(0, (N%i + 1 - K))

    class_count += c_1 + c_2

if K==0:
    class_count -= N
# output
print(class_count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0
for i in range(1, n+1):
    if i <= k:
        continue
    q, r = divmod(n, i)
    if r < k:
        ans += (i-k)*q
    else:
        ans += (i-k)*q + (r-k+1)
print(ans)

Submission status: Accepted

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

cnt=0
for i in range(1,n+1):
    temp=(n//i)*(i-k)+max((n-(i*(n//i)+k-1)),0) if i-1>=k else 0
    cnt+=min(temp,n)
    #print(temp,i)
print(cnt)

Submission status: Accepted

Solution code:
import sys
def main():
    input = sys.stdin.readline
    N,K = map(int, input().split())
    
    ans = 0
    for b in range(K+1, N+1):
        div, mod = divmod(N, b)
        one = b - K
        ans += div * one
        ans += max(0, mod - K + (1 if K!=0 else 0))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    Ans = 0
    if K == 0: print(N ** 2)
    else:
        for b in range(K + 1, N + 1):
            Ans += (b - K) * (N // b)
            mod = N % b
            if mod >= K and mod > 0: Ans += mod - K + 1
        
        print(Ans)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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


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

if k == 0:
    ans+=1
print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    MIIS = lambda: map(int,input().split())
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,K = MIIS()
    #NからK+1
    # a % b = K + x (x = 0 ... b-K-1) (K+1<=b)
    # a // b = y (y=0...(N-K)//b)
    ans = 0
    # for i in range(K+1,N+1):
    #     diff = ((N-K)//i+1) * (i-K)
    #     print(i,diff,i-K-1,i-K)
    #     ans += ((N-K)//i+1) * (i-K)
    # print(ans)
    ans = 0
    # for b in range(1,N+1):
    #     for a in range(1,N+1):
    #         # write(str('|{} {} {}| '.format(a,b,a % b >= K)))
    #         if a % b >= K:
    #             ans += 1
    #     print()
    ans2 = 0
    for b in range(K+1,N+1):
        ans2 += (N//b)*(b-K)
        # print(b,N//b*b+1,max(N - (N//b*b + K) +1,0))

        
        ans2 += max(N - (N//b*b + K) +min(1,K),0)
        # for r in range(N//b*b+1,N+1):
            
        #     if r % b >= K:
        #         ans2 += 1
        #     else:
        #         print('a!',r,b)
        # write(str('|{} {}| '.format(b,(N//b)*(b-K)+max((N%b)-K,0))))
        # print()
    
    print(ans2)

    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

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

if __name__=='__main__':
  main()