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.

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1e18

const int RT = 31644;

vector<int>prime;
vector<int>factor;
bitset<31666> status;

void sieve()
{
    int rt = 3164;
    for(int i = 4; i <= rt; i+=2) status[i]=true;
    for(int i = 3; i <= rt; i+=2)
        if(!status[i])
            for(int j = i*i; j < RT; j+=(i<<1))
                status[j] = true;

    prime.push_back(2);
    status[2]=false;

    for(int i = 3; i <= RT; i+=2)
        if(!status[i])
            prime.push_back(i);
}

lll primefac(int n)
{
    int pf_idx=0,pf=prime[pf_idx],SIZE=prime.size();
    lll ans=1,lol=0;
    while(pf*pf<=n&&pf<SIZE)
    {
        if(n%pf==0)
        {
            lol=0;
            while(n%pf==0) {n/=pf; lol++; }
            ans*=(lol+1);
            //cout<<ans<<endl;
        }
        pf=prime[++pf_idx];
    }
    if(n!=1) ans*=(1+1);
    return ans;
}
void solve()
{
   sieve();
   int n;
   cin>>n;
   lll num=1;
   for(int i=2;i<=n;i++)
   {
      num+=(primefac(i)*i);
   }
   cout<<num<<endl;
}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //int t; cin>>t; while(t--) solve();
    solve();

}