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

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update>

#define ll long long
#define int long long
#define Size(v) (int)v.size()

using namespace std;
// using namespace __gnu_pbds;

ll n;

const int nax = 1e6 + 5;
bool prime[nax];
vector<int> primes;

void sieve() {
  prime[1] = true;

  for (int i = 2; i < nax; ++i) {
    if (prime[i] == false) {
      for (int j = i * i; j < nax; j += i)
        prime[j] = true;
    }
  }

  for (int i = 1; i < nax; ++i)
    if (prime[i] == false)
      primes.push_back(i);
}

void solve() {
  cin >> n;
  ll cnt = 0;

  for (int j = 0; j < Size(primes) && primes[j] * primes[j] <= n; ++j) {
    int temp = 0;
    int i = primes[j];
    while (n % i == 0) {
      ++temp;
      n /= i;
    }

    temp *= 2;
    int add = sqrt(temp);

    if (add * (add + 1) > temp)
      --add;
    if ((add + 1) * (add + 2) <= temp)
      ++add;

    // add * (add + 1) <= temp

    cnt += add;
  }

  if (n > 1) {
    ++cnt;
  }

  cout << cnt;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int t = 1;
  sieve();
  while (t--)
    solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update>

#define ll long long
#define Size(v) (int)v.size()

using namespace std;
// using namespace __gnu_pbds;

ll n;

void solve() {
  cin >> n;
  ll cnt = 0;

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

    temp *= 2;
    int add = sqrt(temp);

    if (add * (add + 1) > temp)
      --add;
    if ((add + 1) * (add + 2) <= temp)
      ++add;

    // add * (add + 1) <= temp

    cnt += add;
  }

  if (n > 1) {
    ++cnt;
  }

  cout << cnt;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int t = 1;
  while (t--)
    solve();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

  unordered_map<long long int, int> mp;

  while (n % 2 == 0) {
    mp[2]++;
    n = n / 2;
  }

  for (long long int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      mp[i]++;
      n = n / i;
    }
  }

  if (n > 2) {
    mp[n]++;
  }

  for (auto it = mp.begin(); it != mp.end(); it++) {
    long long int l = 1, r = it->second, temp = it->second;
    while (l <= r) {
      long long int mid = l + (r - l) / 2;
      if ((mid * (mid + 1)) / 2 <= temp &&
          ((mid + 2) * (mid + 1)) / 2 <= temp) {
        l = mid + 1;
      } else if ((mid * (mid + 1)) / 2 <= temp &&
                 ((mid + 2) * (mid + 1)) / 2 > temp) {
        ans = ans + mid;
        break;
      } else if (((mid) * (mid + 1)) / 2 > temp) {
        r = mid - 1;
      }
    }
  }

  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

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

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

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

  unordered_map<long long int, int> mp;

  while (n % 2 == 0) {
    mp[2]++;
    n = n / 2;
  }

  for (long long int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      mp[i]++;
      n = n / i;
    }
  }

  if (n > 2) {
    mp[n]++;
  }

  for (auto it = mp.begin(); it != mp.end(); it++) {
    long long int l = 1, r = it->second, temp = it->second;
    while (l <= r) {
      long long int mid = l + (r - l) / 2;
      if ((mid * (mid + 1)) / 2 <= temp &&
          ((mid + 2) * (mid + 1)) / 2 <= temp) {
        mid = l + 1;
      } else if ((mid * (mid + 1)) / 2 <= temp &&
                 ((mid + 2) * (mid + 1)) / 2 > temp) {
        ans = ans + mid;
        break;
      } else if (((mid) * (mid + 1)) / 2 > temp) {
        r = mid - 1;
      }
    }
  }

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

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

int main() {
  ll sol = 0, cnt;
  ll n;
  cin >> n;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i > 0)
      continue;
    cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    ll j = 1;
    while (cnt >= j) {
      sol++;
      cnt -= j;
      j++;
    }
  }
  if (n > 1)
    sol++;
  cout << sol;
}


Error: TLE

Fixed submission:

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

int main() {
  int sol = 0, cnt;
  ll n;
  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i > 0)
      continue;
    cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    int j = 1;
    while (cnt >= j) {
      sol++;
      cnt -= j;
      j++;
    }
  }
  if (n > 1)
    sol++;
  cout << sol;
}
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;
using ll = long long;
// using P = pair<int, int>;

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

  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0)
      return false;
  }

  return true;
}

double cntdiv(ll n, ll i) {
  double result = 0;
  while (n % i == 0) {
    result += 1;
    n /= i;
  }
  return result;
}
int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  double sqn = sqrt(n);
  for (int i = 1; i <= sqn; ++i) {
    if (n % i == 0) {
      if (IsPrime(i))
        ans += ll(floor((-1.0 + sqrt(1.0 + 8.0 * cntdiv(n, i))) / 2.0));
      ll ni = n / i;
      if (IsPrime(ni) && i != ni)
        ans += ll(floor((-1.0 + sqrt(1.0 + 8.0 * cntdiv(n, ni))) / 2.0));
    }
  }
  if (IsPrime(n))
    ans = 1;
  cout << ans << endl;
  return 0;
}

Error: -8

Fixed submission:

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

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

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

  return true;
}

double cntdiv(ll n, ll i) {
  double result = 0;
  while (n % i == 0) {
    result += 1;
    n /= i;
  }
  return result;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i * i <= n; ++i) {
    if (n % i == 0) {
      if (IsPrime(i))
        ans += ll(floor((-1.0 + sqrt(1.0 + 8.0 * cntdiv(n, i))) / 2.0));
      ll ni = n / i;
      if (IsPrime(ni))
        ans += ll(floor((-1.0 + sqrt(1.0 + 8.0 * cntdiv(n, ni))) / 2.0));
    }

    // if (IsPrime(i) && n%i == 0) {
    //   ans += ll(floor((-1.0+sqrt(1.0+8.0*cntdiv(n,i)))/2.0));
    // }
  }
  if (IsPrime(n))
    ans = 1;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll N;
  cin >> N;
  vector<pair<ll, int>> a;
  for (ll i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      int cnt = 0;
      while (N % i == 0) {
        N = N / i;
        cnt++;
      }
      a.push_back({i, cnt});
    }
  }
  if (N != 1) {
    a.push_back({N, 1});
  }
  int res = 0;
  for (auto &it : a) {
    ll p = it.first;
    int k = it.second;
    int sum = 0;
    for (int i = 1; i + sum <= k; i++) {
      sum += i;
      res++;
    }
  }
  cout << res << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll N;
  cin >> N;
  vector<pair<int, int>> a;
  for (int i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      int cnt = 0;
      while (N % i == 0) {
        N = N / i;
        cnt++;
      }
      a.push_back({i, cnt});
    }
  }
  if (N != 1) {
    a.push_back({N, 1});
  }
  int res = 0;
  for (auto &it : a) {
    int p = it.first;
    int k = it.second;
    int sum = 0;
    for (int i = 1; i + sum <= k; i++) {
      sum += i;
      res++;
    }
  }
  cout << res << endl;

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

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
// sort(V.begin(), V.end(), compare_function);

/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/

/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}

void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll p = 2;
  int ats = 0;
  while (p * p <= n) {
    if (n % p == 0) {
      int laip = 0;
      while (n % p == 0) {
        n = n / p;
        laip++;
      }
      int i = 1;
      while (laip >= i) {
        ats++;
        laip = laip - i;
        i++;
      }
    }
    p++;
  }
  if (n > 1) {
    ats++;
  }
  cout << ats << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
// sort(V.begin(), V.end(), compare_function);

/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/

/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}

void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  int p = 2;
  int ats = 0;
  while (p * p <= n) {
    if (n % p == 0) {
      int laip = 0;
      while (n % p == 0) {
        n = n / p;
        laip++;
      }
      int i = 1;
      while (laip >= i) {
        ats++;
        laip = laip - i;
        i++;
      }
    }
    p++;
  }
  if (n > 1) {
    ats++;
  }
  cout << ats << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\\n';
const int MX = 100001; // check the limits, dummy

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

  ll N;
  cin >> N;
  int ans = 0;
  FOR(i, 2, 1000010) {
    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 << nl;

  return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


Error: TLE

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

long long f(long long k) { return (1 + k) * k / 2; }

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

  long long n;
  cin >> n;
  long long ops = 0;
  unordered_map<long long, long long> d;
  if (n == 1) {
    cout << 0 << "\\n";
    return 0;
  }
  long long i = 2;
  while (i * i <= n) {
    if (n % i == 0) {
      d[i]++;
      n = n / i;
    } else {
      i++;
    }
  }
  if (d.size() == 0) {
    cout << 1 << "\\n";
    return 0;
  }
  i = 2;
  while (i <= n) {
    if (n % i == 0) {
      d[i]++;
      n = n / i;
    } else {
      i++;
    }
  }
  d[n]++;
  for (auto &[k, v] : d) {
    if (k == 1)
      continue;
    long long q = 1;
    while (f(q) <= v)
      q++;
    --q;
    ops += q;
  }
  cout << ops << "\\n";
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
// #include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

bool isZero = true;

// string ans = "Yes";
ll ans = 0;
ll N;
vector<ll> A;

int main() {
  cin >> N;

  vector<ll> prime;
  vector<ll> primeF;
  ll nowP = 1;
  ll tmpN = N;

  if (tmpN % 2 == 0) {
    ll F = 0;
    while (tmpN % 2 == 0) {
      F++;
      tmpN /= 2;
    }
    prime.push_back(2);
    primeF.push_back(F);
  }

  while (tmpN > 1) {
    nowP += 2;
    if (nowP > sqrt(N)) {
      prime.push_back(tmpN);
      primeF.push_back(1);
      break;
    }

    if (tmpN % nowP != 0)
      continue;

    int F = 0;
    while (tmpN % nowP == 0) {
      F++;
      tmpN /= nowP;
    }
    prime.push_back(nowP);
    primeF.push_back(F);
  }

  // 線形探索...
  for (int p : primeF) {
    ll x = 0;
    while ((x + 1) * (x + 2) / 2 <= p) {
      x++;
    }
    ans += x;
  }

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


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
// #include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

bool isZero = true;

// string ans = "Yes";
ll ans = 0;
ll N;
vector<ll> A;

int main() {
  cin >> N;

  vector<ll> prime;
  vector<ll> primeF;
  ll nowP = 1;
  ll tmpN = N;

  if (tmpN % 2 == 0) {
    ll F = 0;
    while (tmpN % 2 == 0) {
      F++;
      tmpN /= 2;
    }
    prime.push_back(2);
    primeF.push_back(F);
  }

  while (tmpN > 1) {
    nowP += 2;
    if (nowP > sqrt(N) && primeF.size() == 0) {
      prime.push_back(N);
      primeF.push_back(1);
      break;
    }

    if (tmpN % nowP != 0)
      continue;

    int F = 0;
    while (tmpN % nowP == 0) {
      F++;
      tmpN /= nowP;
    }
    prime.push_back(nowP);
    primeF.push_back(F);
  }

  // 線形探索...
  for (int p : primeF) {
    ll x = 0;
    while ((x + 1) * (x + 2) / 2 <= p) {
      x++;
    }
    ans += x;
  }

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

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

#define int long long int
#define pb push_back
#define mod 1000000007
typedef vector<int> vi;
typedef pair<int, int> pi;
#define F first;
#define S second;
#define mp make_pair;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define forev(i, a, b) for (int i = a; i >= b; i--)
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

// Modular Multiplicative Inverse a x = 1 (mod m)
// https://math.stackexchange.com/questions/1372705/formula-for-reciprocal-of-a-factorial
// invFact(n) = fact(n)^(mod-2)

int32_t main() {
  fast int n;
  cin >> n;
  //    int arr[n+1]={0};
  int tot = 0;
  for (int i = 2; i * i <= n; i++) {
    int num = 0;
    while (n % i == 0) {
      num++;
      n /= i;
    }
    for (int j = 1;; j++) {
      if (num < j)
        break;
      num -= j;
      tot++;
      //			cout<<i<<" "<<j<<"\\n";
    }
  }
  if (n != 1)
    tot++;
  cout << tot;
  return 0;
}

Error: TLE

Fixed submission:

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

#define int long long int
#define pb push_back
#define mod 1000000007
typedef vector<int> vi;
typedef pair<int, int> pi;
#define F first;
#define S second;
#define mp make_pair;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define forev(i, a, b) for (int i = a; i >= b; i--)
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

// Modular Multiplicative Inverse a x = 1 (mod m)
// https://math.stackexchange.com/questions/1372705/formula-for-reciprocal-of-a-factorial
// invFact(n) = fact(n)^(mod-2)

int32_t main() {
  fast int n;
  cin >> n;
  //    int arr[n+1]={0};
  int tot = 0;
  for (int i = 2; i <= n; i++) {
    int num = 0;
    while (n % i == 0) {
      num++;
      n /= i;
    }
    for (int j = 1;; j++) {
      if (num < j)
        break;
      num -= j;
      tot++;
      //			cout<<i<<" "<<j<<"\\n";
    }
  }
  cout << tot;
  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++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template <typename T> vector<T> make_v(size_t a, T b) {
  return vector<T>(a, b);
}

template <typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

  int c = 0;
  for (ll i = 2; i * i <= n; i++) {
    int t = 0;
    while (n % i == 0) {
      n /= i;
      t++;
    }

    for (int j = 1; j * (j + 1) <= 2 * t; j++) {
      c++;
    }
  }

  if (n > 1) {
    c += 1;
  }

  cout << c << endl;

  return 0;
}


Error: -6
77ce8696-3220-4423-b89c-42faaf4088da.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02660/C++/s952203549.cpp:32: int main(): Assertion `false' failed.


Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template <typename T> vector<T> make_v(size_t a, T b) {
  return vector<T>(a, b);
}

template <typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

  int c = 0;
  for (int i = 2; i * i <= n; i++) {
    int t = 0;
    while (n % i == 0) {
      n /= i;
      t++;
    }
    continue;
    for (int j = 1; j * (j + 1) <= 2 * t; j++) {
      c++;
    }
  }
  assert(false);

  if (n > 1) {
    c += 1;
  }

  cout << c << endl;

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

#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

vector<pair<int64, int>> Factorize(int64 x) {
  vector<pair<int64, int>> r;
  for (int64 d = 2; d * d <= x; d++) {
    int c = 0;
    while (x % d == 0) {
      x /= d;
      c++;
    }
    if (c > 0) {
      r.push_back({d, c});
    }
  }
  if (x > 1)
    r.push_back({x, 1});
  return r;
}

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

  int64 n;
  cin >> n;
  auto pfs = Factorize(n);
  int count = 0;
  for (auto [p, f] : pfs) {
    // cout << "p: " << p << " f: " << f << endl;
    for (int i = 1; i <= f; i++) {
      // cout << i << " " << f << endl;
      f -= i;
      count++;
    }
  }
  cout << count << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

vector<pair<int64, int>> Factorize(int64 x) {
  vector<pair<int64, int>> r;
  for (int d = 2; d * d <= x; d++) {
    int c = 0;
    while (x % d == 0) {
      x /= d;
      c++;
    }
    if (c > 0) {
      r.push_back({d, c});
    }
  }
  if (x > 1)
    r.push_back({x, 1});
  return r;
}

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

  int64 n;
  cin >> n;
  auto pfs = Factorize(n);
  int count = 0;
  for (auto [p, f] : pfs) {
    // cout << "p: " << p << " f: " << f << endl;
    for (int i = 1; i <= f; i++) {
      // cout << i << " " << f << endl;
      f -= i;
      count++;
    }
  }
  cout << count << endl;
}