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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bitset<1000010> pk;
vector<ll> udd;
void eos(ll x) {
  ll g, h, f;
  pk.set();
  pk[0] = pk[1] = 0;
  for (h = 4; h <= x; h += 2)
    pk[h] = 0;
  udd.push_back(2);
  for (g = 3; g <= x; g += 2)
    if (pk[g]) {
      for (h = g * g, f = 2 * g; h <= x; h += f)
        pk[h] = 0;
      udd.push_back(g);
    }
}
int main() {
  eos(1e6 + 7);
  int g, h, nt, re = 0;
  ll q, x;
  scanf("%lld", &q);
  for (g = 0; udd[g] * udd[g] <= q; g++) {
    x = udd[g];
    nt = 0;
    while (q % x == 0) {
      q /= x;
      nt++;
    }
    for (h = 1; h <= nt; nt -= h, h++)
      re++;
  }
  if (q != 1)
    re++;
  printf("%d\\n", re);
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bitset<1000010> pk;
vector<int> udd;
void eos(int x) {
  ll g, h, f;
  pk.set();
  pk[0] = pk[1] = 0;
  for (h = 4; h <= x; h += 2)
    pk[h] = 0;
  udd.push_back(2);
  for (g = 3; g <= x; g += 2)
    if (pk[g]) {
      for (h = g * g, f = g << 1; h <= x; h += f)
        pk[h] = 0;
      udd.push_back(g);
    }
}
int main() {
  eos(1e6 + 7);
  int g, pre = 0, re = 0;
  ll q, x;
  scanf("%lld", &q);
  for (g = 0; udd[g] * udd[g] <= q; g++) {
    x = udd[g];
    while (q % x == 0) {
      re++;
      q /= x;
      x *= udd[g];
      pre = g;
    }
  }
  if (udd[pre] != q && q != 1) {
    for (g = 0; udd[g] * udd[g] <= q; g++)
      if (q % udd[g] == 0) {
        printf("%d\\n", re);
        return 0;
      }
    printf("%d\\n", re + 1);
  } else
    printf("%d\\n", re);
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define FLASH                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << '=' << (x) << endl;
#define mxn 200005
#define f first
#define s second
using namespace std;

int main() {
  FLASH
  ll n, ans = 0;
  cin >> n;
  for (int i = 2; i <= 1000010; ++i) {
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    for (int j = 1; j < 10000; j++) {
      if (cnt < j)
        break;
      cnt -= j;
      ans++;
    }
  }
  if (n > 1) {
    ans++;
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define FLASH                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << '=' << (x) << endl;
#define mxn 200005
#define f first
#define s second
using namespace std;
vector<ll> v;
int main() {
  FLASH
  ll n, ans = 0;
  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 < 10000; j++) {
      if (cnt < j)
        break;
      cnt -= j;
      ans++;
    }
  }
  if (n > 1) {
    ans++;
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(A) A.begin(), A.end()
bool _predicate(int a, const int &element) {
  return (
      element ==
      a); // This will cause all elements to be deleted that are larger than 3
}
int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  ll N = n;
  vector<bool> mat(sqrt(N) + 1, false);
  for (ll i = 2; i <= (int)(sqrt(N)); i++) {
    // cout << i << ":" << endl;
    ll I = i;
    if (mat[i])
      continue;
    while (I < sqrt(N)) {

      mat[I] = true;
      I *= i;
      // cout << I << " ";
      // cout << I << " ";
    }
    // cout << i << ":" << endl;

    // cout << endl;
    int e = 0;
    while (n % i == 0) {
      n /= i;
      e++;
    }
    int emax = 0;
    int exe = e;
    while (true) {
      emax++;
      if (emax * (emax + 1) >= 2 * e) {
        if (emax * (emax + 1) > 2 * e)
          emax--;
        exe = emax * (emax + 1) / 2;
        break;
      }
    }
    // if(emax>0)cout <<n<<" "<< i << " " << e<<" "<<emax << endl;

    // if (emax > 0)cout << n << " " << i << " " << e << " " << emax << endl;

    ans += emax;
  }
  if (ans == 0)
    ans++;
  if (n > sqrt(N) && N != n)
    ans++;
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(A) A.begin(), A.end()
bool _predicate(int a, const int &element) {
  return (
      element ==
      a); // This will cause all elements to be deleted that are larger than 3
}
int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  ll N = n;
  vector<bool> mat(sqrt(N) + 1, false);
  for (int i = 2; i <= (int)(sqrt(N)); i++) {
    // cout << i << ":" << endl;
    int I = i;
    if (mat[i])
      continue;
    while (I < sqrt(N)) {

      mat[I] = true;
      I *= i;
      // cout << I << " ";
      // cout << I << " ";
    }
    // cout << i << ":" << endl;

    // cout << endl;
    int e = 0;
    while (n % i == 0) {
      n /= i;
      e++;
    }
    int emax = 0;
    int exe = e;
    while (true) {
      emax++;
      if (emax * (emax + 1) >= 2 * e) {
        if (emax * (emax + 1) > 2 * e)
          emax--;
        exe = emax * (emax + 1) / 2;
        break;
      }
    }
    // cout <<n<<" "<< i << " " << e<<" "<<emax << endl;
    for (int j = exe; j < e; j++) {
      n *= i;
    }
    ans += emax;
  }
  if (ans == 0)
    ans++;
  if (n > sqrt(N) && N != n)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;

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

int triDec(int a) {
  int x = 0;
  while (a > 0) {
    a -= x;
    if (a <= x)
      return x;
    x++;
  }
  return x;
}

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

  auto pp = primePowDec(n);

  int ans = 0;
  for (auto i : pp)
    ans += triDec(i.second);

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

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

int triDec(int a) {
  int x = 0;
  while (a > 0) {
    a -= x;
    if (a <= x)
      return x;
    x++;
  }
  return x;
}

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

  auto pp = primePowDec(n);

  int ans = 0;
  for (auto i : pp)
    ans += triDec(i.second);

  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;

vector<pair<long long, long long>> prime_factorize(ll num) {
  vector<pair<long long, long long>> res;
  for (ll i = 2; i * i <= num; i++) {
    if (num % i != 0)
      continue;
    ll ex = 0;
    while (num % i == 0) {
      ex++;
      num /= i;
    }
    res.push_back(make_pair(i, ex));
  }
  if (num != 1)
    res.push_back(make_pair(num, 1));
  return res;
}

int main() {
  ll N;
  cin >> N;
  auto pf = prime_factorize(N);
  ll res = 0;
  for (auto p : pf) {
    ll e = p.second;
    ll max = 0;
    ll x = 1;
    while (e >= x)
      e -= x++, ++max;
    res += max;
  }
  cout << res;
  return 0;
}

Error: TLE

Fixed submission:

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

ll prime_factorize(ll num) {
  ll res = 0;
  for (int i = 2; i * i <= num; i++) {
    if (num % i != 0)
      continue;
    ll ex = 0;
    while (num % i == 0) {
      ex++;
      num /= i;
    }
    for (int j = 1; j <= ex; j++) {
      if (ex - j < 0)
        break;
      ex -= j;
      res += 1;
    }
  }
  if (num != 1)
    res++;
  return res;
}

int main() {
  ll N;
  cin >> N;
  cout << prime_factorize(N);
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <math.h>
#include <stdio.h>
int a[1000006];
int p[1000006], pt = 0;
int main() {
  long long n;
  scanf("%lld", &n);
  int ans = 0;
  for (int i = 2; i <= 1000001; i++) {
    if (a[i] == 0) {
      p[pt++] = i;
      for (int j = 2; j * i < 1000001; j++) {
        a[i * j] = 1;
      }
    }
  }
  for (int i = 0; i < pt; i++) {
    int f = 0;
    while (n % p[i] == 0) {
      f++;
      n /= p[i];
    }
    for (int j = 1; j <= f; j++) {
      f -= j;
      ans++;
    }
  }
  if (n > 1000000)
    ans++;
  printf("%d", ans);
}

Error: -11

Fixed submission:

#include <math.h>
#include <stdio.h>
int a[1000006];
int b[1000006];
int p[1000006], pt = 0;
int main() {
  long long n;
  int ans = 0;
  for (int i = 2; i <= 1000001; i++) {
    if (a[i] == 0) {
      p[pt++] = i;
      for (int j = i; j * i <= 1000001; j++) {
        a[i * j] = 1;
      }
    }
  }
  for (long long i = 0; i < pt; i++) {
    int f = 0;
    while (n % p[i] == 0) {
      f++;
      n /= p[i];
    }
    for (int j = 1; j <= f; j++) {
      f -= j;
      ans++;
    }
  }
  if (n > 1000000)
    ans++;
  printf("%d", ans);
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

//
// Created by aarav on 9/11/2020.
//

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const string nl = "\\n";

bool prime(int n) {
  if (n <= 1)
    return false;
  if (n <= 3)
    return true;

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

  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0)
      return false;

  return true;
}

vector<bool> sieve(int n) {
  vector<bool> prime(n + 1, true);

  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p)
        prime[i] = false;
    }
  }
  return prime;
}

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

  ll N;
  cin >> N;
  if (N == 1) {
    cout << 0 << nl;
    exit(0);
  }
  vector<bool> isprime = sieve(1000001);
  long long ans = 0;
  vector<ll> primes;
  ll mx = (ll)sqrt(N);
  for (long long i = 2; i <= mx; i++) {
    if (isprime[i] && ((N % i) == 0)) {
      long long cnt = 0;
      while (N % i == 0) {
        cnt++;
        N /= i;
      }
      long long c = 1;
      while (((c + 2) * (c + 1) / 2) <= cnt)
        c++;
      ans += c;
    }
  }
  if (N > 1)
    ans++;
  if (ans == 0)
    cout << 1 << nl;
  else
    cout << ans << nl;
}


Error: 0

Fixed submission:

//
// Created by aarav on 9/11/2020.
//

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define f first
#define s second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define ins insert

#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define trav(a, x) for (auto &a : x)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)

typedef pair<int, int> pi;
typedef vector<int> vint;
typedef vector<long long> vlong;
typedef long long ll;
typedef priority_queue<int, vector<int>, greater<int>> minheap;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MX = 2e5 + 5;
const string nl = "\\n";

vector<bool> sieve(int n) {
  vector<bool> prime(n + 1, true);

  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p)
        prime[i] = false;
    }
  }
  return prime;
}

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

  ll N;
  cin >> N;
  vector<bool> isprime = sieve(1000001);
  long long ans = 0;
  for (long long i = 2; i <= sqrt(N); i++) {
    if (isprime[i] && N % i == 0) {
      long long cnt = 1;
      while (N % (long long)pow(i, cnt) == 0)
        cnt++;
      cnt--;
      long long c = 1;
      while (c * (c + 1) / 2 <= cnt)
        c++;
      c--;
      ans += c;
    }
  }
  if (N == 1)
    cout << 0 << nl;
  else if (isprime[N])
    cout << 1 << nl;
  else
    cout << ans << nl;
}

/* stuff you should look for
 * int overflow, array bounds
 * special cases (n=1?)
 * do smth instead of nothing and stay organized
 * WRITE STUFF DOWN
 */
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

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

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

int main(void) {
  ll N;
  cin >> N;

  ll ans = 0;
  ll n = N;
  map<ll, ll> counts;

  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      counts[i]++;
      n /= i;
    }
  }

  if (is_prime(n)) {
    counts[n]++;
  }

  for (auto count : counts) {
    ll c = count.second;
    for (ll i = 1; i <= c; i++) {
      c -= i;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

constexpr ll SQRT_MAX_N = 1e6;

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

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

int main(void) {
  ll N;
  cin >> N;

  set<ll> cand;

  for (ll i = 2; i <= SQRT_MAX_N; i++) {
    if (!is_prime(i)) {
      continue;
    }
    for (ll j = i; j <= N; j *= i) {
      cand.insert(j);
    }
  }

  ll ans = 0;
  ll n = N;
  while (true) {
    cerr << n << endl;
    if (n > SQRT_MAX_N && is_prime(n)) {
      // cerr << n << " is prime" << endl;
      ans++;
      break;
    }

    bool erased = false;

    for (auto x : cand) {
      if (n % x == 0) {
        ans++;
        n /= x;
        // cerr << "use : " << x << endl;
        cand.erase(x);
        erased = true;
        break;
      }
    }

    if (!erased) {
      break;
    }
  }

  cout << ans << endl;

  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++)

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

  vector<pair<long int, int>> s;
  for (long int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    if (cnt != 0)
      s.emplace_back(i, cnt);
  }

  int ans = 0;
  if (n != 1)
    ans++;

  rep(i, s.size()) {
    int e = 1;
    while (s[i].second - e >= 0) {
      // cout << s[i].first << s[i].second << endl;
      s[i].second -= e;
      e++;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

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

  vector<pair<long int, int>> s;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    if (cnt != 0)
      s.emplace_back(i, cnt);

    if (n == 1)
      break;
  }

  int ans = 0;
  if (n != 1)
    ans++;

  rep(i, s.size()) {
    int e = 1;
    while (s[i].second - e >= 0) {
      // cout << s[i].first << s[i].second << endl;
      s[i].second -= e;
      e++;
      ans++;
    }
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>

using namespace std;
using i64 = int64_t;

i64 dp[3005][3005];
i64 N, S;
const i64 MOD = 998244353LL;

i64 rot(int n) {
  for (i64 i = 1;; i++) {
    n -= i;
    if (i >= n)
      return i;
  }
}

int main() {
  vector<bool> isprime(1000005, true);
  isprime[0] = isprime[1] = false;
  for (int i = 2; i <= 1000005; i++) {
    if (!isprime[i])
      continue;
    for (int j = 2; i * j <= 1000005; j++) {
      isprime[i * j] = false;
    }
  }
  i64 N, T;
  cin >> N;
  T = N;
  map<i64, i64> factors;
  for (i64 i = 2; i <= T && i * i <= N; i++) {
    if (!isprime[i])
      continue;
    while (T % i == 0) {
      factors[i]++;
      T /= i;
    }
  }
  if (T != 1)
    factors[T]++;
  i64 ret = 0;
  for (auto &&p : factors) {
    cerr << p.first << " " << p.second << endl;
    ret += rot(p.second);
  }
  cout << ret << endl;
}


Error: 0
2 3
3 1


Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using i64 = int64_t;

i64 dp[3005][3005];
i64 N, S;
const i64 MOD = 998244353LL;

i64 rot(int n) {
  for (i64 i = 1;; i++) {
    n -= i;
    if (i >= n)
      return i;
  }
}

int main() {
  vector<bool> isprime(100005, true);
  isprime[0] = isprime[1] = false;
  for (int i = 2; i <= 100005; i++) {
    if (!isprime[i])
      continue;
    for (int j = 2; i * j <= 100005; j++) {
      isprime[i * j] = false;
    }
  }
  i64 N, T;
  cin >> N;
  T = N;
  map<i64, i64> factors;
  for (i64 i = 2; i <= T && i * i <= N; i++) {
    if (!isprime[i])
      continue;
    while (T % i == 0) {
      factors[i]++;
      T /= i;
    }
  }
  if (T != 1)
    factors[T]++;
  i64 ret = 0;
  for (auto &&p : factors) {
    cerr << p.first << " " << p.second << endl;
    ret += rot(p.second);
  }
  cout << ret << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void Main() {
  // input
  u_int64_t N;
  cin >> N;

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

  int ans = 0;
  for (u_int64_t prime = 2; prime * prime <= N; prime++) {
    // 割り切れない
    if (N % prime != 0) {
      continue;
    }

    // N = prime ^ f * …… とする
    // 割り切れる
    // ここで, N は prime で割り切れなくまでする必要がある,
    // でないとこの後にでてくる prime の素数性が保たれなくなる
    int f = 0;
    while (N % prime == 0) {
      f++;
      N /= prime;
    }

    // f > 1 + 2 + 3 + … + n となる最大の n は?
    for (int e = 1; e <= f; e++) {
      f -= e;
      ans++;
    }
  }

  if (N != 1) {
    ans++;
  }

  // output
  cout << ans << endl;
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Error: TLE

Fixed submission:

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

void Main() {
  // input
  u_int64_t N;
  cin >> N;

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

  int ans = 0;
  u_int64_t loop_num = N;
  for (u_int64_t prime = 2; prime <= loop_num; prime++) {
    // 割り切れない
    if (N % prime != 0) {
      continue;
    }

    // N = prime ^ f * …… とする
    // 割り切れる
    // ここで, N は prime で割り切れなくまでする必要がある,
    // でないとこの後にでてくる prime の素数性が保たれなくなる
    int f = 0;
    while (N % prime == 0) {
      f++;
      N /= prime;
    }

    // f > 1 + 2 + 3 + … + n となる最大の n は?
    for (int e = 1; e <= f; e++) {
      f -= e;
      ans++;
    }

    if (N == 1) {
      break;
    }
  }

  // output
  if (ans == 0) {
    cout << 1 << endl;
  } else {
    cout << ans << endl;
  }
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int64_t N;
  cin >> N;
  int top = sqrt(N);
  map<int, int> soinsu;
  int i = 2;
  bool flag = false;
  if (N == 1)
    flag = true;
  while (i <= top) {
    if (N % i == 0) {
      if (soinsu.count(i) > 0)
        soinsu.at(i) += 1;
      else
        soinsu[i] = 1;
      N /= i;
      top = sqrt(N);
    } else {
      i++;
    }
  }
  if (N != 1) {
    if (soinsu.count(N) > 0)
      soinsu.at(N) += 1;
    else
      soinsu[N] = 1;
  }

  if (flag)
    cout << 0 << endl;
  else if (soinsu.size() == 0)
    cout << 1 << endl;
  else {
    int count = 0;
    int t;
    for (auto itr = soinsu.begin(); itr != soinsu.end(); ++itr) {
      t = 1;
      while (true) {
        if (itr->second < t)
          break;
        else {
          itr->second -= t;
          t++;
          count++;
        }
      }
    }
    cout << count << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int64_t N;
  cin >> N;
  int64_t top = 1000000;
  map<int, int> soinsu;
  int i = 2;
  bool flag = false;
  if (N == 1)
    flag = true;
  while (i <= top || i <= N) {
    if (N % i == 0) {
      if (soinsu.count(i) > 0)
        soinsu.at(i) += 1;
      else
        soinsu[i] = 1;
      N /= i;
    } else {
      i++;
    }
  }
  if (flag)
    cout << 0 << endl;
  else if (soinsu.size() == 0)
    cout << 1 << endl;
  else {
    int count = 0;
    int t;
    for (auto itr = soinsu.begin(); itr != soinsu.end(); ++itr) {
      t = 1;
      while (true) {
        if (itr->second < t)
          break;
        else {
          itr->second -= t;
          t++;
          count++;
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll n, m;
  cin >> n;
  m = n;
  vector<ll> v;
  map<ll, ll> mp;
  for (int i = 2; i <= sqrt(m); i++) {
    if (n % i == 0) {
      if (v.empty()) {
        v.push_back(i);
      } else {
        if (*prev(v.end()) != i) {
          v.push_back(i);
        }
      }
      mp[i]++;
      n /= i;
      i--;
    }
  }
  if (n != 1) {
    v.push_back(n);
    mp[n]++;
  }
  if (m == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (n == m) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 0;
  for (auto a : v) {
    ll c = mp[a];
    for (int i = 2; i < 100; i++) {
      if (i * (i + 1) / 2 <= c)
        continue;
      ans += i - 1;
      break;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  ll n, m;
  cin >> n;
  m = n;
  vector<ll> v;
  map<ll, ll> mp;
  for (int i = 2; i <= sqrt(m); i++) {
    if (n % i == 0) {
      if (v.empty()) {
        v.push_back(i);
      } else {
        if (*prev(v.end()) != i) {
          v.push_back(i);
        }
      }
      mp[i]++;
      n %= i;
      i--;
    }
  }
  if (m == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (n == m) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 0;
  for (auto a : v) {
    ll c = mp[a];
    for (int i = 2; i < 100; i++) {
      if (i * (i + 1) / 2 <= c)
        continue;
      ans += i - 1;
      break;
    }
  }
  cout << ans << endl;
}