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

#include <bitset>
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
  int64_t N;
  cin >> N;
  bitset<1000001> b;

  int64_t d = 1;
  for (int64_t i = 2; i * i <= N; i += d) {
    for (int64_t j = i + i; j * j <= N; j += i) {
      b.set(j);
    }
    d = 2;
  }

  unordered_map<int64_t, int64_t> p;
  int64_t tmp = N;
  int64_t i = 2;
  d = 1;
  while (i * i <= tmp) {
    if (b[i] == 1) {
      i += d;
      d = 2;
      continue;
    }
    if (tmp % i == 0) {
      p.insert(make_pair(i, 1LL));
      tmp /= i;
      while (tmp % i == 0) {
        ++(p[i]);
        tmp /= i;
      }
    }
    i += d;
    d = 2;
  }
  if (1 < tmp) {
    p.insert(make_pair(tmp, 1LL));
  }

  int64_t result = 0;
  for (auto &q : p) {
    i = 1;
    d = 1;
    while (i <= q.second) {
      ++result;
      ++d;
      i += d;
    }
  }
  cout << result << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bitset>
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
  int64_t N;
  cin >> N;
  bitset<1000001> b;

  unordered_map<int64_t, int64_t> p;
  int64_t i = 2;
  while (i * i <= N) {
    if (b[i] == 1) {
      ++i;
      continue;
    }
    if (N % i == 0) {
      p[i] = 1;
      int64_t tmp = N / i;
      while (tmp % i == 0) {
        ++(p[i]);
        tmp /= i;
      }
    }
    for (int64_t j = i + i; j * j <= N; j += i) {
      b.set(j);
    }
    ++i;
  }
  if (p.empty() && (1 < N) && (b[N] == 0)) {
    p[N] = 1;
  }

  int64_t result = 0;
  for (auto &q : p) {
    int64_t i = 1;
    while (i <= q.second) {
      ++result;
      q.second -= i;
      ++i;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
#define endl '\\n'
#define pi pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#ifdef LOCAL
template <class T> ostream &operator<<(ostream &str, const vector<T> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
#define dbg cerr << "  line " << __LINE__ << ": "
#else
#define var(x) 0
struct dbg_cls {
  template <class T> dbg_cls &operator<<(const T &oth) { return *this; }
} dbg;
#endif
using ll = long long;
using ld = long double;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    vector<ll> table(100);
    int prev = 0;
    for (ll i = 1; i <= 12; i++) {
      for (ll j = prev; j <= prev + i; j++)
        table[j] = i - 1;
      prev += i;
    }

    ll x;
    cin >> x;
    map<ll, ll> factor;
    for (ll j = 2; j * j <= x; j++) {
      while (x % j == 0) {
        ++factor[j];
        x /= j;
      }
    }
    if (x != 1)
      ++factor[x];
    ll ans = 0;
    for (auto p : factor)
      ans += table[p.second];
    cout << ans << '\\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define endl '\\n'
#define pi pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#ifdef LOCAL
template <class T> ostream &operator<<(ostream &str, const vector<T> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
#define dbg cerr << "  line " << __LINE__ << ": "
#else
#define var(x) 0
struct dbg_cls {
  template <class T> dbg_cls &operator<<(const T &oth) { return *this; }
} dbg;
#endif
using ll = long long;
using ld = long double;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    vector<ll> table(100);
    int prev = 0;
    for (int i = 1; i <= 12; i++) {
      for (int j = prev; j <= prev + i; j++)
        table[j] = i - 1;
      prev += i;
    }

    ll x;
    cin >> x;
    map<int, int> factor;
    for (int j = 2; j * j <= x; j++) {
      while (x % j == 0) {
        ++factor[j];
        x /= j;
      }
    }
    if (x != 1)
      ++factor[x];
    int ans = 0;
    for (auto p : factor)
      ans += table[p.second];
    cout << ans << '\\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <map>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define inf 1e9 + 7
using namespace std;
typedef long long ll;
const double pi = acos(-1);

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <map>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define inf 1e9 + 7
using namespace std;
typedef long long ll;
const double pi = acos(-1);

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < n; i++)
#define REPR(i, n) for (long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (long long i = m; i <= n; i++)
#define FORR(i, m, n) for (long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(), (v).end()
#define FIN                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll inf = 1e15;

map<ll, ll> primes(ll n) {
  map<ll, ll> r;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      r[i]++;
      n /= i;
    }
  }

  if (n != 1)
    r[n] = 1;
  r[1] = 0;
  return r;
}

int main() {
  FIN

      ll n,
      k = 0;
  ;
  cin >> n;
  ll i;
  map<ll, ll> v;
  v = primes(n);
  for (i = 2; i * i <= n; i++) {
    // cout<<i<<" ";
    if (n % i == 0) {
      k = 0;
      while (n % i == 0) {
        n /= i;
        k++;
        // cout<<i<<" "<<n<<"\\n";
      }
      v[i] = k;
    }
  }
  // cout<<endl<<i<<endl;
  ll ans = 0;
  for (auto i : v) {
    ll p = sqrt(1 + 8 * i.second) - 1;
    p /= 2;
    ans += p;
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < n; i++)
#define REPR(i, n) for (long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (long long i = m; i <= n; i++)
#define FORR(i, m, n) for (long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(), (v).end()
#define FIN                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll inf = 1e15;

map<ll, ll> primes(ll n) {
  map<ll, ll> r;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      r[i]++;
      n /= i;
    }
  }

  if (n != 1)
    r[n] = 1;
  r[1] = 0;
  return r;
}

int main() {
  FIN

      ll n,
      k = 0;
  ;
  cin >> n;
  ll i;
  map<ll, ll> v;
  v = primes(n);
  for (i = 2; i * i <= n; i++) {
    // cout<<i<<" ";
    if (n % i == 0) {
      k = 0;
      while (n % i == 0) {
        n /= i;
        k++;
        // cout<<i<<" "<<n<<"\\n";
      }
      v[i] = k;
    }
  }
  // cout<<endl<<i<<endl;
  ll ans = 0;
  for (auto i : v) {
    ll p = sqrt(1 + 8 * i.second) - 1;
    p /= 2;
    ans += p;
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < n; i++)
#define REPR(i, n) for (long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (long long i = m; i <= n; i++)
#define FORR(i, m, n) for (long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(), (v).end()
#define FIN                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll inf = 1e15;

map<ll, ll> primes(ll n) {
  map<ll, ll> r;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      r[i]++;
      n /= i;
    }
  }

  if (n != 1)
    r[n] = 1;
  r[1] = 0;
  return r;
}

int main() {
  FIN

      ll n,
      k = 0;
  ;
  cin >> n;
  ll i;
  vector<ll> v;
  for (i = 2; i * i <= n; i++) {
    // cout<<i<<" ";
    if (n % i == 0) {
      k = 0;
      while (n % i == 0) {
        n /= i;
        k++;
        // cout<<i<<" "<<n<<"\\n";
      }
      v.push_back(k);
    }
  }
  if (n != 1)
    v.push_back(1);
  // cout<<endl<<i<<endl;
  ll ans = 0;
  for (auto i : v) {
    ll p = sqrt(1 + 8 * i) - 1;
    p /= 2;
    ans += p;
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < n; i++)
#define REPR(i, n) for (long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (long long i = m; i <= n; i++)
#define FORR(i, m, n) for (long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(), (v).end()
#define FIN                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll inf = 1e15;

map<ll, ll> primes(ll n) {
  map<ll, ll> r;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      r[i]++;
      n /= i;
    }
  }

  if (n != 1)
    r[n] = 1;
  r[1] = 0;
  return r;
}

int main() {
  FIN

      ll n;
  cin >> n;
  ll ans = 0;
  map<ll, ll> r = primes(n);
  // primes(n);
  vll a(45, 0);
  FOR(i, 1, 100) a[i] = i + a[i - 1];
  for (auto p : r) {

    ll q = p.second;
    q = sqrt(1 + 8 * q) - 1;
    q /= 2;
    ans += q;
  }
  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, ans = 0;
  cin >> n;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      long long div = i;
      while (n % div == 0) {
        ++ans;
        n /= div;
        div *= i;
      }
    }
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n > 1) {
    ++ans;
  }
  cout << ans;
  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 i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      int div = i;
      while (n % div == 0) {
        ++ans;
        n /= div;
        div *= i;
      }
    }
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n > 1) {
    ++ans;
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<bool> prime(1000001, true);
  prime[0] = false;
  prime[1] = false;
  for (ll i = 2; i * i < 1000001; i++) {
    if (!prime[i])
      continue;
    for (ll j = 2 * i; j < 1000001; j += i) {
      prime[j] = false;
    }
  }
  vector<ll> primes;
  rep(i, 1000001) {
    if (prime[i])
      primes.push_back(i);
  }
  // rep(i, 100) cout << primes[i] << " ";
  // cout << "\\n" << primes.back() << "\\n";
  ll ans = 0;
  rep(i, primes.size()) {
    ll p = primes[i];
    if (p * p > N)
      break;
    if (N % p != 0)
      continue;
    int c = 0;
    while (N % p == 0) {
      N /= p;
      c++;
    }
    rep(j, 1000001) {
      if (c > j) {
        ans++;
        c -= j + 1;
      } else {
        break;
      }
    }
  }
  if (N > 1)
    ans++;
  cout << ans << "\\n";
}

Error: 0

Fixed submission:

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

typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<bool> prime(1000001, true);
  prime[0] = false;
  prime[1] = false;
  for (ll i = 2; i * i < 1000001; i++) {
    if (!prime[i])
      continue;
    for (ll j = 2 * i; j < 1000001; j += i) {
      prime[j] = false;
    }
  }
  vector<ll> primes;
  rep(i, 1000001) {
    if (prime[i])
      primes.push_back(i);
  }
  // rep(i, 100) cout << primes[i] << " ";
  // cout << "\\n" << primes.back() << "\\n";
  ll ans = 0;
  rep(i, 1000001) {
    ll p = primes[i];
    if (p * p > N)
      break;
    if (N % p != 0)
      continue;
    int c = 0;
    while (N % p == 0) {
      N /= p;
      c++;
    }
    rep(j, 1000001) {
      if (c > j) {
        ans++;
        c -= j + 1;
      } else {
        break;
      }
    }
  }
  if (N > 1)
    ans++;
  cout << ans << "\\n";
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

vector<int64_t> primes = {2, 3, 5, 7};
int primes_extend(int calc_from, int calc_to);
int factoring(int64_t n, map<int64_t, int> &factors);

int main() {

  int64_t n;
  cin >> n;

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

  primes_extend(10, 100);
  primes_extend(100, 10000);
  primes_extend(10000, 1000100);

  map<int64_t, int> factors;
  factoring(n, factors);
  for (pair<int64_t, int> p : factors) {
    // fprintf(stderr,"%ld: %d\\n",p.first,p.second);
  }

  map<int64_t, int> nn;
  for (int64_t i = 1; i <= 100; ++i) {
    nn[i * (i + 1) / 2] = i;
  }

  int count = 0;
  for (pair<int64_t, int> p : factors) {
    auto it = nn.upper_bound(p.second);
    --it;
    count += it->second;
  }
  cout << count << endl;
}

int primes_extend(int calc_from, int calc_to) {

  for (int i = calc_from; i <= calc_to; ++i) {
    int j;
    int loop_max = sqrt(i);
    for (j = 0; (primes[j] <= loop_max) && (j < primes.size()); ++j) {
      if ((i % primes[j]) == 0) {
        // not prime...
        break;
      }
    }
    if ((j >= primes.size()) || (primes[j] > loop_max)) {
      primes.push_back(i);
    }
  }
  // fprintf(stderr,"count: %d\\n",primes.size());
  return 0;
}

int factoring(int64_t n, map<int64_t, int> &factors) {
  int64_t maxfactor = sqrt(n);
  for (int i = 0; (n > 1) && (primes[i] <= maxfactor); ++i) {
    while ((n % primes[i]) == 0) {
      n /= primes[i];
      factors[primes[i]]++;
    }
  }
  if (n != 1) {
    factors[n]++;
  }

  return 0;
}


Error: 0

Fixed submission:

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

vector<int> primes = {2, 3, 5, 7};
int primes_extend(int calc_from, int calc_to);
int factoring(int64_t n, map<int, int> &factors);

int main() {

  int64_t n;
  cin >> n;

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

  primes_extend(10, 100);
  primes_extend(100, 10000);
  primes_extend(10000, 100000);
  primes_extend(100000, 1000001);

  map<int, int> factors;
  factoring(n, factors);
  for (pair<int, int> p : factors) {
    // fprintf(stderr,"%d: %d\\n",p.first,p.second);
  }

  map<int64_t, int> nn;
  for (int64_t i = 1; i <= 100; ++i) {
    nn[i * (i + 1) / 2] = i;
  }

  int count = 0;
  for (pair<int, int> p : factors) {
    auto it = nn.upper_bound(p.second);
    --it;
    count += it->second;
  }
  cout << count << endl;
}

int primes_extend(int calc_from, int calc_to) {

  for (int i = calc_from; i <= calc_to; ++i) {
    int j;
    int loop_max = sqrt(i);
    for (j = 0; (primes[j] <= loop_max) && (j < primes.size()); ++j) {
      if ((i % primes[j]) == 0) {
        // not prime...
        break;
      }
    }
    if ((j >= primes.size()) || (primes[j] > loop_max)) {
      primes.push_back(i);
    }
  }
  // fprintf(stderr,"count: %d\\n",primes.size());
  return 0;
}

int factoring(int64_t n, map<int, int> &factors) {
  int64_t maxfactor = sqrt(n);
  for (int i = 0; (n > 1) && (primes[i] <= maxfactor); ++i) {
    while ((n % primes[i]) == 0) {
      n /= primes[i];
      factors[primes[i]]++;
    }
  }
  if (n != 1) {
    factors[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 < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
  ll N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  map<ll, ll> memo;
  vector<ll> memo2;
  ll tmp = 2;
  while (tmp * tmp <= N) {
    if (N % tmp == 0) {
      ll cnt = 0;
      while (N % tmp == 0) {
        N /= tmp;
        cnt++;
      }
      memo[tmp] = cnt;
      memo2.push_back(tmp);
    } else
      tmp++;
  }
  if (N > 1) {
    memo[tmp]++;
    memo2.push_back(tmp);
  }
  /*for (ll i:memo2){
      cout << i << " " << memo[i] << endl;
  }+*/
  for (ll i = 0; i < memo2.size(); i++) {
    ll j = 1;
    while (memo[memo2[i]] >= j) {
      ans++;
      memo[memo2[i]] -= j;
      j++;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
  ll N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll tmp = N;
  vector<ll> primes;
  ll ans = 0;
  for (ll i = 2; i <= tmp && i * i <= N; i++) {
    bool flag = true;
    for (ll j = 0; j < primes.size(); j++) {
      if (i % primes[j] == 0) {
        flag = false;
        break;
      }
    }
    if (flag) {
      primes.push_back(i);
      ll div = i;
      while (tmp % div == 0) {
        tmp /= div;
        div *= i;
        ans++;
        // cout << tmp << endl;
      }
    }
  }
  if (tmp == N)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

vector<pair<ll, int>> factor(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    int ex = 0;
    while (n % i == 0) {
      ex++;
      n /= i;
    }
    res.push_back({i, ex});
  }
  if (n != 1)
    res.push_back({n, 1});
  return res;
}

int main() {
  ll n;
  cin >> n;
  int ans = 0;
  vector<pair<ll, int>> fs;
  fs = factor(n);
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: WA

Fixed submission:

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

vector<pair<ll, int>> factor(ll n) {
  vector<pair<ll, int>> res;
  for (ll i; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    int ex = 0;
    while (n % i == 0) {
      ex++;
      n /= i;
    }
    res.push_back({i, ex});
  }
  if (n != 1)
    res.push_back({n, 1});
  return res;
}

int main() {
  ll n;
  cin >> n;
  int ans = 0;
  vector<pair<ll, int>> fs;
  fs = factor(n);
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}