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

Submission status: Wrong Answer

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

a = np.array([0]*n,dtype ='int16')
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: Wrong Answer

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

a = np.array([0]*n)
a[0] += n
b = np.array([1,0])
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(a)
print(np.sum(a[k:]))

Submission status: Wrong Answer

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
for b in range(K+1,N+1):  # b を固定
    ans += N//b*(b-K) + max(0,N % b - (K-1))
print(ans)

Submission status: Wrong Answer

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

N,K = MI()

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

    rem = n-loop_cnt*b
    ans += max(0,rem-k+1)
    # print(b,ans)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#bはKより真に大きい、N以下
#aはK以上

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

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

print(count)

Submission status: Wrong Answer

Solution code:
#bはKより真に大きい、N以下
#aはK以上

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

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

print(count)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    ans = 0
    for i in range(1, n - k + 1):
        p, q = divmod(n - k + 1, k + i)
        ans += p * i + min(q, i)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,K = IL()

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

#a=b*x+kk  (k<kk<b)

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

cnt=0
for b in range(k+1,n+1):
    ux=n//b
    if n%b==0:
        umod=0
    else:
        umod=max(0,n%b-k+1)
    dmod=max(0,b-k)
    print(b,"##############")
    print(umod,dmod)

    cnt+=umod+dmod*(ux)

print(cnt)

Submission status: Wrong Answer

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

#a=b*x+kk  (k<kk<b)

cnt=0
for b in range(k+1,n+1):
    ux=n//b
    if n%b==0:
        umod=0
    else:
        umod=max(0,n%b-k+1)
    dmod=max(0,b-k)
    #print(b,"##############")
    #print(umod,dmod)

    cnt+=umod+dmod*(ux)

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
ans=0
for b in range(K,N+1):
    if b==0:
        continue
    #aの数
    #N=pb+r
    #0<=r<bをp回ループした後、r個 or r+1個の余りがある
    #(b-K)でK<=r<bを表している
    #(N//b)でループ数を表している
    ans += (b-K)*int(N//b)

    if N%b>=K and K>0:
        #
        ans+=N%b-K+1
    elif N%b>=0:
        ans+=N%b
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

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

print(ans)

Submission status: Wrong Answer

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

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

for b in range(K+1, N+1, 1):
    cnt += 1
    tmp = (N - (K + cnt - 1)) // b
    ans += cnt * (tmp + 1)
    if (tmp + 1) * b + K <= N:
        ans += N - ((tmp + 1) * b + K) + 1
    print(b, ans)

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ans = 0
cnt = 0
if K == 0:
    print(N * N)
    exit()

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=0
for b in range(k+1,n+1):
  q=n//b
  s=n%b
  ans+=q*(b-k)
  if s>=k and s:
    ans+=s-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(k+1,n+1):
  q=n//b
  s=n%b
  ans+=q*(b-k)
  if s>=k and s:
    ans+=s-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):
  q=n//b
  s=n%b
  ans+=q*(b-k)
  if q>=k:
    ans+=q-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):
  q=n//b
  s=n%b
  ans+=q*(b-k)
  if s>=k:
    ans+=s-k+1
print(ans)

Submission status: Wrong Answer

Solution code:
def check():
    N,K = map(int, input().split())
    total = 0
    
    if K == 0: return N**2
    
    for b in range(1,N+1):
        if b <= K:
            continue
        
        amari = N-b*(N//b)        
        test = amari-K+1 if amari >= K else 0           
        total += (b - K) * N//b + test
    return total
    
print(check())

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    n,k = map(int, input().split())
    ans = 0
    for b in range(k+1, n+1):
        c = 0
        a = k+c*b
        while a <= n:
            if a+b-k <= n:
                ans += b-k
            else:
                ans += n-a+1
            c += 1
            a = k+c*b
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

for b in range(K + 1, N - K + 1):
    B = b
    while (B < N):
        B += b
        if B < N:
            ans += b - K
        else:
            ans += max((N % b)-K+1, 0)
if K == 0:
    ans -= 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans=0

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

Submission status: Wrong Answer

Solution code:
N,K = [int(x) for x in input().split()]
ans =0
for i in range(K+1,N+1):
  #print((N//i)*(i-K),N%i+1-K)
  ans += (N//i)*(i-K)
  if N%i!=0 and K!=0:
    ans +=(N%i+1-K)
  elif N%i!=0 and K==0:
    ans +=(N%i)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
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 = 1000000007


n, k = LI()
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: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = 0
if k == 0:
  start = 1
else:
  start = k

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

print(x)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N, K = map(int, input().split())
    
    if K == 0:
        print(N*N)
        sys.exit()
    
    ans = 0
    ans_tmp = 0
    for i in range(K, N+1):
        j = 0
        tmp = (i*j) + K
        while tmp <= N:
            ans_tmp += 1
            j += 1
            tmp = (i*j) + K
        #ans = ans + ans_tmp
    
    for i in range(K+1, N+1):
        j = 1
        tmp = (i*j) + K
        while tmp <= N:
            ans += 1
            j += 1
            tmp = (i*j) + K
            
    print(ans)
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N, K = map(int, input().split())
    
    if K == 0:
        print(N*N)
        sys.exit()
    
    ans = 0
    for i in range(K, N+1):
        j = 0
        tmp = (i*j) + K
        while tmp <= N:
            ans += 1
            j += 1
            tmp = (i*j) + K
    
    for i in range(K+1, N+1):
        j = 1
        tmp = (i*j) + K
        while tmp <= N:
            ans += 1
            j += 1
            tmp = (i*j) + K
            
    print(ans)
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
def kosuu(n,b,k):
    if n%b == 0:
        return (n//b) * (b-k)
    else:
        res = 0
        res += n//b * (b-k)
        diff = n%b - k
        if diff >= 0:
            res += diff + 1
        return res

cnt = 0
for b in range(K+1,N+1):
    ko = kosuu(N,b,K)
    # print(b,ko)
    cnt += ko

print(cnt)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=0
## a<b and k>0
ans+=(n-k)*(n-k+1)//2

#print(ans)
## a>b
for i in range(1,n):
    if i*(k+1)>n:
        break
    #print(min(n,i*(k+1)*2))
    t=(k+1)*i
    ans+=max(0,min(n,t*2)-t-k+1)

print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=0
## a<b and k>0
ans+=(n-k)*(n-k+1)//2

#print(ans)
## a>b
for i in range(1,n):
    #print("i",i)
    #print(ans)
    if i*(k+1)>n:
        if n>=i*(k+1):
            ans+=n-i*(k+1)+1
        break
    ans+=i*(k+1)*2-i*(k+1)-k



print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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):
        temp=(i-k)*(n//i)
        r=n%i
        if r>=k:
            temp=temp+(r+1-k)
        print(temp)
        ans=ans+temp
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


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

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

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


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

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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc090/tasks/arc091_b

import itertools
import collections
import bisect


def main():
    N, K = map(int, input().split())
    ans = 0
    for b in range(K+1, N+1):
        p = N // b
        r = N - b * p
        tmp = p * (b - K) + max(0, r - K + 1) if K != 0 else max(0, r - K) # 該当する部分をまとめて計算する
        # print("b = {}, c = {}, p = {}, tmp = {}".format(b, b - K, p, tmp))
        ans += tmp

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc090/tasks/arc091_b

import itertools
import collections
import bisect


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

    print(total)

Submission status: Wrong Answer

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

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

    print(total)

Submission status: Wrong Answer

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

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

print(total)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
"""
a<bとして良い
bを固定する
b=a*p+q (q:あまり)
q>=kのものを調べる
bがN以下、aがb以下でfor loop
K
"""
N, K = map(int, input().split())

ans = 0

for b in range(2,N+1): #2~Nまで
  for a in range(2,N+1): #2~Nまで
    q = a%b
    #print(a,b,q,K)
    if q >= K:
      ans += 1
      
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 解説どおりにやるとK = 0で失敗する? 
def number_of_a(b):
	q, r = divmod(N,b)
	# for each range, we have b-K possible A's
	# in the last range, we have max(0,r-K+1) possible A's.
	s = q * max(0,b-K) + max(0,r-K+1)
	# print((b,q,r,s))
	return s
 
N, K = map(int,input().split())
s = 0; b = 1;
while b <= N:
	s += number_of_a(b)
	b += 1
print(s)

Submission status: Wrong Answer

Solution code:
# 解説どおりにやるとK = 0で失敗する? 
def number_of_a(b):
	q, r = divmod(N,b)
	# for each range, we have b-K possible A's
	# in the last range, we have max(0,r-K+1) possible A's.
	s = q * max(0,b-K) + max(0,r-K+1)
	# print((b,q,r,s))
	return s

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

Submission status: Wrong Answer

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

cc = 0

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

print(cc)

Submission status: Wrong Answer

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

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)