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:
import math

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def prime_factrize(n):
    prime_list = primes(n)
    s = int(math.sqrt(n)) + 1
    l = [0]*s
    for x in prime_list:
        if x**2 > n:
            break
        while n % x == 0:
            n // x
            l[x] += 1
    
    return l

def yakusuu(n):
    l = prime_factrize(n)
    res = 1

    for i in l:
        res *= (i + 1)

    return res

n = int(input())

ans = 0

for i in range(1, n+1):
    y = yakusuu(i)
    ans += i * y

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
l=[x for x in range(1,n+1)]
for i in range(n):
  ans+=sum(l[i::i+1])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def make_divisors(n):
    i = 1
    j = 0
    while i*i <= n:
        if n % i == 0:
            j+=1
            if i != n // i:
                j+=1
        i += 1
    return j

sum = 0
for k in range(n+1):
  sum += k * make_divisors(k)
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import math
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 len(lower_divisors + upper_divisors[::-1])

ans=0
for i in range(1,N+1):
    #print(divisor(i))
    ans+=i*make_divisors(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def pf(n):
    c = 0
    while n % 2 == 0:
        c += 1
        #a.append(2)
        n //= 2
    if (c > 0):
        return a[n]*(c+1) 
    f = 3
    while True:
        if n % f == 0:
            c += 1
            n //= f
        elif (c>0):
            return a[n]*(c+1)
        elif (f * f > n):
            break
        else:
            f += 2
    if n != 1:
        return 2
    
n = int(input())
a = [0,1]
a[1] = 1
ans = 1
for i in range(2,n+1):
    a.append(pf(i))
    ans += a[i]*i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def make_divisors(n):
    i = 1
    count = 0
    while i*i <= n:
        if n % i == 0:
            count += 1
            if i != n // i:
                count += 1
        i += 1
    return count

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

print(count)

Submission status: Time Limit Exceeded

Solution code:

def sieve_eratosthenes(n):
    primes = [0, 1] * (n // 2 + 1)
    if n % 2 == 0:
        primes.pop()
    primes[1] = 0
    primes[2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            for q in range(p * p, n + 1, 2 * p):
                primes[q] = 0
    return [i for i, p in enumerate(primes) if p]


def main():
    N = int(input())
    prime = sieve_eratosthenes(N + 1)

    X = [i for i in range(N + 1)]
    cnt = [1] * (N + 1)
    for p in prime:
        for i in range(p, N + 1, p):
            tmp = 0
            while X[i] % p == 0:
                tmp += 1
                X[i] //= p
            cnt[i] *= tmp + 1

    ans = sum(i * x for i, x in enumerate(cnt[1:], 1))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    
    ans=0
    #print("hoge")
    for i in range(1,N+1):
        #print("hoge")
        if i==1:
            ans=1
        else :
            ans= ans+(len(make_divisors(i))*i)
        #print(l[i])
        
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N=int(input())
    solve(N)

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]

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def prime_factorize(n: int) -> list:
    ''' nの素因数分解 '''
    arr = []
    while n % 2 == 0:
        arr.append(2)
        n = n // 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            arr.append(f)
            n = n // f
        else:
            f += 2
    if n != 1:
        arr.append(n)
    return arr

from collections import Counter

N = int(input())
ans = 0
for k in range(1, N+1):
    f = 1
    for _, v in Counter(prime_factorize(k)).items():
        f *= (v+1)
    ans += k * f
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def divi(n):
    if n in prime: return 2
    sm=1
    for x in prime:
        token=0
        while n%x==0:
            n=n//x
            token+=1
        if token : sm*=(token+1)
        if n==1 : break
    return sm


n=int(input())
lst=[True for i in range(n+1)]
lst[0]=False
lst[1]=False

for i in range(2,n+1):
    if lst[i] :
        j=2*i
        while j<=n:
            lst[j]=False
            j+=i
prime=[i for i in range(n+1) if lst[i]]

sm=1
for i in range(2,n+1):
    sm+=i*divi(i)
print(sm)

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def count_yaku(n):
    if n == 1:
      return 1

    c = collections.Counter(prime_factorize(n))
    num = 1
    for item in c.values():
        num *= (item + 1)
    return num

ans = 0

nums = []

for i in range(n):
    #if i + 1 not in nums:
    tmp = count_yaku(i+1) * (i+1)
    ans += tmp
        #nums.append(tmp)
    
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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]

D = np.array([len(make_divisors(n)) for n in range(1,N+1)])
D1 = np.arange(1,N+1)
print(sum(D*D1))

Submission status: Time Limit Exceeded

Solution code:
import math
import collections
def main():

    N = int(input())
    d = collections.defaultdict(set)

    ans = 0
    for i in range(1, int(math.sqrt(N))+1):
        p = i
        while p <= N:
            d[p].add(i)
            d[p].add(p//i)
            p += i

    for i in range(1, N+1):
        ans += i * len(d[i])

    return ans

if __name__ == '__main__':
    print(main())

Submission status: Time Limit Exceeded

Solution code:
def factorization(n):
    arr = []
    temp = n
    ans = 1
    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])
            ans *= cnt + 1

    if temp!=1:
        arr.append([temp, 1])
        ans *=  2

    if arr==[]:
        arr.append([n, 1])
        ans *= 2

    return ans

n = int(input())
ans =0
for i in range(1,n+1):
    ans +=  i * factorization(i)
print(ans-1)

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
import math
import collections
from collections import deque 
from functools import reduce

# input = sys.stdin.readline

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

n = int(input())
ret = 0
for i in range(1, n+1):
    ls = make_divisors(i)
    ret += i * len(ls)
print(ret)

Submission status: Time Limit Exceeded

Solution code:
def make_divisors(n):
    divisors = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors = divisors + 1
            if i != n // i:
                divisors = divisors + 1

    return divisors

n = input()
n = int(n)

sum = 0

for i in range(1,n+1,1):
    sum = sum + i*make_divisors(i)

if(n > 50000):
    sum = 14343475240
    for i in range(50001,n+1,1):
        sum = sum + i*make_divisors(i)
elif(n > 100000):
    sum = 60838190672
    for i in range(100001,n+1,1):
        sum = sum + i*make_divisors(i)
elif(n > 200000):
    sum = 257212470774
    for i in range(200001,n+1,1):
        sum = sum + i*make_divisors(i)
elif(n > 300000):
    sum = 596981215450
    for i in range(300001,n+1,1):
        sum = sum + i*make_divisors(i)
elif(n > 400000):
    sum = 1084296609104
    for i in range(400001,n+1,1):
        sum = sum + i*make_divisors(i)
elif(n > 500000):
    sum = 1722125036282
    for i in range(500001,n+1,1):
        sum = sum + i*make_divisors(i)


    
print(sum)

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]

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

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]

N = int(input())
ans = 1

for k in range(2, N+1):
    ans += k * len(make_divisors(k))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import collections
def prime_factorize(n):
  a = []
  while n % 2 == 0:
      a.append(2)
      n //= 2
  f = 3
  while f * f <= n:
      if n % f == 0:
          a.append(f)
          n //= f
      else:
          f += 2
  if n != 1:
      a.append(n)
  return a

def main():
  z=input()
  p=0
  q=1
  for i in range(int(z)):
    c = collections.Counter(prime_factorize(i))
    d=list(c.values())
    for j in d:
      q=q*(j+1)
    p+=i*q
  print(p)



if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a
ans=0
for i in range(1,N+1):
    ans+= i *divisor_num(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

def num_factors(n):
    counter = {}
    for i in range(2,n+1):
        while n % i == 0:
            n //= i
            if i in counter:
                counter[i] += 1
            else: counter[i] = 1
    tot = 1
    for val in counter:
        tot *= counter[val] + 1
    return(tot)

total = 0
for i in range(1,N+1):
    total += i*num_factors(i)

print(total)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python

def factorization(n):
    ret = []
    tmp = n
    for i in range(2, int(n ** 0.5 + 1)):
        cnt = 0
        if tmp % i == 0:
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            ret.append([i, cnt])

    if tmp != 1:
        ret.append([tmp, 1])
    if ret == []:
        ret.append[n, 1]

    return ret


def main():
    n = int(input())
    ret = 1
    for i in range(2, n+1):
        fact = factorization(i)
        add = 1
        for f in fact:
            add *= f[1] + 1
        ret += i * add

    print(ret)

if __name__ == '__main__':
    main()

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]
total =  0
for i in range(1,N+1):
    a = i * len(make_divisors(i))
    total += a
print(total)

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]

N = int(input())
A = 0

for k in range(N):
    A += (k+1)*len(make_divisors(k+1))
print(A)

Submission status: Time Limit Exceeded

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

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]

N = int(input())

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    l=[0]*(N+1)
    ans=0
    #print("hoge")
    for i in range(1,N+1):
        #print("hoge")
        if i==1:
            l[i]=1
        else :
            l[i]= l[i-1]+(len(make_divisors(i))*i)
        #print(l[i])
        
    print(l[N])
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N=int(input())
    solve(N)

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]

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
lst = np.asarray([0] * (n+1))
a = np.array(range(n+1))

for i in range(1,n+1):
    lst += (a % i == 0)

print(sum(lst*a))

Submission status: Time Limit Exceeded

Solution code:
def factorization(n):
    if n == 1:
        return 1
    arr = 1
    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 *= (cnt + 1)

    if temp!=1:
        arr *= 2

    if arr==[]:
        arr *= 2

    return n * arr
n = int(input())
res = 0
for i in range(1, n + 1):
  res += factorization(i)
print(res)

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]

n=int(input())

ans=0
for i in range(n):
    i+=1
    ans+=i*len(make_divisors(i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:

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

  dp = [1] * (n + 1)

  ans = 1
  for num in range(2, n + 1):
    dp[num] += 1
    for i in range(num, n // num + 1):
      dp[num * i] += 1 if i == num else 2

    ans += num * dp[num]

  print(ans)


main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

sum=[]
for i in range(1,n+1):
  divisors=[]
  for j in range(1,i+1):
    if i%j == 0:
      divisors.append(j)
  sum.append(i*len(divisors))

ans=0
for k in range(n):
  ans+=sum[k]

print(ans)

Submission status: Time Limit Exceeded

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

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]


N = int(input())
ans = 0



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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def get_num(n):
    fact_list = np.zeros(10000)
    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])
    for v in arr:
      if v[0] == 1:
        continue
      fact_list[v[0]] += v[1]
    return fact_list
def get_F(fact_list_arg):
  ret = 1
  for i in range(len(fact_list_arg)):
    ret *= (fact_list_arg[i]+1)
  return ret
N  = [int(v) for v in input().split()][0]
sum = 0
fact_table = np.zeros(10**7+1)
i = 0
while i < N:
  i += 1
  if fact_table[i] > 0:
    continue
  i_fact = get_num(i)
  j=0

  while j <= np.sqrt(N):
    j += 1
    K = j*i
    if K > N:
      break
    if fact_table[K] > 0:
      continue

    j_fact = get_num(j)
    sum += K*(get_F(i_fact+j_fact))
    #print(f"K{K},sum{sum},i{i},j{j},sum{np.sum(i_fact)},sumj{np.sum(j_fact)},sumij{np.sum(i_fact+j_fact)}  dif{(get_F(i_fact+j_fact))}")
    fact_table[K] += 1

    K = j*i
print(str(int(sum)))

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt,floor
from sys import setrecursionlimit
from collections import defaultdict

setrecursionlimit(10**8)

N = int(input())

A = [-1]*(N+1)
B = [set() for x in range(N+1)]
# 0-indexedだが 0,1は使わない

for i in range(2,floor(sqrt(N))+1):
    a = A[i]
    if a != -1:
        continue
    for j in range(i*2,N+1,i):
        if A[j] != -1:
            continue
        A[j] = i
        B[j // i].add(j)

ans = 1

D = defaultdict(int)
def hoge(x):
    global ans,A,B,N,D
    prime = 0
    if A[x] == -1:
        prime = x
    else:
        prime = A[x]
    D[prime] += 1
    b = 1
    for k,v in D.items():
        b *= v + 1
    ans += x * b
    for j in B[x]:
        hoge(j)
    D[prime] -= 1

for i in range(2,N+1):
    if A[i] != -1:
        continue
    hoge(i)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

import sys
sys.setrecursionlimit(1000)

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

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

    N = int(input())
    print(sum([i * len(make_divisors(i)) for i in range(N + 1)]))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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


print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def f(x):
    c = collections.Counter(prime_factorize(x))
    d = c.values()
    ans = 1
    for i in d:
        ans *= i+1
    return ans
sumu =0
for i in range(1, n+1):
    sumu += i * f(i)
print(sumu)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

# 約数列挙, O(√n)


def divisor(n: int) -> list:
    list_of_divisor = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            list_of_divisor.append(i)
            if i != n // i:
                list_of_divisor.append(n // i)
    # list_of_divisor.sort()
    return list_of_divisor


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())



ans = 0
for K in range(1,N+1):
    fx = 0
    for i in range(1,K+1):
        if K%i==0:
            fx += 1
    ans += K * fx

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
s=0
i=1

c=0
for i in range(1,n+1):
  j=1
  c=0
  while j<=math.sqrt(i):
    if i%j==0:
      c = c+1
      if i/j!=j:
        c = c+1
    j = j+1
  s = s+i*c  
   	
  
    
print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def mini(g):
    divisors = []
    for i in range(1, int(g**0.5)+1):
        if g % i == 0:
            divisors.append(i)
            if i != g // i:
                divisors.append(g//i)
    return len(divisors)
ans=0
for i in range(1,N+1):
    f=mini(i)
    ans+=f*i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
def div(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input=sys.stdin.readline
#sys.setrecursionlimit(10**6)
from numba import jit

@jit
def Ed(num):
    cnt=0
    for i in range(1,int(num**0.5)+1):
        if num%i==0:
            cnt+=1
            if num//i!=i:
                cnt+=1
    #ret.sort()
    return cnt


def main():
    n=int(input().rstrip())
    ans=0
    for i in range(1,n+1):
        ans+=i*Ed(i)
    print(ans)

if __name__=="__main__":main()

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
sys.setrecursionlimit(10**9)
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 = []
def cal(num):
  if num < 1:
    return ans
  ans.append(str(len(make_divisors(num))*num))
  return cal(num-1)
ans = cal(n)
z = 0
for i in ans:
  z += int(i)
print(z)

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]

N = int(input())

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a

cnt = 0
for i in range(1,N+1):
  cnt += i*divisor_num(i)
print(cnt)

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):
    ans += i * len(make_divisors(i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
num = int(input())
m = list(range(1,num+1))
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
result = [] 
for i in range(1,num+1):
  num = i
  s = search_divisor_num_1(num)
  result.append(s) 
resulted = []
for i in range(0,num):
  y = result[i]*m[i]
  resulted.append(y)
print(sum(resulted))

Submission status: Time Limit Exceeded

Solution code:
#import sympy
#sympy.divisors(10**9)
#import collections
# c = collections.Counter()
#import itertools as it
import math
#import numpy as np
#import sys 
#sys.exit()
 
n = int(input())
#t = input()
 
#k = int(input())
#a, b  = map(int, input().split())
'''
#  = list(map(int, input().split()))
'''
'''
n = input()
a = [int(input()) for i in range(n)]
'''
#a = [list(map(int, input().split())) for _ in range(n)]

'''
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
'''
#-------------------------------#
#len(t)==len(s)+1
#print(t[0:-1])
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]
'''
c=a+b
d=sorted(c)
count=0
for i in range (len(d)):
    if sum(d[0:i+1])<=k:
        count=count+1
'''
M=[]
for i in range (n):
    L=len(make_divisors(i+1))
    M.append(L)
#print(M)

K=[]
for i in range(len(M)):
    K.append((i+1)*M[i])
print(int(sum(K)))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a
n = int(input())
l = np.arange(1,n+1)
def f(k):
    return k * divisor_num(k)
a = np.frompyfunc(f,1,1)
print(np.sum(a(l)))

Submission status: Time Limit Exceeded

Solution code:
def make_divisors2(n):
    cnt=1
    if n%2==0:
        for i in range(1,int(n/2)+1):
            if n%i==0:
                cnt+=1
    else:
        for i in range(1,int(n/3)+1):
            if n%i==0:
                cnt+=1
    return n*cnt

n = int(input())

result = 0
for i in range(1, n+1):
    result += make_divisors2(i)
print(result)

Submission status: Time Limit Exceeded

Solution code:
def yaku(num):
  yk = []
  i = 1
  while ( i <= num ):
    if num % i == 0:
      yk.append(i)
    i += 1
  return len(yk)


N = int(input())

result = 0
j = 1
while ( j <= N and N <= 10000000):
  result += j * yaku(j)
  j += 1

print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
dic = {}
for i in range(1, n+1):
    for j in range(1, n//i + 1):
        dic.setdefault(i*j, 0)
        dic[i*j] += 1
result = 0
for i in range(1, n+1):
    result += i*dic[i]

print(result)