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: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        num = n // i
        ans += i*num*(num+1)//2
    

    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

N = int(input())

cnt = [0] * (10 ** 7 + 1)

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
n = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

def calc():
  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,n+1):
    ans+=i*table[i]
  print(ans)
calc()

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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

#####MakeDivisors######
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 divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()
ans = 0
for i in range(1,N+1):
  ans += i*((N//i)*((N//i)+1)//2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@numba.njit('(i8,)', cache=True)
def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

N = int(read())
print(main(N))

Submission status: Accepted

Solution code:
import numba

@numba.njit
def main(N):
    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]
    return ans

N = int(input())
print(main(N))

Submission status: Accepted

Solution code:
import sys
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

N = int(read())
print(main(N))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

def sieve(n):
    count = [i for i in range(n+1)]
    count[0] = 0

    for i in range(1, n+1):
        j = 2 * i
        while j <= n:
            count[j] += j
            j += i
    return count

N = ii()
l = sieve(N)
#print(l)
#print(sum([l[i] * i for i in range(1, N+1)]))
print(sum(l))

Submission status: Accepted

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: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

def sieve(n):
    count = [1 for i in range(n+1)]
    count[0] = 0

    for i in range(1, n+1):
        j = 2 * i
        while j <= n:
            count[j] += 1
            j += i
    return count

N = ii()
l = sieve(N)

print(sum([l[i] * i for i in range(1, N+1)]))

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(a, N+1, a):
            x += b
    return x

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
# 約数の個数の表を作る
N = int(input())
dp = [0]*(N+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 += dp[i]*i
print(ans)

Submission status: Accepted

Solution code:
def main(N):
    ans = 0
    for x in range(1, N+1):
        y = N//x
        g = y*(y+1)//2
        g *= x
        ans += g
    print(ans)


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

Submission status: Accepted

Solution code:
def main():
    k=int(input())
    ans=0
    for i in range(1,k+1):
        for j in range(i,k+1,i):
            ans+=j
    print(ans)
    
if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 幅優先探索（行きがけ）
import collections
import sys
import copy


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 = N//i
        num += int((y*(y+1)*i)/2)

    print(num)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
n_input = int(input())
ans = 0
for i in range(1, n_input + 1):
    n = n_input // i
    ans += n * (1 + n) * i // 2
print(ans)

Submission status: Accepted

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)

Submission status: Accepted

Solution code:
from  numba import njit

@njit
def main(N):
    count=0
    for n in range(1 ,N+1):
        for m in range(n,N+1,n):
            count+=m
    print(count)
if __name__ == "__main__":
    N = int(input())
    main(N)

Submission status: Accepted

Solution code:
n = int(input())


def calc(b, e, cnt):
    return (b + e) * cnt // 2


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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

def main():
    N = int(input())
    ans = 0
    for i in range(1,N+1):
        Y = N // i
        ans += (Y * (Y + 1) * i) // 2
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import copy
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)


def main():
    N = I()
    c = [1] * (N + 1)
    
    for i in range(2, N + 1):
        k = i
        while k <= N:
            c[k] += 1
            k += i

    ans = sum(i * c for (i, c) in enumerate(c))
    print(ans)
main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
ans = 0
for k in range(1, N + 1):
    ans += ((N // k + 1) * k * (N // k)) // 2
print(ans)

Submission status: Accepted

Solution code:
# 篩を埋めながら解く方法と(NlogN), 公式解説の方法(N)
# 公式解説のO(N)で解く
N = int(input())
ans = 0
for x in range(1, N+1):
    y = N // x
    ans += y*(y+1)*x // 2
print(ans)

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from numba import njit


@njit
def main(n):
    ans = 0
    for i in range(1, n + 1):
        ans += i * (n // i) * (n // i + 1) // 2
    print(ans)


if __name__ == '__main__':
    n = int(readline())
    main(n)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))

Submission status: Accepted

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

Submission status: Accepted

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

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

N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
from numba import jit


@jit
def main(n):
    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)
    return dp.sum()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    k=int(input())
    Ans=[0]*(k+1)
    for i in range(1,k+1):
        for j in range(i,k+1,i):
            Ans[j]+=1
    ans=0
    for i in range(1,k+1):
        ans+=i*(Ans[i])
    print(ans)
    
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())

answer=0
for x in range(1,n+1):
  y=n//x
  answer+=y*(y+1)*x/2
print(int(answer))

Submission status: Accepted

Solution code:
import sys
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    ans = 0
    for i in range(1,N+1):
        n = N//i
        ans += n*(n+1)*i//2
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

# ans = 0
# for v in range(1, N + 1):
#     if v > N // 2:
#         ans += v
#     else:
#         ans += (v + (N // v) * v) * (N // v) // 2
# print(ans)

ans = 0
for v in range(1, N // 2 + 1):
    ans += (v + (N // v) * v) * (N // v) // 2
ans += (N // 2 + 1 + N) * (N - N // 2) // 2
print(ans)

Submission status: Accepted

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


def main():
    N = int(input())
    ans = 0
    for i,count in enumerate(f(N)):
        ans += i*count
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
#from __future__ import print_function, division    #while using python2


def modinv(n,p):
    return pow(n,p-2,p)

import math

def main():
    #sys.stdin = open('input.txt', 'r')
    #sys.stdout = open('output.txt', 'w')

    n = int(input())
    ans = 0
    for i in range(1, n+1):
        a = i 
        l = n - (n % i)
        k = l // i 
        inc = (((a + l) * k) // 2)
        ans += inc 
        # print(inc)

    print(ans)

#------------------ Python 2 and 3 footer by Pajenegod and c1729-----------------------------------------
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

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

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

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

if __name__ == '__main__':
   main()

Submission status: Accepted

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

dic = [0]*(N+1)
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)