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
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def era(n):
    ret = [1 for i in range(n + 2)]
    for i in range(2, int(math.sqrt(n) +3)):
        if ret[i] != 0:
            for j in range(2, n//i + 1):
                ret[i * j] = 0
    rret = []
    for i, r in enumerate(ret):
        if r == 1 and i != 0:
            rret.append(i)

    return rret


def solve():
    n = getN()
    # sosu = era(n)

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


    print(ans)
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = 0

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


print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    dp = [1] * (N + 1)
    for i in range(2, N + 1):
        for j in range(i, N + 1, i):
            dp[j] += 1
    count = 0
    for i in range(1, N + 1):
        count += dp[i] * i
    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = [0]*N

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

res = 0
for i in range(i):
    k = i+1
    res += k*T[i]

print(res)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from bisect import bisect_right, bisect_left

N = int(input())
cnt = [0]*(N+1)
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:
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def calc(N, p):
	n = int(N // p)
	cnt = int((n * (n + 1) * p // 2))
	return cnt


#処理内容
def main():
	N = int(input())
	ans = 0
	for i in range(1, N + 1):
		ans += calc(N, i)

	print(ans)



if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    r = 0
    for i in range(1, N+1):
        s = N//i
        l = i * s
        r += (s * (i + l))//2
    return r
print(main())

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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



n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

def wa(a, n, d):
   return (n * (2*a + (n-1) * d)) // 2

ans = 0
for i in range(1, n+1):
   last = n - (n % i)
   num = (last - i) // i + 1
   ans += wa(i, num, i)
print(ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np

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

def prime_table(N):
    is_prime = np.zeros(N, np.int64)
    is_prime[2:3] = 1
    is_prime[3::2] = 1
    for p in range(3, N, 2):
        if p * p >= N:
            break
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, np.where(is_prime)[0]

def main(N, primes):
    div = np.ones(N + 1, dtype=np.int64)
    for p in primes:
        for i in range(N // p + 1):
            div[p * i] += div[i]
    div *= np.arange(N + 1)
    return div.sum()

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, i8[:]))
    cc.compile()

from my_module import main

N = int(read())
is_prime, primes = prime_table(N + 1)
print(main(N, primes))

Submission status: Accepted

Solution code:
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline
#import numpy as n



def main():

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

    print(ans)





if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
def II():
	return int(sys.stdin.readline())

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

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

def SI():
	return sys.stdin.readline().strip()
n = II()
d = [0]+[1]*n
for i in range(2,n+1):
	for j in range(i,n+1,i):
		d[j]+=1
for i in range(1,n+1):
	d[i]*=i
	d[i]+=d[i-1]
print(d[n])

Submission status: Accepted

Solution code:
n = int(input())
div = [2 for _ in range(n)]
div[0] = 1
ans = 1
for num in range(2, n + 1):
    ans += num * div[num - 1]
    tmp = num - 1
    while 1:
        tmp += num
        try:
            div[tmp] += 1
        except IndexError:
            break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

CNT = [1] * (N + 1)

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

c = [1 for i in range(n+1)]
c [0] = 0
if n == 1:
  print (1)
  exit()

for i in range(2,n+1):
  x = i
  while x <= n:
    c[x] += 1
    x += i
s = 0
for i in range(n+1):
  s += i * c[i]
print (s)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = [1]*(n+1)
    ans = 1
    for i in range(2, n+1):
        a[i] += 1
        ans += a[i]*i
        for j in range(i*2, n+1, i):
            a[j] += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    memo = [1] * (n + 1)
    ans = 1
    for i in range(2, n + 1):
        memo[i] += 1
        for j in range(i * 2, n + 1, i):
            memo[j] += 1
        ans += memo[i] * i
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

def solve():
      input = sys.stdin.readline
      X = int(input())
      Count = [1] * (X + 1)
      if X == 1: print(1)
      else:
            ans = 1
            for i in range(2, X + 1):
                  Count[i] += 1
                  ans += Count[i] * i
                  d = i * 2
                  while d <= X:
                        Count[d] += 1
                        d += i
            print(ans)


      return 0

if __name__ == "__main__":
      solve()

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    cnt=[1]*(N+1)
    
    M=1+(N//2)
    if N%2==1:
        M+=1
    for i in range(1,M):
        temp=2*i
        while temp<=N:
            cnt[temp]+=1
            temp+=i
            
    ans=0
    for i in range(1,N+1):
        ans+=cnt[i]*i
    print(ans)

main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

ans = [0] * (n + 1)

for i in range(1, n + 1):
    ind = i
    while True:
        if ind >= n + 1:
            break
        ans[ind] += 1
        ind += i
res = 0
for i in range(n + 1):
    res += i * ans[i]
print(res)

Submission status: Accepted

Solution code:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=[1]*(10**7+1)
if n==1:
    print(1)
    exit()
ans=1
for i in range(2,n+1):
    k=0
    while i*k<10**7+1:
        l[i*k]+=1
        k+=1
    ans+=i*l[i]
print(ans)

Submission status: Accepted

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


N = int(input())

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

Submission status: Accepted

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


print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(N,) = [int(x) for x in input().split()]

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

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N = int(input())
sieve = [-1] * (N + 1)
sieve[0] = sieve[1] = 0
maxPrime = int(math.sqrt(N))
for i in range(maxPrime + 1):
    if sieve[i] != -1:
        continue
    else:
        index = i * i
        while True:
            if index > N:
                break
            sieve[index] = i
            index += i

ans = 1
for i in range(2,N+1):
    if sieve[i] == -1:
        ans += 2 * i
    else:
        primeFactorList = []
        index = i
        while sieve[index] != -1:
            primeFactorList.append(sieve[index])
            index //= sieve[index]
        primeFactorList.append(index)
        primeFactorList.sort()
        lastIndex = 0
        curans = 1
        for j in range(1,len(primeFactorList)):
            if primeFactorList[j] != primeFactorList[j-1]:
                curans *= (j - lastIndex + 1)
                lastIndex = j
        curans *= len(primeFactorList) - lastIndex + 1
        ans += curans * i
print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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 LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    N = I()
    f = [1]*(N+1)
    for p in range(2,N+1):
        f[p] += 1
        j = 2*p
        fp = f[p]
        while j <= N:
            f[j] += 1
            j += p
    ans = 0
    for i in range(1,N+1):
        ans += i*f[i]
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def main():

    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)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
from itertools import *
s=[*accumulate(range(n+1))]
a=0
for i in range(1,n+1):
  a+=i*s[n//i]
print(a)

Submission status: Accepted

Solution code:
def num_divisors_table(n):
    table = [0] * (n + 1)

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

    return table




n = int(input())
a = num_divisors_table(n)
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    c = [1] * (N+1)
    for i in range(2, N+1):
        for j in range(i, N+1, i):
            c[j] += 1
    # print(c)
    ans = 0
    for i in range(1, N+1):
        ans += i * c[i]
    return ans


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = [0 for _ in range(n+1)]
ans = 0
for i in range(1,n+1):
  now = 0
  while True:
    try:
      now += i
      a[now] += 1
    except:
      break
  ans += i*a[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

memo = [2] * (n+1)
memo[1] = 1

for k in range(2, n // 2 + 2):
    for i in range(2, n):
        if k * i > n:
            break
        memo[k*i] += 1

ans = 0
for i, memoi in enumerate(memo):
    ans += i * memoi
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

is_prime = [True] * (n + 1)
is_prime[0] = is_prime[1] = False
for i in range(2, n + 1):
    ans += i
    for j in range(2, n // i + 1):
        is_prime[i * j] = False
        ans += i * j

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ret = 0
for i in range(1, N + 1) :
  j = N // i
  if j < 1 :
    break
  ret += (1 + j) * i * j // 2
  
print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    ans=0
    for i in range(1,N+1):
        d=N//i
        ans+=i*(1+d)*d//2

    print(ans)





if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

count=[1]*(n+1)

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

ans=0

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

print(ans)

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


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

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

    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Runtime Error

Solution code:
import sympy
n= int(input())
o=0
for i in range(1,n+1):
    o+=i*len(sympy.divisors(i))
print(o)

Submission status: Runtime Error

Solution code:
from math import sqrt as s

N = int(input())

if N == 1: print(1)
else:
  total = 1
  for i in range(2, N+1):
    count = 0
    for j in range(1, int(s(i))+1):
      if i % j == 0: count += 1
    if s(i) % 1 == 0: count = count * 2 - 1
    else: count *= 2
    total += i * count

print(total)

Submission status: Runtime Error

Solution code:
N = int(input())
import math
truelist = [0]
def getlist(x):
    list = []
    for i in range(1,x+1):
        if x%i == 0 and (not i in list):
            list.append(i)
    return len(list)
tlist = getlist(N)
for i in range(1,int(math.sqrt(N+1))):
    t = getlisst(i)*i
    if math.sqrt(i) != int(math.sqrt(i)):
        t *= 2
    else:
        t *= 2 -1
    truelist.append(getlist(i)*i)
print(sum(truelist))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import random
# random.sample to choose distinct element in a list or tuple 
abc=list(map(int ,input().split()))
k=int(input())
count=0
# x=element
for i in range(0,k):
    element=random.sample(list(abc))
    second_multi=element*2
    if(element == abc[0]):
        if(b>second_multi and c>b):
            count+=1
        else:
            count+=0
    elif(element == abc[1]):
        second_multi1=element*2
        if(second_multi1>a and c>b):
            count+=1
        else:
            count+=0
    elif(element== abc[2]):
        second_multi2=element*2
        if(b>a and second_multi2>b):
            count+=1
        else:
            count+=0

if(count > 1):
    print("Yes")
elif(count==0):
    print("No")

Submission status: Runtime Error

Solution code:
import math
import sys
import os
from operator import mul
import sympy

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

# 約数
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)

    divisors.sort()
    return divisors

N = I()
ans = 0

for i in range(1,N+1):
    ans += i * sympy.divisor_count(i)
    # print(i,sympy.divisor_count(i))

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sympy
n = int(input())
print(sum([i*sympy.divisor_count(i) for i in range(1, n+1)]))

Submission status: Runtime Error

Solution code:
import sys
from itertools import chain
import numpy as np


def solve(N: int):
    fx = np.zeros(N + 1, dtype=np.uint64)
    for i in range(1, N + 1):
        fx[i::i] += 1
    return np.sum(np.arange(0, N + 1, dtype=np.uint64) * fx)


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N = map(int, line.split())
    N = int(next(tokens))  # type: int
    answer = solve(N)
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sympy
N=int(input())
for i in range(N+1):
    res += i*len(sympy.divisors(i))

print(res)

Submission status: Runtime Error

Solution code:
import math
N = int(input())
Array = [1]*(N+1)
for i in range(1,int(math.sqrt(N))):
  for j in range(i+1,N,i):
    N[j]+=1
ans = 0
for i in range(1,N+1):
  ans+=i*N[i]
print(ans)

Submission status: Runtime Error

Solution code:
import sympy
f = 0
N = int(input())
for i in range(N+1):
    x = list(sympy.divisors(i))
    f = f + (i * len(x))
print(f)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:
ans = 0
for i in range(N):
    j = N // i
    ans += i * j * (j+1) / 2

print(ans)

Submission status: Runtime Error

Solution code:

import sys
import math
input = sys.stdin.readline

def inp():
    return(int(input()))
    
def SieveOfEratosthenes(n, prime,primesquare, a): 
    for i in range(2,n+1): 
        prime[i] = True
    for i in range((n * n + 1)+1): 
        primesquare[i] = False
    prime[1] = False
    p = 2
    while(p * p <= n): 
        if (prime[p] == True): 
            i = p * 2 
            while(i <= n): 
                prime[i] = False
                i += p 
        p+=1
    j = 0
    for p in range(2,n+1):  
        if (prime[p]==True):  

            a[j] = p 

            primesquare[p * p] = True
            j+=1
def countDivisors(n): 
    if (n == 1): 
        return 1
    prime = [False]*(n + 2) 
    primesquare = [False]*(n * n + 2) 
    a = [0]*n 
    SieveOfEratosthenes(n, prime, primesquare, a) 
    ans = 1
    i=0
    while(1):  
        if(a[i] * a[i] * a[i] > n): 
            break

        cnt =  1
        while (n % a[i] == 0): 
            n = n / a[i] 
            cnt = cnt + 1 
        ans = ans * cnt 
        i+=1
    n=int(n) 
    if (prime[n]==True): 
        ans = ans * 2
    elif (primesquare[n]==True): 
        ans = ans * 3
    elif (n != 1): 
        ans = ans * 4
    return ans 
    
n = inp()
sum = 0
for i in range(n):
    sum+=countDivisors(i)

Submission status: Runtime Error

Solution code:
import sympy
n=int(input())
sum=0
for i in range(1,n):
  sum+=sumsympy.divisor_count(i)*i
print(sum)

Submission status: Runtime Error

Solution code:
import sympy

N = int(input())
ans = 0

for i in range(1,N+1):
    ans += i * sympy.divisor_count(i)

print(ans)

Submission status: Runtime Error

Solution code:
import sympy
n = int(input())
ans, count = 0, 0

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

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

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
S = 0
import sympy

for i in range(1,N+1):
    S = S + sympy.divisor_count(i)*i

print(S)

Submission status: Runtime Error

Solution code:
n = int(input())
cnt_tb = [0]*n
for i in range(1, n + 1):
    j = 1
    tmp = i*j
    while (tmp <= n):
        cnt_tb[tmp] += 1
        j += 1
        tmp = i*j
ans = 0
for i, cnt in enumerate(cnt_tb):
    ans += (i + 1) * cnt
print(ans)