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

#include <bits/stdc++.h>
#define LLI long long int
#define pii pair<int, int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if (x != 0 && MODE == x)
#define MODE 0
using namespace std;

bool prime[1000007] = {};
bool v[1000007] = {};

int main() {
  int i, j;
  LLI N;

  for (i = 2; i <= 1000000; i++) {
    prime[i] = 1;
  }

  for (i = 2; i <= 1000000; i++) {
    if (prime[i]) {
      for (j = 2; i * j <= 1000000; j++)
        prime[i * j] = 0;
    }
  }

  scanf("%lld", &N);

  int ans = 0;
  for (i = 2; (LLI)i * i <= N; i++) {
    if (!prime[i])
      continue;
    v[i] = 1;

    if (N % i == 0) {
      for (j = i; N % j == 0; j *= i) {
        N /= j;
        de(1) printf("N = %lld\\n", N);
        ans++;
      }

      while (N % i == 0)
        N /= i;
    }
  }

  if (N > 1)
    ans++;

  printf("%d\\n", ans);

  return 0;
}

//
//          ___ ___  __________  __________
//         /////\\  \\/\\   ______\\/\\\\\\\\\\\\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \\ \\  \\ \\  \\_____/\\ \\\\\\\\_____/      New Empire of CHSH ...
//       ////   \\ \\  \\ \\  \\      \\ \\\\\\\\\\\\\\\\\\\\\\
//      ////__   \\ \\  \\ \\  \\      \\ \\\\\\\\_____/
//     ///////\\   \\ \\  \\ \\  \\______\\ \\\\\\\\_______   ________
//    ////____/    \\ \\__\\ \\___   ___\\ \\\\\\\\\\\\\\\\\\\\\\ _\\  ___  \\_
//   /__/           \\/__/\\/__/\\  \\__/\\ \\\\\\\\_____//\\  .\\_/\\_  \\
//                           \\ \\  \\   \\ \\\\\\\\\\\\\\\\\\\\\\\\  \\_\\/_\\  \\
// ... with the AC Power of   \\ \\  \\   \\ \\\\\\\\_____/ \\   _____  \\
//   The Great Tsundere Doggy. \\ \\  \\   \\ \\\\\\\\     \\ \\  \\  \\ \\  \\
//                              \\ \\__\\   \\ \\\\\\\\\\\\\\\\\\\\ \\__\\  \\ \\__\\
//                               \\/__/    \\/________/\\/__/   \\/__/
//


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define LLI long long int
#define pii pair<int, int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if (x != 0 && MODE == x)
#define MODE 0
using namespace std;

bool prime[1000007] = {};
bool v[1000007] = {};

int main() {
  int i, j;
  LLI N;

  for (i = 2; i <= 1000000; i++) {
    prime[i] = 1;
  }

  for (i = 2; i <= 1000000; i++) {
    if (prime[i]) {
      for (j = 2; i * j <= 1000000; j++)
        prime[i * j] = 0;
    }
  }

  scanf("%lld", &N);

  int ans = 0;
  for (i = 2; (LLI)i * i <= N; i++) {
    if (!prime[i])
      continue;
    v[i] = 1;

    if (N % i == 0) {
      for (j = i; N % j == 0; j *= i) {
        N /= j;
        de(1) printf("N = %lld\\n", N);
        ans++;
      }
    }
  }

  if (prime[N] && !v[N])
    ans++;

  printf("%d\\n", ans);

  return 0;
}

//
//          ___ ___  __________  __________
//         /////\\  \\/\\   ______\\/\\\\\\\\\\\\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \\ \\  \\ \\  \\_____/\\ \\\\\\\\_____/      New Empire of CHSH ...
//       ////   \\ \\  \\ \\  \\      \\ \\\\\\\\\\\\\\\\\\\\\\
//      ////__   \\ \\  \\ \\  \\      \\ \\\\\\\\_____/
//     ///////\\   \\ \\  \\ \\  \\______\\ \\\\\\\\_______   ________
//    ////____/    \\ \\__\\ \\___   ___\\ \\\\\\\\\\\\\\\\\\\\\\ _\\  ___  \\_
//   /__/           \\/__/\\/__/\\  \\__/\\ \\\\\\\\_____//\\  .\\_/\\_  \\
//                           \\ \\  \\   \\ \\\\\\\\\\\\\\\\\\\\\\\\  \\_\\/_\\  \\
// ... with the AC Power of   \\ \\  \\   \\ \\\\\\\\_____/ \\   _____  \\
//   The Great Tsundere Doggy. \\ \\  \\   \\ \\\\\\\\     \\ \\  \\  \\ \\  \\
//                              \\ \\__\\   \\ \\\\\\\\\\\\\\\\\\\\ \\__\\  \\ \\__\\
//                               \\/__/    \\/________/\\/__/   \\/__/
//