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):
def main():
    N = int(input())
    nums = [2] * (N+1)


    
    
    ans = 1
    
    for i in range(2,N+1):
        
        ans += i * nums[i]
        tmp_i = i * 2
        while tmp_i<= N:
            nums[tmp_i] += 1
            tmp_i += i
            


    
    print(ans)





main()

Solution (Python):

def eratos(N):
    isprime = [1 for i in range(N+1)]
    for i in range(2, N+1):
        j = i
        while j <= N:
            isprime[j] += 1
            j = j + i
    return isprime        

N = int(input())

is_prime = eratos(N)
ans = 0

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

Solution (Python):
import sys
from itertools import accumulate
import bisect

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    s = sum(i*(N//i)*(N//i+1)//2 for i in range(1, N+1))
    print(s)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

INF = float("inf")


N = int(input())
table = [False for i in range(N+1)]
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 is_prime
p = primes(N)
pr = []
for i in range(N+1):
    if p[i]:
        pr.append(i)
n = len(pr)
ans = 1
def dfs(cur_num,index,s,pre,me):
    global ans
    for i in range(index,n):
        if i == index:
            if cur_num*pr[i] <= N:
                ans += (pre*(me+2))*cur_num*pr[i]
                dfs(cur_num*pr[i],index,s+pre*(me+2),pre,me+1)
            else:
                break
        else:
            if cur_num*pr[i] <= N:
                ans += pre*(me+1)*2*cur_num*pr[i]
                dfs(cur_num*pr[i],i,s+pre*(me+1)*2,pre*(me+1),1)
            else:
                break
    return
dfs(1,0,1,1,0)
print(ans)

Solution (Python):
import sys
import numpy as np

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

def main(N):
    div = np.zeros(N+1, np.int64)
    for n in range(1, N+1):
      for m in range(n, N+1, n):
        div[m] += 1
    div *= np.arange(N + 1)
    return div.sum()

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

Solution (Python):
n = int(input())
result = 0
for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        result += j

print(result)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    def num_divisors_table(n):
        table = [0] * (n + 1)

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

    ans = num_divisors_table(N)

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):

import sys
from collections import Counter
sys.setrecursionlimit(10**8)
INF = float("inf")


def eratosthenes_sieve(n):
    table = [0] * (n + 1)
    prime_list = []

    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1

    return prime_list


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

    table = [0] * (N + 1)
    table[0] = 0
    table[1] = 1
    prime_list = []

    for i in range(2, N + 1):
        if table[i] == 0:
            prime_list.append(i)
            table[i] = 2
            for j in range(i + i, N + 1, i):
                c = j
                cnt = 0
                while c % i == 0:
                    c //= i
                    cnt += 1
                table[j] = table[c]*(cnt+1)
    
    ans = 0
    for i in range(N+1):
        ans += i*table[i]
    print(ans)
    return


if __name__ == '__main__':
    main()

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

ans = 0

if N == 1:
    print(1)
    exit()
if N == 2:
    print(5)
    exit()
if N == 3:
    print(11)
    exit()

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

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

print(ans)

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

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

ans = 0
for x in range(1, N+1):
  if x * x > N:
    break
  
  ans += x * x
  
  y_high = N//x
  ans += 2 * x * (f(y_high) - f(x))

print(ans)

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):
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

import bisect

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 Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

N = 10**7+1

arr = [1]*N

def sieve():
    for i in range(2, N,2):
        cnt = 0
        num = i
        while num % 2 == 0:
            cnt+=1
            num = num//2
        arr[i] = arr[i]*(cnt+1)
    
    
    for i in range(3, N, 2):
        if arr[i] == 1:
            for j in range(i, N, i):
                cnt = 0
                num = j
                while num % i == 0:
                    cnt+=1
                    num = num//i
                arr[j]  =arr[j] * (cnt+1)


sieve()
n = int(ri())


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

print(ans)

Solution (Python):
from sys import stdin



from math import sqrt, floor


def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())

res=['NET', 'DA']



def sieve(x):
    a=[2]*(x+1)
    a[1]=1
    sq=floor(sqrt(x))
    for i in range(2, sq+1):
        if a[i]:
            for j in range(i*i, x+1, i):
                a[j]+=2
            a[i*i]-=1
    return a


test_case=1
while test_case:
    test_case-=1


    n=ii()
    a=sieve(n)
    c=0
    
    for i in range(1, n+1):
        c+=i*a[i]
    print(c)

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

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

Solution (Python):
import sys

def I(): 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 main():
    n = I()
    f = [1]*(n+1)
    ans = 1
    for i in range(2, n+1):
        for j in range(i, n+1, i):
            f[j] += 1
        ans += i*f[i]
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
N = int(input())

def sieve_Eratosthenes(n):
    f = [True]*(n+1)
    f[0] = False
    f[1] = False
    m = int(n**0.5+1)
    for i in range(2,m):
        if f[i]:
            for j in range(i*i,n+1, i):
                f[j] = False
    return f

def getPrimeLists(n):
    table = sieve_Eratosthenes(n)
    return [x for x in range(2,n+1) if table[x]]


ps = getPrimeLists(N)

m = [1] * (N+1)

for p in ps:
    q = p
    i = 1
    while True:
        for n in range(q,N+1,q):
            m[n] *= p * (i+1)
            m[n] //= i
        q *= p
        i += 1
        if q > N:
            break

print(sum(m)-1)

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

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

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

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

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

def sum_n(n):
  return n*(n+1)//2

answer=0
for i in range(1,N+1):
  term=N//i
  answer+=i*sum_n(term)
  
print(answer)

Solution (Python):
def calc(n, a, d):
    return (n * (2 * a + (n - 1) * d)) // 2


n = int(input())
ans = 0
for i in range(1, n + 1):
    n_ = (n // i)
    d, a = i, i
    sm = calc(n_, a, d)
    ans += sm
print(ans)

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

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

print(ans)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    sqrt_intN = int(N ** 0.5 + 1)
    l = [1 if i % 2 else 2 for i in range(N+1)]
    if N == 1:
        print(1)
        return
    if N == 2:
        print(5)
        return
    ans = 5
    for i in range(3, N+1):
        ans += (l[i] + 1) * i
        t = i * 2
        while t <= N:
            l[t] += 1
            t += i
    
    print(ans)

if __name__ == '__main__':
    main()

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





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

print(ans)

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()


def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l



def summarizeList(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res


def main():
  n=I()
  ans=0

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

  
  
  
  
  
  
  
  
  

  

  return ans


print(main())

Solution (Python):
n=int(input())
ans=2*(n*(n+1))//2-1
a=2
while n//a>1:
  
  
  
  
  ans+=((n//a-1)*(2*a+n-n%a))//2
  a+=1
print(ans)

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *



N = INT()

cnt = [2]*(N+1)
cnt[0] = 0
cnt[1] = 1

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


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

print(sum(cnt))

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

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

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

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

dp = [1 for _ in range(N+1)]
for i in range(2, 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)

Solution (Python):
def findDivisors(n): 
      
    
    
    div = [0 for i in range(n + 1)] 
      
    
    for i in range(1, n + 1): 
          
        
        
        for j in range(1, n + 1): 
            if j * i <= n: 
                div[i * j] += 1
            else:
              break
    return div

n=int(input())
ans=0
dp=findDivisors(n)
for i in range(len(dp)):
	ans+=(dp[i]*(i))

print(ans)

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

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

print( ans )

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

count = 0
for i in range(n):
  m = n // (i+1)
  count += (i+1)*m*(m+1)/2

print(int(count))

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
sieve=[-1]*(n+1)
for i in range(2,n+1):
  if sieve[i]==-1:
    sieve[i]=i
    for j in range(i*i,n+1,i):
      if sieve[j]==-1:
        sieve[j]=i

Ans=[1]*(n+1)
for i in range(2,n+1):
  p=sieve[i]
  cur=i
  ct=0
  while cur>1:
    if cur%p==0:
      cur//=p
      ct+=1
    else:
      break
  if i==pow(p,ct):
    Ans[i]=i*(ct+1)
  else:
    Ans[i]=Ans[i//(p**ct)]*Ans[p**ct]
print(sum(Ans)-1)

Solution (Python):




from __future__ import division, print_function 

import sys
import os
from collections import Counter, deque, defaultdict
import itertools
import math
import io


"""Uncomment modules according to your need"""













if sys.version_info[0] < 3:
    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip



"""value of mod"""
MOD = 998244353
mod = 10**9 + 7

"""Uncomment next 4 lines if doing huge recursion"""




def prepare_factorial(mod=mod):
    """ returns two lists, factorial and inverse factorial modulo argument by default 10**9 +7 """
    
    fact = [1]
    for i in range(1, 200005):
        fact.append((fact[-1] * i) % mod)

    ifact = [0] * 200005
    ifact[200004] = pow(fact[200004], mod - 2, mod)
    for i in range(200004, 0, -1):
        ifact[i - 1] = (i * ifact[i]) % mod

    return fact, ifact

def modinv(n, p):
    """ returns N inverse modulo p """
    return pow(n, p - 2, p)

def ncr(n, r,  fact, ifact):
    """ takes 4 arguments: n , r and factorial and inverse factorial lists"""
    t = (fact[n] * (ifact[r]*ifact[n-r]) % MOD)% MOD
    return t


def get_n(Sum):    
    """this function returns the maximum n for which Summation(n) <= Sum"""
    ans = (-1 + sqrt(1 + 8*Sum))//2
    return ans

def sieve(n):
    """ returns a list of prime numbers till n """
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r



def divs(n, start=1):
    """ returns a list of all divisors till n """
    divisors = []
    
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors



def divn(n, primes):
    """ returns the number of divisors, two arguments n and the sieve till n """
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
    return divs_number


def lrfind(d, x, default=-1):
    """ Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found """
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return default, default
    else:
        return left, right

def gcd(x, y): 
    """ returns greatest common divisor of x and y """
    while y:
        x, y = y, x % y
    return x

def check_sorted(a):
    ''' returns True/False '''
    for i in range(len(a)-1):
        if a[i]>a[i+1]:
            return False
    return True
def ceil(n, k=1): return n // k + (n % k != 0) 
def input(): return sys.stdin.readline().strip()
def ii(): return int(input()) 
def mi(): return map(int, input().split()) 
def li(): return list(map(int, input().split())) 
def lw(): return input().split() 
def lcm(a, b): return abs(a * b) // gcd(a, b) 
def prr(a, sep=' ', end='\n'): print(sep.join(map(str, a)), end=end) 
def dd(): return defaultdict(int) 
def ddl(): return defaultdict(list) 
def write(s): return sys.stdout.write(s)














def main():
    
    x=ii()
    answer=0
    for i in range(1,x+1):
        an=x-(x%i)
        a=i
        n=an//a
        answer+=(n*(a+an))//2
    print(answer)
""" -------- 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')



""" main function"""

if __name__ == '__main__':
    main()

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

ans = 0

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

print(ans)

Solution (Python):

from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = 0
for i in range(1,n+1):
    
    m = n//i
    x += i*(m*(m+1)//2)
print(x)

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

    ans = 0
    l = n
    i = 1
    while l > 0:
        k = i*(i+1)//2
        l_n = n//(i+1)
        ans += k*(l*(l+1)//2-l_n*(l_n+1)//2)
        l = l_n
        i+=1
    
    print(ans)
main()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
ans = 0
table = [0] * (n + 1)

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

print(ans)

Solution (Python):
N = int(input())
yakusu = [0] * (N + 2)
cnt = 0
for i in range(1, N+1):
    x = i
    cnt += i * (yakusu[i] + 1)
    yakusu[i] += 1
    while (True):
        x += i
        if (x <= N):
            yakusu[x] += 1
        else:
            break

print(cnt)

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

    return r

print(main())

Solution (Python):
n = int(input())
dp = [0]*(n+1)
for i in range(2,n+1):
    j = 2
    while 1:
        if i*j <= n:
            dp[i*j] += 1
        else:
            break
        j += 1
ans = 0
for i in range(2,n+1):
    ans += i*dp[i]
print(ans+n*(n+1)-1)

Solution (Python):



import sys
from numba import njit

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

@njit('i8(i8)', cache=True)
def f(N):
    r = 0
    for i in range(1, N+1):
        n = N // i
        r += i * n * (1 + n) // 2
    return r

def main():
    N = i2n()
    print(f(N))
    return

main()

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

res = 0

for i in range(1, N+1):
    a = N//i
    b = (1+a)*a//2
    res += b*i
print(res)

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

if N == 1:
  print(1)

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

  sum_ += (N//2+1 + N) * (N - (N//2+1) + 1) // 2

  print(sum_)

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

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

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

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

print(res)

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

dp = [1] * (N+100)
dp[0] = 0
dp[1] = 1

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



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

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

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

dp = num_divisors_table(N)

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

print(ans)

Solution (Python):
import math

n=int(input())
 
ans=0
for x in range(1,n+1):
  mx=math.floor(n/x)
  ans+=mx*(mx+1)*x
  
print(round(ans/2))

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

ans = 0

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

allsum = n*(n+1)*0.5
partsum = (n//2)*(n//2+1)*0.5




ans = ans + (allsum - partsum)

print(int(ans))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

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

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

divs = [1] * (N+1)

ans = 1
for i in range(2, N+1):
    if divs[i] == 1:  
        k = i
        while k <= N:
            m = k
            cnt = 1
            while m % i == 0:
                cnt += 1
                m //= i
            divs[k] *= cnt
            k += i
        ans += i*2
    else:
        ans += i*divs[i]
print(ans)

Solution (Python):
N = int(input())
if N == 1:
    print(1)
elif N == 2:
    print(5)
elif N == 3:
    print(11)
else:
    ans = N*(N+1)-1
    for i in range(2,N//2+1):
        t = N//i
        ans += i*(t*(t+1)//2-1)
    print(ans)

Solution (Python):
import sys
from collections import deque
import bisect

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()

    yaku = [0] * (N + 1)

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

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

    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

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

lis=[1 for i in range(10**7)]


for i in range(2,10**7+1):
    for j in range(1,(10**7)//i+1):
        lis[i*j-1]+=1
s=0
for i in range(n):
    s+=lis[i]*(i+1)

print(s)

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

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

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys  

if __name__=='__main__':
  n = int(sys.stdin.readline().rstrip())
  l = [0]*n
  ans = 0
  for i in range(n):
    for j in range(i,n,(i+1)):
      ans += j+1
  print(ans)

Solution (Python):
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())





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

print(answer)

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math


n = ni()

nums = [1]*(n+1)

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


cnt=0
for i in range(n+1):
  cnt+=nums[i]*i

print(cnt)

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

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

ans = 0

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

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