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

/*---------------------------------
 *File name: B.cpp
 *Creation date: 2020-05-31 20:52
 *-------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define PII pair<int, int>
#define Pque priority_queue
#define loop(c, a, b) for (int c = a; c <= b; ++c)
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;

int main() {
  LL n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) {
      LL tmp = i;
      while (n % tmp == 0) {
        ans++;
        n /= tmp;
        tmp *= i;
      }
      while (n % i == 0)
        n /= i;
    }
  }
  if (n != 1)
    ans++;
  printf("%d\\n", ans);
  return 0;
}

Error: 0

Fixed submission:

/*---------------------------------
 *File name: B.cpp
 *Creation date: 2020-05-31 20:00
 *-------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;
const LL maxn = 1e6 + 5;

int num;
int prim[maxn];
bool is_prim[maxn];
LL pre[maxn];

inline void init() {
  num = 1;
  memset(is_prim, 1, sizeof is_prim);
  is_prim[1] = is_prim[0] = 0;
  for (int i = 2; i < maxn; i++) {
    if (is_prim[i]) {
      prim[num++] = i;
    }
    for (int j = 1; j < num && i * prim[j] < maxn; j++) {
      is_prim[i * prim[j]] = 0;
    }
  }
}

inline int work(LL x) {
  LL cnt = 0;
  for (int i = 1; i < num; ++i) {
    int tmp = 0;
    while (x % prim[i] == 0) {
      x /= prim[i];
      tmp++;
    }
    if (tmp == 0)
      continue;
    int l, r;
    l = 1, r = 3000;
    while (l <= r) {
      int mid = l + r >> 1;
      if (mid * (mid + 1) / 2 > tmp)
        r = mid - 1;
      else if (mid * (mid + 1) / 2 == tmp) {
        tmp = mid;
        break;
      } else
        l = mid + 1;
      if (l > r)
        tmp = r;
    }
    cnt += tmp;
  }
  if (x > 1)
    cnt++;
  printf("%lld\\n", cnt);
}

int main() {
  LL n;
  scanf("%lld", &n);
  init();
  work(n);
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
long long n, i, j, x;
int ans = 0;

int main(void) {
  scanf("%lld", &n);

  for (i = 2; i * i <= n; i++) {

    // printf("%lld ", i);
    for (x = 0; n % i == 0; x++) { // 素数がいくつあるか確認
      n /= i;
    }
    // printf("%lld ", x);

    for (j = 0; j * (j + 1) / 2 <= x; j++)
      ; // 1,2,3,....の組を見つける

    // printf("%lld\\n", j - 1);
    ans += j - 1;
  }

  if (n - 1)
    ans += 1;

  printf("%d", ans);
}

Error: TLE

Fixed submission:

#include <stdio.h>
long long n, i, j, x;
int ans = 0;

int main(void) {
  scanf("%lld", &n);

  for (i = 2; i <= n; i++) {

    // printf("%lld ", i);
    for (x = 0; n % i == 0; x++) { // 素数がいくつあるか確認
      n /= i;
    }
    // printf("%lld ", x);

    for (j = 0; j * (j + 1) / 2 <= x; j++)
      ; // 1,2,3,....の組を見つける

    // printf("%lld\\n", j - 1);
    ans += j - 1;
  }

  printf("%d", ans);
}
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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<ll, ll>;

vector<P> prime_factor(ll n) {
  vector<P> res;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i != 0)
      continue;
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    res.push_back(P(i, cnt));
  }
  if (n != 1)
    res.push_back(P(n, 1)); // nが素数の時
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<P> vec = prime_factor(n);
  ll ans = 0;
  for (auto p : vec) {
    ll q = p.first;
    ll num = p.second;
    int tmp = 2 * num;
    tmp = sqrt(tmp) - 1;
    // cout << q << " " << num << endl;
    for (ll k = tmp;; k++) {
      if (k * (1 + k) <= 2 * num && 2 * num < (k + 1) * (k + 2)) {
        ans += k;
        // cout << k << endl;
        break;
      }
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<ll, ll>;

vector<P> prime_factor(ll n) {
  vector<P> res;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i != 0)
      continue;
    int cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    res.push_back(P(i, cnt));
  }
  if (n != 1)
    res.push_back(P(n, 1)); // nが素数の時
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<P> vec = prime_factor(n);
  ll ans = 0;
  for (auto p : vec) {
    int q = p.first;
    int num = p.second;
    // cout << q << " " << num << endl;
    for (int k = 1;; k++) {
      if (k * (1 + k) <= 2 * num && 2 * num < (k + 1) * (k + 2)) {
        ans += k;
        // cout << k << endl;
        break;
      }
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll, ll>>
#define vvl vector<vector<ll>> // a(縦行,vector<ll>(横列));
#include <algorithm>           //__gcd(a,b)
#include <cstdlib>
#include <iostream>
#include <vector>
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;
}

const long long INF = 1LL << 60;

vector<pair<long long, long long>> prime_factorize(long long N) {
  vector<pair<long long, long long>> res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0)
      continue;
    long long ex = 0;
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1)
    res.push_back({N, 1});
  return res;
}

int main() {
  long long N;
  cin >> N;
  long long ans = 0;
  const auto &pf = prime_factorize(N);
  long long res = 1;
  for (auto p : pf) {
    for (int i = 0; i <= p.second; i++) {
      if ((i + 1) * (i + 2) / 2 > p.second)
        break;
      ans++;
    }
  }

  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll, ll>>
#define vvl vector<vector<ll>> // a(縦行,vector<ll>(横列));
#include <algorithm>           //__gcd(a,b)
#include <cstdlib>
#include <iostream>
#include <vector>
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;
}

const long long INF = 1LL << 60;

vector<pair<long long, long long>> prime_factorize(long long N) {
  vector<pair<long long, long long>> res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0)
      continue;
    long long ex = 0;
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1)
    res.push_back({N, 1});
  return res;
}

int main() {
  long long N;
  long long e = 0;
  cin >> N;
  vl d(N);
  long long ans = 0;
  const auto &pf = prime_factorize(N);
  long long res = 1;
  for (auto p : pf) {
    for (int i = 1; i <= p.second; i++) {
      if (i * (i + 1) / 2 > p.second)
        break;
      ans++;
    }
  }

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

#include <iostream>

using namespace std;

bool primes[(int)1e6];

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

  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  int max_v;
  for (max_v = 1; (long int)max_v * (long int)max_v <= n; ++max_v)
    ;
  {
    for (int i = 2; i <= max_v; ++i)
      primes[i] = true;
    primes[0] = primes[1] = false;
    for (int i = 2; i <= max_v; ++i) {
      if (primes[i]) {
        for (int j = i + i; j <= max_v; j += i)
          primes[j] = false;
      }
    }
  }

  int ans = 0;
  for (int p = 2; p <= max_v; ++p) {
    if (primes[p] == false)
      continue;
    int div_num = 0;
    while (n % p == 0) {
      n /= p;
      div_num++;
    }
    int p_ans;
    for (p_ans = 1; p_ans * (p_ans + 1) <= div_num * 2; ++p_ans)
      ;
    ans += p_ans - 1;
  }
  if (1 < n)
    ans++;

  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

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

  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }
  if ((n & 1) == 0) {
    int div_num = 0;
    while ((n & 1) == 0) {
      n >>= 1;
      div_num++;
    }
    int p_ans;
    for (p_ans = 1; p_ans * (p_ans + 1) <= div_num * 2; ++p_ans)
      ;
    ans += p_ans - 1;
  }

  for (int p = 3; p <= n; p += 2) {
    int div_num = 0;
    while (n % p == 0) {
      n /= p;
      div_num++;
    }
    int p_ans;
    for (p_ans = 1; p_ans * (p_ans + 1) <= div_num * 2; ++p_ans)
      ;
    ans += p_ans - 1;
  }

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

// 高知能系Vtuberの高井茅乃です。
// Twitter: https://twitter.com/takaichino
// YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i <= n; i++)
#define MODA 1000000007

int main() {
  // エラトステネスの篩でP_max以下の素数vector primeをつくる
  bool *pr;
  ll P_max = 2000000; // 10^6くらいまでが現実的か
  pr = (bool *)malloc(sizeof(bool) * (P_max + 1));
  REP(i, P_max + 1) pr[i] = true;
  pr[0] = false;
  pr[1] = false;
  for (ll i = 2; i * i <= P_max; i++) {
    if (pr[i] == true) {
      for (ll j = 2 * i; j <= P_max; j += i) {
        pr[j] = false;
      }
    }
  }
  vector<ll> prime;
  for (ll i = 2; i <= P_max; i++) {
    if (pr[i])
      prime.push_back(i);
  }
  //
  ll n;
  cin >> n;
  // 整数Xの素因数分解の結果をmapで返す。上のvector primeはもちろんいる
  ll X = n;
  ll diving = X; // これをどんどん割っていく。dividingが正しい
  map<ll, ll> prf;
  for (ll i = 0; diving > 1 && prime[i] * prime[i] <= X; i++) {
    while (diving % prime[i] == 0) {
      diving /= prime[i];
      prf[prime[i]]++;
    }
  }
  if (diving > 1)
    prf[diving]++;
  // これは素因数分解の結果が見たくなったときに使うもの
  // for(auto i = prf.begin(); i!= prf.end(); i++) cout << i->first << "," <<
  // i->second << " "; cout << endl;
  //
  ll re = 0;
  ll ans = 0;
  for (auto i = prf.begin(); i != prf.end(); i++) {
    for (re = 1; re <= i->second; re++) {
      ans++;
      i->second -= re;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

// 高知能系Vtuberの高井茅乃です。
// Twitter: https://twitter.com/takaichino
// YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i <= n; i++)
#define MODA 1000000007

int main() {
  // エラトステネスの篩でP_max以下の素数vector primeをつくる
  bool *pr;
  ll P_max = 1000000; // 10^6くらいまでが現実的か
  pr = (bool *)malloc(sizeof(bool) * (P_max + 1));
  REP(i, P_max + 1) pr[i] = true;
  pr[0] = false;
  pr[1] = false;
  for (ll i = 2; i * i <= P_max; i++) {
    if (pr[i] == true) {
      for (ll j = 2 * i; j <= P_max; j += i) {
        pr[j] = false;
      }
    }
  }
  vector<ll> prime;
  for (ll i = 2; i <= P_max; i++) {
    if (pr[i])
      prime.push_back(i);
  }
  //
  ll n;
  cin >> n;
  // 整数Xの素因数分解の結果をmapで返す。上のvector primeはもちろんいる
  ll X = n;
  ll diving = X; // これをどんどん割っていく。dividingが正しい
  map<ll, ll> prf;
  for (ll i = 0; diving > 1 && prime[i] * prime[i] <= X; i++) {
    while (diving % prime[i] == 0) {
      diving /= prime[i];
      prf[prime[i]]++;
    }
  }
  if (diving > 1)
    prf[diving]++;
  // これは素因数分解の結果が見たくなったときに使うもの
  // for(auto i = prf.begin(); i!= prf.end(); i++) cout << i->first << "," <<
  // i->second << " "; cout << endl;
  //
  ll re = 0;
  ll ans = 0;
  for (auto i = prf.begin(); i != prf.end(); i++) {
    for (re = 1; re <= i->second; re++) {
      ans++;
      i->second -= re;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false),
            cout << fixed << setprecision(9), 0);
// int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv
// ./prog.exe") >> 8), 0);
int main() {
  Int N;
  cin >> N;
  Int ans = 0;
  for (Int p = 2; p * p <= N; p++) {
    int cnt = 0;
    while (N % p == 0)
      cnt++, N /= p;
    for (int i = 1; i <= cnt; i++) {
      ans += 1, cnt -= i;
    }
  }
  if (N != 1)
    ans += 1;
  cout << ans << '\\n';
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false),
            cout << fixed << setprecision(9), 0);
// int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv
// ./prog.exe") >> 8), 0);
int main() {
  Int N;
  cin >> N;
  Int ans = 0;
  for (int p = 2; p * p <= N; p++) {
    int cnt = 0;
    while (N % p == 0)
      cnt++, N /= p;
    for (int i = 1; i <= cnt; i++) {
      ans += 1, cnt -= i;
    }
  }
  if (N != 1)
    ans += 1;
  cout << ans << '\\n';
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

static const auto do_fast_io = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  return nullptr;
}();

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

/**
 * References
 */


Error: TLE

Fixed submission:

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

static const auto do_fast_io = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  return nullptr;
}();

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

/**
 * References
 */
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

vector<pair<long long, long long>> primeFact(long long n) {
  vector<pair<long long, long long>> result;
  long long s = floor(sqrt(n));
  for (long long i = 2; i <= s; i++) {
    if (n == 1)
      break;

    long long r = 0;
    while (n % i == 0) {
      r++;
      n /= i;
    }

    if (r == 0)
      continue;
    result.push_back({i, r});
  }

  if (n > s) {
    result.push_back({n, 1});
  }
  return result;
}

void solver() {
  long long n;
  cin >> n;

  vector<pair<long long, long long>> primes = primeFact(n);
  long long ans = 0;
  for (int i = 0; i < primes.size(); i++) {
    long long r = primes[i].second;
    long long rSum = 0;
    long long j = 1;
    while (rSum <= r) {
      rSum += j;
      j++;
    }
    ans += j - 2;
  }
  cout << ans << "\\n";
}

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


Error: TLE

Fixed submission:

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

vector<pair<long long, long long>> primeFact(long long n) {
  vector<pair<long long, long long>> result;
  long long n_ = n;
  for (long long i = 2; i <= n_; i++) {
    if (n == 1)
      break;

    long long r = 0;
    while (n % i == 0) {
      r++;
      n /= i;
    }

    if (r == 0)
      continue;
    result.push_back({i, r});
  }
  return result;
}

void solver() {
  long long n;
  cin >> n;

  vector<pair<long long, long long>> primes = primeFact(n);
  long long ans = 0;
  for (int i = 0; i < primes.size(); i++) {
    long long r = primes[i].second;
    long long rSum = 0;
    long long j = 1;
    while (rSum <= r) {
      rSum += j;
      j++;
    }
    ans += j - 2;
  }
  cout << ans << "\\n";
}

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

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
using namespace std;
int main() {
  long long int n, k;
  scanf("%lld", &n);
  k = n;
  int cnt = 0;
  long long int j = 1LL, suma = 1LL;
  int ans = 0;
  if (k == 1)
    cout << 0 << "\\n";
  else {
    for (long long int i = 2; i <= k; i++) {
      cnt = 0;
      j = 1LL;
      suma = 1LL;
      while (k % i == 0) {
        cnt++;
        k = 1LL * k / i;
        if (cnt >= suma) {
          ans++;
          j++;
          suma = 1LL * (j) * (j + 1) / 2;
        }
      }
      if (i * i > k && k > 1000) {
        cout << ans + 1 << "\\n";
        return 0;
      }
    }
    cout << ans << "\\n";
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
using namespace std;
int main() {
  long long int n, k;
  scanf("%lld", &n);
  k = n;
  int cnt = 0;
  long long int j = 1LL, suma = 1LL;
  int ans = 0;
  for (long long int i = 2; i <= k; i++) {
    cnt = 0;
    j = 1LL;
    suma = 1LL;
    while (k % i == 0) {
      cnt++;
      k = 1LL * k / i;
      if (cnt >= suma) {
        ans++;
        j++;
        suma = 1LL * (j) * (j + 1) / 2;
      }
    }
    if (ans == 0 && i * i > n) {
      cout << 1 << "\\n";
      return 0;
    }
  }
  cout << ans << "\\n";

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

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long int n;
  long long int n1;
  long long int *nn =
      (long long int *)(malloc(sizeof(long long int) * 1000001));
  long long int q;
  long long int qq;
  long int ans = 0;
  cin >> n;
  n1 = n;

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

  for (int i = 0; (long long int)i * i <= n; i++) {
    nn[i] = i;
  }

  for (int i = 2; (long long int)i * i <= n; i++) {
    for (int j = 2 * i; (long long int)j * j <= n; j += i) {
      nn[j] = -1;
    }
  }

  for (int i = 2; (long long int)i * i <= n1; i++) {
    q = nn[i];
    qq = q;
    // cout << qq << " " << i << endl;
    if (nn[i] == -1)
      continue;

    while (!(n % qq)) {
      n = n / qq;
      qq = qq * q;
      // cout << n  << " " << qq << endl;
      ans++;
    }
  }

  if (n1 / n < n)
    ans++;

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

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main() {
  long int n;
  long int n1;
  vector<int> nn;
  int q;
  int qq;
  int ans = 0;
  cin >> n;
  n1 = n;

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

  for (int i = 0; i <= 1000001; i++) {
    nn.push_back(i);
  }

  for (int i = 2; i * i <= n; i++) {
    for (int j = 2 * i; j * j <= n; j += i) {
      nn[j] = -1;
    }
  }

  for (int i = 2; i * i <= n1; i++) {
    q = nn[i];
    qq = q;
    // cout << qq << " " << i << endl;
    if (nn[i] == -1)
      continue;

    while (!(n % qq)) {
      n = n / qq;
      qq = qq * q;
      // cout << n  << " " << qq << endl;
      ans++;
    }
  }
  if (ans == 0)
    ans++;

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

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

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

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  long long int n;
  cin >> n;
  long long int ans = 0;
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    long long int num = 0;
    while (n % i == 0) {
      n /= i;
      num += 1;
    }
    for (long long int j = 1;; j++) {
      if (num >= j) {
        num -= j;
        ans += 1;
      } else
        break;
    }
  }
  if (n != 1) {
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}

Error: -8

Fixed submission:

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

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

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  long long int n;
  cin >> n;
  long long int ans = 0;
  for (long long int i = 0; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    long long int num = 0;
    while (n % i == 0) {
      n /= i;
      num += 1;
    }
    for (long long int j = 1;; j++) {
      if (num >= j) {
        num -= j;
        ans += 1;
      } else
        break;
    }
  }
  if (n != 1) {
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long n;
  cin >> n;
  int ans = 0;
  vector<long long> c;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int count = 1;
      int cnt = 0;
      c.push_back(i);
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      while (count <= cnt) {
        cnt -= count;
        count++;
        ans++;
      }
    }
  }
  if (!(n == 1))
    ans += 1;

  cout << ans << endl;
  cout << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  long long n;
  cin >> n;
  vector<pair<long long, int>> tan;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int count = 0;
      while (n % i == 0) {
        n /= i;
        count++;
      }
      tan.push_back({i, count});
    }
  }
  if (!(n == 1))
    tan.push_back({n, 1});

  int s = tan.size();
  int ans = 0;

  for (int i = 0; i < s; i++) {
    int count = 1;
    ans += 1;
    while (tan[i].second - count >= count + 1) {
      tan[i].second -= count;
      count++;
      ans += 1;
    }
  }

  cout << ans << endl;
}