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.



Sample input:
4


Sample output:
23

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input().strip())
    ans = 0
    for i in range(1,N+1):
        for j in range(i,N+1,i):
            ans += j
    return ans

if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 0
    for i in range(1,n+1):
        ans += i * (n//i)*((n//i)+1) / 2
    print(int(ans))



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def su(N):
    return N*(N+1) / 2

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 0
    for i in range(1,n+1):
        ans += i * su(n//i)
    print(int(ans))



if __name__ == '__main__':
    solve()

Submission status: Accepted

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

print(int(ans))

Submission status: Accepted

Solution code:
def F(N): 
    r = int(N**0.5) # x >= 10^9 のときは注意
    ans = 0
    for d in range(1,N//r+1):
        ans += d*(1+(N//d))*(N//d)//2

    #print(ans)    
    for c in range(1,r):
        a = N//(c+1)
        b = N//c
        """
        (a,b] 上で d の和を求める
        """
        s = b*(b+1)//2-a*(a+1)//2
        ans += s*(c*c+c)//2
        #ans %= MOD
    return ans


# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

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

Submission status: Accepted

Solution code:
n=int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
sum=0
for i in range(1,n+1,1):
    t=int(n/i)
    sum+=i*t*(t+1)/2

print(int(sum))

Submission status: Accepted

Solution code:
N = int(input())
lis = [1] * (10**7+1)
for i in range(2,10**7+1):
    for j in range(i,10**7+1,i):
        lis[j] += 1
ans = 0
for i in range(1,N+1):
    ans += lis[i] * i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

res = 0
for j in range(1,n+1):
    x = n//j
    res += j*(1+x)*x//2

print(res)

Submission status: Accepted

Solution code:
def f(n):
    ans=0
    for a in range(1,n+1):
        ans+=a*(n//a)*(n//a+1)//2
    print(ans)
if __name__ == "__main__":
    f(int(input()))

Submission status: Accepted

Solution code:
n = int(input())
total = 0
for j in range(1, n + 1):
    x = j
    y = n // x
    total += y * (y + 1) * x // 2
print(total)

Submission status: Accepted

Solution code:
from numba import njit
@njit('void(i8)')
def f(n):
    ans=0
    for a in range(1,n+1):
        ans+=a*(n//a)*(n//a+1)//2
    print(ans)

f(int(input()))

Submission status: Accepted

Solution code:
from numba import njit
@njit('void(i8)')
def f(n):
    ans=0
    for a in range(1,n):
        for k in range(a,n,a):
            ans+=k
    print(ans)
f(int(input())+1)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
#https://www.youtube.com/watch?v=3gFnZhZlAF8
#【競プロ実況】ABC172 AからD問題【かつっぱ】
#等差数列の和

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

Submission status: Accepted

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# import numpy as np

def _sum_ob_divisors(n):
    def f(n, x):
        y = n // x
        return y * (y + 1) * x // 2
    return sum(f(n, i) for i in range(1, n + 1))


# def _sum_ob_divisors(n):
#     L = [1] * (n + 1)
#     # L = np.ones(n + 1, dtype=np.int64)
#     for i in range(2, n + 1):
#         for j in range(i, n + 1, i):
#             L[j] += 1
#         # L[i:n + 1:i] += 1
#     # print(f'{L=}')
#     return sum(i * x for i, x in enumerate(L))


def sum_ob_divisors(f):
    n = int(f.read())

    return _sum_ob_divisors(n)


def main():
    ans = sum_ob_divisors(sys.stdin.buffer)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
data = stdin.readline().rstrip()

a = int(data)

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

Submission status: Accepted

Solution code:
n = int(input())

def sieve(n):
    # 1.9 seconds.

    # 1 and n are divisors for every n.
    is_prime = [2]*(n + 1)
    is_prime[0], is_prime[1] = 0, 0

    # is_prime holds the number of positive divisors of N. Instead of being a bool of 0/1 for prime/not prime. for example of N=24--->  is_prime[24] = 6 (1, 2, 3, 4, 6 ,24)

    for num in range(2, n+1//2):
        for mult in range(2*num, n+1, num):
            is_prime[mult] += 1
        
    ans = 1

    # i is N. elem is f(N)
    for i, elem in enumerate(is_prime[2:]):
        ans += (elem)*(i + 2)

    print(ans)

sieve(n)

Submission status: Accepted

Solution code:
n = int(input())

def sieve(n):
    is_prime = [1]*(n + 1)
    is_prime[0], is_prime[1] = 0, 0

    # for is_prime[24]. Initially it is 0. when num (outer loop) is 2. is_prime[24] = 0+1
    # when num is 3. is_prime[24] = 1+1. when num is 4 and 6 it is again incremented by 1.
    # Thus in the end is_prime[A] contains all divisors of A excpet 1, A. (special case A=1)

    for num in range(2, n+1//2):
        for mult in range(2*num, n+1, num):
            is_prime[mult] += 1
        
    ans = 1

    # i is N. elem is f(N)
    for i, elem in enumerate(is_prime[2:]):
        ans += (elem + 1)*(i + 2)

    print(ans)

sieve(n)

Submission status: Accepted

Solution code:
from numba import njit
@njit('void(i8)')
def solve(n):
    s=0
    for i in range(1,n):
        for j in range(i,n,i):
            s+=j
    print(s)
solve(int(input())+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    nums = [1] * (N + 1)
    s = 0
    for i in range(2, N+1):
        tmp = i
        while tmp <= N:
            nums[tmp] += 1 
            tmp += i
    for i in range(1, N+1):
        s += i * nums[i]
    print(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
#for i in range(1,x+1):
#    for j in range(1,x+1):
#        if i % j == 0:
#            ans += i
for i in range(1,x+1):
    num = x // i
    ans += num*(num+1)/2*i
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calc():
  n=int(input())
  table=[i for i in range(n+1)]
  for i in range(2,n+1):
    if table[i]<i:
      continue
    for j in range(i,n+1,i):
      table[j]=i
  ans=0
  for i in range(1,n+1):
    cnt={}
    ret=i
    while i!=1:
      prime=table[i]
      if prime in cnt:
        cnt[prime]+=1
      else:
        cnt[prime]=1
      i//=prime
    for val in cnt.values():
      ret*=val+1
    ans+=ret
  print(ans)
calc()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n= int(input())

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

Submission status: Accepted

Solution code:
import collections

def calc():
  n=int(input())
  table=[i for i in range(n+1)]
  for i in range(2,n+1):
    if table[i]<i:
      continue
    for j in range(i,n+1,i):
      table[j]=i
  ans=0
  for i in range(1,n+1):
    cnt={}
    ret=i
    while i!=1:
      prime=table[i]
      if prime in cnt:
        cnt[prime]+=1
      else:
        cnt[prime]=1
      i//=prime
    for val in cnt.values():
      ret*=val+1
    ans+=ret
  print(ans)
calc()

Submission status: Accepted

Solution code:
N = int(input())

res = 0
for i in range(1,N+1):
    y = N // i
    s = y * (y+1) // 2
    res += s * i

print(res)

Submission status: Accepted

Solution code:
import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n = int(input()); ans = 0
	arr = [1]*(n+1)
	i = 1
	while i*2 < n+1:
		j = 2
		while i*j < n+1:
			arr[i*j] += 1
			j += 1
		i += 1
	ans = 0
	for i in range(1, n+1):
		ans += i * arr[i]
	print(ans)


	





		

if __name__ == "__main__":
	solve()

Submission status: Accepted

Solution code:
N = int(raw_input())

ans = 0
for i in range(1, N+1):
  # i + 2i + 3i + ... + (N/i)*i
  q = N/i
  ans += (i * q * (q+1))/2
print ans

Submission status: Accepted

Solution code:
n = int(input())

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


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

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()

    ans_list = [1] * n

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

    count = 0
    for i, ans in enumerate(ans_list):
        count += (i+1) * ans

    print(count)
 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#https://www.youtube.com/watch?v=3gFnZhZlAF8
#【競プロ実況】ABC172 AからD問題【かつっぱ】
# 等差数列の和
# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
ans =0
for i in range(1,N+1):
    n =N//i #項数
    ans +=n*(2*i +(n-1)*i)//2
print(ans)

Submission status: Accepted

Solution code:
def solve(n):
  ans = 0
  for i in range(1,n+1):
    for j in range(i,n+1,i):
      if j % i == 0:
        ans += j
  return ans

def main():
  N = int(input())
  print(solve(N))
  return

main()

Submission status: Accepted

Solution code:
def S(k):
    return k * (k + 1) // 2

N = int(input())
M = int((N+1)**.5)
ans = 0
# 前半
for i in range(1, N // (M+1) + 1):
    ans += i * S(N // i)
# 後半
for k in range(1, M+1):
    ans += S(k) * (S(N//k) - S(N//(k+1)))
print(ans)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline

def S(k):
    return k * (k + 1) // 2

N = int(readline())
M = int((N+1)**.5)
ans = 0
# 蜑榊濠
for i in range(1, N // (M+1) + 1):
    ans += i * S(N // i)
# 蠕悟濠
for k in range(1, M+1):
    ans += S(k) * (S(N//k) - S(N//(k+1)))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def cal(b, e):
    return ((b + (e//b) * b) * (e//b))//2

n = int(input())
ans = 0

for i in range(1, n+1):
    ans += cal(i, n)

print(ans)

Submission status: Accepted

Solution code:
def A083356(n):
    t = 0
    for r in range(1, int(n**0.5)+1):
        t += r*(r+int(n/r))*(int(n/r)+1-r)//2
    return t

def A000330(n):
    return n * (n + 1) * (2 * n +1) // 6

def A143127(n):
    return 2 * A083356(n) - A000330(int(n**0.5))

n = int(input())
print(A143127(n))

Submission status: Accepted

Solution code:
import math
n=int(input())

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

for i in range(2,int(math.sqrt(n))+1):#振るい
  for j in range(i,n//i+1):
    if i==j:
      l[i*j]+=1
    else:
      l[i*j]+=2
print(sum([i*l[i] for i in range(n+1)]))

Submission status: Accepted

Solution code:
import math
n=int(input())

l=[4 if i%2==0 else 2 for i in range(max(5,n+1))]
l[1]=1
l[2]=2
l[4]=3
for i in range(3,int(math.sqrt(n))+1):#振るい
  for j in range(i,n//i+1):
   # print(i,i*j)
    if i==j:
      l[i*j]+=1
    else:
      l[i*j]+=2
#print(l)

l2=[i*l[i] for i in range(n+1)]
print(sum(l2))

Submission status: Accepted

Solution code:
import time
import math
N=int(input())
if N==1:
    print(1)
    exit()


d=[1]*(N+1)

ans=0
for i in range(1,N+1):
    # しょこうi こうさi
    # まっこう N-N%i
    ans+=(N//i)*(i+N-N%i)//2


print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
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):
    ans = 0
    for i in range(1, N+1):
        for j in range(i, N+1, i):
            ans += j
    return ans


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 28 13:44:44 2020

@author: NEC-PCuser
"""
N = int(input())
ans = 0
for i in range(1, N + 1):
    n = N // i
    ans += i * n * (n + 1) // 2 

print(ans)

Submission status: Accepted

Solution code:
N = int(input())


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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
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):
    ans = 0
    for i in range(1, N+1):
        for j in range(i, N+1, i):
            ans += j
    return ans


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    m = int((n+1)**.5)
    u = n // (m + 1)
    ans = 0
    for i in range(1, u+1):
        v = n // i
        ans += v * (v + 1) // 2 * i
    for i in range(m, 0, -1):
        v = n // i
        ans += (v * (v + 1) - u * (u + 1)) // 2 * i * (i + 1) // 2
        u = v
    print(ans)
    return

solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

Xarray = np.arange(1, N+1)
Xans = ((N // Xarray) * (2 * Xarray + ((N // Xarray) - 1) * Xarray)) // 2

print(sum(Xans))

Submission status: Accepted

Solution code:
n = int(input())

L = [0] * (n + 1)

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

i = 0
ans = 0
for i in range(len(L)):
    ans += i *L[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())                                                
                                                                
ans = 0                                                         
for i in range(1, n + 1):                                       
    terms = n // i    # 項数                                      
    ans += terms * (i + i * terms) // 2  # 項数＊(初項＋末項)//2        
                                                                
print(ans)

Submission status: Accepted

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

Submission status: Accepted

Solution code:
n=int(input())

ans=0

def calc(begin, end, cnt):
    return cnt*(begin+end)//2

for i in range(1, n+1):
    begin=i
    end=(n//i)*i
    cnt=(n//i)

    ans+=calc(begin, end, cnt)

print(ans)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    ans = 0
    for i in range(1, n+1):
        v = n // i
        ans += v * (v + 1) // 2 * i
    print(ans)
    return

solve()

Submission status: Accepted

Solution code:
n=int(input())

ans=0

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

Solution code:
N=input()
ans=0
for cur in range(1,N+1):
    for i in range(cur,N+1,cur):
        ans+=i
print ans

Submission status: Accepted

Solution code:
import math
N=input()
ans=0
for cur in range(1,N+1):
    for i in range(cur,N+1,cur):
        ans+=i
print ans

Submission status: Accepted

Solution code:
n = int(input())
F = [1] * -~n
for i in range(2, n + 1):
    for j in range(i, n + 1, i):
        F[j] += 1
print(sum(e * v for e, v in enumerate(F)))

Submission status: Accepted

Solution code:
def solve(N):
    ans = 0
    for i in range(1,N+1):
        tmp = N//i
        ans += tmp*(2*i + (tmp-1)*i)//2
    
    return ans 

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

Submission status: Accepted

Solution code:
import time
import math
N=int(input())
if N==1:
    print(1)
    exit()


d=[1]*(N+1)

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


print(ans)

Submission status: Accepted

Solution code:
def solve(N):
    ans = 0
    for i in range(1,N+1):
        ans += N//i*(2*i + (N//i-1)*i)//2
    
    return ans 

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

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

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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys 
import numpy as np
from numba import jit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@jit(cache=True)
def solve(n):
  a = np.zeros(N+1,np.int64)
  for i in range(1,N+1):
      for j in range(i,N+1,i):
        a[j] += j
  ans = a.sum()
  return ans
 
N = int(readline())
print(solve(N))

Submission status: Accepted

Solution code:
N = int(input())

def gfunc(n):
    return int((n * (n + 1)) / 2)


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

Submission status: Accepted

Solution code:
def m():
    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        n = N//i

        ans += (n * (n + 1) // 2)*i
        pass
    return ans


print(m())

Submission status: Accepted

Solution code:
n=int(input())
g=0
for i in range(n):
    g+=((n//(i+1))*((n//(i+1)+1)*(i+1)/2))
print(int(g))

Submission status: Accepted

Solution code:
import math
N=input()
A=[ 2 for _ in range(N+1)]
A[0]=0
A[1]=1

for cur in range(2,N+1):
    for i in range(cur*2,N+1,cur):
        A[i]+=1

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(int(N)):
  q = N // (i+1)
  #print(type(i),type(q),type(ans))
  ans += (i+1)*q*(q+1)/2
print(int(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
N=input()
A=[ 2 for _ in range(N+1)]
A[0]=0
A[1]=1

for cur in range(2,N+1):
    for i in range(cur*2,N+1,cur):
        A[i]+=1

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

Submission status: Accepted

Solution code:
def main():
  N,t=int(input()),0
  for x in range(1,N+1):
    t+=(N//x)*(N//x+1)*x//2
  print(t)

main()

Submission status: Accepted

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