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: Runtime Error

Solution code:
import sympy
sympy.divisors(10**9)

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 = int(input())
sum = 0
for i in range(n):
    sum += (i + 1) * len(make_divisors(i + 1))
print(sum)

Submission status: Runtime Error

Solution code:
import sympy

n = int(input())

ans = 0

for k in range(1, n+1):
    ans += k * len(sympy.divisors(k))

print(ans)

Submission status: Runtime Error

Solution code:
import sympy

def func(k):
    i = 1
    cnt = 1
    if k == 1:
        return cnt
    while i < k:
        if k % i == 0:
            cnt += 1
            if i != n // i:
                cnt += 1
        i += 1
    return cnt

n = int(input())
sum = 0
for i in range(1, n + 1):
    sum += i * sympy.divisor_count(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 * len(sympy.divisors(i))
print(ans)

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 = 0
for k in range(1, n+1):
  ans += k*sympy.divisor_count(k)
print(ans)

Submission status: Runtime Error

Solution code:
import sympy

n  = int(input())

ans = 0
for i in range(1, n+1):
    fk = len(sympy.divisors(i))
    ans += i * fk

print(ans)

Submission status: Runtime Error

Solution code:
import sympy


n = int(input())

total = 0
for i in range(1,n+1):
    div = sympy.divisors(i)
    total += i * len(div)
print(total)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)
from sympy import divisor_count 
N = int(input())
a=0
for i in range(0,N+1):
    a+= i*divisor_count(i)
print(a)

Submission status: Runtime Error

Solution code:
import sympy
import math

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

N = int(input())
ans = 0
for i in range(N):
    n = N + 1
    if is_prime(n):
        ans += 2*n
    else:
        ans += (i+1) * sympy.divisor_count(i+1)
print(ans)

Submission status: Runtime Error

Solution code:
# ABC172d


from collections import Counter


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    n = int(input())

    def prime_factorize(n):  # 因数分解
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a
    import math

    def calcYakusu(n):
        #d = Counter(prime_factorize(n))
        waru = math.floor(n ** 0.5)
        yakusu_zu = []
        n2 = n
        while yakusu.get(n2) == None:
            if waru == 1:
                yakusu_zu.append(2)
                break
            if n2 % waru == 0:
                n2 = n2 // waru
                yakusu_zu.append(waru)
            else:
                waru -= 1
        if waru != 1:
            yakusu_zu.append(n2)

        ans = 1
        for i in yakusu_zu:
            ans += yakusu[i] - 1

        return ans

    yakusu = [0] * (n + 2)
    yakusu[1] = 1
    yakusu[2] = 2
    ans = 0
    for i in range(1, n + 1):
        if yakusu.get(i) == None:
            yakusu[i] = calcYakusu(i)
        ans += i*yakusu[i]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sympy

n=int(input())

s=0
for i in range(1, n+1):
    s+=sympy.divisor_count(i) * i

print(s)

Submission status: Runtime Error

Solution code:
N=int(input())
num=0
for i in range(1, N+1):
  yakusuu= divisor(i)
  num=num + i*yakusuu
        
print(num)
         
def divisor(n): 
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
      i += 1
  table = list(set(table))
  tablelen=len(table)
  return tablelen

Submission status: Runtime Error

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

main()

Submission status: Runtime Error

Solution code:
N = int(input())

import sympy
ans = 0
for i in range(1,N+1):
    ans +=  i*len(sympy.divisors(i))

print(ans)

Submission status: Runtime Error

Solution code:
import sympy


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


n = int(input())

total = 0
for num in range(1, n+1, 1):
    total += num * len(sympy.divisors(num))
print(total)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def divisor(p):
    return [n for n in range(1,p) if p % n == 0]
  
n = int(input())

a = [divisor(i)*i for i in range(1, n+1)]

print(sum(a))

Submission status: Runtime Error

Solution code:
N=int(input())
num=0
for i in range(1, N+1):
  yakusuu= divisor(i)
  num=num + i*yakusuu
        
print(num)
         
def divisor(n): 
  i = 1
  table = []
  hile i * i <= n:
  if n%i == 0:
    table.append(i)
    table.append(n//i)
    i += 1
  table = list(set(table))
  tablelen=len(table)
  return tablelen

Submission status: Runtime Error

Solution code:
import sympy

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

Submission status: Runtime Error

Solution code:
import sympy

N = int(input())

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

Submission status: Runtime Error

Solution code:
import sympy

n = int(input())

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

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(2147483647)
from sympy import divisor_count 
N = int(input())
a=0
for i in range(0,N+1):
    a+= i*divisor_count(i)
print(a)

Submission status: Runtime Error

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

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 sys
sys.setrecursionlimit(10**6)
import sympy
n=int(input())
cnt=0
for i in range(1,n+1):
    cnt+=i*len(sympy.divisors(i))
print(cnt)

Submission status: Runtime Error

Solution code:
import sympy


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


n = int(input())
total = 0
for num in range(1, n+1, 1):
    total += num * len(sympy.divisors(num))

print(total)

Submission status: Runtime Error

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

ans = 0
for i in range(n):
    ans += (i+1) * sympy.divisor_count(i+1)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)

import sympy
n=int(input())
ans=0

for i in range(1,n+1):
    ans+=i*len(sympy.divisors(i))

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
num=0
for i in range(1, N+1):
	yakusuu= divisor(i)
	num=num + i*yakusuu
      
print(num)
     
def divisor(n): 
	i = 1
    table = []
    while i * i <= n:
    	if n%i == 0:
        	table.append(i)
            table.append(n//i)
            i += 1
    table = list(set(table))
   	tablelen=len(table)
  	return tablelen

Submission status: Runtime Error

Solution code:
import sympy
N = int(input())
ans = 0
for k in range(1, N+1):
    ans += k*len(sympy.divisors(k))
print(ans)

Submission status: Runtime Error

Solution code:
from sympy import divisor_count 
N = int(input())
a=0
for i in range(0,N+1):
    a+= i*divisor_count(i)
print(a)

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

res=0
for k in range(1,N+1):
	res+=k*len(sympy.divisors(k))
print(res)

Submission status: Runtime Error

Solution code:
N = int(input())

smallest_prime = [0]*(N+1)
for x in range(2,N+1):
    if smallest_prime[x] == 0:
        smallest_prime[x] = x
    else:
        continue
    for j in range(2,N+1):
        ind = x*j
        if ind>=len(smallest_prime):
            break
        else:
            smallest_prime[ind] = x
num_pos = [0]*(N+1)
num_pos[1] = 1
num_pos[2] = 2

for x in range(3,len(num_pos)):
    if x == smallest_prime[x]:
        # x is a prime
        num_pos[x] = 2
    else:
        old_x = x
        p = smallest_prime[x]
        exp = 0
        while x%p == 0:
            x = x//p
            exp += 1
        num_pos[old_x] = (exp+1)*num_pos[x]
temp = 0

for i in range(1,N+1):
    temp += num_pos[i]*i
print(temp)

Submission status: Runtime Error

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

sum=0
for i in range(1,n+1):
    sum+=i*sympy.divisor_count(i)

print(sum)

Submission status: Runtime Error

Solution code:
import sympy

inputNum = int(input())
count = 0

for i in range(1, inputNum + 1):
    count += i * len(sympy.divisors(i))

print(count)

Submission status: Runtime Error

Solution code:

import sympy
n=int(input())

sum=0
for i in range(1,n+1):
    sum+=i*sympy.divisor_count(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.divisors(i)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import math
import numpy as np
import functools
import operator
import collections
import itertools
import sympy

N=int(input())
ans=0
for i in range(1,N+1):
    ans+=i*len(sympy.divisors(i))
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

n=int(input())

import sympy
sum=0
for i in range(1,n+1):
    sum+=i*sympy.divisor_count(i)

print(sum)

Submission status: Runtime Error

Solution code:
import sympy

N = int(input())
div = []
for i in range(1,N+1):
    f = sympy.divisor_count(i)
    div.append(f*i)

print(sum(div))

Submission status: Runtime Error

Solution code:
N = int(input())

smallest_prime = [0]*(N+1)
for x in range(2,N+1):
    if smallest_prime[x] == 0:
        smallest_prime[x] = x
    else:
        continue
    for j in range(2,len(A)):
        ind = x*j
        if ind>=len(smallest_prime):
            break
        else:
            smallest_prime[ind] = x
num_pos = [0]*(N+1)
num_pos[1] = 1
num_pos[2] = 2

for x in range(3,len(num_pos)):
    if x == smallest_prime[x]:
        # x is a prime
        num_pos[x] = 2
    else:
        old_x = x
        p = smallest_prime[x]
        exp = 0
        while x%p == 0:
            x = x//p
            exp += 1
        num_pos[old_x] = (exp+1)*num_pos[x]
temp = 0

for i in range(1,N+1):
    temp += num_pos[i]*i
print(temp)

Submission status: Runtime Error

Solution code:
N=int(input())
num=0
for i in range(1, N+1):
  yakusuu= divisor(i)
  num=num + i*yakusuu
  
print(num)

def divisor(n): 
	i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
	table = list(set(table))
    tablelen=len(table)
	return tablelen

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(iput())
sum = 0

for i in range(1, n+1):
	sum += sympy.divisor_count(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*len(sympy.divisors(i))

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

furui = np.zeros(N+1, dtype=float)
for i in range(1, N+1):
    furui[i::i] += 1

for i in range(1, N+1):
    furui[i] = furui[i]*i

print(int(furui.sum()))

Submission status: Runtime Error

Solution code:
import sympy


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())
ans=0
for i in range(1,N+1):
    # ans+= i*len(sympy.divisors(i))
    ans+= i*len(make_divisors(i))
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 27 21:14:26 2020

@author: naoki
"""
import sympy 
def make_divisors(n):
    lower_divisors, upper_divisors = [] , []
    i = 1
    while i*i <= n:
        if n%i == 0:
            lower_divisors.append(i)
            if i != n //i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())

count = 0 
for i in range(1,N+1):
    count += i*(len(make_divisors(i)))
print(count)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[16]:


import sympy


# In[13]:


N = int(input())


# In[15]:


print(sum(k*sympy.divisor_count(k) for k in range(1,N+1)))


# In[ ]:

Submission status: Runtime Error

Solution code:
import sympy
count = 0
N = int(input())
for i in range(N):

    count = count + (i+1) * sympy.divisor_count(i+1)

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sympy

x = int(input())
ans = 0
for i in range(1,x+1):
    ans = ans + i*sympy.divisor_count(i)

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sympy import divisor_count 
N = int(input())
a=0
for i in range(0,N+1):
    divisor_count_n = divisor_count(i)
    a+= i*divisor_count_n
print(a)

Submission status: Runtime Error

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
for i in range(1, n+1):
  sum += make_divisors(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())
x = 0

for i in range(n):
        euler = sympy.divisor_count(i + 1)
        x += euler * (i +1)

print(x)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0
for k in range(N):
    fk = len(sympy.divisors(k+1))
    ans += (k+1) * fk
print(ans)

Submission status: Runtime Error

Solution code:
import sympy
N = int(input())
ans = 0
for k in range(N):
    ans += k*len(sympy.divisors(k))
print(ans)

Submission status: Runtime Error

Solution code:
import sympy
N = int(input().strip())
x=0
for i in range(N):
    x+=sympy.divisor_count(i+1)*(i+1)
print(x)

Submission status: Runtime Error

Solution code:
import sympy

n = int(input())
res = sum([i * len(sympy.divisors(i)) for i in range(1, n+1)])
print(res)

Submission status: Runtime Error

Solution code:
import sympy


n=int(input())

sum_data=0

for i in range(1,n+1):
    x=sympy.divisor_count(i)

    sum_data=x*i+sum_data

print(sum_data)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(result)