alexjercan/bugnet huggingface dataset:
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M_PI 3.14159265358979323846

void solve() {
  int n;
  cin >> n;
  vector<int> a(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j += i)
      a[j]++;
  }
  ll total = 0;
  for (ll i = 1; i <= n; i++)
    total += (i * (ll)a[i]);
  cout << total;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  int t = 1;
  //        cin>>t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M_PI 3.14159265358979323846

ull numDiv(ull n) {
  ull cnt = 0;
  for (ull i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;

      else // Otherwise count both
        cnt = cnt + 2ull;
    }
  }
  return cnt;
}

void solve() {
  ull n;
  cin >> n;
  ull total = 0;
  for (ull i = 1; i <= n; i++) {
    total += (i) * (numDiv(i));
    //            cout<<total<<"\\n";
  }
  cout << total;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  int t = 1;
  //        cin>>t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
  // INPUT
  ll N = 0;
  cin >> N;

  // SOURCE
  ll ans = 0;
  for (ll i = 1; i < N + 1; ++i) {
    ll Y = N / i;
    ans += (Y * (Y + 1) * i) / 2;
  }

  // OUTPUT
  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
  // INPUT
  ll N = 0;
  cin >> N;

  // SOURCE
  ll ans = 0;
  for (ll i = 1; i < N + 1; ++i) {
    for (ll j = 1; j <= i; ++j) {
      if (i % j == 0)
        ans += i;
    }
  }

  // OUTPUT
  cout << ans << endl;

  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
int main(void) {
  unsigned long long int n, ans = 0, i, temp;
  cin >> n;
  for (i = 1; i <= n; i++) {
    temp = n / i;
    ans += ((temp * (temp + 1)) / 2) * i;
  }
  cout << ans;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
void SieveOfEratosthenes(int n, bool prime[], bool primesquare[], int 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 (int 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 (int i = 0; i <= (n * n + 1); i++)
    primesquare[i] = false;

  // 1 is not a prime number
  prime[1] = false;

  for (int 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 (int i = p * 2; i <= n; i += p)
        prime[i] = false;
    }
  }

  int j = 0;
  for (int 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
int func(int 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];

  int 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
  int ans = 1;

  // Loop for counting factors of n
  for (int 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.
    int 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(void) {
  unsigned long long int n, ans = 0, i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    ans += i * (func(i));
  }
  cout << ans;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define rep(i, n) for (i = 0; i < n; i++)
bool is_prime(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0)
      return 0;
  return 1;
}

const int maxn = 10000005;
#define RAGE                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
int divi[maxn];
signed main() {
  RAGE;
  int t = 1;
  //  cin>>t;
  while (t--) {
    int n, i, j, k, m;
    cin >> n;
    int ans = 0;
    for (i = 1; i <= n; i++) {
      for (j = 1; j * i <= n; j++)
        divi[j * i]++;
    }
    for (i = 1; i <= n; i++)
      ans += divi[i] * i;
    cout << ans;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define rep(i, n) for (i = 0; i < n; i++)
bool is_prime(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0)
      return 0;
  return 1;
}

int countDivisors(int n) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;

      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}
signed main() {

  int t = 1;
  //  cin>>t;
  while (t--) {
    int n, i, j, k, m;
    cin >> n;
    int ans = 1;
    for (i = 2; i <= n; i++) {
      if (is_prime(i))
        ans += 2 * i;
      else {
        ans += i * countDivisors(i);
      }
    }
    cout << ans;
  }

  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  // your code goes here
  long long int n;
  cin >> n;
  vector<long long int> arr(n + 1, 1);
  for (long long int i = 2; i <= n; i++) {
    for (long long int j = i; j <= n; j += i) {
      arr[j]++;
    }
  }
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    ans = ans + (i * arr[i]);
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  // your code goes here
  int n;
  cin >> n;
  vector<int> arr(n, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        int x = j, y = i / j;
        if (x == y) {
          arr[i]++;
        } else {
          arr[i] += 2;
        }
      }
    }
    // cout<<arr[i]<<" ";
  } // cout<<endl;
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = ans + i * arr[i];
  }
  cout << ans;
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> P;
#define mp(x, y) make_pair(x, y)

typedef queue<int> qi;
typedef queue<string> qs;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i <= (b); i++)
#define repm(i, n) for (int i = n; i >= 0; i--)

#define all(v) v.begin(), v.end()
// sort( all(v) )　などと使える

ll f(ll x) {
  ll cnt = 0;

  for (ll i = 1; i * i <= x; i++) {
    if (x % i == 0)
      cnt++;
    if (x % i == 0 && i * i != x)
      cnt++;
  }

  return cnt;
}

int main(void) {
  ll n;
  cin >> n;

  ll ans = 0;

  // cout << f(n) << endl;

  for (ll j = 1; j <= n; j++) {
    // jの倍数はqコあるよ
    ll q = n / j;
    // jの倍数 * jはj + 2 * j + ・・・ + q * j
    //  = q * (q + 1) / 2 * j
    ans += j * q * (q + 1) / 2;
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> P;
#define mp(x, y) make_pair(x, y)

typedef queue<int> qi;
typedef queue<string> qs;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i <= (b); i++)
#define repm(i, n) for (int i = n; i >= 0; i--)

#define all(v) v.begin(), v.end()
// sort( all(v) )　などと使える

ll f(ll x) {
  ll cnt = 0;

  for (ll i = 1; i * i <= x; i++) {
    if (x % i == 0)
      cnt++;
    if (x % i == 0 && i * i != x)
      cnt++;
  }

  return cnt;
}

int main(void) {
  ll n;
  cin >> n;

  ll ans = 0;

  // cout << f(n) << endl;

  for (ll k = 1; k <= n; k++) {
    ans += k * f(k);
  }

  cout << ans << endl;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back

const int maxn = 1e7 + 10;
int divisors[maxn];

void sieve() {
  for (int i = 1; i < maxn; i++) {
    for (int j = i; j < maxn; j += i) {
      divisors[j]++;
    }
  }
}

void solve() {
  int n;
  cin >> n;
  sieve();
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += i * divisors[i];
  }
  cout << ans << "\\n";
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back

int Noofdivisiors(int n) {
  map<int, int> m1;
  int x = 2;
  while (n > 1) {
    while (n % x == 0 and n > 1) {
      m1[x]++;
      n = n / x;
    }
    x += 1;
  }
  int sum = 1;
  for (auto i : m1)
    sum *= (i.second + 1);
  return sum;
}

void solve() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += i * Noofdivisiors(i);
  }
  cout << ans << "\\n";
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T, typename cmp=less<T>> using oset =tree<T, null_type,
// cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define mod 1000000007
#define inf 100000000000000000
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(), _x.end()
#define f first
#define s second
#define pb push_back
void mahakal() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
}
const ll maxN = 2e5 + 5, N = 1e7 + 1;
ll n, a[N];
void pre() {
  for (ll i = 1; i < N; i++) {
    for (ll j = i; j < N; j += i) {
      a[j]++;
    }
  }
}
void solve() {
  pre();
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    ans += (i * a[i]);
  }
  cout << ans << endl;
}

int main() {
  // mahakal(),
  fast;
  ll t = 1;
  // cin>>t ;
  while (t--)
    solve();

  return 0;
}

Error: TLE

Fixed submission:

/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T, typename cmp=less<T>> using oset =tree<T, null_type,
// cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define mod 1000000007
#define inf 100000000000000000
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(), _x.end()
#define f first
#define s second
#define pb push_back
void mahakal() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
}
const ll maxN = 2e5 + 5, N = 1e3 + 1;
ll n;
ll F(ll nn) {
  ll ans = 0;
  for (ll i = 1; i * i <= nn; i++) {
    if (nn % i == 0) {
      if (i * i == nn)
        ans++;
      else
        ans += 2;
    }
  }
  return ans;
}
void solve() {
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    ans += i * F(i);
  }
  cout << ans << endl;
}

int main() {
  // mahakal(),
  fast;
  ll t = 1;
  // cin>>t ;
  while (t--)
    solve();

  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

// AnkitCode99 here....
// every ups and downs matter!

#include <bits/stdc++.h>
#define endl "\\n"
#define Ryuga                                                                  \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(nullptr);                                                            \\
  cout.tie(nullptr)
typedef long long int ll;
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define pb push_back

using namespace std;

const ll sz = 1e5 + 5;
const ll szz = (1e7 + 7);
const ll mod = 1e9 + 7;

ll spf[szz];
void sieve() {
  ll st = 1;
  rep(i, 2, szz) { spf[i] = i; }
  for (ll i = 2; i < szz; i += 2) {
    spf[i] = 2;
  }
  rep(i, 3, (ll)sqrt(szz)) {
    if (spf[i] == i) {
      for (ll j = i * i; j < szz; j += i) {
        if (spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }
}

ll f(ll n) {
  if (n == 1)
    return 1;
  map<ll, ll> mp;
  while (n != 1) {
    ll x = spf[n];
    while (n % x == 0) {
      mp[x]++;
      n /= x;
    }
  }

  ll ans = 1;
  for (auto x : mp) {
    ans *= (x.second + 1);
  }
  return ans;
}

int main() {
  Ryuga;

  clock_t startTime = clock();

  sieve();
  ll n;
  cin >> n;
  ll tot = 0;
  rep(i, 1, n + 1) { tot += i * f(i); }
  cout << tot << endl;

  cerr << endl
       << setprecision(20)
       << double(clock() - startTime) / (double)CLOCKS_PER_SEC << " seconds."
       << endl;

} // Goodbye...

Error: TLE

Fixed submission:

// AnkitCode99 here....
// every ups and downs matter!

#include <bits/stdc++.h>
#define endl "\\n"
#define Ryuga                                                                  \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(nullptr);                                                            \\
  cout.tie(nullptr)
typedef long long int ll;
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define pb push_back

using namespace std;

const ll sz = 1e5 + 5;
const ll szz = (1e7 + 7);
const ll mod = 1e9 + 7;

ll spf[szz];
void sieve() {
  ll st = 1;
  iota(spf, spf + szz, st);

  for (ll i = 2; i < szz; i += 2) {
    spf[i] = 2;
  }
  rep(i, 3, (ll)sqrt(szz)) {
    if (spf[i] == i) {
      for (ll j = 2 * i; j < szz; j += i) {
        if (spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }
}

ll f(ll n) {
  if (n == 1)
    return 1;
  map<ll, ll> mp;
  while (n != 1) {
    ll x = spf[n];
    while (n % x == 0) {
      mp[x]++;
      n /= x;
    }
  }

  ll ans = 1;
  for (auto x : mp) {
    ans *= x.second;
  }
  return ans;
}

int main() {
  Ryuga;

  clock_t startTime = clock();

  sieve();
  ll n;
  cin >> n;
  ll tot = 0;
  rep(i, 1, n + 1) { tot += i * f(i); }
  cout << tot << endl;

  cerr << endl
       << setprecision(20)
       << double(clock() - startTime) / (double)CLOCKS_PER_SEC << " seconds."
       << endl;

} // Goodbye...
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;
long long n, i, j, nr;
int main() {

  cin >> n;
  for (j = 1; j <= n; j++)
    for (i = j; i <= n; i += j)
      if (i % j == 0)
        nr += i;
  cout << nr;
}


Error: TLE

Fixed submission:

#include <iostream>
#define N 200002
using namespace std;
long long n, i, j, nr;
int main() {

  cin >> n;
  for (j = 1; j <= n; j++)
    for (i = j; i <= n; i++)
      if (i % j == 0)
        nr += i;
  cout << nr;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

// c++ テンプレ
#include <bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint, vector<llint>, greater<llint>> que;
priority_queue<llint> Que;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

llint calc(llint x) { return x * (x + 1) / 2; }
void solve() {
  llint n;
  cin >> n;
  llint ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += calc(n / i) * i;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}


Error: TLE

Fixed submission:

// c++ テンプレ
#include <bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint, vector<llint>, greater<llint>> que;
priority_queue<llint> Que;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

llint f(long long N) {
  llint x = 1;
  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;
    }

    // その結果を push
    x *= (ex + 1);
  }

  // 最後に残った数について
  if (N != 1)
    x *= 2;
  return x;
}

void solve() {
  llint n;
  cin >> n;
  llint ans = 0;
  for (llint i = 1; i <= n; i++) {
    int x = f(i);
    ans += x * i;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long n;
  long long ans = 0;
  cin >> n;

  for (long long i = 1; i <= n; i++) {
    long long k = n / i;
    ans += k * (k + 1) * i / 2;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  long long a;
  long long cnt = 0, ans = 1, x = 1;
  cin >> a;

  for (int j = 2; j <= a; j++) {
    long long n = j;
    ans = 1;
    for (int i = 2; i <= sqrt(n); i++) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      ans *= (cnt + 1);
      if (n == 1)
        break;
    }
    if (n != 1)
      ans *= 2;
    x += ans * j;
  }
  cout << x << endl;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#define lrep(i, cc, n) for (long long i = cc; i < n; ++i)
#define sqrep(i, cc, n) for (long long i = cc; i * i <= n; ++i)
#define rrep(i, cc, n) for (long i = cc; i > n; --i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9 = 1000000000;
const ll mod = 1000000007;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, 1, n + 1) {
    ll num = n / i;
    ll first = i;
    ll last = i + i * (num - 1);
    ans += (first + last) * num;
  }
  cout << ans / 2 << endl;
}

Error: TLE

Fixed submission:

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

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#define lrep(i, cc, n) for (long long i = cc; i < n; ++i)
#define sqrep(i, cc, n) for (long long i = cc; i * i <= n; ++i)
#define rrep(i, cc, n) for (long i = cc; i > n; --i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9 = 1000000000;
const ll mod = 1000000007;

ll cntd(ll x) {
  ll cnt = 0;
  sqrep(i, 1, x) {
    if (x % i == 0) {
      cnt++;
      if (x != i * i)
        cnt++;
    }
  }
  return cnt;
}
int main() {
  ll n;
  cin >> n;
  ll ans = 1;
  vector<ll> v(10000000, 1);
  // rep(i, 1, 10000000){
  // v[i]=cntd(i+1);
  //}
  rep(i, 2, n + 1) { ans += i * cntd(i); }
  cout << ans << endl;
}