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:
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
# stdin = open("sample.txt")

MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt+1
    if temp != 1:
        arr[temp] = 1+1
    if arr == {}:
        arr[n] = 1+1
    return arr

def main():
    n = int(stdin.readline().rstrip())
    ans = 0
    for i in range(2,n+1):
        dict_n = fact(i)
        list_n = list(dict_n.values())
        f = np.prod(list_n)
        ans += i*f
    print(ans+1)
main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 0
for num in range(1, n+1):
    count = n // num
    last = count * num
    total = count * (num + last) // 2
    ans += total

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())

def eratosthenes(lim):
  is_p=[2]*lim

  is_p[0]=0
  is_p[1]=1

  for i in range(2,lim):
    for j in range(i*2,lim,i):
      is_p[j] += 1

  return is_p

lim=n+1
is_p=eratosthenes(lim)

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

Submission status: Time Limit Exceeded

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def primeFactorization(x):
	d = defaultdict(int)
	d[1] = 0
	while(x%2 == 0):
		x //= 2
		d[2] += 1
	for i in range(3,int(sqrt(x))+1,2):
		while(x%i == 0):
			d[i] += 1
			x //= i
	if(x > 2):
		d[x] += 1
	return d

def Sieve(x):
	checkPrime = [1 for i in range(x+1)]
	zz = 2
	L = []
	while(zz**2 <= x):
		if(checkPrime[zz] == 1):
			for i in range(zz*2,x+1,zz):
				checkPrime[i] = 0
		zz += 1
	for i in range(2,x):
		if(checkPrime[i] == 1):
			L.append(i)
	return L
	# return checkPrime

# print(len(Sieve(int(sqrt(10**7))+1)))


def solve(x):
	check = [0]*(x+1)
	for i in range(1,x+1):
		j = 1
		while(i*j < x+1):
			check[i*j] += 1
			j += 1
	ans = 0
	# print(check)
	for i in range(1,x+1):
		ans += i * check[i]
	return ans

N = int(stdin.readline())
ans = solve(N)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
def phan(n):
  m=math.floor(math.sqrt(n))+1
  jud=0
  for i in range(2,m):
    if (n%i)==0:
      jud=jud+1
  if jud==0:
     return 1
  else:
    return 0
def plist(x):
  plist=[]
  for i in range(2,x):
    if phan(i)==1:
      plist.append(i)
  return plist
def yakusu(x):
  count=0
  kata=1
  if phan(x)==0:
    for i in plist(x):
      counti=0
      for j in range(1,10**7):
        if x%(i**j)==0:
          counti=counti+1
        else:
          kata=kata*(counti+1)
          break
  elif phan(x)==1:
    if x!=1:
      kata=kata*2
    elif x==1:
      kata=1
  return kata
sum2=0
for i in range(1,(N+1)):
  sum2=sum2+i*yakusu(i)
print(sum2)

Submission status: Time Limit Exceeded

Solution code:
from numba import jit
import math
import numpy

@jit(cache=True)
def aaa(n):
    pl=[0]*(n+1)
    for i in range(1,n+1):
        for l in range (i,n+1,i):
            pl[l]+=1
    return(pl)

n=int(input())
p=numpy.array(list(range(n+1)))
pl=numpy.array(aaa(n))
q=numpy.dot(p,pl)
print(q)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
l=[x for x in range(1,n+1)]
for i in range(1,n+1):
  num=n//i
  k=num*((2*i)+((num-1)*i))
  ans+=k//2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
cnt = 0
for i in range(1, n+1):
    hoge = int(n//i)
    cnt += (hoge + 1) * i * hoge // 2
print(cnt)

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

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

print(num)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


n = int(input())
count = np.zeros(n+1, dtype=np.int64)
for num in range(1, n+1):
    count[num::num] += 1

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        if i % j == 0:
            ans += i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a = [i for i in range(n+1)]
res=0
time = 0
for i in range(1,n+1):
  cnt = n // a[i]
  res += a[i]*cnt*(cnt+1)//2
  #print(res)

print(res)

Submission status: Time Limit Exceeded

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


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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
import math
## 素数判定 O (√n)
def is_prime(n):
    for i in range(2,int(math.sqrt(n)+1)):
        if n % i == 0:
            return False
    return n != 1 # 1の場合は除外
def soinsu(n):
    dic = defaultdict(int)
    i = 2
    while i*i <= n:
        if n%i == 0:
            dic[i] += 1
            n //= i
        else:
            i += 1
    if n!= 1:
        dic[n] += 1
    return dic
n = I()
ans = 0
yaku = [1] *(10**7+1)
yaku[0] = 0
yaku[1] = 1
for i in range(1,n+1):
    for j in range(i*2,n+1,i):
        yaku[j] += 1
for i in range(1,n+1):
    if is_prime(i):
        y = 2
    else:
        y = yaku[i]
    ans += i * y
print(ans)

Submission status: Time Limit Exceeded

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

n = int(input())
res = 0

for i in range(1, n+1):
    for j in range(1, n+1):
        if i%j == 0:
            res += i

print(res)

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())
num = [j*search_divisor_num_1(j) for j in range(1,N+1) ]
print(sum(num))

Submission status: Time Limit Exceeded

Solution code:
import math

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


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


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


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

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


def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0
    return [prime for prime in primes if prime != 0]


N = int(input())
DP = [0] * (N+1)
ans = 1
DP[1] = 1
for a in primes(N):
    cnt = 1
    while True:
        p = (a ** cnt) * (1 + cnt)
        DP[a ** cnt] = p
        ans += p
        cnt += 1
        if a ** cnt > N:
            break

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


print(ans)

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

Submission status: Time Limit Exceeded

Solution code:
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
 
def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a
 
N=int(input())
num=0
for i in range(1, N+1):
    yakusuu= divisor_num(i)
    num    =num + i*yakusuu
 
print(num)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
N = int(input())
dic = defaultdict(int)


def prime(n):  # O(√n)で素因数分解結果を返す
    dic = defaultdict(int)
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            dic[i] += 1
        i += 1
    if n != 1:
        dic[n] = 1
    return dict(dic)


sum_num = 0
for i in range(N):
    if (i == 0):
        sum_num += 1
        continue

    temp = prime(i + 1)
    sum_prime = 1
    for value in temp.values():
        sum_prime *= (value + 1)

    sum_num += (i + 1) * sum_prime
print(sum_num)

Submission status: Time Limit Exceeded

Solution code:
#ABC172 D
def main(n):
    sum = 0
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            sum += 1*j
    return sum

n = int(input())
print(main(n))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
S = 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


for i in range(1, X + 1):
    S += i * len(divisor(i))

print(S)

Submission status: Time Limit Exceeded

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

N=int(input())

A=[i for i in range(10**7+1)]
B=[i for i in range(10**7+1)]

if N==1:
    print(1)
    sys.exit()

def main():
    ANS=0

    for i in range(2,N+1):
        if B[i]==1:
            ANS+=A[i]
            continue
        
        for j in range(i,10**7+1,i):

            count=0
            while B[j]%i==0:
                count+=1
                B[j]//=i
            A[j]*=count+1
        ANS+=A[i]

    print(ANS+1)
main()

Submission status: Time Limit Exceeded

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
import math
## 素数判定 O (√n)
def is_prime(n):
    for i in range(2,int(math.sqrt(n)+1)):
        if n % i == 0:
            return False
    return n != 1 # 1の場合は除外
def soinsu(n):
    dic = defaultdict(int)
    i = 2
    while i*i <= n:
        if n%i == 0:
            dic[i] += 1
            n //= i
        else:
            i += 1
    if n!= 1:
        dic[n] += 1
    return dic
n = I()
ans = 0
yaku = [1] *(10**7+1)
yaku[0] = 0
yaku[1] = 1
for i in range(2,10**7+1):
    if i > n:
        break
    for j in range(i*2,10**7+1,i):
        if j > n:
            break
        yaku[j] += 1
for i in range(2,n+1):
    if is_prime(i):
        y = 2
    else:
        y = yaku[i]+1
    ans += i * y
print(ans+1)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    m=n//i
    m*=i
    for j in range(i,m+1,i):
        ans+=j
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

#input = sys.stdin.readline
#def main():

#---------------------------------------------------------

def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
    
def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num

n = int(input())

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

from functools import reduce
from operator import mul
from collections import defaultdict, Counter
from heapq import heappush, heappop
import sys
from math import sqrt, floor

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve(N):
    "void()"
    px = [0] * (N + 1)
    primes = []
    divs = defaultdict(list)
    divs[1] = []

    for i in range(2, N + 1):
        if px[i] == 0:
            # prime
            primes.append(i)
#            divs[i] = [i]
            j = 2 * i
            while j <= N:
                px[j] = 1
                j += i

    # debug("num primes: len(primes)", len(primes))
    # 664579

    # numdivs = [0] * (N + 1)
    # numdivs[1] = 1
    # for i in range(2, N + 1):
    #     if not i in divs:
    #         ubound = floor(sqrt(i)) + 1
    #         for p in primes:
    #             if p > ubound:
    #                 break
    #             if i % p == 0:
    #                 divs[i] = [p] + divs[i // p]
    #                 break

    #     numdivs[i] = reduce(
    #         mul,
    #         (x + 1 for x in Counter(divs[i]).values()),
    #         1)

    # print(sum(i * numdivs[i] for i in range(1, N+1)))
    numdivs = [0] * (N + 1)
    numdivs[1] = 1
    #targets = [1]
    for p in primes:
        ubound = N // p
        for t in range(N, 0, -1):
            if t > ubound:
                continue
            if numdivs[t] == 0:
                continue
            cur = t
            cur *= p
            m = 2
            tnum = numdivs[t]
            while cur <= N:
                # debug(": cur", cur)
                numdivs[cur] = tnum * m
                m += 1
                # targets.append(cur)
                cur *= p
            # print(targets)
    # debug(": numdivs", numdivs)
    print(sum(i * numdivs[i] for i in range(1, N+1)))


def main():
    N = int(input())
    solve(N)


def _test():
    """
    >>> solve(4)
    23

    >>> solve(100)
    26879

    #>>> solve(10000000)
    #838627288460105
    """
    # solve(100000)  # 1m8.507s
    # solve(10000000)
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()

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

S = 0

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

print(S)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


S = 0

for k in range(N+1):
  D = [0]
  for i in range(1,k):
    if k % i == 0:
      D.append(i)
  S = S + k*len(D)

print(S)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
def m(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
ans=0
for i in range(1,N+1):
  ans+=i*len(m(i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def div(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; 
ans = 0
n = int(input())
for i in range(1,n+1):
    ans+=i*div(i)
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())

num_divisor = []
divisor = []
for i in range(1, n+1, 1):
    for j in range(1, i+1, 1):
        if i % j == 0:
            divisor.append(j)
    num_divisor.append(len(divisor))
    divisor = []

multiplier = np.arange(1, n+1, 1)
num_divisor_arr = np.array(num_divisor)
answer_arr = multiplier * num_divisor_arr
answer = answer_arr.sum()

print(answer)

Submission status: Time Limit Exceeded

Solution code:
def divisors(n):
    if(n==1):
      cnt=1
    else:
      cnt=0
      for i in range(1, int(n**0.5)+1):
          if n % i == 0:
              cnt+=2
      if any(i**2 == n for i in range(1,(n//2)+1)):
          cnt-=1
    return cnt
N=int(input())
sum=0
for i in range(N):
  n=i+1
  sum+=n*divisors(n)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l = [False] * (N + 1)
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

num = [0] * (10**5 + 1)
for i in range(1, 10**5):
  num[i] = count(i)


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
    if i<=10**5:
      ans += num[i] * i
    else:
      x = int(i**(1/2)) + 1
      a = 1
      while x>1:
        if num[x]!=2:
          continue
          x -= 1
        else:
          y = i
          while True:
            if y%x==0:
              y//=x
              a += 1
            else:
              break
          if y<=10**5:
            ans += a * num[y]
            break
          else:
            x -= 1
            continue
              

  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from collections import deque

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


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


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


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


def main():
    N = NI()
    # P = primes(N)
    # D = [1] * (N+1)
    # for p in P:
    #     for i in range(1, N//p + 100):
    #         d = p * i
    #         if d > N:
    #             break
    #
    #         tmp = 0
    #         while d % p == 0:
    #             tmp += 1
    #             d = d // p
    #         D[p*i] *= tmp + 1
    ans = 1
    for i in range(2, N+1):
        pf = prime_fact(i)
        tmp = 1
        for a, b in pf.items():
            tmp *= b+1
        ans += tmp * i

    def num_divisors_table(n):
        table = [0] * (n + 1)

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

        return table
    D = num_divisors_table(N)
    ans = 0
    for i in range(1, N+1):
        ans += D[i] * i
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

a = sum(num_divisors_table(n))
print(a)

Submission status: Time Limit Exceeded

Solution code:
def primes(n, m=2):
    primeList = set(range(max(2, m), n + 1))
    for i in range(2, int(n ** 0.5 + 1)):
        primeList.difference_update(range(i * 2, n + 1, i))
    return list(primeList)


def PrimeFactorization(n):
    pf = {}
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            pf[i] = pf.get(i, 0) + 1
            n //= i
    if n > 1:
        pf[n] = 1
    return pf


def resolve():
    import copy
    n = int(input())
    primelist = primes(n)
    ans = {1: 1}
    for i in primelist:
        nextans = copy.deepcopy(ans)
        for j in ans:
            index = j
            count = 0
            while True:
                index *= i
                count += 1
                if index > n:
                    break
                nextans[index] = nextans[j] * (count + 1)
        ans = nextans
    answer = 0
    for k, v in ans.items():
        answer += k * v
    print(answer)


if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ls = [1]*n

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

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

Submission status: Time Limit Exceeded

Solution code:
import collections

def prime_factorize(n):
    prime_factor_list = []
    while n%2 == 0:
        prime_factor_list.append(2)
        n //= 2
    f = 3
    while f*f <= n:
        if n%f == 0:
            prime_factor_list.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime_factor_list.append(n)
    
    prime_factor = collections.Counter(prime_factor_list)

    return prime_factor

def yakusuu(n):
    c = prime_factorize(n)
    res = 1
    for i in c.values():
        res *= (i + 1)
    
    return res

n = int(input())

ans = 0

for i in range(1, n+1):
    y = yakusuu(i)
    ans += i * y

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
    b= lower_divisors + upper_divisors[::-1]
    return len(b)



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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
  tmp = int(n/i)
  ans += i * tmp * (tmp + 1)

print(int(ans/2))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

ans = 0
for j in range (1, N+1):
    divisors = 0
    i = 1
    while i*i <= j:
        if j % i == 0:
            if i != j // i:
                divisors += 2
            else:
                divisors += 1
        i += 1
    ans += j * divisors

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import collections
def main():

    N = int(input())
    d = collections.defaultdict(int)

    ans = 0
    for i in range(1, int(math.sqrt(N))+1):
        p = i
        while p <= N:
            d[p] += 1
            if p // i > int(math.sqrt(N)):
                d[p] += 1
            p += i

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

    return ans

if __name__ == '__main__':
    print(main())