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

#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x) {
  std::cout << x << " ";
}

template <typename T>

void println(T x) {
  std::cout << x << "\\n";
}

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

signed main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  bool pairwise = true;

  set<int> div;
  rep(i, n) {
    if (!pairwise)
      break;
    for (int j = 1; j * j <= a[i]; ++j) {
      if (a[i] % j == 0) {
        auto it = div.find(j);
        if (it != div.end())
          pairwise = false;
        if (j != 1)
          div.insert(j);
        if (a[i] / j != j) {
          auto it2 = div.find(a[i] / j);
          if (it2 != div.end())
            pairwise = false;
          if (a[i] / j != 1)
            div.insert(a[i] / j);
        }
      }
    }
  }

  if (pairwise) {
    print("pairwise coprime");
    return 0;
  }
  int pairgcd = a[0];
  rep1(i, n) { pairgcd = gcd(pairgcd, a[i]); }
  if (pairgcd == 1) {
    print("setwise coprime");
    return 0;
  } else
    print("not coprime");
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x) {
  std::cout << x << " ";
}

template <typename T>

void println(T x) {
  std::cout << x << "\\n";
}

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

signed main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  bool pairwise = true;
  rep(i, n - 1) {
    FOR(j, i + 1, n) {
      if (gcd(a[i], a[j]) != 1)
        pairwise = false;
    }
  }
  if (pairwise) {
    print("pairwise coprime");
    return 0;
  }
  int pairgcd = a[0];
  rep1(i, n) { pairgcd = gcd(pairgcd, a[i]); }
  if (pairgcd == 1) {
    print("setwise coprime");
    return 0;
  } else
    print("not coprime");
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
// #define int long long

using namespace std;

const int N = 1e6 + 9;
vector<int> prime;
bool used[N];

void calc() {
  for (int i = 4; i < N; i += 2)
    used[i] = 1;
  for (int i = 3; i * i < N; i += 2) {
    if (used[i])
      continue;
    for (int j = i * i; j < N; j += i)
      used[j] = 1;
  }
  prime.push_back(2);
  for (int i = 3; i < N; i += 2) {
    if (!used[i])
      prime.push_back(i);
  }
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int data[n];
  for (int i = 0; i < n; ++i)
    cin >> data[i];
  calc();
  vector<int> cnt(N, 0);
  int fl = 1;
  for (int i = 0; i < n; ++i) {
    int tmp = data[i];
    for (auto a : prime) {
      if (a * a > tmp)
        break;
      if (tmp % a == 0) {
        ++cnt[a];
        while (tmp % a == 0)
          tmp /= a;
      }
    }
    if (tmp > 1)
      ++cnt[tmp];
  }
  for (int i = 0; i < N; ++i) {
    if (cnt[i] > 1)
      fl = 0;
  }
  if (fl) {
    cout << "pairwise coprime";
    return 0;
  }
  int b = data[0];
  for (int i = 1; i < n; ++i)
    b = __gcd(b, data[i]);
  if (b == 1) {
    cout << "setwise coprime";
    return 0;
  }
  cout << "not coprime";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<int> prime;
  prime.push_back(2);
  vector<bool> check(500005, 0);
  check[2] = 1;
  for (int i = 3; i <= 500000; ++i) {
    if (check[i] == 1)
      continue;
    else {
      prime.push_back(i);
      if (i * i <= 500000) {
        for (int j = i * i; j <= 500000; j += i)
          check[j] = 1;
      }
    }
  }
  int n;
  cin >> n;
  int data[n];
  for (int i = 0; i < n; ++i)
    cin >> data[i];
  int fl = 1;
  int fl2 = 1;
  vector<int> used(1000001, 0);
  for (int i = 0; i < n && fl; ++i) {
    for (int j = 0; j < ((prime.size())); ++j) {
      if (fl == 0)
        break;
      if (data[i] % prime[j] == 0) {
        if (used[prime[j]] != 0) {
          fl = 0;
        }
        used[prime[j]] += 1;
        if (used[prime[j]] >= n) {
          fl2 = 0;
        }
      }
    }
  }
  if (fl2 == 1) {
    int a;
    a = data[0];
    for (int i = 1; i < n; ++i)
      a = __gcd(a, data[i]);
    if (a != 1)
      fl2 = 0;
  }
  if (fl)
    cout << "pairwise coprime";
  else if (fl2)
    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 n;
int a[1000010];
vector<int> v;
bool flag[1000010];
map<int, bool> mp;
int main() {
  cin >> n;
  flag[0] = 1;
  flag[1] = 1;
  for (int i = 2; i <= 1000000; i++) {
    if (!flag[i]) {
      v.push_back(i);
      for (int j = i + i; j <= 1000000; j += i) {
        flag[j] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int gcd = a[0];
  for (int i = 1; i < n; i++) {
    gcd = __gcd(gcd, a[i]);
  }
  if (gcd != 1) {
    cout << "not coprime" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    int x = 0;
    while (a[i] > 1) {
      if (!flag[a[i]]) {
        if (mp[a[i]]) {
          cout << "setwise coprime" << endl;
          return 0;
        }
        mp[a[i]] = 1;
        break;
      }
      while (x < v.size() && a[i] % v[x] != 0) {
        x++;
      }
      if (mp[v[x]]) {
        cout << "setwise coprime" << endl;
        return 0;
      }
      mp[v[x]] = 1;
      while (a[i] % v[x] == 0) {
        a[i] /= v[x];
      }
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;
}

Error: TLE

Fixed submission:

#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000010];
vector<int> v;
bool flag[1000010];
map<int, bool> mp;
int main() {
  cin >> n;
  flag[0] = 1;
  flag[1] = 1;
  for (int i = 2; i <= 1000000; i++) {
    if (!flag[i]) {
      v.push_back(i);
      for (int j = i + i; j <= 1000000; j += i) {
        flag[j] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int gcd = a[0];
  for (int i = 1; i < n; i++) {
    gcd = __gcd(gcd, a[i]);
  }
  if (gcd != 1) {
    cout << "not coprime" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    int x = 0;
    while (a[i] > 1) {
      if (flag[a[i]]) {
        if (mp[a[i]]) {
          cout << "setwise coprime" << endl;
          return 0;
        }
        mp[a[i]] = 1;
      }
      while (x < v.size() && a[i] % v[x] != 0) {
        x++;
      }
      if (x >= v.size()) {
        cout << "setwise coprime" << endl;
        return 0;
      }
      if (mp[v[x]]) {
        cout << "setwise coprime" << endl;
        return 0;
      }
      mp[v[x]] = 1;
      while (a[i] % v[x] == 0) {
        a[i] /= v[x];
      }
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

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

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];

  vector<bool> IsPrime(1000100, true);
  vector<int> D(1000100, 1);
  IsPrime.at(0) = false;
  IsPrime.at(1) = false;
  for (int i = 2; i <= 1000000; i++) {
    if (IsPrime.at(i) == true) {
      D[i] = i;
      for (int j = 2; i * j <= 1000000; j++) {
        IsPrime.at(i * j) = false;
        D[i * j] = i;
      }
    }
  }

  bool fg1 = 1;
  bool fg2 = 1;
  set<int> fac;
  for (int i = 0; i < N; i++) {
    int B = A[i];
    set<int> Afac;
    while (D[B] != B) {
      Afac.insert(D[B]);
      B /= D[B];
    }
    Afac.insert(B);
    for (auto m : Afac) {
      if (fac.count(m))
        fg1 = 0;
      if (m != 1)
        fac.insert(m);
    }
    if (fg1 == 0)
      break;
  }

  int G = gcd(A[0], A[1]);
  for (int i = 2; i < N; i++) {
    G = gcd(G, A[i]);
  }
  if (G != 1)
    fg2 = 0;

  if (fg1)
    cout << "pairwise coprime" << endl;
  else if (fg2)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

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

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];

  vector<bool> IsPrime(1000100, true);
  vector<int> D(1000100, 0);
  IsPrime.at(0) = false;
  IsPrime.at(1) = false;
  for (int i = 2; i <= 1000000; i++) {
    if (IsPrime.at(i) == true) {
      D[i] = i;
      for (int j = 2; i * j <= 1000000; j++) {
        IsPrime.at(i * j) = false;
        D[i * j] = i;
      }
    }
  }

  bool fg1 = 1;
  bool fg2 = 1;
  set<int> fac;
  for (int i = 0; i < N; i++) {
    int B = A[i];
    while (D[B] != B) {
      if (fac.count(D[B]))
        fg1 = 0;
      fac.insert(D[B]);
      B /= D[B];
    }
    if (fg1 == 0)
      break;
  }

  int G = gcd(A[0], A[1]);
  for (int i = 2; i < N; i++) {
    G = gcd(G, A[i]);
  }
  if (G != 1)
    fg2 = 0;

  if (fg1)
    cout << "pairwise coprime" << endl;
  else if (fg2)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
int a[1000005];
bool v[1000005];

int main() {
  int n;
  cin >> n;
  bool pair = false;
  int num;
  for (int i = 0; i < n; ++i) {
    cin >> num;
    ++a[num];
  }
  for (int i = 2; i <= 1000000; ++i)
    if (!v[i]) {
      int t = 0;
      for (int j = 1; j * i <= 1000000; ++j) {
        t += a[j * i];
        v[j * i] = true;
      }
      if (t == n) {
        cout << "not coprime\\n";
        return 0;
      } else if (t >= 2)
        pair = true;
    }

  if (pair)
    cout << "setwise coprime\\n";
  else
    cout << "pairwise coprime\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
int a[1000005];

int main() {
  int n;
  cin >> n;
  bool set = false, pair = false;
  int num;
  for (int i = 0; i < n; ++i) {
    cin >> num;
    for (int j = 2; j <= num / 2; ++j) {
      if (num % j == 0) {
        ++a[j];
        while (num >= j) {
          if (num % j == 0)
            num /= j;
          else
            break;
        }
      }
    }
    ++a[num];
  }
  for (int i = 2; i <= 1000000; ++i)
    if (a[i] == n) {
      cout << "not coprime\\n";
      return 0;
    } else if (a[i] >= 2)
      pair = true;
  if (pair)
    cout << "setwise coprime\\n";
  else
    cout << "pairwise coprime\\n";
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void pf(int n, vector<int> &v) {
  int p = 2;
  while (p * p <= n) {
    if (n % p != 0) {
      p++;
      continue;
    }
    v.push_back(p);
    while (n % p == 0)
      n /= p;
  }
  if (n != 1)
    v.push_back(n);
}

int main(void) {
  int N;
  cin >> N;

  vector<int> c(1'000'000);

  rep(i, N) {
    int a;
    cin >> a;
    vector<int> v;
    pf(a, v);
    for (int p : v)
      c[p]++;
  }

  bool pc = true;
  bool sc = true;
  rep(i, 1'000'000) {
    if (c[i] < 2)
      continue;
    pc = false;
    if (c[i] == N) {
      sc = false;
      break;
    }
  }

  if (pc)
    cout << "pairwise coprime" << endl;
  else if (sc)
    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 < (n); i++)
using ll = long long;
using namespace std;

int main(void) {
  int N;
  cin >> N;

  vector<int> c(1'000'000);

  rep(i, N) {
    int a;
    cin >> a;
    if (a < 2)
      continue;
    int p = 2;
    while (a > 1) {
      if (a % p != 0) {
        p++;
        continue;
      }
      c[p]++;
      while (a % p == 0)
        a /= p;
    }
  }

  bool pc = true;
  bool sc = true;
  rep(i, 1'000'000) {
    if (c[i] < 2)
      continue;
    pc = false;
    if (c[i] == N) {
      sc = false;
      break;
    }
  }

  if (pc)
    cout << "pairwise coprime" << endl;
  else if (sc)
    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;

#define pb push_back
#define ll long long
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define bug cout << "ok" << endl

const ll INF = 1e9 + 5, N = 1e6 + 5, mod = 1e9 + 7, M = 1e5 + 5;

ll d[N + 5];

ll pairwise[N + 5], a[N + 5];

int main() {
  for (int i = 2; i <= N; i++) {
    if (!d[i]) {
      d[i] = i;
      if (i * 1ll * i <= N) {
        for (int j = i * i; j <= N; j += i) {
          if (d[j] > 0)
            continue;
          d[j] = i;
        }
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    int x = a[i];
    while (x > 1) {
      pairwise[d[x]]++;
      int l = d[x];
      do {
        x /= l;
      } while (x % l == 0);
    }
    if (x > 1)
      pairwise[x]++;
  }
  bool q1 = true, q2 = true;
  for (int i = 1; i <= N; i++) {
    if (pairwise[i] > 1)
      q1 = false;
    if (pairwise[i] == n)
      q2 = false;
  }
  if (q1) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  if (q2) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
}

Error: -8

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define ll long long
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define bug cout << "ok" << endl

const ll INF = 1e9 + 5, N = 1e6 + 5, mod = 1e9 + 7, M = 1e5 + 5;

ll d[N + 5];

ll pairwise[N + 5], a[N];

int main() {
  for (int i = 2; i <= N; i++) {
    if (!d[i]) {
      d[i] = i;
      if (i * 1ll * i <= N) {
        for (int j = i * i; j <= N; j += i) {
          if (d[j] > 0)
            continue;
          d[j] = i;
        }
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    int x = a[i];
    while (x > 1) {
      pairwise[d[x]]++;
      x /= d[x];
      int l = d[x];
      do {
        x /= l;
      } while (x % l == 0);
    }
    if (x > 1)
      pairwise[x]++;
  }
  bool q1 = true, q2 = true;
  for (int i = 1; i <= N; i++) {
    if (pairwise[i] > 1)
      q1 = false;
    if (pairwise[i] == n)
      q2 = false;
  }
  if (q1) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  if (q2) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 3;
int num[N];
int main() {
  int n, x;
  cin >> n;
  int z = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    num[x]++;
    z = __gcd(z, x);
  }
  if (z != 1) {
    cout << "not coprime" << endl;
    return 0;
  }

  for (int i = 2; i < N; i++) {
    int cnt = 0;
    for (int j = i; j < N; j += i) {
      cnt += num[j];
    }
    if (cnt > 1) {
      cout << "setwise coprime" << endl;
      return 0;
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 3;
int num[N];
int main() {
  int n, x;
  cin >> n;
  int z = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    num[x]++;
    z = __gcd(z, x);
  }
  if (z != 1) {
    cout << "not coprime" << endl;
    return 0;
  }
  for (int i = 1; i <= N; i++) {
    int cnt = 0;
    if (num[i]) {
      for (int j = i; j <= N; j += i) {
        cnt += num[j];
      }
      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>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const int mxN = 1000010;

int spf[mxN];

void sieve() {
  spf[1] = 1;
  for (int i = 2; i < mxN; i++) {
    spf[i] = i;
  }
  for (int i = 4; i < mxN; i += 2) {
    spf[i] = 2;
  }
  for (int i = 3; i * i < mxN; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < mxN; j += i) {
        if (spf[j] == j)
          spf[j] = i;
      }
    }
  }
}

set<int> getFactorization(int n) {
  set<int> res;
  while (n != 1) {
    res.emplace(spf[n]);
    n = n / spf[n];
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  sieve();
  int n;
  cin >> n;
  vector<int> cnt(mxN, 0);
  rep(_, n) {
    int a;
    cin >> a;
    auto f = getFactorization(a);
    for (auto &&e : f) {
      cnt[e]++;
    }
  }
  bool pc = true, sc = true;
  rep(i, mxN) {
    if (cnt[i] > 1)
      pc = false;
    if (cnt[i] == n)
      sc = false;
  }
  if (pc) {
    cout << "pairwise coprime";
  } else if (sc) {
    cout << "setwise coprime";
  } else {
    cout << "not coprime";
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const int mxN = 1000010;

int spf[mxN];

void sieve() {
  spf[1] = 1;
  for (int i = 2; i < mxN; i++) {
    spf[i] = i;
  }
  for (int i = 4; i < mxN; i += 2) {
    spf[i] = 2;
  }
  for (int i = 3; i * i < mxN; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < mxN; j += i) {
        if (spf[j] == j)
          spf[j] = i;
      }
    }
  }
}

vector<int> getFactorization(int n) {
  vector<int> res;
  while (n != 1) {
    res.emplace_back(spf[n]);
    n = n / spf[n];
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  sieve();
  int n;
  cin >> n;
  vector<int> cnt(mxN, 0);
  rep(_, n) {
    int a;
    cin >> a;
    auto f = getFactorization(a);
    vector<bool> isCnt(mxN, true);
    for (auto &&e : f) {
      if (isCnt[e]) {
        cnt[e]++;
        isCnt[e] = false;
      }
    }
  }
  bool pc = true, sc = true;
  rep(i, mxN) {
    if (cnt[i] > 1)
      pc = false;
    if (cnt[i] == n)
      sc = false;
  }
  if (pc) {
    cout << "pairwise coprime";
  } else if (sc) {
    cout << "setwise coprime";
  } else {
    cout << "not coprime";
  }
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repa(i, s, n) for (int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i, a, b) for (int i = a; i >= b; i--)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const int A = 1000005;
signed main() {
  int n;
  cin >> n;
  vi a(n), c(A);
  rep(i, n) {
    cin >> a[i];
    c[a[i]]++;
  }

  bool pc = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) {
      pc = false;
    }
  }

  if (pc) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  rep(i, n) g = __gcd(g, a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

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

Error: 0

Fixed submission:

#include <bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repa(i, s, n) for (int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i, a, b) for (int i = a; i >= b; i--)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const int A = 100005;
signed main() {
  int n;
  cin >> n;
  vi a(n), c(A);
  rep(i, n) {
    cin >> a[i];
    c[a[i]]++;
  }

  bool pc = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) {
      pc = false;
    }
  }

  if (pc) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  rep(i, n) g = __gcd(g, a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

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