alexjercan/bugnet huggingface dataset:
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 REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int, int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

void factor(ll a, map<ll, ll> &factors) {
  for (int i = 2; i * i <= a; i++) {
    if (0 == a % i)
      while (0 == a % i) {
        a /= i;
        factors[i]++;
      }
  }
  if (1 != a)
    factors[a]++;
  return;
}

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

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

  for (auto p : fs) {
    ll x = p.second;
    ll b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }

  cout << ans;

  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 REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int, int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

void factor(ll a, map<ll, ll> &factors) {
  for (int i = 2; i * i <= a; i++) {
    if (0 == a % i)
      while (0 == a % i) {
        a /= i;
        factors[i]++;
      }
  }
  if (1 != a)
    factors[a]++;
  return;
}

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

  map<ll, ll> factors;
  factor(N, factors);

  for (auto p : factors) {
    ll x = p.second;
    ll b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }

  cout << ans;

  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;
typedef pair<int, int> P;
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<int, int>> prime;
  int ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    if (n % i == 0) {
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      for (int j = 1;; j++) {
        cnt -= j;
        if (cnt >= 0)
          ans++;
        else
          break;
      }
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<int, int>> prime;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    if (n % i == 0) {
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      for (int j = 1;; j++) {
        cnt -= j;
        if (cnt >= 0)
          ans++;
        else
          break;
      }
    }
  }
  if (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;
  long long ii;
  long kotae;
  int i;
  int j;
  int k;
  int a[66];

  k = 1;
  a[0] = 0;
  a[1] = 0;
  for (i = 1; i < 11; i++) {
    a[k] = a[k - 1] + 1;
    k++;
    for (j = 0; j < i; j++) {
      a[k] = a[k - 1];
      k++;
    }
  }

  cin >> n;

  kotae = 0;

  for (ii = 2; i < 1000001; ii++) {
    i = 0;
    while (n > 0) {
      // iiで割り切れなければループを抜ける
      if (n % ii > 0) {
        break;
      }
      n = n / ii;
      i++;
    }
    kotae = kotae + a[i];
    if (ii * ii > n) {
      break;
    }
  }
  if (n > 1)
    kotae++;
  cout << kotae << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  long long n;
  long long ii;
  long kotae;
  int i;
  int j;
  int k;
  int a[66];

  k = 1;
  a[0] = 0;
  a[1] = 0;
  for (i = 1; i < 11; i++) {
    a[k] = a[k - 1] + 1;
    k++;
    for (j = 0; j < i; j++) {
      a[k] = a[k - 1];
      k++;
    }
  }

  cin >> n;

  kotae = 0;

  for (ii = 2; i < 1000001; ii++) {
    i = 0;
    while (n > 0) {
      // iiで割り切れなければループを抜ける
      if (n % ii > 0) {
        break;
      }
      n = n / ii;
      i++;
    }
    kotae = kotae + a[i];
    if (ii > n) {
      break;
    }
  }
  if (n > 1)
    kotae++;
  cout << kotae << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  // unordered_map<ll, int> count;
  // count.reserve(1024);
  vector<pair<ll, int>> factors;
  ll ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      // ans = max(ans, count[i]);
      // ans -= count[i]/2;
      // ans += (count[i]+1)/2;
      n /= i;
      // factors.pb(i);
    }
    factors.pb(mp(i, cnt));
  }
  if (n != 1) {
    factors.pb(mp(n, 1));
    // count[n]++;
    // ans += 1;
  }
  for (auto it : factors) {
    int times = it.s;
    // int times = count[it];
    int curr = 1;
    while (times - curr >= 0) {
      times -= curr;
      curr++;
      ans++;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  // unordered_map<ll, int> count;
  // count.reserve(1024);
  vector<pair<ll, int>> factors;
  ll ans = 0;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      // ans = max(ans, count[i]);
      // ans -= count[i]/2;
      // ans += (count[i]+1)/2;
      n /= i;
      // factors.pb(i);
    }
    factors.pb(mp(i, cnt));
  }
  if (n != 1) {
    factors.pb(mp(n, 1));
    // count[n]++;
    // ans += 1;
  }
  for (auto it : factors) {
    int times = it.s;
    // int times = count[it];
    int curr = 1;
    while (times - curr >= 0) {
      times -= curr;
      curr++;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(), a.end()
#define dbg(n) cout << #n << ' ' << n << endl;
#define dbg_v(v)                                                               \\
  cout << #v << ":";                                                           \\
  for (auto x : v)                                                             \\
    cout << " " << x;                                                          \\
  cout << endl;
int power(ll x, ll y) {
  ll res = 1;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
int gcd(int a, int b) {
  if (!a)
    return b;
  return gcd(b % a, a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  ll k = n;
  vector<int> a;
  ll sum[1000001];
  sum[0] = 0;
  sum[1] = 1;
  for (int i = 2; i < 1000001; i++)
    sum[i] = sum[i - 1] + i;
  for (ll i = 2; i * i <= n; i++) {
    int ct = 0;
    while (k % i == 0) {
      k /= i;
      ct++;
    }
    if (ct) {
      a.pb(ct);
    }
  }
  if (k > 1)
    a.pb(1);
  ll ans = 0;
  for (int i = 0; i < (int)a.size(); i++) {
    auto l = lower_bound(sum, sum + a[i], a[i]);
    if (sum[l - sum] > a[i])
      ans += (ll)(l - sum) - 1;
    else
      ans += (ll)(l - sum);
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define dbg(n) cout << #n << ' ' << n << endl;
int main() {
  ll n;
  cin >> n;
  int pro[32] = {0};
  pro[0] = 0;
  pro[1] = 1;
  for (int i = 2; i < 32; i++)
    pro[i] = pro[i - 1] + i;
  int a[1000001] = {0};
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      a[i]++;
      n = n / i;
    }
  }
  ll ans = 0;
  if (n > 1)
    ans++;
  for (int i = 0; i < 1000001; i++) {
    if (a[i] > 0) {
      int k = 0;
      while (pro[k] < a[i])
        k++;
      if (pro[k] > a[i])
        k--;
      //	cout<<pro[3]<<" "<<pro[4]<<endl;
      ans += k;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template <typename T> inline istream &operator>>(istream &i, v(T) & v) {
  rep(j, sz(v)) i >> v[j];
  return i;
}
template <typename T1, typename T2>
inline istream &operator>>(istream &i, pair<T1, T2> &v) {
  return i >> v.fi >> v.se;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i * i <= n; ++i) {
    ll cnt = 0;
    ll c = 0;
    while (n % i == 0) {
      c++;
      if (cnt < c) {
        cnt++;
        c -= cnt;
      }
      n /= i;
    }
    ans += cnt;
  }
  if (n > 1)
    ans++;
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template <typename T> inline istream &operator>>(istream &i, v(T) & v) {
  rep(j, sz(v)) i >> v[j];
  return i;
}
template <typename T1, typename T2>
inline istream &operator>>(istream &i, pair<T1, T2> &v) {
  return i >> v.fi >> v.se;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

  ll n;
  cin >> n;
  ll temp = n;
  ll ans = 0;
  for (int i = 2; i * i <= temp; ++i) {
    ll cnt = 0;
    ll c = 0;
    while (temp % i == 0) {
      c++;
      if (cnt < c) {
        cnt++;
        c -= cnt;
      }
      temp /= i;
    }
    ans += cnt;
  }
  if (temp > 1)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

static bool is_prime(large x) {
  if (x <= 1 || x % 2 == 0 || x % 3 == 0)
    return false;
  for (auto k = 5LL; k * k <= x; k += 6) {
    if (x % k == 0)
      return false;
    if (x % (k + 2) == 0)
      return false;
  }

  return true;
}

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

  auto primes = std::vector<large>();
  primes.push_back(2);
  primes.push_back(3);
  for (auto x = 5LL; x * x <= 1'000'000'000'000; x += 6) {
    if (is_prime(x))
      primes.push_back(x);
    if (is_prime(x + 2))
      primes.push_back(x + 2);
  }

  auto counter = map<large, large>();
  {
    auto x = n;
    for (auto p : primes) {
      if (x < p)
        break;
      if (x % p == 0) {
        x /= p;
        auto cnt = 1LL;
        while (x % p == 0) {
          x /= p;
          cnt++;
        }
        counter[p] = cnt;
      }
    }
    if (x != 1) {
      counter[x] = 1;
    }
  }

  auto total = 0LL;
  for (auto [val, cnt] : counter) {
    // cout << val << " for " << cnt << "times\\n";
    for (auto size = 1; size <= cnt; size++) {
      cnt -= size;
      total++;
    }
  }

  cout << total << endl;
  return 0;
}


Error: TLE

Fixed submission:

#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

  auto counter = map<large, large>();
  auto x = n;
  while (x % 2 == 0) {
    x /= 2;
    counter[2]++;
  }
  for (auto d = 3; d * d <= x; d += 2) {
    while (x % d == 0) {
      x /= d;
      counter[d]++;
    }
  }
  if (x != 1) {
    counter[x]++;
  }

  auto total = 0LL;
  for (auto [val, cnt] : counter) {
    for (auto size = 1; size <= cnt; size++) {
      cnt -= size;
      total++;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

ll f(ll x) {
  ll ans = 0;
  ll cnt = 0;
  while (1) {
    ans = ans + cnt;
    if (ans >= x) {
      if (ans == x) {
        return cnt;
      } else {
        return cnt - 1;
      }
    }
    cnt++;
  }
  return 0;
}

int main() {
  ll n, NUM;
  ll ans = 0;
  cin >> n;
  NUM = n;
  vector<ll> primes;

  ll cnt = 0;

  for (ll i = 2; i * i <= NUM; ++i) {
    cnt = 0;
    while (n % i == 0) {
      cnt++;
      // x.at(i)++;
      n /= i;
    }
    if (cnt) {
      // cout << i << " " << cnt << endl;
      ans += f(cnt);
    }
  }

  if (n != 1) {
    // x.at(num)++;
    ans++;
  }

  // for (int i = 2; i <= n; i++)
  // {
  //     ans += f(x.at(i));
  // }
  // if (num != 1)
  // {
  //     ans++;
  // }

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


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

ll f(ll x) {
  ll ans = 0;
  ll cnt = 0;
  while (1) {
    ans = ans + cnt;
    if (ans >= x) {
      return cnt;
    }
    cnt++;
  }
  return 0;
}

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

  vector<int> x(n + 1);
  int num = n;

  for (int i = 2; i * i <= n; ++i) {
    while (num % i == 0) {
      x.at(i)++;
      num /= i;
    }
  }

  if (num != 0) {
    x.at(num)++;
  }

  for (int i = 2; i <= n; i++) {
    ans += f(x.at(i));
  }
  if (num != 1) {
    ans++;
  }

  cout << ans << endl;
  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;
  vector<pair<int64_t, int64_t>> table;

  int64_t y = 0;
  while (N % 2 == 0) {
    N /= 2;
    y++;
    if (N % 2 != 0 && y != 0) {
      table.emplace_back(2, y);
      break;
    }
  }
  // cout << N << endl;
  int64_t i = 3;
  while (i * i <= N) {
    int64_t x = 0;
    while (N % i == 0) {
      N /= i;
      x++;
      // cout << N << endl;
    }
    if (x != 0) {
      table.emplace_back(i, x);
    }
    i += 2;
  }

  if (N != 1) {
    table.emplace_back(N, 1);
  }

  // ここで各素因数のチェック
  /*for (int i = 0; i < table.size(); i++) {
        cout << table.at(i).first << " " << table.at(i).second <<endl;
  }*/

  int64_t ans = 0;

  // 長さチェック
  // cout << table.size() << endl;

  for (int64_t j = 0; j < table.size(); j++) {
    int64_t y = table.at(j).second;
    int64_t b = 1;
    while (y >= b) {
      ans++;
      y -= b;
      b++;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int64_t N;
  cin >> N;
  vector<pair<int, int>> table;

  int y = 0;
  while (N % 2 == 0) {
    N /= 2;
    y++;
    if (N % 2 != 0 && y != 0) {
      table.emplace_back(2, y);
      break;
    }
  }

  int i = 3;
  while (i * i < N) {
    int x = 0;
    while (N % i == 0) {
      N /= i;
      x++;
    }
    if (x != 0) {
      table.emplace_back(i, x);
    }
    i += 2;
  }

  if (N != 1) {
    table.emplace_back(N, 1);
  }

  // ここで各素因数のチェック
  /*for (int i = 0; i < table.size(); i++) {
        cout << table.at(i).first << " " << table.at(i).second <<endl;
  }*/

  int ans = 0;

  // 長さチェック
  // cout << table.size() << endl;

  for (int j = 0; j < table.size(); j++) {
    int y = table.at(j).second;
    int b = 1;
    while (y >= b) {
      ans++;
      y -= b;
      b++;
    }
  }

  cout << ans << endl;

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

#include <algorithm>
#include <iostream>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;
const long long m = 1e18;
int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  for (long long i = 2; i * i <= n; i++) {
    long long cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    int j = 1;
    while (cnt) {
      if (cnt >= j) {
        cnt -= j;
        ans++;
        j++;
      } else
        break;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;
const long long m = 1e18;
int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    int j = 1;
    while (cnt) {
      if (cnt >= j) {
        cnt -= j;
        ans++;
        j++;
      } else
        break;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}
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;

int main() {
  long n, ans = 0;
  cin >> n;
  long temp = n;
  for (long i = 2; i * i <= n; i++) {
    long t = 0;
    while (temp % i == 0) {
      temp /= i;
      t++;
    }
    if (t >= 36) {
      ans += 8;
    } else if (t >= 28) {
      ans += 7;
    } else if (t >= 21) {
      ans += 6;
    } else if (t >= 15) {
      ans += 5;
    } else if (t >= 10) {
      ans += 4;
    } else if (t >= 6) {
      ans += 3;
    } else if (t >= 3) {
      ans += 2;
    } else if (t >= 1) {
      ans += 1;
    }
  }
  if (temp != 1)
    ans++;
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  long n, ans = 0;
  cin >> n;
  long temp = n;
  for (int i = 2; i * i <= n; i++) {
    long t = 0;
    while (temp % i == 0) {
      temp /= i;
      t++;
    }
    if (t >= 36) {
      ans += 8;
    } else if (t >= 28) {
      ans += 7;
    } else if (t >= 21) {
      ans += 6;
    } else if (t >= 15) {
      ans += 5;
    } else if (t >= 10) {
      ans += 4;
    } else if (t >= 6) {
      ans += 3;
    } else if (t >= 3) {
      ans += 2;
    } else if (t >= 1) {
      ans += 1;
    }
  }
  if (temp != 1)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i, a, n) for (int i = a; i < n; i++)
#define rf(i, n, a) for (int i = n; i >= a; i--)
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()
#define fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int fun(int n) {
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (i * (i + 1) / 2 <= n)
      res = i;
  }
  return res;
}
int32_t main() {
  fast;
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0)
        cnt++, n /= i;
      ans += fun(cnt);
    }
  }
  if (n > 1)
    ans++;
  cout << ans << "\\n";
}

Error: TLE

Fixed submission:

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i, a, n) for (int i = a; i < n; i++)
#define rf(i, n, a) for (int i = n; i >= a; i--)
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()
#define fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int fun(int n) {
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (i * (i + 1) / 2 <= n)
      res = i;
  }
  return res;
}
int32_t main() {
  fast;
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0)
        cnt++, n /= i;
      ans += fun(cnt);
    }
  }

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