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 math; from collections import *
import sys; from functools import reduce

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def getlistofstring(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9)+7; SEXYMOD = 998244353; MAXN = int(1e5)





N = int(input())
dp = [2] * (N+1)
dp[1] = 1
i = 2
while i < N:
    for j in range(2*i, N+1, i):
        dp[j] += 1
    i += 1

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

'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

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

Solution (Python):
def primes(n):
    is_prime = [0] * (n + 1)
    is_prime[0] = 0
    is_prime[1] = 1
    for i in range(2, n+1):
        for j in range(i, n + 1, i):
            is_prime[j] += j
    return sum(is_prime)
    
n = int(input())
ans = 0
print(primes(n)+(n*(n+1)//2)-1)

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

memo = list(range(N+1))

temp = [0]*(N+1)
temp[0] = 1
temp[1] = 1

for x,c in enumerate(memo):
    if temp[x] == 0:
        for y in range(x,N+1,x):
            memo[y] *= temp[y]+1
            temp[y] = 1
        k = 2
        while x**k <= N:
            for y in range(x**k,N+1,x**k):
                temp[y] += 1
            k += 1
    memo[x] *= temp[x]+1

print(sum(memo)-1)

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

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


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


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

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]

def num_divisors_table(n):
    table = [0 for i in range(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())

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

Solution (Python):
n = int(input())
a = [1] * n
for i in range(2, n+1):
    for j in range(i, n+1, i):
        a[j-1] += 1
print(sum([(i+1) * a[i] for i in range(n)]))

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

ans = 0
for i in range(1, N+1):
    num = N//i
    k = 0
    if num % 2 == 0:
        k = (num+1)*(num//2)
    else:
        k = num * ((num+1)//2)
    ans += i * k

print(ans)

Solution (Python):

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

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

r = 0

r0 = (1+n)*n-1
r = 0
for i in range(2, n//2+1):
    c = n // i
    s, e = i*2, i*c
    r += (c-1) * (s+e) // 2
print(r0+r)

Solution (Python):
n = int(input())
d = [1 for _ in range(n+1)]

for i in range(2,n+1):
  for j in range(1,n//i+1):
    a = i*j
    if a > n:
      break
    d[a] += 1
ans = 0
for k in range(1,n+1):
  ans += k*d[k]
print(ans)

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

S=[0]*(N+1)
T=0
for i in range(1,N+1):
    T+=i
    S[i]=T
    
for i in range(1,N+1):
    W+=i*S[N//i]
print(W)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    N = int(input())
    cnt = [0] * (N + 1)
    for i in range(1, N + 1):
        for j in range(i, N + 1, i):
            cnt[j] += 1

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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import collections
import heapq
import json
N=int(input())
l=[0]*(N+1)

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


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

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

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

Solution (Python):



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


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

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

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

lst = [1] * n
for i in range(2, n+1):
  counter = 1
  while i * counter <= n:
    lst[i*counter - 1] += 1
    counter += 1

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

Solution (Python):
from math import isqrt

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

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  

N = I()

import math

def sieve_of_eratosthenes(n):
    prime_list = []  
    A = [1]*(n+1)    
    A[0] = A[1] = 0
    for i in range(2,math.floor(math.sqrt(n))+1):
        if A[i]:
            prime_list.append(i)
            for j in range(i**2,n+1,i):
                A[j] = 0
    for i in range(math.floor(math.sqrt(n))+1,n+1):
        if A[i] == 1:
            prime_list.append(i)
    return prime_list

primelist = sieve_of_eratosthenes(N)

list = [i for i in range(N+1)]

for p in primelist:
    a = p
    r = 2
    while a <= N:
        for i in range(1,N//a+1):
            if i % p == 0:
                continue
            else:
                list[a*i] *= r
        a *= p
        r += 1

print(sum(list))

Solution (Python):
import sys
import math
import heapq
from collections import defaultdict, deque
input = sys.stdin.readline
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

n=r()
a=[1]*(n+1)
cnt=1
for i in range(2,n+1):
    for j in range(i,n+1,i):
        a[j]+=1
    cnt+=i*a[i]
print(cnt)

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

ans=0
if n==1:
    ans=1
else:

    yakusuu=[1]*(n+1)

    for i in range(2,n+1):
        num=i

        while(num<=n):
            yakusuu[num]+=1
            num=num+i
    
    for i in range(1,n+1):
        ans+=yakusuu[i]*i

print(ans)

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

cnt = [1] * n
for i in range(2, n + 1):
    for j in range(i - 1, n, i):
        cnt[j] += 1
print(sum((i + 1) * cnt[i] for i in range(n)))

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

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

print(ans)

Solution (Python):
def do():
    if n == 1:
        print(1)
        return 0
    x = (1+n) * n
    x -= 1
    
    for i in range(2, (n // 2) + 1):
        num = n // i
        x += i * ( (1 + num) * num // 2)
        x -= i
        
        

    print(x)

res = 0
n = int(input())
do()

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

ans = 0

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

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    d = [0] * (N+1)
    ans = 0
    for i in range(1, N+1):
        for j in range(i, N+1, i):
            d[j] += 1
        ans += i * d[i]
    print(ans)


main()

Solution (Python):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())

    N = NI()

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

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math

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

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

Solution (Python):
from math import floor
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case 


def num_divisors(n):
    i = 1
    result = 0
    while i * i <= n:
        if n % i == 0:
            result += 2 if n // i != i else 1
        i += 1
    return result


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

    return int(result)


if __name__ == "__main__":
    n = int_in()
    out(solve(n))

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

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

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

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

ans = sum(i*n for i,n in enumerate(checked))

print(ans)

Solution (Python):
import sys 

n = int(input())

sum = 0

for i in range(1, n + 1):
	last = n // i * i 
	count = (last - i) // i + 1

	

	s = (i + last)  * count // 2 
	
	sum += s

print(sum)

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

ans=[1]*N
for i in range(2,N+1):
    tmp=i
    while tmp-1<N:
        ans[tmp-1]+=1
        tmp+=i
anss=0
for i in range(1,N+1):
    anss+=i*ans[i-1]
print(anss)

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

ans = 0

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

print(ans)

Solution (Python):
def main():
    N = int(input())
    S =0
    for i in range(1,N+1):
        S  += (i+(N-N%i))*(N//i)//2

    print(S)


if __name__ == '__main__':
    main()

Solution (Python):
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())
ans=0
for i,j in enumerate(num_divisors_table(n)):
  ans+=i*j
print(ans)

Solution (Python):



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


def main():
    t = num_divisors_table(N)
    ans = sum([i * x for i, x in enumerate(t)])
    print(ans)
    

if __name__ == "__main__":
    main()

Solution (Python):
from math import sqrt
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

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

    table = [1] * (N + 1)

    for n in range(2,N):
        for i in range(2*n, N+1, n):
            table[i] += 1
    
    ans = 0
    for i in range(1, N+1):
        ans += i * (table[i] + 1)
    
    print(ans - 1)


if __name__ == "__main__":
    main()

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

Solution (Python):
import math

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

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

Solution (Python):
N = int(input())
conv = [0]*(N+1)
for i in range(1,N+1):
    for j in range(1,N//i+1):
        conv[i*j-1] += 1
   

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

Solution (Python):
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())
a = num_divisors_table(N)
ans = 0
for i in range(N+1):
  ans += i*a[i]
print(ans)

Solution (Python):
def main():
    n = int(input())
    arr = [0] * n

    for i in range(1, int(n**0.5+1)):
        for j in range(i**2, n + 1, i):
            arr[j-1] += 2

    for i in range(1, int(n**0.5+1)):
        arr[i ** 2 - 1] -= 1

    res = 0
    for i, a in enumerate(arr):
       res += (i+1) * a
    print(res)


if __name__ == '__main__':
    main()

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

M = 10**7+5
cnt = [0] * M

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

ans = 0

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

print(ans)

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())


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

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

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

Solution (Python):

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

if __name__ == "__main__":
    resolve()

Solution (Python):
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd

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

Solution (Python):
import os
import sys

import numpy as np


def solve(inp):
    n = inp[0]
    ans = n * (n + 1) // 2
    for i in range(2, n + 1):
        k = n // i
        ans += i * k * (k + 1) // 2
    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print(ans)

Solution (Python):
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 eratosthenes_sieve(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()

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

Solution (Python):


import math
from collections import Counter
import array

class Sieve:
    def __init__(self, n=10**7+100):
        self.N = n

        self.nd = array.array('i', [1] * n)

        for i in range(2, n):
            for j in range(i, n, i): 
                self.nd[j] += 1
    
    def primes(self):
        return [i for i, e in enumerate(self.s) if e == -1 and i >= 2]

    def fastfactorize(self, n):
        assert(n <= self.N)

        ret = []

        while self.s[n] != -1:
            ret += [self.s[n]]
            n = n // self.s[n]

        ret += [n]

        return ret

    def isprime(self, n):
        if n < self.N:
            return self.s[n] == -1
        for p in self.PRIMES:
            if p*p > n:
                return True
            if n % p == 0:
                return False

    def numDivisors(self, n):
        if n == 1: return 1

        c = dict()

        for f in self.fastfactorize(n):
            if f not in c: c[f] = 0
            c[f] += 1

        ret = 1
        for p in c:
            ret *= (c[p] + 1)
        return ret

    def factorize(self, n):
        if n < self.N:
            return self.fastfactorize(n)
        
        for p in self.PRIMES:
            if p*p > n:
                break
            if n % p == 0:
                return [p] + self.factorize(n // p)

        return [n]

N = int(input())

sieve = Sieve()

ans = 0

for k in range(1, N+1):
    ans += k*sieve.nd[k]

print(ans)

Solution (Python):
n = int(input())
dp = [0 for _ in range(n + 1)]
ans = 0
for i in range(n + 1):
    if i > 0:
        for j in range(i, n + 1, i):
            dp[j] += 1
    ans += i * dp[i]
print(ans)

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

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

Solution (Python):
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N = int(input())

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

main()

Solution (Python):


N, = map(int, input().split())

ans = 0

ans = 0
for k in range(N, 0, -1):
    mi = int(N/k)
    sum_num = (1+mi) * (mi//2) if mi%2==0 else mi * ((mi-1)//2) + mi
    ans += k * sum_num

print(ans)

Solution (Python):
def prime_factorize(N):
    ans = 0
    f = 1
    while f <= N:
        ans += f * (N//f) * (N//f+1) //2

        f += 1
    return ans

def main():
    N = int(input())
    ans = prime_factorize(N)
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
dp = [2]*n
dp[0]=1
ans = 1

if n == 1:
  print(1)
  quit()
  
for i in range(1, n):
  ans += (i+1)*dp[i]
  temp = (i+1)*2 
  while temp <= n: 
    dp[temp-1]+=1
    temp += i+1 

print(ans)

Solution (Python):

MAX = 10**7+10

fac = [0] * (MAX+1)

N = int(input())

for i in range(1, MAX):
    for j in range(1, MAX):
        try:
            fac[i*j] += 1
        except IndexError: 
            break

ans = [1]
for i in range(2, MAX):
    ans.append(ans[-1] + i * fac[i])

print(ans[N-1])









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

now = 1
ans = [1]

for i in range(2, 10**7+1):
    now += i * len(make_divisors(i))
    
    ans.append(now)

print(ans[:10])
'''
'''
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])

    ret = 1
    for i in range(len(arr)):
        ret *= (arr[i][1] + 1)
    return ret

now = 1
ans = [1]

for i in range(2, 10**7+1):
    now += i * factorization(i)
    
    ans.append(now)

print(len(ans))
'''

Solution (Python):
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

def eratos2(n):
	ans = n*(n+1)//2
	
	for i in range(2,n+1):
		
		ans += (n//i)*(2*i+(n//i-1)*i)//2
		
	return ans

print(eratos2(readInt()))

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

cum_l = []

s = 0
for i in range(1,10000001):
    s += i
    cum_l.append(s)

ans = 0 
for i in range(1,n+1):
    k = n // i
    ans += (i*(cum_l[k-1]))

print(ans)

Solution (Python):
n=int(input())
li=[1 for _ in range(10**7+1)]
ans=1

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

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

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

Solution (Python):
n=int(input())
ans=n*(n+1)//2

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

print(ans)

Solution (Python):
def sums(N):
    """ sum of 1~N"""
    return N*(N+1)//2

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

Solution (Python):
n=int(input())
a = [i for i in range(n+1)]
res=0
time = 0
for i in range(1,n+1):
  cnt = n // a[i]
  res += a[i]*cnt*(cnt+1)//2
  

print(res)

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

Solution (Python):
n = int(input())
board = [1] * (n+1)

def divisor_num(n, board):
    for i in range(2, n+1):
        j = 1
        while i*j <= n:
            board[i*j] += 1
            j += 1

divisor_num(n, board)
res = sum([i * board[i] for i in range(1, n+1)])
print(res)

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

Solution (Python):
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter

from functools import lru_cache

sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


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

Solution (Python):
n=int(input())
ans=0
i=1
while i*2<=n:
    temp=(n//i)
    temp2=temp*(temp+1)//2
    ans+=i*temp2
    i+=1
ans+=(i+n)*(n-i+1)//2
print(ans)

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

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

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

print(ans + (N + N//2 + 1) * (N - N//2) // 2)

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

count = 0
import math

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

print(count)

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

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

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

def g(x):
    return int(0.5 * x * (x+1))

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

print(ans)

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

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

ans=0
j=1
while(j*(j*1)<=N):
    b=1+(N//j)
    a=1+(N//(j+1))
    tmp=((N//a)*((N//a)+1))//2
    tmpa=(a*(a-1))//2
    tmpb=(b*(b-1))//2
    ans+=(tmpb-tmpa)*tmp
    j+=1
for i in range(1,a):
    ans+=i*((N//i)*((N//i)+1))//2
print(ans)

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

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

f = [1] + [2] * (N - 1)
ans = 1
for i in range(1, N):
    k = i + 1
    ans += k * f[i]
    for j in range(k * 2 - 1, N, k):
        f[j] += 1
print(ans)

Solution (Python):
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

divs = num_divisors_table(n)

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

print(res)

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

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

div_cnt = [2] * n
div_cnt[0] = 1

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


res = 0
for i in range(n):
    res += (i + 1) * div_cnt[i]

print(res)

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

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

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

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