Buggy python submission (verdict: Runtime Error):
N = int(input())
A = tuple(map(int, input().split()))
def p(n):
    is_prime = [True if i%2 == 1 else False for i in range(0, n+1) ]
    is_prime[0] = False
    is_prime[1] = False
    is_prime[2] = True # 2は素数
    for i in range(3, int(n**0.5) + 1, 2):
        if not is_prime[i]:
            continue
        # iの倍数は素数ではないとする
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = p(max(A))
fact_counts = dict()
for a in A:
    aa = a*a
    for p in primes:
        if p > aa:
            continue
        if a%p == 0:
            fact_counts.setdefault(p, 0)
            fact_counts[p] += 1
pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')

Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = tuple(map(int, input().split()))
def p(n):
    is_prime = [True if i%2 == 1 else False for i in range(0, n+1) ]
    is_prime[0] = False
    is_prime[1] = False
    is_prime[2] = True # 2は素数
    # 3からの奇数について
    for i in range(3, int(n**0.5) + 1, 2):
        # 既に素数の倍数であればスキップ
        if not is_prime[i]:
            continue
        # iの倍数は素数ではないとする
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = p(max(A))
fact_counts = dict()
for a in A:
    for p in primes:
        if p > a:
            continue
        if a%p == 0:
            fact_counts.setdefault(p, 0)
            fact_counts[p] += 1
pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == n:
        print('not coprime')
    else:
        print('setwise coprime')

Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = tuple(map(int, input().split()))
def p(n):
    is_prime = [True if i%2 == 1 else False for i in range(0, n+1) ]
    is_prime[0] = False
    is_prime[1] = False
    is_prime[2] = True # 2は素数
    # 3からの奇数について
    for i in range(3, int(n**0.5) + 1, 2):
        # 既に素数の倍数であればスキップ
        if not is_prime[i]:
            continue
        # iの倍数は素数ではないとする
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = p(max(A))

fact_counts = dict()
for a in A:
    for p in primes:
        if a%p == 0:
            fact_counts.setdefault(p, 0)
            fact_counts[p] += 1

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == n:
        print('not coprime')
    else:
        print('setwise coprime')


Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = tuple(map(int, input().split()))
fact_counts = dict()
def fact(n):
    if n%2 == 0:
        fact_counts.setdefault(2, 0)
        fact_counts[2] += 1
        while n%2 == 0:
            n //= 2

    for f in range(3, int(n**0.5)+1, 2):
        if n%f == 0:
            fact_counts.setdefault(f, 0)
            fact_counts[f] += 1
            while n%f == 0:
                n //= f

    if n > 1:
        fact_counts.setdefault(n, 0)
        fact_counts[n] += 1

for a in A:
    fact(a)

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == n:
        print('not coprime')
    else:
        print('setwise coprime')


Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = tuple(map(int, input().split()))
fact_counts = dict()
def fact(n):
    if n%2 == 0:
        fact_counts.setdefault(2, 0)
        fact_counts[2] += 1
    while n%2 == 0:
        n //= 2

    for f in range(3, int(n**0.5)+1, 2):
        if n%f == 0:
            fact_counts.setdefault(f, 0)
            fact_counts[f] += 1
        while n%f == 0:
            n //= f
    if n > 1:
        fact_counts.setdefault(n, 0)
        fact_counts[n] += 1

for a in A:
    fact(a)

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == n:
        print('not coprime')
    else:
        print('setwise coprime')


Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = tuple(map(int, input().split()))
# fact_counts = [0] * (10**6+1)
fact_counts = dict()
def fact(n):
    if n%2 == 0:
        # fact_counts[2] += 1
        fact_counts.setdefault(2, 0)
        fact_counts[2] += 1
    while n%2 == 0:
        n //=2

    for f in range(3, int(n**0.5)+ 1, 2):
        if n%f == 0:
            # fact_counts[f] += 1
            fact_counts.setdefault(f, 0)
            fact_counts[f] += 1
        while n%f == 0:
            n //= f
    if n != 1:
        # fact_counts[n] += 1
        fact_counts.setdefault(n, 0)
        fact_counts[n] += 1

for a in A:
    fact(a)

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == n:
        print('not coprime')
    else:
        print('setwise coprime')


Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = tuple(map(int, input().split()))

fact_counts = [0] * (10**6+1)
def fact(n):
    if n%2 == 0:
        fact_counts[2] += 1
    while n%2 == 0:
        n //=2

    for f in range(3, int(n**0.5)+ 1, 2):
        if n%f == 0:
            fact_counts[f] += 1
        while n%f == 0:
            n //= f
    if n != 1:
        fact_counts[n] += 1

for a in A:
    fact(a)

pairwise = True
for c in fact_counts:
    if c > 1:
        pairwise = False

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts) == n:
        print('not coprime')
    else:
        # すべてに共通する素因数が見つからなかったら
        print('setwise coprime')


Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = tuple(map(int, input().split()))
def fact(n):
    factors = set()
    while n%2 == 0:
        factors.add(2)
        n //=2

    for f in range(3, int(n**0.5)+ 1, 2):
        while n%f == 0:
            factors.add(f)
            n //= f
    if n != 1:
        factors.add(n)
    return factors

fact_and = fact(A[0])
fact_or = fact(A[0])

pairwise = True
for a in A[1:]:
    aset = fact(a)
    if len(fact_or & aset):
        # 今まで出てきた素因数と共通するものが見つかったらpairwiseではない
        pairwise = False
    fact_and = fact_and & aset
    fact_or = fact_or | aset

if pairwise:
    print('pairwise coprime')
else:
    if len(fact_and) == 0:
        # すべてに共通する素因数が見つからなかったら
        print('setwise coprime')
    else:
        print('not coprime')


Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')