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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vpi vector<pair<int, int>>
#define w(t)                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define pi pair<int, int>
#define mii map<int, int>
#define pb push_back
#define ff first
#define ss second
#define FOR(i, t, n) for (int i = t; i < n; i++)
#define SCI(x) scanf("%d", &x)
#define SCL(x) scanf("%lld", &x)

ll factor(ll c) {
  ll d = 1 + 4 * c;
  ll ans = (sqrt(d) - 1);
  //	cout<<ans<<endl;
  return ans / 2;
}

map<ll, ll> m;

void primeFactor(ll n) {
  for (ll i = 2; i * i < n; i++) {
    if (n % i == 0) {
      ll c = 0;
      while (n % i == 0) {
        c++;
        n = n / i;
      }

      m[i] = c;
    }
  }
  if (n > 1) {
    m[n] = 1;
  }
}

void solve() {
  ll n;
  cin >> n;
  primeFactor(n);
  ll ans = 0;
  for (auto it : m) {
    ans += factor(2 * it.ss);
  }
  cout << ans << endl;
}

int main() {

  solve();

  //	cout<<factor(8)<<endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vpi vector<pair<int, int>>
#define w(t)                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define pi pair<int, int>
#define mii map<int, int>
#define pb push_back
#define ff first
#define ss second
#define FOR(i, t, n) for (int i = t; i < n; i++)
#define SCI(x) scanf("%d", &x)
#define SCL(x) scanf("%lld", &x)

int factor(int c) {
  int d = 1 + 4 * c;
  int ans = (sqrt(d) - 1);
  //	cout<<ans<<endl;
  return ans / 2;
}

map<int, int> m;

void primeFactor(ll n) {
  for (int i = 2; i * i < n; i++) {
    if (n % i == 0) {
      int c = 0;
      while (n % i == 0) {
        c++;
        n = n / i;
      }

      m[i] = c;
    }
  }
  if (n > 1) {
    m[n] = 1;
  }
}

void solve() {
  ll n;
  cin >> n;
  primeFactor(n);
  int ans = 0;
  for (auto it : m) {
    // cout<<it.ss<<" "<<factor(2*it.ss)<<endl;
    ans += factor(2 * it.ss);
  }
  cout << ans << endl;
}

int main() {

  solve();

  //	cout<<factor(8)<<endl;
}
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;

  // 素因数分解
  ll limit = n;
  map<ll, int> mp;
  for (ll i = 2; i * i < n; i++) {
    ll x = 0;
    // 割り切れるなら
    while (n % i == 0) {
      n /= i;
      x++;
    }
    mp[i] = x;
  }
  if (n != 1) {
    mp[n]++;
  }

  int ans = 0;
  for (auto myPair : mp) {
    int count = myPair.second;
    int iter = 1;
    while (count >= iter) {
      count -= iter;
      iter++;
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

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

  // 素因数分解
  ll limit = n;
  map<ll, int> mp;
  for (int i = 2; i * i < n; i++) {
    ll x = 0;
    // 割り切れるなら
    while (n % i == 0) {
      n /= i;
      x++;
    }
    mp[i] = x;
  }
  if (n != 1) {
    mp[n]++;
  }

  int ans = 0;
  for (auto myPair : mp) {
    int count = myPair.second;
    int iter = 1;
    while (count >= iter) {
      count -= iter;
      iter++;
      ans++;
    }
  }

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

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  /*int N;
  cin>>N;
  long long A[100000];
  long long answer=1;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]==0) answer=0;
  }
  if(answer==0) cout<<answer<<endl;
  else{
  for(int i=0;i<N;i++){
    answer=answer*A[i];
    if(answer>1000000000000000000){
      answer=-1;
      break;
    }
  }
  cout<<answer<<endl;
  }*/
  long long N;
  cin >> N;
  int div[1000001];
  for (int i = 0; i <= 1000000; i++) {
    div[i] = 0;
  }
  long long answer = 0;
  long long i = 2;
  while (i * i <= N && N > 1) {
    if (N % i == 0) {
      int judge = 1;
      while (N % i == 0) {
        N = N / i;
        div[i]++;
        if (div[i] == judge) {
          div[i] = 0;
          answer++;
          judge++;
        }
      }
    }
    i++;
    if (N != 1 && i * i > N) {
      answer++;
    }
  }
  cout << answer << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  /*int N;
  cin>>N;
  long long A[100000];
  long long answer=1;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]==0) answer=0;
  }
  if(answer==0) cout<<answer<<endl;
  else{
  for(int i=0;i<N;i++){
    answer=answer*A[i];
    if(answer>1000000000000000000){
      answer=-1;
      break;
    }
  }
  cout<<answer<<endl;
  }*/
  long long N;
  cin >> N;
  int div[1000001];
  for (int i = 0; i <= 1000000; i++) {
    div[i] = 0;
  }
  long long answer = 0;
  int i = 2;
  while (i * i <= N && N > 1) {
    if (N % i == 0) {
      int judge = 1;
      while (N % i == 0) {
        N = N / i;
        div[i]++;
        if (div[i] == judge) {
          div[i] = 0;
          answer++;
          judge++;
        }
      }
    }
    i++;
    if (N != 1 && i * i > N) {
      answer++;
    }
  }
  cout << answer << endl;

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

// インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   // 最大値を求める
#define MIN(x) *min_element(ALL(x))   // 最小値を求める
// 定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 1000000007    // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素
map<ll, ll> prime; // 素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

// O(√n)
// 整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n) {
  if (n <= 1)
    return;
  ll l = sqrt(n);
  FOR(i, 2, l) {
    if (n % i == 0) {
      prime_factorize(i);
      prime_factorize(ll(n / i));
      return;
    }
  }
  // mapでは存在しないkeyの場合も自動で構築される
  prime[n]++;
  return;
}
signed main() {
  long long n;
  cin >> n;
  prime_factorize(n);
  long long ans = 0;
  for (auto p : prime) {
    auto x = p.second;
    int k = 1;
    while (x >= k) {
      x -= k;
      k++;
      ans++;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P = pair<int, int>;
bool is_prime(long long N) {
  if (N == 1)
    return false;
  for (long long i = 2; i * i <= N; ++i) {
    if (N % i == 0)
      return false;
  }
  return true;
}
int main() {
  ll n;
  cin >> n;
  if (is_prime(n)) {
    cout << 1 << endl;
  } else if (n == 1) {
    cout << 0 << endl;
  } else {
    int ans = 0;
    for (int i = 2; i <= n; i++) {
      if (is_prime(n)) {
        ans++;
        break;
      };
      if (is_prime(i)) {
        int cnt = 0;
        while (n % i == 0) {
          n /= i;
          cnt++;
        }
        int k = 1;
        while (cnt >= k) {
          cnt -= k;
          k++;
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
  u64 N;
  cin >> N;

  if (N < 2) {
    cout << 0 << endl;
    return 0;
  }
  if (N < 4) {
    cout << 1 << endl;
    return 0;
  }

  map<u64, u64> prms;
  u64 p = 2;

  while (N >= p) {
    if (N % p == 0) {
      prms[p] = prms[p] + 1;
      N /= p;
    } else {
      p++;
      if (p * p > N) { // N is prime
        prms[N] = 1;
        break;
      }
    }
  }

  u64 ans = 0;

  for (auto itr = prms.begin(); itr != prms.end(); itr++) {
    u64 k = 1;
    u64 val = itr->second;
    while (val >= k) {
      val -= k;
      k++;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
  u64 N;
  cin >> N;

  if (N < 2) {
    cout << 0 << endl;
    return 0;
  }
  if (N < 4) {
    cout << 1 << endl;
    return 0;
  }

  map<u64, u64> prms;
  u64 p = 2;
  u64 oN = N;

  while (N >= p) {
    if (N % p == 0) {
      prms[p] = prms[p] + 1;
      N /= p;
    } else {
      p++;
    }

    if (prms.empty() && p * p > oN)
      break;
  }

  if (prms.empty()) { // N is primaly number
    cout << 1 << endl;
    return 0;
  }

  u64 ans = 0;

  for (auto itr = prms.begin(); itr != prms.end(); itr++) {
    u64 k = 1;
    u64 val = itr->second;
    while (val >= k) {
      val -= k;
      k++;
      ans++;
    }
  }

  cout << ans << endl;

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

#define _USE_MATH_DEFINES

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

typedef pair<int, int> pii;
typedef long long ll;

const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

int main() {

  ll n;
  cin >> n;

  map<ll, int> m;

  ll num = n;
  for (ll i = 2; i * i <= n; i++) {
    while (num % i == 0) {
      m[i]++;
      num /= i;
    }
  }

  if (num != 1) {
    m[num]++;
  }

  set<ll> s;

  for (auto it = m.begin(); it != m.end(); it++) {
    if (it->second == 0) {
      continue;
    }

    ll z = it->first;
    for (int j = 0; j < it->second; j++) {
      s.insert(z);
      z *= it->first;
    }
  }

  num = n;
  int cnt = 0;

  for (auto it = s.begin(); it != s.end(); it++) {

    if (num % *it == 0) {
      cnt++;
      num /= *it;
    }
  }
  cout << cnt << endl;
}

Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES

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

typedef pair<int, int> pii;
typedef long long ll;

const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

int main() {

  ll n;
  cin >> n;

  vector<ll> p;
  p.emplace_back(2);

  for (ll i = 3; i * i <= n; i++) {
    bool isP = true;
    for (int pi : p) {
      if (i % pi == 0) {
        isP = false;
      }
    }

    if (isP) {
      p.emplace_back(i);
    }
  }

  set<ll> s;

  for (int pi : p) {
    ll z = pi;
    while (n % z == 0) {
      s.insert(z);
      z *= pi;
    }
  }

  if (n != 1 && s.size() == 0) {
    s.insert(n);
  }

  ll num = n;
  int cnt = 0;

  for (auto it = s.begin(); it != s.end(); it++) {
    if (num % *it == 0) {
      cnt++;
      num /= *it;
    }
  }
  cout << cnt << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

const int maxn = 1e6 + 100;
int prime[maxn]; // 就是个素数表
bool sf[maxn]; // 判断这个数是不是素数，sf[i]中的i是从1到maxn的数

void init() {  // 核心 欧拉筛代码
  int num = 0; // num 用来记筛到第几个质数
  memset(sf, true, sizeof(sf));
  for (int i = 2; i <= maxn; i++) { // 外层枚举1~maxn
    if (sf[i])
      prime[++num] = i;              // 如果是质数就加入素数表
    for (int j = 1; j <= num; j++) { // 内层枚举num以内的质数
      if (i * prime[j] > maxn)
        break;                  // 筛完结束
      sf[i * prime[j]] = false; // 筛掉...
      if (i % prime[j] == 0)
        break; // 避免重复筛
    }
  }
  sf[1] = false;
  sf[0] = false; // 1 0 特判
}

int main() {
  init();
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll i = 2; i * i <= n; i++) {
    if (!sf[i])
      continue;
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1)
    mp[n]++;
  int ans = 0;
  for (auto i : mp) {
    for (int j = 1; i.second >= j; j++)
      i.second -= j, ++ans;
  }
  cout << ans << "\\n";
}

Error: 0

Fixed submission:

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

const int maxn = 1e6 + 100;
int prime[maxn]; // 就是个素数表
bool sf[maxn]; // 判断这个数是不是素数，sf[i]中的i是从1到maxn的数

void init() {  // 核心 欧拉筛代码
  int num = 0; // num 用来记筛到第几个质数
  memset(sf, true, sizeof(sf));
  for (int i = 2; i <= maxn; i++) { // 外层枚举1~maxn
    if (sf[i])
      prime[++num] = i;              // 如果是质数就加入素数表
    for (int j = 1; j <= num; j++) { // 内层枚举num以内的质数
      if (i * prime[j] > maxn)
        break;                  // 筛完结束
      sf[i * prime[j]] = false; // 筛掉...
      if (i % prime[j] == 0)
        break; // 避免重复筛
    }
  }
  sf[1] = false;
  sf[0] = false; // 1 0 特判
}

int main() {
  init();
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (int i = 2; i * i <= n; i++) {
    if (!sf[i])
      continue;
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1)
    mp[n]++;
  int ans = 0;
  for (auto i : mp) {
    for (int j = 1; i.second >= j; j++)
      i.second -= j, ++ans;
  }
  cout << ans << "\\n";
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll p[10000];
ll j;
ll ans;
bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  if (n == 1)
    return false;
  return true;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    bool w = true;
    while (n % i == 0) {
      res[i]++;
      n = n / i;
      if (w) {
        w = false;
        p[j] = i;
        j++;
      }
    }
  }
  if (n != 1) {
    ans++;
  }
  return res;
}
int main(void) {
  ll n;
  cin >> n;
  if (is_prime(n)) {
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> m;
  m = prime_factor(n);
  for (int i = 0; i < j; i++) {
    if (m[p[i]] > 0) {
      ll k = 1;
      while (m[p[i]] > 0) {
        m[p[i]] -= k;
        ans++;
        if (m[p[i]] < 0) {
          ans--;
        } else {
        }
        k++;
      }
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll p[10000];
ll j;
ll ans;
bool is_prime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  if (n == 1)
    return false;
  return true;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (int i = 2; i * i <= n; i++) {
    bool w = true;
    while (n % i == 0) {
      res[i]++;
      n = n / i;
      if (w) {
        w = false;
        p[j] = i;
        j++;
      }
    }
  }
  if (n != 1) {
    ans++;
  }
  return res;
}
int main(void) {
  ll n;
  cin >> n;
  if (is_prime(n)) {
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> m;
  m = prime_factor(n);
  for (int i = 0; i < j; i++) {
    if (m[p[i]] > 0) {
      ll k = 1;
      while (m[p[i]] > 0) {
        m[p[i]] -= k;
        ans++;
        if (m[p[i]] < 0) {
          ans--;
        } else {
        }
        k++;
      }
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(a, n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<ll>> Graph;
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;
}
const ll INF = 1e18;

// 素因数分解
vector<P> prime_factorize(ll n) {
  vector<P> res;
  for (ll a = 2; a * a <= n; ++a) {
    ll ex = 0; // 指数
    // 割り切れる限り割る
    while (n % a == 0) {
      ++ex;
      n /= a;
    }
    res.push_back({a, ex});
  }
  if (n != 1)
    res.push_back({n, 1});
  return res;
}

int main() {
  ll n;
  cin >> n;
  auto res = prime_factorize(n);
  ll ans = 0;
  for (auto p : res) {
    ll now = p.first;
    ll ex = p.second;
    int i = 1;
    while (1) {
      if (i > ex)
        break;
      ex -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(a, n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<ll>> Graph;
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;
}
const ll INF = 1e12;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  ll n;
  vector<ll> f, primes;
  Sieve(ll n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i])
        continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j])
          f[j] = i;
      }
    }
  }
  bool isPrime(ll x) { return f[x] == x; }
  vector<ll> factorList(ll x) {
    vector<ll> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(ll x) {
    vector<ll> fl = factorList(x);
    if (fl.size() == 0)
      return {};
    vector<P> res(1, P(fl[0], 0));
    for (ll p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll now = n;
  ll ans = 0;
  Sieve s(ll(1e7));
  // 約数全列挙
  vector<ll> fac;
  ll la;
  for (ll i = 2; i * i <= now; i++) {
    if (n % i == 0) {
      fac.push_back(i);
      if (i * i == n)
        continue;
      fac.push_back(n / i);
    }
  }
  sort(fac.begin(), fac.end());
  for (ll x : fac) {
    if (x > n)
      continue;
    if (!s.isPrime(x))
      continue;
    ll t = x;
    while (n % t == 0) {
      ans++;
      n /= t;
      t *= x;
    }
  }
  if (ans == 0)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define forr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()), (a.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL << 60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

map<ll, ll> factors;

int main() {
  ll N;
  cin >> N;
  bool check = true;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 2; i <= sqrt(N); i++) {
    while (N % i == 0) {
      check = false;
      factors[i]++;
      N /= i;
    }
    if (N == 1)
      break;
  }
  if (check) {
    cout << 1 << endl;
    return 0;
  }

  if (N != 1)
    factors[N]++;

  ll ans = 0;
  for (const auto &[key, value] : factors) {
    ll k = (-1 + sqrt(1 + 8 * value)) / 2;
    ans += k;
  }
  cout << ans << endl;
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>
#define forr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()), (a.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL << 60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
  ll N;
  cin >> N;
  vector<ll> factors(100000000);
  bool check = true;
  for (int i = 2; i <= sqrt(N); i++) {
    while (N % i == 0) {
      check = false;
      factors[i]++;
      N /= i;
    }
    if (N == 1)
      break;
  }
  if (check) {
    cout << 1 << endl;
    return 0;
  }

  if (N != 1)
    factors[N]++;

  ll ans = 0;
  for (int i = 0; i < factors.size(); i++) {
    ll k = (-1 + sqrt(1 + 8 * factors[i])) / 2;
    ans += k;
  }
  cout << ans << endl;

  return 0;
}