Problem:


Score : 400 points

Problem Statement

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

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

Constraints

1 \leq N \leq 10^7

Input

Input is given from Standard Input in the following format:

N

Output

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

Sample Input 1

4

Sample Output 1

23

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

Sample Input 2

100

Sample Output 2

26879

Sample Input 3

10000000

Sample Output 3

838627288460105

Watch out for overflows.



Sample input:
4


Sample output:
23

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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

num_dict={1:1}

s=0
for i in range(1,N+1):
    keys=list(num_dict.keys())
    if(i in keys):
        s+=i*num_dict[i]
    else:
        cnt=1
        for k in keys[::-1]:
            if(i%k==0):
                cnt+=1
        num_dict[i]=cnt
        s+=i*num_dict[i]

print(s)

Submission status: Time Limit Exceeded

Solution code:
def yaku(num):
  yakusuu_array = []
  for i in range(1,num+1):
    if num % i == 0:
        yakusuu_array.append(i)
  return yakusuu_array

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


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]

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

def f(x):
    return x * (make_divisors2(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:
n = int(input())
ans = 0
for i in range(1,n+1):
    for j in range(i,n+1,i):
        ans += j

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def gcd_cnt(t):
    a = 0
    kosuu = n//t
    a=kosuu*(2*t + (kosuu-1)*t)//2
    return a

n = int(input())
sub = 0
#約数でそのままアクセス可能
kosuu_ls = [0]*(n+1)
for t in range(1,n+1):
    sub+=gcd_cnt(t)
print(sub)

Submission status: Time Limit Exceeded

Solution code:
import sys
from numba import njit, i8
input = lambda: sys.stdin.readline().rstrip()

@njit(i8(i8), cache=True)
def trial_division(n):
    if n < 2:
        return n
    prime_factors = 1
    e = 0
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            e += 1
            n //= i
        if e > 0:
            prime_factors *= (e + 1)
        e = 0
    if n > 1:
        prime_factors *= 2

    return prime_factors

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
def factorization(n):
    arr = []
    temp = n
    num = 0
    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 math.prod([f[1]+1 for f in arr])
if __name__ == "__main__":
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        ans += i*factorization(i)
    print(ans-1)

Submission status: Time Limit Exceeded

Solution code:
#ABC172D
N = int(input())
ans = []
for n in range(1,N+1):
    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
    ans.append(cot*n)
print(sum(ans))

Submission status: Time Limit Exceeded

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

for i in range(1,n+1):
    now=int(n/i)
    ans+=int(now*(now+1)/2*i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

X=0
for k in range(1,n+1):
    f=0
    for i in range(1,k+1):
        if k%i==0:
            f+=1

    X+=k*f



print(X)

Submission status: Time Limit Exceeded

Solution code:
N=int(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
tot=1
A=[1]
for k in range(2,N+1):
    tot=1
    for i in range(len(factorization(k))):
        tot*=(factorization(k)[i][1]+1)
    A.append(tot)

total=0
for j in range(N):
    total+=A[j]*(j+1)

print(total)
## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict
def main():
    input = sys.stdin.readline
    n = int(input())
    nums_table = defaultdict(int)
    ans = 0
    for i in range(1, n+1):
        for j in range(i,n+1,i):
            nums_table[j-1] += 1
    for i, v in nums_table.items():
        ans += (i+1)*v
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
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 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]
  
import math
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:
def check_divisor(num):
  for i in range(num):
    x = len([i for i in range(1, num + 1) if not num % i])
  return x

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = []
for i in range(N):
  data = [1 for a in range(i + 1) if (i+1) % (a +1) == 0]
  ans.append((i+1) * sum(data))

print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    N=int(input())

    # divisors=sieve(N)
    #
    # # print(divisors)
    # sum=0
    # for i,n in enumerate(divisors):
    #     sum+=i*n

    # print(5*(2+5-1)//2)
    print(sieve(N))

def sieve(n):
    # is_prime = [i for i in range(n+1)]
    sum=n*(2+n-1)//2

    for i in range(2, n+1):
        # print(is_prime)
        sum += i
        j = 2 * i
        while j <= n:
            sum += j
            j += i

    return sum


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
#import numpy as np
import functools
import operator
import collections
import itertools
#import sympy
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:
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())

sum = 0
for k in range(n+1):
  sum += k * make_divisors(k)
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
i = 1
x = 1
total = 0
yakusu_list = []
for i in range(n+1):
    for x in range(1,i+1):
        if i % x == 0:
            yakusu_list.append(x)
    total = total + i * len(yakusu_list)
    yakusu_list = []
print(total)

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
l=[i for i in range(n+1)]
for i in range(2,int(math.sqrt(n))+1):
  if l[i]==i:
    for j in range(2,int(n/i)+1):
      if l[i*j]==i*j:
        l[i*j]=i

def time(n,r,c,ans):
  lc=l[c]
  if lc==1:
    return ans*(n+1)
  elif r==lc:
    return time(n+1,r,c//r,ans)
  else:
    return time(1,lc,c//lc,ans*(n+1))
ans=0
for i in range(1,n+1):
  t=time(0,0,i,1)
  ans+=i*t
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())

k = 1

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

ret = 0

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

print(ret)

Submission status: Time Limit Exceeded

Solution code:
def divisor(n):  # nの約数を全て求める
    i = 1
    table = set()
    while i * i <= n:
        if n % i == 0:
            table.add(i)
            table.add(n // i)
        i += 1
    
    return len(table)
n = int(input().strip())

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

Submission status: Time Limit Exceeded

Solution code:

def divCount(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; 
  
# Driver Code 
s=0
for i in range(1,int(input())+1):
	s+=i*divCount(i)
print(s)

Submission status: Time Limit Exceeded

Solution code:
def soin(n):
    l=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137]
    arr=1
    temp=n
    
    r=len(l)
    for i in range(r):
        if l[i]>n**0.5:
            break
        if temp%l[i]==0:
            cnt=0
            while temp%l[i]==0:
                cnt+=1
                temp//=l[i]
            arr*=(cnt+1)

    if temp!=1:
        arr*=2

    if arr==1:
        arr*=2

    return arr


n=int(input())
m=1
for i in range(2,n+1):
    m+=i*soin(i)

print(m)

Submission status: Time Limit Exceeded

Solution code:
import math 
def num_divisors_table(n):
  maxnum=math.floor((n + 1)/2) #3
  table = [0 for _ in range(n+1)]
  length=n-maxnum
  aftersum=int(maxnum*length+length*(length+1)/2)

  for i in range(1, maxnum+1):
    for j in range(i, n+1, i):
      aftersum += j
      #print(i,j)
  return aftersum

N=int(input())
#Nlist,ans_1=num_divisors_table(N)
#print(Nlist)
print(num_divisors_table(N))
#print(int(sum(Nlist)+ans_1))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
data = stdin.readline().rstrip()

a = int(data)

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

ans = 0
for i in range(1,a+1):
    ans += i*divisor_num(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import collections
x = int(input())

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

l = []

for i in range(x):
    count_dict = collections.Counter(prime_decomposition(i + 1))
   
    ans = 1
    for k, v in count_dict.items():
        ans =  ans * (v + 1)
    l.append(ans * (i + 1))
    ans = 1
print(sum(l))

Submission status: Time Limit Exceeded

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

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)

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

Submission status: Time Limit Exceeded

Solution code:
import collections
import math

n = int(input())

f_list = [[]]*(10**7+1) # すべて素数扱い

def get_ans(t):
    c = collections.Counter(t)
    v_list = c.values()
    ans = 1
    for v in v_list:
        ans *= v+1
    return ans

ans = 0
for i in range(2, n+1):
    tmp = [i] # 約数のリスト
    if i % 2 == 0:
        tmp = f_list[i//2]+[2]
    else:
        f = 3
        while f*f <= i:
            if i % f == 0:
                tmp = f_list[i//f]+[f]
                break
            else:
                f += 2
    f_list[i] = tmp
    ans += i*get_ans(tmp)
print(ans+1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


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

    return len(lower_divisors) + len(upper_divisors)


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

Submission status: Time Limit Exceeded

Solution code:
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,
                  log2, pi, radians, sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


def inlist():
    return(list(map(int, input().split())))


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


def findDivisors(n):
    total = 0

    for i in range(1, n + 1):
        for j in range(1, n + 1):
            if j * i <= n:
                total += (i*j)
    return total


n = inp()
ans = 0
ans = findDivisors(n)
print(ans)

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
        table[i] *= i
    return table


N = int(input())
ans = 0

A = num_divisors(N)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
def yakusu(x):
  cou = 0
  for i in range(1,x+1):
    if x % i == 0:
      cou += 1
  return cou
      
N = int(input())

ans = 0
for k in range(1,N+1):
  ans += k*yakusu(k)
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())

g = 0
for i in range(N):
    g += (i+1) * search_divisor_num_1(i+1)
print(g)

Submission status: Time Limit Exceeded

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

N = int(input())

result = 0
for n in range(1,N+1):
    result += sum([n*i for i in range(1, int(N/n)+1)])

print(result)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
def count_divisor(n):
    i, count = 1, 0
    while i * i <= n:
        if n % i == 0:
            if i * i == n:
                count += 1
            else:
                count += 2
        i += 1
    return count
ans=0
for k in range(1,n+1):
    ans+=k*count_divisor(k)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

N = int(input())
ANS = 0
for i in range(1, N+1):
    c = Counter(factorization(i))
    ans = 1
    for j in c.values():
        ans *= (j+1)
    ANS += i*ans

print(ANS)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = 0
for n in range(N+1):
    i = 1
    j = 0
    while i  <=n:
        if n % i == 0:
            j += 1
        else:
            j
        i += 1    
    a += n * j
print(a)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

ans = 0

for i in range(N):
    tmp = (i + 1) * make_divisors(i + 1)
    ans += tmp
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(input())

    is_prime = [1] * (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] == 1:
            continue
        for j in range(i * 2, N + 1, i):
            is_prime[j] = i
    ans = 0
    for i in range(2, N+1):
        primdic = {}
        num = i
        while True:
            key = is_prime[num]
            num = num // is_prime[num]
            if key == 1:
                if not num in primdic:
                    primdic[num] = 1
                    break
                else:
                    primdic[num] += 1
                    break
            if not key in primdic:
                primdic[key] = 1
            else:
                primdic[key] += 1
        tmp = 1
        for v in primdic.values():
            tmp *= (v+1)
        ans += tmp * i
    ans += 1
    print(ans)



if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import sys

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

n = int(sys.stdin.readline())
s = 0
for k in range(n+1):
    s += k*count_divisors(k)
print(s)

Submission status: Time Limit Exceeded

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

ABC172_Dd()

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

def f(x):
    return x * (make_divisors2(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:
primes = [2]

def f(x):
  if x==1:
    return 1
  a = []
  ret = 1
  for i in primes:
    cnt = 0
    while x%i==0:
      x //= i
      cnt += 1
    if cnt!=0:
      a.append(cnt)
  if len(a)==0:
    primes.append(x)
    ret = 2
  else:
    for i in a:
      ret *= i+1
  return ret

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
def yakusuu(k):
  dic={}
  i=2
  while i*i<=k:
    if k%i!=0:
      continue
    ex=0
    while k%i==0:
      ex+=1
      k/=i
    dic[i]=ex
    i+=1
  if k!=1:
    dic[k]=1
  return dic

def f(dic):
  y=1
  for key in dic:
    if dic[key]==0:
      continue
    y=y*(dic[key]+1)
  return y

def main(N):
  all=0
  for k in range(1,N+1):
    all+=k*f(yakusuu(k))
  return all
      
if __name__=='__main__':
  print(main(int(input())))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def divisor(n):
  for i in range(n):
    x = len([i for i in range(1,n+1) if not n % i])
  return n * x

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
def make_divisors(n):
    count = 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            count += 1
            if i != n // i:
                count += 1
        i += 1
    return max(count,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())

def f(K): # kの正の約数の個数
    cnt = 0
    for i in range(1, K+1): 
        if (K % i == 0): cnt += 1
    return cnt
    
sum = 0
for K in range(1, N+1):
    sum += K*f(K)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
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
A = 0
for i in range(1,N+1):
    A += i*search_divisor_num_1(i)
print(A)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
import collections

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

def F(n):
    an = 1
    c = collections.Counter(prime_factorize(n))
    d = c.values()

    for i in d:
        an *= (i + 1)

    return an

    
ans = 0

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

print("{}".format(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
#print(search_divisor_num_1(8))
N = int(input())
ans = 0
for i in range(N+1):
    ans += i*search_divisor_num_1(i)
print(ans)

Submission status: Time Limit Exceeded

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

def get_primenumber(number):#エラトステネスの篩
    prime_list = []
    search_list = list(range(2,number+1))
    #search_listの先頭の値が√nの値を超えたら終了
    while search_list[0] <= math.sqrt(number):
      #search_listの先頭の値が√nの値を超えたら終了
      #search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        #head_numの倍数を除去
        search_list = [num for num in search_list if num % head_num != 0]
    #prime_listにsearch_listを結合
    prime_list.extend(search_list)
    return prime_list

SOSU=get_primenumber(10**6)

#素因数分解
def factorization(n):
    arr = []
    temp = n
    #for i in range(2, int(-(-n**0.5//1))+1):
    for i in SOSU:
        if int(-(-n**0.5//1))+1<i:
            break
        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