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: Runtime Error

Solution code:
n = int(input())
aaa = list(map(int, input().split()))
aaa.sort()
ans = int(2 ** (n / 2) % (10 ** 9 + 7)) if n % 2 == 0 else int(2 ** ((n - 1) / 2) % (10 ** 9 + 7))
if n % 2 == 0:
    for i in range(0, n, 2):
        if aaa[i] != aaa[i + 1]:
            ans = 0
            break
else:
    for i in range(1, n, 2):
        if aaa[i] != aaa[i + 1]:
            ans = 0
            break
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
aaa = list(map(int, input().split()))
aaa.sort()
mod = 10 ** 9 + 7
ans = int(2 ** (n / 2) % mod) if n % 2 == 0 else int(2 ** ((n - 1) / 2) % mod)
if n % 2 == 0:
    for i in range(0, n, 2):
        if aaa[i] != aaa[i + 1]:
            ans = 0
            break
else:
    for i in range(1, n, 2):
        if aaa[i] != aaa[i + 1]:
            ans = 0
            break
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
aaa = list(map(int, input().split()))
aaa.sort()
mod = 10 ** 9 + 7
ans = int(2 ** (n / 2) % mod) if n % 2 == 0 else int(2 ** ((n - 1) / 2) % mod)
if n % 2 == 0:
    for i in range(0, n, 2):
        if aaa[i] != aaa[i + 1]:
            ans = 0
            break
else:
    for i in range(1, n - 1, 2):
        if aaa[i] != aaa[i + 1]:
            ans = 0
            break
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
aaa = list(map(int, input().split()))
aaa.sort()
mod = 10 ** 9 + 7
ans = int(2 ** (n / 2) % mod) if n % 2 == 0 else int(2 ** ((n - 1) / 2) % mod)
if n % 2 == 0:
    for i in range(0, n, 2):
        if aaa[i] != aaa[i + 1]:
            ans = 0
            break
else:
    for i in range(1, n - 1, 2):
        if aaa[i] != aaa[i + 1]:
            ans = 0
            break
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
alist = list(map(int,input().split()))
dic = {}
mod = 10**9+7
for i in range(n):
    if alist[i] not in dic:
        dic[alist[i]] = 0
    dic[alist[i]] += 1
k = 0
while n-k-1 >= 2:
    p = n-k-1
    if p == 0:
        if dic[p] != 1:
            print(0)
            exit()
    else:
        if dic[p] != 2:
            print(0)
            exit()
    k += 2
else:
    print(2**(n//2)%mod)

Submission status: Runtime Error

Solution code:
n = int(input())
alist = list(map(int,input().split()))
dic = {}
for i in range(n):
    if alist[i] not in dic:
        dic[alist[i]] = 0
    dic[alist[i]] += 1
k = 0
while n-k-1 >= 2:
    p = n-k-1
    if p == 0:
        if dic[p] != 1:
            print(0)
            exit()
    else:
        if dic[p] != 2:
            print(0)
            exit()
    k += 2
else:
    print(2**(n//2))

Submission status: Runtime Error

Solution code:
n = int(input())
alist = list(map(int,input().split()))
dic = {}
for i in range(n):
    if alist[i] not in dic:
        dic[alist[i]] = 0
    dic[alist[i]] += 1

k = -2
while n-1-k >= 2:
    k += 2
    if n-1-k != 0:
        if dic[n-1-k] != 2:
            print(0)
            exit()
    else:
        if dic[0] != 1:
            print(0)
            exit()

p = n//2
print(2**p)

Submission status: Runtime Error

Solution code:
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)))

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

if n%2 == 0:
    c = collections.Counter(a)
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    ans = 1
    for i in range(len(item)):
        if 2*i + 1 == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    print(ans%MOD)
else:
    c = collections.Counter(a)
    ans = 1
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    for i in range(1,len(item)):
        if 2*i == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    if item[0][0] == 0 and item[0][1] == 1:
        print(ans%MOD)
    else:
        print(0)

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

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

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[i]+2==A[i+2] for i in range(0,N-2,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i+1] and A[i]-2==A[i-1] for i in range(2,N,2)):
        print(2**(N//2))
    else:
        print(0)

Submission status: Runtime Error

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

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[i]+2==A[i+2] for i in range(0,N-2,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i+1]==A[i+2] and A[i+1]+2==A[i+3] for i in range(0,N-2,2)):
        print(2**(N//2))
    else:
        print(0)

Submission status: Runtime Error

Solution code:
import math
from collections import Counter
mod = 1000000007
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
flag = 1
if n % 2 == 0:
    start = 1
else:
    if c[0] != 1:
        flag = 0
    start = 2
for i in range(start, n, 2):
    if c[i] != 2:
        flag = 0
        break
if flag == 0:
    print(0)
else:
    print(int(math.pow(2, n // 2)) % mod)

Submission status: Runtime Error

Solution code:
import math
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
flag = 1
if n % 2 == 0:
    start = 1
else:
    if c[0] != 1:
        flag = 0
    start = 2
for i in range(start, n, 2):
    if c[i] != 2:
        flag = 0
        break
if flag == 0:
    print(0)
else:
    print(int(math.pow(2, n // 2)))

Submission status: Runtime Error

Solution code:
import math
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
flag = 1
if n % 2 == 0:
    start = 1
else:
    if c[0] < 1:
        flag = 0
    start = 2
for i in range(start, n, 2):
    if c[i] != 2:
        flag = 0
        break
if flag == 0:
    print(0)
    exit()
else:
    print(int(math.pow(2, n // 2)))

Submission status: Runtime Error

Solution code:
def resolve():
    N = int(input())
    # A = input().replace(" ", "")
    A = list(map(int, readline().rstrip().split()))
    import collections
    counter = collections.Counter(A)
    if N % 2 == 1:
        if counter["0"] != 1:
            print("0")
            return
        for k, v in counter.items():
            if k == "0":
                continue
            if int(k) % 2 == 1:
                print("0")
                return
            if v != 2:
                print("0")
                return
    else:
        for k, v in counter.items():
            if int(k) % 2 == 0:
                print("0")
                return
            if v != 2:
                print("0")
                return
    
    print( (2**(N//2)) % (10**9+7) )




if '__main__' == __name__:
    resolve()

Submission status: Runtime Error

Solution code:
#Beginner 050 C

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

if L % 2 == 0:
    lst = [2*i+1 for i in range(L//2)]
    if set(lst) == set(A):
        print(2**(L//2))
    else:
        pront(0)
        quit()
else:
    lst = [2*i for i in range(L//2+1)]
    if set(lst) == set(A):
        print(2**(L//2+1))
    else:
        pront(0)
        quit()

Submission status: Runtime Error

Solution code:
from collections import Counter

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

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

ll m = 1e9+7;

ll pw(ll a, ll n)
{
    ll ans = 1;
    while (n > 0)
    {
        if (n % 2 != 0)
            ans = (ans * a) % m;
        a = (a * a) % m;
        n = n / 2;
    }
    return ans % m;
}

int main()
{
    ll n;
    cin >> n;
    map<ll, ll> mp;
    rep(i, 0, n)
    {
        ll a;
        cin >> a;
        mp[a]++;
    }
    bool y = true;
    for (auto x:mp)
    {
        if (n%2 == 0 && x.second != 2)
            y = false;
        if (n%2 == 1 && x.second != 2 && x.first != 0)
            y = false;
        if (n%2 == 1 && x.second != 1 && x.first == 0)
            y = false;
    }
    if (y == false)
        cout << 0;
    else 
        cout << pw(n/2, 2) % m;
    return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
from collections import deque

mod = 10**9 + 7
n = int(input())
a = deque(sorted(list(map(int, (input().split())))))

if n % 2 == 0:
    for i in range(n//2):
        b = a.pop()
        c = a.pop()
        if b == (i+1)*2 and c = (i+1)*2:
            print(0)
            sys.exit()
    print(pow(2, n//2, mod))

if n % 2 == 1:
    if a.pop() != 0:
        print(0)
        sys.exit()
    for i in range(n//2):
        b = a.pop()
        c = a.pop()
        if b == (i+1)*2 and c = (i+1)*2:
            print(0)
            sys.exit()
    print(pow(2, n//2, mod))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;





int main() {
  ll N; cin>>N;
  ll A[N+1] = {};
  REP(i,N) {
    ll a; cin>>a;
    A[a]++;
  }
  ll ans = 1;
  REP(i,N){
    if(A[i] > 2) {cout<<0<<endl;return 0;}
    if(A[i] == 0) continue;
    ans *= A[i];
    ans %= MOD;
  }
  if(A[0] == 2) ans = 0;
  cout<<ans<<endl;


  return 0;
}

Submission status: Runtime Error

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 20:16
N = INT()
A = LIST()

flag = True
# A.sort()

dic = {}
for i in range(N):
    if not A[i] in dic:
        dic[A[i]] = 1
    else:
        dic[A[i]] += 1


if N % 2 == 1:
    for i in range((N+1) // 2):
        if i == 0:
            if dic[i] != 1:
                flag = False
        elif dic[i * 2] != 2:
            flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** ((N-1) // 2))
else:
    for i in range(N // 2):
        if dic[2 * i + 1] != 2:
            flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** (N//2))






        


    # c = Counter(A)
    # c = sorted(c.items(), key=lambda x: x[0], reverse = False)
    # if c[0][1] != 1:
        # print(0)
    # for i in c[1:]:
        # if c[0]

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import collections

n = int(input())
A = map(int, input().split())
c = collections.Counter(A)
if n % 2 == 0:
    for k, v in c.items():
        if v % 2 != 0:
            print(0)
            break
    else:
        print(int((2 ** (n / 2)) % (10 ** 9 + 7)))
else:
    if c[0] != 1:
        print(0)
    else:
        for k, v in c.items():
            if v % 2 != 0 and k != 0:
                print(0)
                break
        else:
            print(int((2 ** ((n - 1) / 2)) % (10 ** 9 + 7)))

Submission status: Runtime Error

Solution code:
import collections

n = int(input())
A = map(int, input().split())
c = collections.Counter(A)
if n % 2 == 0:
    for k, v in c.items():
        if v % 2 != 0:
            break
    else:
        print(int((2 ** (n / 2)) % (10 ** 9 + 7)))
else:
    if c[0] != 1:
        print(0)
    else:
        for k, v in c.items():
            if v % 2 != 0 and k != 0:
                print(0)
                break
        else:
            print(int((2 ** ((n - 1) / 2)) % (10 ** 9 + 7)))

Submission status: Runtime Error

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

if n % 2 == 0:
  for i in range(n//2):
    if not a[2*i] == a[2*i+1] == 2*i+1:
      print(0)
      exit()
else:
  if a[0] != 0:
    print(0)
    exit()
  for i in range(n//2):
    if not a[2*i+1] == a[2*i+2] == 2*i+2
    print(0)
    exit()
print(pow(2, n//2) % mod)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
abs_nums = list(map(int, input().split()))
abs_nums.sort()
if N % 2 == 0:
    for i in range(0, N, 2):
        if abs_nums[i] != i+1 or abs_nums[i+1] != i+1:
            print("0")
            sys.exit()
else:
    if abs_nums[0] != 0:
        print("0")
        sys.exit()
    for i in range(1, N, 2):
        if abs_nums[i] != i+1 or abs_nums[i+1] != i+1:
            print("0")
            sys.exit()

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

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
abs_nums = list(map(int, input().split()))
abs_nums.sort()
if N % 2 == 0:
    for i in range(0, N, 2):
        if abs_nums[i] != i+1 or abs_nums[i+1] != i+1:
            print("0")
            sys.exit()
else:
    if abs_nums[0] != 0:
        print("0")
        sys.exit()
    for i in range(1, N, 2):
        if abs_nums[i] != i+1 or abs_nums[i+1] != i+1:
            print("0")
            sys.exit()
    
print(f"{int((2**(N/2)) % ((10**9)+7))}")

Submission status: Runtime Error

Solution code:
N=int(input())
A = list(map(int,input().split()))
A = list(set(A))
c = 0
for i in range((N+1)%2, N, 2):
  if not A[c] == i:
    print(0)
    end()
  c += 1
print(2**(c-c%2))

Submission status: Runtime Error

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

A.sort()
c = 0
s = 0
if N % 2 == 1:
    if A[0] != 0 or A[1] == 0:
        c += 1
    for i in range(N-2):
        if A[i] + 2 != A[i+2]:
            c += 1
    if c == 0:
        s = (2 ** ((N-1)/2))
        print(int(s % 1000000007))
    else:
        print(0)
else:
    if A[0] != 1 or A[1] != 1:
        c += 1    
    for i in range(N-2):
        if A[i] + 2 != A[i+2]:
            c += 1
    if c == 0:
        s = (2 ** ((N)/2))
        print(int(s % 1000000007))
    else:
        print(0)

Submission status: Runtime Error

Solution code:
n=int(input());print([0,pow(2,(n//2),(10**9+7))][sorted(map(int,input().split()))==[i+(i+N+1)%2for i in range(N)]])

Submission status: Runtime Error

Solution code:
MOD=1000000007
def modpow(a,n,mod):
    res=1
    a=a%mod
    while(n>0):
        if(n&1):
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res

N=int(input())
A=list(map(int,input().split()))
cnt=[0]*10001
for i in range(N):
    cnt[A[i]]+=1
if(N%2==1):
    if(cnt[0]!=1):
        print(0)
        exit()
    for i in range(2,N,2):
        if(cnt[i]!=2):
            print(0)
            exit()
elif(N%2==0):
    for i in range(1,N,2):
        if(cnt[i]!=2):
            print(0)
            exit()
print(modpow(2,N//2,MOD))

Submission status: Runtime Error

Solution code:

def mod_(b, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * b % mod
        b = b * b % mod
        n >>= 1
    return int(res)

def main():

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

    n = ((N+1) >> 1)
    li = [0]*n



    for a in A:
        if li[a >> 1] >= 2:
            print(0)
            break
        else:
            li[a >> 1] += 1

    if N & 1:
        if li[0] != 1:
            print(0)
        elif li.count(2) != n-1:
            print(0)
        else:
            c = n-1
            print(2 ** c % (1E9+7))
    else:
        if li.count(2) != n:
            print(0)
        else:
            c = n
            print(2 ** c % (1E9+7))

main()

Submission status: Runtime Error

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

if len(A)%2 == 0:
    result = 2**(len(A)//2)
    a = np.arange(1, len(A), 2).tolist()
    a = sorted(a+a)
    if a == A:
        pass
    else:
        result = 0
else:
    result = 2**(len(A)//2)
    a = np.arange(2, len(A), 2).tolist()
    a = sorted([0]+a+a)
    if a == A:
        pass
    else:
        result = 0
print(result)

Submission status: Runtime Error

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

li = [0]*((N+1) >> 1)

for a in A:
    if li[a >> 1] >= 2:
        print(0)
        break
    else:
        li[a >> 1] += 1

if N & 1:
    if li[0] != 1:
        print(0)
    elif li.count(1) > 1:
        print(0)
    else:
        c = li.count(2)
        print(int(2**c % (10E9 - 7)))
else:
    if li.count(1) > 0:
        print(0)
    else:
        c = li.count(2)
        print(int(2**c % (10E9 - 7)))

Submission status: Runtime Error

Solution code:
def main():
    people_num = int(input())
    information = sorted(list(map(int, input().split())))
    unique = len(set(information))
    answer = 0
    if information[1] > 0 and unique * 2 == people_num + people_num % 2:
        answer = (unique - people_num % 2) ** 2
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

A.sort()
c = 0
s = 0
if N % 2 == 1:
    for i in range(1,N-1):
        if A[i] == A[i+1]:
            c += 1
    if c == (N-1)/2:
        s = (2 ** ((N-1)/2))
        print(int(s % 1000000007))
    else:
        print(0)
else:
    for i in range(N-1):
        if A[i] == A[i+1]:
            c += 1
    if c == (N)/2:
        s = (2 ** ((N)/2))
        print(int(s % 1000000007))
    else:
        print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
S = [input() for i in range(N)]
m_count = 0
m_str = []

for i in range(N):
    if S.count(S[i]) > m_count:
        m_str = [S[i]]
        m_count = S.count(S[i])
    elif S.count(S[i]) == m_count:
        m_str.append(S[i])

m_str = list(set(m_str))
m_str.sort()

print(m_str[i] for i in len(m_str))

Submission status: Runtime Error

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

while 0 in A:
    A.remove(0)

A_ = list(set(A))
A_.sort()
for i in range(len(A_) - 1):
    if A_[i+1] == A_[i]+2:
        judge = 1
    else:
        judge = 0

if len(set(A)) == len(A)/2 and judge:
    print((2 ** (len(A) // 2)) % (10**9 +7))
else:
    print(0)

Submission status: Runtime Error

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

while 0 in A:
    A.remove(0)

A_ = list(set(A))
A_.sort()
for i in range(len(A_) - 1):
    if A_[i+1] == A_[i]+2:
        judge = 1
    else:
        judge = 0

if len(set(A)) == len(A)/2 and judge:
    print(2 ** (len(A) // 2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
judge = 0
while 0 in A:
    A.remove(0)
for i in range(len(set(A))):
    if set(A)[i+1] - set(A)[i] == 2:
        judge = 1
    else:
        judge = 0
        break
if len(set(A)) == len(A)/2 and judge:
    print(2 ** (len(A) // 2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
flg = True
if n%2==0:
  if 0 in a or len(set(a))!=n//2:
    flg=False
else:
  if len([0 for i in a if a==0])!=1 or len(set(a))!~n//2+1:
    flg=False
if flg:
  print(2**(n//2)%(10**9+7))
else:
  print(0)

Submission status: Runtime Error

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))
flg = True
if n%2==0:
  if 0 in a or len(set(a))!=n//2:
    flg=False
  else:
    if len([0 for i in a if a==0])!=1 or len(set(a))!~n//2+1:
      flg=False
  if flg:
    print(2**(n//2)%(10**9+7))
  else:
    print(0)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
even=[]
odd=[]
for i in range(0,n // 2):
    even.append(2*i+1)
even=even+even
even.sort()
for j in range(1,(n-1 // 2)+1):
    odd.append(2*j)
odd =odd + odd
odd.append(0)
odd.sort()
if n % 2 == 1:
    if a == odd:
        print(pow(2,n-1 // 2,10**9+7)
    else:
        print(0)
else:
    if a == even:
        print(2,n // 2,10**9+7)
    else:
        print(0)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[int(x) for x in input().split()]
a.sort()
set_a=list(set(a))
if N % 2 ==0:
	for i in range(N):
		a[i] != 2*(i // 2) + 1
		print(0)
		exit(0)
else:
	if a[0] != 0:
		print(0)
		exit(0)
	else:
		for i in range(1,N):
			a[i] != 2(i+1 // 2) +1
			print(0)
			exit(0)
if N % 2==1:
	len=len(set_a)-1
else:
	len=len(set(a))
ans=2**len
print(ans)

Submission status: Runtime Error

Solution code:
N,x=map(int,input().split())
a=[int(x) for x in input().split()]
a.sort()
set_a=list(set(a))
if N % 2 ==0:
	for i in range(N):
		a[i] != 2*(i // 2) + 1
		print(0)
		exit(0)
else:
	if a[0] != 0:
		print(0)
		exit(0)
	else:
		for i in range(1,N):
			a[i] != 2(i+1 // 2) +1
			print(0)
			exit(0)
if N % 2==1:
	len=len(set_a)-1
else:
	len=len(set(a))
ans=2**len
print(ans)