Language: C++

//Author : Vipul Sharma

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

// MACROS
#define ll long long ll
#define ld long double
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i,b,a) for(ll i=b-1;i>=a;i--)
#define eqrep(i,a,b) for(ll i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
# define INF 0x3f3f3f3f 
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

using namespace std;
long long cost = 1e18;

void SieveOfEratosthenes(ll n, bool prime[], 
                         bool primesquare[], ll a[]) 
{ 
    // Create a boolean array "prime[0..n]" and 
    // initialize all entries it as true. A value 
    // in prime[i] will finally be false if i is 
    // Not a prime, else true. 
    for (ll i = 2; i <= n; i++) 
        prime[i] = true; 
  
    // Create a boolean array "primesquare[0..n*n+1]" 
    // and initialize all entries it as false. A value 
    // in squareprime[i] will finally be true if i is 
    // square of prime, else false. 
    for (ll i = 0; i <= (n * n + 1); i++) 
        primesquare[i] = false; 
  
    // 1 is not a prime number 
    prime[1] = false; 
  
    for (ll p = 2; p * p <= n; p++) { 
        // If prime[p] is not changed, then 
        // it is a prime 
        if (prime[p] == true) { 
            // Update all multiples of p 
            for (ll i = p * 2; i <= n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    ll j = 0; 
    for (ll p = 2; p <= n; p++) { 
        if (prime[p]) { 
            // Storing primes in an array 
            a[j] = p; 
  
            // Update value in primesquare[p*p], 
            // if p is prime. 
            primesquare[p * p] = true; 
            j++; 
        } 
    } 
} 
  
// Function to count divisors 
ll countDivisors(ll n) 
{ 
    // If number is 1, then it will have only 1 
    // as a factor. So, total factors will be 1. 
    if (n == 1) 
        return 1; 
  
    bool prime[n + 1], primesquare[n * n + 1]; 
  
    ll a[n]; // for storing primes upto n 
  
    // Calling SieveOfEratosthenes to store prime 
    // factors of n and to store square of prime 
    // factors of n 
    SieveOfEratosthenes(n, prime, primesquare, a); 
  
    // ans will contain total number of distinct 
    // divisors 
    ll ans = 1; 
  
    // Loop for counting factors of n 
    for (ll i = 0;; i++) { 
        // a[i] is not less than cube root n 
        if (a[i] * a[i] * a[i] > n) 
            break; 
  
        // Calculating power of a[i] in n. 
        ll cnt = 1; // cnt is power of prime a[i] in n. 
        while (n % a[i] == 0) // if a[i] is a factor of n 
        { 
            n = n / a[i]; 
            cnt = cnt + 1; // incrementing power 
        } 
  
        // Calculating number of divisors 
        // If n = a^p * b^q then total divisors of n 
        // are (p+1)*(q+1) 
        ans = ans * cnt; 
    } 
  
    // if a[i] is greater than cube root of n 
  
    // First case 
    if (prime[n]) 
        ans = ans * 2; 
  
    // Second case 
    else if (primesquare[n]) 
        ans = ans * 3; 
  
    // Third casse 
    else if (n != 1) 
        ans = ans * 4; 
  
    return ans; // Total divisors 
} 

int main()
{
	
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    booster;
    ll n;
    cin>>n;
    ll res=0;
    for(ll i=1;i<=n;i++)
    {
    	res+=(i*countDivisors(i));
    }
    cout<<res<<endl;
    return 0;
}

Compiler output:
a.cc:32:29: error: expected ',' or '...' before 'n'
   32 | void SieveOfEratosthenes(ll n, bool prime[],
      |                             ^
a.cc: In function 'void SieveOfEratosthenes(long long int)':
a.cc:39:13: error: expected ';' before 'i'
   39 |     for (ll i = 2; i <= n; i++)
      |             ^
a.cc:39:13: error: 'i' was not declared in this scope
a.cc:39:25: error: 'n' was not declared in this scope; did you mean 'yn'?
   39 |     for (ll i = 2; i <= n; i++)
      |                         ^
      |                         yn
a.cc:39:26: error: expected ')' before ';' token
   39 |     for (ll i = 2; i <= n; i++)
      |         ~                ^
      |                          )
a.cc:39:28: error: 'i' was not declared in this scope
   39 |     for (ll i = 2; i <= n; i++)
      |                            ^
a.cc:46:13: error: expected ';' before 'i'
   46 |     for (ll i = 0; i <= (n * n + 1); i++)
      |             ^
a.cc:46:26: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for (ll i = 0; i <= (n * n + 1); i++)
      |                          ^
      |                          yn
a.cc:46:36: error: expected ')' before ';' token
   46 |     for (ll i = 0; i <= (n * n + 1); i++)
      |         ~                          ^
      |                                    )
a.cc:50:5: error: 'prime' was not declared in this scope
   50 |     prime[1] = false;
      |     ^~~~~
a.cc:52:13: error: expected ';' before 'p'
   52 |     for (ll p = 2; p * p <= n; p++) {
      |             ^
a.cc:52:13: error: 'p' was not declared in this scope
a.cc:52:29: error: 'n' was not declared in this scope; did you mean 'yn'?
   52 |     for (ll p = 2; p * p <= n; p++) {
      |                             ^
      |                             yn
a.cc:52:30: error: expected ')' before ';' token
   52 |     for (ll p = 2; p * p <= n; p++) {
      |         ~                    ^
      |                              )
a.cc:52:32: error: 'p' was not declared in this scope
   52 |     for (ll p = 2; p * p <= n; p++) {
      |                                ^
a.cc:62:8: error: expected initializer before 'j'
   62 |     ll j = 0;
      |        ^
a.cc:63:13: error: expected ';' before 'p'
   63 |     for (ll p = 2; p <= n; p++) {
      |             ^
a.cc:63:25: error: 'n' was not declared in this scope; did you mean 'yn'?
   63 |     for (ll p = 2; p <= n; p++) {
      |                         ^
      |                         yn
a.cc:63:26: error: expected ')' before ';' token
   63 |     for (ll p = 2; p <= n; p++) {
      |         ~                ^
      |                          )
a.cc: At global scope:
a.cc:77:4: error: expected initializer before 'countDivisors'
   77 | ll countDivisors(ll n)
      |    ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:142:8: error: expected initializer before 'n'
  142 |     ll n;
      |        ^
a.cc:143:10: error: 'n' was not declared in this scope; did you mean 'yn'?
  143 |     cin>>n;
      |          ^
      |          yn
a.cc:144:8: error: expected initializer before 'res'
  144 |     ll res=0;
      |        ^~~
a.cc:145:12: error: expected ';' before 'i'
  145 |     for(ll i=1;i<=n;i++)
      |            ^
a.cc:145:12: error: 'i' was not declared in this scope
a.cc:145:20: error: expected ')' before ';' token
  145 |     for(ll i=1;i<=n;i++)
      |        ~           ^
      |                    )
a.cc:145:21: error: 'i' was not declared in this scope
  145 |     for(ll i=1;i<=n;i++)
      |                     ^
a.cc:149:11: error: 'res' was not declared in this scope; did you mean 'rep'?
  149 |     cout<<res<<endl;
      |           ^~~
      |           rep