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

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

int main() {
  ll n, nth, sum, ans, i, j;
  scanf("%lld", &n);
  j = 1;
  if (!(n & 1)) {
    while (!(n & 1)) {
      cnt[j]++;
      n /= 2;
    }
    j++;
  }
  for (i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      while (n % i == 0) {
        cnt[j]++;
        n /= i;
      }
      j++;
    }
  }
  if (n > 1)
    cnt[j]++, j++;
  ans = 0;
  for (i = 1; i < j; i++) {
    sum = cnt[i] * 2;
    nth = (-1 + sqrt(1 + 4 * sum)) / 2;
    ans += nth;
  }
  printf("%lld\\n", ans);
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int i, j;
  ll n, nth, sum, ans;
  cin >> n;
  j = 1;
  if (!(n & 1)) {
    while (!(n & 1)) {
      cnt[j]++;
      n /= 2;
    }
    j++;
  }
  for (i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      while (n % i == 0) {
        cnt[j]++;
        n /= i;
      }
      j++;
    }
  }
  if (n > 1)
    cnt[j]++, j++;
  ans = 0;
  for (i = 1; i < j; i++) {
    sum = cnt[i] * 2;
    nth = (-1 + sqrt(1 + 4 * sum)) / 2;
    ans += nth;
  }
  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;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll N;
  cin >> N;
  int ans = 0;
  FOR(i, 2, 100000000) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    FOR(j, 1, 10000) {
      if (cur < j)
        break;
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll N;
  cin >> N;
  int ans = 0;
  FOR(i, 2, 1000000000) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    FOR(j, 1, 10000) {
      if (cur < j)
        break;
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << "\\n";
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

long long freq[1000005];
vector<long long> sums;

int main() {
  long long N;
  scanf("%lld", &N);

  if (N == 1) {
    printf("0");
    return 0;
  }

  long long tempN = N, i = 2;
  while (i * i <= tempN) {
    if (N % i == 0) {
      N /= i;
      freq[i]++;
    }

    else
      i++;
  }

  long long ans = 0;
  if (N == tempN) {
    printf("1");
    return 0;
  }

  else if (N > 1) {
    // freq[N]++;
    ans++;
  }

  i = 0;
  while (true) {
    sums.push_back(i * (i + 1) / 2);
    if (sums.back() >= (long long)(1E6) * (long long)(1E6))
      break;

    i++;
  }

  for (long long int i = 0; i < 1000005; i++) {
    if (freq[i] == 0)
      continue;

    long long pos =
        upper_bound(sums.begin(), sums.end(), freq[i]) - sums.begin();
    ans += pos - 1;
  }

  printf("%lld", ans);
}


Error: WA

Fixed submission:

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

long long freq[1000005];
vector<long long> sums;

int main() {
  long long N;
  scanf("%lld", &N);

  if (N == 1) {
    printf("0");
    return 0;
  }

  long long tempN = N, i = 2;
  while (i * i <= tempN) {
    if (N % i == 0) {
      N /= i;
      freq[i]++;
    }

    else
      i++;
  }

  long long ans = 0;
  if (N == tempN) {
    printf("1");
    return 0;
  }

  else if (N > 1) {
    freq[N]++;
    ans++;
  }

  i = 0;
  while (true) {
    sums.push_back(i * (i + 1) / 2);
    if (sums.back() >= (long long)(1E6) * (long long)(1E6))
      break;

    i++;
  }

  for (long long int i = 0; i < 1000005; i++) {
    if (freq[i] == 0)
      continue;

    long long pos =
        upper_bound(sums.begin(), sums.end(), freq[i]) - sums.begin();
    ans += pos - 1;
  }

  printf("%lld", ans);
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

void solve() {
  long long int n, res = 0;
  cin >> n;

  for (int i = 2; i <= 1000010; i++) {
    if (n % i == 0) {
      int pow = 0;
      while (n % i == 0) {
        pow++;
        n /= i;
      }

      for (int j = 1; j < 1000010; j++) {
        if (pow < j)
          break;
        pow -= j;
        res++;
      }
    }
  }

  if (n > 1)
    res++;

  cout << res;
}

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

  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

  long long int n, res = 0;
  cin >> n;

  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int pow = 0;
      while (n % i == 0) {
        pow++;
        n /= i;
      }

      for (int j = 1; j <= 10000; j++) {
        if (pow < j)
          break;
        pow -= j;
        res++;
      }
    }
  }

  if (n > 1)
    res++;

  cout << res;
  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;
using ll = long long;

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

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

  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;
using ll = long long;

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

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

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

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long long n;
  int t = 0;
  cin >> n;
  for (long long i = 1; (i * i) <= n; i += 2) {
    int p = (i == 1) ? 2 : i;
    int c = 0;
    while (n % p == 0) {
      n /= p;
      c++;
    }
    if (c > 0) {
      for (int j = 1; c >= j; j++) {
        c -= j;
        t++;
      }
    }
  }
  if (n > 1) {
    t++;
  }
  cout << t << endl;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long long n;
  int t = 0;
  cin >> n;
  for (int i = 1; (i * i) <= n; i += 2) {
    int p = (i == 1) ? 2 : i;
    int c = 0;
    while (n % p == 0) {
      n /= p;
      c++;
    }
    t += (sqrt(1 + 8 * c) - 1) / 2;
  }
  if (n > 1) {
    t++;
  }
  cout << t << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;

int main() {
  ll N;
  ll ans = 0;
  cin >> N;
  for (ll i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    ll z = i;
    while (N % z == 0) {
      N /= z;
      z *= i;
      ans++;
    }
    while (N % i == 0) {
      N /= i;
    }
  }
  if (N != 1)
    ans++;
  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

typedef long long ll;

int main() {
  ll N;
  ll ans = 0;
  cin >> N;
  for (int i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    ll z = i;
    while (N % z == 0) {
      N /= z;
      z *= i;
      ans++;
    }
    while (N % i == 0) {
      N /= i;
    }
  }
  if (N != 1)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = (ll)(n - 1); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); i++)
#define RFOR(i, a, b) for (ll i = (ll)(a); i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main() {
  map<ll, ll> primes;
  ll D;
  cin >> D;
  ll i = 2;
  double Dsq = sqrt(D);
  while (D > 1) {
    while (D % i == 0) {
      if (primes.count(i) == 0) {
        primes[i] = 1;
      } else {
        primes[i] += 1;
      }
      D /= i;
    }
    i++;
    if (Dsq < i) {
      primes[D] = 1;
      break;
    }
  }
  ll ans = 0;
  ll count;
  for (auto v : primes) {
    count = 1;
    ll tmp = v.S;
    while (tmp - count >= 0) {
      ans++;
      tmp -= count;
      count++;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = (ll)(n - 1); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); i++)
#define RFOR(i, a, b) for (ll i = (ll)(a); i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main() {
  map<ll, ll> primes;
  ll D;
  cin >> D;
  ll i = 2;
  while (D > 1) {
    while (D % i == 0) {
      if (primes.count(i) == 0) {
        primes[i] = 1;
      } else {
        primes[i] += 1;
      }
      D /= i;
    }
    i++;
  }
  ll ans = 0;
  ll count;
  for (auto v : primes) {
    count = 1;
    ll tmp = v.S;
    while (tmp - count >= 0) {
      ans++;
      tmp -= count;
      count++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

bool is_prime(ll x) {
  if (x == 1)
    return false;
  for (int factor = 2; factor <= sqrt(x); factor++) {
    if (x % factor == 0) {
      return false;
    }
  }
  return true;
}

ll next_prime(ll prime) {
  for (ll i = prime + 1; i <= LLONG_MAX; i++) {
    if (is_prime(i)) {
      return i;
    }
  }
}

bool can_divide(ll n, ll z) { return n % z == 0; }

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

  ll counter = 0;
  ll divisor;
  ll last_prime = 2;

  for (ll p = 2; p <= n; p = next_prime(p)) {
    // printf("p: %lld, n: %lld\\n", p, n);

    if (p > sqrt(n)) {
      break;
    }

    for (int e = 1; pow(p, e) <= n; e++) {
      divisor = pow(p, e);
      if (!can_divide(n, divisor)) {
        if (can_divide(n, p)) {
          n /= p;
        }
        break;
      }
      n /= divisor;
      // printf("p: %lld, e: %d, n: %lld\\n", p, e, n);
      counter++;
    }

    last_prime = p;
  }

  if (is_prime(n) && n > last_prime) {
    counter++;
  };

  cout << counter << endl;
}

Error: TLE

Fixed submission:

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

bool is_prime(ll x) {
  if (x == 1)
    return false;
  for (int factor = 2; factor <= sqrt(x); factor++) {
    if (x % factor == 0) {
      return false;
    }
  }
  return true;
}

ll next_prime(ll prime) {
  for (ll i = prime + 1; i <= LLONG_MAX; i++) {
    if (is_prime(i)) {
      return i;
    }
  }
}

bool can_divide(ll n, ll z) { return n % z == 0; }

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

  ll counter = 0;
  ll divisor;
  ll last_prime = 2;

  ll factor = 1;

  for (ll p = 2; p <= n; p = next_prime(p)) {
    // printf("p: %lld, n: %lld\\n", p, n);

    // Do this better
    if (p > n / factor) {
      break;
    }

    if (factor == 1 && p > sqrt(n)) {
      break;
    }

    for (int e = 1; pow(p, e) <= n; e++) {
      divisor = pow(p, e);
      if (!can_divide(n, divisor)) {
        if (can_divide(n, p)) {
          factor = p;
        }
        break;
      }
      n /= divisor;
      // printf("p: %lld, e: %d, n: %lld\\n", p, e, n);
      counter++;
    }

    last_prime = p;
  }

  if (is_prime(n) && n > last_prime) {
    counter++;
  };

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

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

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


Error: TLE

Fixed submission:

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

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


#include <iostream>
#include <numeric>
#include <vector>

int main() {
  int64_t N;
  std::cin >> N;

  size_t i = 2;
  int64_t R = 0;
  while (i <= N) {
    int64_t c = 0;
    while (N % i == 0) {
      N /= i;
      ++c;
    }
    if (c != 0) {
      size_t t = 1;
      size_t j = 1;
      while (t <= c) {
        ++j;
        t += j;
      }
      R += j - 1;
    } else {
      if (i * i > N) {
        ++R;
        break;
      }
    }
    ++i;
  }
  std::cout << R << std::endl;

  return 0;
}

Error: TLE

Fixed submission:


#include <iostream>
#include <numeric>
#include <vector>

int main() {
  int64_t N;
  std::cin >> N;

  size_t i = 2;
  int64_t R = 0;
  while (i <= N) {
    int64_t c = 0;
    while (N % i == 0) {
      N /= i;
      ++c;
    }
    if (c != 0) {
      size_t t = 1;
      size_t j = 1;
      while (t <= c) {
        ++j;
        t += j;
      }
      R += j - 1;
    }
    ++i;
  }
  std::cout << R << std::endl;

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

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

int main() {
  long long n;
  cin >> n;
  int ans = 0;
  for (long long i = 2; i * i <= n; i++) {
    int cnt = 0;
    if (n % i != 0)
      continue;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    ans += (-1 + (sqrt(1 + 8 * cnt))) / 2;
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    if (n % i != 0)
      continue;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    ans += (-1 + (sqrt(1 + 8 * cnt))) / 2;
  }
  if (n != 1)
    ans++;
  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++)

int main() {
  long long n;
  map<long long, int> mp;
  bool flag = true;

  cin >> n;
  long long tmp = n;
  if (n == 1) {
    cout << 0;
    return 0;
  }
  for (long long i = 2; i * i <= n; i++) {
    while (tmp % i == 0) {
      tmp /= i;
      mp[i]++;
      flag = false;
    }
  }
  if (tmp != 1)
    mp[tmp]++;

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

  int ans = 0;
  for (auto a : mp) {
    int num = a.second;
    // cout << "[" << a.first << " " << a.second << "]";

    int tmp = 1;
    while (num >= tmp) {
      num -= tmp;
      tmp++;
      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++)

int main() {
  long long n;
  map<long long, int> mp;
  bool flag = true;

  cin >> n;
  if (n == 1) {
    cout << 0;
    return 0;
  }
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      mp[i]++;
      flag = false;
    }
  }
  if (n != 1)
    mp[n]++;

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

  int ans = 0;
  for (auto a : mp) {
    int num = a.second;
    // cout << "[" << a.first << " " << a.second << "]";

    int tmp = 1;
    while (num >= tmp) {
      num -= tmp;
      tmp++;
      ans++;
    }
  }

  cout << ans;
  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++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using PP = pair<int, pair<int, int>>;
using T = tuple<string, int, int>;
const ll INF = 1LL << 60;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      for (int j = 1; j <= cnt; j++) {
        ans++;
        cnt -= j;
      }
    }
  }
  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++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using PP = pair<int, pair<int, int>>;
using T = tuple<string, int, int>;
const ll INF = 1LL << 60;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      for (int j = 1; j <= cnt; j++) {
        ans++;
        cnt -= j;
      }
    }
  }
  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 vi vector<int>
#define all(v) v.begin(), v.end()
#define ll long long int
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
const ll MOD = 1e9 + 7;

void solve() {
  ll n;
  cin >> n;
  ll cnt = 0;
  ll ans = 0;
  vector<int> v(10);
  for (int i = 0; i < 10; i++) {
    if (i)
      v[i] = i + 1 + v[i - 1];
  }
  for (ll i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    if (cnt) {
      int j = 1;
      while (cnt > 0) {
        cnt -= (j);
        if (cnt >= 0)
          ans++;
        j++;
      }
    }
  }
  if (n > 1) {
    ans++;
  }
  cout << ans;
}

int main() { IOS solve(); }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


Error: TLE

Fixed submission:

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

#define vi vector<int>
#define all(v) v.begin(), v.end()
#define ll long long int
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
const ll MOD = 1e9 + 7;

ll cal(ll a) {
  ll cnt = 0;
  int i = 1;
  while (a) {
    a -= i;
    if (a >= 0)
      cnt++;
    else
      break;
    i++;
  }
  return cnt;
}

void solve() {
  ll n;
  cin >> n;
  ll cnt = 0;
  ll ans = 0;
  while (n % 2 == 0) {
    cnt++;
    n /= 2;
  }
  ans += cal(cnt);
  for (int i = 3; i * i <= n; i += 2) {
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    if (cnt)
      ans += cal(cnt);
  }
  if (n > 1) {
    ans++;
  }
  cout << ans;
}

int main() { IOS solve(); }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main() {
  ll n;
  ll result = 0;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<pair<ll, int>> p;
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    p.emplace_back(i, cnt);
  }
  if (n != 1) {
    p.emplace_back(n, 1);
  }

  for (auto x : p) {
    int num = x.second;
    int count = 1;
    while (count <= num) {
      num -= count;
      result++;
      count++;
    }
  }
  cout << result << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main() {
  ll n;
  ll result = 0;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<pair<ll, int>> p;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    p.emplace_back(i, cnt);
  }
  if (n != 1) {
    p.emplace_back(n, 1);
  }

  for (auto x : p) {
    int num = x.second;
    int count = 1;
    while (count <= num) {
      num -= count;
      result++;
      count++;
    }
  }
  cout << result << endl;
}