Buggy python submission (verdict: Time Limit Exceeded):
# E - Coprime
from math import gcd

N = int(input())
A = list(map(int,input().split()))
L = [None]*(10**6+1)
L[1] = set()

def prime(x):
    global L
    if L[x]!=None:
        return L[x]
    p = 2
    while True:
        if x%p==0:
            s = prime(x//p)|set([p])
            L[x] = s
            return L[x]
        p = p+1 if p*p<=x else x
        
G = A[0]
pairwise = True
s = prime(A[0])

for i in range(1,N):
    a = A[i]
    t = prime(a)
    if len(s&t)>0:
        pairwise = False
    s = s|t
    G = gcd(G,a)

if pairwise:
    print('pairwise coprime')
elif G==1:
    print('setwise coprime')
else:
    print('not coprime')

Fixed submission:
# E - Coprime
from math import gcd

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
MAX = 10**6
L = [0]*(MAX+1)

def prime(x):
    global L
    p = 2
    while x>1:
        if L[x]==1:
            return False
        if x%p==0:
            while x%p==0:
                x //= p
            tmp = p
            while tmp<=MAX:
                L[tmp] = 1
                tmp += p
        p = p+1 if p*p<x else x   
    return True
        
G = A[0]
pairwise = True
_ = prime(A[0])

for i in range(1,N):
    a = A[i]
    if pairwise:
        pairwise = prime(a)
    G = gcd(G,a)

if pairwise:
    print('pairwise coprime')
elif G==1:
    print('setwise coprime')
else:
    print('not coprime')

Buggy python submission (verdict: Time Limit Exceeded):
# E - Coprime
from math import gcd

N = int(input())
A = list(map(int,input().split()))

def prime(x):
    s = set()
    p = 2
    while x>1:
        if x%p==0:
            s.add(p)
            while x%p==0:
                x //= p
        p += 1
    return s

G = A[0]
pairwise = True
s = prime(A[0])

for i in range(1,N):
    a = A[i]
    t = prime(a)
    if len(s&t)>0:
        pairwise = False
    s = s|t
    G = gcd(G,a)

if pairwise:
    print('pairwise coprime')
elif G==1:
    print('setwise coprime')
else:
    print('not coprime')

Fixed submission:
# E - Coprime
from math import gcd

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
MAX = 10**6
L = [0]*(MAX+1)

def prime(x):
    global L
    p = 2
    while x>1:
        if L[x]==1:
            return False
        if x%p==0:
            while x%p==0:
                x //= p
            tmp = p
            while tmp<=MAX:
                L[tmp] = 1
                tmp += p
        p = p+1 if p*p<x else x   
    return True
        
G = A[0]
pairwise = True
_ = prime(A[0])

for i in range(1,N):
    a = A[i]
    if pairwise:
        pairwise = prime(a)
    G = gcd(G,a)

if pairwise:
    print('pairwise coprime')
elif G==1:
    print('setwise coprime')
else:
    print('not coprime')

Buggy python submission (verdict: Time Limit Exceeded):
# E - Coprime
from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

def lcm(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

N = int(input())
A = list(map(int,input().split()))
seki = 1
for a in A:
    seki *= a
if lcm_list(A)==seki:
    print('pairwise coprime')
elif gcd_list(A)==1:
    print('setwise coprime')
else:
    print('not coprime')

Fixed submission:
# E - Coprime
from math import gcd

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
MAX = 10**6
L = [0]*(MAX+1)

def prime(x):
    global L
    p = 2
    while x>1:
        if L[x]==1:
            return False
        if x%p==0:
            while x%p==0:
                x //= p
            tmp = p
            while tmp<=MAX:
                L[tmp] = 1
                tmp += p
        p = p+1 if p*p<x else x   
    return True
        
G = A[0]
pairwise = True
_ = prime(A[0])

for i in range(1,N):
    a = A[i]
    if pairwise:
        pairwise = prime(a)
    G = gcd(G,a)

if pairwise:
    print('pairwise coprime')
elif G==1:
    print('setwise coprime')
else:
    print('not coprime')