Problem:


Score : 300 points

Problem Statement

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

Constraints

 2 \leq N \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.

Sample Input 1

3

Sample Output 1

3

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

Sample Input 2

100

Sample Output 2

473

Sample Input 3

1000000

Sample Output 3

13969985



Sample input:
3


Sample output:
3

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input().rstrip('\n'))
res = 0
for a in range(1,N):
  if N%a == 0:
    res += N//a-1
  else:
    res += N//a
print(res)

Submission status: Accepted

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

N = int(input())
table = num_divisors_table(N)

res = 0

for c in range(N)[1:]:
  res += table[N-c]

print(res)

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())
a = num_divisors_table(n-1)

ans = 0
for i in a:
    #print(i)
    ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        if k<0 or n<k:
            return 0
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N=intput()
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 a in range(1, N):
    b_max = (N - 1) // a

    if a * b_max >= N:
        continue

    ans += b_max


print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

    total = 0
    for a in range(1, N):
        if N % a == 0:
            bmax = N // a - 1
        else:
            bmax = N // a

        total = total + bmax
    print(total)


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

class ABC(object):

    def __init__(self):
        pass


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

        n_c = n - 1

        ans = 0
        for i_a in range(1, n_c+1):
            max_b = n_c // i_a
            ans += max_b

        print(ans)
        return


if __name__ == "__main__":
    obj = ABC()
    obj.main()
    sys.exit(0)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()

    ans = 0
    for A in range(1,N+1):
        for B in range(1,N+1):
            if A*B > N:
                break

            C = N - A*B
            if C > 0:
                ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy
import time

import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
from numba import jit


def main():
    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)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Sum = 0
hoge = num_divisors_table(N-1)
Sum = sum(hoge)

print(Sum)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for a in range(1, N):
    for b in range(a, N):
        # print(a, b, a * b < N)
        if a * b < N:
            ans += 1
            if a != b:
                ans += 1
        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:
import math
N = int(input())
ans=0
for i in range(1,N+1,1):
  ans += math.ceil(N/i)-1
  
print(ans)

Submission status: Accepted

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

main()

Submission status: Accepted

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))


    N = NI()
    ans = (N-1) * 2 - 1
    for i in range(2,N//2+1):
        j = 2
        while i * j < N:
            ans += 1
            j += 1
    print(ans)


if __name__ == '__main__':
    main()

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 a in range(1, N+1):
    x = N // a

    if N % a == 0:
        ans += x - 1
    else:
        ans += x

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    N = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

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

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

res = 0
for a in range(1, n):
    max_b = int((n-1)/a)
    res += max_b

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby
class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i - 1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod
        
def iparse():
    return list(map(int, input().split()))


# RUN LENGTH ENCODING str -> tuple


def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())

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

Submission status: Accepted

Solution code:
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part
n=int(I())
cnt=0
for a in range(1,n):
    for b in range(1,n):
        if a*b>=n:
            break
        cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
#import numpy as np
import re
import math
from collections import defaultdict,deque,Counter
from fractions import Fraction
import bisect
import itertools
from itertools import accumulate
from copy import deepcopy

import heapq
import random
import time
import os
import sys
from functools import lru_cache,reduce
readline=sys.stdin.readline
sys.setrecursionlimit(100000)
alp="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class Point():
    def __init__(self,y,x):
        self.x=x
        self.y=y
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):print("yes" if b else "no")
def Yn(b):print("Yes" if b else "No")
def YN(b):print("YES" if b else "NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(b,t,f):return t if b else f
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def inputintlist(row=1): 
    if row==1:
        ret=list(map(int,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=int(input())
    return ret
def inputfloatlist(row=1): 
    if row==1:
        ret=list(map(float,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=float(input())
    return ret
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    from queue import PriorityQueue
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])#[cost,x]
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)#x→yが複数ある場合のためにmin()する
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow
def zipsort(*args):
    ziplist=sorted(zip(*args))
    for a in range(len(args)):
        for b in range(len(ziplist)):
            args[a][b]=ziplist[b][a]
def zipreverse(*args):
    ziplist=list(zip(*args))
    rev=[]
    for a in range(len(ziplist)-1,-1,-1):
        rev.append(ziplist[a])
    for a in range(len(args)):
        for b in range(len(rev)):
            args[a][b]=rev[b][a]

def to10(A):
    ret=0
    for a in range(len(A)-1,-1,-1):
        ret+=X[a]*2**(N-1-a)
    return ret
######################################################################################################
n=int(input())
cnt=0
for a in range(1,n+1):
    if n%a==0:
        b=n//a
        cnt+=max(b-1,0)
    else:
        b=n//a
        cnt+=max(b,0)
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

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

print(sigma)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
ans = 0
C = Counter([])
for a in range(1, N + 1):
    for b in range(1, N + 1):
        if a * b >= N:
            break
        ans += 1
        if a == b:
            C[a * b] += 1

for v in C.values():
    if v >= 2:
        ans -= (v - 1)
print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
def SR(n):
    return [S() for _ in range(n)]
def LSR(n):
    return [LS() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    f = [1]*n
    f[1] = 1
    for i in range(1,n):
        j = 2*i
        fi = f[i]
        while j < n:
            f[j] += 1
            j += i
    print(sum(f)-1)
    return

#Solve
if __name__ == "__main__":
    solve()

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 numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    res = 0

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

    print(res)



main()

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

print(ans)

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+1):
    ans += (N-1)//i
print(ans)

Submission status: Accepted

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

n, t = int(si()), 0
for i in range(1, n):
    q = n//i
    if not n % i:
        q -= 1
    t += q
print(t)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
def II(): return int(input())

n=II()
count=0
for a in range(1,n):
    m=int(n/a)+1
    for b in range(1,m):
        c=n-a*b
        if 1<=c:
            count+=1
print(count)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
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 = 0

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

    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a, b, c = 1, 1, 1
ans = 0

while n >= c:
    while b <= (n-c):
        ans += (n-c)//b
        b += 1
    c += 1

print(ans)

Submission status: Accepted

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

#N, K = map(int, input().split())
#A = list(map(int, input().split()))
#flag = True
for B in range(1, N+1):
	ans += N//B
	if N%B == 0:
		ans -= 1

#ans = 0
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

ans = 0
for c in range(1, n):
    d = primeFactor(n-c)
    temp = 1
    for k, v in d.items():
        temp *= (v+1)
    ans += temp
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(res)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

class Eratosthenes:
    # https://cp-algorithms.com/algebra/prime-sieve-linear.html
    def __init__(self, n):
        primes, lp = [], [0] * (n + 1)
        for i in range(2, n + 1):
            if lp[i] == 0:
                primes.append(i)
                lp[i] = i

            for pj in primes:
                if pj > lp[i] or i * pj > n: break
                lp[i * pj] = pj
        self.primes, self.lp = primes, lp

    def is_prime(self, x): return self.lp[x] == x

    def factors(self, x):
        ret = []
        while x > 1:
            ret.append(self.lp[x])
            x //= self.lp[x]
        return ret

    def factors_count(self, x):
        ret = defaultdict(int)
        while x > 1:
            ret[self.lp[x]] += 1
            x //= self.lp[x]
        return ret


def main():
    N = I()
    era = Eratosthenes(N)
    d = defaultdict(int)
    for i in range(1, N):
        cnt = era.factors_count(i)
        tmp = 1
        for v in cnt.values():
            tmp *= v+1
        d[i] = tmp

    ans = 0
    for c in range(1, N):
        ans+= d[N - c]

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#import numpy as np

(N, ) = [int(n) for n in input().split()]

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ans = 0
    for A in range(1, N+1):
        ans += (N-1) // A
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

res = 0
for a in range(1, n + 1):
    x = math.ceil(n / a) - 1
    res += x

print(res)