Problem:


Score : 400 points

Problem Statement

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

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

Constraints

1 \leq N \leq 10^7

Input

Input is given from Standard Input in the following format:

N

Output

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

Sample Input 1

4

Sample Output 1

23

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

Sample Input 2

100

Sample Output 2

26879

Sample Input 3

10000000

Sample Output 3

838627288460105

Watch out for overflows.



Sample input:
4


Sample output:
23

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.read
from functools import reduce
from operator import mul
def main():
    n = int(input())
    # n=1ならprint(1)してexit(コーナーケース対策).
    if n == 1:
        print(1)
        sys.exit()

    jisu = [[] for _ in range(n + 1)]
    jisu[1].append(1)
    num = [i for i in range(n + 1)]
    for i1 in range(2, n + 1):
        if jisu[i1]:
            continue
        else:
            jisu[i1].append(1)
            for i2 in range(i1, n + 1, i1):
                if num[i2] == 1 or i2 % i1 != 0:
                    continue
                else:
                    tmp1 = 2
                    num[i2] /= i1
                    while num[i2] > 1:
                        if num[i2] % i1 == 0:
                            num[i2] /= i1
                            tmp1 += 1
                        else:
                            break
                    jisu[i2].append(tmp1)
    r = 1
    for j1 in range(2, n + 1):
        t = reduce(mul, jisu[j1])
        t *= j1
        r += t
    print(r)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

    for div in range(1, num + 1):
        for i in range(div, num + 1):
            if i % div == 0:
                ans += i

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

    for div in range(1, num + 1):
        for i in range(1, num + 1):
            if i % div == 0:
                ans += i

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
"""
// Author : snape_here - Susanta Mukherjee
     
 """
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 

def isPrime(n):
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

from math import *

import bisect

from decimal import *

getcontext().prec = 50

abc="abcdefghijklmnopqrstuvwxyz"

pi=3.141592653589793238

def fn(n):
    c=0
    for i in range(1,int(sqrt(n))+1):
        if n%i==0:
            if i==n//i:
                c+=1 
            else:
                c+=2 
    return c

def main():

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


# region fastio
 
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")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main()

Submission status: Time Limit Exceeded

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

def cl(x):
  return x * (x + 1) / 2

for i in range(1, n + 1):
  s += i * cl(int(n / i))
  
print (int(s))

Submission status: Time Limit Exceeded

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

def calcsum(x):
  return x * (x + 1) / 2

for i in range(1, n + 1):
  _sum += i * calcsum(int(n / i))
  
print (int(_sum))

Submission status: Time Limit Exceeded

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

def calcsum(x):
  return int (x * (x + 1) / 2)

for i in range(1, n + 1):
  r = int(n / i)
  _sum += i * calcsum(r)
  
print (_sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

total = 0

for i in range(1, n + 1):
  m = n // i
  total += i * sum(range(1, m + 1))

print(total)

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
ans=0
for i in range(1,n+1):
	ans+=((math.floor(n/i)*(math.floor(n/i)+1))/2)*i
print(int(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 k in range(1, N+1):
    ans += k*len(make_divisors(k))

print(ans)

Submission status: Time Limit Exceeded

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

N = int(input())
ans = 0
for k in range(1, N+1):
    ans += k*yakusu(k)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def sumofdivisors(N):
    res = 0
    for K in range(1,N+1):
        res += K*len(make_divisors(K))
    return res

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

if __name__ == "__main__":
    N = int(input())
    print(sumofdivisors(N))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [1,2]

for i in range(3, n+1):
    for j in range(2, i):
        cnt = 0
        num = 0
        if i%j == 0:
            num = i
            while num%j ==0:
                cnt += 1
                num = num/j
            break  
    
    if num == 0:
        a.append(2)
    else:
        number = int(num)
        b = (cnt+1) * a[number-1]
        a.append(b)
sum = 0
for i in range(1,n+1):
    sum += i*a[i-1]

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:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202006_5th/D_input.txt")
else:
    f=sys.stdin
def get_dividor(num):
    ans=0
    for _ in range(1,num+1):
        if _**2>num:
            break
        if num%_==0:
            ans+=1
            if (_**2)!=num:
                ans+=1
    return ans
n=int(f.readline().strip())
ans_sum=0
for _ in range(1,n+1):
    ans_sum+=_*get_dividor(_)
print(ans_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())
ansList = [0] * (10 ** 7 + 1)
for x in range(2, n + 1):
    cnt = 0
    while True:
        val = x * cnt
        cnt += 1
        if val > n: break
        ansList[val] += 1

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

Submission status: Time Limit Exceeded

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

ans = 0


def mySum(x):
    global ans
    ans += x


for i in range(1, N+1):
    num = 0
    mySum(i)
    if i != 1:
        mySum(i)
    for j in range(2, int(math.sqrt(i))+1):
        q, mod = divmod(i, j)
        if mod == 0:
            mySum(i)
            if j != q:
                mySum(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

t = 0

for i in range (1,N+1):
  p = N//i
  s = int(i*p*(1+p)/2)
  t = t+s

print(t)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
for i in range(1, n + 1):
    x, y = i, (n // i) * i
    #等差数列の和は(1/2)*(項数(今回はn//i))*(初項＋末項)
    ans += ((n // i) * (x + y) // 2)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

t = int(0)

for i in range (1,N+1):
  p = N//i
  s = int(p*(2*i+(p-1)*i)/2)
  t = t + s

print(t)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = [0]*N

for i in range(1,N+1):
    for j in range(1,i+1):
        if i % j == 0:
            lst[i-1] += i

print(sum(lst))

Submission status: Time Limit Exceeded

Solution code:
def num_divisors(n):
    num = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            num += 1
            if i != n // i:
                num += 1
    return num

N = int(input())

S = 0
for i in range(1,N+1):
    S += i * num_divisors(i)
print(S)

Submission status: Time Limit Exceeded

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

N = int(input())

S = 0
for i in range(1,N+1):
    S += i * num_divisors(i)
print(S)

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

ans = 0
for i in range(1, n+1):
  num = 0
  for j in range(1, i+1):
    if i%j == 0:
      num += 1
  ans += num * i
  
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 = [0] * (N + 1)

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

    print(sum(d))

if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin,stdout
n=int(stdin.readline());ans=0
fctrs=[0]*(n+1)
for i in range(1,n+1):
        for j in range(i,n+1,i):
            fctrs[j]+=1
for i in range(1,n+1):
    ans+=(i*fctrs[i])
stdout.write(str(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202006_5th/D_input.txt")
else:
    f=sys.stdin
ans=1
n=int(f.readline().strip())
prime=[]
# Start from where n is equal to 2
for _ in range(1,n):
    number_of_multiply=[]
    tmp=_+1
    num_of_divisor=1
    for __ in prime:
        cnt=0
        if tmp==1:
            break
        while (tmp%__)==0:
            cnt+=1;tmp//=__;
        if cnt>0:
            num_of_divisor*=cnt+1
    if num_of_divisor==1:
        prime.append(_+1)
        ans+=(_+1)*2
    else:
        ans+=(_+1)*num_of_divisor
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
f=sys.stdin
ans=1
n=int(f.readline().strip())
prime=[]
# Start from where n is equal to 2
for _ in range(1,n):
    number_of_multiply=[]
    num_of_divisor=1
    tmp=_+1
    for __ in prime:
        cnt=0
        if tmp<=1:
            break
        while (tmp%__)==0:
            cnt+=1;tmp//=__;
        if cnt>0:
            num_of_divisor*=cnt+1
    if num_of_divisor==1:
        prime.append(_+1)
        ans+=(_+1)*2
    else:
        ans+=(_+1)*num_of_divisor
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202006_5th/D_input.txt")
else:
    f=sys.stdin
ans=1
n=int(f.readline().strip())
prime=[]
# Start from where n is equal to 2
for _ in range(1,n):
    number_of_multiply=[]
    num_of_divisor=1
    tmp=_+1
    for __ in prime:
        cnt=0
        if tmp<=1:
            break
        while (tmp%__)==0:
            cnt+=1;tmp=tmp//__;
        if cnt>0:
            num_of_divisor*=cnt+1
    if num_of_divisor==1:
        prime.append(_+1)
        ans+=(_+1)*2
    else:
        ans+=(_+1)*num_of_divisor
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202006_5th/D_input.txt")
else:
    f=sys.stdin
ans=1
n=int(f.readline().strip())
prime=[]
# Start from where n is equal to 2
for _ in range(1,n):
    number_of_multiply = []
    tmp=_+1
    for __ in prime:
        cnt=0
        if tmp<=1:
            break
        while (tmp%__)==0:
            cnt+=1;tmp=int(tmp/__);
        if cnt>0:
            number_of_multiply.append(cnt)
    if len(number_of_multiply)==0:
        prime.append(_+1)
        ans+=(_+1)*2
    else:
        num_of_divisor=1
        for ___ in number_of_multiply:
            num_of_divisor*=___+1
        ans+=(_+1)*num_of_divisor
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202006_5th/D_input.txt")
else:
    f=sys.stdin
ans=1
n=int(f.readline().strip())
prime=[]
# Start from where n is equal to 2
for _ in range(1,n):
    number_of_multiply = []
    num_of_divisor=1
    tmp=_+1
    for __ in prime:
        cnt=0
        if tmp<=1:
            break
        while (tmp%__)==0:
            cnt+=1;tmp=int(tmp/__);
        if cnt>0:
            num_of_divisor*=cnt+1
    if num_of_divisor==1:
        prime.append(_+1)
        ans+=(_+1)*2
    else:
        ans+=(_+1)*num_of_divisor
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 素数列挙 (エラトステネスの篩)
def primes_create(n):
    p = [True]*(n+1)
    p[0] = p[1] = False
    i = 2
    while i*i <= n:
        if p[i]:
            for j in range(i<<1, n+1, i): p[j] = False
        i += 1
    return p

P = primes_create(3163)
P_list = []
for i in range(len(P)):
    if P[i]: P_list.append(i)

# 素数と個数を求める
def factorize(n):
    res = []
    if n < 2: return res
    for i in range(2, n):
        if i*i > n: break
        if n%i: continue
        c = 0
        while n%i == 0: n //= i; c += 1
        res += [[i, c]]
    if n != 1: res += [[n, 1]]
    return res

def factorize_2(n):
    res = []
    if n < 2: return res
    for i in P_list:
        if i*i > n: break
        if n%i: continue
        c = 0
        while n%i == 0: n //= i; c += 1
        res += [[i, c]]
    if n != 1: res += [[n, 1]]
    return res

n = int(input())

s = 0
for i in range(1, n+1):
    cc = 1
    for p,c in factorize_2(i):
        cc *= (c + 1)
    s += i * cc
print(s)

Submission status: Time Limit Exceeded

Solution code:
# 約数の個数を出力
def divisor_counter(n):
    # if n < 1: return -1
    if n < 1: return 0
    if n == 1: return 1
    count = 0
    for i in range(1, n):
        if i*i > n: break
        if n % i == 0:
            count += 1 if n == i*i else 2
    return count

n = int(input())

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())

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]
    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 divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return ret
  
ans = 0
for i in range(1,n+1):
  ans += len(divisors(i))*i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def get_sum(a, d, n):
    """ 等差数列の和：(初項a, 公差d, 項数n) """
    return (2*a + (n-1)*d) * n // 2

N = INT()

ans = 0
for i in range(1, N+1):
    cnt = N // i
    ans += get_sum(i, i, cnt)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main(n) : 
    i = 1
    final = []
    while i <= n : 
        if (n % i==0) : 
            final.append(i,)
        i = i + 1
    return len(final)
n = int(input())
ans = []
for i in range(1, n+1):
    ans.append(main(i))
val = 1
final_ans = 0
for i in ans:
    final_ans+=(val*i)
    val+=1
print(final_ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202006_5th/D_input.txt")
else:
    f=sys.stdin
ans=1
n=int(f.readline().strip())
prime=[]
# Start from where n is equal to 2
for _ in range(1,n):
    number_of_multiply = []
    tmp=_+1
    for __ in prime:
        cnt=0
        while (tmp%__)==0:
            cnt+=1;tmp=int(tmp/__);
        if cnt>0:
            number_of_multiply.append(cnt)
    if len(number_of_multiply)==0:
        prime.append(_+1)
        ans+=(_+1)*2
    else:
        num_of_divisor=1
        for ___ in number_of_multiply:
            num_of_divisor*=___+1
        ans+=(_+1)*num_of_divisor
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
s=0
for i in range(1,n+1):
    s+=i*((math.floor(n/i)*math.floor(n/i+1))/2)
print (int(s))

Submission status: Time Limit Exceeded

Solution code:
def solve():
    n = int(input())
    d = [0 for _ in range(n + 1)]
    ans = 0
    for i in range(1, n+1):
        for j in range(i, n+1, i):
            d[j] += j
    print(sum(d))




if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

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

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


import copy
calced = {}
def calc_main(x):
    arr = {}
    temp = x
    for i in range(2, int(-(-x**0.5//1))+1):
        if temp%i == 0:
            cnt = 0
            t_arr = calced[temp // i]
            t = t_arr.get(i, 0)
            arr = copy.deepcopy(t_arr)
            arr[i] = t + 1

    if temp!=1:
        arr[temp] = 2

    if arr == {}:
        if x == 1:
            arr[temp] = 1
        else:
            arr[temp] = 2

    calced[x] = arr

    return arr

def calc(x):
    arr = calc_main(x)
    ans = 1
    for i in arr.values():
        ans *= i

    return ans


def main():
    n = input_int()

    ans = 0
    for j in range(1, n + 1):
        ans += (n // j) * ((n // j) + 1) * j / 2
        # for i in range(j, n + 1, j):
        #     ans += i

    print(int(ans))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
cnt=np.zeros(n+1,dtype = int)
for i in range(1,n+1):
    cnt[i::i]+=1
ans=cnt*np.arange(n+1)
print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
List=[2 for x in range(n+1)]
List[0]=0
List[1]=1
ans=1
 
for x in range(2,n+1):
  for y in range(2*x,n+1,x):
    List[y]+=1
  ans+=x*List[x]
print(ans)

Submission status: Time Limit Exceeded

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

#初項a、公差d=a、n項までの和
for a in range(1,N+1):
    n=N//a
    S=((2*a+(n-1)*a)*n)//2
    ans=ans+S
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
import math

N = int(input())
ans = 0

def prime_factorization(x):
  divided = x
  d = defaultdict(int)
 
  for i in range(2, int(math.sqrt(x)//1)+1):
    while True:
      if divided%i == 0:
        divided //= i
        d[i] += 1
      else:
        break
  d[divided] += 1
  if 1 in d:
    del d[1]
  return d

def get_divisor_num(d):
  num = 1
  for v in d.values():
    num *= v+1
  return num

for k in range(1, N+1):
  ans += k * get_divisor_num(prime_factorization(k))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())    

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math


def yakusu(K):
    Y = set()
    for i in range(1, int(math.sqrt(K)) + 1):
        if K % i == 0:
            Y.add(i)
            Y.add(K // i)
    return len(Y)


def main():
    N = int(sys.stdin.readline().rstrip())

    sum_ = 0
    for k in range(1, N + 1):
        sum_ += k * yakusu(k)

    print(sum_)


main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())    

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def calc(b, e):
    # 等差数列の和
    cnt = e // b
    ans_tmp = (b + e) * cnt // 2
    return ans_tmp

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())    

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:


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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def calc(b, e):
    # 等差数列の和
    cnt = e // b
    return (b + e) * cnt // 2

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
def func(n):
    return int(((n+1)*n)/2)
a = 0
for i in range(1, n+1):
    a += i * func(n // i)
print(a)

Submission status: Time Limit Exceeded

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

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

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

    return ans
        
print(main())

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

print(num_divisors_table(N))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def solve(stdin):
    n = stdin[0]
    dp = np.zeros(n+1,dtype=np.int64)
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            dp[j]+=1
    dp*=np.arange(n+1)
    return dp.sum()

def main():
    stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=' ')
    print(solve(stdin))

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()

if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    #from my_module import solve
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())

f = [1] * (n + 1)
for i in range(2, n + 1):
    if f[i] != 1: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        f[m] *= cnt + 1
        m += i

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