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

# d = dict()


def make_divisors(n):
    divisors = []
    # res = 0
    # if n in d:
    #     return d
    for i in range(1, int(n ** 0.5) + 1):
        # if i in d:
        #     res += 1
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    # return res + len(divisors)
    return len(divisors)


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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
def SieveOfEratosthenes(n, prime,primesquare, a): 
    for i in range(2,n+1): 
        prime[i] = True
    for i in range((n * n + 1)+1): 
        primesquare[i] = False
    prime[1] = False
  
    p = 2
    while(p * p <= n): 
        if (prime[p] == True): 
            i = p * 2 
            while(i <= n): 
                prime[i] = False
                i += p 
        p+=1
    j = 0
    for p in range(2,n+1):  
        if (prime[p]==True): 
            a[j] = p 
            primesquare[p * p] = True
            j+=1

def countDivisors(n): 
    if (n == 1): 
        return 1
    prime = [False]*(n + 2) 
    primesquare = [False]*(n * n + 2) 
    a = [0]*n
    SieveOfEratosthenes(n, prime, primesquare, a)
    ans = 1
    i=0
    while(1): 
        if(a[i] * a[i] * a[i] > n): 
            break
        cnt = 1  
        while (n % a[i] == 0): 
            n = n / a[i] 
            cnt = cnt + 1 
        ans = ans * cnt 
        i+=1
      
    n=int(n) 
    if (prime[n]==True): 
        ans = ans * 2
    elif (primesquare[n]==True): 
        ans = ans * 3
    elif (n != 1): 
        ans = ans * 4
  
    return ans
c=0
for i in range(1,n+1):
  c+=(i*countDivisors(i))
print(c)

Submission status: Time Limit Exceeded

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

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 = list()
num = list()
for i in range(1,N+1):
    ans.append(make_divisors(i))
    num.append(i)
    
print(sum(np.array(ans)*np.array(num)))

Submission status: Time Limit Exceeded

Solution code:
#Problem D
N = int(input())

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



ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
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())
num=0
for i in range(1, N+1):
    yakusuu= divisor_num(i)
    num    =num + i*yakusuu

print(num)

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 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:
def make_divisors(n):
  cnt = 0
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      cnt += 1
      if i != n // i:
        cnt += 1
  return cnt

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

Submission status: Time Limit Exceeded

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

def num_d(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)*n

N=int(input().rstrip('\n'))
res = 0
time = N // 10
last = N % 10
if time>=1:
  for i in range(time):
    res += num_d(i*10+1)
    res += num_d(i*10+2)
    res += num_d(i*10+3)
    res += num_d(i*10+4)
    res += num_d(i*10+5)
    res += num_d(i*10+6)
    res += num_d(i*10+7)
    res += num_d(i*10+8)
    res += num_d(i*10+9)
    res += num_d(i*10+10)
  if last >= 1:
    for i in range(1,last+1):
      res += num_d(10*time+i)
else:
  for i in range(1,last+1):
    res += num_d(i)
print(res)

Submission status: Time Limit Exceeded

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

def countDivisors(n) : 
    cnt = 0
    for i in range(1, (int)(math.sqrt(n)) + 1) : 
        if (n % i == 0) : 

            if (n / i == i) : 
                cnt = cnt + 1
            else : 
                cnt = cnt + 2
                  
    return n * cnt

ans = 0
for i in range(1, N+1):
    ans += countDivisors(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]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def yakusu(value):
  test = 0
  for val in range(1, value + 1, 1):
    if value % val == 0:
      test += 1
  return test

answer = 0
for i in range(1, N + 1, 1):
  answer += (i * yakusu(i))
print(answer)

Submission status: Time Limit Exceeded

Solution code:
import math

def countDivisors(n) : 
    cnt = 0
    for i in range(1, (int(math.sqrt(n)) + 1)): 
        if (n % i == 0) : 
            # If divisors are equal, 
            # count only one 
            if (n / i == i) : 
                cnt = cnt + 1
            else : # Otherwise count both 
                cnt = cnt + 2
    return cnt 

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

Submission status: Time Limit Exceeded

Solution code:
def f(x):
  rtn = 0
  i = 1
  while i * i < x:
    rtn += 2 if x%i == 0 else 0
    i += 1
  return rtn + (1 if i * i == x else 0)

N = int(input())
ans = 0
K = 1
while K <= N:
  ans += K*f(K)
  K += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

tot=0
for M in range(1,N+1):
  m_tot=0
  for i in range(1,M+1):
    if M%i==0:
      m_tot+=1
  tot+=M*m_tot

print(tot)

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

Submission status: Time Limit Exceeded

Solution code:
def f(n):
  p=1
  if n%2==0:
    c=0
    while n%2==0:
      c+=1
      n/=2
    p*=c+1
  for i in range(3,int(n**0.5)+1,2):
    if n%i==0:
      c=0
      while n%i==0:
        c+=1
        n/=i
      p*=c+1
  if n!=1:
    p*=2
  return p

n=int(input())
x=0
for i in range(1,n+1):
  pi=f(i)
  x+=i*pi

print(x)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
cnt = 1
res = 0

for j in range(1, N+1):
  div_low = []
  div_up = []
  i = 1
  while i * i <= j:
    if j % i == 0:
      # res += (cnt * i)
      # cnt += 1
      div_low.append(i)
      if i != j // i:
        div_up.append(j // i)
    i += 1
  div = div_low + div_up[::-1]
  # print(div)
  res += (cnt * len(div))
  cnt += 1
  

print(res)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())


def factorization(num):
    arr = []
    temp = num
    for i in range(2, int(-(-num**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 not arr:
        arr.append([num, 1])
    return arr


count = 0
for i in range(1, n+1):
    if i == 1:
        count += 1
        continue
    f = factorization(i)
    tmp = 0
    for f_dict in f:
        if tmp == 0:
            tmp = f_dict[1] + 1
        else:
            tmp = tmp * (f_dict[1] + 1)
    count += i * tmp
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
from collections import defaultdict

def prime_factorization_1(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        dict_counter = defaultdict(int)
        for prime in prime_list:
            while num % prime == 0:
                dict_counter[prime] += 1
                num //= prime
        if num != 1:
            dict_counter[num] += 1

        dict_counter = dict(dict_counter)

        return dict_counter

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 prime_factorization_2(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1

        return dict_counter
      
def search_divisor_num_2(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        divisor_num = 1
        dict_fact = prime_factorization_1(num)
        for value in dict_fact.values():
            divisor_num *= (value + 1)
        return divisor_num
      
def f(num):
  if num==1:
    return 1
  else:
    a = 0
    for i in range(1,num+1):
      a += i*search_divisor_num_2(i)
    return a

  
num = int(input())
ans = f(num)
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
from collections import defaultdict
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
ans=0
for i in range(1,N+1):
  ans+=search_divisor_num_1(i)*i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#ABC172D
def make_divisors(n):
    cot = 0
    i = 1
    while i*i <= n:
        if n / i == i:
            cot = cot + 1 
            break
        elif n % i == 0:
            cot = cot + 2
        i += 1
    return cot
N = int(input())
ans = 0
for i in range(N):
    ans = ans + (i+1) * int(make_divisors(i+1))
print(ans)

Submission status: Time Limit Exceeded

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

a = int(input())
ans = 0
li = []
for i in range(a):
    li = divisor(i+1)
    ans += (i + 1) * len(li)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math as mt 
import collections
N = int(raw_input())
MAXN = N+1
  
# stores smallest prime factor for 
# every number 
spf = [0 for i in range(MAXN)] 
  
# Calculating SPF (Smallest Prime Factor)  
# for every number till MAXN. 
# Time Complexity : O(nloglogn) 
def sieve(): 
    spf[1] = 1
    for i in range(2, MAXN): 
          
        # marking smallest prime factor  
        # for every number to be itself. 
        spf[i] = i 
  
    # separately marking spf for  
    # every even number as 2 
    for i in range(4, MAXN, 2): 
        spf[i] = 2
  
    for i in range(3, int(mt.ceil(mt.sqrt(MAXN)))): 
          
        # checking if i is prime 
        if (spf[i] == i): 
              
            # marking SPF for all numbers 
            # divisible by i 
            for j in range(i * i, MAXN, i):  
                  
                # marking spf[j] if it is  
                # not previously marked 
                if (spf[j] == j): 
                    spf[j] = i 
# A O(log n) function returning prime  
# factorization by dividing by smallest  
# prime factor at every step 
def getFac(x): 
    count=0
    ret = collections.Counter()
    while (x != 1): 
        ret[spf[x]]+=1
        count+=1
        x //= spf[x]
    return ret , count


sieve() 
ans = 0
for i in range(1,N+1):
    fac, count = getFac(i)
    tmp = 1
    for v in fac.values():
        tmp *= (v+1)
    ans += tmp*i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math  
  
# method to print the divisors 
def printDivisors(n) : 
    count = 0
    # Note that this loop runs till square root 
    i = 1
    while i <= math.sqrt(n): 
          
        if (n % i == 0) : 
              
            # If divisors are equal, print only one 
            if (n / i == i) : 
                count+=1
            else : 
                # Otherwise print both 
                count+=2
        i = i + 1
    return count
n = int(input())
ans = 0
for i in range(1,n+1):
    ans+=printDivisors(i)*i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1

    return num

N=int(input())
if N==1:
    print(1)
else:
    sum=0
    for i in range(2,N+1):
        sum+=i*num_divisors_trial_division(i)
        #print(temp)
    print(1+sum)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

if __name__ == '__main__':
    n = int(sys.stdin.readline())
    x = 0
    for i in range(1,n+1):
        x += i*make_divisors(i)
    print(x)

Submission status: Time Limit Exceeded

Solution code:
import math
def countDivisors(n):
    cnt = 0
    for i in range(1, (int)(math.sqrt(n)) + 1):
        if (n % i == 0):
            if (n / i == i):
                cnt = cnt + 1
            else:
                cnt = cnt + 2
                  
    return cnt
#print(countDivisors(5))    
n=int(input())    
ans=0
for i in range(1,n+1):
    ans+=(i*countDivisors(i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def get_primes(n):
    sieve = [1] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i:: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def prime_factorization(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


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

    yakusu = [0] * (N + 1)

    primes = get_primes(N)

    ans = 0
    for i in range(1, N + 1):
        if yakusu[i] != 0:
            ans += i * yakusu[i]
            continue

        primefacts = prime_factorization(i)
        c = collections.Counter(primefacts)
        tmp = 1
        for k in c.keys():
            tmp *= c[k] + 1

        yakusu[i] = tmp
        ans += i * tmp

        for prime in primes:
            if i * prime > N:
                break
            if prime in c.keys():
                yakusu[i * prime] = (c[prime] + 2) * tmp // (c[prime] + 1)
            else:
                yakusu[i * prime] = tmp * 2

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def f(n):
    d=np.int64([i for i in range(1,n+1) if n%i==0])
    return(len(d))

sum=np.int64(0)
for i in np.int64(range(1,N+1)):
    sum+=np.int64(i)*np.int64(f(i))
print(sum)

Submission status: Time Limit Exceeded

Solution code:
def div_count(n):
  count = 0
  for v in range(1,n+1):
    if n%v == 0:
    	count += 1
  return count
N = int(input())
sum = 0
for i in range(1,N+1):
  sum += i*div_count(i)

print(sum)

Submission status: Time Limit Exceeded

Solution code:
def findDivisors(n): 
      
    # List to store the count 
    # of divisors 
    div = [0 for i in range(n + 1)] 
      
    # For every number from 1 to n 
    for i in range(1, n + 1): 
          
        # Increase divisors count for 
        # every number divisible by i 
        for j in range(1, n + 1): 
            if j * i <= n: 
                div[i * j] += 1
    return div

n=int(input())
ans=0
dp=findDivisors(n)
for i in range(len(dp)):
	ans+=(dp[i]*(i))
#print(*dp)
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]

n = int(input())

s = 0

for k in range(n):
  s += (k+1)*len(make_divisors(k+1))
  
print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

r = 0

for i in range(N):
    m = i + 1
    j = int(N/(m))
    r = r + int(m*j*(1+j)/2)

print(r)

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 divisor_count(n):
  c = collections.Counter(prime_factorize(n))
  count = 1
  for i in c.values():
    count *= (i + 1)
  return count
  
if __name__ == '__main__':
  N = int(input())
  total = 0
  for i in range(1, N + 1):
    total += i * divisor_count(i)
  print(total)

Submission status: Time Limit Exceeded

Solution code:
MAX = 10000001;

# array to store
# prime factors
factor = [0] * (MAX + 1);


# function to generate all
# prime factors of numbers
# from 1 to 10^6
def generatePrimeFactors():
    factor[1] = 1;

    # Initializes all the
    # positions with their value.
    for i in range(2, MAX):
        factor[i] = i;

        # Initializes all
    # multiples of 2 with 2
    for i in range(4, MAX, 2):
        factor[i] = 2;

        # A modified version of
    # Sieve of Eratosthenes
    # to store the smallest
    # prime factor that divides
    # every number.
    i = 3;
    while (i * i < MAX):
        # check if it has
        # no prime factor.
        if (factor[i] == i):
            # Initializes of j
            # starting from i*i
            j = i * i;
            while (j < MAX):
                # if it has no prime factor
                # before, then stores the
                # smallest prime divisor
                if (factor[j] == j):
                    factor[j] = i;
                j += i;
        i += 1;

    # function to calculate


# number of factors
def calculateNoOFactors(n):
    if (n == 1):
        return 1;
    ans = 1;

    # stores the smallest
    # prime number that
    # divides n
    dup = factor[n];

    # stores the count of
    # number of times a
    # prime number divides n.
    c = 1;

    # reduces to the next
    # number after prime
    # factorization of n
    j = int(n / factor[n]);

    # false when prime
    # factorization is done
    while (j > 1):
        # if the same prime
        # number is dividing
        # n, then we increase
        # the count
        if (factor[j] == dup):
            c += 1;

            # if its a new prime factor
        # that is factorizing n,
        # then we again set c=1 and
        # change dup to the new prime
        # factor, and apply the formula
        # explained above.
        else:
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;

            # prime factorizes
        # a number
        j = int(j / factor[j]);

        # for the last
    # prime factor
    ans = ans * (c + 1);

    return ans;


# Driver Code

if __name__ == "__main__":
    generatePrimeFactors()
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        tmp = calculateNoOFactors(i)
        ans += i*tmp
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(raw_input())
mem = {1: 1}
def f(k):

	q = k
	d = 2
	cp = 1
	while(q != 1):
		if q % d == 0:
			count = 0
			while(q % d == 0):
				count +=1
				q /= d
			cp *= count+1
		d+=1
		if q in mem:
			mem[k] = cp * mem[q]
			return mem[k]
	mem[k] = cp
	return cp

s = 0
for k in range(1,n+1):
	#print 'f('+str(k)+')==',f(k)
	s += k * f(k)
print s 




#2 4 6 8 10 12 14 16 18
#    6      12       18

Submission status: Time Limit Exceeded

Solution code:
import math as mt 
MAXN = int(input())
MAXN+=1
spf = [0 for i in range(MAXN)] 
def 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, mt.ceil(mt.sqrt(MAXN))): 
        if (spf[i] == i): 
            for j in range(i * i, MAXN, i): 
                if (spf[j] == j): 
                    spf[j] = i 

def get(x): 
    ret = {}
    while (x != 1):
                try:
                    ret[spf[x]]+=1
                except:
                    ret[spf[x]]=1
               # print(x)
                x = x // spf[x] 
    p=1
    for i in ret.keys():
        p=p*(ret[i]+1)
    return p

sieve()
r=1
for i in range(2,MAXN):
    p=get(i)
    r+=i*p
print(r)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N=input()

#約数列挙
def make_divisors(n):
    divisors=[]
    ret=0
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            ret+=1
            if i!=n/i:
                ret+=1
    return ret

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=0
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]   
for i in range(1,n+1):
    a+=i*len(make_divisors(i))
    

    
print(a)

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

Submission status: Time Limit Exceeded

Solution code:
#Sum of Divisors
import numpy as np
N = int(input())

def divisor(X):
    W1 = np.full(X,X)
    W2 = np.arange(1,X+1)
    return X-np.count_nonzero(W1%W2)

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
def divisor(n):
   x = {}
   while n % 2 == 0:
      if "2" not in x.keys():
         x["2"] = 1
      else:
         x["2"]+=1
      n = n/2
   for i in range(3,int(math.sqrt(n))+1,2):
      while n%i == 0:
         tmp = str(i)
         if tmp not in x.keys():
            x[tmp] = 1
         else:
            x[tmp] +=1
         n = n/i
   if n > 2:
      tmp = str(n)
      x[tmp] = 1
   res = 1
   for item in x.values():
      res*=(item+1)
   return res
n = int(input())
sum=0
for i in range(1,n+1):
   sum+=(i*divisor(i))
print(sum)

Submission status: Time Limit Exceeded

Solution code:
def f(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
#print(f(100))

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
res = 0
def SieveOfEratosthenes(n, prime,primesquare, a): 
    for i in range(2,n+1): 
        prime[i] = True
    for i in range((n * n + 1)+1): 
        primesquare[i] = False
    prime[1] = False
    p = 2
    while(p * p <= n): 
        if (prime[p] == True): 
            i = p * 2 
            while(i <= n): 
                prime[i] = False
                i += p 
        p+=1
    j = 0
    for p in range(2,n+1):  
        if (prime[p]==True):  
            a[j] = p 
            primesquare[p * p] = True
            j+=1
def countDivisors(n): 
    if (n == 1): 
        return 1
    prime = [False]*(n + 2) 
    primesquare = [False]*(n * n + 2) 
    a = [0]*n
    SieveOfEratosthenes(n, prime, primesquare, a) 
    ans = 1
    i=0
    while(1):  
        if(a[i] * a[i] * a[i] > n): 
            break
        cnt = 1  
        while (n % a[i] == 0): 
            n = n / a[i] 
            cnt = cnt + 1 
        ans = ans * cnt 
        i+=1   
    n=int(n) 
    if (prime[n]==True): 
        ans = ans * 2
    elif (primesquare[n]==True): 
        ans = ans * 3
    elif (n != 1): 
        ans = ans * 4 
    return ans 
for i in range(1, n+1):
    res += i*countDivisors(i)
print(res)

Submission status: Time Limit Exceeded

Solution code:
import math  
def printDivisors(n) : 
    ans=0  
    i = 1
    while i <= math.sqrt(n): 
        if (n % i == 0) : 
            if (n / i == i) : 
                ans=ans+1 
            else : 
                ans=ans+2
        i = i + 1
    return ans
n=int(input())
ans=0
for i in range(1,n+1):
    ans=ans+(i*printDivisors(i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

def m_div(n):
    ans=0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ans+=1
            if i != n // i:
                ans+=1

    return ans


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

print(ans)

Submission status: Time Limit Exceeded

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

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

    sum_data=0

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

    print(sum_data)

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]

ans = 0
for n in range(1,N+1):
    ans += n * len(make_divisors(n))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

import math
def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    
    return num

ans = 0
for i in range(1, N+1):
    ans += i * num_divisors_trial_division(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]


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