Problem:


Score : 400 points

Problem Statement

For a positive integer X, let f(X) be the number of positive divisors of X.

Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Constraints

1 \leq N \leq 10^7

Input

Input is given from Standard Input in the following format:

N

Output

Print the value \sum_{K=1}^N K\times f(K).

Sample Input 1

4

Sample Output 1

23

We have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\times 1 + 2\times 2 + 3\times 2 + 4\times 3 =23.

Sample Input 2

100

Sample Output 2

26879

Sample Input 3

10000000

Sample Output 3

838627288460105

Watch out for overflows.



Sample input:
4


Sample output:
23

Submission status: Wrong Answer

Solution code:
n=int(input())
import math
nn=int(n/2)
a=[1]
a*=(n+1)
for i in range(2,nn+1):
    t=i
    while t<=n:
        a[t]+=1
        t+=i
for i in range(nn+1,n+1):
    a[i]+=1
ans=0
for i in range(1,n+1):
    ans+=a[i]*i

print(ans)

Submission status: Wrong Answer

Solution code:
# ABC172d


from collections import Counter


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

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

    def calcYakusu(n):
        #d = Counter(prime_factorize(n))
        waru = math.floor(n ** 0.5)
        yakusu_zu = []
        n2 = n
        while yakusu[n2] == -1:
            if waru == 1:
                yakusu_zu.append(2)
                break
            if n2 % waru == 0:
                n2 = n2 // waru
                yakusu_zu.append(waru)
            else:
                waru -= 1
        if waru != 1:
            yakusu_zu.append(n2)

        ans = 1
        for i in yakusu_zu:
            ans += yakusu[i] - 1

        return ans

    yakusu = [-1] * (n + 2)
    yakusu[1] = 1
    yakusu[2] = 2
    ans = 0
    for i in range(1, n + 1):
        if yakusu[i] == None:
            yakusu[i] = calcYakusu(i)
        ans += i*yakusu[i]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
import math
nn=int(math.sqrt(n))
a=[0]
a*=(n+1)
for i in range(1,nn+1):
    t=i
    while t<=n:
        a[t]+=1
        t+=i
for i in range(nn+1,n+1):
    a[i]+=1
ans=0
for i in range(1,n+1):
    ans+=a[i]*i

print(ans)

Submission status: Wrong Answer

Solution code:
def facto(n):
    arr = 0
    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==0:
        arr+=2

    return arr

n=int(input())
ass=0
for i in range(1,n+1):
  ass+=i*facto(i)

Submission status: Wrong Answer

Solution code:


import math


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

yakusu = [-1] * (N+1)

yakusu[1] = 1

for i in range(2, N):
    if(yakusu[i] == -1):
        array = factorization(i)
        yakusu_num = 1
        for a in array:
            yakusu_num = yakusu_num * (a[1] + 1)

        j = i
        y = yakusu_num
        while j <= N:
            yakusu[j] = y
            y += 1
            j = j * i


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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
dp = [0 for _ in range(n + 1)]
ans = 0
for i in range(n + 1):
    if i > 0:
        for j in range(i, n + 1, i):
            dp[j] += 1
    dp[i] = i * dp[i]
    ans += i * dp[i]
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N, = map(int, input().split())

ans = 0

ans = 0
for k in range(N, 0, -1):
    mi = int(N/k)
    sum_num = (1+mi) * (mi//2) if mi%2==0 else (mi-1) * ((mi-1)//2) + mi
    ans += k * sum_num

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
dp = [0 for _ in range(n + 1)]
ans = 0
for i in range(n + 1):
    if i > 0:
        for j in range(i, n + 1, i):
            dp[j] += 1
    ans +=  i * dp[i]
print(sum(dp))

Submission status: Wrong Answer

Solution code:
n = int(input())
board = [1] * (n+1)

def divisor_num(n, board):
    for i in range(2, n+1):
        j = 1
        while i*j <= n:
            board[i*j] += 1
            j += 1

divisor_num(n, board)
res = sum([i * board[i] for i in range(1, n+1)])
print(board)

Submission status: Wrong Answer

Solution code:
import math as mt 
  

def sumDivisorsOfDivisors(n): 
  
    mp = dict() 
    for j in range(2, mt.ceil(mt.sqrt(n))): 
  
        count = 0
        while (n % j == 0): 
            n //= j 
            count += 1
  
        if (count): 
            mp[j] = count 
  
    if (n != 1): 
        mp[n] = 1
  
    ans = 1
    for it in mp: 
        pw = 1
        summ = 0
  
        for i in range(mp[it] + 1, 0, -1): 
            summ += (i * pw) 
            pw *= it 
      
        ans *= summ 
  
    return ans 
  

print(sumDivisorsOfDivisors(int(input())))

Submission status: Wrong Answer

Solution code:
import math
n = 10 ** 7
k = int(input())
lis = []
for i in range(1,10 ** 2+1):
    li = []
    cnt = 1
    num = i
    if i == 1:
        lis.append(1)
    else:
        for j in range(2,math.ceil(math.sqrt(i))+1):
            while num % j == 0:
                cnt += 1
                num //= j
            if cnt != 1:
                li.append(cnt)
                cnt = 1
        if num != 1:
            li.append(2)
        ans = 1
        for nu in li:
            ans *= nu
        lis.append(ans*i)
print(sum(lis))

Submission status: Wrong Answer

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

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))


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())
ans = 1
if n == 1:
    print(1)
else:
    for i in range(2,n+1):
        nf = factorization(i)
        cnt = 1
        for j in range(len(nf)):
            cnt *= nf[j][1]+1
        ans += i * cnt
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
l=[]
for i in range(1,n+1):
  cnt=0
  j=1
  while j<=i**0.5:
    if i%j==0:
      cnt+=1
    j+=1
  if i**0.5==int(i**0.5):
    l.append(cnt*2-1)
  else:
    l.append(cnt*2)
ans=0
for t in range(n):
  p=(t+1)*l[t]
  ans+=p
  print(l[t])
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
List=[1 for x in range(n+1)]
for x in range(2,n+1):
  for y in range(x,n+1,x):
    List[y]+=1
ans=1
for x in range(1,n+1):
  ans+=(List[x]*x)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

res = 5
for i in range(3,n+1):
	s = 2
	for j in range(2,i//2+1):
		if i%j==0:
			s+=1
	res+=s*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())
o=0
for i in range(1,n+1):
    o+=i*len(make_divisors(i))
print(o)

Submission status: Time Limit Exceeded

Solution code:
def main():
    from collections import Counter
    from functools import lru_cache
    from copy import deepcopy
    N = int(input())
    X = [i for i in range(N + 1)]
    prime = [2, ]
    for i in range(3, N + 1):
        x = int(i ** 0.5) + 1
        for p in prime:
            if p > x:
                prime.append(i)
                break
            if i % p == 0:
                X[i] = p
                break
        else:
            prime.append(i)

    @lru_cache(maxsize=None)
    def lis(n):
        if n == 1:
            return dict()
        a = X[n]
        if a == n:
            C = dict()
            C[a] = 1
        else:
            C = deepcopy(lis(n // a))
            if C.get(a):
                C[a] += 1
            else:
                C[a] = 1
        return C

    A = 0

    for i in range(1, N + 1):
        Cl = lis(i)
        ans = 1
        for v in Cl.values():
            ans *= v + 1
        A += ans * i

    print(A)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    from collections import Counter
    N = int(input())
    X = [i for i in range(N + 1)]
    prime = [2, ]
    for i in range(3, N + 1):
        x = int(i ** 0.5) + 1
        for p in prime:
            if p > x:
                prime.append(i)
                break
            if i % p == 0:
                X[i] = p
                break
        else:
            prime.append(i)


    def cnt(n):
        L = list()
        while n != 1:
            L.append(X[n])
            n //= X[n]
        C = Counter(L)
        ans = 1
        for v in C.values():
            ans *= v + 1
        return ans


    A = 0

    for i in range(1, N + 1):
        A += cnt(i) * i

    print(A)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret
ans = 0
for k in range(1, n+1):
    d = primeFactor(k)
    temp = 1
    for _, v in d.items():
        temp *= (v+1)
    ans += k*temp
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
MAX = 10000000
divisors = [0 for i in range(MAX+1)]

for i in range(1,MAX+1):
    for j in range(i,MAX+1,i):
        divisors[j]+=1
sum = 0
for i in range(1,n+1):
    sum += divisors[i]*i
print(sum)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())
verbose = False
counter = Counter()

for i in range(1, N+1):
    counter.update(range(i, N+1, i))

p = 0
for i in range(1, N+1):
    p += i * counter[i]

print(p)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())

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 += i * search_divisor_num_1(i)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
import math
def getdiv(x):
    list = []
    for i in range(1,math.floor(math.sqrt(x))+1):
        if x%i==0 and (not i in list):
            list.append(i)
    if math.sqrt(x) == math.floor(math.sqrt(x)):
        return len(list)*2-1
    else:
        return len(list)*2
numlist = [0]
for i in range(1,N+1):
    numlist.append(i*getdiv(i))
print(sum(numlist))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def getdiv(x):
    list = [0]
    for i in range(1,x+1):
        if x%i==0 and (not i in list):
            list.append(i)
    return len(list)-1
numlist = [0]
for i in range(1,N+1):
    numlist.append(i*getdiv(i))
print(sum(numlist))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from collections import Counter


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


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


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


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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from collections import Counter


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


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


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


def _solve(string):
    n = int(string)
    ans = 0
    for i in range(1, n + 1):
        c = 0
        for j in range(1, int(i**0.5) + 1):
            if i % j == 0:
                c += 2
        if i**0.5 == int(i**0.5):
            c -= 1
        ans += i * c
    return str(ans)


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

Submission status: Time Limit Exceeded

Solution code:
def makedivisors(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 k in range(1,n+1):
    ans += k * len(makedivisors(k))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
# 愚直にやると約数の個数テーブルをO(NlogN)
print(sum(i * j for i in range(1, n + 1)
          for j in range(1, n // i + 1)))

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
class Sieve:
    """
    N以下の素数を列挙するエラトステネスのふるいです。
    O(NloglogN)でできます。

    Attributes
    sieveList : その数の素因数のうち最小のものの配列
    primes : N以下の素因数のリスト
    """
    def __init__(self, N):
        self.sieveList = [-1 for _ in range(N+1)]
        self.sieveList[1] = 1
        self.primes = []

        for i in range(2, N+1):
            #すでに何らかの数で割られていたらcontinue
            if self.sieveList[i] != -1:
                continue
            self.primes.append(i)
            for j in range(i, N+1, i):
                if self.sieveList[j] != -1:
                    continue
                self.sieveList[j] = i

    def getPrimes(self):
        return self.primes

    def getSieveList(self):
        return self.sieveList

class FastFactorization(Sieve):
    """
    高速素因数分解です。
    与えられたL個の数がA以下の時、
    エラトステネスでO(AloglogA)＋素因数分解でO(LlogA) = O(AloglogA+NlogA)でできます。
    """

    def __init__(self, N):
        """
        前処理でスーパークラスのエラトステネスを使ってN以下の素因数を列挙します。
        """
        super().__init__(N)
        self.N = N
        self.sieveList = self.getSieveList()

    def factorize(self, x):
        if x > self.N:
            raise ValueError("与えられた数がエラトステネスのリストの上限を超えている")
        # p = set()
        p = defaultdict(int)
        tmp = -1
        ans = 1
        while x > 1:
            divisor = self.sieveList[x]
            if divisor != tmp:
            	ans *= p[tmp] + 1
            	tmp = divisor
            x //= divisor
            # p.add(divisor)
            p[divisor] += 1
            
        ans *= p[tmp] + 1
            
        return ans
        
        

N = int(input()) # <= 10**7

ff = FastFactorization(N)

ans = 0
for i in range(1, N+1):
	factors = ff.factorize(i)

	ans += i * factors
	
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
class Sieve:
    """
    N以下の素数を列挙するエラトステネスのふるいです。
    O(NloglogN)でできます。

    Attributes
    sieveList : その数の素因数のうち最小のものの配列
    primes : N以下の素因数のリスト
    """
    def __init__(self, N):
        self.sieveList = [-1 for _ in range(N+1)]
        self.sieveList[1] = 1
        self.primes = []

        for i in range(2, N+1):
            #すでに何らかの数で割られていたらcontinue
            if self.sieveList[i] != -1:
                continue
            self.primes.append(i)
            for j in range(i, N+1, i):
                if self.sieveList[j] != -1:
                    continue
                self.sieveList[j] = i

    def getPrimes(self):
        return self.primes

    def getSieveList(self):
        return self.sieveList

class FastFactorization(Sieve):
    """
    高速素因数分解です。
    与えられたL個の数がA以下の時、
    エラトステネスでO(AloglogA)＋素因数分解でO(LlogA) = O(AloglogA+NlogA)でできます。
    """

    def __init__(self, N):
        """
        前処理でスーパークラスのエラトステネスを使ってN以下の素因数を列挙します。
        """
        super().__init__(N)
        self.N = N
        self.sieveList = self.getSieveList()

    def factorize(self, x):
        if x > self.N:
            raise ValueError("与えられた数がエラトステネスのリストの上限を超えている")
        # p = set()
        p = defaultdict(int)
        while x > 1:
            divisor = self.sieveList[x]
            x //= divisor
            # p.add(divisor)
            p[divisor] += 1
            
        return p

N = int(input()) # <= 10**7

ff = FastFactorization(N)

ans = 0
for i in range(1, N+1):
	factors = ff.factorize(i)
	pattern = 1
	for vals in factors.values():
		pattern *= vals + 1

	ans += i * pattern
	
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = 10**7+1
P = [1 for _ in range(n)]
P[0]=0
P[1]=0
for i in range(2,int(n**0.5)+1):
    for j in range(i*i,n,i):
        P[j] = 0
Q = []
for i in range(2,n):
    if P[i]==1:
        Q.append(i)
def f(x):
    if x==1:
        return 1
    if P[x]==1:
        return 2
    C = {}
    for q in Q:
        if x%q==0:
            cnt = 0
            while x%q==0:
                x = x//q
                cnt += 1
            C[q] = cnt
        if x==1:break
        if P[x]==1:
            C[x]=1
            break
    num = 1
    for q in C:
        num *= C[q]+1
    return num
N = int(input())
cnt = 0
for i in range(1,N+1):
    cnt += i*f(i)
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

x=[-1]*(n+1) #2以上の自然数に対して最小の素因数を表す
x[0]=0
x[1]=1
i=2
prime=[]
while i<=n:
    if x[i]==-1:
        x[i]=i
        prime.append(i)
    for j in prime:
        if i*j>n or j>x[i]:break
        x[j*i]=j
    i+=1

def f(k):
    z=[]
    if k==1:
        return 1
    p=x[k]
    c=1
    while k>1:
        if p!=x[k//p]:
            z.append(c)
            c=1
        else:
            c+=1

        k=k//p
        p=x[k]

    ans=1
    for i in range(len(z)):
        ans=ans*(z[i]+1)
    return ans
s=0
for i in range(n):
    s+=(i+1)*f(i+1)
print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
for i in range(1,N+1): #1-N
  first = i; kosu = N//i
  end = kosu*i
  temp = (first+end)*kosu//2
  ans += temp
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

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

def fact(n):
    arr=[]
    while n>1:
        now=n
        cnt=0
        p=bp[now]
        while now % p == 0:
            now//=p
            cnt+=1
        arr.append([p,cnt])
        n=now
    return arr

ans=1 # for "1"
for i in range(2,n+1):
    cnt=1
    for p,c in fact(i):
        cnt*=(c+1)
    ans += (i*cnt)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
ans = 0
for i in range(1,n+1):
    yakusu = 0 
    for j in range(1,int(math.sqrt(i))+1):
        if i % j == 0:
            yakusu += 1
    yakusu = yakusu * 2
    if float(int(math.sqrt(i))) == math.sqrt(i):
        yakusu -= 1
    ans += yakusu * i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
num = []
for i in range(1,n+1):
    yakusu = 0 
    for j in range(1,int(math.sqrt(i))+1):
        if i % j == 0:
            yakusu += 1
    yakusu = yakusu * 2
    if float(int(math.sqrt(i))) == math.sqrt(i):
        yakusu -= 1
    num.append(yakusu)
ans = 0
for i in range(n):
    ans += (i + 1) * num[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
truelist = [0]
def getlist(x):
    list = []
    for i in range(1,x+1):
        if x%i == 0 and (not i in list):
            list.append(i)
    return len(list)
tlist = getlist(N)
for i in range(1,N+1):
    truelist.append(getlist(i)*i)
print(sum(truelist))

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt

N = int(input())

ans = 0

for i in range(1,N+1):
    t = sqrt(i)
    #平方数の除外
    if t //1 == t :
        ans += i
        
    j = 1
    while j < t:
        if i%j == 0:
            ans += 2*i
        j += 1
   # print(ans)
print(ans)

Submission status: Time Limit Exceeded

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

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(1,i+1):
        if i%j == 0:
            count += 1
    ans += i*count
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
import os
from operator import mul
# import sympy

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

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

    return divisors

N = I()
ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def num_div(n):
  num_div_n = 0
  for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
      num_div_n += 2
      if n // i == i:
        num_div_n -= 1
        
  return num_div_n

sum_div = 0
for i in range(n):
  sum_div += (i + 1) * num_div(i + 1)
  
print(sum_div)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter


class Osa_k:
    def __init__(self, maximum):
        self.table = [-1] * (maximum+1)
        for i in range(2, maximum+1):
            if self.table[i] == -1:
                self.table[i] = i
                for k in range(i*i, maximum+1, i):
                    if self.table[k] == -1:
                        self.table[k] = i

    def factorize(self, n):
        res = Counter()
        b = n
        while self.table[b] != -1:
            res[self.table[b]] += 1
            b //= self.table[b]
        return res


def solve():
    N = int(input())
    ins = Osa_k(N)
    ans = 0

    for i in range(1, N+1):
        cnt = i
        for j in ins.factorize(i).values():
            cnt *= (j+1)
        ans += cnt

    print(ans)


solve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def factorization(n):
    if n==1:
        return 1
    else:
        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])
        ans=1
        for j in arr:
            ans*=j[1]+1
        return ans

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

dp = [None]*(n+1)
def p_factor(x):
  x_copy = x
  flag = False
  pf={}
  for i in range(2,int(x**0.5)+1):
    while x%i==0:
      pf[i]=pf.get(i,0)+1
      x//=i
      if dp[x]:
        flag = True
        break
    if flag:break        		
   
  if flag:
    for i in dp[x].keys():
      pf[i] = pf.get(i,0)+dp[x][i]
  else:
    if x>1:pf[x]=1
  dp[x_copy] = pf
  return pf

def divisor_count(x):
  factor = p_factor(x)
  primes = factor.keys()
  num_div = 1
  
  for p in primes:
    num_div *= factor[p]+1
  return num_div

sum_div = 1
for i in range(2,n+1):
  sum_div += i*divisor_count(i)
print(sum_div)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def p_factor(x):
  factor = {}
  i = 2
  while x>1:
    if x%i == 0:
      x //= i
      if factor.get(i):
        factor[i] += 1
      else:
        factor[i] = 1
      continue
    else:
      i += 1
  return factor

def divisor_count(x):
  factor = p_factor(x)
  primes = factor.keys()
  num_div = 1
  
  for p in primes:
    num_div *= factor[p]+1
  return num_div

sum_div = 1
for i in range(2,n+1):
  sum_div += i*divisor_count(i)
print(sum_div)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import numpy as np


def solve(N):
    fx = np.zeros(N + 1, dtype=np.uint32)
    for i in range(1, N + 1):
        fx[i::i] += 1
    return np.sum(np.arange(0, N + 1, dtype=np.uint64) * fx)


def main():
    N = int(input())  # type: int
    answer = solve(N)
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


def solve(N: int):
    fx = np.zeros(N + 1, dtype=np.uint64)
    for i in range(1, N + 1):
        fx[i::i] += 1
    return np.sum(np.arange(0, N + 1, dtype=np.uint64) * fx)


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