Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = tuple(map(int, input().split()))
U = 10**6
D = list(range(U+1))
i = 2
while i*i <= U:
  if D[i] != i:
    i += 1
    continue
  for j in range(i*i, U+1, i):
    D[j] = min(D[j], i)
  i += 1
C = [0]*(U+1)
is_pairwise = True
for a in A:
  while a > 1:
    d = D[a]
    while a%d == 0:
      a //= d
    if C[d]:
      is_pairwise = False
    C[d] += 1
if max(C) == n:
  print("not coprime")
else:
  if is_pairwise:
    print("pairwise coprime")
  else:
    print("setwise coprime")

Fixed submission:
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


from collections import defaultdict
n = int(input())
A = tuple(map(int, input().split()))
x = A[0]
M1 = defaultdict(int)
M2 = defaultdict(int)
b = False
for a in A:
    x = gcd(x, a)
    if b:
      continue
    for f, cnt in primeFactor(a).items():
      if cnt >= M1[f]:
        M2[f] = M1[f]
        M1[f] = cnt
      elif cnt >= M2[f]:
        M2[f] = cnt
      if M2[f] >= 1:
        b = True
        break
if x != 1:
    print("not coprime")
    exit()
if b:
  print("setwise coprime")
  exit()
print("pairwise coprime")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


from collections import defaultdict
def main():
  n = int(input())
  A = tuple(map(int, input().split()))
  x = A[0]
  M1 = defaultdict(int)
  M2 = defaultdict(int)
  for a in A:
      x = gcd(x, a)
      for f, cnt in primeFactor(a).items():
        if cnt >= M1[f]:
          M2[f] = M1[f]
          M1[f] = cnt
        elif cnt >= M2[f]:
          M2[f] = cnt
  if x != 1:
      print("not coprime")
      exit()
  for d in M2.values():
      if d >= 1:
          print("setwise coprime")
          exit()
  print("pairwise coprime")
if __name__ == "__main__":
  main()

Fixed submission:
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


from collections import defaultdict
n = int(input())
A = tuple(map(int, input().split()))
x = A[0]
M1 = defaultdict(int)
M2 = defaultdict(int)
b = False
for a in A:
    x = gcd(x, a)
    if b:
      continue
    for f, cnt in primeFactor(a).items():
      if cnt >= M1[f]:
        M2[f] = M1[f]
        M1[f] = cnt
      elif cnt >= M2[f]:
        M2[f] = cnt
      if M2[f] >= 1:
        b = True
        break
if x != 1:
    print("not coprime")
    exit()
if b:
  print("setwise coprime")
  exit()
print("pairwise coprime")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


from collections import defaultdict
n = int(input())
A = tuple(map(int, input().split()))
x = A[0]
M1 = defaultdict(int)
M2 = defaultdict(int)
for a in A:
    x = gcd(x, a)
    for f, cnt in primeFactor(a).items():
      if cnt >= M1[f]:
        M2[f] = M1[f]
        M1[f] = cnt
      elif cnt >= M2[f]:
        M2[f] = cnt
if x != 1:
    print("not coprime")
    exit()
for d in M2.values():
    if d >= 1:
        print("setwise coprime")
        exit()
print("pairwise coprime")

Fixed submission:
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


from collections import defaultdict
n = int(input())
A = tuple(map(int, input().split()))
x = A[0]
M1 = defaultdict(int)
M2 = defaultdict(int)
b = False
for a in A:
    x = gcd(x, a)
    if b:
      continue
    for f, cnt in primeFactor(a).items():
      if cnt >= M1[f]:
        M2[f] = M1[f]
        M1[f] = cnt
      elif cnt >= M2[f]:
        M2[f] = cnt
      if M2[f] >= 1:
        b = True
        break
if x != 1:
    print("not coprime")
    exit()
if b:
  print("setwise coprime")
  exit()
print("pairwise coprime")

Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
from collections import defaultdict
n = int(input())
A = tuple(map(int, input().split()))
x = A[0]
M1 = defaultdict(int)
M2 = defaultdict(int)
for a in A:
    x = gcd(x, a)
    cnt = 0
    while a%2 == 0:
        cnt += 1
        a //= 2
    if cnt >= M1[2]:
        M2[2] = M1[2]
        M1[2] = cnt
    elif cnt >= M2[2]:
        M2[2] = cnt
    f = 3
    cnt = 0
    while f*f <= a:
        if a%f == 0:
            cnt += 1
            a //= f
        else:
            if cnt >= M1[f]:
                M2[f] = M1[f]
                M1[f] = cnt
            elif cnt >= M2[f]:
                M2[f] = cnt
            f += 2
            cnt = 0
    if a != 1:
        if 1 >= M1[a]:
            M2[a] = M1[a]
            M1[a] = 1
        elif 1 >= M2[a]:
            M2[a] = 1
if x != 1:
    print("not coprime")
    exit()
for d in M2.values():
    if d >= 1:
        print("setwise coprime")
        exit()
print("pairwise coprime")

Fixed submission:
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


from collections import defaultdict
n = int(input())
A = tuple(map(int, input().split()))
x = A[0]
M1 = defaultdict(int)
M2 = defaultdict(int)
b = False
for a in A:
    x = gcd(x, a)
    if b:
      continue
    for f, cnt in primeFactor(a).items():
      if cnt >= M1[f]:
        M2[f] = M1[f]
        M1[f] = cnt
      elif cnt >= M2[f]:
        M2[f] = cnt
      if M2[f] >= 1:
        b = True
        break
if x != 1:
    print("not coprime")
    exit()
if b:
  print("setwise coprime")
  exit()
print("pairwise coprime")