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

#include <iostream>
#include <vector>
using namespace std;
vector<pair<long long, long long>> pre(long long n) {
  vector<pair<long long, long long>> res;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    int num = 0;
    while (n % i == 0) {
      num++;
      n /= i;
    }
    res.push_back(make_pair(i, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  long long n;
  cin >> n;
  const auto pf = pre(n);
  long long ans = 0;
  for (auto p : pf) {
    long long e = p.second;
    long long tmp = 0, cur = 1;
    while (e >= cur)
      e -= cur++, ++tmp;
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
vector<pair<long long, long long>> pre(long long n) {
  vector<pair<long long, long long>> res;
  for (int i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    int num = 0;
    while (n % i == 0) {
      num++;
      n /= i;
    }
    res.push_back(make_pair(i, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  long long n;
  cin >> n;
  const auto pf = pre(n);
  long long ans = 0;
  for (auto p : pf) {
    long long e = p.second;
    long long tmp = 0, cur = 1;
    while (e >= cur)
      e -= cur++, ++tmp;
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll, ll>;
bool operator<(const ipair a, const ipair b) { return a.first < b.first; };
#define rep(i, n) for (int i = 0; i < (n); ++i)
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; }
bool isprime(ll l) {
  if (l == 1)
    return false;
  for (ll i = 2; i * i <= l; i++) {
    if (l % i == 0)
      return false;
  }
  return true;
}

int main() {

  ll n;
  cin >> n;
  ll cp = n;
  ll ans = 0, l = 2;
  if (isprime(n)) {
    cout << 1 << endl;
    return 0;
  }
  while (n >= l) {
    if (n % l != 0) {
      l++;
      continue;
    } else {
      ll c = 0;
      while (n % l == 0) {
        c++;
        n /= l;
      }
      ll a;
      for (ll i = 1; i <= c; i++) {
        if (i * (i + 1) <= 2 * c && 2 * c < (i + 1) * (i + 2)) {
          a = i;
          break;
        }
      }
      ans += a;
    }
    if (n == 1)
      break;
    if (isprime(n)) {
      ans++;
      break;
    }
    l++;
  }
  cout << ans;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll, ll>;
bool operator<(const ipair a, const ipair b) { return a.first < b.first; };
#define rep(i, n) for (int i = 0; i < (n); ++i)
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; }
bool isprime(int l) {
  for (int i = 2; i * i <= l; i++) {
    if (l % i == 0)
      return false;
  }
  return true;
}

int main() {

  ll n;
  cin >> n;
  ll cp = n;
  int ans = 0, l = 2;
  while (n >= l) {
    if (n % l != 0) {
      l++;
      continue;
    } else {
      if (isprime(l)) {
        int c = 1;
        while (n >= (int)pow(l, c)) {
          if (n % (int)pow(l, c) == 0) {
            n /= (int)pow(l, c);
            ans++;
            c++;
          } else
            break;
        }
      }
      l++;
    }
  }

  cout << ans;

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

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

vector<pair<long long, long long>> a(long long n) {
  vector<pair<long long, long long>> res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0) {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  long long N;
  cin >> N;
  long long res = 0;
  auto pairs = a(N);

  for (auto p : pairs) {
    long long e = p.second;
    long long tmp = 0, cnt = 1;
    while (e >= cnt) {
      e -= cnt;
      cnt++;
      tmp++;
    }
    res += tmp;
  }
  cout << res << '\\n';
  return 0;
}

Error: TLE

Fixed submission:

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

vector<pair<long long, long long>> a(long long N) {
  vector<pair<long long, long long>> pairs;
  for (int i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;

    long long exp = 0;
    while (N % i == 0) {
      N /= i;
      exp++;
    }
    pairs.push_back({N, exp});
  }

  if (N != 1)
    pairs.push_back({N, 1});
  return pairs;
}

int main() {
  long long N;
  cin >> N;
  long long res = 0;
  auto pairs = a(N);

  for (auto p : pairs) {
    long long e = p.second;
    long long tmp = 0, cnt = 1;
    while (e >= cnt) {
      e -= cnt;
      cnt++;
      tmp++;
    }
    res += tmp;
  }
  cout << res << '\\n';
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll max1 = 2000000;
ll pri[200000];
ll vis[2000000] = {0};

bool isprime(ll n) {
  if (n == 1)
    return false;
  for (ll i = 2; i <= sqrt(n + 0.5); i++)
    if (n % i == 0)
      return false;
  return true;
}

int main() {
  vis[1] = 1;
  for (int i = 2; i <= sqrt(max1 + 0.5); i++)
    for (int k = i * i; k <= max1; k += i)
      if (!vis[k])
        vis[k] = 1;
  int cnt = 0;
  for (int i = 2; i <= max1; i++)
    if (!vis[i])
      pri[cnt++] = i;
  ll n;
  cin >> n;
  map<ll, int> ans;
  for (int i = 0; i < 148933 && n >= pri[i]; i++) {
    int flag = 0;
    int cnt = 0;
    while (n % pri[i] == 0) {
      n /= pri[i];
      cnt++;
      flag = 1;
    }
    if (flag)
      ans[pri[i]] = cnt;
  }
  if (isprime(n))
    ans[n] = 1;
  cnt = 0;
  for (map<ll, int>::iterator it = ans.begin(); it != ans.end(); it++) {
    // cout << it->first << "  " << it->second << endl;
    int i;
    for (i = 1; 1; i++) {
      if (it->second < i * (i + 1) / 2) {
        cnt += i - 1;
        break;
      }
    }
  }
  cout << cnt;

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll max1 = 2000000;
ll pri[100000];
ll vis[2000000] = {0};

bool isprime(int n) {
  if (n == 1)
    return false;
  for (int i = 2; i <= sqrt(n + 0.5); i++)
    if (n % i == 0)
      return false;
  return true;
}

int main() {
  vis[1] = 1;
  for (int i = 2; i <= sqrt(max1 + 0.5); i++)
    for (int k = i * i; k <= max1; k += i)
      if (!vis[k])
        vis[k] = 1;
  int cnt = 0;
  for (int i = 2; i <= max1; i++)
    if (!vis[i])
      pri[cnt++] = i;
  ll n;
  cin >> n;
  map<ll, int> ans;
  for (int i = 0; i < 148933 && n >= pri[i]; i++) {
    int flag = 0;
    int cnt = 0;
    while (n % pri[i] == 0) {
      n /= pri[i];
      cnt++;
      flag = 1;
    }
    if (flag)
      ans[pri[i]] = cnt;
  }
  if (isprime(n))
    ans[n] = 1;
  cnt = 0;
  for (map<ll, int>::iterator it = ans.begin(); it != ans.end(); it++) {
    // cout << it->first << "  " << it->second << endl;
    int i;
    for (i = 1; 1; i++) {
      if (it->second < i * (i + 1) / 2) {
        cnt += i - 1;
        break;
      }
    }
  }
  cout << cnt;

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

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

ll o = 0;
set<ll> op;
bool isPrime(ll n) {
  // Corner case
  if (n == 2) {
    return true;
  } else if (n <= 1 || n % 2 == 0)
    return false;

  for (ll i = 3; i <= sqrt(n); i += 2)
    if (n % i == 0)
      return false;

  return true;
}

void tbaben(ll i) {
  // int j=floor(sqrt(i));
  if (isPrime(i)) {
    if (!op.count(i)) {
      o++;
    }
    return;
  }
  for (ll k = 2; k <= i; k++) {
    if (i % k == 0 && !op.count(k)) {
      if (isPrime(k)) {
        o++;
        op.insert(k);
        tbaben(i / k);
        return;
      } else {
        for (ll d = 2; d <= sqrt(k); d++) {
          ll oi = d * d;
          while (oi <= k) {
            if (oi == k && isPrime(d)) {
              o++;
              op.insert(k);
              tbaben(i / k);
              return;
            }
            oi *= d;
          }
        }
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll t;
  cin >> t;
  tbaben(t);
  cout << o << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

ll o = 0;
set<int> op;
bool isPrime(int n) {
  // Corner case
  if (n <= 1)
    return false;

  // Check from 2 to n-1
  for (int i = 2; i < n; i++)
    if (n % i == 0)
      return false;

  return true;
}

void tbaben(int i) {
  // int j=floor(sqrt(i));
  for (int k = 2; k <= i; k++) {
    if (!op.count(k) && i % k == 0) {
      if (isPrime(k)) {
        o++;
        op.insert(k);
        tbaben(i / k);
        return;
      } else {
        bool os = false;
        for (int d = 2; d <= sqrt(k); d++) {
          int oi = d * d;
          while (oi <= k) {
            if (oi == k) {
              os = true;
              break;
            }
            oi *= d;
          }
          if (os) {
            break;
          }
        }
        if (os) {
          o++;
          op.insert(k);
          tbaben(i / k);
          return;
        }
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  tbaben(t);
  cout << o << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

void solve(long long N) {
  vector<pair<ll, ll>> res;
  for (ll i = 2; i <= N / i; i++) {
    ll b = 0;
    while (N % i == 0) {
      N /= i;
      b++;
    }
    res.emplace_back(i, b);
  }
  if (N != 1)
    res.emplace_back(N, 1);

  ll ans = 0;
  for (auto s : res) {
    ll p = s.second;
    ll b = 1;
    while (b <= p) {
      p -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
}

// void solve(long long N){
//     vector<pair<ll,int>> fs;
//     for(ll i = 2; i*i <= N; i++){
//         int x = 0;
//         while(N%i == 0){
//             N/=i;
//             ++x;
//         }
//         fs.emplace_back(i,x);
//     }
//     if(N != 1) fs.emplace_back(N,1);

//     int ans = 0;
//     for(auto p : fs) {
//         int x = p.second;
//         int b = 1;
//         while(b <= x){
//             x -= b;
//             b++;
//             ++ans;
//         }
//     }
//     cout << ans << endl;
// }

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Error: TLE

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

void solve(long long N) {
  vector<pair<ll, ll>> res;
  for (int i = 2; i * i < N; i++) {
    ll b = 0;
    while (N % i == 0) {
      N /= i;
      b++;
    }
    res.emplace_back(i, b);
  }
  if (N != 1)
    res.emplace_back(N, 1);

  ll ans = 0;
  for (auto s : res) {
    ll p = s.second;
    ll b = 1;
    while (b <= p) {
      p -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
}

// void solve(long long N){
//     vector<pair<ll,int>> fs;
//     for(ll i = 2; i*i <= N; i++){
//         int x = 0;
//         while(N%i == 0){
//             N/=i;
//             ++x;
//         }
//         fs.emplace_back(i,x);
//     }
//     if(N != 1) fs.emplace_back(N,1);

//     int ans = 0;
//     for(auto p : fs) {
//         int x = p.second;
//         int b = 1;
//         while(b <= x){
//             x -= b;
//             b++;
//             ++ans;
//         }
//     }
//     cout << ans << endl;
// }

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define P_B push_back
#define E_B emplace_back
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i])
        continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j])
          f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x; }
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0)
      return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll, int>> factor(ll x) {
    vector<pair<ll, int>> res;
    for (int p : primes) {
      int y = 0;
      while (x % p == 0)
        x /= p, ++y;
      if (y != 0)
        res.emplace_back(p, y);
    }
    if (x != 1)
      res.emplace_back(x, 1);
    return res;
  }
};

int main() {
  string S;
  ll N, n, A, B, ans = 0;

  cin >> N;

  Sieve s(1000005);

  auto fs = s.factor(N);

  rep(i, fs.size()) {
    int count = 1;
    while (fs[i].se >= count) {
      fs[i].se -= count;
      count++;
    }
    ans += count - 1;
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using namespace std;

int main() {
  string S;
  ll N, n, A, B, ans = 0;
  long double z;
  bool cn;
  vector<ll> p, q;

  cin >> N;
  z = sqrt(N);
  n = z / 1;

  p.push_back(2);

  for (ll i = 3; i <= n; i++) {
    cn = false;
    for (ll j = 0; j < p.size(); j++) {
      if (i % p[j] == 0) {
        cn = true;
        break;
      }
    }
    if (cn)
      continue;
    p.push_back(i);
  }

  rep(i, p.size()) {
    int count = 0;
    while (true) {
      if (N % p[i] == 0) {
        count++;
        N /= p[i];
      } else {
        break;
      }
    }
    q.push_back(count);
  }

  rep(i, q.size()) {
    int count = 0;
    while (q[i] > 0) {
      q[i] -= (count + 1);
      if (q[i] < 0)
        break;
      count++;
    }
    ans += count;
  }

  if (N != 1)
    ans += 1;
  cout << ans << endl;

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

#include <chrono>

template <typename T> inline bool is_prime(T n) {
  if (n <= 1) {
    return false;
  }

  if (n == 2) {
    return true;
  }

  if (n % 2 == 0) {
    return false;
  }

  for (T i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

template <typename T> inline auto compute_z_list(T n) {
  std::vector<T> vec;
  for (T i = 2; i * i <= n; i++) {
    if (n % i != 0 || !is_prime(i)) {
      continue;
    }

    auto elem = i;
    while (n % i == 0) {
      vec.push_back(elem);

      if (is_prime(n / elem)) {
        vec.push_back(n / elem);
      }

      n /= i;
      elem *= i;
    }
  }

  return vec;
}

template <typename T> inline size_t func(T num) {
  static const auto z_list = compute_z_list(num);

  static std::vector<T> vec;
  if (num == 1)
    return vec.size();

  for (auto z : z_list) {
    if (num % z != 0) {
      continue;
    }

    if (std::find(vec.cbegin(), vec.cend(), z) == vec.cend()) {
      vec.push_back(z);
      return func(num / z);
    }
  }

  return vec.size(); // not reached
}

int main() {
  unsigned long long num;
  std::cin >> num;

  if (is_prime(num)) {
    std::cout << 1 << std::endl;
    return 0;
  }

  std::cout << func(num) << std::endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

#include <chrono>

template <typename T> inline bool is_prime(T n) {
  if (n <= 1) {
    return false;
  }

  if (n == 2) {
    return true;
  }

  if (n % 2 == 0) {
    return false;
  }

  const auto iter_num = static_cast<T>(std::sqrt(n));
  for (T i = 3; i <= iter_num; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

template <typename T> inline auto compute_z_list(T n) {
  std::vector<T> vec;
  for (T i = 2; i <= n; i++) {
    if (is_prime(n)) {
      vec.push_back(n);
      break;
    }

    if (n % i != 0 || !is_prime(i)) {
      continue;
    }

    auto elem = i;
    while (n % i == 0) {
      n /= i;
      vec.push_back(elem);
      elem *= i;
    }
  }
  return vec;
}

template <typename T> inline size_t func(T num) {
  static const auto z_list = compute_z_list(num);

  static std::vector<T> vec;
  if (num == 1)
    return vec.size();

  for (auto z : z_list) {
    if (num % z != 0) {
      continue;
    }

    if (std::find(vec.cbegin(), vec.cend(), z) == vec.cend()) {
      vec.push_back(z);
      return func(num / z);
    }
  }

  return vec.size(); // not reached
}

int main() {
  unsigned long long num;
  std::cin >> num;

  if (is_prime(num)) {
    std::cout << 1 << std::endl;
    return 0;
  }

  std::cout << func(num) << std::endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i, l, r) for (i = l; i < r; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define P pair<ll, ll>
#define F first
#define S second
signed main() {
  ll N, M, ans = 0, p = 2;
  cin >> N;
  M = N;
  while (M > p * p) {
    while (N % p != 0 && M > p * p)
      p++;
    if (N % p == 0) {
      ll e = 0, n = 0;
      while (N % p == 0) {
        e++;
        N /= p;
      }
      while ((n + 1) * (n + 2) <= 2 * e)
        n++;
      ans += n;
    }
  }
  for (p = 2; p * p <= N; p++)
    if (N % p == 0)
      break;
  if (p * p > N && N != 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i, l, r) for (i = l; i < r; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define P pair<ll, ll>
#define F first
#define S second
signed main() {
  ll N, i, ans = 0, p = 1;
  cin >> N;
  while (N > p * p) {
    while (N % p != 0 && N > p * p)
      p++;
    if (N % p == 0) {
      ll e = 0;
      while (N % p == 0) {
        e++;
        N /= p;
      }
      ans += (-1 + sqrt(8 * e + 1)) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int main(int argc, const char *argv[]) {
  ios_base::sync_with_stdio(false);
  ll N;
  cin >> N;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }

  map<ll, int> Map;
  for (ll n = 2; n * n <= N; ++n) {
    while (N % n == 0) {
      Map[n]++;
      N /= n;
    }
  }
  if (N != 1) {
    Map[N] = 1;
  }

  vector<int> Sum(11);
  for (int i = 1; i <= 10; ++i) {
    Sum[i] = Sum[i - 1] + i;
  }
  int Ans = 0;
  for (auto &z : Map) {
    int k = z.second;
    for (int i = 1; i <= 10; ++i) {
      if (k < Sum[i]) {
        Ans += i - 1;
        break;
      }
    }
  }
  cout << Ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int main(int argc, const char *argv[]) {
  ios_base::sync_with_stdio(false);
  ll N;
  cin >> N;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }

  map<ll, int> Map;
  for (int n = 2; n * n <= N; ++n) {
    while (N % n == 0) {
      Map[n]++;
      N /= n;
    }
  }
  if (N != 1) {
    Map[N] = 1;
  }

  vector<int> Sum(11);
  for (int i = 1; i <= 10; ++i) {
    Sum[i] = Sum[i - 1] + i;
  }
  int Ans = 0;
  for (auto &z : Map) {
    int k = z.second;
    for (int i = 1; i <= 10; ++i) {
      if (k < Sum[i]) {
        Ans += i - 1;
        break;
      }
    }
  }
  cout << Ans << endl;

  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

bool ar[N];
vector<int> prime;

void sieve() {
  fill_n(ar, N, 1);
  ar[0] = ar[1] = 0;
  for (int i = 4; i < N; i += 2)
    ar[i] = 0;
  for (int i = 3; i * i < N; i += 2) {
    if (not ar[i])
      continue;
    for (int j = i * i; j < N; j += i)
      ar[j] = 0;
  }
  prime.push_back(2);
  for (int i = 3; i < N; i += 2) {
    if (ar[i])
      prime.push_back(i);
  }
}

int main() {
  sieve();

  ll n;
  scanf("%lld", &n);

  auto tmp = n;
  int indx = 0;
  map<ll, int> factor;
  while (tmp != 1) {
    if ((ll)prime[indx] * prime[indx] > tmp)
      break;
    while (tmp % prime[indx] == 0) {
      tmp = tmp / prime[indx];
      factor[prime[indx]]++;
    }
    indx++;
  }
  if (tmp != 1)
    factor[tmp] = 1;
  int cnt = 0;
  for (auto p : factor) {
    for (int i = 1;; ++i) {
      if ((i * (i + 1)) / 2 > p.second) {
        cnt += i - 1;
        break;
      }
    }
  }
  printf("%d\\n", cnt);
}

Error: 0

Fixed submission:

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

vector<long long int> primes;
bool isprime[2000009];
int ndiv[2000009];

void div() {
  long long int sum = 0;
  for (int i = 1; sum <= 1000000; i++) {
    sum += i;
    ndiv[sum] = i;
  }
  int c = 1;
  for (int i = 1; i <= 1000000; i++) {
    if (ndiv[i] == 0)
      ndiv[i] = c;
    else
      c = ndiv[i];
  }
}
void sieve() {
  for (int i = 3; i <= 1000005; i += 2) {
    if (isprime[i] == 0) {
      for (int j = i * 2; j <= 1000005; j += i)
        isprime[j] = 1;
    }
  }
  primes.push_back(2);
  for (int i = 3; i <= 1000005; i += 2)
    if (isprime[i] == 0)
      primes.push_back(i);
}

int main() {
  sieve();
  div();
  long long num, n;
  map<long long int, long long int> mp;
  vector<long long int> st;
  while (cin >> num) {
    n = num;
    for (int i = 0; i <= sqrt(num); i++) {
      if (num % primes[i] == 0) {
        st.push_back(primes[i]);
        while (num % primes[i] == 0) {
          mp[primes[i]]++;
          num /= primes[i];
        }
      }
    }
    if (num > 1) {
      st.push_back(num);
      mp[num]++;
    }
    int sum = 0;
    for (int i = 0; i < st.size(); i++) {
      /// cout<<st[i]<<"   "<<mp[st[i]]<<endl;

      sum += ndiv[mp[st[i]]];
    }
    cout << sum << endl;
    mp.clear();
    st.clear();
  }

  return 0;
}