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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod = 1e9 + 7;
const ll inf = 1e16;

#define rep(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m - 1; i >= n; i--)
#define fi first
#define se second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sum(x) accumulate(all(x), 0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve() {
  ll n;
  cin >> n;
  vll a(n);
  rep(i, 0, n) cin >> a[i];

  ll g = a[0];
  rep(i, 1, n) g = __gcd(a[i], g);

  map<ll, vll> mp;
  ll f = 0;
  rep(j, 0, n) {
    for (ll i = 2; i * i <= a[j]; i++) {
      if (a[j] % i)
        continue;
      ll tot = 0;
      while (a[j] % i == 0) {
        a[j] /= i;
        tot++;
      }
      if (mp[i].size()) {
        f = 1;
        break;
      }
      mp[i].eb(tot);
    }
    if (f)
      break;
    if (a[j] != 1) {
      if (mp[a[j]].size()) {
        f = 1;
        break;
      }
      mp[a[j]].eb(1);
    }
  }

  // for(auto p:mp) if(p.se.size()>1) f=1;

  if (f == 0)
    cout << "pairwise coprime" << endl;
  else if (f == 1 && g == 1)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod = 1e9 + 7;
const ll inf = 1e16;

#define rep(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m - 1; i >= n; i--)
#define fi first
#define se second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sum(x) accumulate(all(x), 0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve() {
  ll n;
  cin >> n;
  vll a(n);
  rep(i, 0, n) cin >> a[i];

  ll g = a[0];
  rep(i, 1, n) g = __gcd(a[i], g);

  map<ll, vll> mp;
  ll f = 0;
  rep(j, 0, n) {
    for (ll i = 2; i * i <= a[j]; i++) {
      if (a[j] % i)
        continue;
      ll tot = 0;
      while (a[j] % i == 0) {
        a[j] /= i;
        tot++;
      }
      mp[i].eb(tot);
    }
    if (a[j] != 1)
      mp[a[j]].eb(1);
  }

  for (auto p : mp)
    if (p.se.size() > 1)
      f = 1;

  if (f == 0)
    cout << "pairwise coprime" << endl;
  else if (f == 1 && g == 1)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream &operator>>(istream &I, vector<T> &v) {
  for (T &e : v)
    I >> e;
  return I;
}
template <class T> ostream &operator<<(ostream &O, const vector<T> &v) {
  for (const T &e : v)
    O << e << ' ';
  return O;
}

bool setwise(const vector<int> &a) {
  int g = 0;
  for (int i = 0; i < sz(a); i++) {
    g = __gcd(g, a[i]);
  }

  return g == 1;
}

#define MAXN 1000001

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

void factorize(int x, map<int, int> &m) {
  set<int> vis;
  while (x != 1) {
    if (!vis.count(spf[x]))
      m[spf[x]]++, vis.emplace(spf[x]);
    assert(spf[x] != 0);
    x /= spf[x];
  }
}

bool pairwise(vector<int> a) {
  sort(all(a));
  map<int, int> pf;
  for (auto x : a) {
    factorize(x, pf);
  }

  for (auto it : pf) {
    if (it.second >= 2)
      return 0;
  }

  return 1;
}

void _main() {
  sieve();
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  if (pairwise(a))
    cout << "pairwise coprime";
  else if (setwise(a))
    cout << "setwise coprime";
  else
    cout << "not coprime";
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //        freopen("input.txt", "r", stdin);
  int _t = 1;
  //        cin >> _t;
  while (_t--)
    _main();
  return 0;
}


Error: TLE

Fixed submission:

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream &operator>>(istream &I, vector<T> &v) {
  for (T &e : v)
    I >> e;
  return I;
}
template <class T> ostream &operator<<(ostream &O, const vector<T> &v) {
  for (const T &e : v)
    O << e << ' ';
  return O;
}

bool setwise(const vector<int> &a) {
  int g = 0;
  for (int i = 0; i < sz(a); i++) {
    g = __gcd(g, a[i]);
  }

  return g == 1;
}

bool pairwise(vector<int> &a) {
  sort(all(a));
  vector<bool> p((int)1e6 + 1, 1);
  for (int x = 2; x <= 1e6; x++) {
    if (p[x]) {
      int cnt = 0;
      for (auto i : a) {
        if (i % x == 0)
          cnt++;
      }
      if (cnt >= 2)
        return 0;
    }
  }

  return 1;
}

void _main() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  if (pairwise(a))
    cout << "pairwise coprime";
  else if (setwise(a))
    cout << "setwise coprime";
  else
    cout << "not coprime";
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //        freopen("input.txt", "r", stdin);
  int _t = 1;
  //        cin >> _t;
  while (_t--)
    _main();
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
#define For(i, a, b) for (ll i = a; i <= b; i++)

bool ok1 = 1, ok2 = 0;
ll n, res, arr[1000010];
unordered_map<ll, ll> P;

void PrimeDefactorizeProcess(ll u) {
  For(i, 2, sqrt(u) + 1) if (u > 1 && u % i == 0) {
    while (u % i == 0)
      u /= i;
    P[i]++;
  }
  if (u > 1)
    P[u]++;
}

void process() {
  For(i, 1, n) PrimeDefactorizeProcess(arr[i]);
  for (unordered_map<ll, ll>::iterator iter = P.begin(); iter != P.end();
       iter++)
    if (iter->second > 1)
      ok1 = 0;
  res = arr[1];
  For(i, 2, n) res = __gcd(res, arr[i]);
  if (res == 1)
    ok2 = 1;
  if (ok1)
    cout << "pairwise coprime"
         << "\\n";
  else if (ok2)
    cout << "setwise coprime"
         << "\\n";
  else
    cout << "not coprime"
         << "\\n";
}

void input() {
  cin >> n;
  For(i, 1, n) cin >> arr[i];
}

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

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
#define For(i, a, b) for (ll i = a; i <= b; i++)

bool ok1 = 1, ok2 = 0;
ll n, res, arr[200010];
map<ll, ll> P;

void PrimeDefactorizeProcess(ll u) {
  For(i, 2, sqrt(u) + 1) if (u > 1 && u % i == 0) {
    while (u % i == 0)
      u /= i;
    P[i]++;
  }
  if (u > 1)
    P[u]++;
}

void process() {
  For(i, 1, n) PrimeDefactorizeProcess(arr[i]);
  for (map<ll, ll>::iterator iter = P.begin(); iter != P.end(); iter++)
    if (iter->second > 1)
      ok1 = 0;
  res = arr[1];
  For(i, 2, n) res = __gcd(res, arr[i]);
  if (res == 1)
    ok2 = 1;
  if (ok1)
    cout << "pairwise coprime"
         << "\\n";
  else if (ok2)
    cout << "setwise coprime"
         << "\\n";
  else
    cout << "not coprime"
         << "\\n";
}

void input() {
  cin >> n;
  For(i, 1, n) cin >> arr[i];
}

int main() {
  input();
  process();
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
typedef long long ll;
const int N = 1e6 + 10;
int const mod = 1e9 + 7;
using namespace std;

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int n, x, vis[N], cnt[N], cntm = 0;

int main() {
  cin >> n;
  bool tmam = 1;
  int GCD = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    cnt[x]++;
    GCD = gcd(GCD, x);
  }
  for (int i = 2; i < N; i++) {
    cntm = 0;
    if (vis[i] == 0) {
      for (int j = i; j < N; j += i) {
        vis[j] = 1;
        cntm += cnt[j];
      }
      if (cntm > 1)
        tmam = 0;
    }
    if (!tmam)
      break;
  }
  if (tmam)
    cout << "pairwise coprime"
         << "\\n";
  else if (!tmam && GCD == 1)
    cout << "setwise coprime"
         << "\\n";
  else
    cout << "not coprime"
         << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 1e6 + 5;
int n;
int rc[N], totgcd, num[N];
int prime[N], vis[N], cnt = 0;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
inline void getprime() {
  memset(vis, 0, sizeof(vis));
  for (int i = 2; i < N; ++i) {
    if (!vis[i]) {
      vis[i] = 1;
      prime[++cnt] = i;
    }
    for (int j = 1; j <= cnt && i * prime[j] < N; ++j) {
      vis[i * prime[j]] = 1;
      if (i % prime[j] == 0)
        break;
    }
  }
}
inline void div(int a) {
  for (int i = 1; i <= cnt && prime[i] <= a; ++i) {
    int j = 0;
    while (!(a % prime[i])) {
      a /= prime[i];
      if (!j)
        ++rc[i];
      ++j;
    }
  }
}
int main() {
  getprime();
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &num[i]);
  totgcd = num[1];
  for (int i = 2; i <= n; ++i) {
    totgcd = gcd(totgcd, num[i]);
  }
  if (totgcd != 1) {
    printf("not coprime\\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i)
    div(num[i]);
  for (int i = 1; i <= cnt; ++i)
    if (rc[i] > 1) {
      printf("setwise coprime\\n");
      return 0;
    }
  printf("pairwise coprime\\n");
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int gcd(int x, int y) {
  if (x == 0)
    return y;
  else
    return gcd(y % x, x);
}
int main() {
  int N;
  cin >> N;
  int A[1000000];
  int M = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    M = max(M, A[i]);
  }
  int judge[1000001];
  for (int i = 1; i <= M; i++)
    judge[i] = 0;
  for (int i = 2; i <= M; i++) {
    if (judge[i] == 0) {
      for (int j = i; j <= M; j += i) {
        if (judge[j] == 0)
          judge[j] = i;
      }
    }
  }
  int set = 0;
  int pnum[1000001];
  for (int i = 1; i <= M; i++)
    pnum[i] = 0;
  for (int i = 0; i < N; i++) {
    int a = A[i];
    while (a != 1) {
      int n = judge[a];
      while (a % n == 0)
        a /= n;
      pnum[n]++;
    }
  }
  for (int i = 1; i <= M; i++) {
    if (pnum[i] > 1) {
      set = 1;
      break;
    }
  }
  if (set == 0)
    cout << "pairwise coprime" << endl;
  else {
    int g = A[0];
    for (int i = 1; i < N; i++) {
      g = gcd(g, A[i]);
    }
    if (g == 1)
      cout << "setwise coprime" << endl;
    else
      cout << "not coprime" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int gcd(int x, int y) {
  if (x == 0)
    return y;
  else
    return gcd(y % x, x);
}
int main() {
  int N;
  cin >> N;
  int A[1000000];
  int M = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    M = max(M, A[i]);
  }
  M /= 2;
  vector<int> p;
  int judge[500001];
  for (int i = 1; i <= M; i++)
    judge[i] = 0;
  for (int i = 2; i <= M; i++) {
    if (judge[i] == 0) {
      p.push_back(i);
      for (int j = 2 * i; j <= M; j += i)
        judge[j] = 1;
    }
  }
  int set = 0;
  for (int i = 0; i < p.size(); i++) {
    int q = p[i];
    int zero = 0;
    for (int j = 0; j < N; j++) {
      if (A[j] % q == 0)
        zero++;
    }
    if (zero > 1) {
      set = 1;
      break;
    }
  }
  if (set == 0)
    cout << "pairwise coprime" << endl;
  else {
    int g = A[0];
    for (int i = 1; i < N; i++) {
      g = gcd(g, A[i]);
    }
    if (g == 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;
#define REP(i, n) for (int(i) = 0; i < (n); i++)
typedef long long ll;
int pr[2000000];

// 素因数分解。O(√n)。
map<int, int> prime_factor(int m) {
  map<int, int> rtn;
  for (int i = 2; i * i <= m; i++) {
    while (!(m % i)) {
      ++rtn[i];
      m /= i;
    }
  }
  if (m != 1)
    rtn[m] = 1;
  return rtn;
}

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

  REP(i, 2000000) pr[i] = 0;

  REP(i, n) {
    int tmp;
    cin >> tmp;
    map<int, int> mp = prime_factor(tmp);
    for (auto p : mp) {
      pr[p.first]++;
      // cout<<p.first<<"^"<<p.second<<" ";
    }
  }

  REP(i, 2000000) if (pr[i] == n) {
    cout << "not coprime" << endl;
    return 0;
  }

  REP(i, 2000000) {
    if (pr[i] > 1) {
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "pairwise coprime" << endl;
  return 0;
}

Error: 0

Fixed submission:

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

// 素因数分解。O(√n)。
map<int, int> prime_factor(int m) {
  map<int, int> rtn;
  for (int i = 2; i * i <= m; i++) {
    while (!(m % i)) {
      ++rtn[i];
      m /= i;
    }
  }
  if (m != 1)
    rtn[m] = 1;
  return rtn;
}

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

  REP(i, 5000) pr[i] = 0;

  REP(i, n) {
    int tmp;
    cin >> tmp;
    map<int, int> mp = prime_factor(tmp);
    for (auto p : mp) {
      pr[p.first]++;
      // cout<<p.first<<"^"<<p.second<<" ";
    }
  }

  /*REP(i,5000) if(pr[i]==n){
    cout<<"not coprime"<<endl;
    return 0;
  }

  REP(i,5000){
    if(pr[i]>1){
      cout<<"setwise coprime"<<endl;
      return 0;
    }
  }*/

  cout << "pairwise coprime" << endl;
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

/*** akshaykumar99 ***/

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

const long long MOD = 1e9 + 7;
const long double PI = acos(-1);
const long long N = 1e6 + 1;

typedef long long ll;
typedef long double ld;

ll spf[N];
void sieve() {
  spf[1] = 1;
  for (ll i = 2; i < N; i++)
    spf[i] = i;

  for (ll i = 4; i < N; i += 2)
    spf[i] = 2;

  for (ll i = 3; i * i < N; i++) {
    if (spf[i] == i) {
      for (ll j = i * i; j < N; j += i)
        if (spf[j] == j)
          spf[j] = i;
    }
  }
}
vector<ll> getFactorization(ll x) {
  vector<ll> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
void test_case() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  sieve();
  for (ll i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<bool> done(N, 0);
  bool flag = 0;
  for (ll i = 0; i < n; i++) {
    vector<ll> p = getFactorization(v[i]);
    for (ll j = 0; j < p.size(); j++) {
      if (done[p[j]]) {
        flag = 1;
        break;
      }
    }
    for (ll j = 0; j < p.size(); j++) {
      done[p[j]] = 1;
    }
    if (flag)
      break;
  }
  if (!flag) {
    cout << "pairwise coprime\\n";
    return;
  }
  ll gg = v[0];
  for (int i = 1; i < n; i++) {
    gg = __gcd(gg, v[i]);
  }
  if (gg == 1) {
    cout << "setwise coprime\\n";
    return;
  }
  cout << "not coprime\\n";
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll tc = 1;
  // cin>>tc;
  while (tc--)
    test_case();
  return 0;
}


Error: -8

Fixed submission:

/*** akshaykumar99 ***/

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

const long long MOD = 1e9 + 7;
const long double PI = acos(-1);
const long long N = 1e6 + 1;

typedef long long ll;
typedef long double ld;

int spf[N];
void sieve() {
  spf[1] = 1;
  for (int i = 2; i < N; i++)
    spf[i] = i;

  for (int i = 4; i < N; i += 2)
    spf[i] = 2;

  for (int i = 3; i * i < N; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < N; j += i)
        if (spf[j] == j)
          spf[j] = i;
    }
  }
}
vector<int> getFactorization(int x) {
  vector<int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
void test_case() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<bool> done(N, 0);
  bool flag = 0;
  for (int i = 0; i < n; i++) {
    vector<int> p = getFactorization(v[i]);
    for (int j = 0; j < p.size(); j++) {
      if (done[p[j]]) {
        flag = 1;
        break;
      }
      done[p[j]] = 1;
    }
    if (flag)
      break;
  }
  if (!flag) {
    cout << "pairwise coprime\\n";
    return;
  }
  ll gg = v[0];
  for (int i = 1; i < n; i++) {
    gg = __gcd(gg, v[i]);
  }
  if (gg == 1) {
    cout << "setwise coprime\\n";
    return;
  }
  cout << "not coprime\\n";
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll tc = 1;
  // cin>>tc;
  while (tc--)
    test_case();
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int n, a[1000010], g;
vector<int> p;
int cnt[1000010];
bool isprime(int x) {
  int s = sqrt(x);
  for (int i = 2; i <= s; i++)
    if (x % i == 0)
      return 0;
  return 1;
}
int main() {
  for (int i = 2; i <= 1000; i++)
    if (isprime(i))
      p.push_back(i);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i == 1)
      g = a[i];
    else
      g = __gcd(g, a[i]);
  }
  if (g > 1) {
    printf("not coprime\\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int x = a[i];
    int s = sqrt(x);
    for (int j = 0; p[j] <= s && j < p.size(); j++) {
      if (x % p[j] == 0) {
        cnt[p[j]]++;
        if (cnt[p[j]] > 1) {
          printf("setwise coprime\\n");
          return 0;
        }
        while (x % p[j] == 0)
          x /= p[j];
      }
    }
    if (x > 1)
      cnt[x]++;
    if (cnt[x] > 1) {
      printf("setwise coprime\\n");
      return 0;
    }
  }
  printf("pairwise coprime\\n");
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, a[1000010], g;
vector<int> p;
int cnt[1000010];
bool isprime(int x) {
  int s = sqrt(x);
  for (int i = 2; i <= s; i++)
    if (x % i == 0)
      return 0;
  return 1;
}
int main() {
  for (int i = 2; i <= 1000; i++)
    if (isprime(i))
      p.push_back(i);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i == 1)
      g = a[i];
    else
      g = __gcd(g, a[i]);
  }
  if (g > 1) {
    printf("not coprime\\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int x = a[i];
    int s = sqrt(x);
    for (int j = 0; p[j] <= s; j++) {
      if (x % p[j] == 0) {
        cnt[p[j]]++;
        if (cnt[p[j]] > 1) {
          printf("setwise coprime\\n");
          return 0;
        }
        while (x % p[j] == 0)
          x /= p[j];
        if (x > 1)
          cnt[x]++;
        if (cnt[x] > 1) {
          printf("setwise coprime\\n");
          return 0;
        }
      }
    }
  }
  printf("pairwise coprime\\n");
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9 + 7;
const ll LLINF = 7e18;
using namespace std;

bool num[1000001];
int coun[1000001];

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

  bool is_pairwise = true;
  bool is_setwise = true;

  for (int i = 0; i < n; i++) {
    int tmp = a[i];
    for (int k = 2; k * k <= tmp; k++) {
      if (tmp % k == 0) {
        if (num[k] == true)
          is_pairwise = false;
        num[k] = true;
        coun[k]++;
        while (tmp % k == 0) {
          tmp /= k;
        }
      }
    }
    if (tmp != 1) {
      if (num[tmp] == true)
        is_pairwise = false;
      else
        is_setwise = true;
      num[tmp] = true;
      coun[tmp]++;
    }
  }

  for (int i = 1; i <= 1000000; i++) {
    if (coun[i] == n)
      is_setwise = false;
  }
  if (is_pairwise)
    cout << "pairwise coprime" << endl;
  else if (is_setwise)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9 + 7;
const ll LLINF = 7e18;
using namespace std;

bool num[100001];
int coun[100001];

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

  bool is_pairwise = true;
  bool is_setwise = true;

  for (int i = 0; i < n; i++) {
    int tmp = a[i];
    for (int k = 2; k * k <= tmp; k++) {
      if (tmp % k == 0) {
        if (num[k] == true)
          is_pairwise = false;
        num[k] = true;
        coun[k]++;
        while (tmp % k == 0) {
          tmp /= k;
        }
      }
    }
    if (tmp != 1) {
      if (num[tmp] == true)
        is_pairwise = false;
      else
        is_setwise = true;
      num[tmp] = true;
    }
  }

  for (int i = 1; i <= 100000; i++) {
    if (coun[i] == n)
      is_setwise = false;
  }
  if (is_pairwise)
    cout << "pairwise coprime" << endl;
  else if (is_setwise)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
  return 0;
}