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 math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n = int(input())

factors = [1] * (n+1)

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

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

print(ans)

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

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

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

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

print(t)

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

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

Solution (Python):



n=int(input())
ans=0

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

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

count = 0

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

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

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

Solution (Python):
def main():



    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)



if __name__ == '__main__':
   main()

Solution (Python):










import sys

def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip("\n") for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]

def OutH(lst): print(*lst)
def OutV(lst): print(*lst, sep="\n")

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)


N = iIn()

ans = 0
for k in range(1, N+1):
    ans += k * (N // k) * (N // k + 1) // 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):
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):
def main():



    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)



if __name__ == '__main__':
   main()

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):
n = int(input())

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

print(sum1)

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

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

print(sum1)

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

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

Solution (Python):
n=int(input())
s=0
for i in range(1,n+1):
    c=1
    x=i*c
    while x<=n:
        s+=x
        c+=1
        x=i*c
print(s)

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

Solution (Python):


def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def g(N: int) -> int:
    """
    1~Nの総和を求める.

    Args:\n
        N (int): 正整数

    Returns:\n
        int: 1~Nの総和
    """
    return int(N * (N + 1) / 2)


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 正整数（1 <= N <= 10^7）
    """
    
    ans = 0
    for n in range(1, N + 1):
        ans += n * g(N // n)

    
    print(ans)


if __name__ == "__main__":
    
    N = get_input()

    
    main(N)

Solution (Python):


N = int(input())

def g(N: int) -> int:
    return int(N * (N + 1) / 2)


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

print(ans)

Solution (Python):
import sys
def resolve():
    readline=sys.stdin.readline
    n=int(readline())
    answer=0

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

    return

resolve()

Solution (Python):

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

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

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

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

T = [1] * (N+1)

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

ans = 0

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

print(ans)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    ans = 0
    for j in range(1, N + 1):
        k = N // j
        ans += k * (k + 1) // 2 * j
    print(ans)


def main():
    
    
    
    
    
    
    solve()


if __name__ == "__main__":
    main()

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

dp = [0] * (n+1)

for i in range(1, n+1):
    t = n//i
    
    dp[i] = i*t*(t+1)//2
    
print(sum(dp))

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

dp = [0] * (n+1)

for i in range(1, n+1):
    t = n//i
    
    dp[i] = i*t*(t+1)//2
    
print(sum(dp))

Solution (Python):

import sys
def multiple_sum(x, n):
    
    k = n // x
    return x * (k + 1) * k // 2


def solve(N: int):
    ans = 0
    for i in range(1, N + 1):
        ans += multiple_sum(i, N)
    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)


if __name__ == "__main__":
    main()

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

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

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

print(ans)

Solution (Python):

import sys
def multiple_sum(x, n):
    
    k = n // x
    return x * (k + 1) * k // 2


def solve(N: int):
    ans = 0
    for i in range(1, N + 1):
        ans += multiple_sum(i, N)
    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)


if __name__ == "__main__":
    main()

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

N = int(readline())

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

print(ans)

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

print(ans)

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

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

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

Solution (Python):


def solve(n):
    ans = 0
    r = n
    for c in range(1, n + 1):
        l = n // (c + 1)
        if r - l == 1: break
        ans += (l + 1 + r) * (r - l) // 2 * c * (c + 1) // 2
        r = l
    for d in range(1, r + 1):
        c = n // d
        ans += (c + 1) * c // 2 * d
    return ans

n=int(input())
print(solve(n))

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

D = [0] * (N + 1)
for i in range(1, N + 1):
    j = 1
    while j * i <= N:
        D[j * i] += 1
        j += 1
S = 0
for i in range(1, N + 1):
    S += i * D[i]
print(S)

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

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

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

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

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

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

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

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

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

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

    print(ans)

main()

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

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

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

    print(ans)

main()

Solution (Python):
import sys
import collections
sys.setrecursionlimit(10**6)


def main(input, print):
    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(sys.stdin.readline, print)

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

Solution (Python):
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import collections
import heapq
import json
N=int(input())
l=[0]*(N+1)
ma=0
ans=0
for i in range(1,N+1):
    ma=(N//i)*i
    ans=ans+(i+ma)*(N//i)//2
print(ans)

Solution (Python):
def solve(n):
    ans=0
    for d in range(1,n+1):
        c=n//d
        ans+=(c+1)*c//2*d
    return ans

n=int(input())
print(solve(n))

Solution (Python):
import numpy as np
from numba import njit, int64

n = int(input())


@njit(int64(int64))
def f(n):
    cnt = np.zeros(n + 1, np.int16)
    for i in range(1, n + 1):
        cnt[i::i] += 1

    return (cnt * np.arange(n + 1)).sum()


ans = f(n)
print(ans)

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

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

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

ans=0

Total=0

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

Solution (Python):


import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

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

def main():
    n = ni()
    ans = 0
    div = [0] * (n+1)
    for i in range(1, n+1):
        for j in range(1, n//i+1):
            div[i*j] += 1
    
    for i in range(1, n+1):
        ans += i * div[i]
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

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

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


if __name__ == "__main__":
    main()

Solution (Python):


import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

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

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


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
from numba import njit

n = int(input())


@njit
def f(n):
    cnt = np.zeros(n + 1, np.int16)
    for i in range(1, n + 1):
        cnt[i::i] += 1

    return (cnt * np.arange(n + 1)).sum()


ans = f(n)
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((int)(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):
import math
N = int(input())

answer = 0
for i in range(1,N+1):
    baisuu_count = N//i
    add = baisuu_count*(2*i+(baisuu_count-1)*i)//2
    answer+=add
print(answer)

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

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

print(ans)

Solution (Python):
N = int(input())
num = []
for _ in range(N + 1):
    num.append(1)
for i in range(2, N + 1):
    cnt = 1
    while cnt * i <= N:
        num[cnt * i] += 1
        cnt += 1
ans = 0
for i in range(1, N + 1):
    ans += num[i] * i
print(ans)

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

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

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

Solution (Python):
def tousa_sum(amin, amax, d): 
    n = (amax-amin) // d + 1
    return n * (2*amin + (n-1)*d) // 2

n = int(input())
total = 0
for i in range(1, n+1):
    total += tousa_sum(i, n, i)
print(total)

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

    sum = 0
    for j in range(n):
        j += 1
        
        
        
        k = n // j
        sum += (k * (1 + k) // 2) * j 

    print(sum)


if __name__ == '__main__':
    main()

Solution (Python):
def main(n):
    ans = 0
    for k in range(1, n+1):
        for f in range(1,n//k+1):
            ans += k*f
    return ans

n = int(input())
print(main(n))

Solution (Python):
n = int(input())
result = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        if(i * j <= n):
            result += i*j
        else:
            break
print(result)

Solution (Python):
import numba

@numba.njit
def main(n):
    ans = 0
    for k in range(1, n+1):
        for f in range(1,n//k+1):
            ans += k*f
    return ans

n = int(input())
print(main(n))

Solution (Python):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    ans = N * (N+1) - 1
    for i in range(2,int(math.sqrt(N))+1):
        ans += i*i
        j = i + 1
        while i * j <= N:
            ans += 2 * i * j
            j += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

import sys
def main(N):
    d = [1] * (N + 1)
    for n in range(2, N + 1):
        for i in range(n, N + 1, n):
            d[i] += 1
    print(sum(d[i] * i for i in range(1, N + 1)))

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    main(N)

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

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

Solution (Python):

def main2():
    n = int(input())
    res=0
    div = [0]*(n+1)
    for i in range(1,(n+1)):
        for j in range(0,n,i):
            if(i+j<=n):
                div[i+j]+=1
        res+=i*div[i]
    print(res)



if __name__ == '__main__':
    main2()

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

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

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

if n == 1:
    print(1)
elif n == 2:
    print(5)
else:
    FK[2] = 2
    for i in range(4, n+1, 2):
        FK[i] += 1

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

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

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):
def func(x, n):
    y = n//x
    return y*(y+1)*x//2

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

    for i in range(1, N + 1):
        res += func(i, N)

    print(res)

resolve()

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

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

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

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))


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

def main():
    n = INT()
    table = [0] * (n + 1)
    table[0] = 0
    table[1] = 1

    for i in range(2, n + 1):
        if table[i] == 0:
            table[i] = 2
            for j in range(i + i, n + 1, i):
                cnt = 0
                c = j
                while c % i == 0:
                    c //= i
                    cnt += 1
                table[j] = table[c] * (cnt + 1)

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

    return


if __name__ == '__main__':
    main()

Solution (Python):








import sys,math

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

isPrime = [True]*(N+1)
f = [1]*(N+1)

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

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

print(sum)

Solution (Python):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())

    N = NI()

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

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

    print(ans)


if __name__ == '__main__':
    main()

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

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

    ans = 0
    for d in range(1, N + 1):
        m = N // d
        ans += d * f(m)
    print(ans)


if __name__ == '__main__':
    main()

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

    N = int(input())

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

    ans = 0
    for k in range(1, isqrt(N) + 1):
        
        
        
        
        
        
        m = N // k
        ans += 2 * k * (f(m) - f(k - 1)) - k * k
    print(ans)


if __name__ == '__main__':
    main()

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

ans=0
j=1
while(j*(j*1)<=N):
    b=1+(N//j)
    a=1+(N//(j+1))
    tmp=((N//a)*((N//a)+1))//2
    tmpa=(a*(a-1))//2
    tmpb=(b*(b-1))//2
    ans+=(tmpb-tmpa)*tmp
    j+=1
for i in range(1,a):
    ans+=i*((N//i)*((N//i)+1))//2
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)

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

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

terms = n - n // 2
result += terms * (n // 2 + 1 + n) // 2

print(result)

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

ans= 0

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

print(ans)

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

ans= 0

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

print(ans)

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

f = [1] * (n+1)
f[1] = 1

for i in range(2, n+1):
    for j in range(0,n+1,i):
        f[j] += 1
ans = 0
for k in range(1, n+1):
    ans += k * f[k]

print(ans)

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

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

print(result)

Solution (Python):
import os
import sys


def solve(n):
    ans = 0
    for i in range(1, int(n ** 0.5) + 1):
        k = n // i
        ans += i * k * (k + 1) // 2
        if i != k:
            l = n // (i + 1)
            ans += i * (i + 1) * (k + l + 1) * (k - l) // 4
    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8,)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8,)', cache=True)(solve)

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

Solution (Python):
n = int(input())
ans = 0
for i in range(1, int(n ** 0.5) + 1):
    k = n // i
    ans += i * k * (k + 1) // 2
    if i != k:
        l = n // (i + 1)
        ans += i * (i + 1) * (k + l + 1) * (k - l) // 4
print(ans)

Solution (Python):
import sys, math,os
from io import BytesIO, IOBase



from collections import defaultdict as dd, deque, Counter


def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')

INF = 10**9
mod = 998244353

n=int(data())
l=[1]*(n+1)
for i in range(1,n):
    for j in range(2*i,n+1,i):
        l[j]+=1
ans=0
for i in range(1,n+1):
    ans+=l[i]*i
out(ans)

Solution (Python):
import math
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):
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
def g(j):
    Y = N // j
    return Y * (Y + 1) * j // 2

print(sum([g(j) for j in range(1, N+1)]))

Solution (Python):
import numpy as np
N = int(input())

S = 0
def g(j):
    Y = N // j
    return Y * (Y + 1) * j // 2

print(sum([g(j) for j in range(1, N+1)]))

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7



N = INT()

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

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)

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

Solution (Python):
import numpy as np
from numba import *

@njit('i8(i8,i8[:])', cache=True)
def solve(x,count):
    for i in range(2,x+1):
        for j in range(i,x+1,i):
            count[j] += 1
    return int(np.sum(np.arange(x+1)*count))

if __name__== "__main__":
    x = int(input())
    count = np.ones(x + 1, dtype=np.int64)
    print(solve(x,count))

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


print(sum(table))

Solution (Python):
N = int(input())
a = 0
for i in range (N):
	x= N//(i+1)
	a += x*(x+1)*(i+1)

a = a/2
	
print(int(a))

Solution (Python):
N = int(input())
rlt = 0
 
lst = [2]*(N+1)
lst[1] = 1
 
for i in range(2,N//2+1):
  j = 2
  while i*j <= N:
    lst[i*j] += 1
    j += 1

for i in range(1,N+1):
  rlt += i*lst[i]
  
print(rlt)

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

Solution (Python):
"""
AtCoder :: Beginner Contest 172 :: D :: Sum of Divisors
https://atcoder.jp/contests/abc172/tasks/abc172_d
"""
import sys

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

def solve(N):
    """Solve puzzle."""
    soln = 0
    for i in range(1, N+1):
        k = N // i
        soln += i * summation(k)
    return soln


def main():
    """Main program."""
    N = int(sys.stdin.readline())
    print(solve(N))


if __name__ == '__main__':
    main()

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

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

ans = 0

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

print(ans)

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


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
    i = 2
    while True:
        step = i // 2
        start = (i + 1) // 2 * step
        if start > N:
            break
        end = N // step * step
        ret += (start + end) * ((end - start) // step + 1) // 2
        i += 1
    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):
n = int(input())

ans = 0
for i in range(1,n+1):
  
  kousu=n//i
  
  an = i + (kousu-1)*i
  
  sn = (i + an)*kousu//2
  ans += sn
print(ans)

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

Solution (Python):



def main():
    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)


if __name__ == "__main__":
    main()