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):
from numba import njit, i8


@njit(i8(i8))
def solve(N):
    ans = 0
    for i in range(1, N + 1):
        j = N // i
        ans += j * (j + 1) // 2 * i
    return ans


N = int(input())
print(solve(N))

Solution (Python):
from numba import njit, i8


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


N = int(input())
print(solve(N))

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

Solution (Python):



from math import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq














import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
MAXN = 10**7+1
dp = [1] * (MAXN+1)
for i in range(2,MAXN+1):
    for j in range(i, MAXN+1,i):
        dp[j] += 1
n = I()
ans = 0
for i in range(1,n+1):
    ans += i * dp[i]
print(ans)

Solution (Python):

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

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


if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()

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):
    res = N // i
    ans += res*(res+1)//2*i
print(ans)

Solution (Python):
N = int(input())
L = [1]*(N+1)
for k in range(2,N+1):
    t = 1
    while k*t <= N:
        L[k*t] += 1
        t += 1
ans = 0
for k in range(1,N+1):
    ans += k*L[k]
print(ans)

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

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


ans = 0
for k in range(1, n+1):
    ans += k*X[k]
print(ans)

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

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


if __name__ == '__main__':
    main()

Solution (Python):




def solve():
    N = int(input())
    res = 0
    for i in range(1,N+1):
        k = N // i
        res +=i*(k+1)*k//2
    print(res)







if __name__ == '__main__':
    solve()

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

l=num_divisors_table(N)
ans=0

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

print(ans)

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





g=lambda x:(x*(n//x)*(n//x+1))//2
print(sum(g(i) for i in range(1,n+1)))

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

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

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

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

ans = 0
for n in range(1, N+1):
    for m in range(n, N+1, n):
        ans += m

print(ans)

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

div = [0] * (N + 1)
for n in range(1, N+1):
    for m in range(n, N+1, n):
        div[m] += 1

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

print(ans)

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

Solution (Python):
def solve(string):
    n = int(string)
    return str(sum(i * (n // i) * (n // i + 1) // 2 for i in range(1, n + 1)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

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

ans = 0
s = 1
for a in range(1, int(n ** .5) + 1):
    div = n // a
    ans += ((div + 1) * div // 2 - s) * a * 2 + a * a
    s += a + 1

print(ans)

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

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

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

def calc(start, end):
	n = end // start
	return (n * (n+1) // 2) * start

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

print(ans)

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
import numpy as np
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    divs = np.arange(1, n + 1)
    divs2 = n // divs
    divs3 = divs2 * (divs2 + 1) // 2
    divs3 = divs3 * divs
    r = divs3.sum()
    print(r)

if __name__ == '__main__':
    main()

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

def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    r = 0
    for i1 in range(1, n + 1):
        num_of_div = n // i1
        r += num_of_div * (num_of_div + 1) // 2 * i1
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
n = int(stdin.readline())
ans = 0
dp = [0]*(n+1)
for i in range(1,n+1):
    j = i
    while j <= n:
        dp[j] += 1
        j += i
for i in range(1,n+1):
    ans += dp[i]*i
print(ans)

Solution (Python):
from sys import stdin
n = int(stdin.readline())
ans = 0
for j in range(1,n+1):
    a = n//j
    ans += a*(a+1)*j//2
print(ans)

Solution (Python):
def g(n):
    ans = (n*(n+1))//2
    return ans

N = int(input())
ans = 0

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

print(ans)

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

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

for i in range(1, N + 1):

    cnt = N // i
    ans += (cnt * (cnt + 1) * i // 2) 

print(ans)

Solution (Python):
def main():
    N = int(input())
    ans = 0
    for x in range(1, int(N ** 0.5) + 1):
        
        e = N // x
        ans += x * (e * e + e - x * x)
    print(ans)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
def main():
    N = int(input())
    ans = 0
    for x in range(1, N + 1):
        
        e = N // x
        ans += x * e * (1 + e) // 2
    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):
    j = i
    while j <= n:
        ans += j
        j += i
print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
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()
res = [0]*(n+1)
for i in range(1,n+1):
    for j in range(1,n+1):
        if i*j > n: break
        res[i*j] += 1
print(sum(i*x for i,x in enumerate(res)))

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())


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

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

x=[-1]*(n+1) 
x[0]=0
x[1]=1
i=2
prime=[]
while i<=n:
    if x[i]==-1:
        x[i]=i
        prime.append(i)
    for j in prime:
        if i*j>n or j>x[i]:break
        x[j*i]=j
    i+=1

def f(k):
    z=[]
    if k==1:
        return 1
    p=x[k]
    c=1
    while k>1:
        if p!=x[k//p]:
            z.append(c)
            c=1
        else:
            c+=1

        k=k//p
        p=x[k]

    ans=1
    for i in range(len(z)):
        ans=ans*(z[i]+1)
    return ans
s=0
for i in range(n):
    s+=(i+1)*f(i+1)
print(s)

Solution (Python):
N = int(input())
memo = [1]*(N+1)
for i in range(2,N+1):
    tmp = i
    while tmp <= N:
        memo[tmp] += 1
        tmp += i
ans = 0
for key,val in enumerate(memo):
    ans += key*val
print(ans)

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

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

Solution (Python):
N = int(input())
ans = 0
for i in range(1,N+1): 
  first = i; kosu = N//i
  end = kosu*i
  temp = (first+end)*kosu//2
  ans += temp
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):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
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()
print(sum((i*(N//i)*(N//i+1)//2) for i in range(1,N+1)))

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

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

bp = [0] * (n+10)
for i in range(2, n+10):
    if bp[i] == 0:
        bp[i] = i
        for j in range(i*i, n+1, i):
            if bp[j]==0:
                bp[j] = i

def fact(n):
    ret=1
    while n>1:
        now=n
        cnt=0
        p=bp[now]
        while now % p == 0:
            now//=p
            cnt+=1
        ret*=cnt+1
        n=now
    return ret

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

print(ans)

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

bp = [0] * (n+10)
for i in range(2, n+10):
    if bp[i] == 0:
        bp[i] = i
        for j in range(i*i, n+1, i):
            bp[j] = i


def fact(n):
    ret=1
    while n>1:
        now=n
        cnt=0
        p=bp[now]
        while now % p == 0:
            now//=p
            cnt+=1
        ret*=cnt+1
        n=now
    return ret
ans=0
for i in range(1,n+1):
    ans += i*fact(i)

print(ans)

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

bp = [0] * (n+10)
for i in range(2, n+10):
    if bp[i] == 0:
        bp[i] = i
        for j in range(i*i, n+1, i):
            if bp[j]==0:
                bp[j] = i


def f(k):
    if k==1:
        return 1
    z=[]
    p=bp[k]
    cnt=1
    ans=1

    while k>=2:
        k//=p
        if p==bp[k]:
            cnt+=1
        else:

            ans*=cnt+1
            cnt=1
            p=bp[k]

    return ans

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

print(ans)

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

x=[-1]*(10**7+5)
x[0]=0
x[1]=1
i=2
prime=[]
while i<=10**7+1:

    if x[i]==-1:
        x[i]=i
        prime.append(i)

    for j in prime:
        if i*j>10**7+1 or j>x[i]:break
        x[j*i]=j
    i+=1



def f(k):
    if k==1:
        return 1

    z=[]
    p=x[k]
    m=1
    ans=1
    while k>=2:
        k=k//p
        if p==x[k]:
            m+=1
        else:
            z.append(m)
            m=1
            p=x[k]

    for i in range(len(z)):
        ans*=z[i]+1
    return ans
ans=0
for i in range(1,n+1):
    
    ans += i*f(i)

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())
ans = 0
for i in range(1,n+1):
    ans += ((i+i*(n//i))*(n//i))//2
    
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):
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 math , sys

N = int(input())
Ns = int(math.sqrt(N))+1
if N == 1:
    print(1)
    sys.exit()
if N == 2:
    print(5)
    sys.exit()
if N == 3:
    print(11)
    sys.exit()
if N == 4:
    print(23)
    sys.exit()
if N == 5:
    print(33)
    sys.exit()  

ans = [ 2 for _ in range(N+1)]
ans[0]=0
ans[1]=1
for i in range(2,Ns):
    num=i
    while num < N+1:
        if math.sqrt(num)<i:
            flag=True
        elif num == i**2:
            ans[num]+=1
        else:
            ans[num]+=2
        num+=i
tot = 0
for i in range(N+1):
    tot+=i*ans[i]
print(tot)

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

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

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

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):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        ans += i*(1 + n//i)*(n//i)//2
    print(ans)



if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        ans += i*(1 + n//i)*(n//i)//2
    print(ans)



if __name__=='__main__':
    main()

Solution (Python):
def g(k):
    gans = k*(k+1)/2
    return gans
N = int(input())
ans = 0
for i in range(1,N+1):
    ans += i*g(N//i)
    
 
print(int(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 j in range(1,N+1):
  N_j = N//j
  ans += j*(1+N_j)*N_j//2
print(ans)

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

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

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




'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''


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

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




'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''


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