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: Wrong Answer

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

dic = dict()
for a in A:
    a = int(a)
    dic[a] = dic.get(a, 0) + 1

keys = list(dic.keys())
values = list(dic.values())

if N % 2 == 0:
    if keys == [2*i+1 for i in range(N//2)] and values == [2 for i in range(N//2)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
else:
    if keys == [2*i for i in range(N//2)] and values == [1] + [2 for i in range(N//2 - 1)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]
z = Counter(a)
mul = 1
if n%2 == 1:
    if 1 in list(z.keys()):
        print(0)
        exit()
    if 0 in list(z.keys()):
        if z[0] != 1:
            print(0)
            exit()
        if z[0] == 1:
            for i in list(z.values())[1:]:
                if i%2 == 0:
                    continue
                else:
                    print(0)
                    exit()
            for i in list(z.values()):
                mul*=i
            print(mul%(10**9+7))
    else:
        print(0)
        exit()
if n%2 == 0:
    if 0 in list(z.keys()):
        print(0)
        exit()
    if 1 in list(z.keys()):
        if z[1] != 2:
            print(0)
            exit()
        if z[1] == 2:
            for i in list(z.values())[1:]:
                if i%2 == 0:
                    continue
                else:
                    print(0)
                    exit()
            for i in list(z.values()):
                mul*=i
            print(mul%(10**9+7))
    else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

import sys

def main(argv):
    n = sys.stdin.readline().rstrip()

    while n:
        result = -1
        n = int(n)
        count = [0 for i in range(0, int(n / 2))]
        if n % 2 != 0:
            count.append(0)
        a = [int(i) for i in raw_input().split()]
        for a_i in a:
            index, reminder = divmod(a_i, 2)
            if reminder == n % 2 or index >= len(count):
                result = 0
                break
            else:
                count[index] += 1

        if result < 0:
            if n % 2 != 0:
                if count[0] != 1:
                    result = 0
                else:
                    for c in count[1:]:
                        if c != 2:
                            result = 0
                            break
                    if result != 0:
                        result = 2 ** (len(count) - 1)
            else:
                for c in count:
                    if c != 2:
                        result = 0
                        break
                if result != 0:
                    result = 2 ** len(count)
        print result

        n = sys.stdin.readline().rstrip()

if __name__ == "__main__":
    main(sys.argv)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
if N % 2 == 1 and A.count(0) == 1 and np.all(A.count(i*2+2)==2 for i in range(N//2)):
    print(np.mod(np.power(2, N//2), (np.power(10, 9) + 7)))
elif N % 2 == 0 and np.all(A.count(i*2+1)==2 for i in range(N//2)):
    print(np.mod(np.power(2, N//2), (np.power(10, 9) + 7)))
else:
    print(0)

Submission status: Wrong Answer

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

dic = dict()
for a in A:
    a = int(a)
    dic[a] = dic.get(a, 0) + 1

keys = list(dic.keys())
values = list(dic.values())

if N % 2 == 0:
    if keys == [2*i+1 for i in range(N//2)] and values == [2 for i in range(N//2)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
else:
    if keys == [2*i for i in range(N//2)] and values == [1] + [2 for i in range(N//2 - 1)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
if N % 2 == 1 and A.count(0) == 1 and np.all(A.count(i*2+2)==2 for i in range(N//2)):
    print(2**(N//2) % (10**9 + 7))
elif N % 2 == 0 and np.all(A.count(i*2+1)==2 for i in range(N//2)):
    print(2**(N//2) % (10**9 + 7))
else:
    print(0)

Submission status: Wrong Answer

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

dic = dict()
for a in A:
    a = int(a)
    dic[a] = dic.get(a, 0) + 1

keys = dic.keys()
values = dic.values()

if N % 2 == 0:
    if keys == [2*i+1 for i in range(N//2)] and values == [2 for i in range(N//2)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
else:
    if keys == [2*i for i in range(N//2)] and values == [1] + [2 for i in range(N//2 - 1)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]
z = Counter(a)
mul = 1
if n%2 == 1:
    if 0 in list(z.keys()):
        if z[0] != 1:
            print(0)
            exit()
        if z[0] == 1:
            for i in list(z.values())[1:]:
                if i%2 == 0:
                    continue
                else:
                    print(0)
                    exit()
            for i in list(z.values()):
                mul*=i
            print(mul%(10**9+7))
    else:
        print(0)
        exit()
if n%2 == 0:
    if 1 in list(z.keys()):
        if z[1] != 2:
            print(0)
            exit()
        if z[1] == 2:
            for i in list(z.values())[1:]:
                if i%2 == 0:
                    continue
                else:
                    print(0)
                    exit()
            for i in list(z.values()):
                mul*=i
            print(mul%(10**9+7))
    else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]
z = Counter(a)
mul = 1
if n%2 == 1:
    if 0 in list(z.keys()):
        if z[0] != 1:
            print(0)
            exit()
        if z[0] == 1:
            for i in list(z.values())[1:]:
                if i%2 == 0:
                    continue
                else:
                    print(0)
                    exit()
            for i in list(z.values()):
                mul*=i
            print(mul%(10**9+7))
    else:
        print(0)
        exit()
if n%2 == 0:
    if 1 in list(z.keys()):
        if z[1] != 2:
            print(0)
            exit()
        if z[1] == 2:
            for i in list(z.values())[1:]:
                if i%2 == 0:
                    continue
                else:
                    print(0)
                    exit()
            for i in list(z.values()):
                mul*=i
            print(mul*(10**9+7))
    else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 1 and A.count(0) != 1 and all(A.count(i*2+2)==2 for i in range(N//2)):
    print(2**(N//2) % (10**9 + 7))
elif N % 2 == 0 and all(A.count(i*2+1)==2 for i in range(N//2)):
    print(2**(N//2) % (10**9 + 7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]
z = Counter(a)
mul = 1
if n%2 == 1:
    if 0 in list(z.keys()):
        if z[0] != 1:
            print(0)
            exit()
        if z[0] == 1:
            for i in list(z.values())[1:]:
                if i%2 == 0:
                    continue
                else:
                    print(0)
                    exit()
            for i in list(z.values()):
                mul*=i
            print(mul)
    else:
        print(0)
        exit()
if n%2 == 0:
    if 1 in list(z.keys()):
        if z[1] != 2:
            print(0)
            exit()
        if z[1] == 2:
            for i in list(z.values())[1:]:
                if i%2 == 0:
                    continue
                else:
                    print(0)
                    exit()
            for i in list(z.values()):
                mul*=i
            print(mul)
    else:
        print(0)
        exit()

Submission status: Wrong Answer

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

l = []
if N % 2 == 1:
    l = list(range(2, N, 2))
else:
    l = list(range(1, N, 2))

expected = sum(l) * 2
actual = sum(A)
if actual != expected:
    print(0)
else:
    print(2 ** len(l))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
f=True
if n%2==0:
    for i in range(n):
        if a[i]!=i//2*2+1:
            f=False
            break
else:
    for i in range(n):
        if a[i]!=(i+1)//2*2:
            f=False
            break
print(2**(n//2) if f else 0)

Submission status: Wrong Answer

Solution code:
n = input()
a = map(int, raw_input().split())
a.sort()
ok = 0
print a

if n % 2 == 1:
	for i in range(len(a)):
		if (i % 2 == 0 and a[i] != i) or (i % 2 == 1 and a[i] != i + 1):
			print 0
			ok = 1
			break

if n % 2 == 0:
	for i in range(len(a)):
		if (i % 2 == 1 and a[i] != i) or (i % 2 == 0 and a[i] != i + 1):
			print 0
			ok = 1
			break

if ok == 0:
	# print pow(2, n / 2)
	print pow((2 % 1000000007), ((n / 2) % 1000000006)) % 1000000007

Submission status: Wrong Answer

Solution code:

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

A_ = sorted(A)

if len(A_) == 1:
    if A_[0] == 0:
        print(1)
    else:
        print(0)

else:

    if len(A_) % 2 == 0:
        if A_[0] != 0 or A_[1] != 0:
            print(0)
            exit()

    else:
        if A_[0] != 0 or A_[1] == 0:
            print(0)
            exit()





    for i in range(len(A_) // 2):
        if A_[2*i] != A_[2*i+1]:
            print(0)
            exit()


    ans_ = 2 ** (N // 2)
    ans = ans_ % (10**9 + 7)
    print(ans)

Submission status: Wrong Answer

Solution code:

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

A_ = sorted(A)

if len(A_) == 1:
    if A_[0] == 0:
        print(1)
    else:
        print(0)

elif A_[0] == A_[1] == 0:
    print(0)

else:
    ans_ = 2 ** (N // 2)

    for i in range(len(A_) // 2):
        if A_[2*i] != A_[2*i+1]:
            print(0)
            exit()


    ans = ans_ % (10**9 + 7)
    print(ans)

Submission status: Wrong Answer

Solution code:

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

A_ = sorted(A)

if len(A_) == 1:
    if A_[0] == 0:
        print(1)
    else:
        print(0)

elif A_[0] == A_[1] == 0:
    print(0)

else:
    ans_ = 2 ** (N // 2)
    ans = ans_ % (10**9 + 7)
    print(ans)

Submission status: Wrong Answer

Solution code:

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

A_ = sorted(A)

if A_[0] == A_[1] == 0:
    print(0)
else:
    print(2 ** (N // 2))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
flag=0

if n%2==0:
    b=list(range(1,n,2))
    for i in range(n//2):
        if a.count(b[i])!=2:
            print("0")
            flag+=1
            break
if n%2==1:
    c=list(range(0,n,2))
    for i in range(n//2):
        if i==0:
            if a.count(c[i])!=1:
                print("0")
                flag+=1
                break

        else:
            if a.count(c[i])!=2:
                print("0")
                flag+=1
                break
        
if flag==0:
    print(2**(n//2)%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
ans = 1
for i in range(N):
    c = A.count(i)
    if N%2 == i%2:
        if c:
            ans *= 0
    else:
        if c == 0:
            ans *= 0
        if c == 1:
            if i != 0:
                ans *= 0
        if c == 2:
            ans *= 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

# n = 10 ** 5
# データ読み込み関係
n = int(input())

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

l = [0] * n

# 基本的な状況のリストを作成
for i in range(n):
    l[i] = abs((n - 1 - i) - i)

possible = True

# 報告状況が実現可能か確認
for e in l:
    if e in a:
        a.remove(e)
    else:
        possible = False
        break

if(possible == False):
    print(0)
    sys.exit()

multiCount = int(n / 2)

print(2 ** multiCount % (10 ** 9 + 7))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
A.sort()
ans=1
if N%2==1:
  i=1
  if A[0]!=0:
    print(0)
    exit()
  while i<N:
    if A[i]==A[i+1] and A[i]==(i//2+1)*2:
      i+=2
      ans*=2
      ans%=mod
    else:
      print(0)
      exit()
  print(ans)
else:
  i=0
  while i<N:
    if A[i]==A[i+1] and A[i]==(i//2)*2+1:
      i+=2
      ans*=2
      ans%=mod
    else:
      print(0)
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
A.sort()
ans=1
if N%2==1:
  i=1
  if A[0]!=0:
    print(0)
    exit()
  while i<N:
    if A[i]==A[i+1] and A[i]==(i//2+1)*2:
      i+=2
    else:
      print(0)
      exit()
  for i in range(N//2):
    ans*=2
    ans%=mod
  print(ans)
else:
  i=0
  while i<N:
    if A[i]==A[i+1] and A[i]==(i//2)*2+1:
      i+=2
    else:
      print(0)
  for i in range(N//2):
    ans*=2
    ans%=mod
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=list(map(int,input().split()))
lenS=len(S)
T=[]
for i in range(1,N+1):
    T.append(abs(i-(N+1-i)))

T.sort()
S.sort()



for i in range(N):
    if T!=S:
        print(0)
        exit()


ans=1
nagasa=lenS//2
for i in range(nagasa):
    
    ans=(ans*2)%(10**9+7)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=list(map(int,input().split()))
lenS=len(S)
T=[]
for i in range(1,N+1):
    T.append(abs(i-(N+1-i)))

T.sort()
S.sort()

def mal(a):
    return (a*2)%(10**9+7)

for i in range(N):
    if T!=S:
        print(0)
        exit()


ans=1
for i in range(lenS//2):
    
    ans=mal(ans)

print(ans)

Submission status: Time Limit Exceeded

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

x = int((n + 1) // 2)
if n % 2 == 1:
  if a.count(0) != 1:
    print(0)
    exit()
  else:
    for i in range(x-1):
      if a.count(n - 1 - (i*2)) != 2:
        print('0')
        exit()
    print(2**(x-1))
else:
  for i in range(x-1):
      if a.count(n - 1 - (i*2)) != 2:
        print('0')
        exit()
  print(2**x)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
flag = True
if n % 2 == 1:
    if a.count(0) != 1:
        flag = False
    for i in range(1, n//2+1):
        if a.count(i*2) != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)
elif n % 2 == 0:
    for i in range(n//2):
        if a.count(i*2+1) != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)

Submission status: Time Limit Exceeded

Solution code:
from sys import exit
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
    for i in range(N // 2):
        if A.count(i * 2 + 1) != 2:
            print(0)
            exit()
        else:
            continue
    print(int(2 ** (N / 2)) % (10 ** 9 + 7))
else:
    n = 0
    if A.count(0) != 1:
        print(0)
        exit()
    else:
        for i in range(N // 2):
            if A.count(i * 2 + 2) != 2:
                print(0)
                exit()
            else:
                continue
    print(int(2 ** (N // 2)) % (10 ** 9 + 7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lst = [int(s) for s in input().split()]

is_success = True

if n % 2 == 1:
    is_success = lst.count(0) == 1

for i in range(n - 1, 0, -2):
    if lst.count(i) != 2:
        is_success = False
        break

if is_success:
    tmp = 1

    for _ in range(n // 2):
        tmp *= 2
        tmp %= 10 ** 9 + 7

    print(tmp)
else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
if N % 2 != 0:
    num_list = [int(i) for i in range(2, N, 2)]
    for num in num_list:
        if A.count(num) != 2:
            break
    else:
        if A.count(0) == 1:
            ans = (2 ** (N // 2)) % (10**7 + 7)

else:
    num_list = [int(i) for i in range(1, N, 2)]
    for num in num_list:
        if A.count(num) != 2:
            break
    else:
        ans = 2 ** (N // 2) % (10**7 + 7)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
if N % 2 != 0:
    num_list = [int(i) for i in range(2, N, 2)]
    for num in num_list:
        if A.count(num) != 2:
            break
    else:
        if A.count(0) == 1:
            ans = 2 ** (N // 2)

else:
    num_list = [int(i) for i in range(1, N, 2)]
    for num in num_list:
        if A.count(num) != 2:
            break
    else:
        ans = 2 ** (N // 2)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[int(x) for x in input().split()]

if N%2==1:
    if A.count(0)!=1:
        print(0)
        exit()
    elif A.count(0)==1:
        for i in range(1,N//2):
            if A.count(2*i)==2:
                pass
            else:
                print(0)
                exit()
else:
    for i in range(N//2):
        if A.count(2*i+1)==2:
            pass
        else:
            print(0)
            exit()

print(2**(N//2))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(x) for x in input().split()]

flg = True
if N%2 == 0:
  for i in range(1, N, 2): flg &= A.count(i) == 2
else:
  flg &= A.count(0) == 1
  for i in range(2, N+1, 2): flg &= A.count(i) == 2

print(2**(N//2) if flg else 0)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
q = [int(x) for x in input().split(' ')]

contradiction = False
if (n%2 == 1):
    count = 2**((n-1)//2)
    for i in range(0,n,2):
        if(i == 0):
            contradiction = (q.count(i) != 1)
        else:
            contradiction = (q.count(i) != 2)
else:
    count = 2**(n//2)
    for i in range(1,n,2):
        contradiction = (q.count(i) != 2)
    
if (contradiction):
    print(0)
else:
    print(count%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
N= int(input())
Alist = list(map(int, input().split())) 
res = 1
if N % 2 ==0:
    for i in range(0,N//2):
        res = res*2 % (10**9+7)
        if Alist.count(2*i+1) != 2:
            print(0)
            exit()

    print(res)

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

Submission status: Time Limit Exceeded

Solution code:
N= int(input())
Alist = list(map(int, input().split())) 
res = 1
if N % 2 ==0:
    for i in range(0,N//2):
        res = res*2 % (10**9+7)
        if Alist.count(2*i+1) != 2:
            print(0)
            exit()

    print(res)

elif N % 2 ==1:
    if Alist.count(0) != 1:
        print(0)
        exit()
    else:
        for i in range(1,(N+1)//2):
            res = res*2 % (10**9+7)
            if Alist.count(2*i) != 2:
                print(0)
                exit()
    print(res)

Submission status: Time Limit Exceeded

Solution code:
N= int(input())
Alist = list(map(int, input().split())) 
res = 1
if N % 2 ==0:
    for i in range(0,N//2):
        if Alist.count(2*i+1) != 2:
            print(0)
            exit()
    for j in range(1,N//2+1):
        res = res*2 % (10**9+7)
    print(res)

elif N % 2 ==1:
    if Alist.count(0) != 1:
        print(0)
        exit()
    else:
        for i in range(1,(N+1)//2):
            if Alist.count(2*i) != 2:
                print(0)
                exit()
    for j in range(1,(N+1)//2):
        res = res*2 % (10**9+7)
    print(res)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = list(map(int, input().split()))
mod = 10**9+7
ans = 1

lst = {}
for i in num:
    if i not in lst:
        lst[i] = num.count(i)

# print(lst)

if n%2==0:
    for i in range(n%2):
        if lst[i*2+1]!=2:
            print(0)
            exit()
    for i in range(n//2):
        ans = ans*2%mod
    print(ans)
else:
    for i in range((n-1)//2):
        if lst[(i+1)*2]!=2:
            print(0)
            exit()
        if num.count(0)!=1:
            print(0)
            exit()
    for i in range((n-1)//2):
        ans = ans*2%mod
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
dic = Counter(list(map(int,input().split())))
rslt = 1
a = 10**9 + 7
if n % 2 == 0:
    if dic != Counter(sum([[i,i] for i in range(1, n, 2)], [])):
        rslt = 0
    else:
        rslt = 2**(n//2) % a

else:
    if dic != Counter(abs(i) for i in range(-n+1, n, 2)):
        rslt = 0
    else:
        rslt = 2**(n//2) % a
            
print(rslt)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import math

def main():
    N = int(input())
    A = list(map(int,input().split()))
    answer = 0

    if N % 2:
        if A.count(0) != 1:
            answer = 0
            print(answer)
            exit()

        for i in range(2,N,2):
            if A.count(i) != 2:
                answer = 0
                print(answer)
                exit()
        
        answer = (2 ** (int((N-1)/2))) % (int(math.pow(10,9))+7)
        print(answer)
        return
    
    else:
        if A.count(0) != 0:
            answer = 0
            print(answer)
            exit()
        for i in range(1, N, 2):
            if A.count(i) != 2:
                answer = 0
                print(answer)
                exit()

        answer = (2 ** (int(N/2))) % (10**9+7)
        print(answer)
        return

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

def main():
    N = int(input())
    A = list(map(int,input().split()))
    answer = 0

    if N % 2:
        if A.count(0) != 1:
            answer = 0
            print(answer)
            exit()

        for i in range(2,N,2):
            if A.count(i) != 2:
                answer = 0
                print(answer)
                exit()
        
        answer = (2 ** (int((N-1)/2))) % (10**9+7)
        print(answer)
        return
    
    else:
        if A.count(0) != 0:
            answer = 0
            print(answer)
            exit()
        for i in range(1, N, 2):
            if A.count(i) != 2:
                answer = 0
                print(answer)
                exit()

        answer = (2 ** (int(N/2))) % (10**9+7)
        print(answer)
        return

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def main():
    N = int(input())
    A = list(map(int,input().split()))
    answer = 0

    if N % 2:
        if A.count(0) != 1:
            answer = 0
            print(answer)
            exit()

        for i in range(2,N,2):
            if A.count(i) != 2:
                answer = 0
                print(answer)
                exit()
        
        answer = (2 ** (int((N-1)/2))) % (10**9+7)
        print(answer)
        return
    
    else:
        if A.count(0) != 0:
            answer = 0
            print(answer)
            exit()
        for i in range(1, N, 2):
            if A.count(i) != 2:
                answer = 0
                print(answer)
                exit()

        answer = (2 ** (int(N/2))) % (10**9+7)
        print(answer)
        return

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
nums = [int(e) for e in input().split()]
nums.sort()
t=1
ans = 1
for i in range(0,9):
    t = t*10
t+=7
if(N%2)==1:
    if(nums.count(0) == 1):
        for i in range(2,N,2):
            if(nums.count(i))==2:
                ans = (ans * 2)%t
            else:
                print('0')
                break
        else:
            print(ans)
    else:
        print('0')
else:
    for i in range(1,N,2):
        if(nums.count(i))==2:
            ans = (ans *2)%t
        else:
            print('0')
            break
    else:
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
dic = Counter(list(map(int,input().split())))
rslt = 1
r = 10**9 + 7
if n % 2 == 0:
    if dic != Counter(sum([[i,i] for i in range(1, n, 2)], [])):
        rslt = 0
    else:
        for _ in range(n//2):
            rslt = rslt * 2 % r
else:
    if dic != Counter(abs(i) for i in range(-n+1, n, 2)):
        rslt = 0
    else:
        for _ in range(n//2):
            rslt = rslt * 2 % r
print(rslt)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
dic = Counter(list(map(int,input().split())))
rslt = 1
if n % 2 == 0:
    if dic != Counter(sum([[i,i] for i in range(1, n, 2)], [])):
        rslt = 0
    else:
        for _ in range(n//2):
            rslt = rslt * 2 % (10**9+7)
else:
    if dic != Counter(abs(i) for i in range(-n+1, n, 2)):
        rslt = 0
    else:
        for _ in range(n//2):
            rslt = rslt * 2 % (10**9+7)
print(rslt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = input().split()
X = [0] * (N // 2)
count = 0

num = 2 ** (len(A) - len(set(A)))



for a in A:
    k = A.count(str(a))
    if k == 2:
        count += 1
    else:
        pass

K = 2 ** (count/2)

if A.count('0') == 2:
    print(0)
elif K == num:
    print(int(K))
else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
nums = [int(e) for e in input().split()]
nums.sort()
t=1
ans = 1
for i in range(0,9):
    t = t*10
t+=7
if(N%2)==1:
    if(nums.count(0) == 1):
        for i in range(2,N,2):
            if(nums.count(i))==2:
                ans = ans * 2
            else:
                print('0')
                break
        else:
            print(ans%(t))
    else:
        print('0')
else:
    for i in range(1,N,2):
        if(nums.count(i))==2:
            ans = ans *2
        else:
            print('0')
            break
    else:
        print(ans%(t))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
nums = [int(e) for e in input().split()]
nums.sort()
t=1
ans = 1
for i in range(0,9):
    t = t*10
t+=7
if(N%2)==1:
    if(nums.count(0) == 1):
        for i in range(2,N,2):
            if(nums.count(i))==2:
                continue
            else:
                print('0')
                break
        else:
            for k in range(0,N//2):
                ans = ans*2
            print(ans%(t))
    else:
        print('0')
else:
    for i in range(1,N,2):
        if(nums.count(i))==2:
            continue
        else:
            print('0')
            break
    else:
        for k in range(0,N//2):
            ans = ans*2
        print(ans%(t))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = list(map(int,input().split()))
s = 1
if n%2!=0:
  l1 = [i for i in range(0,n,2)]
  for i in l1:
    a = l.count(i)
    if ( (i==0 and a==1) or (i!=0 and a==2)):
      s *= 2
    else:
      s = 0
      break
  else:
    s //= 2
else:
  l1 = [i for i in range(1,n,2)]
  for i in l1:
    a=l.count(i)
    if a==2:
      s *= 2
    else:
      s = 0
      break
print(int(s)%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = list(map(int,input().split()))
s = 1
if n%2!=0:
  l1 = [i for i in range(0,n,2)]
  for i in l1:
    a = l.count(i)
    if (i==0 and a==1) or (i!=0 and a==2):
      s *= 2
    else:
      s = 0
      break
  else:
    s //= 2
else:
  l1 = [i for i in range(1,n,2)]
  for i in l1:
    a=l.count(i)
    if a==2:
      s *= 2
    else:
      s = 0
      break
print(int(s))

Submission status: Time Limit Exceeded

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

flag = True

if N % 2 != 0:
    for i in range(0,N,2):
        if i == 0:
            if A.count(0) != 1:
                flag = False
                break
        else:
            if A.count(i) != 2:
                flag = False
                break
else:
    for i in range(1,N,2):
        if A.count(i) != 2:
            flag = False
            break
            
if flag == False:
    print(0)
else:
    print(pow(2,N//2,10**9+7))

Submission status: Time Limit Exceeded

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

flag = True

if N % 2 != 0:
    for i in range(0,N,2):
        if i == 0:
            if A.count(0) != 1:
                flag = False
        else:
            if A.count(i) != 2:
                flag = False
else:
    for i in range(1,N,2):
        if A.count(i) != 2:
            flag = False
            
if flag == False:
    print(0)
else:
    print(pow(2,N//2,10**9+7))

Submission status: Time Limit Exceeded

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

ans = 0
if N%2==1:
    for i in range(0,N,2):
        # print(i)
        if i==0:
            if A.count(i)!=1:
                # print('A',A)
                break
        elif A.count(i)!=2:
            # print('B',i)
            break
    else:
        ans = pow(2,(N-1)//2,10**9+7)
else:
    for i in range(1,N,2):
        if A.count(i)!=2:
            # print(i)
            break
    else:
        ans = pow(2,N//2,10**9+7)
print(ans)