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

/*
2020/7/21
7/23
*/

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

typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main() {
  long long N;
  cin >> N;
  vector<pair<ll, ll>> prime;
  long long i = 2;
  while (i * i <= N) {
    if (N % i == 0) {
      int count = 0;
      while (N % i == 0) {
        N /= i;
        count++;
      }
      prime.push_back({i, count});
    }
    i++;
  }
  if (N != 1)
    prime.push_back({N, 1});
  int ans = 0;
  for (auto kani : prime) {
    int i = 1;
    while (kani.second - i >= 0) {
      ans++;
      kani.second -= i;
      i++;
    }
  }

  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

/*
2020/7/21
7/23
*/

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

typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vb divide(N + 1, false);
  vector<pair<ll, ll>> prime;
  int i = 2;
  while (i * i <= N) {
    if (N % i == 0) {
      int count = 0;
      while (N % i == 0) {
        N /= i;
        count++;
      }
      prime.push_back({i, count});
    }
    i++;
  }
  if (N != 1)
    prime.push_back({N, 1});
  int ans = 0;
  for (auto kani : prime) {
    int i = 1;
    while (kani.second - i >= 0) {
      ans++;
      kani.second -= i;
      i++;
    }
  }

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

#include "bits/stdc++.h"
#define ll long long int
using namespace std;
int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i < 1000010; i++) {
    ll count = 0;
    while (n % i == 0) {
      n /= i;
      count++;
    }

    for (ll j = 1; j < 10000; j++) {
      if (count < j)
        break;
      ans++;

      count -= j;
    }
  }

  if (n > 1) {
    ans++;
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    int count = 0;
    while (n % i == 0) {
      n /= i;
      count++;
    }

    for (int j = 1; j < 100000; j++) {
      if (count < j) {
        break;
      }

      count -= j;
      ans++;
    }
  }

  if (n > 1) {
    ans++;
  }

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

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

typedef long long ll;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

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

  ll m = n;

  for (ll i = 2; i * i <= n; ++i) {
    while (m % i == 0) {
      if (m % i == 0) {
        a.push_back(i);
        m /= i;
      } else
        break;
    }
  }
  if (m != 1)
    a.push_back(m);

  int n2 = a.size();
  ll ans = 0;

  int cc = 1;
  rep(i, n2) {
    if (a[i] == a[i + 1])
      ++cc;
    else {
      int res = 1;
      while (cc > 0) {
        if (cc >= res) {
          ++ans;
          cc -= res;
          ++res;
        } else
          break;
      }
      cc = 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

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

typedef long long ll;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

bool IsPrime2(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

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

  // エラトステネスのふるい
  bitset<10000007> is_prime(0); // 十分大きなサイズを確保します
  for (int i = 2; i <= 1000000; ++i)
    is_prime.set(i); // とりあえず全部ふるいに入れます
  for (int i = 2; i <= 1000000; ++i) {
    if (is_prime[i]) { // 素数 i を発見したら
      for (int j = i * 2; j <= 1000000; j += i) {
        is_prime.reset(j); // i の倍数をふるい落とす
      }
    }
  }

  if (IsPrime2(n))
    ans = 1;
  else {

    for (int i = 2; i * i <= n; ++i) {
      if (n % i == 0 && is_prime[i]) {
        ++ans;
        n /= i;
        //            a.push_back(i);
        ll i2 = i;
        while (true) {
          i2 *= i;
          if (n % i2 == 0)
            a.push_back(i2);
          else
            break;
        }
      }
    }

    sort(a.begin(), a.end());
    int m = a.size();

    rep(i, m) {
      if (n % a[i] == 0) {
        ++ans;
        n /= a[i];
      }

      if (n == 1)
        break;
    }
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const ll INF = 1e18;
const int MOD = 1e9 + 7;

int main() {

  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

  // ifstream cin (".in");
  // ofstream cout (".out")

  ll n;
  cin >> n;
  ll ans = 0;

  for (ll i = 2; n > 1 && i * i <= n; ++i) {
    int temp = 0;
    while (n % i == 0)
      ++temp, n /= i;
    for (int j = 1;; ++j) {
      if (temp >= j)
        ++ans, temp -= j;
      else
        break;
    }
  }

  if (n > 1)
    ++ans;

  cout << ans << '\\n';
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const ll INF = 1e18;
const int MOD = 1e9 + 7;

int main() {

  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

  // ifstream cin (".in");
  // ofstream cout (".out")

  ll n;
  cin >> n;
  ll ans = 0;

  for (ll i = 2; n > 1 && i <= n; ++i) {
    int temp = 0;
    while (n % i == 0)
      ++temp, n /= i;
    for (int j = 1;; ++j) {
      if (temp >= j)
        ++ans, temp -= j;
      else
        break;
    }
  }

  cout << ans << '\\n';
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define ll long long

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

  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    if (n % i) {
      continue;
    }
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    for (int j = 1; j <= cnt; j++) {
      cnt -= j;
      ans++;
    }
  }

  if (n > 1)
    ans++;

  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

#define ll long long

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

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

  if (n > 1)
    ans++;

  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> fs;
  for (ll i = 2; i * i <= n; i++) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      x++;
    }
    if (x != 0)
      fs.emplace_back(i, x);
  }
  if (n != 1)
    fs.emplace_back(n, 1);
  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> fs;
  for (int i = 2; i * i <= n; i++) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      x++;
    }
    if (x != 0)
      fs.emplace_back(i, x);
  }
  if (n != 1)
    fs.emplace_back(n, 1);
  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

int main() {

  ll nx;
  cin >> nx;
  if (nx == 2) {
    cout << 1;
    return 0;
  }
  if (nx == 3) {
    cout << 1;
    return 0;
  }
  ll n = 0;
  rep(i, nx) {
    if (i * i > nx) {
      n = i;
      break;
    }
  }
  if (is_prime(nx) && nx > 1) {
    cout << 1;
    return 0;
  }

  ll ans = 0;
  for (ll i = 2; i * i <= nx; i++) {
    ll count = 0;
    if (nx % i != 0) {
      continue;
    }
    while (nx % i == 0) {
      count++;
      nx = nx / i;
    }
    ll j;
    for (ll i = 1; i <= count; i++) {
      if (i * (i + 1) <= 2 * count && 2 * count < (i + 1) * (i + 2)) {
        j = i;
        break;
      }
    }

    ans += j;
    if (nx == 1) {
      break;
    }
    if (is_prime(nx)) {
      ans++;
      break;
    }
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

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

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

int main() {

  ll nx;
  cin >> nx;
  if (nx == 2) {
    cout << 1;
    return 0;
  }
  if (nx == 3) {
    cout << 1;
    return 0;
  }
  ll n = 0;
  rep(i, nx) {
    if (i * i > nx) {
      n = i;
      break;
    }
  }
  if (is_prime(nx) && nx > 1) {
    cout << 1;
    return 0;
  }

  ll ans = 0;
  for (ll i = 2; i <= nx; i++) {
    ll count = 0;
    if (nx % i != 0) {
      continue;
    }
    while (nx % i == 0) {
      count++;
      nx = nx / i;
    }
    ll j;
    for (ll i = 1; i <= count; i++) {
      if (i * (i + 1) <= 2 * count && 2 * count < (i + 1) * (i + 2)) {
        j = i;
        break;
      }
    }

    ans += j;
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  long long int N;
  cin >> N;
  int ans = 0;
  for (int i = 2; i < 1000010; i++) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    for (int j = 1; j < 10000; j++) {
      if (cur < j)
        break;
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long int N;
  cin >> N;
  int ans = 0;
  for (int i = 2; i * i <= N; i++) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    for (int j = 1; j <= cur; j++) {
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << endl;

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

#include <iostream>
using namespace std;

int main() {
  long long int N;
  cin >> N;
  int ans = 0;
  for (long long int i = 2; i * i <= N; i++) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    for (long long int j = 1; j <= cur; j++) {
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long int N;
  cin >> N;
  int ans = 0;
  for (int i = 2; i * i < N; i++) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    for (int j = 1; j <= cur; j++) {
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << endl;

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

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

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(void) {
  long long n;
  cin >> n;
  int tab[100];
  int c = 1;
  int t = 1;
  for (int i = 0; i < 100; i++) {
    if (i == t) {
      c++;
      t = c * (c + 1) / 2;
    }
    tab[i] = c - 1;
  }

  long long ans = 0;
  const auto &res = prime_factorize(n);
  for (auto p : res) {
    ans += tab[p.second];
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main(void) {
  long long n;
  cin >> n;
  int tab[100];
  int c = 1;
  int t = 1;
  for (int i = 0; i < 100; i++) {
    if (i == t) {
      c++;
      t = c * (c + 1) / 2;
    }
    tab[i] = c - 1;
  }

  long long ans = 0;
  long long tar = n;
  long long cnt;
  for (long long i = 2; i < n + 1; i++) {
    if (i > tar)
      break;
    else if (i * i > n && tar == n) {
      ans = 1;
      break;
    } else if (tar % i == 0) {
      cnt = 0;
      while (tar % i == 0) {
        tar /= i;
        cnt++;
      }
      ans += tab[cnt];
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc {
  // 宣言
  long long a;

public:
  // 素因数分解
  void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n) {
  // 割る数の初期値
  a = 2;
  // √n ≧ a ( n ≧ a * a ) の間ループ処理
  while (n >= a * a) {
    // a で割り切れたら、a は素因数
    // そして、割られる数を a で割る
    // a で割り切れなかったら、 a を 1 増加させる
    if (n % a == 0) {
      // printf("%d * ", a);
      v.push_back(a);
      n /= a;
    } else {
      a++;
    }
  }
  // 最後に残った n は素因数
  v.push_back(n);
  // printf("%d\\n", n);
}

int main() {
  // std::stack<int> stack;
  long n;
  cin >> n;
  int sq = (int)sqrt(n);
  vector<long long> cnt(sq + 1);
  int ans = 0;
  if (n == 1) {
    ans = 0;
  } else {
    Calc objCalc;
    objCalc.decompositPrime(n);
    if (v.size() == 1) {
      ans = 1;
      cout << ans << endl;
      return 0;
    }
    long tmp = v[0];
    int cnt = 1;
    int cnt2;
    for (int i = 1; i < v.size(); i++) {
      if (tmp != v[i]) {
        cnt2 = 1;
        while (cnt >= cnt2) {
          ans++;
          cnt -= cnt2;
          cnt2++;
        }
        cnt = 1;
        tmp = v[i];
      } else {
        cnt++;
      }
    }
    cnt2 = 1;
    while (cnt >= cnt2) {
      ans++;
      cnt -= cnt2;
      cnt2++;
    }
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc {
  // 宣言
  int a;

public:
  // 素因数分解
  void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n) {
  // 割る数の初期値
  a = 2;
  // √n ≧ a ( n ≧ a * a ) の間ループ処理
  while (n >= a * a) {
    // a で割り切れたら、a は素因数
    // そして、割られる数を a で割る
    // a で割り切れなかったら、 a を 1 増加させる
    if (n % a == 0) {
      // printf("%d * ", a);
      v.push_back(a);
      n /= a;
    } else {
      a++;
    }
  }
  // 最後に残った n は素因数
  v.push_back(n);
  // printf("%d\\n", n);
}

int main() {
  // std::stack<int> stack;
  long long n;
  cin >> n;
  int sq = (int)sqrt(n);
  vector<long long> cnt(sq + 1);
  long long ans = 0;
  if (n == 1) {
    ans = 0;
  } else {
    Calc objCalc;
    objCalc.decompositPrime(n);
    if (v.size() == 1) {
      ans = 1;
      cout << ans << endl;
      return 0;
    }
    for (auto &num : v) {
      cnt[num]++;
    }
    int tmp;
    for (int i = 2; i <= sq; i++) {
      // cout << cnt[i] << endl;
      tmp = 1;
      while (tmp <= cnt[i]) {
        ans++;
        cnt[i] -= tmp;
        tmp++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long int ll;

ll cnt = 0;

void prime(ll x) {
  ll ans = 0;
  while (x % 2 == 0) {
    ans++;
    x = x / 2;
  }

  cnt += (-1 + sqrt(1 + 8 * ans)) / 2;

  for (ll i = 3; i * i <= x; i += 2) {
    ans = 0;
    while (x % i == 0) {
      ans++;
      x = x / i;
    }
    cnt += (-1 + sqrt(1 + 8 * ans)) / 2;
  }

  if (x > 2) {
    cnt++;
  }
}

int main() {
  ll n;
  scanf("%lld", &n);
  prime(n);
  printf("%lld\\n", cnt);
}


Error: TLE

Fixed submission:

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

typedef long long int ll;

ll arr[1000001], cnt = 0;

ll prime(ll x) {
  ll ans = 0;
  while (x % 2 == 0) {
    ans++;
    //		arr[2]+=1;
    x = x / 2;
  }

  cnt += (-1 + sqrt(1 + 8 * ans)) / 2;

  for (ll i = 3; i * i <= x; i++) {
    ans = 0;
    while (x % i == 0) {
      ans++;
      //			arr[i]+=1;
      x = x / i;
    }
    cnt += (-1 + sqrt(1 + 8 * ans)) / 2;
  }

  if (x > 2) {
    cnt++;
  }
}

int main() {
  ll n;
  cin >> n;
  prime(n);
  /*for(ll i=0;i<1000001;i++)
  {
          if(arr[i]>0)
          {
                  for(ll j=1;j<100;j++)
                  {
                          arr[i]-=j;
                          if(arr[i]>=0)
                                  cnt++;
                          else
                                  j=100;
                  }
          }
  }*/
  cout << cnt << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define mod 1000000007    // 10^9+7
#define INF 1000000000000 // 10^12
#define F first
#define S second
#define P pair<int, int>
#define all(vec) vec.begin(), vec.end()
map<int, int> mp;
int tri(int n) {
  int x = 0;
  for (int i = 1;; i++) {
    if (x + i > n) {
      return i - 1;
    } else
      x += i;
  }
  return 0;
}
vector<int> vec;
signed main() {
  int n;
  int ans = 0;
  cin >> n;
  int nn = n;
  for (int i = 2; i <= sqrt(nn); i++) {
    if (n % i == 0) {
      mp[i]++;
      n /= i;
      i--;
    }
    if (n == 1) {
      break;
    }
  }
  if (n > 1) {
    mp[n]++;
  }
  for (auto x : mp) {
    ans += tri(x.second);
  }
  if (ans == 0 && n > 1)
    cout << 1 << endl;
  else
    cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define mod 1000000007    // 10^9+7
#define INF 1000000000000 // 10^12
#define F first
#define S second
#define P pair<int, int>
#define all(vec) vec.begin(), vec.end()
map<int, int> mp;
int tri(int n) {
  int x = 0;
  for (int i = 1;; i++) {
    if (x + i > n) {
      return i - 1;
    } else
      x += i;
  }
  return 0;
}
vector<int> vec;
signed main() {
  int n;
  int ans = 0;
  cin >> n;
  int nn = n;
  for (int i = 2; i <= nn; i++) {
    if (n % i == 0) {
      mp[i]++;
      n /= i;
      i--;
    }
    if (n == 1) {
      break;
    }
  }
  if (n > 1) {
    mp[n]++;
  }
  for (auto x : mp) {
    ans += tri(x.second);
  }
  if (ans == 0 && n > 1)
    cout << 1 << endl;
  else
    cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
// #pragma GCC optimize ("Ofast")

using namespace std;
#define ms(x, a) memset(x, a, sizeof x)
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1e9 + 7, seed = 131, MAXN = 0;

map<int, int> m;

int main() {
  // cin.tie(0)->sync_with_stdio(0);
  ll n;
  cin >> n;
  for (ll i = 2; n != 1, i * i <= n; ++i) {
    while (n % i == 0)
      n /= i, m[i]++;
  }
  ll tot = n != 1;
  int a;
  for (auto x : m) {
    a = 2;
    for (int i = 1;; a++) {
      if (i > x.second) {
        tot += a - 2;
        break;
      }
      i += a;
    }
  }
  cout << tot << '\\n';
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
// #pragma GCC optimize ("Ofast")

using namespace std;
#define ms(x, a) memset(x, a, sizeof x)
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1e9 + 7, seed = 131, MAXN = 0;

map<int, int> m;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  ll n;
  cin >> n;
  for (int i = 2; n != 1; ++i) {
    while (n % i == 0)
      n /= i, m[i]++;
  }
  ll tot = 0;
  int a;
  for (auto x : m) {
    a = 2;
    for (int i = 1;; a++) {
      if (i > x.second) {
        tot += a - 2;
        break;
      }
      i += a;
    }
  }
  cout << tot << '\\n';
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
vector<ll> ko(12345678);
void divisor(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    ll a = 0;
    while (n % i == 0) {
      a++;
      n /= i;
    }
    if (a > 0) {
      ko.push_back(a);
    }
  }
  if (n != 1) {
    ko.push_back(1);
  }
  return;
}
signed main() {
  ll n, cnt = 0, ans = 0;
  cin >> n;
  divisor(n);
  for (ll h = 0; h < ko.size(); h++) {
    cnt = 1;
    while (ko[h] >= cnt) {
      ko[h] -= cnt;
      ans++;
      cnt++;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
vector<ll> ko(12345678);
void divisor(ll n) {
  for (int i = 2; i * i <= n; i++) {
    ll a = 0;
    while (n % i == 0) {
      a++;
      n /= i;
    }
    if (a > 0) {
      ko.push_back(a);
    }
  }
  if (n != 1) {
    ko.push_back(1);
  }
  return;
}
signed main() {
  vector<ll> v;
  map<ll, ll> cost;
  ll n, m, a = 0, b = 0, c, x, cnt = 0, ans = 0;
  cin >> n;
  a = n;
  divisor(n);
  for (int h = 0; h < ko.size(); h++) {
    cnt = 1;
    while (ko[h] >= cnt) {
      ko[h] -= cnt;
      ans++;
      cnt++;
    }
  }
  cout << ans << endl;
  return 0;
}