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

#include <bits/stdc++.h>
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define mod (ll)(1e9 + 7)
#define inf (ll)(3e18 + 7)
#define pi (double)acos(-1.0)
#define P pair<int, int>
#define PiP pair<int, pair<int, int>>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp = prime_factor(n);
  ll ans = 0;
  for (auto x : mp) {
    ll now = x.second;
    ll i = 1, cnt = 1;
    while (cnt <= now) {
      i++;
      cnt += i;
    }
    ans += i - 1;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define mod (ll)(1e9 + 7)
#define inf (ll)(3e18 + 7)
#define pi (double)acos(-1.0)
#define P pair<int, int>
#define PiP pair<int, pair<int, int>>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> mp;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1)
    mp[n]++;
  return mp;
}

int main() {
  ll n, ans = 0;
  cin >> n;
  for (auto x : prime_factor(n)) {
    ll now = x.second, i = 1;
    while (now - i >= 0) {
      now -= i;
      ans++;
      i++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

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

  int ans = 0;
  for (auto v : vp) {
    int t = v.second;
    int dis = 1;
    while (t >= dis) {
      t -= dis;
      dis++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

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

  ll ans = 0;
  for (auto v : vp) {
    ll t = v.second;
    ll dis = 1;
    while (t >= dis) {
      t -= dis;
      dis++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
  ll n;
  cin >> n;
  bool flag = false;
  for (ll i = 2; i * i <= n; ++i) {
    if (!(n % i)) {
      flag = 1;
      break;
    }
  }
  if (!flag && n ^ 1) {
    cout << 1 << "\\n";
    return;
  }
  unordered_map<ll, int> div;
  int ans = 0;
  while (!(n % 2)) {
    n /= 2;
    div[2]++;
  }
  for (ll i = 3; i * i <= n; i += 2) {
    while (!(n % i)) {
      ++div[i];
      n /= i;
    }
  }
  if (n > 1)
    div[n]++;
  for (auto &i : div) {
    int k = 1;
    while (i.se >= k) {
      ++ans;
      i.se -= k;
      ++k;
    }
  }
  cout << ans << "\\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
  ll n;
  cin >> n;
  bool flag = false;
  for (int i = 2; 1LL * i * i <= n; ++i) {
    if (!(n % i)) {
      flag = 1;
      break;
    }
  }
  if (!flag && n ^ 1) {
    cout << 1 << "\\n";
    return;
  }
  unordered_map<int, int> div;
  int i = 2, ans = 0;
  while (n ^ 1) {
    while (!(n % i)) {
      ++div[i];
      n /= i;
    }
    ++i;
  }
  for (auto &j : div) {
    int k = 1;
    while (j.se >= k) {
      ++ans;
      j.se -= k;
      ++k;
    }
  }
  cout << ans << "\\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

//-----------------------
// author : xyqkoala
// time : 2020-07-23
//-----------------------

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long LL;
const int MOD = 1e9 + 7;

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int T = 1;
  // cin>>T;
  while (T--) {
    solve();
  }
  return 0;
}

void solve() {
  LL n;
  cin >> n;
  unordered_map<int, int> t;
  for (LL i = 2; i * i <= n; i++) {
    if (n % i)
      continue;
    while (n % i == 0) {
      n = n / i;
      t[i]++;
    }
  }
  if (n > 1)
    t[n]++;
  int res = 0;
  for (auto item : t) {
    int cnt = 2 * item.second;
    int tcnt = sqrt(cnt);
    if ((tcnt * (tcnt + 1) > cnt))
      tcnt--;
    res += tcnt;
  }
  cout << res << endl;
}


Error: TLE

Fixed submission:

//-----------------------
// author : xyqkoala
// time : 2020-07-23
//-----------------------

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long LL;
const int MOD = 1e9 + 7;

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int T = 1;
  // cin>>T;
  while (T--) {
    solve();
  }
  return 0;
}

void solve() {
  LL n;
  cin >> n;
  unordered_map<int, int> t;
  for (int i = 2; i * i <= n; i++) {
    if (n % i)
      continue;
    while (n % i == 0) {
      n = n / i;
      t[i]++;
    }
  }
  if (n > 1)
    t[n]++;
  int res = 0;
  for (auto item : t) {
    int cnt = 2 * item.second;
    int tcnt = sqrt(cnt);
    if ((tcnt * (tcnt + 1) > cnt))
      tcnt--;
    res += tcnt;
  }
  cout << res << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  for (long long i = 3; i * i <= num; i += 2) {
    if (num % i == 0)
      return false;
  }

  return true;
}

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

  map<long long, long long> cnt;
  set<long long> ans;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    bool ok = IsPrime(i);
    if (ok) {
      long long k = n;
      while (k % i == 0) {
        cnt[i]++;
        k /= i;
      }
    }

    long long l = n / i;
    ok = IsPrime(l);
    if (ok) {
      long long k = n;
      while (k % l == 0) {
        cnt[l]++;
        k /= l;
      }
    }
  }

  for (auto now : cnt) {
    long long num = now.first, c = now.second - 1;
    long long l = num;
    long long j = 1;
    while (c >= 0) {
      if (ans.count(l)) {
        l *= num;
        j++;
        c--;
      }
      if (c < 0)
        break;
      if (!ans.count(l)) {
        ans.insert(l);
        c -= j;
      }
    }
  }

  cout << ans.size() << endl;
}

Error: TLE

Fixed submission:

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

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

  map<long long, long long> cnt;
  set<long long> ans;
  for (long long i = 1; i * i <= n; i++) {
    bool ok = false;
    for (long long j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        ok = true;
        break;
      }
    }
    if (!ok && i != 1) {
      long long k = n;
      while (k % i == 0) {
        cnt[i]++;
        k /= i;
      }
    }
    ok = false;
    long long l = n / i;
    for (long long j = 2; j * j <= l; j++) {
      if (l % j == 0) {
        ok = true;
        break;
      }
    }
    if (!ok) {
      long long k = n;
      while (k % l == 0) {
        cnt[l]++;
        k /= l;
      }
    }
  }

  for (auto now : cnt) {
    long long num = now.first, c = now.second - 1;
    long long l = num;
    long long j = 1;
    while (c >= 0) {
      if (ans.count(l)) {
        l *= num;
        j++;
        c--;
      }
      if (c < 0)
        break;
      if (!ans.count(l)) {
        ans.insert(l);
        c -= j;
      }
    }
  }

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

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

map<long long int, int> prime_factor(long long int n) {
  map<long long int, int> ret;
  for (long long int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

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

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  int output = 0;

  map<long long int, int> prime = prime_factor(N);

  vector<int> done;
  for (long long int i = 0; i < N + 1; i++) {
    if (prime[N] != 0) { // N is prime
      output++;
      cout << output << endl;
      return 0;
    }
    int num = 1;
    while (1) {
      if (prime[i] == 0) {
        break;
      }
      if (prime[i] >= num) {
        if (find(done.begin(), done.end(), pow(i, num)) !=
            done.end()) { // if i^num is in done
          break;
        } else {
          N /= pow(i, num);
          output++;
          prime[i] -= num;
          num += 1;
          continue;
        }
      } else {
        N /= pow(i, prime[i]);
        break;
      }
    }
  }
  cout << output << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

map<long long int, int> prime_factor(long long int n) {
  map<long long int, int> ret;
  for (long long int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

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

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  int output = 0;

  map<long long int, int> prime = prime_factor(N);
  if (prime[N] != 0) // N is prime
  {
    cout << 1 << endl;
    return 0;
  }

  vector<int> done;
  for (long long int i = 0; i < N + 1; i++) {
    int num = 1;
    while (1) {
      if (prime[i] == 0) {
        break;
      }
      if (prime[i] >= num) {
        if (find(done.begin(), done.end(), pow(i, num)) !=
            done.end()) { // if i^num is in done
          break;
        } else {
          N /= pow(i, num);
          output++;
          prime[i] -= num;
          num += 1;
          continue;
        }
      } else {
        break;
      }
    }
  }
  cout << output << endl;

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

#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch,
 * system("pause") or input loop */
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, ans = 0;
  cin >> n;
  vector<pair<int, int>> fact;
  if (n == 1) {
    cout << 0 << "\\n";
    return 0;
  }
  bool pr = true;
  ll store = n;
  for (ll fac = 2; fac * fac <= store; fac++) {
    int cnt = 0, ansc = 0;
    while (n % fac == 0) {
      pr = false;
      n /= fac;
      cnt++;
    }
    int check{0};
    for (int j{1}; check + j <= cnt; j++) {
      check += j;
      ansc++;
    }
    ans += ansc;
  }
  if (n != 1) {
    ans++;
  }
  if (pr) {
    cout << 1 << "\\n";
    return 0;
  }
  cout << ans << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch,
 * system("pause") or input loop */
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, ans = 0;
  cin >> n;
  vector<pair<int, int>> fact;
  if (n == 1) {
    cout << 0 << "\\n";
    return 0;
  }
  bool pr = true;
  ll store = n;
  for (ll fac = 2; n != 1; fac++) {
    if (fac * fac > store && n == store) {
      break;
    }
    int cnt = 0, ansc = 0;
    while (n % fac == 0) {
      pr = false;
      n /= fac;
      cnt++;
    }
    int check{0};
    for (int j{1}; check + j <= cnt; j++) {
      check += j;
      ansc++;
    }
    ans += ansc;
  }
  if (pr) {
    cout << 1 << "\\n";
    return 0;
  }
  cout << ans << "\\n";
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main() {
  ll n;
  cin >> n;
  ll start_n = n;
  ll ans = 0;
  ll limit_i = (int)sqrt(n) + 1;
  for (int i = 2; i < limit_i; i++) {
    // if(n == 1) break;
    int count = 0;
    while (n % i == 0) {
      n /= i;
      count++;
    }
    int t = 1;
    while (count > 0) {
      count -= t;
      t++;
      if (count >= 0)
        ans++;
      ;
    }
  }

  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main() {
  ll n;
  cin >> n;
  ll start_n = n;
  ll ans = 0;
  for (int i = 2; (ll)(i * i) < start_n; i++) {
    if (n % i == 0) {
      int count = 0;
      while (n % i == 0) {
        count++;
        n /= i;
      }

      for (int j = 1; count > 0; j++) {
        if (count >= j) {
          count -= j;
          ans++;
        } else {
          break;
        }
      }
    }
  }

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

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

const int N = 1000020;
int lp[N + 5];
vector<int> pr;
#define pii pair<int, int>
vector<long long> tr;
void triangular_numbers() {
  for (int i(1);; ++i) {
    ll x = ((i * (i + 1)) / 2);

    if (x > N)
      break;
    tr.emplace_back((i * (i + 1)) / 2);
  }
}

void pre() {
  for (int i = 2; i <= N; ++i) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= N; ++j)
      lp[i * pr[j]] = pr[j];
  }
}
vector<pii> fac;
bool is_prime(ll n) {
  if (n & 1 ^ 1)
    return false;
  for (int i(3); i * i <= n; i += 2) {
    if (n % i == 0)
      return false;
  }
  return true;
}
bool flag = true;
void factor(ll x) {
  for (ll i(0); pr[i] * pr[i] <= x && i < pr.size(); ++i) {
    ll p = pr[i];

    ll cnt = 0;
    if (x % p == 0) {
      flag = false;
      while (x % p == 0) {

        cnt++;
        x /= p;
      }
      fac.emplace_back(p, cnt);
    }
  }
  if (x > 1) {
    fac.emplace_back(x, 1);
  }
}
int main() {
  ll n;
  pre();
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }

  factor(n);
  /*if (!flag) {
          cout << 1 << endl;
          return 0;
  }*/
  ll ans = 0;
  triangular_numbers();

  for (auto &x : fac) {
    auto it = upper_bound(tr.begin(), tr.end(), x.second);

    it--;
    auto k = (it - tr.begin());
    ans += (k + 1);
  }

  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

const int N = 1000020;
int lp[N + 5];
vector<int> pr;
#define pii pair<int, int>
vector<long long> tr;
void triangular_numbers() {
  for (int i(1);; ++i) {
    ll x = ((i * (i + 1)) / 2);

    if (x > N)
      break;
    tr.emplace_back((i * (i + 1)) / 2);
  }
}

void pre() {
  for (int i = 2; i <= N; ++i) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= N; ++j)
      lp[i * pr[j]] = pr[j];
  }
}
vector<pii> fac;
bool is_prime(ll n) {
  if (n & 1 ^ 1)
    return false;
  for (int i(3); i * i <= n; i += 2) {
    if (n % i == 0)
      return false;
  }
  return true;
}
void factor(ll x) {
  for (ll i(0); pr[i] * pr[i] <= x && i < pr.size(); ++i) {
    ll p = pr[i];

    ll cnt = 0;
    if (x % p == 0) {
      while (x % p == 0) {

        cnt++;
        x /= p;
      }
      fac.emplace_back(p, cnt);
    }
  }
  if (x > 1) {
    fac.emplace_back(x, 1);
  }
}
int main() {
  ll n;
  pre();
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (is_prime(n)) {
    cout << 1 << endl;
    return 0;
  }
  factor(n);
  ll ans = 0;
  triangular_numbers();

  for (auto &x : fac) {
    auto it = upper_bound(tr.begin(), tr.end(), x.second);

    it--;
    auto k = (it - tr.begin());
    ans += (k + 1);
  }

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

#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

ll N, ans;

int main() {
  fast();
  cin >> N;
  for (ll i = 2, M = N, z = 2; i * i <= M && N != 1; z = ++i) {
    while (N % z == 0)
      ans++, N /= z, z *= i;
    while (N % i == 0)
      N /= i;
  }

  cout << ans + (N != 1) << "\\n";
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

ll N, ans;

int main() {
  fast();
  cin >> N;
  for (ll i = 2, M = N; i * i <= M && N != 1; i++) {
    ll z = i;
    while (N % z == 0)
      ans++, N /= z, z *= i;
    while (N % i == 0)
      N /= i;
    assert(i < 800000);
  }

  cout << ans + (N != 1) << "\\n";
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <bits/stdc++.h>
#include <math.h>

using namespace std;
typedef long long ll;
#define M_PI 3.14159265358979323846
const int MOD = 1e9 + 7;

void solve() {
  long long n;
  cin >> n;
  int total = 0;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ll num = 0;
      while (n % i == 0) {
        n = n / i;
        num++;
      }
      for (ll j = 1;; j++) {
        if (num < j)
          break;
        num -= j;
        total++;
      }
    }
  }
  if (n != 1)
    total++;
  cout << total;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  int t = 1;
  //        cin>>t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


Error: TLE

Fixed submission:


#include <bits/stdc++.h>
#include <math.h>

using namespace std;
typedef long long ll;
#define M_PI 3.14159265358979323846
const int MOD = 1e9 + 7;

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

void solve() {
  long long n;
  cin >> n;
  int total = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ll num = 0;
      while (n % i == 0) {
        n = n / i;
        num++;
      }
      for (ll j = 1;; j++) {
        if (num < j)
          break;
        num -= j;
        total++;
      }
    }
  }
  if (n != 1)
    total++;
  cout << total;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  int t = 1;
  //        cin>>t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define pii pair<int, int>
#define fst first
#define snd second
#define pub push_back
#define vi vector<int>
#define ll long long

using namespace std;

int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, res = 0;
  cin >> n;
  for (long long i = 2; i * i <= n; i++) {
    ll to = 0;
    while (n % i == 0) {
      to++;
      n /= i;
    }
    if (to) {
      int val = sqrt(2 * to);
      if (val * (val + 1) > 2 * to) {
        val--;
      }
      res += val;
    }
  }
  if (n > 1) {
    res++;
  }
  cout << res << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define pii pair<int, int>
#define fst first
#define snd second
#define pub push_back
#define vi vector<int>
#define ll long long

using namespace std;

int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, res = 0;
  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    ll to = 0;
    while (n % i == 0) {
      to++;
      n /= i;
    }
    if (to) {
      int val = sqrt(2 * to);
      if (val * (val + 1) > 2 * to) {
        val--;
      }
      res += val;
    }
  }
  if (n > 1) {
    res++;
  }
  cout << res << "\\n";
  return 0;
}