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:
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
ans = 0
for i, cnt in enumerate(cnt_tb):
    ans += (i + 1) * cnt
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
ssum = 0
start = time.time()
for k in range(1, N + 1):
    X = int(N / k)
    ssum += k * X * (X + 1) / 2
print(int(ssum))

Submission status: Runtime Error

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
for i range(1,len(make_divisors)):
  ans = ans + make_divisors[i] * 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 * (len(sympy.divisors(i)))

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

#define UN unsigned
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define pb push_back
//~ #define x first
//~ #define y second
const int N = 1e7 + 1;

int main(void) {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	int n = 0;
	cin >> n;
	vector<int> d(N, 2);
	ll ans = 1;
	for(int i=2; i<=n; i++){
		ans += 1LL * d[i] * i;
		for(int j=2; j*i <= n; j++) {
			d[i*j]++;
		}
	}
	cout << ans << endl;
	return 0;
}

Submission status: Runtime Error

Solution code:
import sympy

N = int(input())

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

#include <bits/stdc++.h>
#include <math.h>

using namespace std;


int main()
{

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin>>n;
  //cout << sqrt(n);

  long respuesta;
  int f_K = 0;
  int start;

  #define v1000000 7235062807366
  #define v2000000 30326413365285
  #define v3000000 596981215451

  if (n>10000000) {
    start = 0;
    respuesta = 0;
  }
  else if (n>2000000) {
    start = 2000001;
    respuesta = v2000000;
  }
  else if (n>1000000) {
    start = 1000001;
    respuesta = v1000000;
  }
  else {
    start = 1;
    respuesta = 1;
  }




  for (int i = start; i<=n;i++) {
    f_K = 0;
    for (int j = 1; j<sqrt(i);j++) {
      if ((i/j)*j==i) {
        f_K+=2;
      }
    }
    if (sqrt(i)==(floor(sqrt(i))))  f_K++;
    //cout << i <<"  " <<f_K <<endl;
    respuesta+=(f_K*i);
  }
  cout << respuesta;

}

Submission status: Runtime Error

Solution code:
import math
import sys
import collections
import bisect
import sympy
readline = sys.stdin.readline


def main():
    N = int(readline().rstrip())
    ans = 0
    for i in range(1, N+1):
        n = N // i
        ans += 0.5 * n * (2*i + i * (n-1))
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
import sys
import collections
import bisect
import sympy
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    sumN = 0
    for i in range(n):
        sumN += len(sympy.divisors(i + 1)) * (i + 1)
    print(sumN)


if __name__ == '__main__':
    main()

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)

Submission status: Runtime Error

Solution code:
# sympyをインポート
 import sympy
# 
ans = 0
# 
#
for i in range(N):
     ans += (i+1) * sympy.divisor_count(i+1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:


N,M,K = list(map(int,input().split()))

As = list(map(int,input().split()))
Bs = list(map(int,input().split()))

As_sum = [0]
Bs_sum = [0]

answer = 0

for i in range(N):
    As_sum.append(As_sum[i]+As[i])
for i in range(M):
    Bs_sum.append(Bs_sum[i]+Bs[i])

answer = 0

for i in range(len(As_sum)):
    j = M
    if As_sum[i] > K:
        continue
    while As_sum[i] + Bs_sum[j] > K and j>=0:
        j -= 1
    answer = max(answer, i+j)

print(answer)

Submission status: Runtime Error

Solution code:


N,M,K = list(map(int,input().split()))

As = list(map(int,input().split()))
Bs = list(map(int,input().split()))

As_sum = [0]
Bs_sum = [0]

answer = 0

for i in range(N+1):
    As_sum.append(As_sum[i]+As[i])
for i in range(M+1):
    Bs_sum.append(Bs_sum[i]+Bs[i])

answer = 0
j = M

for i in range(len(As_sum)):
    if As_sum[i] < K:
        break
    while Bs_sum[j] > K - As_sum[i]:
        j -= 1
    answer = max(answer, i+j)

print(answer)

Submission status: Runtime Error

Solution code:
import numpy as np

N,M,K = list(map(int,input().split()))

As = np.array(list(map(int,input().split())))
Bs = np.array(list(map(int,input().split())))

As_selected = []
Bs_selected = []

answer = 0

for i in range(N+1):
    if(As[0:i].sum() <= K):
         As_selected.append(As[0:i].sum())
    else:
        break
for i in range(M+1):
    if(Bs[0:i].sum() <= K):
         Bs_selected.append(Bs[0:i].sum())
    else:
        break

answer = 0

for i in np.arange(len(As_selected))+1:
    for j in np.arange(len(Bs_selected))+1:
        if(As_selected[-i] > K):
            break

        if(As_selected[-i] + Bs_selected[-j] <= K):
            answer = max(len(As_selected)+len(Bs_selected) -i - j, answer)
            break

print(answer)

Submission status: Runtime Error

Solution code:
def Sqrt(n):
    for x in range(n+1):
        if x * x > n:
            return x

n=int(input())
answer = 0

sqrt = Sqrt(n)

for i in range(1,sqrt):
    answer += (n//i) * (i + i*(n//i)) // 2

answer += (n-sqrt+1) * (sqrt + n) // 2

print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def eratosthenes(N):
    A = [i for i in range(2, N+1)]
    P = []
    time = 0
    
    while True:
        prime = min(A)
        
        if prime > math.sqrt(N):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
    
    return P


def f(i, primes):
  factors = list()
  factor_n = list()
  prev = 1
  count = 0
  j=0
  while j<len(primes):
    if i == primes[j]:
      if prev==primes[j]:
        count+=1
      else:
        factor_n.append(count)
        prev=primes[j]
        count=1
      factor_n.append(count)
      factors.append(primes[j])
      break
    elif i % primes[j]==0:
      if prev==primes[j]:
        count+=1
      else:
        factor_n.append(count)
        count=1
        prev=primes[j]
      i = i / primes[j]
      factors.append(primes[j])
      j=0
    else:
      j+=1
  output = 1
  #print(factor_n)
  for j in range(len(factor_n)):
    output = output * (factor_n[j]+1)
  return output


primes = eratosthenes(N)

sum_n = 0
for i in range(1,N+1):
  if i==1:
    sum_n +=1
  elif i in primes:
    sum_n += i*2
  else:
    fi = f(i, primes)
    sum_n += i * fi
print(sum_n)

Submission status: Runtime Error

Solution code:
N = int(input())
def numberOfDivided(number):
  sum1 = 0
  for i in range(1, (number + 1)):
	if number % i == 0:
      sum1 += 1
  return sum1
sum = 0
for i in range(1, (N + 1)):
  l = numberOfDivided(i)
  sum += i * l
 
print(sum)

Submission status: Runtime Error

Solution code:
def numberOfDivided(number):
  sum1 = 0
  for i in range(1, number + 1):
	if number % i == 0:
      sum1 += 1
  return sum1
N = int(input())
sum = 0
for i in range(1, N + 1):
  #l = numberOfDivided(i)
  sum += i * 0
 
print(sum)

Submission status: Runtime Error

Solution code:
def numberOfDivided(number):
  sum1 = 0
  for i in range(1, number + 1):
	if number % i == 0:
      sum1 += 1
  return sum1
N = int(input())
sum = 0
for i in range(1, N + 1):
  sum += i * numberOfDivided(i)
 
print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())
 

sum = 0
for i in range(1, N + 1):
  sum += i * numberOfDivided(i)
 
print(sum)
def numberOfDivided(number):
  sum1 = 0
  for i in range(1, number + 1):
	if number % i == 0:
      sum1 += 1
  return sum1

Submission status: Runtime Error

Solution code:
N = int(input())
 
def numberOfDivided(number):
  sum1 = 0
  for i in range(1, number + 1):
	if number % i == 0:
      sum1 += 1
  return sum1
sum = 0
for i in range(1, N + 1):
  sum += i * numberOfDivided(i)
 
print(sum)

Submission status: Runtime Error

Solution code:
N = input()
 
def numberOfDivided(number):
  sum1 = 0
  for i in range(1, number + 1):
	if number % i == 0:
      sum1 += 1
  return sum1
sum = 0
for i in range(1, N + 1):
  sum += i * numberOfDivided(i)
 
print(sum)

Submission status: Runtime Error

Solution code:
N = input()
 
def numberOfDivided(number):
  sum1 = 0
  for i in range(1, number + 1)
	if number % i == 0:
      sum1 += 1
  return sum1
sum = 0
for i in range(1, N + 1):
  sum += i * numberOfDivided(i)
 
print(sum)

Submission status: Runtime Error

Solution code:
N = input()
 
def numberOfDivided(number):
  sum1 = 0
  for i in range(1, N + 1)
	if number % i == 0:
      sum1 += 1
  return sum1
sum = 0
for i in range(1, N + 1):
  sum = i * numberOfDivided(i)
 
print(sum)

Submission status: Runtime Error

Solution code:
N = input()

def numberOfDivided(number):
  sum1 = 0
  for i in range(1, number + 1)
	if number % i == 0:
      sum1 += 1
  return sum1
sum = 0
for i in range(1, N + 1):
  sum = i * numberOfDivided(i)

print(sum)

Submission status: Runtime Error

Solution code:
s = 0
q = int(n ** .5)
for i in range(1, int(n ** .5) + 1):
	x = n // i
	s += i * (x * (x+1)) / 2
	if x**2 != n:
		y = max(n // (i+1), q)
		s += (i * (i+1) // 2) * ((x * (x+1) // 2) - (y * (y+1) // 2))

print(int(s))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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:
ans = 0
for j = 1, ..., N:
  for i = 1, ..., N:
   if i % j == 0 then ans += i
print ans

Submission status: Runtime Error

Solution code:
# エラトステネスの篩
def make_prime_table(N):
    sieve = list(range(N + 1))
    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: Runtime Error

Solution code:
from sympy import factorint

N = int(input())
ans = [0]

for i in range(2,N+1):
    fx = factorint(i)
    fx_sum=1
    for _, v in fx.items():
        fx_sum = fx_sum * (v + 1)
    ans.append(i*fx_sum)

print(1+sum(ans))

Submission status: Runtime Error

Solution code:
import sympy

N = int(input())

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

print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:


n = int(input())
l = [1]*(n+1)
l[0] = 0
ans = l[1]

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

    ans += (l[i]*i)
return ans



print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    input = sys.stdin.readline
    n = int(input())
    nums_table = defaultdict(int)
    ans = 0
    for i in range(1, n+1):
        nums_table[i] = 2
    nums_table[1] = 1
    for i in range(2, n//2+1):
        for j in range(2*i,n+1,i):
            nums_table[j] += 1
    for i in range(1, n+1):
        ans += i * nums_table[i]
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit


@njit('(i8)', cache=True)
def solve(x):
    count = np.zeros(x + 1, dtype=np.int64)
    for i in range(1, x + 1):
        for j in range(i, x + 1, i):
            count[j] += j
    return count.sum()


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

Submission status: Runtime Error

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

Solution code:
import sys, re, sympy
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement, zip_longest
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip_longest(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

    

N = INT()
num = 0

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

print(num)

Submission status: Runtime Error

Solution code:
import sympy

N = int(input())
num = 0

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

print(num)

Submission status: Runtime Error

Solution code:
N=int(input())
summa=0
for n in range(1,N+1):
	kosu=0
	if n%2==0:
		for m in range(2,n,2):
			if n%m==0:
				kosuu+=1
		summa+=n*kosu
	else:
		for m in range(1,n,2):
			if n%m==0:
				kosuu+=1
		summa+=n*kosu
print(summa)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())

ans = np.zeros((N, N))
A = np.arange(1, N + 1)

ans[0, :] = A
ans[1, :] = A[A%2 == 0]
ans[2, :] = A[A%3 == 0]
ans[3, :] = A[A%4 == 0]

print(np.sum(ans))

Submission status: Runtime Error

Solution code:
import sympy

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

print(t)

Submission status: Runtime Error

Solution code:
n = int(input())

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

Submission status: Runtime Error

Solution code:
def yakusu(x):
    save = []
    for i in range(1,x + 1):
        if x % i == 0:
            save.append(i)
    return len(save)

n = input()

sum_yakusu = 0

for i in range(1, n+1):
    tmp = i * yakusu(i)
    sum_yakusu += tmp

print(sum_yakusu)

Submission status: Runtime Error

Solution code:
def yakusu(x):
    save = []
    for i in range(1,x + 1):
        if x % i == 0:
            save.append(i)
    print(save)
    return len(save)

n = input()

sum_yakusu = 0

for i in range(1, n+1):
    tmp = i * yakusu(i)
    sum_yakusu += tmp

print(sum_yakusu)

Submission status: Runtime Error

Solution code:
import sympy

a = int(input())

ans = 0
while a>0:
   ans += a*sympy.divisor_count(a)
   a -= 1
print(ans)

Submission status: Runtime Error

Solution code:
import sympy
a = int(input())
ans = 0
while a>0:
   ans += a*len(sympy.divisors(a))
	a -= 1
print(ans)

Submission status: Runtime Error

Solution code:
import sympy

a = int(input())

ans = 0
while a>0:
   ans += a*len(sympy.divisors(a))
   a -= 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
from collections import Counter as C

n=int(input())
a = list(input().split())
a = [int(i) for i in a]
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]
bc=np.array(bc).T
b=bc[0]
c=bc[1]

d=C(a)
d2={}
for k,v in d.items():
  d2[k]=k*v

#print(d)
ans=sum(d2.values())
for i in range(q):
  #print(d2)
  
  if d.get(b[i]):
    removed=d.pop(b[i])
    _=d2.pop(b[i])
    d[c[i]]+=removed
    d2[c[i]]=c[i]*d[c[i]]
  else:
    pass
  #print((np.array(list(d2.values()))))
  ans+=(c[i]-b[i])*removed
  print(ans)

Submission status: Runtime Error

Solution code:
## necessary imports
import sys
input = sys.stdin.readline
#from math import ceil, floor, factorial;

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp

## gcd function
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b);

## nCr function efficient using Binomial Cofficient
def nCr(n, k): 
    if(k > n - k): 
        k = n - k 
    res = 1
    for i in range(k): 
        res = res * (n - i) 
        res = res / (i + 1) 
    return int(res) 

## upper bound function code -- such that e in a[:i] e < x;
def upper_bound(a, x, lo=0):
    hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x:
            lo = mid+1
        else:
            hi = mid
    return lo

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p): 
    res = 1
    x = x % p  
    if (x == 0) : 
        return 0
    while (y > 0) : 
        if ((y & 1) == 1) : 
            res = (res * x) % p 
        y = y >> 1      
        x = (x * x) % p 
    return res 

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];
    
    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;


# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n): 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e7 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
spf = [0 for i in range(MAXN)]
spf_sieve() 
def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()))
## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################


## SIEVE ON
n = int(input()); ans = 0;
for i in range(1, n+1):
    fct = factoriazation(i); this = 1;
    for k in fct:
        this *= (fct[k] + 1);
    ans += i * this;
print(ans);

Submission status: Runtime Error

Solution code:
# 170Dと同じような方法g使える．ただしN=10^7なので，うまくわからないけどなぁ...
N = int(input())
Res = [0] * (N+1)
import numpy as np
Res = np.array(Res)
for i in range(1,N+1):
    Res[::i] += 1
Range = np.arange(N+1)
Res = Res * Range
print(np.sum(Res))

Submission status: Runtime Error

Solution code:
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline
from numba import*
########################################
@njit('i8(i8)',cache=1)
def main():
	mxn =  10**7
	divs = [0]*(mxn + 11)
	for i in range(1,mxn+1):
		for j in range(0, mxn+1,i):
			divs[j]+=1

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


main()

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    # nd:num of div
    r = 0
    for i1 in range(1, n):
        y = n // i1
        r += y * (y + 1) * i1 / 2
    print(int(r))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from math import factorial
from functools import lru_cache

n,v=map(int,input().split())
m=10**9+7
#r!(0>r>M)
lis=[0]
def permutation(n, x, mod=10**9+7):
    # nPx
    # 順列
    # ex) permutaion(5, 2) = 20
    tmp = 1
    for i in range(n, n-x, -1):
        tmp = (tmp * i) % mod
    return tmp


def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
 
@lru_cache(maxsize=1000)
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p))%p

acc=0
for j in range(n+1):
  s=comb(n,j,m)
  t=s*permutation(v,j,m)%m
  acc+=((-1)**j)*t*(permutation(v-j,n-j,m))**2%m
print(acc%m)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
int n;
long long sum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j+=i) 
			sum+=j;
	cout<<sum;
}

Submission status: Runtime Error

Solution code:
import sympy

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

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.divisors(k)

print(ans)

Submission status: Runtime Error

Solution code:
import numba
@numba.njit('(i8,)', cache=True)
def m(n):
    return sum(m*((n//m)**2+n//m-m**2) for m in range(1,int(n**.5)+1))

print(m(int(input())))

Submission status: Runtime Error

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

@njit
def main():
    N = int(input())
    Answer = 0

    for i in range(1,N+1):
        cnt = N // i
        num = cnt * (cnt + 1) >> 1
        num *= i
        Answer += num

print(Answer)
main()

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
n = int(input())

ans = 1
flag = [True] * (n + 1)
flag[2] = False
for i in range(2, n + 1):
    if flag[i]: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        flag[m] = False
        ans += m * (cnt + 1)
        m += i

print(ans)

Submission status: Runtime Error

Solution code:
import sympy as sp

N = int(input())

N_list = list(range(1, N+1))

num_divisors = []
for i in range(1, N+1):
	N_divisors = list(sp.divisors(i))
	num_divisors.append(len(N_divisors))

s = 0
for a, b in zip(N_list, num_divisors):
	s += a*b
	
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
import sympy
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

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

	print(ans)


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

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:
import sympy

num = int(input())
ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n=int(input())
cnt=np.zeros(n+1,dtype = int)
for i in range(1,n+1):
    cnt[i::i]+=1
ans=cnt*np.arrange(n+1)
print(ans)

Submission status: Runtime Error

Solution code:
from numba import njit

@njit("i8(i8)")
def solve(n):
    s = [1] * (n+1)
    ans = 1
    for i in range(2,n+1):
        for j in range(i,n+1,i):
            s[j] += 1
        ans += (i * s[i])
	return ans
n = int(input()) 
print(solve(n))

Submission status: Runtime Error

Solution code:
from numba import njit
import numpy as np

@njit("i8(i8)")
def solve(n):
    s = np.ones(n + 1, dtype=np.int64)
    ans = 1
    for i in range(2,n+1):
        for j in range(i,n+1,i):
            s[j] += 1
        ans += (i * s[i])
n = int(input()) 
print(solve(n))

Submission status: Runtime Error

Solution code:
from numba import njit
import numpy as np
 
 
@njit("i8(i8)")
def solve(n):
    s = [1]*(n+1)
    ans = 1
    for i in range(2,n+1):
        for j in range(i,n+1,i):
            s[j] += 1
        ans += (i * s[i])
n = int(input()) 
print(solve(n))

Submission status: Runtime Error

Solution code:
from numba import njit

@njit("i8(i8)")

n = int(input())    

def solve(n):
    s = [1]*(n+1)
    ans = 1
    for i in range(2,n+1):
        for j in range(i,n+1,i):
            s[j] += 1
        ans += (i * s[i])

print(solve(n))

Submission status: Runtime Error

Solution code:
from numba import njit 
@njit("i8(i8)")
n = int(input())    

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

print(ans)