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

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

#define rep(i, n, m) for (int i = (n); i < (m); i++)
#define rep_d(i, n, m) for (int i = (n)-1; i >= (m); i--)
#define sort_asc(X) sort((X).begin(), (X).end())
#define sort_desc(X) sort((X).begin(), (X).end(), greater<>())
#define endl "\\n"

template <class T> bool chmax(T &a, T b);
template <class T> bool chmin(T &a, T b);
int *eratosthenes(int N);
bool bit_search(int pattern, int N);
void initialize(void);

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
  T a;
  K b;
};
typedef struct {
  vector<int> to;
  int cost;
} edge;

vector<int> prime_factorize(ll N) {
  vector<int> vec;
  int lim = sqrt(N) + 1;
  rep(i, 2, N + 1) {
    if (i >= lim) {
      vec.push_back(N);
      break;
    }
    if (N % i == 0) {
      vec.push_back(i);
      while (N % i == 0)
        N /= i;
    }
  }
  return vec;
}
int main(void) {
  // initialize();
  int N;
  cin >> N;
  vector<int> inputs(N), vec(N - 1);
  rep(i, 0, N) scanf("%d", &inputs[i]);
  int GCD = __gcd(inputs[0], inputs[1]);
  vec[0] = GCD;
  rep(i, 2, N) {
    GCD = __gcd(GCD, inputs[i]);
    vec[i - 1];
  }
  if (GCD != 1) {
    printf("not coprime\\n");
    return 0;
  }
  vector<bool> used((int)(1e6 + 5), false);
  for (auto input : inputs) {
    const auto &vec = prime_factorize(input);
    for (auto v : vec) {
      if (used[v]) {
        printf("setwise coprime\\n");
        return 0;
      }
      used[v] = true;
    }
  }
  printf("pairwise coprime\\n");
}

template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int *eratosthenes(int N) {
  int *prime_array = new int[N + 1];
  int lim = N;
  prime_array[0] = 0;
  prime_array[1] = 0;
  rep(i, 2, N + 1) { prime_array[i] = 1; }
  rep(i, 2, lim) {
    if (prime_array[i] == 0)
      continue;
    lim = N / i;
    for (int j = i * 2; j < N + 1; j += i) {
      prime_array[j] = 0;
    }
  }
  return prime_array;
}
bool bit_search(int pattern, int N) {
  int cnt = 0;
  rep(bit, 0, N) {
    if (pattern & (1 << bit)) {
      cnt++;
    }
  }
  return true;
}
void initialize(void) { cout << fixed << setprecision(10); }


Error: 0

Fixed submission:

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

#define rep(i, n, m) for (int i = (n); i < (m); i++)
#define rep_d(i, n, m) for (int i = (n)-1; i >= (m); i--)
#define sort_asc(X) sort((X).begin(), (X).end())
#define sort_desc(X) sort((X).begin(), (X).end(), greater<>())
#define endl "\\n"

template <class T> bool chmax(T &a, T b);
template <class T> bool chmin(T &a, T b);
int *eratosthenes(int N);
bool bit_search(int pattern, int N);
void initialize(void);

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
  T a;
  K b;
};
typedef struct {
  vector<int> to;
  int cost;
} edge;

vector<int> prime_factorize(ll N) {
  vector<int> vec;
  int lim = sqrt(N) + 1;
  rep(i, 2, N + 1) {
    if (i >= lim) {
      vec.push_back(N);
      break;
    }
    if (N % i == 0) {
      vec.push_back(i);
      while (N % i == 0)
        N /= i;
    }
  }
  return vec;
}
int main(void) {
  // initialize();
  int N;
  cin >> N;
  vector<int> inputs(N), vec(N - 1);
  rep(i, 0, N) scanf("%d", &inputs[i]);
  int GCD = __gcd(inputs[0], inputs[1]);
  vec[0] = GCD;
  rep(i, 2, N) {
    GCD = __gcd(GCD, inputs[i]);
    vec[i - 1];
  }
  if (GCD != 1) {
    printf("not coprime\\n");
    return 0;
  }
  vector<bool> used(N + 5, false);
  for (auto input : inputs) {
    const auto &vec = prime_factorize(input);
    for (auto v : vec) {
      if (used[v]) {
        printf("setwise coprime\\n");
        return 0;
      }
      used[v] = true;
    }
  }
  printf("pairwise coprime\\n");
}

template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int *eratosthenes(int N) {
  int *prime_array = new int[N + 1];
  int lim = N;
  prime_array[0] = 0;
  prime_array[1] = 0;
  rep(i, 2, N + 1) { prime_array[i] = 1; }
  rep(i, 2, lim) {
    if (prime_array[i] == 0)
      continue;
    lim = N / i;
    for (int j = i * 2; j < N + 1; j += i) {
      prime_array[j] = 0;
    }
  }
  return prime_array;
}
bool bit_search(int pattern, int N) {
  int cnt = 0;
  rep(bit, 0, N) {
    if (pattern & (1 << bit)) {
      cnt++;
    }
  }
  return true;
}
void initialize(void) { cout << fixed << setprecision(10); }