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

#include <cmath>
#include <iostream>
#define MAX_N 100001
using namespace std;

bool isPrime(int n) {
  if (n == 0 || n == 1)
    return false;
  if (n == 2 || n == 3)
    return true;
  if (n % 2 == 0)
    return false;
  for (int i = 5; i <= sqrt(n); i += 2) {
    if (n % i == 0)
      return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int nc = n;
  cout << n << ':';
  if (isPrime(n) == true) {
    cout << ' ' << n << endl;
    return 0;
  }
  for (int i = 2; i <= nc; i++) {
    if (isPrime(i) == false)
      continue;
    if (nc % i)
      continue;
    while (nc % i == 0) {
      cout << ' ' << i;
      nc /= i;
    }
  }
  cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#define MAX_N 100001
using namespace std;

bool isPrime(int n) {
  if (n == 0 || n == 1)
    return false;
  if (n == 2 || n == 3)
    return true;
  if (n % 2 == 0)
    return false;
  for (int i = 5; i <= sqrt(n); i += 2) {
    if (n % i == 0)
      return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int nc = n;
  cout << n << ':';
  for (int i = 2; i <= nc; i++) {
    if (isPrime(i) == false)
      continue;
    if (nc % i)
      continue;
    while (nc % i == 0) {
      cout << ' ' << i;
      nc /= i;
    }
  }
  cout << endl;

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define CIN(in)                                                                \\
  int in;                                                                      \\
  cin >> in;
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double ESP = 1e-10;
using namespace std;
int main() {
  CIN(in);
  cout << in << ":";
  loop(i, 2, 1e9 + 10) {
    if (i * i > in) {
      cout << " " << in;
      break;
    }
    while (in % i == 0) {
      cout << " " << i;
      in /= i;
    }
    if (in == 1)
      break;
  }
  cout << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define CIN(in)                                                                \\
  int in;                                                                      \\
  cin >> in;
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double ESP = 1e-10;
using namespace std;
int main() {
  CIN(in);
  cout << in << ":";
  loop(i, 2, 1e9 + 10) {
    while (in % i == 0) {
      cout << " " << i;
      in /= i;
    }
    if (in == 1)
      break;
  }
  cout << endl;
}
Problem p02467 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define FI first
#define SE second
#define VE vector<int>
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define LL long long
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ROF(i, a, b) for (int i = b - 1; i >= a; i--)
#define YES(i) cout << (i ? "YES" : "NO") << endl
#define Yes(i) cout << (i ? "Yes" : "No") << endl
using namespace std;
//
const int INF = 1e9 + 7;
//
int main() {
  int N;
  cin >> N;
  cout << N << ":";
  for (int i = 2; i * i <= N; i++) {
    while (N % i == 0) {
      cout << " " << i;
      N /= i;
    }
  }
  if (N != 1) {
    cout << " " << N;
  }
  cout << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define FI first
#define SE second
#define VE vector<int>
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define LL long long
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ROF(i, a, b) for (int i = b - 1; i >= a; i--)
#define YES(i) cout << (i ? "YES" : "NO") << endl
#define Yes(i) cout << (i ? "Yes" : "No") << endl
using namespace std;
//
const int INF = 1e9 + 7;
//
int main() {
  int N;
  cin >> N;
  cout << N << ":";
  while (N % 2 == 0) {
    N /= 2;
    cout << " " << 2;
  }
  for (int i = 3; N != 1; i += 2) {
    if (N % i == 0) {
      while (N % i == 0) {
        N /= i;
        cout << " " << i;
      }
    }
  }
  cout << endl;
  return 0;
}
Problem p02467 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int pr[50847534];

int x = 0;
int nextpr(int p) {
  int nxp = p + 2;
  int i = 0;
  int ok = 0;
  pr[x] = p;
  x++;
  if (p == 2)
    return 3;
  while (1 == 1) {
    for (i = 0; pr[i] * pr[i] <= nxp; i++) {
      ok = 0;
      if (nxp % pr[i] == 0) {
        ok = 1;
        break;
      }
    }
    if (ok == 0) {
      return nxp;
    } else {
      nxp += 2;
    }
  }
}

int main() {
  int n, n2;
  int p = 2;
  int done = 0;
  scanf("%d", &n);
  printf("%d:", n);
  n2 = n;
  while (n > 1) {
    if (n % 2 == 0) {
      printf(" 2");
      n /= 2;
      done = 1;
    } else if (n % p == 0) {
      printf(" %d", p);
      n /= p;
      done = 1;
    } else {
      /*printf("X%d\\n",p);*/
      p = nextpr(p);
    }
    if (p * p > n2 && done == 0) {
      printf(" %d", n2);
      break;
    }
  }
  printf("\\n");
}

Error: TLE

Fixed submission:

#include <stdio.h>
int pr[50847534];

int x = 0;
int nextpr(int p) {
  int nxp = p + 2;
  int i = 0;
  int ok = 0;
  pr[x] = p;
  x++;
  if (p == 2)
    return 3;
  while (1 == 1) {
    for (i = 0; pr[i] * pr[i] <= nxp; i++) {
      ok = 0;
      if (nxp % pr[i] == 0) {
        ok = 1;
        break;
      }
    }
    if (ok == 0) {
      return nxp;
    } else {
      nxp += 2;
    }
  }
}

int main() {
  int n;
  int p = 2;
  scanf("%d", &n);
  printf("%d:", n);
  while (n > 1) {
    if (n % 2 == 0) {
      printf(" 2");
      n /= 2;
    } else if (n % p == 0) {
      printf(" %d", p);
      n /= p;
    } else {
      p = nextpr(p);
    }
  }
  printf("\\n");
}
Problem p02467 (C++) — buggy submission, verdict: Time Limit Exceeded

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

bool isprime(long long int val) {
  if (val <= 1)
    return false;
  for (long long int i = 2; i * i <= val; i++) {
    if (val % i == 0LL)
      return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  vector<int> v;
  int k = n;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      v.push_back(i);
    }
    if (isprime(n)) {
      v.push_back(n);
      break;
    }
  }
  cout << k << ":";
  for (int i = 0; i < v.size(); i++) {
    cout << " " << v[i];
  }
  cout << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<int> v;
  int k = n;
  for (int i = 2; i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      v.push_back(i);
    }
  }
  cout << k << ":";
  for (int i = 0; i < v.size(); i++) {
    cout << " " << v[i];
  }
  cout << endl;
}
Problem p02467 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#
#include <cmath>

using namespace std;

int main() {
  long int n;
  scanf("%ld", &n);

  long int *memo;
  memo = (long int *)malloc(n / 3 * sizeof(long int));

  double ceilodd = sqrt(n * 1.0);

  bool divisable = false;

  printf("%ld:", n);

  memo[0] = 2;
  while (n % 2 == 0) {
    printf(" 2");
    n /= 2;
  }

  memo[1] = 3;
  while (n % 3 == 0) {
    printf(" 3");
    n /= 3;
  }

  long int cnt = 2;

  for (long int i = 5; i <= ceilodd; i += 2) {
    divisable = false;

    for (long int j = 3; j < sqrt(i * 1.0); j += 2) {
      if (i % j == 0) {
        divisable = true;
        break;
      }
    }

    if (divisable == false) {
      memo[cnt] = i;
      while (n % memo[cnt] == 0) {
        printf(" %ld", memo[cnt]);
        n /= memo[cnt];
        if (n == 1)
          break;
      }
      if (n == 1)
        break;
      cnt++;
    }
  }

  if (n != 1)
    printf(" %ld", n);

  printf("\\n");

  free(memo);

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

int main() {
  long int n;
  scanf("%ld", &n);

  long int *memo;
  memo = (long int *)malloc(n / 3 * sizeof(long int));

  double ceilodd = sqrt(n * 1.0);
  long int max = n / 3;

  bool divisable = false;

  printf("%ld:", n);

  memo[0] = 2;
  while (n % 2 == 0) {
    printf(" 2");
    n /= 2;
  }

  memo[1] = 3;
  while (n % 3 == 0) {
    printf(" 3");
    n /= 3;
  }

  long int cnt = 2;

  for (long int i = 5; i <= max; i += 2) {
    divisable = false;

    for (long int j = 3; j < sqrt(i * 1.0); j += 2) {
      if (i % j == 0) {
        divisable = true;
        break;
      }
    }

    if (divisable == false) {
      memo[cnt] = i;
      while (n % memo[cnt] == 0) {
        printf(" %ld", memo[cnt]);
        n /= memo[cnt];
        if (n == 1)
          break;
      }
      if (n == 1)
        break;
      cnt++;
    }
  }

  if (n != 1)
    printf(" %ld", n);

  printf("\\n");

  free(memo);

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

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define INF 2147483647

using namespace std;

bool isprime(int x) {
  if (x == 2)
    return (true);
  if (x <= 1 || x % 2 == 0)
    return (false);

  for (int i = 3; i <= sqrt(x) + 1; i += 2) {
    if (x % i == 0)
      return (false);
  }
  return (true);
}

int main(void) {
  int n;

  cin >> n;

  int tmp = n;

  cout << n << ":";

  if (isprime(n)) {
    cout << " " << n << endl;
    return (0);
  }

  for (int i = 2; i <= n; i++) {
    if (tmp == 1)
      break;
    if (isprime(i)) {
      if (tmp % i == 0) {
        cout << " " << i;
        tmp /= i;
        i--;
      }
    }
  }
  cout << endl;

  return (0);
}

Error: TLE

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n, m;
  int i = 2;

  scanf("%d", &n);
  printf("%d:", n);

  m = n;

  while (1) {
    if (n % i == 0) {
      printf(" %d", i);
      if (i == m)
        break;
      n /= i;
      continue;
    }
    if (i == m)
      break;
    i++;
  }
  printf("\\n");

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

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-9;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
/*素因数分解*/
void prime_factor(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      cout << " " << i;
    }
  }
  if (n != 1)
    cout << " " << n;
  return;
}
int main() {
  ll n;
  cin >> n;
  cout << n << ":";
  prime_factor(n);
  cout << endl;
  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-9;

/*?卒???属??????*/
bool is_prime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return n != 1; // 1?????卒????????????
}
/*?卒???属?????????*/
vector<int> divisor(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  return res;
}
/*?卒??????属????則贈*/
map<int, int> res;
void prime_factor(int n) {
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
}

int main() {
  int n;
  cin >> n;
  /*if(is_prime(n))
          cout <<"Yes"<<endl;
  else
          cout <<"No"<<endl;
  cout<<endl;*/
  prime_factor(n);
  cout << n << ":";
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= res[i]; j++) {
      cout << " " << i;
    }
  }
  cout << endl;
  /*for(int i = 0;i <=n;i++){
          if(prime_factor(n)[i]){
                  for(int j = 0;j <prime_factor(n)[i];j++)
                          cout <<"?卒??????属????則贈  ="<<i<<endl;
          }
  }
  cout <<endl;*/
  /*for(int i = 0;i < divisor(n).size();i++){
          cout <<divisor(n)[i]<<endl;
  }*/
  return 0;
}
Problem p02467 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

/////

int main() {
  bool fact[200000];
  fill(fact, fact + 200000, true);
  fact[0] = fact[1] = false;
  for (int i = 2; i < 100000; i++) {
    if (!fact[i])
      continue;
    for (int j = 2; i * j < 200000; j++) {
      fact[i * j] = false;
    }
  }
  set<int> prime;
  for (int i = 0; i < 200000; i++) {
    if (fact[i])
      prime.insert(i);
  }
  int n;
  cin >> n;
  cout << n << ":";
  for (auto &&i : prime) {
    if (n <= 1)
      break;
    while (n % i == 0) {
      cout << " " << i;
      n /= i;
    }
  }
  if (n > 1)
    cout << " " << n;
  cout << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

/////

int main() {
  int n;
  cin >> n;
  cout << n << ":";
  for (int i = 2; n > 1; i++) {
    while (n % i == 0) {
      cout << " " << i;
      n /= i;
    }
  }
  cout << endl;
}
Problem p02467 (C++) — buggy submission, verdict: Runtime Error

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

ll num[1000010], prime[1000010], n_prime = 0;

ll Prime() {
  ll i, j;
  for (i = 0; i < 1000010; i++)
    prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (i = 2; i < 1000010; i++) {
    if (prime[i]) {
      num[++n_prime] = i;
      for (j = 2 * i; j < 1000010; j = j + i)
        prime[j] = 0;
    }
  }
}

int main() {
  ll n, i, j;
  Prime();
  while (scanf("%lld", &n) != EOF) {
    printf("%lld:", n);
    for (i = 1; i < n_prime && num[i] <= sqrt(n); i++) {
      if (n < num[i])
        break;
      if (n % num[i] == 0) {
        while (n % num[i] == 0) {
          n = n / num[i];
          printf(" %lld", num[i]);
        }
      }
    }
    if (n > 1)
      printf(" %lld", n);
    printf("\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <cmath>
#include <iostream>

using namespace std;

bool IsPrime(long long n) {
  long long i;
  for (i = 2; i < sqrt(n); i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}

int main() {
  long long n = 0, i, prime[i];
  for (i = 2; i <= 1000; i++) {
    if (IsPrime(i))
      prime[n++] = i;
  }
  while (cin >> n) {
    cout << n << ":";
    for (i = 0; n != 1; i++) {
      while (n % prime[i] == 0 && n != 1) {
        cout << " " << prime[i];
        n /= prime[i];
      }
    }
    cout << endl;
  }
  return 0;
}
Problem p02467 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
void p(int x) {
  int i, j;
  for (i = 2; i <= 1000000; i++) {
    if (x == 1) {
      printf("\\n");
      return;
    }
    while (x % i == 0) {
      printf(" %d", i);
      x = x / i;
    }
  }
  printf(" %d\\n", x);
}
int main() {
  int x;
  scanf("%d", &x);
  printf("%d:", x);
  p(x);
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int ans[10000];
int main() {
  int n;
  cin >> n;
  int as = 0;
  int top = 2;
  int pre = n;
  while (n != 1) {
    if (n % top == 0) {
      while (n % top == 0) {
        ans[as++] = top;
        n /= top;
      }
    }
    top++;
  }
  cout << pre << ":";
  for (int i = 0; i < as; i++) {
    cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}
Problem p02467 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int a[10000000];
vector<int> vc;

void sieve() {
  int i, j;
  a[1] = 1;

  vc.push_back(2);

  for (i = 4; i <= 1000000; i += 2)
    a[i] = 1;
  for (i = 3; i <= 1000000; i += 2) {
    if (a[i] == 0) {
      for (j = 3 * i; j <= 1000000; j = j + i * 2)
        a[j] = 1;
      vc.push_back(i);
    }
  }
}
int main()

{
  sieve();
  int i, j, k, l = 0, n;
  scanf("%d", &n);
  printf("%d:", n);
  for (i = 0; n != 1 && i < vc.size(); i++) {
    for (; n % vc[i] == 0;) {
      printf(" %d", vc[i]);
      n = n / vc[i];
      l++;
    }
  }
  if (l == 0)
    printf(" %d", n);
  printf("\\n");
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int prime(int n) {
  int i, f;
  f = 0;
  for (i = 2; i <= sqrt(n); i++) {
    if (n % i == 0)
      return 1;
  }
  return 0;
}
int main() {

  long long int n, i, j, f, g, k;
  while (scanf("%lld", &n) != EOF) {
    f = 0;
    printf("%lld:", n);
    for (i = 2; i <= n; i++) {
      if (n % i == 0) {

        if (prime(i) == 0) {
          while (n % i == 0) {
            n = n / i;
            printf(" ");
            printf("%lld", i);
          }
        }
      }
    }
    printf("\\n");
  }
  return 0;
}
Problem p02467 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
void p(int x) {
  int i, j;
  for (i = 2; i <= 1000000; i++) {
    if (x == 1) {
      printf("\\n");
      return;
    }

    while (x % i == 0) {
      printf(" %d", i);
      x = x / i;
    }
  }
  printf(" %d\\n", x);
}

int main() {
  int x;
  cin >> x;
  printf("%d:", x);
  p(x);

  return 0;
}

Error: MLE

Fixed submission:

#include <bits/stdc++.h>
#define N 1000000001
using namespace std;
int a[N + 9];
void sieve() {
  long long int i, j, s = sqrt(N);
  for (i = 4; i <= N; i += 2)
    a[i] = 1;
  for (i = 3; i <= s; i += 2) {
    if (a[i] == 0) {
      for (j = i * i; j <= N; j += 2 * i)
        a[j] = 1;
    }
  }
}
int main() {
  sieve();
  long long int n, i, j, f, g, k, tc = 1, t;

  while (scanf("%lld", &n) != EOF) {
    printf("%lld :", n);
    for (i = 2; i <= n; i++) {
      if (a[i] == 0) {
        while (n % i == 0) {
          n = n / i;
          if (n % i == 0) {
            printf(" ");
            printf("%lld", i);
          }
        }
      }
    }
    printf("\\n");
  }
  return 0;
}
Problem p02467 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
// #define Kongxiangzhouye
#define sd(x) scanf("%d", &x)
#define ss(x) scanf("%s", x)
#define sc(x) scanf("%c", &x)
#define sf(x) scanf("%f", &x)
#define slf(x) scanf("%lf", &x)
#define slld(x) scanf("%lld", &x)
#define me(x, b) memset(x, b, sizeof(x))
#define pd(d) printf("%d\\n", d);
#define plld(d) printf("%lld\\n", d)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N = 100000;
const int INF = 0x3f3f3f3f;

bool vis(int a) {
  int len = sqrt(a + 0.5);
  for (int i = 2; i < len; i++) {
    if (a % i == 0)
      return 0;
  }
  return 1;
}
int main() {
#ifdef Kongxiangzhouye
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << n << ":";
  int flag;
  while (n != 1) {
    flag = 1;
    for (int i = 2; i < sqrt(n + 0.5); i++) {
      if (vis(i) && n % i == 0) {
        flag = 0;
        n = n / i;
        cout << " " << i;
        break;
      }
    }
    if (flag == 1)
      break;
  }
  cout << " " << n << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
ll pow(ll x, ll y, ll mod) {
  if (y == 0)
    return 1;
  ll w = pow(x, y / 2, mod);
  ll ans = w * w % mod;
  if (y & 1)
    ans *= x % mod;
  return ans;
}

bool vis[50000001];

int main() {

  ios::sync_with_stdio(false);
  int m = sqrt(50000001 + 0.5);
  memset(vis, 0, sizeof(vis));
  for (int i = 2; i <= m; i++) {
    if (!vis[i])
      for (int j = i * 2; j < 50000001; j = j + i)
        vis[j] = 1;
  }
  int n;
  cin >> n;
  cout << n << ":";
  while (n != 1) {
    for (int i = 2; i <= n; i++) {
      if (vis[i] == 0 && n % i == 0) {
        cout << " " << i;
        n = n / i;
        break;
      }
    }
  }
  cout << endl;
  return 0;
}