Problem:
 Score : 600 points    Problem Statement Find the number of sequences of length K consisting of positive integers such that the product of any two adjacent elements is at most N , modulo 10^9+7 .      Constraints  1\leq N\leq 10^9  1  2\leq K\leq 100 (fixed at 21:33 JST)  N and K are integers.         Input Input is given from Standard Input in the following format:  N  K       Output Print the number of sequences, modulo 10^9+7 .        Sample Input 1 3 2      Sample Output 1 5  (1,1) , (1,2) , (1,3) , (2,1) , and (3,1) satisfy the condition.       Sample Input 2 10 3      Sample Output 2 147       Sample Input 3 314159265 35      Sample Output 3 457397712

Solution (Python):
import numpy as np
N, K = list(map(int, input().split()))
mod = 1000000007

m = N ** 0.5
cnt = [N // i - N // (i + 1) for i in range(1, int(m) + 1)] 
cnt = np.array((cnt + [1 for _ in range(N - sum(cnt))])[::-1])
nxt = cnt[:]
for _ in range(K - 1):
    cnt = nxt * np.cumsum(cnt)[::-1] % mod

print(sum(cnt) % mod)

Solution (Python):
import numpy as np
N, K = map(int, input().split())
mod = 1000000007

m = N ** 0.5
cnt = [N // i - N // (i + 1) for i in range(1, int(m) + 1)] 
cnt = np.array((cnt + [1 for _ in range(N - sum(cnt))])[::-1])
nxt = cnt[:]
for _ in range(K - 1):
    cnt = nxt * np.cumsum(cnt)[::-1] % mod

print(sum(cnt) % mod)

Solution (Python):
from itertools import accumulate

def f(n,k):
    lim = int((n + 0.1) ** 0.5) + 1
    ws = []
    s = 0
    for i in range(1, lim):
        w = n // i - n // (i + 1)
        ws.append(w)
        s += w
    ws += [1] * (n - s)
    dp=ws
    m = len(ws)
    for _ in range(k - 1):
        dp=[s*w%md for s,w in zip(accumulate(dp[::-1]),ws)]
    print(sum(dp) % md)
md=10**9+7
n,k=map(int,input().split())
f(n,k)

Solution (Python):
def f(n,k):
    lim = int((n + 0.1) ** 0.5) + 1
    ws = []
    s = 0
    for i in range(1, lim):
        w = n // i - n // (i + 1)
        ws.append(w)
        s += w
    ws += [1] * (n - s)
    m = len(ws)
    dp0 = ws[::-1]
    dp1 = [0] * m
    for _ in range(k - 1):
        s = 0
        for j in range(m):
            s += dp0[j]
            dp1[m - j - 1] = (s * ws[j]) % md
        dp0 = dp1[:]
    print(sum(dp0) % md)
md=10**9+7
n,k=map(int,input().split())
f(n,k)

Solution (Python):
MOD = pow(10, 9) + 7

def main():
  n, k = map(int, input().split())
  dyaku = set([1, n])
  i = 2
  while i*i<=n:
    if n // i not in dyaku:
      dyaku.add(i)
      dyaku.add(n//i)
    i += 1
  reyaku = [0] + list(sorted(dyaku))
  ddyaku = {s: i+1 for i, s in enumerate(sorted(dyaku))}
  dp = [[0 for _ in range(k)] for _ in range(len(dyaku) + 1)]
  for i in range(1, len(dyaku)+1):
    dp[i][1] = (((reyaku[i] - reyaku[i-1]) * (n // reyaku[i])) % MOD + dp[i-1][1]) % MOD
  for i in range(2, k):
    for j in range(1, len(dyaku)+1):
      dp[j][i] = (((reyaku[j] - reyaku[j-1]) * dp[ddyaku[n//reyaku[j]]][i-1]) % MOD + dp[j-1][i]) % MOD
  print(dp[-1][-1])


if __name__ == '__main__':
  main()

Solution (Python):
MOD = 10 ** 9 + 7


def main(N, K):
  W = []
  i = 1
  while i <= N:
    v = N // i
    j = N // v
    
    W.append(j - i + 1)
    i += j - i + 1

  l = len(W)
  dp = [0] * l

  total = 0
  for i, w in enumerate(W):
    total += w
    dp[l - i - 1] = total

  for i in range(2, K + 1):
    tmp = [0] * l
    total = 0
    for j, w in enumerate(W):
      v = dp[j] * w
      total += v
      total %= MOD
      tmp[l - j - 1] = total

    dp = tmp

  return dp[0]


if __name__ == '__main__':
  N, K = map(int, input().strip().split())
  
  
  print(main(N, K))

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
mod = 10 ** 9 + 7
sqrt = int(N**(1/2))
count = [N//i - N//(i+1) for i in range(1, N//sqrt)] + [1] * sqrt
ansList = count
for _ in range(K):
    ansList = [(i * j) % mod for i, j in zip(accumulate(reversed(ansList)), count)]

print(ansList[-1])

Solution (Python):
from itertools import accumulate
def BC132_F():
    n, k = list(map(int, input().split(' ')))
    mod = 10**9 + 7
    sqt = int(n**0.5)
    cnt = [n // i - n // (i + 1) for i in range(1, n // sqt)] + [1] * sqt
    x = cnt
    for _ in range(k):
        x = [(i * j) % mod for i, j in zip(accumulate(reversed(x)), cnt)]
    return x[-1]
 
 
print(BC132_F())

Solution (Python):
from math import sqrt, floor
N, K = map(int, input().split())
mod = 10**9+7

sn = floor(sqrt(N))
t = N//(sn + 1)

dp1 = [0] + [1]*sn + [0]
dp2 = [0] + [N//j - N//(j+1) for j in range(1, t+1)]
dp2 += [0]*(len(dp1) - len(dp2))
C = dp2[:]
for _ in range(K-1):
    d1 = [0]*(sn + 2)
    d2 = [0]*(sn + 2)
    
    sumd1 = 0
    for d in dp1[1:]:
        sumd1 = (sumd1 + d) % mod
    
    d1[1] = sumd1
    
    for i in range(1, sn+1):
        d2[i] = (d2[i] + dp1[i]) % mod
        d1[1] = (d1[1] + dp2[i]) % mod
        d1[i+1] = (d1[i+1] - dp2[i]) % mod
    
    for i in range(1, sn+2):
        dp1[i] = (d1[i] + dp1[i-1])%mod
        dp2[i] = (d2[i] + dp2[i-1])%mod
    dp1[-1] = 0
    
    dp2 = [d*c%mod for d, c in zip(dp2, C)]
ans = 0
for d in dp1:
   ans = (ans + d)%mod
for d in dp2:
    ans = (ans + d)%mod
print(ans)

Solution (Python):
from bisect import bisect
mod = 10**9+7
N,K = map(int,input().split())

c = []
for i in range(1,int(N**0.5)+1):
    c.append(i)
    c.append(int(N/i))
c = list(set(c))
c.sort()

k = []
for i in c:
    if int(N/i) != int(N/(i+1)):
        k.append(i)

dp = [[0]*len(k) for _ in range(K)]
for i in range(len(k)):
    dp[0][i]=k[i]

inv = [0]*(len(k)-1)
for i in range(len(k)-1):
    inv[i] = pow(k[i+1]-k[i],mod-2,mod)

index = [0]*len(k)
for i in range(len(k)):
    m = int(N/(k[i]+1))
    index[i] = bisect(k,m)

for i in range(K-1):
    dp[i+1][0] = dp[i][-1]
    for j in range(len(k)-1):
        m = int(N/(k[j]+1))
        l = index[j]
        S = dp[i][l-1]+(dp[i][l]-dp[i][l-1])*(m-k[l-1])*inv[l-1]
        dp[i+1][j+1] = dp[i+1][j]+(k[j+1]-k[j])*S
        dp[i+1][j+1] %= mod

print(dp[-1][-1])

Solution (Python):

import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  

def solve(N: int, K: int):
    ns = []
    for i in range(1, N + 1):
        if N < i * i:
            break
        ns.append(i)
        ns.append(N // i)
    ns = sorted(list(set(ns)))

    m = {n: i for i, n in enumerate(ns)}
    l = [1] * len(ns)
    for i, (s, b) in enumerate(zip(ns, ns[1:])):
        l[i] = (N // s) - (N // b)

    dp = [[0] * len(ns) for _ in range(K+1)]
    dp[0][m[N]] = 1

    for i in range(K):
        for j in range(len(ns) - 2, -1, -1):
            dp[i][j] += dp[i][j + 1]
        for j, nn in enumerate(ns):
            nj = m[N // nn]
            dp[i+1][j] = (dp[i+1][j] + dp[i][nj] * l[j]) % MOD

    return sum(dp[-1]) % MOD


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    result = solve(N, K)
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
def hersCode(l, r, n, N):
  ok = l
  ng = r + 1
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if mid * n <= N:
      ok = mid
    else:
      ng = mid
  return ng


N, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7

if N == 1:
  print(1)
  exit()

L = []
t = 1
n = N
while t <= N:
  L.append(t)
  t = hersCode(t, N, N // t ,N)

D = [0] * len(L)
L.append(N + 1)
for i in range(len(L) - 1):
  D[i] = (L[i + 1] - L[i]) % MOD
DP = [[0] * (len(D)) for _ in range(K)]
for i in range(len(D)):
  DP[0][i] = D[i]

for i in range(1, K):
  S = [0] * len(D)
  S[0] = DP[i - 1][0]
  for j in range(1, len(D)):
    S[j] = S[j - 1] + DP[i - 1][j]
  for j in range(len(D)):
    DP[i][j] = S[-1 -j] * D[j] % MOD

print(sum(DP[K - 1]) % MOD)

Solution (Python):


import math

MOD = 1000000007



def fact(n):
  ans = {0}
  for i in range(1,math.ceil(n**0.5)+1):
      ans.add(i)
      ans.add(n//i)
  return sorted(list(ans))

def main():
  N,K = map(int, input().split())
  dp = [{} for _ in range(K+1)]
  keys = fact(N)
  dp[1] = {f:f for f in keys}

  for i in range(1,K):
    j_prev = 0
    dp[i+1][0] = 0
    for j in keys[1:]:
      dp[i+1][j] = (dp[i+1][j_prev] + (j-j_prev)*dp[i][N//j]) % MOD
      j_prev = j
  print(dp[K][N])


if __name__ == "__main__":
  main()

Solution (Python):


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

    MOD = 10 ** 9 + 7
    r = int(N ** 0.5 + 1)
    z = [i for i in range(r)] + [N // i for i in range(1, r)][::-1]
    m = len(z)
    pre = [0] + [1] * (m - 1)
    for _ in range(1, K+1):
        dp = [0] * m
        for i in range(1, m):
            dp[i] = (dp[i-1] + pre[m-i] * (z[i] - z[i-1])) % MOD
        pre = dp
    print(dp[-1])


main()

Solution (Python):
import numpy as np
n, k = list(map(int, input().split()))
mod = 10 ** 9 + 7

m = n ** 0.5
cnt = [n // i - n // (i + 1) for i in range(1, int(m) + 1)] 
cnt = np.array((cnt + [1 for _ in range(n - sum(cnt))])[::-1])
nxt = cnt[:]
for _ in range(k - 1):
	cnt = nxt * np.cumsum(cnt)[::-1] % mod

print(sum(cnt) % mod)

Solution (Python):
N,K=map(int,input().split())
mod=10**9+7

import math
SQ=int(math.sqrt(N))

DP1=[1]*(SQ+1)
DP1[0]=0


DP2=[]

k=SQ

for i in range(SQ,0,-1):
    DP2.append(N//i-k)
    k=N//i


KOSUU2=[v for v in DP2]





for j in range(K-1):
    NDP1=[0]*(SQ+2)
    NDP2=[0]*(SQ+1)

    for j in range(1,SQ+1):
        NDP2[-j]-=DP1[j]
        NDP1[1]+=DP1[j]

    
    
    

    for j in range(-1,-SQ-1,-1):
        NDP1[-j+1]-=DP2[j]
        NDP1[1]+=DP2[j]

    
    
    

    for j in range(1,SQ+2):
        NDP1[j]+=NDP1[j-1]

    NDP2[0]+=NDP1[-1]

    for j in range(1,SQ+1):
        NDP2[j]+=NDP2[j-1]

    
    
    

    for j in range(SQ):
        NDP2[j]=NDP2[j]*KOSUU2[j]

    
    
    

    DP1=[n%mod for n in NDP1[:SQ+1]]
    DP2=[n%mod for n in NDP2[:SQ]]

    
print((sum(DP1)+sum(DP2))%mod)

Solution (Python):
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

i = 1
n = []
while i <= N :
    j = N // i
    if i <= j :
        n.append(1)
        i += 1
    else :
        n.append(N//j-i+1)
        i = N // j + 1

M = len(n)

dp = [[0] * M for _ in range(K)]
dp[0] = n

for k in range(1, K) :
    sdp = [0] * M
    sdp[0] = dp[k-1][0]
    for i in range(1, M) :
        sdp[i] = (sdp[i-1] + dp[k-1][i]) % MOD
    for i in range(M) :
        dp[k][i] = sdp[M-i-1] * n[i] % MOD

ret = 0

for j in range(M) :
    ret += dp[K-1][j]
    ret %= MOD
    
print(ret)

Solution (Python):
def main():
	N, K = map(int, input().split())
	DIV = 10**9+7
	sqrtn = int(N**0.5)
	ans = 1
	s = []
	for i in range(1, sqrtn+1):
		s.append(i)
		if i < N//i:
			s.append(N//i)
	s.sort()

	r = []
	for i in range(len(s)-1):
		left = N//s[i+1]
		right = N//s[i]
		r.append(right-left)
	r.append(1)

	m = len(s)
	mp = {}
	for i in range(m):
		mp[s[i]] = i

	dp = [[0 for _ in range(m)] for _ in range(K+1)]
	dp[0][mp[N]] = 1
	for i in range(K):
		for j in range(m-2, -1, -1):
			dp[i][j] += dp[i][j+1]
			dp[i][j] %= DIV
		for j in range(m):
			nj = mp[N//s[j]]
			dp[i+1][j] += dp[i][nj]*r[j]%DIV
			dp[i+1][j] %= DIV

	ans = 0
	for j in range(m):
		ans += dp[K][j]
		ans %= DIV
	print(ans)


if __name__ == '__main__':
	main()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    l = []
    sq = int(n ** 0.5) + 1
    for i in range(1,sq+1):
        l.append((i,n//i,1))

    t = sq
    
    for j,i,_ in l[::-1]:
        
        if t >= i:
            continue
        c = i - t
        l.append((i,j,c))
        t = i

    

    ll = len(l)
    dp = [[0] * ll for _ in range(k+1)]
    dp[0][0] = 1

    l.append((inf,0,0))
    for i in range(k):
        dpi = dp[i]
        np = dp[i+1]
        m = 0
        c = 0
        for j in range(ll-1,-1,-1):
            t = l[j][1]
            tc = l[j][2]
            while l[m][0] <= t:
                c += dpi[m]
                c %= mod
                m += 1
            np[j] = c * tc % mod

    
    return sum(dp[-1]) % mod


print(main())

Solution (Python):
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

MOD = 10 ** 9 + 7
N, K = list(map(int, sys.stdin.readline().split()))


nexts = []
n = N
while True:
    p = int(N // (int(N // n) + 1))
    nexts.append(n)
    if p <= 0:
        break
    n = p


dp = defaultdict(lambda: defaultdict(int))
prev = 0
for n, m in zip(nexts, reversed(nexts)):
    dp[0][m] = m
for k in range(1, K):
    dp[k][0] = 0
    prev = 0
    for n, m in zip(nexts, reversed(nexts)):
        dp[k][m] = (dp[k][prev] + dp[k-1][n] * (m-prev)) % MOD
        prev = m
print(dp[K - 1][N])

Solution (Python):
Q = 10**9+7
from collections import deque
from itertools import accumulate


def main():
    N, K = map( int, input().split())
    ans = 0
    d = deque()
    e = deque()
    M = int(N**(1/2))*2
    for i in range(1, int(N**(1/2))+1):
        if i**2 == N:
            d.append(i)
            M -= 1
            continue
        d.append(i)
        e.appendleft(N//i)
    T = list(d)+list(e)
    CT = [1]*M
    for i in range(1,M):
        CT[i] = T[i] - T[i-1]
    accT = list( map(lambda x:x%Q, accumulate(CT) ))
    dp = [[0]*M for _ in range(K)]
    for i in range(M):
        dp[1][i] = accT[-i-1]*CT[i]%Q
    for k in range(1, K-1):
        accT[0] = dp[k][0]
        for i in range(M-1):
            accT[i+1] = (accT[i]+dp[k][i+1])%Q
        for i in range(M):
            dp[k+1][i] = accT[-i-1]*CT[i]%Q
    print(sum(dp[K-1])%Q)
    
if __name__ == '__main__':
    main()

Solution (Python):
import math
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

MOD = 10 ** 9 + 7
N, K = list(map(int, sys.stdin.readline().split()))

NM = []
prev = 0
for i in range(1, int(math.sqrt(N)) + 2):
    m = int(N // i)
    NM.append(N - m - prev)
    prev = N - m

cnt = N
nums = []
while cnt >= 1:
    nums.append(cnt)
    i = int(N // cnt)
    p = NM[i] if i < len(NM) else 1
    cnt -= p
nums.reverse()


dp = defaultdict(lambda: defaultdict(int))
for n in nums:
    dp[1][n] = n
for k in range(2, K + 1):
    for n in nums:
        i = int(N // n)
        p = NM[i] if i < len(NM) else 1
        ret = dp[k - 1][i] * p % MOD
        cum = dp[k][n - p]
        dp[k][n] = (cum + ret) % MOD

ans = dp[K][N]
print(ans % MOD)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(N, K):
    r = set([0])
    for i in range(1, math.floor(math.sqrt(N))+1):
        r.add(N//i)
        r.add(i)
    r = list(r)
    r.sort()
    

    m = {}
    for i in range(len(r)-1):
        m[i+1] = r[i+1]-r[i]
    DP1 = {k: v for k, v in m.items()}
    DP2 = {}
    M = Mod(10**9+7)
    for _ in range(K):
        S = [0]
        for k in range(1, len(DP1)+1):
            S.append(M.add(S[-1], DP1[k]))
        for k in DP1:
            DP2[k] = M.mul(S[len(DP1)-k+1], m[k])
        DP1, DP2 = DP2, DP1
        

    ans = 0
    for v in DP2.values():
        ans = M.add(ans, v)
    return ans


def main():
    N, K = read_int_n()
    print(slv(N, K))


if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
N, K = map(int, input().split())
MOD = 10 ** 9 + 7













JN = deque()  
SQN = int(N**0.5)
JN.append(SQN)

if SQN**2 != N:
    JN.append(N//SQN)
for j in range(SQN-1, 0, -1):
    JN.appendleft(j)
    JN.append(N//j)
JN.appendleft(0)



LJN = len(JN)

dp = [[0 for _ in range(LJN)] for _ in range(K)]
cdp = [[0 for _ in range(LJN)] for _ in range(K)]
w = [0 for _ in range(LJN)]


prv = 0
for i in range(1,LJN):
    jn = JN[i]
    dp[0][i] = 1
    w[i] = jn - prv
    cdp[0][i] = jn
    prv = JN[i]

for i in range(K-1):
    for j in range(1,LJN):
        dp[i+1][j] = cdp[i][LJN-j]
        dp[i+1][j] %= MOD
        cdp[i+1][j] = cdp[i+1][j-1] + dp[i+1][j] * w[j]
        cdp[i+1][j] %= MOD

print(cdp[-1][-1])

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

MOD = 10 ** 9 + 7

spl = int(N ** 0.5) + 1
l = list(range(spl)) + [N // i for i in reversed(range(1, spl))]
m = 2 * spl - 1

for i in reversed(range(m - 1)):
    l[i + 1] -= l[i]

dp = [l[:]] + [[0] * m for _ in range(K - 1)]
for i in range(K - 1):
    for j in range(m - 1):
        dp[i][j + 1] += dp[i][j]
        dp[i][j + 1] %= MOD

    for j in range(1, m):
        dp[i + 1][-j] = dp[i][j] * l[-j] % MOD

ans = 0
for v in dp[-1][1:]:
    ans += v
    ans %= MOD
print(ans)

Solution (Python):
from itertools import accumulate as ac
N,K=map(int,input().split())
n=int(N**0.5)
mod=10**9+7
list_a=[1]*n
list_b=[N//j-N//(j+1) for j in range(1,n)]+[(N//n-n)]
list_p=[p for p in list_b]
list_aa=list(ac(list_a))
list_bb=list(reversed(list(ac(reversed(list_b)))))

for i in range(K-1):
    temp=sum(list_a)
    list_a=[(temp+list_bb[j])%mod for j in range(n)]
    list_b=[(list_p[j]*list_aa[j])%mod for j in range(n)]
    list_aa=list(ac(list_a))
    list_bb=list(reversed(list(ac(reversed(list_b)))))
    
print((sum(list_a+list_b))%mod)

Solution (Python):
n,m=map(int,input().split(' '))
Mod=1000000007
spl=int(n**0.5)+1
f,k=[i for i in range(spl)]+[n//i for i in range(1,spl)][::-1],2*spl-1
dp=[0]+[1]*(k-1)
for i in range(m):
	dp2=[0]*k
	for j in range(1,k):
		dp2[j]=(dp2[j-1]+dp[k-j]*(f[j]-f[j-1]))%Mod
	dp=dp2
print(dp[k-1])

Solution (Python):
from itertools import accumulate
def BC132_F():
    n, k = list(map(int, input().split(' ')))
    mod = 10**9 + 7
    sqt = int(n**0.5)
    cnt = [n // i - n // (i + 1) for i in range(1, n // sqt)] + [1] * sqt
    x = cnt
    for _ in range(k):
        x = [(i * j) % mod for i, j in zip(accumulate(reversed(x)), cnt)]
    return x[-1]


print(BC132_F())

Solution (Python):
from itertools import accumulate as r;n,k=map(int,input().split());m=10**9+7;j=int(n**0.5);c=[n//(i+1)-n//(i+2) for i in range(n//(j+1))]+[1]*j;x=c;exec("x=[(y*d)%m for y,d in zip(r(x[::-1]),c)];"*k);print(x[-1])

Solution (Python):
from itertools import accumulate

N,K = map(int, input().split())
As = [] 
for i in range(1,int(N**0.5)+1):
    As.append(i)
    if N//i != i:
        As.append(N//i)
As = sorted(As,reverse=False)
nums = []
for i in range(len(As)-1):
    nums.append(As[i+1]-As[i])
nums = [1] + nums
nums.reverse()
mod = 10**9 + 7
ans = 0
dp = [[0] * len(As) for i in range(K+1)]


dp[0][0] = 1
for i in range(K):
    
    
    acc = list(accumulate(dp[i]))
    for j in range(len(As)):
        dp[i+1][len(As)-j-1] = acc[j]*nums[j]%mod
print(sum(dp[K])%mod)

Solution (Python):
def main():
     MOD=10**9+7
     n,k=map(int,input().split())
     t=[]
     t_cnt=[]
     cnt=[0]
     for i in range(1,int(n**0.5)+1):
          tmp=n//i
          if tmp not in t:
               t.append(tmp)
               t_cnt.append(1)
          else:
               cnt[-1]+=tmp
               t_cnt[-1]+=1
     for tmp in range(t[-1]-1,0,-1):
          tmp_j=n//(tmp)-n//(tmp+1)
          if tmp_j!=0:
               t.append(tmp)
               t_cnt.append(tmp_j)
     
     cnt=[]
     now=0
     for i in range(len(t)):
          now+=t[i]*t_cnt[i]
          cnt.append(now)
     kind=len(cnt)
     dp=[cnt]+[[0]*kind for i in range(k-2)]
     
     for i in range(1,k-1):
          for j in range(kind):
               dp[i][j]=(dp[i-1][kind-j-1]*t_cnt[j]+dp[i][j-1])%MOD
     print(dp[-1][-1])
     return
 
if __name__ == '__main__':
    main()

Solution (Python):
import math

MOD = 10**9 + 7


def main():
    N, K = map(int, input().split())
    R = int(math.sqrt(N))
    if N // R == R:
        M = R * 2 - 1
    else:
        M = R * 2
    mapping = [0] * (M+1)
    for i in range(1, R+1):
        mapping[i] = i
        mapping[-i] = N//i
    cnt = [0] * (M+1)
    for i in range(1, M+1):
        cnt[i] = mapping[i] - mapping[i-1]
    dp = [[0] * (M+1) for _ in range(K+1)]
    dp[0] = list(cnt)
    for i in range(M):
        dp[0][i+1] += dp[0][i]

    for i in range(K-1):
        for j in range(1, M+1):
            if j <= R:
                idx = -j
            else:
                idx = M - j + 1
            dp[i+1][j] = dp[i][idx]
        for j in range(M):
            dp[i+1][j+1] = (dp[i+1][j] + dp[i+1][j+1] * cnt[j+1]) % MOD
    print(dp[K-1][M])


if __name__ == "__main__":
    main()

Solution (Python):

"""
Created on Sat Jun 29 22:14:02 2019

@author: Yamazaki Kenichi
"""

N, K = map(int,input().split())
mod = 10**9+7

r = int(pow(N,1/2))

const = []
if N // r == r:
    s = r - 1
else:
    s = r

for i in range(1,r+1):
    const.append(N//i - N//(i+1))


const.reverse()
const = [1 for i in range(s)] + const

dp = [[]]
for c in const:
    try:
        dp[0].append(dp[0][-1] +c)
    except:
        dp[0].append(c)
dp += [[0 for i in range(len(const))] for k in range(K-1)]

for k in range(1,K):
    for i in range(len(const)):
        dp[k][i] = (dp[k][i-1] + dp[k-1][len(const)-i-1]%mod
                      * const[i])%mod
print(dp[-1][-1]%mod)

Solution (Python):
N,K=map(int,input().split())
mod=10**9+7
Layer=[]
a=1
b=1
while(b<=N):
    a=b
    b=N//(N//a)+1
    Layer.append((a,b))

num=[x[1]-x[0] for x in Layer]
M=len(Layer)

dp=[[0 for j in range(M+1)] for i in range(K+1)]
dp[0][0]=1
sdp=[0 for i in range(M+2)]
for k in range(K):
    for j in range(M+1):
        sdp[j+1]=(dp[k][j]+sdp[j])%mod
    for j in range(M):
        dp[k+1][j]=(sdp[M-j]*num[j])%mod
ans=0
for j in range(M+1):
    ans+=dp[K][j]
    ans%=mod
print(ans)

Solution (Python):
from itertools import accumulate
N,K=map(int,input().split())
N_s=int(N**0.5)
list_a=[1]*N_s
list_b=[N//j-N_s for j in range(1,N_s+1)]
list_p=[N//j-N_s for j in range(1,N_s+1)]
for p in range(1,len(list_p)):
        list_p[p-1]=list_p[p-1]-list_p[p]
        
for p in range(1,len(list_b)):
    list_b[p-1]=list_b[p-1]-list_b[p]

list_bb=list(reversed(list(accumulate(reversed(list_b)))))
list_aa=list(accumulate(list_a))

mod=10**9+7

for i in range(K-1):
    temp=sum(list_a)
    list_an=[(temp+list_bb[j])%mod for j in range(N_s)]
    list_bn=[(list_p[j-1]*list_aa[j-1])%mod for j in range(1,N_s+1)]

    list_bbn=list(reversed(list(accumulate(reversed(list_bn)))))
    list_aa=list(accumulate(list_an))
    list_a=list_an
    list_b=list_bn
    list_bb=list_bbn
    
print((sum(list_a)+sum(list_b))%mod)

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

    U = []; V = []
    for x in range(1, int(N**.5)+1):
        U.append(x)
        if x < N//x:
            V.append(N//x)
    V.reverse(); U.extend(V)

    L = len(U)
    prv = 0
    R = []
    for x in U:
        R.append(x-prv)
        prv = x
    def gen(it):
        MOD = 10**9 + 7
        r = 0
        for p, s in it:
            r = (p * s + r) % MOD
            yield r

    S = [1]*(L+1)
    S[-1] = 0
    for k in range(K):
        S[L-1::-1] = gen(zip(R, S))
    print(S[0])
solve()

Solution (Python):
import sys
def solve():
    N, K = map(int, input().split())
    MOD = 10**9 + 7

    U = []; V = []
    for x in range(1, int(N**.5)+1):
        U.append(x)
        if x < N//x:
            V.append(N//x)
    V.reverse(); U.extend(V)

    L = len(U)
    prv = 0
    R = []
    for x in U:
        R.append(x-prv)
        prv = x
    def gen(R, S):
        r = 0
        for p, s in zip(R, S):
            r = (p * s + r) % MOD
            yield r

    S = [1]*(L+1)
    S[-1] = 0
    for k in range(K):
        S[L-1::-1] = gen(R, S)
    print(S[0])
solve()

Solution (Python):
N, K = map(int, input().split())
P = 10**9+7
R = int(N**0.5)+1
A = [i for i in range(R)] + [N//i for i in range(1, R)][::-1]
M = len(A)
X = [0] + [1] * (M-1)
for i in range(1, K+1):
    NX = [0] * M
    for j in range(1, M):
        NX[j] = (NX[j-1] + X[M-j]*(A[j]-A[j-1])) % P
    X = NX
print(X[-1])

Solution (Python):
mod=1000000007
n,k=map(int,input().split())
s=int(n**0.5)
Num=[0]*(s+1)
for i in range(s,0,-1):
    Num[i]=i
    Num.append(n//i)
l=len(Num)
for i in range(1,l):
    Num[-i]=Num[-i]-Num[-i-1]
DP=[[0]*l for _ in range(k)]
DP[0]=Num[:]
for i in range(1,k):
    tmp=0
    for j in range(1,l):
        tmp+=DP[i-1][j]
        tmp%=mod
        DP[i][-j]=(tmp*Num[-j])%mod
ans=0
for i in DP[-1][1:]:
    ans+=i
    ans%=mod
print(ans)

Solution (Python):
import math
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
def ddprint(x):
  if DBG:
    print(x)

R = 10**9+7
n,k = inm()
q = int(math.sqrt(n))
a = [ [0]*(q+1) for j in range(k) ]
b = [ [0]*(q+1) for j in range(k) ]
c = [0]*(q+1)
c[1] = n - n//2
for i in range(2,q):
    c[i] = n//i - n//(i+1)
c[q] = n//q - q
for i in range(1,q+1):
    a[0][i] = 1
    b[0][i] = c[i]


for j in range(1,k):
    aacc = [0]*(q+2)
    bacc = [0]*(q+2)
    for i in range(1,q+1):
        aacc[i] = (aacc[i-1] + a[j-1][i])%R
    for i in range(q,0,-1):
        bacc[i] = (bacc[i+1] + b[j-1][i])%R
    for i in range(1,q+1):
        a[j][i] = (aacc[q]+bacc[i])%R
        b[j][i] = (aacc[i]*c[i])%R

print( (sum(a[k-1]) + sum(b[k-1])) % R )

Solution (Python):
import numpy as np

n, k = list(map(int, input().split()))
MOD = 10 ** 9 + 7
l = int(n ** 0.5)
coe = [n // i - l for i in range(l, 0, -1)]
coe.append(0)
coe.reverse()
coe = np.array(coe, dtype=np.int64)

dp1 = np.ones(l + 1, dtype=np.int64)
dp2 = coe.copy()
dp1[0] = 0
for i in range(k - 1):
    dp1acc_f = np.add.accumulate(dp1) % MOD
    dp1acc_b = np.add.accumulate((dp1 * coe % MOD)[::-1])[::-1] % MOD
    s = dp1acc_f[-1]
    dp1acc_f = np.roll(dp1acc_f, 1)
    dp1[1:] = (s + dp2[1:]) % MOD
    dp2[1:] = (dp1acc_b + dp1acc_f * coe)[1:] % MOD
ans = (dp1.sum() + dp2[1]) % MOD
print(ans)

Solution (Python):
N, K = map(int, input().split())
MOD = 10**9 + 7

sq = 0
while (sq + 1) * (sq + 1) <= N:
    sq += 1

num = [0 for i in range(2 * sq + 1)]
for i in range(1, sq + 1):
    num[i] = 1
for i in range(1, sq + 1):
    lo = max(sq + 1, (N + i + 1) // (i + 1))
    hi = N // i
    num[2 * sq + 1 - i] = hi - lo + 1

dp = [[0 for j in range(2 * sq + 2)] for i in range(K + 1)]
dp[0][1] = 1
for i in range(K):
    for j in range(1, 2 * sq + 1):
        ways = dp[i][j] * num[j] % MOD
        dp[i + 1][1] += ways
        dp[i + 1][2 * sq + 2 - j] -= ways
    for j in range(1, 2 * sq + 1):
        dp[i + 1][j] += dp[i + 1][j - 1]

ans = 0
for j in range(1, 2 * sq + 1):
    ans += dp[K][j] * num[j]
print(ans % MOD)

Solution (Python):
import numpy as np
N,K = map(int,input().split())
MOD = 10 ** 9 + 7
M = int(N**.5)


upper_cnt = np.zeros(M+1, dtype=np.int64)
a = np.arange(M+1, dtype=np.int64)
upper_cnt[1:] = N // a[1:] - np.maximum(M, N // (a[1:]+1))



lower = np.zeros(M+1, dtype=np.int64)
upper = np.zeros(M+1, dtype=np.int64)

lower[1] = 1
for k in range(1,K+1):
    prev_lower = lower
    prev_upper = upper
    np.cumsum(prev_lower, out = prev_lower)
    np.cumsum(prev_upper, out = prev_upper)
    prev_lower %= MOD
    prev_upper %= MOD
    
    lower = np.zeros(M+1, dtype=np.int64)
    lower += (prev_lower[-1] + prev_upper[-1])
    lower[1:] -= prev_upper[:-1] 
    lower[0] = 0
    
    
    upper = prev_lower * upper_cnt
    lower %= MOD
    upper %= MOD
    
answer = (lower.sum() + upper.sum()) % MOD
print(answer)

Solution (Python):
n, k = [int(x) for x in input().strip().split(" ")]
mod = pow(10, 9) + 7

ll = []
ks = []
cc = 0
last = 0
for i in range(n):
    i += 1
    if n//i < i:
        last = n//i
        break
    ll.append(n//i)
    ks.append(1)
    last = n//i
    cc += 1

while True:
    if last == 0:
        break
    if last >= len(ll):
        mm = last
    else:
        mm = ll[last]
    ll.append(last * (ll[last-1] - mm))
    ks.append((ll[last-1] - mm))
    last -= 1
n_l = len(ll)

for _ in range(k-2):
    nll = []
    m = sum(ll) % mod
    for i in range(n_l):
        x = n_l - i - 1
        nll.append((m * ks[i]) % mod)
        m -= (mod + ll[x]) % mod
    ll = nll[:]
print(sum(ll) % mod)

Solution (Python):
import numpy as np

n, k = list(map(int, input().split()))
MOD = 10 ** 9 + 7
l = int(n ** 0.5)
coe = []
for i in range(l, 0, -1):
    coe.append(n // i - l)
coe.append(0)
coe.reverse()
coe = np.array(coe, dtype=np.int64)

dp1 = np.ones(l + 1, dtype=np.int64)
dp2 = coe.copy()
dp1[0] = 0
for i in range(k - 1):
    dp1acc = np.add.accumulate(dp1) % MOD
    dp12acc = np.add.accumulate((dp1 * coe % MOD)[::-1])[::-1]
    s = dp1acc[-1]
    dp1acc = np.roll(dp1acc, 1)
    dp1acc[0] = 0
    dp12acc[0] = 0
    dp1[1:] = (s + dp2[1:]) % MOD
    dp2 = dp12acc + dp1acc * coe % MOD
ans = (dp1.sum() + dp2[1]) % MOD
print(ans)

Solution (Python):
n,k = [int(x) for x in input().split()]
mod = 1000000007
if n == 1:
    print(1)
    quit()
f = [0,n]
i = 1
while f[i] >= i:
    i += 1
    f.append(n//i)
s = [0]*len(f)
for i in range(1,len(f)):
    s[i] = 1
for i in range(2,len(f))[::-1]:
    if f[i] <= i:
        s[-1] = f[i-1]-f[i]
    else:
        s.append(f[i-1]-f[i])
MA = len(s)
dp = [[0]*MA for i in range(k)]
dp[0] = [s[i] for i in range(MA)]
for i in range(MA-1):
    dp[0][i+1] += dp[0][i]
    dp[0][i+1] %= mod
for l in range(k-1):
    for i in range(1,MA):
        j = MA-i
        dp[l+1][i] += dp[l][j]*s[i]
        dp[l+1][i] %= mod
        dp[l+1][i] += dp[l+1][i-1]
        dp[l+1][i] %= mod
print(dp[-1][-1])