Language: C++

#include <bits/stdc++.h>
using namespace std;

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

struct unionFind {
    int elements = 0;
    vector<int> Par, Rank_p;
    unionFind(int n) : Par(n), Rank_p(n) {
        for (int id = 0; id < n; id++) {
            elements   = n;
            Par[id]    = id;
            Rank_p[id] = 0;
        }
    }
    int find(int x) {
        if (Par[x] == x)
            return x;
        else
            return Par[x] = find(Par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (Rank_p[x] < Rank_p[y])
            Par[x] = y;
        else {
            Par[y] = x;
            if (Rank_p[x] == Rank_p[y]) Rank_p[x]++;
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int groups() {
        set<int> se;
        for (auto x : Par) {
            se.insert(x);
        }
        return se.size();
    }
};

int main() {
    lint n, k;
    cin >> n >> k;

    lint ans = 0;
    for (int b = k + 1; b <= n; b++) {
        lint p = n / b;
        lint r = n % b;
        ans += p * max(0, b - k) + max(0, r - k + 1);
        dd(p, r);
        dd(b, ans);
        if (k == 0) { ans--; }
    }

    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:23: error: no matching function for call to 'max(int, lint)'
   75 |         ans += p * max(0, b - k) + max(0, r - k + 1);
      |                    ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:75:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'lint' {aka 'long long int'})
   75 |         ans += p * max(0, b - k) + max(0, r - k + 1);
      |                    ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:75:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   75 |         ans += p * max(0, b - k) + max(0, r - k + 1);
      |                    ~~~^~~~~~~~~~
a.cc:75:39: error: no matching function for call to 'max(int, lint)'
   75 |         ans += p * max(0, b - k) + max(0, r - k + 1);
      |                                    ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:75:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'lint' {aka 'long long int'})
   75 |         ans += p * max(0, b - k) + max(0, r - k + 1);
      |                                    ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:75:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   75 |         ans += p * max(0, b - k) + max(0, r - k + 1);
      |                                    ~~~^~~~~~~~~~~~~~