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.

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

def solve():
    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
        
        return table


    table = num_divisors_table(n)

    ans = 0

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

    print(ans)
solve()

Solution (Python):
def main(N):
    ans = 0
    for i in range(N):
        num = N//(i+1)
        numsum = (num*(num+1))//2
        numsum *= (i+1)
        ans += numsum

    return ans


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

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

Solution (Python):
n = int(input())

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

print(ans)

Solution (Python):
N=10**7
llist=[0]*(N+1)
for i in range(1,N+1):
  for j in range(i,N+1,i):
    llist[j]+=1
dp=[0]*(N+1)
for i in range(1,N+1):
  dp[i]=dp[i-1]+llist[i]*i
N=int(input())
print(dp[N])

Solution (Python):
N = int(input())

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

print (ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF = 10**20
def main():
    N=ii()

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


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
dp=[0 for _ in range(n+1)]
for j in range(1,n+1):
    i = 1
    while j*i<=n:
        dp[j*i] += j*i
        i+=1

print(sum(dp))

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

Solution (Python):
n = int(input())
b = [1]*(10**7+1)
for i in range(2, n+1):
    for j in range(i, 10**7+1, i):
        b[j] += 1
ans = 0
for i in range(1, n+1):
    ans += (i*b[i])
print(ans)

Solution (Python):
n = int(input())

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

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)
if __name__ == '__main__':
    main()

Solution (Python):
def s(n):
  return (n*(n+1))//2

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

Solution (Python):


import sys

class DSumOfDivisors:
    def solve(self, tc=0):
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        

        n = int(input())

        print(int(sum(k/2 * int(n/k) * int(1 + n/k) for k in range(1, n + 1))))


solver = DSumOfDivisors()
input = sys.stdin.readline

solver.solve()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

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

    return

if __name__ == '__main__':
    main()

Solution (Python):
import unittest


def solve(n):
    total = 0
    for i in range(1, n+1):
        k = n // i
        total += i * k * (k + 1) // 2

    return total


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


if __name__ == "__main__":
    main()


class Test(unittest.TestCase):
    def test1(self):
        self.assertEqual(solve(1), 1)
        self.assertEqual(solve(2), 5)
        self.assertEqual(solve(3), 11)
        self.assertEqual(solve(4), 23)

    def test2(self):
        self.assertEqual(solve(100), 26879)

    def test3(self):
        self.assertEqual(solve(10000000), 838627288460105)

Solution (Python):
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007

inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')



def solve():
    
    

    s=1
    n=ii()
    a=[2]*(n+1)
    for j in range(2,n+1):
        for k in range(2*j,n+1,j):
            a[k]+=1
    for i in range(2,n+1):
        s+=i*a[i]
    print(s)
    










        
if __name__ =="__main__":

    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()

Solution (Python):
import sys
import  math
from heapq import *
import fractions
import bisect
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())

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

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

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

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

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

Solution (Python):
def mysum(x):
    return x*(x+1)//2

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

Solution (Python):
N = int(input())

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

Solution (Python):

N = int(input())

sieve = [0] * (N + 1)
sieve[0] = -1
sieve[1] = -1
for i in range(2, N + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    for j in range(i * i, N + 1, i):
        if sieve[j] == 0:
            sieve[j] = i


def f(K):
    t = []
    a = K
    while a != 1:
        if len(t) != 0 and t[-1][0] == sieve[a]:
            t[-1][1] += 1
        else:
            t.append([sieve[a], 1])
        a //= sieve[a]
    result = 1
    for _, n in t:
        result *= (n + 1)
    return result


result = 0
for K in range(1, N + 1):
    result += K * f(K)
print(result)

Solution (Python):
'''import math



n,m,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
pa=[0]*n
pb=[0]*m
pa=[a[0]]
pb=[b[0]]
for i in range(n):
	pa[i]=pa[i-1]+a[i]
for i in range(m):
	pb[i]=pb[i-1]+b[i]

'''
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

s=0

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

Solution (Python):
n = int(input())

answer = 0
for k in range(1, n // 2 + 1):
    m = n // k
    answer += k * m * (m + 1) // 2

m = (n // 2 + 1)
answer += (m + n) * (n - m + 1) // 2

print(answer)

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	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): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))
def In(x,a): 
    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): 
    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)

    
    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)

Solution (Python):
N = int(input())

res = 0
for i in range(N):
    k = i+1
    N_k = N // k
    res += k * N_k * (N_k+1) // 2

print(res)

Solution (Python):
mod = 1000000007
eps = 10**-9


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

    N = int(input())

    div_num = [1] * (N+1)
    ans = 0
    for i in range(1, N+1):
        ans += i * div_num[i]
        for j in range(2, N+1):
            if i*j > N:
                break
            div_num[i*j] += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
from numba import jit

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

@jit
def main():
	n = I()
	ans = 0
	for k in range(1,n+1):
		ans += k * 0.5 * (n // k) * (n // k + 1)
	print(int(ans))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline





def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))





def main():

	n=II()

	ans=0

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

	print(ans)











if __name__ == "__main__":
	main()

Solution (Python):
n = int(input())

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

print(
  sum(
    list( (n//i) *(n//i + 1) //2 * i  for i in range(1, n+1))
  )
)

Solution (Python):
N = int(input())

cur = 2
ans = N*(N+1)//2
while cur <= N:
    n = N//cur
    ans += cur * (n+1) * n // 2
    cur += 1
print(ans)

Solution (Python):
N = int(input())

s = 0
for divisor in range(1, N+1):
    num = N // divisor
    tmp = num * divisor
    s += tmp * (num + 1) // 2

print(s)

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

Solution (Python):
from math import floor
from collections import defaultdict


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    
    return divisors


def main():
    N = int(input())
    divlist = defaultdict(int)

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

    print(int(ans))


def test():
    ans = 0
    for i in range(1, 10000000):
        d = Calc_Divisors(i)
        print(len(d))
        ans += len(d) * i
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def examA():
    N = I()
    ans = N + N**2 + N**3
    print(ans)
    return

def examB():
    S = SI()
    T = SI()
    ans = 0
    for s,t in zip(S,T):
        if s!=t:
            ans += 1
    print(ans)
    return

def examC():
    N, M, K = LI()
    A = LI()
    B = LI()
    SA = 0
    b = 0
    SB = 0
    for i in range(M):
        if SB+B[i]>K:
            break
        SB += B[i]
        b += 1
    
    ans = 0
    ans = max(ans,b)
    for i in range(N):
        SA += A[i]
        if SA+SB>K:
            while(b>=0):
                if SA+SB<=K:
                    break
                SB -= B[b-1]
                b -= 1
        if b==-1:
            break
        

        ans = max(ans,b+i+1)
    print(ans)
    return

def examD():
    def primes(n):
        is_prime = [True] * (n + 1)
        is_prime[0] = False
        is_prime[1] = False
        for i in range(2, int(n ** 0.5) + 1):
            if not is_prime[i]:
                continue
            for j in range(i * 2, n + 1, i):
                is_prime[j] = False
        return [i for i in range(n + 1) if is_prime[i]]
    N = I()
    P = primes(N)
    
    D = [1]*(N+1)
    for p in P:
        for i in range(1,1+N//p):
            cnt = 1
            cur = i
            while(cur%p==0):
                cnt += 1
                cur //= p
            D[p*i] *= (1+cnt)

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

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math


MOD = 10 ** 9 + 7




n = int(input())
num = 0
for i in range(1, n+1):
    last = (n - (n%i))//i
    num += (i * last * (last+1) // 2)

print(num)

Solution (Python):
n = int(input())


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

    divisors.sort()
    return divisors


ans = 0
for i in range(1, n+1):
    k = n//i
    if 1 < k:
        ans += i*k*(k+1)//2
    else:
        ans += (n+i)*(n-i+1)//2
        break

print(ans)

Solution (Python):
import math

N = int(input())

M = [2] * (N+1)
M[1] = 1

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

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

print(ans)