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

#include <iostream>
using namespace std;

typedef long long ll;
#define CIN_I(a)                                                               \\
  ll a;                                                                        \\
  cin >> a;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(s, i, n) for (ll i = s; i < (ll)(n); i++)

int main() {
  CIN_I(N);
  ll res = 0;
  FOR(1, k, N + 1) {
    ll sigA = N / k;
    res += sigA * (sigA + 1) * k / 2;
  }
  cout << res << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
#define CIN_I(a)                                                               \\
  ll a;                                                                        \\
  cin >> a;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(s, i, n) for (ll i = s; i < (ll)(n + 1); i++)

ll yakusuu(ll n) {
  ll ans = 1;
  vector<ll> x(n + 1);
  ll num = n;
  for (ll i = 2; i <= n; i++) {
    while (num % i == 0) {
      x[i]++;
      num /= i;
    }
  }
  for (ll i = 2; i <= n; i++) {
    ans *= x[i] + 1;
  }
  return ans;
}

int main() {
  CIN_I(N);
  ll res = 0;
  FOR(1, K, N) { res += K * yakusuu(K); }
  cout << res << endl;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h> //toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\\n"
using namespace std;
typedef long long ll;

void solve() {
  ll n;
  cin >> n;
  ll i;
  ll ans = 0;
  for (i = 1; i <= n; i++) {
    ll m = n / i;
    ll temp = (m * (m + 1)) / 2;
    temp *= i;
    ans += temp;
  }
  cout << ans << endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
//     freopen("output.txt","w",stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h> //toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\\n"
using namespace std;
typedef long long ll;

void solve() {
  ll n;
  cin >> n;
  ll i, j;
  ll ans = 0;
  for (i = 1; i <= n; i++) {
    ll p = 0;
    j = 1;
    while (j * j <= i) {
      if (i % j == 0) {
        ll d1 = j;
        ll d2 = i / j;
        if (d1 != d2) {
          p += 2;
        } else {
          p++;
        }
        // cout << i << " " << d1 << " " << d2 << endl;
      }
      j++;
    }
    // cout << i << " " << p << endl;
    ans += p * i;
  }
  // ans++;
  cout << ans << endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
//     freopen("output.txt","w",stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll n;
  cin >> n;
  ll arr[n + 1];
  memset(arr, 0, sizeof(arr));
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      arr[j]++;
    }
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += i * arr[i];
  }
  cout << ans;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll divCount(int n) {
  // sieve method for prime calculation
  bool hash[n + 1];
  memset(hash, true, sizeof(hash));
  for (int p = 2; p * p < n; p++)
    if (hash[p] == true)
      for (int i = p * 2; i < n; i += p)
        hash[i] = false;

  // Traversing through all prime numbers
  ll total = 1;
  for (int p = 2; p <= n; p++) {
    if (hash[p]) {

      // calculate number of divisor
      // with formula total div =
      // (p1+1) * (p2+1) *.....* (pn+1)
      // where n = (a1^p1)*(a2^p2)....
      // *(an^pn) ai being prime divisor
      // for n and pi are their respective
      // power in factorization
      int count = 0;
      if (n % p == 0) {
        while (n % p == 0) {
          n = n / p;
          count++;
        }
        total = total * (count + 1);
      }
    }
  }
  return total;
}
int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  ll arr[n + 1];
  memset(arr, 0, sizeof(arr));
  arr[1] = 1;
  ans++;

  for (int i = 2; i <= n; i++) {
    arr[i] = divCount(i);
    ans += i * arr[i];
  }
  cout << ans;
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<ll> d(n + 1);
  for (int i = 1; i <= n; i++) {
    int j = 1;
    while (j * i <= n) {
      d[j * i]++;
      j++;
    }
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += i * d[i];
  }

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int f(int x) {
  int cnt = x;
  for (int i = 2; i * i <= x; i++) {
    int num = 0;
    while (x % i == 0) {
      num++;
      x /= i;
    }
    cnt *= num + 1;
  }
  if (x != 1)
    cnt *= 2;
  return cnt;
}

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += f(i);
  }
  cout << ans << endl;
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL));
using namespace std;
int main() {
  fastread();
  ll n, h;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    h = n / i;
    ans += i * (1 + h) * h / 2;
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL));
using namespace std;
int main() {
  fastread();
  ll n;
  cin >> n;
  ll ans = 0;
  for (int j = 1; j <= n; j++) {
    for (int i = 1; i <= n; i++) {
      if (i % j == 0) {
        ans += i;
      }
    }
  }

  cout << ans << endl;

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

#include <iostream>
#include <vector>

#define ll long long

int main() {
  ll N;
  ll sum = 0;

  std::cin >> N;
  std::vector<ll> data(N + 1, 1);

  for (ll i = 2; i <= N; i++) {
    for (ll j = i; j <= N; j += i) {
      data[j]++;
    }
  }

  for (ll i = 1; i <= N; i++) {
    sum += i * data[i];
  }
  std::cout << sum;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

#define ll long long

int main() {
  ll N;
  ll sum = 0;

  std::cin >> N;
  std::vector<ll> data(N, 0);

  for (ll i = 0; i < N; i++) {
    int count = 0;
    for (ll j = 1; j <= (i + 1); j++) {
      if ((i + 1) % j == 0) {
        count++;
      }
    }
    data[i] = count;
  }
  for (ll i = 0; i < N; i++) {
    sum += (i + 1) * data[i];
  }
  std::cout << sum;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for (int i = (l), i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                  's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  vector<ll> lis(n + 1);
  REP(i, 1, n + 1) {
    for (ll l = i; l < n + 1; l += i) {
      lis[l]++;
    }
  }
  REP(i, 1, n + 1) { ans += lis[i] * i; }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for (int i = (l), i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                  's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  vector<ll> lis(n + 1, 1);
  REP(i, 2, n + 1) {
    ll c = i;
    int count = 1;
    if (lis[i] != 1) {
      // cout << "%" <<  i << endl;
      // cout << lis[i] << endl;
      continue;
    }
    while (c <= n) {
      c *= i;
      count++;
    }
    count--;
    c /= i;
    vector<int> flag(n + 1, 0);
    while (c >= i) {
      for (int l = c; l < n + 1; l += c) {
        if (flag[l] == 1) {
          continue;
        }
        lis[l] *= (count + 1);
        flag[l] = 1;
      }
      count--;
      c /= i;
    }
  }
  REP(i, 1, n + 1) {
    // cout << lis[i] << endl;
    ans = ans + (lis[i] * i);
  }
  cout << ans << endl;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

// #include<bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <vector>
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
const int MAXN = 2e5 + 10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x & (-x))
using namespace std;
// getline(cin,s);
// set<ll>::iterator it;
// map<int,int>::iterator it;
// unordered_map
typedef long long ll;
int main() {
  ll n, ans = 0;
  scanf("%lld", &n);
  ans = (1 + n) * n / 2;
  for (ll i = 2; i <= n; i++) {
    for (ll j = i; j <= n; j += i) {
      ans += j;
    }
  }
  printf("%lld\\n", ans);
  return 0;
}

Error: TLE

Fixed submission:

// #include<bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <vector>
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
const int MAXN = 2e5 + 10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x & (-x))
using namespace std;
// getline(cin,s);
// set<ll>::iterator it;
// map<int,int>::iterator it;
// unordered_map
typedef long long ll;
ll find(int x) {
  ll sum = 1;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      ll num = 1;
      while (x % i == 0) {
        num++;
        x /= i;
      }
      sum *= num;
    }
  }
  if (x > 1)
    sum *= 2;
  return sum;
}
int main() {
  int n;
  ll ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    ll sum = find(i);
    ans += (sum * i);
  }
  printf("%lld\\n", ans);
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long N;
  cin >> N;

  long long ans = 0;

  for (int i = 1; i < N + 1; i++) {
    long long Y = N / i;
    ans += Y * (Y + 1) * i / 2;
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  long long N;
  cin >> N;

  long long ans = 0;

  for (int i = 1; i < N + 1; i++) {

    long long i_half = i / 2;
    long long count = 1;

    for (int j = 1; j < i_half + 1; j++) {
      if (i % j == 0) {
        count += 1;
      }
    }
    ans += i * count;
  }
  cout << ans << endl;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int main() {
#ifdef LOCAL_EXEC
#else
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#endif // LOCAL_EXEC
  long long int i, j, k, n, m, y, sum = 0, x;
  long long int mt[10000001] = {0};
  cin >> n;
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j += i) {
      mt[j] += 1;
    }
  }
  for (i = 1; i <= n; i++) {
    sum += i * mt[i];
  }
  cout << sum;
  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;

int main() {
#ifdef LOCAL_EXEC
#else
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#endif // LOCAL_EXEC
  long long int i, j, k, n, m, y, sum, x;
  map<long long int, long long int> mt;
  mt[1] = 1;
  // for(i=2;i<=100000;i++){
  //   if(mt[i]==0){
  // for(j=1;i*j<=100000;j++){
  //   if(mt[i*j]==0)
  // mt[i*j]=i;
  //}
  // mt[i]=1;
  //}
  //}
  cin >> n;
  sum = 1;
  // cout<<mt[99]<<endl;
  for (i = 2; i <= n; i++) {
    if (mt[i] == 1)
      sum += i * 2;
    else {
      x = 0;
      y = i;
      map<long long int, long long int> pt;
      // cout<<mt[i]<<endl;
      for (j = 2; j * j <= y; j++) {
        if (y % j == 0) {
          x += 1;
          pt[j] = 1;
          if ((y / j) != j) {
            x += 1;
            pt[y / j] = 1;
          }
        }
      }
      // if(y!=1&&pt[y]==0)
      // x+=1;
      // cout<<x<<endl;
      sum += (i * (x + 2)) % 10000000000000000;
      sum %= 10000000000000000;
    }
    // cout<<sum<<endl;
  }
  cout << sum;
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(ri, n) for (int ri = (int)(n - 1); ri >= 0; ri--)
#define rep2(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri, x, n) for (int ri = (int)(n - 1); ri >= (int)(x); ri--)
#define repit(itr, x) for (auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr, x) for (auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep2(i, 1, n + 1) {
    ll k = n / i;
    ans += (ll)i * k * (k + 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(ri, n) for (int ri = (int)(n - 1); ri >= 0; ri--)
#define rep2(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri, x, n) for (int ri = (int)(n - 1); ri >= (int)(x); ri--)
#define repit(itr, x) for (auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr, x) for (auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

void dfs(vector<int> &sprime, int now, int co, int n, int lv, int mxl,
         ll &ans) {
  if (lv == mxl) {
    if (now != 0)
      ans += co * now;
    return;
  }
  dfs(sprime, now, co, n, lv + 1, mxl, ans);
  ll p = 1;
  for (int i = 1;; i++) {
    p *= sprime.at(lv);
    ll ad = p * now;
    if (ad > n)
      break;
    dfs(sprime, ad, co * (i + 1), n, lv + 1, mxl, ans);
  }
}

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  vector<bool> prime(n + 1, true);
  prime.at(0) = prime.at(1) = false;
  for (int i = 2; i * i <= n; i++) {
    if (prime.at(i) == true) {
      for (int j = 2; i * j <= n; j++) {
        prime.at(i * j) = false;
      }
    }
  }
  vector<int> sprime;
  rep(i, n + 1) {
    if (prime.at(i) == true)
      sprime.push_back(i);
  }
  dfs(sprime, 1, 1, n, 0, sprime.size(), ans);
  cout << ans << endl;
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

long long inf = 1000000007;

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

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

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;

long long inf = 1000000007;

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

  for (long long i = 1; i <= n; i++) {
    long long pre = i;
    long long num = i;

    for (long long j = 2; j <= num; j++) {
      long long cnt = 0;
      while (num % j == 0) {
        num /= j;
        cnt++;
      }
      pre *= cnt + 1;
    }

    ans += pre;
  }

  cout << ans << endl;

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

#include "bits/stdc++.h"

#define ll long long
#define pb push_back
#define pii pair<ll, ll>
#define vpii vector<pii>
#define vi vector<ll>
#define vs vector<string>
#define vvi vector<vector<ll>>
#define inf 1'010'000'000'000'000'017LL
#define all(it, a) for (auto it = (a).begin(); it != (a).end(); it++)
#define sz(x) (ll) x.size()
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repr(i, a, b) for (ll i = a; i > b; i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define mp make_pair
#define whatis(x) cout << #x << " is " << x << "\\n";
#define graph(n) adj(n, vector<ll>())

using namespace std;

template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll DivisorCount(ll x) {
  ll ans = 1;
  for (int i = 2; i <= sqrt(x); i++) {
    int cnt = 0;
    while (x % i == 0) {
      cnt++;
      x /= i;
    }
    ans *= (cnt + 1);
    if (x == 1)
      break;
  }
  if (x != 1)
    ans *= 2;
  return ans;
}

void Main() {
  ll N;
  cin >> N;

  ll result = 0;
  rep(i, 1, N + 1) {
    ll X = N / i;
    result += i * X * (X + 1) / 2;
  }

  cout << result << endl;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  Main();
  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"

#define ll long long
#define pb push_back
#define pii pair<ll, ll>
#define vpii vector<pii>
#define vi vector<ll>
#define vs vector<string>
#define vvi vector<vector<ll>>
#define inf 1'010'000'000'000'000'017LL
#define all(it, a) for (auto it = (a).begin(); it != (a).end(); it++)
#define sz(x) (ll) x.size()
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repr(i, a, b) for (ll i = a; i > b; i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define mp make_pair
#define whatis(x) cout << #x << " is " << x << "\\n";
#define graph(n) adj(n, vector<ll>())

using namespace std;

template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll DivisorCount(ll x) {
  ll ans = 1;
  for (int i = 2; i <= sqrt(x); i++) {
    int cnt = 0;
    while (x % i == 0) {
      cnt++;
      x /= i;
    }
    ans *= (cnt + 1);
    if (x == 1)
      break;
  }
  if (x != 1)
    ans *= 2;
  return ans;
}

void Main() {
  ll N;
  cin >> N;

  vi f(N + 1, 0);
  rep(i, 1, N + 1) {
    rep(k, 1, N + 1) {
      if (i % k == 0)
        f[i]++;
    }
  }
  ll result = 0;
  rep(i, 1, N + 1) { result += f[i] * i; }
  cout << result << endl;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

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

#include <bits/stdc++.h>
#define ll long long int
#define st string
#define con continue
#define br break
#define rt return 0
#define fr first
#define sec second
using namespace std;
int main() {
  // ll tc; cin>>tc; while(tc--){
  ll n, m, mn = INT_MAX, i, x, j, a = 0, t, k, b = -1, mx = -1, cnt = 0, c = 0;
  st s, str;
  char strn;
  cin >> n; // a=n; n-=1;
  ll ara[n + 1], bra[n + 1], taj[n + 1];
  memset(ara, 0, sizeof(ara));
  // for(i=1;i<=n;i++) cin>>ara[i];
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j += i) {
      ara[j]++;
    }
  }
  for (i = 1; i <= n; i++)
    a += (i * ara[i]);

  cout << a << endl;

  rt;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define st string
#define con continue
#define br break
#define rt return 0
#define fr first
#define sec second
using namespace std;
int main() {
  // ll tc; cin>>tc; while(tc--){
  ll n, m, mn = INT_MAX, i, x, j, a = 0, t, k, b = -1, mx = -1, cnt = 0, c = 0;
  st s, str;
  char strn;
  cin >> n;
  // ll ara[n+1],bra[n+1],taj[n+1];
  map<ll, ll> mp;
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j += i) {
      mp[j]++;
    }
  }
  for (i = 1; i <= n; i++)
    a += (mp[i] * i);

  cout << a << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep_lr(i, l, r) for (int i = (l); i < (r); i++)
#define all(x) (x).begin(), (x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

vi divide(10000100, 1);

int main() {

  int n;
  cin >> n;
  rep_lr(i, 2, n + 1) {
    int ii = i;
    while (ii <= n) {
      divide[ii]++;
      ii += i;
    }
  }

  ll ans = 0;
  rep_lr(i, 1, n + 1) { ans += (ll)i * divide[i]; }

  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep_lr(i, l, r) for (int i = (l); i < (r); i++)
#define all(x) (x).begin(), (x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

vi prime, mnpf;
void preprime(int n) {

  prime.resize(0);
  mnpf.assign(n + 1, 1);
  rep(i, n + 1) {
    if (i < 2)
      continue;
    if (mnpf[i] != 1)
      continue;

    prime.push_back(i);
    mnpf[i] = i;
    int ii = i;
    while (ii <= n) {
      if (mnpf[ii] == 1)
        mnpf[ii] = i;
      ii += i;
    }
  }
}

V<ll> prft;
void pflz(ll n) {
  ll nn = n;
  int k = 0;
  while (nn > 1 && k < prime.size()) {
    if (nn % prime[k])
      k++;
    else {
      nn /= prime[k];
      prft.push_back(prime[k]);
    }
  }
  if (nn > 1)
    prft.push_back(nn);
  return;
}

int main() {

  int n;
  cin >> n;
  preprime(n);

  ll ans = 1;
  rep_lr(i, 2, n + 1) {
    prft.resize(0);
    pflz(i);

    ll f = 1;
    int k = 1;
    rep(j, prft.size() - 1) {
      if (prft[j] == prft[j + 1])
        k++;
      else {
        f *= k + 1;
        k = 1;
      }
    }
    f *= k + 1;
    ans += i * f;
  }

  cout << ans << endl;
}