Problem p02574 (python)

Fixed submission:
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N = int(input())
A = list(map(int, input().split()))
M = [0] * (10**6+1)
for i in A:
    M[i] += 1
if gcd_list(A) > 1:
    print('not coprime')
    exit()
for i in range(2,10**6+1):
    c = 0
    for j in range(i,10**6+1,i):
        c += M[j]
    if c > 1:
        print('setwise coprime')
        exit()
print('pairwise coprime')

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while search_list[0] <= math.sqrt(number):
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        search_list = [num for num in search_list if num % head_num != 0]
    prime_list.extend(search_list)
    return prime_list
N = int(input())
A = list(map(int, input().split()))
P = get_primenumber(max(A))
D = [False] * (len(P))
c = True
for i in range(N):
    for j in range(len(P)):
        if A[i] % P[j] == 0:
            if D[j]:
                c = False
            D[j] = True
if c:
    print('pairwise coprime')
    exit()
if gcd_list(A) == 1:
    print('setwise coprime')
    exit()
print('not coprime')

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while search_list[0] <= math.sqrt(number):
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        search_list = [num for num in search_list if num % head_num != 0]
    prime_list.extend(search_list)
    return prime_list
N = int(input())
A = list(map(int, input().split()))
P = get_primenumber(max(A))
D = [False] * (len(P))
c = True
for i in range(N):
    for j in range(len(P)):
        if A[i] % P[j] == 0:
            if D[j]:
                c = False
            D[j] = True
if c:
    print('pairwise coprime')
    exit()
if gcd_list(A) == 1:
    print('setwise coprime')
    exit()
print('not coprime')

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcbd_list(numbers):
    return reduce(math.gcd, numbers)
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while search_list[0] <= math.sqrt(number):
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        search_list = [num for num in search_list if num % head_num != 0]
    prime_list.extend(search_list)
    return prime_list
N = int(input())
A = list(map(int, input().split()))
P = get_primenumber(max(A))
D = [False] * (max(A)+1)
c = True
for i in range(N):
    for j in range(len(P)):
        if A[i] % P[j] == 0:
            if D[j]:
                c = False
            D[j] = True
if c:
    print('pairwise coprime')
    exit()
if gcbd_list(A) == 1:
    print('setwise coprime')
    exit()
print('not coprime')

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcbd_list(numbers):
    return reduce(math.gcd, numbers)
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while search_list[0] <= math.sqrt(number):
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        search_list = [num for num in search_list if num % head_num != 0]
    prime_list.extend(search_list)
    return prime_list
N = int(input())
A = list(map(int, input().split()))
P = get_primenumber(max(A))
D = [False] * (10**6+1)
c = True
for i in range(N):
    for j in range(len(P)):
        if A[i] % P[j] == 0:
            if D[j]:
                c = False
            D[j] = True
if c:
    print('pairwise coprime')
    exit()
if gcbd_list(A) == 1:
    print('setwise coprime')
    exit()
print('not coprime')

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcbd_list(numbers):
    return reduce(math.gcd, numbers)
N = int(input())
A = list(map(int, input().split()))
P = [False] * (16 + 1)
c = True
for i in range(N):
    if P[A[i]] == True:
        c = False
    P[A[i]] = True
    for j in range(2, math.floor(A[i]**0.5)+1):
        if A[i] % j == 0:
            if P[j] == True:
                c = False
            P[j] = True
if c == True:
    print('pairwise coprime')
    exit()
if gcbd_list(A) == 1:
    print('setwise coprime')
    exit()
print('not coprime')