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: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count=0

for b in range(2,N+1):
  for a in range(1,N+1):
    if a%b>=K:
      count+=1
            
print(count)

Submission status: Wrong Answer

Solution code:
import sys
n,k = map(int,input().split())
ans = 0
if k == 0:
    print(n**2)
    sys.exit()
for b in range(k+1,n+1):
    ans_per_loop = b - k
    loop, r = divmod(n,b)
    new = ans_per_loop*loop
    if r >= k:
        new += r-k+1
    print(new)
    ans += new
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()

ans = 0
for b in range(K+1, N+1):
    cnt = 0
    while b*(cnt+1)<=N:
        ans += b*(cnt+1)-(b*cnt+K)
        cnt += 1
    ans += max(0, N-b*cnt-K+1)
print(ans)

Submission status: Wrong Answer

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): #bを一個ずつチェックK+1からNまで
  amari = b-K
  loop = N//b
  nokori = max(N%b+1-K,0)
  temp = loop*amari + nokori
  print(b,amari,loop,nokori,temp)
  ans += temp
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

    # 愚直なやり方で見つけたパターンをb毎の式に落とす
    # for a in range(1, N+1):
    #     print([a % b for b in range(1, N+1)])

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
N,K=list(map(int,input().split()))
ans=0
for i in range(1,N+1):#割る数
   if i<=K:
      continue
   else:
      ans+=(N//i)*(i-K)
      ans+=N-(N//i)*i-(K-1) if N-(N//i)*i-(K-1)>0 else 0
print(ans)

Submission status: Wrong Answer

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

if k == 0:
    ans -= n

print(ans)

Submission status: Wrong Answer

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

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

if k == 0:
    ans -= n

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

for i in range(k+1, n+1):
    print("i={}".format(i))
    cnt = (i-1)-k+1
    add = n // i * cnt
    if n % i >= k:
        add += (n % i) - k + 1
    res += add

print(res)

Submission status: Wrong Answer

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

if k==0:
    print(pow(n,2))
    exit()

ans=0
# あまりの数で場合わけ
for i in range(k,n+1):
    ans+=n-i
    for j in range(1,int(pow(n-i,0.5))+1):
        ans+=max((n-i)//j-i,0)
        if j>i:
            ans+=max((n-i)//j-j,0)


print(ans)

Submission status: Wrong Answer

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

if k==0:
    print(pow(n,2))
    exit()

ans=0
# あまりの数で場合わけ
for i in range(k,n+1):
    ans+=n-i
    for j in range(1,int(pow(n-i,0.5))+1):
        ans+=max((n-i)//j-i,0)
        if j>i:
            ans+=max((n-i)//j-j-1,0)


print(ans)

Submission status: Wrong Answer

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

if k==0:
    print(pow(n,2))
    exit()

ans=0
# あまりの数で場合わけ
for i in range(k,n):
    ans+=n-i
    for j in range(1,int(pow(n-i,0.5))+1):
        ans+=max((n-i)//j-i,0)
        if j>i:
            ans+=max((n-i)//j-j-1,0)


print(ans)

Submission status: Wrong Answer

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

if k==0:
    print(pow(n,2))
    exit()

ans=0
# あまりの数で場合わけ
for i in range(k,n+1):
    ans+=n-i
    for j in range(1,int(pow(n-i,0.5))+1):
        ans+=max((n-i)//j-i,0)
        if j>k:
            ans += max((n - i) // j - i-1, 0)


print(ans)

Submission status: Wrong Answer

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

if k==0:
    print(pow(n,2))
    exit()

ans=0
# あまりの数で場合わけ
for i in range(k,n+1):
    ans+=n-i
    for j in range(1,int(pow(n-i,0.5))+1):
        ans+=max((n-i)//j-i,0)



print(ans)

Submission status: Wrong Answer

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

n = min(N,M)
m = max(N,M)

if n*m == 1:
  print(1)
  exit()
if n == 1:
  print(m-2)
  exit()
print((n-2)*(m-2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n,k=map(int,input().split())
    ans=n**2
    ans-=n*k
    for i in range(k+1,n+1):
        temp=n//i
        temp*=k
        temp+=min(temp%i,k-1)
        ans-=temp 
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
def main():
    n,k=map(int,input().split())
    ans=0
    for i in range(1,1+n):
        for j in range(1,n+1):
            if i%j==k:
                ans+=1
    print(ans)

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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)
print(count)

Submission status: Wrong Answer

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

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: Wrong Answer

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
    ans -= m*i
    ans -= k
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 l!=0 and l>=k:
            ret += l-k+1
        elif l==0:
            ret += l
print(ret)

Submission status: Wrong Answer

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)

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

Solution code:
# むずい

Submission status: Wrong Answer

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

ans=0
for b in range(1,n+1):
    if b<=k:
        continue
    num = n//b
    add=num * (b-k)

    nokori = n-b*num
    if nokori-k+1 > 0:
       add+= nokori - k+1

#    print("  ",b,num,add)
    ans+=add
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(K,N):
  a = i+1
  while a <= N:
    ans += (N-i) // a + 1 
    a += 1

print(ans)

Submission status: Wrong Answer

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

def f(x, y):
    a, b = divmod(x,y)
#    print("aa",b*(a+1))
    return y*a*(a+1)//2 + (b+1)*(a+1)

r = 0
for b in range(K+1, N+1):
#    print(f(N-K, b), f(N-b, b))
    r += f(N-K, b)- f(N-b, b)
#    print(b, N-b+1, N-K+1)
#    print(b, (N-K)//b, (N-b)//b, (N-K)%b, (N-b)%b, b-K)
#    for j in range(N-b+1,N-K+1):
#        r += j//b + 1
print(r)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

print(answer)
#59

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	ans = 0
	for i in range(K + 1, N + 1):
		ans += (N // i) * (i - K)
		if N % i >= K:
			ans += N % i - K + 1
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0
for b in range(max(k,1),n+1):
    if n % b != 0:
        t = math.ceil(n/b)
    else:
        t = int(n/b) + 1
    if n % b >= k:
        count += (b-k)*t - ((t*b-1)-n)
    else:
        count += (b-k)*(t-1)
    print(b,count)

#k=0のとき,n=0を除外する
if k ==0:
    count -= (n-k)


print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(s)

Submission status: Wrong Answer

Solution code:
import bisect
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
from operator import mul

import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

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

ans = 0
if K == 0:
    print(N ** 2)
    exit()
# K < b <= N
for b in range(K + 1, N + 1):
    nk = (N - K)
    bk = (b - K)
    ans += nk // b * bk + min((nk % b) + 1, bk)
    print(b, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
# a%b >= K iff xb+K <= a < (x+1)b
# bごとに数えるだけ

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

for b in range(K+1,N+1):
  cnt = 0
  x_max = N//b
  # 0 <= x < x_max
  # 各xに対してb-K個ある
  cnt += x_max * (b-K)
  # x = x_max
  lower = x_max*b+K
  if lower <= N:
    upper = min((x_max+1)*b-1,N)
    cnt += upper - lower + 1
  ans += cnt
  
print(ans)

Submission status: Wrong Answer

Solution code:
# a%b >= K iff xb+K <= a < (x+1)b
# bごとに数えるだけ

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

for b in range(K+1,N+1):
  cnt = 0
  x_max = N//b
  # 0 <= x < x_max
  # 各xに対してb-K個ある
  cnt += x_max * (b-K)
  # x = x_max
  lower = min(x_max*b+K,N)
  upper = min((x_max+1)*b-1,N)
  cnt += upper - lower + 1
  ans += cnt
  
print(ans)

Submission status: Wrong Answer

Solution code:
# a%b >= K iff xb+K <= a < (x+1)b
# bごとに数えるだけ

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

for b in range(K+1,N+1):
  cnt = 0
  x_max = (N-K)//b
  # 0 <= x < x_max
  # 各xに対してb-K個ある
  cnt += x_max * (b-K)
  # x = x_max
  lower = x_max*b+K
  upper = min((x_max+1)*b-1,N)
  cnt += upper - lower + 1
  ans += cnt
  
print(ans)

Submission status: Wrong Answer

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*(b-K)+max(0,r-K+1)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

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

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ans = 0
N,K = list(map(int,input().split()))
for i in range(N):
    b=i+1
    p=int(N/b)

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

print(ans)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=input().split()
n,k=int(n),int(k)
print((n-k)**2-k)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

print ans

Submission status: Wrong Answer

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

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

print ans

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
    for j in range(1, N):
       if i % j >= K:
           ans += 1

print ans

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for b in range(K+1,N+1):
	#for rem in range(K,b):
	# ans += (N - rem) // b
	k = ((N - K) // b)
	num = min(((N - K) % b) + 1,b-K)
	other = (b - K) - num

	ans += ((b - K) * (k + 1) - other)
	

if K == 0:
	print(ans - 10)
else:
	print(ans)

Submission status: Wrong Answer

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

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,K=[int(i) for i in input().split()]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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 = 0
        q = K
        while b * p + q <= N:
            if b * p + q > 0:
                res += 1
            if q == b - 1:
                p += 1
                q = K
            else:
                q += 1

    print(res)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans=0
for k in range(K,N):
    if k==0:
        for i in range(1,N+1):
            if N//i==1:
                ans+=N-(i-1)
                break
            else:
                ans+=N//i
    else:
        for i in range(k+1,N+1):
            if (N-k)//i==0:
                ans+=N-(i-1)
                break
            else:
                ans+=1+(N-k)//i
print(ans)

Submission status: Time Limit Exceeded

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

# a = b * x + K
ans = 0
for k in range(K,N+1):
  b = k+1
  while (b <= N):
    if k == 0:
      ans += (N-k)//b
    else:
      ans += (N-k)//b +1
    #print(ans,(N-k)//b +1,k,b)
    b += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
hako = []
for a in range(1, n + 1):
  for b in range(1, n + 1):
    if a % b >= k:
      hako.append(1)
print(sum(hako))

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(1, N+1):
    for j in range(1, N+1):
       if i % j >= K:
           ans += 1

print ans

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

r = 0

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

print(r)

Submission status: Time Limit Exceeded

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


for k in range(K, N):
	for b in range(k+1, N+1):
		for i in range(0, N+1):
			a = i*b + k
			if a > N:
				break
			elif a != 0:
				count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n, k = map(int, input().split())
ans = 0
for m in range(k, n):
    nm = n - m
    sb = m + 1
    s = nm // sb
    ds = [nm // d + 1 for d in range(s, 0, -1)]
    ds = [sb] + ds + [n + 1]
    # print(m, nm, sb, s, ds)
    dd = np.diff(ds)
    pd = np.arange(s + 1, 0, -1) if m else np.arange(s, -1, -1)
    # print(dd, pd, dd * pd, sum(dd * pd))
    ans += sum(dd * pd)
print(ans)

Submission status: Accepted

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

# In[9]:


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


# In[10]:


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


# In[ ]:

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    if k == 0:
        print(n ** 2)
        exit()
        
    res = 0
    for b in range(1, n + 1):
        q, r = divmod(n, b)
        res += max(0, (b - 1 - (k - 1))) * q + max(0, r - (k - 1))
    print(res)


if __name__ == '__main__':
    resolve()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

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

    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N,K=mint()
if K==0:
    print(N**2)
    exit()
ans=0
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:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    N, K = map(int, sysread().split())
    ans = 0
    for b in range(K+1, N+1):
        if K == 0:
            ans -= 1
        count = b-1 -K + 1
        alpha = (N-b+1) % b
        prim_add = (N-b+1) // b + 1
        prim = b-1 - alpha + 1
        if count <= prim:
            ans += count * prim_add
            continue
        ans += prim * prim_add
        L = (count - prim) // b
        resid = (count - prim) % b
        ans += ((prim_add + 1 + (L+prim_add)) * L // 2) * b
        ans += (L+ prim_add + 1) * resid

    print(ans)
if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

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

if __name__ == '__main__':
    main()