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

#include <bits/stdc++.h>
#define maxn 1000086

using namespace std;

int n, x;
int y;

int a[maxn];
int p[maxn], cnt;
bool tag[maxn];
bool suc = true;

int main() {
  for (int i = 2; i < 1001; i++) {
    if (!tag[i])
      p[++cnt] = i;
    for (int j = 1; j <= cnt && p[j] * i < 1001; j++) {
      tag[p[j] * i] = true;
      if (i % p[j] == 0)
        break;
    }
  }
  // printf("%d--\\n", cnt);
  memset(tag, 0, sizeof(tag));
  scanf("%d", &n);
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] ^ 1)
      tot++;
  }
  if (tot > 78503)
    suc = false;
  for (int j = 1; j <= n; j++) {
    int x = a[j];
    if (!y)
      y = x;
    else
      y = __gcd(y, x);
    if (!suc)
      continue;
    for (int i = 1; i <= cnt; i++) {
      if (x % p[i] == 0) {
        if (tag[p[i]])
          suc = false;
        else
          tag[p[i]] = true;
      }
      while (x % p[i] == 0)
        x /= p[i];
    }
    if (x ^ 1) {
      if (tag[x])
        suc = false;
      else
        tag[x] = true;
    }
  }
  if (suc)
    printf("pairwise coprime");
  else if (y == 1)
    printf("setwise coprime");
  else
    printf("not coprime");
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define maxn 1000086

using namespace std;

int n, x;
int y;

int p[maxn], cnt;
bool tag[maxn];
bool suc = true;

int main() {
  for (int i = 2; i < maxn; i++) {
    if (!tag[i])
      p[++cnt] = i;
    for (int j = 1; j <= cnt && p[j] * i < maxn; j++) {
      tag[p[j] * i] = true;
      if (i % p[j] == 0)
        break;
    }
  }
  memset(tag, 0, sizeof(tag));
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &x);
    if (!y)
      y = x;
    else
      y = __gcd(y, x);
    if (!suc)
      continue;
    for (int i = 1; i <= cnt; i++) {
      if (x % p[i] == 0) {
        if (tag[i])
          suc = false;
        else
          tag[i] = true;
      }
    }
  }
  if (suc)
    printf("pairwise coprime");
  else if (y == 1)
    printf("setwise coprime");
  else
    printf("not coprime");
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define rep(X, N) for (ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(), (V).end()
#define endl "\\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main() {

  int n;
  cin >> n;
  vector<int> a(n);

  rep(i, n) { cin >> a[i]; }

  int allgcd = a[0];

  rep(i, n) { allgcd = __gcd(allgcd, a[i]); }

  vector<int> traversed(1000001);
  bool pairwise = true;

  // cerr << "check" << endl;

  rep(i, n) { traversed[a[i]]++; }

  for (int i = 2; i <= 1000000; i++) {
    int count = 0;
    for (int j = i; j <= 1000000; j = j + i) {
      if (traversed[j] > 0)
        count += traversed[j];
    }

    // cerr << i << " " << count << endl;
    if (count > 1) {
      pairwise = false;
      break;
    }
  }

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

  return 0;
}


Error: -6
4df70a89-0e8c-4023-9989-e4067b0fc0f8.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02574/C++/s493332896.cpp:57: int main(): Assertion `false' failed.


Fixed submission:

#include <bits/stdc++.h>

#define rep(X, N) for (ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(), (V).end()
#define endl "\\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main() {

  int n;
  cin >> n;
  vector<int> a(n);

  rep(i, n) { cin >> a[i]; }

  int allgcd = a[0];

  rep(i, n) { allgcd = __gcd(allgcd, a[i]); }

  vector<bool> traversed(1000001, false);
  bool pairwise = true;

  sort(ALL(a));

  // cerr << "check" << endl;

  rep(i, n) { traversed[a[i]] = true; }

  for (int i = 2; i <= 1000000; i++) {
    int count = 0;
    for (int j = i; j <= 1000000; j = j + i) {
      if (traversed[j])
        count++;
    }

    // cerr << i << " " << count << endl;
    if (count > 1) {
      pairwise = false;
      break;
    }
  }

  if (pairwise) {
    assert(false);
    cout << "pairwise coprime" << endl;
  } else if (allgcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }

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

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

bool judge = 0;
long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}

ll MAX = 2000000;

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

  int N;
  cin >> N;
  vector<ll> A(N);
  ll gcd, m = 0;
  map<ll, bool> ma;
  map<ll, ll> cnt;
  rep(i, N) {
    cin >> A[i];
    ma[A[i]] = true;
    if (i == 0)
      gcd = A[i];
    else
      gcd = GCD(gcd, A[i]);
    m = max(m, A[i]);
  }

  int MAX = m + 1;
  vector<int> is_prime(MAX, 1);
  is_prime[0] = 0, is_prime[1] = 0;
  for (int i = 2; i < MAX; ++i) {
    if (!is_prime[i])
      continue;
    for (ll j = i; j < MAX; j += i) {
      is_prime[j] = 0;
      if (ma[j]) {
        cnt[i]++;
        if (cnt[i] >= 2) {
          judge = 1;
          break;
        }
      }
    }
  }

  if (!judge && gcd == 1) {
    cout << "pairwise coprime" << endl;
  } else if (gcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

bool judge = 0;
long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}

vector<ll> SPF(ll n) {
  vector<ll> spf(n + 1);
  for (int i = 0; i <= n; i++)
    spf[i] = i;

  for (ll i = 2; i * i <= n; i++) {
    if (spf[i] == i) {
      for (ll j = i * i; j <= n; j += i) {
        if (spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }

  return spf;
}

void prime(ll N, map<ll, bool> &ma, vector<ll> spf) {
  map<ll, bool> maa;
  while (N != 1) {
    maa[spf[N]] = true;
    N /= spf[N];
  }

  for (auto m : maa) {
    if (ma[m.first]) {
      judge = 1;
      break;
    } else {
      ma[m.first] = true;
    }
  }
}

ll MAX = 2000000;

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

  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> spf = SPF(MAX);
  ll gcd;
  map<ll, bool> ma;
  rep(i, N) {
    if (i == 0)
      gcd = A[i];
    cin >> A[i];
    gcd = GCD(gcd, A[i]);
    if (!judge)
      prime(A[i], ma, spf);
  }

  if (!judge && gcd == 1) {
    cout << "pairwise coprime" << endl;
  } else if (gcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }

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

#include <algorithm>
#include <cassert>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string.h>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

ll N;
ll A[1000010];
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int main() {
  cin >> N;
  for (ll i = 0; i < N; i++)
    cin >> A[i];
  sort(A, A + N);
  bool pairwise = true;
  bool isPrime[1000010];
  for (ll i = 1; i <= A[N - 1]; i++)
    isPrime[i] = true;
  for (ll i = 0; i < N; i++) {
    if (!isPrime[A[i]]) {
      pairwise = false;
      break;
    }
    vector<ll> v;
    ll a = A[i];
    for (ll j = 2; j * j <= a; j++) {
      if (a % j == 0)
        v.push_back(j);
      while (a % j == 0)
        a /= j;
    }
    if (a != 1)
      v.push_back(a);
    for (auto x : v) {
      for (ll j = x; j <= A[N - 1]; j += x) {
        isPrime[j] = false;
      }
    }
  }
  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  ll _gcd = A[0];
  for (ll i = 1; i < N; i++) {
    _gcd = gcd(_gcd, A[i]);
  }
  if (_gcd == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string.h>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

ll N;
ll A[1000010];
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int main() {
  cin >> N;
  for (ll i = 0; i < N; i++)
    cin >> A[i];
  sort(A, A + N);
  bool pairwise = true;
  bool isPrime[1000010];
  for (ll i = 1; i <= A[N - 1]; i++)
    isPrime[i] = true;
  for (ll i = 0; i < N; i++) {
    if (!isPrime[A[i]]) {
      pairwise = false;
      break;
    }
    vector<ll> v;
    ll a = A[i];
    for (ll j = 2; j <= a; j++) {
      if (a % j == 0)
        v.push_back(j);
      while (a % j == 0)
        a /= j;
    }
    if (a != 1)
      v.push_back(a);
    for (auto x : v) {
      for (ll j = x; j <= A[N - 1]; j += x) {
        isPrime[j] = false;
      }
    }
  }
  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  ll _gcd = A[0];
  for (ll i = 1; i < N; i++) {
    _gcd = gcd(_gcd, A[i]);
  }
  if (_gcd == 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>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

int a_max;

vector<bool> f(1e6 + 1, true);
vector<int> d(1e6 + 1, 0);
void sieve(void) {
  rep(i, 1e6 + 1) d[i] = i;
  f[0] = false, f[1] = false;
  for (int i = 2; i * i <= a_max; ++i) {
    d[i] = min(d[i], i);
    if (f[i]) {
      for (int j = 2 * i; j <= a_max; j += i) {
        f[j] = false;
        d[j] = i;
      }
    }
  }
}

map<ll, ll> prime_factory(int x) {
  map<ll, ll> res;
  if (x == d[x])
    res[x]++;
  else {
    res[d[x]]++;
    for (auto i : prime_factory(x / d[x]))
      res[i.first] += i.second;
  }
  return res;
}

void solve(void) {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  a_max = *max_element(a.begin(), a.end());
  sieve();
  map<ll, ll> mp;
  rep(i, n) {
    for (auto i : prime_factory(a[i]))
      mp[i.first] += 1;
  }
  bool flag = true;
  bool flag_x = true;
  for (auto i : mp) {
    if (i.first == 1)
      continue;
    if (i.second > 1)
      flag = false;
    if (i.second == n)
      flag_x = false;
  }
  if (flag)
    cout << "pairwise coprime" << endl;
  else {
    if (flag_x)
      cout << "setwise coprime" << endl;
    else
      cout << "not coprime" << endl;
  }
}
int main(void) {
  solve();

  // cin >> a_max;
  // sieve();
  // for (auto i : prime_factory(a_max))
  //     cout << i.first << " " << i.second << endl;
}

Error: TLE

Fixed submission:

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

int a_max;

vector<bool> f(1e6 + 1, true);

void sieve(void) {
  f[0] = false, f[1] = false;
  for (int i = 2; i * i <= a_max; ++i) {
    if (f[i]) {
      for (int j = 2 * i; j <= a_max; j += i)
        f[j] = false;
    }
  }
}

map<ll, ll> prime_factory(int x) {
  map<ll, ll> res;
  if (f[x]) {
    res[x] = 1;
    return res;
  }

  set<ll> st;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      st.insert(i);
      if (x % (x / i) == 0)
        st.insert(x / i);
    }
  }
  vector<ll> tmp;
  for (auto i : st) {
    if (f[i]) {
      while (x % i == 0) {
        tmp.push_back(i);
        x /= i;
      }
    }
  }

  for (auto i : tmp)
    res[i]++;
  return res;
}

void solve(void) {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  a_max = *max_element(a.begin(), a.end());
  sieve();
  map<ll, ll> mp;
  rep(i, n) {
    for (auto i : prime_factory(a[i]))
      mp[i.first] += 1;
  }
  bool flag = true;
  bool flag_x = true;
  for (auto i : mp) {
    if (i.second > 1)
      flag = false;
    if (i.second == n)
      flag_x = false;
  }
  if (flag)
    cout << "pairwise coprime" << endl;
  else {
    if (flag_x)
      cout << "setwise coprime" << endl;
    else
      cout << "not coprime" << endl;
  }
}
int main(void) { solve(); }
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const int maxn = 1e6 + 5;

inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

bool vis[maxn];
int a[maxn];

bool deal(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      if (vis[i])
        return false;
      vis[i] = true;
      while (n % i == 0)
        n /= i;
    }
  }
  if (n > 1) {
    if (vis[n])
      return false;
    vis[n] = true;
  }
  return true;
}

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

  int n, res = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    res = gcd(a[i], res);
  }
  bool ans = true;
  for (int i = n; i >= 1; i--) {
    ans = deal(a[i]);
    if (!ans)
      break;
  }
  if (ans)
    cout << "pairwise coprime";
  else if (res == 1)
    cout << "setwise coprime";
  else
    cout << "not coprime";
  return 0;
}

Error: TLE

Fixed submission:

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

const int maxn = 1e6 + 5;

inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

bool isprime[maxn];
int a[maxn], prime[maxn], primesize;
bool vis[maxn], mark[maxn];

void init(int n) {
  memset(isprime, 1, sizeof(isprime));
  isprime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (isprime[i])
      prime[++primesize] = i;
    for (int j = 1; j <= primesize && i * prime[j] <= n; j++) {
      isprime[i * prime[j]] = false;
      if (i % prime[j] == 0)
        break;
    }
  }
}

bool deal(int n) {
  for (int i = 1; i <= primesize && prime[i] <= n; i++) {
    if (n == 1)
      break;
    if (n % prime[i] == 0) {
      if (vis[prime[i]])
        return false;
      vis[prime[i]] = true;
      while (n % prime[i] == 0)
        n /= prime[i];
      if (isprime[n]) {
        if (vis[n])
          return false;
        vis[n] = true;
        break;
      }
    }
  }
  return true;
}

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

  init(1e6);
  int n;
  cin >> n;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (i == 1)
      res = a[i];
    else if (res != 1)
      res = gcd(res, a[i]);
  }
  bool ans = true;
  for (int i = n; i >= 1; i--) {
    ans = deal(a[i]);
    if (ans == false)
      break;
  }
  if (ans)
    cout << "pairwise coprime";
  else if (res == 1)
    cout << "setwise coprime";
  else
    cout << "not coprime";
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

/*Q-5---ATCODER-BEGINNER-#ROUND_177*/
#include <bits/stdc++.h>
#define MAX 1000001
#define endl '\\n'
#define ll long long
using namespace std;

ll factors[MAX];
bool possible;

void findFactors(ll n) {
  for (ll i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        if (i != 1) {
          if (factors[i] == 1) {
            possible = false;
            return;
          }
          factors[i] = 1;
        }
      } else {
        if (i != 1) {
          if (factors[i] == 1) {
            possible = false;
            return;
          }
          factors[i] = 1;
        }

        if (n / i != 1) {
          if (factors[n / i] == 1) {
            possible = false;
            return;
          }
          factors[n / i] = 1;
        }
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  possible = true;

  ll n{0};
  cin >> n;

  ll arr[n];
  for (ll i = 0; i < n; i++)
    cin >> arr[i];

  // finding the GCD of all N-elements
  ll gcd = arr[0];
  for (ll i = 0; i < n; i++) {
    gcd = __gcd(gcd, arr[i]);
  }

  //
  for (ll i = 0; i < n; i++) {
    findFactors(arr[i]);
  }

  if (possible) {
    cout << "pairwise coprime" << endl;
  } else if (gcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

/*Q-5---ATCODER-BEGINNER-#ROUND_177*/
#include <bits/stdc++.h>
#define MAX 1000001
#define endl '\\n'
#define ll long long
using namespace std;

ll factors[MAX];

void findFactors(ll n) {
  for (ll i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        factors[i]++;
      } else {
        factors[i]++;
        factors[n / i]++;
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n{0};
  cin >> n;

  ll arr[n];
  for (ll i = 0; i < n; i++)
    cin >> arr[i];

  // finding the GCD of all N-elements
  ll gcd = arr[0];
  for (ll i = 0; i < n; i++) {
    gcd = __gcd(gcd, arr[i]);
  }

  //
  for (ll i = 0; i < n; i++) {
    findFactors(arr[i]);
  }

  bool possible = true;
  for (ll i = 2; i < MAX; i++) {
    if (factors[i] > 1) {
      possible = false;
      break;
    }
  }

  if (possible) {
    cout << "pairwise coprime" << endl;
  } else if (gcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }

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

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

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

  vector<int> num(1e6 + 1);
  num[1] = 1;
  for (int i = 2; i <= 1e6; i++) {
    if (num[i] == 0) {
      num[i] = i;
      for (int j = 2; i * j <= 1e6; j++) {
        if (num[i * j] == 0)
          num[i * j] = i;
      }
    }
  }

  map<int, int> cnt;
  vector<map<int, int>> mul(N);
  for (int i = 0; i < N; i++) {
    while (a[i] != 1) {
      mul[i][num[a[i]]]++;
      if (mul[i][num[a[i]]] == 1)
        cnt[num[a[i]]]++;
      a[i] /= num[a[i]];
    }
  }

  int ty = 0;
  for (auto y : cnt) {
    if (y.second == N) {
      ty = 2;
      break;
    } else if (y.second >= 2) {
      ty = 1;
    }
  }

  if (ty == 0)
    cout << "pairwise coprime" << endl;
  if (ty == 1)
    cout << "setwise coprime" << endl;
  if (ty == 2)
    cout << "not coprime" << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

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

  vector<bool> num(1e6 + 1, true);
  map<int, int> mp;
  for (int i = 2; i <= 1e6; i++) {
    if (num[i]) {
      mp[i] = true;
      for (int j = 2; i * j <= 1e6; j++) {
        num[i * j] = false;
      }
    }
  }

  map<int, int> cnt;
  vector<map<int, int>> mul(N);
  for (int i = 0; i < N; i++) {
    for (auto x : mp) {
      while (a[i] % x.first == 0) {
        a[i] /= x.first;
        mul[i][x.first]++;
        if (mul[i][x.first] == 1)
          cnt[x.first]++;
      }
      if (a[i] > 2)
        mul[i][a[i]]++;
      if (mul[i][a[i]] == 1)
        cnt[a[i]]++;
    }
  }

  int ty = 0;
  for (auto y : cnt) {
    if (y.second == N) {
      ty = 2;
      break;
    } else if (y.second >= 2) {
      ty = 1;
    }
  }

  if (ty == 0)
    cout << "pairwise coprime" << endl;
  if (ty == 1)
    cout << "setwise coprime" << endl;
  if (ty == 2)
    cout << "not coprime" << endl;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

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

#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

#define MAXX 500005
#define INF INT_MAX

#define PI 3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll long long

#define mod 1000000007

map<ll, bool> mp;

int main() {
  FAST;
  int n;
  cin >> n;

  int m;
  bool flag = true;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (i == 0) {
      m = a;
    } else {
      m = __gcd(m, a);
    }
    if (flag) {
      for (int j = 2; j * j <= a; j++) {
        if (a % j == 0) {
          int k1 = a / j;
          if (mp[k1]) {
            flag = false;
          }
          if (mp[j] && j != k1) {
            flag = false;
          }
          mp[k1] = true;
          mp[j] = true;
        }
      }

      if (mp[a] == true) {
        flag = false;
      }
      if (a != 1)
        mp[a] = true;
    }
  }

  if (flag) {
    cout << "pairwise coprime";
    return 0;
  }
  if (m == 1) {
    cout << "setwise coprime";
    return 0;
  }

  cout << "not coprime";
  return 0;

  return 0;
}

Error: 0

Fixed submission:

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

#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

#define MAXX 500005
#define INF INT_MAX

#define PI 3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll long long

#define mod 1000000007

bool p[MAXX];

int main() {
  FAST;
  int n;
  cin >> n;
  int a[n + 5];

  int m = a[0];
  bool ans = true;

  for (int i = 0; i < n; i++) {
    int a[i];
    cin >> a[i];
    if (i == 0) {
      m = a[i];
    } else {
      m = __gcd(m, a[i]);
    }

    if (ans) {
      int s = 0;
      for (int j = 2; j * j <= a[i]; j++) {
        if (a[i] % j == 0) {
          int k = a[i] / j;
          if (p[j]) {
            ans = false;
          }
          if (p[k] && j != k)
            ans = false;
          p[j] = true;
          p[k] = true;
          s++;
        }
      }
      if (!s) {
        if (p[a[i]])
          ans = false;
        p[a[i]] = true;
      }
    }
  }

  if (ans) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  if (m == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  return 0;
}