description: For two positive integers l and r (l ≤ r) let c(l, r) denote the number of integer pairs (i, j) such that l ≤ i ≤ j ≤ r and \operatorname{gcd}(i, j) ≥ l. Here, \operatorname{gcd}(i, j) is the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of integers i and j.
  
  YouKn0wWho has two integers n and k where 1 ≤ k ≤ n. Let f(n, k) denote the minimum of ∑_{i=1}^{k}{c(x_i+1,x_{i+1})} over all integer sequences 0=x_1 < x_2 < … < x_{k} < x_{k+1}=n.
  
  Help YouKn0wWho find f(n, k). 
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 3 ⋅ 10^5) — the number of test cases.
  
  The first and only line of each test case contains two integers n and k (1 ≤ k ≤ n ≤ 10^5). 
  
  Output
  
  For each test case, print a single integer — f(n, k).
  
  Example
  
  Input
  
  
  4
  6 2
  4 4
  3 1
  10 3
  
  
  Output
  
  
  8
  4
  6
  11
  
  Note
  
  In the first test case, YouKn0wWho can select the sequence [0, 2, 6]. So f(6, 2) = c(1, 2) + c(3, 6) = 3 + 5 = 8 which is the minimum possible.
solution: #include <bits/stdc++.h>
  using namespace std;
  const int N = 100000;
  long long dp[17][100010];
  long long coef[100010];
  long long Calc(int l, int r) {
    long long sum = 0;
    for (int i = l; i <= r;) {
      int v = r / i, j = r / v;
      sum += coef[v] * (j - i + 1ll);
      i = j + 1;
    }
    return sum;
  }
  void Solve(long long *f, long long *g, int l, int r, int L, int R) {
    if (l > r) return;
    int mid = l + r >> 1, pos = -1;
    if (min(mid - 1, R) >= L) {
      long long wei = Calc(min(mid - 1, R) + 1, mid);
      for (int i = min(mid - 1, R); i >= L; i--) {
        if (g[mid] > f[i] + wei) g[mid] = f[i] + wei, pos = i;
        wei += coef[mid / i];
      }
    }
    if (pos == -1) pos = L;
    Solve(f, g, l, mid - 1, L, pos);
    Solve(f, g, mid + 1, r, pos, R);
  }
  int main() {
    for (int i = 1; i <= N; i++) {
      coef[i] = i;
    }
    for (int i = 1; i <= N; i++) {
      for (int j = i + i; j <= N; j += i) {
        coef[j] -= coef[i];
      }
    }
    for (int i = 1; i <= N; i++) {
      coef[i] += coef[i - 1];
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
      dp[1][i] = i * (i + 1ll) / 2;
    }
    for (int it = 1; it < 16; it++) {
      Solve(dp[it], dp[it + 1], 1, N, 1, N);
    }
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
      int n, k;
      scanf("%d%d", &n, &k);
      if (k >= 17)
        printf("%d\n", n);
      else
        printf("%lld\n", dp[k][n]);
    }
    return 0;
  }
  