Problem p02467 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <exception>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define per(i, a, n) for (ll i = (a); i > (n); i--)
#define lep(i, a, n) for (ll i = (a); i <= (n); i++)
#define pel(i, a, n) for (ll i = (a); i >= (n); i--)
#define clr(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM, X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM, X, Y)                                                     \\
  cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
static const int INF = 1e+9 + 7;
ll n, m, l;
string s, t;
ll d[200010], dp[1010][1010];
double w[1000], v[1000];
double box[200010];

int main() {
  cin >> n;
  m = 2;
  cout << n << ":";
  while (n >= m * m) {
    if (n % m == 0) {
      printf(" %lld", m);
      n /= m;
    } else {
      m++;
    }
  }
  printf(" %lld\\n", n);
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <exception>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define per(i, a, n) for (ll i = (a); i > (n); i--)
#define lep(i, a, n) for (ll i = (a); i <= (n); i++)
#define pel(i, a, n) for (ll i = (a); i >= (n); i--)
#define clr(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM, X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM, X, Y)                                                     \\
  cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
static const int INF = 1e+9 + 7;
ll n, m, l;
string s, t;
ll d[200010], dp[1010][1010];
double w[1000], v[1000];
double box[200010];

vector<int> PRIME;

bool prime(ll x) {
  PRIME.push_back(2);
  if (x % 2 == 0) {
    // puts("Not Prime");
    // return false;
  }
  for (int i = 3; i * i <= x; i += 2) {
    if (d[i])
      continue;
    PRIME.push_back(i);
    if (x % i == 0) {
      // puts("Not Prime");
      // return false;
    }
    rep(j, 2, x) d[i * j]++;
  }
  // puts("Prime");
  return true;
}

int main() {
  vi vec;
  cin >> n;
  cout << n << ":";
  prime(n);
  rep(i, 0, PRIME.size()) {
    if (n % PRIME[i] == 0) {
      while (n % PRIME[i] == 0) {
        vec.pb(PRIME[i]);
        n /= PRIME[i];
      }
    }
  }
  if (n > 1)
    vec.pb(n);
  sort(all(vec));
  rep(i, 0, vec.sz) cout << " " << vec[i];
  puts("");
  return 0;
}