Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e6+5;
const int mod=1e9+7;
int prime[maxn];
int visit[maxn];
void Prime(){
    for (int i = 2;i <= maxn; i++) {
        if (!visit[i]) {
            prime[++prime[0]] = i;
        }
        for (int j = 1; j <=prime[0] && i*prime[j] <= maxn; j++) {

            visit[i*prime[j]] = 1;
            if (i % prime[j] == 0) {
                break;
            }
        }
    }
}
int vis[maxn];
int a[maxn];
signed  main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    Prime();
    int n;
    cin>>n;
    int cnt=0;
    int flag=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            cnt++;
        }
    }
    if(cnt>=2){
            int ans=a[1];
            for(int i=2;i<=n;i++){
                ans=__gcd(a[i],ans);
            }
            if(ans==1){
                cout<<"setwise coprime"<<endl;
            }
            else{
                cout<<"not coprime"<<endl;
            }
    }
    else{
        bool flag=0;
        for(int i=1;i<=n&&flag==0;i++){
            for(int j=0;j<prime[0]&&prime[j]*prime[j]<=i;j++){
                while(a[i]%prime[j]==0){
                    if(vis[prime[j]]==0)
                    vis[prime[j]]=1;
                    else{
                        flag=1;
                        break;
                    }
                    if(a[i]==1)break;
                }
            }
            if(a[i]!=1){
                if(vis[a[i]]==0)
                vis[a[i]]=1;
                else{
                     flag=1;
                     break;
                }
            }
        }
        if(flag==0){
            cout<<"pairwise coprime"<<endl;
        }
        else{
            int ans=a[1];
            for(int i=2;i<=n;i++){
                ans=__gcd(a[i],ans);
            }
            if(ans==1){
                cout<<"setwise coprime"<<endl;
            }
            else{
                cout<<"not coprime"<<endl;
            }
        }
    }



    return 0;
}




Compiler output:
a.cc: In function 'void Prime()':
a.cc:10:14: error: reference to 'visit' is ambiguous
   10 |         if (!visit[i]) {
      |              ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:5: note:                 'long long int visit [1000005]'
    7 | int visit[maxn];
      |     ^~~~~
a.cc:15:13: error: reference to 'visit' is ambiguous
   15 |             visit[i*prime[j]] = 1;
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:5: note:                 'long long int visit [1000005]'
    7 | int visit[maxn];
      |     ^~~~~