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:
#!/usr/bin/env python
import os
import operator
from collections import defaultdict
import sys
from io import BytesIO, IOBase
import bisect
import math
def primeFactors(n):
    div=1
    for i in range(2,int(math.sqrt(n)+1)):
        if n%i==0:
            cnt=0
            while n%i==0:
                #print(n)
                cnt+=1
                n//=i
            div*=(cnt+1)
            #print(cnt)
    if n>1:
        div*=(1+1)
    return div
def main():
    n=int(input())
    # ans=primeFactors(n)
    # print(ans)
    if n>10**4:
        ans=1
        for i in range(2, 10**4 + 1):
            ans = ans + (i * primeFactors(i))
        for i in range(10**4+1,n+1):
            ans = ans + (i * primeFactors(i))
        print(ans)
    else:
        ans=1
        for i in range(2,n+1):
            ans=ans+(i*primeFactors(i))
        print(ans)











































BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
#import sympy

n = int(input())
ans = 0

#for i in range(1,n + 1):
#    lst = sympy.divisors(i)
#    ans += i * len(lst)


for j in range(1,n + 1):
    divisors = []
    for i in range(1, int(j**0.5)+1):
        if j % i == 0:
            divisors.append(i)
            if i != j // i:
                divisors.append(j // i)
    
    ans += j * len(divisors)

print(ans)

Submission status: Time Limit Exceeded

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

N = int(input())
ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
###<AOJ.1-6>
###<B>
##n = int(input())
##for i in range(n):
##    x, y = map(str,input().split())
##    y = int(y)
##    

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def pcheck(n):
    rootn = int(n ** 0.5)
    for i in range(2, rootn + 2):
        if n % i == 0:
            return False
    return True

def div(k):
    if k == 1:
        return 1
    rootk = int(k ** 0.5)
    pl = []
    for i in range(2, rootk + 2):
        if k % i == 0:
            p = 0
            while k % i == 0:
                k //= i
                p += 1
            pl.append(p)
    if (pcheck(k) == True) & (k != 1):
        p = 1
        pl.append(p)
    num = 1
    for i in range(len(pl)):
        num *= (pl[i] + 1)
    return num
s = 0
for i in range(1, n + 1):
    s += i * div(i)
print(s)

Submission status: Time Limit Exceeded

Solution code:
def SieveOfEratosthenes(n, prime,primesquare, a): 
    for i in range(2,n+1): 
        prime[i] = True
  
 
    for i in range((n * n + 1)+1): 
        primesquare[i] = False
  
    
    prime[1] = False
  
    p = 2
    while(p * p <= n): 
        if (prime[p] == True): 
            i = p * 2 
            while(i <= n): 
                prime[i] = False
                i += p 
        p+=1
      
  
    j = 0
    for p in range(2,n+1):  
        if (prime[p]==True):  
            # Storing primes in an array 
            a[j] = p 
  
            # Update value in primesquare[p*p], 
            # if p is prime. 
            primesquare[p * p] = True
            j+=1
  
# Function to count divisors 
def countDivisors(n): 
    if (n == 1): 
        return 1
  
    prime = [False]*(n + 2) 
    primesquare = [False]*(n * n + 2) 
      
    a = [0]*n 
  
    SieveOfEratosthenes(n, prime, primesquare, a) 
  
    ans = 1
   
    i=0
    while(1):  
        if(a[i] * a[i] * a[i] > n): 
            break 
        cnt = 1 # cnt is power of  
                # prime a[i] in n. 
        while (n % a[i] == 0): # if a[i] is a factor of n 
            n = n / a[i] 
            cnt = cnt + 1 # incrementing power  
        ans = ans * cnt 
        i+=1      
    n=int(n) 
    # First case 
    if (prime[n]==True): 
        ans = ans * 2
  
    # Second case 
    elif (primesquare[n]==True): 
        ans = ans * 3
  
    # Third case 
    elif (n != 1): 
        ans = ans * 4
  
    return ans # Total divisors
        
t = int(input())
ans = 0
for i in range(1,t+1):
    ans = ans + i * countDivisors(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
N=int(input())
ans=0
#func=len(make_divisors(N))
for i in range(1,N+1):
    ans+=i*len(make_divisors(i))
print(ans)

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=[]
for _ in range(max(n+2,3300)):
    factors.append([])
for i in range(2,3300):
    if(len(factors[i])==0):
        for j in range(i,n+2,i):
            factors[j].append(i)
ans=1
# print(factors)
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)

Submission status: Time Limit Exceeded

Solution code:
import math

n=int(input())

sm=0

for i in range(1,n+1):
  cnt=0
  for j in range(1,int(math.sqrt(i))+1):
    #print("here")
    if i%j==0:
      cnt+=1

  if math.sqrt(i)==int(math.sqrt(i)):
    sm+=(i*((2*cnt)-1))
  else:
    sm+=(i*cnt*2)
  #print(i,cnt)
  #print(sm)
print(sm)

Submission status: Time Limit Exceeded

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

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

print(sum(i*a for i,a in enumerate(li,1)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

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

print(ans)

Submission status: Time Limit Exceeded

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

    # divisors.sort()
    return count


N = int(input())

# K = make_divisors(N)
# print(K)
# Y = range((N))

result = 0
for iter in range(N):
    # print(make_divisors(iter+1))
    result += make_divisors(iter+1) * (iter+1)

print(result)

Submission status: Time Limit Exceeded

Solution code:
#素因数分解して列挙する関数、約数列挙ではない！
from collections import Counter
from math import log2

def factorize(n):
  if n==1:
    return 1
  b = 2
  fct = []
  while b * b <= n:
    while n % b == 0:
      n //= b
      fct.append(b)
    b = b + 1
  if n > 1:
    fct.append(n)
  c = Counter(fct)
  ans = 1
  for v in c.values():
    ans *= v+1
  return ans
def solve():
  ans = 0
  N = int(input())
  for i in range(1,N+1,2):
    f = factorize(i)
    m = int(log2(N//i))
    ans += i*f*(m*pow(2,m+1)+1)
  return ans
print(solve())

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**7)
n = int(input())

def count_divisor(x):
    count = 0
    for i in range(1,x+1):
        if x%i == 0:
            count += 1
    return count
result = 0

for i in range(1,n+1):
    result += i*count_divisor(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())

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

print(sigma)

Submission status: Time Limit Exceeded

Solution code:
import math
def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    
    return num

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

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

def count_divisor(x):
    count = 0
    for i in range(1,x+1):
        if x%i == 0:
            count += 1
    return count
result = 0

for i in range(1,n+1):
    result += i*count_divisor(i)

print(result)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

sm=0
lis=[1]*(n+1)

for i in reversed(range(2,n+1)):
    for mul in range(1,10**10):
        if i*mul > n:
            break
        lis[i*mul]+=1

ans=0

for i in range(len(lis)):
    ans+=(i*lis[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
sums=0
for j in range(n):
    q=0
    i=1
    while i*i<=j+1:
        if (j+1)%i==0:
            q=q+2
            if (j+1)//i==i:
                q=q-1
        i=i+1
    sums=sums+(j+1)*q
print(sums)

Submission status: Time Limit Exceeded

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


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

for n in range(1, N+1):
    data = make_divisors(n)
    ans += len(data) * n

print(ans)

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
            j = 1
            q = p
            x = 0
            while True:
                if not current % q:
                    j *= 2
                    q = p ** j
                else:
                    j = j // 2
                    q = p ** j
                    if j == 0:break
                    if not current % q:
                        current = current // q
                        x += j
                dic[p] = x
        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 soin(n):
    arr=1
    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*=(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:
n = int(input())
answer = [None for i in range(0, n+1)]
answer[1] = 1
small_factors = [1]
p = 1
while (p < n):
    p = p + 1
    if answer[p] is None:
        limit = n / p
        new_small_factors = []
        for i in small_factors:
            j = i
            while j <= limit:
                new_small_factors.append(j)
                answer[j * p] = answer[j] + answer[i]
                j = j * p
        small_factors = new_small_factors
print(sum((k + 1) * d for k,d in enumerate(answer[1:])))

Submission status: Time Limit Exceeded

Solution code:
def gcd_cnt(t):
    for i in range(t, n+1,t):
        kosuu_ls[i]+=i
    #print("defない", kosuu_ls)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
table=[[] for _ in range(n+1)]
import copy
from collections import defaultdict
def yaku(m):
    pf=defaultdict(int)
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
            if table[m]!=[]:
                tmp=copy.deepcopy(table[m])
                for key in pf.keys():
                    tmp[key]+=pf[key]
                return tmp
    if m>1:pf[m]=1
    return pf

ans=1
for m in range(2,n+1):
    table[m]=yaku(m)
    tmp=1
    for k in table[m].keys():
        tmp*=(table[m][k]+1)
    ans+=m*tmp

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

sum = 0
ro = 1
for num in nums:
    for j in range(1,num+1):
        sum += ro*j
    ro += 1
print(sum)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

su = 0
for i in range(1,n+1):
    m = int(n/i)
    su += int(m*(2*i + (m-1)*i)/2)
    

print(su)

Submission status: Time Limit Exceeded

Solution code:
import numpy
n=int(input(''))
b=numpy.zeros((n+1,1),dtype=int)


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


q=[numpy.arange(0,n+1,dtype=int)]


s=numpy.dot(q,b)
print(sum(s)[0])

Submission status: Time Limit Exceeded

Solution code:
# import collections
# import math

# def func(num):
#     if num == 1:
#         return 1
#     elif num == 2:
#         return 4
#     elif num == 3:
#         return 6

#     else:
#         count = 2
#         #1と自身
#         for i in range(2, int(math.sqrt(num)+2)):
#             if num%i == 0:
#                 count += 1
#         value = num*count
#         return value

# n = int(input())

# ans = 0
# for i in range(1, n+1):
#     ans += func(i)
    
# print(ans)

# import collections
# import math

# def func(num):
#     if num == 1:
#         return 1
#     elif num == 2:
#         return 4
#     elif num == 3:
#         return 6
#     else:
#         numbers = []
#         temp = num
#         while num%2 == 0:
#             numbers.append(2)
#             num //= 2

#         i = 3
#         while i*i <= num:
#             if num%i == 0:
#                 numbers.append(i)
#                 num //= i
#             else:
#                 i += 2

#         if num != 1:
#             numbers.append(n)

#         factors = collections.Counter(numbers)
#         divisor = list(factors.values())
#         count = 1

#         for i in divisor:
#             count *= (i+1)

#         value = temp*count
#         return value

# n = int(input())
# ans = 0

# for i in range(1,n+1):
#     ans += func(i)

# print(ans)

import collections
import math

def func(num):
    if num == 1:
        return 1
    elif num == 2:
        return 4
    elif num == 3:
        return 6
    else:
        arr = []
        temp = num
        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])

        count = 1
        for i in range(len(arr)):
            count *= (arr[i][1]+1)
        value = num*count
        return value

            

n = int(input())
ans = 0

for i in range(1,n+1):
    ans += func(i)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import collections
n=int(input())
l=[]
for i in range(1,n+1):
  cnt=0
  j=2
  ll=[]
  while j<=i**0.5:
    if i%j==0:
      i//=j
      ll.append(j)
    else:
      j+=1
  if i>i**0.5:
    ll.append(i)
  l.append(ll)
ans=0
for t in range(n):
  c=collections.Counter(l[t])
  v=c.values()
  p=1
  for vv in v:
    p*=(vv+1)
  ans+=(t+1)*p
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]

sun=0
for K in range(1,N+1):
    sun += K * len(make_divisors(K))

print(sun)

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

    def calcYakusu(n):
        #d = Counter(prime_factorize(n))
        waru = math.floor(n ** 0.5)
        yakusu_zu = []
        n2 = n
        while yakusu[n2][0] == -1:
            if waru == 1:
                break
            if n2 % waru == 0:
                n2 = n2 // waru
                yakusu_zu.append(waru)
            else:
                waru -= 1
        yakusu_zu.append(n2)

        tmp = Counter()
        for i in yakusu_zu:
            tmp += yakusu[i][1] if len(yakusu[i]
                                       [1]) > 0 else Counter([i])
        yakusu[n][1] = tmp
        yakusu[n][0] = 1
        for i in yakusu[n][1]:
            yakusu[n][0] *= (yakusu[n][1][i] + 1)
        return yakusu[n][0]

    yakusu = [[-1, Counter()] for _ in range(n+2)]
    yakusu[1] = [1, Counter()]
    yakusu[2] = [2, Counter([2])]
    ans = 0
    for i in range(1, n + 1):
        if yakusu[i][0] == -1:
            yakusu[i][0] = calcYakusu(i)
        ans += i*yakusu[i][0]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
from collections import Counter

N = int(input())
dic = {}

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
for i in range(1,n+1):
    ans+=i*len(make_divisors(i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
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 += len(make_divisors(i))*i
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def func(x):
    c=0
    for i in range(1,x+1):
        if x%i==0:
            c+=1
    return c
n=int(input())
ans=0
for i in range(1,n+1):
    ans+=(func(i)*i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def printDivisors(n) :
    temp = []

    i = 1
    while i <= n :
        if (n % i==0) :
            temp.append(i)
        i = i + 1
    return temp
n = int(input())
j = 1
sum =0
for i in range(1,n+1):
    a = len(printDivisors(i))
    sum += a *j
    j+=1
print(sum)

Submission status: Time Limit Exceeded

Solution code:

n = int(input())
ans = 0


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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:

N=int(input())
ans=0


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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
ans = 0
for i in range(1,N+1):
  ans+=i*len(make_divisors(i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def factorization(n):
    if n ==1:
        yakusuu=1
    else:
        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])
    
        yakusuu=1
        for i in range(len(arr)):
            yakusuu = yakusuu *(arr[i][1]+1)
            i+=1
    return yakusuu

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

print(kei)

Submission status: Time Limit Exceeded

Solution code:
a=input().split(" ")
b=list(a)
x=int(a[0])
c=0
d=0
e=0
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

for j in range(1,x+1):
    d=d+(j*int(len(make_divisors(j))))

print(d)

Submission status: Time Limit Exceeded

Solution code:
def divisor(a):
  count=0
  for i in range(1,a+1):
    if a%i==0:
      count+=1
  return count
n=int(input())
sm=0
for i in range(1,n+1):
  sm+=i*divisor(i)
print(sm)

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

Submission status: Time Limit Exceeded

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    d = [1] * (N + 1)

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

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
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
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 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):
    count = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            count += 1
            if i != n // i:
                count += 1
    return count

N = int(input())
ans = 0
for j in range(N):
    n = j + 1
    if n == 1:
        ans += 1
    elif is_prime(n):
        ans += n*2 
    else:
        ans += n*make_divisors(n)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    a=i
    for j in range(2,1+int(i**.5)):
        b=0
        while i%j==0:
            i//=j
            b+=1
        a*=b+1
        if i==1:
            break
    if i!=1:
        a*=2
    ans+=a
print(ans)

Submission status: Time Limit Exceeded

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