prithivMLmods/Coder-Stat huggingface dataset:
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long int
#define INF 10000000000000000LL
#define pll pair<long long, long long>
const int MAX = 1e7;
const ll MOD = 1e18;
const int TOT_PRIMES = 19;
const int MAX_A = 70;
ll dp[90000];
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  ll n;
  cin >> n;
  ll cnt = 0;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < i; j++) {
      dp[cnt] = i;
      cnt++;
    }
  }
  ll tot = 0;
  for (int i = 2; i * i <= n; i++) {
    ll u = 0;
    while (n % i == 0) {
      n = n / i;
      u++;
    }
    tot = tot + dp[u] - 1;
  }
  if (n > 1)
    tot += 1;
  cout << tot;
}

Fixed submission:
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long int
#define INF 10000000000000000LL
#define pll pair<long long, long long>
const int MAX = 1e7;
const ll MOD = 1e18;
const int TOT_PRIMES = 19;
const int MAX_A = 70;
ll dp[90000];
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  ll n;
  cin >> n;
  ll cnt = 0;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < i; j++) {
      dp[cnt] = i;
      cnt++;
    }
  }
  ll tot = 0;
  for (ll i = 2; i * i <= n; i++) {
    ll u = 0;
    while (n % i == 0) {
      n = n / i;
      u++;
    }
    tot = tot + dp[u] - 1;
  }
  if (n > 1)
    tot += 1;
  cout << tot;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
  long long int i, j, k, n, b, ans = 0, po = 0;
  scanf("%lld", &n);
  for (i = 2; 1; i++) {
    po = 0;
    if (n % i == 0) {
      while (1) {
        if (n % i == 0) {
          n = n / i;
          po++;
        } else
          break;
      }
      for (j = 1; 1; j++) {
        if (po >= j) {
          po = po - j;
          ans++;
        } else
          break;
      }
    }
    if (n == 1)
      break;
  }
  printf("%lld", ans);
}

Fixed submission:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
  long long int i, j, k, n, b, ans = 0, po = 0;
  scanf("%lld", &n);
  for (i = 2; 1; i++) {
    po = 0;
    if (n % i == 0) {
      while (1) {
        if (n % i == 0) {
          n = n / i;
          po++;
        } else
          break;
      }
      for (j = 1; 1; j++) {
        if (po >= j) {
          po = po - j;
          ans++;
        } else
          break;
      }
    }
    if (n == 1)
      break;
    if (i > 1000000) {
      ans += 1;
      break;
    }
  }
  printf("%lld", ans);
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  ll n;
  cin >> n;
  map<int, int> m;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      m[i]++;
      n /= i;
    }
  }
  if (n != 1)
    m[n] = 1;
  int ans = 0;
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    int num = itr->second;
    int count = 1;
    while (true) {
      num -= count;
      count++;
      if (num >= 0)
        ans++;
      else
        break;
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  ll n;
  cin >> n;
  map<int, int> m;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      m[i]++;
      n /= i;
    }
  }
  if (n != 1)
    m[n] = 1;
  int ans = 0;
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    int num = itr->second;
    int count = 1;
    while (true) {
      num -= count;
      count++;
      if (num >= 0)
        ans++;
      else
        break;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
// g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef long long ll;

vector<pair<ll, int>> factor(ll x) {
  vector<pair<ll, int>> res;
  for (int i = 2; i * i <= x; i++) {
    int cnt = 0;
    while (x % i == 0)
      x /= i, cnt++;
    if (cnt)
      res.emplace_back(i, cnt);
  }
  if (x != 1)
    res.emplace_back(x, 1);
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> fs = factor(n);
  int ans = 0;
  for (pair<ll, int> p : fs) {
    // cout << p[i].first << ' ' << p[i].second << endl;
    int b = 1;
    int x = p.second;
    while (x >= b) {
      x -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
}


Fixed submission:
// g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef long long ll;

vector<pair<ll, int>> factor(ll x) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= x; i++) {
    int cnt = 0;
    while (x % i == 0)
      x /= i, cnt++;
    if (cnt)
      res.emplace_back(i, cnt);
  }
  if (x != 1)
    res.emplace_back(x, 1);
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> fs = factor(n);
  int ans = 0;
  for (pair<ll, int> p : fs) {
    // cout << p[i].first << ' ' << p[i].second << endl;
    int b = 1;
    int x = p.second;
    while (x >= b) {
      x -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ((ll)(n)); i++)
#define reg(i, a, b) for (ll i = ((ll)(a)); i <= ((ll)(b)); i++)
#define irep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define ireg(i, a, b) for (ll i = ((ll)(b)); i >= ((ll)(a)); i--)
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
template <class T = int> void print(vector<T> v) {
  for (auto a : v)
    cout << a << " ";
  cout << endl;
}

/*
 */

ll n, ans = 0;

int main(void) {
  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    int c = 0;
    while (n % i == 0) {
      n /= i;
      c++;
    }
    // cerr<<i<<","<<c<<endl;
    for (int j = 1; j <= c; j++) {
      c -= j;
      ans++;
    }
  }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ((ll)(n)); i++)
#define reg(i, a, b) for (ll i = ((ll)(a)); i <= ((ll)(b)); i++)
#define irep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define ireg(i, a, b) for (ll i = ((ll)(b)); i >= ((ll)(a)); i--)
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
template <class T = int> void print(vector<T> v) {
  for (auto a : v)
    cout << a << " ";
  cout << endl;
}

/*
 */

ll n, ans = 0;

int main(void) {
  cin >> n;
  for (ll i = 2; i * i <= n; i++) {
    int c = 0;
    while (n % i == 0) {
      n /= i;
      c++;
    }
    // cerr<<i<<","<<c<<endl;
    for (int j = 1; j <= c; j++) {
      c -= j;
      ans++;
    }
  }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<int, int> P;

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

  map<ll, int> mp;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      mp[i]++;
    }
  }
  if (n != 1)
    mp[n]++;

  int ans = 0;
  for (auto x : mp) {
    int t = x.second;
    for (int i = 1; i < 100; i++) {
      if (i > t)
        break;
      ans++;
      t -= i;
    }
  }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<int, int> P;

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

  map<ll, int> mp;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      mp[i]++;
    }
  }
  if (n != 1)
    mp[n]++;

  int ans = 0;
  for (auto x : mp) {
    int t = x.second;
    for (int i = 1; i < 100; i++) {
      if (i > t)
        break;
      ans++;
      t -= i;
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main() {
  ll n;
  cin >> n;
  ll start_n = n;
  ll ans = 0;
  for (int i = 2; (ll)(i * i) < start_n; i++) {
    if (n % i == 0) {
      int count = 0;
      while (n % i == 0) {
        count++;
        n /= i;
      }

      for (int j = 1; count > 0; j++) {
        if (count >= j) {
          count -= j;
          ans++;
        } else {
          break;
        }
      }
    }
  }

  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main() {
  ll n;
  cin >> n;
  ll start_n = n;
  ll ans = 0;
  ll limit_i = (int)sqrt(n) + 1;
  for (int i = 2; i < limit_i; i++) {
    // if(n == 1) break;
    int count = 0;
    while (n % i == 0) {
      n /= i;
      count++;
    }
    int t = 1;
    while (count > 0) {
      count -= t;
      t++;
      if (count >= 0)
        ans++;
      ;
    }
  }

  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

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

  long long int n, ans = 0;
  cin >> n;

  unordered_map<long long int, int> mp;

  while (n % 2 == 0) {
    mp[2]++;
    n = n / 2;
  }

  for (long long int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      mp[i]++;
      n = n / i;
    }
  }

  if (n > 2) {
    mp[n]++;
  }

  for (auto it = mp.begin(); it != mp.end(); it++) {
    long long int l = 1, r = it->second, temp = it->second;
    while (l <= r) {
      long long int mid = l + (r - l) / 2;
      if ((mid * (mid + 1)) / 2 <= temp &&
          ((mid + 2) * (mid + 1)) / 2 <= temp) {
        mid = l + 1;
      } else if ((mid * (mid + 1)) / 2 <= temp &&
                 ((mid + 2) * (mid + 1)) / 2 > temp) {
        ans = ans + mid;
        break;
      } else if (((mid) * (mid + 1)) / 2 > temp) {
        r = mid - 1;
      }
    }
  }

  cout << ans;
  return 0;
}

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

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

  long long int n, ans = 0;
  cin >> n;

  unordered_map<long long int, int> mp;

  while (n % 2 == 0) {
    mp[2]++;
    n = n / 2;
  }

  for (long long int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      mp[i]++;
      n = n / i;
    }
  }

  if (n > 2) {
    mp[n]++;
  }

  for (auto it = mp.begin(); it != mp.end(); it++) {
    long long int l = 1, r = it->second, temp = it->second;
    while (l <= r) {
      long long int mid = l + (r - l) / 2;
      if ((mid * (mid + 1)) / 2 <= temp &&
          ((mid + 2) * (mid + 1)) / 2 <= temp) {
        l = mid + 1;
      } else if ((mid * (mid + 1)) / 2 <= temp &&
                 ((mid + 2) * (mid + 1)) / 2 > temp) {
        ans = ans + mid;
        break;
      } else if (((mid) * (mid + 1)) / 2 > temp) {
        r = mid - 1;
      }
    }
  }

  cout << ans;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
// sort(V.begin(), V.end(), compare_function);

/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/

/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}

void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  int p = 2;
  int ats = 0;
  while (p * p <= n) {
    if (n % p == 0) {
      int laip = 0;
      while (n % p == 0) {
        n = n / p;
        laip++;
      }
      int i = 1;
      while (laip >= i) {
        ats++;
        laip = laip - i;
        i++;
      }
    }
    p++;
  }
  if (n > 1) {
    ats++;
  }
  cout << ats << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
// sort(V.begin(), V.end(), compare_function);

/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/

/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}

void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll p = 2;
  int ats = 0;
  while (p * p <= n) {
    if (n % p == 0) {
      int laip = 0;
      while (n % p == 0) {
        n = n / p;
        laip++;
      }
      int i = 1;
      while (laip >= i) {
        ats++;
        laip = laip - i;
        i++;
      }
    }
    p++;
  }
  if (n > 1) {
    ats++;
  }
  cout << ats << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
// #include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

bool isZero = true;

// string ans = "Yes";
ll ans = 0;
ll N;
vector<ll> A;

int main() {
  cin >> N;

  vector<ll> prime;
  vector<ll> primeF;
  ll nowP = 1;
  ll tmpN = N;

  if (tmpN % 2 == 0) {
    ll F = 0;
    while (tmpN % 2 == 0) {
      F++;
      tmpN /= 2;
    }
    prime.push_back(2);
    primeF.push_back(F);
  }

  while (tmpN > 1) {
    nowP += 2;
    if (nowP > sqrt(N) && primeF.size() == 0) {
      prime.push_back(N);
      primeF.push_back(1);
      break;
    }

    if (tmpN % nowP != 0)
      continue;

    int F = 0;
    while (tmpN % nowP == 0) {
      F++;
      tmpN /= nowP;
    }
    prime.push_back(nowP);
    primeF.push_back(F);
  }

  // 線形探索...
  for (int p : primeF) {
    ll x = 0;
    while ((x + 1) * (x + 2) / 2 <= p) {
      x++;
    }
    ans += x;
  }

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


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
// #include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

bool isZero = true;

// string ans = "Yes";
ll ans = 0;
ll N;
vector<ll> A;

int main() {
  cin >> N;

  vector<ll> prime;
  vector<ll> primeF;
  ll nowP = 1;
  ll tmpN = N;

  if (tmpN % 2 == 0) {
    ll F = 0;
    while (tmpN % 2 == 0) {
      F++;
      tmpN /= 2;
    }
    prime.push_back(2);
    primeF.push_back(F);
  }

  while (tmpN > 1) {
    nowP += 2;
    if (nowP > sqrt(N)) {
      prime.push_back(tmpN);
      primeF.push_back(1);
      break;
    }

    if (tmpN % nowP != 0)
      continue;

    int F = 0;
    while (tmpN % nowP == 0) {
      F++;
      tmpN /= nowP;
    }
    prime.push_back(nowP);
    primeF.push_back(F);
  }

  // 線形探索...
  for (int p : primeF) {
    ll x = 0;
    while ((x + 1) * (x + 2) / 2 <= p) {
      x++;
    }
    ans += x;
  }

  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

typedef long long ll;

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

int main() {
  ll N;
  ll ans = 0;
  cin >> N;
  map<ll, ll> prime = prime_factor(N);
  for (auto p : prime) {
    ll max_e = p.second;
    int e = 1;
    int cnt = 0;
    while (max_e >= e) {
      cnt++;
      max_e -= e;
      e++;
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

typedef long long ll;

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

int main() {
  ll N;
  ll ans = 0;
  cin >> N;
  map<ll, ll> prime = prime_factor(N);
  for (auto p : prime) {
    ll max_e = p.second;
    int e = 1;
    int cnt = 0;
    while (max_e >= e) {
      cnt++;
      max_e -= e;
      e++;
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
/*
  Reference:-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int, int>
#define all(vec) vec.begin(), vec.end()
ll mod = 1000000007;
const int N = 2e5 + 5;
ll power(ll n, ll k) {
  ll ans = 1;
  while (k) {
    if (k & 1)
      ans = (ans * n) % mod;
    k /= 2;
    n = (n * n) % mod;
  }
  // ans=(ans-1+mod)%mod;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll a;
  cin >> a;
  ll ans = 0;
  ll n = a;
  for (int i = 2; i * i <= a; i++) {
    if (n % i == 0) {
      ll co = 0;
      while (n % i == 0) {
        n /= i;
        co++;
      }
      // cout<<i<<" "<<co<<" ";
      ll sum = 1, num = 1;
      while (sum <= co) {
        sum = (num * (num + 1)) / 2;
        num++;
      }
      // cout<<num<<endl;
      ans += num - 2;
    }
  }
  if (n > 1)
    ans++;
  cout << ans;

  return 0;
}


Fixed submission:
/*
  Reference:-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int, int>
#define all(vec) vec.begin(), vec.end()
ll mod = 1000000007;
const int N = 2e5 + 5;
ll power(ll n, ll k) {
  ll ans = 1;
  while (k) {
    if (k & 1)
      ans = (ans * n) % mod;
    k /= 2;
    n = (n * n) % mod;
  }
  // ans=(ans-1+mod)%mod;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll a;
  cin >> a;
  ll ans = 0;
  ll n = a;
  for (ll i = 2; i * i <= a; i++) {
    if (n % i == 0) {
      ll co = 0;
      while (n % i == 0) {
        n /= i;
        co++;
      }
      // cout<<i<<" "<<co<<" ";
      ll sum = 1, num = 1;
      while (sum <= co) {
        sum = (num * (num + 1)) / 2;
        num++;
      }
      // cout<<num<<endl;
      ans += num - 2;
    }
  }
  if (n > 1)
    ans++;
  cout << ans;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

const int mod = 1e9 + 7;

inline int add(int a, int b) {
  int res = a + b;
  if (res >= mod)
    res -= mod;
  return res;
}
inline int sub(int a, int b) {
  int res = a - b;
  if (res < 0)
    res += mod;
  return res;
}
inline int mul(int a, int b) { return (a * b) % mod; }

void solve() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return;
  }
  vector<int> v;
  bool is = true;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      is = false;
      break;
    }
  if (is) {
    cout << 1 << endl;
    return;
  }
  int x = n;
  int lim = 1e6;
  for (int i = 2; i <= max(lim, x); i++) {
    if (x % i == 0) {
      int cnt = 0;
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      v.push_back(cnt);
    }
  }
  if (x != 1)
    v.push_back(1);
  int ans = 0;
  for (int a : v) {
    int i = 1;
    while (i * (i + 1) / 2 <= a) {
      i++;
    }
    i--;
    ans += i;
  }
  cout << ans << endl;
}

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);

  int T = 1;
  // cin >> T;

  while (T--) {
    solve();
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

const int mod = 1e9 + 7;

inline int add(int a, int b) {
  int res = a + b;
  if (res >= mod)
    res -= mod;
  return res;
}
inline int sub(int a, int b) {
  int res = a - b;
  if (res < 0)
    res += mod;
  return res;
}
inline int mul(int a, int b) { return (a * b) % mod; }

void solve() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return;
  }
  vector<int> v;
  bool is = true;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      is = false;
      break;
    }
  if (is) {
    cout << 1 << endl;
    return;
  }
  int x = n;
  int lim = 1e6;
  for (int i = 2; i <= min(lim, x); i++) {
    if (x % i == 0) {
      int cnt = 0;
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      v.push_back(cnt);
    }
  }
  if (x != 1)
    v.push_back(1);
  int ans = 0;
  for (int a : v) {
    int i = 1;
    while (i * (i + 1) / 2 <= a) {
      i++;
    }
    i--;
    ans += i;
  }
  cout << ans << endl;
}

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);

  int T = 1;
  // cin >> T;

  while (T--) {
    solve();
  }
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n, ans = 0;
  cin >> n;
  vector<int> v;
  for (int i = 1; i <= 100; i++) {
    v.push_back(i * (i + 1) / 2);
  }
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    if (cnt)
      ans += upper_bound(v.begin(), v.end(), cnt) - v.begin();
  }
  if (n != 1)
    ans++;
  cout << ans;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n, ans = 0;
  cin >> n;
  vector<int> v;
  for (int i = 1; i <= 100; i++) {
    v.push_back(i * (i + 1) / 2);
  }
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    if (cnt)
      ans += upper_bound(v.begin(), v.end(), cnt) - v.begin();
  }
  if (n != 1)
    ans++;
  cout << ans;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, a, n) for (int i = a; i < n; ++i)
typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9 + 7;

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
vector<ll> q;

ll getAns(ll m) {
  ll x = 0;
  auto it = upper_bound(all(q), m) - q.begin() - 1;
  return it;
}

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i <= 8; i++) {
    q.pb(((i + 1) * i) / 2);
  }
  for (ll i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    ll j = 0;
    for (; j <= 8;) {
      if ((j * (j + 1)) <= cnt)
        j++;
    }
    j--;
    ans += j;
  }
  if (n > 1)
    ans++;
  cout << ans;
}

int main() {
  Blue;
  int test = 1;
  // cin>>test;
  while (test--)
    solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, a, n) for (int i = a; i < n; ++i)
typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9 + 7;

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
vector<ll> q;

ll getAns(ll m) {
  ll x = 0;
  auto it = upper_bound(all(q), m) - q.begin() - 1;
  return it;
}

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i <= 8; i++) {
    q.pb(((i + 1) * i) / 2);
  }
  for (ll i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    ans += getAns(cnt);
  }
  if (n > 1)
    ans++;
  cout << ans;
}

int main() {
  Blue;
  int test = 1;
  // cin>>test;
  while (test--)
    solve();
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));

bool isPrime(int x) {
  int i;
  if (x < 2)
    return 0;
  else if (x == 2)
    return 1;
  if (x % 2 == 0)
    return 0;
  for (i = 3; i * i <= x; i += 2)
    if (x % i == 0)
      return 0;
  return 1;
}

signed main() {
  int N;
  cin >> N;
  if (N == 1) {
    cout << 0;
    return 0;
  }
  if (isPrime(N)) {
    cout << 1;
    return 0;
  }

  int ans = 0;
  for (int i = 2; i <= N; i++) {
    if (N % i == 0) {
      int cnt = 0;
      while (N % i == 0) {
        cnt++;
        N /= i;
      }
      int a = sqrt(1 + 8 * cnt);
      int b = (-1 + a) / 2;
      ans += b;
    }
  }
  cout << ans;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));

bool isPrime(int x) {
  int i;
  if (x < 2)
    return 0;
  else if (x == 2)
    return 1;
  if (x % 2 == 0)
    return 0;
  for (i = 3; i * i <= x; i += 2)
    if (x % i == 0)
      return 0;
  return 1;
}

signed main() {
  int N;
  cin >> N;
  if (N == 1) {
    cout << 0;
    return 0;
  }
  if (isPrime(N)) {
    cout << 1;
    return 0;
  }

  int ans = 0;
  for (int i = 2; i <= N; i++) {
    if (N % i == 0) {
      int cnt = 0;
      while (N % i == 0) {
        cnt++;
        N /= i;
      }
      int a = sqrt(1 + 8 * cnt);
      int b = (-1 + a) / 2;
      ans += b;
    } else {
      if (i * i > N) {
        ans++;
        break;
      }
    }
  }
  cout << ans;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, a, n) for (int i = a; i < n; ++i)
typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9 + 7;

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
vector<ll> q;

ll getAns(ll m) {
  ll x = 0;
  auto it = upper_bound(all(q), m) - q.begin() - 1;
  return it;
}

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i <= 1e6; i++) {
    q.pb(((i + 1) * i) / 2);
  }
  for (int i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    ans += getAns(cnt);
  }
  if (n > 1)
    ans++;
  cout << ans;
}

int main() {
  Blue;
  int test = 1;
  // cin>>test;
  while (test--)
    solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, a, n) for (int i = a; i < n; ++i)
typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9 + 7;

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
vector<ll> q;

ll getAns(ll m) {
  ll x = 0;
  auto it = upper_bound(all(q), m) - q.begin() - 1;
  return it;
}

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i <= 1e6; i++) {
    q.pb(((i + 1) * i) / 2);
  }
  for (ll i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    ans += getAns(cnt);
  }
  if (n > 1)
    ans++;
  cout << ans;
}

int main() {
  Blue;
  int test = 1;
  // cin>>test;
  while (test--)
    solve();
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: 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>;
using v = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

const ll INF = 1001001001001;

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

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

  v a;

  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      a.push_back(0);
      while (n % i == 0) {
        a[a.size() - 1]++;
        n /= i;
      }
    }
  }
  if (n != 1) {
    a.push_back(1);
  }

  int ans = 0;

  for (int i = 0; i < a.size(); i++) {
    double t = (sqrt(8 * a[i] + 1) - 1) / 2.0;
    ans += (int)t;
  }

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

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>;
using v = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

const ll INF = 1001001001001;

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

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

  v a;

  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      a.push_back(0);
      while (n % i == 0) {
        a[a.size() - 1]++;
        n /= i;
      }
    }
  }
  if (n != 1) {
    a.push_back(1);
  }

  int ans = 0;

  for (int i = 0; i < a.size(); i++) {
    double t = (sqrt(8 * a[i] + 1) - 1) / 2.0;
    ans += (int)t;
  }

  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

vector<pair<ll, ll>> fact(ll n) {
  vector<pair<ll, ll>> p;
  for (int i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    p.push_back(make_pair(i, cnt));
  }
  if (n != 1)
    p.push_back(make_pair(n, 1));
  return p;
}
int main() {

  ll n;
  cin >> n;
  const auto &res = fact(n);
  int ans = 0;
  for (auto iter : res) {
    int cnt = iter.second;
    int i = 1;
    while (cnt >= i) {
      cnt -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

vector<pair<ll, ll>> fact(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    p.push_back(make_pair(i, cnt));
  }
  if (n != 1)
    p.push_back(make_pair(n, 1));
  return p;
}
int main() {

  ll n;
  cin >> n;
  const auto &res = fact(n);
  int ans = 0;
  for (auto iter : res) {
    int cnt = iter.second;
    int i = 1;
    while (cnt >= i) {
      cnt -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set =
    tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
if you have any question about any part of my code,
please don't shy to ask anytime :)
*/

bool isprime(ll n) {
  if (n == 2)
    return true;

  if (n % 2 == 0 || n < 2)
    return false;

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

  return true;
}

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;

  unordered_set<ll> s;
  unordered_map<ll, ll> h;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      s.insert(i);
      n /= i;
      h[i]++;
    }
  }

  if (n > 1) {
    s.insert(n);
    h[n]++;
  }

  for (auto it : s) {
    for (int i = 1;; i++) {
      if (h[it] >= i) {
        ans++;
        h[it] -= i;
      } else {
        break;
      }
    }
  }

  cout << ans << endl;
}

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

  // ll t;
  // cin >> t;

  // while (t--)
  // {
  //     solve();
  // }
  solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set =
    tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
if you have any question about any part of my code,
please don't shy to ask anytime :)
*/

bool isprime(ll n) {
  if (n == 2)
    return true;

  if (n % 2 == 0 || n < 2)
    return false;

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

  return true;
}

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;

  unordered_set<ll> s;
  unordered_map<ll, ll> h;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      s.insert(i);
      n /= i;
      h[i]++;
    }
  }

  if (n > 1) {
    s.insert(n);
    h[n]++;
  }

  for (auto it : s) {
    for (int i = 1;; i++) {
      if (h[it] >= i) {
        ans++;
        h[it] -= i;
      } else {
        break;
      }
    }
  }

  cout << ans << endl;
}

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

  // ll t;
  // cin >> t;

  // while (t--)
  // {
  //     solve();
  // }
  solve();
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>

#define ll long long
using namespace std;
const int lim = 5e6;
int lp[lim + 10], pr[lim], cnt = 0;
vector<ll> V;
unordered_map<ll, int> mp;
ll n;
void sieve() {
  for (int i = 2; i <= lim; i++) {
    if (lp[i] == 0)
      lp[i] = pr[++cnt] = i;
    int j = 1;
    while (j <= cnt && pr[j] <= lp[i] && i * pr[j] <= lim) {
      lp[i * pr[j]] = pr[j];
      j++;
    }
  }
}
bool prime(long long x) {
  if (x < 2)
    return false;
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}
void add() {
  for (ll i = 2; i <= lim; i++)
    if (lp[i] == i)
      for (ll temp = i; temp <= (ll)1e13; temp *= i)
        V.push_back(temp);
}
int main() {
  /*sieve();
  add();
  sort(V.begin(),V.end());
  cin >> n;
  ll ans = 0 , tmp = 1;
  for (auto x : V)
      if (n % x == 0 && x <= n) n /= x , ans++ , tmp = x;
  if (prime(n) == true && n > tmp) ans++;
  cout << ans;*/
  ll ans = 0;
  cin >> n;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
        mp[i]++;
      }
      V.push_back(i);
    }
  if (n > 1)
    V.push_back(n), mp[n]++;
  for (auto x : V) {
    int sum = 1;
    while (mp[x] >= sum)
      mp[x] -= sum, ans++, sum++;
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>

#define ll long long
using namespace std;
const int lim = 5e6;
int lp[lim + 10], pr[lim], cnt = 0;
vector<ll> V;
unordered_map<ll, int> mp;
ll n;
void sieve() {
  for (int i = 2; i <= lim; i++) {
    if (lp[i] == 0)
      lp[i] = pr[++cnt] = i;
    int j = 1;
    while (j <= cnt && pr[j] <= lp[i] && i * pr[j] <= lim) {
      lp[i * pr[j]] = pr[j];
      j++;
    }
  }
}
bool prime(long long x) {
  if (x < 2)
    return false;
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}
void add() {
  for (ll i = 2; i <= lim; i++)
    if (lp[i] == i)
      for (ll temp = i; temp <= (ll)1e13; temp *= i)
        V.push_back(temp);
}
int main() {
  /*sieve();
  add();
  sort(V.begin(),V.end());
  cin >> n;
  ll ans = 0 , tmp = 1;
  for (auto x : V)
      if (n % x == 0 && x <= n) n /= x , ans++ , tmp = x;
  if (prime(n) == true && n > tmp) ans++;
  cout << ans;*/
  ll ans = 0;
  cin >> n;
  for (ll i = 2; i * i <= n; i++)
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
        mp[i]++;
      }
      V.push_back(i);
    }
  if (n > 1)
    V.push_back(n), mp[n]++;
  for (auto x : V) {
    int sum = 1;
    while (mp[x] >= sum)
      mp[x] -= sum, ans++, sum++;
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

long long n;
vector<pair<int, int>> ve;

void factorize(long long n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int temp = 0;
      while (n % i == 0) {
        n /= i;
        temp++;
      }
      ve.emplace_back(i, temp);
    }
  }
  if (n > 1) {
    ve.emplace_back(n, 1);
  }
}

int f(int a) {
  int r = a, l = 0, ans = -1;
  while (r >= l) {
    int mid = (r + l) / 2;
    if (mid * (mid + 1) / 2 > a) {
      r = mid - 1;
    } else {
      ans = mid;
      l = mid + 1;
    }
  }
  return ans;
}

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

  cin >> n;
  factorize(n);

  int ans = 0;
  for (auto i : ve) {
    ans += f(i.second);
  }
  cout << ans << '\n';
  return 0;
}

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

long long n;
vector<pair<int, int>> ve;

void factorize(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int temp = 0;
      while (n % i == 0) {
        n /= i;
        temp++;
      }
      ve.emplace_back(i, temp);
    }
  }
  if (n > 1) {
    ve.emplace_back(n, 1);
  }
}

int f(int a) {
  int r = a, l = 0, ans = -1;
  while (r >= l) {
    int mid = (r + l) / 2;
    if (mid * (mid + 1) / 2 > a) {
      r = mid - 1;
    } else {
      ans = mid;
      l = mid + 1;
    }
  }
  return ans;
}

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

  cin >> n;
  factorize(n);

  int ans = 0;
  for (auto i : ve) {
    ans += f(i.second);
  }
  cout << ans << '\n';
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (int i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    mp[n]++;
  }
  ll ans = 0;
  vector<ll> s(51);
  for (int i = 0; i < 50; ++i) {
    s[i + 1] = s[i] + (i + 1);
  }
  for (auto a : mp) {
    ll key = a.first;
    ll value = a.second;
    ll res = upper_bound(s.begin(), s.end(), value) - s.begin() - 1;
    ans += res;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    mp[n]++;
  }
  ll ans = 0;
  vector<ll> s(51);
  for (int i = 0; i < 50; ++i) {
    s[i + 1] = s[i] + (i + 1);
  }
  for (auto a : mp) {
    ll key = a.first;
    ll value = a.second;
    ll res = upper_bound(s.begin(), s.end(), value) - s.begin() - 1;
    ans += res;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ret return
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair<int, int>
#define pll pair<long long, long long>
#define FAST                                                                   \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 2e6;

bool notprime[maxn + 100];
ll cnt[maxn + 100];
ll n;
vector<int> divi;

inline void getdiv() {
  notprime[1] = 1;
  ll k = n;
  for (int i = 2; i < maxn; ++i) {
    if (!notprime[i]) {
      for (int j = i + i; j < maxn; j += i) {
        notprime[j] = 1;
      }
      if (k % i == 0) {
        divi.PB(i);
      }
      while (k % i == 0) {
        cnt[i]++;
        k /= i;
      }
    }
  }
  if (k > 1) {
    divi.PB(k);
  }
}

int main() {
  FAST cin >> n;
  getdiv();
  ll ans = 0;
  for (auto u : divi) {
    if (u >= maxn) {
      ans++;
    } else {
      ll val = cnt[u];
      ll cnt = 1;
      while (val >= cnt) {
        val -= cnt;
        cnt++;
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ret return
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair<int, int>
#define pll pair<long long, long long>
#define FAST                                                                   \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 2e6;

bool notprime[maxn + 100];
ll cnt[maxn + 100];
ll n;
vector<ll> divi;

inline void getdiv() {
  notprime[1] = 1;
  ll k = n;
  for (int i = 2; i < maxn; ++i) {
    if (!notprime[i]) {
      for (int j = i + i; j < maxn; j += i) {
        notprime[j] = 1;
      }
      if (k % i == 0) {
        divi.PB(i);
      }
      while (k % i == 0) {
        cnt[i]++;
        k /= i;
      }
    }
  }
  if (k > 1) {
    divi.PB(k);
  }
}

int main() {
  FAST cin >> n;
  getdiv();
  ll ans = 0;
  for (auto u : divi) {
    if (u >= maxn) {
      ans++;
    } else {
      ll val = cnt[u];
      ll cnt = 1;
      while (val >= cnt) {
        val -= cnt;
        cnt++;
        ans++;
      }
    }
  }
  cout << ans << endl;
}