alexjercan/bugnet huggingface dataset:
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int INF = 1e18;
int mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[1000005];
int gcd(int X, int Y) {
  if (X % Y == 0) {
    return Y;
  } else {
    return gcd(Y, X % Y);
  }
}
signed main() {
  vector<int> is_prime(1005, 1);
  is_prime[0] = 0;
  is_prime[1] = 0;
  for (int i = 2; i <= 1000; i++) {
    if (!is_prime[i])
      continue;
    for (int j = i * 2; j < 1000; j += i)
      is_prime[j] = 0;
  }
  set<int> prime;
  for (int i = 1; i <= 1000; i++) {
    if (is_prime[i] == 1) {
      prime.insert(i);
    }
  }
  int N;
  cin >> N;
  vector<int> A(N);
  int GCD = 0;
  bool ok = true;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0) {
      GCD = A[i];
    }
    GCD = gcd(GCD, A[i]);
  }
  for (int i = 0; i < N; i++) {
    int X = A[i];
    for (int j : prime) {
      if (j * j > A[i]) {
        break;
      }
      if (X % j == 0) {
        if (cnt[j] >= 2) {
          ok = false;
          goto END;
        }
        cnt[j]++;
        while (X % j == 0) {
          X /= j;
        }
      }
    }
    if (X >= 2) {
      cnt[X]++;
      if (cnt[X] >= 2) {
        ok = false;
        goto END;
      }
    }
  }
  for (int i = 1; i <= 1000000; i++) {
    if (cnt[i] >= 2) {
      ok = false;
    }
  }
END:;
  if (ok) {
    cout << "pairwise coprime" << endl;
  } else if (GCD == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int INF = 1e18;
int mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[1000005];
int gcd(int X, int Y) {
  if (X % Y == 0) {
    return Y;
  } else {
    return gcd(Y, X % Y);
  }
}
signed main() {
  vector<int> is_prime(1000005, 1);
  is_prime[0] = 0;
  is_prime[1] = 0;
  for (int i = 2; i < 1000005; i++) {
    if (!is_prime[i])
      continue;
    for (int j = i * 2; j < 1000005; j += i)
      is_prime[j] = 0;
  }
  set<int> prime;
  for (int i = 1; i <= 1000000; i++) {
    if (is_prime[i] == 1) {
      prime.insert(i);
    }
  }
  int N;
  cin >> N;
  vector<int> A(N);
  int GCD = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0) {
      GCD = A[i];
    }
    int X = A[i];
    for (int j : prime) {
      if (j * j > A[i]) {
        break;
      }
      if (X % j == 0) {
        cnt[j]++;
        while (X % j == 0) {
          X /= j;
        }
      }
    }
    if (X >= 2) {
      cnt[X]++;
    }
    GCD = gcd(GCD, A[i]);
  }
  bool ok = true;
  for (int i = 1; i <= 1000000; i++) {
    if (cnt[i] >= 2) {
      ok = false;
    }
  }
  if (ok) {
    cout << "pairwise coprime" << endl;
  } else if (GCD == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (long long i = 2; i <= n; ++i) {
      if (f[i])
        continue;
      primes.push_back(i);
      f[i] = i;
      for (long long j = i * i; j <= n; j += i) {
        if (!f[j])
          f[j] = i;
      }
    }
  }

  bool isPrime(int x) { return f[x] == x; }

  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<pair<int, int>> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0)
      return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  Sieve s(1000001);

  ll all = gcd(a[0], a[1]);
  rep(i, n) all = gcd(all, a[i]);

  bool pc = true;
  map<int, int> mp;
  rep(i, n) {
    auto f = s.factor(a[i]);

    for (auto x : f) {
      if (x.first == 1)
        continue;
      mp[x.first]++;
      if (mp[x.first] > 1) {
        pc = false;
        break;
      }
    }
    if (!pc)
      break;
  }

  if (pc) {
    cout << "pairwise coprime" << endl;
  } else if (!pc && all == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(a.rbegin(), a.rend());

  ll all = gcd(a[0], a[1]);
  rep(i, n) all = gcd(all, a[i]);

  bool pc = true;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (gcd(a[i], a[j]) != 1) {
        pc = false;
        break;
      }
    }
    if (!pc)
      break;
  }

  if (pc) {
    cout << "pairwise coprime" << endl;
  } else if (!pc && all == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int main() {
  int n;
  int allgcd;
  bool pairwise = true;

  vector<bool> st(1000005); // 素因数
  vector<bool> sosu(1000005);

  for (int i = 2; i < 1000001; i++) {
    bool flag = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0)
        flag = false;
    }
    if (flag)
      sosu[i] = true;
  }

  cin >> n;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    // setwiseの判定
    if (i == 0)
      allgcd = tmp;
    else
      allgcd = gcd(allgcd, tmp);
    // pairwiseの判定
    if (tmp == 1)
      continue;
    if (pairwise) {
      if (sosu[tmp] == true) {
        if (st[tmp] == true)
          pairwise = false;
        else
          st[tmp] = true;
      } else {
        for (int a = 2; a * a <= tmp; a++) {
          if (tmp % a != 0)
            continue;
          while (tmp % a == 0) {
            tmp /= a;
          }
          // cout << "[" << a << "]";
          if (st[a] == true)
            pairwise = false;
          else
            st[a] = true;
          if (tmp > 2) {
            // cout << "[" << tmp << "]";
            if (st[tmp] == true)
              pairwise = false;
            else
              st[tmp] = true;
          }
        }
      }
    }
  }

  if (pairwise)
    cout << "pairwise coprime";
  else if (allgcd == 1)
    cout << "setwise coprime";
  else
    cout << "not coprime";

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int main() {
  int n;
  int allgcd;
  bool pairwise = true;

  vector<bool> st(100005); // 素因数分解した数をつっこむ
  vector<bool> sosu(1000005);

  for (int i = 2; i < 1000000; i++) {
    bool flag = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0)
        flag = false;
    }
    if (flag)
      sosu[i] = true;
  }

  cin >> n;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    // setwiseの判定
    if (i == 0)
      allgcd = tmp;
    else
      allgcd = gcd(allgcd, tmp);
    // pairwiseの判定
    if (sosu[tmp] == true) {
      if (st[tmp] == true)
        pairwise = false;
      else
        st[tmp] = true;
    } else {
      for (int a = 2; a * a <= tmp; a++) {
        if (tmp % a != 0)
          continue;
        while (tmp % a == 0) {
          tmp /= a;
        }
        if (st[a] == true)
          pairwise = false;
        else
          st[a] = true;
      }
    }
  }

  if (pairwise)
    cout << "pairwise coprime";
  else if (allgcd == 1)
    cout << "setwise coprime";
  else
    cout << "not coprime";

  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
const int N = 2e6;

#define Maxn 1000000

int n, a[N], vis[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]), vis[a[i]] += 1;
  int A = 1, B = 0;
  for (int j = 2; j <= Maxn; ++j) {
    int num = j, tmp = 0;
    for (int i = num; i <= Maxn; i += num)
      if (vis[i])
        tmp += vis[i];
    if (tmp > 1)
      B = 1;
    if (tmp == n)
      A = 0;
  }
  if (A == 0)
    puts("not coprime");
  else if (B == 1)
    puts("setwise coprime");
  else
    puts("pairwise coprime");
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
const int N = 2e6;

#define Maxn 1000000

int n, a[N], prime[N], pcnt;
bool not_prime[N];

void make_table() {
  not_prime[1] = true;
  for (int i = 2; i <= Maxn; ++i) {
    if (!not_prime[i])
      prime[++pcnt] = i;
    for (int j = 1; j <= pcnt; ++j) {
      if (i * prime[j] > Maxn)
        break;
      not_prime[i * prime[j]] = true;
      if (i % prime[j] == 0)
        break;
    }
  }
}

int main() {
  make_table();
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  int A = 1, B = 0;
  for (int j = 1; j <= pcnt; ++j) {
    int num = prime[j], tmp = 0;
    for (int i = 1; i <= n; ++i)
      if (a[i] % num == 0)
        tmp++;
    if (tmp > 1)
      B = 1;
    if (tmp == n)
      A = 0;
  }
  if (A == 0)
    puts("not coprime");
  else if (B == 1)
    puts("setwise coprime");
  else
    puts("pairwise coprime");
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007 // 1e9+7
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
set<int> prime_find(int n) {
  vector<bool> v(n + 1, 1);
  set<int> p;
  int k = 2;
  while (k * k <= n) {
    if (v[k])
      for (int i = k * k; i <= n; i += k)
        v[i] = 0;
    k++;
  }
  for (int i = 2; i <= n; i++)
    if (v[i])
      p.insert(i);
  return p;
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &v[i]);
  set<int> p = prime_find(1e7);
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int k = v[i];
    for (set<int>::iterator it = p.begin(); (*it) * (*it) <= k && it != p.end();
         it++) {
      int x = *it;
      if (k % x == 0) {
        while (k % x == 0)
          k /= x;
        mp[x]++;
      }
    }
    if (k != 1)
      mp[k]++;
  }
  int ans = 0;
  for (set<int>::iterator it = p.begin(); it != p.end(); it++) {
    ans = max(mp[*it], ans);
  }
  if (ans <= 1)
    cout << "pairwise coprime" << endl;
  else if (ans < n)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, a[1000005];
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
ll lcm(ll x, ll y, ll g) { return x / gcd(x, y) * y; }
ll l[1000005], ls;
bool hsh[1000005];
int main() {
  cin >> n;
  bool flag = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    // if(hsh[a[i]])flag=0;
    // else hsh[a[i]]=1;
  }
  ls = 0;
  l[0] = 1;
  ll mx = 1e6 / 2 + 3;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= ls; j++) {
      if (gcd(l[j], a[i]) != 1) {
        flag = 0;
        break;
      }
    }
    if (!flag)
      break;
    int gc = gcd(a[i], l[ls]);
    if (gc < mx)
      l[ls] = lcm(a[i], l[ls], gc);
    if (l[ls] > 1e11) {
      ls++;
      l[ls] = 1;
    }
  }
  if (flag) {
    cout << "pairwise coprime";
    return 0;
  }
  ll g = a[1];
  for (int i = 2; i <= n; i++) {
    g = gcd(g, a[i]);
  }
  if (g == 1)
    cout << "setwise coprime";
  else
    cout << "not coprime";
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

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

vector<int> prime;
int cnt[1000001];

void eratos(void) {
  bool isprime[1000001];
  memset(isprime, true, sizeof(isprime));
  for (int i = 2; i <= 1000; i++) {
    if (isprime[i]) {
      prime.push_back(i);
      for (int j = 2 * i; j <= 1000000; j += i) {
        isprime[j] = false;
      }
    }
  }
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, t;
  vector<int> v;
  int g = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    v.push_back(t);
  }

  for (int i = 0; i < n; i++) {
    g = gcd(g, v[i]);
  }

  if (g != 1) {
    cout << "not coprime" << '\\n';
    return 0;
  }

  memset(cnt, 0, sizeof(cnt));
  eratos();

  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    long long int x = v[i];
    for (int j = 0; j < prime.size(); j++) {
      if (x == 1 || x < prime[j] * prime[j]) {
        // cout << x << ' ' << prime[j] << '\\n';
        break;
      }
      if (x % prime[j] == 0) {
        if (cnt[prime[j]] > 0) {
          cout << "setwise coprime" << '\\n';
          return 0;
        }
        cnt[prime[j]]++;
        while (1) {
          if (x % prime[j] != 0) {
            break;
          }
          x /= prime[j];
        }
        // cout << prime[j] << ' ' << x << '\\n';
      }
    }
    if (x > 1) {
      if (cnt[x] > 0) {
        cout << "setwise coprime" << '\\n';
        return 0;
      }
      cnt[x]++;
    }
  }
  cout << "pairwise coprime" << '\\n';
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

vector<int> prime;
int cnt[1000001];

void eratos(void) {
  bool isprime[1000001];
  memset(isprime, true, sizeof(isprime));
  for (int i = 2; i <= 1000000; i++) {
    if (isprime[i]) {
      prime.push_back(i);
      for (int j = 2 * i; j <= 1000000; j += i) {
        isprime[j] = false;
      }
    }
  }
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, t;
  vector<int> v;
  int g = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    v.push_back(t);
  }

  for (int i = 0; i < n; i++) {
    g = gcd(g, v[i]);
  }

  if (g != 1) {
    cout << "not coprime" << '\\n';
    return 0;
  }

  eratos();

  sort(v.begin(), v.end());
  for (int i = 0; i < prime.size(); i++) {
    for (int j = 0; j < v.size(); j++) {
      if (v[j] % prime[i] == 0) {
        if (cnt[prime[i]] > 0) {
          cout << "setwise coprime" << '\\n';
          return 0;
        }
        cnt[prime[i]]++;
      }
    }
  }
  cout << "pairwise coprime" << '\\n';
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int a[1000005];
int cnt[1000005];
bool p[1000005];

int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  for (int i = 2; i <= 1000000; i++)
    p[i] = true;
  for (int i = 2; i <= 1000000; i++) {
    if (p[i]) {
      for (int j = 2 * i; j <= 1000000; j += i)
        p[j] = false;
    }
  }
  vector<int> pr;
  for (int i = 0; i < n; i++) {
    for (int j = 2; j <= sqrt(a[i]); j++) {
      if (!p[j])
        continue;
      if (a[i] % j == 0) {
        while (a[i] % j == 0)
          a[i] /= j;
        cnt[j]++;
      }
    }
    if (a[i] != 1)
      cnt[a[i]]++;
  }
  bool ok = false;
  for (int i = 2; i <= 1000000; i++) {
    if (!p[i])
      continue;
    if (cnt[i] == n) {
      cout << "not coprime" << endl;
      return 0;
    }
    if (cnt[i] >= 2) {
      ok = true;
    }
  }
  if (ok)
    cout << "setwise coprime" << endl;
  else
    cout << "pairwise coprime" << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int a[1000005];
bool p[1000005];

int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  for (int i = 2; i <= 1000000; i++)
    p[i] = true;
  for (int i = 2; i <= 1000000; i++) {
    if (p[i]) {
      for (int j = 2 * i; j <= 1000000; j += i)
        p[j] = false;
    }
  }
  vector<int> pr;
  for (int i = 2; i <= 1000000; i++)
    if (p[i])
      pr.pb(i);
  bool ok = false;
  for (int p : pr) {
    bool tmp = true;
    for (int i = 0; i < n; i++) {
      if (a[i] % p != 0) {
        tmp = false;
        break;
      }
    }
    if (tmp) {
      ok = true;
      break;
    }
  }
  if (ok) {
    cout << "not coprime" << endl;
    return 0;
  }
  for (int p : pr) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] % p == 0) {
        cnt++;
      }
    }
    if (cnt > 1) {
      cout << "setwise coprime" << endl;
      return 0;
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int arr[1000001];

vector<int> vis(1000001, 0);

int main() {
  int n;
  cin >> n;
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mx = max(mx, arr[i]);
  }
  bool flag = false;
  for (int i = 0; i < n; i++) {
    int m = arr[i];
    for (int j = 1; j <= sqrt(m); j++) {
      if (m % j == 0) {
        vis[j]++;
        if (vis[i] > 1 && i != 1) {
          flag = true;
          break;
        }

        if (j != m / j) {
          vis[m / j]++;
          if (vis[m / j] > 1 && m / j != 1) {
            flag = true;
            break;
          }
        }
      }
    }
    if (flag == true) {
      break;
    }
  }

  if (flag == false) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int x = __gcd(arr[0], arr[1]);
  for (int i = 1; i < n; i++) {
    x = __gcd(x, arr[i]);
  }
  if (x == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int arr[1000001];

vector<int> vis(1000001, 0);

int main() {
  int n;
  cin >> n;
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mx = max(mx, arr[i]);
  }
  bool flag = false;
  for (int i = 0; i < n; i++) {
    int m = arr[i];
    for (int j = 1; j <= sqrt(m); j++) {
      if (m % j == 0) {
        vis[j]++;
        if (j != m / j) {
          vis[m / j]++;
        }
      }
    }
  }
  for (int i = 2; i <= mx; i++) {
    if (vis[i] > 1) {
      flag = true;
      break;
    }
  }

  if (flag == false) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int x = __gcd(arr[0], arr[1]);
  for (int i = 1; i < n; i++) {
    x = __gcd(x, arr[i]);
  }
  if (x == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define fr(i, a, n) for (ll i = a; i < n; i++)
#define YES cout << "YES" << endl
#define all(v) v.begin(), v.end()
#define NO cout << "NO" << endl
#define pb(x) emplace_back(x)
#define fastio                                                                 \\
  std::ios_base::sync_with_stdio(false);                                       \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define vi vector<ll>
#define mi map<ll, ll>
#define pi pair<ll, ll>
#define what(x) cout << #x << " =" << x << endl;
using namespace std;
using ll = long long;

int main() {
  fastio;
  ll n;
  vector<ll> m(2000005);
  cin >> n;
  ll gcd = 0;
  ll p = 0;
  fr(i, 0, n) {
    ll x;
    cin >> x;

    gcd = __gcd(gcd, x);
    bool prime = true;
    // if(x%2==0)if(m[2]>=1)p=1;else m[2]++;
    for (ll k = 2; k * k <= x; k++) {
      if (x % k == 0) {
        prime = false;
        m[k]++;
        // what(m[k]);
        if (k != x / k)
          m[x / k]++;

        if (m[k] > 1 || m[x / k] > 1) {
          p = 1;
          break;
        }
      }
    }
    // what(x);
    if (prime && x != 1) {
      m[x]++;
      if (m[x] > 1) {
        p = 1;
      }
    }
  }

  if (p == 0)
    cout << "pairwise coprime" << endl;
  else if (gcd == 1)
    cout << "setwise coprime" << endl;

  else
    cout << "not coprime" << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define fr(i, a, n) for (ll i = a; i < n; i++)
#define YES cout << "YES" << endl
#define all(v) v.begin(), v.end()
#define NO cout << "NO" << endl
#define pb(x) emplace_back(x)
#define fastio                                                                 \\
  std::ios_base::sync_with_stdio(false);                                       \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define vi vector<ll>
#define mi map<ll, ll>
#define pi pair<ll, ll>
#define what(x) cout << #x << " =" << x << endl;
using namespace std;
using ll = long long;

vector<ll> m(200005);
int main() {
  fastio;
  ll n;

  cin >> n;
  ll gcd = 0;
  ll p = 0;
  fr(i, 0, n) {
    ll x;
    cin >> x;

    gcd = __gcd(gcd, x);
    // if(x%2==0)if(m[2]>=1)p=1;else m[2]++;
    for (ll k = 2; k * k <= x; k++) {
      if (x % k == 0) {
        m[k]++;
        if (k != x / k)
          m[x / k]++;
      }

      if (m[k] > 1 || m[x / k] > 1) {
        p = 1;
        break;
      }
    }
  }

  if (p == 0)
    cout << "pairwise coprime" << endl;
  else if (gcd == 1)
    cout << "setwise coprime" << endl;

  else
    cout << "not coprime" << endl;
}