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,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()

ans = 0

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

Submission status: Accepted

Solution code:
n=int(input())

ksum=0
nn=n//2
for k in range(1,nn+1):
    m=n//k
    ksum+=k*m*(m+1)//2

ksum=ksum+(n-nn)*(n++nn+1)//2

print(ksum)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
#n=10000000
ksum=0
for k in range(1,n+1):
    m=n//k
    ksum+=k*m*(m+1)//2
    
print(ksum)

Submission status: Accepted

Solution code:
n = int(input().strip())

ans=0
for divisor in range(1,n+1):
    ans+=divisor*(n//divisor*(n//divisor+1)//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:
import sys

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


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

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


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

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


if __name__ == '__main__':
    resolve2()

Submission status: Accepted

Solution code:
#in the name of allah
import sys
import math as mt
import bisect
input=sys.stdin.buffer.readline  
t=1
#t=int(input())
for _ in range(t):
    #n,m,k=map(int,input().split())
    #a=list(map(int,input().split()))
    #b=list(map(int,input().split()))
    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 numba as nb

input = sys.stdin.readline


@nb.njit("i8(i8)")
def g(n):
    return n * (n + 1) // 2


@nb.njit("i8(i8)")
def solve(n):
    ans = 0
    for i in range(1, n + 1):
        ans += i * g(n // i)
    return ans


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

    ans = solve(N)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

divisors = [0 for _ in range(n+1)]

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

ans = 0
for k in range(n+1):
    ans += (k * divisors[k])

print(ans)

Submission status: Accepted

Solution code:
import sys

#import numba as nb

input = sys.stdin.readline


#@nb.njit("i8(i8)")
def solve(n):
    ans = 0
    for i in range(1, n + 1):
        m = n // i
        ans += i * m * (m + 1) // 2
    return ans


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

    ans = solve(N)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

import numba as nb

input = sys.stdin.readline


@nb.njit("i8(i8)")
def solve(n):
    ans = 0
    for i in range(1, n + 1):
        m = n // i
        ans += i * m * (m + 1) // 2
    return ans


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

    ans = solve(N)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def solve():
    
    n = int(input())
    
    divisors = [0 for _ in range(n+1)]
    
    for i in range(1, n+1):
        for j in range(i, n+1, i):
            divisors[j] += 1
    #print(divisors)
    
    ans = 0
    for k in range(n+1):
        ans += (k * divisors[k])
    
    print(ans)

solve()

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    m=n//i #　iを約数にもつ数の個数
    j=(1+m)*m//2 
    ans+=j*i
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

m = [0] * (N+1)
for i in range(1, N+1):
  temp = i
  for k in range(temp, N+1, i):
    m[k] += 1

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

Submission status: Accepted

Solution code:
import numpy as np
from numba import jit

@jit # TLE, without this!!!
def solve():
    
    n = int(input())
    
    divisors = np.zeros(n+1, np.int64)
    
    for i in range(1, n+1):
        for j in range(i, n+1, i):
            divisors[j] += 1
    #print(divisors)
    
    ans = 0
    for k in range(n+1):
        ans += (k * divisors[k])
    
    print(ans)

solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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


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

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy
ans = 0
n = int(input())
for i in range(1, n + 1):
    k = n // i
    ans += i * k * (k + 1) // 2
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

def floor(a,b):
    return a//b

N = I()

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

goukei = 0
half = N//2
for i in range(1,half+1):
  goukei += i*g(N//i)

add = list(range(half+1,N+1))
goukei += sum(add)
print(goukei)

Submission status: Accepted

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

# 改行区切りの入力をn行読み込んで数値リストにして返します。
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)

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

main()

Submission status: Accepted

Solution code:
N = int(input())

def g(X, N):
  Y = N//X
  return Y*(Y+1)*X//2

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

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3
ans = 0
n = int(input())
for i in range(1, n + 1):
    k = n // i
    ans += i * k * (k + 1) // 2
print(ans)

Submission status: Accepted

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

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:
# Problem D - Sum of Divisors

# input
N = int(input())

# initialization
ans = 0

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

# output
print(ans)

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

import numba as nb

input = sys.stdin.readline


@nb.njit("i8(i8)")
def solve(n):
    table = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    ans = 0
    for i, v in enumerate(table):
        ans += i * v
    return ans


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

    ans = solve(N)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
from numba import jit

@jit
def solve():
    
    n = int(input())
    
    divisors = np.zeros(n+1, np.int64)
    
    for i in range(1, n+1):
        for j in range(i, n+1, i):
            divisors[j] += 1
    #print(divisors)
    
    ans = 0
    for k in range(n+1):
        ans += (k * divisors[k])
    
    print(ans)

solve()

Submission status: Accepted

Solution code:
import sys

import numba as nb

input = sys.stdin.readline


@nb.njit
def solve(n):
    table = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    ans = 0
    for i, v in enumerate(table):
        ans += i * v
    return ans


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

    ans = solve(N)

    print(ans)


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()
    g = [1]*(n+1)
    for i in range(2, n+1):
        for j in range(i, n+1, i):
            g[j] += 1
    s = sum(i*g[i] for i in range(n+1))
    print(s)
    return

solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# D - Sum of Divisors

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 += j
    #ans += i*D[i]
print(ans)

Submission status: Accepted

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

# 改行区切りの入力をn行読み込んで数値リストにして返します。
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)

Submission status: Accepted

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

# 改行区切りの入力をn行読み込んで数値リストにして返します。
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(1, n+1):
    for j in range(i, n+1, i):
        ans += j

print(ans)

Submission status: Accepted

Solution code:
# D - Sum of Divisors

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)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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:
#172D
#Sum of Divisors

n=int(input())
ans=0

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():

#---------------------------------------------------------

    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        n = N // i  # 項数n
        cnt = (n * (2 * i + (n - 1) * i)) // 2  # 初項i, 項数n の等差数列の和の公式
        ans += cnt
    print(ans)

#---------------------------------------------------------

if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
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)]
### stdout
def OutH(lst): print(*lst)
def OutV(lst): print(*lst, sep="\n")
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
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)

Submission status: Accepted

Solution code:
def main():

#---------------------------------------------------------

    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        n = N // i  # 項数n
        cnt = (n * (2 * i + (n - 1) * i)) // 2  # 初項i, 項数n の等差数列の和の公式
        ans += cnt
    print(ans)

#---------------------------------------------------------

if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum1)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 標準入力を取得
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# D - Sum of Divisors
N = int(input())
ans = 0
for x in range(1,N+1):
    a = N//x
    ans += a*(a+1)//2*x
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

dp = [0] * (n+1)

for i in range(1, n+1):
    t = n//i
    # i, 2*i,...,のt個の等差数列
    dp[i] = i*t*(t+1)//2
    
print(sum(dp))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
def multiple_sum(x, n):
    # x + 2x + ... + kx(<= 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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
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)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# O(sqrt(N))solution

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())

ans=0

Total=0

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

Submission status: Accepted

Solution code:
#create date: 2020-06-27 21:00

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
    #print(div)
    for i in range(1, n+1):
        ans += i * div[i]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#create date: 2020-06-27 21:00

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for j in range(1, N+1):
    # ある数jのNまでの倍数をすべて足す。等差数列の和
    n = N // j
    tmp = n * (2 * j + (n-1) * j) // 2
    ans += tmp

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def tousa_sum(amin, amax, d): # 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)

Submission status: Accepted

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

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

    print(sum)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
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)

Submission status: Accepted

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