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

Solution code:
def make_divisors(n):
    cnt = 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            cnt += 1
            if i != n // i:
                cnt += 1
        i += 1
    return cnt
numbers = [1,10, 100, 1000, 10000, 100000, 200000, 250000,300000,350000, 400000,450000, 500000,750000,1000000]
datas = [0,23,473,7053,93643,1166714, 2472071, 3145923, 3829761, 4522005,5221424,5927120,6638407,10261678,13969985]

N = int(input())
ttl = 0
numPin = 0

for i in range(len(numbers)):
    if numbers[i] <= N < numbers[i+1]:
        numPin = i
        break

if numPin != len(numbers)-1:
    if N - numbers[numPin] < numbers[numPin + 1] - N:
        for i in range(numbers[numPin], N):
            ttl += make_divisors(i)
        print(ttl + datas[numPin])
    else:
        for i in range(N,numbers[numPin+1]):
            ttl -= make_divisors(i)
        print(ttl + datas[numPin + 1])
else:
    print(datas[numPin])

Submission status: Runtime Error

Solution code:
N = int(input())
def factorization(n):
    arr = []
    temp = n
    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
ans = 1
for i in range(2,N):
    a = factorization(n)
    b = 1
    for j in range(len(a)):
        x = a[j][1]
        b *= (x+1)
    ans += b
print(ans)

Submission status: Runtime Error

Solution code:
x = int(input())

for a in range(1, x+1):
    for b in range(1, x+1):
        if a * b >= x:
            pass
        else:          
            for c in range(1, x+1):
                kai = (a * b) + c
                if kai == x:
                #print(a,b,c)
                    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
import sympy
N = int(input())
# N = 100


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]


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


ans = 0
for i in range(1, N):
    ans += len(sympy.divisors(i))


print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N = input()
rN = int(np.sqrt(N))
setN = 0
for c in range(1, N):
    for a in range(1, rN+1):
        b = (N-c)/a
        if b == int(b):
            if a*a == N-c:
                setN += 1
                #print(a, a, c, N-c)
            elif b > rN:
                setN += 2
                #print(a, b, c, N-c)
            else:
                setN += 1
                #print(a, b, c, N-c)

print(setN)

Submission status: Runtime Error

Solution code:
n = int(input())
import math
def num_divisors(prime_count):
    num = 1
    
    for prime, count in prime_count.iteritems():
        num *= (count + 1)
    
    return num

total = 0

for i in range(1,n):
  c = n-i
  total += num_divisors(n-i)
print(total)

Submission status: Runtime Error

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



a=0
for i in range(1,n):
    a+=sympy.divisor_count(i)
print(a)

Submission status: Runtime Error

Solution code:
import sympy
N=int(input())
count=0
for i in range(1,N):
    count+=sympy.divisor_count(i)
print(count)

Submission status: Runtime Error

Solution code:
#C

# 与えられた数字までの数字の約数をカウントする。
import sympy

N = int(input())
counter = 0
for i in range(1,N):
  counter = counter + int(sympy.divisor_count(i))

print(counter)

Submission status: Runtime Error

Solution code:
import sympy
      
def ProgramC():
    num = int(input())
    count = 0

    for i in range(num-1):
        a_b = num - (i + 1)        
        
        count = count + len(sympy.divisors(a_b))

    print(count)    
      
if __name__ == '__main__':
    ProgramC()

Submission status: Runtime Error

Solution code:
import sympy

cnt = 0
for C in range(1, N):
    div = sympy.divisors(N-C)
    cnt += len(div)
    # if len(div) % 2 == 0:
    #     cnt += len(div)
    # else:
    #     cnt += 2 * len(div) - 1

print(cnt)

Submission status: Runtime Error

Solution code:
def num_divisors(prime_count):
    num = 1
    
    for prime, count in prime_count.iteritems():
        num *= (count + 1)
    
    return num
N = int(input())
ans = 1
for i in range(2,N):
    ans += um_divisors(i)
print(ans)

Submission status: Runtime Error

Solution code:
import sympy

n=int(input())
abc=n
ans=0
for c in range(1,n):
  ab=abc-c
  ans+=len(sympy.divisors(ab))

print(ans)

Submission status: Runtime Error

Solution code:
import sys
import re
import queue
import collections
import math
import sympy
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


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

	print(sum)

	return

if __name__ == '__main__':
	main()

Submission status: Runtime Error

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

N, K = map(int, input().split())

L = [list(map(int, input().split())) for _ in range(K)]

S = []

for left, right in L:
    S.extend(range(left, right+1))

S = sorted(list(set(S)))

n_list = [0] * N
n_list[0] = 1

for idx, value in enumerate(n_list):
    if value == 0:
        continue
    if S[0] + idx >= N:
        break
    for s in S:
        next_idx = s + idx
        if next_idx >= N:
            break
        n_list[next_idx] += value

print(n_list[-1] % 998244353)

Submission status: Runtime Error

Solution code:
def SieveOfEratosthenes(n, prime, primesquare, a):
    # Create a boolean array "prime[0..n]"
    # and initialize all entries it as
    # true. A value in prime[i] will finally
    # be false if i is not a prime, else true.
    for i in range(2, n + 1):
        prime[i] = True

    # Create a boolean array "primesquare[0..n*n+1]"
    # and initialize all entries it as false.
    # A value in squareprime[i] will finally be
    # true if i is square of prime, else false.
    for i in range((n * n + 1) + 1):
        primesquare[i] = False

    # 1 is not a prime number
    prime[1] = False

    p = 2
    while (p * p <= n):
        # If prime[p] is not changed,
        # then it is a prime
        if (prime[p] == True):
            # Update all multiples of p
            i = p * 2
            while (i <= n):
                prime[i] = False
                i += p
        p += 1

    j = 0
    for p in range(2, n + 1):
        if (prime[p] == True):
            # Storing primes in an array
            a[j] = p

            # Update value in primesquare[p*p],
            # if p is prime.
            primesquare[p * p] = True
            j += 1


# Function to count divisors
def countDivisors(n):
    # If number is 1, then it will
    # have only 1 as a factor. So,
    # total factors will be 1.
    if (n == 1):
        return 1

    prime = [False] * (n + 2)
    primesquare = [False] * (n * n + 2)

    # for storing primes upto n
    a = [0] * n

    # Calling SieveOfEratosthenes to
    # store prime factors of n and to
    # store square of prime factors of n
    SieveOfEratosthenes(n, prime, primesquare, a)

    # ans will contain total
    # number of distinct divisors
    ans = 1

    # Loop for counting factors of n
    i = 0
    while (1):
        # a[i] is not less than cube root n
        if (a[i] * a[i] * a[i] > n):
            break

        # Calculating power of a[i] in n.
        cnt = 1  # cnt is power of
        # prime a[i] in n.
        while (n % a[i] == 0):  # if a[i] is a factor of n
            n = n / a[i]
            cnt = cnt + 1  # incrementing power

        # Calculating number of divisors
        # If n = a^p * b^q then total
        # divisors of n are (p+1)*(q+1)
        ans = ans * cnt
        i += 1

    # if a[i] is greater than
    # cube root of n

    n = int(n)
    # First case
    if (prime[n] == True):
        ans = ans * 2

    # Second case
    elif (primesquare[n] == True):
        ans = ans * 3

    # Third case
    elif (n != 1):
        ans = ans * 4

    return ans  # Total divisors
n= int(input())
x=0
for i in range(1,n):
    x+=countDivisors(n-i)
    #print(countDivisors(n-i))

print(x)

Submission status: Runtime Error

Solution code:
import sympy


n = int(input())
count = 0
for i in range(1, n, 1):
    count += sympy.divisor_count(i)
print(count)

Submission status: Runtime Error

Solution code:
import sympy
kazu=int(input())
ans=0
for i in range(kazu): 
    a=sympy.divisors(i)
    b=len(a)
    ans+=b
print(ans)

Submission status: Runtime Error

Solution code:
import os,sys
a,b,c=0
count=0
n=input()
for a in range(n):
    for b in range(n):
        for c in range(n):
            if a*b+c==n:
                count+=1
print(count)

Submission status: Runtime Error

Solution code:
import sys, math
sys.setrecursionlimit(10 ** 9 + 7)
n = int(input())
def A(a, count):
    if a > n:
        print(count)
    elif n % a == 0:
        A(a + 1, count + n // a - 1)
    else:
        A(a + 1, count + n // a)
A(1, 0)

Submission status: Runtime Error

Solution code:
def factorization(n):
    arr = []
    temp = n
    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])
    t = (arr[0][1]+1)*(arr[1][1]+1)
    print(t) 

    return arr

factorization(int(input()))

Submission status: Runtime Error

Solution code:
import numpy as np
N = input()
rN = int(np.sqrt(N))
setN = 0
setN2 = 0
for c in range(1, N):
    for a in range(1, rN+1):
        if (N-c)%a == 0:
            if a*a == N-c:
                setN += 1
                #print(a, a, c, N-c)
            elif (N-c)/a > rN:
                setN += 2
            else:
                setN2 += 1
                #print(a, int((N-c)/a), c, N-c)

print(setN+setN2)

Submission status: Runtime Error

Solution code:
N=int(input())

cou=0
for i in range(1:N-1):
    for w in range(1:(N-i)):
        if (N-i)%w==0:
            cou+=1

print(cou)

Submission status: Runtime Error

Solution code:
import sys
import math
def INT(): return int(input())
sys.maxsize = 10 ** 15
sys.setrecursionlimit(10 ** 9 + 7)

# -*- coding: utf-8 -*-

n = INT()

def A(a, count):
    global n
    if a > n:
        print(count)
    else:
        if n % a == 0:
            A(a + 1, count + n // a - 1)
        else:
            A(a + 1, count + n // a)
        
A(1, 0)

Submission status: Runtime Error

Solution code:
import collections
import numpy as np


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 = 0
for i in range(1, N):
    if N-i == 1:
        ans += 1
    if N-i > 1:
        c = collections.Counter(prime_factorize(N-i))
        prod = np.prod(np.array(list(c.values()))+1)
        ans += prod
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
s = [0,1]
for i in range(2,N):
    for j in range(2,i**0.5+1):
        if i % j == 0:
            k = i//j
            s.apppend(2*s[k])
            break
    if len(s) != i:
        s.append(1)
print(sum(s))

Submission status: Runtime Error

Solution code:
import math
n = int(input())
k = int(math.sqrt(n)) if n != k ** 2 else int(math.sqrt(n)) - 1
ans = 0
for i in range(1, k + 1):
    t = int((n - 1) / i)
    ans += (t- i + 1) * 2
    if n != i ** 2:
        ans -= 1 
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
ans = 0
for i in range(1, N):
    if N-i == 1:
        ans += 1
    if N-i > 1:
        c = collections.Counter(prime_factorize(N-i))
        prod = np.prod(np.array(list(c.values()))+1)
        ans += prod
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
import math
def num_divisors_trial_division(n):
    num = 0
    for i in xrange(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    
    return num
for k in range(1,N):
    count=count+num_divisors_trial_division(k)
print(count)

Submission status: Runtime Error

Solution code:
import sys
import math

def helper(x, N, hashset):
	left = 1
	right = x
	ans = 0
	# while left <= right:
	# 	prod = left * right
	# 	if prod == x:
	# 		# print(left, right, x, N)
	# 		if left == right:
	# 			ans += 1
	# 		else:
	# 			ans += 2
	# 		left += 1
	# 		right -= 1

	# 	elif prod > x:
	# 		right -= 1

	# 	else:
	# 		left += 1

	for i in range(1, int(x**0.5)+1):
		j = x / i

		if j in hashset:
			if i == j:
				ans += 1
			else:
				ans += 2


	return ans



N = int(input())
if N == 2:
	print('1')
else:
	c = 1
	ans = 0
	hashset = set([i for i in range(1, N+1)])

	while N-c >= 1:
		ans += helper(N-c, N, hashset)
		c += 1
		# print(ans)

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
cnt = 0
for c in range(1, N-1):
  for a in range(1, N - c // 2):
    if b % a == 0:
    	cnt += 2
print(cnt)

Submission status: Runtime Error

Solution code:
from sympy import divisors
n = int(input())

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

Submission status: Runtime Error

Solution code:
import math

N = int(input())

yakusu = [0] * N+1
yakusu[1] = 1
for i in range(2,N+1):
  for j in range(1,i):
    if i*j > N:
      break
    yakusu[i*j] += 2
    
  yakusu[i*i] += 1

counter = 0
for num in yakusu[1:N]:
  counter += num
      
print(counter)

Submission status: Runtime Error

Solution code:
N = input()
B = 1
C = 1
cur=0
while C <= N:
  K = N - C
  C += 1
  while B <= N:
    L = K % B
    B += 1
    if L = 0:
      cur += 1
print(cur)

Submission status: Runtime Error

Solution code:
%%time
n = int(input())

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

print(cnt)

Submission status: Runtime Error

Solution code:
def get_divisors(n):
    if n < 1:
        return
    i = 1
    while i * i <= n:
        if n % i == 0:
            yield i
            if i * i != n:
                yield round(n / i)
        i = i + 1

n = int(input())
# a * b + c = n 
# a * b - n = c

cnt = 0

import sympy
for i in range(1, n):
  cnt += len(list(get_divisors(n-i)))
print(cnt)

Submission status: Runtime Error

Solution code:
import sympy

N = int(input())
c = 1
total = 0

while(N-c >= 1):
      divnums = sympy.divisors(N-c)

      # print(N-c,end=" ")
      # print(str(divnums) + ", divcombies: " + str(divcombies))
      
      total += len(divnums)
      c += 1

print(total)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(1, n):
    for j in range(1, n):
        for k in range(1, n):
            if (i*j+k) == n:
                count += 1
                return 
print(count)

Submission status: Runtime Error

Solution code:
N=int(input())
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]
count=0
for k in range(1,N):
    r=make_divisors(k)
    count=count+r
print(count)

Submission status: Runtime Error

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

n = int(input())

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

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

print(count + 1)

Submission status: Runtime Error

Solution code:
N=int(input())
import sympy
sum=0
for c in range(1,N):
    sum+=sympy.divisor_count(c)
print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
sum=0
import sympy
# 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]
sum=0
for c in range(1,N):
    sum+=sympy.divisor_count(c)
print(sum)

Submission status: Runtime Error

Solution code:
import sympy
N = int(input())
count = 0
for c in range(1, N):
    count += len(sympy.divisors(c))
print(count)

Submission status: Runtime Error

Solution code:
N=int(input())
def ans(n):
    if n<=0:
        return n
    x = 0
    for i in range(1,n+1):
        if n%i==0:
            x=x+1
    return x +ans(n-1)
print(ans(N-1))

Submission status: Runtime Error

Solution code:
import sympy
n=int(input())
a = 0
for i in range(n):
    a += len(sympy.divisors(n-i-1))
print(a)

Submission status: Runtime Error

Solution code:
import sympy
import sys
sys.setrecursionlimit(10**6)
n=int(input())
ans=0
for c in range(1,n):
    ab=n-c
    buffer=sympy.divisors(ab)
    ans+=len(buffer)
print(ans)

Submission status: Runtime Error

Solution code:
def divisor_count(n, modulus=1, proper=False):

    if not modulus:
        return 0
    elif modulus != 1:
        n, r = divmod(n, modulus)
        if r:
            return 0
    if n == 0:
        return 0
    n = Mul(*[v + 1 for k, v in factorint(n).items() if k > 1])
    if n and proper:
        n -= 1
    return n
def factorint(n, limit=None, use_trial=True, use_rho=True, use_pm1=True,
              use_ecm=True, verbose=False, visual=None, multiple=False):
    if isinstance(n, Dict):
        n = dict(n)
    if multiple:
        fac = factorint(n, limit=limit, use_trial=use_trial,
                           use_rho=use_rho, use_pm1=use_pm1,
                           verbose=verbose, visual=False, multiple=False)
        factorlist = sum(([p] * fac[p] if fac[p] > 0 else [S.One/p]*(-fac[p])
                               for p in sorted(fac)), [])
        return factorlist

    factordict = {}
    if visual and not isinstance(n, Mul) and not isinstance(n, dict):
        factordict = factorint(n, limit=limit, use_trial=use_trial,
                               use_rho=use_rho, use_pm1=use_pm1,
                               verbose=verbose, visual=False)
    elif isinstance(n, Mul):
        factordict = {int(k): int(v) for k, v in
            n.as_powers_dict().items()}
    elif isinstance(n, dict):
        factordict = n
    if factordict and (isinstance(n, Mul) or isinstance(n, dict)):
        # check it
        for key in list(factordict.keys()):
            if isprime(key):
                continue
            e = factordict.pop(key)
            d = factorint(key, limit=limit, use_trial=use_trial, use_rho=use_rho,
                          use_pm1=use_pm1, verbose=verbose, visual=False)
            for k, v in d.items():
                if k in factordict:
                    factordict[k] += v*e
                else:
                    factordict[k] = v*e
    if visual or (type(n) is dict and
                  visual is not True and
                  visual is not False):
        if factordict == {}:
            return S.One
        if -1 in factordict:
            factordict.pop(-1)
            args = [S.NegativeOne]
        else:
            args = []
        args.extend([Pow(*i, evaluate=False)
                     for i in sorted(factordict.items())])
        return Mul(*args, evaluate=False)
    elif isinstance(n, dict) or isinstance(n, Mul):
        return factordict

    assert use_trial or use_rho or use_pm1 or use_ecm

    from sympy.functions.combinatorial.factorials import factorial
    if isinstance(n, factorial):
        x = as_int(n.args[0])
        if x >= 20:
            factors = {}
            m = 2 # to initialize the if condition below
            for p in sieve.primerange(2, x + 1):
                if m > 1:
                    m, q = 0, x // p
                    while q != 0:
                        m += q
                        q //= p
                factors[p] = m
            if factors and verbose:
                for k in sorted(factors):
                    print(factor_msg % (k, factors[k]))
            if verbose:
                print(complete_msg)
            return factors
        else:
            # if n < 20!, direct computation is faster
            # since it uses a lookup table
            n = n.func(x)

    n = as_int(n)
    if limit:
        limit = int(limit)
        use_ecm = False

    # special cases
    if n < 0:
        factors = factorint(
            -n, limit=limit, use_trial=use_trial, use_rho=use_rho,
            use_pm1=use_pm1, verbose=verbose, visual=False)
        factors[-1] = 1
        return factors

    if limit and limit < 2:
        if n == 1:
            return {}
        return {n: 1}
    elif n < 10:
        # doing this we are assured of getting a limit > 2
        # when we have to compute it later
        return [{0: 1}, {}, {2: 1}, {3: 1}, {2: 2}, {5: 1},
                {2: 1, 3: 1}, {7: 1}, {2: 3}, {3: 2}][n]

    factors = {}

    # do simplistic factorization
    if verbose:
        sn = str(n)
        if len(sn) > 50:
            print('Factoring %s' % sn[:5] + \
                  '..(%i other digits)..' % (len(sn) - 10) + sn[-5:])
        else:
            print('Factoring', n)

    if use_trial:
        # this is the preliminary factorization for small factors
        small = 2**15
        fail_max = 600
        small = min(small, limit or small)
        if verbose:
            print(trial_int_msg % (2, small, fail_max))
        n, next_p = _factorint_small(factors, n, small, fail_max)
    else:
        next_p = 2
    if factors and verbose:
        for k in sorted(factors):
            print(factor_msg % (k, factors[k]))
    if next_p == 0:
        if n > 1:
            factors[int(n)] = 1
        if verbose:
            print(complete_msg)
        return factors

    # continue with more advanced factorization methods

    # first check if the simplistic run didn't finish
    # because of the limit and check for a perfect
    # power before exiting
    try:
        if limit and next_p > limit:
            if verbose:
                print('Exceeded limit:', limit)

            _check_termination(factors, n, limit, use_trial, use_rho, use_pm1,
                               verbose)

            if n > 1:
                factors[int(n)] = 1
            return factors
        else:
            # Before quitting (or continuing on)...

            # ...do a Fermat test since it's so easy and we need the
            # square root anyway. Finding 2 factors is easy if they are
            # "close enough." This is the big root equivalent of dividing by
            # 2, 3, 5.
            sqrt_n = integer_nthroot(n, 2)[0]
            a = sqrt_n + 1
            a2 = a**2
            b2 = a2 - n
            for i in range(3):
                b, fermat = integer_nthroot(b2, 2)
                if fermat:
                    break
                b2 += 2*a + 1  # equiv to (a + 1)**2 - n
                a += 1
            if fermat:
                if verbose:
                    print(fermat_msg)
                if limit:
                    limit -= 1
                for r in [a - b, a + b]:
                    facs = factorint(r, limit=limit, use_trial=use_trial,
                                     use_rho=use_rho, use_pm1=use_pm1,
                                     verbose=verbose)
                    for k, v in facs.items():
                        factors[k] = factors.get(k, 0) + v
                raise StopIteration

            # ...see if factorization can be terminated
            _check_termination(factors, n, limit, use_trial, use_rho, use_pm1,
                               verbose)

    except StopIteration:
        if verbose:
            print(complete_msg)
        return factors

    # these are the limits for trial division which will
    # be attempted in parallel with pollard methods
    low, high = next_p, 2*next_p

    limit = limit or sqrt_n
    # add 1 to make sure limit is reached in primerange calls
    limit += 1
    iteration = 0
    while 1:

        try:
            high_ = high
            if limit < high_:
                high_ = limit

            # Trial division
            if use_trial:
                if verbose:
                    print(trial_msg % (low, high_))
                ps = sieve.primerange(low, high_)
                n, found_trial = _trial(factors, n, ps, verbose)
                if found_trial:
                    _check_termination(factors, n, limit, use_trial, use_rho,
                                       use_pm1, verbose)
            else:
                found_trial = False

            if high > limit:
                if verbose:
                    print('Exceeded limit:', limit)
                if n > 1:
                    factors[int(n)] = 1
                raise StopIteration

            # Only used advanced methods when no small factors were found
            if not found_trial:
                if (use_pm1 or use_rho):
                    high_root = max(int(math.log(high_**0.7)), low, 3)

                    # Pollard p-1
                    if use_pm1:
                        if verbose:
                            print(pm1_msg % (high_root, high_))
                        c = pollard_pm1(n, B=high_root, seed=high_)
                        if c:
                            # factor it and let _trial do the update
                            ps = factorint(c, limit=limit - 1,
                                           use_trial=use_trial,
                                           use_rho=use_rho,
                                           use_pm1=use_pm1,
                                           use_ecm=use_ecm,
                                           verbose=verbose)
                            n, _ = _trial(factors, n, ps, verbose=False)
                            _check_termination(factors, n, limit, use_trial,
                                               use_rho, use_pm1, verbose)

                    # Pollard rho
                    if use_rho:
                        max_steps = high_root
                        if verbose:
                            print(rho_msg % (1, max_steps, high_))
                        c = pollard_rho(n, retries=1, max_steps=max_steps,
                                        seed=high_)
                        if c:
                            # factor it and let _trial do the update
                            ps = factorint(c, limit=limit - 1,
                                           use_trial=use_trial,
                                           use_rho=use_rho,
                                           use_pm1=use_pm1,
                                           use_ecm=use_ecm,
                                           verbose=verbose)
                            n, _ = _trial(factors, n, ps, verbose=False)
                            _check_termination(factors, n, limit, use_trial,
                                               use_rho, use_pm1, verbose)

        except StopIteration:
            if verbose:
                print(complete_msg)
            return factors
        #Use subexponential algorithms if use_ecm
        #Use pollard algorithms for finding small factors for 3 iterations
        #if after small factors the number of digits of n is >= 20 then use ecm
        iteration += 1
        if use_ecm and iteration >= 3 and len(str(n)) >= 25:
            break
        low, high = high, high*2
    B1 = 10000
    B2 = 100*B1
    num_curves = 50
    while(1):
        if verbose:
            print(ecm_msg % (B1, B2, num_curves))
        while(1):
            try:
                factor = _ecm_one_factor(n, B1, B2, num_curves)
                ps = factorint(factor, limit=limit - 1,
                               use_trial=use_trial,
                               use_rho=use_rho,
                               use_pm1=use_pm1,
                               use_ecm=use_ecm,
                               verbose=verbose)
                n, _ = _trial(factors, n, ps, verbose=False)
                _check_termination(factors, n, limit, use_trial,
                                       use_rho, use_pm1, verbose)
            except ValueError:
                break
            except StopIteration:
                if verbose:
                    print(complete_msg)
                return factors
        B1 *= 5
        B2 = 100*B1
        num_curves *= 4


N = int(input())
ans = 0
for i in range(1, N):
    Q = N - i
    ans += sympy.divisor_count(Q)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import math
def INT(): return int(input())
sys.maxsize = 10 ** 15
sys.setrecursionlimit(10 ** 9 + 7)

# -*- coding: utf-8 -*-

n = INT()

def A(a, count):
    if a > n:
        print(count)
    else:
        if n % a == 0:
            A(a + 1, count + n // a - 1)
        else:
            A(a + 1, count + n // a)
        
A(1, 0)

Submission status: Runtime Error

Solution code:
import sys
import math
def INT(): return int(input())
sys.maxsize = 10 ** 15
sys.setrecursionlimit(10 ** 9 + 7)

# -*- coding: utf-8 -*-

n = INT()

def A(a, count):
    if a > n:
        print(count)
    else:
        if float(n) % float(a) == 0.0:
            A(a + 1, count + n // a - 1)
        else:
            A(a + 1, count + n // a)
        
A(1, 0)