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

#include <bits/stdc++.h>

#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define endl "\\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

// 素数判定
// から派生して、最初の約数を返す
int isPrime(ll a) {
  if (a == 1)
    return 1;
  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0)
      return i;
  }
  return -1;
}

void solve() {
  ll n;
  cin >> n;

  ll first_prime = isPrime(n);
  if (first_prime <= 0) {
    cout << 1;
    return;
  }
  if (first_prime == 1) {
    cout << 0;
    return;
  }

  map<ll, ll> mp;

  int ans = 0;
  for (int i = first_prime; i <= n; i = isPrime(n)) {
    if (i == 1) {
      break;
    }
    if (i == -1) {
      mp[n]++;
      break;
    }
    while (n % i == 0) {
      // cout << i << " ";
      mp[i]++;
      n /= i;
    }
  }

  for (auto &m : mp) {
    // cout << m.first << " : " << m.second << endl;
    int i = 1;
    while (m.second >= i) {
      m.second -= i;
      ++i;
      ++ans;
    }
  }
  cout << ans;
}

int main() {
  fastio;
  solve();

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define endl "\\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

// 素数判定
// から派生して、最初の約数を返す
int isPrime(ll a) {
  if (a == 1)
    return 1;
  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0)
      return i;
  }
  return -1;
}

void solve() {
  ll n;
  cin >> n;

  ll first_prime = isPrime(n);
  if (first_prime <= 0) {
    cout << 1;
    return;
  }
  if (first_prime == 1) {
    cout << 0;
    return;
  }

  map<ll, ll> mp;

  int ans = 0;
  for (int i = first_prime; i <= n; i++) {
    while (n % i == 0) {
      // cout << i << " ";
      mp[i]++;
      n /= i;
    }
  }

  for (auto &m : mp) {
    // cout << m.first << " : " << m.second << endl;
    int i = 1;
    while (m.second >= i) {
      m.second -= i;
      ++i;
      ++ans;
    }
  }
  cout << ans;
}

int main() {
  fastio;
  solve();

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

#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>

using namespace std;

bool LF_PRIME_SEQUENCE(const long &n, vector<long> &vPrime) {
  if (n < 2) {
    return false;
  }
  vPrime.clear();
  vPrime.push_back(2);
  for (long i = 2; i * i <= n; i++) {
    int iPrimeType = 1;
    for (long j = 0; j < vPrime.size(); j++) {
      if (i % vPrime[j] == 0) {
        iPrimeType = 0;
        break;
      }
      if (i < vPrime[j] * vPrime[j]) {
        break;
      }
    }
    if (iPrimeType == 1) {
      vPrime.push_back(i);
    }
  }
  return true;
}

int main() {
  long N;
  scanf("%ld", &N);
  vector<long> vPrime;
  if (!LF_PRIME_SEQUENCE(N, vPrime)) {
    printf("%d", 0);
  } else {
    long nSum = 0;
    for (long int i = 0; i < vPrime.size(); i++) {
      int nCount = 0;
      while (N % vPrime[i] == 0) {
        N /= vPrime[i];
        nCount++;
      }
      if (nCount != 0) {
        int k = 0;
        for (int j = 1; j < nCount + 2; j++) {
          k += j;
          if (k > nCount) {
            nSum += (j - 1);
            break;
          }
        }
      }
    }
    if (N != 1) {
      nSum++;
    }
    printf("%d", nSum);
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>

using namespace std;

bool LF_PRIME_SEQUENCE(const long int &n, vector<int> &vPrime) {
  if (n < 2) {
    return false;
  }
  vPrime.clear();
  vPrime.push_back(2);
  for (int i = 2; i * i <= n; i++) {
    int iPrimeType = 1;
    for (int j = 0; j < vPrime.size(); j++) {
      if (i % vPrime[j] == 0) {
        iPrimeType = 0;
        break;
      }
      if (i < vPrime[j] * vPrime[j]) {
        break;
      }
    }
    if (iPrimeType == 1) {
      vPrime.push_back(i);
    }
  }
  return true;
}

int main() {
  long int N;
  scanf("%ld", &N);
  vector<int> vPrime;
  if (!LF_PRIME_SEQUENCE(N, vPrime)) {
    printf("%d", 0);
  } else {
    int nSum = 0;
    for (int i = 0; i < vPrime.size(); i++) {
      int nCount = 0;
      while (N % vPrime[i] == 0) {
        N /= vPrime[i];
        nCount++;
      }
      if (nCount != 0) {
        int k = 0;
        for (int j = 1; j < nCount + 2; j++) {
          k += j;
          if (k > nCount) {
            nSum += (j - 1);
            break;
          }
        }
      }
    }
    if (N != 1) {
      nSum++;
    }
    printf("%d", nSum);
  }

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

#include <bits/stdc++.h>
using namespace std;
#define n 1000000
int lowestp[n + 1];
bool prime[n + 1];
int ans = 0;
long long int count_p(long long int a, long long int b) {
  int c = 0;
  while (a % b == 0)
    a = a / b, c++;
  int i = 0, j = 1;
  while (1) {
    i += j;
    j++;
    if (i + j > c)
      break;
  }
  ans += j - 1;
  return a;
}
int main() {
  int t;

  memset(prime, true, sizeof(prime));

  for (int p = 2; p * p <= n; p++) {
    // If prime[p] is not changed, then it is a prime
    if (prime[p] == true) {
      // Update all multiples of p greater than or
      // equal to the square of it
      // numbers which are multiple of p and are
      // less than p^2 are already been marked.
      lowestp[p] = p;
      for (int i = p * p; i <= n; i += p)
        if (prime[i])
          prime[i] = false, lowestp[i] = p;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p])
      lowestp[p] = p;
  lowestp[1] = 1;
  long long int a;
  cin >> a;
  if (a == 1) {
    cout << 0 << endl;
    return 0;
  }
  long long int b = -1;
  for (long long int i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      b = i;
      break;
    }
  }
  // cout<<b<<"b"<<endl;
  if (b == -1)
    cout << 1;
  else {
    while (a != 1) {
      // cout<<a<<"a "<<b<<endl;
      a = count_p(a, b);

      if (a <= 1000000)
        b = lowestp[a];
      else {
        b = a;
        for (long long int i = 2; i * i <= a; i++) {
          if (a % i == 0) {
            b = i;
            break;
          }
        }
      }
    }
    cout << ans;
  }
  cout << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define n 1000000
int lowestp[n + 1];
bool prime[n + 1];
int ans = 0;
long long int count_p(long long int a, long long int b) {
  int c = 0;
  while (a % b == 0)
    a = a / b, c++;
  int i = 0, j = 1;
  while (1) {
    i += j;
    j++;
    if (i + j > c)
      break;
  }
  ans += j - 1;
  return a;
}
int main() {
  int t;

  memset(prime, true, sizeof(prime));

  for (int p = 2; p * p <= n; p++) {
    // If prime[p] is not changed, then it is a prime
    if (prime[p] == true) {
      // Update all multiples of p greater than or
      // equal to the square of it
      // numbers which are multiple of p and are
      // less than p^2 are already been marked.
      lowestp[p] = p;
      for (int i = p * p; i <= n; i += p)
        if (prime[i])
          prime[i] = false, lowestp[i] = p;
    }
  }
  long long int a;
  cin >> a;
  if (a == 1) {
    cout << 0 << endl;
    return 0;
  }
  long long int b = -1;
  for (long long int i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      b = i;
      break;
    }
  }
  if (b == -1)
    cout << 1;
  else {
    while (a != 1) {
      a = count_p(a, b);
      if (a <= 1000000)
        b = lowestp[a];
      else {
        b = a;
        for (long long int i = 2; i * i <= a; i++) {
          if (a % i == 0) {
            b = i;
            break;
          }
        }
      }
    }
    cout << ans;
  }
  cout << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\\n"
#define MOD 1000000007
#define DEB(x) cout << "##" << x << "##" << endl;
void solve() {
  ll n, count1 = 0, ans = 0;
  cin >> n;
  while (n % 2 == 0) {
    n = n / 2;
    count1++;
  }
  ans += (sqrt(1.0 + 8 * count1) - 1) / 2;
  for (int i = 3; i <= sqrt(n); i += 2) {
    count1 = 0;
    if (n == 1)
      break;
    while (n % i == 0) {
      n = n / i;
      count1++;
    }
    ans += (sqrt(1.0 + 8 * count1) - 1) / 2;
  }
  if (n != 1) {
    ans++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int tt = 1;
  // cin>>tt;
  while (tt--)
    solve();
  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\\n"
#define MOD 1000000007
#define DEB(x) cout << "##" << x << "##" << endl;
void solve() {
  ll n, count1 = 0, ans = 0;
  cin >> n;
  while (n % 2 == 0) {
    n = n / 2;
    count1++;
  }
  ans += (sqrt(1.0 + 8 * count1) - 1) / 2;
  for (int i = 3; i * i <= n; i += 2) {
    count1 = 0;
    if (n == 1)
      break;
    while (n % i == 0) {
      n = n / i;
      count1++;
    }
    ans += (sqrt(1.0 + 8 * count1) - 1) / 2;
  }
  if (n != 1) {
    ans++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int tt = 1;
  // cin>>tt;
  while (tt--)
    solve();
  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 ld long double
#define pii pair<ll, ll>
#define vi vector<ll>
#define si set<ll>
#define mii map<int, int>
#define umii unordered_map<ll, ll>
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define ask(x) cerr << #x << " = " << x << "\\n";
#define INF 1000000007
#define hell 998244353

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

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ll n, res = 0, t;
  cin >> n;

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

  for (ll i = 2; i * i <= n; ++i) {
    t = i;
    while (n % t == 0) {
      n /= t;
      t *= i;
      ++res;
    }
    while (n % i == 0)
      n /= i;
  }
  if (n > 1)
    ++res;

  cout << res;

  return 0;
}

Error: -8

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define vi vector<ll>
#define si set<ll>
#define mii map<int, int>
#define umii unordered_map<ll, ll>
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define ask(x) cerr << #x << " = " << x << "\\n";
#define INF 1000000007
#define hell 998244353

vector<bool> dp(1000010);

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

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

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ll n, cr = 0, res = 0, temp;
  cin >> n;

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

  for (ll i = 2; i * i <= 1000010; ++i)
    if (!dp[i])
      for (ll j = i * i; j <= 1000010; j += i)
        dp[j] = 1;

  vi primes;
  for (ll i = 2; i <= 1000010; ++i)
    if (!dp[i])
      primes.pb(i);

  // for (ll i = 0; i < 10; ++i)
  // 	cout << primes[i] << '\\n';

  while (true) {
    if (isPrime(n)) {
      ++res;
      break;
    } else {
      temp = primes[cr];
      while (n % temp == 0) {
        n /= temp;
        temp *= primes[cr];
        ++res;
      }
      ++cr;
    }
    if (primes[cr] > n)
      break;
  }

  cout << res;

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

#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, ans = 0, p;
  cin >> n;
  for (int i = 2; i < 1000010; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    for (int j = 1;; j++) {
      if (cnt < j) {
        break;
      }
      cnt = cnt - j;
      ans++;
    }
  }
  if (n > 1) {
    ans++;
  }
  cout << ans << "\\n";
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

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

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

#define dbg(a) cerr << __LINE__ << ": " << #a << " = " << a << '\\n'
typedef long long ll;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const ll MXN = 1e18;

map<ll, int> mp;
void factor(ll n) {
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      while (n % i == 0) {
        mp[i]++;
        n /= i;
      }
    }
  }
  if (n > 1) {
    mp[n]++;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  factor(n);
  int ans = 0;
  for (auto aa : mp) {
    long double p = aa.second;
    int val = (sqrt(1 + 8 * p) - 1) / 2;
    ans += val;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

#define dbg(a) cerr << __LINE__ << ": " << #a << " = " << a << '\\n'
typedef long long ll;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const ll MXN = 1e18;

map<ll, int> mp;
void factor(ll n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      while (n % i == 0) {
        mp[i]++;
        n /= i;
      }
    }
  }
  if (n > 1) {
    mp[n]++;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  factor(n);
  int ans = 0;
  for (auto aa : mp) {
    long double p = aa.second;
    int val = (sqrt(1 + 8 * p) - 1) / 2;
    ans += val;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <vector>
#define ll long long
using namespace std;
map<int, int> m;
int sum;
int main() {

  long long int num;
  scanf("%lld", &num);

  int num1 = num;

  for (long long int j = 2; j <= sqrt(num); j++) // 提供质因数
  {
    while (0 == (num % j)) // 循环判断质因数
    {
      if (0 == (num % j)) // 如果j是num的质因数
      {
        m[j]++;
        // cout<<j<<endl;
      }
      num = num / j;
    }
  }
  if (num != 1) {
    m[num]++;
  }

  map<int, int>::iterator iter;
  for (iter = m.begin(); iter != m.end(); iter++) {

    int k = iter->second;
    // cout<<k<<endl;
    int q = 1;
    while (k > 0) {

      if ((k - q) >= 0) {
        sum++;
      }

      k = k - q;
      q++;
    }
  }
  cout << sum << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <vector>
#define ll long long
using namespace std;
map<int, int> m;
int sum;
int main() {

  long long int num;
  scanf("%lld", &num);

  int num1 = num;

  int flag = 1; // 标示符标示num是质数

  for (long long int i = 2; i * i < num; i++) {
    if (0 == (num % i)) // 如果num不是质数
    {
      flag = 0; // 标示符标示num不是质数
    }
  }

  if (1 == flag && num != 1) // 当num是质数
  {
    cout << 1 << endl;
    return 0;
  } else // 当num不是质数
  {
    for (int j = 2; j <= num; j++) // 提供质因数
    {
      while (0 == (num % j)) // 循环判断质因数
      {
        if (0 == (num % j)) // 如果j是num的质因数
        {
          m[j]++;
          // cout<<j<<endl;
        }
        num = num / j;
      }
    }
  }

  map<int, int>::iterator iter;
  for (iter = m.begin(); iter != m.end(); iter++) {

    int k = iter->second;
    // cout<<k<<endl;
    int q = 1;
    while (k > 0) {

      if ((k - q) >= 0) {
        sum++;
      }

      k = k - q;
      q++;
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void solve_test() {
  LL n;
  cin >> n;

  int ops = 0;
  for (LL i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }

      int j = 1;
      while (cnt >= j) {
        cnt -= j;
        j++;
        ops++;
      }
    }
  }
  if (n > 1)
    ops++;

  cout << ops << '\\n';
}

int main() {
  int T;
  T = 1;
  for (int t = 1; t <= T; t++)
    solve_test();

  return 0;
}


Error: TLE

Fixed submission:

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

void solve_test() {
  LL n;
  cin >> n;

  int ops = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }

      int j = 1;
      while (cnt >= j) {
        cnt -= j;
        j++;
        ops++;
      }
    }
  }
  if (n > 1)
    ops++;

  cout << ops << '\\n';
}

int main() {
  int T;
  T = 1;
  for (int t = 1; t <= T; t++)
    solve_test();

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

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  long long n;
  cin >> n;
  long long num = n;
  int cnt = 0;

  for (long long i = 2; i * i <= n; i++) {
    if (num == 1)
      break;
    if (num % i != 0)
      continue;
    long long j = i;
    while (num % j == 0) {
      num /= j;
      j *= i;
      cnt++;
    }
    while (num % i == 0) {
      num /= i;
    }
  }

  if (num != 1)
    cnt++;

  cout << cnt << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int num = n;
  int cnt = 0;

  for (int i = 2; i * i <= n; i++) {
    if (num == 1)
      break;
    if (num % i != 0)
      continue;
    int j = i;
    while (num % j == 0) {
      num /= j;
      j *= i;
      cnt++;
    }
    while (num % i == 0) {
      num /= i;
    }
  }

  if (num != 1)
    cnt++;

  cout << cnt << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i, st, n) for (i = st; i < n; i++)
#define vec vector
#define mst(a, b) memset(a, b, sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld", &x)
#define pfl(x) printf("%lld\\n", x)
#define pf(x) printf("%lld", x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN

ll gcd(ll a, ll b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
ll power(ll x, ll y) {
  ll res = 1;
  while (y > 0) {
    if (y % 2 == 1) {
      res = (res * x);
    }
    x = (x * x);
    y = y / 2;
  }
  return res;
}

int main() {

  /*#ifndef ONLINE_JUDGE

     freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
    #endif
 */
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, i;
  cin >> n;
  if (n == 1)
    cout << "0";
  else {
    ll ans = 0;
    vec<ll> v;
    for (i = 2; i * i <= n; i++) {

      ll c = 0;
      while (n % i == 0) {
        c++;
        n /= i;
      }
      if (c)
        v.pb(c);
    }
    if (n > 1)
      v.pb(1);
    for (auto z : v) {
      for (i = 60; i > 0; i--) {
        if ((i * (i + 1)) / 2 <= z) {
          ans += i;
          break;
        }
      }
    }
    cout << ans;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i, st, n) for (i = st; i < n; i++)
#define vec vector
#define mst(a, b) memset(a, b, sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld", &x)
#define pfl(x) printf("%lld\\n", x)
#define pf(x) printf("%lld", x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN

ll gcd(ll a, ll b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
ll power(ll x, ll y) {
  ll res = 1;
  while (y > 0) {
    if (y % 2 == 1) {
      res = (res * x);
    }
    x = (x * x);
    y = y / 2;
  }
  return res;
}

int main() {

  /*#ifndef ONLINE_JUDGE

     freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
    #endif
 */
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  if (n == 1)
    cout << "0";
  else {
    ll ans = 0;
    vec<ll> v;
    for (int i = 2; i * i <= n; i++) {

      ll c = 0;
      while (n % i == 0) {
        c++;
        n /= i;
      }
      if (c)
        v.pb(c);
    }
    if (n > 1)
      v.pb(1);
    for (auto z : v) {
      for (int i = 60; i > 0; i--) {
        if ((i * (i + 1)) / 2 <= z) {
          ans += i;
          break;
        }
      }
    }
    cout << ans;
  }
  return 0;
}