Language: C++

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
// int a[100010],n,j;
bool ok=true;
int gcd(int a,int b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
void factor(int x,long long fact[])
{
   if(ok==true)
            return;
        for(int i=1;i*i<=x;i++){
            if(x%i==0){
                int a=i;
                int b=x/i;
                if(a==b){
                    a=i;
                    b=1;
                }
                if(a!=1){
                    if(fact[a]){
                        ok=true;
                        return;
                    }
                    fact[a]++;
                }
                if(b!=1){
                    if(fact[b]){
                        ok=true;
                        return;
                    }
                    fact[b]++;
                }
            }
        }
  
}
int main()
{
    int n;
    cin>>n;
    int a[n];
    //cin >> a[i];
    for(int i=0;i<n;i++)
        cin >> a[i];
    int totalgcd=a[0];
    long long fact[1000001]={0};
   //factor(a[0],fact);
    for(int i=1;i<n;i++)
    {
        totalgcd=__gcd(totalgcd,a[i]);
      // factor(a[i],fact);
    }
  fact[1]=1;
    for(int i=0;i<n;i++)
        factor(a[i],fact);
  
   //int ispairwise=1;
   // for(int i=0;i<n;i++)
   // {
   //   if(fact[a[i]]>1){ispairwise=0;break;}
   // }
   if(!ok)
   {
    cout <<"pairwise coprime" << endl;
   }
else if(totalgcd==1)
     cout <<"setwise coprime" << endl;
   else
     cout <<"not coprime" << endl;
}
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
// int a[100010],n,j;
bool ok=false;
int gcd(int a,int b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
void factor(int x,long long fact[])
{
   if(ok==true)
            return;
        for(int i=1;i*i<=x;i++){
            if(x%i==0){
                int a=i;
                int b=x/i;
                if(a==b){
                    a=i;
                    b=1;
                }
                if(a!=1){
                    if(fact[a]){
                        ok=true;
                        return;
                    }
                    fact[a]++;
                }
                if(b!=1){
                    if(fact[b]){
                        ok=true;
                        return;
                    }
                    fact[b]++;
                }
            }
        }
  
}
int main()
{
    int n;
    cin>>n;
    int a[n];
    //cin >> a[i];
    for(int i=0;i<n;i++)
        cin >> a[i];
    int totalgcd=a[0];
    long long fact[1000001]={0};
   //factor(a[0],fact);
    for(int i=1;i<n;i++)
    {
        totalgcd=__gcd(totalgcd,a[i]);
      // factor(a[i],fact);
    }
 // fact[1]=1;
    for(int i=0;i<n;i++)
        factor(a[i],fact);
  
   //int ispairwise=1;
   // for(int i=0;i<n;i++)
   // {
   //   if(fact[a[i]]>1){ispairwise=0;break;}
   // }
   if(!ok)
   {
    cout <<"pairwise coprime" << endl;
   }
else if(totalgcd==1)
     cout <<"setwise coprime" << endl;
   else
     cout <<"not coprime" << endl;
}


Compiler output:
a.cc:81:6: error: redefinition of 'bool ok'
   81 | bool ok=false;
      |      ^~
a.cc:5:6: note: 'bool ok' previously defined here
    5 | bool ok=true;
      |      ^~
a.cc:82:5: error: redefinition of 'int gcd(int, int)'
   82 | int gcd(int a,int b)
      |     ^~~
a.cc:6:5: note: 'int gcd(int, int)' previously defined here
    6 | int gcd(int a,int b)
      |     ^~~
a.cc:89:6: error: redefinition of 'void factor(int, long long int*)'
   89 | void factor(int x,long long fact[])
      |      ^~~~~~
a.cc:13:6: note: 'void factor(int, long long int*)' previously defined here
   13 | void factor(int x,long long fact[])
      |      ^~~~~~
a.cc:119:5: error: redefinition of 'int main()'
  119 | int main()
      |     ^~~~
a.cc:43:5: note: 'int main()' previously defined here
   43 | int main()
      |     ^~~~