alexjercan/bugnet huggingface dataset:
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#pragma region 宣言部分
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define rep(i, m, n) for (int i = (m); i < (n); i++)
#define P pair<int, int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector<int> a
const int INF = 1 << 20;
const int MOD = 1e9 + 7;

#pragma endregion

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll m = n;
  vector<ll> sosuu;
  // cout << "!" << endl;
  for (ll i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (m % i == 0) {
      m /= i;
      cnt++;
    }
    if (cnt != 0)
      sosuu.pb(cnt);
  }
  ll res = 0;
  if (m > 1)
    res++;

  for (int i = 0; i < sosuu.size(); i++) {

    // cout << i << " " << num[i] << endl;
    int r = 1;
    while (sosuu[i] >= 0) {
      sosuu[i] -= r;
      r++;
    }
    // cout << r-2 << endl;
    res += (r - 2);
  }
  cout << res << endl;
  return 0;
}

Error: 0

Fixed submission:

#pragma region 宣言部分
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define rep(i, m, n) for (int i = (m); i < (n); i++)
#define P pair<int, int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector<int> a
const int INF = 1 << 20;
const int MOD = 1e9 + 7;

#pragma endregion

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll m = n;

  int num[1000010] = {0};
  // cout << "!" << endl;
  bool flag = false;
  for (ll i = 2; i * i <= n; i++) {
    while (m % i == 0) {
      flag = true;
      m /= i;
      num[i]++;
    }
  }

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

  if (m > 1)
    num[m]++;

  ll res = 0;
  for (ll i = 2; i * i <= n; i++) {
    // cout << num[i] << endl;

    if (num[i] != 0) {
      // cout << i << " " << num[i] << endl;
      int r = 1;
      while (num[i] >= 0) {
        num[i] -= r;
        r++;
      }
      // cout << r-2 << endl;
      res += (r - 2);
    }
  }
  cout << res << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

int fun(int n) {
  int res = 0;
  for (int i = 1; i < 45; i++) {
    if (i * (i + 1) / 2 <= n)
      res = i;
  }
  return res;
}

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

  int t = 1;
  // cin >> t;
  while (t--) {
    int n;
    cin >> n;

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

    int ans = 0;
    for (auto p : mp) {
      ans += fun(p.second);
    }

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

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \\n";
  return 0;
}


Error: TLE

Fixed submission:

// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

int fun(int n) {
  int res = 0;
  for (int i = 1; i <= 30; i++) {
    if (i * (i + 1) / 2 <= n)
      res = i;
  }
  return res;
}

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

  int t = 1;
  // cin >> t;
  while (t--) {
    int n;
    cin >> n;

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

    int ans = 0;
    for (auto p : mp) {
      ans += fun(p.second);
    }

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

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \\n";
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll, ll>
#define mii map<pii, ll>
#define all(a) (a).begin(), (a).end()
#define fi first
#define si second
#define sz(x) (ll) x.size()
#define endl '\\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod 1000000007
#define inf 1000000000000000000
#define puts(n) cout << n;
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m, v) memset(m, v, sizeof(m))
using namespace std;
const ll M = 1000000 + 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<bool> isp(M, true);
  for (ll i = 2; i * i < M; i++) {
    if (isp[i]) {
      for (ll j = i * i; j < M; j += i)
        isp[j] = false;
    }
  }
  vi primes;
  for (ll i = 2; i < M; i++) {
    if (isp[i])
      primes.pb(i);
  }
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i < primes.size() && primes[i] * primes[i] <= n; i++) {
    ll cnt = 0;
    while (n % primes[i] == 0) {
      cnt++;
      n /= primes[i];
    }
    ll sum = 0, val = 0;
    while (sum + val <= cnt) {
      sum += val;
      val++;
    }
    ans += (val - 1);
  }
  if (n != 1)
    ans++;
  cout << ans;

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll, ll>
#define mii map<pii, ll>
#define all(a) (a).begin(), (a).end()
#define fi first
#define si second
#define sz(x) (ll) x.size()
#define endl '\\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod 1000000007
#define inf 1000000000000000000
#define puts(n) cout << n;
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m, v) memset(m, v, sizeof(m))
using namespace std;
const ll M = 1000000 + 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<bool> isp(M, true);
  for (ll i = 2; i * i < M; i++) {
    if (isp[i]) {
      for (ll j = i * i; j < M; j += i)
        isp[j] = false;
    }
  }
  vi primes;
  for (ll i = 2; i < M; i++) {
    if (isp[i])
      primes.pb(i);
  }
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; primes[i] * primes[i] <= n; i++) {
    ll cnt = 0;
    while (n % primes[i] == 0) {
      cnt++;
      n /= primes[i];
    }
    ll sum = 0, val = 0;
    while (sum + val <= cnt) {
      sum += val;
      val++;
    }
    ans += (val - 1);
  }
  if (n != 1)
    ans++;
  cout << ans;

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

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

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

  int a[] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120};

  long long ans = 0;
  map<long long, int> mp;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    n /= i;

    long long ex = 1;
    while (n % i == 0) {
      n /= i;
      ex++;
    }
    mp[i] += ex;

    long long l = 1;
    while (mp[i] >= l) {
      mp[i] -= l;
      l++;
    }
    ans += l - 1;
  }
  if (n > 1) {
    mp[n]++;
    for (int j = 0; j < 15; j++) {
      if (a[j] <= mp[n] && mp[n] < a[j + 1]) {
        ans += j;
        mp[n] -= a[j];
        break;
      }
    }
  }

  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

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

  int a[] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120};

  long long ans = 0;
  map<long long, int> mp;
  for (int i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    n /= i;

    int ex = 1;
    while (n % i == 0) {
      n /= i;
      ex++;
    }
    mp[i] += ex;

    int l = 1;
    while (mp[i] >= l) {
      mp[i] -= l;
      l++;
    }
    ans += l - 1;
  }
  if (n > 1) {
    mp[n]++;
    for (int j = 0; j < 15; j++) {
      if (a[j] <= mp[n] && mp[n] < a[j + 1]) {
        ans += j;
        mp[n] -= a[j];
        break;
      }
    }
  }

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

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  ll c = 0, x;
  ll ans = 0;
  vector<ll> v;
  for (ll i = 1; i * (i + 1) <= n * 2; i++) {
    v.push_back((i * (i + 1)) / 2);
  }
  while (n % 2 == 0) {
    c++;
    n /= 2;
  }
  if (c > 0) {
    x = upper_bound(v.begin(), v.end(), c) - v.begin();
    ans += x;
  }
  for (ll i = 3; i * i <= n; i += 2) {
    c = 0;
    while (n % i == 0) {
      c++;
      n /= i;
    }
    if (c > 0) {
      x = upper_bound(v.begin(), v.end(), c) - v.begin();
      ans += x;
    }
  }
  if (n > 2) {
    ans++;
  }
  cout << ans;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  ll c = 0, x;
  ll ans = 0;
  vector<ll> v;
  for (ll i = 1; i * (i + 1) <= n * 2; i++) {
    v.push_back((i * (i + 1)) / 2);
  }
  while (n % 2 == 0) {
    c++;
    n /= 2;
  }
  if (c > 0) {
    x = upper_bound(v.begin(), v.end(), c) - v.begin();
    ans += x;
  }
  for (int i = 3; i * i <= n; i += 2) {
    c = 0;
    while (n % i == 0) {
      c++;
      n /= i;
    }
    if (c > 0) {
      x = upper_bound(v.begin(), v.end(), c) - v.begin();
      ans += x;
    }
  }
  if (n > 2) {
    ans++;
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

vector<ll> factors(ll N) {
  vector<ll> ret;

  if (N % 2 == 0) {
    ret.push_back(2);
    while (N % 2 == 0)
      N /= 2;
  }

  ll root = sqrt(N);
  for (ll p = 3; p <= root; p += 2) {
    if (N % p)
      continue;
    ret.push_back(p);
    while (N % p == 0)
      N /= p;
  }

  if (N > 1)
    ret.push_back(N);
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  ll N;
  cin >> N;

  ll score = 0;
  for (ll p : factors(N)) {
    // divide out increasing powers of p
    for (ll q = p; N % q == 0; q *= p) {
      N /= q;
      score++;
    }
    // leftover powers of p
    while (N % p == 0)
      N /= p;
  }

  assert(N == 1);
  cout << score << endl;
}


Error: 0

Fixed submission:

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

vector<ll> factors(ll N) {
  vector<ll> ret;

  if (N % 2 == 0) {
    ret.push_back(2);
    while (N % 2 == 0)
      N /= 2;
  }

  ll root = sqrt(N);
  for (ll p = 3; p <= root; p += 2) {
    if (N % p)
      continue;
    ret.push_back(p);
    while (N % p == 0)
      N /= p;
  }

  if (N > 1)
    ret.push_back(N);
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  ll N;
  cin >> N;

  ll score = 0;
  for (ll p : factors(N)) {
    // divide out increasing powers of p
    for (ll q = p; N % q == 0; q *= p) {
      N /= q;
      score++;
    }
    // leftover power of p
    if (N % p == 0)
      N /= p;
  }

  assert(N == 1);
  cout << score << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread() {}
template <class T1, class... T2> inline void qread(T1 &IEE, T2 &...ls) {
  register T1 __ = 0, ___ = 1;
  register char ch;
  while (!isdigit(ch = getchar()))
    ___ = (ch == '-') ? -___ : ___;
  do {
    __ = (__ << 1) + (__ << 3) + (ch ^ 48);
  } while (isdigit(ch = getchar()));
  __ *= ___;
  IEE = __;
  qread(ls...);
  return;
}
ll n, ans;
ll f[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= 10; i++) {
    f[i] = i * (i + 1) / 2;
  }
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    int id = lower_bound(f + 1, f + 11, cnt) - f;
    if (f[id] > cnt)
      id--;
    ans += id;
  }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread() {}
template <class T1, class... T2> inline void qread(T1 &IEE, T2 &...ls) {
  register T1 __ = 0, ___ = 1;
  register char ch;
  while (!isdigit(ch = getchar()))
    ___ = (ch == '-') ? -___ : ___;
  do {
    __ = (__ << 1) + (__ << 3) + (ch ^ 48);
  } while (isdigit(ch = getchar()));
  __ *= ___;
  IEE = __;
  qread(ls...);
  return;
}
ll n, ans;
ll f[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= 10; i++) {
    f[i] = i * (i + 1) / 2;
  }
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    int id = lower_bound(f + 1, f + 11, cnt) - f;
    if (f[id] > cnt)
      id--;
    ans += id;
  }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

int f[50];
long long n;
int res = 0;

int main() {
  for (int i = 1; i < 10; i++) {
    f[i * (i + 1) / 2] = i;
  }
  for (int i = 1; i < 50; i++) {
    if (f[i] < f[i - 1]) {
      f[i] = f[i - 1];
    }
  }
  scanf("%lld", &n);
  for (int i = 2; 1ll * i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      res += f[cnt];
    }
  }
  if (n != 1) {
    res += f[1];
  }
  printf("%d\\n", res);
}


Error: TLE

Fixed submission:

#include <cstdio>

int f[50];
long long n;
int res = 0;

int main() {
  for (int i = 1; i < 10; i++) {
    f[i * (i + 1) / 2] = i;
  }
  for (int i = 1; i < 50; i++) {
    if (f[i] < f[i - 1]) {
      f[i] = f[i - 1];
    }
  }
  scanf("%lld", &n);
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      res += f[cnt];
    }
  }
  if (n != 1) {
    res += f[1];
  }
  printf("%d\\n", res);
}
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 ans = 0;
  for (long long ii = 2; ii * ii <= N; ii++) {
    if (N % ii == 0) {
      long long num = 0;
      while (N % ii == 0) {
        num++;
        N /= ii;
      }
      ans += (long long)((sqrt(1 + 8 * num) - 1) / 2);
    }
  }
  if (N > 1)
    ans++;

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


Error: TLE

Fixed submission:

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

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

  int ans = 0;
  for (int ii = 2; ii * ii <= N; ii++) {
    if (N % ii == 0) {
      int num = 0;
      while (N % ii == 0) {
        num++;
        N /= ii;
      }
      ans += (int)((sqrt(1 + 8 * num) - 1) / 2);
    }
  }
  if (N > 1)
    ans++;

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

#include <bits/stdc++.h>

const int N = 1e7 + 5;

bool vis[N];

int main() {
  long long n, siz, ans = 0;
  std::cin >> n;
  siz = std::sqrt(n);
  for (long long i = 2; i <= n / i; ++i) {
    if (!vis[i]) {
      for (long long j = (long long)i * i; j <= siz; j += i)
        vis[j] = 1;
      long long cnt = 0;
      while (n % i == 0)
        n /= i, ++cnt;
      long long add, sum;
      for (add = sum = 0; sum <= cnt;)
        sum += ++add;
      ans += add - 1;
    }
  }
  if (n > 1)
    ++ans;
  std::cout << ans;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

const int N = 1e7 + 5;

bool vis[N];

int main() {
  long long n, siz, ans = 0;
  std::cin >> n;
  siz = std::sqrt(n);
  for (int i = 2; i <= n / i; ++i) {
    if (!vis[i]) {
      for (long long j = i * i; j <= siz; j += i)
        vis[j] = 1;
      long long cnt = 0;
      while (n % i == 0)
        n /= i, ++cnt;
      long long add, sum;
      for (add = sum = 0; sum <= cnt;)
        sum += ++add;
      ans += add - 1;
    }
  }
  if (n > 1)
    ++ans;
  std::cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <ctime>
#include <map>
#include <math.h>
#include <typeinfo>
#define R(i, n) for (int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

map<ll, int> primeFactor(ll n) {
  map<ll, int> 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;
  SL(N);
  map<ll, int> m = primeFactor(N);
  int ans = 0;
  for (auto x : m) {
    int e = 1;
    while (x.second - e >= 0) {
      ans++;
      x.second -= e;
      e++;
    }
  }
  P(ans);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <ctime>
#include <map>
#include <math.h>
#include <typeinfo>
#define R(i, n) for (int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

map<ll, int> primeFactor(ll n) {
  map<ll, int> ret;
  for (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() {
  ll N;
  SL(N);
  map<ll, int> m = primeFactor(N);
  int ans = 0;
  for (auto x : m) {
    int e = 1;
    while (x.second - e >= 0) {
      ans++;
      x.second -= e;
      e++;
    }
  }
  P(ans);
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
using namespace std;

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

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  map<int, int> mp;
  long long i = 2;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  while (N != 1) {
    if (N % i == 0) {
      N = N / i;
      mp[i]++;
      continue;
    }
    i++;
    if (i > 1000000) {
      ans++;
      break;
    }
  }

  for (auto e : mp) {
    if (e.second < 3) {
      ans++;
    } else if (e.second < 6) {
      ans = ans + 2;
    } else if (e.second < 10) {
      ans = ans + 3;
    } else if (e.second < 15) {
      ans = ans + 4;
    } else if (e.second < 21) {
      ans = ans + 5;
    } else if (e.second < 28) {
      ans = ans + 6;
    } else if (e.second < 36) {
      ans = ans + 7;
    } else if (e.second < 45) {
      ans = ans + 8;
    }
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;

  map<int, int> mp;
  long long i = 2;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  while (N != 1) {
    if (N % i == 0) {
      N = N / i;
      mp[i]++;
      continue;
    }
    i++;
  }
  int ans = 0;
  for (auto e : mp) {
    if (e.second < 3) {
      ans++;
    } else if (e.second < 6) {
      ans = ans + 2;
    } else if (e.second < 10) {
      ans = ans + 3;
    } else if (e.second < 15) {
      ans = ans + 4;
    } else if (e.second < 21) {
      ans = ans + 5;
    } else if (e.second < 28) {
      ans = ans + 6;
    } else if (e.second < 36) {
      ans = ans + 7;
    } else if (e.second < 45) {
      ans = ans + 8;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  // freopen("in.txt","r",stdin);
  long long n;
  cin >> n;

  if (n == 1)
    cout << 0;
  else {

    long long lim = n;

    int ans = 0;
    bool chk = false;
    for (long long i = 2; i * i <= lim; i += 2) {
      // cout<<i<<" ";
      int div = i;
      while (n % div == 0) {
        // cout<<i<<" ";
        chk = true;
        ans++;
        n /= div;

        div *= i;
        if (n % div != 0) {
          while (n % i == 0)
            n /= i;
        }
      }
      if (i == 2)
        i -= 1;
    }
    if (n != 1)
      ans++;

    if (chk == false)
      ans = 1;

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

Error: TLE

Fixed submission:

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

int main() {
  // freopen("in.txt","r",stdin);
  long long n;
  cin >> n;

  if (n == 1)
    cout << 0;
  else {

    long long lim = n;

    int ans = 0;
    bool chk = false;
    for (int i = 2; i * i <= lim; i += 2) {
      // cout<<i<<" ";
      int div = i;
      while (n % div == 0) {
        // cout<<i<<" ";
        chk = true;
        ans++;
        n /= div;

        div *= i;
        if (n % div != 0) {
          while (n % i == 0)
            n /= i;
        }
      }
      if (i == 2)
        i -= 1;
    }
    if (chk == false)
      ans = 1;

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