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 Rust (1.42.0) (judge verdict: Time Limit Exceeded)

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn cnt_divider(x: usize) -> usize {
    let x_sq: usize = (x as f64).sqrt() as usize;
    let mut cnt = 0;
    for i in 1..x_sq+1 {
        if x%i==0 {
            cnt += 1;
            //println!("{}",i);
        }
    }

    if x==x_sq*x_sq {
        cnt*2-1
    } else {
        cnt*2
    }
}

fn main(){

    input!{
        n: usize,
    }
    let mut dp: Vec<usize> = vec![1;n+1];
    let mut ans = 0;

    // for i in 1..n+1 {
    //     for j in (i*2..n+1).step_by(i) {
    //         dp[j] += 1;
    //     }
    //     ans += i*dp[i];
    // }


    for i in 1..n+1 {
        ans += i*cnt_divider(i);
    }
    //println!("{}",cnt_divider(n));
    // let n_sq: usize = (n as f64).sqrt().ceil() as usize;
    // println!("{}", n_sq);
    println!("{}", ans);
}