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

def is_prime(n):
  if n == 1: return False
  for k in range(2, int(math.sqrt(n))+ 1):
    if n%k == 0:
      return False
  return True

def make_divisors(n):
    if is_prime(n):
      return 2
    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 = 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:

import collections

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

def prime_factor(n, prime_factor_table):
    prime_count = collections.defaultdict(int)
    
    while prime_factor_table[n] != 0:
        prime_count[prime_factor_table[n]] += 1
        n = n // prime_factor_table[n]
    
    if n > 1:
        prime_count[n] += 1
    
    return prime_count

def num_divisors(prime_count):
    num = 1
    
    for prime, count in prime_count.items():
        num *= (count + 1)
    
    return num

N = int(input())
LIMIT = 10**7+10
LIMIT = N+1
table = prime_factor_table(LIMIT)

maximum = 0
count = 0
ans = 0
for i in range(1, LIMIT):
    num = num_divisors(prime_factor(i, table))
    ans += i * num
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def devv(n):
	i=1
	count=0
	while i<=n:
		if n%i==0:
			count=count+1
		i=i+1
	return count

t=int(input())
j=1
Sum=0
while j<=t:
	Sum=Sum+(j*devv(j))
	j=j+1
print(Sum)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    N = int(input())
    primes = [2]

    for i in range(3, int(N ** (0.5))+1):
        done = False
        for k in primes:
            if not i % k:
                done = True
                break
        if not done:
            primes.append(i)
    #print(primes)

    ret = 1# f(1) = 1

    for i in range(2, N+1):
        current = i
        dic = defaultdict(lambda:(0))
        eval_max = int(i ** (0.5))
        for p in primes:
            if p > eval_max:
                break
            while True:
                if not current % p:
                    current = current // p
                    dic[p] += 1
                else:break
        if current != 1:
            dic[current] += 1
        tmp = 1
        for key in dic.keys():
            tmp *= dic[key] + 1
        #print(dic, tmp)
        ret += tmp * i

    print(ret)


if __name__ == "__main__":
    run()

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(2, N + 1):
    arr = factorization(i)
    divisor = 1
    for j in arr:
        divisor *= j[1] + 1
#    print(i, divisor)
    ans += i * divisor
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

total = 0
for i in range(1,N+1):
    total += i*prime(i)
print(total)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def yakusu(value):
  test = 0
  for val in range(1, value + 1, 1):
    if value % val == 0:
      test += 1
  return test

answer = sum([i * yakusu(i) for i in range(1, N + 1, 1)])
print(answer)

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]

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n=int(input())
s=time.time()
factors=defaultdict(lambda:[])
for i in range(2,3300):
    if(i not in factors):
        for j in range(i,10000001,i):
            factors[j].append(i)
ans=1
# print(factors)
# print(time.time()-s)
for i in range(2,n+1):
    tt=1
    tn=i
    for j in factors[i]:
        temp=0
        while(tn%j==0):
            temp+=1
            tn=tn//j
        tt*=(temp+1)
    if(tn!=1):
        tt*=2
    ans+=i*tt
print(ans)
# print(time.time()-s)

Submission status: Time Limit Exceeded

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

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

    if temp!=1:
        arr.append([temp, 1])

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

    return arr

ans=1
for i in range(2,N+1):
    L=factorization(i)
    fi=1
    for x,y in L:
        fi*=(y+1)
    ans+=i*fi
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]




result = 0
for tmp in range(1, n + 1):
    result += tmp * len(make_divisors(tmp))

print(result)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

n = inp()
if n == 1:
    print(1)
    quit()
cnt = 1
res = 1
ans = [-1] * (n+1)
ans[1] = 1 
pl = get_sieve_of_eratosthenes(n)
for x in pl:
    # print(x)
    cnt += 1
    ans[x] = 2
    res += 2*x
    c = 2
    while pow(x,c) <= n:
        now = pow(x,c)
        if ans[now] == -1:
            ans[now] = c+1
            res += now*(c+1)
            cnt += 1
        c += 1
# print(ans)
while cnt < n:
    for i in range(2,n+1):
        for j in range(i+1,n+1):
            if i * j > n: break
            if math.gcd(i,j) != 1 or ans[i*j] != -1: continue
            if ans[j] == -1: continue
            ans[i*j] = ans[i] * ans[j]
            res += (i*j) * ans[i*j]
            cnt += 1
# print(ans)
# for i in range(1,n+1):
#     res += ans[i] * i
#     if ans[i] < -1:
#         print(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())
li=[]
f=[len(make_divisors(i)) for i in range(1,n+1)]
for i in range(1,n+1):
    li.append(i*f[i-1])
print(sum(li))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = 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 j in range(1,n+1):
    a += j * make_divisors(j)
print(a)

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
li=[i for i in range(1,N+1)]
for i in range(1,N+1):
  ans+=divisor_num(i)*i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def keisan(count):
    count1 = 0
    for i in range(1,int(count/2) + 1):
        if count % i == 0:
            count1 += 1
    return count1+1

if __name__=="__main__":
    list = int(input())
    sum=0

    for i in range(1,list+1):

        sum=sum+ i * keisan(i)

    print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

count = 0
for i in range(n):
    sho = n//(i+1)
    sumA = (i+1)*(n//(i+1)+1)*(n//(i+1))//2
    count+=sumA
print(count)

Submission status: Time Limit Exceeded

Solution code:

def func_div(num):
    cnt = 0
    for div in range(1, int(num/2 + 1)):
        if num % div == 0:
            cnt += 1

    return cnt+1

N = int(input())

res = 0
for i in range(1, N+1):
    res += (i * func_div(i))
    
print(res)

Submission status: Time Limit Exceeded

Solution code:
def YakuNum(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())
sum = 0
for K in range(1,N+1):
  sum += K * YakuNum(K)
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
def divisors(num):
    ans = 0
    for i in range(1,num+1):
        if num%i == 0:
            ans += 1
    return ans    
        
t = int(input())
ans = 0
for i in range(1,t+1):
    ans = ans + i * 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())
ans = 0
for i in range(1,n+1,1):
    ans += i*len(make_divisors(i))


print(ans)

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(1, N+1):
    ans += i * search_divisor_num_1(i)

print(ans)

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

for i in range(n+1):
  sum += i * search_divisor_num_1(i)
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

###素因数分解高速###
NN = 10 ** 7 + 10
primes = []
isprime = [True for _ in range(NN + 1)]
min_factor = [-1 for _ in range(NN + 1)]
memo = [[[], []] for _ in range(NN + 1)]
ans_arr = [0 for _ in range(NN + 1)]
#エラトステネスの篩
for i in range(2, NN + 1):
    if isprime[i]:
        primes.append(i)
        min_factor[i] = i
        for j in range(i * 2, NN + 1, i):
            isprime[j] = False
            if min_factor[j] == -1:
                min_factor[j] = i
    
    m = i // min_factor[i]
    res = [[j for j in i] for i in memo[m]]
    if min_factor[i] in res[0]:
        res[1][res[0].index(min_factor[i])] += 1
    else:
        res[0].append(min_factor[i])
        res[1].append(1)
    memo[i] = res
    
    tmp = 1
    for j in res[1]:
        tmp *= j + 1
    ans_arr[i] = tmp * i

#print(memo)

#print(ans_arr)

n = INT()

ans = 1 + sum(ans_arr[:n + 1])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math as mt 
import collections
N = int(raw_input())
MAX_SIZE = N+1
  
# stores smallest prime factor for 
# every number 
# Python3 program to generate all 
# prime numbers less than N in O(N) 


# isPrime[] : isPrime[i] is true if 
#			 number is prime 
# prime[] : stores all prime number 
#		 less than N 
# SPF[] that store smallest prime 
# factor of number [for ex : smallest 
# prime factor of '8' and '16' 
# is '2' so we put SPF[8] = 2 , 
# SPF[16] = 2 ] 
isprime = [True] * MAX_SIZE 
prime = [] 
SPF = [None] * (MAX_SIZE) 

# function generate all prime number 
# less then N in O(n) 
def manipulated_seive(N): 

	# 0 and 1 are not prime 
	isprime[0] = isprime[1] = False

	# Fill rest of the entries 
	for i in range(2, N): 
	
		# If isPrime[i] == True then i is 
		# prime number 
		if isprime[i] == True: 
		
			# put i into prime[] vector 
			prime.append(i) 

			# A prime number is its own smallest 
			# prime factor 
			SPF[i] = i 
		
		# Remove all multiples of i*prime[j] 
		# which are not prime by making is 
		# Prime[i * prime[j]] = false and put 
		# smallest prime factor of i*Prime[j] 
		# as prime[j] [ for exp :let i = 5 , j = 0 , 
		# prime[j] = 2 [ i*prime[j] = 10 ] 
		# so smallest prime factor of '10' is '2' 
		# that is prime[j] ] this loop run only one 
		# time for number which are not prime 
		j = 0
		while (j < len(prime) and
			i * prime[j] < N and
				prime[j] <= SPF[i]): 
		
			isprime[i * prime[j]] = False

			# put smallest prime factor of i*prime[j] 
			SPF[i * prime[j]] = prime[j] 
			
			j += 1
		

# A O(log n) function returning prime  
# factorization by dividing by smallest  
# prime factor at every step 
def getFac(x): 
    count=0
    ret = collections.Counter()
    while (x != 1): 
        ret[SPF[x]]+=1
        count+=1
        x //= SPF[x]
    return ret , count


manipulated_seive(MAX_SIZE)
ans = 0
for i in range(1,N+1):
    fac, count = getFac(i)
    tmp = 1
    for v in fac.values():
        tmp *= (v+1)
    ans += tmp*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())
count = 0
for i in range(N+1):
    count += (i * len(make_divisors(i)))

print(count)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)

def sieve(n=10**7):
    srn = int(n ** 0.5) + 1
    f = [True] * (srn + 1)
    res = []
    for i in range(2, srn+1):
        if not f[i]:
            continue
        res.append(i)
        for j in range(i * i, srn+1, i):
            f[j] = False
    return res

def trial_division(n):
    num = dict()
    for p in pn:
        while n % p == 0:
            num[p] = num.get(p, 0) + 1
            n //= p
    if n > 1:
        num[n] = 1
    res = 1
    for v in num.values():
        res *= (v + 1)
    return res

N = int(input())
pn = sieve(N)
res = sum(i * trial_division(i) for i in range(1, N+1))
print(res)

Submission status: Time Limit Exceeded

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

import math
from collections import defaultdict

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 prime_factorization_1(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        dict_counter = defaultdict(int)
        for prime in prime_list:
            while num % prime == 0:
                dict_counter[prime] += 1
                num //= prime
        if num != 1:
            dict_counter[num] += 1

        dict_counter = dict(dict_counter)

        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_1(num)
        for value in dict_fact.values():
            divisor_num *= (value + 1)
        return divisor_num



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

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
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]
    return len(lower_divisors + upper_divisors[::-1])*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:
def num_divisors(number):
    table = [0] * (number + 1)

    for i in range(1, number + 1):
        for j in range(i, number + 1, i):
            table[j] += 1
    return table


N = int(input())
ans = 0

A = num_divisors(N)
A = [A[i] * i for i in range(len(A))]
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ints = [0 for i in range(n)]

k = 1
summed = 0

for i in range(1, n + 1):
    if i != 1:
        while k * i <= n:
            ints[k * i - 1] += 1
            k += 1
        k = 1
    summed += (ints[i-1]+1) * i

print(summed)

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(2,n+1):
    t = 1
    for j in factorization(i):
        t *= j[1]+1
        # print(t)
    ans += i * t

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# 整数の入力
from collections import Counter
import numpy as np
N = int(input())

def prime_factors(n):
    """Returns all the prime factors of a positive integer"""
    factors = []
    d = 2
    while n > 1:
        while n % d == 0:
            factors.append(d)
            n /= d
        d = d + 1
        if d*d > n:
            if n > 1: factors.append(int(n))
            break
    return factors

def kfk(k):
    c = Counter(prime_factors(k))
    fk = np.prod(np.array(list(c.values()))+1)
    kfk = k * fk
    return kfk

def sum_kfk(n):
    s = 0
    for k in range(1, n+1):
        s += kfk(k)

    return int(s)

print(sum_kfk(N))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

#nの約数を全て求める
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 table

a = int(input())
sum = 0

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

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[-1]
N=int(input())
ans=0
li=[i for i in range(1,N+1)]
for i in range(1,N+1):
  ans+=num_divisors_table(i)*i
print(ans)

Submission status: Time Limit Exceeded

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

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

for i in range(1, n + 1):
    ans += i*l[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
for i in range(1,n+1):
    k= i*len(make_divisors(i))
    c=c+k
print(c)

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]

answer = 0
for i in range(1, n+1):
    yakusus = make_divisors(i)
    tmp = i * len(yakusus)
    answer += tmp

print(answer)

Submission status: Time Limit Exceeded

Solution code:

def make_div_cnt(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):
    ans += make_div_cnt(i) * i


print(ans)

Submission status: Time Limit Exceeded

Solution code:
def divisors(n):
    i = 1
    cnt = 0
    while i*i <= n:
        if n % i == 0:
            cnt += 1
            if i * i != n:
                cnt += 1
        i += 1
    return cnt

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def main():
    N = NI()
    P = primes(N)
    D = [1] * (N+1)
    for p in P:
        for i in range(1, N//p + 100):
            d = p * i
            if d > N:
                break

            tmp = 0
            while d % p == 0:
                tmp += 1
                d = d // p
            D[p*i] *= tmp + 1

    ans = 0
    for i, d in enumerate(D):
        ans += i * d
    print(ans)


if __name__ == "__main__":
    main()

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

aa = 0

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

print(aa)

Submission status: Time Limit Exceeded

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

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

#print(make_divisors(12))
#print(len(make_divisors(12)))

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

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

sum = 0

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

Submission status: Time Limit Exceeded

Solution code:
#ABC172D
def make_divisors(n):
    cot = 0
    i = 1
    while i*i <= n:
        if n / i == i:
            cot = cot + 1 
            break
        elif n % i == 0:
            cot = cot + 2
        i += 1
    return cot
N = int(input())
ans = [(i+1) * int(make_divisors(i+1)) for i in range(N)]
print(sum(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]
  
i=int(input())
ans=0
for a in range(1, i+1):
  n=make_divisors(a)
  ans+=len(n)*a
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())
answer = int(0)

for i in range(n+1):
    c = len(make_divisors(i))
    answer += int(c * i)


print(answer)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
import math
nn=int(n/2)
a=[3,2]
a*=(n+1)
a[1]-=1
a[2]-=1
for i in range(3,nn+1):
    t=i+i
    while t<=n:
        a[t]+=1
        t+=i
ans=0
for i in range(1,n+1):
    ans+=a[i]*i

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math  

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

number = int(input())
toprint = 0
for i in range (1, number + 1) :
  toprint += (i * sumOfDivisors(i))
  
print (toprint)