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

// According to all known laws of aviation, there is no way that a bee should be
// able to fly. Its wings are too small to get its fat little body off the
// ground. The bee, of course, flies anyway. Because bees don't care what humans
// think is impossible.
#include <bits/stdc++.h>
#define FAST_IO                                                                \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define mod 1000000007
#define endl "\\n"
using namespace std;
using bigint = long long int;
using vi = vector<int>;
using vll = vector<long long int>;

map<bigint, int> m;
int count1(int N) { return int((-1 + sqrt(1 + 8 * N)) / 2); }
void factorize(bigint N) {
  for (bigint i = 2; i * i <= N; i++) {
    while (N % i == 0) {
      m[i]++;
      N /= i;
    }
  }
  if (N > 1)
    m[N]++;
}
int main() {
  bigint N;
  cin >> N;
  factorize(N);
  int ans = 0;
  for (auto x : m) {
    ans += (count1(x.second));
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

// According to all known laws of aviation, there is no way that a bee should be
// able to fly. Its wings are too small to get its fat little body off the
// ground. The bee, of course, flies anyway. Because bees don't care what humans
// think is impossible.
#include <bits/stdc++.h>
#define FAST_IO                                                                \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define mod 1000000007
#define endl "\\n"
using namespace std;
using bigint = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
bigint ans;
void factorize(bigint N) {
  for (int i = 2; i * i <= N; i++) {
    int cnt = 0;
    while (N % i == 0) {
      N /= i;
      cnt++;
    }
    bigint c = 1 + 8 * cnt;
    c = sqrt(c);
    c -= 1;
    c /= 2;
    if (c > 0)
      ans += c;
  }
  if (N > 1)
    ans++;
}
int main() {
  bigint N;
  cin >> N;
  factorize(N);
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

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

  long long n;
  cin >> n;
  map<long long, int> mp;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0)
        cnt++, n /= i;
      mp[i] = cnt;
    }
  }
  if (n > 1)
    mp[n] = 1;
  int ans = 0;
  for (auto [f, s] : mp) {
    for (int i = 1; s >= i; ++i) {
      s -= i;
      ans++;
    }
  }
  cout << ans;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

  long long n;
  cin >> n;
  map<int, int> mp;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0)
        cnt++, n /= i;
      mp[i] = cnt;
    }
  }
  if (n > 1)
    mp[n] = 1;
  int ans = 0;
  for (auto [f, s] : mp) {
    for (int i = 1; s >= i; ++i) {
      s -= i;
      ans++;
    }
  }
  cout << ans;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) rep(i, 0, n)

bool IsPrime(ll num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;

  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }

  return true;
}

void solve() {
  ll n;
  cin >> n;
  if (IsPrime(n)) {
    cout << 1 << endl;
    return;
  }
  ll ans = 0;
  map<ll, ll> m;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      m[i]++;
      n /= i;
    }
  }
  if (n != 1)
    m[n] = 1;
  for (auto it : m) {
    ans += (sqrt(it.second * 8 + 1) - 1) / 2;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) rep(i, 0, n)

void solve() {
  ll n;
  cin >> n;
  // if(IsPrime(n)){cout<<1<<endl;return;}
  ll ans = 0;
  map<ll, ll> m;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      m[i]++;
      n /= i;
    }
  }
  if (n != 1)
    m[n] = 1;
  for (auto it : m) {
    ans += (sqrt(it.second * 8 + 1) - 1) / 2;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  long long n, m;
  cin >> n;
  int ans = 0;
  for (long long i = 2; i <= n; i++) {
    if (n <= i * i) {
      ans++;
      break;
    }
    if (n % i == 0) {
      int ansi = 0;
      while (n % i == 0) {
        n /= i;
        ansi++;
      }
      int a = (int)sqrt(2 * ansi);
      for (int j = 0; j <= 3; j++) {
        if (ansi < (a + j) * (a + j + 1) / 2) {
          ans += a + j - 1;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  long long n, m;
  cin >> n;
  m = n;
  int ans = 0;
  for (int i = 2; i * i <= m; i++) {
    if (n % i == 0) {
      int ansi = 0;
      while (n % i == 0) {
        n /= i;
        ansi++;
      }

      for (int j = 1; true; j++) {
        if (ansi < j * (j + 1) / 2) {
          ans += j - 1;
          break;
        }
      }
    }
  }
  if (m == n && n != 1)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  for (long long i = 2; i <= n; i++) {
    if (n < i * i) {
      ans++;
      break;
    }
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      a.push_back(cnt);
      tmp++;
    }
  }
  for (int i = 0; i < tmp; i++) {
    int k = 0;
    for (int j = 1; j * (j + 1) / 2 <= a[i]; j++) {
      k = j;
    }
    ans += k;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

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

  for (int i = 2; i <= n; i++) {
    if (n < i * i) {
      ans++;
      break;
    }
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      a.push_back(cnt);
      tmp++;
    }
  }
  for (int i = 0; i < tmp; i++) {
    int k = 0;
    for (int j = 1; j * (j + 1) / 2 <= a[i]; j++) {
      k = j;
    }
    ans += k;
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <typename T1, typename T2> bool chmin(T1 &a, T2 b) {
  if (a <= b)
    return 0;
  a = b;
  return 1;
}
template <typename T1, typename T2> bool chmax(T1 &a, T2 b) {
  if (a >= b)
    return 0;
  a = b;
  return 1;
}
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long double eps = 1e-9;
long double pi = acos(-1);

// firstに素因数、secondに素因数が何個あるか
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> res;
  for (ll p = 2; p * p <= n; ++p) {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0) {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  vector<pair<ll, ll>> v = prime_factorize(n);
  ll ans = 0;
  for (int i = 0; i < v.size(); i++) {
    ll now = v[i].first;
    for (int j = 1; j <= v[i].second; j++) {
      if (v[i].second >= j) {
        v[i].second -= j;
        n /= now;
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Error: -8

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define drep(i, n) for (int i = (n)-1; i >= 0; i--)
#define MOD 1e9 + 7;
using namespace std;
using Graph = vector<vector<int>>;
typedef vector<vector<char>> field_t;
typedef unsigned long long int ull;
typedef pair<int, int> point_t;
vector<vector<int>> z;
map<int, int> mp;
int ans;
bool IsPrime(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;
}
priority_queue<int> divisor(int n) {
  priority_queue<int> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push(i);
      if (i * i != n)
        ret.push(n / i);
    }
  }
  return ret;
}

signed main() {
  int N;
  cin >> N;
  int cnt = N;
  priority_queue<long long> q;
  if (!IsPrime(cnt)) {
    if (cnt == 1) {
      cout << 0 << endl;
      return 0;
    } else {
      const auto &res = divisor(N);
      for (int j = 0; j < res.size(); ++j) {
        if (cnt >= j) {
          cnt /= j;
          ans++;
        } else {
          break;
        }
      }
      cout << ans << endl;
    }

  } else {
    cout << 1 << endl;
    return 0;
  }

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

#include <iostream>
using namespace std;
int main() {
  long long n;
  cin >> n;
  int ans = 0;
  long long _n = n;
  for (int i = 2; (long long)i * i <= _n; i++)
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      // cout << i << ' ' << cnt << endl;
      for (int j = 1; cnt > 0; j++) {
        if (cnt < j)
          break;
        ans++;
        cnt -= j;
      }
    }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  long long n;
  cin >> n;
  int ans = 0;
  long long _n = n;
  for (int i = 2; i * i <= _n; i++)
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      // cout << i << ' ' << cnt << endl;
      for (int j = 1; cnt > 0; j++) {
        if (cnt < j)
          break;
        ans++;
        cnt -= j;
      }
    }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  vector<int> pf;
  for (int64_t i = 2; i * i <= n; ++i) {
    if (n % i)
      continue;
    int cnt = 0;
    while (n % i == 0) {
      ++cnt;
      n /= i;
    }
    pf.push_back(cnt);
  }
  if (n != 1) {
    pf.push_back(1);
  }

  int ans = 0;
  for (auto e : pf) {
    for (int i = 1; i <= e; ++i) {
      e -= i;
      ++ans;
    }
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

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

  vector<int> pf;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i)
      continue;
    int cnt = 0;
    while (n % i == 0) {
      ++cnt;
      n /= i;
    }
    pf.push_back(cnt);
  }
  if (n != 1) {
    pf.push_back(1);
  }

  int ans = 0;
  for (auto e : pf) {
    for (int i = 1; i <= e; ++i) {
      e -= i;
      ++ans;
    }
  }

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

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

int main() {
  long long num;
  long long fac[10000][2] = {0};
  int count = 0;
  long long i;
  cin >> num;

  long long num2 = sqrt(num) + 1;

  for (i = 2; i <= num2; i++) {
    if (num % i == 0) {
      fac[count][0] = i;
      fac[count][1] = 0;
      while (num % i == 0) {
        fac[count][1]++;
        num /= i;
      }
      count++;
    }
  }

  if (num > num2) {
    fac[count][0] = num;
    fac[count][1] = 1;
    count++;
  }

  // for (i = 0; i < count;i++) cout << fac[i][0] << '&' << fac[i][1] << endl;

  int div = 0;
  for (i = 0; i < count; i++) {
    int a = 0;
    for (int k = 0; k <= fac[i][1]; k++) {
      a += k;
      if (a == fac[i][1]) {
        div += k;
        break;
      } else if (a > fac[i][1]) {
        div += k - 1;
        break;
      }
    }
  }

  cout << div << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long num;
  long long fac[10000][2] = {0};
  int count = 0;
  long long i;
  cin >> num;

  for (i = 2; i <= num; i++) {
    if (num % i == 0) {
      fac[count][0] = i;
      fac[count][1] = 0;
      while (num % i == 0) {
        fac[count][1]++;
        num /= i;
      }
      count++;
    }
  }

  // for (i = 0; i < count;i++) cout << fac[i][0] << '&' << fac[i][1] << endl;

  int div = 0;
  for (i = 0; i < count; i++) {
    int a = 0;
    for (int k = 0; k <= fac[i][1]; k++) {
      a += k;
      if (a == fac[i][1]) {
        div += k;
        break;
      } else if (a > fac[i][1]) {
        div += k - 1;
        break;
      }
    }
  }

  cout << div << endl;

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

#include <bits/stdc++.h>
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;
    }
    res.push_back({a, ex});
  }
  if (N != 1)
    res.push_back({N, 1});
  return res;
}

int main() {
  long long N;
  cin >> N;
  const auto &pf = prime_factorize(N);
  long long res = 0;
  for (auto p : pf) {
    for (int i = 1;; i++) {
      if (i * (i + 1) / 2 <= p.second && p.second < (i + 1) * (i + 2) / 2) {
        res += i;
        break;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int isPrime(long long x) {
  long long i;
  if (x < 2)
    return 0;
  else if (x == 2)
    return 1;
  if (x % 2 == 0)
    return 0;
  for (i = 3; i * i <= x; i += 2) {
    if (x % i == 0)
      return 0;
  }
  return 1;
}

int main() {
  ll n;
  cin >> n;
  int cnt = 0;
  if (isPrime(n)) {
    cout << 1 << endl;
    return 0;
  }
  for (ll i = 2; i <= 1000000000; i++) {
    if (n % i == 0) {
      cnt++;
      n /= i;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

// In the name of GOD

#include <bits/stdc++.h>
#define ll long long
#define pp pair<int, int>
using namespace std;
const ll N = 1e9, MOD = 998244353;

void solve() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0;
    return;
  }
  int ans = 0;
  for (ll i = 2; i * i <= n; ++i) {
    int count = 0;
    while (n % i == 0) {
      count++;
      n /= i;
    }
    int x = 0;
    while (x * (x + 1) / 2 <= count)
      x++;
    ans += --x;
  }
  if (n > 2)
    ans++;
  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tt = 1;
  // cin >> tt;
  for (int tc = 1; tc <= tt; ++tc) {
    solve();
  }
}


Error: TLE

Fixed submission:

// In the name of GOD

#include <bits/stdc++.h>
#define ll long long
#define pp pair<int, int>
using namespace std;
const ll N = 1e9, MOD = 998244353;

void solve() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0;
    return;
  }
  int ans = 0;
  for (int i = 2; i * i <= n; ++i) {
    int count = 0;
    while (n % i == 0) {
      count++;
      n /= i;
    }
    int x = 0;
    while (x * (x + 1) / 2 <= count)
      x++;
    ans += --x;
  }
  if (n > 2)
    ans++;
  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tt = 1;
  // cin >> tt;
  for (int tc = 1; tc <= tt; ++tc) {
    solve();
  }
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define str to_string
#define endl "\\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}

map<lint, int> p_factorization(lint n) {
  map<lint, int> soinsu;
  for (int i = 2; i <= sqrt(n); i++) {
    while (n % i == 0) {
      n /= i;
      soinsu[i]++;
    }
  }
  if (n != 1)
    soinsu[n]++;
  return soinsu;
}

// AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main() {
  lint n;
  cin >> n;
  int ans = 0;
  auto soinsu = p_factorization(n);
  for (auto p : soinsu) {
    int kosuu = p.second;
    for (int i = 1; i < 1000; i++) {
      kosuu -= i;
      if (kosuu < 0)
        break;
      ans++;
    }
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define str to_string
#define endl "\\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}

// AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main() {
  map<lint, lint> insu;
  lint n, m;
  cin >> n;
  m = n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 2; i <= sqrt(n); i++) {
    while (m % i == 0) {
      insu[i]++;
      insu[n / i]++;
      m /= i;
    }
  }
  insu[n]++;
  int ans = 0;
  for (auto p : insu) {
    int num = p.first;
    int kosuu = p.second;
    for (int i = 1; i < 10000; i++) {
      if (kosuu < i)
        break;
      lint warukazu = 1;
      for (int j = 1; j <= i; j++) {
        warukazu *= num;
      }
      if (n % (warukazu) != 0)
        break;
      n /= warukazu;
      ans++;
      kosuu -= i;
    }
  }
  cout << ans << endl;
}
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++)
#define repa(i, a, n) for (int i = (a); i < (n); i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define rrepa(i, a, n) for (int i = n; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define MOD 1000000007
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

int main() {

  ll n;
  cin >> n;
  int ans = 0;
  map<int, int> num;

  bool ex = true;
  int p = 2;
  while (n != 1 && ex) {
    ex = false;
    for (ll i = p; i * i <= n; i++) {
      if (n % i != 0)
        continue;
      p = i;
      int beki = 0;
      while (n % i == 0) {
        beki++;
        n /= i;
      }

      int x = 0;
      while (x < beki) {
        ans++;
        x++;
        beki -= x;
      }

      ex = true;
      break;
    }
  }
  if (n != 1) {
    ans++;
  }

  cout << ans << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repa(i, a, n) for (int i = (a); i < (n); i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define rrepa(i, a, n) for (int i = n; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define MOD 1000000007
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

int main() {

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

  bool ex = true;
  int p = 2;
  while (n != 1 && ex) {
    ex = false;
    for (int i = p; i * i <= n; i++) {
      int beki = 0;
      if (n % i != 0)
        continue;
      p = i;
      while (n % i == 0) {
        beki++;
        n /= i;
      }
      int cnt = 0;
      while (cnt + 1 <= beki) {
        cnt++;
        beki -= cnt;
      }
      ans += cnt;
      ex = true;
      break;
    }
  }
  if (n != 1)
    ans++;

  cout << ans << "\\n";

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

#include <iostream>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[]) {
  long long N;
  cin >> N;

  map<long long, long long> m;
  long long tmp = N;
  for (long long i = 2; i * i <= tmp; ++i) {
    if (tmp % i == 0) {
      tmp /= i;
      m[i] = 1;
      while (tmp % i == 0) {
        tmp /= i;
        ++m[i];
      }
    }
  }
  if (tmp > 1) {
    m[tmp] = 1;
  }

  long long ret = 0;
  for (map<long long, long long>::iterator i = m.begin(); i != m.end(); ++i) {
    long long x = i->second;
    for (long long j = 1; j <= x; ++j) {
      ++ret;
      x -= j;
      if (j > x)
        break;
    }
  }

  cout << ret << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[]) {
  long long N;
  cin >> N;

  map<long long, long long> m;
  long long tmp = N;
  for (int i = 2; i * i <= tmp; ++i) {
    if (tmp % i == 0) {
      tmp /= i;
      m[i] = 1;
      while (tmp % i == 0) {
        tmp /= i;
        ++m[i];
      }
    }
  }
  if (tmp > 1) {
    m[tmp] = 1;
  }

  long long ret = 0;
  for (map<long long, long long>::iterator i = m.begin(); i != m.end(); ++i) {
    int x = i->second;
    for (int j = 1; j <= x; ++j) {
      ++ret;
      x -= j;
      if (j > x)
        break;
    }
  }

  cout << ret << endl;

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return (0);
  }
  ll tmpn = n;
  // ll lim = sqrt(n)+1;
  ll div = 2;
  ll c = 0;
  while (div * div <= tmpn) {
    ll num = 0;
    while (n % div == 0) {
      num++;
      n /= div;
    }
    for (int i = 1;; i++) {
      if (num >= i) {
        c++;
        num -= i;
      } else
        break;
    }
    div++;
  }
  if (n != 1)
    c++;
  cout << c << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return (0);
  }
  ll tmpn = n;
  ll lim = sqrt(n);
  ll div = 2;
  ll c = 0;
  while (div <= lim) {
    if (n % div)
      continue;
    ll e = 1;
    ll z = pow(div, e);
    while (n % z == 0) {
      c++;
      e++;
      n /= z;
    }
    div++;
  }
  if (n % tmpn == 0)
    c++;
  cout << c << endl;
}