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

Submission status: Accepted

Solution code:
N = int(input())

#1 is dividable by all
#-> sum = 1 + 2 + .. + N = (N+1)*N//2
ans = (N+1)*N//2
for num in range(2, N+1):
    for tt in range(N//num+1):
        ans += num*tt

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
print(sum(map(lambda x:n//x*(n//x+1)//2*x,range(1,n+1))))

Submission status: Accepted

Solution code:
n=int(input())
def f(x):
  tmp=(n//x)*(n//x+1)//2
  return x*tmp

ans=sum(map(f,range(1,n+1)))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

ans=0
for j in range(1,n+1): # 割る数
	a=j #初項
	d=n//j #項数
	tmp=(a+(a*d))*d//2
	ans+=tmp
	
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)*i//2
print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


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

print(ans)

Submission status: Accepted

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

print(int(ans))

Submission status: Accepted

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

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 itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
x=[-1]*(10**7+5)
x[0]=0
x[1]=1
i=2
while i<=10**7+1:
    j=2*i
    if x[i]==-1:
        x[i]=i
        while j<=10**7+1:
            if x[j]==-1:x[j]=i
            j+=i
    i+=1
def f(k):
    if k==1:
        return 1

    z=[]
    p=x[k]
    m=1
    ans=1
    while k>=2:
        k=k//p
        if p==x[k]:
            m+=1
        else:
            z.append(m)
            m=1
            p=x[k]

    for i in range(len(z)):
        ans*=z[i]+1
    return ans
s=0
for i in range(1,n+1):
    s+=i*f(i)
print(s)

Submission status: Accepted

Solution code:
n=int(input())
x=[i for i in range(n+3)]
x[0]=0
x[1]=1
i=2
while i<=n+1:
    j=2*i
    if x[i]==i:
        
        while j<=n+1:
            if x[j]==j:x[j]=i
            j+=i
    i+=1
def f(k):
    if k==1:
        return 1

    z=[]
    p=x[k]
    m=1
    ans=1
    while k>=2:
        k=k//p
        if p==x[k]:
            m+=1
        else:
            z.append(m)
            m=1
            p=x[k]

    for i in range(len(z)):
        ans*=z[i]+1
    return ans
s=0
for i in range(1,n+1):
    s+=i*f(i)
print(s)

Submission status: Accepted

Solution code:
import numba
@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        b=N//a
        x += a*b*(b+1)//2
    return x
N = int(input())
print(main(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numba

@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        b=N//a
        x += a*b*(b+1)//2
    return x
 
N = int(input())
print(main(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import math


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


N = z()
yakusu_nums = [0]*(N+1)
for i in range(1, N+1):
    for j in range(i, N+1, i):
        yakusu_nums[j] += 1
ans = 0
for i, yakusu_num in enumerate(yakusu_nums):
    # print(i, yakusu_num)
    ans += i*yakusu_num
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def sum_number_line(a: int, n: int) -> int:
    return (2*a + (n - 1)*a) * n // 2

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

print(ans)

Submission status: Accepted

Solution code:
from math import floor
N = int(input())
ans = 0
# for j in range(1, N+1):
#     for i in range(1, N+1):
#         if i % j == 0: # iがjの倍数なら
#             ans += i
for j in range(1, N+1):
    n = N//j
    ans += j*n*(n+1)//2
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
from numba import njit

@njit
def main(N):
    spf = np.zeros(N+1,np.int32)
    prime = np.zeros(N+1,np.int32)
    index = 0
    for i in range(2,N+1):
        if not spf[i]:
            spf[i] = i
            prime[index] = i
            index += 1
        for j in range(index):
            if prime[j] > i or i*prime[j] > N:
                break
            spf[i*prime[j]] = prime[j]
    ans = 0
    for k in range(1,N+1):
        n = k
        before = spf[n]
        count = 0
        fk = 1
        while n > 1:
            if spf[n] == before:
                count += 1
                n //= spf[n]
            else:
                fk *= (count+1)
                before = spf[n]
                count = 1
                n //= spf[n]
        fk *= (count+1)
        ans += k*fk
    print(ans)
    
N = int(input())
main(N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main(N):
    x = 0
    for i in range(1,N+1):
        for j in range(i,N+1,i):
            x += j
    return x
N = int(input())
print(main(N))

Submission status: Accepted

Solution code:
import numba

@numba.njit
def main(N):
    x = 0
    for i in range(1,N+1):
        for j in range(i,N+1,i):
            x += j
    return x
N = int(input())
print(main(N))

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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

Submission status: Accepted

Solution code:
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# ------------------- fast io --------------------
from math import gcd, ceil
 
def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi
 
 
def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans
 
def lcm(a, b): return a * b // gcd(a, b)
 
 
def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


N = int(input())
k = int(1e7+1)
muls = [0] * k
for i in range(1, N+1):
    for j in range(0, N+1, i):
        muls[j] += 1

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
if N==1:
    print(1)
    exit()
def divisor(n):
    m=N//n
    return n*m*(m+1)//2
M=N//2
ans=0
for i in range(2,M+1):
    ans+=divisor(i)
ans+=N*(N+1)-M*(M+1)//2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
sho_list = [0] * (N + 1)
for n in range(1, N + 1):
    for j in range(n, N + 1, n):
        sho_list[j] += 1
ans = 0
for k in range(1, N + 1):
    ans += k * sho_list[k]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

def number_of_divisor(n):
    ans=[0]*(n+1)
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            ans[j]+=1
    return ans

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input()); print(sum((((N // i) * (2 * 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):
    y = n//j
    ans += y*(y+1)*j//2
print(ans)

Submission status: Accepted

Solution code:
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:
#!/usr/bin/env python3

#                 N    N'
#   | 1  2  3  4  5
# 1 | 1  2  3  4  5 :  N // 1   1 * N' (N'+1) // 2
# 2 |    2     4    :  N // 2   2 * N' (N'+1) // 2
# 3 |       3       :  N // 3   3 * N' (N'+1) // 2
# 4 |          4    :  N // 4   4 * N' (N'+1) // 2
# 5 |             5 :  N // 5   5 * N' (N'+1) // 2


def solve(N):
    answer = 0
    for i in range(1, N + 1):
        mprime = N // i
        answer += i * (mprime * (mprime + 1)) // 2
    return answer


def main():
    N = int(input())  # type: int
    answer = solve(N)
    print(answer)


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

dp = [0]*(n+1)

for i in range(1,n+1):
  x = n//i
  for j in range(1,x+1):
    dp[i*j]+=1
    
sum_div = 0
for i in range(1,n+1):
  sum_div += i*dp[i]
print(sum_div)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,n+1):
  k=n//i
  ans=ans+i*k*(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_max = int(N/i)
        ans += n_max*(n_max+1)*i

    print(int(ans/2))

if __name__ =="__main__":
    main()

Submission status: Accepted

Solution code:

import numba  # noqa
from numba import njit, b1, i4, i8, f8  # noqa

N = int(input())


@njit((i8, ), cache=True)
def main(N):
    ans = 0
    for j in range(1, N + 1):
        x = N // j
        ans += int(j * x * (x + 1) / 2)
    return ans


print(main(N))

Submission status: Accepted

Solution code:
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:
'''
Created on 2020/08/23

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

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

Submission status: Accepted

Solution code:
'''
Created on 2020/08/23

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  ans=0
  for i in range(1,N+1):
    ans+=((N//i)*(N//i+1)*i)//2
  print(ans)
  return
main()
#間に合わなそう

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# AOTコンパイルテスト
import sys


def solve(n):
    su = 0
    for i in range(1, n+1):
        m = n//i
        su += m*(2*i + (m-1)*i)//2
    return su


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

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

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

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

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


if __name__ == '__main__':
    main()

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] += j
    
    return table
  
n=int(input())
print(sum(num_divisors_table(n)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    N = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from numba import njit
def main():
    @njit
    def solve(n):
        r = 0
        for i1 in range(1, n + 1):
            for i2 in range(i1, n + 1, i1):
                r += i2
        return r
    no = int(input())
    print(solve(no))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numba
def main():
    @numba.njit('(i8,)', cache=True)
    def solve(n):
        r = 0
        for i1 in range(1, n + 1):
            y = n // i1
            r += y * (y + 1) // 2 * i1
        return r
    no = int(input())
    print(solve(no))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numba
def main():
    @numba.njit
    def solve(n):
        r = 0
        for i1 in range(1, n + 1):
            y = n // i1
            r += y * (y + 1) // 2 * i1
        return r
    no = int(input())
    print(solve(no))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    r = 0
    for i1 in range(1, n + 1):
        y = n // i1
        r += y * (y + 1) // 2 * i1
    print(r)


if __name__ == '__main__':
    main()

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, 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):
  k = n//i
  ans += i * k * (k+1) //2
print(ans)

Submission status: Accepted

Solution code:

"""
def factorization(n):
    if (n == 1 ):
        return [1]
    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[1]+1 for arr in arr ]

#print(factorization(N))

sum_ans = 0
def cal(list):
    ans = 1
    for i in list:
        ans *= i

    return ans


for i in range(1,N+1):
    #print(factorization(i),i)
    sum_ans += i * cal(factorization(i))
    #lenが掛け算

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

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

Submission status: Accepted

Solution code:
n=int(input())

ans=0

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

print(int(ans))

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(i,N//i,m)
print(ans)

Submission status: Accepted

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


def main():
    n = int(input())
    table = [1]*(n+1)
    
    for i in range(2, n+1):
        for j in range(i, n+1, i):
            table[j] += 1
    
    ans = 0
    for i in range(n+1):
        ans += table[i]*i
    
    print(ans)
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
A=[0]*N
ans=0
for i in range(1,N+1):
  ii=i
  while N>=ii:
    A[ii-1]+=1
    ii+=i
  ans+=A[i-1]*i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

ans=0

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(sum_num)

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:
ans = 0

N = int(input())

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

print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
N=int(sys.stdin.readline())
# ans=sum((N//x)*(N//x+1)*x//2 for x in range(1,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:
import sys
N=int(sys.stdin.readline())
ans=sum((N//x)*(N//x+1)*x//2 for x in range(1,N+1))
print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
ans=0
for i in range(1,n+1):
    num=n//i
    ans+=(num*(i+num*i))//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

solve()

Submission status: Accepted

Solution code:
N=int(input())

# X以下のnの約数の個数
def g(n,X):
    m=X//n
    s=(m*(m+1)//2)*n
    return s

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

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
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):
    a = n//i
    b = i*a

    ans += (i+b)*a//2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
divisors = [0 for _ in range(N+1)]
result = 0

for n in range(1, N+1):
  for m in range(n, N+1, n):
    divisors[m] += 1
for i, d in enumerate(divisors):
  result += i * d
print(result)

Submission status: Accepted

Solution code:
N = int(input())
divisors = [1 for _ in range(N+1)]
result = 0

for n in range(2, N+1):
  for m in range(n, N+1, n):
    divisors[m] += 1
for i, d in enumerate(divisors):
  result += i * d
print(result)

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

def main():
    import sys
    input = sys.stdin.readline

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(int(ans))

Submission status: Accepted

Solution code:
n = int(input())

s = int(n*(n+1)/2)

for l in range(2,n+1):
    i = 1
    while l*i <= n:
        s += l*i
        i += 1
print(s)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]



n = I()
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:
# -*- coding:utf-8 -*-

def solve():
    # O(NlogN)解放
    #
    # f(1)~f(N)までの総和を求めるということは、
    # 1の倍数の数
    # 2の倍数の数
    # 3の倍数の数...
    # を1からNまで計算して足していけばよい。
    #
    # 配列 anss[i] := iの倍数の個数
    # に対して、
    # i=1からNまで順に足して行けば良い。
    N = int(input())

    anss = [0]*(N+1)

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

    ans = 0
    for i, a in enumerate(anss[1:]):
        ans += (i+1)*a
    print(ans)


def solve2():
    # O(N)の解法。
    #
    # f(1)~f(N)までの総和を求めるということは、
    # 1の倍数の数
    # 2の倍数の数
    # 3の倍数の数...
    # を1からNまで計算して足していけばよい。
    #
    # 1の倍数は    1,2,3,4,5,...
    # 2の倍数は 2*(1,2,3,4,5,...)
    # 3の倍数は 3*(1,2,3,4,5,...)
    # よって、Nまでの1の倍数の個数をg(N)とすると、
    # Nまでの2の倍数の個数は、g(N//2)
    # Nまでの3の倍数の個数は、g(N//3)
    #
    # これを利用すると、kの倍数の個数の計算はO(1)でできるので、
    # 全体の計算量はO(N)
    N = int(input())

    i = 1
    ans = 0
    while N//i != 0:
        n = N//i
        ans += i*((n*(n+1))//2)
        i += 1
    print(ans)


if __name__ == "__main__":
    solve2()

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

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

if __name__=="__main__":
    main()

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