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

#include <iostream>
#include <map>
#include <vector>

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

using namespace std;
using ll = long long;

map<ll, ll> prime_factor(ll);

int main() {
  ll N, ans = 0;
  cin >> N;

  map<ll, ll> m = prime_factor(N);
  for (auto p : m) {
    int n = 1;
    while (p.second >= (n + 1) * (n + 2) / 2) {
      n++;
    }
    ans += n;
  }
  cout << ans << endl;

  return 0;
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <map>
#include <vector>

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

using namespace std;
using ll = long long;

map<int, int> prime_factor(ll);

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

  ll ans = 0;
  for (auto m : prime_factor(N)) {
    int flag = 1, n = 1;
    while (flag) {
      if (n * (n + 1) / 2 <= m.second && m.second < (n + 1) * (n + 2) / 2) {
        ans += n;
        flag = 0;
      }
      n++;
    }
  }

  cout << ans << endl;

  return 0;
}

map<int, int> prime_factor(ll n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  long long int n;
  cin >> n;
  vector<int> ss(1, 0);

  for (long long int i = 2; i * i <= n; ++i) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      ++x;
    }
    ss.push_back(x);
  }
  if (n != 1)
    ss.push_back(1);

  int ans = 0;

  for (int i = 0; i < ss.size(); ++i) {
    int j = 1;
    //        cout << ss[i] << endl;
    while (j <= ss[i]) {
      ss[i] -= j;
      ++ans;
      ++j;
    }
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

int main(void) {
  long long int N;
  cin >> N;
  vector<int> ss(1, 0);

  // 割る数の初期値24
  int a = 2;
  int last_a = 2;
  int t = 0;
  // √n ≧ a ( n ≧ a * a ) の間ループ処理
  while (N >= a * a) {
    // a で割り切れたら、a は素因数
    // そして、割られる数を a で割る
    // a で割り切れなかったら、 a を 1 増加させる
    if (N % a == 0) {
      if (a != last_a) {
        ++t;
        ss.push_back(0);
      }
      ++ss[t];
      N /= a;
      last_a = a;
    } else {
      ++a;
    }
  }
  if (N != 1 && N != last_a) {
    ++t;
    ss.push_back(0);
    ++ss[t];
  } else if (N == last_a) {
    ++ss[t];
  }

  int ans = 0;

  for (int i = 0; i < ss.size(); ++i) {
    int j = 1;
    //        cout << ss[i] << endl;
    while (1) {
      ss[i] -= j;
      if (ss[i] < 0)
        break;
      ++ans;
      ++j;
    }
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, j) for (ll i = (j); i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)
#define ssort(n) sort((n).begin(), (n).end())
using ll = long long;
using ld = long double;
typedef pair<int, int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main() {
  ll n;
  cin >> n;
  int t;
  ll n_tmp = n;
  int count;
  int j;
  ll ans = 0;
  FOR(i, sqrtl(n) + 1, 2) {
    count = 0;
    while (n_tmp % i == 0) {
      n_tmp /= i;
      count++;
    }
    j = 1;
    while (count >= j) {
      count -= j;
      j++;
      ans++;
    }
  }
  if (n_tmp == n && n != 1) {
    ans = 1;
    cout << ans << endl;
    return 0;
  } else if (n == 1) {
    ans = 0;
    cout << ans << endl;
    return 0;
  }
  n = n_tmp;
  FOR(i, sqrtl(n) + 1, 2) {
    while (n_tmp % i == 0) {
      n_tmp /= i;
    }
  }
  if (n == n_tmp && n != 1) {
    ans++;
  }
  cout << ans << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, j) for (int i = (j); i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)
#define ssort(n) sort((n).begin(), (n).end())
using ll = long long;
using ld = long double;
typedef pair<int, int> P;

int findFactors(int num) {
  int i;

  while (num % 2 == 0) { // 偶数の素数は2のみ

    num /= 2;
  }
  for (i = 3; i <= num; i++) { // 他の素数で割っていく
    while (num % i == 0) {
      num /= i;
    }
  }
  return 0;
}

int main() {
  ll N;
  cin >> N;
  map<ll, int> num_count;
  queue<ll> num_list;
  int n_ = N;
  while (N % 2 == 0) { // 偶数の素数は2のみ
    if (!num_count.count(2)) {
      num_list.push(2);
      num_count[2] = 1;
    }
    num_count[2]++;
    N /= 2;
  }
  for (int i = 3; i <= sqrt(N); i += 2) { // 他の素数で割っていく
    while (N % i == 0) {
      if (!num_count.count(i)) {
        num_list.push(i);
        num_count[i] = 1;
      }
      num_count[i]++;
      N /= i;
    }
  }
  if (N % n_ == 0) {
    num_list.push(n_);
    num_count[n_] = 1;
  }

  ll ans = 0;
  while (!num_list.empty()) {

    int n_count;
    int num = num_list.front();
    n_count = num_count[num];

    num_list.pop();
    for (int i = 1; n_count >= i; ++i) {
      n_count -= i;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

vector<pair<ll, ll>> prime(ll n) {
  vector<pair<ll, ll>> mp;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i != 0)
      continue;

    ll ex = 0;
    while (n % i == 0) {
      ++ex;
      n /= i;
    }
    mp.push_back(make_pair(i, ex));
  }
  if (n != 1)
    mp.push_back(make_pair(n, 1));
  return mp;
}

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


Error: TLE

Fixed submission:

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

vector<pair<ll, ll>> prime(ll n) {
  vector<pair<ll, ll>> mp;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i != 0)
      continue;

    ll ex = 0;
    while (n % i == 0) {
      ++ex;
      n /= i;
    }
    mp.push_back(make_pair(i, ex));
  }
  if (n != 1)
    mp.push_back(make_pair(n, 1));
  return mp;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  prime(n);
  auto pf = prime(n);
  for (auto p : pf) {
    ll cal = p.second;
    ll tmp = 0;
    ll cur = 1;
    while (cal >= cur)
      cal -= cur++, ++tmp;
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int64_t n;
  cin >> n;
  int64_t p = n;
  int mod = 2;
  vector<int> A(int(sqrt(n) + 2), 0);
  int m = 0;
  int ans = 0;
  int counter = 1;
  for (int i = 2; i < int(sqrt(n) + 2); i++) {
    while (p % i == 0) {
      A[i]++;
      if (A[i] == counter) {
        A[i] -= counter;
        counter++;
        ans++;
      }
      p /= i;
    }
    counter = 1;
  }
  if (p != 1) {
    ans++;
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

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

int main() {
  int64_t n;
  cin >> n;
  int64_t p = n;
  int mod = 2;
  vector<int> A(int(sqrt(n)), 0);
  int m = 0;
  int ans = 0;
  while (p > 1) {

    if (p % mod == 0) {
      A[m]++;
      p /= mod;

    } else {
      mod++;
      m++;
    }
  }

  for (int i = 0; i < int(sqrt(n)); i++) {

    for (int j = 1; j < 20; j++) {

      if (A[i] >= j) {

        ans++;
        A[i] -= j;
      } else {
        break;
      }
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define vb vector<bool>
#define vvb vector<vb>
#define vstr vector<string>
#define pll pair<ll, ll>
#define pb pair<bool, bool>
#define vpll vector<pll>
#define vpb vector<pb>

using namespace std;

bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}
vpll calc(ll n) {
  vpll ans;

  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ans.push_back({i, 1});
      // ll x = n / i;
      n /= i;
      while (n % i == 0) {
        ans[ans.size() - 1].second++;
        n /= i;
      }
    }
  }
  /*
  if (ans.size() == 0)
  {
          ans.push_back({ n, 1 });
  }*/
  if (n != 1) {
    ans.push_back({n, 1});
  }
  return ans;
}

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << "0" << endl;
    return 0;
  }
  if (is_prime(n) == true) {
    cout << "1" << endl;
    return 0;
  }
  vpll primes = calc(n);
  /*
  cout << "primes: " << endl;
  for (ll i = 0; i < primes.size(); i++)
  {
          cout << primes[i].first << " ";
  }
  cout << endl;*/
  ll ans = 0;
  for (ll i = 0; i < primes.size(); i++) {
    for (ll j = 1; primes[i].second - j >= 0; j++) {
      ans++;
      primes[i].second -= j;
    }
  }
  cout << ans << endl;
  return 0;
}

/*
714530981539

*/


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define vb vector<bool>
#define vvb vector<vb>
#define vstr vector<string>
#define pll pair<ll, ll>
#define pb pair<bool, bool>
#define vpll vector<pll>
#define vpb vector<pb>

using namespace std;

bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}
vpll calc(ll n) {
  vpll ans;
  for (ll i = 2; i <= n; i++) {
    if (n % i == 0) {
      ans.push_back({i, 1});
      // ll x = n / i;
      n /= i;
      while (n % i == 0) {
        ans[ans.size() - 1].second++;
        n /= i;
      }
    }
  }
  /*
  if (ans.size() == 0)
  {
          ans.push_back({ n, 1 });
  }*/
  return ans;
}

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << "0" << endl;
    return 0;
  }
  if (is_prime(n) == true) {
    cout << "1" << endl;
    return 0;
  }
  vpll primes = calc(n);
  /*
  cout << "primes: " << endl;
  for (ll i = 0; i < primes.size(); i++)
  {
          cout << primes[i].first << " ";
  }
  cout << endl;*/
  ll ans = 0;
  for (ll i = 0; i < primes.size(); i++) {
    for (ll j = 1; primes[i].second - j >= 0; j++) {
      ans++;
      primes[i].second -= j;
    }
  }
  cout << ans << endl;
  return 0;
}

/*
714530981539

*/
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int table[1000];
int bisect_right(int x, int a[], int left, int right) {
  int mid;
  right++;
  while (left < right) {
    mid = (left + right) / 2;
    if (a[mid] <= x) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }
  return left;
}

int counter(int i) {
  if (i == 0) {
    return 0;
  }
  return bisect_right(i, table, 0, 999) - 1;
}

void solve(long long N, int *ans) {
  int cnt = 0;
  while (N % 2 == 0) {
    cnt++;
    N /= 2;
  }
  *ans += counter(cnt);
  long long now = 3;
  cnt = 0;
  while (now * now <= N) {
    while (N % now == 0) {
      cnt++;
      N /= now;
    }
    *ans += counter(cnt);
    cnt = 0;
    now += 2;
  }
  if (N != 1) {
    *ans += counter(1);
  }
}

int main(void) {
  long long N;
  scanf("%lld", &N);
  for (int i = 0; i < 1000; i++) {
    table[i] = i * (i + 1) / 2;
  }
  int ans = 0;
  solve(N, &ans);
  printf("%d\\n", ans);
  return 0;
}


Error: TLE

Fixed submission:

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int table[1000];
int bisect_right(int x, int a[], int left, int right) {
  int mid;
  right++;
  while (left < right) {
    mid = (left + right) / 2;
    if (a[mid] <= x) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }
  return left;
}

int counter(int i) {
  if (i == 0) {
    return 0;
  }

  return bisect_right(i, table, 0, 999) - 1;
}

void solve(long long N, int *ans) {
  int cnt = 0;
  while (N % 2 == 0) {
    cnt++;
    N /= 2;
  }
  *ans += counter(cnt);
  int now = 3;
  cnt = 0;
  while (now * now <= N) {
    while (N % now == 0) {
      cnt++;
      N /= now;
    }
    *ans += counter(cnt);
    cnt = 0;
    now += 2;
  }
  if (N != 1) {
    *ans += counter(1);
  }
}

int main(void) {
  long long N;
  scanf("%lld", &N);
  for (int i = 0; i < 1000; i++) {
    table[i] = i * (i + 1) / 2;
  }
  int ans = 0;
  solve(N, &ans);
  printf("%d\\n", ans);
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream &operator>>(istream &I, vector<T> &v) {
  for (T &e : v)
    I >> e;
  return I;
}
template <class T> ostream &operator<<(ostream &O, const vector<T> &v) {
  for (const T &e : v)
    O << e << ' ';
  return O;
}

void _main() {
  ll n;
  cin >> n;
  map<ll, int> pf;
  for (ll div = 2; div * div <= n; div++) {
    while (n % div == 0) {
      pf[div]++;
      n /= div;
    }
  }

  if (n > 1)
    pf[n]++;

  int ans = 0;
  for (auto &it : pf) {
    int i = 1;
    while (it.second - i >= 0) {
      ans++;
      it.second -= i++;
    }
  }

  cout << ans;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //        freopen("input.txt", "r", stdin);
  int _t = 1;
  //        cin >> _t;
  while (_t--)
    _main();
  return 0;
}


Error: TLE

Fixed submission:

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream &operator>>(istream &I, vector<T> &v) {
  for (T &e : v)
    I >> e;
  return I;
}
template <class T> ostream &operator<<(ostream &O, const vector<T> &v) {
  for (const T &e : v)
    O << e << ' ';
  return O;
}

void _main() {
  ll n;
  cin >> n;
  map<ll, int> pf;
  for (int div = 2; div * div <= n; div++) {
    while (n % div == 0) {
      pf[div]++;
      n /= div;
    }
  }

  if (n > 1)
    pf[n]++;

  int ans = 0;
  for (auto &it : pf) {
    int i = 1;
    while (it.second - i >= 0) {
      ans++;
      it.second -= i++;
    }
  }

  cout << ans;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //        freopen("input.txt", "r", stdin);
  int _t = 1;
  //        cin >> _t;
  while (_t--)
    _main();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <utility>
#include <vector>

using namespace std;
struct aaa {
  aaa() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} aaa;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}
#define debug(v)                                                               \\
  { cerr << "\\033[1;36m[debug]\\033[m " << #v << " : " << v << endl; }

using int64 = long long;

void facts(int64 n, map<int64, int64> &fact) {
  int64 t = n;
  for (int64 i = 2; i * i <= t; i++) {
    while (n % i == 0) {
      fact[i]++;
      n /= i;
    }
  }
  if (n != 1)
    fact[n]++;
}

int main() {
  int64 n;
  cin >> n;

  map<int64, int64> fact;
  facts(n, fact);

  int64 ans = 0;
  for (auto [a, b] : fact) {

    for (int i = 1; i <= b; i++) {
      b -= i;
      ans++;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <utility>
#include <vector>

using namespace std;
struct aaa {
  aaa() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} aaa;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}
#define debug(v)                                                               \\
  { cerr << "\\033[1;36m[debug]\\033[m " << #v << " : " << v << endl; }

using int64 = long long;

bool isPrime(int n) {
  if (n < 2)
    return false;
  else if (n == 2)
    return true;
  else if (n % 2 == 0)
    return false;

  //    double sqrtNum = sqrt(n);
  for (int i = 3; i * i <= n; i += 2) {
    if (n % i == 0)
      return false;
  }

  return true;
}

void facts(int64 n, map<int64, int64> &fact) {
  for (int i = 2; i <= n; i++) {
    while (n % i == 0) {
      fact[i]++;
      n /= i;
    }
  }
  if (n != 1)
    fact[n]++;
}

int main() {
  int64 n;
  cin >> n;

  if (isPrime(n)) {
    cout << 1 << endl;
    return 0;
  }

  map<int64, int64> fact;
  facts(n, fact);

  int64 ans = 0;
  for (auto [a, b] : fact) {

    for (int i = 1; i <= b; i++) {
      b -= i;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long N;
  cin >> N;
  if (N == 1)
    cout << 0 << endl;
  else {
    long num = N;
    int res = 0;
    for (long i = 2; i * i <= N; i++) {
      int cnt = 0;
      while (num % i == 0) {
        num /= i;
        ++cnt;
      }
      int j = 1;
      while (cnt - j >= 0) {
        cnt -= j;
        ++res;
        ++j;
      }
    }
    if (num != 1)
      ++res;
    cout << res << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  long N;
  cin >> N;
  if (N == 1)
    cout << 0 << endl;
  else {
    long num = N;
    int res = 0;
    for (int i = 2; i * i <= N; i++) {
      int cnt = 0;
      while (num % i == 0) {
        num /= i;
        ++cnt;
      }
      int j = 1;
      while (cnt - j >= 0) {
        cnt -= j;
        ++res;
        ++j;
      }
    }
    if (num != 1)
      ++res;
    cout << res << endl;
  }
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl "\\n"
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> VL;
typedef set<ll> SL;
typedef pair<ll, ll> p2;
const ll M = 1000000007;
const ll M2 = 998244353;
vector<ll> v(1000005, 0);
void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 2; i <= 1000010; i++) {
    ll curr = 0;
    while (n % i == 0) {
      curr++;
      n /= i;
    }
    for (int j = 1; j < 1000000; j++) {
      if (curr < j)
        break;
      ans++;
      curr -= j;
    }
  }
  if (n > 1)
    ans++;
  cout << ans;
}

int main() {
  IOS int _ = 1;
  // cin>>_;
  while (_--) {
    solve();
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl "\\n"
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> VL;
typedef set<ll> SL;
typedef pair<ll, ll> p2;
const ll M = 1000000007;
const ll M2 = 998244353;

void solve() {
  ll n;
  cin >> n;
  map<ll, ll> m;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      m[i]++;
      n /= i;
    }
  }
  if (n > 1)
    m[n]++;
  ll ans = 0;
  for (auto &it : m) {
    // cout<<it.F<<" " <<it.S<<endl;
    ll k = 1;
    while (it.S >= k) {

      it.S -= k;
      k++;
      ans++;
    }
  }
  cout << ans;
}

int main() {
  IOS int _ = 1;
  // cin>>_;
  while (_--) {
    solve();
  }

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

#include <bits/stdc++.h>

#define FOR(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
  ll n, ntmp;
  cin >> n;
  map<ll, ll> ret;
  vector<ll> nsm((ll)sqrt(n) + 2, 0);
  nsm[0] = 0;
  FOR(i, 1, (ll)sqrt(n) + 2) nsm[i] = nsm[i - 1] + i;

  ntmp = n;
  for (ll i = 2; i * i <= ntmp; i++) {
    while (ntmp % i == 0) {
      ret[i]++;
      ntmp /= i;
    }
  }
  if (ntmp != 1)
    ret[ntmp] = 1;

  ll ans = 0;
  auto itr = ret.begin();
  while (itr != ret.end()) {
    ll tmp = itr->second;
    ans += (upper_bound(nsm.begin(), nsm.end(), tmp) - nsm.begin()) - 1;
    itr++;
  }

  cout << ans << "\\n";
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define FOR(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
  ll n, ntmp;
  cin >> n;
  vector<ll> ret((ll)sqrt(n) + 2, 0);
  vector<ll> nsm((ll)sqrt(n) + 2, 0);
  nsm[0] = 0;
  FOR(i, 1, (ll)sqrt(n) + 2) nsm[i] = nsm[i - 1] + i;

  ntmp = n;
  bool flag = false;
  for (ll i = 2; i * i <= ntmp; i++) {
    while (ntmp % i == 0) {
      flag = true;
      ret[i]++;
      ntmp /= i;
    }
  }
  if (!flag) {
    cout << "1";
    return 0;
  }
  if (ntmp != 1)
    ret[ntmp] = 1;

  ll ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    ll tmp = ret[i];
    if (tmp == 0)
      continue;
    ans += (ll)(lower_bound(nsm.begin(), nsm.end(), tmp) - nsm.begin());
    // cout << ((int)(lower_bound(nsm.begin(), nsm.end(), tmp) -
    // nsm.begin())+1);
  }

  cout << ans << "\\n";
  return 0;
}