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



n = int(input())
ans = n * (n + 1) - 1  

i = 2
while i * i <= n:
    num = n // i
    min_i = i * i
    max_i = i * num
    ans += (num - i + 1) * (min_i + max_i)  
    ans -= min_i
    i += 1
print(ans)

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

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

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

Solution (Python):
N=int(input())
A=[]
for i in range(1,N+1):
    x=N//i
    y=i*x*(x+1)/2
    A.append(y)
print(int(sum(A)))

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))

def main():
    n = II()
    res = 0
    for i in range(1,n+1):
        y = n//i
        res += y*(y+1)*i//2
    print(res)


if __name__ == '__main__':
    main()

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 i in range(n):
  i=i+1
  a=i
  y=n//i
 
  ans+=(i*y*(y+1)/2)
 
 
 
print(int(ans))

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

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

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

Solution (Python):


from functools import reduce
from operator import mul
from collections import defaultdict, Counter
from heapq import heappush, heappop
import sys
from math import sqrt, floor

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  


def debug(*x):
    print(*x)


def solve(N):
    ret = 0
    for i in range(1, N + 1):
        num = N // i
        end = num * i
        ret += (i + end) * num // 2
    print(ret)


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


def _test():
    """
    >>> solve(4)
    23

    >>> solve(100)
    26879

    >>> solve(10000000)
    838627288460105
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        
        
        from my_module import solve  
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()

Solution (Python):
soe = [0]*(10**7+1)
soe[1] = 1
for i in range(2,10**7+1):
    if soe[i]==0:
        for j in range(i,10**7+1,i):
            if soe[j]==0:
                soe[j]=i
n = int(input())
res = 0
for i in range(1,n+1):
    t = i
    d = dict()
    ans = 1
    
    while soe[t]!=t:
        d[soe[t]]=d.get(soe[t],0)+1
        t//=soe[t]
    if t!=1:
        d[soe[t]]=d.get(soe[t],0)+1
    for j in d:
        ans*=(d[j]+1)
    
    res+=ans*i

print(res)

Solution (Python):
import sys

from numba import njit

input = sys.stdin.readline


@njit
def make_n_divisor_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():
    N = int(input())

    table = make_n_divisor_table(N)

    ans = 0
    for i, v in enumerate(table):
        ans += i * v

    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
import math
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

    v = int(math.sqrt(N))

    for i in range(2, v+1):
        u = i
        for j in range(2, N//i+1):
            u += i
            d[u] += 1 + (j > v)

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

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

Solution (Python):
'''
- f(X)のイメージ

x軸: 正整数, y軸: 約数

                    10 ... every 10
                  9    ... every 9
                8      ... every 8
              7        ... every 7
            6          ... every 6
          5          5 ... every 5
        4       4      ... every 4
      3     3     3    ... every 3
    2   2   2   2    2 ... every 2
  1 1 1 1 1 1 1 1 1  1 ... every 1

問題は Σ^N_{K=1} K × f(K) なので
約数の数f(K)にKが掛かっている。

なので上のイメージを少し変更して

                    10 ... Σ^floor(N/10)_{K=1} 10*K
                  9    ...
                8      ...
              7        ...
            6          ...
          5         10 ...
        4       8      ...
      3     6     9    ...
    2   4   6   8   10 ... Σ^floor(N/2)_{K=1} 2*K
  1 2 3 4 5 6 7 8 9 10 ... Σ^floor(N/1)_{K=1} 1*K

これの総和を求めれば良い。

=> Σ^N_{K=1} Σ^{floor(N/K)}_{L=1} K*L
'''
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())
ans = 0
for i in range(1, n + 1):
    p = n // i
    ans += p * (p + 1) * i // 2
print(ans)

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

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

print(ans)

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

Solution (Python):

from numba import njit


@njit
def solve(N):
    res = 0
    for a in range(1, N + 1):
        for b in range(1, N // a + 1):
            res += a * b
    return res


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


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
ans = [0] * (n+1)
for i in range(1,n+1):
    for j in range(1,n+1):
        if i*j > n: break
        ans[i*j] += 1
res = 0
for i in range(1,n+1):
    res += i*ans[i]
print(res)

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

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

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

print(ans)

Solution (Python):
import math
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

    v = int(math.sqrt(N))
    for i in range(2, N//2+1):
        for j in range(i+i, N+1, i):
            d[j] += 1

    
    
    
    
    

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

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

Solution (Python):

def main():
    N = int(input())
    res = 0
    for a in range(1, N + 1):
        for b in range(1, N // a + 1):
            res += a * b
    print(res)


if __name__ == "__main__":
    main()

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

Solution (Python):
import math
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

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

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

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

Solution (Python):
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

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

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

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

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

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

print(res)

Solution (Python):




import sys
input = sys.stdin.readline

from numba import njit,i8


@njit(i8(i8))
def sum_g(N):
    res = 0
    for i in range(1,N+1):
        end = N // i
        res += end * (end + 1) * i // 2
    return res


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

    res = sum_g(N)

    print(res)


main()

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

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

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

print(res)

Solution (Python):




import sys
input = sys.stdin.readline

from numba import njit


@njit
def sum_g(N):
    res = 0
    for i in range(1,N+1):
        end = N // i
        res += end * (end + 1) * i // 2
    return res


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

    res = sum_g(N)

    print(res) 


main()

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

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

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

Solution (Python):




import sys
input = sys.stdin.readline



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

    res = 0

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

    print(res) 




main()

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

summation = 0
for j in range(1, N+1):
    Y = N//j
    
    summation += Y*(1+Y)*j/2

print(int(summation))

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

N = int(input())

sum = 0
for k in range(1, N+1):
    for i in range(k, N+1, k):
        sum += i

print(sum)

Solution (Python):
import sys

N = int(sys.stdin.readline().strip())

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

print(ans)

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

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

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

print(ans)

Solution (Python):

N = int(input())

factors = [0] * (N + 1)

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

total = 1

for i in range(2, N + 1):
	table = {}
	j = i
	while j > 1:
		f = factors[j]
		if f in table:
			table[f] += 1
		else:
			table[f] = 1
		
		j //= f
	count = 1
	for c in table.values():
		count *= (c + 1)
	total += i * count

print(total)

Solution (Python):
import sys

N = int(sys.stdin.readline().strip())

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

print(ans)

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

ans = n * (n + 1) // 2

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

print(ans)

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

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

print(res)

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

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

print(res)

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):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



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

Solution (Python):


def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = II()

    ans = 0
    sqrt = int(N ** 0.5)

    for m in range(1, sqrt + 1):
        b = N//m
        ans += m * (m + b) * (b + 1 - m)
    ans -= sqrt * (sqrt + 1) * (2 * sqrt + 1) // 6
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        target = i
        current = 1
        while True:
            target = i * current
            current += 1
            if target > N:
                break
            ans += target
    print(ans)
if __name__ == "__main__":
    main()

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

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


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

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

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

print(ans)

Solution (Python):
from numba import jit, i8, void


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


@jit(i8(i8))
def solve(n):
    ans = 0
    for i in range(1, n + 1):
        ans += i * g(n // i)
    return ans

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


main()

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N = int(input().strip())
    return N,


@njit
def solve(N):
    ndivs = 0
    for i in range(1, N+1):
        for j in range(i, N+1, i):
            ndivs += j
    return ndivs


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

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):
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):
def f(n):
    return n * (n+1) // 2

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

Solution (Python):
n = int(input())
num = [0 for i in range(n + 1)]
for i in range(n):
    for j in range(n // (i + 1)):
        num[(i + 1) * (j + 1)] += 1
ans = 0
for i in range(n):
    ans += (i + 1) * num[i + 1]
print(ans)

Solution (Python):
n = int(input())
f = [1] * (n + 1)
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):
from sys import stdin
input = stdin.readline

N = int(input())

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

ans = 0

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

print(ans)

Solution (Python):
from numba import jit, i8, void


@jit(i8(i8))
def g(n):
    return n * (n + 1) // 2


@jit(i8(i8))
def solve(n):
    ans = 0
    for i in range(1, n + 1):
        ans += i * g(n // i)
    return ans

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


main()

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

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

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

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):
a,n=0,int(input())+1
for i in range(1,n):
  for j in range(i,n,i): a+=j
print(a)

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache





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






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


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


def DD(arg): return defaultdict(arg)


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


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


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


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


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


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


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


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]


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




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

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

Solution (Python):
import numpy as np

def solve(stdin):
    n = stdin[0]
    dp = np.zeros(n+1,dtype=np.int64)
    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()

def main():
    stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=' ')
    print(solve(stdin))

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()

if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import solve
    main()

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

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

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

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

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





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

Solution (Python):

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

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





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

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

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

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

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

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

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

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

Solution (Python):

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)

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

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

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

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

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

Solution (Python):

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

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

Solution (Python):

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)

Solution (Python):

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)

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

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

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

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

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

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

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

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

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

Solution (Python):

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

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

Solution (Python):


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