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:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

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

# 多分全探索
# Cを全探索
N = getN()

# 素因数分解する

# A = iの時？
# N - cは1 ~ N - 1まで
# この中でA * Bはいくつある？

# Aが1の時

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

Submission status: Accepted

Solution code:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = 0
for a in range(1,n):
    x += (n-1)//a
print(x)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import accumulate


def read():
    N = int(input().strip())
    return N,


def solve(N):
    ans = 0
    for a in range(1, N):
        b, c = divmod(N, a)
        if c == 0:
            ans += (b-1)
        else:
            ans += b
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
mex = 10**6 +5
lp = [0 for i in range(mex)]
prime = []

def init():
    lp[1] = 1
    for i in range(2,mex):
        if lp[i]==0:
            lp[i] = i
            prime.append(i)
        j = 0
        while j<len(prime) and i*prime[j]<mex:
            lp[i*prime[j]] = prime[j]
            if(i%prime[j]==0):
                break
            j+=1
init()
cnt = 0
for i in range(1,n+1):
    temp = n-i
    me = 1
    freq = defaultdict(int)
    while temp>1:
        freq[lp[temp]]+=1
        temp = temp//lp[temp]
    for x in freq:
        me*=(freq[x]+1)
    cnt+=me
print(cnt-1)

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

ans = 0
for i in range(1, N):#A
  count = int(N // i)
  if count * i == N:
    count -= 1
  ans += count
  #print(ans)
    
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

N = int(input())

Nsq = math.floor(math.sqrt(N-1))

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

count = count * 2 - Nsq
print(count)

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())
num = 0
for i in range(1,n):#Aの数値
    num += ((n - 1) // i)
print(num)

Submission status: Accepted

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


        else:
            break
print(ans*2+an)

Submission status: Accepted

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

#l = list(map(int, input().split()))
#import numpy as np
#arr = np.array([int(i) for i in input().split()])
'''
a,b=[],[]
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
def premf(n):
    #前処理
    #minfactor:複数の素因数分解を高速(O(Q*logA_max))に行う,indexはその整数
    #return resで素数リスト(eratosthenes),MinFactorで前処理用リスト返す
    IsPrime=[False]+[False]+[True]*(n-1)
    MinFactor=[0]+[1]+[-1]*(n-1)

    res=[]
    
    for i in range(2,n+1):
        if IsPrime[i]:
            MinFactor[i]=i
    
            res.append(i)
    
            for j in range(i*2,n+1,i):
                IsPrime[j]=False
                if MinFactor[j]==-1: MinFactor[j]=i
                
    return MinFactor
def mf(n,MinFactor):
    #minfactor:nに対し[[素因数,個数],...]を返す
    res=[]
    while n!=1:
        prime=MinFactor[n]
        exp=0
        while MinFactor[n]==prime:
            exp+=1
            n//=prime
        res.append([prime,exp])
    return res


n=int(input())
mff=premf(n)

cnt=0
for i in range(1,n):#c=i
    r=mf(i,mff)
    #print(r)
    no=1
    for jtem in r:
        no*=(jtem[1]+1)
    #print(no)
    cnt+=no
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

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

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
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

inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
ans = 0
for i in range(1,int(math.sqrt(n))+1):
    ans+=max(((((n-1)//i-(i-1))-1)*2+1),0)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
t = [0] * (N + 10)
for i in range(1, N+1):
    for j in range(1, (N+1)//i+1):
        t[i*j] += 1

print(sum(t[:N]))

Submission status: Accepted

Solution code:
n=int(input())
f=0
for i in range(1,n+1):
    for j in range(1,n+1):
        e=n-(i*j)
        if(e<=0):
            break
        elif(e in range(1,n+1)):
            f=f+1
print(f)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

    ans=0

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

if __name__=="__main__":main()

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())

    ans = 0

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


if __name__ == "__main__":
    main()

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())
ans_list = []

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

Submission status: Accepted

Solution code:
n=int(input())
jud=0
a=1
ans=0
while jud!=1:
    x=n//a
    if x==1:
        jud=1
    else:
        ans+=x
        if n%a==0:
            ans-=1
        a+=1
ans+=n-a
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
#A==Bのとき
i = 1
while i ** 2 < n:
    ans += 1
    i += 1
#A!=Bのとき
i = 1
while i*(i+1) < n:
    j = i+1
    while i*j < n:
        ans += 2
        j += 1
    i += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools

N = int(input())

d = 0
for a in range(1, N):
    for b in range(1, N):
        ab = a * b
        if ab > N or N-ab==0:
            break
        for c in range(N-ab, N):
            if ab + c == N:
                d += 1
            if ab + c > N:
                break
print(d)

Submission status: Accepted

Solution code:
class PrimeFactor():

    def __init__(self, n):
        """
        エラトステネス　O(N loglog N)
        """
        self.n = n
        self.table = list(range(n+1))       # 最小素因数のリスト
        self.table[2::2] = [2]*(n//2)
        for p in range(3, int(n**0.5) + 2, 2):
            if self.table[p] == p:
                for q in range(p * p, n + 1, 2 * p):
                    if self.table[q] == q:
                        self.table[q] = p

    def is_prime(self, x):
        """ 素数判定　O(1) """
        if x < 2:
            return False
        return self.table[x] == x

    def prime_factors(self, x):
        """ 素因数分解 O(logN)  (試し割りだとO(sqrt(N))) """
        res = []
        if x < 2:
            return res
        while self.table[x] != 1:
            res.append(self.table[x])
            x //= self.table[x]
        return res

    def prime_counter(self, x):
        """
        素因数分解（個数のリスト） O(logN)
        {素因数: 個数}　の形で返す
        """
        res = dict()
        if x < 2:
            return res
        while self.table[x] != 1:
            res[self.table[x]] = res.get(self.table[x], 0) + 1
            x //= self.table[x]
        return res

    def divisors_counter(self, x):
        """ 約数の個数　O((logN)^2) """
        res = 1
        for value in self.prime_counter(x).values():
            res *= (value+1)
        return res

    def prime_gcd(self, X, mod=None):
        """ n個の最大公約数　X:n個のリスト  (O((logN)^2)) """
        exponents = self.prime_counter(X[0])
        for x in X[1:]:
            Y = self.prime_counter(x)
            for prime, exp in exponents.items():
                if Y[prime] < exp:
                    exponents[prime] = Y[prime]
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp, mod)
        if mod == None:
            return res
        else:
            return res % mod

    def prime_lcm(self, X, mod=None):
        """ n個の最小公倍数　X:n個のリスト  (O((logN)^2)) """
        exponents = dict()
        for x in X:
            for prime, exp in self.prime_counter(x).items():
                if exp > exponents.get(prime, 0):
                    exponents[prime] = exp
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp, mod)
        if mod == None:
            return res
        else:
            return res % mod

N = int(input())
P = PrimeFactor(N)
res = 0
for k in range(1,N):
    res += P.divisors_counter(k)
print(res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
table=[0]*(n)
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())
s = 0
for i in range(1, n):
	s += (n-1) // i
print(s)

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())
#for i in range(t):
  #n,m=map(int,input().split())
z=0
for i in range(1,n):
  z+=n//i
  if n%i==0:
    z-=1
print(z)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

count = 0
for i in range(1, n // 2 + 1):
    for j in range(i, n // i + 1):
        if i * j >= n:
            break
        if i != j:
            count += 1
        count += 1
print(count)

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:
n = int(input())
counted = 0

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

print(counted)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class Eratosthenes:
    def __init__(self, n):
        self.n = n
        self.min_factor = [-1] * (n + 1)
        self.min_factor[0], self.min_factor[1] = 0, 1

    def get_primes(self):
        primes = []
        is_prime = [True] * (self.n + 1)
        is_prime[0] = is_prime[1] = False
        for i in range(2, self.n + 1):
            if not is_prime[i]:
                continue
            primes.append(i)
            self.min_factor[i] = i
            for j in range(i * 2, self.n + 1, i):
                is_prime[j] = False
                if self.min_factor[j] == -1:
                    self.min_factor[j] = i
        return primes

    def prime_factorization(self, n):
        res = []
        while n != 1:
            prime = self.min_factor[n]
            exp = 0
            while self.min_factor[n] == prime:
                exp += 1
                n //= prime
            res.append([prime, exp])
        return res



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

    er = Eratosthenes(n + 1)
    er.get_primes()
    res = 0
    for c in range(1, n + 1):
        ab = n - c
        if n - c <= 0:
            continue
        prime = er.prime_factorization(ab)
        cnt = 1
        for _, ex in prime:
            cnt *= ex + 1
        res += cnt
    print(res)



if __name__ == '__main__':
    resolve()

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:
def eratosthenes(n):
    """エラトステネスの篩 O(NloglogN)

    Args:
        n (int): 上限値 (n > 1)
    
    Returns:
        list: 問題に応じた返り値
            - 素数判定:      is_prime
            - 素数列挙:      [i for i in range(n+1) if is_prime[i]]
            - 最小素因数列挙: min_factor
    """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    min_factor = [-1] * (n+1)
    min_factor[0] = 0
    min_factor[1] = 1

    for i in range(2, n+1):
        if is_prime[i]:
            min_factor[i] = i
            for j in range(i*2, n+1, i):
                is_prime[j] = False
                if min_factor[j] == -1:
                    min_factor[j] = i

    return min_factor


n = int(input())

l = eratosthenes(n)

res = 1
for i in range(2, n):
    d = dict()
    while i > 1:
        if l[i] not in d:
            d[l[i]] = 1
        else:
            d[l[i]] += 1
        i //= l[i]
    
    tmp = 1
    for v in d.values():
        tmp *= v + 1

    res += tmp

print(res)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter
def min_fac_array(n):
    nums = [i for i in range(n+1)]
    for i in range(2,n+1):
        if nums[i] == i:
            for j in range(2*i,n+1,i):
                if nums[j] == j:
                    nums[j] = i
    return nums

def fac_fast(mfa,a):
    n = a
    fac = []
    while n != 1:
        fac.append(mfa[n])
        n //=mfa[n]
    return fac

def main(): 
    n = int(input())
    mfa = min_fac_array(n)
    ans = 1
    for i in range(2,n):
        fac = fac_fast(mfa,i)
        dic = Counter(fac)
        temp = 1
        for p in dic.values():
            temp*=p+1
        ans+=temp
    
    print(ans)
main()

Submission status: Accepted

Solution code:
N = int(input())

N -= 1

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

print(a+1)

Submission status: Accepted

Solution code:
n = int(input())

n -= 1
ans = 0

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

Submission status: Accepted

Solution code:
import math

N = int(input())

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

Submission status: Accepted

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

def main():
    from math import sqrt
    input = sys.stdin.readline
    n = int(input())
    m = int(sqrt(n)) + 1

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



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

s = 0

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

print(s)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10

from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

n = inp()
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 a in range(1, n + 1):
    ans += (n - 1) // a
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)
    elif N % i != 0:
        count += N // i
        

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#def f(x):#a*b=xとなるabの組の個数 = xの約数の個数


for p in range(N-1):
    ans += (N-1)//(p+1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans = 0
n = int(input())
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())

  
div_num = [0 for _ in range(n+1)]
for i in range(1,n+1):
  for j in range(i,n+1,i):
    div_num[j] += 1

#print(div_num)
print(sum(div_num[1:n]))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    N=int(sys.stdin.readline())
    out=0
    for i in range(1,N):
        out+=(N-1)//i
    print(out)

main()

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for a in range(1, n + 1):
    q = n // a
    r = n % a

    # a <= b
    # b: a, a+1, ..., q
    # c: ...  ,r + a, r
    if q < a:
        continue
    
    else:
        # a < b, a == b
        ans += ((q - a) * 2 + 1)
        if r == 0:
            if a == q:
                ans -= 1
            else:
                ans -= 2
        # print(a, ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math, re
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    ans = 0
    for A in range(1, N):
        ans += N // A
        if N % A == 0:
            ans -= 1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

result = 0

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

Submission status: Accepted

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

# dp
# dp[i] = dp[i-1](C+=1したやつ）+ (i-1)の約数の数。

def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
  
primes = make_prime_list_2(1000)

def num_primes(n):
  wk = n
  res = 1
  for p in primes:
    if p*p > wk:
      break
    cnt = 0
    while wk % p == 0:
      wk = wk // p
      cnt += 1
    res = res * (cnt+1)
  if wk >= 2:
    res *= 2
  return res

dp = [0] * (N+1)
dp[1] = 0
dp[2] = 1

for i in range(2,N):
  dp[i+1] = dp[i] + num_primes(i)
  
print(dp[N])

Submission status: Accepted

Solution code:
N = int(input())

print(sum((N-1) // i for i in range(1, N)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter


n = int(input())

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

print((ans))

Submission status: Accepted

Solution code:
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

n=int(input())

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

print(cnt)

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:
      continue
    else:
      if a != b:
        count += 2
      else:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
    temp = n//i
    ans += temp
    if i*temp==n:
      ans -= 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())

ans = 0
for i in range(1, n):
    d, m = divmod(n, i)
    if m == 0:
        d -= 1
    ans += d
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    d = [0 for i in range(n+1)]
    for i in range(1,int(n**0.5)+1):
        for j in range(i,n//i+1):
            if j==i:
                d[i*j]+=1
            else:
                d[i*j]+=2
    ans = 0
    for i in range(n):
        ans += d[i]
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N):
    ret = N - 1
    for i in range(2, N + 1):
        ret += (N - 1) // i
    return ret


def main():
    # parse input
    N = int(input())
    print(solve(N))


# tests
T1 = """
3
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
3
"""

T2 = """
100
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
473
"""

T3 = """
1000000
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
13969985
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(x)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()

    ans = N-1

    for i in range(2, N):
        for j in range(1, N):
            if i*j > N-1:
                break
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

a = int(input())
cnt = 0

for i in range(1,a):
    if a%i == 0:
        cnt += (a//i)-1
    else:
        cnt += a//i
#    print(a//i,cnt)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for A in range(1, N):
    q, r = N // A, N % A
    if r == 0:
        ans += q - 1
    else:
        ans += q

print(ans)

Submission status: Accepted

Solution code:
n = int( input() )

s = 0
for k in range( 1, n ):
    s = s + ( ( n - 1 ) // k )

print( s )