Problem p03846 (python)

Fixed submission:
# input
N = int(input())
A = list(map(int, input().split()))

cnt = [0 for i in range(N)]
ans = 1

if N % 2 == 0:
    for i in range(N):
        if A[i] % 2 == 0:
            print(0)
            exit()
        cnt[A[i]] += 1
        if cnt[A[i]] > 2:
            print(0)
            exit()
        if cnt[A[i]] == 1:
            ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)
else:
    for i in range(N):
        if A[i] % 2 == 1:
            print(0)
            exit()
        if A[i] > 0:
            cnt[A[i]] += 1
            if cnt[A[i]] > 2:
                print(0)
                exit()
            if cnt[A[i]] == 1:
                ans = (ans * 2) % (10 ** 9 + 7)
        if A[i] == 0:
            cnt[0] += 1
            if cnt[0] > 1:
                print(0)
                exit()
    print(ans)

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
A = list(map(int, input().split()))

cnt = [0 for i in range(N)]
ans = 1

if N % 2 == 0:
    for i in range(N):
        if A[i] % 2 == 0:
            print(0)
            exit()
        cnt[A[i]] += 1
        if cnt[A[i]] > 2:
            print(0)
            exit()
        if cnt[A[i]] == 1:
            ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)
else:
    for i in range(N):
        if A[i] % 2 == 1:
            print(0)
            exit()
        if A[i] > 0:
            cnt[A[i]] += 1
            if cnt[A[i]] > 2:
                print(0)
                exit()
            if cnt[A[i]] == 1:
                ans = (ans * 2) % (10 ** 9 + 7)
        if A[i] == 0:
            cnt[0] += 1
            if cnt[0] > 1:
                print(0)
                exit()
    print(ans)


ans = 1

if N % 2 == 0:
    for i in range(1, N, 2):
        if A.count(i) > 2:
            print(0)
            exit()
    for i in range(N / 2):
        ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)
else:
    if A.count(0) > 1:
        print(0)
        exit()
    for i in range(2, N, 2):
        if A.count(i) > 2:
            print(0)
            exit()
    for i in range(N // 2):
        ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
A = list(map(int, input().split()))

ans = 1

if N % 2 == 0:
    for i in range(1, N, 2):
        if A.count(i) > 2:
            print(0)
            exit()
    for i in range(N / 2):
        ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)
else:
    if A.count(0) > 1:
        print(0)
        exit()
    for i in range(2, N, 2):
        if A.count(i) > 2:
            print(0)
            exit()
    for i in range(N // 2):
        ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
A = map(int, input().split())

count = [0 for i in range(N)]
ans = 1

if N % 2 == 0:
    for i in range(N):
        count[A[i]] += 1
        if count [A[i]] > 2:
             print(0)
             exit()
        if A[i] == 0 and count[A[i]] > 1:
            print(0)
            exit()
        ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)
else:
    for i in range(N):
        if count [A[i]] > 2:
             print(0)
             exit()
        ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)