Problem:
 Score : 400 points    Problem Statement For a positive integer X , let f(X) be the number of positive divisors of X .  Given a positive integer N , find \sum_{K=1}^N K\times f(K) .      Constraints  1 \leq N \leq 10^7         Input Input is given from Standard Input in the following format:  N       Output Print the value \sum_{K=1}^N K\times f(K) .        Sample Input 1 4      Sample Output 1 23  We have f(1)=1 , f(2)=2 , f(3)=2 , and f(4)=3 , so the answer is 1\times 1 + 2\times 2 + 3\times 2 + 4\times 3 =23 .       Sample Input 2 100      Sample Output 2 26879       Sample Input 3 10000000      Sample Output 3 838627288460105  Watch out for overflows.

Solution (Python):
import sys
import numpy as np

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

def prime_table(N):
    is_prime = np.zeros(N, np.int64)
    is_prime[2:3] = 1
    is_prime[3::2] = 1
    for p in range(3, N, 2):
        if p * p >= N:
            break
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, np.where(is_prime)[0]

def main(N, primes):
    div = np.ones(N + 1, dtype=np.int64)
    for p in primes:
        for i in range(N // p + 1):
            div[p * i] += div[i]
    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, i8[:]))
    cc.compile()

from my_module import main

N = int(read())
is_prime, primes = prime_table(N + 1)
print(main(N, primes))

Solution (Python):
import sys


import math


input = sys.stdin.readline




def main():

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

    print(ans)





if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
n = II()
d = [0]+[1]*n
for i in range(2,n+1):
	for j in range(i,n+1,i):
		d[j]+=1
for i in range(1,n+1):
	d[i]*=i
	d[i]+=d[i-1]
print(d[n])

Solution (Python):
n = int(input())
div = [2 for _ in range(n)]
div[0] = 1
ans = 1
for num in range(2, n + 1):
    ans += num * div[num - 1]
    tmp = num - 1
    while 1:
        tmp += num
        try:
            div[tmp] += 1
        except IndexError:
            break
print(ans)

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

CNT = [1] * (N + 1)

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

print(ans)

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

c = [1 for i in range(n+1)]
c [0] = 0
if n == 1:
  print (1)
  exit()

for i in range(2,n+1):
  x = i
  while x <= n:
    c[x] += 1
    x += i
s = 0
for i in range(n+1):
  s += i * c[i]
print (s)

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

if __name__ == "__main__":
    main()

Solution (Python):
import sys


import math


input = sys.stdin.readline




def main():

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

    print(ans)





if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys


import math


input = sys.stdin.readline




def main():

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

    print(ans)





if __name__ == "__main__":
    main()

Solution (Python):
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys

def solve():
      input = sys.stdin.readline
      X = int(input())
      Count = [1] * (X + 1)
      if X == 1: print(1)
      else:
            ans = 1
            for i in range(2, X + 1):
                  Count[i] += 1
                  ans += Count[i] * i
                  d = i * 2
                  while d <= X:
                        Count[d] += 1
                        d += i
            print(ans)


      return 0

if __name__ == "__main__":
      solve()

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

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

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

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

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

Solution (Python):

import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

def div(n): 
    div = [0 for i in range(n + 1)] 
    for i in range(1,n+1): 
        for j in range(i,n+1,i): 
            div[j] += 1
    return div

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

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

Solution (Python):

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    cnt=[1]*(N+1)
    
    M=1+(N//2)
    if N%2==1:
        M+=1
    for i in range(1,M):
        temp=2*i
        while temp<=N:
            cnt[temp]+=1
            temp+=i
            
    ans=0
    for i in range(1,N+1):
        ans+=cnt[i]*i
    print(ans)

main()

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

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

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

ans = [0] * (n + 1)

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

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=[1]*(10**7+1)
if n==1:
    print(1)
    exit()
ans=1
for i in range(2,n+1):
    k=0
    while i*k<10**7+1:
        l[i*k]+=1
        k+=1
    ans+=i*l[i]
print(ans)

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


N = int(input())

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

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


print(int(ans))

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

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

Solution (Python):
(N,) = [int(x) for x in input().split()]

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

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

print(total)

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

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

print(s)

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):
import math
N = int(input())
sieve = [-1] * (N + 1)
sieve[0] = sieve[1] = 0
maxPrime = int(math.sqrt(N))
for i in range(maxPrime + 1):
    if sieve[i] != -1:
        continue
    else:
        index = i * i
        while True:
            if index > N:
                break
            sieve[index] = i
            index += i

ans = 1
for i in range(2,N+1):
    if sieve[i] == -1:
        ans += 2 * i
    else:
        primeFactorList = []
        index = i
        while sieve[index] != -1:
            primeFactorList.append(sieve[index])
            index //= sieve[index]
        primeFactorList.append(index)
        primeFactorList.sort()
        lastIndex = 0
        curans = 1
        for j in range(1,len(primeFactorList)):
            if primeFactorList[j] != primeFactorList[j-1]:
                curans *= (j - lastIndex + 1)
                lastIndex = j
        curans *= len(primeFactorList) - lastIndex + 1
        ans += curans * i
print(ans)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
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)
mod = 1000000007

def solve():
    N = I()
    f = [1]*(N+1)
    for p in range(2,N+1):
        f[p] += 1
        j = 2*p
        fp = f[p]
        while j <= N:
            f[j] += 1
            j += p
    ans = 0
    for i in range(1,N+1):
        ans += i*f[i]
    print(ans)
    return


if __name__ == "__main__":
    solve()

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

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

def main():

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

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

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

    print(res)

if __name__ == "__main__":
    main()

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

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

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
from itertools import *
s=[*accumulate(range(n+1))]
a=0
for i in range(1,n+1):
  a+=i*s[n//i]
print(a)

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

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

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int,readline().split())

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

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

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

Solution (Python):

import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys


buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    c = [1] * (N+1)
    for i in range(2, N+1):
        for j in range(i, N+1, i):
            c[j] += 1
    
    ans = 0
    for i in range(1, N+1):
        ans += i * c[i]
    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = [0 for _ in range(n+1)]
ans = 0
for i in range(1,n+1):
  now = 0
  while True:
    try:
      now += i
      a[now] += 1
    except:
      break
  ans += i*a[i]
print(ans)

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

memo = [2] * (n+1)
memo[1] = 1

for k in range(2, n // 2 + 2):
    for i in range(2, n):
        if k * i > n:
            break
        memo[k*i] += 1

ans = 0
for i, memoi in enumerate(memo):
    ans += i * memoi
print(ans)

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

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

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

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

print(ans)

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

ret = 0
for i in range(1, N + 1) :
  j = N // i
  if j < 1 :
    break
  ret += (1 + j) * i * j // 2
  
print(ret)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

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

    print(ans)





if __name__ == "__main__":
    main()

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):
N = int(input())
ans = 0

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

print(ans)

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

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

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

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

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

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

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

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

count=[1]*(n+1)

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

ans=0

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

print(ans)

Solution (Python):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


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

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

    print(res)


if __name__ == "__main__":
    main()

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

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