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

#pragma region
#ifndef LOCAL_DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <assert.h>
#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <vector>
#define pb push_back
#define f(i, a, b) for (int i = a; i < b; i++)
#define revf(i, b, a) for (int i = b; i >= a; i--)
#define all(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define revsrt(v) sort(v.rbegin(), v.rend())
#define sp << ' ' <<
#define en << '\\n'
#define precision(x) cout << fixed << setprecision(x);
#define fio                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;

template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &v) {
  os << "{" << v.first << ", " << v.second << "}" en;
  return os;
}

template <typename T> ostream &operator<<(ostream &os, set<T> &v) {
  for (T t : v)
    os << t << " ";
  os en;
  return os;
}

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (T t : v)
    os << t << " ";
  os en;
  return os;
}

template <typename T> istream &operator>>(istream &is, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++)
    is >> v[i];
  return is;
}

#define int long long
#define pii pair<int, int>
#define float long double
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vvpii vector<vpii>
#pragma endregion

int mod = 1e9 + 7; // 998244353;
const int MAX = 1e6 + 5;

vvi factors(MAX);

void preprocessing() {
  // factors[1].pb(1);

  f(i, 2, MAX) {
    if (!factors[i].size())
      for (int j = i; j < MAX; j += i) {
        factors[j].pb(i);
      }
  }
}

void solvetestcase() {
  int n;
  cin >> n;
  vi v(n);
  cin >> v;

  srt(v);

  bool a = true;
  vector<bool> factors_vis(MAX, 0);
  f(i, 0, n) {
    // cout << i sp factors[v[i]];
    for (int j : factors[v[i]]) {
      if (factors_vis[j]) {
        a = false;
        break;
      }
      factors_vis[j] = 1;
    }

    if (!a)
      break;
  }

  int g = 0;
  f(i, 0, n) g = __gcd(g, v[i]);
  bool b = g == 1;

  if (a) {
    cout << "pairwise coprime\\n";
  } else if (b) {
    cout << "setwise coprime\\n";
  } else {
    cout << "not coprime\\n";
  }
}

#undef int
int main() {
  fio;
  preprocessing();

  int t = 1;
  // UNCOMMENT FOR TESTCASES	\\
	cin >> t;

  f(T, 1, t + 1) {
    // UNCOMMENT FOR CODEJAM,HACKERCUP	\\
		cout << "Case #" << T << ": ";
    solvetestcase();
    cout.flush();
  }

  return 0;
};

/*
    AUTHOR:     KUNAL TAWATIA
    EDUCATION:  INDIAN INSTITUTE OF TECHNOLOGY, JODHPUR
*/


Error: 0

Fixed submission:

#pragma region
#ifndef LOCAL_DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <assert.h>
#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <vector>
#define pb push_back
#define f(i, a, b) for (int i = a; i < b; i++)
#define revf(i, b, a) for (int i = b; i >= a; i--)
#define all(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define revsrt(v) sort(v.rbegin(), v.rend())
#define sp << ' ' <<
#define en << '\\n'
#define precision(x) cout << fixed << setprecision(x);
#define fio                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;

template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &v) {
  os << "{" << v.first << ", " << v.second << "}" en;
  return os;
}

template <typename T> ostream &operator<<(ostream &os, set<T> &v) {
  for (T t : v)
    os << t << " ";
  os en;
  return os;
}

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (T t : v)
    os << t << " ";
  os en;
  return os;
}

template <typename T> istream &operator>>(istream &is, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++)
    is >> v[i];
  return is;
}

#define int long long
#define pii pair<int, int>
#define float long double
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vvpii vector<vpii>
#pragma endregion

int mod = 1e9 + 7; // 998244353;
const int MAX = 1e1 + 5;

vvi factors(MAX);

void preprocessing() {
  factors[1].pb(1);

  f(i, 2, MAX) {
    if (!factors[i].size())
      for (int j = i; j < MAX; j += i) {
        factors[j].pb(i);
      }
  }
}

void solvetestcase() {
  int n;
  cin >> n;
  vi v(n);
  cin >> v;

  bool a = true;
  vector<bool> factors_vis(MAX, 0);
  f(i, 0, n) {
    for (int j : factors[v[i]]) {
      if (factors_vis[j]) {
        a = false;
        break;
      }
      factors_vis[j] = 1;
    }

    if (!a)
      break;
  }

  int g = 0;
  f(i, 0, n) g = __gcd(g, v[i]);
  bool b = g == 1;

  if (a) {
    cout << "pairwise coprime\\n";
  } else if (b) {
    cout << "setwise coprime\\n";
  } else {
    cout << "not coprime\\n";
  }
}

#undef int
int main() {
  fio;
  preprocessing();

  int t = 1;
  // UNCOMMENT FOR TESTCASES	\\
	cin >> t;

  f(T, 1, t + 1) {
    // UNCOMMENT FOR CODEJAM,HACKERCUP	\\
		cout << "Case #" << T << ": ";
    solvetestcase();
    cout.flush();
  }

  return 0;
};

/*
    AUTHOR:     KUNAL TAWATIA
    EDUCATION:  INDIAN INSTITUTE OF TECHNOLOGY, JODHPUR
*/