Problem:


Score : 400 points

Problem Statement

For a positive integer X, let f(X) be the number of positive divisors of X.

Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Constraints

1 \leq N \leq 10^7

Input

Input is given from Standard Input in the following format:

N

Output

Print the value \sum_{K=1}^N K\times f(K).

Sample Input 1

4

Sample Output 1

23

We have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\times 1 + 2\times 2 + 3\times 2 + 4\times 3 =23.

Sample Input 2

100

Sample Output 2

26879

Sample Input 3

10000000

Sample Output 3

838627288460105

Watch out for overflows.



Sample input:
4


Sample output:
23

Submission status: Time Limit Exceeded

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

ans = 0
for K in range(1, N+1):
    f = num_divisors_trial_division(K)
    ans += K*f
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
from itertools import accumulate

n = int(input())
d = deque()


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


ans = 0
for i in range(n+1):
    d.append(i * len(make_divisors(i)))
ans = accumulate(d)
print(list(ans)[-1])

Submission status: Time Limit Exceeded

Solution code:
def divCount(n): 

    # sieve method for 
    # prime calculation 
    hh = [1] * (n + 1); 

    p = 2; 
    while((p * p) < n): 
        if (hh[p] == 1): 
            for i in range((p * 2), n, p): 
                hh[i] = 0; 
        p += 1; 

    # Traversing through  
    # all prime numbers 
    total = 1; 
    for p in range(2, n + 1): 
        if (hh[p] == 1): 

            # calculate number of divisor 
            # with formula total div =  
            # (p1+1) * (p2+1) *.....* (pn+1) 
            # where n = (a1^p1)*(a2^p2)....  
            # *(an^pn) ai being prime divisor 
            # for n and pi are their respective  
            # power in factorization 
            count = 0; 
            if (n % p == 0): 
                while (n % p == 0): 
                    n = int(n / p); 
                    count += 1; 
                total *= (count + 1); 

    return total; 

# Driver Code 
a = int(input())
sum = 0
for i in range(1, a+1):
    sum += i*divCount(i)
print(sum)

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]
  
def main():
  n = int(input())
  div = make_divisors(n)
  sum = 0
  for i in range(1, n+1):
    sum = sum + i*len(make_divisors(i))

  print(sum)
  
main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
result = 0
for i in range(1, N+1):
    temp = 0
    for j in range(1, i+1):
        if i % j == 0:
            temp += 1
    result += temp * i
print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

nums = []
for n in range(1,N+1):
    nums.append(int(N/n))

sum = 0
ro = 1
for num in nums:
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

s=0

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

for i in range(n):
	num=make_divisors(i+1)
	s+=(i+1)*len(num)

print(s)

Submission status: Time Limit Exceeded

Solution code:

import math
from collections import defaultdict


def factorization(x, d):
    """
    素因数分解する
    かつ途中結果を利用して計算を効率よく行いたい

    fa(x) をxの素因数分解とする ; a^x * b^y * ...
    例えばxが2で割り切れるとすると、
    fa(x) = 2 * fa(x // 2) = ... = 2 * .... * fa(1)
    となるため、計算過程を覚えておいて、逆算することで
    xを試し割りする途中の値についても素因数分解をえる
    """
    if x == 1:
        # d[1]はすでに格納済みの想定
        return d

    calc = [(1, x)]
    found = False
    for t in range(2, math.floor(math.sqrt(x)) + 1):
        if found:
            break
        
        while x % t == 0:
            calc.append((t, x // t))
            x //= t
            if x in d:
                found = True
                break

    if not found and x > 1:
        calc.append((x, 1))

    while len(calc) > 1:
        c, b = calc.pop()
        y = c * b
        d[y] = d[b].copy()
        d[y][c] += 1
    return d


def divisors(fact):
    values = fact.values()
    ans = 1
    for v in values:
        ans *= (v + 1)
    return ans


def submit():
    n = int(input())
    d = {1: defaultdict(int)}

    ans = 0
    while n > 1:
        if n not in d:
            d = factorization(n, d)
        
        ans += n * divisors(d[n])
        n -= 1
    print(ans + 1)


if __name__ == "__main__":
    submit()

Submission status: Time Limit Exceeded

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


def _main(N):
    print(_num_table(N))


if __name__ == "__main__":
    N = int(input())
    _main(N)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = 0
def f(x):
    divisors = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            divisors.append(i)
            if i != x // i:
                divisors.append(x//i)
    return len(divisors)*x

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

print(a)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
sum =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+1):
    sum +=  i*len(make_divisors(i))
print(sum)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  counter = Counter(table)
  yaku = 1
  for key, value in counter.items():
    yaku *= (value + 1)
  return yaku

#print(prime_decomposition(4))

from sys import stdin
m = int(stdin.readline().rstrip())

kei = 0
for i in range(m):
  kei += (i+1) * prime_decomposition(i + 1)
print(kei)

Submission status: Time Limit Exceeded

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 len(lower_divisors + upper_divisors[::-1])
sumi=0
for i in range(1,n+1):
    sumi+=i*make_divisors(i)
print(sumi)

Submission status: Time Limit Exceeded

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*n

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

Submission status: Time Limit Exceeded

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

def countdiv(n):
    i=1
    count = 0
    while i<=math.sqrt(n):
        if n%i==0:
            if n/i==i:
                count+=1
            else:
                count+=2
        i+=1
    return count

dp = [0]*int(1e7+1)
n=int(input())
Sum = 0
for i in range(1,n+1):
    val = countdiv(i)
    Sum+=i*val
print(Sum)

Submission status: Time Limit Exceeded

Solution code:
# Python3 program to count distinct  
# divisors of a given number n 
  
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 casse 
    elif (n != 1): 
        ans = ans * 4
  
    return ans # Total divisors 
  
  
# This code is contributed 
# by mits 
N = int(input())

ans = 0
for i in range(1, N+1):
  ans += i*countDivisors(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def fac(n):
    arr = []
    temp = n
    a = 1
    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])
    
    for i in arr:
        a = a * (i[1] + 1)
    return a * n


ans = 0
for i in range(1, n+1):
    ans += fac(i)
print(ans - 1)

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 divisors
total=0
for k in range(N+1):
    f=len(make_divisors(k))
    total+=k*f
print(total)

Submission status: Time Limit Exceeded

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

for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        fx[j] += 1

l = [i * x for i, x in enumerate(fx)]
print(sum(l))

Submission status: Time Limit Exceeded

Solution code:
def countDivisors(num):
    ans = 1
    x = 2
    while x * x <= num:
        cnt = 1
        while num % x == 0:
            cnt += 1
            num /= x
        ans *= cnt
        x += 1
    return ans * (1 + (num > 1))




if __name__ == "__main__":
    N = int(input())
    res = 0
    for k in range(1,N+1):
        res += k*countDivisors(k)
    print(res)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c=0
for i in range(1,n+1):
  d=0
  for j in range(1,i+1):
    if i%j==0:
      d+=1
  c+=d*i
print(c)

Submission status: Time Limit Exceeded

Solution code:
k = int(input().rstrip())

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)


ans = 0
for i in range(1, k+1):
    ans += make_divisors(i) * i

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [0] * 1000
ppp = 0
for i in range(1, 1000):
  while n % i == 0:
    n //= i
    s[i] += 1
    
for j in range(1, 1000):
  ppp += j * s[j]
  
print(ppp)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def print_factors(x):
    j = 0
    for i in range(1, x + 1):
       if x % i == 0:
           j += 1
    return j

o = 0
for i in range(1, n + 1):
    o += i * print_factors(i)
print(o)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

sum = 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 len(lower_divisors + upper_divisors[::-1])


for i in range(1,n + 1):
    sum += i * make_divisors(i)

print(sum)

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)

N=int(input())
kei=0
for K in range(N):
    kei=kei+(K+1)*make_divisors(K+1)

print(kei)

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]

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

    total = 0

    for n in range(1, N+1):
        total += n * len(make_divisors(n))
    
    print(total)




if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()

import numpy as np

c = np.array(range(1,n+1), dtype=np.uint64)
nn = np.array([n] * n)
d = nn//c

e = d * (d+1) //2 * c

# print(e)
print(int(sum(e)))

Submission status: Time Limit Exceeded

Solution code:
#n=int(input())
n=10**7
A=[1]*(n+1)
A[1]=1
for i in range(2,n+1):
    for j in range(i,n+1,i):
        A[j]+=1
A[1]=1
sum=0
for i in range(1,n+1):
    sum+=i*A[i]
print(sum)

Submission status: Time Limit Exceeded

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

n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += (i * count_divisors(i))

print(ans)

Submission status: Time Limit Exceeded

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]

ans=0
for i in range(n+1):
  ans+=i*len(make_divisors(i))

print(ans)

Submission status: Time Limit Exceeded

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

S = 0
c = num_divisors_table(N)
for i in range(N):
    S += c[i+1]*(i+1)

print(S)

Submission status: Time Limit Exceeded

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]
result = 0

for i in range(1,N+1):
	tmp = len(make_divisors(i))
	result +=i*tmp
print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

answer = [0 for i in range(0, n+1)]
answer[1] = 1

small_factors = [1]
p = 1
while (p < n):
    p = p + 1
    if answer[p] is 0:
        #print("\n\nPrime: " + str(p))
        limit = n / p
        new_small_factors = []
        for i in small_factors:
            j = i
            while j <= limit:
                new_small_factors.append(j)
                answer[j * p] = answer[j] + answer[i]
                j = j * p
        small_factors = new_small_factors
ans = 0;
for i,k in enumerate(answer):
    if k==None:
        continue
    ans+=((i)*(k))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
"""
ai             aj
bi             bj


1              2
2              1

1  how many pairs 
2
"""



import collections
n = int(raw_input())
mem = {1: 1}
primes = [True] * (n + 1)
posprimes = []
for d in range(2, n +1):
	if primes[d] is True:
		posprimes.append(d)
		k = 2
		while(k * d <= n):
			primes[k * d] = False
			k += 1

def f(k):
	if primes[k] is True:
		mem[k] = 2 if k > 1 else 1
		return mem[k]
	for pos in posprimes:
		if k % pos == 0:
			count = 0
			q = k
			while(q % pos == 0):
				q /= pos
				count += 1

			mem[k] = (count + 1) * mem[q]
			return mem[k]



s = 0
k = 1
while (k<= n):
	s += k * f(k)
	k += 1
print s




#2 4 6 8 10 12 14 16 18
#    6      12       18

Submission status: Time Limit Exceeded

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

N = int(input())
ans = 0
for i in range(1, N+1):
    ans += i * divisors_count(i)
print(ans)

Submission status: Time Limit Exceeded

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]

ans=0
for i in range(n+1):
    ans+=i*len(make_divisors(i))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main(x):
  A = []
  for i in range(1, x+1):
    if x % i == 0:
      A.append(i)
  B = len(A)
  return B



N = int(input())
Sum = 0
for i in range(1, N+1):
  Sum += i * main(i)
ans = Sum
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import collections
import math as mt 

MAXN=10**7+1
spf = [0 for i in range(MAXN)] 
# Calculating SPF (Smallest Prime Factor) 
# for every number till MAXN. 
# Time Complexity : O(nloglogn) 
def sieve(MAXN): 

# stores smallest prime factor for 
# every number 
	
	spf[1] = 1
	for i in range(2, MAXN): 
		
		# marking smallest prime factor 
		# for every number to be itself. 
		spf[i] = i 

	# separately marking spf for 
	# every even number as 2 
	for i in range(4, MAXN, 2): 
		spf[i] = 2

	for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
		
		# checking if i is prime 
		if (spf[i] == i): 
			
			# marking SPF for all numbers 
			# divisible by i 
			for j in range(i * i, MAXN, i): 
				
				# marking spf[j] if it is 
				# not previously marked 
				if (spf[j] == j): 
					spf[j] = i 

# A O(log n) function returning prime 
# factorization by dividing by smallest 
# prime factor at every step 
def getFactorization(x): 
	ret = list() 
	ans=collections.defaultdict(int)
	while (x != 1): 
		#ret.append(spf[x])
		ans[spf[x]]+=1  
		x = x // spf[x] 
	pro=1
	for x in ans:
		pro=pro*(ans[x]+1)

	return pro 

# Driver code 

# precalculating Smallest Prime Factor 

n=int(input())
sieve(n+1) 
ans=0 
for x in range(1,n+1):
	p = getFactorization(x) 
	ans=ans+(x*p)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
a=int(input())
b=list(i+1 for i in range(a))
www=0
for j in b:
  ans=0
  c=[x+1 for x in range(int(math.sqrt(j)//1))]
  for y in c:
    if j%y==0:
      if not j/y==y:
        ans+=2
      else:
        ans+=1
  www+=ans*j
print(www)

Submission status: Time Limit Exceeded

Solution code:
def yakusuu(x):
    p = 0
    for i in range (1,x+1):
        if x%i == 0:
            p = p+1
    return p
a = int(input())
c = 0
for i in range (0,a+1):
    b = yakusuu(i)
    c = c + i * b
print(c)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def 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
    
ans = 0
for k in range(1, N+1):
    ans += k*divisors(k)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
su = 0
for i in range(1,n+1):
  a = i
  l = (n//i)*i
  m = (n//i)/2
  su += m*(a+l)
print(int(su))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
sum = 0
for i in range(1, n+1):
  a = np.array([j for j in range(1, i+1) if i%j==0])
  sum += i*len(a)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

output = 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]
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

for i in range(N + 1):
    count = search_divisor_num_1(i)
    output += i * count


print(output)

Submission status: Time Limit Exceeded

Solution code:
from numba import njit
import numpy as np


@njit("i8(i8)")
def solve(n):
    ans = 1
    res = np.ones(n + 1, dtype=np.int64)
    for i in range(2, n + 1):
        res[i::i] += 1
        res[i] *= i
        ans += res[i]
    return ans


N = int(input())
print(solve(N))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
c = 1
for i in range(N):
  cnt = 0
  cc = 1
  for a in range(i + 1):
    if c % cc == 0:
      cnt += 1
    cc += 1
  ans += cnt * (i + 1)
  c += 1
  
print(ans)

Submission status: Time Limit Exceeded

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


n = int(input())
ans = 0
div_list = num_divisors_table(n)

for i in range(1, n+1):
    ans += i * div_list[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
ans = 0
N = int(input())
for j in range(N):
    num = 0
    for i in range(1, int(math.sqrt(j+1) + 1e-9) + 1):
        if (j+1) % i == 0:
            num += 1
            if (j+1) != i**2:
                num += 1
    ans += (j+1) * num
print(ans)

Submission status: Time Limit Exceeded

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())
sum = 0
t = num_divisors_table(n)
for i in range(1, n + 1):
    # sum += i * sympy.divisor_count(i)
    sum += i * t[i]

print(sum)

Submission status: Time Limit Exceeded

Solution code:
m = int(input())

ans = 0

for n in range(1 , m+1):
    cnt = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            cnt += 1
            if i != n // i:
                cnt += 1
    ans += n*cnt

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

def k(n):
    s=1
    arr = factorization(n)
    for i in range(len(arr)):
        s *= (arr[i][1] + 1)
    return s

def main():
    n = int(input())
    s = 0
    
    #print(arr)
    for i in range(2,n+1):
        s += i * k(i)
    s += 1
    print(s)
main()

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
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

n = int(input())
ans = 0
for i in range(n):
    tmp = make_divisors(i + 1)
    ans = ans + (1 + i) * len(tmp)
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(cnt)

    if temp!=1:
        arr.append(1)

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

    return arr

if __name__ == '__main__':
    n = int(input())
    sum = 1
    for i in range(2, n+1):
        cum = 1
        for j in factorization(i):
            cum *= (j + 1)
        sum += i*cum
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
    
def f(x, result):
    if x == 1:
        return 1
    while True:
        if x % 2 == 0:
            qcnt = 0
            while True:
                x = x // 2
                qcnt += 1
                if x % 2 != 0:
                    break
            return result[x] * (qcnt + 1)
        else:
            break
    
    while True:
        if x == 1:
            break
        else:
            p = 3
            while True:
                if x % p == 0:
                    pcnt = 0
                    while True:
                        x = x // p
                        pcnt += 1
                        if x % p != 0:
                            break
                    return result[x] * (pcnt + 1)
                else:
                    p += 2
    y = 1
    for i in yakusu.values():
        y *= (i+1)
    return y
    

s = 0
result = {1:1}
for i in range(1,n+1):
    result[i] = f(i, result)
    s += i * f(i,result)
    

print(s)

Submission status: Time Limit Exceeded

Solution code:
import math
def countDivisors(n):
    cnt = 0
    for i in range(1, (int)(math.sqrt(n)) + 1):
        if (n % i == 0):

            # If divisors are equal,
            # count only one
            if (n / i == i):
                cnt = cnt + 1
            else:  # Otherwise count both
                cnt = cnt + 2
    return cnt

    return cnt
n = int(input())
j = 1
sum =0
for i in range(1,n+1):
    a = countDivisors(i)
    sum += a *j
    j+=1
print(sum)

Submission status: Time Limit Exceeded

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

n=int(input())
s=0
for i in range(1,n+1):
    s+=make_divisors(i)*i
print(s)

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    def yaku(n):
        kazu=0
        i=1
        while i*i <=n:
            if n%i ==0:
                kazu+=2
                if i**2==n:
                    kazu-=1
            i+=1
        return kazu
    answer=0
    for j in range(N):
        answer+=(j+1)*yaku(j+1)
    print(answer)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
rs=1
l=[]
for i in range(n+2):
    l.append(0)
for i in range(2,n+1):
    for j in range(i+i,n+1,i):
        l[j]+=1
for i in range(2,n+1):
    rs+=((l[i]+2)*i)
print(rs)