Language: C++

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define len(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define lb lower_bound
#define ub upper_bound
#define mine min_element
#define maxe max_element
#define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <class T> void __f(const char* name, T&& a) {
    cerr << name << ": " << a << '\n';
}
template <class T, class... Ts> void __f(const char* names, T&& a, Ts&&... b) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << a << " /";
    __f(comma + 1, b...);
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T> bool mini(T& a, const T& b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, const T& b) { return a < b ? (a = b, 1) : 0; }

typedef long long ll;
typedef double db;
typedef pair<int, int> pi;
typedef pair<int, pi> ti;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ti> vti;
typedef vector<vpi> vvpi;

const int inf = (int)0x3f3f3f3f3f3f3f3f;
const int ninf = (int)0xc0c0c0c0c0c0c0c0;
const int M = (int)1e9 + 7;
const int N = 1e3;

int n, a[N], p[N], gcd = -1;
bool vis[N];
vi pr;

void sieve() {
    fort(i, 2, N) {
        if (!p[i]) {
            p[i] = i;
            pr.pb(i);
        }
        for (int j = 0; j < len(pr) && i * pr[j] <= N; ++j) {
            p[i * pr[j]] = pr[j];
            if (i % pr[j] == 0) break;
        }
    }
}

signed main() {
//    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    fort(i, 1, n) {
        cin >> a[i];
        if (gcd == -1) gcd = a[i];
        else gcd = __gcd(gcd, a[i]);
    }
    sieve();
    fort(i, 1, n) {
        while (p[a[i]]) {
            if (vis[p[a[i]]] == 1) {
                if (gcd == 1) cout << "setwise coprime\n";
                else cout << "not coprime\n";
                return 0;
            }
            vis[p[a[i]]] = 1;
            a[i] /= p[a[i]];
        }
    }
    cout << "pairwise coprime\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:73:13: error: reference to 'gcd' is ambiguous
   73 |         if (gcd == -1) gcd = a[i];
      |             ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:49:20: note:                 'long long int gcd'
   49 | int n, a[N], p[N], gcd = -1;
      |                    ^~~
a.cc:73:24: error: reference to 'gcd' is ambiguous
   73 |         if (gcd == -1) gcd = a[i];
      |                        ^~~
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:49:20: note:                 'long long int gcd'
   49 | int n, a[N], p[N], gcd = -1;
      |                    ^~~
a.cc:74:14: error: reference to 'gcd' is ambiguous
   74 |         else gcd = __gcd(gcd, a[i]);
      |              ^~~
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:49:20: note:                 'long long int gcd'
   49 | int n, a[N], p[N], gcd = -1;
      |                    ^~~
a.cc:74:26: error: reference to 'gcd' is ambiguous
   74 |         else gcd = __gcd(gcd, a[i]);
      |                          ^~~
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:49:20: note:                 'long long int gcd'
   49 | int n, a[N], p[N], gcd = -1;
      |                    ^~~
a.cc:80:21: error: reference to 'gcd' is ambiguous
   80 |                 if (gcd == 1) cout << "setwise coprime\n";
      |                     ^~~
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:49:20: note:                 'long long int gcd'
   49 | int n, a[N], p[N], gcd = -1;
      |                    ^~~