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

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

inline map<ll, int> sieve(ll n) {
  map<ll, int> PrimeNumber;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      PrimeNumber[i]++;
      n /= i;
    }
  }
  if (n != 1)
    PrimeNumber[n] = 1;
  return PrimeNumber;
}

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int gcd = 0;
  map<int, int> mp;
  bool ok = true;
  rep(i, n) {
    int a;
    cin >> a;
    gcd = __gcd(gcd, a);
    auto res = sieve(a);
    for (auto x : res) {
      if (mp[x.first])
        ok = false;
      mp[x.first]++;
    }
  }
  if (gcd != 1) {
    cout << "not coprime";
    return 0;
  }
  if (ok) {
    cout << "pairwise coprime";
  } else {
    cout << "setwise coprime";
  }
  cout << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

inline map<ll, int> sieve(ll n) {
  map<ll, int> PrimeNumber;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      PrimeNumber[i]++;
      n /= i;
    }
  }
  if (n != 1)
    PrimeNumber[n] = 1;
  return PrimeNumber;
}

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  int gcd = 0;
  map<int, int> mp;
  bool ok = true;
  rep(i, n) {
    gcd = __gcd(gcd, a[i]);
    auto res = sieve(a[i]);
    for (auto x : res) {
      if (mp[x.first])
        ok = false;
      mp[x.first]++;
    }
  }
  if (gcd != 1) {
    cout << "not coprime";
    return 0;
  }
  if (ok) {
    cout << "pairwise coprime";
  } else {
    cout << "setwise coprime";
  }
  cout << "\\n";
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >> n;
  const int MAX = 1e6;
  int gcd = 0;
  vi cnt(MAX + 1);
  rep(i, n) {
    int a;
    cin >> a;
    gcd = __gcd(gcd, a);
    cnt[a]++;
  }
  if (gcd != 1) {
    cout << "not coprime";
    return 0;
  }
  bool ok = true;
  for (int i = 2; i <= MAX; i++) {
    int res = 0;
    for (int j = i; j <= MAX; j += i)
      res += cnt[j];
    if (1 < res)
      ok = false;
  }
  if (ok) {
    cout << "pairwise coprime";
  } else {
    cout << "setwise coprime";
  }
  cout << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

inline map<ll, int> sieve(ll n) {
  map<ll, int> PrimeNumber;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      PrimeNumber[i]++;
      n /= i;
    }
  }
  if (n != 1)
    PrimeNumber[n] = 1;
  return PrimeNumber;
}

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int gcd = 0;
  map<int, int> mp;
  bool ok = true;
  rep(i, n) {
    int a;
    cin >> a;
    gcd = __gcd(gcd, a);
    auto res = sieve(a);
    for (auto x : res) {
      if (mp[x.first])
        ok = false;
      mp[x.first]++;
    }
  }
  if (gcd != 1) {
    cout << "not coprime";
    return 0;
  }
  if (ok) {
    cout << "pairwise coprime";
  } else {
    cout << "setwise coprime";
  }
  cout << "\\n";
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma GCC optimize("Ofast")
#include <algorithm>
#include <stdio.h>
#include <vector>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
long long num[1000005], cnt[1000005] = {0}, cnt2[1000005] = {0};
bool prime[1000005] = {0}, check = 0;
vector<long long> all;
int main() {
  long long i, j, n;
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &num[i]);
    cnt[num[i]]++;
    if (cnt[num[i]] > 1 && num[i] != 1)
      check = 1;
  }
  long long v = num[0];
  for (i = 1; i < n; i++)
    v = GCD(v, num[i]);
  for (i = 2; i <= 1000000; i++) {
    if (!prime[i]) {
      all.emplace_back(i);
      for (j = i * i; j <= 1000000; j += i)
        prime[j] = 1;
    }
  }
  all.emplace_back(1000000001);
  if (v == 1) {
    if (check) {
      puts("setwise coprime");
      return 0;
    }
    for (i = 0; i < n && !check; i++) {
      for (auto x : all) {
        if (x * x > num[i])
          break;
        if (num[i] % x == 0)
          cnt2[x]++;
        while (num[i] % x == 0)
          num[i] /= x;
        if (cnt2[x] >= 2)
          check = 1;
      }
      long long id = lower_bound(all.begin(), all.end(), num[i]) - all.begin();
      if (all[id] == num[i]) {
        cnt2[num[i]]++;
        if (cnt2[num[i]] >= 2)
          check = 1;
      }
    }
    if (check)
      puts("setwise coprime");
    else
      puts("pairwise coprime");
  } else
    puts("not coprime");
}


Error: TLE

Fixed submission:

#pragma GCC optimize("Ofast")
#include <algorithm>
#include <stdio.h>
#include <vector>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
long long num[1000005], cnt[1000005] = {0}, cnt2[1000005] = {0};
bool prime[1000005] = {0}, check = 0;
vector<long long> all;
int main() {
  long long i, j, n;
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &num[i]);
    cnt[num[i]]++;
    if (cnt[num[i]] > 1 && num[i] != 1)
      check = 1;
  }
  long long v = num[0];
  for (i = 1; i < n; i++)
    v = GCD(v, num[i]);
  for (i = 2; i <= 1000000; i++) {
    if (!prime[i]) {
      all.emplace_back(i);
      for (j = i * i; j <= 1000000; j += i)
        prime[j] = 1;
    }
  }
  all.emplace_back(1000000001);
  if (v == 1) {
    if (check) {
      puts("setwise coprime");
      return 0;
    }
    for (i = 0; i < n && !check; i++) {
      for (auto x : all) {
        if (x > num[i])
          break;
        if (num[i] % x == 0)
          cnt2[x]++;
        while (num[i] % x == 0)
          num[i] /= x;
        if (cnt2[x] >= 2)
          check = 1;
      }
    }
    if (check)
      puts("setwise coprime");
    else
      puts("pairwise coprime");
  } else
    puts("not coprime");
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

// hail to jwalaji
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  // cout<<"good 1: "<<endl;
  vector<int> arr[1000002];
  for (lli i = 2; i < 1000002; i++) {
    if (arr[i].size() == 0) {
      lli k = i;
      while (k < 1000002) {
        arr[k].push_back(i);
        k += i;
      }
    }
  }
  // cout<<"good 2: "<<endl;
  vector<lli> coun(1000002, 0);
  lli n, maxa = 0;
  cin >> n;
  for (lli i = 0; i < n; i++) {
    lli a;
    cin >> a;
    for (auto &k : arr[a]) {
      coun[k]++;
      if (coun[k] > maxa) {
        maxa = coun[k];
      }
    }
  }
  if (maxa >= n) {
    cout << "not coprime" << endl;
  } else if (maxa == 1 || maxa == 0) {
    cout << "pairwise coprime" << endl;
  } else {
    cout << "setwise coprime" << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

// hail to jwalaji
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int lli;
bool prime[1000005];
vector<lli> primes;
bool factorize(vector<lli> a) {
  for (lli i = 0; i < a.size(); ++i) {
    // cout<<"a[i] : "<<a[i]<<endl;
    lli start = 0;
    while (a[i] > 1) {
      if (start >= primes.size()) {
        primes.push_back(a[i]);
        // cout<<"primes : "<<a[i]<<endl;
        prime[a[i]] = 1;
        break;
      }
      if ((a[i] % primes[start]) == 0) {
        if (prime[primes[start]] == 1) {
          return false;
        }
        while ((a[i] % primes[start]) == 0 && a[i] > 1) {
          a[i] = a[i] / primes[start];
          // cout<<"primes : "<<primes[start]<<endl;
        }
        prime[primes[start]] = 1;
      }
      start++;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  prime[0] = 1;
  prime[1] = 1;
  for (lli i = 2; i < sqrt(100005); i++) {
    if (prime[i])
      continue;
    else {
      for (lli j = i; j * i < 100005; j++) {
        prime[i * j] = 1;
      }
    }
  }
  for (lli i = 0; i < 100005; i++) {
    if (!prime[i]) {
      primes.push_back(i);
    }
  }
  // for(lli i=0;i<100;i++){
  //      cout<<primes[i]<<" ";
  // }
  lli n;
  cin >> n;
  vector<lli> arr(n);
  for (lli i = 0; i < n; i++) {
    cin >> arr[i];
  }
  // bool pairwise=false,setwise=false;
  if (factorize(arr)) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  lli check = __gcd(arr[0], arr[1]);
  for (lli i = 2; i < arr.size(); ++i) {
    check = __gcd(check, arr[i]);
  }
  if (check == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
void sieve(vector<int> &x, int k) {

  for (int i = 1; i <= k; i++) {
    x[i] = i;
  }
  int i = 2;
  while (i < k) {
    if (x[i] == i) {
      for (int j = i; j <= k; j = j + i) {
        if (x[j] == j) {
          x[j] = i;
        }
      }
    }
    i++;
  }
}
set<int> prime(int k, vector<int> &x) {
  set<int> ans;
  while (k != 1) {
    ans.insert(x[k]);
    k = k / x[k];
  }
  return ans;
}

int main() {

  int n;
  cin >> n;
  vector<int> y;
  int m = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    y.pb(t);
    m = max(m, t);
  }
  vector<int> x(m + 1);
  sieve(x, m);
  map<int, int> ans;
  int flag = 0;
  /*for (int i = 0; i < x.size(); i++)
  {
      cout << x[i] << " ";
  }*/

  for (int i = 0; i < n; i++) {
    set<int> p = prime(y[i], x);
    for (auto t : p) {
      ans[t]++;
      if (ans[t] > 1) {
        flag = 1;
      }
      if (ans[t] == n) {
        flag = 2;
        break;
      }
    }
  }
  if (flag == 0) {
    cout << "pairwise coprime" << endl;
  } else if (flag == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
void sieve(vector<bool> &x, int k) {

  int i = 2;
  while (i < k) {
    if (x[i] == true) {

      int j = 2;
      while ((i * j) <= k) {
        x[i * j] = false;
        j++;
      }
    }
    i++;
  }
}

int main() {

  int n;
  cin >> n;
  vector<int> y;
  int m = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    y.pb(t);
    m = max(m, t);
  }
  vector<bool> x(m + 1, true);
  sieve(x, m);
  vector<int> pr;
  int ss = x.size();

  for (int i = 2; i < ss; i++) {
    if (x[i] == true) {
      pr.pb(i);
      // cout << i << " ";
    }
  }
  int e = pr.size();
  int flag = 0;
  vector<set<int>> s;
  map<int, int> w;
  for (int i = 0; i < n; i++) {
    set<int> r;
    int q = y[i];

    int j = 0;
    while (j < e && q > 0) {
      while (q % pr[j] == 0 && q > 0) {
        q = q / pr[j];
        r.emplace(pr[j]);
      }
      j++;
    }
    s.pb(r);
  }
  int count = 0;

  for (int i = 0; i < s.size(); i++) {
    for (auto t : s[i]) {
      w[t]++;
    }
  }
  int u = s.size();
  for (auto t : w) {
    if (t.second == u) {
      flag = 2;
      break;
    } else if (t.second > 1) {
      flag = 1;
    }
  }

  if (flag == 0) {
    cout << "pairwise coprime" << endl;
  } else if (flag == 1) {
    cout << "setwise coprime" << endl;
  } else if (flag == 2) {
    cout << "not coprime" << endl;
  }
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

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

vector<int> divs[1000005];
int cnt[1000005];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  for (int i = 2; i <= 1000000; ++i) {
    for (int m = i; m <= 1000000; m += i) {
      divs[m].push_back(i);
    }
  }

  int N;
  cin >> N;
  vector<int> A(N);
  for (int &e : A)
    cin >> e;

  bool pair = 1;

  for (int i = 0; i < N; ++i) {
    for (int d : divs[A[i]]) {
      // cout << i << " " << d << endl;
      if (cnt[d] > 0) {
        pair = 0;
      }
      cnt[d]++;
    }
  }

  if (pair) {
    cout << "pairwise coprime" << endl;
  } else {
    for (int v = 1; v <= 1000000; ++v) {
      // cout << kv.first << " " << kv.second <<endl;
      if (cnt[v] == N) {
        cout << "not coprime" << endl;
        return 0;
      }
    }
    cout << "setwise coprime" << endl;
  }
}

Error: TLE

Fixed submission:

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

vector<int> divs[1000005];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  for (int i = 2; i <= 1000000; ++i) {
    for (int m = i; m <= 1000000; m += i) {
      divs[m].push_back(i);
    }
  }

  int N;
  cin >> N;
  vector<int> A(N);
  for (int &e : A)
    cin >> e;

  map<int, int> cnt;

  bool pair = 1;

  for (int i = 0; i < N; ++i) {
    for (int d : divs[A[i]]) {
      // cout << i << " " << d << endl;
      if (cnt[d] > 0) {
        pair = 0;
      }
      cnt[d]++;
    }
  }

  if (pair) {
    cout << "pairwise coprime" << endl;
  } else {
    for (auto &kv : cnt) {
      // cout << kv.first << " " << kv.second <<endl;
      if (kv.second == N) {
        cout << "not coprime" << endl;
        return 0;
      }
    }
    cout << "setwise coprime" << endl;
  }
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\\n'
#define fi first
#define se second
#define pi pair<ll, ll>
#define pii pair<ll, pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  vector<ll> v(n);
  const ll nax = 1e6 + 7;
  vector<ll> sieve(nax, 0);
  ll g = v[0];
  for (ll i = 0; i < n; i++) {
    cin >> v[i];
    sieve[v[i]]++;
    if (i >= 1)
      g = __gcd(g, v[i]);
  }
  int ans = 0;
  bool ok = false;
  for (ll i = 2; i < nax; i++) {
    ll cnt = 0;
    for (ll j = i; j < nax; j += i) {
      cnt += sieve[j];
    }
    if (cnt >= 2)
      ok = true;
    if (cnt >= n)
      ans++;
  }
  if (ans >= 1 && g != 1)
    cout << "not coprime" << endl;
  else {
    if (ans == 0 && ok)
      cout << "setwise coprime" << endl;
    else
      cout << "pairwise coprime" << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\\n'
#define fi first
#define se second
#define pi pair<ll, ll>
#define pii pair<ll, pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  unordered_map<ll, set<ll>> m;
  ll n;
  cin >> n;
  vector<ll> odd, even;
  vector<ll> v(n);
  bool ok = false, ok1 = false;
  for (ll i = 0; i < n; i++) {
    cin >> v[i];
    ll have = v[i];
    for (ll j = 2; j * j <= have; j++) {
      if (have % j == 0) {
        while (have % j == 0) {
          m[j].insert(i);
          have = have / j;
        }
      }
    }
    if (have > 1) {
      m[have].insert(i);
    }
  }
  for (auto k : m) {
    if (k.se.size() >= 2) {
      ok = true;
    }
    if (k.se.size() >= n) {
      ok1 = true;
    }
    if (ok && ok1)
      break;
  }
  if (!ok && !ok1)
    cout << "pairwise coprime" << endl;
  else {
    if (ok && !ok1)
      cout << "setwise coprime" << endl;
    else
      cout << "not coprime" << endl;
  }
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

int n;
int a[1000000], cnt[1000001];

int prime[1000];
bool is_prime[1001];

int sieve(int n) {
  int p = 0;
  for (int i = 0; i <= n; i++)
    is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = 2 * i; j <= n; j += i)
        is_prime[j] = false;
    }
  }
  return p;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);

  int p = sieve(1000);
  for (int i = 0; i < p; i++) {
    for (int j = 0; j < n; j++) {
      int pi = prime[i];
      if (a[j] % pi == 0)
        cnt[pi]++;
      while (a[j] % pi == 0)
        a[j] /= pi;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] > 1000)
      cnt[a[i]]++;
  }
  int ans = 0;
  for (int i = 2; i <= 1000000; i++) {
    if (cnt[i] > 1)
      ans = 1;
    if (cnt[i] == n) {
      ans = 2;
      break;
    }
  }

  if (ans == 0)
    printf("pairwise coprime\\n");
  if (ans == 1)
    printf("setwise coprime\\n");
  if (ans == 2)
    printf("not coprime\\n");
  return 0;
}


Error: TLE

Fixed submission:

#include <cstdio>

int n;
int a[1000000], cnt[1000001];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);

  for (int i = 2; i <= 1000; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j] % i == 0)
        cnt[i]++;
      while (a[j] % i == 0)
        a[j] /= i;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] > 1000)
      cnt[a[i]]++;
  }
  int ans = 0;
  for (int i = 2; i <= 1000000; i++) {
    if (cnt[i] > 1)
      ans = 1;
    if (cnt[i] == n) {
      ans = 2;
      break;
    }
  }

  if (ans == 0)
    printf("pairwise coprime\\n");
  if (ans == 1)
    printf("setwise coprime\\n");
  if (ans == 2)
    printf("not coprime\\n");
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int is_prime(int n) {

  int i;
  i = 2;

  if (n == 1) {
    return 0;

  } else if (n == 2) {
    return 1;

  } else {
    while (1) {
      if (n % i == 0) {
        return 0;

      } else if (n < i * i) {
        return 1;

      } else {
        i++;
      }
    }
  }

  return 0;
}

int gcd(int m, int n) {

  if (m % n == 0) {
    return n;
  } else {
    return gcd(n, m % n);
  }
}

int is_set(int b[1145140], int n) {

  int i;
  i = 2;

  if (n == 1)
    return 0;

  if (is_prime(n) == 1) {
    if (b[n] == 1) {
      return 1;
    } else {
      b[n] = 1;
    }

  } else {
    while (n % i > 0) {
      i++;
    }

    if (b[i] == 1) {
      return 1;

    } else {
      b[i] = 1;

      while (n % i == 0) {
        n /= i;
      }

      return is_set(b, n);
    }
  }

  return 0;
}

int main() {

  int i, N, GCD, D, set;
  cin >> N;

  int a[N];
  int b[1145140];

  for (i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (i = 0; i < 100; i++) {
    b[i] = 0;
  }

  for (i = 0; i < N; i++) {
    if (i == 0) {
      GCD = a[i];

    } else {
      D = gcd(GCD, a[i]);
      GCD = D;
    }

    if (GCD == 1)
      break;
  }

  if (GCD > 1) {
    cout << "not coprime\\n";
    return 0;
  }

  for (i = 0; i < N; i++) {
    set = is_set(b, a[i]);
    if (set == 1) {
      cout << "setwise coprime\\n";
      return 0;
    }
  }

  cout << "pairwise coprime\\n";

  return 0;
}

Error: 0

Fixed submission:

#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int is_prime(int n) {

  int i;
  i = 2;

  if (n == 1) {
    return 0;

  } else if (n == 2) {
    return 1;

  } else {
    while (1) {
      if (n % i == 0) {
        return 0;

      } else if (n < i * i) {
        return 1;

      } else {
        i++;
      }
    }
  }

  return 0;
}

int gcd(int m, int n) {

  if (m % n == 0) {
    return n;
  } else {
    return gcd(n, m % n);
  }
}

int is_set(int b[1145140], int n) {

  int i;
  i = 2;

  if (n == 1)
    return 0;

  if (is_prime(n) == 1) {
    if (b[n] == 1) {
      return 1;
    } else {
      b[n] = 1;
    }

  } else {
    while (n % i > 0) {
      i++;
    }

    if (b[i] == 1) {
      return 1;

    } else {
      b[i] = 1;

      while (n % i == 0) {
        n /= i;
      }

      return is_set(b, n);
    }
  }

  return 0;
}

int main() {

  int i, N, GCD, D, set;
  cin >> N;

  int a[N];
  int b[100000];

  for (i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (i = 0; i < 100; i++) {
    b[i] = 0;
  }

  for (i = 0; i < N; i++) {
    if (i == 0) {
      GCD = a[i];

    } else {
      D = gcd(GCD, a[i]);
      GCD = D;
    }

    if (GCD == 1)
      break;
  }

  if (GCD > 1) {
    cout << "not coprime\\n";
    return 0;
  }

  for (i = 0; i < N; i++) {
    set = is_set(b, a[i]);
    if (set == 1) {
      cout << "setwise coprime\\n";
      return 0;
    }
  }

  cout << "pairwise coprime\\n";

  return 0;
}