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

#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

vector<long long> f(long long x) {
  vector<long long> ans;
  for (long long a = 2; a * a <= x; ++a) {
    if (x % a != 0)
      continue;
    long long ex = 0; // 指数

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

    // その結果を push
    for (int i = 0; i < ex; i++)
      ans.push_back(a);
  }
  if (x != 1)
    ans.push_back(x);

  return ans;
}

void ff(long long x) {
  vector<long long> ans;
  for (long long a = 2; a * a <= x; ++a) {
    if (x % a != 0)
      continue;
    long long ex = 0; // 指数

    // 割れる限り割り続ける
    while (x % a == 0) {
      cout << " " << x << endl;
      ++ex;
      x /= a;
    }

    // その結果を push
    for (int i = 0; i < ex; i++)
      ans.push_back(a);
  }
}

long long g(long long x) {
  long long y = 0, count = 0;
  if (x == 1)
    return 1;
  for (int i = 1; i < x; i++) {
    y += i;

    if (y > x) {
      break;
    } else {
      count++;
    }
  }

  return count;
}

int main() {
  long long n, ans = 0;
  cin >> n;
  /**/
  vector<long long> x = f(n);
  vector<long long> y(1000);

  int count = 0;
  y.at(0)++;
  for (int i = 1; i < x.size(); i++) {
    // cout << " " << x.at(i) << endl;
    if (x.at(i) == x.at(i - 1)) {
      y.at(count)++;
    } else {
      count++;
      y.at(count)++;
    }
  }

  count = 0;

  while (y.at(count) != 0) {
    // cout << y.at(count) << endl;

    long long x;

    ans += g(y.at(count));
    // cout << g(y.at(count)) << endl;
    count++;
  }

  if (n == 1)
    ans = 0;
  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

vector<long long> f(long long x) {
  vector<long long> ans;
  if (x == 1)
    return ans;
  else {
    int i = 2;
    while (x > 1) {
      while (x % i == 0) {
        ans.push_back(i);
        x /= i;
      }
      i++;
    }
    return ans;
  }
}

long long g(long long x) {
  long long y = 0, count = 0;
  if (x == 1)
    return 1;
  for (int i = 1; i < x; i++) {
    y += i;

    if (y > x) {
      break;
    } else {
      count++;
    }
  }

  return count;
}

int main() {
  long long n, ans = 0;
  cin >> n;
  /**/
  vector<long long> x = f(n);
  vector<long long> y(1000);

  int count = 0;
  y.at(0)++;
  for (int i = 1; i < x.size(); i++) {
    // cout << " " << x.at(i) << endl;
    if (x.at(i) == x.at(i - 1)) {
      y.at(count)++;
    } else {
      count++;
      y.at(count)++;
    }
  }

  count = 0;

  while (y.at(count) != 0) {
    // cout << y.at(count) << endl;

    long long x;

    ans += g(y.at(count));
    // cout << g(y.at(count)) << endl;
    count++;
  }

  if (n == 1)
    ans = 0;
  cout << ans << endl;

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

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sayyes cout << "Yes" << endl;
#define sayno cout << "No" << endl;
using namespace std;
typedef long long ll;
const double PI = acos(-1);
typedef pair<int, int> P;
const int mod = 1e9 + 7;

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

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

    // その結果を push
    res.push_back({a, ex});
  }

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

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

  ll ans = 0;
  auto factor = prime_factorize(n);
  for (auto v : factor) {
    int s = v.second;
    int sa = 1;
    while (1) {
      s -= sa;
      if (s < 0)
        break;
      sa++;
      ans++;
    }
  }
  cout << ans;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sayyes cout << "Yes" << endl;
#define sayno cout << "No" << endl;
using namespace std;
typedef long long ll;
const double PI = acos(-1);
typedef pair<int, int> P;
const int mod = 1e9 + 7;

map<int, int> prime_factor(ll n) {
  map<int, int> res;
  for (
      int i = 2; i * i <= n;
      i++) // i以下はすでに試しているからi*iよりnが小さかったらもう割り切れるものはない
  {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

int main() {
  ll n;
  cin >> n;
  map<int, int> factor;
  ll ans = 0;
  factor = prime_factor(n);
  for (auto v : factor) {
    int s = v.second;
    int sa = 1;
    while (1) {
      s -= sa;
      if (s < 0)
        break;
      sa++;
      ans++;
    }
  }
  cout << ans;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

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

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod 1000000007
#define pii pair<int, int>
#define PI 2 * acos(0.0)
#define forn(i, n) for (int i = 0; i < n; i++)

vi prime;

void seive() {
  prime.pb(2);
  bitset<1000005> ck;
  for (int i = 3; i * i <= 1000005; i += 2)
    if (!ck[i])
      for (int j = i * i; j <= 1000005; j += 2 * i)
        ck[j] = 1;

  for (int i = 2; i <= 1000005; i += 2)
    if (!ck[i])
      prime.pb(i);
}

int main() {
  io;
  ll n;
  cin >> n;
  int ans = 0;
  for (ll x = 2; x * x <= n; x++) {
    if (n % x)
      continue;
    int p = 0;
    while (n % x == 0) {
      n /= x;
      p++;
    }
    int m = 1;
    while (p >= m) {
      ans++;
      p -= m;
      m++;
    }
  }
  if (n > 1)
    ans++;
  cout << ans << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

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

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod 1000000007
#define pii pair<int, int>
#define PI 2 * acos(0.0)
#define forn(i, n) for (int i = 0; i < n; i++)

int main() {
  io;
  ll n;
  cin >> n;
  int ans = 0;
  for (int x = 2; x * x <= n; x++) {
    if (n % x)
      continue;
    int p = 0;
    while (n % x == 0) {
      n /= x;
      p++;
    }
    int m = 1;
    while (p >= m) {
      ans++;
      p -= m;
      m++;
    }
  }
  if (n > 1)
    ans++;
  cout << ans << "\\n";
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < n; i++)
#define cint(a)                                                                \\
  int a;                                                                       \\
  cin >> a;
#define cstr(str)                                                              \\
  string str;                                                                  \\
  cin >> str;
#define vv(Type, n, m, d) vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

bool is_prime(ll a) {
  if (a == 1)
    return false;

  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0)
      return false;
  }
  return true;
}

int main(void) {

  ios::sync_with_stdio(false);
  cin.tie(0);

  vector<int> a;
  ll n;
  cin >> n;
  int cnt = 0;
  ll b = n;

  for (ll i = 2; i * i <= n; i++) {
    int c = 0;
    while (true) {
      if (n % i)
        break;
      c++;
      n /= i;
    }
    a.emplace_back(c);
  }

  for (auto d : a) {
    int i = 1;
    while (true) {
      if (d - i < 0)
        break;
      d -= i++;
      cnt += 1;
    }
  }
  if (n != 1)
    cnt++;
  cout << cnt << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < n; i++)
#define cint(a)                                                                \\
  int a;                                                                       \\
  cin >> a;
#define cstr(str)                                                              \\
  string str;                                                                  \\
  cin >> str;
#define vv(Type, n, m, d) vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

bool is_prime(ll a) {
  if (a == 1)
    return false;

  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0)
      return false;
  }
  return true;
}

int main(void) {

  ios::sync_with_stdio(false);
  cin.tie(0);

  map<ll, int> a;
  ll n;
  cin >> n;
  int cnt = 0;
  ll b = n;

  for (int i = 2; i * i <= n; i++) {
    int c = 0;
    while (true) {
      if (n % i)
        break;
      c++;
      n /= i;
    }
    if (c > 0)
      a[i] = c;
  }

  for (auto d : a) {
    int i = 1;
    while (true) {
      if (d.second - i < 0)
        break;
      d.second -= i++;
      cnt += 1;
    }
  }
  if (n != 1)
    cnt++;
  cout << cnt << endl;

  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: 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<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;
}

Error: 0

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<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;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for (int i = (a); i > (b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i)&1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

long long T[maxN];
const long long INF = 1000000000000000000ll;

void solve() {
  long long n;
  scanf("%lld", &n);
  int res = 0;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) {
      int c = 0;
      while (n % i == 0)
        n /= i, c++;

      int j = 0, s = 0;
      while (s + j + 1 <= c)
        j++, s += j;
      res += j;
    }

  if (n != 1ll)
    res++;
  printf("%d\\n", res);
}

int main() {
  int t = 1;
  // scanf ("%d", &t);
  while (t--)
    solve();
  return 0;
}


Error: TLE

Fixed submission:

#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for (int i = (a); i > (b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i)&1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

long long T[maxN];
const long long INF = 1000000000000000000ll;

void solve() {
  long long n;
  scanf("%lld", &n);
  int res = 0;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      int c = 0;
      while (n % i == 0)
        n /= i, c++;

      int j = 0, s = 0;
      while (s + j + 1 <= c)
        j++, s += j;
      res += j;
    }

  if (n != 1ll)
    res++;
  printf("%d\\n", res);
}

int main() {
  int t = 1;
  // scanf ("%d", &t);
  while (t--)
    solve();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

vector<bool> create_is_prime_table(uint64_t max_value) {
  vector<bool> is_prime(max_value + 1, true); // max_valueまでの素数表
  is_prime[0] = false;
  is_prime[1] = false;
  for (uint64_t i = 2; i <= max_value; ++i) {
    if (not is_prime[i])
      continue;
    for (uint64_t j = i * i; j <= max_value; j += i) {
      is_prime[j] = false;
    }
  }

  return is_prime;
}

int main() {
  uint64_t N;
  cin >> N;

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

  uint64_t sqrtN = uint64_t(floor(sqrt(N)));

  auto is_prime = create_is_prime_table(sqrtN + 1);

  uint64_t operation_cnt = 0;

  uint64_t N_divided = N;
  for (uint64_t i = 2; i <= sqrtN; ++i) {
    if (not is_prime[i])
      continue;
    if (N_divided < i)
      break;
    uint64_t powered_factor = i;
    while (N_divided % powered_factor == 0) {
      operation_cnt += 1;
      N_divided /= powered_factor;
      powered_factor *= i;
    }
  }

  cout << (operation_cnt + (N_divided > sqrtN ? 1 : 0)) << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

vector<bool> create_is_prime_table(uint64_t max_value) {
  vector<bool> is_prime(max_value + 1, true); // max_valueまでの素数表
  is_prime[0] = false;
  is_prime[1] = false;
  for (uint64_t i = 2; i <= max_value; ++i) {
    if (not is_prime[i])
      continue;
    for (uint64_t j = i * i; j <= max_value; j += i) {
      is_prime[j] = false;
    }
  }

  return is_prime;
}

int main() {
  uint64_t N;
  cin >> N;

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

  uint64_t sqrtN = uint64_t(floor(sqrt(N)));

  auto is_prime = create_is_prime_table(N + 1);

  // cout << "[";
  // for (uint64_t j = 0; j <= sqrtN; j++) {
  //   if (is_prime[j]) {
  //     cout << j << ", ";
  //   }
  // }
  // cout << "]" << endl;

  uint64_t operation_cnt = 0;
  bool N_is_prime = true;

  uint64_t N_divided = N;
  for (uint64_t i = 2; i <= N; ++i) {
    if (not is_prime[i])
      continue;
    if (N_divided < i)
      break;
    uint64_t powered_factor = i;
    while (N_divided % powered_factor == 0) {
      N_is_prime = false;
      operation_cnt += 1;
      N_divided /= powered_factor;
      powered_factor *= i;
    }
  }

  if (N_is_prime) {
    cout << "1" << endl;
  } else {
    cout << operation_cnt << endl;
  }

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

/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin
    Dept of ICE, NSTU
*/
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\\n"
#define f0(n) for (int i = 0; i < n; i++)
#define ms(x) memset(x, 0, sizeof(x))
#define ins insert
#define ALL(v) v.begin(), v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(), v.end())
#define maxv(v) *max_element(v.begin(), v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template <typename T> inline T Bigmod(T base, T power, T MOD) {
  T ret = 1;
  while (power) {
    if (power & 1)
      ret = (ret * base) % MOD;
    base = (base * base) % MOD;
    power >>= 1;
  }
  return ret;
}

bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
int main() {
  IOS ll n;
  while (cin >> n) {
    ll ans = 0;
    ll sq = sqrt(n) + 1;
    for (ll i = 2; i <= sq; i++) {
      ll cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      ll po = 1;
      while (cnt > 0) {
        if (cnt - po >= 0)
          ans++;
        cnt -= po;
        po++;
      }
    }
    if (n > 1)
      ans++;
    cout << ans << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin
    Dept of ICE, NSTU
*/
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\\n"
#define f0(n) for (int i = 0; i < n; i++)
#define ms(x) memset(x, 0, sizeof(x))
#define ins insert
#define ALL(v) v.begin(), v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(), v.end())
#define maxv(v) *max_element(v.begin(), v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template <typename T> inline T Bigmod(T base, T power, T MOD) {
  T ret = 1;
  while (power) {
    if (power & 1)
      ret = (ret * base) % MOD;
    base = (base * base) % MOD;
    power >>= 1;
  }
  return ret;
}

bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
int main() {
  IOS ll n;
  while (cin >> n) {
    int ans = 0;
    for (ll i = 2; i <= n; i++) {
      int cnt = 0;
      if (n % i == 0) {
        while (n % i == 0) {
          cnt++;
          n /= i;
        }
      }
      int po = 1;
      while (cnt > 0) {
        if (cnt - po >= 0)
          ans++;
        cnt -= po;
        po++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using ll = long long;
// print(fixed << setprecision(10));
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repk(i, n, k) for (ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9 + 7;

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

  ll n;
  cin >> n;
  int ans = 0, cnt, p;
  for (ll i = 2; i * i < n; i++) {
    if (n % i == 0) {
      cnt = 0;
      p = i;
      while (n % p == 0) {
        n /= p;
        p *= i;
        cnt++;
      }
      ans += cnt;
      while (n % i == 0) {
        if (n % p == 0)
          n /= p;
        else
          p /= i;
      }
    }
    if (i != 2)
      i++;
  }
  if (n != 1)
    ans++;
  print(ans);
  return 0;
}

Error: TLE

Fixed submission:

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

using ll = long long;
// print(fixed << setprecision(10));
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repk(i, n, k) for (ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9 + 7;

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

  ll n;
  cin >> n;
  int ans = 0, cnt, p;
  for (int i = 2; i * i < n; i++) {
    if (n % i == 0) {
      cnt = 0;
      p = i;
      while (n % p == 0) {
        n /= p;
        p *= i;
        cnt++;
      }
      ans += cnt;
      while (n % i == 0) {
        if (n % p == 0)
          n /= p;
        else
          p /= i;
      }
    }
    if (i != 2)
      i++;
  }
  if (n != 1)
    ans++;
  print(ans);
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
int main() {
  ll n, ans = 0;
  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]++;
  for (auto p : mp) {
    ll i = 1;
    while (p.second - i >= 0) {
      p.second -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
int main() {
  ll n, ans = 0;
  cin >> n;
  map<int, int> mp;
  for (int i = 2; i <= n; i += 2) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
    if (i == 2)
      i--;
  }
  for (auto p : mp) {
    int i = 1;
    while (p.second - i >= 0) {
      p.second -= i;
      i++;
      ans++;
    }
  }
  cout << ans;
}