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

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, n) for (int i = 0; i < (int)n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const ll MOD = 1e9 + 7;

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

  ll x;
  cin >> x;

  ll ans = 0;
  for (ll i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      ll p = 1;
      ll aux = 0;
      while (x % i == 0) {
        x /= i;
        aux++;
        if (aux == p) {
          ans++;
          aux = 0;
          p++;
        }
      }
    }
  }

  if (x > 1)
    ans++;

  cout << ans << '\\n';

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, n) for (int i = 0; i < (int)n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const ll MOD = 1e9 + 7;

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

  ll x;
  cin >> x;

  ll ans = 0;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      int p = 1;
      int aux = 0;
      while (x % i == 0) {
        x /= i;
        aux++;
        if (aux == p) {
          ans++;
          aux = 0;
          p++;
        }
      }
    }
  }

  if (x > 1)
    ans++;

  cout << ans << '\\n';

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

#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

bool isPrime(lld k) {
  if (k == 1)
    return false;

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

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

  lld n = 0;
  cin >> n;

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

  int ans = 0;

  vector<lld> v;

  map<lld, int> mp;

  v.push_back(1);
  for (int i = 2; i <= 100; i++) {
    v.push_back(v.back() + i);
  }

  for (lld i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      if (isPrime(n / i) && i != n / i) {
        mp[n / i]++;
      }
      n /= i;
    }
  }

  for (auto &p : mp) {
    ans += upper_bound(ALL(v), p.second) - v.begin();
  }

  cout << max(1, ans) << '\\n';

  return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

bool isPrime(lld k) {
  if (k == 1)
    return false;

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

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

  lld n = 0;
  cin >> n;

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

  int ans = 0;

  vector<lld> v;

  map<lld, int> mp;

  v.push_back(1);
  for (int i = 2; i <= 100; i++) {
    v.push_back(v.back() + i);
  }

  for (lld i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      if (isPrime(n / i) && i != n / i) {
        mp[n / i]++;
      }
      n /= i;
    }
  }

  for (auto &p : mp) {
    ans += upper_bound(ALL(v), p.second) - v.begin();
  }

  cout << max(1, ans) << '\\n';

  return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"

using namespace std;

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

  vector<long long> x;
  for (long long i = 2; i * i <= N; i++) {
    int m = 0;
    while (N % i == 0) { // 素数で割り切れなくなるまで割っていく
      m++;               // 割った個数を配列に足す
      N /= i;
    }
    if (0 != m) {
      x.push_back(m);
    }
    if (1 == N) {
      break;
    }
  }
  if (1 != N) {
    x.push_back(1);
  }

  int nAns = 0;
  for (long long n = 0; n < x.size(); ++n) {
    int m = sqrt(2 * x[n]) - 1;
    int l = x[n] - ((1 + m) * m) / 2;
    nAns += m;
    m++;
    while (m <= l) {
      l -= m;
      m++;
      nAns += 1;
    }
  }

  std::cout << nAns << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"

using namespace std;

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

  vector<long long> x;
  for (long long i = 2; i <= N; i++) {
    int m = 0;
    while (N % i == 0) { // 素数で割り切れなくなるまで割っていく
      m++;               // 割った個数を配列に足す
      N /= i;
    }
    if (0 != m) {
      x.push_back(m);
    }
    if (1 == N) {
      break;
    }
  }
  int nAns = 0;
  for (long long n = 0; n < x.size(); ++n) {
    int m = sqrt(2 * x[n]) - 1;
    int l = x[n] - ((1 + m) * m) / 2;
    nAns += m;
    m++;
    while (m <= l) {
      l -= m;
      m++;
      nAns += 1;
    }
  }

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

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

int main() {

  long long n;
  long long answer = 0;
  cin >> n;
  long long tmp_n = n;
  for (long long i = 2; i * i <= n; i++) {
    long long tmp = i;
    while (tmp_n % tmp == 0) {
      tmp_n /= tmp;
      answer++;
      tmp *= i;
    }
    while (tmp_n % ((long long)i) == 0) {
      tmp_n /= i;
    }
  }
  cout << answer + (tmp_n > 1) << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {

  long long n;
  int answer = 0;
  cin >> n;
  long long tmp_n = n;
  for (int i = 2; i * i <= n; i++) {
    long long tmp = i;
    while (tmp_n % tmp == 0) {
      tmp_n /= tmp;
      answer++;
      tmp *= i;
    }
    while (tmp_n % ((long long)i) == 0) {
      tmp_n /= i;
    }
  }
  cout << answer + (tmp_n > 1) << endl;
  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 long long ll;
typedef unsigned long long ull;
template <typename T> void fin(T a) {
  cout << a << endl;
  exit(0);
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  map<ll, ll> mp;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      mp[i]++;
    }
  }
  if (n != 1)
    mp[n]++;
  for (auto x : mp) {
    ll s = x.second;
    ll now = 1;
    while (now <= s) {
      s -= now;
      now++;
      ans++;
    }
  }

  fin(ans);
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> void fin(T a) {
  cout << a << endl;
  exit(0);
}

int main() {
  ll n;
  cin >> n;
  int ans = 0;
  map<int, int> mp;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      mp[i]++;
    }
  }
  if (n != 1)
    mp[n]++;
  for (auto x : mp) {
    int s = x.second;
    int now = 1;
    while (now <= s) {
      s -= now;
      now++;
      ans++;
    }
  }

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

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

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

  int ans = 0;
  for (auto &x : P) {
    int s = x.second;
    int k = 1;
    while (s >= k) {
      s -= k;
      k++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  ll n;
  cin >> n;
  vector<int> x(n + 1);
  int num = n;
  for (ll i = 2; i <= n; i++) {
    while (num % i == 0) {
      x.at(i)++;
      num /= i;
    }
  }
  int ans = 0;
  for (ll i = 2; i <= n; i++) {
    for (int k = 1; k < n; k++) {
      x.at(i) -= k;
      if (x.at(i) < 0)
        break;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>

using namespace std;

int result = 0;

void prime_factor(int64_t n) {
  for (int64_t i = 2; i * i <= n; i++) {
    int before = 0;
    int now = 0;
    while (n % i == 0) {
      now++;
      if (now > before) {
        result++;
        before = now;
        now = 0;
      }
      n /= i;
    }
  }
  if (n != 1) {
    result++;
  }
  return;
}

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

  cout << result << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <map>

using namespace std;

int result = 0;

void prime_factor(int64_t n) {
  for (int64_t i = 2; i <= n; i++) {
    int before = 0;
    int now = 0;
    while (n % i == 0) {
      now++;
      if (now > before) {
        result++;
        before = now;
        now = 0;
      }
      n /= i;
    }
  }
  return;
}

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

  cout << result << 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;
using ll = long long;
using P = pair<int, int>;

ll lower(ll m) {
  ll ans = 1;
  while (ans * (ans + 1) / 2 <= m) {
    ans++;
  }

  return ans - 1;
}

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

map<ll, ll> factor(ll x) {
  map<ll, ll> fac;
  ll p = 2;
  while (p * p <= x) {
    if (x % p == 0) {
      fac[p]++;
      x /= p;
    } else {
      p++;
    }
  }
  if (isprime(x))
    fac[x]++;

  return fac;
}

void solve() {
  ll n;
  cin >> n;

  ll ans = 0;
  map<ll, ll> fac = factor(n);
  for (auto it = fac.begin(); it != fac.end(); it++) {
    ans += lower(it->second);
  }

  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}


Error: TLE

Fixed submission:

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

ll lower(ll m) {
  ll ans = 1;
  while (ans * (ans + 1) / 2 <= m) {
    ans++;
  }

  return ans - 1;
}

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

map<ll, ll> factor(ll x) {
  map<ll, ll> fac;
  ll p = 2;
  while (x != 1) {
    if (isprime(x)) {
      fac[x]++;
      return fac;
    }
    while (x % p == 0) {
      fac[p]++;
      x /= p;
      if (x == 0) {
        return fac;
      }
    }
    p++;
  }

  return fac;
}

void solve() {
  ll n;
  cin >> n;

  ll ans = 0;
  map<ll, ll> fac = factor(n);
  for (auto it = fac.begin(); it != fac.end(); it++) {
    ans += lower(it->second);
  }

  cout << ans << endl;
}

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

// g++ -std=c++11
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

const int INF = 1000000000;
const int MAXN = 200000;
const int MOD = 1000000007;
const char nl = '\\n';

int main() {

  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

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

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

  cout << ans << nl;
  return 0;
}

Error: TLE

Fixed submission:

// g++ -std=c++11
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

const int INF = 1000000000;
const int MAXN = 200000;
const int MOD = 1000000007;
const char nl = '\\n';

int main() {

  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

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

  for (int i = 2; i * i <= n; i++) {
    int j = 1;
    if (n % i == 0) {
      ll fact = i, cont = 0;
      while (n % i == 0) {
        n /= i;
        cont++;
        if (cont == j) {
          ans++;
          j++;
          cont = 0;
        }
      }
    }
  }
  if (n > 1)
    ans++;

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

#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main() {
  long long n, rest;
  double root;
  int count = 0;
  vector<pair<int, int>> P;

  cin >> n;
  root = sqrt(n);

  rest = n;
  for (int i = 2; i <= root; i++) {
    count = 0;
    while (rest % i == 0) {
      rest /= i;
      count++;
    }
    P.push_back(make_pair(i, count));
  }

  if (n % rest == 0 && rest > root) {
    P.push_back(make_pair(rest, 1));
  }

  int ans = 0;
  for (int i = 0; i < P.size(); i++) {
    for (int j = 1; j < 1000000000000; j++) {
      P[i].second -= j;
      if (P[i].second < 0) {
        break;
      }
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main() {
  long long n, rest;
  double root;
  int count = 0;

  cin >> n;
  root = sqrt(n);

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

  rest = n;
  for (int i = 2; i <= n / 2; i++) {
    if (rest % i == 0) {
      rest /= i;
      count += 1;
    }
  }
  if (count == 0) {
    count += 1;
  }

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

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

int main() {
  long long n;
  int c = 0;
  int d = 0;
  cin >> n;
  vector<long long> a(17);
  if (n > 3) {
    for (long long i = 2; i * i <= n; i++) {
      int b = 0;
      while (n % i == 0) {
        b++;
        n /= i;
      }
      if (b != 0) {
        a.at(d) = b;
        d++;
      }
    }
    if (n != 1) {
      c++;
    }
    for (long long i = 0; a.at(i) != 0; i++) {
      for (long long j = 1; a.at(i) >= j; j++) {
        a.at(i) -= j;
        c++;
      }
    }
    cout << c << endl;
  } else if (n == 1) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  long long n;
  int c = 0;
  int d = 0;
  cin >> n;
  vector<long long> a(20);
  if (n > 3) {
    for (int i = 2; i * i <= n; i++) {
      int b = 0;
      while (n % i == 0) {
        b++;
        n /= i;
      }
      if (b != 0) {
        a.at(d) = b;
        d++;
      }
    }
    if (n != 1) {
      c++;
    }
    for (int i = 0; a.at(i) != 0; i++) {
      for (int j = 1; a.at(i) >= j; j++) {
        a.at(i) -= j;
        c++;
      }
    }
    cout << c << endl;
  } else if (n == 1) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

  ll ans = 0;
  for (auto c : m) {
    ll cnt = 1;
    ll remain = c.second;
    while (remain >= cnt) {
      remain -= cnt;
      ans++;
      cnt++;
    }
  }

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


Error: TLE

Fixed submission:

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

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

  vector<int> prime_cnts;

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

  int ans = 0;
  for (auto c : m) {
    ll cnt = 1;
    while (c.second >= cnt) {
      c.second -= cnt;
      ans++;
      cnt++;
    }
  }

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

#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> v;
  ll k = 0;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(0);
      while (n % i == 0) {
        v[k]++;
        n /= i;
      }
      k++;
    }
  }
  if (n > 1)
    v.push_back(1);

  ll ans = 0;
  for (ll i = 0; i < v.size(); i++) {
    ll k = 1;
    while (k * (k + 1) / 2 <= v[i])
      k++;
    ans += k - 1;
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> v;
  int k = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(0);
      while (n % i == 0) {
        v[k]++;
        n /= i;
      }
      k++;
    }
  }
  if (n > 1)
    v.push_back(1);

  ll ans = 0;
  for (int i = 0; i < v.size(); i++) {
    int k = 1;
    while (k * (k + 1) / 2 <= v[i])
      k++;
    ans += k - 1;
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for (int i = 0; i < n; i++)
#define IINF 2e9
#define MOD 1e9 + 7

int main(void) {

  ll n;
  cin >> n;
  map<ll, int> mp;

  bool flag = true;

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

  if (n % 2 != 0) {
    for (int i = 3; i <= sqrt(n); i += 2) {
      if (n % i == 0) {
        flag = false;
      }
    }

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

  ll temp = n;
  while (temp % 2 == 0) {
    mp[2]++;
    temp /= 2;
  }

  for (int i = 3; i <= sqrt(n); i++) {
    while (temp % i == 0) {
      mp[i]++;
      temp /= i;
    }
  }
  int ans = 0;

  if (temp != 1)
    ans++;

  for (auto m : mp) {
    ans += (-1 + sqrt(1 + m.second * 8)) / 2;
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for (int i = 0; i < n; i++)
#define IINF 2e9
#define MOD 1e9 + 7

int main(void) {

  ll n;
  cin >> n;
  map<ll, int> mp;

  bool flag = true;

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

  if (n % 2 != 0) {
    for (int i = 3; i <= sqrt(n); i += 2) {
      if (n % i == 0) {
        flag = false;
      }
    }

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

  ll temp = n;
  while (temp % 2 == 0) {
    mp[2]++;
    temp /= 2;
  }
  for (int i = 3; i <= temp; i++) {
    while (temp % i == 0) {
      mp[i]++;
      temp /= i;
    }
  }

  int ans = 0;
  for (auto m : mp) {
    ans += (-1 + sqrt(1 + m.second * 8)) / 2;
  }

  cout << ans << endl;

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

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

vector<pair<ll, ll>> fact(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    p.push_back(make_pair(i, cnt));
  }
  if (n != 1)
    p.push_back(make_pair(n, 1));
  return p;
}
int main() {

  ll n;
  cin >> n;
  const auto &res = fact(n);
  int ans = 0;
  for (auto iter : res) {
    int cnt = iter.second;
    int i = 1;
    while (cnt >= i) {
      cnt -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

vector<pair<ll, ll>> fact(ll n) {
  vector<pair<ll, ll>> p;
  for (int i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    p.push_back(make_pair(i, cnt));
  }
  if (n != 1)
    p.push_back(make_pair(n, 1));
  return p;
}
int main() {

  ll n;
  cin >> n;
  const auto &res = fact(n);
  int ans = 0;
  for (auto iter : res) {
    int cnt = iter.second;
    int i = 1;
    while (cnt >= i) {
      cnt -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
 * problem:
 * method:
 * date:
 */
#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>
#define LL long long
using namespace std;
vector<pair<LL, int>> v;
LL N, res;
int main() {
  LL i;
  cin >> N;
  for (i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      v.push_back(make_pair(i, 0));
      while (N % i == 0) {
        v.back().second++;
        N /= i;
      }
    }
  }
  if (N > 1) {
    v.push_back(make_pair(N, 1));
  }
  res = 0;
  for (pair<LL, int> &p : v) {
    int x = sqrt(p.second * 2);
    if ((x + 1) * x > p.second * 2) {
      x--;
    }
    res += x;
  }
  cout << res << endl;
  return 0;
}


Error: TLE

Fixed submission:

/*
 * problem:
 * method:
 * date:
 */
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>
#define LL long long
using namespace std;
vector<pair<LL, int>> v;
LL N, res;
int main() {
  LL i;
  cin >> N;
  for (i = 2; i < N; i++) {
    if (N % i == 0) {
      v.push_back(make_pair(i, 0));
      while (N % i == 0) {
        v.back().second++;
        N /= i;
      }
    }
  }
  if (N > 1) {
    v.push_back(make_pair(N, 1));
  }
  res = 0;
  for (i = 0; i < v.size(); i++) {
    pair<LL, int> p = v[i];
    int x = sqrt(p.second * 2);
    if ((x + 1) * x > p.second * 2) {
      x--;
    }
    res += x;
  }
  cout << res << endl;
  return 0;
}