Problem:


Score : 300 points

Problem Statement

Given is a positive integer N.
How many tuples (A,B,C) of positive integers satisfy A \times B + C = N?

Constraints

 2 \leq N \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.

Sample Input 1

3

Sample Output 1

3

There are 3 tuples of integers that satisfy A \times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).

Sample Input 2

100

Sample Output 2

473

Sample Input 3

1000000

Sample Output 3

13969985



Sample input:
3


Sample output:
3

Submission status: Accepted

Solution code:
n = int(input())
if n%2:
    h = n//2
else:
    h = n//2+1
count=0
for i in range(h+1,0,-1):
    judge = n//i
    if n%i == 0:
        count=count+judge-1
    else:count += judge
for i in range(h+2,n):
    count+=1

print(count)

Submission status: Accepted

Solution code:
def c_a_times_b_plus_c():
    N = int(input())
    ans = 0
    for a in range(1, N + 1):
        for b in range(N // a, 0, -1):
            if N - a * b >= 1:
                ans += 1
    return ans

print(c_a_times_b_plus_c())

Submission status: Accepted

Solution code:
import sys

N = int(input())

ans = 0

for i in range(1, N):
    if i == 1:
        ans += N - 1
        continue

    if i * 2  + 1 <= N:
        ans += (N - 1) // i 
    else:
        ans += N - i
        break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
for i in range(1,N):
    cnt += (N-1) // i

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
#エラトステネスの篩（素数列挙）さらに合成数をふるい落とした素数を記録
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
    if is_prime[i] != True:
        continue
    for j in range(i * 2, n + 1, i):
        is_prime[j] = i



def factorization3(l):
    #素因数分解で、余計な素数を探索せずに済む！
    num = 1
    temp = l 
    
    while is_prime[temp] != True and temp != 1:
        k = is_prime[temp]
        cnt=0
        while temp % k == 0:
            cnt+=1
            temp //= k
        num *= (cnt+1)

    if temp!=1:
        num *= 2

    if num == 1:
        num *= 2

    return num
#ここまでの計算量はO(NloglogN(前処理) + logN(実際の分解))

total = 1
for x in range(2,n):
  y = factorization3(x)
  total += y
print(total)

Submission status: Accepted

Solution code:
n = int(input())
res = 0
for a in range(1, n):
  res += ((n - 1) // a)
print(res)

Submission status: Accepted

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def get_factor(N):
    N1 = N + 2
    A = [2, 0] * (N1//2)

    for i in range(3, N1, 2):
        if A[i]:
            continue
        for j in range(i, N1, 2*i):
            A[j] = i

    def factor(n):
        i = 0
        ans = []

        while n & 1 == 0:
            i += 1
            n >>= 1
        if i:
            ans.append((2, i))

        while n > 1:
            a = A[n]
            i = 1
            while True:
                n //= a
                b = A[n]
                if a != b:
                    ans.append((a, i))
                    b = a
                    break
                i += 1

        return ans


    return factor

def resolve():
    N = int(sys.stdin.readline())

    f = get_factor(N)

    ans = 0
    for i in range(1, N):
        num = 1
        #print(i, f(i))
        for a, b in f(i):
            num *= b + 1
        ans += num
    print(ans)
if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
a = 1
while a < n:
    s = (n - 1) // a
    ans += s

    s = 0
    a += 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
res=0
for i in range(1,n):
  res+=(n-1)//i
print(res)

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0

for i in range(1, N):
    cnt += (N-1)//i
    
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

ret = 0
for a in range(1, N + 1) :
  ret += (N - 1) // a
  
print(ret)

Submission status: Accepted

Solution code:
n = int(input())
c = 0
for i in range(1,n):
  c += (n-1)//i
print(c)

Submission status: Accepted

Solution code:
import math
n=int(input())
ans=0
for i in range(1,int(math.sqrt(n))+1):
    for j in range(i,(n-1)//i+1):
        k=n-i*j
        if k>0:
          if i==j:
            ans+=1
          else:
            ans+=2
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
c=0
for i in range(1,n//2+2):
    for j in range(i,n//i+1):
        s=i*j
        if(s<n):
            if(i!=j):
                c+=2
            else:
                c+=1
print(c)

Submission status: Accepted

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

def solve(N: int):
    ans = 0
    for i in range(1, N):
        if N % i == 0:
            ans += (N / i) -1
        else:
            ans += (N // i)
    print(int(ans))

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
n=int(input())
l=int(math.sqrt(n))
x=0
l=int(math.sqrt(n))
for i in range(1,l+1):
    y=(n-1)//i-i+1
    x+=2*(y-1)+1
if l*l==n:
    x+=1

print(x)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        if n<=a*b:
            break
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
half = int(N**0.5)
if half**2==N:
  half-=1
ans = 0
for i in range(1, (half+1)):
  tmp = (N-1)//i
  
  ans += (tmp + (tmp-half))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

ans=0

for i in range(1,n):
    ans+=(n-1)//i

print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input()) - 1
    ans = 0

    for i in range(1, n+1):
        ans += n//i

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(n):
  b=(n-1)//(i+1)
  ans=ans+b
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for A in range(1, N + 1):
    ans += (N - 1) // A

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,n):
  if n % i == 0:
    ans += n // i - 1
  else:
    ans += n // i
print(ans)

Submission status: Accepted

Solution code:
import math
def check(x):
    return math.sqrt(x) == int(math.sqrt(x)) and x != 1

n = int(input())
a = [1]* (n +1);
for i in range(2, n+1):
    for j in range(i, n+1, i):
        if j // i != i:
            a[j] += 1
        else:
            a[j] += 2
ans = 0
for i in range(1, n):
    ans += a[n - i] if not check(n-i) else a[n-i] - 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
result = 0
for a in range(1, n):
	# b = (n - 1) // a
	result += (n - 1) // a
print(result)

Submission status: Accepted

Solution code:
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
#import numpy as np
n = int(input())
#n, m = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

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

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
N=int(input())

sq_set=set()
for i in range(1,10**3+1):
  sq_set.add(i*i)
#print(sq_set)

alist=[i for i in range(N)]
dlist=[i for i in range(N+1)]
for i in range(2,int(N**0.5)+1):
  if dlist[i]<i:
    continue
  else:
    for j in range(i**2,N+1,i):
      dlist[j]=i  
#print(dlist)

answer=1
for i in range(1,N-1):
  AB=N-i
  AB_copy=AB
  facts=defaultdict(int)
  while AB>1:
    facts[dlist[AB]]+=1
    AB//=dlist[AB]
    
  num_div=1
  for k,v in facts.items():
    num_div*=v+1
    
  #print(AB_copy,facts,num_div)
  answer+=num_div
  
print(answer)

Submission status: Accepted

Solution code:

n  = int(input())
ans = 0
for i in range(1,1000000):
    a2 = (n-1)//i
    ans += a2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n):
    p = n // i
    if p * i < n:
        ans += p
    else:
        ans += p - 1
print(ans)

Submission status: Accepted

Solution code:
# 179 C
N = int(input())
ans = 0
for i in range(1, N):
    ans += (N-1)//i
    
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()

    count = 0

    tmp_list = [i for i in range(1,n)]

    for i in range(1, n):
        insert_index = bisect_right(tmp_list, n//i)
        if i * insert_index == n:
            insert_index -= 1
        count += insert_index

    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
for a in range(1,N):
  b = (N-1) // a
  cnt += b
      
print(cnt)

Submission status: Accepted

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

    # A*B<Nとなる(A, B)の数
    ans = 0
    for i in range(1, N):
        ans += (N - 1) // i

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
prim = [1]*(n)
for i in range(2,n):
  k = i
  while k<n:
    prim[k] += 1
    k += i
for i in range(1,n):
  tmp = n-i
  cnt += prim[tmp]
print(cnt)

Submission status: Accepted

Solution code:
def number(N):
    m=0
    for i in range(1,N+1):
        for j in range(1,N//i+2):
            if N-i*j>0:
                m+=1
    return m
N=int(input())
print(number(N))

Submission status: Accepted

Solution code:
def resolve():
	N = int(input())
	res = 0
	for n in range(1, N):
		res += (N-1)//n
	print(res)
resolve()

Submission status: Accepted

Solution code:
N=int(input())

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)

    # divisors.sort()
    return divisors
lis=[1]*10**6
#A*B
ans=1
for i in range(1,N-1):
    now=i+1
    while now<=10**6:
        lis[now-1]+=1
        
        now+=(i+1)
    ans+=lis[i]
#print(lis[:10])
print(ans)

Submission status: Accepted

Solution code:
# import sympy

# 約数の列挙
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

def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

def main():
    N = int(input())
    table = num_divisors_table(N)
    ans = 0
    for c in range(1, N):
        #ab = make_divisors(N-c)
        #ab = sympy.divisors(N-c)
        ab = table[N-c]
        ans += ab
    print(ans)
        
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  count = 0
  for i in range(1,N):
    M = (N-1) // i
    for j in range(1,M+1):
      count += 1
  print(count)
  
main()

Submission status: Accepted

Solution code:
import math
N = int(input())

k = 0
for a in range(1,N) :
    bmax = math.floor((N-1)/a)
    #print(bmax)
    k = k + bmax

print(k)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    Ans = 0
    for a in range(1, N + 1):
        maxb = (N - 1) // a
        Ans += maxb
    print(Ans)
    
resolve()

Submission status: Accepted

Solution code:
n=int(input())
a=0
b=0
for i in range(1,n):
  for j in range(i,n):
    if i*j<n:
      if i==j:
        b+=1
      else:
        a+=1
    else:
      break
print(a*2+b)

Submission status: Accepted

Solution code:
import sys


def resolve(in_):
    N = int(next(in_))
    # A * B + C = N
    # 

    ans = 0
    for a in range(1, N + 1):
        b, m = divmod(N, a)
        if m == 0:
            b -= 1
        ans += b

    return ans



def main():
    answer = resolve(sys.stdin)
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

N = int(input())
ans = 0

for a in range(1, N):
    ans += ((N-1) // a)
print(ans)

Submission status: Accepted

Solution code:
import sys
from math import *

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


n = Num()
ans = 0
for i in range(1, n + 1):
    ans += n // i


def div(n):
    count = 0
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            if n // i == i:
                count += 1
            else:
                count += 2
    return count


print(ans - div(n))

Submission status: Accepted

Solution code:
n=int(input())
s=0
for i in range(1,10**6+1):
    s=s+(n-1)//i
print(s)

Submission status: Accepted

Solution code:
n=int(input())
n=n-1
ans=0
for i in range(1,n+1):
    ans+=n//i
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    N = int(input())

    ans = 0
    for a in range(1, N + 1):
        for b in range(a, N + 1):
            if a * b > N - 1:
                break
            else:
                ans += 1
                if a != b:
                    ans += 1
    print(ans)







if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
sm=0
for i in range(1,n):
  sm+=(n-1)//i
print(sm)

Submission status: Accepted

Solution code:
n = int(input())
c = 0
for i in range(1, (n // 2) + 1):
    if i ** 2 >= n:
        break
    if n % i == 0:
        a = n // i - 1
    else:
        a = n // i
    c += 2 * (a - i) + 1
print(c)

Submission status: Accepted

Solution code:
n = int(input())
c=0
for i in range(1,n):
  a = 0
  while a<n-i:
    a+=i
    c+=1

print(c)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
i=1
for i in range(1,n):
    a=int((n-1)/i)
    cnt+=a
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

if n==1:
    print(0)
    exit()

ans = 1
ans += (n-2)*2

for i in range(2,n-1):
    ans += (n-1)//i-1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
answer = 0
for i in range(1,N):
    if N % i == 0:
        answer += (N // i - 1)
    else:
        answer += N // i
print(answer)

Submission status: Accepted

Solution code:
import math
n=int(input())

cnt=0
for a in range(1,n+1):
    cnt+=math.floor((n-1)/a)
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0

for i in range(1,n+1):
  cnt += (n-1)//i
print (cnt)

Submission status: Accepted

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

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
    div,mod = divmod(n,i)
    ans += div
    if mod == 0:
        ans -= 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

result = 0

for  A_1 in range(N):
    A = A_1 + 1
    B_m = N // A
    
    if N % A == 0:
        B_m -= 1
    
    result += B_m
    
print(result)

Submission status: Accepted

Solution code:
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    ans = 0
    for i in range(1, 1000):

        lo = 1
        hi = n + 1
        while hi - lo > 1:
            mid = (hi + lo) // 2
            if i * mid >= n:
                hi = mid
            else:
                lo = mid
        if lo < i:
            break
        else:
            ans += (lo - i) * 2 + 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

import sys


def std_in():
    return sys.stdin.readline().strip()


def main():
    n = int(std_in())
    ans = 0
    neg = 0
    for a in range(1, n + 1):
        b, c = divmod(n, a)
        ans += b
        if c == 0:
            neg += 1

    print(ans - neg)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
N=int(input())
wari=1
count=0
sum=0
for i in range(N):
    count=(N-1)//wari
    sum+=count
    wari+=1
print(sum)

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
ans = 0
divide_minimam_prime = [i for i in range(n + 1)]
is_prime = [True for i in range(n + 1)]
is_prime[0] = False
is_prime[1] = False
for div in range(2,int(n**0.5) + 1):
    if is_prime[div]:
        # divが素数だった場合
        k = div
        divide_minimam_prime[k] = k
        k += div
        while k <= n:
            is_prime[k] = False
            if divide_minimam_prime[k] == k:
                divide_minimam_prime[k] = div
            k += div
for i in range(1,n):
    k = i
    use_divnum = defaultdict(int)
    while k != 1:
        div = divide_minimam_prime[k]
        while k % div == 0 and k > 1:
            k = k // div
            use_divnum[div] += 1
    count = 1

    for j in use_divnum.values():
        count *= j + 1
    ans += count
print(ans)

Submission status: Accepted

Solution code:
num = int(input())

def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
  
cnt = 0

print(sum(num_divisors_table(num)[:-1]))

Submission status: Accepted

Solution code:
N = int(input())
count = 0
for A in range(1, N):
    if N % A == 0:
        B_num = (N // A) - 1
        count += B_num
    else:
        B_num = N // A
        count += B_num
print(count)

Submission status: Accepted

Solution code:
#c
N=int(input())
ans=0
for i in range(1,N):
    s = N//i
    if i*s <N:
        ans += s
    else:
        ans += s-1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

for i in range(1,N):
    ans += int((N-1)/i)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

total = 0
for i in range(n-1):
  total += n // (i+1)
  if n % (i+1) == 0 :
    total -= 1

print(total)

Submission status: Accepted

Solution code:
import math

def main():
    N=int(input())

    n_list=[0 for i in range(N)]

    for i in range(1,N):
        counter=1
        while counter*i<=N-1:
            n_list[counter*i]+=1
            counter+=1
    res=sum(n_list)
    print(res)
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
S=N-1
ret=0
for i in range(1,N+1):
  ret+=S//i
print(ret)

Submission status: Accepted

Solution code:
N = int(input())
c = 0

for A in range(1, N + 1):
    for B in range(1, N + 1):
        if A * B >= N:
            break
        else:
            c += 1
print(c)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for A in range(1, N):
  ans += (N + A - 1) // A - 1
print(ans)

Submission status: Accepted

Solution code:
import math
n=int(input())
ans=0
for i in range(1,n):
    temp=(n-1)//i
    ans+=temp
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    N = ii()
    ans = 0
    for a in range(1, N):
        if a*a + 1 <= N:
            ans += 1
        maxb = (N-1)//a
        if a < maxb:
            ans += (maxb - a)*2
    print(ans)










main()

Submission status: Accepted

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

n = int(input())

cnt = 0
for i in range(n):
    a = i+1
    cnt += n//a
    if n%a == 0:
        cnt -= 1

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
s=0
for c in range(1,n):
    s+=(n-1)//c
print(s)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
    ans += (n-1)// i
print(ans)

Submission status: Accepted

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

N = INT()

# a = N % A
# b = N % B
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
ans = 0

memo = [0] * N
A = N - 1
ans = 0
for i in range(1, N):
    ans += A // i
print(ans)
    # memo[i]



# for c in range(1, N):
#     # c = 0 ~ N - 1
#     s = N - c
#     d = divisor(s)
#     print(d)
#     ans += len(d)
# print(ans)

Submission status: Accepted

Solution code:
def main():
  n=int(input())
  r=0
  for i in range(1,n):
    for j in range(1,n):
      if i*j<n:
        r+=1
      else:
        break
  print(r)
main()

Submission status: Accepted

Solution code:
n=int(input())
ans=0
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
table=num_divisors_table(n)
for i in range(1,n):
    ans+=table[n-i]
print(ans)

Submission status: Accepted

Solution code:

n = int(input())

nsq = int( n ** (1/2) )
ans = 0
for i in range(1,nsq+1):
  res = (n-1) // i
  
  if res >= nsq:
    ans += 2*(res-i) + 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ans=0
for a in range(1,int(N**0.5)+1):
    for b in range(a,(N//a+1)):
        if a*b < N and a==b:
            ans+=1
        elif a*b < N and a!=b:
            ans+=2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

divisors = []
ans = 0
# # cは正の整数である
# for i in range(1, N+1):
#     for j in range(1, N+1):
#         for c in range(1, N+1):
#             if i*j+c == N:
#                 print(i, j, c)
#                 ans += 1

for i in range(1, N):  # 1~N-1まで見る
    divisors.append([i, N//i])

for a, b in divisors:
    if a*b == N:
        ans += b-1
    else:
        ans += b
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for a in range(1, N):
    ans += (N - 1) // a

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

c = 0

for i in range(1, n):
  c += (n - 1) // i

print(c)

Submission status: Accepted

Solution code:
def main():
	N = int(input())

	c = 0
	for A in range(1, N):
		c += int((N - 1) / A)
	print(c)

main()

Submission status: Accepted

Solution code:
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time


def get_int(): return int(stdin.readline().strip())


def get_tuple(): return map(int, stdin.readline().split())


def get_list(): return list(map(int, stdin.readline().split()))

n = get_int()
ans = n-1
for i in range(2,n):
    temp = n//i
    if temp*i==n: temp -= 1
    ans += temp
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    ans = 0
    for a in range(1, n):
        for b in range(1, n):
            if n - a * b > 0:
                ans += 1
            else:
                break
    print(ans)

resolve()

Submission status: Accepted

Solution code:
N = int(input())

dl = [0] * (N)

for i in range(1, N):
    for j in range(i, N, i):
        dl[j] += 1

ans = sum(dl)
print(ans)

Submission status: Accepted

Solution code:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
def era_primes(n):
    is_prime = [-1] * (n + 1)
    is_prime[1]=1
    for i in range(2, int(n**0.5) + 1):
        if is_prime[i]!=-1:
            continue
        for j in range(i * 2, n + 1, i):
            if is_prime[j]==-1:
                is_prime[j] = i
    for i in range(n):
        if is_prime[i+1]==-1:
            is_prime[i+1]=i+1
    return is_prime

def factorize(N,prime_list):  # prime_listに素数のリストをぶち込め！
    lst = []
    # N==1のときも
    # if N==1:
    #     lst.append(1)
    while prime_list[N]!=1:
        lst.append(prime_list[N])
        N//=prime_list[N]
    return lst

lst=era_primes(10**6+10)

ans=0
for i in range(n-1):
    c=i+1
    ab=factorize(n-c,lst)
    dic={}
    tmp=1
    for i in ab:
        if i in dic:
            dic[i]+=1
        else:
            dic[i]=1
    for j in dic.values():
        tmp*=j+1
    # print(tmp)
    ans+=tmp
    # print(ab)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

count=0
for i in range(1,x):
    count+=x//i
    if x%i==0:
        count-=1
print(count)

Submission status: Accepted

Solution code:
num = input()
num = int(num)
count = 0
for n in range(1,num):
    m = (num-1) // n
    count += m

print(count)

Submission status: Accepted

Solution code:
#http://sucrose.hatenablog.com/entry/2016/11/06/234635
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

def main():
    n = int(input())

    divtable = num_divisors_table(n)
    
    ans = 0
    for c in range(1,n):
        t = divtable[n-c]
        ans += t

    print(ans)
    
        

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
cnt=0
for i in range(1, N):
    cnt += (N-1)//i
print(cnt)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N = int(input())
ans = 0

for i in range(1, N):
    ans += math.floor((N-1)/i)

ans = ans
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1, n):
    c1 = n // i
    c2 = n % i

    if c2 == 0:
        ans += c1 - 1
    else:
        ans += c1
print(ans)