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:
counter = 0

N = int(input())
counter += (N-2)*2+1
limit = 0
for i in range(1000):
    if (i+1)**2 >=1000000:
        limit = i

if N >= 100:
    if N%2 == 0:
        counter += (N//2-3)*2+1
    else:
        counter += (N//2-2)*2+1

    for i in range(limit):
        for j in range(N//3):
            if (i+3) * (i+3+j) < N:
                if j == 0:
                    counter += 1
                else:
                    counter += 2
            else:
                break
else:
    for i in range(limit):
        for j in range(N // 2):
            if (i + 2) * (i + 2 + j) < N:
                if j == 0:
                    counter += 1
                else:
                    counter += 2
            else:
                break
print(counter)

Submission status: Accepted

Solution code:
import math as mt
from collections import defaultdict
  
MAXN = 10**6
  
spf = [0 for i in range(MAXN)] 
  
def sieve(): 
    spf[1] = 1
    for i in range(2, MAXN): 
        spf[i] = i 
    for i in range(4, MAXN, 2): 
        spf[i] = 2
  
    for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
        if (spf[i] == i): 
            for j in range(i * i, MAXN, i):  
                if (spf[j] == j): 
                    spf[j] = i 
  
# A O(log n) function returning prime  
# factorization by dividing by smallest  
# prime factor at every step 
def getFactorization(x): 
    d = defaultdict(int)
    while (x != 1): 
        #ret.append(spf[x])
        d[spf[x]] += 1 
        x = x // spf[x] 
    #return Counter(ret)
    ans = 1
    for i in d:
        ans *= (d[i]+1)
    return ans
sieve()

n = int(input())
ans = 0
for i in range(1, n):
    ans += getFactorization(i)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s=(n-1)
if n==2:
    print(1)
else:
    ab = n//2 if n%2==0 else n//2 + 1
    for x in range(2,ab):
        if n%x==0:
            s+=(n//x - 1)
        else:
            s+=(n//x)
    print(s + n//2)

Submission status: Accepted

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

for i in range(int(N ** 0.5)):
    a = int((N-1)/(i+1))
    pl = 2*(a-(i+1))+1 
    if pl >= 0:
      res += pl

print(res)

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input(''))
a=1
k=0
F=int(N**(1/2))

while a<N:
  if N%a>0:
    b=N//a
    k=k+b
    b=0
  else:
    b=N//a
    k=k+b-1
    b=0
  a=a+1

print(k)

Submission status: Accepted

Solution code:
a=int(input())
i=1
n=0
while i<a:
    n=n+int((a-1)/i)
    i=i+1

print(n)

Submission status: Accepted

Solution code:
import math

N = int(input())

ans = 0

for a in range(1, N):
    cnt = 0
    for b in range(a, N):
        if a * b < N:
            if a < b:
                cnt += 2
            elif a == b:
                cnt += 1
        else:
            break
    ans += cnt

print (ans)

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())
def num_divisor(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_divisor(n-1)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
n = int(input())
count = 0
for i in range(1, n):
    if (math.floor(n/i) == n/i):
        res = n/i - 1
        if(i == res):
            count += 1
        if(res<= i):
            print(int(count))
            exit()
    else:
        res = math.floor(n/i)
        if(i == res):
            count += 1
        if(res<= i):
            print(int(count))
            exit()
    count = count + (res-i+1)*2 - 1
print(int(count))

Submission status: Accepted

Solution code:
n= int(input())
ans=0
nn = int((n-1)//2)+1
for i in range(2,nn):
    for j in range(i,nn):
        if i*j>n-1:
            break
        else:
            if i==j:
                ans += 1
            else:
                ans+=2
# a or b =1
ans += (n-1-1)*2
print(ans+1)

Submission status: Accepted

Solution code:
n = int(input())


def getNumsOfDivisorsOfEachNumbers(n: int):
    # validation check
    if not isinstance(n, int):
        raise("[ERROR] parameter must be integer")
    if n < 0:
        raise("[ERROR] parameter must be not less than 0 (n >= 0)")
    nums = [0] * (n + 1)  # 0-indexed
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            nums[j] += 1
    nums.pop(0)
    return nums


l = getNumsOfDivisorsOfEachNumbers(n)

res = 0
for c in l:
    res += c

res -= l[n - 1]

print(res)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

cnt = 0
for i in range(1,N):
    if N%i == 0:
        cnt += N//i - 1
    else:
        cnt += N//i
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:
N=int(input())
ans=0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, N+1):
    add = 0
    add = N//i if N%i!=0 else N//i-1
    count += add

print(count)

Submission status: Accepted

Solution code:





MAX = 1000001;


factor = [0] * (MAX + 1)

def generatePrimeFactors():
    factor[1] = 1


    for i in range(2, MAX):
        factor[i] = i;


    for i in range(4, MAX, 2):
        factor[i] = 2;


    i = 3
    while (i * i < MAX):

        if (factor[i] == i):

            j = i * i
            while (j < MAX):

                if (factor[j] == j):
                    factor[j] = i
                j += i
        i += 1

def calculateNoOFactors(n):
    if (n == 1):
        return 1;
    ans = 1;

    # stores the smallest
    # prime number that
    # divides n
    dup = factor[n];

    # stores the count of
    # number of times a
    # prime number divides n.
    c = 1;

    # reduces to the next
    # number after prime
    # factorization of n
    j = int(n / factor[n]);

    # false when prime
    # factorization is done
    while (j > 1):
        # if the same prime
        # number is dividing
        # n, then we increase
        # the count
        if (factor[j] == dup):
            c += 1;

        # if its a new prime factor
        # that is factorizing n,
        # then we again set c=1 and
        # change dup to the new prime
        # factor, and apply the formula
        # explained above.
        else:
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;

        # prime factorizes
        # a number
        j = int(j / factor[j]);

    # for the last
    # prime factor
    ans = ans * (c + 1);

    return ans;


# Driver Code
n=int(input())
generatePrimeFactors()
a=0
for i in range(1,n):
        a+=calculateNoOFactors(n-i)
print(a)

Submission status: Accepted

Solution code:
n = int(input())
table = [0] * (n + 1)
ans = 0

for i in range(1, n):
    for j in range(i, n, i):
        table[j] += 1
print(sum(table))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N = int(input()) - 1
rNf = math.floor(N**0.5)
ans = 0
for i in range(1, rNf + 1):
  ans += math.floor(N/i)
ans *= 2
ans -= rNf**2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(1,n):
    if n%i == 0:
        tmp = int(n/i)-1
    else:
        tmp = int(n/i)

    ans += tmp

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

if n % 2 != 0:
    for x in range(1, n//2+1):
        if n % x == 0:
            cnt += n // x -1
        else:
            cnt += n // x 

else:
    for x in range(1,n//2):
        if n % x == 0:
            cnt += n // x -1
        else:
            cnt += n // x 

cnt += n // 2
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

x = 0
A = 1

while A < N:
    y = N // A
    if N % A == 0:
        x -= 1
    x += y
    A += 1
    
print(x)

Submission status: Accepted

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

res=0

for i in range(1,ceil(n/2)):
    for j in range(i+1,n):
        if i*j < n:
            res+=1
        else:
            break

if int(n**0.5) == n**0.5:
    print(res*2 + int(n**0.5) - 1)
else:
    print(res*2 + int(n**0.5))

Submission status: Accepted

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

for a in range(1,n):
  for b in range(1,n-a+1):
    if a*b < n:
      ans+=1
    else:
      break
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:
# author:  Taichicchi
# created: 19.09.2020 21:48:28

import sys
N = int(input())

cnt = 0

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

print(cnt)

Submission status: Accepted

Solution code:
import math
n=int(input())
c=1+(n-1-1)*2


for i in range(2,n):
    for j in range(2,n):
        if i*j>=n:
            break
        c+=1

print(c)

Submission status: Accepted

Solution code:
import math

N = int(input())
cnt = 0
maxI = int(math.floor(math.sqrt(N)))

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

cnt *= 2

if N == maxI * maxI:
  cnt += maxI + 1
else:
  cnt += maxI

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def getNumsOfDivisorsOfEachNumbers(n: int):
    c = 0
    # validation check
    if not isinstance(n, int):
        raise("[ERROR] parameter must be integer")
    if n < 0:
        raise("[ERROR] parameter must be not less than 0 (n >= 0)")
    nums = [0] * (n + 1) # 0-indexed
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            nums[j] += 1
    nums.pop(0)
    for i in range(len(nums)):
        c+=nums[i]
    return c




#N = map(int,input().split())
#AB=[]
N = int(input())
#C = input()
#D, T, S=map(int,input().split())



if N == 1:
    print("0")
    exit(0)
elif N == 2:
    print("1")
    exit(0)
c = 0



print(getNumsOfDivisorsOfEachNumbers(N-1))

'''
for i in range(1,N):
    for j in range(1, i + 1):
        if j*j > i:
            break
        if i%j == 0:
            if j*j == i:
                c += 1
            else:
                c += 2
print(c)

'''

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N = int(input())
sqrt = math.ceil(math.sqrt(N))
#print(sqrt)
ans = N - 1
for a in range(2, N):
    ans += (N-1)//a
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

total = 0


for i in range(1, N + 1):
    a = N // i
    if N <= a * i:
        a -= 1 
    total += a

print(total)

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisect_left


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

def bindex(a,x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return i
    return None

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N = intinput()

    # ans1 = [-1] * 21
    # for N in range(2,21):
    #     cnt = 0
    #     for i in range(1,N):
    #         for j in range(1,N):
    #             for k in range(1,N):
    #                 if i*j+k == N:
    #                     cnt += 1
    #     ans1[N] = cnt
# 
    # ans2 = [-1] * 21
    # for N in range(2,21):
    #     n = int(sqrt(N))
    #     cnt = 0
    #     for i in range(1,n+1):
    #         a = ceil((N-i*i)/i)
    #         b = a-1 if a-1 >= 0 else 0
    #         cnt += a+b
    #     ans2[N] = cnt
    # for N in range(2,21):
    #     print(N, ans1[N] == ans2[N], ans1[N], ans2[N])

    n = int(sqrt(N))
    cnt = 0
    for i in range(1,n+1):
        a = ceil((N-i*i)/i)
        b = a-1 if a-1 >= 0 else 0
        cnt += a+b
    print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

ct = 0
for i in range(1, N):
    if i * i >= N:
        break
    x = int((N - 1)/i)
    ct += (x - i)*2 + 1
print(ct)

Submission status: Accepted

Solution code:
n=int(input())

m=int((n-1)**(1/2))

cnt=0
for i in range(1,m+1):
    cnt+=((n-1)//i-i)*2+1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

memo = dict()
def prime_factorize(n):
    a = []
    original_n = n
    while n % 2 == 0:
        a.append(2)
        n //= 2
        if n in memo:
            n_ = a + memo[n]
            memo[original_n] = n_
            return n_
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
            if n in memo:
                n_ = a + memo[n]
                memo[original_n] = n_
                return n_
        else:
            f += 2
    if n != 1:
        a.append(n)
    memo.update({original_n: a})
    return a

answer = 0
memo = dict()

import collections
for i in range(n-1):
    num = i+1
    if num == 1:
        answer += 1
        continue

    primes = prime_factorize(num)
    col = collections.Counter(primes)
    temp = 1
    for k, v in col.items():
        temp *= (v+1)

    answer += temp

print(answer)

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline().strip())

eroot_n = int(pow(n, 0.5))
res = 0
for num_a in range(1, eroot_n + 1):
    limit_b = int(n / num_a) + 1
    for num_b in range(num_a, limit_b):
        """
        print(num_a)
        print(num_b)
        print('\n')
        """
        if num_a * num_b >= n:
            continue
        if num_a == num_b:
            res = res + 1
        else:
            res = res + 2
print(res)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

for a in range(1, n):
    counter += (n + a - 1) // a - 1

print(counter)

Submission status: Accepted

Solution code:
N = int(input())

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

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

output = 0
divisor = num_divisors_table(n-1)

output = sum(divisor)

print(output)

Submission status: Accepted

Solution code:
import sys, os.path
import math
from collections import Counter
if(os.path.exists('input.txt')):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")



MAX = 1000001

factor = [0]*(MAX + 1)

def generatePrimeFactors():
    factor[1] = 1
    for i in range(2,MAX):
        factor[i] = i
    for i in range(4,MAX,2):
        factor[i] = 2
    i = 3
    while(i * i < MAX):
        if (factor[i] == i):
            j = i * i
            while(j < MAX):
                if (factor[j] == j):
                    factor[j] = i
                j += i
        i+=1


def calculateNoOFactors(n):
    if (n == 1):
        return 1
    ans = 1
    dup = factor[n]
    c = 1
    j = int(n / factor[n])
    while (j > 1):
        if (factor[j] == dup):
            c += 1
        else:
            dup = factor[j]
            ans = ans * (c + 1)
            c = 1
        j = int(j / factor[j])
    ans = ans * (c + 1)

    return ans
generatePrimeFactors()

n = int(input())
temp = n
c = 1
count = 0
while(temp-c > 0):
    w = temp-c
    count += calculateNoOFactors(w)
    c += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

Sum = 0
preSum = 0

a = N -1
b = 1

while True:
  c = a // b
  
  #print([a,b,c])
  
  if c < b:
    Sum = preSum * 2 + b - 1
    break
  elif c == b:
    Sum = preSum * 2 + 1 + b - 1
    break
  else:
    preSum += c - 1 - b + 1
    b += 1
  
  #print(preSum)

print(Sum)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
n = int(input())

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

print(count)

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    n = int(input())
    prime = [2, ]
    X = [i for i in range(0, n + 1)]
    for i in range(3, n + 1):
        x = i ** 0.5
        for p in prime:
            if p > x:
                prime.append(i)
                break
            if i % p == 0:
                X[i] = p
                break
        else:
            prime.append(i)

    def cnt(n):
        L = list()
        while n != 1:
            L.append(X[n])
            n //= X[n]
        C = Counter(L)
        ans = 1
        for c in C.values():
            ans *= c + 1
        return ans
    print(sum(cnt(i) for i in range(1, n)))



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = 0
b = 0
c = 0
while a < n:
    a+=1
    if a == n:
        break
    if n%a == 0:
        c+= n//a - 1
    else:
        c+= n//a
print(c)

Submission status: Accepted

Solution code:
import math
a=int(input())
n=0
for i in range(1,a):
    n+=math.floor((a-1)/i)

print(n)

Submission status: Accepted

Solution code:
from sys import stdin
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
ans = 0
n = int(stdin.readline().rstrip())
for c  in range(1,n):
    cnt = 1
    n2 = n - c#ここからユークリッド,a * b = n2→これやめた、素因数分解する
    #約数の個数がわかればよい
    data = collections.Counter(prime_factorize(n2))
    tmp = list(data.values())
    for x in range(len(tmp)):
        cnt *= tmp[x] + 1
    ans += cnt
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n = int(input())

ans = 0

for a in range(n):
    ans += math.floor(n/(a+1)-1)
    if n % (a+1) != 0:
        ans +=1

print(ans)

Submission status: Accepted

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

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:
#!python3.8
# -*- coding: utf-8 -*-
# abc179/abc179_c
import sys
from math import ceil

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

m = 10**6 + 1000
div = [0, 1] + [2] * m
for i in range(2, len(div)):
    for j in range(2 * i, len(div), i):
        div[j] += 1

def main():
    N = i2n()
    ans = 0
    for n in range(1, N):
        ans += div[n]
    print(ans)
    return

main()

Submission status: Accepted

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

for a in range(1, n + 1):
    if n % a == 0:
        ans += n // a - 1
    else:
        ans += n // a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
if N == 2:
    print(1)
    import sys
    sys.exit()
if N == 3:
    print(3)
    import sys
    sys.exit()


s = 0
m = N//2 if N%2 == 0 else N//2 + 1
for n in range(1, m):
    s += (N//n if N%n != 0 else N//n - 1)

print(s+N//2)

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 

  
N = int(input())

d =[0] * (N+1)
for i in range(1,N+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
sum = 0
for i in range(1,N):
  sum += d[N-i]
  
print(sum)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

for a in range(1, n):
  for b in range(n//a):
    num += 1
  if n % a == 0:
    num -= 1

print(num)

Submission status: Accepted

Solution code:
"""O(N^0.5) solution"""

N = int(input())
N -= 1

ans = 0
n = int(N**.5)
for x in range(1, n+1):
  # (x,x)
  ans += 1
  # (x,y)
  ans += N//x - x
  # (y,x)
  ans += N//x - x

print(ans)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
import math

n = int(input())
mod = 0
if (n-1)%2 != 0:
    mod = 1

b = math.ceil((n-1)**0.5)
cnt = 0

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

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:
import math
n=int(input())
cnt=0
temp=math.ceil(math.sqrt(n))
for i in range(1, temp+1):
  for j in range(1, temp+1):
    if i!=j and i*j<n:
      cnt+=1
    elif i==j and i*j<n:
      cnt+=1
for k in range(temp+1, n):
  for l in range(1, temp+1):
    if k*l<n:
      cnt+=2
    else:
      break;
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

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

n=I()
dp=[0]*(n+1)
dp[2]=1
for i in range(3,n+1):
    c=collections.Counter(prime_factorize(i-1))
    divnum=list(c.values())
    tmp=1
    for j in divnum:tmp*=j+1
    dp[i]=dp[i-1]+tmp
print(dp[n])

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:
import sys
import re
import queue
import collections
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 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N = i_input()
	sum = 0
	for i in range(1,N):
		sum += (N-1) // i

	print(sum)

	return

if __name__ == '__main__':
	main()