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

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
  lli n;
  cin >> n;

  vector<lli> cnt(n + 2, 0);
  for (lli i = 1; i <= n; i++) {
    for (lli j = i; j <= n; j += i) {
      cnt[j]++;
    }
  }

  lli ans = 0;
  for (lli i = 1; i <= n; i++) {
    ans += i * cnt[i];
  }
  cout << ans << endl;
}

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // lli t; cin >> t; while(t--)
  solve();
  rt;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
  lli no = 1e7;
  vector<lli> prime(no + 2, 0);

  for (lli i = 2; i <= sqrt(no); i++) {
    if (prime[i] != 0) {
      continue;
    }
    for (lli j = i * i; j <= no; j += i) {
      // if (prime[j] == 0) {
      prime[j] = i;
      // }
    }
  }

  lli n;
  cin >> n;
  lli ans = 0;

  for (lli i = 1; i <= n; i++) {
    unordered_map<lli, lli> mp;
    unordered_set<lli> st;
    lli val = i;
    while (prime[val] != 0) {
      lli p = prime[val];
      val /= p;
      mp[p]++;
      st.insert(p);
    }
    if (val != 1) {
      mp[val]++;
      st.insert(val);
    }
    lli no = 1;
    for (auto vv : st) {
      no *= (1 + mp[vv]);
    }
    no *= i;
    ans += no;
  }

  cout << ans << endl;
}

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // lli t; cin >> t; while(t--)
  solve();
  rt;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long int ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  ll sum = 0LL;
  for (int i = 1; i <= n; i++) {
    ll x = floor((double)n / i);
    sum += (ll)i * x * (x + 1) / 2;
  }
  cout << sum << '\\n';
}

Error: TLE

Fixed submission:

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

typedef long long int ll;

int f(int x) {
  int divisors = 0, batas = sqrt(x);
  for (int i = 1; i <= batas; i++)
    if (x % i == 0)
      divisors += (i * i == x) ? 1 : 2;
  return divisors;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  ll sum = 0LL;
  for (int i = 1; i <= n; i++)
    sum += (ll)i * f(i);
  cout << sum << '\\n';
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  long long int n, i, j, s = 0, sum = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j = j + i)
      sum += j;
  }
  cout << sum;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  long long int n, i, j, s = 0, sum = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= i; j++) {
      if (i % j == 0)
        s++;
    }
    sum += (s * i);
    s = 0;
  }
  cout << sum;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll N;
  cin >> N;
  ll n = 1;
  // for(ll i = 0; i*i < N; i++) n = i + 1;

  ll ans = 0;
  ll now = 0;

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

  for (ll i = 1; i <= N && 0; i++) {
    now = 0;
    ;
    ll temp = i;
    for (ll j = 1; j * j <= i; j++) {
      if (!(i % j)) {
        now += 2;
        if (i / j == j)
          now--;
      }
    }
    cout << i << ':' << now << endl;
    ans += now * i;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long N;
  long long ans = 1;
  cin >> N;
  long long ansans = 1;
  for (long long n = 2; n < N + 1; n++) {
    /* code */
    ans = 1;

    vector<long long> x(n + 1);
    long long num = n; // 素因数分解する変数num

    for (long long i = 2; i <= n; i++) {
      while (num % i == 0) { // 素数で割り切れなくなるまで割っていく
        x.at(i)++;           // 割った個数を配列に足す
        num /= i;
      }
    }

    for (long long i = 2; i <= n; i++) {
      ans *= x.at(i) + 1; // それぞれを+1して掛けていく
    }
    ansans += n * ans;
  }
  cout << ansans << endl;

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

/*
     “You just can’t beat the person who won’t give up.”
                                                            */
#include <bits/stdc++.h>
#define ll long long
#define oo 0x3f3f3f3f3f3f3f3fLL
#define lp(i, n) for (int i = 0; i < int(n); i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
const int maxn = 2e5 + 5;
const double EPS = 1e-9;
const int mod = 1e9 + 7;

inline void File() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif
}
ll sum(ll i) { return ((i * (i + 1)) / 2); }
int main() {
  ios_base::sync_with_stdio(0);
  File();
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += i * sum(n / i);
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

int countDiv(int x) {
  if (x == 1)
    return 1;
  int ans = 1;
  for (int i = 2; i <= x; i++) {
    int countDiv = 0;
    while (x % i == 0) {
      countDiv++;
      x /= i;
    }
    ans *= countDiv + 1;
  }
  return ans;
}

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

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<long long int> fac(n + 1, 0);
  int i = 1;
  while (i <= n) {
    int j = 1;
    while (i * j <= n) {
      fac[i * j]++;
      j++;
    }
    i++;
  }
  i = 1;
  long long int sum = 0;
  while (i <= n) {
    sum = sum + fac[i] * i;
    i++;
  }
  cout << sum;
  return 0;
}

Error: TLE

Fixed submission:


/*Bismillahir Rahmanir Rahim*/

#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#define ll long long int
#define dd double
using namespace std;

int main() {
  ll b, c, i, s = 0, ans = 0, r, j;
  cin >> b;
  for (i = 1; i <= b; i++) {
    ll s1 = 0;
    for (j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        if (i / j == j)
          s1++;
        else {
          s1 += 2;
        }
      }
    }
    ans += (s1 * i);
  }
  cout << ans << endl;
}
// Apna Time Aayega :)
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long int n;
  cin >> n;
  long long int i, s = 0, j;
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j = j + i) {
      s = s + j;
    }
  }
  cout << s << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long int factor(long long int n) {
  long long int i, c = 0;
  for (i = 1; i <= n; i++) {
    if (n % i == 0)
      c++;
  }
  return c;
}
int main() {
  long long int n;
  cin >> n;
  long long int i, s = 0;
  for (i = 1; i <= n; i++) {
    s = s + i * factor(i);
  }
  cout << s << endl;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

// N以下の1の倍数の個数 = N以下のすべての数の約数のうち1が入っているもの
// を1~Nまでやって数を数え、足していく
#include <bits/stdc++.h>

int main() {
  int N;
  std::cin >> N;

  std::vector<long long> yakusu(N + 1);
  // 1~Nについて
  for (int i = 1; i <= N; i++) {
    // iを約数として持っている数に正の字をつけていく
    // 最低i, 最高N, iが1つ約数であれば公差iの等差数列になる
    for (int j = i; j <= N; j += i) {
      yakusu[j]++;
    }
  }

  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += i * yakusu[i];
  }

  std::cout << ans << std::endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

long long Get_Yakusu(int in) {
  long long ret = 0;

  for (int i = 1; i <= in; i++) {
    if (in % i == 0)
      ret++;
  }

  return ret;
}

long long Get_Yakusu2(int in) {
  long long ret = 0;

  for (int i = 1; i <= in; i++) {
    if (in % i == 0)
      ret++;
  }

  return ret;
}

int main() {
  int n;
  std::cin >> n;

  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long yakusu_num = Get_Yakusu(i);

    ans += (i * yakusu_num);
  }

  std::cout << ans << std::endl;

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

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
using P = pair<int, int>;
using ll = long long;
const int MOD = 1e9 + 7;
int main() {
  ll n;
  cin >> n;
  ll ret = 0;
  for (ll i = 1; i <= n; i++) {
    ret += n / i * (i + n / i * i) / 2;
  }
  cout << ret << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
using P = pair<int, int>;
using ll = long long;
const int MOD = 1e9 + 7;
int main() {
  vector<int> prime;
  for (int i = 2; i < sqrt(1e7); i++) {
    bool p = true;
    for (int j = 0; j < prime.size(); j++) {
      if (prime[j] > sqrt(i))
        break;
      if (i % prime[j] == 0) {
        p = false;
        break;
      }
    }
    if (p) {
      prime.emplace_back(i);
    }
  }
  int n;
  cin >> n;
  ll ret = 0;
  for (int i = 1; i <= n; i++) {
    if (i == 1)
      ret++;
    else {
      int a = i;
      int cnt = 0;
      ll s = 1;
      for (int j = 0; j < prime.size(); j++) {
        if (sqrt(i) < prime[j])
          break;
        if (a % prime[j] == 0) {
          cnt++;
          a /= prime[j];
          j--;
        } else {
          s *= cnt + 1;
          cnt = 0;
        }
      }
      s *= cnt + 1;
      cnt = 0;
      if (a > 1)
        s *= 2;
      ret += s * i;
    }
  }
  cout << ret << endl;
}
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 REP(i, b, n) for (int i = b; i < (b) + (n); i++)
using namespace std;
using ll = long long;

ll f(ll n) { return n * (n + 1) / 2; }

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  REP(i, 1, n) { ans += i * f(n / 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++)
using namespace std;

int isPrime(int num) {
  if (num <= 1)
    return 0;
  for (int i = 2; i < num; i++) {
    if (num % i == 0)
      return 0;
  }
  return 1;
}

int divisor_cnt(int num) {
  int divisor = 1;
  int tmp = num;
  if (isPrime(num))
    return 2;
  for (int i = 2; i < num; i++) {
    int cnt = 0;
    if (isPrime(i)) {
      while (tmp % i == 0) {
        tmp /= i;
        cnt++;
      }
      divisor *= cnt + 1;
    }
  }
  return divisor;
}

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

#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;

int main() {

  int n;
  cin >> n;
  vector<int> ans((n + 1), 1);
  vector<bool> prime((n + 1), true);

  for (int i = 2; i <= n; i++) {

    if (prime[i] == true) {
      for (int j = 2 * i; j <= n; j += i) {

        ll cnt = 0;
        ll temp = j;
        while (temp % i == 0) {
          cnt++;
          temp = temp / i;
        }

        ans[j] *= (cnt + 1);
        prime[j] = false;
      }
      ans[i] = 2;
    }
  }

  ll fn = 0;
  for (int i = 1; i <= n; i++) {
    fn += (ll)i * ans[i];
  }

  cout << fn << "\\n";
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;

int main() {
  int n;
  cin >> n;
  map<int, int> m;
  ll total = 0;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j * i <= n; j++) {
      m[i * j]++;
    }
    total += (i * (ll)m[i]);
  }
  cout << total << "\\n";

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

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

int main() {
  int64_t N;
  cin >> N;
  int64_t ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j += i) {
      ans += j;
    }
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int64_t N;
  cin >> N;
  int64_t ans = 0;
  for (int i = 1; i <= N; i++) {
    int64_t f = 0;
    for (int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        if (i / j == j) {
          f++;
        } else {
          f += 2;
        }
      }
    }
    ans += (f * i);
  }
  cout << ans << endl;
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll f[10000002];

int main() {

  ll n;
  cin >> n;
  for (int i = 1; i < 10000002; ++i) {
    for (int j = i; j < 10000002; j += i) {
      ++f[j];
    }
  }

  ll ans = 0;
  for (ll i = 1; i <= n; ++i) {
    ans += (i * f[i]);
  }
  cout << ans;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {

  ll n;
  cin >> n;
  vector<ll> v;
  for (ll i = 1; i <= n; ++i) {
    ll tmp = 0;
    for (ll j = 1; j <= sqrt(i); ++j) {
      if (i % j == 0) {
        if (i / j == j) {
          tmp++;
        } else {
          tmp += 2;
        }
      }
    }
    v.push_back(tmp);
  }
  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    ans += ((i + 1) * v[i]);
  }
  cout << ans;
  return 0;
}
Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll N = 1e7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<ll> prime(N + 1, 1), d(N + 1, 0);
  ll i, j, k, ans = 0;
  for (i = 2; i * i <= N; i++) {

    for (j = i * i; j <= N; j += i) {
      prime[j]++;
      if (j == i * i)
        d[j] = 1;
    }
  }
  ans = 1;
  for (i = 2; i <= n; i++) {
    if (d[i] == 1) {
      ans += (i * (2 * prime[i] - 1));
      // cout<<(2*prime[i]-1)<<" ";
    } else {
      ans += (i * 2 * (prime[i]));
      // cout<<(2*prime[i])<<" ";
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  ll i, j, k, ans = 0;
  for (i = 1; i <= n; i++) {
    ll p = 0;
    for (j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        if (i / j == j)
          p++;
        else
          p += 2;
      }
    }
    ans += i * p;
  }
  cout << ans << endl;
}
Problem p02624 (C++) — buggy submission, verdict: Runtime Error

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

ll no[10000005];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //    ll x;
  //    x=1ll << 59;
  //    ll y=(1ll << 59) - 1ll;
  //    cout<<((double)(x)==(double)(x-1))<<endl;
  ll n;
  cin >> n;
  no[1] = 1;
  for (int i = 2; i <= n; i++) {
    no[i]++;
    for (int j = i; j <= n; j += i)
      no[j]++;
  }
  ll s = 0;
  for (int i = 1; i <= n; i++)
    s += (ll)(i * no[i]);
  cout << s;
}


Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll no[10000005];
vector<int> prime(10000005, 0);
// vector<int>prime1(1000001,0);
vector<int> mark(10000005, 0);
int nprime;

void sieve(int n) /// FINDING PRIME
{
  int limit = sqrt(n * 1.0) + 1, s = 0;
  nprime = 0;
  mark[1] = 1; /// 1 if not prime.
  mark[2] = 0;
  prime[nprime++] = 2; // cout<<2<<endl;
  // for(int i=4;i<=n;i+=2)mark[i]=1;
  for (int i = 3; i <= n; i += 2) {
    if (!mark[i]) {
      prime[nprime++] = i; // cout<<i<<endl;
      if (i <= limit) { /// karon limit er upor theke n porjonto not prime gula
                        /// already cuta hoise.
        for (int j = i * i; j <= n; j += i * 2) {
          mark[j] = 1;
        }
      }
    }
  }
}

ll nod(ll n) /// Number of divisors
{
  ll listi[1001], listsize = 0, x5 = 0, nod = 1, x3 = 1;
  ll sqrtN = sqrt(n) + 1;
  for (int i = 0; prime[i] <= sqrtN && i < nprime; i++) {
    if (n % prime[i] == 0) { // x4++;if(x4>1)return 1;
      while (n % prime[i] == 0) {
        n /= prime[i];
        // listi[listsize++]=prime[i];
        x3++; // cout<<prime[i]<<" "<<i<<endl;
      }
      nod *= x3;
      x3 = 1;
    } // cout<<prime[i]<<" "<<i<<endl;
  }
  if (n > 1)
    nod *= 2;

  return nod;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //    ll x;
  //    x=1ll << 59;
  //    ll y=(1ll << 59) - 1ll;
  //    cout<<((double)(x)==(double)(x-1))<<endl;
  sieve(10000000);
  for (int i = 0; i < nprime; i++) {
    no[prime[i]] = 2;
    ll b = 2;
    for (ll j = prime[i] * prime[i]; j <= 10000000; j *= prime[i])
      no[j] = (++b);
  }
  ll n;
  cin >> n;
  ll hishab = 0;
  for (int i = 1; i <= n; i++) {
    ll a;
    if (no[i] == 0)
      a = (ll)(i * nod(i));
    else
      a = (ll)(i * no[i]);
    hishab += a;
  }
  cout << hishab;
}
Problem p02624 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <stdlib.h>
#include <string>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

ll num[10000100];

int main() {
  rep(i, 10000100) num[i] = 1;
  ll N;
  cin >> N;
  for (ll i = 2; i <= N; i++) {
    for (ll j = 1; i * j <= N; j++) {
      num[i * j] += 1;
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    ans += i * num[i];
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <stdlib.h>
#include <string>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

vector<ll> prime;        // i番目の素数
bool is_prime[10000100]; // is_prime[i] がTrueならiは素数

void sieve(ll n) {
  for (ll i = 0; i <= n; i++)
    is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (ll i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime.push_back(i);
      for (ll j = 2 * i; j <= n; j += i)
        is_prime[j] = false;
    }
  }
}

ll N;
vector<vector<P>> factorize(N + 1);

ll factorization(ll n) {
  ll num = 1;
  ll i = 0;
  ll temp = n;
  while (prime[i] * prime[i] <= n) {
    ll index = 1;
    while (temp % prime[i] == 0) {
      index++;
      temp /= prime[i];
    }
    i++;
    num *= index;
  }
  if (temp != 1) {
    num *= 2;
  }
  return num;
}

int main() {
  cin >> N;
  sieve(N);
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    ans += i * factorization(i);
  }
  cout << ans << endl;
}
Problem p02624 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int f[10000009];
int main() {
  for (int i = 1; i <= 10000007; i++) {
    for (int j = i; j <= 10000007; j = j + i) {
      f[j]++;
    }
  }
  int a;
  cin >> a;
  long long ans = 0;
  for (int i = 1; i <= a; i++) {
    ans = ans + i * f[i];
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int f[1000009];
int main() {
  for (int i = 1; i <= 1000008; i++) {
    for (int j = i; j <= 1000008; j = j + i) {
      f[j]++;
    }
  }
  int a;
  cin >> a;
  long long ans = 0;
  for (int i = 1; i <= a; i++) {
    ans = ans + i * f[i];
  }
  cout << ans << endl;
}