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())
a = [int(i) for i in input().split()]

# aの各数値の個数をdictで保持(数値:個数) 
a_dict = {}
for v in a:
    if v in a_dict:
        a_dict[v] += 1
    else:
        a_dict[v] = 1

# a_dictの中になければならない数値のリストを作成
possible_list = {i: True for i in range(1, n, 2)}
 
can = True
if n % 2 == 0:
    for k, v in a_dict.items():
        # 数値が2個でない、もしくはkがpossible_list内に存在しないならFalse
        if v != 2 or k not in possible_list:
            can = False
            break
else:
　　　　if a_dict[0] != 1:
        can = False
    else:
        for k, v in a_dict.items():
            if v != 2 or k not in possible_list:
                can = False
                break
 
if can:
    print(2 ** (n // 2) % (10 ** 9 + 7))
else:
    print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
arr = sorted([int(i) for i in input().split()])
ok = True
b = {}
for i in range(N):
    if arr[i] not in b:
        b[arr[i]] = 1
    else:
        b[arr[i]] += 1
if N%2 :
    if b[0] != 1:
        ok = False
    for i in range(1,(N-1)//2+1):
        if ok== False:
            break
        if b[2*i]!= 2:
            ok = False
else:
    for i in range(1,N//2+1):
        if b[2*i-1] != 2:
            ok = False

if ok :
    print(2**(N//2)%(10**9+7))
else:
    print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
arr = sorted([int(i) for i in input().split()])
ok = True
b = {}
for i in range(N):
    if arr[i] not in b:
        b[arr[i]] = 1
    else:
        b[arr[i]] += 1
if N%2 :
    if b[0] != 1:
        ok = False
    for i in range(1,(N-1)//2+1):
        if b[2*i]!= 2:
            ok = False
else:
    for i in range(1,N//2+1):
        if b[2*i-1] != 2:
            ok = False

if ok :
    print(2**(N//2))
else:
    print(0)

Submission status: Runtime Error

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


def main():
    """Function."""
    n = int(input())
    a = list(map(int, input().split()))

    flag = 1
    if n % 2 == 0:
        check = [0 for _ in range(n // 2)]
        for num in a:
            dum = (num - 1) // 2
            if check[dum] >= 2:
                flag = 0
                break
            else:
                check[dum] += 1

        for num in check:
            if num != 2:
                flag = 0
                break

        if flag == 1:
            print(int((2 ** (n // 2)) % (1e9 + 7)))
        else:
            print(0)

    else:
        check = [0 for _ in range((n // 2) + 1)]
        for num in a:
            dum = num // 2

            if dum == 0:
                if check[0] >= 1:
                    flag = 0
                    break
                else:
                    check[0] += 1

            else:
                if check[dum] >= 2:
                    flag = 0
                    break
                else:
                    check[dum] += 1

        if check[0] != 1:
            flag = 0
        for num in check[1:]:
            if num != 2:
                flag = 0
                break

        if flag == 1:
            print(int(2 ** ((n - 1) // 2) % (1e9 + 7)))
        else:
            print(0)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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


def main():
    """Function."""
    n = int(input())
    a = list(map(int, input().split()))

    flag = 1
    if n % 2 == 0:
        check = [0 for _ in range(n // 2)]
        for num in a:
            dum = (num - 1) // 2
            if check[dum] >= 2:
                flag = 0
                break
            else:
                check[dum] += 1

        for num in check:
            if num != 2:
                flag = 0
                break

        if flag == 1:
            print((2 ** (n // 2)) % (1e9 + 7))
        else:
            print(0)

    else:
        check = [0 for _ in range((n // 2) + 1)]
        for num in a:
            dum = num // 2

            if dum == 0:
                if check[0] >= 1:
                    flag = 0
                    break
                else:
                    check[0] += 1

            else:
                if check[dum] >= 2:
                    flag = 0
                    break
                else:
                    check[dum] += 1

        if check[0] != 1:
            flag = 0
        for num in check[1:]:
            if num != 2:
                flag = 0
                break

        if flag == 1:
            print(2 ** ((n - 1) // 2) % (1e9 + 7))
        else:
            print(0)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
zero = a_list.count(0)
D = 1000000000 + 7
a_set = set(a_list)
if zero == 1 and n -1 == 2 * a_set:
    print(2 ** ((n-1)//2) % D)
elif zero == 0 and n == 2 * a_set:
    print(2 ** (n//2) % D)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
A = [int(i) for i in input().split()]
A.sort()

if N % 2 != 0:
    if A[0] == 0:
        a = A[1:]
        j = 1
        k = 0
        for i in range(0, N//2 + 1, 2):
            if a[k] == a[k+1] == 2*j:
                j += 1
                k += 2
            else:
                print(0)
                sys.exit()
        print((2**(N//2)) % (10**9+7))
        
    else:
        print(0)
else:
    j = 1
    k = 0
    for i in range(0, N//2 + 1, 2):
        if A[k] == A[k+1] == 2*j -1:
            j += 1
            k += 2
        else:
            print(0)
            sys.exit()
    print((2**(N//2)) % (10**9+7))

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
A = [int(i) for i in input().split()]
A.sort()

if N % 2 != 0:
    if A[0] == 0:
        a = A[1:]
        j = 1
        for i in range(0, N//2 + 1, 2):
            if a[i] == a[i+1] == 2*j:
                j += 1
            else:
                print(0)
                sys.exit()
        print((2**(N//2)) % (10**9+7))
        
    else:
        print(0)
else:
    j = 1
    k = 0
    for i in range(0, N//2 + 1, 2):
        if A[k] == A[k+1] == 2*j -1:
            j += 1
            k += 2
        else:
            print(0)
            sys.exit()
    print((2**(N//2)) % (10**9+7))

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
A = [int(i) for i in input().split()]
A.sort()

if N % 2 != 0:
    if A[0] == 0:
        a = A[1:]
        j = 1
        for i in range(0, N//2 + 1, 2):
            if a[i] == a[i+1] == 2*j:
                j += 1
            else:
                print(0)
                sys.exit()
        print((2**(N//2)) % (10**9+7))
        
    else:
        print(0)
else:
    j = 1
    for i in range(0, N//2+1, 2):
        if A[i] == A[i+i] == 2*j -1:
            j += 1
        else:
            print(0)
            sys.exit()
    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 == 0:
  if a == sorted(2*[2*x+1 for x in range(n/2)]):
    print(2**(n/2))
  else:
    print(0)
else:
  if a == sorted(list(2*[2*x for x in range(n//2+1)])[1:]):
    print(2**(n//2))
  else:
    print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
if not N%2:
    result = 2**(N/2)
    A.sort()
    for i in range(0,N-1,2):
        if A[i] != A[i+1]:
            result = 0
else:
    result = 2**(N/2 - 1)
    for i in range(1,N,2):
        if A[i] != A[i+1]:
            result = 0
print(int(result))

Submission status: Runtime Error

Solution code:
N=int(input())
l=list(map(int,input().split()))
a=1
if N%2==0:
  if N!=set(l)*2:
    a=0
else:
  if l.count(0)!=1 or N!=2*len(set(l))+1:
    ans=0
  else:
    ans=0
if a:
  print((2**(N//2))%(10**9+7))
else:
  print(0)

Submission status: Runtime Error

Solution code:
N=int(input())
l=map(int,input().split())
a=1
if N%2==0:
  if int(N/2)!=set(l):
    a=0
else:
  if l.count(0)!=1 or N!=2*len(set(l))+1:
    ans=0
if ans:
  print(2**(N//2)%(10**9+7))

Submission status: Runtime Error

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

for i,x in enumerate(l.sort()):
  if n%2 and x!=int((i+1)/2):
    print(0)
  else:
    if i%2 and i+1!=x:
      print(0)
    elif i!=x:
      print(0)
      
else:
  print(int((n/2)**2)%(10**9+7))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
l=list(map(int,input().split())).sort()
for i,x in enumerate(l):
  if n%2 and x!=int((i+1)/2):
    print(0)
  else:
    if i%2 and i+1!=x:
      print(0)
    elif i!=x:
      print(0)
      
else:
  print(((n/2)**2)%10**9+7)

Submission status: Runtime Error

Solution code:
N=int(input())
if N%2==0:
    L=[]
    for i in range(int(N/2)):
        L.append(i*2+1)
        L.append(i*2+1)
        
else:
    L=[0]
    for i in range(1,int((N-1)/2)+1):
        L.append(i*2)
        L.append(i*2)

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

if A==L:
    if N%2==0:
        ans=1
        for j in range(int(N/2)):
            ans*=2
            ans%=(10**9+7)
        print(ans)
    else:
        ans=1
        for j in range(int(N-1)/2):
            ans*=2
            ans%=(10**9+7)
        print(ans)
else:
    print(0)

Submission status: Runtime Error

Solution code:
N=int(input())
if N%2==0:
    L=[]
    for i in range(int(N/2)):
        L.append(i*2+1)
        L.append(i*2+1)
        
else:
    L=[0]
    for i in range(1,int((N-1)/2)+1):
        L.append(i*2)
        L.append(i*2)

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

if A==L:
    if N%2==0:
        print(int(2**(N/2)%(10**9+7)))
    else:
        print(int(2**((N-1)/2)%(10**9+7)))
else:
    print(0)

Submission status: Runtime Error

Solution code:
N=int(input())
if N%2==0:
    L=[]
    for i in range(int(N/2)):
        L.append(i*2+1)
        L.append(i*2+1)
        
else:
    L=[0]
    for i in range(1,int((N-1)/2)+1):
        L.append(i*2)
        L.append(i*2)

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

if A==L:
    if N%2==0:
        print(int(2**(N/2)))
    else:
        print(int(2**((N-1)/2)))
else:
    print(0)

Submission status: Runtime Error

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


if N % 2 == 1:
  if A.count(0) != 1:
    print(0)
  else:
    if not all([A.count(i) == 2 for i in range(2, N, 2)]):
      print(0)
    else:
      print(2 ** ((N - 1) // 2) % (10**9 + 7))
else:
  if not all([A.count(i) == 2 for i in range(1, N, 2)]):
    print(0)
  else:
    print(2 ** ((N // 2) % (10**9 + 7)))

Submission status: Runtime Error

Solution code:
n = int(input())
nums = {0:0}

for i in list(map(int, input().split())):
    if i != 0 and (n%2 == i%2):
        print(0)
        break
    if i in nums:
        if nums[i] <= 1:
            nums[i] += 1
        else:
            print(0)
            break
    else:
        nums[i] = 1
else:        
    if n%2 == 1:
        if nums[0] == 0:
            print(0)
            break
    del nums[0]
    
    if 1 in list(nums.values()):
        print(0)
    else:
        print(2**len(nums.values()))

Submission status: Runtime Error

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
A.sort()
A = collections.Counter(A)

ans = 1
count = 0
if N == 1:
    if A[0] == 0:
        ans = 1
    else:
        print(0)

if N % 2 == 0:
    for i in range(1, int(N/2)+1):
        if A[i*2-1] == 2:
            count += 1
        else:
            ans = 0
else:
    if A.count(0) == 1:
        for i in range(1, int(N/2)+1):
            if A[i*2] == 2:
                count += 1

            else:
                ans = 0
    else:
        ans = 0
for i in range(count):
    ans *= 2
    ans %= 1000000007
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
A = input().split()

As = sorted(A)
OE = N % 2
if OE == 1:
    As.pop(0)
for i in range (0, N, 2):
    #print(As)
    if As[i] != As[i + 1]:
        print(0)
        exit()
    if As[i] != str(i - 1 + OE):
        print(0)
        exit()

print(int(pow(2, int((N-OE)/2)) % (pow(10, 9) + 7)))

Submission status: Runtime Error

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

s=list(sorted(s))
if N%2==1:
    s.remove(0)
    for i in range(n-1)

a = []
for i in range(n//2):
    a.append(2*i+1)

if s[0::2]==s[1::2] and s[0::2] ==a :
    print((2**((len(s))//2))%(10**9+7))
else:
    print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
def main():
    if A[0] == N % 2:
        print(0)
        return 0
    if A[0] == 0:
        del A[0]
    if A[0] == 0:
        print(0)
        return 0
    i = 1
    while True:
        if i >= len(A):
            break
        if len(A) % 2 != 0:
            print(0)
            return 0
        if A[i] != A[i - 1]:
            print(0)
            return 0
        i += 2
    i = 2
    while True:
        if i >= len(A):
            break
        if A[i] == A[i - 1]:
            print(0)
            return 0
        i += 2
    print(pow(2, len(A) // 2) % 1000000007)
main()

Submission status: Runtime Error

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

mod = 10 ** 9 + 7

if N = 1 and input_list[0] == 0:
    print(1)
else:
    if N % 2 == 1:
        if input_list[0] != 0:
            print(0)
        else:
            flag = 2
            limit = (N - 1) // 2
            for i in range(1, limit, 2):
                if input_list[i] == flag and input_list[i+1] == flag:
                    flag += 2
                    if i == limit-1:
                        print((2**limit) % mod)
                else:
                    print(0)
                    break
    elif N % 2 == 0:
        flag = 1
        limit = N // 2
        for i in range(0, limit, 2):
            if input_list[i] == flag and input_list[i+1] == flag:
                flag += 2
                if i == limit-2:
                    print((2**limit) % mod)
            else:
                print(0)
                break

Submission status: Runtime Error

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

mod = 10 ** 9 + 7

if N = 1 and input_list[0] == 0:
    print(1)

if N % 2 == 1:
    if input_list[0] != 0:
        print(0)
    else:
        flag = 2
        limit = (N - 1) // 2
        for i in range(1, limit, 2):
            if input_list[i] == flag and input_list[i+1] == flag:
                flag += 2
                if i == limit-1:
                    print((2**limit) % mod)
            else:
                print(0)
                break
elif N % 2 == 0:
    flag = 1
    limit = N // 2
    for i in range(0, limit, 2):
        if input_list[i] == flag and input_list[i+1] == flag:
            flag += 2
            if i == limit-2:
                print((2**limit) % mod)
        else:
            print(0)
            break


# 5
# 4 2 0 2 4

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
if N%2==0:
    for i in range(N):
        if A[i]%2==1 and (A[i]-1)/2<=N/2:
            B[(A[i]-1)//2]+=1
        else:
            print(0)
            exit()
    for i in range(len(B)):
        if B[i]!=2:
            print(0)
            exit()
    print(int(pow(2,N/2)%(pow(10,9)+7)))
elif N%2==1:
    for i in range(N):
        if A[i]%2==0 and A[i]/2<=N+1/2:
            B[A[i]//2]+=1
        else:
            print(0)
            exit()
    if B[0]!=1:
        print(0)
        exit()
    for i in range(len(B)-1):
        if B[i+1]!=2:
            print(0)
            exit()
    print(int(pow(2,(N-1)/2)%(pow(10,9)+7)))
else:
    print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

cnt = [0 for i in range(N)]
ans = 1

if N % 2 == 0:
    for i in range(N):
        if A[i] % 2 == 0:
            print(0)
            exit()
        cnt[A[i]] += 1
        if cnt[A[i]] > 2:
            print(0)
            exit()
        if cnt[A[i]] == 1:
            ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)
else:
    for i in range(N):
        if A[i] % 2 == 1:
            print(0)
            exit()
        if A[i] > 0:
            cnt[A[i]] += 1
            if cnt[A[i]] > 2:
                print(0)
                exit()
            if cnt[A[i]] == 1:
                ans = (ans * 2) % (10 ** 9 + 7)
        if A[i] == 0:
            cnt[0] += 1
            if cnt[0] > 1:
                print(0)
                exit()
    print(ans)


ans = 1

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

Submission status: Runtime Error

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

ans = 1

if N % 2 == 0:
    for i in range(1, N, 2):
        if A.count(i) > 2:
            print(0)
            exit()
    for i in range(N / 2):
        ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)
else:
    if A.count(0) > 1:
        print(0)
        exit()
    for i in range(2, N, 2):
        if A.count(i) > 2:
            print(0)
            exit()
    for i in range(N // 2):
        ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)

Submission status: Runtime Error

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

count = [0 for i in range(N)]
ans = 1

if N % 2 == 0:
    for i in range(N):
        count[A[i]] += 1
        if count [A[i]] > 2:
             print(0)
             exit()
        if A[i] == 0 and count[A[i]] > 1:
            print(0)
            exit()
        ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)
else:
    for i in range(N):
        if count [A[i]] > 2:
             print(0)
             exit()
        ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)

Submission status: Runtime Error

Solution code:
# try:
import numpy as np

n = int(input())
a = list(map(int,input().split()))
a = np.array(a)
x = 1e9 + 7

if len(a)%2 == 1:
    temp = int((len(a) - 1)/2)
    ans = int((2**(temp % 30) + (temp//30) * x) % x)
    if sum(a == 0) != 1:
        ans = 0
    else:
        a = a[a!=0]
else:
#     ans = 2**(temp)%(1e9 + 7)
    temp = int((len(a))/2)
    ans = int((2**(temp % 30) + (temp//30) * x) % x)
    a = a+1

cands = [2*k for k in range(1,int(len(a)/2) + 1)] * 2

b,bb = np.unique(a,return_counts=True)
if sum(bb == 2) != len(a)/2:
    ans = 0
b == np.array(cands)
for bbb, ccc in zip(b,cands):
    if bbb != ccc:
        ans = 0
        break

print(ans)
# except:
#     print(0)

Submission status: Runtime Error

Solution code:
import numpy as np

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


if len(a)%2 == 1:
    ans = int(2**((len(a) - 1)/2)%(1e9 + 7))
    if sum(a == 0) != 1:
        ans = 0
    else:
        a = a[a!=0]
else:
    ans = int(2**((len(a))/2)%(1e9 + 7))
    a = a+1

cands = [2*k for k in range(1,int(len(a)/2) + 1)] * 2

for c in cands:
    if sum(a == c) != 2:
        ans = 0
        break

print(ans)

Submission status: Runtime Error

Solution code:
import sys

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

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

table = [0] * n
for i in range(n):
    s1 = (a[i] + n - 1) / 2
    s2 = n - 1 - s1
    if not is_integer_num(s1):
        print(0)
        sys.exit()

    x1 = int(s1)
    x2 = int(s2)
    if x1 != x2:
        table[x1] += 1
        table[x2] += 1
    else:
        table[x1] += 1

if (n % 2) == 0:
    for i in range(n):
        if table[i] != 2:
            print(0)
            sys.exit()
else:
    for i in range(n):
        mid = n // 2
        if i == mid:
            if table[i] != 1:
                print(0)
                sys.exit()
        else:
            if table[i] != 2:
                print(0)
                sys.exit()
ans = int(pow(2, n // 2) % (10e9 + 7))
print(ans)

Submission status: Runtime Error

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

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

BN = [0] * (N//2+1)

# 偶奇で分けて集計
for i in range(N):
    if N % 2 != 0:
        BN[N//2 - AN[i]//2] += 1
    else:
        BN[N//2 - (AN[i]-1)//2] += 1

# 偶数の場合は真ん中を考慮
ans = 0
for i in range(len(BN)):
    if BN[i] > 2 or N % 2 != 0 and BN[-1] > 1:
        print(0)
        exit()

# 結果出力
print(2 ** (N//2))

Submission status: Runtime Error

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

if n%2 == 0:
    valid = True
    for i in range(n):
        if i%2 == 0: v = i+1
        else: v = i
        if a[i] != v:
            valid = False
            print(0)
            break
    if valid:
        print(int((2**(n/2))%MOD))

else:
    valid = True
    for i in range(n):
        if i%2 != 0: v = i+1
        else: v = i
        if a[i] != v:
            valid = False
            print(0)
            break
    if valid:
        print(int(2**((n-1)/2))%MOD)

Submission status: Runtime Error

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

if n%2 == 0:
    a_valid = []
    for i in range(1, n, 2):
        a_valid += [i, i]
    if a == a_valid:
        print(int((2**(n/2))%MOD))
    else:
        print(0)
else:
    a_valid = [0]
    for i in range(2, n, 2):
        a_valid += [i, i]
    if a == a_valid:
        print(int((2**int(n/2))%MOD))
    else:
        print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
d=int(n/2)
for i in range(n):
  a[i]=int(a[i])
a.sort()
a.reverse()
j=1
count=2
while(a[j-1]==a[j]):
  j+=2
  count=count*2
  if(j>=n-1):
    break

if(count==2**(d)):
  print(2**(d))
else:
  print(0)