Python 2 (PyPy), 145 bytes
Because turning code-golf competitions into fastest-code competitions is fun, here is an O(n) algorithm that, on TIO, solves n = 5,000,000,000 in 30 seconds. (Dennis’s sieve is O(n log n).)
import sympy
n=input()
def g(i,p,k,s):
while p*max(p,k)<=n:l=k*p;i+=1;p=sympy.sieve[i];s-=g(i,p,l,n/l*(n/l*k+k-2)/2)
return s
print~g(1,2,1,-n)
How it works
We count the size of the set
S = {(a, b) | 2 ≤ a ≤ n, 2 ≤ b ≤ largest-proper-divisor(a)},
by rewriting it as the union, over all primes p ≤ √n, of
Sp = {(p⋅d, b) | 2 ≤ d ≤ n/p, 2 ≤ b ≤ d},
and using the inclusion–exclusion principle:
|S| = ∑ (−1)m − 1 |Sp1 ∩ ⋯ ∩ Spm| over m ≥ 1 and primes p1 < ⋯ < pm ≤ √n,
where
Sp1 ∩ ⋯ ∩ Spm = {(p1⋯pm⋅e, b) | 1 ≤ e ≤ n/(p1⋯pm), 2 ≤ b ≤ p1⋯pm − 1e},
|Sp1 ∩ ⋯ ∩ Spm| = ⌊n/(p1⋯pm)⌋⋅(p1⋯pm − 1⋅(⌊n/(p1⋯pm)⌋ + 1) − 2)/2.
The sum has CnC⋅n nonzero terms, where C seems convergeconverges to about 0.17 some constant that’s probably 6⋅(if nothing else, it’s certainly bounded by the density 61 − ln 2)/π2 ≈ 0.61 of square-free integers)186544. The final result is then |S| + n − 1.