Problem:


Score : 300 points

Problem Statement

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

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

Constraints

1≦N≦10^5

0≦A_i≦N-1

Input

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

N
A_1 A_2 ... A_N

Output

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

Sample Input 1

5
2 4 4 0 2

Sample Output 1

4

There are four possible orders, as follows:

2,1,4,5,3

2,5,4,1,3

3,1,4,5,2

3,5,4,1,2

Sample Input 2

7
6 4 0 2 4 0 2

Sample Output 2

0

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

Sample Input 3

8
7 5 1 1 7 3 5 3

Sample Output 3

16



Sample input:
5
2 4 4 0 2


Sample output:
4

Submission status: Wrong Answer

Solution code:

N = int(input())

can_flg = True

lst_A = input().split()

for i in range(len(lst_A)):
    lst_A[i] = int(lst_A[i])

lst_A.sort()

while 1:
    if len(lst_A) % 2 == 1:
        if lst_A[0] != 0:
            can_flg = False
            break
        for i in range(1, len(lst_A), 2):
            if not((lst_A[i] == (i + 1)) and (lst_A[i + 1] == (i + 1))):
                can_flg = False
                break
    else:
        for i in range(len(lst_A), 2):
            if not ((lst_A[i] == (i + 1)) and (lst_A[i + 1] == (i + 1))):
                can_flg = False
                break
    break

if can_flg == True:
    ans = 2 ** (len(lst_A) // 2)
    ans = ans % (10 ** 9 + 7)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split(" "))
a_num = [N-i for i in range(1, N, 2)]
if sum(a) == (sum(a_num)*2):
    print(pow(N//2, 2) % (10**9 + 7))
else:
    print("0")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split(" "))
a_num = [N-i for i in range(1, N, 2)]
if sum(a) == (sum(a_num)*2):
    print(pow(N//2, 2))
else:
    print("0")

Submission status: Wrong Answer

Solution code:

N = int(input())

can_flg = True

lst_A = input().split()

for i in range(len(lst_A)):
    lst_A[i] = int(lst_A[i])

lst_A.sort()

while 1:
    if len(lst_A) % 2 == 1:
        if lst_A[0] != 0:
            can_flg = False
            break
        for i in range(1, len(lst_A), 2):
            if not((lst_A[i] == (i + 1)) and (lst_A[i + 1] == (i + 1))):
                can_flg = False
                break
        if can_flg == False:
            break
    else:
        for i in range(len(lst_A), 2):
            if not ((lst_A[i] == (i + 1)) and (lst_A[i + 1] == (i + 1))):
                can_flg = False
                break
        if can_flg == False:
            break
    break

if can_flg == True:
    ans = 2 ** (len(lst_A) // 2)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:

N = int(input())

can_flg = True

lst_A = input().split()

for i in range(len(lst_A)):
    lst_A[i] = int(lst_A[i])

lst_A.sort()

while 1:
    if len(lst_A) % 2 == 1:
        if lst_A[0] != 0:
            can_flg = False
            break
        for i in range(1, len(lst_A), 2):
            if not(lst_A[i] == (i + 1) and lst_A[i + 1] == (i + 1)):
                can_flg = False
                break
        if can_flg == False:
            break
    else:
        for i in range(len(lst_A), 2):
            if not (lst_A[i] == (i + 2) and lst_A[i + 1] == (i + 2)):
                can_flg = False
                break
        if can_flg == False:
            break
    break

if can_flg == True:
    ans = 2 ** (len(lst_A) // 2)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input()
a_num = [N-i for i in range(1, N, 2)]
a = a.replace(" ", "")
if a.count("0") == 1:
    a = a.replace("0", "")
for i in range(len(a_num)):
    if a.count(str(a_num[i])) == 2:
        a = a.replace(str(a_num[i]), "")
if len(a) == 0:
    print(pow(N//2, 2))
else:
    print("0")

Submission status: Wrong Answer

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

from collections import defaultdict
d = defaultdict(int)
for i in a:
    d[i] += 1

if len(a)%2==1:
    if d["0"]!=1:
        print(0)
    else:
        d["0"] +=1
        if all(x==2 for x in d.values()) and max(d.keys())==str(len(a)-1):
            print(2**int(int(max(d.keys()))/2))
        else:
            print(0)
else:
    if all(x==2 for x in d.values()) and max(d.keys())==str(len(a)-1):
        print(2**int((int(max(d.keys()))+1)/2))
    else:
        print(0)

Submission status: Wrong Answer

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

sa = set(a)

if len(a)%2==1:
    if len(sa)!=int(len(a)/2)+1:
        print(0)
    else:
        print(2**(len(sa)-1))
else:
    if len(sa)!=int(len(a))/2:
        print(0)
    else:
        print(2**len(sa))

Submission status: Wrong Answer

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

sa = set(a)

if len(a)%2==1:
    if len(sa)!=int(len(a)/2)+1:
        print(0)
        exit()

    print(2**(len(sa)-1))
else:
    if len(sa)!=int(len(a))/2:
        print(0)
        exit()

    print(2**len(sa))

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
"""考え方
・Nが奇数の時、
0が一個と、
2, 4, 6, ..., K (< N)が2個ずつ

・Nが偶数の時、
1, 3, ... K (< N)が2個ずつ

"""
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10**9+7

    dic = {}
    for a in A:
        if not a in dic:
            dic[a] = 0
        dic[a] += 1
    
    if N%2 == 0:
        # Nが偶数のとき
        for i in range(N):
            num = i*2+1
            if num > N:
                break

            if not num in dic:
                print(0)
                return

            if dic[num] == 2:
                continue
            else:
                print(0)
                return
        print((2**i)%MOD)
        return
    else:
        # Nが奇数のとき
        for i in range(N):
            num = i*2
            if num > N:
                break
            
            if not num in dic:
                print(0)
                return
            
            if num == 0 and dic[num] == 1:
                continue
            elif num != 0 and dic[num] == 2:
                continue
            else:
                print(0)
                return
        print((2**(i-1))%MOD)
        return
        

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
"""考え方
・Nが奇数の時、
0が一個と、
2, 4, 6, ..., K (< N)が2個ずつ

・Nが偶数の時、
1, 3, ... K (< N)が2個ずつ

"""
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10**9+7

    dic = {}
    for a in A:
        if not a in dic:
            dic[a] = 0
        dic[a] += 1
    
    if N%2 == 0:
        # Nが偶数のとき
        for i in range(N):
            num = i*2+1
            if num > N:
                break

            if not num in dic:
                print(0)
                return

            if dic[num] == 2:
                continue
            else:
                print(0)
                return
        print(2**(i)%MOD)
        return
    else:
        # Nが奇数のとき
        for i in range(N):
            num = i*2
            if num > N:
                break
            
            if not num in dic:
                print(0)
                return
            
            if num == 0 and dic[num] == 1:
                continue
            elif num != 0 and dic[num] == 2:
                continue
            else:
                print(0)
                return
        print(2**(i-1)%MOD)
        return
        

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int,input().split()))
#nが奇数の場合,0,2,2,4,4,...
#nが偶数の場合,1,1,3,3,...
a.sort()
flag = True
if n %2==1:
    for n,v in enumerate(a):
        if n==0:
            if v != 0:
                flag=False
                break
        else:
            if v!=((n+1)//2)*2:
                flag=False
                break
else:
    for n,v in enumerate(a):
        if v!=(n//2)*2+1:
            flag=False
            break
if flag:
    print(2**(len(a)//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(list(map(int, input().split())))
MOD = 10 ** 9 + 7
if N % 2 == 1 and a[0] != 0:
    print(0)
    exit()
for i in range(N % 2 + 1, N, 2):
  if not(a[i - 1] == a[i] == i):
    break
  else:
    print(2 ** (N // 2) % MOD)
    exit()
print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

K = Counter(A).most_common()
flag = True

for i in range(len(K)):
    if K[i][1] != 2:
        if K[i][0] == 0 and K[i][1] == 1:
            continue
        else:
            flag = False

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

Submission status: Wrong Answer

Solution code:
import itertools
N = input()
l = list(map(int,input().split(" ")))
l.sort()
N = int(N)
flag = True

if N %2 == 0:
    for i in range(0 , N ,2):
        if l[i] == l[i+1] == i + 1 :
            pass
        else:
            flag = False
    if flag:
        print(2**(N//2))
    else:
        print(0)
else:
    of = 1
    if l[0] == 0:
        of = 1
    else:
        flag = False


    for i in range(of , N ,2):
        if l[i] == l[i+1] == i+of :
            pass
        else:
            flag = False
    if flag:
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

A.sort()
flag = True

if N%2==1:
    b=[0]
    for i in range(1, N):
        c=i
        if i%2==1:
            c += 1
        b.append(c)
    if A != b:
        print(0)
    else:
        ans = 2
        for i in range((N-1)//2-1):
            ans *= 2
            ans = ans % (10**9+7)
        print(ans)
    
else:
    d=[]
    for i in range(N):
        e=i
        if i%2==0:
            e += 1
        d.append(e)
    
    if A != d:
        print(0)
    else:
        ans = 2
        for i in range(N//2-1):
            ans *= 2
            ans = ans % (10**9+7)
        print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
# print(A)
if A.count(0) > 1:
    print(0)
    exit()

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
# print(A)
if A.count(0) > 1:
    print(0)
    exit()

counter = {}
memo = [0 for i in range(N)]

# if N % 2 == 0:  # 偶数
for i in range(N):
    if A[i] > N-1:
        print(0)
        exit()
    if memo[A[i]] < 2:
        memo[A[i]] += 1
        counter[A[i]] = 1
    else:
        print(0)
        exit()

if N % 2 == 0:
    print((len(counter)**2)%(10**9+7))
else:
    print(((len(counter)-1)**2)%(10**9+7))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=map(int,input().split())
if N%2==0:
  if sorted(A)==sorted([i*2+1 for i in range(N//2)]*2):
    print(2**(N//2))
  else:
    print('0')
else:
  if sorted(A)==sorted([(j+1)*2 for j in range(N//2)]*2+[0]):
      print(2**(N//2))
  else:
    print('0')

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

from collections import Counter

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

ans = -1
A_ = Counter(A)
cnt = 0
if N % 2 == 1:
    if A_[0] != 1:
        ans = 0
    for i in range(2,N,2):
        if A_[i] != 2:
            ans = 0
            break
        cnt += 1
else:
    for i in range(1,N,2):
        if A_[i] != 2:
            ans = 0
            break
        cnt += 1

if ans == 0:
    print(ans)
else:
    print(2**cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, *A = map(int, open(0).read().split())
l = [v for _, v in sorted(Counter(A).items())]
if (len(l) == N // 2) or (l[0] == 1 and len(l) == N // 2 + 1):
    if all(v == 2 for v in l[N % 2:]):
        print(2 ** (N // 2))
    else:
        print(0)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, *A = map(int, open(0).read().split())
l = [v for _, v in sorted(Counter(A).items())]
if (len(l) == N // 2) or (l[0] == 1 and len(l) == N // 2 + 1):
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, *A = map(int, open(0).read().split())
l = [v for _, v in sorted(Counter(A).items())]
if (N % 2 == 0 and len(l) == N // 2) or \
       (N % 2 == 1 and l[0] == 1 and len(l) == N // 2 + 1):
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, *A = map(int, open(0).read().split())
l = sorted(Counter(A).values())
if (N % 2 == 0 and len(l) == N // 2) or \
       (N % 2 == 1 and l[0] == 0 and len(l) == N // 2 + 1):
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, *A = map(int, open(0).read().split())
l = sorted(Counter(A).values())
if (N % 2 == 0 and sum(l) == N) or \
       (N % 2 == 1 and l[0] == 1 and len(l) == N // 2 + 1):
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = Counter(map(int, input().split()))
A[0] = 2
mod = 10 ** 10 + 7


def n_power_m_mod(n, m, mod):
    ret = 1
    for _ in range(m):
        ret *= n
        ret %= mod
    return ret


if all(v == 2 for v in A.values()):
    print(n_power_m_mod(2, n//2, mod))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def is_valid(xs):
    d = defaultdict(lambda: 0)
    for x in xs:
        d[x] += 1

    if len(xs) % 2 == 0:
        for v in range(1, len(xs), 2):
            if d[v] != 2:
                return False
    else:
        if d[0] != 1:
            return False
        for v in range(2, len(xs), 2):
            if d[v] != 2:
                return False

    return True


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

if is_valid(xs):
    print(2 ** (n // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for ai in a:
    d[ai] += 1
ans = 1
if n % 2:
    for k, v in d.items():
        if k > 0 and v == 2:
            ans *= 2
        elif k == 0 and v == 1:
            ans *= 1
        else:
            ans = 0
            break
else:
    for v in d.values():
        if v == 2:
            ans *= 2
        else:
            ans = 0
            break
print(ans)

Submission status: Wrong Answer

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

MOD = 10 ** 9 + 7

ex = []
if N % 2 == 1:
    ex.append(0)
    for i in range(1, N//2 + 1):
        ex.append(i*2)
        ex.append(i*2)
    ans = 2 ** (N//2)
else:
    for i in range(N//2):
        ex.append(i*2 + 1)
        ex.append(i*2 + 1)
    ans = 2 ** (N//2)

A.sort()
if A != ex:
    ans = 0


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	ans = 0
	lie = False
	count = [0]*N
	odd = N % 2 == 1
	for i in range(N):
		if A[i] > N-1:
			lie = True
			break
		if (A[i]%2 == 0) ^ odd:
			lie = True
			break
		count[A[i]] += 1
		if count[A[i]] > 2:
			lie = True
			break

	if odd and count[0] != 1:
		lie = True
	if not(odd) and count[0] > 0:
		lie = True

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


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	ans = 0
	lie = False
	count = [0]*N
	odd = N % 2 == 1
	for i in range(N):
		if A[i] > N-1:
			lie = True
			break
		if A[i] % 2 == 1 ^ odd:
			lie = True
			break
		count[A[i]] += 1
		if count[A[i]] > 2:
			lie = True
			break

	if odd and count[0] != 1:
		lie = True
	if not(odd) and count[0] > 0:
		lie = True

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


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	ans = 0
	lie = False
	count = [0]*N
	odd = N % 2 == 1
	for i in range(N):
		if A[i] > N-1:
			lie = True
			break
		if A[i] % 2 == 1 and odd:
			lie = True
			break
		count[A[i]] += 1
		if count[A[i]] > 2:
			lie = True
			break
	if odd and count[0] != 1:
		lie = True
	if not(odd) and count[0] > 0:
		lie = True

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


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	ans = 0
	lie = False
	count = [0]*N
	odd = N % 2 == 1
	for i in range(N):
		if A[i] > N-1:
			lie = True
			break
		if A[i] % 2 == 1 and odd:
			lie = True
			break
		count[A[i]] += 1
		if count[A[i]] > 2:
			lie = True
			break
	if odd and count[0] != 1:
		lie = True

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


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
n = int(input())
odd = n % 2 == 1
if "".join(sorted(list(input().split()))) == "0" * odd + "".join([str(i) * 2 for i in range(1 + odd, n, 2)]):
    cnt = 1
    for i in range(n//2):
        cnt *= 2
        cnt = cnt % (10 ** 9 + 7)
    print(cnt)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = sorted(Counter(list(map(int, input().split()))).items(), key=lambda x: x[0])
if len(A) != (N + 1) // 2:
    print(0)
    exit()
if N % 2 == 1:
    if A[0][0] != 0 or A[0][1] != 1:
        print(0)
        exit()
    for (a, n), i in zip(A, range(N // 2 + 1, 2)):
        if a != i or n != 2:
            print(0)
            exit()
else:
    for (a, n), i in zip(A, range(1, N // 2 + 1, 2)):
        if a != i or n != 2:
            print(0)
            exit()
print(2 ** (N // 2) % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = sorted(Counter(list(map(int, input().split()))).items(), key=lambda x: x[0])
if len(A) != (N + 1) // 2:
    print(0)
    exit()
if N % 2 == 1:
    if A[0][0] != 0 or A[0][1] != 1:
        print(0)
        exit()
    for (a, n), i in zip(A, range(N // 2 + 1, 2)):
        if a != i or n != 2:
            print(0)
            exit()
else:
    for (a, n), i in zip(A, range(1, N // 2 + 1, 2)):
        if a != i or n != 2:
            print(0)
            exit()
print(2 ** (N // 2))

Submission status: Wrong Answer

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(people_num == 1):
    print(1)
elif(bool_false):
    print(((people_num//2) **2) % (10**9 +7))
else:
    print(0)

Submission status: Wrong Answer

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(people_num == 1):
    print(1)
elif(bool_false):
    print(((people_num//2) **2) / (10**9 +7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a_s = sorted([int(i) for i in input().split(" ")])

if n % 2 == 0 and all(np.array(a_s[::2])!=np.array(a_s[1::2])):
    print(0)
elif n % 2 == 1 and all(np.array(a_s[::2][:-1])==np.array(a_s[1::2])):
    print(0)
elif n % 2 == 1:
    print((2**((n-1)//2)) % (10**9+7))
elif n % 2 == 0:
    print((2**(n // 2)) % (10**9+7))

Submission status: Wrong Answer

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

flag = False
# validation
for a in A:
    if A.count(a) > 2:
        print(0)
        exit()
    elif A.count(a) == 1:
        if a != 0:
            print(0)
            exit()
        elif flag is False:
            flag = True
        else:
            print(0)
            exit()

if N % 2 != 0:
    N -= 1

tempN = int(N / 2)
ans = int(tempN ** 2)

temp = 10 ** 9 + 7
if ans > temp:
    ans %= temp

print(ans)

Submission status: Wrong Answer

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

# validation
for a in A:
    if A.count(a) > 2:
        print(0)
        exit()
    elif A.count(a) == 1:
        if a != 0:
            print(0)
            exit()

if N % 2 != 0:
    N -= 1

tempN = int(N / 2)
ans = int(tempN ** 2)

temp = 10 ** 9 + 7
if ans > temp:
    ans %= temp
print(ans)

exit()

l = []
fl = []
for i in range(N):
    l.append([])

for i in range(N):
    left = i
    right = N - i - 1

    for x in range(len(A)):
        if A[x] == left - right:
            l[x].append(i + 1)
            l[x].append(N - i)

print(l)

Submission status: Wrong Answer

Solution code:
import collections
import sys
l = int(input())
inputs = [int(j) for j in input().split(' ')]
cs = collections.Counter(inputs)
if l % 2 == 0:
  for v,c in cs.items():
    if v % 2 == 0 or c != 2:
      print(0)
      sys.exit()
else:
  for v,c in cs.items():
    if v % 2 != 0 or (c != 2 and v != 0):
      print(0)
      sys.exit()
print(2**int(l/2))

Submission status: Wrong Answer

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

# validation
for a in A:
    if A.count(a) > 2:
        print(0)
        exit()
    elif A.count(a) == 1:
        if a != 0:
            print(0)
            exit()

if N % 2 != 0:
    N -= 1

tempN = int(N / 2)
ans = int(tempN ** 2)

temp = 10 ** 9 + 7
if ans > temp:
    ans %= temp
print(ans)

Submission status: Wrong Answer

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


# validation
for a in A:
    if A.count(a) > 2:
        print(0)
        exit()
    elif A.count(a) == 1:
        if a != 0:
            print(0)
            exit()

if N % 2 != 0:
    N -= 1
ans = int((N / 2) * (N / 2))
if ans > 10 ** 9 + 7:
    ans %= 10 ** 9 + 7
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
import itertools
count = 0
check = [int(abs((N-i+1)- i)) for i in range(1,N+1)]

flag = sorted(A) == sorted(check)
if flag:
    print(2 ** (N//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
ans=0
if N%2!=0:
    c=list(Counter(A).items())
    c.sort(reverse=True)
    for a,b in c:
        if a!=0 and b==2:
            ans+=1
        elif a==0 and b==1:
            print(2**ans)
        else:
            print(0)
            break
else:
    if A.count(0)>0:
        print(0)
    else:
        c=list(Counter(A).items())
        c.sort(reverse=True)
        for a,b in c:
            if a!=1 and b==2:
                ans+=1
            elif a==1 and b==2:
                ans+=1
                print(2**ans)
            else:
                print(0)
                break

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
from collections import Counter
def is_ok(n, a_list):
    if N%2==0:
        # even
        c = Counter(a_list)
        for a in a_list:
            if a%2==0:
                return False
            elif c[a] != 2:
                return False
    else:
        # odd
        c = Counter(a_list)
        for a in a_list:
            if a%2==1:
                return False
            elif a == 0:
                if c[a]!=1:
                    return False
            elif c[a] != 2:
                return False
    
    return True


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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
flag = 0
if n % 2 == 1:
  if a.count(0) != 1:
    print(0)
    sys.exit()
  else:
    sa = n-1
    while sa > 0:
      if a.count(sa) != 2:
        print(0)
        sys.exit()
      sa -= 2
else:
  if a.count(0) != 0:
    print(0)
    sys.exit()
  else:
    sa = n-1
    while sa > 0:
      if a.count(sa) != 2:
        print(0)
        sys.exit()
      sa -= 2


print(2 ** (n // 2) / mod)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import bisect

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # mod用
    p=10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

    N = int(input().rstrip())
    # A = list(map(int, input().split()))
    A = list(int(_) for _ in input().split())
    # A = list(input().split())
    A.sort()
    flag = False
    if A[0] == '0' and N%2 == 1:
        flag = True
        for i in range(N):
            if A[i] != (i + 1) // 2 * 2:
                flag = False
                break
    if A[0] == '1' and N%2 == 0:
        flag = True
        for i in range(N):
            if A[i] != i // 2 * 2 + 1:
                flag = False
                break
    if flag:
        print(2**(N//2) % p)
    else:
        print(0)
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
import bisect

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # mod用
    p=10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

    N = int(input().rstrip())
    A = list(input().split())
    A.sort()
    if(N==1 and A[0]!=str(0)):
        print(0)
        exit()
    else:
        ans = (2**(N//2)) % p
    if(N == 1):
        print(1)
        exit()
    if(N%2 == 1):
        c= A.pop(0)
        if c != str(0):
            print(0)
            exit()
        for i in range(0,2,N):
            if i%2 == 0 and A[i] != str(i+2):
                ans = 0
                break
            if i%2 == 1 and A[i] != str(i+1):
                ans = 0
                break      
    else:
        for i in range(0,2,N):
            if i%2 == 0 and A[i] != str(i+1):
                ans = 0
                break
            if i%2 == 1 and A[i] != str(i):
                ans = 0
                break  
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
import bisect

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # mod用
    p=10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

    N = int(input().rstrip())
    A = list(input().split())
    s_num = N -1
    A.sort()
    if(N==1 and A[0]!=str(0)):
        ans = 0
    else:
        ans = 2**(N//2) % p
    if(N%2 == 1):
        s = 2
        c= A.pop(0)
        if c != str(0):
            print(0)
            exit()
    else:
        s = 1
    for i in range(N//2):
        j = i*2
        if(A[j] == A[j+1] and A[j+1] == str(s+j) and A[j] == str(s+j)):
            continue
        else:
            ans = 0
            break        

    print(ans)
    
if __name__ == '__main__':
    main()