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

Solution (Python):
import math
import time

N=int(input())

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

print(sum)

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

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

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

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

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

result = 0
for i in range(1, n + 1):
    for j in range(1, (n // i) + 1):
        result += i * j
print(result)

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

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

print(ans)

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

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())
s = 0
for d in range(1, n+1):
    for k in range(d, n+1, d): s += k
print(s)

Solution (Python):
n = int(input())
f = [0]*(n+1)
for d in range(1, n+1):
    for k in range(d, n+1, d): f[k] += 1
s = 0
for k in range(1, n+1): s += k * f[k]
print(s)

Solution (Python):
import functools

n = int(input())
print(functools.reduce(lambda i, j: i + ((n // j) + 1) * (n // j) * j // 2, range(n + 1)))

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

Solution (Python):
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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

def T(i):
    return i * (i + 1) // 2


def solve():
    
    
    
    
    
        
            
        
    

    
    
    n = ri()
    if n in [1,2,3]:
        print ({1:1, 2:5, 3:11}[n])
        return

    sq = int(n**0.5)
    ans = 0
    for i in range(1, sq + 1):
        
        ans += i * T(n // i)
        ans += T(i) * (T(n // i) - T(n // (i + 1)))

    if sq * (sq + 1) > n:
        ans -= sq * T(n // sq)
    print (ans)





mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

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

Solution (Python):


N = int(input().strip())


ans = 0

for k in range(1, N+1):
    quot = N // k  
    num_divisor = quot * (quot + 1) // 2
    
    ans += k * num_divisor


print(ans)

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

if __name__ == "__main__":
    main()

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

s,k,n = 0,1,N
while k<=n:
	m = N//k
	s += (k-1)*k*(n-m)*(n+m+1)//2
	s += k*m*(m+1)
	k,n = k+1,m
if m<k-1:
	s -= (k-1)*m*(m+1) 
print(s//2)

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

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

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):
def tousa(b,l):
    cnt=l//b
    s=(b+l)*cnt//2
    return s

n=int(input())
ans=0
for k in range(1,n+1):
    N=n//k
    ans+=tousa(k,k*N)
print(ans)

Solution (Python):
import sys
read = sys.stdin.read
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    
    r = 0
    for i1 in range(1, n + 1):
        y = n // i1
        r += y * (y + 1) * i1 / 2
    print(int(r))

if __name__ == '__main__':
    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) >> 1

print(res)

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

print(res)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')








 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()

ans=0

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

Solution (Python):
import sys
read = sys.stdin.read
from math import sqrt, floor
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    
    nd = [2] * (n + 1)

    for i1 in range(2, floor(n / 2) + 1):
        for i2 in range(i1 * 2, n + 1, i1):
            nd[i2] += 1

    r = 1
    for j1 in range(2, n + 1):
        r += nd[j1] * j1
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n = readint()

print(sum([k*(n//k)*(n//k+1)//2 for k in range(1,n+1)]))

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

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())
l = list(range(1, N+1))


def calc(i):
    return (i + N//i * i) * (N//i) // 2


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

print(ans)

Solution (Python):
N = int(input())
l = list(range(1, N+1))


def calc(i):
    return sum(list(range(i, N+1, i)))


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

print(ans)

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

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

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

    def ggg():
        for divisor in range(1, num + 1):
            quotient = num // divisor
            yield (quotient + 1) * quotient * divisor // 2

    print(sum(ggg()))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    num = int(input())
    ans = 0

    for divisor in range(1, num + 1):
        quotient = num // divisor
        ans += (quotient + 1) * quotient * divisor // 2

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    num = int(input())
    gg = ((
        (quotient := num // divisor) + 1) * quotient * divisor // 2
        for divisor in range(1, num + 1))
    print(sum(gg))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    num = int(input())
    ans = 0

    for divisor in range(1, num + 1):
        quotient = num // divisor
        ans += (quotient + 1) * quotient * divisor // 2

    print(ans)


if __name__ == '__main__':
    main()

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

ans = 0

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

print(ans)

Solution (Python):
import sys
import math


def main():
    N = int(sys.stdin.readline().rstrip())

    sum_ = 0

    for i in range(1, int(math.sqrt(N)) + 1):

        sum_ += i**2

        k1 = N // i
        

        k1_sum = k1 * (k1 + 1) // 2
        k2_sum = i * (i + 1) // 2
        sum_ += 2 * i * (k1_sum - k2_sum)

    print(sum_)


main()

Solution (Python):
"""
// Author : snape_here - Susanta Mukherjee
     
 """
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 

def isPrime(n):
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

from math import *

import bisect

from decimal import *

getcontext().prec = 50

abc="abcdefghijklmnopqrstuvwxyz"

pi=3.141592653589793238

l=[0]*10000005

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

def main():

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



 
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")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 

 
 
if __name__ == "__main__":
    
    main()

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

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

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

answer = 0
n = int(input())
for i in range(1, n+1):
  answer += i * f(n//i)

print(answer)

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

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

print(answer)

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

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

if __name__ == '__main__':
    main()

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)

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

print(sum([n * (N // n) * (N // n + 1) // 2 for n in range(1, N + 1)]))

Solution (Python):
n = int(input())
from math import ceil
def g(x, n):
    y = n // x
    return int(x * (y + 1) * y /2 )
print(sum(g(i+1, n) for i in range(n)))

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

class unionfind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.size = [1 for i in range(n)]
    def find(self,a):
        if a == self.parent[a]: return a
        else: self.parent[a] = find(self,self.parent[a]); return self.parent[a]
    def unite(self,a,b):
        pa,pb = self.find(self,a), self.find(self,b)
        if pa == pb: return
        else: self.parent[pb] = pa; self.size[pa] += self.size[pb]
    def same(self,a,b): return find(self,a) == find(self,b)

n = iinput()
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())

total = 0

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

print(total)

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

Solution (Python):
def II(): return int(input())
N=II()
ans=0
def calc(b,e):
  cnt=e//b
  return (b+e)*cnt//2
for i in range(1,N+1):
  ans+=calc(i,N//i*i)
print(ans)

Solution (Python):
N=int(input())
from numba import*
@njit('i8(i8)',cache=1)
def f(N):
    d=[1]*N
    for i in range(2,N+1):
        for j in range(i-1,N,i):
            d[j]+=1
    r=0
    for i in range(N):
        r+=(i+1)*d[i]
    return r
print(f(N))

Solution (Python):

N = int(input())
div_cnt = [0 for i in range(10**7+1)]
for i in range(1, 10**7+1):
    c = i
    while c <= 10**7:
        div_cnt[c] += 1
        c += i
ans = 0
for i in range(1, N+1):
    ans += i*div_cnt[i]
print(ans)

Solution (Python):
def f():n=int(input());print(sum(m*((g:=n//m)**2+g-m**2)for m in range(1,int(n**.5)+1)))
if __name__=="__main__":f()

Solution (Python):
def j(n):
    print(sum(m*((n//m)**2+n//m-m**2) for m in range(1,int(n**.5)+1)))

if __name__ == "__main__":
    j(int(input()))

Solution (Python):
n=int(input());print(sum(m*((g:=n//m)**2+g-m**2)for m in range(1,int(n**.5)+1)))

Solution (Python):
from numba import jit
n = int(input())
@jit
def main(n):
    ans = 0
    for i in range(1, n+1):
        ans += i * (n//i) * (n//i + 1) //2
    print(ans)
main(n)

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

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

print(int(total))

Solution (Python):
import sys
import math
from collections import deque
input = sys.stdin.readline


N = int(input())

A = [0]
B = []

Answer = 0

j = 1;
while j*j<=N:
    A.append(j)
    if N//j != j:
        B.append(N//j)
    j+=1

B.reverse()
A =  A + B

Answer = 0
for i in range(1,len(A)):
    num = ((N//A[i])*(N//A[i]+1)//2)
    num *= ((A[i]*(A[i]+1)//2)-(A[i-1]*(A[i-1]+1)//2))
    Answer += num

print(Answer)

Solution (Python):
def calc(b,e):
  cnt=e//b
  return (b+e)*cnt//2
def II(): return int(input())
N=II()
ans=0
for i in range(1,N+1):  
  ans+=calc(i,N//i*i)
print(ans)

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

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

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

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

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)