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: Wrong Answer

Solution code:
N = int(input())
ans = 0
for i in range(1,N+1):
    for j in range(1,N+1):
        if i%j ==0:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
for i in range(1,N+1):
    for j in range(1,N+1):
        if i%j ==0:
            ans += 1

Submission status: Wrong Answer

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))+2):
    t = getlist(i)
    if math.sqrt(i) != int(math.sqrt(i)):
        t *= 2
    else:
        t *= 2
        t -= 1
    truelist.append(t*i)
print(sum(truelist))

Submission status: Wrong Answer

Solution code:
from functools import reduce
from collections import Counter


def f2nom(f):
    return reduce(lambda x, y: x * (y + 1), f, 1)


def sp(n):
    p = [2]
    *t, = range(3, n + 1, 2)
    for i, _ in enumerate(t):
        if not t[i]:
            continue
        p.append(t[i])
        for j in range(i, len(t), t[i]):
            t[j] = 0
    return p


def solve(string):
    n = int(string)
    ps = sp(int(10**3.5))
    t = [0] * (n + 1)
    for p in ps:
        if p <= n:
            t[p] = [p]
    ans = 1
    for i in range(2, n + 1):
        if not t[i]:
            ans += i * 2
            continue
        ans += i * f2nom(Counter(t[i]).values())
        for p in ps:
            if i * p > n:
                break
            t[i * p] = t[i][:]
            t[i * p].append(p)
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Wrong Answer

Solution code:
n=int(input())

bp = [0] * (n+10)
for i in range(2, n+10):
    if bp[i] == 0:
        bp[i] = i
        for j in range(i*i, n+1, i):
            bp[j] = i


def f(k):
    if k==1:
        return 1
    z=[]
    p=bp[k]
    cnt=1
    ans=1

    while k>=2:
        k//=p
        if p==bp[k]:
            cnt+=1
        else:
            ans*=cnt+1
            cnt=1
            p=bp[k]

    return ans

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

print(ans)

Submission status: Wrong Answer

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

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''


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

Submission status: Wrong Answer

Solution code:
import math
import sys
import os
from operator import mul
import numpy as np
# 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")

N = I()
ans = 0

# 足し方の見方を変える。等差数列の和をKまで足す
# 1 + 2 + 3 + 4 +...
#   + 2     + 4 +...
for i in range(1,N+1):
    # Nを超えない整数
    y = N//i
    sum = y*(y+1)*i/2
    ans += sum

print(ans)





# 素数 エラトステネス
def seachPrimeNum(N):
   max = int(np.sqrt(N))
   seachList = [i for i in range(2,N+1)]
   primeNum = []
   while seachList[0] <= max:
       primeNum.append(seachList[0])
       tmp = seachList[0]
       seachList = [i for i in seachList if i % tmp != 0]
   primeNum.extend(seachList)
   return primeNum

# 約数
def divisor_count(n):
    divisors = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors += 1
            if i != n // i:
                divisors += 1

    return divisors

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
n = int(input())
cnt = [-1] + [1] + [2] * 10000000
for i in range(2, 10000001 // 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: Wrong Answer

Solution code:
N=int(input())
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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
f = 0
for j in range(1,N+1):
    count = 0
    for i in range(1,int(j**0.5)+4):
        if j%i == 0:
            count +=1
    f = f + (j * count)
print(f)

Submission status: Wrong Answer

Solution code:
N = int(input())
f = 0
for j in range(1,N+1):
    count = 0
    for i in range(1,int(j**0.5)+4):
        if j%i == 0:
            count +=1
    print(count)
    f = f + (j * count)
print(f)

Submission status: Wrong Answer

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: Wrong Answer

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(1, n+1):
    sum+=countDivisors(i)
print(sum)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])
        if temp != 1:
            arr.append([temp, 1])
        if arr == []:
            arr.append([n, 1])
        return arr

    n = int(input())
    r = 0
    for i1 in range(1, n + 1):
        pn = factorization(i1)
        t1 = i1
        for pne in pn:
            t1 *= (pne[1] + 1)
        r += t1
    print(r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    n = int(input())

    maxa2 = (n + 1) // 2
    maxa2 = max(6, maxa2)  # maxa2が6未満だとエラーになる
    p = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2)]
    p[0] = p[1] = False
    p[2] = p[3] = p[5] = True
    for is1 in range(3, maxa2, 2):
        for is2 in range(is1 ** 2, maxa2, is1):
            p[is2] = False
    prime_list = [i for i, b in enumerate(p) if b]

    nums = [i for i in range(n + 1)]
    prime_nums = {e:defaultdict(int) for e in range(n + 1)}
    for prime in prime_list:
        p = prime
        while p <= n:
            t1 = nums[p]
            jisu = 0
            while t1 > 1 and t1 % prime == 0:
                jisu += 1
                t1 = t1 // prime
            nums[p] = t1
            prime_nums[p][prime] = jisu
            p += prime
    r = 0
    for i, pre in enumerate(prime_nums.values()):
        t2 = i
        for v in pre.values():
            t2 *= (v + 1)
        r += t2
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

print(table)

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

count = 0
for i in range(1, (N+1)//2+1):
  count += int(np.ceil((N+1)/i)) * (N - (N)%i) // 2 


print(count)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:

N = int(input())

d = {}
ans = 0
for X in range(1,N+1):
  wList = []
  for x in reversed(range(1,X+1)):
    if -(-x//2) > X+1 :
      wList.append(x)
    else:
      a,b = divmod(X, x)
      if b == 0:
        if x in d:
          wList.extend(d[x])
          break
        else:
          wList.append(a)
          wList.append(x)
    
  wList2 = set(wList)
  ans = ans + X * len(wList2)
  d[X]=wList2
print(ans)

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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

ans = np.zeros(n+1)
for i in range(1, n+1):
  ans[i::i] += 1

ans *= np.arange(n+1)
# [0, f(1), ..., f(n)] * [0, 1, 2, ..., n]
print(sum(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())

def divisor(n): 
	i = 1
	count=0
	table = []
	while i * i <= n:
		if n%i == 0:
			count+=1
		i += 1
	return i
count=0
for i in range(1,N+1): 
	count+=i*divisor(i)
print(count)

Submission status: Wrong Answer

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


ans = 0
k = make_divisors(int(input()))
for i in range(1,len(k)):
    ans = ans + k[i] * i 
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from math import ceil, sqrt

def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(Ss())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])

def binary(i):
  return [0] * (i-1) + [1]

def get_x_repeated_binary(i, size):
  b = binary(i)
  b = b * ceil(size / len(b))
  return b[:size]

n = I()
rbs = [1] * n

for i in range(2, ceil(sqrt(n))):
  rbs = [a+b for a, b in zip(rbs, get_x_repeated_binary(i, n))]

print(np.sum([i * x for i, x in enumerate(rbs, 1)]))

Submission status: Wrong Answer

Solution code:
#D
n = int(input())
#約数の数を求める＞＞倍数であり、n以下であるものの総和を求める   
ans = 0
for i in range(1, n + 1):
    #iの倍数の数を求める
    m = n // i
    #初項i:公差i:m項までの等比数列の和
    ans += n * (2 * i + i * (n - 1)) *0.5
print(int(ans))

Submission status: Wrong Answer

Solution code:
#D
n = int(input())
#約数の数を求める＞＞倍数であり、n以下であるものの総和を求める
# >>
#等差数列の和(初項a:公差d:n番目の項まで)
def Sun_of_Arithmetic_sequence(a, d, n):
    return (2 * a + (n - 1) * d) * n // 2
    
ans = 0
for i in range(1, n + 1):
    #iの倍数の数を求める
    m = n // i
    #初項i:公差i:m項までの等比数列の和
    ans += n * (2 * i + i * (n - 1)) / 2    
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def fuck(x):
    # Note that this loop runs till square root 
    j=0
    i = 1
    while i <= math.sqrt(x): 
          
        if (x % i == 0) : 
              
            # If divisors are equal, print only one 
            if (x / i == i) : 
                j+=1 
            else : 
                # Otherwise print both 
                j+=2 
        i = i + 1
    return (j)        
        
n=int(input())
arr=[]
if (n>=3):
 for x in range(1,n+1):
     arr.append(fuck(x))

ans=0 
i=1
while(i<=len(arr)):
    ans+=i*arr[i-1]
    i+=1

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    cnt = 1
    for j in range(1,int(i**0.5)+5):
        if i==j:break
        if i%j ==0:cnt += 1
    ans += i*cnt
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    m=n//i*i
    k=n//i
    if k>1:
        #ans+=(i+m)*((m-i+1)//i)//2
        ans+=(k//2)*(2*i+(k-1)*i)
    else:
        ans+=i
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def f(X):
    if X == 1 :
        return 1
    elif X == 2:
        return 2
    elif X == 3:
        return 2
    elif X == 4:
        return 3
    t = math.sqrt(X)
    suuu = t * t == X
    total = 1
    for i in range(2,int(math.sqrt(X))+1):
        if X < i :
            continue
        cnt = 1
        while X % i == 0:
            X /= i
            cnt += 1
        total *= cnt
    return total + 1 if not suuu else total

N = int(input())
r = 0
for i in range(1,N+1):
    r += N * f(i)
    #print(i,N,f(i))
print(r)

Submission status: Wrong Answer

Solution code:
import math
def f(X):
    if X == 1 :
        return 1
    elif X == 2:
        return 2
    elif X == 3:
        return 2
    elif X == 4:
        return 3
    t = math.sqrt(X)
    suuu = t * t == X
    total = 1
    for i in range(2,int(math.sqrt(X))+1):
        cnt = 1
        while X % i == 0:
            X /= i
            cnt += 1
        total *= cnt
    return total + 1 if not suuu else total

N = int(input())
r = 0
for i in range(1,N+1):
    r += N * f(i)
    #print(i,N,f(i))
print(r)

Submission status: Wrong Answer

Solution code:
import math
def f(X):
    t = math.sqrt(X)
    suuu = t * t == X
    total = 1
    for i in range(2,X+1):
        cnt = 1
        while X % i == 0:
            X /= i
            cnt += 1
        total *= cnt
    return total 

N = int(input())
r = 0
for i in range(1,N+1):
    r += N * f(i)
    print(i,N,f(i))
print(r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

    def count_yakusu(num):
        count = 0
        range1 = math.floor(math.sqrt(num))
        print(range1)
        for i in range(1, range1+1):
            if num % i == 0:
                if num / i == i:
                    count += 1
                else:
                    count += 2
        return count

    amount = 0
    for i in range(1, n+1):
        amount += i * count_yakusu(i)

    print(amount)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
"""
    Satwik_Tiwari ;) .
    4th july , 2020  - Saturday
"""

#===============================================================================================
#importing some useful libraries.
from __future__ import division, print_function

from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase


import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
#If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
#If the element is already present in the list,
# the right most position where element has to be inserted is returned

#==============================================================================================

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


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

# inp = lambda: sys.stdin.readline().rstrip("\r\n")

#===============================================================================================
#some shortcuts

mod = 1000000007
def inp(): return sys.stdin.readline().rstrip("\r\n") #for fast input
def out(var): sys.stdout.write(str(var))  #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
# def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  #as stdout.write always print sring.
def testcase(t):
    for p in range(t):
        solve()
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)
def power(a,b):
    ans = 1
    while(b>0):
        if(b%2==1):
            ans*=a
        a*=a
        b//=2
    return ans
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

#===============================================================================================
# code here ;))
def bs(a,l,h,x):
    while(l<h):
        # print(l,h)
        mid = (l+h)//2
        if(a[mid] == x):
            return mid
        if(a[mid] < x):
            l = mid+1
        else:
            h = mid
    return l

def sieve(a): #O(n loglogn) nearly linear
    #all odd mark 1
    for i in range(3,((10**6)+1),2):
        a[i] = 1
    #marking multiples of i form i*i 0. they are nt prime
    for i in range(3,((10**6)+1),2):
        for j in range(i*i,((10**6)+1),i):
            a[j] = 0
    a[2] = 1 #special left case
    return (a)


def bfs(g,st):
    visited = [-1]*(len(g))
    visited[st] = 0
    queue = []
    queue.append(st)
    new = []
    while(len(queue) != 0):
        s = queue.pop()
        new.append(s)
        for i in g[s]:
            if(visited[i] == -1):
                visited[i] = visited[s]+1
                queue.append(i)
    return visited


def dfsusingstack(v,st):
    d = deque([])
    visited = [0]*(len(v))
    d.append(st)
    new = []
    visited[st] = 1
    while(len(d) != 0):
        curr = d.pop()
        new.append(curr)
        for i in v[curr]:
            if(visited[i] == 0):
                visited[i] = 1
                d.append(i)
    return new

# 6
# 1 -1 2 3 -5 0
def solve():
    n = int(inp())
    cnt = [0]*(n+1)
    for i in range(1,n+1):
        j = 1
        while(i*j <= n):
            cnt[i*j] +=1
            j+=1
    print(cnt[:20])
    ans = 0
    for i in range(1,n+1):
        ans += i*cnt[i]
    print(ans)


testcase(1)
# testcase(int(inp()))

Submission status: Wrong Answer

Solution code:
import math
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: Wrong Answer

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

Submission status: Wrong Answer

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

    print(tot)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# エラトステネスの篩
def make_prime_table(N):
    sieve = list(range(N + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(2, int(N ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, N + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


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


N = int(input())

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

Submission status: Wrong Answer

Solution code:
# エラトステネスの篩
def make_prime_table(N):
    sieve = list(range(max(N + 1, 3)))
    sieve[0] = -1
    sieve[1] = -1
    sieve[2] = 2
    for i in range(3, int(N ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, N + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


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


N = int(input())

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

Submission status: Wrong Answer

Solution code:
# エラトステネスの篩
def make_prime_table(N):
    sieve = list(range(max(N + 1, 3)))
    sieve[0] = -1
    sieve[1] = -1
    sieve[2] = 2
    for i in range(3, int(N ** 0.5) + 1, 2):
        if sieve[i] != 0:
            continue
        sieve[i] = i
        for j in range(i * i, N + 1, i):
            if sieve[j] == 0:
                sieve[j] = i
    return sieve


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


N = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
  for j in range(1,n+1):
    if j%i==0:
      ans+=i    

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, math, copy
from collections import Counter,defaultdict,deque
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)

def main():
    n = int(input())
    dp = [0 for _ in range(n)]
    ans = 0
    for i in range(n):
        if dp[i] != 0:
            continue
        x = i+1
        div = defaultdict(int)
        check = 2
        while(x != 1 and check <= int(x**0.5)+2):
            while x%check == 0:
                div[check] += 1
                x /= check
            check += 1
        if x != 1:
            div[x] += 1
        number = 1
        for j in div:
            number *= div[j]+1
        dp[i] = div
        ans += (i+1)*number
        for j in range(2,n//(i+1)+1):
            y = (i+1)*j
            div2 = copy.deepcopy(dp[i])
            check = 2
            while(j != 1 and check <= int(x**0.5)+2):
                while j%check == 0:
                    div2[check] += 1
                    j /= check
                check += 1
            if j != 1:
                div2[j] += 1
            number = 1
            for r in div2:
                number *= div2[r]+1
            dp[y-1] = div2
            ans += y*number
    print(ans)
        
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit


@njit('i8(i8)', cache=True)
def solve(x):
    count = np.ones(x + 1, dtype=np.int8)
    for i in range(2, x + 1):
        for j in range(i, x + 1, i):
            count[j] += 1
    return int(np.sum(np.arange(x + 1) * count))


if __name__ == "__main__":
    x = int(input())
    print(solve(x))

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/07/04

@author: fanta
'''
import numpy as np

N = int(input())

sum = 0

start = 0
end = 0
startL = []
endL = []
v = np.array([])

for n in range(N):
    start = n+1

    end = N - N%start

    if (start == end):
        sum += start
    else:
        startL.append(start)
        endL.append(end)

np_startL = np.array(startL)
np_endL = np.array(endL)

v = (np_endL - np_startL) // np_startL + 1
sum += np.sum((np_endL + np_startL) * v // 2)

print(sum)

Submission status: Wrong Answer

Solution code:
def prime_factorize(n):
    a = [1]
    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

N = int(input())
sum = 0
for i in range(1,N+1):
  sum += i*len(prime_factorize(i))
print(sum)

Submission status: Wrong Answer

Solution code:
def prime_factorize(n):
    a = [1]
    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

N = int(input())

Submission status: Wrong Answer

Solution code:
n = int(input())

def cal(i):
    s = (i + i*(n//i))*(n//i)*0.5
    return s

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

Submission status: Wrong Answer

Solution code:
def solve(n):
    ans = 0
    for i in range(1,n+1):
        y = n//i
        print(y)
        ans += (y*(y+1)*i)/2
    return ans

def main():
    n = int(input())
    print(int(solve(n)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
b=int(input("b=?"))
def divisor(n):       
    hh = [1] * (n + 1);       
    p = 2; 
    while((p * p) < n): 
        if (hh[p] == 1): 
            for i in range((p * 2), n, p): 
                hh[i] = 0; 
        p += 1;   
    total = 1; 
    for p in range(2, n + 1): 
        if (hh[p] == 1):            
            count = 0; 
            if (n % p == 0): 
                while (n % p == 0): 
                    n = int(n / p); 
                    count += 1; 
                total *= (count + 1);                   
    return total; 
sum = 0
for i in range(1,b+1):
    sum += i*divisor(i)
print(sum)