Problem:
Score : 400 points

Problem Statement

Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.
He remembers that the remainder of a divided by b was greater than or equal to K.
Find the number of possible pairs that he may have had.

Constraints

1 \leq N \leq 10^5

0 \leq K \leq N-1

All input values are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of possible pairs that he may have had.

Sample Input 1

5 2

Sample Output 1

7

There are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).

Sample Input 2

10 0

Sample Output 2

100

Sample Input 3

31415 9265

Sample Output 3

287927211

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

#![allow(unused)]

use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};
use std::{cmp, collections, fmt, io, iter, ops, str};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($args: tt)*) => { eprintln!($fmt, $($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt:expr) => {};
    ($fmt:expr, $($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let n = parse_word::<i32>();
    let k = parse_word::<i32>();

    println!("{}", solve(n, k));
}

fn solve(n: i32, k: i32) -> i32 {
    if k == 0 {
        return n * n;
    }

    // b = k + 1    =>  a = k,
    //                      k +     (k + 1),
    //                      k + 2 * (k + 1), ..
    // b = k + 2    =>  a = k,                k + 1,
    //                      k +     (k + 2), (k + 1) +     (k + 2),
    //                      k + 2 * (k + 2), (k + 1) + 2 * (k + 2),
    //                      ..
    // b = k + d    =>  a = k,                k + 1,                ..,  k + (d - 1),
    //                      k +     (k + d), (k + 1) +     (k + d), .., (k + (d - 1)) +     (k + d),
    //                      k + 2 * (k + d), (k + 1) + 2 * (k + d), .., (k + (d - 1)) + 2 * (k + d),
    //                      ..,
    //                      k + m * (k + d), (k + 1) + m * (k + d), .., (k + (d - 1)) + m * (k + d)
    // ..
    // b = k + (n - k)

    let solve_d = |d| {
        (0..d)
            .map(|i| {
                // from a to n (inclusive), step-by (k + d)
                let a = k + i;
                (n - a) / (k + d) + 1
            })
            .sum::<i32>()
    };

    (0..(n - k)).map(|d| solve_d(d + 1)).sum::<i32>()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}