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:
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

a = 1
ans = 0
while(n/a>1):
    ans+=ceil(n/a) - 1


    a+=1
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())

max_a = int(N ** 0.5)+2
cnt = 0
for a in range(1, max_a):
  for b in range(a, N+1):
    if a*b >= N:
      break
    elif a == b:
      cnt += 1
    else:
      cnt += 2
        

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

cnt=0
for a in range(1,int(n**0.5)+1):
    for b in range(a,n+1):
        if a*b<n:
            if a==b:
                cnt+=1
            else:
                cnt+=2
        else:
            break

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

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

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())
count=0
for A in range(1,N):
    count+=(N-1)//A
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    dp = [0]*(n+1)
    for i in range(1,n+1):
        j = 1
        while i*j <= n:
            dp[i*j] += 1
            j += 1

    #print(dp)
    pairs = 0
    for c in range(1,n):
        x = n-c
        count = dp[x]
        #print(c,x,count)
        pairs += count

    print(pairs)
    

main()

Submission status: Accepted

Solution code:
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque, defaultdict
from fractions import gcd
from functools import reduce
from itertools import groupby, combinations
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return list(map(lambda x: x + d, A))
def ldec(A, d=1): return list(map(lambda x: x - d, A))

N = n1()

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

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
def Sieve_of_Eratosthenes(maxA):
    lst = [-1]*(maxA+1)
    lst[0] = 0
    lst[1] = 1
    for i in range(2, maxA+1):
        if lst[i] == -1:
            for g in range(i, maxA+1, i):
                if lst[g] == -1:
                    lst[g] = i
    return lst

def factorization(n):  # 「n = 1」はダメ！！！
    d = defaultdict(int)
    now = n
    while True:
        if now == lst[now]:
            if now != 1:
                d[now] += 1
            break
        r = lst[now]
        while now % r == 0:
            now //= r
            d[r] += 1
    ans = 1
    for i, m in d.items():
        ans *= (m+1)
    return ans

n = int(input())

ans = 0
lst = Sieve_of_Eratosthenes(n+1)
for c in range(1, n):
    ans += factorization(n-c)

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()


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

Submission status: Accepted

Solution code:
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans = 0
"""
for c in range(1,N):
    ans += len(make_divisors(N-c))
print(ans)
"""

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

Submission status: Accepted

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

c = 0
for i in range(1,n):
    if n % i == 0:
        c += ((n / i) -1)
    else:
        c += math.floor(n / i)

print(int(c))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    ans=0
    for i in range(1,n+1):
        for j in range(1,n//i+1):
            if i*j<n:
                ans+=1
                #print(i,j)
    print(ans)

        
        
        
        



        
        
        
        
        
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
big = 10**6+1
ans = [0 for _ in range(big)]
for i in range(1,big):
  now = i
  while now < big:
    ans[now] += 1
    now += i
#print(ans)
print(sum(ans[:n]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 20:17:59 2020

@author: liang
"""
#C
N = int(input())

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())


cnt = 0
for a in range(1, n + 1):
    b = 1
    while a * b < n:
        cnt += 1
        b += 1

print(cnt)

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:
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
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())
ans = 0
for a in range(1, N):
    for b in range(1, N):
        seki = a * b
        if seki < N:
            ans += 1
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
MOD = 10**9 + 7
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic

def solve(N):
    # AB + C = N
    # C = 1.. N-1
    ds = [2] * (N + 1)
    ds[0] = ds[1] = 1
    for i in xrange(2, N + 1):
        for j in xrange(2*i, N + 1, i):
            ds[j] += 1

    return sum(ds[i] for i in xrange(1, N))
    
N = rri()
print solve(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:
#!/usr/bin/env python3
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    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:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

##fix value of a and then count

count =0 

for a in range(1,n):
    ##find the number of bs such that a*b < n stricly less than
    b = n // a
    if a*b == n:
        b-=1
    
    count+=b

print(count)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

for a in range(1, N):
  maxb = N//a
  if N%a == 0:
    maxb -= 1
  if maxb > 0:
  	ans += maxb
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ans=0
for a in range(1,10**6):
    if a>=N:
        break
    for b in range(1,10**6):
        A=a*b
        c=N-A
        if c<=0:
            break
        if 1<=c<=10**6:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())

def kouho_num(a):
    if n%a==0:
        return n//a-1
    else:
        return n//a
ans=0

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

Submission status: Accepted

Solution code:
from math import floor
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+1):
    if N % i == 0:
        ans += (N // i) - 1
    else:
        ans += (N // i)

print(ans)

Submission status: Accepted

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


def solve(N: int):
    ans = 0
    for a in range(1, N):
        bb = N // a
        cc = N % a
        ans += bb - (1 if cc == 0 else 0)
    return ans


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

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

    class osa_k:
        def __init__(self, sup):
            if sup > 2 * 10**8:
                raise RuntimeError(
                )
            self.MINFact = [-1] * (sup + 1)
            self.MINFact[0] = 0
            self.MINFact[1] = 1
            primes = [True for i in range(sup+1)]
            primes[0] = False
            primes[1] = False
            for i in range(2, sup+1):
                if primes[i]:
                    self.MINFact[i] = i
                    mul = 2
                    while i*mul <= sup:
                        primes[i*mul] = False
                        if self.MINFact[i*mul] == -1:
                            self.MINFact[i*mul] = i
                        mul += 1

        def prime_factor(self, n):
            res = 1
            while n > 1:
                prime = self.MINFact[n]
                exp = 0
                while self.MINFact[n] == prime:
                    n //= prime
                    exp += 1
                res *= (exp + 1)
            return res

    ok = osa_k(N+1)

    ans = 0
    for c in range(1, N):
        M = N - c
        ans += ok.prime_factor(M)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())


def ceil(a, b):
    return -(-a // b)


ans = 0

for a in range(1, n):
    for b in range(1, ceil(n, a)):
        if n-a*b > 0:
            ans += 1
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())
ans = sum((N - 1)//denom for denom in range(1, N))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:

n=int(input())

cnt=0
for i in range(1,n):
  for j in range(1,n):
    if i*j<n:
      cnt+=1
    else:
      break
print(cnt)

Submission status: Accepted

Solution code:

def resolve():
    n = int(input())
    cnt = 0
    for a in range(1, n+1):
        b = n // a
        c = n % a
        cnt += b
        if c == 0:
            cnt -= 1

    print(cnt)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:
n = int(input())
ans = 0
for a in range(1, n):
    for b in range(a, n):
        if a * b < n:
            if a == b:
                ans += 1
            else:
                ans += 2
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


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


def read_float():
    return float(readline())


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


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


def read_str_n():
    return readline().strip().split()


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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(N):
    ans = 0
    for a in range(1, N+1):
        for b in range(1, N//a + 1):
            c = N - a*b
            if c > 0:
                ans += 1

    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# A * B < N となる A, B を数える

N = int(read())
A = np.arange(1, N + 1)
B = (N - 1) // A
print(B.sum())

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

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 sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()

    ans = 0
    for a in range(1, 1000005):
        for b in range(1, 1000005):
            if a * b > 1000_000:
                break
            c = N - (a * b)
            if c > 0:
                ans += 1
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n=int(input())

ans=0

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

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

Submission status: Accepted

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

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

print(ans)

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:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())
    
    ans = 0
    for a in range(1, N+1):
        ans += N // a
        if N % a == 0:
            ans -= 1
    
    print(ans)


if __name__ == '__main__':
    main()

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())
ans = 0
for i in range(1,N):
    ans += (N-1)//i


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

print(sum(num_divisors_table(n-1)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# 与えられた N 以下の素数を列挙して、その N 以下の素数の素因数分解を高速に与えるアルゴリズム。
#
# 計算量:
#     構築: O(N)　
#     素因数分解: n <= N なる n に対し O(log n)、N < n <= N**2 なる n に対し、O(N / log N)
#
#
# 参考: https://cp-algorithms.com/algebra/prime-sieve-linear.html (n <= N に対して O(log n) の部分)

from collections import defaultdict

n = int(input())
N = n + 10  # 10 ** 7 以下だとよさそう。10 ** 7 でPyPy3で構築に500ms程度。
lp = [0] * (N+1)
pr = []  # N 以下の素数のリスト
for i in range(2, N+1):
    if lp[i] == 0:
        lp[i] = i
        pr.append(i)
    for j, p in enumerate(pr):
        if p > lp[i] or i * p > N:
            break
        lp[i * p] = p


def fac_small(n):
    """
    引数 n の素因数分解をして、素因数を昇順に格納したリストを返す。
    ex. fac_small(60) == [2, 2, 3, 5]
    与えられた n について 1 <= n <= N を仮定する。n == 1 では空リストを返す。
    計算量は O(log n) 
    """
    # assert 1 <= n <= N
    ret = defaultdict(int)
    while n > 1:
        ret[lp[n]] += 1
        n //= lp[n]
    return ret


ans = 0
for c in range(1, n):
    tmp = 1
    for f in (fac_small(n - c)).values():
        tmp *= (f + 1)
    ans += tmp

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  ans=0
  for a in range(1,n):
    if n%a==0:
      _n=n-1
    else:
      _n=n

    ans+=_n//a

  return ans

# main()
print(main())

Submission status: Accepted

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

def solve():
    n=int(input())
    count=0
    for i in range(1,n):
        for j in range(1,n):
            if n - i*j>0:
                count+=1
            else:
                break
    print(count)

if __name__=="__main__":
    solve()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

#エラトステネスの篩と素因数分解

from collections import Counter
M = 10**6 + 4
prime = [0]*M
for i in range(2, M):
    if prime[i]:
        continue
    for j in range(i, M, i):
        if not prime[j]:
            prime[j] = i

def pd(x):
    C = Counter()
    while x > 1:
        C[prime[x]] += 1
        x //= prime[x]
    return C

N = int(readline())

ans = 0
for i in range(1, N):
    c = pd(i)
    res = 1
    for vi in c.values():
        res *= (1+vi)
    ans += res
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
import sys
import math
from functools import cmp_to_key

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)


def main():
    n = int(input())
    ans = 0
    for a in range(1, n+1):
        ans += (n-1) // a
    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

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

N=int(readline())
# 1～(N - 1)の約数を数える

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
ans = 0
for i in range(1, N):
  for j in range(i, N, i):
    ans += 1

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())
MAX = pow(10,6) + 10
ans = 0
for a in range(1,MAX):
  kosu = N//a
  if N%a == 0:
    kosu -=1
  ans += kosu
print(ans)

Submission status: Accepted

Solution code:
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(k):  # fix inputs here
    console("----- solving ------")

    dp = [0 for _ in range(k+1)]

    for i in range(1,k+1):
        for j in range(i,k+1,i):
            dp[j] += 1
    
    return sum(dp[:-1])


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    k = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    # lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(list(map(int,input().split())))

    res = solve(k)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)

Submission status: Accepted

Solution code:
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
mod = int(1e9) + 7
INF=float('inf')

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n = ni()
ans = 0
for a in range(1,n):
    ans += (n-1)//a
print(ans)

Submission status: Accepted

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

    print(ans)



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:
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
ans = 0
for a in range(1, N):
    ans += N // a
    if N % a == 0:
        ans -= 1
print(ans)