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

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)

#define dump(x) cerr << #x << " = " << (x) << endl;
#define dumparr(x)                                                             \\
  cerr << #x;                                                                  \\
  for (auto elem : x) {                                                        \\
    cerr << " " << elem;                                                       \\
  }                                                                            \\
  cerr << endl;
#define dumppairs(x)                                                           \\
  cerr << #x;                                                                  \\
  for (auto elem : x) {                                                        \\
    cerr << "(" << elem.first << " " << elem.second << ") ";                   \\
  }                                                                            \\
  cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x)                                                           \\
  cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void) {
  ll n_orig;
  cin >> n_orig;
  ll n = n_orig;
  int ulimit = 1000001;

  vector<bool> is_sosus(ulimit, true);
  is_sosus[0] = false;
  is_sosus[1] = false;

  REP(i, ulimit) {
    if (!is_sosus[i]) {
      continue;
    }
    ll cnt = i * 2;
    while (cnt < ulimit) {
      is_sosus[cnt] = false;
      cnt += i;
    }
  }

  vector<ll> sosu_cnt(ulimit, 0);

  REP(i, ulimit) {
    if (!is_sosus[i]) {
      continue;
    }
    if (n % i != 0) {
      continue;
    }
    while (n % i == 0) {
      n /= i;
      sosu_cnt[i]++;
    }
  }

  ll ans = 0;
  REP(i, ulimit - 1) {
    if (sosu_cnt[i] == 0) {
      continue;
    }
    ll sub = 1;
    ll cnt = sosu_cnt[i];

    dump(cnt) while (cnt > 0) {
      cnt -= sub;
      sub++;
      if (cnt >= 0) {
        ans++;
      }
    }
  }
  dump(ans) if ((n != 1) && (n_orig > 1e6)) { ans++; }
  cout << ans << endl;
  return 0;
}

Error: -6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)


Fixed submission:

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)

#define dump(x) cerr << #x << " = " << (x) << endl;
#define dumparr(x)                                                             \\
  cerr << #x;                                                                  \\
  for (auto elem : x) {                                                        \\
    cerr << " " << elem;                                                       \\
  }                                                                            \\
  cerr << endl;
#define dumppairs(x)                                                           \\
  cerr << #x;                                                                  \\
  for (auto elem : x) {                                                        \\
    cerr << "(" << elem.first << " " << elem.second << ") ";                   \\
  }                                                                            \\
  cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x)                                                           \\
  cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void) {
  ll n;
  cin >> n;
  ll ulimit = 100001;
  vector<bool> is_sosus(ulimit, true);
  is_sosus[0] = false;
  is_sosus[1] = false;
  REP(i, ulimit) {
    if (!is_sosus[i]) {
      continue;
    }
    ll cnt = i;
    while (cnt < ulimit) {
      cnt += i;
      is_sosus[cnt] = false;
    }
  }

  vector<ll> sosu_cnt(ulimit, 0);

  REP(i, ulimit) {
    if (!is_sosus[i]) {
      continue;
    }
    if (n % i != 0) {
      continue;
    }
    while (n % i == 0) {
      n /= i;
      sosu_cnt[i]++;
    }
  }
  ll ans = 0;
  REP(i, ulimit - 1) {
    if (sosu_cnt[i] == 0) {
      continue;
    }
    ll sub = 1;
    ll cnt = sosu_cnt[i];
    while (cnt > 0) {
      cnt -= sub;
      sub++;
      ans++;
    }
  }
  int ans2 = ans + ans - ans;
  cout << ans2 << endl;
  return 0;
}