Problem:


Score : 300 points

Problem Statement

There are N people, conveniently numbered 1 through N.
They were standing in a row yesterday, but now they are unsure of the order in which they were standing.
However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.
According to their reports, the difference above for person i is A_i.

Based on these reports, find the number of the possible orders in which they were standing.
Since it can be extremely large, print the answer modulo 10^9+7.
Note that the reports may be incorrect and thus there may be no consistent order.
In such a case, print 0.

Constraints

1≦N≦10^5

0≦A_i≦N-1

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the number of the possible orders in which they were standing, modulo 10^9+7.

Sample Input 1

5
2 4 4 0 2

Sample Output 1

4

There are four possible orders, as follows:

2,1,4,5,3

2,5,4,1,3

3,1,4,5,2

3,5,4,1,2

Sample Input 2

7
6 4 0 2 4 0 2

Sample Output 2

0

Any order would be inconsistent with the reports, thus the answer is 0.

Sample Input 3

8
7 5 1 1 7 3 5 3

Sample Output 3

16



Sample input:
5
2 4 4 0 2


Sample output:
4

Submission status: Accepted

Solution code:
import sys
from collections import Counter
n = input()
a = [int(x) for x in raw_input().split()]
a.sort()
if n == 1:
    if a[0] == 0:
        print 1
        sys.exit()
c = 0
if n&1:
    if a[0] == 0:
        del a[0]
        d = Counter(a)
        for i in d.keys():
            if i == 0:
                print 0
                sys.exit()
            if i&1:
                print 0
                sys.exit()
            if not(i&1):
                if d[i] == 2:
                    c += 1
                if d[i] != 2:
                    print 0
                    sys.exit()
    if c == (n-1)//2:
        print (1 << c)%(10**9+7)
if not(n&1):
    d = Counter(a)
    for i in d.keys():
        if i&1:
            if d[i] == 2:
                c +=1
            if d[i] != 2:
                print 0
                sys.exit()
        if not(i&1):
            print 0
            sys.exit()
    if c == n//2:
        print (1 << c)%(10**9+7)

Submission status: Accepted

Solution code:
def solve(n,a):
    ct = [0 for _ in range(n)]
    for v in a:
        ct[v] += 1

    if n%2 == 1:
        if ct[0] != 1:
            return 0

        for i in range(1,n):
            if i%2 == 1:
                if ct[i] != 0:
                    return 0
            else:
                if ct[i] != 2:
                    return 0
    else:
        if ct[0] != 0:
            return 0

        for i in range(1,n):
            if i%2 == 1:
                if ct[i] != 2:
                    return 0
            else:
                if ct[i] != 0:
                    return 0

    return 2**(n//2)%(10**9+7)

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(solve(n,a))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

cin = sys.stdin
#cin = open("in.txt", "r")

MODULO = int(10**9+7)
N = int(cin.readline())
A = list(map(int, cin.readline().split()))
pos = [0]*(N+1)
if (N%2==1):
    pos[0]=1
for ai in A:
    if (ai+N)%2==0 or ai>=N or ai<0:
        print(0)
        exit()
    pos[ai]+=1
    if pos[ai]>2:
        print(0)
        exit()
cnt = 1
for i in range(N//2):
    cnt = cnt * 2 % MODULO
print(cnt)

Submission status: Accepted

Solution code:
N = int(raw_input())
A = list(map(int,raw_input().split()))
A.sort()
MOD = 10**9 + 7
def calc(a):
	if N % 2 == 0:
		B = [int(i/2)*2 + 1 for i in range(0,N)]
		if A != B:
			return 0
	else:
		B = [int(i/2)*2 for i in range(1,N+1)]
		if A != B:
			return 0
	return 2 ** int(N/2)

print(calc(A) % MOD)

Submission status: Accepted

Solution code:
N = int(input())
A = map(int, input().split())

if N%2 == 0:
    count = [(2 if i%2 == 1 else 0) for i in range(N)]
else:
    count = [(2 if i%2 == 0 else 0) for i in range(N)]
    count[0] = 1

for a in A:
    count[a] -= 1
    if count[a] < 0:
        print(0)
        break
else:
    print(2**(N//2)%(10**9+7))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter

def maybe_check(n,A):
    try:
        if n <= 0 or n > 100000:
            raise

        div = 1000000007
        maybe_list = [abs(abs(i - n) - ((n -1 ) - abs(i - n))) for i in range(1, n+1)]
        maybe_list.sort()
        A.sort()
        if A !=  maybe_list:
            raise

        pattern = len([num for num,count in Counter(maybe_list).items() if count != 1])
        return (2 ** pattern) % div

    except:
        return 0


_n = int(raw_input())
_A = map(int,raw_input().split())

print maybe_check(_n,_A)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def main():
    n = int(input())
    a = list(map(int, input().split()))
    r = 0
    a.sort()
    if n % 2 == 1:
        if a[0] != 0:
            return 0
        r = 1
        for i in range(n//2):
            if a[i*2+1] == a[i*2+2] and a[i*2+1] == i*2+2:
                r = r*2 % mod
            else:
                return 0
    else:
        r = 1
        for i in range(n//2):
            if a[i*2+1] == a[i*2] and a[i*2+1] == i*2+1:
                r = r*2 % mod
            else:
                return 0

    return r


print(main())

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from collections import Counter
import sys
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7
A = Counter(A)

if N % 2 == 1:
    for num, cnt in A.items():
        # print(num, cnt)
        if num == 0:
            if cnt != 1:
                print(0)
                sys.exit()
        else:
            if not (num % 2 == 0 and cnt == 2):
                print(0)
                sys.exit()
    print((2 ** (N // 2)) % MOD)
else:
    for num, cnt in A.items():
        # print(num, cnt)
        if not (num % 2 == 1 and cnt == 2):
            print(0)
            sys.exit()
    print((2 ** (N // 2)) % MOD)

Submission status: Accepted

Solution code:
def get_possible(n, people):
    counts = {}
    values = set([])
    for person in people:
        if not counts.get(person):
            counts[person] = 1
            values.add(person)
        else:
            counts[person] += 1
 
    # If even
    if n % 2:
        start_value = 0
    else:
        start_value = 1
 
    if values != set([i for i in xrange(start_value, n , 2)]):
        return 0
 
    possibilities = 1
 
    if 0 in values:
        values.remove(0)
 
    for key in list(values):
        if counts.get(key) != 2:
            return 0
        else:
            possibilities *= counts.get(key)
 
    return possibilities
 
 
 
if __name__ == "__main__":
    n = int(raw_input())
    people = map(int, raw_input().split(' '))
    print (get_possible(n, people) % (10**9 + 7))

Submission status: Accepted

Solution code:
from collections import Counter

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

if n % 2 == 0:
    f = True
    for k in a.values():
        f &= k == 2
    if f:
        print(pow(2, n // 2, 10 ** 9 + 7))
    else:
        print(0)
else:
    f = True
    a[0] += 1
    for k in a.values():
        f &= k == 2
    if f:
        print(pow(2, n // 2, 10 ** 9 + 7))
    else:
        print(0)

Submission status: Accepted

Solution code:
import math, sys

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

p = [0] * math.ceil(N / 2)

even = (N & 1 == 0)

for i in range(N):
    p[ int((a[i] - even) / 2) ] += 1

# check
if (even and p[0]!=2) or (not even and p[0]!=1):
    print(0)
    sys.exit()
    
ans = p[0]
for i in range(1, len(p)):
    val = p[i]
    if val!=2:
        print(0)
        sys.exit()
    ans = (ans * p[i]) % 1000000007

print(ans)

Submission status: Accepted

Solution code:
#! /usr/bin/env python3

D = 10**9+7
N = int(input())
A = list(map(int, input().split()))
M = N%2>0
b = 1
C = [0] * (N//2+1)
if M:
    for i in A:
        if i%2 < 1:
            C[i//2] += 1 
    b = (N//2) == sum(1 for x in C[1:] if x == 2) and C[0] == 1
    
else:
    for i in A:
        if i%2 > 0:
            C[i//2] += 1 
    b = (N//2) == sum(1 for x in C if x == 2)

print((2**(N//2))%D if b else 0)

Submission status: Accepted

Solution code:
import math



N = int(raw_input())
A = map(int, raw_input().split())
B = [0] * N

# print A

bad = False

for a in A:
    if N % 2 == 0: # even
        if a % 2 == 0: 
            bad = True
            break

    else:
        if a % 2 == 1:
            bad = True
            break

    r = (a + N - 1) / 2
    leftbig = r
    rightbig = N-1-r



    if leftbig < N and B[leftbig] < 1:
        B[leftbig] = 1
    else:
        if rightbig >= N: 
            bad = True
            break

        if B[rightbig] < 1:
            B[rightbig] = 1
        else:
            bad = True
            break

if bad:
    print '0'
else:
    if N % 2 == 0:
        print pow(2, N/2, 10**9+7)
    else:
        print pow(2, (N-1)/2, 10**9+7)

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3


P = 10 ** 9 + 7


def count_perms(n, xs, mod=P):
    if n % 2 == 0:
        std = sorted(list(range(1, n, 2)) * 2)
    else:
        std = sorted([0] + list(range(2, n, 2)) * 2)
    if sorted(xs) != std:
        return 0
    elif n % 2 == 0:
        return pow(2, (n - 2) // 2 + 1, mod)
    else:
        return pow(2, (n - 1) // 2, mod)


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    print(count_perms(n, xs))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
A.reverse()
if N % 2:
	B = [i for i in range(2,N,2)]*2
	B.sort()
	B.reverse()
	B.append(0)
else:
	B = [i for i in range(1,N,2)]*2
	B.sort()
	B.reverse()
if A == B:
	ans = 2**(N//2)
else:
	ans = 0
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
n = int(raw_input())
a = sorted(map(int, raw_input().split()))

x = []
if n % 2 == 0:
    for i in range(1, n, 2):
        x.extend([i, i])
else:
    x.append(0)
    for i in range(2, n, 2):
        x.extend([i, i])

if a == x:
    if n % 2 == 0:
        print (2 ** (n/2)) % (10 ** 9 + 7)
    else:
        print (2 ** ((n-1)/2)) % (10 ** 9 + 7)
else:
    print 0

Submission status: Accepted

Solution code:
#!coding:utf-8

n = input()
a = [int(i) for i in raw_input().split()]
a.sort()

ok = True

if(n%2==0):
    for i in range(n):
        if(a[i]!=(i/2*2+1)):
            ok = False

if(n%2==1):
    for i in range(n):
        if(a[i]!=((i+1)/2*2)):
            ok = False


if(ok):
    print 2**(n/2)%1000000007
        
else:
    print '0'

Submission status: Accepted

Solution code:
n = input()
a = map(int,raw_input().split())
m = 1000000007

c = [0]*n
ct = 1
for x in a:
    p1 = (n-1+x)/2
    p2 = (n-1-x)/2
    c[p1] += 1
    c[p2] += 1
    if (c[p1]<2 and c[p2]<2):
        ct *= 2
        ct = ct%m
    elif (c[p1]>2 and c[p2]>2):
        ct = 0
        break
print ct

Submission status: Accepted

Solution code:
n = input()
a = map(int, raw_input().split())
a = sorted(a)
c = 1
i = 0
if n%2 == 0:
    k = 1
    while i < len(a):
        if not a[i] == a[i+1] == k:
            print 0
            exit()
        c *= 2
        c %= 10**9 + 7
        i += 2
        k += 2
else:
    if not a[0] == 0:
        print 0
        exit()
    k = 2
    i = 1
    while i < len(a):
        if not a[i] == a[i+1] == k:
            print 0
            exit()
        c *= 2
        c %= 10**9 + 7
        i += 2
        k += 2
print c

Submission status: Accepted

Solution code:
N = input()
A = map(int, raw_input().split())
C = [0]*N
for a in A:
    C[a] += 1
ok = True
if N%2==0 and C[0]!=0 or N%2!=0 and C[0]!=1:
    ok = False
for i in range(N%2+1, N, 2):
    if C[i]!=2:
        ok = False
print 2**(N/2)%(10**9+7) if ok else 0

Submission status: Accepted

Solution code:
import collections

def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    ac = dict(collections.Counter(a))

    if n % 2 == 0:
        if 0 in ac:
            return 0
    else:
        if 0 not in ac or ac[0] != 1:
            return 0
        else:
            del ac[0]
    ans = 1

    for k, v in ac.items():
        if (k + n) % 2 == 1 and v == 2:
            ans = (ans * 2) % 1000000007
        else:
            return 0

    return ans

print(solve())

Submission status: Accepted

Solution code:
from sys import stdin
import math
n = int(stdin.readline())
di = {}
a = map(int,stdin.readline().split())
for i in a:
    di[i] = di.get(i,0)+1
valid = 1

if n%2:
    if di.get(0,0)!=1:
        valid = 0
        
    else:
        for i in di:
            if i==0:
                continue
            if i >=n:
                valid = 0
                break
            if i%2:
                valid = 0
                break
            if di.get(i,0)!=2:
                valid = 0
                break
else:
    for i in di:
        if i>=n:
            break
        if i%2==0:
            valid = 0
            break
        if di.get(i,0)!=2:
            valid = 0
            break
if valid:
    print pow(2,n/2,10**9 + 7)
else:
    print 0

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

MOD = 10**9 + 7

n()
A = ln()

L = len(A)

A.sort()

if L % 2 == 1:
    c = A[0]
    del A[0]
    B = A[1::2][::-1] + [c] + A[0::2]
else:
    B = A[1::2][::-1] + A[0::2]

for i in xrange(L):
    j = L - i - 1
    if abs(i - j) != B[i]:
        print 0
        break
else:
    print pow(2, len(A) / 2, MOD)

Submission status: Accepted

Solution code:
n=int(raw_input())
a=map(int,raw_input().split())
a.sort()
if n%2==0:
    i=0
    j=-1
    while i<n-1:
        j+=1
        if a[i]==a[i+1]==2*j+1:
            i+=2
            continue
        else:
            print(0)
            exit()
    print(pow(2,n/2,10**9+7))
else:
    i=1
    j=0
    while i<n-1:
        j+=1
        if a[i]==a[i+1]==2*j:
            i+=2
            continue
        else:
            print(0)
            exit()
    print(pow(2,(n-1)/2,10**9+7))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
	sta=[1,1]
	s=3
else:
	sta=[0]
	s=2

for i in range(s,n)[::2]:
	sta.append(i)
	sta.append(i)

if sorted(sta)!=sorted(a):
	print(0)
	exit()

i=int(n/2)
print(pow(2,i,10**9+7))

Submission status: Accepted

Solution code:
n = input()
A = map(int, raw_input().split())
C = [0]*((n+1)/2)
MOD = 10**9+7
for e in A:
    C[e/2] += 1
if n%2 == 1:
    if C[0] != 1 or any(C[i] != 2 for i in xrange(1, (n+1)/2)):
        print 0
        exit(0)
    print pow(2, (n-1)/2, MOD)
if n%2 == 0:
    if any(C[i] != 2 for i in xrange((n+1)/2)):
        print 0
        exit(0)
    print pow(2, n/2, MOD)

Submission status: Accepted

Solution code:
import collections
n = int(input())
a = list(map(int, input().split()))

MOD = 10**9 + 7
cnt = collections.Counter(a)
if n%2 == 0:
    ans = 1
    for i in range(1,n, 2):
        if cnt[i] == 2:
            ans = ans*2%MOD
        else:
            print(0)
            exit()
else:
    ans = 1
    for i in range(2,n, 2):
        if cnt[i] == 2:
            ans = ans*2%MOD
        else:
            print(0)
            exit()
    if cnt[0] != 1:
        print(0)
        exit()
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
N_orig = N
As = list(map(int,input().split()))
As.sort()

Bs = []
if N % 2 == 1:
    Bs.append(0)
    N -= 1
    b = 2
else:
    b = 1

while N > 0:
    Bs.append(b)
    Bs.append(b)
    N -= 2
    b += 2

if As != Bs:
    print(0)
else:
    print(pow(2, N_orig // 2, 1000000007))

Submission status: Accepted

Solution code:
from collections import Counter
N = int(raw_input())
A = sorted(map(int, raw_input().split()))
mod = 10**9+7

if N%2 == 1:
    if A[0] != 0:
        print 0
        exit()
    x = 2
    for i in xrange(1, N, 2):
        if A[i] != x or A[i+1] != x:
            print 0
            exit()
        x += 2
    print pow(2, N/2, mod)
else:
    x = 1
    for i in xrange(0, 2, N):
        if A[i] != x or A[i+1] != x:
            print 0
            exit()
        x += 2
    print pow(2, N/2, mod)

Submission status: Runtime Error

Solution code:
n = int(input())

a_list = list(map(int, input().split()))
a_list.sort()
a_counter = {}
for a in a_list:
    if a in a_counter.keys():
        a_counter[a] += 1
    else:
        a_counter[a] = 1

data_error = False

if n % 2 == 0:
   for i in range(1, n, 2):
       if a_counter[i] != 2:
           data_error = True
else:
    for i in range(0, n, 2):
        if a_counter[i] != 2:
            if i == 0 and a_counter[0] == 1:
                continue
            data_error = True

if data_error:
    print(0)
else:
    print(2**(int(n/2)))

Submission status: Runtime Error

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = map(int, input().split())
    mod = 10**9 + 7
    a.sort()
    check = [i+1 - (i+n)%2 for i in range(n)]
    if a != check:
        print(0)
        return
    else:
        ans = pow(2, n//2, mod)
        print(ans)




if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    mod = 10**9 + 7
    a.sort()
    check = [i+1 - (i+n)%2 for i in range(n)]
    if a != check:
        print(0)
        return
    else:
        ans = pow(2, n//2, mod)
        print(ans)




if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
if N==1:
    if A[0]==0:
        print(1)
    else:
        print(0)
else:
    C = {}
    for i in range(N):
        a = A[i]
        if a not in C:
            C[a]=0
        C[a] += 1
    flag = 0
    if N%2==0:
        for i in range(1,N,2):
            if C[i]==2:continue
            flag=1
            break
    else:
        for i in range(2,N,2):
            if C[i]==2:continue
            flag = 1
            break
        if C[0]!=1:
            flag = 1
    if flag==1:
        print(0)
    else:
        p = 10**9+7
        k = N//2
        ans = 1
        cnt = 1
        while cnt<=k:
            ans = (ans*2)%p
            cnt += 1
        print(ans)

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
A=collections.Counter(list(map(int,input().split())))
if N%2==0:
  for i in range(0,N,2):
    if i%2==0 and A[i]==0:
      pass
    elif i%2==a and A[i]==2:
      pass
    else:
        print(0);exit(0)
else:
  for i in range(N):
    if i==0 and A[i]==1:
      continue
    if i%2==0 and A[i]==2:
      pass
    elif i%2==1 and A[i]==0:
      pass
    else:
      print(0);exit(0)
print(pow(2,N//2,10**9+7 ))

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
A=collections.Counter(list(map(int,input().split())))
if N%2==0:
  for i in range(0,N,2):
    if i%2==0 and A[i]==0:
      pass
    elif i%2==a and A[i]==2:
      pass
    else:
        print(0);exit()
else:
  for i in range(N):
    if i==0 and A[i]==1:
      continue
    if i%2==0 and A[i]==2:
      pass
    elif i%2==1 and A[i]==0:
      pass
    else:
      print(0);exit()
print(pow(2,N//2,10**9+7 ))

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
A=collections.Counter(list(map(int,input().split())))
if N%2==0:
  for i in range(0,N,2):
    if i%2==0 and A[i]==0:
      pass
    elif i%2==a and A[i]==2:
      pass
    else:
        print(0);exit()
  print(2**(N//2))
else:
  for i in range(N):
    if i==0:
      if A[i]!=1:
        print(0);exit()
    elif i%2==0 and A[i]==2:
      pass
    elif i%2==1 and A[i]==0:
      pass
    else:
      print(0);exit()
  print(2**(N//2))

Submission status: Runtime Error

Solution code:
from collections import Counter

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

c_al = Counter(al)
print(c_al)
mod = int(10**9 + 7)

if n % 2 == 0:
    for k,v in c_al.items():
        if v != 2:
            print(0)
            exit()
    print((2 ** (n / 2)) % mod)
elif n % 2 != 0:
    for k, v in c_al.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        elif v != 2:
            print(0)
            exit()
    print((2 ** (n // 2)) % mod)

Submission status: Runtime Error

Solution code:
from collections import Counter

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

c_al = Counter(al)
mod = 10**9 + 7

if n % 2 == 0:
    for k,v in c_al.items():
        if v != 2:
            print(0)
            exit()
    print(int((2 ** (n / 2)) % mod))
elif n % 2 != 0:
    for k, v in c_al.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        elif v != 2:
            print(0)
            exit()
    print(int((2 ** (n // 2)) % mod))

Submission status: Runtime Error

Solution code:
from collections import defaultdict, Counter

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

c_al = Counter(al)
mod = 10**9 + 7

if n % 2 == 0 and 0 not in c_al.values():
    print(int((2 ** (n / 2)) % mod))
elif n % 2 != 0 and c_al[0] == 1:
    print(int((2 ** (n // 2)) % mod))
else:
    print(0)

Submission status: Runtime Error

Solution code:
from collections import defaultdict, Counter

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

c_al = Counter(al)
mod = 10**9 + 7

if n % 2 == 0 and 0 not in c_al.values():
    print((2 ** (n / 2)) % mod)
elif n % 2 != 0 and c_al[0] == 1:
    print((2 ** (n // 2)) % mod)
else:
    print(0)

Submission status: Runtime Error

Solution code:
from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))

c_al  = Counter(al)

if n % 2 == 0 and 0 not in c_al.values():
    print(int(2**(n/2))%((10**9) + 7))
elif n % 2 != 0 and c_al[0] == 1:
    print(int(2 ** (n // 2))%((10**9) + 7))
else:
    print(0)

Submission status: Runtime Error

Solution code:
from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))

c_al  = Counter(al)

if n % 2 == 0 and 0 not in c_al.values():
    print(int(2**(n/2))%(10**9) + 7)
elif n % 2 != 0 and c_al[0] == 1:
    print(int(2 ** (n // 2))%(10**9) + 7)
else:
    print(0)

Submission status: Runtime Error

Solution code:
from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))

c_al  = Counter(al)

if n % 2 == 0 and 0 not in c_al.values():
    print(int(2**(n/2)))
elif n % 2 != 0 and c_al[0] == 1:
    print(int(2 ** (n // 2)))
else:
    print(0)

Submission status: Runtime Error

Solution code:
from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))

c_al  = Counter(al)

if n % 2 == 0 and 0 not in c_al.values():
    print(int(2**(n/2)))
elif n % 2 != 0 and c_al[0] == 1:
    print(int(2 ** ((n // 2))))
else:
    print(0)

Submission status: Runtime Error

Solution code:
from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))

c_al  = Counter(al)

if n % 2 == 0 and 0 not in c_al.values():
    print(int(2**(n/2)))
elif n % 2 != 0 and c_al[0] == 1:
    print(int(2 ** ((n // 2))))

Submission status: Runtime Error

Solution code:
from collections import Counter, defaultdict, deque


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

al = list(map(int, input().split()))

if n == 1 and al[0] == 0:
    print(1)
elif n == 2:
    if 0 not in al:
        print(2)
    else:
        print(0)

if n % 2 == 0:
    lst = [0] * n
    for i in range(1, n):
        x = (al[i - 1] + n - 1) / 2
        y = x - al[i - 1]
        # print(x,y)
        # print(n-x-1,x)
        lst[int(n - x - 1)] += 1
        lst[int(x)] += 1
        if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
            print(0)
            exit()
    # print(lst)
    if 0 not in lst:
        print(int(2 ** (n / 2)) % ((10 ** 9) + 7))
    else:
        print(0)
else:
    lst = [0] * n
    for i in range(1, n):
        x = (al[i - 1] + n - 1) / 2
        y = x - al[i - 1]
        # print(x,y)
        # print(n - x - 1, x)
        if x == y:
            lst[int(x)] += 1
        else:
            lst[int(n - x - 1)] += 1
            lst[int(x)] += 1
        if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
            print(0)
            exit()
    # print(lst)
    if 0 not in lst:
        print(int(2 ** ((n - 1) / 2)) % ((10 ** 9) + 7))
    else:
        print(0)

Submission status: Runtime Error

Solution code:
from collections import Counter, defaultdict, deque


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

al = list(map(int, input().split()))

if n == 1 and al[0] == 0:
    print(1)
elif n == 2:
    if 0 not in al:
        print(2)
    else:
        print(0)

if n % 2 == 0:
    lst = [0] * n
    for i in range(1, n):
        x = (al[i - 1] + n - 1) / 2
        y = x - al[i - 1]
        # print(x,y)
        # print(n-x-1,x)
        lst[int(n - x - 1)] += 1
        lst[int(x)] += 1
        if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
            print(0)
            exit()
    # print(lst)
    if 0 not in lst:
        print(int(2 ** (n / 2)) % ((10 ** 9) + 7))
    else:
        print(0)
else:
    lst = [0] * n
    for i in range(1, n):
        x = (al[i - 1] + n - 1) / 2
        y = x - al[i - 1]
        # print(x,y)
        # print(n - x - 1, x)
        lst[int(n - x - 1)] += 1
        lst[int(x)] += 1
        if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
            print(0)
            exit()
    # print(lst)
    if 0 not in lst:
        print(int(2 ** ((n - 1) / 2)) % ((10 ** 9) + 7))
    else:
        print(0)

Submission status: Runtime Error

Solution code:
from collections import Counter, defaultdict, deque

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

al = list(map(int, input().split()))

if n % 2 == 0:
    lst = [0] * n
    for i in range(1, n):
        x = (al[i - 1] + n - 1) / 2
        y = x - al[i - 1]
        # print(x,y)
        # print(n-x-1,x)
        lst[int(n - x - 1)] += 1
        lst[int(x)] += 1
        if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
            print(0)
            exit()
    # print(lst)
    if 0 not in lst:
        print(int(2 ** (n / 2)) % ((10 ** 9) + 7))
    else:
        print(0)
else:
    lst = [0] * n
    for i in range(1, n):
        x = (al[i - 1] + n - 1) / 2
        y = x - al[i - 1]
        # print(x,y)
        # print(n - x - 1, x)
        lst[int(n - x - 1)] += 1
        lst[int(x)] += 1
        if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
            print(0)
            exit()
    # print(lst)
    if 0 not in lst:
        print(int(2 ** ((n - 1) / 2)) % ((10 ** 9) + 7))
    else:
        print(0)

Submission status: Runtime Error

Solution code:
from collections import Counter, defaultdict, deque
n = int(input())
#n,a,b = map(int,input().split())
# al = list(map(int,input().split()))

al = list(map(int,input().split()))

if n % 2 == 0:
    lst = [0]*n
    for i in range(1,n):
        x = (al[i-1]+n-1)/2
        y = x -al[i-1]
        #print(x,y)
        #print(n-x-1,x)
        lst[int(n-x-1)] += 1
        lst[int(x)] += 1
        if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
            print(0)
            exit()
    #print(lst)
    if not 0 in lst:
        print(int(2**(n/2))%((10**9)+7))
    else:
        print(0)
else:
    lst = [0] * n
    for i in range(1, n):
        x = (al[i - 1] + n - 1) / 2
        y = x - al[i - 1]
        # print(x,y)
        #print(n - x - 1, x)
        lst[int(n - x - 1)] += 1
        lst[int(x)] += 1
        if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
            print(0)
            exit()
    #print(lst)
    if not 0 in lst:
        print(int(2 ** ((n-1) / 2))%((10**9)+7))
    else:
        print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
count = [0]*n
for i in a:
    count[i] += 1
    
ans = 0
if n%2 == 0:
    if all(count[2*f]==0 for f in range(n//2)) and all(count[2*k-1]==2 for k in range(1,n//2)):  
        ans = (2**(n//2)) % (1e+9 + 7)
else:
    if count[0] == 1 and all(count[2*f]==2 for f in range(1,n//2)) and all(count[2*k-1]==0 for k in range(1,n//2)):
        ans = (2**(n//2)) % (1e+9 + 7)

print(int(ans))

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

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

if arr.count(0) > 1:
    print(0)
    sys.exit()

if len(arr) % 2 == 0 and arr.count(0) > 0:
    print(0)
    sys.exit()

cnt = Counter(arr)

li = list(cnt.values())

if li.count(2) != n // 2:
    print(0)
    sys.exit()

if not all([x <= 2 for x in li]):
    print(0)
    sys.exit(0)

print(reduce(mul, li))

Submission status: Runtime Error

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
h = Counter()
for x in a:
    h[x] += 1
f = True
for k, v in h..most_common():
    if n % 2 == 1 and k == 0:
        if v != 1:
            f = False
            break
    elif v != 2:
        f = False
        break
MOD = 1000000007
def mpow(n, p, mod):
    r = 1
    while p > 0:
        if p & 1 == 1:
            r = r * n % mod
        n = n * n % mod
        p >>= 1
    return r
print(mpow(2, int(n / 2), MOD) if f else 0)

Submission status: Runtime Error

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
h = Counter()
for x in a:
    h[x] += 1
f = True
for k, v in h.items():
    if n % 2 == 1 and k == 0:
        if v != 1:
            f = False
            break
    elif v != 2:
        f = False
        break
MOD = 1_000_000_007
def mpow(n, p, mod):
    r = 1
    while p > 0:
        if p & 1 == 1:
            r = r * n % mod
        n = n * n % mod
        p >>= 1
    return r
print(mpow(2, int(n / 2), MOD) if f else 0)

Submission status: Runtime Error

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
h = Counter()
for x in a:
    h[x] += 1
f = True
for k, v in h.most_common():
    if n % 2 == 1 and k == 0:
        if v != 1:
            f = False
            break
    elif v != 2:
        f = False
        break
MOD = 1_000_000_007
def mpow(n, p, mod):
    r = 1
    while p > 0:
        if p & 1 == 1:
            r = r * n % mod
        n = n * n % mod
        p >>= 1
    return r
print(mpow(2, int(n / 2), MOD) if f else 0)