Language: C++

#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

struct cww {
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
std::vector<int> Eratosthenes(const int N)
{
    std::vector<bool> is_prime(N + 1);
    for (int i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<int> P;
    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (int j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

vector<pair<long long, long long>> prime_factorize(long long N)
{
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0)
            continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({ a, ex });
    }
    if (N != 1)
        res.push_back({ N, 1 });
    return res;
}

ll ans = 0;
vector<bool> check(100000008);

void dfs(ll num, ll yk, vector<pair<ll, ll>>& pf)
{
    if (check(num))
        return;

    check(num) = true;
    for (int i = 0; i < pf.size(); i++) {
        if (pf[i].second >= 1) {
            pf[i].second = pf[i].second - 1;
            num /= pf[i].first;
            yk = yk / (pf[i].second + 1) * pf[i].second;
            ans += num * yk;
            dfs(num, yk, pf);
        }
    }
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> check(N);
    for (ll k = N; k >= 1; k--) {
        if (check[k])
            continue;
        vector<pair<ll, ll>>& pf = prime_factorize(k);
        ll num = k;
        ll yk = 1;
        ans += k;
        for (auto p : pf)
            res *= p.second + 1;
        dfs(k);
    }
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'void dfs(ll, ll, std::vector<std::pair<long long int, long long int> >&)':
a.cc:64:14: error: no match for call to '(std::vector<bool>) (ll&)'
   64 |     if (check(num))
      |         ~~~~~^~~~~
a.cc:67:10: error: no match for call to '(std::vector<bool>) (ll&)'
   67 |     check(num) = true;
      |     ~~~~~^~~~~
a.cc: In function 'int main()':
a.cc:87:51: error: cannot bind non-const lvalue reference of type 'std::vector<std::pair<long long int, long long int> >&' to an rvalue of type 'std::vector<std::pair<long long int, long long int> >'
   87 |         vector<pair<ll, ll>>& pf = prime_factorize(k);
      |                                    ~~~~~~~~~~~~~~~^~~
a.cc:92:13: error: 'res' was not declared in this scope; did you mean 'rep'?
   92 |             res *= p.second + 1;
      |             ^~~
      |             rep
a.cc:93:12: error: too few arguments to function 'void dfs(ll, ll, std::vector<std::pair<long long int, long long int> >&)'
   93 |         dfs(k);
      |         ~~~^~~
a.cc:62:6: note: declared here
   62 | void dfs(ll num, ll yk, vector<pair<ll, ll>>& pf)
      |      ^~~