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

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

const double pi = 3.1415;
ll absc(ll a, ll b) { return (a - b > 0 ? a - b : b - a); }
ll mini(ll a, ll b) { return (a > b ? b : a); }
ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  return (a % b ? gcd(a % b, b) : b);
}
ll mainasu(ll a, ll b, ll c) {
  if (a >= b)
    return mainasu(a - b, b + 1, c + 1);
  else
    return c;
}
ll gojou(ll n) { return pow(n, 5); }
int main() {
  ll k = -1, num, ans = 0, j;
  bool f = false, g = false, h = false;
  cin >> num;
  vector<int> jou;
  for (ll i = 2; i * i <= ll(num); i++) {
    if (num % i == 0) {
      f = true;
      break;
    }
  }
  if (f) {
    for (int i = 2; i <= num; i++) { // 他の素数で割っていく
      if (num % i == 0) {
        j = 0;
        k++;
        g = true;
        h = false;
      } else
        g = false;
      while (num % i == 0) {
        if (!j)
          jou.push_back(1);
        else
          jou[k]++;
        num /= i;
        j++;
      }
      if (g && num != 1) {
        for (ll l = 2; l * l <= ll(num); l++)
          if (num % l == 0) {
            h = true;
            break;
          }
        if (!h) {
          jou.push_back(1);
          break;
        }
      }
    }
    for (ll i = 0; i < jou.size(); i++) {
      ans += mainasu(jou[i], 1, 0);
    }
    cout << ans;
  } else
    cout << (num == 1 ? 0 : 1);
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

const double pi = 3.1415;
ll absc(ll a, ll b) { return (a - b > 0 ? a - b : b - a); }
ll mini(ll a, ll b) { return (a > b ? b : a); }
ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  return (a % b ? gcd(a % b, b) : b);
}
ll mainasu(ll a, ll b, ll c) {
  if (a >= b)
    return mainasu(a - b, b + 1, c + 1);
  else
    return c;
}
ll gojou(ll n) { return pow(n, 5); }
int main() {
  ll k = -1, num, ans = 0;
  cin >> num;
  vector<ll> jou;
  for (ll i = 2; i <= num;) { // 他の素数で割っていく
    if (num % i == 0)
      k++;
    ll j = 0;
    while (num % i == 0) {
      if (!j)
        jou.push_back(1);
      else
        jou[k]++;
      num /= i;
      j++;
    }
    if (i == 2)
      i++;
    else
      i += 2;
  }
  for (ll i = 0; i < jou.size(); i++) {
    ans += mainasu(jou[i], 1, 0);
  }
  cout << ans;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;

  ll ans = 0;
  ll NN = N;

  for (ll p = 2;; p++) {
    ll cnt = 1;
    while (N % p == 0) {
      // cout << p << endl;
      bool f = false;
      for (int i = 0; i < cnt; i++) {
        if (N % p == 0) {
          N /= p;
        } else {
          f = true;
          break;
        }
      }
      if (f)
        break;
      cnt++;
      ans++;
    }
    if (p * p > N)
      break;
  }

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

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;

  ll ans = 0;
  ll NN = N;

  for (int p = 2;; p++) {
    ll cnt = 1;
    while (N % p == 0) {
      // cout << p << endl;
      bool f = false;
      for (int i = 0; i < cnt; i++) {
        if (N % p == 0) {
          N /= p;
        } else {
          f = true;
          break;
        }
      }
      if (f)
        break;
      cnt++;
      ans++;
    }
    if (p * p > N)
      break;
  }

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

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

ll n;
ll a[maxn];

int main() {
  scanf("%lld", &n);
  if (n == 1) {
    printf("0\\n");
    return 0;
  }
  for (int i = 1; i <= 1000; ++i)
    a[i] = i * (i + 1) / 2;
  int ans = 0;
  ll x = sqrt(n);
  for (int i = 2; i <= n; ++i) {
    if (i > x) {
      ans += 1;
      break;
    }
    int cnt = 0;
    while (n % i == 0) {
      ++cnt;
      n /= i;
    }
    if (cnt) {
      ll *p = lower_bound(a + 1, a + 1001, cnt);
      if (*p == cnt)
        ans += p - a;
      else
        ans += p - a - 1;
    }
  }
  printf("%d\\n", ans);
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

ll n;
ll a[maxn];

inline bool judge(ll &n) {
  for (int i = 2; i * i <= n; ++i)
    if (n % i == 0)
      return false;
  return true;
}

int main() {
  scanf("%lld", &n);
  if (n == 1) {
    printf("0\\n");
    return 0;
  }
  for (int i = 1; i <= 1000; ++i)
    a[i] = i * (i + 1) / 2;
  int ans = 0;
  for (int i = 2; i <= n; ++i) {
    if (judge(n)) {
      ans += 1;
      break;
    }
    int cnt = 0;
    while (n % i == 0) {
      ++cnt;
      n /= i;
    }
    if (cnt) {
      ll *p = lower_bound(a + 1, a + 1001, cnt);
      if (*p == cnt)
        ans += p - a;
      else
        ans += p - a - 1;
    }
  }
  printf("%d\\n", ans);
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> fa;
  for (ll i = 2; i * i <= n; i++) {

    if (n % i == 0) {
      ll x = 0;
      while (n % i == 0) {
        x++;
        n /= i;
      }
      fa.emplace_back(i, x);
      // cout<<i<<endl;
    }
  }
  if (n != 1) {
    fa.emplace_back(n, 1);
  }
  ll ans = 0;
  // cout<<';'<<endl;
  for (auto &i : fa) {
    for (ll j = 1; j <= i.second; j++) {
      i.second -= j;
      ans++;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> fa;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int x = 0;
      while (n % i == 0) {
        x++;
        n /= i;
      }
      fa.emplace_back(i, x);
    }
  }
  if (n != 1) {
    fa.emplace_back(n, 1);
  }
  ll ans = 0;
  for (auto &i : fa) {
    for (ll j = 1; j <= i.second; j++) {
      i.second -= j;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define ppp pair<ll, pair<ll, ll>>
#define pp pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define pi 3.14159265358
#define MOD 998244353
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, i, j, k;

  cin >> n;

  vector<ll> v;
  for (i = 2; i <= sqrt(n); i++) {
    ll occ = 0;
    while (n % i == 0) {
      n = n / i;
      occ++;
    }
    if (occ != 0)
      v.pb(occ);
  }

  if (n != 1)
    v.pb(1);

  ll ans = 0;
  for (i = 0; i < v.size(); i++) {
    ll sum = 0;
    for (j = 1;; j++) {
      if (sum + j > v[i])
        break;
      sum += j;
    }

    ans += j - 1;
    // cout<<v[i]<<" "<<j<<endl;
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll chck(ll x) {
  for (int i = 1; i <= 64; i++) {
    if ((i * (i + 1)) / 2 > x)
      return i - 1;
  }
}
int main() {
  vector<ll> res;
  ll n, j = 0, cnt, ans = 0;
  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      res.pb(cnt);
    }
  }
  if (n > 1)
    res.pb(1);
  for (int i = 0; i < res.size(); i++) {
    ans += chck(res[i]);
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

bool isprime[1000005];

void init() {

  for (int i = 0; i < 1000005; i++)
    isprime[i] = true;

  isprime[0] = isprime[1] = false;

  for (int i = 2; i < 1000005; i++) {
    if (!isprime[i])
      continue;
    for (int j = i * 2; j < 1000005; j += i) {
      isprime[j] = false;
    }
  }
}

bool isPrime(int num) {

  if (num == 1)
    return false;

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

  return true;
}

signed main() {

  init();

  int n;
  cin >> n;

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

  int ans = 0;

  for (int i = 0; i < 1000005; i++) {

    if (!isprime[i])
      continue;

    int cnt = 0;

    while (n % i == 0) {
      n /= i;
      cnt++;
    }

    int sum = cnt;

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

      if (j <= cnt) {
        cnt -= j;
        ans++;
      }
    }
  }

  if (isPrime(n) == true)
    ans++;

  cout << ans << endl;

  return 0;
}


Error: 0

Fixed submission:

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

bool isprime[1000005];

void init() {

  for (int i = 0; i < 1000005; i++)
    isprime[i] = true;

  isprime[0] = isprime[1] = false;

  for (int i = 2; i < 1000005; i++) {
    if (!isprime[i])
      continue;
    for (int j = i * 2; j < 1000005; j += i) {
      isprime[j] = false;
    }
  }
}

bool isPrime(int num) {

  if (num == 1)
    return false;

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

  return true;
}

signed main() {

  init();

  int n;
  cin >> n;

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

  if (n > 1000000)
    assert(0);

  int ans = 0;

  for (int i = 0; i < 1000005; i++) {

    if (!isprime[i])
      continue;

    int cnt = 0;

    while (n % i == 0) {
      n /= i;
      cnt++;
    }

    int sum = cnt;

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

      if (j <= cnt) {
        cnt -= j;
        ans++;
      }
    }
  }

  cout << ans << endl;

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

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

int main() {
  long long N;
  cin >> N;
  vector<long long> memo;
  long long temp = 0;
  long long num = N;
  while (N % 2 == 0) {
    N /= 2;
    temp++;
  }
  if (temp > 0) {
    memo.push_back(temp);
  }
  double sqrtNUM = sqrt(num);
  for (long long i = 3; i <= sqrtNUM + 2; i++) {
    if (N % i != 0) {
      continue;
    }
    temp = 0;
    while (N % i == 0) {
      N /= i;
      temp++;
    }
    memo.push_back(temp);
  }
  long long cnt = 0;
  for (auto memo_con : memo) {
    long long value = memo_con;
    long long i = 1;
    while (1) {
      value -= i;
      if (value >= 0) {
        cnt++;
      } else {
        break;
      }
      i++;
    }
  }
  if (cnt == 0 && num != 1) {
    cout << 1 << endl;
    return 0;
  }
  if (N != 1) {
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  long long N;
  cin >> N;
  vector<long long> memo;
  long long temp = 0;
  while (N % 2 == 0) {
    N /= 2;
    temp++;
  }
  if (temp > 0) {
    memo.push_back(temp);
  }
  for (long long i = 3; i <= N; i++) {
    if (N % i != 0) {
      continue;
    }
    temp = 0;
    while (N % i == 0) {
      N /= i;
      temp++;
    }
    memo.push_back(temp);
  }
  long long cnt = 0;
  for (auto memo_con : memo) {
    long long value = memo_con;
    long long i = 1;
    while (1) {
      value -= i;
      if (value >= 0) {
        cnt++;
      } else {
        break;
      }
      i++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const long long INF = 1e17 + 7;
const long long MOD = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

int main() {

  long long n;
  cin >> n;

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

  map<long long, int> mp;
  long long id = 2;
  long long num = n;
  bool fin = false;
  while (n) {
    if (n % id == 0) {
      mp[id]++;
      n /= id;
    } else {
      id++;
    }
    if (n <= 1)
      break;
    if (fin) {
      mp[n]++;
      break;
    }
    if (id * id > num)
      fin = true;
  }

  long long cnt = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int now = itr->second;
    for (long long i = 1; i <= itr->second; i++) {
      now -= i;
      cnt++;
      if (now == 0) {
        break;
      }
      if (now < 0) {
        cnt--;
        break;
      }
    }
  }
  if (cnt == 0)
    cnt++;
  cout << cnt << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

const long long INF = 1e17 + 7;
const long long MOD = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

bool is_prime(long long x) {
  bool res = true;
  if (x == 1)
    res = false;

  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      res = false;
      return res;
    }
  }
  return res;
}

int main() {

  long long n;
  cin >> n;

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

  if (is_prime(n) == true) {
    cout << 1 << endl;
    return 0;
  }

  map<long long, int> mp;
  long long id = 2;
  while (n) {
    if (n % id == 0) {
      mp[id]++;
      n /= id;
    } else {
      id++;
    }
    if (n <= 1)
      break;
  }

  long long cnt = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int now = itr->second;
    for (long long i = 1; i <= itr->second; i++) {
      now -= i;
      cnt++;
      if (now == 0) {
        break;
      }
      if (now < 0) {
        cnt--;
        break;
      }
    }
  }
  if (cnt == 0)
    cnt++;
  cout << cnt << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

int main() {

  long long n;
  cin >> n;
  long long mx = n;

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

  long long ans = 0;
  for (long long i = 2; i * i <= n; i++) {
    long long cnt = 0;
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      for (int j = 1; j <= cnt; j++) {
        cnt -= j;
        ans++;
      }
    }
  }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

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

using namespace std;

int main() {

  long long n;
  cin >> n;
  long long mx = n;

  vector<long long> table;

  if (n == 1 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17) {
    table.push_back(n);
  }

  for (long long i = 2; i * i <= mx; i++) {
    if (n % i == 0) {
      while (1) {
        if (n % i != 0)
          break;
        n /= i;
        table.push_back(i);
      }
    }
  }

  if (table.size() <= 1) {
    if (table[0] > 1) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }

  sort(table.begin(), table.end());

  /*
  for(int i = 0; i < table.size(); i++){
          cout << table[i] << "  ";
  }
  cout << endl;
  */

  long long ans = 0;
  long long cnt = 1;
  for (int i = 0; i < table.size(); i++) {
    if (table[i] != table[i + 1]) {
      if (cnt == 1) {
        ans++;
        continue;
      }
      // cout << "cnt : " << cnt << endl;
      long long k = 0;
      for (int j = 1; j <= cnt; j++) {
        k += j;
        // cnt += 1;
        if (k > cnt) {
          ans += (j - 1);
          cnt = 1;
          break;
        }
      }
    } else {
      cnt++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int)x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9 + 7;
const int INF = 2e9;
template <class T> void print(const T &t) { cout << t << endl; }
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll n;
  cin >> n;
  bool is_prime = true;
  ll ans = 0;
  for (ll i = 2; i < 1000007; i++) {
    ll num = 0;
    while (n % i == 0) {
      num++;
      n /= i;
    }
    for (ll j = 1; num - j >= 0; j++) {
      ans++;
      num -= j;
    }
  }
  if (n >= 1000007)
    ans++;
  print(ans);
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int)x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9 + 7;
const int INF = 2e9;
template <class T> void print(const T &t) { cout << t << endl; }
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  vector<int> res; // 求めた素数を入れる配列
  vector<bool> is_prime(n + 1, true);
  for (ll p = 2; p <= 1000000; p++) {
    if (!is_prime[p])
      continue;
    // p の倍数を全て消す。
    for (ll k = p * 2; k <= 1000000; k += p)
      is_prime[k] = false;
    res.push_back(p);
  }
  rep(i, sz(res)) {
    ll num = 0;
    while (n % res[i] == 0) {
      n /= res[i];
      num++;
    }
    for (ll j = 1; num - j >= 0; j++) {
      ans++;
      num -= j;
    }
  }
  if (ans == 0)
    ans++;
  if (n == 1)
    ans = 0;
  print(ans);
}
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>;

// 素因数分解
vector<pair<long long, long long>> prime_factorize(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() {
  ll n, cnt = 2;
  cin >> n;

  int ans = 0;
  auto m = prime_factorize(n);
  for (auto it = m.begin(); it != m.end(); it++) {
    // cout << it->first << "," << it->second << endl;
    int n = it->second;
    for (int i = 1; i <= n; i++) {
      n -= i;
      ans++;
    }
  }
  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;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n, cnt = 2;
  cin >> n;
  map<int, int> m;
  while (n != 1) {
    if (n % cnt == 0) {
      if (m.find(cnt) != m.end()) {
        m[cnt] += 1;
      } else {
        m[cnt] = 1;
      }
      n /= cnt;
    } else {
      cnt++;
    }
  }
  int ans = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    // cout << it->first << "," << it->second << endl;
    int n = it->second;
    for (int i = 1; i <= n; i++) {
      n -= i;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

#define sws                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for (int i = 0; i < n; i++)

#define MAX 1000005

bool primos[MAX];
bool pot[MAX];

void sieve() {
  memset(primos, true, sizeof(primos));
  memset(pot, false, sizeof(pot));
  primos[0] = primos[1] = false;

  for (int i = 2; i * i < MAX; i++) {
    if (primos[i]) {
      int at = 2;
      for (int j = i * i; j < MAX; j += i) {
        primos[j] = false;
        if (pow(i, at) == j) {
          at++;
          pot[j] = true;
        }
      }
    }
  }
}

int main() {

  ll n;
  cin >> n;
  sieve();

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

  int ops = 0;
  for (int i = 2;; i++) {
    if (i > n or (i * (ll)i > n and n > MAX)) {
      break;
    }

    if ((primos[i] or pot[i]) and n % i == 0) {
      n /= i;
      ops++;
    }
  }

  if (n > MAX) {
    cout << ops + 1 << endl;
  } else {
    cout << ops << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

#define sws                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for (int i = 0; i < n; i++)

#define MAX 1000005

bool primos[MAX];
bool pot[MAX];

void sieve() {
  memset(primos, true, sizeof(primos));
  memset(pot, false, sizeof(pot));
  primos[0] = primos[1] = false;

  for (int i = 2; i * i < MAX; i++) {
    if (primos[i]) {
      int at = 2;
      for (int j = i * i; j < MAX; j += i) {
        primos[j] = false;
        if (pow(i, at) == j) {
          at++;
          pot[j] = true;
        }
      }
    }
  }
}

int main() {

  ll n;
  cin >> n;
  sieve();

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

  int ops = 0;
  for (int i = 2;; i++) {
    if (i > n or (i * i > n and ops == 0)) {
      break;
    }

    if ((primos[i] or pot[i]) and n % i == 0) {
      // cout << i << endl;
      n /= i;
      ops++;
    }
  }

  if (ops == 0) {
    cout << 1 << endl;
  } else {
    cout << ops << endl;
  }

  return 0;
}