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:
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())
      
siki = 0

for i in range(N):
  siki = siki + (i+1)*len(make_divisors(i+1))

print(siki)

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()


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]

from collections import deque  #listよりdequeの方が両端へのアクセスは計算量が少ない
def main():
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        l = len(make_divisors(i))
        ans += i * l 
    print(ans)    

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def make_divisors(n):
    lower_divisors , upper_divisors = 0, 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors += 1
            if i != n // i:
                upper_divisors += 1
        i += 1
    return lower_divisors + upper_divisors
n = int(input())
ans = 0
for i in range(1,n+1):
  ans += i * 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())

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
dp = [0]*(n+1)
for i in range(2,n+1):
    j = 2
    while 1:
        if i*j <= n:
            dp[i*j] += 1
        else:
            break
        j += 1
ans = 0
for i in range(2,n+1):
    ans += i*dp[i]
print(ans+n*(n+1)-1)

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

def main():
  a=int(input())
  total=0
  for i in range(1,a+1):
    div=search_divisor_num_1(i)
    total+=i*div
  print(total)

main()

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 

n=int(input())
dp=[]
for i in range(1,n+1):
	dp.append(countDivisors(i))
ans=0
for i in range(len(dp)):
	ans+=(dp[i]*(i+1))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

total = 0
for i in range(1, N + 1):
    N_max = N // i * i
    num = N // i
    total += (N_max + i) * (num // 2)
    if num%2:
        total += (N_max + i) // 2
print(total)

Submission status: Time Limit Exceeded

Solution code:
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    print(sum([((i + 1) * len(factors(i + 1))) for i in range(n)]))
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1],1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

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


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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#ABC172D
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(N):
    ans = ans + (i+1) * len(make_divisors(i+1))
print(ans)

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

sum_ = 0

for i in range(1, n + 1):
    
    # print('i')
    # print(i)
    
    # 約数を求める
    f_x = 0
    for j in range(1, i + 1):

        # print('j')
        # print(j)

        if i % j == 0:
            f_x = f_x + 1

    # print('f_x')
    # print(f_x)

    sum_ = sum_ + (i * f_x)

print(sum_)

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
ans=0
dans=0
for j in range(a+1):
    for i in range(j):
        x = len([i for i in range(1,j+1) if not j % i])
        dans=x
    ans=ans+(j*dans)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
sum = 0
for i in range(1,n+1):
  m = int(n / i)
  add = int(i * m * (m+1) / 2)
  #print(add)
  sum += add
print(sum)

Submission status: Time Limit Exceeded

Solution code:
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return len(table)
  
  
a = int(input())
sum = 0

for i in range(1,a+1):
  sum += i*divisor(i)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
def divisors(n):
    count = 0
    upper_divisors = []
    i = 1
    while i*i <= n:
        if n % i == 0:
            count += 1
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return len(upper_divisors[::-1]) + count

n = int(input())

total = 0
for i in range(1,n+1):
    count = divisors(i)
    total += i * count
print(total)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


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)

def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        l = make_divisors(i)
        ans += l * i

    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())

ans = 0
for i in range(1,a+1):
    yakusu = 0
    for j in range(1,i+1):
        if i % j == 0:
            yakusu += 1
    ans += i * yakusu

print(ans)

Submission status: Time Limit Exceeded

Solution code:

def gcd(a, b):
    while b: a, b = b, a % b
    return a


def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1 << 32 else [2, 3, 5, 7, 11, 13, 17] if n < 1 << 48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
                                                                                     31, 37]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = y * y % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1


def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g):
                return g
            elif isPrimeMR(n // g):
                return n // g
            return findFactorRho(g)


def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

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


def f(n):
    A = primeFactor(n)
    ret = n
    for key, value in A:
        ret *= (value+1)
    return ret


N = int(input())
DP = [0] * (N+1)
ans = 1
DP[1] = 1
for i in range(2, N+1):
    A = primeFactor(i)
    a = 1
    if len(A) == 1:
        for key, value in A.items():
            a = i * (value+1)
    else:
        for key, value in A.items():
            a *= DP[key**value]
    DP[i] = a
    ans += a


print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**6)
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]

res = 0
for i in range(1,N+1):
    res +=i*len(make_divisors(i))

print(res)

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+1):
    ans += i*len(make_divisors(i))

# ans = sum(B)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math as mt

MAXN = 10000001

# stores smallest prime factor for
# every number
spf = [0 for i in range(MAXN)]


# Calculating SPF (Smallest Prime Factor)
# for every number till MAXN.
# Time Complexity : O(nloglogn)
def sieve():
    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()
    while (x != 1):
        ret.append(spf[x])
        x = x // spf[x]

    return ret
sieve()
n = int(input())
ans = 0
for i in range(1,n+1):
    p = getFactorization(i)
    st = set(p)
    cnt = 1
    for j in st:
        cnt *= (p.count(j)+1)
    ans += i*cnt
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def make_divisors(n):
    cnt=0

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

n=int(input())
ans=0

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

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 divisors
N = int(input())
ans = 0
for i in range(0, N+1):
  F = make_divisors(i)
  ans += i * len(F)
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(1,n+1,1):
  count=0
  for j in range(1,i+1):
    if i%j==0:
      count+=1
  sum=sum+i*count
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n=int(input(''))
b=[]
for a in range(n+1):
    b.append(0)

for a in range(1,n+1):
    c=0
    while(1):
        if a+a*c<=n:
            b[a+a*c]+=1
            c+=1
        else:
            break

s=0
for a in range(n+1):
    s=s+b[a]*a
    
print(s)

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+1):
    ans+=i*len(make_divisors(i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
G = functools.partial(functools.reduce, operator.mul)
N=int(input())
ans=0
for i in range(1,N+1):
  f=[1]
  p=i
  for k in range(2,int((i+1)**(1/2))+1):
    anssub=1
    while i%k==0:
      anssub+=1
      i=i//k
    f+=[anssub]
    if i==1:
      break
  if i!=1:
    f+=[2]
  ans+=p*G(f)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ksum = 1
for i in range(2,n+1):
  divs = 0
  for j in range(1,int(i**0.5)+1):
    if i%j==0:
      divs += 2
  if i%(i**0.5)==0:
    divs -= 1
  ksum += i*divs
print(ksum)

Submission status: Time Limit Exceeded

Solution code:
import math
def yakusuu(a) :
  b=int(math.sqrt(a))+1
  b_set=set()
  for i in range(1,b+1) :
    if a%i==0 :
      b_set.add(i)
      b_set.add(a//i)
  return (len(b_set))
a = int(input())
count = 0
for i in range(1, a + 1):
  k = yakusuu(i)
  count += k * i

print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
#sys.stdin=open('input.txt','r')
#sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
MAX=10000005
divisor = [0]*(MAX)
def sieve():
    for i in range(1, MAX):
        for j in range(i, MAX, i):
            divisor[j]+=1
if __name__ == '__main__':

    sieve()
    for i in range(1,MAX):
        divisor[i]=i*divisor[i]
    for i in range(1,MAX):
        divisor[i]+=divisor[i-1]
    print(divisor[0:10])
    n=ii1()
    print(divisor[n])

Submission status: Time Limit Exceeded

Solution code:
import sys
import math as mt
input=sys.stdin.buffer.readline  

MAXN = 10000001
# stores smallest prime factor for 
# every number 
spf = [0 for i in range(MAXN)] 
  
# Calculating SPF (Smallest Prime Factor)  
# for every number till MAXN. 
# Time Complexity : O(nloglogn) 
def sieve(): 
    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 
 
  
def getFactorization(x): 
    d={}
    while (x != 1): 
        d[spf[x]]=d.get(spf[x],0)+1
        x = x//spf[x] 
    mul=1
    #print(d)
    for i1 in d:
        mul*=(d[i1]+1)
    #print(11,x,mul)
    return mul    
sieve()
t=1
#t=int(input())
for _ in range(t):
    n=int(input())
    #n,m,k=map(int,input().split())
    #l1=list(map(int,input().split()))
    #l2=list(map(int,input().split()))
    ans=1
    for i in range(2,n+1):
        ans+=(i*getFactorization(i))
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def dividor(K):
    X = [0]*K
    num = K
    for i in range(2,num+1):
        while(num%i == 0):
            X[i-1] +=1
            num = num // i
    ans = 1
    for i in range(1,K):
        ans = ans * (X[i] + 1)
    return ans
sum = 1
for i in range(2,N+1):
    sum += i * dividor(i)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())

d = np.ones(n)
ii = np.arange(1, n+1)

for i in range(2, n+1):
    k = 1
    while i*k <= n:
        d[i*k-1] += 1
        k += 1

# ans = 0
# for i in range(n):
#     ans += (i+1)*d[i]

print(int(sum(d*ii)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

dp = [1] * (N + 1)
ans = 1
for i in range(2, N + 1):
    for j in range(i, N + 1, i):
        dp[j] += 1
    ans += i * dp[i]
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

def s(n):
  l = [0]*n
  ans = 0
  for i in range(n):
    for j in range(i,n,(i+1)):
      l[j] += 1
    ans += (i+1)*l[i]
  print(ans)
  
n = int(sys.stdin.readline().rstrip())
s(n)

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(0, N+1):
  F = make_divisors(i)
  ans += i * len(F)
print(ans)

Submission status: Time Limit Exceeded

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

N = int(input())
ans = 0
for i in range(1, N+1):
    til = N//i
    divsum = int(til*(til+1)/2)
    ans += divsum*i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import *
import sys
from bisect import *
input=sys.stdin.readline
from math import *
t=1
while(t):
    t-=1
    n=int(input())
    pre=[[i,{}] for i in range(n+1)]
    for i in range(2,n+1):
        if(pre[i][0]%i==0 and i!=1):
            pre[i][1][i]=1
            pre[i][0]=1
        for j in range(2*i,n+1,i):
            f=pre[j][0]
            c=0
            if(pre[j][0]==1):
                break
            while(f%i==0):
                f=f//i
                c+=1
            pre[j][0]=f
            pre[j][1][i]=c
    r=1
    #print(pre)
    for i in range(2,n+1):
        p=1
        for j in pre[i][1].keys():
            p=p*(pre[i][1][j]+1)
        r+=i*p
    print(r)

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

Submission status: Time Limit Exceeded

Solution code:

n=int(input())

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

sum=0
for i in range(1,n+1):
    sum+=i*num_divisors_table(n)[i]

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 
    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 prime_factorization_2(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1

        return dict_counter
      
def search_divisor_num_2(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        divisor_num = 1
        dict_fact = prime_factorization_2(num)
        for value in dict_fact.values():
            divisor_num *= (value + 1)
        return divisor_num
      
total = 0
n = int(input())
for i in range(1,n+1):
    z = i * search_divisor_num_2(i)
    total += z
    
print(total)

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)

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

main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())
dp = [0] * N

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=1
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

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

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

    return np.prod(arr)

ans = 1
for n in range(2, N+1):
  ans = ans + factorization(n)*n

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def divisorcount(n):
    an = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            an += 1
            if i != n // i:
                an += 1
    return an
ans = 0
for i in range(1, N+1):
    ans += i * divisorcount(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def euler(n):
        num = 0
        for i in range(1, n + 1):
                if n % i  == 0:
                        num += 1
        return num

n = int(input())
x = 0


for i in range(n):
        f = euler(i + 1)
        x += f * (i +1)

print(x)

Submission status: Time Limit Exceeded

Solution code:
#D

def div(N):
    divisor = []
    for j in range(1,int(N**0.5)+1):
            if N % j == 0:
                divisor.append(j)
                if j**2 != N:
                    divisor.append(N//j)
    #print(i,divisor)
    return len(divisor)
result = 0
K = int(input())
for i in range(K+1):
    result += i * div(i)
print(result)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import collections

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())
#N=10**7
#print(prime_factor(N,prime_factor_table(N)))
ans = 0
for i,d in enumerate(num_divisors_table(N)):
    ans += i*d
print(ans)
    #num_divisors_table(N)

Submission status: Time Limit Exceeded

Solution code:
def divisor(n):
    x = [0]*(n+1)
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            x[j]+=1
    for i in range(1,n+1):
        x[i]=x[i]*i
    return x
N = int(input())

print(sum(divisor(N)))