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: Time Limit Exceeded

Solution code:
import numpy as np

N_K = list(map(int, input().split()))
 
count = 0

a = np.array([i for i in range(1, N_K[0]+1)])
b = np.array([i for i in range(1, N_K[0]+1)])

for i in range(len(b)):
    value = a % b[i]

    for l in range(len(value)):
        if value[l] >= N_K[1]:
            count += 1

'''
for a in range(1, N_K[0]+1):
  for b in range(1, N_K[0]+1):
    if a % b >= N_K[1]:
      count += 1
'''
print(count)

Submission status: Time Limit Exceeded

Solution code:
N_K = list(map(int, input().split()))
 
count = 0
 
for a in range(1, N_K[0]+1):
  for b in range(1, N_K[0]+1):
    if a % b >= N_K[1]:
      count += 1
    
print(count)

Submission status: Time Limit Exceeded

Solution code:
n, k = [int(i) for i in input().split()]
ans = 0
for a in range(k,n+1):
    ans += n - a
    for b in range(1,a):
        if a % b >= k:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = [int(i) for i in input().split()]
ans = 0
for a in range(1,n+1):
    for b in range(1,n+1):
        if a % b >= k:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = list(map(int, input().split()))
                                                                                                                           
result = 0
for q in range(k, n):
  for b in range(q+1, n+1):
    result += int((n-q)/b)+1 if q > 0 else int((n-q)/b)

print(result)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = tuple(map(int, input().split()))

if k == 0:
    print(n*n)
    exit()
    
ans = 0
for a in range(k, n+1):
    ans += n-a
    b = np.arange(k+1, a-k+1)
    ans += np.sum((a%b)>=k)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = tuple(map(int, input().split()))

ans = 0
if k == 0:
    print(n*n)
    exit()
for a in range(max(1,k), n+1):
    ans += n-a
    b = np.arange(k+1, a+1)
    ans += np.sum((a%b)>=k)
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        x = i % j
        ans += 1 if x>=k else 0

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
N, K = list(map(int, input().split()))
count = 0
for i in range(K, N+1):
    count += N - i
for i in range(K+1, N+1):
    for j in range(1, i):
        if i % j >= K:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
count=0
for i in range(1,N+1):
    for j in range(1,N+1):
        if i%j>=K:
            count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
N, K = (int(i) for i in input().split())
count = 0
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if (i % j) >= K:
            count = count + 1

print(count)

Submission status: Time Limit Exceeded

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

#あまり(b)はK+1より大きい。
for b in range(K+1,N+1):
    for a in range(1,N+1):
        if a%b>=K:
            count+=1
            
print(count)

Submission status: Time Limit Exceeded

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

count = 0

for a in range(1, n+1):
    for b in range(1, n+1):
        if a % b >= k:
            count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = raw_input()
n= n.split()
N = int(n[0])
K = int(n[1])
ans = 0

for i in range(K,int(N)+1):
	for r in range(1,int(N)+1):
		if r == i:
			ans += int(N) - r
			break
		mod = pow(i,1,r)
		if mod >= K:
			ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

counts = 0
for b in range(1, N+1):
    for a in range(1, N+1):
        if a % b >= K:
            counts += 1

print(counts)

Submission status: Time Limit Exceeded

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

pairs = []

for i in range(1, N + 1):
    for j in range(1, N + 1):
        pairs.append((i, j))

res = 0

for (a, b) in pairs:
    if a % b >= K:
        res += 1

print(res)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

mod = list(map(lambda x: x[0]%x[1], itertools.product(range(1, N+1), repeat=2)))
print(sum([1 for x in mod if x >= K]))

Submission status: Time Limit Exceeded

Solution code:
def f(n, k):
    return 0.5*(n-k)*(n-k+1)

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

cnt = 0
for a in range(K, N+1):
    for b in range(K, a+1):
        if a <= 1 or b <= 1:
            continue
        if ((a%b) >= K):
            cnt += 1

cnt += f(N, K)
print(int(cnt))

Submission status: Time Limit Exceeded

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

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

Ans = 0
Num = K + 1
nTmp = 0
nTmp2 = 0

if K == 0:
    Ans = N**2
else:
    nTmp = int((N - K)*(N - K + 1)/2)
    Ans += nTmp
    while Num < N:
        nTmp2 = N
        while nTmp2 - K >= Num:
            nTmp = nTmp2 % Num
            if nTmp >= K:
                Ans += 1
            
            nTmp2 -= 1
        
        Num += 1


print(Ans)

Submission status: Time Limit Exceeded

Solution code:
#coding=utf-8

def solve(A, B):
    count = 0
    for b in range(B + 1, A + 1):
        for a in range(1, A + 1):
            if a % b >= B:
                count += 1
    return count

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(1, N + 1):
    if i < K:
        continue
    for j in range(1, N + 1):
        if j <= K:
            continue
        elif i < j:
            ans += len(list(range(i, N)))
            break
        elif i > j:
            if i % j >= K:
                ans += 1

if K != 0:
    print(ans)
elif K == 0:
    print(N*N)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
l = raw_input().split()
N = int(l[0])
K = int(l[1])
a = 1
b = 1
total = 0
while a <= N:
    b = 1
    while b <= N:
        if a%b >= K:
            total += 1
        b += 1
    a += 1
print(total)

Submission status: Time Limit Exceeded

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

n,k = input().split()
N = int(n)
K = int(k)

sum = 0
for a in range(1,N+1):
    for b in range(1,N+1):
        if K < (a%b) or K == (a%b):
            sum += 1
        
print(sum)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().strip().split(" "))
count = (n - k) * (n - k + 1) // 2
for a in range(1, n + 1):
    if a < k:
        continue
    for b in range(1, a):
        if a % b >= k:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
count=0
for a in range(1,N+1):
    for b in range(1,N+1):
        if a%b>=K:
            count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
def rep(b,r,N):
    return (N-r)//b+1 if r>0 else N//b

N,K=map(int,input().split(' '))
count = 0
for b in range(K+1,N+1):
    for r in range(K,b):
        count += rep(b,r,N)
print(count)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().strip().split(" "))
count = (n - k) * (n - k + 1) // 2
for a in range(1, n + 1):
    if a < k:
        continue
    for b in range(1, n + 1):
        if a <= b:
            break
        if a % b >= k:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
#a,b<N && b>K
#bの倍数+(k),(k+1)...+(b-1)となるa<Nの数を考える
#bを1~Nで回す
count = 0
for b in range(1,N+1):
    if b <= K:
        continue
    count = count + (b-K)*(N//b)
    #この段階でa = b*(N//b)-1までの処理は完了
    for i in range(b*(N//b), N+1):
        if i % b >= K:
            count += 1
if K == 0:
    count = N*N
print(count)

Submission status: Time Limit Exceeded

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

if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    # aがK以上のとき、 a<b を満たすものはありうる組となる
    # a=bのとき、愚直に計算する
    ans = 0
    for a in range(1, N+1):
        for b in range(1, N+1):
            if a%b >= K:
                #print("({},{})".format(a, b))
                ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(i) for i in input().split()]
c = 0
for a in range(K,N):
	for b in range(a+1,N+1):
		c += (N-a)//b+1
if K == 0:
	c -= N
print(c)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8

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

ct = 0
for i in range(k, n):
  for j in range(1, n+1):
    for x in range(1, n+1):
      if(x%j == i):
        ct += 1

print(ct)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
cnt=0
for a in range(1,n+1):
    for b in range(k+1,n+1):
        if a%b>=k:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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):
        for a in range(k, b):
            ans += ((n - a) // b) + 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
if k == 0:
    print(n**2)
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: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
count = 0
for a in range(1,n+1):
    for b in range(1,n+1):
        if a % b >= k:
            count += 1
            
print(count)

Submission status: Time Limit Exceeded

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

# AtCoder Beginner Contest
# Problem D

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

    count = 0

    for i in range(1, number + 1):
        for j in range(1, number + 1):
            if i % j >= k:
                count += 1

    print(count)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Accepted

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

# ans = 0
# for right in range(k+1, n+1):
#     for left in range(max(1,k), right):
#         while left <= n:
#             ans+=1
#             left+=right
# print(ans, flush=True)
# TLE

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd, log10
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, chain
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
from copy import copy, deepcopy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


n, k = LI()
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, input().split())
answer = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

#解説みた
N, K = na()
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 = list(map(int,input().split()))
ans=0

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = 0
b = 3
for b in range(k+1, n+1):
    if k == 0:
        ans += n
        continue

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

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

Submission status: Accepted

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

cnt = 0
for i in range(K + 1, N + 1):#b = K + 1 ... N
  k = int(N / i)
  l = N % i
  if K == 0:
    cnt += k * (i - K) + max(0, l - K)
  else:
    cnt += k * (i - K) + max(0, l - K + 1)
  #print(cnt, k, l)
  
print(cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Np1 = N+1
ans = 0
for b in range(1, Np1):
    r = b - K
    if r <= 0:
        continue
    for a in range(max(1,K), Np1, b):
        ans += min(a+r, Np1) - a
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)
    if N//b*b+K <= N:
        ans += N - (N//b*b+K) +1 
if K == 0:
    ans -= N
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s = 0

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from copy import deepcopy

INF = 10 ** 20


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

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

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from copy import deepcopy

INF = 10 ** 20


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

if k==0:
    print(n*n)
    sys.exit()
    
icnt=0
for ki in range(k+1,n+1):
    qki=n//ki
    icnt+=qki*(ki-k)+max(n%ki-(k-1),0)

print(icnt)

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)
    if k == 0:
        m = n % i
    else:
        m = n % i - k + 1
    ans = max(ans, ans + m)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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)+max(n%b-k+1,0)-(k<1)
print(c)

Submission status: Accepted

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

#n-k-j>=b*r  j=0,...,b-k-1

Submission status: Accepted

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

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

# mod b ということは、あまり0~b-1が n // b回つづく
for b in range(k, n+1):
    x = n // b
    y = n % b
    ans += (b-k) * x
    if y >= k:
        ans += y + 1 - k
print(ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    print(ans)
    return


if __name__ == '__main__':
    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 = map(int, input().split())
ans = 0
for b in range(k + 1, n + 1):
    temp = n // b
    temp2 = n % b
    ans += temp * (b - k) + max(temp2 - max(0, (k - 1)), 0)
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):
  q,r=divmod(N,i)
  ans += q*max(0,i-K)+max(0,r-K+1)
print(ans)

Submission status: Accepted

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

    print(res)

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)
    if N % b >= K:
        ans += (N % b) - K + 1
if K == 0:
    ans -= N
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n,k = map(int,input().split())

a = np.array([0]*n,dtype ='int64')
a[0] += n
for i in range(1,n):
    c = n // (1+i)
    d = n % (1+i)
    a[1:i+1] += c
    a[0] +=c
    if d > 0:
        a[1:d+1] +=1
print(np.sum(a[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#bを固定すればaの個数をo(1)で計算できそうぷりね

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int, open(0).read().split())

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,K = MI()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

if K == 0:
    print(pow(N, 2))
    sys.exit()

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

print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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):
    quo, rem = divmod(n, i)
    ans += quo * (i-k)
    if rem >= k:
        ans += rem - k + 1

print(ans)

Submission status: Accepted

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

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

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

print(res)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

# a = pb + r 
# N = 10, b = 4
# a (0...10)
# r 0,1,2,3,0,1,2,3,0,1,2
ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from math import floor
N,K = map(int,input().split())
ans = 0
for b in range(K+1, N+1):
    p,r = N//b,N%b
    ans += p*max(0,b-K)+max(0,r-K+1)
print(ans if K!=0 else ans-max(0,b-K))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *

N, K = MAP()

ans = 0

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

if K == 0:
	ans -= N

print(ans)