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 C++ (GCC 9.2.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

template<typename T>
struct Doubling{
	const int LOG_X;
	bool flag1, flag2;
	vector<vector<T>> dp;

	Doubling(int n,ll x):LOG_X(log2(x)+1){//n:配列のサイズ,x:遷移する回数
		flag1 = false;
		flag2 = false;
		dp.assign(LOG_X, vector<T>(n, -1));
	}

	void init(vector<T> &a){//適宜変える
		int n = a.size();
		flag1 = true;
		rep(i, n)
		{
			dp[0][i] = a[i];
		}
	}

	void build(){
		assert(flag1);
		flag2 = true;
		for (int k = 0; k + 1 < LOG_X; ++k)
		{
			for (int i = 0; i < dp[0].size();++i){
				if(dp[k][i]==-1){//2^k先の要素がないなら2^(k+1)先の要素もない
					dp[k + 1][i] = -1;
				}
				else{//2^k*2^k=2^(k+1)
					dp[k + 1][i] = dp[k][dp[k][i]];
				}
			}
		}
	}

	T query(int s,ll x){//s:スタート地点,x:遷移回数
		assert(flag2);
		for (int i = LOG_X - 1; i >= 0; i--)
		{
			if(x&(1LL<<i)){
				s = dp[i][s];
			}
		}
		return s;
	}
};

void solve(){
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;++i){
		ans+=(n-1)/i;
	}
	cout<<ans<<"\n";
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}