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

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a) for (auto &i : a)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI = acos(-1);

int CEIL(int a, int b) {
  return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b);
} // ceil() for int
int mod(int a, int b) {
  return a >= 0 ? a % b : a - (b * CEIL(a, b));
} // always return positive num
int bpm(int x, int y) { // return x^y in order(log(y))
  if (x == 0)
    return 0;
  if (y == 0)
    return 1;
  int ans = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1)
      ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T> struct trio {
  T first{};
  T second{};
  T third{};
};
template <class T> void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++)
    container[i + 1] += container[i];
}

vector<int> prime_list;
void prime_factorization(int n) {
  while (n % 2 == 0) {
    n /= 2;
    prime_list.push_back(2);
  }
  for (int i = 3; i < (int)(sqrt((double)n)) + 2; i += 2)
    if (n % i == 0)
      while (n % i == 0) {
        n /= i;
        prime_list.push_back(i);
      }
  if (n != 1)
    prime_list.push_back(n);
}
class DDivGame {
public:
  static void solve(istream &cin, ostream &cout) {
    prime_list = {};
    int N;
    cin >> N;
    prime_factorization(N);
    map<int, int> primes;
    while (prime_list.size()) {
      primes[prime_list[prime_list.size() - 1]]++;
      prime_list.pop_back();
    }
    int ans = 0;
    vector<int> judge(10000);
    rep(i, 1000) { judge[i] = (i + 1) * (i + 2) / 2; }
    FOR(i, primes) {
      if (i.second != 0) {
        rep(j, 1000) {
          if (i.second >= judge[j] and i.second < judge[j + 1]) {
            ans += j + 1;
            break;
          }
        }
      }
    }
    cout << ans << endl;
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  DDivGame solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Error: 0

Fixed submission:

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a) for (auto &i : a)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI = acos(-1);

int CEIL(int a, int b) {
  return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b);
} // ceil() for int
int mod(int a, int b) {
  return a >= 0 ? a % b : a - (b * CEIL(a, b));
} // always return positive num
int bpm(int x, int y) { // return x^y in order(log(y))
  if (x == 0)
    return 0;
  if (y == 0)
    return 1;
  int ans = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1)
      ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T> struct trio {
  T first{};
  T second{};
  T third{};
};
template <class T> void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++)
    container[i + 1] += container[i];
}

vector<int> prime_list;
void prime_factorization(int n) {
  while (n % 2 == 0) {
    n /= 2;
    prime_list.push_back(2);
  }
  for (int i = 3; i < (int)(sqrt((double)n)) + 2; i += 2)
    if (n % i == 0)
      while (n % i == 0) {
        n /= i;
        prime_list.push_back(i);
      }
  if (n != 1)
    prime_list.push_back(n);
}
class DDivGame {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    prime_factorization(N);
    vector<int> primes(1000000 + 10, 0);
    if (prime_list[0] > 1000000) {
      cout << 1 << endl;
      return;
    }
    while (prime_list.size()) {
      primes[prime_list[prime_list.size() - 1]]++;
      prime_list.pop_back();
    }
    int ans = 0;
    vector<int> judge(10000);
    rep(i, 1000) { judge[i] = (i + 1) * (i + 2) / 2; }
    FOR(i, primes) {
      if (i != 0) {
        rep(j, 1000) {
          if (i >= judge[j] and i < judge[j + 1]) {
            ans += j + 1;
            break;
          }
        }
      }
    }
    cout << ans << endl;
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  DDivGame solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}