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

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

struct Eratos {
  vector<int>
      first_prime; // その数を割り切る最小の素数,その数自身のとき素数とわかる
  vector<int> P;

  Eratos(int N) {
    first_prime.resize(N + 1);
    rep(i, N + 1) first_prime[i] = i;
    for (int i = 2; i <= N; i++) {
      if (first_prime[i] == i) {
        for (int j = 2 * i; j <= N; j += i) {
          first_prime[j] = min(first_prime[j], i);
        }
        P.pb(i);
      }
    }
  }
  vector<int> factorization(int n, vector<int> &f) {
    if (n == 1)
      return f;
    else {
      f.pb(first_prime[n]);
      return factorization(n / first_prime[n], f);
    }
  }
};

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  Eratos er(1000002);

  vector<int> s(1000002, 0);
  int judge1 = 1;
  int judge2 = 1;
  rep(i, n) {
    vector<int> g;
    er.factorization(a[i], g);
    rep(j, g.size()) {
      if (j == 0 || (j > 0 && g[j - 1] < g[j]))
        s[g[j]]++;
    }
  }
  rep(i, 1000002) {
    if (s[i] > 1)
      judge1 = 0;
    if (s[i] == n)
      judge2 = 0;
  }
  if (judge1)
    cout << "pairwise coprime" << endl;
  else if (judge2)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}


Error: TLE

Fixed submission:

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

vector<int> Eratosthenes(const int N) {
  vector<bool> is_prime(N + 1);
  for (int i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  vector<int> P;
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> P = Eratosthenes(1000002);

  vector<int> s(1000002, 0);
  int judge1 = 1;
  int judge2 = 1;
  rep(i, n) {
    rep(j, P.size()) {
      if (a[i] % P[j] == 0) {
        if (s[P[j]])
          judge1 = 0;
        s[P[j]]++;
        if (s[P[j]] == n)
          judge2 = 0;
      }
    }
  }
  if (judge1)
    cout << "pairwise coprime" << endl;
  else if (judge2)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#define N 1000005
using namespace std;
using ll = long long;

int p[N];
void sieve(int n) {
  p[1] = 1;
  p[0] = 1;
  for (ll i = 2; i <= n; ++i) {
    if (p[i] == 0) {
      p[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        p[j] = i;
      }
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &ai : a)
    cin >> ai;
  int max_a = *max_element(a.begin(), a.end());
  sieve(max_a);
  vector<int> cnt(max_a + 1, 0);
  for (auto ai : a) {
    while (ai > 1) {
      int prime = p[ai];
      while (ai % prime == 0)
        ai /= prime;
      ++cnt[prime];
    }
  }

  bool pairwise = true;
  for (int i = 0; i <= max_a; ++i) {
    if (cnt[i] > 1) {
      pairwise = false;
      break;
    }
  }
  if (pairwise) {
    cout << "pairwise coprime\\n";
    return 0;
  }
  int setgcd = gcd(a[0], a[1]);
  for (int i = 2; i < n; ++i) {
    setgcd = gcd(setgcd, a[i]);
  }
  if (setgcd == 1) {
    cout << "setwise coprime\\n";
  } else {
    cout << "not coprime\\n";
  }

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#define N 1000005
using namespace std;

int p[N];
void sieve(int n) {
  p[1] = 1;
  p[0] = 1;
  for (int i = 2; i <= n; ++i) {
    if (p[i] == 0) {
      p[i] = i;
      for (int j = i * i; j <= n; j += i) {
        p[j] = i;
      }
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &ai : a)
    cin >> ai;
  int max_a = *max_element(a.begin(), a.end());
  sieve(max_a);
  vector<int> cnt(max_a + 1, 0);
  for (auto ai : a) {
    while (ai > 1) {
      int prime = p[ai];
      while (ai % prime == 0)
        ai /= prime;
      ++cnt[prime];
    }
  }

  bool pairwise = true;
  for (int i = 0; i <= max_a; ++i) {
    if (cnt[i] > 1) {
      pairwise = false;
      break;
    }
  }
  if (pairwise) {
    cout << "pairwise coprime\\n";
    return 0;
  }
  int setgcd = gcd(a[0], a[1]);
  for (int i = 2; i < n; ++i) {
    setgcd = gcd(setgcd, a[i]);
  }
  if (setgcd == 1) {
    cout << "setwise coprime\\n";
  } else {
    cout << "not coprime\\n";
  }

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

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1000010;
int N;
int A[MAX_N];
bool sieve[1010];
vector<int> primes;
int prime_count[1000010];

void compute_primes() {
  fill(sieve + 2, sieve + 1000, true);
  for (int i = 2; i <= 1000; i++) {
    if (sieve[i]) {
      for (int j = 2; i * j <= 1000; j++)
        sieve[i * j] = false;
    }
  }

  for (int i = 2; i <= 1000; i++)
    if (sieve[i])
      primes.push_back(i);
}

void process(int x) {
  for (int i = 0; i < (int)primes.size() && x > 1; i++) {
    if (x % primes[i] == 0) {
      ++prime_count[primes[i]];
      while (x % primes[i] == 0)
        x /= primes[i];
    }
  }
  if (x > 1)
    ++prime_count[x];
}

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

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

  compute_primes();

  for (int i = 0; i < N; i++)
    process(A[i]);

  bool pairwise = true, setwise = true;
  for (int i = 2; i <= 1000000; i++) {
    if (prime_count[i] > 1)
      pairwise = false;
    if (prime_count[i] == N)
      setwise = false;
  }

  if (pairwise)
    cout << "pairwise coprime\\n";
  else if (setwise)
    cout << "setwise coprime\\n";
  else
    cout << "not coprime\\n";

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1000010;
int N;
int A[MAX_N];
bool sieve[1000010];
vector<int> primes;
int prime_count[1000010];

void compute_primes() {
  fill(sieve + 2, sieve + 1000000, true);
  for (int i = 2; i <= 1000000; i++) {
    if (sieve[i]) {
      for (int j = 2; i * j <= 1000000; j++)
        sieve[i * j] = false;
    }
  }

  for (int i = 2; i <= 1000000; i++)
    if (sieve[i])
      primes.push_back(i);
}

void process(int x) {
  for (int i = 0; i < (int)primes.size() && x > 1; i++) {
    if (x % primes[i] == 0) {
      ++prime_count[primes[i]];
      while (x % primes[i] == 0)
        x /= primes[i];
    }
  }
}

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

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

  compute_primes();

  for (int i = 0; i < N; i++)
    process(A[i]);

  bool pairwise = true, setwise = true;
  for (int i = 2; i <= 1000000; i++) {
    if (prime_count[i] > 1)
      pairwise = false;
    if (prime_count[i] == N)
      setwise = false;
  }

  if (pairwise)
    cout << "pairwise coprime\\n";
  else if (setwise)
    cout << "setwise coprime\\n";
  else
    cout << "not coprime\\n";

  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  int prime[1000011];
  memset(prime, 0, sizeof(prime));
  for (int i = 2; i <= 1000000; i++) {
    if (prime[i] == 0) {
      for (int j = i; j <= 1000000; j = j + i) {
        if (prime[j] == 0) {
          prime[j] = i;
        }
      }
    }
  }
  int n = 0, z = 0, x = 0, arr[1000011], q = 1;
  memset(arr, 0, sizeof(arr));
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> z;
    // if(z==1){continue;}
    // else{
    if (x == 0) {
      x = z;
    } else
      x = __gcd(x, z);
    // if(x!=1){}
    set<int> p;
    while (z > 1) {
      p.insert(prime[z]);
      z /= prime[z];
    }
    for (auto k : p) {
      if (arr[k]) {
        q = 0;
      }
      arr[k] = 1;
    }
    //}
  }
  if (q) {
    cout << "pairwise coprime" << endl;
  } else if (x == 1) {
    cout << "setwise coprime" << endl;
  } else
    cout << "not coprime" << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  int prime[1000001];
  memset(prime, 0, sizeof(prime));
  for (int i = 2; i * i <= 1000000; i++) {
    if (prime[i] == 0) {
      for (ll int j = i; j <= 1000000; j = j + i) {
        if (prime[j] == 0) {
          prime[j] = i;
        }
      }
    }
  }
  int n = 0, z = 0, x = 0, arr[1000001], q = 1;
  memset(arr, 0, sizeof(arr));
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> z;
    // if(z==1){continue;}
    // else{
    if (x == 0) {
      x = z;
    } else
      x = __gcd(x, z);
    // if(x!=1){}
    set<int> p;
    while (z > 1) {
      p.insert(prime[z]);
      z /= prime[z];
    }
    for (auto k : p) {
      if (arr[k]) {
        q = 0;
      }
      arr[k] = 1;
    }
    //}
  }
  if (q) {
    cout << "pairwise coprime" << endl;
  } else if (x == 1) {
    cout << "setwise coprime" << endl;
  } else
    cout << "not coprime" << endl;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 1e6 + 100;
typedef long long ll;

// prime次数
int num[N], n;
inline void divide(int x) {
  for (int i = 2; i <= x / i; i++) {
    if (x % i == 0) {
      num[i]++;
      while (x % i == 0)
        x /= i;
    }
  }
  if (x > 1)
    num[x]++;
}
int main() {

  cin >> n;

  int MaxNum = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    divide(x);

    MaxNum = max(MaxNum, x);
  }

  int f1 = 0;
  for (int i = 2; i <= MaxNum; i++) {
    if (num[i] >= n) {
      puts("not coprime");
      return 0;
    }
    if (num[i] > 1) {
      f1 = 1;
      // return 0;
    }
  }
  if (f1)
    puts("setwise coprime");
  else
    puts("pairwise coprime");
  return 0;
}

Error: 0

Fixed submission:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 2e5 + 100;
typedef long long ll;

// prime次数
int num[N], n;
inline void divide(int x) {
  for (int i = 2; i <= x / i; i++) {
    if (x % i == 0) {
      num[i]++;
      while (x % i == 0)
        x /= i;
    }
  }
  if (x > 1)
    num[x]++;
}
int main() {

  cin >> n;

  int MaxNum = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    divide(x);

    MaxNum = max(MaxNum, x);
  }

  int f1 = 0;
  for (int i = 2; i <= MaxNum; i++) {
    if (num[i] >= n) {
      puts("not coprime");
      return 0;
    }
    if (num[i] > 1) {
      f1 = 1;
      // return 0;
    }
  }
  if (f1)
    puts("setwise coprime");
  else
    puts("pairwise coprime");
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\\n" << (#x) << " = " << (x) << "\\n"
using namespace std;
int n, arr[1000000];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  bool a = true, b = true;
  int count[1000001] = {};
  for (int i = 0; i < n; ++i) {
    int num = arr[i];
    for (int j = 2; j * j <= num; ++j) {
      if (num % j == 0) {
        count[j]++;
        while (num % j == 0)
          num /= j;
      }
    }
    if (num > 1)
      count[num]++;
  }

  for (int i = 0; i < 1000001; ++i) {
    if (count[i] > 1)
      a = false;
    if (count[i] == n)
      b = false;
  }

  if (a) {
    cout << "pairwise coprime";
  } else if (!a && b) {
    cout << "setwise coprime";
  } else {
    cout << "not coprime";
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\\n" << (#x) << " = " << (x) << "\\n"
using namespace std;
int n, arr[1000000];
bool prime[1000001];

void sieve(int n) {
  memset(prime, true, sizeof(prime));

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sieve(1000001);
  bool a = true, b = true;
  for (int i = 2; i < 1000001; ++i) {
    if (prime[i]) {
      int count = 0;
      for (int j = 0; j < n; ++j) {
        if (arr[j] % i == 0)
          count++;
      }
      if (count >= 2) {
        a = false;
      }
      if (count == n) {
        b = false;
        break;
      }
    }
  }
  if (a) {
    cout << "pairwise coprime";
  } else if (!a && b) {
    cout << "setwise coprime";
  } else {
    cout << "not coprime";
  }

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

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

void st() { cout << "setwise coprime"; }

void pr() { cout << "pairwise coprime"; }

void no() { cout << "not coprime"; }
bool primechk[1000007];
map<long long, long long> mp;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, x, cnt, j, bb = 0;
  // preprocess(1000004);
  cin >> n;
  long long arr[n + 5];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < n; i++) {
    x = arr[i];
    for (j = 2; j * j <= x; j++) {
      if (x % j == 0) {
        mp[j]++;
        if (mp[j] == n) {
          no();
          return 0;
        } else if (mp[j] > 1) {
          bb = 1;
        }
        while (x % j == 0) {
          x /= j;
        }
      }
    }
    if (x >= 2) {
      mp[x]++;
      if (mp[x] == n) {
        no();
        return 0;
      } else if (mp[x] > 1) {
        bb = 1;
      }
    }
  }
  if (bb) {
    st();
  } else {
    pr();
  }
  return 0;
}

Error: TLE

Fixed submission:

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

void st() { cout << "setwise coprime"; }

void pr() { cout << "pairwise coprime"; }

void no() { cout << "not coprime"; }
bool primechk[1000007];
map<long long, long long> mp;

int main() {
  long long n, i, x, cnt, j, bb = 0;
  // preprocess(1000004);
  cin >> n;
  long long arr[n + 5];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < n; i++) {
    x = arr[i];
    for (j = 2; j * j <= x; j++) {
      if (x % j == 0) {
        mp[j]++;
        if (mp[j] == n) {
          no();
          return 0;
        } else if (mp[j] > 1) {
          bb = 1;
        }
        while (x % j == 0) {
          x /= j;
        }
      }
    }
    if (x >= 2) {
      mp[x]++;
      if (mp[x] == n) {
        no();
        return 0;
      } else if (mp[x] > 1) {
        bb = 1;
      }
    }
  }
  if (bb) {
    st();
  } else {
    pr();
  }
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

const int N = 1e6;

int cnt[N + 1];
bool flg[N + 1];
std::vector<int> prime;

inline void eular() {
  memset(flg, true, sizeof flg);
  for (int i = 2; i <= N; ++i) {
    if (flg[i]) {
      prime.push_back(i);
    }
    for (std::vector<int>::iterator it = prime.begin();
         it != prime.end() && i * (*it) <= N; ++it) {
      flg[i * (*it)] = false;
      if (i % *it == 0) {
        break;
      }
    }
  }
}

inline void divide(int x) {
  for (std::vector<int>::iterator it = prime.begin();
       it != prime.end() && *it * (*it) <= x; ++it) {
    if (x % *it == 0) {
      cnt[*it]++;
      while (x % *it == 0) {
        x /= *it;
      }
    }
  }
  if (x != 1) {
    cnt[x]++;
  }
}

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

int main() {
  eular();

  int n;
  std::cin >> n;
  int a, g;
  std::cin >> g;
  divide(g);
  for (int i = 1; i < n; ++i) {
    std::cin >> a;
    divide(a);
    g = gcd(a, g);
  }

  if (g != 1) {
    std::cout << "not coprime" << std::endl;
  } else {
    bool flg = true;
    for (std::vector<int>::iterator it = prime.begin(); it != prime.end();
         ++it) {
      if (cnt[*it] > 1) {
        flg = false;
        break;
      }
    }
    if (flg) {
      std::cout << "pairwise coprime" << std::endl;
    } else {
      std::cout << "setwise coprime" << std::endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

const int N = 1e3;

int cnt[N + 1];
bool flg[N + 1];
std::vector<int> prime;

inline void eular() {
  memset(flg, true, sizeof flg);
  for (int i = 2; i <= N; ++i) {
    if (flg[i]) {
      prime.push_back(i);
    }
    for (std::vector<int>::iterator it = prime.begin();
         it != prime.end() && i * (*it) <= N; ++it) {
      flg[i * (*it)] = false;
      if (i % *it == 0) {
        break;
      }
    }
  }
}

inline void divide(int x) {
  for (std::vector<int>::iterator it = prime.begin();
       it != prime.end() && *it * (*it) <= x; ++it) {
    if (x % *it == 0) {
      cnt[*it]++;
      while (x % *it == 0) {
        x /= *it;
      }
    }
  }
  if (x != 1) {
    cnt[x]++;
  }
}

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

int main() {
  eular();

  int n;
  std::cin >> n;
  int a, g;
  std::cin >> g;
  divide(g);
  for (int i = 1; i < n; ++i) {
    std::cin >> a;
    divide(a);
    g = gcd(a, g);
  }

  if (g != 1) {
    std::cout << "not coprime" << std::endl;
  } else {
    bool flg = true;
    for (std::vector<int>::iterator it = prime.begin(); it != prime.end();
         ++it) {
      if (cnt[*it] == 1) {
        flg = false;
        break;
      }
    }
    if (flg) {
      std::cout << "setwise coprime" << std::endl;
    } else {
      std::cout << "pairwise coprime" << std::endl;
    }
  }
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int c[N], a[N];

int gcd(int n, int m) {
  if (m == 0)
    return n;
  return gcd(m, n % m);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    c[a[i]]++;
  }
  int _gcd = 0, f = 0;
  for (int i = 0; i < n; i++) {
    _gcd = gcd(_gcd, a[i]);
  }
  // printf(">\\n");
  for (int i = 2; i < N; i++) {
    int cnt = 0;
    for (int j = i; j < N; j += i) {
      //	printf("%d %d\\n",i,j);
      cnt += c[j];
      if (cnt > 1) {
        f = 1;
        break;
      }
    }
    if (f)
      break;
  }
  if (f == 0 && _gcd == 1) {
    printf("pairwise coprime\\n");
  } else if (_gcd == 1 && f)
    printf("setwise coprime\\n");
  else
    printf("not coprime\\n");
}

/*
1、任意两个互素
2、总gcd==1 且存在不互素的
3、其他

*/

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int nop[N], a[N];
int p[N], cnt;
int s[N];
int gcd(int n, int m) {
  if (m == 0)
    return n;
  return gcd(m, n % m);
}
int main() {
  int n;
  cin >> n;
  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]);
  }
  for (int i = 2; i < N; i++) {
    if (nop[i])
      continue;
    for (int j = i + i; j < N; j += i) {
      nop[j] = 1;
    }
  }
  for (int i = 2; i < N; i++) {
    if (!nop[i])
      p[cnt++] = i;
  } // printf("%d\\n",cnt);
  int f = 0;
  for (int i = 0; i < cnt; i++) {
    int g = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] % p[i] == 0) {
        s[i]++;
        g++;
        if (g > 1)
          break;
        continue;
      }
    }
    if (g > 1) {
      f = 1;
      break;
    }
  }

  if (f == 0 && _gcd == 1) {
    printf("pairwise coprime\\n");
  } else if (_gcd == 1 && f)
    printf("setwise coprime\\n");
  else
    printf("not coprime\\n");
}