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: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
from itertools import chain
import numpy as np


def sieve(n: int):
    """n以下の(1を含まない)素数を返す"""
    if n < 2:
        return []
    primes = [2]
    if n == 2:
        return primes
    flags = np.array([True for i in range(3, n + 1, 2)])
    for i in range(len(flags)):
        if flags[i]:
            n = i * 2 + 3
            primes.append(n)
            flags[i::n] = False
    return primes


def print_a(A):
    for i in range(0, len(A), 5):
        s = f"{i:3} :"
        for j in range(i, min(i + 5, len(A))):
            s += f"{A[j]:7d}"
        print(s)


def f(X, primes):
    y = 1
    for prime in primes:
        if prime > X:
            break
        count = 1
        while X % prime == 0:
            X = X // prime
            count += 1
        y *= count
    return y


def solve(N: int):
    primes = sieve(N)
    fx = np.ones(N + 1, dtype=np.uint64)
    for prime in primes:
        factor = prime
        t = 1
        while factor <= N:
            fx[factor::factor] *= (t + 1)
            fx[factor::factor] = fx[factor::factor] / t
            t += 1
            factor *= prime
    fx *= np.arange(0, len(fx), dtype=np.uint64)
    return fx.sum()


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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    div=1
    n=i
    for j in range(2,int(n**0.5)+1):
        if n%j==0:
            count=1
            while n%j==0:
                n//=j
                count+=1
            div*=count
    if n>1:
        div*=2
    ans+=div*i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

import numpy as np

c = np.zeros(N)
A = 0

for i in range(N):
  for j in range(int(i)+1):
    if (int(i) + 1) % (int(j) + 1) == 0:
      c[i] = c[i] + 1
    else:
      c[i] = c[i]
      
for b in range(N):
  A = A + c[b]*(int(b)+1)
  

  
print(int(A))

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    # 1からｎまでの数それぞれの約数を求める。約数の側から倍数になっているか数える。
    nums = [2] * (n + 1) # 1～nの約数をいれる器。「1とその数自身」があるので初期値2．
    nums[1] = 1 # 1の約数は１だけなので初期値１。
    for i1 in range(2, n // 2 + 1):
        for i2 in range(i1 * 2, n + 1, i1): # i1～nのあいだを間隔i1でスキップしていく。
            nums[i2] += 1
    r = 1 # 数１のk * f(k)は１なので初期値に１にする。
    for j1 in range(2, n + 1):
        r += j1 * nums[j1]
    print(r)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def factorization(n):
    if (n == 1 ):
        return [1]
    arr = []
    temp = n

    
    for i in range(2, int(-(-n**0.5//1))+1) :
        if ( temp % i == 0):
            cnt = 0
            while (temp % i == 0):
                cnt +=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return [arr[1]+1 for arr in arr ]

#print(factorization(N))

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

    return ans


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

print(sum_ans)

Submission status: Time Limit Exceeded

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]

res = 0
N=int(input())
for i in range(N+1):
    res += i*len(make_divisors(i))

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    maxa2 = n + 1
    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
        for i1 in range(n // prime):
            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: Time Limit Exceeded

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 = 1
    for i1 in range(2, 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: Time Limit Exceeded

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

prime_counts = [0] * (N+1)

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

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(1, N+1):
    tmp = i
    while(tmp <= N):
        ans += tmp
        tmp += i

print(ans)

Submission status: Time Limit Exceeded

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)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def div_num(x):
  num = 0
  for i in range(1,x+1):
    if x % i == 0:
      num += 1
  return num

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

Submission status: Time Limit Exceeded

Solution code:
import math

def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]

def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num

N = int(input())
ans = 0

for i in range(1,N+1):
    ans += i * search_divisor_num_1(i)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
result = 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 num in range(1, N+1):
	result += len(make_divisors(num)) * num
print(result)

Submission status: Time Limit Exceeded

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

def make_divisors(n):
    lower_divisors = []
    upper_divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)

    upper_divisors.reverse()
    return lower_divisors + upper_divisors

for num in range(1, N+1):
	result += len(make_divisors(num)) * num
print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 0

for a in range(1, n+1):
  for b in range(1, n+1):
    if a % b == 0:
      ans += a

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

s = int(N*(N+1)/2)
for k in range(2,N+1):
    i = 1
    while k*i <= N:
        s += k*i
        i += 1

print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
def num(n):
    i = 1
    a = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            a.append(i)
            if i != n//i:
                a.append(n//i)
    return len(a)

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())
F = np.zeros(N+1, dtype=int)
K = np.arange(N+1, dtype=int)

for i in range(1,(N+1)//2+1):
    F[::i] += 1

F[(N+1)//2+1:] += 1

print(np.sum(K * F))

Submission status: Time Limit Exceeded

Solution code:
class Osa_k:
    def __init__(self, n_max):
        self.n_max = n_max
        self.min_factor = min_factor = list(range(n_max + 1))
        min_factor[2::2] = [2] * (n_max // 2)
        min_factor[3::6] = [3] * ((n_max + 3) // 6)
        for i in range(5, int(n_max ** .5) + 1, 2):
            if min_factor[i] == i:
                for j in range(i*i, n_max + 1, i):
                    if min_factor[j] == j:
                        min_factor[j] = i

    def __call__(self, n):
        min_factor = self.min_factor
        t = []
        while n > 1:
            if t and t[-1][0] == min_factor[n]:
                t[-1][1] += 1
            else:
                t.append([min_factor[n], 1])
            n //= min_factor[n]
        return t

def f(K):
    res = 1
    for _, i in K:
        res *= i + 1
    return res

P = Osa_k(10**7)
print(sum(i * f(P(i)) for i in range(1, int(input()) + 1)))

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

class Osa_k:
    def __init__(self, n_max):
        self.n_max = n_max
        self.min_factor = min_factor = list(range(n_max + 1))
        min_factor[2::2] = [2] * (n_max // 2)
        min_factor[3::6] = [3] * ((n_max + 3) // 6)
        for i in range(5, int(n_max ** .5) + 1, 2):
            if min_factor[i] == i:
                for j in range(i*i, n_max + 1, i):
                    if min_factor[j] == j:
                        min_factor[j] = i

    def __call__(self, n):
        if not 1 <= n <= self.n_max: raise ValueError("Invaild Value!")
        min_factor = self.min_factor
        n_twoes = (n & -n).bit_length() - 1
        res = {2 : n_twoes}
        n >>= n_twoes
        while n > 1:
            p = min_factor[n]
            res[p] = res.get(p, 0) + 1
            n //= p
        return res.values()

def f(K):
    res = 1
    for i in K:
        res *= i + 1
    return res

P = Osa_k(10**7)
print(sum(i * f(P(i)) for i in range(1, int(input()) + 1)))

Submission status: Time Limit Exceeded

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])
#          wList.append(a)
#          break
#        else:
        wList.append(a)
        wList.append(x)
    
  wList2 = set(wList)
  ans = ans + X * len(wList2)
#  print(X,len(wList2),X * len(wList2),ans)
#  print(wList2)
#  d[X]=wList2
print(ans)
#print(d)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = 0
import math
def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]

def f(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num


for i in range(1,N+1):
    S = S + f(i)*i

print(S)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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))
    return table
count=0
for i in range(1,N+1): 
	count+=i*len(divisor(i))
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
ans = 0
print(int(sum([math.floor(N / (i+1)) * (math.floor(N / (i+1)) + 1) * (i+1) / 2  for i in range(N)])))

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
import math
  
def divisors(n):
  count = 0
  i = 1
  max = math.sqrt(n)
  while i <= max:
    if n % i == 0 and i < max:
      count += 2
    elif n % i == 0 and i == max:
      count += 1
    i += 1
  return count

N = int(input())
ans = 0

for i in range(N):
  j = i+1
  ans += j * divisors(j)
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0
for i in range(N+1):
    mod = 1
    cnt = 1
    while mod**2 <= i:
        if i%mod ==0:
            cnt+=1
            mod+=1
    ans+=i*cnt
print(ans-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

d = [0]*n
for i in range(1, n+1):
    k = 1
    while i*k <= n:
        d[i*k-1] += 1
        k += 1

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

l = []
num = 0
for i in range(1,n+1):
  for j in range(1,i+1):
    if i%j == 0:
      num += 1
  l.append(num)
  num = 0
  
ans = 0
for i in range(1,n+1):
  ans = ans + i*l[i-1]
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

Submission status: Time Limit Exceeded

Solution code:

import math

N = int(input().strip())

t = 0
for j in range(1,N+1):
    cnt = 0
    for i in range(1,int(math.sqrt(j)+1)):
        if j % i == 0 and i ** 2 != j:
            cnt += 2
        elif j % i == 0 and i ** 2 == j:
            cnt += 1
    t = t + cnt*j

print(t)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
now=0
for i in range(1,n+1):
    now+=sum([j for j in range(1,n+1) if j%i==0])
print(now)

Submission status: Time Limit Exceeded

Solution code:
def make_prime_table(n):
    sieve = [True] * (n + 1)
    sieve[0] = False
    sieve[1] = False
    for i in range(4, n + 1, 2):
        sieve[i] = False
    for i in range(3, int(n ** 0.5) + 1, 2):
        if not sieve[i]:
            continue
        for j in range(i * i, n + 1, i * 2):
            sieve[j] = False
    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: Time Limit Exceeded

Solution code:
n=int(input())
div_count=[0 for i in range(10**7+1)]
for i in range(1,10**7+1):
    for j in range(1,10**7+1):
        if i*j>10**7:
            break
        else:
            div_count[i*j]+=1
result=0
for i in range(1,n+1):
    result+=i*div_count[i]
print(result)

Submission status: Time Limit Exceeded

Solution code:
def divis(n):
  count = 0
  for i in range(1, n+1):
    if n % i == 0:
      count += 1
  return count
n = int(input())
summ = 0
for i in range(1,n+1):
  t = divis(i)
  summ += i*t
print(summ)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

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

ans = 0

for k in range(1, N+1):

    if k == 1:
        ans += 1
    else:
        ans += k * len(make_divisors(k))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

print(ans)

# 2darray [[0] * 4 for i in range(3)]
# import itertools

Submission status: Time Limit Exceeded

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
    a =  lower_divisors + upper_divisors[::-1]
    return len(a)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
s = 0

def devisor(x):
    count = 0
    for i in range(1,math.floor(math.sqrt(x))+1):
        if (x % i) == 0:
            count += 2
            if i**2 == x:
                count -= 1
    return count

for i in range(1, N+1):
    s += i * devisor(i)

print(s)

Submission status: Time Limit Exceeded

Solution code:
def divCount(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; 

def solve():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        ans+=i*(divCount(i))
    return ans
    
            
print(solve())

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0

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

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

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)
  while len(b) < size:
    b = b * 2
  return b[:size]

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

for i in range(2, min(n+1, 1000)):
  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: Time Limit Exceeded

Solution code:
N = int(input())

sum = 0

for j in range(1,N+1):
    k = int(N/j)
    sum += int((1+k)*k/2*j)

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())


total = 0
f = 0

def func(x):
    num = 1
    for i in range(1, x):
        if x % i == 0:
            num += 1
    return num
        
for i in range(1, n + 1):
    total += (i * func(i))
    
print(total)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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 in range(1,N+1):
    factor = make_divisors(i)
    ans += i * len(factor)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
for i in range(1, N + 1):
    a = i * (N // i) * (N // i + 1) / 2
    A.append(round(a))
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
p = [2]
for i in range(3, int(10**(7/2))):
    for prime in p:
        if i % prime == 0:
            break
        if prime == p[-1] or prime**2 > i:
            p.append(i)
            break      
SUM = 1
for K in range(2, N+1):
    d_K = K
    for prime in p:
        if K == 1:
            break
        count_p = 1
        while K % prime == 0:
            count_p += 1
            K = K // prime
        d_K *= count_p
    SUM += d_K
print(SUM)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
p = [2]
for i in range(3, int(10**(7/2))):
    for prime in p:
        if i % prime == 0:
            break
        if prime == p[-1] or prime**2 > i:
            p.append(i)
            break      
SUM = 1
for K in range(2, N+1):
    d_K = K
    for prime in p:
        count_p = 1
        while K % prime == 0:
            count_p += 1
            K = K // prime
        d_K *= count_p
    SUM += d_K
print(SUM)

Submission status: Time Limit Exceeded

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

for i in range(1, N + 1):
    count = 0
    for j in range(i, 0, -1):
        if i % j == 0:
            count += 1

    ans += i * count

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

f_x = 0
sum = 0


for i in range(1,N+1):
    for j in range(1,int(math.floor(i+1)/2)+1):
        if i%j == 0:
            f_x += 1
    sum += i*(f_x+1)
    f_x = 0

print(sum-1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

f_x = 0
sum = 0

for i in range(1,N+1):
    for j in range(1,i+1):
        if i%j == 0:
            f_x += 1
    sum += i*f_x
    f_x = 0

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
viz = [0 for i in range(n+1)]
viz[0] = viz[1] = 1
prime = []
for i in range(n+1):
    if not viz[i]:
        prime.append(i)
        j = i*i
        while j <= n:
            viz[j] = 1
            j += i
for i in range(n+1):
    viz[i] = 0
exp = [0 for i in range(len(prime))]
ans = 0

def df (x, now):
    global ans
    ans += x*now
    viz[x] = 1
    i = len(prime) - 1
    while i >= 0:
        y = prime[i]
        if x*y <= n and not viz[x*y]:
            z = now // (exp[i]+1) * (exp[i]+2)
            exp[i] += 1
            df (x*y, z)
            exp[i] -= 1
        i -= 1

df(1, 1)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def sieve1(n):
    isPrime = [True] * (n+1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2*2, n+1, 2):
        isPrime[i] = False
    for i in range(3, n+1):
        if isPrime[i]:
            for j in range(i+i, n+1, i):
                isPrime[j] = False
    return isPrime
numOfDivisors = [2] * (n+1)
numOfDivisors[1] = 1
numOfDivisors[0] = 0
isPrime = sieve1(n)
for i in range(2, n+1):
    if isPrime[i]:
        for j in range(2*i, n+1, i):
            x = j // i
            numOfDivisors[j] += numOfDivisors[x] - 1
ans = 0
for k in range(1, n+1):
    ans += numOfDivisors[k] * k
print (ans)

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    N = int(input())

    ans = 0
    for n in range(1, N+1):
        for m in range(n, N+1, n):
            ans += m
    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    N = int(input())

    def calc(x: int, n: int):
        y = int(n/x)
        return int(y * (y + 1) * x / 2)

    result = 0
    for i in range(1, N+1):
        result += calc(i, N)
    print(result)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def divisor(n):
    i = 1
    count = 0
    while i * i <= n:
        if n % i == 0:
            if i * i != n:
                 count += 2
            else:
                count += 1
        i += 1
    return count*n

N = int(input())
ans = 0
for i in range(1, N+1):
    ans += divisor(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
R=0
zz=1
for x in range(N):
  z=x+1
  for i in range(z//2):
    a=i+1
    if z%a==0:
      zz+=1 
  R=R+z*zz
  zz=1  
print(R)

Submission status: Time Limit Exceeded

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 += Sun_of_Arithmetic_sequence(i, i, m)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#D
n = int(input())
#公約数列挙
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 k in range(1, n + 1):
    ans += k * len(make_divisors(k))
print(ans)

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
ans = 0
 
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)

    
    return len(divisors)
  
for i in range(N):
     ans += (i+1) * make_divisors(i+1)
print(ans)