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:
import math


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

    count = 0
    sqr = int(math.sqrt(N-1))
    for a in range(1, sqr+1):
        count += (len([m+1 for m in range((N-1)//a) if m+1 >= a]) - 1) * 2 + 1
    print(count)

main()

Submission status: Accepted

Solution code:
import math
n = int(input())
m = int(math.sqrt(n))
if n == m ** 2:
    m -= 1

ans = 0
for i in range(1, m + 1):
    t = int((n - 1) / i)
    ans += (t- i + 1) * 2
    if n != i ** 2:
        ans -= 1 
print(ans)

Submission status: Accepted

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

arr = set()
for a in range(1, int(math.sqrt(N))+1):
    for b in range(a, N+1):
        if N-(a*b) <= 0:
            break
        ans += 2
        if a == b:
            ans -= 1
print(ans)

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:
N = int(input())
sum = 0


for A in range(1,N):
  if N // A > 1:
    if  N % A == 0:
      sum += N//A -1
    else:
      sum += N // A
  else:
    sum += 1

print(sum)

Submission status: Accepted

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

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:
import numpy as np
from numba import njit
u4 = np.uint32

@njit
def get_factorization(n):
    sieve_size = (n - 1) // 2
    sieve = np.ones(sieve_size, u4)
    for i in range(sieve_size):
        if sieve[i] == 1:
            value_at_i = i*2 + 3
            for j in range(i, sieve_size, value_at_i):
                value_at_j = j * 2 + 3
                p = 1
                while value_at_j % value_at_i == 0:
                    value_at_j //= value_at_i
                    p += 1
                sieve[j] *= p
    return sieve


@njit('(u4,)', cache=True)
def solve(N):
    sieve = get_factorization(N)
    ans = 0
    for j in range(1, N):
        a = j
        p2 = 1
        while a % 2 == 0:
            p2 += 1
            a //= 2
        if a > 1:
            s_a = (a - 3) // 2
            ans += p2 * sieve[s_a]
        else:
            ans += p2
    return ans


def main():
    N = int(input())
    ans = solve(N)
    print(ans)

main()

Submission status: Accepted

Solution code:
if __name__=="__main__":
  N = int(input())
  ans = 0
  for a in range(1, N):
    num = (N-1)//a
    ans += num
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
def pf(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
n=int(input())
r=0
for c in range(1,n):
  ab=collections.Counter(pf(n-c))
  ab_l=list(ab.values())
  x=1
  for i in ab_l:
    x*=i+1
  r+=x
print(r)

Submission status: Accepted

Solution code:
n=int(input())

count=0
for a in range(1,n+1):
    for b in range(a,n//a+1):
        c=n-(a*b)
        if c>0:
            if a==b:
                count+=1
            else:
                count+=2
        else:
            continue

print(count)

Submission status: Accepted

Solution code:
import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict,deque
import math
def main():
    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)

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

n=int(input())
ans=0
for i in range(1,n):
	temp=(n-1)//i
	if temp>0:
		ans+=temp
	else:
		break
print(ans)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

d =[0] * (10**6+1)
for i in range(1,10**6+1):
  div = collections.Counter(prime_factorize(i))
  index = list(div.values())
  s = 1
  for j in range(len(index)):
    s *= (index[j]+1)
  d[i] = s
  

N = int(input())
sum = 0
for i in range(1,N):
  sum += d[N-i]
  
print(sum)

Submission status: Accepted

Solution code:
n=int(input());count=0
for i in range(1,n):
  count+=[n//i,n//i-1][n%i==0]
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(counter)

Submission status: Accepted

Solution code:
n = int(input())

count = 0
count2 = 0

for a in range(2, n + 1):
    if n > a ** 2:
        count += 1
        if n % a == 0:
            count += 2 * ((n // a) - a - 1)
        else:
            count += 2 * (n // a - a)
    else:
        break
print(count+1+2*(n-2))

Submission status: Accepted

Solution code:
from sys import stdin, stdout
import math
inp = lambda : stdin.readline().strip()
   
n = int(inp())
ans = 0
for i in range(1, n):
    l = 1
    r = n
    while l < r:
        m = (l+r)//2
        if m*i >= n:
            r = m
        else:
            l = m+1
    ans += l-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
n=int(N**0.5)
cnt=0
for i in range(1,n+1):
    a=N//i
    if a-i-1>0:
        cnt+=(a-i-1)*2
    if i**2!=N:
        cnt+=1
    if a*i!=N and a!=i:
        cnt+=2
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def solve():
    n = int(input())
    ct = 0
    for a in range(1, n):
        ct += math.ceil(n/a - 1)
    return ct

print(solve())

Submission status: Accepted

Solution code:
N = int(input())
#それぞれの要素番号に対応する約数の表を作成
yakusuu_table = [0] * N
#今回調べるのは入力された値から-1
for i in range(1, N):
#iの倍数を調べる→iとばし
    for j in range(i,N,i):
        yakusuu_table[j] += 1
print(sum(yakusuu_table))

Submission status: Accepted

Solution code:
n = int(input())

count = 0

for a in range(1, int(n/2) + 1):
	count += (n-1) // a

count += n - 1 - int(n/2)

print(count)

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
from math import floor
a=floor(N**(1/2))
i=1
summ=0
for i in range(1,a+1):
    if N%i==0:
        b=N//i
        if b>i:
            summ=summ+(b-i)*2-1
    else:
        b=N//i
        summ=summ+(b-i+1)*2-1
    i+=1
print(summ)

Submission status: Accepted

Solution code:
from math import floor
n = int(input())
qnt = 0
for x in range(1, n):
	y = n / x
	y = int(y)-1 if y%1 == 0 else int(floor(y))
	qnt += y
print(qnt)

Submission status: Accepted

Solution code:
N = int(input())
under_prod = N-1
A=1
even = 0
count = 0

for i in range(under_prod):
  B=under_prod//A
  count+=B
  A+=1


print(count)

Submission status: Accepted

Solution code:
import itertools
import collections


def prime_factor_table(n):
    table = [0] * (n + 1)

    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i

    return table


def prime_factor(n, prime_factor_table):
    prime_count = collections.Counter()

    while prime_factor_table[n] != 0:
        prime_count[prime_factor_table[n]] += 1
        n //= prime_factor_table[n]
    prime_count[n] += 1

    return prime_count


def solve(N):
    ans = 1

    table = prime_factor_table(1000000)

    for i in range(2, N):
        tmp = prime_factor(i, table)
        tt = 1
        for t in tmp:
            tt *= (tmp[t]+1)
        ans += tt
    return ans


if __name__ == "__main__":
    N = int(input())
    print(solve(N))

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())

is_prime = [1] * (10**6+1)

for a in range(2,10**6+1):
        for v in range(a,10**6+1,a):
            is_prime[v] += 1
# print(is_prime[:10])

n = I()
ans = 0
for c in range(1,n):
    nc = n-c
    ans += is_prime[nc]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

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

Submission status: Accepted

Solution code:
import math

N = int(input()) - 1

B = [2 for i in range(N)]

for i in range(2, math.ceil(math.sqrt(N))+1):
  for j in range(2*i, N+1, i):
    B[j-1] += 1

    if math.ceil(math.sqrt(N)) < j//i:
      B[j-1] += 1

print(sum(B)-1)

Submission status: Accepted

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前
sort()
sorted(reverse=true)
配列の初期化
配列名=[a]*n+[b]*m
Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys


num = int(stdin.readline().rstrip())
res = 0
for el in range(1, num):
    tes = num % el
    tmp = int(num/el)
    if tes == 0:
        tmp -= 1
    res += tmp
print(res)

Submission status: Accepted

Solution code:
N = int(input(""))
A = 1
B = 1
count = 0
while A * B < N:
    while A * B < N:
        count += 1
        B += 1
    B = 1
    A += 1
    count += 1

print(count - N + 1)

Submission status: Accepted

Solution code:
import math

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import collections 
#=input()
n=int(input())
#=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
cnt = 0
hey = 0
for a in range(1, n):
    for b in range(a, n):
        if a * b >= n:
            break
        if a != b:
            cnt += 1
        else:
            hey += 1
print(cnt * 2 + hey)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

# 約数の個数のテーブルを O(N loglog N) で作る
div = [1] * (N+1)
div[0] = 0

for p in range(2, N+1):
  if div[p] != 1:
    continue
  # p は素数
  pp = p  # power of p
  e = 1
  while pp <= N:
    for n in range(pp, N+1, pp):
      div[n] += div[n] // e
    e += 1
    pp *= p  

ans = sum(div[:N])
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import math
inp = lambda : stdin.readline().strip()

n = int(inp())
ans = 0
for i in range(1,n):
    l = 0
    h = n + 1
    while l < h:
        m = (h+l)//2
        if i * m >= n:
            h = m
        else:
            l = m + 1
    ans += (l-1)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
i = 1
s = 0
while i < N:
    s += (N - 1) // i
    i += 1
print(s)

Submission status: Accepted

Solution code:
N = 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

table = num_divisors_table(N)

ans = 0
for C in range(1, N):
    ans += table[N-C]
print(ans)

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    count = 0
    for i in range(1, N):
        for j in range(1, N // i + 1):
            k = N - i*j
            if k > 0:
                count += 1
    print(count)

if __name__ == '__main__':
    main()

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 math
N = int(input())
n = N-1
rn = int(math.floor(math.sqrt(n)))
c = 0
for i in range(n):
  c += (n//(i+1)*2)
print(int(c/2))

Submission status: Accepted

Solution code:
def divisorcount(N):#1~Nまでの数の約数の個数
    ans = 0
    divisor = [0]*N
    for i in range(1,N+1):
        ans += (n-1)//i
    return ans

import math
n = int(input())
bf = [0]*int(10**6+1)

N = n - 1

print(divisorcount(N))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
m = [1]*n
m[0] = 0
ans = 0
for i in range(2,n):
    tmp = i
    for j in range(i,n,i):
        m[j]+=1

for i in range(n):
    if m[i]%2==1:
        ans += 2*(m[i]//2)+1
    else:
        ans += m[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1<<32 else [2, 3, 5, 7, 11, 13, 17] if n < 1<<48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = y * y % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret
def sqrt(n):
    x = 1 << (n.bit_length() + 1) // 2
    y = (x + n // x) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x
def calc(k):
    return (sqrt(8*k+1) - 1) // 2

N  = int(input())
cnt = 0
for i in range(1, N):
    tmp = 1
    pf = primeFactor(i)
    for v in pf.values():
        tmp *= v + 1
    cnt += tmp
print(cnt)

Submission status: Accepted

Solution code:
import math
N = int(input())
ans = 0
A = [0] * (N + 1)
for i in range(2, N):
  ans += (N-1) // i - 1
ans += (N-2)*2 + 1
#a = math.floor(math.sqrt(N-1))
#ans -= a
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
a=1
count=0
while a<N:
  count=count+(N-1)//a
  a=a+1
else:
  print(count)

Submission status: Accepted

Solution code:
import math


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

N = int(input())


summ = 0

summ = sum(num_divisors_table(N-1))
print(summ)

Submission status: Accepted

Solution code:
# import math
# import sympy
# sympy.divisors(10**9)

n = int(input())

# count = 0
# for i in range(1, n):
#     count = count + math.ceil(len(sympy.divisors(i)))
#     # print(math.ceil(len(sympy.divisors(i))))
# print(count)

count = 0
for a in range(1, n - 1):
    if n % a != 0:
        b = n // a
    else:
        b = n // a - 1
    if a <= b:
        count = (count + b)
    else:
        count = (count + b)
    # print(count)

print(count + 1)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(1,n):
    for j in range(i, n):
        if n - i*j < 0:
            break

        if n - i*j > 0 and i == j:
            ans += 1
        elif n - i*j >0 and i != j:
            ans += 2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
count=0
for i in range(1,N+1):
    for j in range(1,N+1):
            
        if i*j >=N:
            count += j-1
            break
print(count)

Submission status: Accepted

Solution code:
import math
N = int(input())
cnt = 0
for a in range(1,N):
  for b in range(a,math.ceil(N/a)):
    c = N - a * b
    if c <= 0:
      break
    else:
      if a == b:
        cnt += 1
      else :
        cnt += 2
print(cnt)

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 math

N=int(input())

ans=0

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

print(ans)

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
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 main():
    n = i_input()
    ans = 0
    for i in range(1,n):
        ans += (n-1)//i
    print(ans)


if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
N=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
print(sum(num_divisors_table(N-1)))

Submission status: Accepted

Solution code:
n = int(input()) - 1

j = 0

ans = 0

for i in range(1, n):
    
    j = i
    
    while True:
        j += 1
        if i * j > n:
            break
        ans += 1


k = 1

er = 0

while True:
    er += 1
    if k ** 2 > n:
        break
    k += 1


print((ans * 2) + er - 1)

Submission status: Accepted

Solution code:
n = int(input())

# c = N - a*b
cnt = 0
for a in range(1, n, 1):
    for b in range(1, n, 1):
        if n <= a*b:
            break
        else:
            if a != b:
                cnt += 2
            else:
                cnt += 1
                break

print(cnt)

Submission status: Accepted

Solution code:
N=int(input())

# 約数の個数のテーブルを O(N logN) で作る
div = [0] * (N+1)
for d in range(1, N+1):
  for n in range(d, N, d):
    div[n] += 1

ans = sum(div[:N])
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math
def solve(N: int):
    count = 0
    for i in range(1, N):
        a = N//i
        if i* a < N:
            count += a
        else:
            count += a-1
    print(count)
    return
def main():
    solve(int(sys.stdin.readline().rstrip()))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

"""
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

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)
"""

n = k()

for i in range(1,n):
  for j in range(n//i,0,-1):
    if 1<=i*j<=n-1:
      cnt += 1
      continue

print(cnt)

Submission status: Accepted

Solution code:
from math import floor, ceil

def main():
    n = int(input())
    cnt = 0
    for a in range(1, n):
        cnt += floor((n-1)/a) - ceil(1/a) +1
    print(cnt)
    
    
if __name__ == "__main__":
    main()

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())
cnt = 0
for i in range(1, 10**6):
    for j in range(1, 10**6):
        if i * j >= n :
            break
        else :
            cnt += 1
print(cnt)

Submission status: Accepted

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

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    n = ii()
    ans = 0
    for a in range(1, n+1):
        q = (n - 1) // a
        # b は 1...q をとれる
        ans += q
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

ans = [0] * N

for A in range(1, N):
    ans[A] = (N - 1) // A

print(sum(ans))

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for a in range(1,int(n**(1/2)+1)):
  tmp = 0
  if (a**2) == n:
    break
  elif n%a == 0:
    tmp += ((n//a)-1-a)*2
    tmp += 1
  elif (a * (n//a)) < n:
    tmp += (n//a-a)*2
    tmp += 1
  #print(tmp)
  ans += tmp
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
x = 0
import math
maxA = int(math.sqrt(N))

for i in range(1,maxA + 1):
  A = i
  for j in range(i,int(N/i) + 1):
    B = j
    if A*B < N and A != B:
      x += 2
    elif A*B < N and A == B:
      x += 1
print(x)

Submission status: Accepted

Solution code:
import math

n = int(input())

ans = 0

for A in range(1, n):
  if n % A == 0:
    ans += n // A - 1
  else:
    ans += n // 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:
import math

n = int(input())
ans =0
for i in range(1,n+1):
    ans += math.ceil(n/i) -1
print(ans)

Submission status: Accepted

Solution code:
k=int(input())
n=k-1
val=n
if k==2:
    print(1)
else:
    for i in range(2,n):
        val+=n//i
    print(val+1)