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

ans=0
cnt=[0]*n
for divisor in range(1,n+1):
    mult=divisor
    while mult<=n:
        cnt[mult-1]+=1
        mult+=divisor
for i,v in enumerate(cnt):
    ans+=(i+1)*v
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""


def make_primes(n): #nまでの素数列挙
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass  


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(int(n))
  return table

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

    # divisors.sort()
    return len(divisors)


n = onem()
po = [1 for i in range(10**7+1)]

for i in range(n+1):
	if i == 0 or i == 1:
		continue
	for j in range(i,n+1,i):
		po[j] += 1
an = 0

for i in range(n+1):
	an += po[i]*i
print(an)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

def divors(u):
    j=0
    for i in range(1,u+1):
        if u % i ==0:
            j+=1
    return j
ans=0
for i in range(1,N+1):
    ans += i*divors(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[0]*(n+1)
for i in range(1,n+1):
 
    for j in range(i,n+1,i):
 
        l[j]+=1
c=0
for i in range(1,n+1):
    c+=i*l[i]
 
print(c)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
  n=int(input())
  ans=0
  d=[0]*(n+1)
  for i in range(1,n+1):
    for j in range(i,n+1,i):
      d[j]+=1
  for i in range(1,n+1):
    ans+=i*d[i]
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
def positive_div(n):
    hh = [1] * (n + 1)
    p = 2
    while (p * p < n):
        if (hh[p] == 1):
            for i in range((2 * p), n, +p):
                hh[i] = 0
        p += 1
    total = 1
    for k in range(2, n +1):
        if hh[k] == 1:
            c = 0
            if n % k == 0:
                while (n%k == 0):
                    n = n//k
                    c += 1
                total *= (c+1)
    return total
n = int(input())
s = 0
for i in range(1,n+1):
    s += i *positive_div(i)
print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def g(n):
  return ((n**2)+n)//2

goukei = 0
for i in range(1,N+1):
  goukei += (i*g(N//i))
print(goukei)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:


N=int(input())
'''
count=0
for i in range(1,N+1):
    n=N//i
    count=n*(i+i*n)//(2)+count
print(count)
'''
count=0
wa=0
for i in range(N,0,-1):

    count=0
    for j in range(1,N+1):
        if(i%j==0):
            count=count+1
    wa=count*i+wa
print(wa)

Submission status: Time Limit Exceeded

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

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:
import numpy as np
n=int(input())
a=np.zeros(n+1,dtype=np.int64)
def fn(i,b):
  if(i!=0):
	  b[i:n+1:i]+=1
gn=np.vectorize(lambda x,b=a:fn(x,a))
b=np.linspace(0,n,n+1,dtype=np.int64)
gn(b)
print(np.sum(a*b,dtype=np.int64))

Submission status: Time Limit Exceeded

Solution code:
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n = int(input())

    ans = 0

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

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """4"""
        output = """23"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """100"""
        output = """26879"""
        self.assertIO(test_input, output)

    # def test_input_3(self):
    #     test_input = """10000000"""
    #     output = """838627288460105"""
    #     self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

divisors = [0 for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(i, n+1, i):
        divisors[j] += 1
#print(divisors)

ans = 0
for k in range(n+1):
    ans += (k * divisors[k])

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

div = [0] * (N+1)

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
a=np.zeros(n+1,dtype=np.int64)
for i in range(1,n+1):
    a[i:n+1:i]+=1
b=np.linspace(0,n,n+1,dtype=np.int64)
print(np.sum(a*b,dtype=np.int64))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
mul = [0] * (N+1)
for i in range(1, N+1):
    for j in range(i, N+1, i):
        mul[j] += 1
ans = 0
for i in range(1, N+1):
    ans += i * mul[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
for i in range(1, N + 1):
    n = N // i  # 項数n
    cnt = (n * (2 * i + (n - 1) * i)) // 2  # 初項i, 項数n の等差数列の和の公式
    ans += cnt
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 0

for i in range(1,n+1):
    for j in range(1,int(i**0.5)+1):
        if i%j == 0:
            ans += i
            if j**2 == i:
                continue
            ans += i

print(ans)

Submission status: Time Limit Exceeded

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

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 正整数（1 <= N <= 10^7）
    """
    # 求解処理
    F = [0 for n in range(N + 1)]
    for n in range(1, N + 1):
        for i in range(1, N // n + 1):
            F[n * i] += 1

    ans = sum([n * F[n] for n in range(N + 1)])

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())

# 求解処理
F = [0 for n in range(N + 1)]
for n in range(1, N + 1):
    for i in range(1, N // n + 1):
        F[n * i] += 1
            
ans = sum([n * F[n] for n in range(N + 1)])

# 結果出力
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())

# 求解処理
F = [0 for n in range(N + 1)]
for n in range(1, N + 1):
    for i in range(1, N + 1):
        if i % n == 0:
            F[i] += 1
            
ans = sum([n * F[n] for n in range(N + 1)])

# 結果出力
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#172D
#Sum of Divisors

n=int(input())
ans=0

for i in range(1,n+1):
    j=1
    while i*j<=n:
        ans+=i*j
        j+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#172D
#Sum of Divisors

N=int(input())
ans=0
for k in range(N):
    a=0
    for i in range(k+1):
        if (k+1)%(i+1)==0:
            a+=1
    ans+=(k+1)*a
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from numba import njit

n = int(input())


@njit
def f(n):
    cnt = np.zeros(n + 1, np.int32)
    for i in range(1, n + 1):
        cnt[i::i] += 1

    return (cnt * np.arange(n + 1)).sum()


ans = f(n)
print(ans)

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:
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:
#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 bisect
from numba import jit


@jit
def solve():
    n = I()
    yaku = [0] * (n+1)
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            yaku[j] += 1
    ans = 0
    for i in range(1,n+1):
        ans += i * yaku[i]
    print(ans)
def main():
    solve()
main()

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
def divisor(n):
    i = 1
    l = []
    while i * i <= n:
        if n % i == 0:
            l.append(i)
            l.append(n//i)
        i += 1
    return len(set(sorted(l)))
total = 0
for i in range(1,a+1):
    total += i * divisor(i)
    
print(total)

Submission status: Time Limit Exceeded

Solution code:
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 #sortされていない
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:
N = int(input())
num = [1 for _ in range(N + 1)]
for i in range(2, N + 1):
    cnt = 1
    while cnt * i <= N:
        num[cnt * i] += 1
        cnt += 1
ans = 0
for i in range(1, N + 1):
    ans += num[i] * i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main(n):
    ans = 0
    for k in range(1, n+1):
        for f in range(1,n//k+1):
            ans += k*f
    return ans

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
table = [0] * (n + 1)
ans = 0
for i in range(1, n + 1):
    # こいつが地獄のように遅い
    # for v in tes.values():
    #     tmp *= (v + 1)
    # print(i, tmp)
    # 1からnまでの約数の個数を数えるズバリのやつがあるらしい エラトステネスを使ってるらしい
    # http://sucrose.hatenablog.com/entry/2016/11/06/234635
    for j in range(i, n + 1, i):
        table[j] += 1
for i in range(1, n + 1):
    ans += i * table[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

N = int(input())
g = 0
for n in range(N):
    A = factorization(n+1)
    f = 1
    for row in A:
        f *= row[1]+1
    g += (n+1) * f

print(g-1)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())+1
print(sum(sum(range(i,n,i))for i in range(1,n)))

Submission status: Time Limit Exceeded

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

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:
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:
n = int(input())
arr = [1] * (n + 1)
for i in range(2, n + 1):
    for j in range(i, n + 1, i):
        arr[j] += 1
ans = 0
for i, c in enumerate(arr):
    ans += i * c
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
import numpy as np
li = np.array([0]*N)
ans = 0
for i in range(N):
    li[i:N:i+1]+=1
    ans += li[i]*(i+1)
    

print(ans)

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

divs = [0] * k

for mult in range(1, k+1):
    for num in range(1, k+1):
        result = num * mult

        if result - 1 < len(divs):
            divs[result - 1] += 1

        else:
            break

result = 0
for x in range(len(divs)):
    result += (x+1) * divs[x]

print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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


print(sum(table))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from numba import *

@njit('i8(i8,i8[:],i8[:])', cache=True)
def solve(x,nums, count):
    for i in range(2,x+1):
        count[np.arange(i,x+1,i)] += 1
    count[0] = 0
    return int(np.sum(nums*count))

if __name__== "__main__":
    x = int(input())
    nums = np.arange(x + 1, dtype=np.int64)
    count = np.ones(x + 1, dtype=np.int64)
    print(solve(x,nums,count))

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
ans=0
for i in range(2,n+1):
    c=0
    for j in range(2,math.floor(math.sqrt(i))+1):
        if i%j==0:
            if i//j!=j:
                c+=2
            else:
                c+=1
    ans+=i*(c+2)
print(ans+1)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
a=[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, 3163]

def factorization(n):
    temp=n
    i=0
    icnt=1
    while temp>1 and i<len(a):
        if temp%a[i]==0:
            cnt=0
            while temp%a[i]==0:
                cnt+=1
                temp //= a[i]
            icnt=icnt*(cnt+1)
        i+=1

    if temp!=1:
        icnt=icnt*2
    if icnt==1:
        icnt=icnt*2

    return icnt

n=int(input())
isum=1
for ii in range(2,n+1):
    icnt=1
    isum+=ii*factorization(ii)

print(isum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 0
for i in range(1,n+1):
  #項数
  kousu=n//i
  #一般項
  an = i + (kousu-1)*i
  #和の公式
  sn = (i + an)*kousu//2
  ans += sn
print(ans)

Submission status: Time Limit Exceeded

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

    N = int(input())
    d = collections.defaultdict(int)
    for i in range(1, N+1):
        d[i] = 2
    d[1] = 1

    ans = 0
    for i in range(2, N//2+1):
        p = i + 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())

Submission status: Time Limit Exceeded

Solution code:
# D - Sum of Divisors
def main():
    N = int(input())
    res = 0
    for a in range(1, N + 1):
        for b in range(1, N // a + 1):
            res += a * b
    print(res)


if __name__ == "__main__":
    main()

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:
import math
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

    v = int(math.sqrt(N))

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

    v = int(math.sqrt(N))

    for i in range(2, v+1):
        for j in range(i+i, N+1, i):
            if j//i > v: d[j] += 2
            else: d[j] += 1

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

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

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

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

    v = int(math.sqrt(N))
    for i in range(2, v+1):
        for j in range(i+i, N+1, i):
            d[j] += 1
            if j//i > v: d[j] += 1

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
dp=[2]*(n+1)
dp[0]=0
dp[1]=1
c=1
for i in range(2,n+1):
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            dp[i]+=2
    if int(i**0.5)*int(i**0.5)==i:
        dp[i]-=1
    c+=dp[i]*i
print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

    v = int(math.sqrt(N))
    for i in range(2, v+1):
        for j in range(i+i, N+1, i):
            d[j] += 1
            if j//i > v: d[j] += 1

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
def main():

    N = int(input())

    d = [0 for _ in range(N+1)]

    v = int(math.sqrt(N))
    for i in range(1, v+1):
        for j in range(i, N+1, i):
            d[j] += 1
            if j//i > v: d[j] += 1

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans = 0
for i in range(1, n+1):
    occ = int(n/i);
    val = int((occ * (occ+1))/2);
    ans += val*i;
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
dp=[1]*(n+1)
dp[0]=0
dp[1]=1
c=0
for i in range(2,n+1):
    for j in range(i,n+1,i):
        dp[j]+=1
for i in range(n+1):
    c+=dp[i]*i
print(c)

Submission status: Time Limit Exceeded

Solution code:
import math
def main():

    N = int(input())

    d = [0 for _ in range(N+1)]

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
table = np.ones(n + 1, dtype=int)
multiple = np.arange(n + 1)

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

Submission status: Time Limit Exceeded

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

    N = int(input())

    d = collections.defaultdict(int)

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
def main():

    N = int(input())

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

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

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

Submission status: Time Limit Exceeded

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

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:
import numpy as np


N = int(input())

e = np.zeros(N + 1)
for i in range(1, N + 1):
    e[i:N+1:i] += 1
ans = 0
for i in range(1, N + 1):
    ans += i * int(e[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def f(n):
    return n * (n+1) // 2

N = int(input())
ans = 0
for i in range(N):
    i += 1
    ans += i * f(N//i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
f = [1] * (n + 1)
for i in range(2, n + 1):
    for j in range(i, n + 1, i):
        f[j] += 1
ans = 0
for i in range(1, n + 1):
    ans += i * f[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
t=[1]*(n+1)
check=[False]*(n+1)
for i in range(2,n+1):
  if check[i]==True:
    continue
  check[i]=True
  for j in range(1,n//i+1):
    check[i*j]=True
    cnt=0
    k=i*j
    while k%i==0:
      k//=i
      cnt+=1
    t[i*j]*=(i**cnt)*(cnt+1)
print(sum(t[1:]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())

    sum_div = sum(range(1, n+1))
    for i in range(2, n+1):
        sum_div += sum(range(i, n+1, i))
    print(sum_div)

main()

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(sys.stdin.readline().strip())

# 1を約数に持つ
divisers = [1 for _ in range(N+1)]
divisers[0] = 0
# divisers[1] = 1

exists = set()
for i in range(2, N+1):
    if i in exists:
        continue
    j = 1
    while i * j <= N:
        tmp = i*j
        exists.add(tmp)
        c = 0
        tmp2 = tmp
        while tmp2 % i == 0:
            tmp2 //= i
            c += 1
        # print(tmp, i, c)
        divisers[tmp] *= c + 1
        j += 1
# print(divisers)

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

print(ans)

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

Submission status: Time Limit Exceeded

Solution code:

n =int(input())

sum = 0
for i in range (1,n+1,1):
    k= n//i
    sum += int(i*k*(k+1)/2)

print(sum)