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

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

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }

  vector<pair<ll, ll>> prime_factor;
  // vector<ll> factor_dimensition;

  // factorization
  for (ll i = 2; i * i <= n; i++) {
    // if(is_prime(i) && n%i==0){
    //     prime_factor.push_back(i);
    //     factor_dimensition.push_back(1);
    //     n /= i;
    //     while(n%i==0){
    //         n /= i;
    //         factor_dimensition[cur]++;
    //     }
    //     cur++;
    // }
    if (n % i == 0) {
      ll count = 0;
      while (n % i == 0) {
        n /= i;
        count++;
      }
      prime_factor.emplace_back(i, count);
      // factor_dimensition.push_back(count);
    }
  }
  if (n != 1) {
    prime_factor.push_back({n, 1});
    // factor_dimensition.push_back(1);
  }

  ll ans = 0;
  // count operation possible for each prime factor
  for (ll i = 0; i < prime_factor.size(); i++) {
    ll count = 1;
    while ((count + 2) * (count + 1) / 2 <= prime_factor[i].second) {
      count++;
    }
    ans += count;
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }

  vector<pair<ll, ll>> prime_factor;
  // vector<ll> factor_dimensition;

  // factorization
  for (int i = 2; i * i <= n; i++) {
    // if(is_prime(i) && n%i==0){
    //     prime_factor.push_back(i);
    //     factor_dimensition.push_back(1);
    //     n /= i;
    //     while(n%i==0){
    //         n /= i;
    //         factor_dimensition[cur]++;
    //     }
    //     cur++;
    // }
    if (n % i == 0) {
      ll count = 0;
      while (n % i == 0) {
        n /= i;
        count++;
      }
      prime_factor.emplace_back(i, count);
      // factor_dimensition.push_back(count);
    }
  }
  if (n != 1) {
    prime_factor.push_back({n, 1});
    // factor_dimensition.push_back(1);
  }

  ll ans = 0;
  // count operation possible for each prime factor
  for (int i = 0; i < prime_factor.size(); i++) {
    ll count = 1;
    while ((count + 2) * (count + 1) / 2 <= prime_factor[i].second) {
      count++;
    }
    ans += count;
  }

  cout << ans << endl;

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

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

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

  vector<pair<long long, int>> A;
  for (long long i = 2; i * i < N; i++) {
    int x = 0;
    while (N % i == 0) {
      N /= i;
      x++;
    }
    A.emplace_back(i, x);
  }
  if (N != 1)
    A.emplace_back(N, 1);

  int count = 0;
  for (auto p : A) {
    int b = 1;
    int y = p.second;
    while (y >= b) {
      y -= b;
      b++;
      count++;
    }
  }
  cout << count << endl;
}


Error: TLE

Fixed submission:

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

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

  vector<pair<long long, int>> A;
  for (int i = 2; i * i < N; i++) {
    int x = 0;
    while (N % i == 0) {
      N /= i;
      x++;
    }
    A.emplace_back(i, x);
  }
  if (N != 1)
    A.emplace_back(N, 1);

  int count = 0;
  for (auto p : A) {
    int b = 1;
    int y = p.second;
    while (y >= b) {
      y -= b;
      b++;
      count++;
    }
  }
  cout << count << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long n;
  cin >> n;
  long long rez = 0, d = 2;
  while (d * d <= n) {
    int ans = 0, cnt = 1;
    while (n % d == 0) {
      ans++;
      if (ans == cnt) {
        rez++;
        ans = 0;
        cnt++;
      }
      n /= d;
    }
    d++;
  }
  if (n != 1) {
    rez++;
  }
  cout << rez;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
int v[1000000];
int main() {
  long long n;
  cin >> n;
  int d = 2, cnt = 0;
  while (d * d <= n) {
    int ans = 0;
    while (n % d == 0) {
      ans++;
      n /= d;
    }
    if (ans > 0) {
      v[cnt] = ans;
      cnt++;
    }
    d++;
  }
  if (n != 1) {
    v[cnt]++;
  }
  int rez = 0;
  for (int i = 0; i <= cnt; i++) {
    int ans = 1;
    while (ans <= v[i]) {
      rez++;
      v[i] -= ans;
      ans++;
    }
  }
  cout << rez;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  long long N;
  std::cin >> N;

  std::vector<long> primes;
  // 8 -> [(2, 3)]
  // 24 -> [(2, 3), (3, 1)] -> (_^1 * _^2) * (3^1)
  for (long long i = 2; i * i <= N; i++) {
    if (i > N)
      break;
    long long count = 0;
    while (N % i == 0) {
      N /= i;
      count++;
    }
    if (count > 0) {
      primes.push_back(count);
    }
  }
  if (N != 1) {
    primes.push_back(1);
  }
  long long result = 0;
  for (auto const &e : primes) {
    // l*(l+1)/2 <= e < (l+1)*(l+2)/2 となるようなl
    long long l = 1;
    while (true) {
      auto flag = l * (l + 1) <= 2 * e && 2 * e < (l + 1) * (l + 2);
      if (flag) {
        break;
      }
      l++;
    }
    result += l;
  }
  std::cout << result << std::endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  long long N;
  std::cin >> N;

  std::vector<long> primes;
  // 8 -> [(2, 3)]
  // 24 -> [(2, 3), (3, 1)] -> (_^1 * _^2) * (3^1)
  long long n = N;
  for (long long i = 2; i <= n; i++) {
    if (i > N)
      break;
    long long count = 0;
    while (N % i == 0) {
      N /= i;
      count++;
    }
    if (count > 0) {
      primes.push_back(count);
    }
  }
  long long result = 0;
  for (auto const &e : primes) {
    // l*(l+1)/2 <= e < (l+1)*(l+2)/2 となるようなl
    long long l = 1;
    while (true) {
      auto flag = l * (l + 1) <= 2 * e && 2 * e < (l + 1) * (l + 2);
      if (flag) {
        break;
      }
      l++;
    }
    result += l;
  }
  std::cout << result << std::endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

int fun(int x) {
  int ans = 0;
  for (int i = 1;; i++) {
    ans += i;
    if (ans == x)
      return i;
    else if (x < ans)
      return i - 1;
  }
}

int main() {
  ll n;
  cin >> n;
  ll half = sqrt(n);
  int ans = 0;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 2; i < half; i++) {
    int a = 0;
    while (n % i == 0) {
      a++;
      n /= i;
    }
    ans += fun(a);
  }
  if (n > 1)
    cout << ans + 1 << endl;
  else
    cout << ans << endl;

  return 0;
}

Error: -8

Fixed submission:

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

int fun(int x) {
  int ans = 0;
  for (int i = 1;; i++) {
    ans += i;
    if (ans == x)
      return i;
    else if (x < ans)
      return i - 1;
  }
}

int main() {
  ll n;
  cin >> n;
  ll half = sqrt(n);
  int ans = 0;
  for (int i = 0; i < half; i++) {
    int a = 0;
    while (n % i == 0) {
      a++;
      n /= i;
    }
    ans += fun(a);
  }
  if (n > 1)
    cout << ans + 1 << endl;
  else
    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;
#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;
}

Error: TLE

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

#include <iostream>
#include <unordered_map>

using namespace std;

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

  unordered_map<long long, int> factor;

  long long a = 2;

  long long N0 = N;

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

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

      if (N < a * a) {
        a = N;
      }
    }
  }

  int count = 0;

  for (const auto &f : factor) {
    int e_sum = f.second;

    int e = 1;

    while (true) {
      if (e_sum >= e) {
        count++;
        e_sum -= e;
        e++;
      } else {
        break;
      }
    }
  }

  cout << count << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <unordered_map>

using namespace std;

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

  unordered_map<long long, int> factor;

  long long a = 2;

  long long N0 = N;

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

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

      if (N0 < a * a) {
        a = N0;
      }
    }
  }

  int count = 0;

  for (const auto &f : factor) {
    int e_sum = f.second;

    int e = 1;

    while (true) {
      if (e_sum >= e) {
        count++;
        e_sum -= e;
        e++;
      } else {
        break;
      }
    }
  }

  cout << count << endl;

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define rep(i, cc, n) for (int i = cc; i <= n; ++i)
#define drep(i, cc, n) for (int i = cc; i >= n; --i)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll choose2(ll n) { return n * (n - 1) / 2; }

int main() {
  ll n;
  cin >> n;
  vector<int> res;

  int cnt = 0;

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

  for (ll a = 2; a * a <= n; a++) {
    if (n % a != 0)
      continue;

    int ex = 0;
    int tmp = 0;
    while (n % a == 0) {
      ex++;
      if (tmp < ex) {
        cnt++;
        tmp = ex;
        ex = 0;
      }
      n /= a;
    }
  }

  if (n != 1)
    cnt++;

  cout << cnt << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define rep(i, cc, n) for (int i = cc; i <= n; ++i)
#define drep(i, cc, n) for (int i = cc; i >= n; --i)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll choose2(ll n) { return n * (n - 1) / 2; }

int main() {
  ll n;
  cin >> n;
  vector<int> res;

  int cnt = 0;

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

  for (int a = 2; a * a <= n; a++) {
    if (n % a != 0)
      continue;

    int ex = 0;
    int tmp = 0;
    while (n % a == 0) {
      ex++;
      if (tmp < ex) {
        cnt++;
        tmp = ex;
        ex = 0;
      }
      n /= a;
    }
  }

  if (n != 1)
    cnt++;

  cout << cnt << endl;

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

#include <bits/stdc++.h>

using namespace std;

long long N;

vector<long long> Primes;
vector<bool> E;

int main(void) {
  long long tmp, count = 0, ans = 0;
  vector<pair<long long, long long>> Z;

  cin >> N;

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

  tmp = N;
  for (long long i = 2; i <= sqrt(N); i++) {
    count = 0;

    while (N % i == 0) {
      count++;
      N = N / i;
    }

    if (count > 0)
      Z.push_back(make_pair(i, count));
  }
  if (N > 1) {
    Z.push_back(make_pair(N, 1));
  }

  if (Z.size() == 0) {
    cout << 1 << endl;
    return 0;
  }

  for (long long i = 0; i < Z.size(); i++) {
    long long j = 1;
    tmp = Z[i].second;
    while (tmp >= j) {
      ans++;
      tmp = tmp - j;
      j++;
    }
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  long long N, tmp, count = 0, ans = 0;
  vector<pair<long long, long long>> Z;

  cin >> N;
  tmp = 2;
  while (N >= 1) {
    if (N % tmp == 0) {
      count++;
      N = N / tmp;
    } else {
      if (count > 0) {
        pair<long long, long long> P = make_pair(tmp, count);
        Z.push_back(P);
      }
      count = 0;
      tmp++;

      if (tmp > N) {
        break;
      }
    }
  }

  for (auto i : Z) {
    long long j = 1;
    tmp = i.second;
    while (tmp >= j) {
      ans++;
      tmp = tmp - j;
      j++;
    }
  }

  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;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i <= n; i++) {
    ll count = 0;
    bool sd = 0;
    while (n % i == 0) {
      n /= i;
      count++;
      sd = 1;
    }
    ll tmp = 0;
    for (int j = 1; count >= j; j++) {
      count -= j;
      tmp++;
    }
    ans += tmp;
    if (!sd && i > (ll)sqrt(n)) {
      ans++;
      break;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i <= n; i++) {
    if (ans == 0 && i > (ll)sqrt(n)) {
      ans = 1;
      break;
    }
    ll count = 0;
    while (n % i == 0) {
      n /= i;
      count++;
    }
    ll tmp = 0;
    for (int j = 1; count >= j; j++) {
      count -= j;
      tmp++;
    }
    ans += tmp;
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int cal(int x) {
  int j = 1;
  while (x - j >= 0) {
    x -= j;
    j++;
  }
  return j - 1;
}
int main() {
  long long n;
  cin >> n;
  int m = int(sqrt(n));
  int a[m + 1];
  for (int i = 1; i <= m; i++)
    a[i] = 0;
  while (n % 2 == 0) {
    n /= 2;
    a[2]++;
  }
  int t = 3, ans = 0;
  while (n != 1 && t <= m) {
    while (n % t == 0) {
      n /= t;
      a[t]++;
    }
    t += 2;
  }
  for (int i = 1; i <= m; i++)
    if (a[i] != 0)
      ans += cal(a[i]);
  if (n == 1)
    cout << ans << endl;
  else
    cout << ans + 1 << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int cal(int x) {
  int j = 1;
  while (x - j >= 0) {
    x -= j;
    j++;
  }
  return j - 1;
}
int main() {
  long long n;
  cin >> n;
  int m = int(sqrt(n));
  int a[m + 1];
  for (int i = 1; i <= m; i++)
    a[i] = 0;
  while (n % 2 == 0) {
    n /= 2;
    a[2]++;
  }
  int t = 3, ans = 0;
  while (n != 1) {
    while (n % t == 0) {
      n /= t;
      a[t]++;
    }
    t += 2;
  }
  for (int i = 1; i <= m; i++)
    if (a[i] != 0)
      ans += cal(a[i]);
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

typedef unsigned long long int ll;

const ll pmax = 1000001;
const ll nmax = (pmax - 1) * (pmax - 1);
const ll powmax = 65;

bool prime[pmax];
ll countsum[powmax];

void countcalc() {
  countsum[0] = 0;
  ll base = 1;
  ll nextsum = 3;
  for (ll i = 1; i < powmax; i++) {
    if (i >= nextsum) {
      base++;
      nextsum += base + 1;
    }
    countsum[i] = base;
    // cout << i << " " << countsum[i] << endl;
  }
}

void sieve() {
  for (ll i = 0; i < pmax; i++)
    prime[i] = true;
  for (ll i = 2; i < ceil(sqrt(pmax)); i++) {
    if (!prime[i])
      continue;
    for (ll j = i + i; j < pmax; j += i)
      prime[j] = false;
  }
}

int main() {
  countcalc();
  sieve();

  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i < pmax; i++) {
    if (!prime[i])
      continue;
    ll cnt = 0;
    while (n % i == 0) {
      n = n / i;
      cnt++;
    }
    // if(cnt != 0) cout << i << " : " << cnt << endl;
    ans += countsum[cnt];
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Error: WA

Fixed submission:

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

typedef unsigned long long int ll;

const ll pmax = 1000001;
const ll nmax = (pmax - 1) * (pmax - 1);
const ll powmax = 65;

bool prime[pmax];
int countsum[powmax];

int countcalc() {
  countsum[0] = 0;
  int base = 1;
  int basesum = 1;
  int nextsum = 3;
  for (int i = 1; i < powmax; i++) {
    if (i >= nextsum) {
      base++;
      basesum = nextsum;
      nextsum += base + 1;
    }
    countsum[i] = base;
  }
}

int sieve() {
  for (int i = 0; i < pmax; i++)
    prime[i] = true;
  for (int i = 2; i < ceil(sqrt(pmax)); i++) {
    if (!prime[i])
      continue;
    for (int j = i + i; j < pmax; j += i)
      prime[j] = false;
  }
}

int main() {
  countcalc();
  sieve();

  int n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i < pmax; i++) {
    if (!prime[i])
      continue;
    int cnt = 0;
    while (n % i == 0) {
      n = n / i;
      cnt++;
    }
    if (cnt != 0)
      cout << i << " : " << cnt << endl;
    ans += countsum[cnt];
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

long long order(long long n) { return (-1 + sqrt(8 * n + 1)) / 2; }

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

  long long res = 0;

  for (long long i = 2; i * i <= n; ++i) {
    long long ctr = 0;
    while (n % i == 0) {
      ctr++;
      n /= i;
    }
    res += order(ctr);
  }

  if (n > 1)
    res++;
  cout << res << '\\n';
  return 0;
}

Error: TLE

Fixed submission:

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

long long order(long long n) { return (-1 + sqrt(8 * n + 1)) / 2; }

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

  int res = 0;
  for (int i = 2; i * i <= n; ++i) {
    int ctr = 0;
    while (n % i == 0) {
      ctr++;
      n /= i;
    }
    res += order(ctr);
  }

  if (n > 1)
    res++;
  cout << res << '\\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)
using namespace std;
using ll = long long;

int main() {
  long long N;
  int answer = 0;
  vector<pair<long long, long long>> prime;
  cin >> N;
  for (long long i = 2; i * i < N; ++i) {
    if (N % i != 0)
      continue;
    int cnt = 0;
    while (N % i == 0) {
      ++cnt;
      N /= i;
    }
    prime.push_back(make_pair(i, cnt));
  }
  if (N != 1)
    prime.push_back(make_pair(N, 1));

  for (long long i = 0; i < prime.size(); ++i) {
    int t = 1, cnt = 0;
    while (prime[i].second > cnt) {
      prime[i].second -= t;
      ++cnt;
      ++t;
    }
    answer += cnt;
  }

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

int main() {
  long long N;
  int answer = 0;
  vector<pair<long long, long long>> prime;
  cin >> N;
  for (int i = 2; i * i < N; ++i) {
    if (N % i != 0)
      continue;
    int cnt = 0;
    while (N % i == 0) {
      ++cnt;
      N /= i;
    }
    prime.push_back(make_pair(i, cnt));
  }
  if (N != 1)
    prime.push_back(make_pair(N, 1));

  for (int i = 0; i < prime.size(); ++i) {
    int t = 1, cnt = 0;
    while (prime[i].second > cnt) {
      prime[i].second -= t;
      ++cnt;
      ++t;
    }
    answer += cnt;
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }

  ll cp = n;
  ll ans = 0;
  for (ll i = 2; i * i <= cp; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    ll k = 1;
    while (k * (k + 1) / 2 <= cnt) {
      k++;
    }
    ans += k - 1;
  }
  ans += (n != 1);
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

static const int MAX = 1e+6;
bool isPrime[MAX + 1];

void eratos(int n) {
  for (int i = 0; i <= n; i++) {
    isPrime[i] = true;
  }
  isPrime[0] = isPrime[1] = false;
  for (ll i = 2; i * i <= n; i++) {
    if (isPrime[i]) {
      int j = i + i;
      while (j <= n) {
        isPrime[j] = false;
        j += i;
      }
    }
  }
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;

  ll cp = n;
  eratos(n);

  bool flag = (n != 1);
  for (ll i = 2; i * i <= cp; i++) {
    if (n % i == 0) {
      if (isPrime[i]) {
        ll cnt = 0;
        while (n % i == 0) {
          n /= i;
          cnt++;
        }
        ll k = 1;
        while (k * (k + 1) / 2 <= cnt) {
          k++;
        }
        ans += k - 1;
        flag = false;
      }
    }
  }
  cout << ans + flag << endl;
  return 0;
}