alexjercan/bugnet huggingface dataset:
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
const ll SIZE = 1e6 + 1;
bool isprime[SIZE];
vector<ll> primes;
map<ll, ll> factors;
void make_primes() {
  for (ll i = 0; i < SIZE; ++i)
    isprime[i] = true;
  isprime[0] = isprime[1] = false;
  for (ll i = 2; i * i <= SIZE; ++i) {
    if (isprime[i]) {
      ll j = i + i;
      while (j < SIZE) {
        isprime[j] = false;
        j += i;
      }
    }
  }
  for (ll i = 0; i < SIZE; i++)
    if (isprime[i])
      primes.push_back(i);
}

void prime_factorize(ll x) {
  for (ll i : primes) {
    while (x % i == 0) {
      ++factors[i];
      x /= i;
    }
  }
  if (x != 1)
    ++factors[x];
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  make_primes();

  prime_factorize(n);
  int ans = 0;
  for (auto &&i : factors) {
    int x = 1;
    while (i.second - x >= 0) {
      i.second -= x;
      ans++;
      x++;
    }
  }
  cout << ans << endl;
}

Error: 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;
const int SIZE = 1e6 + 1;
bool isprime[SIZE];
vector<ll> primes;
map<ll, ll> factors;
void make_primes() {
  for (int i = 0; i < SIZE; ++i)
    isprime[i] = true;
  isprime[0] = isprime[1] = false;
  for (int i = 2; i * i <= SIZE; ++i) {
    if (isprime[i]) {
      int j = i + i;
      while (j < SIZE) {
        isprime[j] = false;
        j += i;
      }
    }
  }
  for (int i = 0; i < SIZE; i++)
    if (isprime[i])
      primes.push_back(i);
}

void prime_factorize(long long x) {
  for (int i = 0; i * i <= x; i++) {
    while (x % primes[i] == 0) {
      ++factors[primes[i]];
      x /= primes[i];
    }
  }
  if (x != 1)
    ++factors[x];
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  make_primes();
  prime_factorize(n);
  int ans = 0;
  for (auto &&i : factors) {
    int x = 1;
    while (i.second - x >= 0) {
      i.second -= x;
      ans++;
      x++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int calc(int n) {
  for (int i = 1;; i++) {
    if (i * (i + 1) > n * 2)
      return i - 1;
  }
}

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

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> vp = prime_factorize(n);
  int ans = 0;
  for (int i = 0; i < vp.size(); i++)
    ans += calc(vp[i].second);
  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

int calc(int n) {
  for (int i = 1;; i++) {
    if (i * (i + 1) > n * 2)
      return i - 1;
  }
}

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

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> vp = prime_factorize(n);
  int ans = 0;
  for (int i = 0; i < vp.size(); i++)
    ans += calc(vp[i].second);
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const int maxn = 500050;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 7e18;
ll power(ll x, ll y) {
  ll ans = 1;
  while (y) {
    if (y & 1)
      ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}

ll gcd(ll x, ll y) {
  if (x % y == 0)
    return y;
  return gcd(y, x % y);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int j, k = 0;
  ll n, i;
  cin >> n;
  for (i = 2; i * i <= n; i++) {
    j = 0;
    while (n % i == 0) {
      n /= i;
      j++;
    }
    int cnt = 1;
    while (j >= cnt) {
      j -= cnt;
      cnt++;
      k++;
    }
  }
  if (n != 1)
    k++;
  cout << k << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const int maxn = 500050;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 7e18;
ll power(ll x, ll y) {
  ll ans = 1;
  while (y) {
    if (y & 1)
      ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}

ll gcd(ll x, ll y) {
  if (x % y == 0)
    return y;
  return gcd(y, x % y);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int i, j, k = 0;
  ll n;
  cin >> n;
  for (i = 2; i * i <= n; i++) {
    j = 0;
    while (n % i == 0) {
      n /= i;
      j++;
    }
    int cnt = 1;
    while (j >= cnt) {
      j -= cnt;
      cnt++;
      k++;
    }
  }
  if (n != 1)
    k++;
  cout << k << "\\n";
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

/**
        1.对题分析，要让转化次数越大，则先从最小开始。
        2.对一个数的x质数，最多能分为多少个不同的数
        3.只需求到根号n以内的变化值
**/
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
int solve(int x) { // 计算以i为底，以x为指数一共有多少不同的值
  int now = 1, res = 0;
  while (now <= x) {
    x -= now;
    now++;
    res++;
  }
  return res;
}
int main() {
  ll n;
  int ans = 0;
  cin >> n;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) { // 计算以i为底的指数为多少
        n /= i;
        cnt++;
      }
      ans += solve(cnt);
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

/**
        1.对题分析，要让转化次数越大，则先从最小开始。
        2.对一个数的x质数，最多能分为多少个不同的数
        3.只需求到根号n以内的变化值
**/
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
int solve(int x) { // 计算以i为底，以x为指数一共有多少不同的值
  int now = 1, res = 0;
  while (now <= x) {
    x -= now;
    now++;
    res++;
  }
  return res;
}
int main() {
  ll n;
  int ans = 0;
  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) { // 计算以i为底的指数为多少
        n /= i;
        cnt++;
      }
      ans += solve(cnt);
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using vll = vector<ll>;
using P = pair<int, int>;
const int inf = 1e9 + 7;
const ll INF = 1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ll n;
  cin >> n;
  map<ll, ll> soin;
  ll c = n;
  for (ll i = 2; i * i <= n; i++) {

    while (n % i == 0) {
      soin[i]++;
      n /= i;
    }
  }
  ll ans = 0;
  if (n != 1)
    ans++;
  //

  for (ll i = 2; i * i <= c; i++) {
    for (int j = 1; j < 100; j++) {
      if (soin[i] >= j) {
        ans++;
        soin[i] -= j;
      } else
        break;
    }
  }
  if (c == 1)
    cout << 0 << endl;
  else {

    cout << ans << endl;
  }
  // cout<<sqrt(c)<<endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using vll = vector<ll>;
using P = pair<int, int>;
const int inf = 1e9 + 7;
const ll INF = 1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ll n;
  cin >> n;
  int soin[1100000];
  ll c = n;
  for (ll i = 2; i * i <= n; i++) {

    while (n % i == 0) {
      soin[i]++;
      n /= i;
    }
  }
  if (n != 1)
    soin[n]++;
  //
  ll ans = 0;
  for (ll i = 2; i * i <= c; i++) {
    for (int j = 1; j < 100; j++) {
      if (soin[i] >= j) {
        ans++;
        soin[i] -= j;
      } else
        break;
    }
  }
  if (c == 1)
    cout << 0 << endl;
  else {
    if (ans == 0)
      ans++;
    cout << ans << endl;
  }
  // cout<<sqrt(c)<<endl;
}
Problem p02660 (C++) — buggy submission, verdict: 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>;

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

  // 素因数分解
  vector<pair<ll, int>> f;
  const ll m = n;
  for (ll i = 2; i * i <= m; i++) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      x++;
    }
    f.emplace_back(i, x);
  }
  if (n != 1)
    f.emplace_back(n, 1);

  // 操作回数を数える
  int ans = 0;
  for (auto p : f) {
    int e = p.second;
    int b = 1;
    while (e >= b) {
      e -= b;
      b++;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

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>;

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

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

  vector<P> f;
  for (int i = 2;; i++) {
    if (n % i == 0) {
      P b = make_pair(i, 1);
      n /= i;
      while (1) {
        if (n % i == 0) {
          b.second++;
          n /= i;
        } else
          break;
      }
      f.push_back(b);
    }
    if (n == 1)
      break;
  }

  int ans = 0;
  int m = f.size();
  rep(i, m) {
    for (int j = 1;; j++) {
      f[i].second -= j;
      if (f[i].second >= 0)
        ans++;
      else
        break;
    }
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t
// 素数判定
bool isPrime(ll x) {
  ll 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;
}

int main() {
  ll N;
  cin >> N;
  if (isPrime(N)) {
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> M;
  for (ll i = 2; i <= N; i++) {
    if (!isPrime(i))
      continue;
    bool flag = false;
    while (N % i == 0) {
      flag = true;
      N /= i;
      M[i]++;
    }
    if (flag && isPrime(N)) {
      M[N]++;
      N = 1;
      break;
    }
    if (N == 1)
      break;
  }
  ll ans = 0;
  for (auto m : M) {
    ll cnt = 1;
    while (1) {
      if (m.second >= cnt) {
        m.second -= cnt;
        cnt++;
        ans++;
      } else
        break;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t
// 素数判定
bool isPrime(ll x) {
  ll 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;
}

int main() {
  ll N;
  cin >> N;
  if (isPrime(N)) {
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> M;
  for (ll i = 2; i <= N; i++) {
    if (!isPrime(i))
      continue;

    while (N % i == 0) {
      N /= i;
      M[i]++;
    }
    if (N == 1)
      break;
  }
  ll ans = 0;
  for (auto m : M) {
    ll cnt = 1;
    while (1) {
      if (m.second >= cnt) {
        m.second -= cnt;
        cnt++;
        ans++;
      } else
        break;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t
// 素数判定
bool isPrime(ll x) {
  ll 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;
}

int main() {
  ll N;
  cin >> N;
  if (isPrime(N)) {
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> M;
  for (ll i = 2; i <= min((ll)1e6 + 5, N); i++) {
    if (!isPrime(i))
      continue;
    // cout << i << endl;
    bool flag = false;
    while (N % i == 0) {
      N /= i;
      M[i]++;
      flag = true;
    }
    if (flag && isPrime(N)) {
      M[N]++;
      N = 1;
      break;
    } else if (N == 1)
      break;
  }
  ll ans = 0;
  if (N != 1) {
    cout << N << endl;
    if (ceill(sqrt(N)) * ceill(sqrt(N)) == N)
      ans++;
    else if (isPrime(N))
      ans++;
    else
      ans += 2;
  }
  for (auto m : M) {
    ll cnt = 1;
    while (1) {
      if (m.second >= cnt) {
        m.second -= cnt;
        cnt++;
        ans++;
      } else
        break;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t
// 素数判定
bool isPrime(ll x) {
  ll 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;
}

int main() {
  ll N, N_;
  cin >> N;
  if (isPrime(N)) {
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> M;
  for (ll i = 2; i <= N; i++) {
    if (!isPrime(i))
      continue;
    // cout << i << endl;
    bool flag = false;
    while (N % i == 0) {
      N /= i;
      M[i]++;
    }
    if (flag && isPrime(N)) {
      M[N]++;
      N = 1;
      break;
    } else if (N == 1)
      break;
  }

  /*if(N != 1){
      if(ceill(sqrt(N)) * ceill(sqrt(N)) == N) cout << 1 << endl;
      else cout << 2 << endl;
      return 0;
  }*/
  ll ans = 0;
  for (auto m : M) {
    ll cnt = 1;
    while (1) {
      if (m.second >= cnt) {
        m.second -= cnt;
        cnt++;
        ans++;
      } else
        break;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#include <map>
using namespace std;

map<long, int> fac(long n) {
  map<long, int> M;
  for (long i = 2; i <= n; i++) {
    if (n == 1)
      break;
    if (i * i > n) {
      M[n] = 1;
      break;
    }
    if (n % i == 0) {
      M[i] = 0;
      while (n % i == 0) {
        n /= i;
        M[i]++;
      }
    }
  }
  return M;
}

int main() {
  long N;
  cin >> N;
  map<long, int> M = fac(N);
  int c = 0;
  for (auto it = M.begin(); it != M.end(); it++) {
    c += (int)((-1.0 + sqrt(1.1 + 8.0 * it->second)) / 2.0);
  }
  cout << c << endl;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <map>
using namespace std;

map<long, int> fac(long n) {
  map<long, int> M;
  for (int i = 2; i <= n; i++) {
    if (n == 1)
      break;
    if (i * i > n) {
      M[n] = 1;
      break;
    }
    if (n % i == 0) {
      M[i] = 0;
      while (n % i == 0) {
        n /= i;
        M[i]++;
      }
    }
  }
  return M;
}

int main() {
  long N;
  cin >> N;
  map<long, int> M = fac(N);
  int c = 0;
  for (auto it = M.begin(); it != M.end(); it++) {
    c += (int)((-1.0 + sqrt(1.1 + 8.0 * it->second)) / 2.0);
  }
  cout << c << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x) {
  std::cout << x << " ";
}
template <typename T>

void println(T x) {
  std::cout << x << "\\n";
}

int decompositPrime(int n) {
  int a = 2;
  int cnt = 0;
  int ans = 0;
  while (n >= a * a) {
    cnt = 0;
    while (n % a == 0) {
      n /= a;
      cnt++;
    }
    int sub = 1;
    while (cnt >= sub) {
      cnt -= sub;
      ans++;
      sub++;
    }
    a++;
  }
  if (n != 1) {
    ans++;
  }
  return ans;
}

signed main(void) {
  int n;
  cin >> n;
  print(decompositPrime(n));
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x) {
  std::cout << x << " ";
}
template <typename T>

void println(T x) {
  std::cout << x << "\\n";
}

int decompositPrime(int n) {
  int a = 2;
  int cnt = 0;
  int ans = 0;
  while (n >= a * a) {
    if (n % a != 0)
      continue;
    cnt = 0;
    while (n % a == 0) {
      n /= a;
      cnt++;
    }
    int sub = 1;
    while (cnt >= sub) {
      cnt -= sub;
      ans++;
      sub++;
    }
    a++;
  }
  if (n != 1)
    ans++;
  return ans;
}

signed main(void) {
  int n;
  cin >> n;
  print(decompositPrime(n));
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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 int INF = (1 << 30) - 1;
const ll LINF = (1LL << 60) - 1;

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

void solve() {
  ll n;
  cin >> n;
  auto mp = prime_factor(n);
  int ans = 0;
  for (auto p : mp) {
    int m = 1;
    while (p.se >= m) {
      ans++;
      p.se -= m;
      m++;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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 int INF = (1 << 30) - 1;
const ll LINF = (1LL << 60) - 1;

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

void solve() {
  ll n;
  cin >> n;
  auto mp = prime_factor(n);
  int ans = 0;
  for (auto p : mp) {
    int m = 1;
    while (p.se >= m) {
      ans++;
      p.se -= m;
      m++;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

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

  long long n;
  cin >> n;
  int ans = 0;
  int div = 2;
  while (n > 1 && div * 1LL * div <= n) {
    int cur = 0;
    int next = 1;
    while (n % div == 0) {
      cur++;
      if (cur == next) {
        cur = 0;
        next++;
      }
      n /= div;
    }
    div++;
    ans += next - 1;
  }
  if (n > 1)
    ans++;
  cout << ans;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

  long long n;
  cin >> n;
  int ans = 0;
  int div = 2;
  while (n > 1 && div * div <= n) {
    int cur = 0;
    int next = 1;
    while (n % div == 0) {
      cur++;
      if (cur == next) {
        cur = 0;
        next++;
      }
      n /= div;
    }
    div++;
    ans += next - 1;
  }
  if (n > 1)
    ans++;
  cout << ans;

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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 100000000000007
using namespace std;
using pii = pair<int, int>;
using LL = int64_t;

vector<pair<int64_t, int64_t>> fs; // 素因数分解の素数，指数のペア

void factorization(int64_t base) { // baseを素因数分解
  // base未満のiが約数か
  for (
      int64_t i = 2; i * i <= base;
      i++) { /*ここのint64_tをintにするとTLEする(キャストって結構時間かかるっぽい)*/
    // iで割り切れるなら限界まで割る

    if (base % i == 0) {
      int64_t cnt = 0;
      while (base % i == 0) {
        base /= i;
        cnt++;
      }
      fs.push_back(make_pair(i, cnt));
    }
  }
  // baseが素数
  if (base > 1) {
    fs.push_back(make_pair(base, 1));
  }
}
int main() {
  int64_t n;
  cin >> n;

  factorization(n);
  // prime_factorize(n);
  int64_t ans = 0;
  for (auto p : fs) {
    int64_t e;
    e = p.second;
    int k = 1;
    while (e - k >= 0) {
      e -= k;
      k++;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 100000000000007
using namespace std;
using pii = pair<int, int>;
using LL = int64_t;

vector<pair<int64_t, int64_t>> fs; // 素因数分解の素数，指数のペア

void prime_factorize(LL N) {
  // vector<pair<LL, LL>> res;
  for (LL a = 2; a * a <= N; a++) {
    if (N % a == 0) {
      LL ex = 0; // 指数

      // 割れる限り割り続ける
      while (N % a == 0) {
        ++ex;
        N /= a;
      }

      fs.push_back(make_pair(a, ex));
    }
  }

  // 最後に残った数について
  if (N != 1)
    fs.push_back(make_pair(N, 1));
}

void factorization(int64_t base) { // baseを素因数分解
  // base未満のiが約数か
  for (int i = 2; i * i <= base; i++) {
    // iで割り切れるなら限界まで割る

    if (base % i == 0) {
      int64_t cnt = 0;
      while (base % i == 0) {
        base /= i;
        cnt++;
      }
      fs.push_back(make_pair(i, cnt));
    }
  }
  // baseが素数
  if (base > 1) {
    fs.push_back(make_pair(base, 1));
  }
}
int main() {
  int64_t n;
  cin >> n;

  factorization(n);
  // prime_factorize(n);
  int64_t ans = 0;
  for (auto p : fs) {
    int64_t e;
    e = p.second;
    int k = 1;
    while (e - k >= 0) {
      e -= k;
      k++;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}