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

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def solve(N):

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

    return ans


def main():

    N = in_n()
    print(solve(N))


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i4,)')(solve)
    cc.compile()


if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
        from my_module import solve
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 解説を参考に作成


# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N):
    ans = 0
    for i in range(1, N + 1):
        ans += (i + i * (N // i)) * (N // i) // 2
    print(ans)


if __name__ == '__main__':
    N = int(input())
    solve(N)
    # print(prime_factorization(10000000))
    pass

Submission status: Accepted

Solution code:
N = int(input())
# iが何回出現するか考える
# 1 -> 1,2,3,4
# 2 -> 2,4
# 3 -> 3
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):
    k=n//i
    ans+=k*(k+1)//2*i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

divs = [0]*(N+1)

for i in range(1,N+1):
    for j in range(1,N+1):
        if i*j > N:
            break
        divs[i*j] += 1

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

Submission status: Accepted

Solution code:
#O(NlogN)
N=int(input())
A=[0]*(N+1)
for i in range(1,N+1):
  for j in range(i,N+1,i):
    A[j] += j

print(sum(A))

Submission status: Accepted

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

    ans = 0

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    ans = 0

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


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
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
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  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b

# 解説によるO(N)解法


N = a_int()
ans = 0

'''
以下のような問題を高速化したい
for k in range(1, N + 1):
    for j in range(1, N + 1):
        ans += k * (k % j == 0)  # jがkの約数になっていれば加算する

式の形からk,jはひっくり返せる
jをgivenとしたとき, k * (k%j==0)となる数列の和を高速に列挙する。
→この数列はkがjの倍数のときだけ値をとる→nonzero数列だけに注目すると以下のように言い換えられる
「jの倍数であってN以下であるものの数列」の和を高速に知りたい

1j+2j+3j...yjを求めたいただし,yj<=N (⇔ y<=N//j)
j*((1+y)*y)//2と式変形可能

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

Submission status: Accepted

Solution code:
production = True

import sys, math, collections

def input(input_format = 0, multi = 0):

    if multi > 0: return [input(input_format) for i in range(multi)]
    else:
        next_line = sys.stdin.readline()[:-1]

        if input_format >= 10:
            use_list = False
            input_format = int(str(input_format)[-1])
        else: use_list = True

        if input_format == 0: formatted_input = [next_line]
        elif input_format == 1: formatted_input = list(map(int, next_line.split()))
        elif input_format == 2: formatted_input = list(map(float, next_line.split()))
        elif input_format == 3: formatted_input = list(next_line)
        elif input_format == 4: formatted_input = (lambda x: [x[0], list(map(int, x[1:]))])(next_line.split())
        elif input_format == 5: formatted_input = (lambda x: [x[0], list(map(float, x[1:]))])(next_line.split())
        elif input_format == 6: formatted_input = next_line.split()
        else: formatted_input = [next_line]

        return formatted_input if use_list else formatted_input[0]


def out(output_line, output_format = 0, newline = True):

    formatted_output = ""

    if output_format == 0: formatted_output = str(output_line)
    elif output_format == 1: formatted_output = " ".join(map(str, output_line))
    elif output_format == 2: formatted_output = "\n".join(map(str, output_line))

    print(formatted_output, end = "\n" if newline else "")


def log(*args):
    if not production:
        print("$$$", end = "")
        print(*args)

enum = enumerate

#
#   >>>>>>>>>>>>>>> START OF SOLUTION <<<<<<<<<<<<<<
#

p = []

def seive(n):
    global p

    p = [0] * (n + 1)

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

def solve():

    n = input(11)

    seive(n)
    t = sum(map(lambda a: a[0] * a[1], enum(p)))

    out(t)
    
    return


#for i in range(input(11)): solve()
solve()

#
#   >>>>>>>>>>>>>>>> END OF SOLUTION <<<<<<<<<<<<<<<
#

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    ans = 0

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()
sqrtN = math.floor(math.sqrt(N))
ans = 0
for m in range(1,sqrtN+1):
  ans += m*(m+(N//m))*(N//m+1-m)
print(ans-(sqrtN*(sqrtN+1)*(2*sqrtN+1)//6))
#Sum_{m=1..floor(sqrt(n))} m*(m+floor(n/m))*(floor(n/m)+1-m) - A000330(floor(sqrt(n)))

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

furui = [1]*(N+1)
ans = 1
for i in range(2, N+1):
    k = i
    while k <= N:
        furui[k] += 1
        k += i
    ans += furui[i]*i

print(ans)

Submission status: Accepted

Solution code:
def main():
    # これはなに？笑
    N = int(input())
    ans = 0

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n = int(input())
result = 0

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


print(int(result))

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:
n = int(input())
print(sum([i * (n // i) * (n // i + 1) // 2 for i in range(1,n+1)]))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        #print(range(i,n+1,i),sum(range(i,n+1,i)))
        ans += sum(range(i,n+1,i))

    print(ans)
main()

Submission status: Accepted

Solution code:
n=int(input())
dp=[1]*(n+1) #約数の個数
ans=1
for i in range(2,n+1):
    for j in range(i, n+1, i):
        dp[j]+=1
    ans+=dp[i]*i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

def gen():
  for j in range(1,N+1):
    yield j * (N//j)*(N//j+1)/2

ans = int(sum(gen()))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

memo = [1]*(N+1)
for x in range(2,N+1):
    for y in range(x,N+1,x):
        memo[y] += 1
print(sum(c*m for c,m in enumerate(memo)))

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:
import sys
import numpy as np
from numba import njit

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


@njit('(i4,i4[:])', cache=True)
def solve(N, yaku):

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

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

    return ans


def main():

    N = in_n()
    yaku = np.zeros(N + 1, np.int32)
    print(solve(N, yaku))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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


print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = int(sum([j * (N//j)*(N//j+1)/2 for j in range(1,N+1)]))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:

n = int(input())

ans = 0

def calc(b,e):
    cnt = e // b
    return (b + e) * cnt // 2

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input())

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

half = int(N/2)+1

each_result = [n*sum_inc(int(N/n)) for n in range(1,half)]

print(sum(each_result)+sum_inc(N) - sum_inc(half-1))

Submission status: Accepted

Solution code:
N = int(input())
dp = [1]*(N+1)
ans = 1
for i in range(2, N+1):
    j = i
    while j < N+1:
        dp[j] += 1
        j += i
    ans += i*dp[i]
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    ans = 0
    for j in range(1, N+1):
        a = int(N/j)
        ans += a*(a+1)*j / 2
    print(int(ans))
    
main()

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

N = int(input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def main():
    n = int(input())
    ret = 0
    for i in range(1, n+1):
        x = n // i
        ret += i * x * (x+1) // 2

    print(ret)

if __name__ == '__main__':
    main()

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:
# 解説

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

    ans = 0
    for div in range(1, N + 1):
        m = N // div  # div, div*2, ..., div*m
        ans += (m * (m + 1) // 2) * div
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
l = [0] * (10 ** 7 + 1)
for i in range(1, 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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
tau = [0 for i in range(n+1)]
for d in range(1,n+1):
	for k in range(d,n+1,d):
		tau[k] += 1
print(sum([k*tau[k] for k in range(1,n+1)]))

Submission status: Accepted

Solution code:
N = int(input())

ans = 1
div = [2 for i in range(N + 1)]

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

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:
n = int(input())
cnt = [1] * (n + 1)
tot = 1
for i in xrange(2, n + 1):
    for j in xrange(i, n + 1, i):
        cnt[j] += 1
    tot += i * cnt[i]
print tot

Submission status: Accepted

Solution code:
n = int(input())

def sieve(n):
    n += 10
    res = list(range(n))
    res[0] = -1
    res[1] = -1
    i = 2
    while i*i<n:
        if res[i]<i:
            i += 1
            continue
        j = i*i
        while j<n:
            if res[j]==j:
                res[j] = i
            j += i
        i += 1
    return res

l = sieve(n)
res = 0
for k in range(1,n+1):
    m = k
    r = 1
    while m!=1:
        p = l[m]
        c = 0
        while l[m]==p:
            m //= l[m]
            c += 1
        r *= c+1
    res += k*r
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# エラトステネスの篩
N = int(input())

sieve = [0] * (N + 1)
sieve[0] = -1
sieve[1] = -1
for i in range(2, N + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    for j in range(i * i, N + 1, i):
        if sieve[j] == 0:
            sieve[j] = i


def f(X):
    t = []
    a = X
    while a != 1:
        if len(t) != 0 and t[-1][0] == sieve[a]:
            t[-1][1] += 1
        else:
            t.append([sieve[a], 1])
        a //= sieve[a]
    result = 1
    for _, n in t:
        result *= (n + 1)
    return result


result = 0
for K in range(1, N + 1):
    result += K * f(K)
print(result)

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(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
num=np.array(list(range(1,n+1)))

x=n//num
ans=num*(x+1)*x/2
print(int(np.sum(ans)))

Submission status: Accepted

Solution code:
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
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 S(): return input()
def LS(): return input().split()


def main():
    n = I()
    ans = 0
    # 式変形より問題文を言い換える

    for j in range(1, n + 1):
        # 1 ~ n の中で j の倍数であるものの総和 の総和
        # 倍数の数
        k = n // j
        # 1 * j + 2 * j + ... + k * j
        ans += ((k + 1) * k // 2) * j
    print(ans)


main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

print(int(res))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int):
    ret = 0
    for i in range(1, N + 1):
        c = N // i
        cc = (1 + c) * c // 2
        ret += i * cc
    print(ret)
    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))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())

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

answer=0
for i in range(1,N+1):
  term=N//i
  answer+=i*sum_n(term)
  
print(answer)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()

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

Submission status: Accepted

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

print(int(count))

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# D (Cheat) 

n = int(input())

ans = 0
for j in range(1,n+1):
#     for i in range(1,n+1):
#         if i % j == 0:
#             ans += i
    _tmp = n//j
    ans += j * _tmp * (_tmp+1) // 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 sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    print(sum([N//(i+1)*(N//(i+1) + 1)*(i+1)//2 for i in range(N)]))
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def readinput():
    n=int(input())
    return n

def main(n):
    fk=[1]*(n+1)
    for i in range(2,n+1):
        j=i
        while(j<=n):
            fk[j]+=1
            j+=i
    sum=0
    for i in range(1,n+1):
        sum+=i*fk[i]
    return sum

def main2(n):
    fk=[]
    for i in range(n+1):
        fk.append(i)
    for i in range(2,n+1):
        j=i
        while(j<=n):
            fk[j]+=j
            j+=i
    sum=0
    for i in range(1,n+1):
        sum+=fk[i]
    return sum

if __name__=='__main__':
    n=readinput()
    ans=main2(n)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from pprint import pprint
import math
from numba import jit, njit

# import numpy as np
# import collections

n = int(input())
# n = 10000000
# n = 100


# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

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


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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

print(res)

Submission status: Accepted

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

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:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# input
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
ans = n * (n + 1) - 1  # 1とk 自信

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)

Submission status: Accepted

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

print(int(out))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans = 0
n = int(input())
s = [0] + [1]*n
for i in range(2, n+1):
    for j in range(i, n+1, i):
        s[j] += 1
for _ in range(n+1):
    ans += _*s[_]
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())
f=[1]*(10**7+1)
f[0]=0
for i in range(2,n+1):
  tem = i
  while tem <= n:
      f[tem] += 1
      tem += i
ans=0
for i in range(1,n+1):
  ans+=i*f[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    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-n%i))*(n//i)//2

print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

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