Problem p03061 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end + 1, 0, -1):
    x = 0
    for j in a:
        if j % i != 0:
            x += 1
        if x >= 2:
            break
    if x <= 1:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
n = int(input())
num_list = list(map(int, input().split()))
num_unique = list(set(num_list))
num_unique.sort()
num_unique.reverse()
max_num = 0
flag = False
for i in range(num_unique[-2], 0, -1):
    if i == 1:
        max_num = 1
        break
    elif flag and count < 2:
        break
    else:
        flag = True
        count = 0
        max_num = i
    for num in num_unique:
        # print("-------------------------------------------")
        # print("最大公約数候補: {0}, 数: {1}, カウント: {2}".format(i, num, count))
        # print("割る： {0}, あまり: {1}".format(num / max_num, num % max_num))
        if num / max_num < 1 or num % max_num != 0:
            count += 1
            if count > 1:
                break
print(max_num)

Buggy submission (verdict: Runtime Error):
n = int(input())
num_list = list(map(int, input().split()))
num_unique = list(set(num_list))
num_unique.sort()
num_unique.reverse()
max_num = 0
flag = False
for i in range(num_unique[-2], 0, -1):
    if i == 1:
        max_num = 1
        break
    elif flag and count < 2:
        break
    else:
        flag = True
        count = 0
        max_num = i
    for num in num_unique:
        print("最大公約数候補: {0}, 数: {1}, カウント: {2}".format(i, num, count))
        print("割る： {0}, あまり: {1}".format(num / max_num, num % max_num))
        if num / max_num < 1 or num % max_num != 0:
            count += 1
            if count > 1:
                break
print(max_num)

Buggy submission (verdict: Runtime Error):
n = int(input())
num_list = list(map(int, input().split()))
num_unique = list(set(num_list))
num_unique.sort()
num_unique.reverse()
max_num = 0
flag = False
for i in range(num_unique[-2], 0, -1):
    if i == 1:
        max_num = 1
        break
    elif flag and count < 2:
        break
    else:
        flag = True
        count = 0
        max_num = i
    for num in num_unique:
        if int(num / max_num) < 1 or num % max_num != 0:
            count += 1
            if count > 1:
                break
print(max_num)

Buggy submission (verdict: Runtime Error):
n = int(input())
num_list = list(map(int, input().split()))
num_unique = list(set(num_list))
num_unique.sort()
num_unique.reverse()
max_num = 0
flag = False
for i in range(num_unique[-2], 0, -1):
    if i == 1:
        max_num = 1
        break
    if flag and count < 2:
        break
    else:
        flag = True
        count = 0
        max_num = i
    for num in num_unique:
        if num / max_num < 1 or num % max_num != 0:
            count += 1
            if count > 1:
                break
print(max_num)

Buggy submission (verdict: Runtime Error):
n = int(input())
num_list = list(map(int, input().split()))
num_unique = list(set(num_list))
num_unique.sort()
num_unique.reverse()
max_num = 0
flag = False
for i in range(num_unique[-2], 0, -1):
    if i == 1:
        max_num = 1
        break

    if flag and count < 2:
        break
    else:
        flag = True
        count = 0
        max_num = i
    for num in num_unique:
        if num / max_num < 1 or num % max_num != 0:
            count += 1
            if count > 1:
                break
print(max_num)

Buggy submission (verdict: Runtime Error):
n = int(input())
num_list = list(map(int, input().split()))
num_unique = list(set(num_list))
num_unique.sort()
num_unique.reverse()
max_num = 0
flag = False
for i in range(num_unique[-2], 0, -1):
    if flag and count < 2:
        break
    elif i == 1:
        max_num = 1
        break
    else:
        flag = True
        count = 0
        max_num = i
    for num in num_unique:
        if int(num / max_num) < 1 or num % max_num != 0:
            count += 1
            if count > 1:
                break
print(max_num)