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: Time Limit Exceeded

Solution code:
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]

c= 0
for i in range(1,int(input())):
    c+=len(make_divisors(i))
print(c)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
z = 0
for a in range(N):
    e = min(a,math.floor(N/(a+1)))
    for b in range(e):
        if N - (a+1)*(b+1) > 0:
            z = z+2
        else:
            pass
    if N - (a+1)*(a+1) > 0:
        z = z+1
    else:
        pass
print(z)

Submission status: Time Limit Exceeded

Solution code:
def is_prime(n):
    for p in range(2, n):
        if n % p == 0:
            return False
    return True


N = int(input())

res = 0
for c in range(1, N):
    ab = N - c

    if ab == 1:
        res += 1
    elif is_prime(ab):
        res += 2
    else:
        for a in range(1, ab + 1):
            if ab % a == 0:
                res += 1

print(res)

Submission status: Time Limit Exceeded

Solution code:
import math
def make_prime_list_2(num):
    if num < 2:
        return []

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

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

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

    return [prime for prime in prime_list if prime != 0]
def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num
N = int(input())
ans = 0
for i in range(N - 1):
  a = search_divisor_num_1(N - (i + 1))
  ans = ans + a 
print(ans)

Submission status: Time Limit Exceeded

Solution code:
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)
    return len(divisors)

num = int(input())
ans = 0
for i in range(1, num):
  ans += make_divisors(i)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
 
yakusu = [0] * (N)
for i in range(1,N):
    for j in range(1,min(i, int((N-1)/i))+1):
      M = i*j
      if i == j:
        yakusu[M] += 1
      else:
        yakusu[M] += 2

print(sum(yakusu[1:N]))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def num_divisors(n):
#     divisers = list(range(1, int(n**0.5)+1))
#     num = 0
#     for d in divisers:
#         if n == d ** 2:
#             num += 1
#             continue
#         if n % d == 0:
#             num += 2
#     return num
    ret = 1
    searched_max_dividor = 1
    next_i = 2

    while n > 1:
        for i in range(next_i, n+1):
#             print(i)
            ex = 0
            if n % i == 0:
                while n % i == 0:
#                     print(n, i)
                    ex += 1
                    n = n // i
                ret *= (ex + 1)
                next_i = i + 1
                break
    return ret


x = int(input())

# x - cの約数の数を求める

num_combination = 0
for each in range(1, x):
    num_combination += num_divisors(each)

print(num_combination)

Submission status: Time Limit Exceeded

Solution code:
# from pprint import pprint
# import math
# import collections
# import sympy

N = int(input())
# N = 1000000
# N = 3

# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

yaku_kosu = [1] * N

for ab in range(1, N):
    if ab > 1:
        yaku_kosu[ab] += 1

        j = 2
        while ab * j < N:
            yaku_kosu[ab * j] += 1
            j += 1

print(sum(yaku_kosu) - 1)

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
b=0
for i in range(1,a):
  for k in range(1,i+1):
    if i%k==0:
      b=b+1
print(b)

Submission status: Time Limit Exceeded

Solution code:
#C

# 与えられた数字までの数字の約数をカウントする。
def make_divisors(n):
    count = 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            count += 1
            if i != n // i:
                count += 1
        i += 1
    return count

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

print(counter)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a
  
for i in range(1, n):
  ans += int(divisor_num(i))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
kazu=int(input())
ans=0
for z in range(kazu): 
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= z:
        if z % i == 0:
            lower_divisors.append(i)
            if i != z // i:
                upper_divisors.append(z//i)
        i += 1
    a=len(lower_divisors + upper_divisors[::-1])
    ans+=a
print(ans)

Submission status: Time Limit Exceeded

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


def div(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

for i in range(1,n):
    l = len(div(i))
    if l%2==1:
        count+=1+(l//2)*2
    else:
        count+=l

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 0
for c in range(1,n):
    if ((n-c)**(1/2)).is_integer():
        ans+=1
    for ab in range(1,int(1+(n-c+1)**(1/2))):
        if ((n-c)/(ab)).is_integer() and ((n-c)/(ab))!=(ab):
            ans+=2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
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 len(divisors)
n = int(input())
# A*B+C = N
counter = 0
for c in range(1,n-1):
    ans = n-c
    counter += make_divisors(ans)
print(counter+1)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
 
yakusu = [0] * (N+1)
for i in range(1,N+1):
    for j in range(1,min(i, int(N/i))+1):
      M = i*j
      if i == j:
        yakusu[M] += 1
      else:
        yakusu[M] += 2

print(sum(yakusu[1:N]))

Submission status: Time Limit Exceeded

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

for i in range(1,10**6):
  for j in range(1,(10**6)//i+1):
    if N > i*j:
      ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import prod, floor, sqrt

N = int(input())

M = N
primes = [*range(2, M+1)]
spf = [None] * 2 + [*range(2, M+1)]
for d in range(2, floor(sqrt(M))+1):
  new_primes = [] 
  for x in primes:
    if x % d == 0 and x != d:
      spf[x] = d
    else:
      new_primes.append(x)
  primes = new_primes
  #primes = [x for x in primes if x % d or x == d]

def divide(x): # x > 1
  soin = []
  old_spf = None
  while x > 1:
    new_spf = spf[x]
    if new_spf == old_spf:
      soin[-1] += 1
    else:
      soin.append(1)
    x = x // new_spf
    old_spf = new_spf
  return prod(i+1 for i in soin)


print(1 + sum(divide(x) for x in range(2, N)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
m = n

x = 1

for i in range(1, n - 1):
    for j in range(1, n):
        n = m
        n -= i
        if n % j == 0:
            x += 1
        else:
            x = x

print(x)

Submission status: Time Limit Exceeded

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

result = 0
for c in range(1, N):
    n = N - c

    total = 0
    for a in range(1, n + 1):
        if n % a != 0:
            continue

        total += 1

        b = n // a
        if a == b:
            result += (total * 2) - 1
            break

        if a > b:
            result += (total - 1) * 2
            break

print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
for A in range(1, N):
    for B in range(1, N):
        if A * B < N:  # 大きさ比較なので計算早いか？
            ans += 1
        else:
            break  # 値大きくなったらもう次のAに
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

count = 0

for c in range(1,n):
    num=n-c
    for a in range(1,n):
        if num%a==0:
            for b in range(1,n):
                if (a*b)+c == n:
                    count += 1
else:
    print(count)

Submission status: Time Limit Exceeded

Solution code:
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]


N = int(input())
count = 0

for i in range(N):
    count = count + len(make_divisors(i))

print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
total=[]
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]
for c in range(1,N):
    total.append(len(make_divisors(c)))
print(sum(total))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
#dp = [[-1] * (N+1) for _ in range(N+1)]  
ans = 0
for C in range(N, 0, -1):
    P = N - C
    if P <= 0:
        continue
    i = 1
    while i <= P:
        if P % i != 0:
            i += 1
            continue
        A = i
        B = P // A
        ans += 1
        i += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def make_divisors(n):
    i=2
    ans=dict()
    div_sum=1
    while i*i <=n:
        while n%i==0:
            n=n//i
            if i in ans:
                ans[i]+=1
            else:
                ans[i]=1
        i+=1
    if n!=1:
        ans[n]=1

    ans_list=list(ans.items())

    for j in ans_list:
        div_sum*=j[1]+1
    return div_sum

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

Submission status: Time Limit Exceeded

Solution code:
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]


N = int(input())
count = 0
for c in range(1, N-1):
    answer = make_divisors(N - c)
    count += len(answer)
print(count+1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(1,n):
    m = (n-1)//i
    for j in range(1,m+1):
        cnt[i*j] += 1
        
for i in range(1,n+1):
    ans += cnt[i]
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
X = []
ans = 0
for c in range(1, N):
  X.append(N - c)
arr_X = np.array(X)

for b in range(1, N):  
  ans += np.count_nonzero(arr_X % b == 0)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math


def main():
    N = int(input())
    ans = 0
    for C in range(1, N + 1):
        AB = N -C
        for i in range(1, int(math.sqrt(AB)) + 1):
            if AB % i == 0:
                ans += 1
                if i != AB // i:
                    ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

output = 0

for i in range(1, N):
    counter = 0
    for j in range(1, int(math.sqrt(i)+1)):
        if i % j == 0:
            counter += 1
    if int(math.sqrt(i)) == math.sqrt(i):
        counter -= 1
        counter *= 2
        counter += 1
    else :
        counter *= 2
    output += counter
    
print(output)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
cnt = 0 
mx = int(N//2+1)
for a in range(1,mx):
    for b in range(a,N):
        if N - a * b > 0:
            if a == b:
                cnt += 1
            else:
                cnt += 2
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def count_divisors(n):
    count = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            count += 1
            if i != n // i:
                count +=1
    return count
 
N = int(input())
S = [0 for i in range(N - 1)]
for i in range(1, N):
    if(i == 1):
        S[i-1] = 1
    else:
        div_count = count_divisors(i)
        S[i-1] = S[i-2] + div_count

print(S[len(S) - 1])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

count = 0

for c in range(1,n):
    for a in range(1,n):
        for b in range(1,n):
            if (a*b)+c == n:
                count += 1
else:
    print(count)

Submission status: Time Limit Exceeded

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


N = int(input())

ans = 0
for C in range(1,N):
  ans += num_divisors_trial_division(N-C)
  C += 1
 
print(ans)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(1, N):
  a = N - i
  #l = list(range(1, a+1))
  prime_number = True
  if a != 1:
    ma = int(math.sqrt(a))+1
    for i in range(1, ma):
      if a % i == 0:
        if a/i >= ma:
          count += 2
        else:
          count += 1
  else:
    count += 1
  
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
if __name__=="__main__":
    N = int(input())
    count = 0
    already = []
    for C in range(1, N):
        AB = N-C
        if AB==1:
            count += 1
            continue
        sqrtAB = math.ceil(AB**0.5)
        if sqrtAB**2==AB:
            sqrtAB += 1
        for B in range(1, sqrtAB):
            if AB%B!=0:
                continue
            else:
                A = int(AB/B)
                if A==B:
                    count += 1
                    continue
                count += 2
            # print(A, B, C)
    print(count)

Submission status: Time Limit Exceeded

Solution code:
def pair(n):
    c=0
    for i in range(1,int(n**(1/2))+1):
        if n%i==0:
            if i**2==n:
                c+=1
            else:
                c+=2
    return c

N=int(input())
ans=0
if N>=2:
    for i in range(2, N+1):
        ans += pair(i-1)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
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]


n = int(input())
ans = 0
for i in range(1, n):
    n_c = n - i
    divisors = make_divisors(n_c)
    
    for j in range(len(divisors)):
        if n_c % divisors[j] == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def divisor(n): 
    i = 1
    s = 0
    while i * i <= n:
        if n%i == 0:
          if n // i == i:
            s += 1
          else:
            s += 2
        i += 1
    return s

N = int(input())
s = 0
for i in range(1, N):
  d = divisor(i)
  s += d
print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
for c in range(1, n):
    temp = n - c
    ls = []
    for a in range(1, int(temp/2) + 2):
        if (not a in ls) and temp % a == 0:
            ans += 2
            ls.append(a)
            ls.append(int(temp / a))
            if temp == a * a:
                ans -= 1
print(ans)

Submission status: Time Limit Exceeded

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

    for i in range(num-1):
        a_b = num - (i + 1)        
        
        lower_divisors , upper_divisors = [], []
        j = 1
        while j*j <= a_b:
            if a_b % j == 0:
                lower_divisors.append(j)
                if j != a_b // j:
                    upper_divisors.append(a_b//j)
            j += 1
        result = lower_divisors + upper_divisors[::-1]        
        
        count = count + len(result)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

answer = 0
for c in range(1, N):
    target = N - c
    count = 0
    for i in range(1, target+1):
        if target % i == 0:
            count += 1
    answer += count

print(answer)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
yakusu=[]
for c in range(1,N):
    for i in range(1,N-c+1):
        if (N-c)%i==0:
            yakusu.append(i)
print(len(yakusu))

Submission status: Time Limit Exceeded

Solution code:
import math

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):
    ab = n-c
    
    e = make_divisors(ab)
    ans += len(e)
        

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
z = 0
for a in range(N):
    d = math.floor(N/(a+1))
    e = min(a,d)
    for b in range(e):
        c = N - (a+1)*(b+1)
        if c > 0:
            z = z+2
        else:
            pass
    f = N - (a+1)*(a+1)
    if f > 0:
        z = z+1
    else:
        pass
print(z)

Submission status: Time Limit Exceeded

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

# floor_root_n = math.ceil(math.sqrt(n))
# # a<=bとしてかんがえる
# s = 0
# if not math.sqrt(n).is_integer():
#     for i in range(1, floor_root_n+1):
#         print(i)
#         s += 2*(floor_root_n-i+1)
# else:
#     for i in range(1, floor_root_n):
#         print(i)
#         s += 2*(floor_root_n-i)+1
# print(s)
s = 0
a = 1
b = 1
while a*b < n:
    while a*b < n:
        b += 1
        s += 1
    a += 1
    b = 1
print(s)

Submission status: Time Limit Exceeded

Solution code:
import os,sys

count=0
n=int(input())
for c in range(1,n+1):
    i=n+1-c
    for a in range(1,i):
        for b in range(1,i):
            if a*b+c==n:
                count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

d = 0
C = 0 # SUM

for j in range(1,N):
    d = 0 
    divisors = []
    for i in range(1, int(j**0.5)+1):
        if j % i == 0:
            divisors.append(i)
            if i != j // i:
                divisors.append(j//i)
           
    #d= len(set(divisors))
    C = C + len(set(divisors))
print(C)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 0
for a in range(1,n):
    for b in range(1,n):
        c = n-a*b
        if c > 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
import math
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
    
def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a

total = 0

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

Submission status: Time Limit Exceeded

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

for i in range(N):
  x = N - (i + 1)
  for i in range(1,x+1):
    d=x%i
    if d==0:
      num+=1
print(num)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
cnt = 0 
for a in range(1,N):
    for b in range(a,N):
        if N - a * b > 0:
            if a == b:
                cnt += 1
            else:
                cnt += 2
print(cnt)

Submission status: Time Limit Exceeded

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

def make_divisors(n):
    add = 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            add += 1
            if i != n // i:
                add += 1
        i += 1
    return add

for i in range(1,int(n//2)+1):
    if i != n-i:
        ans += make_divisors(i)
        ans += make_divisors(n-i)
    if i == n-i:
        ans += make_divisors(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
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]

n=int(input())
c=0
ans=0
for i in range(n-1):
  c=i+1
  div_list=make_divisors(n-c)
  ans+=len(div_list)
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":

    n = int(input())
    result = 0

    for a in range(1,n):
        for b in reversed(range(1,n)):
            if a > b:
                continue
            if a * b > n:
                continue

            if  n - a * b > 0:
                if a == b:
                    result = result + 1
                    break
                else:
                    result = result + 2
        else:
            continue

    print(result)

Submission status: Time Limit Exceeded

Solution code:
valmax = int(input()) 

cnt = 0
for A in range(1,valmax):
    for B in range(1,valmax):
        if A*B >= valmax:
            break
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
#import numpy
#import sympy
import math
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 divi(n):
    ans = {1}
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            ans |= l[i]
            ans |= l[n//i]
    ans.add(n)
    return ans

n = N()
cnt = 1
l = [{} for _ in range(n)]
l[1] = {1}
for i in range(2,n):
    #l[i] = make_divisors(i)
    l[i] = divi(i)
    cnt += len(l[i])

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
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]
  
for i in range(1, n):
  ans += len(make_divisors(i))

print(ans)

Submission status: Time Limit Exceeded

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

    return arr

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

for i in range(N):
    if i == 0:
        continue
    c = factorization(i)
    num = len(c)
    f = 1
    for j in range(len(c)):
        F = c[j] 
        f *= (F[1] + 1)
    ans += f

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#C

# 与えられた数字までの数字の約数をカウントする。
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]

N = int(input())
counter = 0
for i in range(1,N):
  counter += len(make_divisors(i))

print(counter)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
cnt = 0
d = n

for i in range(1, n):
    d -= 1
    for k in range(1,d+1):
        if((d % k) == 0 and (k != d/k)):
            cnt += 1
        if((d % k) == 0 and (k == d/k)):
            cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0

for a in range(1,N):
    if a == 1:
        ans += (N-1)
    else:
        d = N//a
        if d == 1:
           ans += 1
        else:
            for b in range(1,d+1):
                c = N-a*b
                if c > 0:
                    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
  n = int(input())
  count = 0
  for c in range(1, n):
    for i in range(1, n-c+1):
        if (n-c)%i == 0:
            count += 1
  print(count)
main()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

input_ = sys.stdin.readline

# 整数1個だけ
N = int(input_().strip())

sum_ = 0


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


for c in range(1, N):
    pair = 1
    ab = N - c
    if ab == 1:
        sum_ += 1
        continue
    factors = factorization(ab)
    for f in factors:
        pair *= (f[1] + 1)
    sum_ += pair

print(sum_)

Submission status: Time Limit Exceeded

Solution code:
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(make_divisors(i))


print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import chain, cycle, accumulate
def factors(n):
    def prime_powers(n):
        # c goes through 2, 3, 5, then the infinite (6n+1, 6n+5) series
        for c in accumulate(chain([2, 1, 2], cycle([2, 4]))):
            if c * c > n: break
            if n % c: continue
            d, p = (), c
            while not n % c:
                n, p, d = n // c, p * c, d + (p,)
            yield (d)
        if n > 1: yield ((n,))

    r = [1]
    for e in prime_powers(n):
        r += [a * b for a in r for b in e]
    return r

N = int(input())
counter = 0
for i in range(1,N):
    checker = N - i
    counter += len(factors(checker))
print(counter)

Submission status: Time Limit Exceeded

Solution code:


N = int(input())

from itertools import chain, cycle, accumulate  # last of which is Python 3 only


def factors(n):
    def prime_powers(n):
        # c goes through 2, 3, 5, then the infinite (6n+1, 6n+5) series
        for c in accumulate(chain([2, 1, 2], cycle([2, 4]))):
            if c * c > n: break
            if n % c: continue
            d, p = (), c
            while not n % c:
                n, p, d = n // c, p * c, d + (p,)
            yield (d)
        if n > 1: yield ((n,))

    r = [1]
    for e in prime_powers(n):
        r += [a * b for a in r for b in e]
    return len(r)

ans = 0
for i in range(N):
    temp = factors(i)
    ans += temp
print(ans-1)