Problem p03846 (python)

Fixed submission:
from collections import Counter
import numpy as np

MOD = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))
count = Counter(a)
# 0の個数は、count[0]
num = len(a)
ans = 1


if (num % 2 == 0):
    # 偶数パターン
    temp = 1
    loop = int(num / 2)
    for i in range(loop):
        tar = count[temp]
        if (tar == 2):
            ans *= 2
            temp += 2
        else:
            print(0)
            exit()

else:

    tar0 = count[0]
    if (tar0 == 1):
        pass
    else:
        print(0)
        exit()

    temp = 2

    for i in range(num // 2):
        if (count[temp] == 2):
            ans *= 2
            temp += 2
        else:
            print(0)
            exit()

ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import numpy as np

MOD = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))
count = Counter(a)
# 0の個数は、count[0]
num = len(a)
ans = 1


if (num % 2 == 0):
    # 偶数パターン
    temp = 1
    loop = int(num / 2)
    for i in range(loop):
        tar = count[temp]
        if (tar == 2):
            ans *= 2
            temp += 2
        else:
            print(0)
            exit()

else:

    tar0 = count[0]
    if (tar0 == 1):
        pass
    else:
        print(0)
        exit()

    temp = 2

    for i in range(num // 2):
        if (count[temp] == 2):
            ans *= 2
            temp += 2
        else:
            print(0)
            exit()

ans % = MOD
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import numpy as np

n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
# 1; Counter 同士を比較
# 2; 2step loopで2個であることを確認する。

# > linspace で2個ずつ２ステップのリストを比較して、リストが同じであるかIFチェックする。

# 偶数
if (n % 2 == 0):
    check = [0] * n
    for i in range(1, n, 2):
        check[i - 1] = i
        check[i] = i

    checkC = Counter(check)

    if (checkC == count):
        ans = 2 ** (n / 2)
    else:
        ans = 0
# n = 1
elif (n == 1):
    if (a[0] == 0):
        ans = 1
    else:
        ans = 0


# 奇数
else:
    check = [0] * n
    for i in range(2, n, 2):
        check[i - 1] = i
        check[i] = i

    checkC = Counter(check)
    if (checkC == count):
        ans = 2 ** ((n - 1) / 2)
    else:
        ans = 0

print(int(ans % (10**9 + 7)))

Buggy submission (verdict: Runtime Error):
from collections import Counter
import numpy as np

n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
# 1; Counter 同士を比較
# 2; 2step loopで2個であることを確認する。

# > linspace で2個ずつ２ステップのリストを比較して、リストが同じであるかIFチェックする。

# 偶数
if (n % 2 == 0):
    check = [0] * n
    for i in range(1, n, 2):
        check[i - 1] = i
        check[i] = i

    checkC = Counter(check)

    if (checkC == count):
        ans = 2 ** (n / 2)
    else:
        ans = 0
# n = 1
elif (n == 1):
    if (a[0] == 0):
        ans = 1
    else:
        ans = 0


# 奇数
else:
    check = [0] * n
    for i in range(2, n, 2):
        check[i - 1] = i
        check[i] = i

    checkC = Counter(check)
    if (checkC == count):
        ans = 2 ** ((n - 1) / 2)
    else:
        ans = 0

print(int(ans))

Buggy submission (verdict: Runtime Error):
from collections import Counter
import numpy as np

n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
# 1; Counter 同士を比較
# 2; 2step loopで2個であることを確認する。

# > linspace で2個ずつ２ステップのリストを比較して、リストが同じであるかIFチェックする。

# 偶数
if (n % 2 == 0):
    check = [0] * n
    for i in range(1, n, 2):
        check[i - 1] = i
        check[i] = i

    checkC = Counter(check)

    if (checkC == count):
        ans = 2 ** (n / 2)
    else:
        ans = 0
# 奇数
else:
    check = [0] * n
    for i in range(2, n, 2):
        check[i - 1] = i
        check[i] = i

    checkC = Counter(check)
    if (checkC == count):
        ans = 2 ** ((n - 1) / 2)
    else:
        ans = 0

print(int(ans))

Buggy submission (verdict: Runtime Error):
from collections import Counter
import numpy as np

n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
most = count.most_common()
mostA = np.array(most)
num = mostA[:, 1]

# 偶数
if (n % 2 == 0):

    check = num - 2
    if (np.sum(check) == 0):
        ans = 2 ** (n / 2)

    else:
        ans = 0
# 奇数
else:
    num_0 = count[0]
    if (num_0 == 1):
        mostSort = sorted(most)
        mos1 = np.array(mostSort)
        mos2 = mos1[1:, 1]
        target = mos2
        #target = np.array(mostSort[1:])
        check = target - 2
        if (np.sum(check) == 0):
            ans = 2 ** ((n - 1) / 2)
        else:
            ans = 0
    else:
        ans = 0

print(int(ans))