Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\\n';
const int MX = 100001; // check the limits, dummy

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

  ll N;
  cin >> N;
  int ans = 0;
  FOR(i, 2, 1000010) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    FOR(j, 1, 10000) {
      if (cur < j)
        break;
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << nl;

  return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define gcd(m, n) __gcd(m, n)
#define lcm(m, n) m *(n / gcd(m, n))
#define fast                                                                   \\
  std::ios_base::sync_with_stdio(false);                                       \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pi acos(-1.0)
#define endl '\\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

using namespace std;

ll mod(ll a, ll b) { return (a % b + b) % b; }
ll power(ll base, ll exp) {
  ll res = 1;
  while (exp > 0) {
    if (exp % 2 == 1)
      res = (res * base);
    base = (base * base);
    exp /= 2;
  }
  return res;
}

ll isPrime(ll number) {
  if (number < 2)
    return 0;
  if (number == 2)
    return 1;
  if (number % 2 == 0)
    return 0;
  for (ll i = 3; (i * i) <= number; i += 2) {
    if (number % i == 0)
      return 0;
  }
  return 1;
}
bool isPerfectSquare(long double x) {
  // Find floating point value of
  // square root of x.
  long double sr = sqrt(x);

  // If square root is an integer
  return ((sr - floor(sr)) == 0);
}
int main() {
  fast;
  ll n;
  cin >> n;
  vector<ll> ans;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      if (n / i == i) {
        ans.push_back(i);
      } else {
        ans.push_back(n / i);
        ans.push_back(i);
      }
    }
  }
  if (isPrime(n)) {
    cout << 1 << endl;
    return 0;
  }
  ll t = 0;
  sort(ans.begin(), ans.end());
  //	for(auto &a : ans) cout << a << " ";
  ll i = 0;
  while (n != 1) {
    if (isPrime(n)) {
      break;
    }
    if (n % ans[i] == 0) {
      n = n / ans[i];
      t++;
    }
    i++;
  }
  cout << t << endl;
  return 0;
}