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: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    ans = 0
    for i in range(1, n + 1):
        x = n // i
        ans += i * (1 + x) * x // 2
    print(ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
import math
import collections
import heapq
import queue
import itertools
import functools
import operator
import time

readline = sys.stdin.readline
 
IPS = lambda: readline().rstrip()
IP = lambda: int(readline().rstrip())
MP = lambda: map(int, readline().split())
LS = lambda: list(map(int, readline().split()))

def solve():
    for _ in range(1):
        n = IP()
        ans = 0 
        for i in range(1,n+1):
            j = n//i
            ans += i*j*(j+1)//2
 
        print(ans)
        
        
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N=int(input())

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

print(ans)

Submission status: Accepted

Solution code:
# Author:Fuad Ashraful Mehmet ,CSE-UAP
import sys
input=sys.stdin.readline

def fun(num):
    return num*(num+1)//2
n=int(input())

ans=0

for i in range(1,n+1):
    y=n//i

    ans+= i*fun(y)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

def calculate(n):
    result = 0
    for i in range(1, n + 1):
        num = n // i
        if num == 1:
            result += i
        else:
            start = i
            end = num * i
            total = ((start + end) * num) // 2
            result += total

    print(result)


calculate(N)

Submission status: Accepted

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

    ans = 0
    for X in range(1, N + 1):
        Y = N // X
        ans += Y * (Y + 1) * X // 2

    print(ans)


if __name__ == '__main__':
    main()

exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    cnt = [1]*(N+1)

    for i in range(2, N+1):
        j = 1
        while i*j<=N:
            cnt[i*j] += 1
            j += 1

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

solve()

Submission status: Accepted

Solution code:
N=int(input())

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

result = 0
for i in range(1, n + 1):
    for j in range(1, (n // i) + 1):
        result += i * j
print(result)

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = 0
for d in range(1, n+1):
    for k in range(d, n+1, d): s += k
print(s)

Submission status: Accepted

Solution code:
n = int(input())
f = [0]*(n+1)
for d in range(1, n+1):
    for k in range(d, n+1, d): f[k] += 1
s = 0
for k in range(1, n+1): s += k * f[k]
print(s)

Submission status: Accepted

Solution code:
import functools

n = int(input())
print(functools.reduce(lambda i, j: i + ((n // j) + 1) * (n // j) * j // 2, range(n + 1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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

def T(i):
    return i * (i + 1) // 2


def solve():
    # n log n : sieving
    # n = ri()
    # sieve = [1] * (n + 1)
    # ans = 1
    # for p in range(2, n + 1):
        # for q in range(p, n + 1, p):
            # sieve[q] += 1
        # ans += p * sieve[p]
    # print (ans)

    # summing with floor n / i technique
    # O(sqrt n)
    n = ri()
    if n in [1,2,3]:
        print ({1:1, 2:5, 3:11}[n])
        return

    sq = int(n**0.5)
    ans = 0
    for i in range(1, sq + 1):
        # print (i, i * T(n // i), T(i) * (T(n // i) - T(n // (i + 1))))
        ans += i * T(n // i)
        ans += T(i) * (T(n // i) - T(n // (i + 1)))

    if sq * (sq + 1) > n:
        ans -= sq * T(n // sq)
    print (ans)





mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

Submission status: Accepted

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

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

ans = 0

for k in range(1, N+1):
    quot = N // k  # quotient
    num_divisor = quot * (quot + 1) // 2
    
    ans += k * num_divisor


print(ans)

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

s,k,n = 0,1,N
while k<=n:
	m = N//k
	s += (k-1)*k*(n-m)*(n+m+1)//2
	s += k*m*(m+1)
	k,n = k+1,m
if m<k-1:
	s -= (k-1)*m*(m+1) 
print(s//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
X = [N//i for i in range(1, N+1)]
print(sum([x*(x+1)*i//2 for x, i in zip(X, range(1, N+1))]))

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
def tousa(b,l):
    cnt=l//b
    s=(b+l)*cnt//2
    return s

n=int(input())
ans=0
for k in range(1,n+1):
    N=n//k
    ans+=tousa(k,k*N)
print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N = II()
res = 0
for i in range(1, N+1):
    n = N//i
    res += i*n*(n+1) >> 1

print(res)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')

#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4

#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()

ans=0

for i in range(1,n+1):
    
    q=(n//i)*(2*i+i*(n//i -1))//2
    ans+=q
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
from math import sqrt, floor
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    # nd:num of div
    nd = [2] * (n + 1)

    for i1 in range(2, floor(n / 2) + 1):
        for i2 in range(i1 * 2, n + 1, i1):
            nd[i2] += 1

    r = 1
    for j1 in range(2, n + 1):
        r += nd[j1] * j1
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n = readint()

print(sum([k*(n//k)*(n//k+1)//2 for k in range(1,n+1)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
l = list(range(1, N+1))


def calc(i):
    return (i + N//i * i) * (N//i) // 2


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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
l = list(range(1, N+1))


def calc(i):
    return sum(list(range(i, N+1, i)))


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    num = int(input())

    def ggg():
        for divisor in range(1, num + 1):
            quotient = num // divisor
            yield (quotient + 1) * quotient * divisor // 2

    print(sum(ggg()))


if __name__ == '__main__':
    main()

# Python 3.8.2: 1332 ms
# Pypy 3 (7.3.0): 172 ms

Submission status: Accepted

Solution code:
def main():
    num = int(input())
    ans = 0

    for divisor in range(1, num + 1):
        quotient = num // divisor
        ans += (quotient + 1) * quotient * divisor // 2

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    num = int(input())
    gg = ((
        (quotient := num // divisor) + 1) * quotient * divisor // 2
        for divisor in range(1, num + 1))
    print(sum(gg))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(1, n+1):
    m = n // i * i
    cnt = (m - i) // i + 1
    ans += (i + m) * cnt // 2

print(ans)

Submission status: Accepted

Solution code:
import sys
import math


def main():
    N = int(sys.stdin.readline().rstrip())

    sum_ = 0

    for i in range(1, int(math.sqrt(N)) + 1):

        sum_ += i**2

        k1 = N // i
        # k2 = i

        k1_sum = k1 * (k1 + 1) // 2
        k2_sum = i * (i + 1) // 2
        sum_ += 2 * i * (k1_sum - k2_sum)

    print(sum_)


main()

Submission status: Accepted

Solution code:
"""
// Author : snape_here - Susanta Mukherjee
     
 """
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 

def isPrime(n):
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

from math import *

import bisect

from decimal import *

getcontext().prec = 50

abc="abcdefghijklmnopqrstuvwxyz"

pi=3.141592653589793238

l=[0]*10000005

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

def main():

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


# region fastio
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(n):
  return n * (n + 1) // 2

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

print(answer)

Submission status: Accepted

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

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

answer = 0
for i in range(1, n + 1):
  answer += i * a[i]

print(answer)

Submission status: Accepted

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

    ans = 0
    for x in range(1, n+1):
        y = n//x
        ans += y*(y+1)*x//2
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for X in range(1, N + 1):
    Y = N // X
    ans += Y * (Y + 1) * X // 2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

print(sum([n * (N // n) * (N // n + 1) // 2 for n in range(1, N + 1)]))

Submission status: Accepted

Solution code:
n = int(input())
from math import ceil
def g(x, n):
    y = n // x
    return int(x * (y + 1) * y /2 )
print(sum(g(i+1, n) for i in range(n)))

Submission status: Accepted

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

class unionfind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.size = [1 for i in range(n)]
    def find(self,a):
        if a == self.parent[a]: return a
        else: self.parent[a] = find(self,self.parent[a]); return self.parent[a]
    def unite(self,a,b):
        pa,pb = self.find(self,a), self.find(self,b)
        if pa == pb: return
        else: self.parent[pb] = pa; self.size[pa] += self.size[pb]
    def same(self,a,b): return find(self,a) == find(self,b)

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

Submission status: Accepted

Solution code:
n = int(input())

total = 0

for i in range(1, n + 1):
  m = n // i
  total += i * m * (m + 1) // 2

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def II(): return int(input())
N=II()
ans=0
def calc(b,e):
  cnt=e//b
  return (b+e)*cnt//2
for i in range(1,N+1):
  ans+=calc(i,N//i*i)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
from numba import*
@njit('i8(i8)',cache=1)
def f(N):
    d=[1]*N
    for i in range(2,N+1):
        for j in range(i-1,N,i):
            d[j]+=1
    r=0
    for i in range(N):
        r+=(i+1)*d[i]
    return r
print(f(N))

Submission status: Accepted

Solution code:
# NlogNによる脳死回答
N = int(input())
div_cnt = [0 for i in range(10**7+1)]
for i in range(1, 10**7+1):
    c = i
    while c <= 10**7:
        div_cnt[c] += 1
        c += i
ans = 0
for i in range(1, N+1):
    ans += i*div_cnt[i]
print(ans)

Submission status: Accepted

Solution code:
def f():n=int(input());print(sum(m*((g:=n//m)**2+g-m**2)for m in range(1,int(n**.5)+1)))
if __name__=="__main__":f()

Submission status: Accepted

Solution code:
def j(n):
    print(sum(m*((n//m)**2+n//m-m**2) for m in range(1,int(n**.5)+1)))

if __name__ == "__main__":
    j(int(input()))

Submission status: Accepted

Solution code:
n=int(input());print(sum(m*((g:=n//m)**2+g-m**2)for m in range(1,int(n**.5)+1)))

Submission status: Accepted

Solution code:
from numba import jit
n = int(input())
@jit
def main(n):
    ans = 0
    for i in range(1, n+1):
        ans += i * (n//i) * (n//i + 1) //2
    print(ans)
main(n)

Submission status: Accepted

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

for i in range(1, N+1):
    total += i * (N // i) * (N // i + 1) / 2

print(int(total))

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque
input = sys.stdin.readline
#S,L,R = map(int, input().split())

N = int(input())

A = [0]
B = []

Answer = 0

j = 1;
while j*j<=N:
    A.append(j)
    if N//j != j:
        B.append(N//j)
    j+=1

B.reverse()
A =  A + B

Answer = 0
for i in range(1,len(A)):
    num = ((N//A[i])*(N//A[i]+1)//2)
    num *= ((A[i]*(A[i]+1)//2)-(A[i-1]*(A[i-1]+1)//2))
    Answer += num

print(Answer)

Submission status: Accepted

Solution code:
def calc(b,e):
  cnt=e//b
  return (b+e)*cnt//2
def II(): return int(input())
N=II()
ans=0
for i in range(1,N+1):  
  ans+=calc(i,N//i*i)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
def g(n):
    return n * (n + 1) // 2

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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