Problem p03846 (python)

Fixed submission:
N = int(input())
A = [int(n) for n in input().split()]

def main():
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1
    ks =  all(map(lambda k: k % 2 == 0, d.keys())) or all(map(lambda k: k % 2 != 0, d.keys()))
    if 0 in d:
        d[0] += 1
    vs = all(map(lambda v: v == 2, d.values()))

    if ks and vs:
        n = N if N % 2 == 0 else N - 1
        n //= 2
        ans = 1
        for _ in range(n):
            ans *= 2
            ans %= 1000000007
    else:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(n) for n in input().split()]

def main():
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1
    ks =  all(map(lambda k: k % 2 == 0, d.keys())) or all(map(lambda k: k % 2 != 0, d.keys()))
    if 0 in d:
        d[0] += 1
    vs = all(map(lambda v: v == 2, d.values()))

    if ks and vs:
        base = N if len(d) % 2 == 0 else N - 1
        ans = int(2 ** (base / 2)) % 1000000007
    else:
        ans = 0   
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(n) for n in input().split()]

def main():
    a = sorted(A)
    odd = N % 2 != 0
    if odd:
        a = list(map(lambda t: t[1] if t[0] % 2 == 0 else t[1] - 1, enumerate(a)))
    else:
        a = list(map(lambda t: t[1] - 1 if t[0] % 2 == 0 else t[1], enumerate(a)))
    passed = a == list(range(N))
    if passed:
        base = N - 1 if odd else N
        ans = int(2 ** (base / 2)) % 1000000007
    else:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(n) for n in input().split()]

def main():
    a = sorted(A)
    odd = N % 2 != 0
    if odd:
        a = list(map(lambda t: t[1] if t[0] % 2 == 0 else t[1] - 1, enumerate(a)))
    else:
        a = list(map(lambda t: t[1] - 1 if t[0] % 2 == 0 else t[1], enumerate(a)))
    passed = a == list(range(N))
    if passed:
        base = N - 1 if odd else N
        ans = int(2 ** (base / 2))
    else:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(n) for n in input().split()]

def main():
    a = sorted(A)
    even = a[0] == 0
    aborted = False
    for i in range(N):
        correct = (i if even else i + 1) - (0 if i % 2 == 0 else 1)
        if a[i] != correct:
            aborted = True
            break
    ans = 0 if aborted else int(2 ** ((N - (1 if even else 0)) / 2))
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(n) for n in input().split()]

def main():
    a = sorted(A)
    even = a[0] == 0
    aborted = False
    for i in range(N):
        correct = (i if even else i + 1) - (0 if i % 2 == 0 else 1)
        print(a[i], correct)
        if a[i] != correct:
            aborted = True
            break
    ans = 0 if aborted else int(2 ** ((N - (1 if even else 0)) / 2))
    print(ans)

if __name__ == '__main__':
    main()