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 numpy as np
N = int(input())
NM = 10**7+5

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]
  
if __name__ == '__main__':
  
  ans = 0
  for i in range(1, N+1):
    f = make_divisors(i)
    ans += (i*len(f))
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 0
p = 1
while p <= n:
  c = n // p
  q = p * c
  ans += (p + q) * c // 2
  p += 1
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def num_divisors(n):
  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
  total = 1 
  for p in range(2, n + 1):
    if (hh[p] == 1):
      count = 0 
      if (n % p == 0): 
        while (n % p == 0): 
          n = int(n / p)
          count += 1
        total *= (count + 1)
  return total
N = int(input())
ans = 0
for k in range(1,N+1):
  ans += k*num_divisors(k)
print(ans)

Submission status: Time Limit Exceeded

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

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

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]
_sum = 0
for k in range(1,N+1,1):
  _sum += k*len(make_divisors(k))

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

#にぶたん
def search(arr, num):
    if len(arr) == 0:
        return -1
    l = 0
    r = len(arr) - 1
    while r - l > 1:
        c = (r + l) // 2
        if arr[c][0] < num:
            r = c
        elif arr[c][0] > num:
            l = c
        else:
            r = c
            l = c
    if arr[l][0] == num:
        return l
    elif arr[r][0] == num:
        return r
    else:
        return -1

###素因数分解高速###
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 k] for k in memo[m]]
    if len(res) == 0 or res[-1][0] != min_factor[i]:
        res.append([min_factor[i], 1])
    else:
        res[-1][1] += 1
    memo[i] = res
    #print(i, res)
    tmp = 1
    for j in res:
        tmp *= j[1] + 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:
n = int(input())
ans = 0

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

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]

def f(x):
    return x * (len(make_divisors(x)))

n = int(input())

result = 0
for i in range(1, n+1):
    result += f(i)
print(result)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())

div = np.ones(n + 1, dtype=np.int32)

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

print((div * np.arange(n + 1)).sum())

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
def num_div(n) : 
    cnt = 0
    for i in range(1, (int)(math.sqrt(n)) + 1) : 
        if (n % i == 0) : 
            if (n / i == i) : 
                cnt = cnt + 1
            else :
                cnt = cnt + 2 
    return cnt*n 
s = 0
for i in range(1, n+1):
    s+=num_div(i)
print(s)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要


n = int( input() )
def yakusuu_count( num ):
        count = 0
        for i in range(1, int(num**0.5)+1 ):
                if num % i ==0:
                        count += 1
                        if i != num // i:
                                count += 1
        return count

ans = 0
for i in range(1, n+1):
        ans += i * yakusuu_count(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)
    return len(divisors)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return len(ass)

def main():
    res = 0
    for i in range(1,n+1):
        yku = divisor(i)
        ans = i * yku
        res += ans
    
    print(res)
    return
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 lower_divisors + upper_divisors[::-1]


def main():
    n = int(input())
    x = [len(make_divisors(i)) * i for i in range(1, n + 1)]
    print(sum(x))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

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)

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

print (sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

sum = 0
ro = 1
for n in range(1,N+1):
    num = int(N/n)
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy

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=int(input())


keisan=list(range(1,N+1,1))
#
# div=list(map(lambda x: make_divisors(x) ,keisan))
#
# ans_list=[x*y for (x,y) in zip(div,keisan)]


ans_list=list(map(lambda i:i*make_divisors(i),keisan))
#print(ans_list)
# print(div)
# print(keisan)
print(sum(ans_list))

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
import math
import sys

sys.setrecursionlimit(10**6)
 
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(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
 
N = int(input())
div = 0
for i in range(1,N+1):
    f = search_divisor_num(i)
    div += f*i
print(div)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

divisors = [1]*10000000
for i in range(2, 10000001):
    tmp = i
    while tmp <= 10000000:
        divisors[tmp-1] += 1
        tmp += i
ans = 0
for i in range(n):
    ans += (i + 1) * divisors[i]
print(ans)

Submission status: Time Limit Exceeded

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

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

yaku_list = [len(divisor(i)) for i in range(1,num+1)]

for i,j in enumerate(yaku_list):
    ans += int(i+1) * int(j)
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
def make_divisors(n):
    lower_divisors = []
    upper_divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)

    upper_divisors.reverse()
    return len(lower_divisors + upper_divisors)
sumi=0
for i in range(1,n+1):
    sumi+=i*make_divisors(i)
print(sumi)

Submission status: Time Limit Exceeded

Solution code:
import math 
  
# function to count the divisors 
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 

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

def factorization(n):
    if n < 0:
        print("Warning: input < 0")
        return [[],[]]
    elif n == 0:
        print("Warning: input = 0")
        return [[],[]]
    elif n == 1:
        print("Warning: input = 1")
        return [[],[]]
    elif n%1 != 0:
        print("Warning: input is not ineger")
        return [[],[]]
    factor_list = [[],[]]
    temp = n
    for i in range(2, int((n**0.5))+2):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            factor_list[0].append(i)
            factor_list[1].append(cnt)

    if temp!=1:
        factor_list[0].append(temp)
        factor_list[1].append(1)
    return factor_list

def NumYakusuu(inlist):
    kosuu = 1
    for x in inlist:
        kosuu = kosuu*(x+1)
    return kosuu

ans = 1
for K in range(2,N+1):
    fK = NumYakusuu(factorization(K)[1])
    ans += K*fK

print(ans)

Submission status: Time Limit Exceeded

Solution code:

def f(x):
    a = []
    if x == 1:
        return 1
    else:
        y = x
        for i in range(2,x+1):
            if y%i==0:
                c = 0
                while y%i==0:
                    y=y/i
                    c+=1
                a.append(c)
            if y==1:
                ret=1
                for j in range(len(a)):
                    ret*=(a[j]+1)
                return ret
        
            
def main():
    n = int(input())
    s = 0
    for k in range(1,n+1):
        s+=k*f(k)
    print(s)

if __name__=='__main__':
    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 lower_divisors + upper_divisors[::-1]


n = int(input())
ans = 0
a = [i*len(make_divisors(i)) for i in range(2,n+1)]
print(sum(a)+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 seanum(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())
print(sum([i*seanum(i) for i in range(1,n+1)]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l = [False] * (N + 1)
import collections
def count(n):
  ret = 0
  i = 1
  while i*i <= n:
    if n % i == 0:
      ret += 1
      if i != n // i:
        ret += 1
    i += 1
  return ret


ans = 1
l[0] = True
l[1] = True
if N==1:
  print(ans)
else:
  for i in range(2,N+1):
    if l[i]:
      continue
    x = count(i)
    ans += x * i
    l[i] = True

  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

dp = [0] * (N + 1)
for i in range(1, N + 1):
    cursor = i
    while cursor <= N:
        dp[cursor] += 1
        cursor += i

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
out = 0
for i in range(n):
    j = 1
    while (i + 1) * j <= n:
        out += (i + 1) * j
        j += 1

print(out)

Submission status: Time Limit Exceeded

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

N = int(input())

sigma = 0
for k in range(1,N+1):
    sigma += k * make_divisors(k)

print(sigma)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def factorization(n):
    arr = []
    tmp = n

    for i in range(2, int(n**0.5//1)+1):
        if tmp%i==0:
            cnt = 0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    if tmp!=1:
        arr.append([tmp,1])
    if arr==[]:
        arr.append([n,1])
    return arr
  
sum_=0
for i in range(1,n+1):
  arr = factorization(i)
  tmp = 1
  for _, j in arr:
    tmp *= (j+1)
  sum_ += i*tmp
print(sum_-1)

Submission status: Time Limit Exceeded

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

N = int(input().strip())
#-----

def get_divisor(n :int) -> dict:
    ans = []

    for i in range(1, int(n**(1/2)+1) ):
        if  n % i == 0:
            ans.append(i)
            
            d = n / i
            if (d != i) and (d % 1 == 0):
                ans.append( int(d) )
    
    return ans



sum_f = 0

for i in range(1,N+1):
    num_div = len( get_divisor(i) )
    sum_f += i * num_div

print(sum_f)

Submission status: Time Limit Exceeded

Solution code:
import math
N =int(input())
N_kfk = []
kfk = []
for j in range(1,N+1):
    #Nの約数の個数を求める
    N_k = []
    for i in range(1,j+1):
        if i>j**0.5:
            break
        if j % i == 0:
            N_k.append(i)
            N_k.append(j//i)
    set_n = len(set(N_k))
    #print(N_k)
    #Nの約数の個数求めるの終わり
    N_kfk.append(set_n*j)
    #kfk.append(set_n)
print(sum(N_kfk))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
import numpy as np
li = np.array([0]*N)

for i in range(N):
    li[i:N:i+1]+=1
    li[i]*=(i+1)
    

print(sum(li))

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

print(ret)

Submission status: Time Limit Exceeded

Solution code:
def yakusu(x):
    cnt = 0
    for i in range(x):
        if x % (i+1)== 0:
            cnt += 1
    return cnt
n = int(input())
cnt = 0
for k in range(n):
    cnt += (k+1) * yakusu(k+1)
print(cnt)

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

Submission status: Time Limit Exceeded

Solution code:
def num_divisors(n):
  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
  total = 1; 
  for p in range(2, n + 1):
    if (hh[p] == 1):
      count = 0 
      if (n % p == 0): 
        while (n % p == 0): 
          n = int(n / p)
          count += 1
        total *= (count + 1)
  return total;
N = int(input())
ans = 0
for k in range(1,N+1):
  ans += k*num_divisors(k)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
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 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(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

N = int(input())
div = 0
for i in range(1,N+1):
    f = search_divisor_num(i)
    div += f*i
print(div)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

v = 0
for k in range(1, N+1):
    v += int(k/2 * (N//k) * int(1 + N/k))
print(v)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(100000000) 
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())
result = 0
for i in range(1,n+1):
    result += i*len(make_divisors(i))

print(result)

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n == 1:
    print(1)
    exit()

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

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())
d = {}
ans = 0
for i in range(1,10**6+1):
    ans += i * len(make_divisors(i))
    d[i] = ans
print(d[n])

Submission status: Time Limit Exceeded

Solution code:
# ABC172d


from collections import Counter


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    n = int(input())

    def prime_factorize(n):  # 因数分解
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a
    import math

    ans2 = 0
    for i in range(1, n + 1):
        d = Counter(prime_factorize(i))
        ans = 1
        for j in d:
            ans *= d[j] + 1
        ans2 += i*ans
    print(ans2)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def make_divisors(n):
    number=0

    i = 1
    while i*i <= n:
        if n % i == 0:
            number+=1
            if i != n // i:
                number+=1
        i += 1
    return number

answer=0
for n in range(1,N+1):
    answer+=n*make_divisors(n)

print(answer)

Submission status: Time Limit Exceeded

Solution code:
def yaku(num):
  yk = []
  i = 1
  while ( i <= num ):
    if num % i == 0:
      yk.append(i)
    i += 1
  return len(yk)


N = int(input())

result = 0
j = 1
while ( j <= N ):
  result += j * yaku(j)
  j += 1

print(result)

Submission status: Time Limit Exceeded

Solution code:
import itertools
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.Counter()
    
    while prime_factor_table[n] != 0:
        prime_count[prime_factor_table[n]] += 1
        n //= prime_factor_table[n]
    prime_count[n] += 1
    
    return prime_count

table = prime_factor_table(10000000)
#n = int(input())
n = 10000000
res = 1
for i in range(2, n+1):
    fact = prime_factor(i, table)
    #print(fact)
    temp = i
    for item in fact.items():
        #print(item[0], item[1])
        temp *= (item[1]+1)
    #print(temp)
    res += temp

print(res)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
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])
ans = 0
for i in range(1,N+1):
    ans += i * make_divisors(i)
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(1, N+1):
    cnt[i::i] = [j+1 for j in cnt[i::i]]

ans = 0
for i, j in enumerate(cnt):
    ans += i*j
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]
count=0
for i in range(1,n+1):
  count+=len(make_divisors(i)) * i
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

def prime(n):
    prime = {}
    max = int(math.sqrt(n)) + 1
    for i in range(2, max):
        isFirst = True
        while n % i == 0:
            n = n / i
            if isFirst:
                prime[i] = 1
                isFirst = False
            else:
                prime[i] += 1
    if n > 1:
        prime[n] = 1
    return prime

def f(n):
    factors = prime(n)
    if len(factors.keys()) == 0 and n == 1:
        return 1
    count = 0
    for k, v in factors.items():
        if count == 0:
            count = v + 1
        else:
            count = count * (v + 1)
    return count

n = int(input())
sum = 0
for i in range(1, n+1):
    sum += i * f(i)
print(str(sum))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.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
def sieve(MAX):
    divisor = [0]*(MAX)
    for i in range(1, MAX):
        for j in range(i, MAX, i):
            divisor[j]+=1
    return divisor
def findNFactors (n):

    for i in range(1, n + 1):
        print(i, " --> ", end = '')

        for divi in divisor[i]:
            print(divi, ", ", end = '')
        print()

# Driver code
if __name__ == '__main__':
    n=ii1()
    divisor=sieve(n+2)
    for i in range(1,n+2):
        divisor[i]=i*divisor[i]
    for i in range(1,n+2):
        divisor[i]+=divisor[i-1]
    # print(divisor)
    print(divisor[n])