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

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

typedef long long ll;
#define pii pair<pii, pii>
#define _FastIO                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define MAXX 1000005

int n, G = 0;
int a[MAXX];

int main() {
  _FastIO;
  vector<bool> used(MAXX, false);
  cin >> n;
  bool f = true;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (G != 1) {
      if (!i)
        G = a[0];
      else
        G = __gcd(G, a[i]);
    }
    if (f) {
      int s = 0;
      for (ll j = 2; j * j <= a[i]; j++) {
        if ((a[i] % j) == 0) {
          if (used[j])
            f = false;
          used[j] = true;
          int k = a[i] / j;
          if (used[k] && k != j)
            f = false;
          used[k] = true;
          s++;
        }
      }
      if (a[i] != 1 && !s) {
        if (used[a[i]])
          f = false;
        used[a[i]] = true;
      }
    }
  }
  if (f) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  if (G == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

typedef long long ll;
#define pii pair<pii, pii>
#define _FastIO                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define MAXX 1000005

int n, G;
int a[MAXX];

int main() {
  _FastIO;
  vector<bool> used(MAXX, false);
  cin >> n;
  bool f = true;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (!i)
      G = a[0];
    else
      G = __gcd(G, a[i]);
    int s = 0;
    for (ll j = 2; j * j <= a[i]; j++) {
      if ((a[i] % j) == 0) {
        if (used[j])
          f = false;
        used[j] = true;
        int k = a[i] / j;
        if (used[k] && k != j)
          f = false;
        used[k] = true;
        s++;
      }
    }
    if (a[i] != 1 && !s) {
      if (used[a[i]])
        f = false;
      used[a[i]] = true;
    }
  }
  if (f) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  if (G == 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;
typedef int ll;
#define fr(i, k, n) for (ll i = k; i < n; i++)
#define mo map<ll, ll>
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  ll arr[n + 2];

  // ll ms[c];
  unordered_map<ll, ll> ms;
  /*   fr(i,0,1e6+1){
       ms[i] = 0;
   }*/
  // set<ll> sd;
  fr(i, 0, n) {
    cin >> arr[i];
    //	sd.insert(arr[i]);
    //	ms[arr[i]]++;
  }

  ll ans = arr[0];
  fr(i, 1, n) { ans = __gcd(ans, arr[i]); }
  if (ans > 1) {
    cout << "not coprime"
         << "\\n";
  } else {
    ll au = 0;
    //	cout<<ms[3]<<"\\n";
    fr(i, 0, n) {
      ll c = arr[i];

      fr(j, 2, sqrt(arr[i])) {
        if (c % j == 0) {

          ms[j]++;
        }
        while (c % j == 0) {
          c /= j;
        }

        if (ms[j] > 1) {
          //		cout<<j<<"\\n";
          au = 1;
          break;
        }
      }
      // cout<<ms[3]<<" "<<i<<"\\n";
      if (c > 1) {
        ms[c]++;
        //	cout<<ms[3]<<"\\n";
      }
      if (ms[c] > 1) {

        // cout<<c<<"\\n";
        au = 1;
        break;
      }
    }
    if (au == 0) {
      cout << "pairwise coprime"
           << "\\n";
    } else {
      cout << "setwise coprime"
           << "\\n";
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long ll;
#define fr(i, k, n) for (ll i = k; i < n; i++)
#define mo map<ll, ll>
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  ll arr[n + 2];

  // ll ms[c];
  map<ll, ll> ms;
  /*   fr(i,0,1e6+1){
       ms[i] = 0;
   }*/
  // set<ll> sd;
  fr(i, 0, n) {
    cin >> arr[i];
    //	sd.insert(arr[i]);
    //	ms[arr[i]]++;
  }

  ll ans = arr[0];
  fr(i, 1, n) { ans = __gcd(ans, arr[i]); }
  if (ans > 1) {
    cout << "not coprime"
         << "\\n";
  } else {
    ll au = 0;
    //	cout<<ms[3]<<"\\n";
    fr(i, 0, n) {
      ll c = arr[i];

      fr(j, 2, sqrt(arr[i])) {
        if (c % j == 0) {

          ms[j]++;
        }
        while (c % j == 0) {
          c /= j;
        }

        if (ms[j] > 1) {
          //		cout<<j<<"\\n";
          au = 1;
          break;
        }
      }
      // cout<<ms[3]<<" "<<i<<"\\n";
      if (c > 1) {
        ms[c]++;
        //	cout<<ms[3]<<"\\n";
      }
      if (ms[c] > 1) {

        // cout<<c<<"\\n";
        au = 1;
        break;
      }
    }
    if (au == 0) {
      cout << "pairwise coprime"
           << "\\n";
    } else {
      cout << "setwise coprime"
           << "\\n";
    }
  }
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 1e6 + 10;
const int maxm = 1e6 + 10;
const int base = 31337;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n;
int a[maxn];
int bio[maxm + 20];

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

  for (int i = 0; i < n; i++)
    bio[a[i]]++;

  bool flag = true;
  for (int i = 2; i < maxm; i++) {
    int cnt = 0;
    for (int j = i; j < maxm; j += i)
      cnt += bio[j];
    if (cnt > 1) {
      flag = false;
      break;
    }
  }
  if (flag) {
    printf("pairwise coprime");
    return 0;
  }

  flag = true;
  for (int i = 2; i < maxm; i++) {
    int cnt = 0;
    for (int j = i; j < maxm; j += i)
      cnt += bio[j];
    if (cnt == n) {
      flag = false;
      break;
    }
  }

  if (flag) {
    printf("setwise coprime");
  } else
    printf("not coprime");
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 2e5 + 10;
const int maxm = 1e6 + 10;
const int base = 31337;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n;
int a[maxn];
int bio[maxm + 20];

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

  for (int i = 0; i < n; i++)
    bio[a[i]]++;

  bool flag = true;
  for (int i = 2; i < maxm; i++) {
    int cnt = 0;
    for (int j = i; j < maxm; j += i)
      cnt += bio[j];
    if (cnt > 1) {
      flag = false;
      break;
    }
  }
  if (flag) {
    printf("pairwise coprime");
    return 0;
  }

  flag = true;
  for (int i = 2; i < maxm; i++) {
    int cnt = 0;
    for (int j = i; j < maxm; j += i)
      cnt += bio[j];
    if (cnt == n) {
      flag = false;
      break;
    }
  }

  if (flag) {
    printf("setwise coprime");
  } else
    printf("not coprime");
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define str to_string
#define endl "\\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}

map<lint, int> p_factorization(lint n) {
  map<lint, int> soinsu;
  for (int i = 2; i <= sqrt(n); i++) {
    while (n % i == 0) {
      n /= i;
      soinsu[i]++;
    }
  }
  if (n != 1)
    soinsu[n]++;
  return soinsu;
}

// AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  bool pairwise = true;
  vector<int> vec(1000000);
  int n, x, tmp;
  cin >> n;
  cin >> tmp;
  map<lint, int> dic = p_factorization(tmp);
  for (auto p : dic) {
    vec[p.first] = 1;
  }
  for (int i = 1; i < n; i++) {
    cin >> x;
    tmp = __gcd(tmp, x);
    map<lint, int> dic = p_factorization(x);
    if (!pairwise)
      continue;
    for (auto p : dic) {
      if (vec[p.first] == 1) {
        pairwise = false;
      }
      vec[p.first] = 1;
    }
  }
  if (pairwise)
    cout << "pairwise coprime" << endl;
  else if (tmp == 1)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}


Error: TLE

Fixed submission:

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define str to_string
#define endl "\\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}

map<lint, int> p_factorization(lint n) {
  map<lint, int> soinsu;
  for (int i = 2; i <= sqrt(n); i++) {
    while (n % i == 0) {
      n /= i;
      soinsu[i]++;
    }
  }
  if (n != 1)
    soinsu[n]++;
  return soinsu;
}

// AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main() {
  bool pairwise = true;
  vector<int> vec(1000000);
  int n, x, tmp;
  cin >> n;
  cin >> tmp;
  map<lint, int> dic = p_factorization(tmp);
  for (auto p : dic) {
    vec[p.first] = 1;
  }
  for (int i = 1; i < n; i++) {
    cin >> x;
    tmp = __gcd(tmp, x);
    map<lint, int> dic = p_factorization(x);
    if (!pairwise)
      continue;
    for (auto p : dic) {
      if (vec[p.first] == 1) {
        pairwise = false;
      }
      vec[p.first] = 1;
    }
  }
  if (pairwise)
    cout << "pairwise coprime" << endl;
  else if (tmp == 1)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define str to_string
#define endl "\\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}

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

void pf(int x) {
  map<int, int> soinsu;
  while (x > 1) {
    soinsu[minp[x]]++;
    x /= minp[x];
  }
  for (auto p : soinsu) {
    if (vec[p.first])
      pairwise = false;
    else
      vec[p.first] = 1;
  }
}

// AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  for (int i = 2; i <= sqrt(1000000); i++) {
    if (minp[i] == 0) {
      for (int j = i; j < 1000001; j += i) {
        if (minp[j] == 0)
          minp[j] = i;
      }
    }
  }
  for (int i = 2; i < 1000001; i++) {
    if (minp[i] == 0)
      minp[i] = i;
  }
  int n, tmp, x;
  cin >> n >> tmp;
  pf(tmp);
  for (int i = 1; i < n; i++) {
    cin >> x;
    tmp = __gcd(tmp, x);
    if (pairwise)
      pf(x);
  }
  if (pairwise)
    cout << "pairwise coprime" << endl;
  else if (tmp == 1)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}


Error: 0

Fixed submission:

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define str to_string
#define endl "\\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}

vector<int> E(1001, 1);

// AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int tmp;
  for (int i = 2; i <= sqrt(1000); i++) {
    if (E[i]) {
      tmp = i;
      for (int j = i * 2; j < 1001; j += tmp) {
        E[j] = 0;
      }
    }
  }
  bool pairwise = true, is_prime;
  vector<int> pn(0);
  for (int i = 2; i < 1001; i++) {
    if (E[i])
      pn.pb(i);
  }
  int n, x;
  cin >> n >> tmp;
  vector<int> vec(100001);
  is_prime = false;
  for (int prime : pn) {
    if (tmp < prime)
      break;
    if (tmp % prime == 0) {
      vec[prime] = 1;
      is_prime = false;
    }
  }
  if (is_prime)
    vec[tmp] = 1;
  for (int i = 1; i < n; i++) {
    cin >> x;
    tmp = __gcd(tmp, x);
    if (!pairwise)
      continue;
    is_prime = true;
    for (int prime : pn) {
      if (x < prime)
        break;
      if (x % prime == 0) {
        is_prime = false;
        if (vec[prime])
          pairwise = false;
        vec[prime] = 1;
      }
    }
    if (is_prime)
      vec[x] = 1;
  }
  if (pairwise)
    cout << "pairwise coprime" << endl;
  else if (tmp == 1)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

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

int cnt[1000 * 1000 + 2];
bool ok;
void factorize(int n) {
  //    cout<<n<<"*"<<endl;
  if (n % 2 == 0) {
    while (n % 2 == 0)
      n /= 2;
    cnt[2]++;
    if (cnt[2] > 1)
      ok = 0;
    //        cout<<2<<endl;
  }
  for (int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      while (n % i == 0)
        n /= i;
      cnt[i]++;
      if (cnt[i] > 1)
        ok = 0;
      //            cout<<i<<endl;
    }
  }
  if (n > 2) {
    cnt[n]++;
    if (cnt[n] > 1)
      ok = 0;
    //        cout<<n<<endl;
  }
}
int32_t main() {
  int n;
  scanf("%d", &n);
  vector<int> N(n);
  int cgcd = 0;
  ok = 1;
  for (int &x : N)
    scanf("%d", &x), cgcd = __gcd(cgcd, x);
  for (int x : N) {
    factorize(x);
    if (!ok)
      break;
  }
  if (ok)
    printf("pairwise coprime\\n"), exit(0);
  if (cgcd == 1)
    printf("setwise coprime\\n"), exit(0);
  printf("not coprime\\n");
  return 0;
}
/*


*/


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int cnt[1000 * 1000 + 2];
bool ok;
void factorize(int n) {
  //    cout<<n<<"*"<<endl;
  if (n % 2 == 0) {
    while (n % 2 == 0)
      n /= 2;
    cnt[2]++;
    if (cnt[2] > 1)
      ok = 0;
    //        cout<<2<<endl;
  }
  for (int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      while (n % i == 0)
        n /= i;
      cnt[i]++;
      if (cnt[i] > 1)
        ok = 0;
      //            cout<<i<<endl;
    }
  }
  if (n > 2) {
    cnt[n]++;
    if (cnt[n] > 1)
      ok = 0;
    //        cout<<n<<endl;
  }
}
int32_t main() {
  int n;
  scanf("%lld", &n);
  vector<int> N(n);
  int cgcd = 0;
  ok = 1;
  for (int &x : N)
    scanf("%lld", &x), cgcd = __gcd(cgcd, x);
  for (int x : N) {
    factorize(x);
    if (!ok)
      break;
  }
  if (ok)
    printf("pairwise coprime\\n"), exit(0);
  if (cgcd == 1)
    printf("setwise coprime\\n"), exit(0);
  printf("not coprime\\n");
  return 0;
}
/*


*/
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

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

string solve() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  ll AMAX = 1e6 + 1;
  vector<ll> primes(AMAX, -1);
  for (ll i = 2; i < AMAX; i++) {
    if (primes[i] > 0)
      continue;
    for (ll k = i; k < AMAX; k += i) {
      primes[k] = i;
    }
  }
  vector<ll> cnt(AMAX);
  for (int i = 0; i < N; i++) {
    ll a = A[i];
    map<ll, int> m;
    while (a > 1) {
      m[primes[a]]++;
      a /= primes[a];
    }
    for (auto p : m) {
      cnt[p.first]++;
    }
  }
  bool pc = true, sc = true;
  for (int i = 0; i < AMAX; i++) {
    if (cnt[i] > 1)
      pc = false;
    if (cnt[i] == N)
      sc = false;
  }
  if (pc)
    return "pairwise coprime";
  else if (sc)
    return "setwise coprime";
  else
    return "not coprime";
}

int main() {
  auto ans = solve();
  cout << ans << "\\n";
  return 0;
}

Error: 0

Fixed submission:

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

string solve() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  ll AMAX = 1e6 + 1;
  vector<ll> primes(AMAX, -1);
  for (ll i = 2; i < AMAX; i++) {
    if (primes[i] > 0)
      continue;
    for (ll k = i; k * k < AMAX; k += i) {
      primes[k] = i;
    }
  }
  vector<ll> cnt(AMAX);
  for (int i = 0; i < N; i++) {
    ll a = A[i];
    map<ll, int> m;
    while (a > 1) {
      m[primes[a]]++;
      a /= primes[a];
    }
    for (auto p : m) {
      cnt[p.first]++;
    }
  }
  bool pc = true, sc = true;
  for (int i = 0; i < N; i++) {
    if (cnt[i] > 1)
      pc = false;
    if (cnt[i] == N)
      sc = false;
  }
  if (pc)
    return "pairwise coprime";
  else if (sc)
    return "setwise coprime";
  else
    return "not coprime";
}

int main() {
  auto ans = solve();
  cout << ans << "\\n";
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <unordered_map>
#include <vector>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define dbg(x) cerr << #x << " = " << x << '\\n'
#define sz(x) (int)x.size()
#define all(a) (a.begin(), a.end())
#define ff first
#define ss second
#define pii pair<int, int>
#define lcm(a, b) (a * b) / __gcd(a, b)
using namespace std;

int c[1000005];

inline void solve() {
  int n;
  cin >> n;
  int g = 0, mx = 0;
  for (int i = 0, a; i < n; i++) {
    cin >> a;
    c[a]++;
    g = __gcd(g, a);
  }
  if (g != 1) {
    cout << "not coprime" << endl;
    return;
  }
  int p = 1;
  for (int i = 2; i <= 1000000; i++) {
    int cur = 0;
    for (int j = i; j <= 1000000; j += i)
      cur += c[j];
    if (cur > 1) {
      p = 0;
      break;
    }
    if (i & 1)
      i++;
  }
  if (p > 0)
    cout << "pairwise coprime" << endl;
  else
    cout << "setwise coprime" << endl;
}

signed main() {
  int n = 1; // cin>>n;
  while (n--)
    solve();
  return 0;
}
// https://atcoder.jp/contests/abc177/tasks/abc177_e


Error: TLE

Fixed submission:

/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <unordered_map>
#include <vector>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define dbg(x) cerr << #x << " = " << x << '\\n'
#define sz(x) (int)x.size()
#define all(a) (a.begin(), a.end())
#define ff first
#define ss second
#define pii pair<int, int>
#define lcm(a, b) (a * b) / __gcd(a, b)
using namespace std;

inline void solve() {
  map<int, int> c;
  int n;
  cin >> n;
  int g = 0, mx = 0, e = 0;
  for (int i = 0, a; i < n; i++) {
    cin >> a;
    c[a]++;
    mx = max(mx, a);
  }
  int p = 1, s = 1;
  int cur = 0;
  for (int i = 2; i * i <= mx; i++) {
    int cur = 0;
    for (int j = i; j <= mx; j += i)
      cur += c[j];
    if (cur >= n)
      s = 0;
    if (cur > 1)
      p = 0;
  }
  if (p > 0)
    cout << "pairwise coprime" << endl;
  else if (s > 0)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}

signed main() {
  int n = 1; // cin>>n;
  while (n--)
    solve();
  return 0;
}
// https://atcoder.jp/contests/abc177/tasks/abc177_e
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <unordered_map>
#include <vector>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define dbg(x) cerr << #x << " = " << x << '\\n'
#define sz(x) (int)x.size()
#define all(a) (a.begin(), a.end())
#define ff first
#define ss second
#define pii pair<int, int>
#define lcm(a, b) (a * b) / __gcd(a, b)
using namespace std;

int c[1000001];
inline void solve() {
  int n;
  cin >> n;
  int g = 0, mx = 0;
  for (int i = 0, a; i < n; i++) {
    cin >> a;
    c[a]++;
    g = __gcd(g, a);
  }
  if (g != 1) {
    cout << "not coprime" << endl;
    return;
  }
  int p = 1;
  for (int i = 2; i <= 1000000; i++) {
    int cur = 0;
    for (int j = i; j <= 1000000; j += i)
      cur += c[j];
    if (cur > 1) {
      p = 0;
      break;
    }
    if (i & 1)
      i++;
  }
  if (p > 0)
    cout << "pairwise coprime" << endl;
  else
    cout << "setwise coprime" << endl;
}

signed main() {
  int n = 1; // cin>>n;
  while (n--)
    solve();
  return 0;
}
// https://atcoder.jp/contests/abc177/tasks/abc177_e


Error: TLE

Fixed submission:

/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <unordered_map>
#include <vector>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define dbg(x) cerr << #x << " = " << x << '\\n'
#define sz(x) (int)x.size()
#define all(a) (a.begin(), a.end())
#define ff first
#define ss second
#define pii pair<int, int>
#define lcm(a, b) (a * b) / __gcd(a, b)
using namespace std;

inline void solve() {
  map<int, int> c;
  int n;
  cin >> n;
  int g = 0;
  for (int i = 0, a; i < n; i++) {
    cin >> a;
    c[a]++;
    g = __gcd(g, a);
  }
  if (g != 1) {
    cout << "not coprime" << endl;
    return;
  }
  int p = 1;
  for (int i = 2; i <= 1000000; i++) {
    int cur = 0;
    for (int j = i; j <= 1000000; j += i)
      cur += c[j];
    if (cur > 1) {
      p = 0;
      break;
    }
    if (i & 1)
      i++;
  }
  if (p > 0)
    cout << "pairwise coprime" << endl;
  else
    cout << "setwise coprime" << endl;
}

signed main() {
  int n = 1; // cin>>n;
  while (n--)
    solve();
  return 0;
}
// https://atcoder.jp/contests/abc177/tasks/abc177_e