Problem:
Score : 300 points

Problem Statement

Given is a positive integer N.
How many tuples (A,B,C) of positive integers satisfy A \times B + C = N?

Constraints

2 \leq N \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.

Sample Input 1

3

Sample Output 1

3

There are 3 tuples of integers that satisfy A \times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).

Sample Input 2

100

Sample Output 2

473

Sample Input 3

1000000

Sample Output 3

13969985

Solution in Rust (1.42.0) (judge verdict: Accepted)

#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

fn _make_sieve<T: PrimInt>(mut maxu: usize) -> Vec<T> {
    maxu += 1;
    let mut sieve: Vec<T> = (0..maxu).map(|x| T::from(x).unwrap()).collect();

    let mut i = 2;
    while i*i < maxu {
        if sieve[i].to_usize().unwrap() < i { i+=1; continue; }
        for j in (i*i..maxu).step_by(i) {
            if sieve[j].to_usize().unwrap() == j { sieve[j] = T::from(i).unwrap() }
        }
        i += 1;
    }

    sieve
}

pub struct OsaK<T: PrimInt + std::hash::Hash + NumAssign > {
    sieve: Vec<T>
}

impl<T: PrimInt + std::hash::Hash + NumAssign > OsaK<T> {
    pub fn new(max: T) -> Self {
        // O(Nlog(max))
        let maxu = max.to_usize().unwrap();
        let sieve = _make_sieve(maxu);

        Self { sieve }
    }

    pub fn from(vec: Vec<T>) -> Self {
        // O(Nlog(max(vec)))
        let max = vec.iter().max().unwrap();
        let maxu = max.to_usize().unwrap();
        let sieve = _make_sieve(maxu);
        
        Self { sieve }
    }

    pub fn is_prime(&self, x: T) -> bool {
        // O(1)
        if x == one() || x == zero() { return false }
        self.sieve[x.to_usize().unwrap()] == x
    } 

    pub fn prime_factorize(&self, mut n: T) -> std::collections::HashMap<T, T> {
        // O(log log (n))
        let mut res: std::collections::HashMap<T, T> = std::collections::HashMap::new();
        while n > one() {
            *res.entry(self.sieve[n.to_usize().unwrap()]).or_insert(zero()) += one();
            n /= self.sieve[n.to_usize().unwrap()]
        }
        res
    }
}


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
    }

    let osa_k = OsaK::new(n);

    let mut ans = 0;
    for c in 1..n {
        let t = n - c;
        let primes = osa_k.prime_factorize(t);
        // let prime_sum = primes.iter().map(|x| *x.1).sum::<usize>() + 1;
        let div_sum = primes.iter().map(|x| *x.1).fold(1, |acc, x| acc * (x+1));

        if t == 1 {
            ans += 1;
        } else {
            ans += div_sum
        }
    }

    println!("{}", ans);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}