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 fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











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

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
import math


n = I()
ans = 0
yaku = [1] *(10**7+1)
yaku[0] = 0
yaku[1] = 1
for i in range(1,n+1):
    for j in range(i*2,n+1,i):
        yaku[j] += 1
for i in range(1,n+1):
    y = yaku[i]
    ans += i * y
print(ans)

Solution (Python):

import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

    
def main():
    n = ni()
    ans = 0
    for x in range(1,n+1):
        nx = n//x
        ans += (nx+1)*nx*x//2
    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    N=int(sys.stdin.readline())
    r=0
    for i in range(1,N+1):
        r+=(i+N-N%i)*(N//i)//2

    print(r)

    
main()

Solution (Python):
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

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

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

Solution (Python):
import sys  
 
if __name__=='__main__':
  n = int(sys.stdin.readline().rstrip())
  ans = 0
  for i in range(n):
    for j in range(i,n,(i+1)):
      ans += j+1
  print(ans)

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

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

print(ans)

Solution (Python):
n=int(input())
a = [i for i in range(n+1)]
res=0
time = 0
for i in range(1,n+1):
  cnt = n // a[i]
  res += a[i]*cnt*(cnt+1)//2
  

print(res)

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

Solution (Python):
def main():
  n = int(input())
  ans = 0
  SQRT = int(n ** 0.5)
  for m in range(1,SQRT + 1):
    b = int(n/m)
    ans += m * (m + b) * (b + 1 - m)
  ans -= SQRT * (SQRT+1) * (2*SQRT+1) // 6
  print(ans)
main()

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

Solution (Python):



MAX = 10000001; 



factor = [0]*(MAX + 1); 




def generatePrimeFactors(): 
	factor[1] = 1; 

	
	
	for i in range(2,MAX): 
		factor[i] = i; 

	
	
	for i in range(4,MAX,2): 
		factor[i] = 2; 

	
	
	
	
	
	i = 3; 
	while(i * i < MAX): 
		
		
		if (factor[i] == i): 
			
			
			j = i * i; 
			while(j < MAX): 
				
				
				
				if (factor[j] == j): 
					factor[j] = i; 
				j += i; 
		i+=1; 



def calculateNoOFactors(n): 
	if (n == 1): 
		return 1; 
	ans = 1; 

	
	
	
	dup = factor[n]; 

	
	
	
	c = 1; 

	
	
	
	j = int(n / factor[n]); 

	
	
	while (j > 1): 
		
		
		
		
		if (factor[j] == dup): 
			c += 1; 

		
		
		
		
		
		
		else: 
			dup = factor[j]; 
			ans = ans * (c + 1); 
			c = 1; 

		
		
		j = int(j / factor[j]); 

	
	
	ans = ans * (c + 1); 

	return ans; 



n=int(input())

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


print(ans)

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

Solution (Python):
n = int(input())
ans = 0
SQRT = int(n ** 0.5)
for m in range(1,SQRT + 1):
    b = int(n/m)
    ans += m * (m + b) * (b + 1 - m)
ans -= SQRT * (SQRT+1) * (2*SQRT+1) // 6
print(ans)

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

Solution (Python):
import math 
def num_divisors_table(n):
  maxnum=math.floor((n + 1)/2) 
  
  length=n-maxnum
  aftersum=int(maxnum*length+length*(length+1)/2)
  aftersum+=(1+n)*n/2
  if n>=2:
    if n%2==0:
      aftersum+=(1+n/2)*n/2
    else:
      aftersum+=(1+(n-1)/2)*(n-1)/2

  for i in range(3, maxnum+1):
    for j in range(i, n+1, i):
      aftersum += j
      
  return aftersum

N=int(input())


print(int(num_divisors_table(N)))

Solution (Python):
n= int(input())
dp=[1]*n

for i in range(2, n+1):
    k=1
    while i*k<=n:
        dp[i*k-1]+=1
        k+=1
ans = 0
for i in range(1, n+1):
    ans+=i*dp[i-1]
print(ans)

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

import math
def divisor(n):
    a = set()
    for i in range(1, math.ceil(n**0.5) + 1):
        if n % i == 0:
            a.add(i)
            a.add(n // i)
    return a
x = [0] * (n+1)
for i in range(1, n+1):
    for j in range(i, n+1, i):
        x[j] += 1
ans = 0
for i in range(n+1):
    
    ans += (i * x[i])
print(ans)

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

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

def calc():
  n=int(input())
  table=[1]*(n+1)
  check=[False]*(n+1)
  for i in range(2,n+1):
    if check[i]==True:
      continue
    check[i]=True
    for j in range(1,n//i+1):
      check[i*j]=True
      tmp=j
      cnt=1
      while tmp%i==0:
        tmp//=i
        cnt+=1
      table[i*j]*=(i**cnt)*(cnt+1)
  print(sum(table)-1)
calc()

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

ans = 0

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

Solution (Python):
import math
N = int(input())
 
cnt = 0
for i in range(1, int(math.sqrt(N)+1)):
    sub = N//i
    cnt += (sub-i+1)*(sub+i)*i - i**2
cnt = int(cnt)
print(cnt)

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

b = int(a**0.5)+1

res = 0
for i in range(1,a//2+1):
    x = a//i
    y = i*x
    z = (i+y)*x //2
    res += z
zz = (a+a//2+1)*(a-a//2)//2
res +=zz

print(res)

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  
from functools import reduce
from math import gcd


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




def ret_eratos(N: int):
    '''エラトステネスの篩'''
    '''is_primeは約数の個数'''
    is_prime = [0] * (N + 1)
    is_prime[0] = -2  
    is_prime[1] = -1
    for i in range(2, N // 2 + 1):
        for j in range(i * 2, N + 1, i):  
            is_prime[j] += 1
    for i in range(N + 1):
        is_prime[i] += 2
    return is_prime


N = a_int()
eratos = ret_eratos(N)

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

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

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

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

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


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 [i for i in range(n + 1) if is_prime[i]]


def main():
    N = NI()


    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
    D = num_divisors_table(N)
    ans = 0
    for i in range(1, N+1):
        ans += D[i] * i
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
def gcd_cnt(n):
    sub = 0
    for i in range(1, n+1):
        kosuu = n//i
        sub+=kosuu*(2*i + (kosuu-1)*i)//2
    return sub

n = int(input())
sub = gcd_cnt(n)
print(sub)

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

print(int(ans/2))

Solution (Python):
n=int(input())
f=[2-x%2 for x in range(n+1)]
s=5
for c in range(3,n+1):
    for d in range(1,n//c+1):
        f[c*d]+=1
    s+=c*f[c]
if n==1:
    print(1)
elif n==2:
    print(5)
else:
    print(s)

Solution (Python):
n = int(input())
sum = 0;

nn = n//2;
nnn = n-nn
if n <= 5000000:
    for i in range(1,n+1):
        x = n//i;
        sum += i*x*(x+1)//2;
else:
    for i in range(1,5000000+1):
        x = n//i;
        sum += i*x*(x+1)//2;
    sum += (n-5000000)*(5000001+n)//2;
print(sum);

Solution (Python):
from math import sqrt

n = int(input())
ans = 0
divisor = [0 for _ in range(n+1)]
for k in range(1, n+1):
    i = 1
    while 1:
        divisor[k*i] += 1
        i += 1
        if k*i > n:
            break
for i in range(1, n+1):
    ans += i * divisor[i]
print(ans)

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

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

print(ans)

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

print(int(ans/2))

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
def main():
    N = int(input())
    tmp = num_divisors_table(N)
    ans = 0
    for i in range(1,N+1):
        ans += i * tmp[i]

    print(ans)





if __name__ == "__main__":
    main()

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

Solution (Python):


import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

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

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

if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
div_table = [1]*(n+1)
div_table[0] = 0
for i in range(2, n+1):
    j = i
    while j < n+1:
        div_table[j] += 1
        j += i

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

print(ans)

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

l = [1] * (n + 1)
res = 1

for i in range (2, n + 1):
    x = i
    while x < n + 1:
        l[x] += 1
        x += i


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

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

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] += j
    
    return table

n=int(input())
print(sum(num_divisors_table(n)))

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd, sqrt
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



def prime_decomposition(n):
    table = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            table += [i]
            n //= i
        if n == 1:
            break
    if n != 1:
        table += [n]
    return table

n = I()

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




print(ans)

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

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

Solution (Python):
N = int(input())
 
sum = 0
ro = 1
for n in range(1,N+1):
    num = int(N/n)
    if num == 1:
        record = n
        break
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1


sum += int(((record+N)*(N-record+1))/2)
print(sum)

Solution (Python):
import math
N = int(input())
S = 0
for i in range(N):
  j = i + 1
  m = math.floor(N/j)
  S += j*(1/2)*m*(m+1)
print(int(S))

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

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math
from collections import deque
import itertools
import heapq

from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint




def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default




def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    n=int(input())
    a=[0 for i in range(10**7+1)]
    total=0
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            a[j]+=1
        total+=i*a[i]
    print(total)


if __name__ == "__main__":

    main()

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

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

table = num_divisors_table(N)

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

print(ans)

Solution (Python):


import sys
import math
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)



def main():
	log = Logger(0)
	n = int(sys.stdin.readline())
	a = [1]*n
	if n == 1:
		print(1)
		exit()
	for i in range(2, n+1):
		for j in range(i, n+1, i):
			a[j-1] += 1
	log.print(a)
	ans = 0
	for i in range(n):
		ans += a[i] * (i+1)
	print(ans)




main()

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

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

Solution (Python):
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

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

if __name__ == "__main__":
    main()

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

def main():
    n = int(input())
    
    fact = [2]*(n+1)
    fact[1] = 1

    for i in range(2, n+1):
        if n < i*i:
            break
        else:
            fact[i*i] += 1

        for j in range(i+1, n+1):
            now = i*j
            if now <= n:
                fact[i*j] += 2
            else:
                break
    
    ans = 0
    for i in range(1, n+1):
        ans += i * fact[i]

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Solution (Python):
def main():
    n = int(input())
    A = [1] * (n + 1)
    ans = 1
    for i in range(2, n + 1):
        if A[i] == 1:
            m = i ** 2
            j = 2
            for a in range(i, n + 1, i):
                if a == m:
                    A[a] *= (j + 1)
                    m *= i
                    j += 1
                else:
                    count = 1
                    k = a // i
                    while k % i == 0:
                        k = k // i
                        count += 1
                    A[a] *= (count + 1)
            ans += 2 * i
        else:
            ans += A[i] * i
    print(ans)
if __name__ == '__main__':
    main()

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

for i in range(2, n + 1):
    cnt = 1
    while i * cnt <= n:
        div[i * cnt] += 1
        cnt += 1
print(sum([x * y for x, y in enumerate(div)]))

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

Solution (Python):
n=int(input())
if n==1:
    print(1)
else:
    r=1+(n*(n+1)//2-1)*2
    for i in range(2, int(n**0.5)+1):
        for j in range(i*i, n+1, i):
            if i**2!=j:
                r+=2*j
            else:
                r=r+j
    print(r)

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

Solution (Python):


def main():
    N = int(input())
    if N==1:
        print(1)
        exit()
    elif N==2:
        print(5)
        exit()

    divs = [1]*(N+10)

    for i in range(2, N+1):
        max_t = N // i
        for j in range(1, max_t+1):
            val = i*j
            divs[val] += 1
    ans = 0
    for i in range(1, N+1):
        ans += i * divs[i]
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
table = [1] * (N + 1)
res = 0
for x in range(1, N + 1):
  res += table[x] * x
  for y in range(x * 2, N + 1, x): table[y] += 1
print(res)

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

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

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

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


print(ans)

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

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

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

ans=0

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

print(ans)

Solution (Python):
def x(a, N): 
    m = N // a 
    sum = m * (m + 1) // 2
    ans = a * sum
  
    return ans
         
c = 0
num = int(input())
for i in range(1, num + 1):
    c += x(i, num)
print(c)

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())
X = num_divisors_table(N)
sum = 0
for i in range(N):
  sum += (i+1) * X[i+1]

print(sum)

Solution (Python):
N = int(input())
M = 0
r = 0
if N>1000000:
    M = N


for i in range(min(N,1000000)):
    m = i + 1
    j = int(N/(m))
    r = r + int(m*j*(1+j)/2)

if M!=0:
    for i in range(10):
        k = int(M/(i+1))
        if k > 1000000:
            r = r + (i+1)*int((k-1000000)*(k+1000001)/2)

print(r)

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

Solution (Python):
def main():
    n = int(input())
    y = [0]*(n+1)
    for i in range(1,n+1):
        j = 1
        while True:
            if i*j > n:
                break
            y[i*j] += 1
            j += 1
    res = 0
    for i in range(1,n+1):
        res += i*y[i]
    print(res)

if __name__ == '__main__':
    main()

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

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

print(ans)

Solution (Python):
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
def find(a):
    return (a*(a+1))//2
n=int(input())
ans=0
for i in range(1,n+1):
    ans+=i*find(n//i)
print(ans)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
from collections import deque
def input():
    return sys.stdin.readline()[:-1]

n = int(input())

f = [0 for i in range(n+1)]

ans = 0
lis = [0]
for i in range(1,n+1):
    lis.append(lis[-1]+i)

for i in range(1,n+1):
    tmp = n//i
    ans+=lis[tmp]*i

print(ans)

Solution (Python):
import itertools
import collections

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
        table[i] *= i
    return table

N = int(input())


ans = 0
print(sum(num_divisors_table(N)))

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):
import math
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def numdiv(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 = i()
era = numdiv(N)
ans = 0
for i in range(1,N+1):
    ans += era[i]*i
print(ans)

Solution (Python):
from math import sqrt

def solve(N):
    dp = [2 for _ in range(N+1)]
    dp[1] = 1

    for i in range(2,int(sqrt(N)) + 1):
        for j in range(2, N//i + 1):
            if j <= int(sqrt(N)):
                dp[i * j] += 1
            else:
                dp[i * j] += 2

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

    return ans

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

    print(solve(N))

if __name__ == "__main__":
    main()

Solution (Python):
import math

n = int(input())
ret = 0

for m in range(1, n+1):
    if m * m > n:
        break
    val1 = m * (m + (n//m)) * ((n//m) + 1 - m)
    ret += val1

sq = int(math.sqrt(n))
if (sq + 1) ** 2 <= n:
    sq += 1
val3 = sq * (sq + 1) * (2 * sq + 1) // 6
ret -= val3


print(ret)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

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






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

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

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

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

print(x)

Solution (Python):
import math
N = int(input())
number = [2]*N
ans = 1
if(N>=2):
  for i in range(2,N+1):
    ans += number[i-1]*i
    
    if(i <= int(N/2)):
      for j in range(2,N//i+1):
        number[i*j-1] += 1
print(ans)

Solution (Python):
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


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

main()

Solution (Python):


"""
ai             aj
bi             bj


1              2
2              1

1  how many pairs 
2
"""



import collections
n = int(raw_input())
mem = [0] * (n + 1)
mem[1] = 1
primes = [True] * (n + 1)
posprimes = []
d= 2
while( d <= n):
	if primes[d] is True:
		posprimes.append(d)
		k = 2
		while(k * d <= n):
			primes[k * d] = False
			k += 1
	d+=1
def f(k):
	if primes[k] is True:
		mem[k] = 2 if k > 1 else 1
		return mem[k]
	for pos in posprimes:
		if k % pos == 0:
			count = 0
			q = k
			while(q % pos == 0):
				q /= pos
				count += 1

			mem[k] = (count + 1) * mem[q]
			return mem[k]



s = 0
k = 1
while (k<= n):
	s += k * f(k)
	k += 1
print s

Solution (Python):
from numba import njit


@njit
def solve(n: int):
    div = [1] * n  
    for i in range(2, n + 1):
        for j in range(i, n + 1, i):
            div[j - 1] += 1

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

    return ans


print(solve(int(input())))

Solution (Python):


N = int(input())
ans = 0

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

Solution (Python):
n=int(input())
sums=0
i=1
while i<=n:
    m=n//i
    sums=sums+((m+1)/2*m)*i
    i=i+1
print(int(sums))

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

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

Solution (Python):
def num_divisors_table(n):
    table = 0
    
    for i in range(1, n + 1):
        table += ((n//i +1)*(n//i )*i)/2
        
    return int(table)

N =int(input())

print(num_divisors_table(N))

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

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

Solution (Python):
N=int(input())
sum=[0]*(N+3)
ans=0
for i in range(1,N+1):
  sum[i]=sum[i-1]+i
for i in range(1,N+1):
  tmpn=N//i
  tmpsum = sum[tmpn]
  ans+=tmpsum*i
print(ans)