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

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define _repargs(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _repargs(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T> inline void output(T a, int p = 0) {
  if (p)
    cout << fixed << setprecision(p) << a << "\\n";
  else
    cout << a << "\\n";
}
// end of template

template <typename T> inline void voutput(T &v) {
  rep(i, v.size()) {
    if (i)
      cout << " " << v[i];
    else
      cout << v[i];
  }
  cout << endl;
}

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  // source code
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll g = A[0];
  rep(i, N) g = gcd(g, A[i]);
  vector<int> count(1000010, 0);
  rep(i, N) {
    for (int j = 2; j * j <= A[i]; j++) {
      if (A[i] % j == 0) {
        count[j]++;
      }
      while (A[i] % j == 0) {
        A[i] /= j;
      }
    }
    if (A[i] > 1)
      count[A[i]]++;
  }
  //    voutput(count);
  bool all_one = true;
  rep(i, 1000010) {
    if (count[i] > 1) {
      all_one = false;
      break;
    }
  }
  if (all_one) {
    output("pairwise coprime");
    return 0;
  }
  if (g == 1) {
    output("setwise coprime");
    return 0;
  }
  output("not coprime");

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define _repargs(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _repargs(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T> inline void output(T a, int p = 0) {
  if (p)
    cout << fixed << setprecision(p) << a << "\\n";
  else
    cout << a << "\\n";
}
// end of template

template <typename T> inline void voutput(T &v) {
  rep(i, v.size()) {
    if (i)
      cout << " " << v[i];
    else
      cout << v[i];
  }
  cout << endl;
}

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  // source code
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll g = A[0];
  rep(i, N) g = gcd(g, A[i]);
  vector<int> count(100010, 0);
  rep(i, N) {
    for (int j = 2; j * j <= A[i]; j++) {
      if (A[i] % j == 0) {
        count[j]++;
      }
      while (A[i] % j == 0) {
        A[i] /= j;
      }
    }
    if (A[i] > 1)
      count[A[i]]++;
  }
  //    voutput(count);
  bool all_one = true;
  rep(i, 100010) {
    if (count[i] > 1) {
      all_one = false;
      break;
    }
  }
  if (all_one) {
    output("pairwise coprime");
    return 0;
  }
  if (g == 1) {
    output("setwise coprime");
    return 0;
  }
  output("not coprime");

  return 0;
}