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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    count = 0
    if K == 0:
        return N**2

    for b in range(K+1, N+1):
        cc = N//b
        count += cc * (b-K)
        dd = N-cc*b
        if dd >= K:
            count += dd - K + 1

    return count

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
if K==0:
    print(N*N)
    exit()
b = K+1
cnt = 0
while b<=N:
    cnt += (N//b)*(b-K)+max(N%b-K+1, 0)
    b += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

print(m())

Submission status: Accepted

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

Submission status: Accepted

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


def count_a(b, N, K):
    p = int((N + 1) / b)
    r = (N + 1) % b
    return (b - K) * p + max(0, r - K)


count = 0

for b in range(K + 1, N + 1):
    count += count_a(b, N, K)
    if K == 0:
        count -= 1
print(count)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

count = 0
for b in range(1, N+1):
  if b-K <= 0: continue
  x = N // b
  count += (b-K) * x

  if N%b > 0 and N%b >= K:
    if K == 0:
      count += N%b
      continue
    count += N%b-K+1

print(count)

Submission status: Accepted

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

ans=0

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, raw_input().split())
c = 0
for d in range(k+1,n+1):
    p = (n - k) / d
    c += (p+1) * (d-k)
    c -= max(0, (p+1) * d - 1 - n)
    if k == 0: c -= 1
print c

Submission status: Accepted

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

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

print(counter)

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

Solution code:
def solve(n, k):
    if k == 0:
        return n**2
    ans = 0
    for b in range(k+1, n+1):
        m = (n-k) / b
        if (m+1)*b <= n:
            ans += (m+1)*(b-k)
        else:
            ans += m*(b-k) + n - m*b - k + 1
    return ans
n, k = map(int, raw_input().split())
print solve(n, k)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
# a<bのとき(N-k)+(N-k-1)+...+1
ct=(N-K)*(N-K+1)//2
if K==0:
    ct-=N
# a>bのときsum_b(N-K)//b ただしb=k+1~
for b in range(K+1,N+1):
    ct+=(b-K)*(N//b-1)+max(0,N%b-K+1)
print(ct)

Submission status: Accepted

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

res = 0

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
tmp = list(map(int,input().split()))
n, k = tmp[0],tmp[1]
if k == 0:
  print(n**2)
  quit()
ans = 0
for i in range(k+1,n+1):
  t = n // i
  ans += (i-k) * t
  l = n - t * i - k
  if l >= 0:
    ans += (l + 1)
print(ans)

Submission status: Accepted

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


if k==0:
    print(n**2)
else:
    for b in range(k+1,n+1):
        amari=n%b
        if amari>=k and amari<b:
            result+=(amari-k+1)*((n//b)+1)+(b-amari-1)*((n//b))
        elif amari>=k:
            result+=(b-k)*((n//b)+1)
        else:
            result+=(b-k)*((n//b))
    print(result)

Submission status: Accepted

Solution code:
K = input().split()
N = int(K[0])
K = int(K[1])

count = 0
for b in range(K+1, N+1):
    siki1 = int((N-K)/b)
    siki2 = int((N-b+1)/b)
    if siki1 <= siki2:
        count += (b-K)*siki1
    elif siki1 > siki2:
        count += (b-K)*siki1
        count -= (b-N-1)*(siki1 - siki2)
        count -= b*(int((siki1*(siki1+1))/2) - int((siki2*(siki2+1))/2))

if K != 0:
    for a in range(K, N+1):
        count += N-a
if K == 0:
        for a in range(1, N+1):
            count += N-a

print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def calc(N, K):
    # a=K is N-K set.
    # a>K and a<b is N-K+1...N-K+K
    ans = (N - K + 1) *(N - K)//2
#    print ans
    # a>K and a>b
    # a % b = ik  =>  a = b * x + ik
    # b > ik and 1 <= x <= (N - ik)/ik
    ik = N//2 + 1
    while ik >= K and ik != 0:
        x = (N - ik - 1) // ik
        while x > 0:
            tmp = ((N - ik) // x) - ik
#            print("ik:{} tmp:{} x:{}".format(ik,tmp,x))
#            print("N:{} N-ik*x:{}".format(N,N-ik*x))
            if tmp > 0:
                ans = ans + tmp
            x = x - 1
        ik = ik - 1
    if K == 0:
        i = 2
        while i <= N:
            ans = ans + N // i
            i = i + 1
    return ans


def main():
    N, K = map(int, raw_input().split())
    ans = calc(N,K)
    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
    r = n%b
    ans += p*max(0,b-k) + max(0,r-k+1)
if k == 0:ans -= n
print(ans)

Submission status: Accepted

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

count = 0
for i in range(1,n+1):
    if int(n/i)*(i-k) > 0:
        count += int(n/i)*(i-k)
        #print("{}:{}".format(i, int(n/i)*(i-k)))
    if (n % i) + 1 - k > 0:
        count += n%i+1-k
        if k==0:
            count -= 1
            #print("{}:{}".format(i,n%i-k))
        #else:
            #print("{}:{}".format(i,n%i+1-k))
print(count)

Submission status: Accepted

Solution code:
def max(a,b):
    if a > b:
        return a
    else:
        return b
n, k = [int(i) for i in input().split()]
ans = 0


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

Submission status: Accepted

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

count = 0

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

if k == 0:
    count -= n

print(count)

Submission status: Accepted

Solution code:
def count_k_or_more(b, N, K):
    # 0 % bがcountに含まれている場合は-1する必要がある
    # しかし0 % b = 0でこれがcountに含まれるのはK = 0の場合のみ
    # K = の場合はcount = Nになるのでそのままreturnする
    if K == 0:
        return N

    # N = pb + r
    p = N // b
    r = N % b

    count = p * max(b - K, 0) + max(r + 1 - K, 0)
    return count


if __name__ == '__main__':
    N, K = [int(v) for v in input().split()]

    total = 0
    for b in range(1, N + 1):
        total += count_k_or_more(b, N, K)

    print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if K == 0:
    print(N * N)
else:
    count = 0
    for i in range(K + 1, N + 1):
        amari = N % i
        warikiriru = N - amari

        count += warikiriru - int(warikiriru / i) - int(warikiriru / i) * (K - 1)
        # print("w", warikiriru - int(warikiriru / i) - int(warikiriru / i) * (K - 1))
        if amari >= K:
            count += amari - (K - 1)
            # print("a", amari - (K - 1))

    print(count)

Submission status: Accepted

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

if K > 0:
    for b in range(K+1, N+1):
        u = ((N - b)//b) + 1
        v =  (N - K)//b

        cnt += (b-K)*u + (v-u+1)*(-b*(u+v)+2*N-2*K+2)/2
else:
    for b in range(K+1, N+1):
        u = ((N - b)//b) + 1
        v =  (N - K)//b

        cnt += (b-K)*u + (v-u+1)*(-b*(u+v)+2*N-2*K+2)/2 - 1

print(int(cnt))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

a=input().rstrip().split(" ")
n=int(a[0])
k=int(a[1])
t=1
_sum=0

if k == 0:
    t=0
for b in range(k+1,n+1):
    
    _sum = _sum + (b-k)*math.floor(n/b)+max(0,n%b-k+t)
print(_sum)

Submission status: Accepted

Solution code:
S = input().split(" ")
S = [int(i) for i in S]
a = 0
for i in range(1,S[0] + 1):
    a += (max(i-S[1],0) * int(S[0]/i)) + max(0,S[0]%i-(S[1]-1))
if S[1] == 0:
    a -= S[0]    
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

total = 0
for m in xrange(k + 1, n + 1):
    # print "m: %s" % (m,)
    total += n / m * (m - k)
    # print "n / m * (m - k): %s" % (n / m * (m - k),)
    total += max(n % m - (k - 1), 0)
    # print "n rem m - (k - 1): %s" % (max(n % m - (k - 1), 0),)

print total

Submission status: Accepted

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


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

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

print(result)

Submission status: Accepted

Solution code:
import numpy as np

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

for i in range(k + 1, n + 1, 1):
    if k == 0:
        a += n ** 2
        break

    b, c, d= i - k, (n - k) // i, 0
    if i - 1 + i * c > n:
        d = i - 1 + i * c - n

    a += b * (c + 1) - d

print(a)

Submission status: Accepted

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

Submission status: Accepted

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

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

print ans

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#abc090d

n,k=map(int,raw_input().split())
res=0
for b in xrange(1,n+1):
 x=n/b
 r=n%b
 res+=x*max(0,b-k)
 res+=max(0,r-k+1)
if k==0:
 res=n**2
print res

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = input().split(" ")
n = int(x[0])
k = int(x[1])
count = 0

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem D

if __name__ == '__main__':
    number, k = list(map(int, input().split()))
    count = 0

    # See:
    # https://img.atcoder.jp/arc091/editorial.pdf
    # https://beta.atcoder.jp/contests/abc090/submissions/2193514
    for b in range(1, number + 1):
        p, r = divmod(number, b)
        count += p * max(0, b - k) + max(0, r - k + 1)

    if k == 0:
        count -= number

    print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem D

if __name__ == '__main__':
    number, k = list(map(int, input().split()))
    count = 0

    # HACK: Not beautiful.
    if k == 0:
        print(number ** 2)
    else:
        for b in range(1, number + 1):
            p = (number + 1) // b
            r = number - (p * b)
            count += p * max(0, b - k)

            if (number + 1) % b != 0:
                count += max(0, r - k + 1)

        print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

Submission status: Accepted

Solution code:
j = list(map(int, input().split()))
counter = 0
n = j[0]
k = j[1]

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

print(counter)

Submission status: Accepted

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

    # TLE(N, K)
    editorial(N, K)


def editorial(N, K):
    """
    # https://twitter.com/tanakh/status/972832191863336960
    N = p*b + r (0 <= r < b)

    a固定: bが変わるので余りが変わるため意味なし
    b固定: aが変わっても余りは一定周期になる
        0%b, 1%b, 2%b, ..., (b-1)%b, b%b, (b+1)%b, ..., (pb-1)%b, pb%b, ..., (pb+r)%b
        0,   1,   2,   ..., (b-1),   0,   1,       ...,  b-1,      0,    ..., r
        余りの数列: (0...b-1)がp個 と 0...r
        ↓
        0...K-1, K...b-1
        b個の中にKより小さい数はK個
        よって, b - min(b, K) = max(b-K, 0)
    """
    ans = 0
    if K == 0:
        # 次のfor loop計算を0込みにせず、
        # 余り>=0つまりa*bのすべての組合せ数N*Nを返して終了でも良い
        ans -= N

    # 余り>=Kのため mod K+1から
    # K=0のとき、1-N loopよりN余分
    for b in range(K+1, N+1):
        # 0-Nまでの0込みのためN+1
        p, r = divmod(N+1, b)

        ans += p * (b - K) + max(0, r - K)

    print(ans)


def TLE(N, K):
    """
    1 <= a,b <= N <= 10^5
    a mod b >= K
    0 <= K <= N-1
    """
    # a < b: mod b = a, K <= a <= N
    ans = 0
    for a in range(K, N):
        b_pattern = N - a
        ans += b_pattern

    # a > b: mod b = x
    # K >= b: mod b = 0 or K< より
    # K < b < a <= N
    for a in range(K+2, N+1):
        for b in range(K+1, a):
            if a % b >= K:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
Tmp = []
Tmp  = input().rstrip().split(' ')

N = int(Tmp[0])
K = int(Tmp[1])

Ans = 0
nTmp = 0
nTmp2 = 0
nTmp3 = 0

if K == 0:
  Ans = N **2
else:
    for i in range(N+1):
        if i == 0:
            continue
        B = i
        nTmp = B - K
        if nTmp > 0:
            nTmp2 = N // B
            nTmp3 = (B - K) * nTmp2
            Ans += nTmp3
            nTmp2 = N % B
            if nTmp2 != 0:
                nTmp2 = nTmp2 - K + 1
                if nTmp2 > 0:
                    Ans += nTmp2
    
print(Ans)

Submission status: Accepted

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


solve()

Submission status: Accepted

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

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

main()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

ans = 0
for b in range(1, n+1):
    q = n // b
    r = n % b

    ans = ans + q * max(0, b - k) + max(0, r - k + 1)
    if k == 0:
        ans -= 1

print (ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

Solution code:
# coding=utf-8

line = input().split(" ")
n = int(line[0])
k = int(line[1])

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

print(ret)

Submission status: Accepted

Solution code:
lis = list(map(int, input().split()))
n = lis[0]
k = lis[1]
count = 0

for b in range(k+1, n+1):
	quo = int(n / b)
	rem = n % b
	if rem == 0:
		count += quo * (b - k)
	else:
		count += quo * (b - k)
		if (rem >= k) and (k != 0):
			count += rem - k + 1
		elif (rem >= k) and (k == 0):
			count += rem - k
print(count)

Submission status: Accepted

Solution code:
import math
if __name__ == "__main__":
    N, K = list(map(int, (input().split(' '))))
#    ans = N * N
#    buf = 0
#    for i in range(0, K):
#        for j in range(1, N+1):
#            if i == 0:
#                if j == 0:
#                    buf += N
#                else:
#                    buf += math.floor(N / j)
#            else:
#                if j != 1:
#                    if (N % j) >= i:
##                        print(i, j, math.floor(N / j) + 1)
#                        buf += math.floor(N / j) + 1
#                    else:
##                        print(i, j, math.floor(N / j))
#                        buf += math.floor(N / j)
#    ans -= buf
    ans = 0
    if K == 0:
        ans = N**2
    else:
        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)
    print(ans)

Submission status: Accepted

Solution code:
n,k = [int(i) for i in input().split()]
count = 0
if k == 0:
    count = n**2
else:
    for K in range(k,n):
        waru = K+1
        p,r = divmod(n,waru)
        count += p * (waru - k) + max(0,r-k+1)

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

b=1
ans=0
while b<=n:
    p,r=divmod(n,b)
    ans+=p*max(0,b-k)+max(0,r-k+1)
    b+=1
if k==0:
    ans-=n
print(ans)

Submission status: Accepted

Solution code:
def d_remainder_reminder(N, K):
    ans = 0
    for b in range(K + 1, N + 1):
        # N=pb+r(0<=r<b) と表すと、aを"0"からNまで変化させたときに
        # a%bを順に並べた列は、[0,1,2,...,b-1]*p + [0,1,2,...,r] となる
        p = N // b
        r = N % b
        # 条件を満たすaの個数は、p*max(0,b-K) + max(0,r+1-K) 個
        ans += p * max(0, b - K) + max(0, r + 1 - K)
    if K == 0:
        # K=0のとき、1回のループで1だけ解が大きくなる(a=0の分を足してしまうため)
        # その分を差し引く
        ans -= N
    return ans

N,K = [int(i) for i in input().split()]
print(d_remainder_reminder(N, K))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
count = 0
if K == 0:
    print(N*N)
else:
    for b in range(K+1,N+1):
        x = N // b
        y = N % b
        count = count + (b-K)*x #植木算.b-1-K+1 = b-K
        if y >= K:
            count = count + y-K+1 #K=0のときはこの式だと1多くなってしまう
    print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N, K = map(int, input().split(" "))
c = 0
 
if K != 0:
    for b in range(K+1, N+1):
        r = N % b
        p = N // b
        s = p * (b-K)
        t = max(0, r - (K - 1))
        c += (s + t)
        
else:
    c = N ** 2

print(c)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N, K = map(int, input().split(" "))
c = 0
 
if K != 0:
    for b in range(K+1, N+1):
        s = N % b
        t = N - s
        p = t // b * (b - K)
        q = max(0, s - (K - 1))
        c += (p + q)
        
else:
    c = N ** 2

print(c)

Submission status: Accepted

Solution code:
#coding=utf-8

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

def main():
    A, B = input().split(' ')
    print(solve(int(A), int(B)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n,k):
  counter = 0
  for i in range(n,k,-1):
    theValue = n//i * (i-k) + max(n%i-k+1,0)
    if (k == 0):
      theValue = max(theValue-1, 0)
    counter += theValue
  return counter

c = list(map(int, input().split()))
print(solve(c[0], c[1]))

Submission status: Accepted

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

Submission status: Accepted

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

if K != 0:
    for i in range(K, N):
        s = N % a
        t = N - s
        p = t // a * (a - K)
        q = max(0, s - (K - 1))
        ans += (p + q)
        a += 1
else:
    ans = N ** 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

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

Submission status: Accepted

Solution code:
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)
if k == 0:
    print(n*n)
else: print(ans)

Submission status: Accepted

Solution code:

N,K=map(int,input().split(' '))
count = 0
for b in range(K+1,N+1):
    l, h, n = K, b-1, b-K
    while l <= N:
        if h <= N:
            count += n
            if l==0:
                count -=1
        else:
            count += N-l+1
            if l==0:
                count -=1
            break
        l+=b
        h+=b
print(count)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
if k == 0:
    print(n**2)
elif k <= 100:
    ans = 0
    for j in range(k):
        for i in range(k+1,n+1):
            ans += (n-j)//i
    print((n-k+1)*(n-k)-ans)
else:
    r = n//k
    ans = 0
    for i in range(1,r+3): #a=(i-1)×b+あまり
        genkai = n - (i)*k
        for j in range(1,n-k+1): #b=k+j
            x = (i-1)*j
            ans += min(max(genkai-x+1,0),j)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
ans = 0
for b in xrange(K + 1, N + 1):
    l, r, c = K, b - 1, (N + 1) / b
    ll = K + c * b
    ans += c * (r - l + 1)
    if ll <= N:
        ans += N - ll + 1
    if l == 0:
        ans -= 1
print ans

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()));
counter = 0;
if K == 0:
	print (N*N);

else:
	for i in range(N-K):
		counter += (N-i) - K;
	#print (counter)
	for i in range(K+1,N):
		a = N//i;
		#print (i,a)
		b = N%i;
		#print (i,b)
		if b >= K and b != 0:
			b = b;
		else:
			b = K - 1;

		counter += ( b - K + 1 ) + ( a - 1 )*( i - K ) 
		#print (i,counter)

	print (counter)