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 collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()

    num = 0

    for i in range(1, N+1):
        y = math.floor(N/i)
        num += int((y*(y+1)*i)/2)

    print(num)


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(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(1,N+1):
        if i % j == 0:
            ans+=i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def dividor(K):
    X = [0]*K
    num = K
    for i in range(2,num+1):
        while(num%i == 0):
            X[i-1] +=1
            num = num // i
    ans = 1
    for i in range(1,K):
        ans = ans * (X[i] + 1)
    return ans
sum = 1
for i in range(2,N+1):
    sum += i * dividor(i)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
m = [0] * (N+1)
counter = 0
for i in range(1,N+1):
    j = 1
    while i*j <= N:
        m[i*j] += 1
        j += 1
    counter += m[i] * i
print(counter)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())

dp = np.zeros(n+1,np.int64)
#dp[1]=1
for i in range(1,n+1):
    for j in range(i,n+1,i):
        dp[j]+=1
dp*=np.arange(n+1)
print(dp.sum())

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

from collections import defaultdict
dic = defaultdict(int)
ans = 0
for i in range(1, N+1):
    for j in range(i, N+1, i):
        dic[j]+=1
    ans += i*dic[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main(N):
    ans = 0

    for i in range(1, N+1):
        for j in range(i, N+1, i):
            ans += j
    print(ans)


if __name__ == '__main__':
    N = int(input())
    main(N)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += np.sum(np.arange(i, n+1, i, dtype=np.int64))
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())

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

ans = num_divisors_table(N)
#print(ans)
print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

d = [0]*(n+1)

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

ans = sum(d)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

# 約数を求める時間はない！

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())
def f(n):
    lower_divisors = []
    upper_divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
    upper_divisors.reverse()
    return n*len(lower_divisors + upper_divisors)
sumi=0
for i in range(1,n+1):
    sumi+=f(i)
print(sumi)

Submission status: Time Limit Exceeded

Solution code:
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)

Submission status: Time Limit Exceeded

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

# 約数を求める時間はない！

n = int(input())
ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
def countDivisors(num):
    cnt =0
    sqrt = int(num**0.5)
    for x in range(1,sqrt+1):
        if num % x ==0:
            cnt +=1
    return cnt*2 -(sqrt**2 == num)



if __name__ == "__main__":
    N = int(input())
    res = 0
    for k in range(1,N+1):
        res += k*countDivisors(k)
    print(res)

Submission status: Time Limit Exceeded

Solution code:
def main():
  N = int(input())
  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


  ans = 1
  if N==1:
    print(ans)
  else:
    for i in range(2,N+1):
      x = count(i)
      ans += x * i

    print(ans)
    
main()

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import floor
from math import factorial
from operator import mul
from functools import reduce
from collections import defaultdict
def main():
    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())
    if n == 1:
        print(1)
        sys.exit()

    from math import sqrt
    from math import ceil
    maxa = n  # maxa＝「素数判定したい数字のうち最大の数字」
    maxa2 = n
    maxa2 = max(6, maxa2)  # maxa2が6未満だとエラーになる
    p = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2)]
    p[0] = p[1] = False
    p[2] = p[3] = p[5] = True
    for is1 in range(3, maxa2, 2):
        for is2 in range(is1 ** 2, maxa2, is1):
            p[is2] = False
    prime_list = [i for i, b in enumerate(p) if b]

    ps = {e: defaultdict(int) for e in range(n + 1)}
    nums = [i for i in range(n + 1)]
    for pe in prime_list:
        flag = True
        while flag:
            flag = False
            for i1 in range(2,n + 1):
                if nums[i1] % pe == 0:
                    nums[i1] /= pe
                    ps[i1][pe] += 1
                    flag = True

    r = 1
    for i1 in range(2, n + 1):
        pse = ps[i1]
        if pse:
            psv = pse.values()
            psv2 = [i + 1 for i in psv]
            tmp = reduce(mul, psv2)
            r += tmp * i1
    print(r)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def g(x,n):
    y = n // x
    s = int(y * (y+1) * x / 2)
    return s

n = int(input())

answer = 0
for i in range(1,n+1):
    answer += int(g(i,n))

print(answer)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
summ = 0
for k in range(1, n+1):
  counter = 0
  for i in range(1, k//2+1):
    if k%i == 0:
        counter += 1
  counter += 1
  summ += int(k*counter)
print(summ)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
n = int(input())
ans = 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(n):
    ans = ans + (1 + i) * len(divisor(i + 1))
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


def prime_numbers(n):
    """
    n以下の素数列挙
    O(n)
    """
    eratosthenes = [2] * (n + 1)
    eratosthenes[1] = 1
    num_sum = 1
    for i in range(2, n // 2 + 1):
        k = 2
        while True:
            if i * k < n + 1:
                eratosthenes[i * k] += 1
                k += 1
            else:
                break

    return eratosthenes, num_sum


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
f = [0] + [1] + [2] * (N - 1)
for d in range(2, int(N ** 0.5) + 1):
    for i in range((N // d) * d, d * d - 1, -d):
        if d * d == i:
            f[i] += 1
        else:
            f[i] += 2

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

ans = 1

if(N == 1):
    print(ans)
    exit()

for i in range(2, N+1):
    tmp = factorization(i)

#    print(tmp)
    sumnum = 1
    for j in tmp:
        sumnum *= (j[1]+1)

    ans += i * sumnum
#    print(ans)

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())
#li=[]
#f=[len(make_divisors(i)) for i in range(1,n+1)]
#for i in range(1,n+1):
#    li.append(i*f[i-1])
#print(sum(li))

#L=[n//i*(i+n//i*i)//2 for i in range(1,n+1)]
#print(L)
#print(sum(L))
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())

answer=1
# -*- coding:utf-8 -*-
import math

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data


def factorization(n):
    arr = []
    temp = n
    for i in get_sieve_of_eratosthenes(int(N**0.5)):
        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])

    number=1


    for a in arr:
        number*=(a[1]+1)
    return number



for n in range(2,N+1):
    answer+=n*factorization(n)

print(answer)

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import sqrt

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())


def solver(N):
  #print("N=",N)
  ans = 1
  if N > 1:
    for i in range(2,N+1):
      jmax = int(sqrt(i))
      #print("i->jmax=",i,jmax)
      ptn = 2
      
      for j in range(2,jmax+1):
        #print("i,j = ",i,j)
        if i % j == 0:
          q = i // j
          #print("i,j,i//j = ",i,j,q)
          if q > j:
            ptn += 2
          elif q == j:
            ptn += 1
      #print("ptn, i, ptn*i = ",ptn,i,ptn*i)      
      ans += i*ptn
      #print("i=",i,"ptn=",ptn,"ans=",ans)
        
  print(ans)


def main():

    N = I()

    solver(N)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
memo = [0]*(N+1)
for x in range(1,N+1):
    for y in range(x,N+1,x):
        memo[y] += 1
print(sum(c*m for c,m in enumerate(memo)))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        #print(np.arange(i,n+1,i),np.arange(i,n,i).sum())
        ans += np.arange(i,n+1,i).sum()

    print(ans)
main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        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 times(x,y):
    a=0
    while x>=y and x%y==0:
        x=x//y
        a+=1
    return a
N=int(input())
M=primes(math.ceil(10000000*0.5))
S=len(M)
B=[1 for i in range(N+1)]
count=1
for j in range(S):
    for i in range(M[j],N+1,M[j]):
        B[i]*=times(i,M[j])+1
for i in range(2,N+1):
    count+=i*max(B[i],2)
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def 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

n = int(input())
s = 0
for i in range(2, n+1):
  s += i*num_divisors_table(i)[-1]
print(s+1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


def countp(cp, p):
    ret = 0
    while cp % p == 0:
        ret += 1
        cp //= p
    return ret


def count_in(fx_dict):
    if not fx_dict:
        return 2
    ret = 1
    for v in fx_dict:
        ret *= (v + 1)
    return ret


def main():
    N = int(input())
    va = [i for i in range(N + 1)]
    fx = [[] for _ in range(N + 1)]
    for p in range(2, N + 1):
        if va[p] == 1:
            continue
        for cp in range(p, N + 1, p):
            tmp = countp(cp, p)
            va[cp] //= p**tmp
            fx[cp].append(tmp)
    # print(fx)

    ans = 1
    for i in range(2, N + 1):
        if va[i] != 1:
            fx[i].append(1)
        tmp = count_in(fx[i])
        # print(i, tmp)
        ans += i * tmp

    print(ans)
    return


if __name__ == '__main__':
    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 numpy as np
import math

N=int(input())
L=np.ones(N+1)
R=np.arange(0,N+1)

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

print(int(sum(L*R)))

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):
    a = make_divisors(i)
    a = len(a)
    ans += i * a 
    #print(i*a)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def g(X):
    Y = floor(N / X)
    return Y * (Y + 1) * X // 2


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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
count=0
g = 0
y= 0
for i in range(1,N+1):
  y=int(N/i)
  g=y*(y+1)*i/2
  count+=g

print(int(count))

Submission status: Time Limit Exceeded

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

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] += j
  return sum(table)

print(num_divisors_table(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):
        if i%j==0:
            ans+=i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
total = 0
for i in range(1,n+1):
  k = i
  j = k
  while k <= n:
    total += k
    k +=j
print(total)

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

answer=1
# -*- coding:utf-8 -*-
import math
import numpy as np

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data


def factorization(n):
    arr = []
    temp = n
    for i in get_sieve_of_eratosthenes(int(N**0.5)):
        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])

    number=1

    arr=np.array(arr)

    for a in arr[:,1]:
        number*=(a+1)
    return number



for n in range(2,N+1):
    answer+=n*factorization(n)

print(answer)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
from decimal import Decimal
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 = Decimal(input())

sum=0
i=1
while 1:
    if i==1:
        b=1
    else:
        if i>n:
            break
        a=make_divisors(i)
        b=len(a)
    #print(b)
    #print("{}*{}:{}".format(i,b,i*b))
    sum+=i*b
    i+=1
print(sum)
#print(b)
# print(a[len(a)/2])
#print(b)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

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


d=[0]*(n+1)

for i in range(n+1):
    d[i]+=make_divisors(i)


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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# from pprint import pprint
import math

# import numpy as np
# import collections

n = int(input())
# n = 10000000
# n = 100


# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))


def g(x):
    y = n // x
    return int(y * (y + 1) * x / 2)


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


print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = N * (N + 1) // 2
for i in range(2, N+1):
    Y = int(N/i)
    ans += Y * (i + Y * i) // 2

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def sosu(n):
    l = list()
    l.append(2)
    for i in range(2,n):
        for cnt in range(len(l)):
            if i % l[cnt] == 0:
                break
            if cnt == len(l)-1:
                l.append(i)
    return l


def yakusu(n,l):
    cnt = list()
    for s in l:
        tmp = 0
        while n % s == 0:
            tmp += 1
            n = n / s
        if tmp > 0:
            cnt.append(tmp)
    ans = 1
    for i in cnt:
        ans = ans * (i+1)
    return ans
    
n = int(input())
cnt = 0
l = sosu(n+1)
for k in range(n):
    cnt += (k+1) * yakusu(k+1,l)
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    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)

resolve()

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

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

    return ans

print(main())

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


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

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

Submission status: Time Limit Exceeded

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

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

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

    return ans

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

Submission status: Time Limit Exceeded

Solution code:
import math

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())
    total = 0
    for i in range(1,N+1):
        Y = math.floor(N/i)
        total += int(Y*(Y+1)*i/2)
    print(total)

Submission status: Time Limit Exceeded

Solution code:
import logging

yaku = []

def make_divisors(n):
    if n == 1:
        yaku.append(1)
        return 1
    
    ans = 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            if i != n // i:
                if i >= 2:
                    temp = n // i
                    while temp % i == 0:
                        temp = temp // i
                    ans = yaku[n // i - 1] + yaku[temp - 1]
                    yaku.append(ans)
                    return ans
            else:
                if i >= 2:
                    ans = yaku[i - 1] + 1
                    yaku.append(ans)
                    return ans
        i += 1
    yaku.append(2)
    return 2


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

    ans = 0
    for i in range(n):
        i += 1
        #yaku.append(0)
        ans += i * make_divisors(i)

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


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

    divisors.sort()
    return divisors


total = 0
check = [0] * (N + 1)


def two_three(i, score, total, check):
    two = 0
    num_1 = i
    two_score = score
    while num_1 * 2 <= N:
        two += 1
        num_1 = num_1 * 2
        two_score = two_score * (two + 1) * 2 // two
        check[num_1] = 1
        total += two_score
        three = 0
        num_2 = num_1
        three_score = two_score
        while num_2 * 3 <= N:
            three += 1
            num_2 = num_2 * 3
            three_score = three_score * (three + 1) * 3 // three
            check[num_2] = 1
            total += three_score
    three = 0
    num_2 = i
    three_score = score
    while num_2 * 3 <= N:
        three += 1
        num_2 = num_2 * 3
        three_score = three_score * (three + 1) * 3 // three
        check[num_2] = 1
        total += three_score
    return total, check


for i in range(1, N + 1):
    if check[i] == 0:
        score = i * len(make_divisors(i))
        total += score
        total, check = two_three(i, score, total, check)

print(total)

Submission status: Time Limit Exceeded

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

def division(n):
  cnt = 0
  for i in range(1, int(math.sqrt(n))+1):
    if n % i == 0:
      cnt += 1
  cnt *= 2
  if n % math.sqrt(n) == 0:
    cnt -= 1
  return cnt

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

Submission status: Time Limit Exceeded

Solution code:
def divisor(x):
    if x==1:
        return 1
    if x==2 or x==3:
        return 2
    count=0
    for i in range(1,(x//2)+1):
        if x%i==0:
            count+=1
    return count+1

n = int(input())
ans=0
for num in range(1,n+1):
    a = 0
    divisors = divisor(num)
    a = num* divisors 
    ans+=a
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N=int(input())
ans=0
yakusu=[0]*(10**7+1)
for i in range(1,N+1):
    for j in range(i,N+1,i):
        yakusu[j]+=1
for i in range(len(yakusu)):
    ans+=(i)*yakusu[i]
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    N = int(input())
    if N==1:
        print(1)
        exit()
    elif N==2:
        print(5)
        exit()
 
    divs = [1]*(N+10)
 
    for i in range(2, N+1):
        max_t = N // i
        for j in range(1, max_t+1):
            val = i*j
            divs[val] += 1
    ans = 0
    for i in range(1, N+1):
        ans += i * divs[i]
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

    divisors.sort()
    return divisors

cnt = 0
for i in range(1, n+1):
    cnt += int(i)*len(make_divisors(i))
print(cnt)

Submission status: Time Limit Exceeded

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


resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
dp = [1] * (N+1)
dp[0] =  dp[1] =  0

for i in range(2,N+1):
    if dp[i]==1:
        for j in range(i*i, N+1, i):
            dp[j] = i
#print (dp)

def factor(n):
    d = dict()
    #print(dp[n])
    while(dp[n]!=1 and dp[n]!=0):
        d[dp[n]] = d.get(dp[n],0) + 1
        n //= dp[n]
    d[n] = d.get(n,0) + 1
    return d
a = 0
for n in range(N):
    d = factor(n+1)
    ans = 1
    for k,v in d.items():
        ans *= (v+1)
    if n==0:
        ans = 1
    #print(ans,(n+1))
    a += ans*(n+1)
print (a)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
ans=0
d=[0]*(N+1)
for n in range(1,N+1):
    ret=0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret+=1
            if i != n // i:
                ret+=1
    ans+=n*ret
    d[n]=ret
print(ans)