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:
from collections import Counter

n = int(input())
a = 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)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
d=dict()
for i in range(n):
  if a[i] not in d:
    d[a[i]]=1
  else:
    d[a[i]]+=1
d=sorted(list(d.items()))
if n%2:
  for i in range(len(d)):
    if i==0:
      if d[i][0]!=0 or d[i][1]!=1:
        print(0)
        exit()
    else:
      if d[i][0]!=i*2 or d[i][1]!=2:
        print(0)
        exit()
  print(pow(2,len(d)-1,mod)
else:
  for i in range(len(d)):
    if d[i][0]!=2*i+1 or d[i][1]!=2:
      print(0)
      exit()
  print(2,len(d),mod)

Submission status: Runtime Error

Solution code:
#ARC066-C
N=int(input())
A=[int(i) for i in input().split()]
const=10**9+7
cnt={}
ans=0
flag=True
if N%2==0:
    for k in range(1,N,2):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(1,N,2):
        if cnt[k]!=2:
            flag=False
            break
    if flag: ans=pow(2,N//2,const)
else:
    for k in range(0,N,2):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(0,N,2):
        if k==0:
            if cnt[0]!=1:
                flag=False
                break
        else:
            if cnt[k]!=2:
                flag=False
                break
    if flag: ans=pow(2,(N-1)//2,const)
print(ans)

Submission status: Runtime Error

Solution code:
#ARC066-C
N=int(input())
A=[int(i) for i in input().split()]
const=10**9+7
cnt={}
if N%2==0:
    for k in range(1,N,2):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(1,N,2):
        if cnt[k]!=2:
            print(0)
            exit()
    print(pow(2,N//2,const))
else:
    for k in range(0,N,2):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    if cnt[0]!=1:
        print(0)
        exit()
    for k in range(2,N,2):
        if cnt[k]!=2:
            print(0)
            exit()
    print(pow(2,(N-1)//2,const))

Submission status: Runtime Error

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

x = n%2 + 1
for i in range(n)[n%2+2::2]:
    if a[i] != a[i+1] or a[i] - x != 2:
        print(0)
        exit()
    x = a[i]
    
print(2**(n//2) % (10**9+7)

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))
if n % 2 == 1:
    for i in range(0, n, 2):
        if i == 0 and a[i] != 0:
            print(0)
            exit()
        elif a[i] != a[i + 1] or a[i] != 2 * i:
            print(0)
            exit()
else:
    for i in range(0, n, 2):
        if a[i] != a[i + 1] or a[i] != 2 * i + 1:
            print(0)
            exit()
print(2 ** (n // 2))

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
if N%2==0:
	for i in range (N):
		A[i]%2!=1:
			print(0)
			exit()
	print((2**N)%(10**9+7))
else:
	for i in range (N):
		A[i]%2!=0:
			print(0)
			exit()
	if min(A)!=0:
		print(0)
		exit()
	else:
		print((2**(N-1))%(10**9+7))

Submission status: Runtime Error

Solution code:
import numpy as np
import collections
while(1):
    N=int(input())
    A = np.array(list(map(int, input().split())))
    if np.count_nonzero(A ==0)>=2:
        print("0")
        break
    dict=collections.Counter(A)
    key = [k for k, v in dict.items() if int(v) <= 2]
    if len(key)==0:
        print("0")
        break
    else:
        ans=2**len(key)
        ans =ans%(10**9+7)
        print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
mod=10**9+7
a=[]
for i in range(M):
    a.append(int(input()))


DP=[1]*(N+1)

if 1 in a:
    DP[1]=0

for i in range(2,N+1):
    if i in a:
        DP[i]=0
        if DP[i-1]==0:
            print(0)
            exit()
    else:
        DP[i]=DP[i-1]+DP[i-2]
        DP[i]=DP[i]%mod

print(DP[N])

Submission status: Runtime Error

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

a.sort()
if n%2 == 0:
    for i in range(n-1):
        if i%2 == 0:
            if a[i] == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
        else:
            if a[i]+2 == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
    print((2 ** (n//2)) % (10**9+7))
else:
    if a[0] == 0:
        for i in range(1, n-1):
            if i%2 == 1:
                if a[i] == a[i+1]:
                    continue
                else:
                    print(0)
                    sys.exit()
            else:
                if a[i]+2 == a[i+1]:
                    continue
                else:
                    print(0)
                    sys.exit()
        print(2**((n-1)/2)%(10**9+7))
    else:
        print(0)
        sys.exit()

Submission status: Runtime Error

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

a.sort()
if n%2 == 0:
    for i in range(n-1):
        if i%2 == 0:
            if a[i] == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
        else:
            if a[i]+2 == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
    print(int(2**(n/2)%(10**9+7)))
else:
    if a[0] == 0:
        for i in range(1, n-1):
            if i%2 == 1:
                if a[i] == a[i+1]:
                    continue
                else:
                    print(0)
                    sys.exit()
            else:
                if a[i]+2 == a[i+1]:
                    continue
                else:
                    print(0)
                    sys.exit()
        print(int(2**((n-1)/2)%(10**9+7)))    
    else:
        print(0)
        sys.exit()

Submission status: Runtime Error

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

a.sort()
if n%2 == 0:
    for i in range(n-1):
        if i%2 == 0:
            if a[i] == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
        else:
            if a[i]+2 == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
    print(int(2**(n/2)))
else:
    if a[0] == 0:
        for i in range(1, n-1):
            if i%2 == 1:
                if a[i] == a[i+1]:
                    continue
                else:
                    print(0)
                    sys.exit()
            else:
                if a[i]+2 == a[i+1]:
                    continue
                else:
                    print(0)
                    sys.exit()
        print(int(2**((n-1)/2)))    
    else:
        print(0)
        sys.exit()

Submission status: Runtime Error

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

a.sort()
a.append(-1)
counter = 0
b = []
for i in range(n+1):
    if a[counter] == a[i]:
        continue
    else:
        b.append([a[counter], i-counter])
        counter = i
odd = 0
if n%2 == 1:
    if b[0][0] == 0 and b[0][1] == 1:
        b[0][1] += 1
        n += 1
        odd = 1
    else:
        print(0)
        sys.exit()
if odd:
    for i in range(int(n//2)):
        if b[i][0] == i*2 and b[i][1] == 2:
            continue
        else:
            print(0)
            sys.exit()
else:
    for i in range(int(n//2)):
        if b[i][0] == i*2+1 and b[i][1] == 2:
            continue
        else:
            print(0)
            sys.exit()
if odd:
    print(int(2**(n/2 -1)%(10**9 + 7)))
else:
    print(int(2**(n/2)%(10**9 + 7)))

Submission status: Runtime Error

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

a.sort()
a.append(-1)
counter = 0
b = []
for i in range(n+1):
    if a[counter] == a[i]:
        continue
    else:
        b.append([a[counter], i-counter])
        counter = i
odd = 0
if n%2 == 1:
    if b[0][0] == 0 and b[0][1] == 1:
        b[0][1] += 1
        n += 1
        odd = 1
    else:
        print(0)
        sys.exit()
if odd:
    for i in range(int(n//2)):
        if b[i][0] == i*2 and b[i][1] == 2:
            continue
        else:
            print(0)
            sys.exit()
else:
    for i in range(int(n//2)):
        if b[i][0] == i*2+1 and b[i][1] == 2:
            continue
        else:
            print(0)
            sys.exit()
if odd:
    print(int(2**(n/2 -1)))
else:
    print(int(2**(n/2)))

Submission status: Runtime Error

Solution code:
import collections

N=int(input())
A_data=list(map(int,input().split()))
mod=10**9+7

A=collections.Counter(A_data)

if N%2==1:
    if not A[0]==1:
        ans=0
    else:
        for i in range(2,N,2):
            if not A[i]==2:
                ans=0
                break
        if ans!=0:
            ans=2**((N-1)//2)%mod
elif N%2==0:
    for i in range(1,N,2):
        if not A[i]==2:
            ans=0
            break
    if ans!=0:
        ans=2**(N//2)%mod

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
    if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
else:
    if np.all(L-np.arange(N)-np.array([1,0]*(N/2))==0):
        flag = True
    else:
        print(0)
if flag:
    a=1
    for i in range(N//2):
        a = (a*2)%(10**9+7)
    print(a)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
    if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
else:
    if np.all(L-np.arange(N)-np.array([1,0]*(N/2))==0):
        flag = True
    else:print(0)

if flag:
    a=1
    for i in range(N//2):
        a = (a*2)%(10**9+7)
    print(a)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
    if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
else:
    if np.all(L-np.arange(N)+np.array([1,0]*(N/2))==0):
        flag = True
    else:print(0)

if flag:
    a=1
    for i in range(N//2):
        a = (a*2)%(10**9+7)
    print(a)

Submission status: Runtime Error

Solution code:
import sys

MOD = 1000000007

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

if(N%2 == 0):
    a.sort()
    for i in range(N//2):
        n = 2*i + 1
        if(a[2*i] != n or a[2*i + 1] != n):
            print(0)
            sys.exit()
    print((2 ** (N//2)) % MOD)
else:
    a.sort()
    if(a[0] != 0 or a[1] == 0 ):
        print(0)
        sys.exit()
    for i in range((N-1)//2):
        n = 2*i + 2
        if(a[2*i + 1] != n or a[2*i + 2] != n):
            print(0)
            sys.exit()
    print((2 ** ((N-1)//2)) % MOD)

Submission status: Runtime Error

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

def is_valid(A):
    counts = {}
    for a in A:
        if a in counts:
            counts[a] += 1
        else:
            counts[a] = 1
    if len(A) % 2 == 1:
        if counts[0] != 1:
            return False
        
        for i in range(1, len(A) // 2 + 1):
            if 2 * i not in counts or counts[2 * i] != 2:
                return False
        return True
    else:
        for i in range(1, len(A) // 2 + 1):
            if 2 * i not in counts or counts[2 * i - 1] != 2:
                return False
        return True
    return True
        
if is_valid(A):
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Runtime Error

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

def is_valid(A):
    counts = {}
    for a in A:
        if a in counts:
            counts[a] += 1
        else:
            counts[a] = 1
    if len(A) % 2 == 1:
        if counts[0] != 1:
            return False
        
        for i in range(1, len(A) // 2 + 1):
            if counts[2 * i] != 2:
                return False
        return True
    else:
        for i in range(1, len(A) // 2 + 1):
            if counts[2 * i - 1] != 2:
                return False
        return True
    return True
        
if is_valid(A):
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7
c = 1-N%2
flag = True
di = {}
if(N==1):
    if(A[0]==0):
        print(1)
    else:
        print(0)
else:
    for i in A:
        if(i not in di):
            di[i]=1
        else:
            di[i]+=1
    for i in range(N//2):
        if(i+c==0):
            flag &= (di[i]==1)
        else:
            flag &= (di[i*2+c]==2)
        if(not flag):
            print(0)
            break
    else:
        print((2<<(N//2-1))%mod)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7
c = 1-N%2
flag = True
di = {}
if(N==1):
    if(A[0]==0):
        print(1)
    else:
        print(0)
else:
    for i in A:
        if(i not in di):
            di[i]=1
        else:
            di[i]+=1
    for i in range(N//2):
        if(i+c==0):
            flag &= (di[i]==1)
        else:
            flag &= (di[i*2+c]==2)
        if(not flag):

            else:
                print(0)
            break
    else:
        print((2<<(N//2-1))%mod)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7
c = 1-N%2
flag = True
di = {}
for i in A:
    if(i not in di):
        di[i]=1
    else:
        di[i]+=1
for i in range(N//2):
    if(i+c==0):
        flag &= (di[i]==1)
    else:
        flag &= (di[i*2+c]==2)
    if(not flag):
        if(N==1):
            print(1)
        else:
            print(0)
        break
else:
    print((2<<(N//2-1))%mod)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  //整合性チェック
  int guki=N%2;
  vector<int> num((N+1)/2,0);
  bool flag=true;
  for(int i=0;i<N;i++){
    if(guki==1){
      if(a[i]%2==1||a[i]>2*(N/2)){
        flag=false;
        break;
      }
      num[a[i]/2]++;
    }else{
      if(a[i]%2==0||a[i]>2*((N-1)/2)+1){
        flag=false;
        break;
      }
      num[a[i]/2]++;
    }
    
  }
  
  for(int i=0;i<num.size();i++){
      if(guki==1&&i==0){
        if(num[i]!=1){
          flag=false;
          break;
        }
      }else if(num[i]!=2){
        flag=false;
        break;
      }
  }

  if(!flag){
    cout<<"0"<<endl;
    return 0;
  }
  ll ans=1;
  if(guki==1){
    for(int i=0;i<num.size()-1;i++){
      (ans*=2)%=mod;
    }
  }else{
    for(int i=0;i<num.size();i++){
      (ans*=2)%=mod;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Submission status: Runtime Error

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

def check():
    if N % 2 == 0:
        for i in range(1,N)[::2]:
            if A[i-1] != i or A[i] != i:    return 0
        return int(2**(N/2)) % (1e9+7)
    else:
        if A[0] != 0:   return 0
        else:
            for i in range(2,N)[::2]:
                if A[i-1] != i or A[i] != i:    return 0
            return int(2**((N-1)/2)) % int(1e9+7)
        
print(int(check()))

Submission status: Runtime Error

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

def check():
    if N % 2 == 0:
        for i in range(1,N)[::2]:
            if A[i-1] != i or A[i] != i: return 0
        return (2**(N/2)) % (1e9+7)
    else:
        if A[0] != 0: return 0
        else:
            for i in range(2,N)[::2]:
                if A[i-1] != i or A[i] != i: return 0
            return (2**((N-1)/2)) % (1e9+7)
        
print(int(check()))

Submission status: Runtime Error

Solution code:

a = int(input())
x = list(map(int, input().split()))
x.sort()
t =[2]
x = x[::-1]
if a == 1:
  if x[0] == 0:print(1)
  else:print(0)
else:
  if a %2 == 0:
    for i in range(1,a,2):
      if not i == x[-1] and i ==x[-2]:
        print(0)
        break
      x.pop()
      x.pop()
    else:print(2**(a//2))
  else:
    if x.pop() != 0:
      print(0)
      exit()
    for i in range(0,a,2):
      if not i == x[-1] and i ==x[-2]:
        print(0)
        break
      x.pop()
      x.pop()
    else:print(2**(a//2))

Submission status: Runtime Error

Solution code:
a = int(input())
x = list(map(int, input().split()))
x.sort()
t =[2]
x = x[::-1]
if a == 1:
  if x[0] == 0:print(1)
  else:print(0)
else:
  if a %2 == 0:
    print(t[3])
    for i in range(1,a,2):
      if not i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
        print(0)
        break
    else:print(2**(a//2))
  else:
    if x.pop() != 0:
      print(0)
      exit()
    for i in range(0,a,2):
      if not i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
        print(0)
        break
    else:print(2**(a//2))

Submission status: Runtime Error

Solution code:
a = int(input())
x = list(map(int, input().split()))
x.sort()
x = x[::-1]
if a %2 == 0:
  for i in range(1,a,2):
    if not i == x[-1] and i ==x[-2]:
      x.pop()
      x.pop()
      print(0)
      break
  else:print(2**(a//2))
else:
  for i in range(0,a,2):
    x.pop()
    if not i == x[-1] and i ==x[-2]:
      x.pop()
      x.pop()
      print(0)
      break
  else:print(2**(a//2))

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
INF=1e9+7
if N%2==1:
    if A[0]!=0:
        print(0)
        quit()
    for i in range((N-1)//2):
        if A[2*i+1]!=2*(i+1) or A[2*i+2]!=2*(i+1):
            print(0)
            quit()
    print(2**((N-1)//2)%INF)
else:
    for i in range(N//2):
        if A[2*i]!=2*i+1 or A[2*i+1]!=2*i+1:
            print(0)
            quit()
    print(2**(N//2)%INF)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if a[0]!=0:
        print(0)
        exit()
    for i in range(n//2):
        if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
            print(0)
            exit()
    print((pow(2,n//2))%(1e9+7))
else:
    for i in range(n//2):
        if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
            print(0)
            exit()
    print((pow(2,n//2))%(1e9+7))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if a[0]!=0:
        print(0)
        exit()
    for i in range(n//2):
        if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
            print(0)
            exit()
    print((pow(2,n//2))%(1e9+7))
else:
    for i in range(n//2):
        if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
            print(0)
            exit()
    print(((pow(2,n//2))%(1e9+7)))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if a[0]!=0:
        print(0)
        exit()
    for i in range(n//2):
        if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
            print(0)
            exit()
    print(int(pow(2,n//2)%(1e9+7)))
else:
    for i in range(n//2):
        if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
            print(0)
            exit()
    print(int(pow(2,n//2)%(1e9+7)))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if a[0]!=0:
        print(0)
        exit()
    for i in range(n//2):
        if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
            print(0)
            exit()
    print(pow(2,n//2)%(1e9+7))
else:
    for i in range(n//2):
        if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
            print(0)
            exit()
    print(pow(2,n//2)%(1e9+7))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=1
a.sort()
la=list(set(a))
if n%2==0:
    for i in range(1,n,2):
        if a.count(i)==2:
            ans*=2
            ans%=1e9+7
        else:
            ans=0
            break
else:
    if a[0]==0 and a[1]!=0:
        a=a[1:]
        for i in range(2,n,2):
            if a.count(i)==2:
                ans*=2
                ans%=1e9+7
            else:
                ans=0
                break
    else:
        ans=0
print(int(ans))

Submission status: Runtime Error

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

cnt = dict()

for d in dat:
    if cnt.__contains__(d):
        cnt[d]+=1
    else:
        cnt[d]=1

if n%2:
    if cnt[0] != 1:
        print(0)
        exit(0)
    for i in range(2,n,2):
        if cnt[i] != 2:
            print(0)
            exit(0)
else:
    for i in range(1,n,2):
        if cnt[i] != 2:
            print(0)
            exit(0)
print(2**(n//2))

Submission status: Runtime Error

Solution code:
from collections import Counter


N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)


if N % 2:
    if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
        ans = pow(2, N//2, mod)
    else:
        ans = 0
else:
    if all(countA[i] == 2 for i in range(1, N, 2)):
        ans = pow(2, N//2, mod)

print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter


N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)


if N % 2:
    if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
        ans = 2 ** (N // 2) % mod
    else:
        ans = 0
else:
    if all(countA[i] == 2 for i in range(1, N, 2)):
        ans = 2 ** (N // 2) % mod

print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter


N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)


if N % 2:
    if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
        ans = pow(2, N//2) % mod
    else:
        ans = 0
else:
    if all(countA[i] == 2 for i in range(1, N, 2)):
        ans = pow(2, N//2) % mod

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  if d[i]!=2:
    ans=0
if d[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)

Submission status: Runtime Error

Solution code:
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  d[i]!=2:
    ans=0
if d[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = True
for i,j in enumerate(a):
  if n % 2:
    if j != ((i+1) // 2) * 2:
      b = False
      break
  else:
    if j != (i // 2) * 2 + 1:
      b = False
      break
if b == True:
  print(((n // 2) ** 2) % mod)
else:
  print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False



for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*((i)//2) +1):
            continue
        else:
            bool_false = False
            break

if(len(people_num) == 1):
    print(1)
elif(bool_false):
    print((people_num//2) **2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll pw(ll n,ll m){
  if(m==0) return 1;
  else if(m%2==0) return pw(n*n,m/2);
  else return n*pw(n,m-1);
}

int main(){
  ll n,a[100010];
  cin>>n;
  fr(i,n) cin>>a[i];
  sort(a,a+n);
  for(int i=n-1;i>=0;i-=2) a[i]++;
  bool f=1;
  fr(i,n) if(a[i]!=i+1) f=0;
  cout<<(f?pw(2,n/2):0)<<endl;
}

Submission status: Runtime Error

Solution code:

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

co = a_list.copy()
if 0 in co:
    co.remove(0)
co.sort()


if not len(co) % 2 == 0:
    print(0)
    quit()

for index in range(len(a_list))[:-1:2]:
    if not co[index] == co[index + 1]:
        print(0)
        quit()


print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Runtime Error

Solution code:

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

co = a_list.copy()
if 0 in co:
    co.remove(0)
co.sort()


if not len(co) % 2 == 0:
    print(0)
    quit()

for index in range(len(a_list))[:-2:2]:
    if not co[index] == co[index + 1]:
        print(0)
        quit()


print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Runtime Error

Solution code:


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

co = a_list.copy()
if 0 in co:
    co.remove(0)
co.sort()


if not len(co) % 2 == 0:
    print(0)
    quit()

for index in range(len(a_list))[:-1:2]:
    if not co[index] == co[index + 1]:
        print(0)
        quit()




print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Runtime Error

Solution code:


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

co = a_list.copy()
if 0 in co:
    co.remove(0)
co.sort()


if not len(co) % 2 == 0:
    print(0)
    quit()

for index in range(len(a_list))[:-1:2]:
    print(co[index])
    print(co[index+1])
    if not co[index] == co[index + 1]:
        print(0)
        quit()




print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Runtime Error

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

co = a_list.copy()
if 0 in co:
    co.remove(0)
co.sort()


if not len(co) % 2 == 0:
    print(0)
    quit()

for index in range(len(a_list))[::2]:
    print(co[index])
    print(co[index+1])
    if not co[index] == co[index + 1]:
        print(0)
        quit()




print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Runtime Error

Solution code:

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

co = a_list.copy()
co.sort()
if 0 in co:
    co.remove(0)

if not len(co) % 2 == 0:
    print(0)
    quit()



for index in range(len(a_list)[:-1:2]):
    if not a_list[index] == a_list[index + 1]:
        print(0)
        quit()




print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Runtime Error

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

co = a_list.copy()
co.sort()
if 0 in co or len(co) % 2 == 1:
    co.remove(0)
else:
    print(0)
    quit()


for index in range(len(a_list)[:-1:2]):
    if not a_list[index] == a_list[index + 1]:
        print(0)
        quit()




print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Runtime Error

Solution code:


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

co = a_list.copy()
co.sort()
if 0 in co or len(co) % 2 == 1:
    co.remove(0)
else:
    print(0)
    quit()


for index in range(len(a_list)[::2]):
    if not a_list[index] == a_list[index + 1]:
        print(0)
        quit()




print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
A=list(map(int,input().split()))
if N%2==1:
    if 0 not in A:
        print(0)
    else:
        B=A.remove(0)
        Bc=dict(collections.Counter(B))
        for i in Bc.keys():
            if Bc[i]!=2:
                print(0)
                break
        else:
            print(2**(B//2)%(10**9+7))
else:
    Bc=dict(collections.Counter(A))
    for i in Bc.keys():
        if Bc[i]!=2:
            print(0)
            break
    else:
        print(2**(B//2)%(10**9+7))

Submission status: Runtime Error

Solution code:
def inpl(): return [int(i) for i in input().split()]
import sys
N = int(input())
A = inpl()
H = dict([])
if N%2:
    H[0] = -1
    for i in range(1, 1+N//2):
        H[2*i] = -2
else:
    for i in range(1, 1+N//2):
        H[2*i-1] = -2
for i in A:
    H[i] += 1
H = list(H.values())
if any(H):
    print(0)
    sys.exit()
print(2**(N//2))

Submission status: Runtime Error

Solution code:

def power(N):
    ans=1
    for i in range(N):
        ans=(ans*2)%(10**9+7)
    return ans

N=int(input())

A = map(int,input().split())
flag=True
if N%2==0:
    n = [0 for i in range(N/2)]
    for a in A:
        if a%2==0:
            print(0)
            flag=False
            break
        if (a-1)/2 in range(N/2):
            n[(a-1)/2]+=1
            if n[(a-1)/2]==3:
                print(0)
                flag=False
                break
        else:
            print(0)
            flag=False
            break
    if flag:
        print(power(N/2))
    
else:
    n = [0 for i in range((N+1)/2)]
    for a in A:
        if a%2==1:
            print(0)
            flag=False
            break
        if a/2 in range((N+1)/2):
            n[a/2]+=1
            if a==0:
                if n[a]==2:
                    print(0)
                    flag=False
                    break
            elif n[a/2]==3:
                print(0)
                flag=False
                break
        else:
            print(0)
            flag=False
            break
    if flag:
        print(power((N-1)/2))