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

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORD(i, a, b) for (int i = a; i >= b; i--)
#define REP(i, n) FOR(i, 0, n)
#define pb push_back
#define en "\\n"
#define ITER(i, a) for (typeof(a.begin()) i = a.begin(); i != a.end(); i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a, b) memset((a),(b),sizeof((a))
typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef vector<int> VI;
typedef long long int LL;

int main() {
  // your code goes here
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long int n;
  cin >> n;
  long int a[n];
  for (long int i = 0; i < n; i++)
    cin >> a[i];
  bool d = true;
  long int b[1000001] = {0};
  for (long int i = 0; i < n; i++) {
    for (long int j = 2; j <= sqrt(a[i]); j++) {
      if (a[i] % j == 0) {
        b[j]++;
        if (j * j != a[i]) {
          b[a[i] / j]++;
        }
      }

      if (b[j] >= 2 || b[a[i] / j] >= 2) {
        d = false;
        break;
      }
    }
    if (a[i] > 1)
      b[a[i]]++;
    if (b[a[i]] >= 2) {
      d = false;
      break;
    }
  }
  for (long int i = 2; i < 1000001; i++) {
    if (b[i] >= 2) {
      d = false;
      break;
    }
  }
  if (d == true)
    cout << "pairwise coprime" << en;
  else {
    long int g = a[0];
    for (long int i = 1; i < n; i++) {
      g = __gcd(a[i], g);
      /// cout<<g<<en;
    }
    // cout<<g<<en;
    if (g == 1)
      cout << "setwise coprime" << en;
    else
      cout << "not coprime" << en;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORD(i, a, b) for (int i = a; i >= b; i--)
#define REP(i, n) FOR(i, 0, n)
#define pb push_back
#define en "\\n"
#define ITER(i, a) for (typeof(a.begin()) i = a.begin(); i != a.end(); i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a, b) memset((a),(b),sizeof((a))
typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef vector<int> VI;
typedef long long int LL;

int main() {
  // your code goes here
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  bool d = true;
  int b[1000001] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= sqrt(a[i]); j++) {
      if (a[i] % j == 0) {
        b[j]++;
        if (j * j != a[i]) {
          b[a[i] / j]++;
        }
      }
    }
  }

  for (int i = 2; i < 1000001; i++) {
    if (b[i] >= 2) {
      d = false;
      break;
    }
  }
  if (d == true)
    cout << "pairwise coprime" << en;
  else {
    int g = a[0];
    for (int i = 1; i < n; i++) {
      g = __gcd(a[i], g);
      /// cout<<g<<en;
    }
    // cout<<g<<en;
    if (g == 1)
      cout << "setwise coprime" << en;
    else
      cout << "not coprime" << en;
  }
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"

#define ll long long int
#define ld long double
#define fastIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr)
#define pb push_back

using namespace std;
typedef pair<int, int> pii;

bool hasGCD[1000001] = {false};

bool decompose(int n) {
  bool found = true;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (hasGCD[i])
        found = false;
      hasGCD[i] = true;
      while (n % i == 0)
        n /= i;
    }
  }
  if (n != 1) {
    if (hasGCD[n])
      found = false;
    hasGCD[n] = true;
  }

  return found;
}

int main() {
  fastIO;
  int n;
  cin >> n;
  int a[n];
  for (int &i : a)
    cin >> i;

  bool isPairwise = true;
  for (int i = 0; i < n; i++) {
    isPairwise = isPairwise && decompose(a[i]);
  }
  if (isPairwise) {
    cout << "pairwise coprime";
    return 0;
  }

  int gcd = a[0];
  for (int i = 0; i < n; i++) {
    gcd = __gcd(gcd, a[i]);
  }
  if (gcd == 1)
    cout << "setwise coprime";
  else
    cout << "not coprime";
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"

#define ll long long int
#define ld long double
#define fastIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr)
#define pb push_back

using namespace std;
typedef pair<int, int> pii;

bool hasGCD[1000001] = {false};

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

int main() {
  fastIO;
  int n;
  cin >> n;
  int a[n];
  for (int &i : a)
    cin >> i;

  bool isPairwise = true;
  for (int i = 0; i < n; i++) {
    isPairwise = isPairwise && decompose(a[i]);
  }
  if (isPairwise) {
    cout << "pairwise coprime";
    return 0;
  }

  int gcd = a[0];
  for (int i = 0; i < n; i++) {
    gcd = __gcd(gcd, a[i]);
  }
  if (gcd == 1)
    cout << "setwise coprime";
  else
    cout << "not coprime";
}
Problem p02574 (C++) — buggy submission, verdict: Runtime Error

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

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

  int a[n], mx = 0;
  rep(i, n) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }

  bool check = true;

  vector<int> v(mx + 1, 0), s(mx + 1, 0);
  for (itn i = 0; i <= mx; i++)
    s[i] = 0;
  for (int i = 0; i < n; i++)
    s[a[i]]++;

  for (int i = 2; i <= mx; i++) {
    if (v[i] != 0)
      continue;
    v[i]++;

    int cnt = 0;
    cnt += s[i];
    for (int j = 2 * i; j <= mx; j += i) {
      v[i]++;
      cnt += s[j];
    }
    if (cnt >= 2)
      check = false;
    if (cnt == n) {
      cout << "not coprime" << endl;
      return 0;
    }
  }

  if (check)
    cout << "pairwise coprime" << endl;
  else
    cout << "setwise coprime" << endl;
}

Error: 0

Fixed submission:

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

int main(void) {
  int n;
  cin >> n;
  int a[n];
  int mx = 0;
  map<int, int> mp;
  rep(i, n) {
    cin >> a[i];
    mx = max(mx, a[i]);
    mp[a[i]]++;
  }

  vector<int> v(mx + 2, 0);
  vector<int> s(mx + 2, 0);
  for (int i = 2; i < n; i++) {
    if (v[i] != 0)
      continue;

    v[i]++;

    for (int j = 2 * i; j <= mx; j += i) {
      v[j]++;
      if (mp[j] > 0)
        s[i]++;
    }
  }

  bool check = true, check2 = true;
  for (int i = 2; i < mx; i++) {
    if (s[i] == n)
      check = false;
    if (s[i] >= 2)
      check2 = false;
  }
  if (check2 == true) {
    cout << "pairwise coprime" << endl;
  } else {
    if (check == true)
      cout << "setwise coprime" << endl;
    else
      cout << "not coprime" << endl;
  }
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define endl '\\n'
#define hell 1000000007
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
using namespace std;
#define MAXN 1000001
int spf[MAXN];
int ct[MAXN];
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

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

    // marking smallest prime factor for every
    // number to be itself.
    spf[i] = i;

  // separately marking spf for every even
  // number as 2
  for (int i = 4; i < MAXN; i += 2)
    spf[i] = 2;

  for (int i = 3; i * i < MAXN; i++) {
    // checking if i is prime
    if (spf[i] == i) {
      // marking SPF for all numbers divisible by i
      for (int j = i * i; j < MAXN; j += i)

        // marking spf[j] if it is not
        // previously marked
        if (spf[j] == j)
          spf[j] = i;
    }
  }
}

void getFactorization(int x) {
  // vector<int> ret;
  while (x != 1) {
    int y = spf[x];
    ct[y]++;
    while (spf[x] == y) {
      x = x / spf[x];
    }
  }
  return;
}

signed main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, 0, n) cin >> a[i];
  int x = a[0];
  rep(i, 1, n) { x = gcd(x, a[i]); }
  rep(i, 0, MAXN) ct[i] = 0;
  sieve();

  rep(i, 0, n) { getFactorization(a[i]); }

  int flag = 0;
  rep(i, 0, MAXN) {
    if (ct[i] > 1) {
      flag = 1;
      break;
    }
  }

  if (flag == 0) {
    cout << "pairwise coprime" << endl;
    return 0;
  } else {
    if (x == 1) {
      cout << "setwise coprime" << endl;
      return 0;
    } else {
      cout << "not coprime" << endl;
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define endl '\\n'
#define hell 1000000007
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
using namespace std;

int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

signed main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, 0, n) cin >> a[i];
  int x = a[0];
  rep(i, 1, n) { x = gcd(x, a[i]); }

  int flag = 0;
  rep(i, 0, n) {
    rep(j, i + 1, n) {
      if (gcd(a[i], a[j]) != 1) {
        flag = 1;
        break;
      }
    }
  }
  if (flag == 0) {
    cout << "pairwise coprime" << endl;
    return 0;
  } else {
    if (x == 1) {
      cout << "setwise coprime" << endl;
      return 0;
    } else {
      cout << "not coprime" << endl;
    }
  }
}
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[1000001], 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[1000001];

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

  for (i = 0; i < 1000001; 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[100001], 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[100001];

  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;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

// #define int long long
// signed main(){
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int g = a[0];
  for (int i = 0; i < n; i++) {
    g = __gcd(g, a[i]);
  }
  if (g != 1) {
    cout << "not coprime"
         << "\\n";
    return 0;
  }

  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int m = a[i];
    int d = 2;
    while (d * d <= m) {
      if (m % d)
        d++;
      else {
        mp[d]++;
        while (m % d == 0)
          m /= d;
      }
    }
    mp[m]++;
  }

  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->first != 1 && itr->second > 1) {
      cout << "setwise coprime"
           << "\\n";
      return 0;
    }
  }

  cout << "pairwise coprime"
       << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

// エラトステネスの篩
vector<bool> IsPrime;
void e_sieve(int size) {
  size = max(2, size);
  IsPrime.assign(size, true);
  IsPrime[0] = false;
  IsPrime[1] = false;
  int chk = 2;
  while (chk * chk <= size) {
    if (IsPrime[chk]) {
      int tchk = chk * 2;
      while (tchk <= size) {
        IsPrime[tchk] = false;
        tchk += chk;
      }
    }
    chk++;
  }
}

// #define int long long
// signed main(){
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  int m = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m = max(m, a[i]);
  }
  int g = a[0];
  for (int i = 0; i < n; i++) {
    g = __gcd(g, a[i]);
  }
  if (g != 1) {
    cout << "not coprime"
         << "\\n";
    return 0;
  }

  e_sieve(m + 5);
  vector<int> p;
  for (int i = 0; i < m; i++) {
    if (IsPrime[i])
      p.emplace_back(i);
  }

  for (int i = 0; i < p.size(); i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] % p[i] == 0)
        cnt++;
    }
    if (cnt > 1) {
      cout << "setwise coprime"
           << "\\n";
      return 0;
    }
  }
  cout << "pairwise coprime"
       << "\\n";

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

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

using ll = long long;
const int INF = 1e9 + 100;
const int S = 1e3 + 5;

vector<int> pr;
vector<int> isp(S, 1);
void sieve() {
  for (int p = 2; p < S; p++) {
    if (isp[p]) {
      pr.push_back(p);
      for (int j = p * 2; j < S; j += p) {
        isp[j] = 0;
      }
    }
  }
}

int n;
vector<int> a;
bool f1() {
  vector<int> occ(1e6 + 5, 0);
  for (auto it : a) {
    for (auto p : pr) {
      if (it % p == 0) {
        if (occ[p]) {
          return 0;
        }
        occ[p]++;
        while (it % p == 0) {
          it /= p;
        }
      }
    }
    if (it != 1) {
      if (occ[it]) {
        return 0;
      }
      occ[it]++;
    }
  }
  return 1;
}
bool f2() {
  int allGCD = a[0];
  for (int i = 1; i < n; i++) {
    allGCD = __gcd(allGCD, a[i]);
  }
  return allGCD == 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  sieve();
  // cout<<pr.size()<<'\\n';
  // for (int i = 0; i < 5; i++){
  // 	cout<<pr[i]<<'\\n';
  // }

  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (f1()) {
    cout << "pairwise coprime\\n";
  } else if (f2()) {
    cout << "setwise coprime\\n";
  } else {
    cout << "not coprime\\n";
  }
  return 0;
}

Error: 0

Fixed submission:

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

using ll = long long;
const int INF = 1e9 + 100;
const int S = 1e3 + 5;

vector<int> pr;
vector<int> isp(S, 1);
void sieve() {
  for (int p = 2; p < S; p++) {
    if (isp[p]) {
      pr.push_back(p);
      for (int j = p * 2; j < S; j += p) {
        isp[j] = 0;
      }
    }
  }
}

int n;
vector<int> a;
bool f1() {
  vector<int> occ(S, 0);
  for (auto it : a) {
    for (auto p : pr) {
      if (it % p == 0) {
        if (occ[p]) {
          return 0;
        }
        occ[p]++;
        while (it % p == 0) {
          it /= p;
        }
      }
    }
    if (it != 1) {
      if (occ[it]) {
        return 0;
      }
      occ[it]++;
    }
  }
  return 1;
}
bool f2() {
  int allGCD = a[0];
  for (int i = 1; i < n; i++) {
    allGCD = __gcd(allGCD, a[i]);
  }
  return allGCD == 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  sieve();
  // cout<<pr.size()<<'\\n';
  // for (int i = 0; i < 5; i++){
  // 	cout<<pr[i]<<'\\n';
  // }

  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (f1()) {
    cout << "pairwise coprime\\n";
  } else if (f2()) {
    cout << "setwise coprime\\n";
  } else {
    cout << "not coprime\\n";
  }
  return 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
vector<int> primes[1000006];
void find_prime() {
  for (int i = 2; i <= 1e6; i++) {
    if (!sz(primes[i]))
      for (int j = i; j <= 1e6; j += i)
        primes[j].pb(i);
  }
}
int n;
int used[1000006];
void func(int a) {
  for (int i : primes[a])
    used[i]++;
}
void final() {
  int kind = 0;
  for (int i = 0; i <= 1e6; i++) {
    //	cout<<used[i]<<' ';
    if (used[i] == n)
      kind = 2ll;
    if (used[i] > 1)
      kind = max(kind, 1ll);
  }
  if (!kind)
    cout << "pairwise coprime";
  if (kind == 1)
    cout << "setwise coprime";
  if (kind == 2)
    cout << "not coprime";
}
signed main() {
  //	time_t a=clock();
  find_prime();
  //	cout<<clock()-a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    func(a);
  }
  final();
  re 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
vector<int> primes[1000006];
void find_prime() {
  for (int i = 2; i <= 1e6; i++) {
    if (!sz(primes[i]))
      for (int j = i; j <= 1e6; j += i)
        primes[j].pb(i);
  }
}
int n;
int used[1000006];
void func(int a) {
  for (int i : primes[a])
    used[i]++;
}
int final() {
  int kind = 0;
  for (int i = 0; i <= 1e6; i++) {
    //	cout<<used[i]<<' ';
    if (used[i] == n)
      kind = 2ll;
    if (used[i] > 1)
      kind = max(kind, 1ll);
  }
  if (!kind)
    cout << "pairwise coprime";
  if (kind == 1)
    cout << "setwise coprime";
  if (kind == 2)
    cout << "not coprime";
}
signed main() {
  find_prime();
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    func(a);
  }
  final();
  re 0;
}
Problem p02574 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define fio                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
#define endl "\\n"
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

void solution() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int &x : A)
    cin >> x;
  int g = A[0];
  unordered_map<int, int> c;
  for (int x : A) {
    g = __gcd((unsigned)g, (unsigned)x);
    c[x]++;
  }
  if (g > 1) {
    cout << "not coprime" << endl;
    return;
  }
  int m = *max_element(all(A));
  for (int i = 2; i <= m; i++) {
    int cur = 0;
    for (int j = i; j <= m; j += i) {
      cur += c[j];
    }
    if (cur > 1) {
      cout << "setwise coprime" << endl;
      return;
    }
  }
  cout << "pairwise coprime" << endl;
  return;
}

int main() {
  fio;
  int t;
  t = 1;
  // cin >> t;
  for (int i = 1; i <= t; i++) {
    // cout << "Case #" << i << ": ";
    solution();
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define fio                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
#define endl "\\n"
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

void solution() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int &x : A)
    cin >> x;
  int g = A[0];
  map<int, int> c;
  for (int x : A) {
    g = __gcd((unsigned)g, (unsigned)x);
    c[x]++;
  }
  if (g > 1) {
    cout << "not coprime" << endl;
    return;
  }
  int m = *max_element(all(A));
  for (int i = 2; i <= m; i++) {
    int cur = 0;
    for (int j = i; j <= m; j += i) {
      cur += c[j];
    }
    if (cur > 1) {
      cout << "setwise coprime" << endl;
      return;
    }
  }
  cout << "pairwise coprime" << endl;
  return;
}

int main() {
  fio;
  int t;
  t = 1;
  // cin >> t;
  for (int i = 1; i <= t; i++) {
    // cout << "Case #" << i << ": ";
    solution();
  }
  return 0;
}