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(n) for n in input().split()]

def main():
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1
    ks =  all(map(lambda k: k % 2 == 0, d.keys())) or all(map(lambda k: k % 2 != 0, d.keys()))
    if 0 in d:
        d[0] += 1
    vs = all(map(lambda v: v == 2, d.values()))

    if ks and vs:
        base = N if len(d) % 2 == 0 else N - 1
        ans = int(2 ** (base / 2)) % 1000000007
    else:
        ans = 0   
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def main():
    a = sorted(A)
    odd = N % 2 != 0
    if odd:
        a = list(map(lambda t: t[1] if t[0] % 2 == 0 else t[1] - 1, enumerate(a)))
    else:
        a = list(map(lambda t: t[1] - 1 if t[0] % 2 == 0 else t[1], enumerate(a)))
    passed = a == list(range(N))
    if passed:
        base = N - 1 if odd else N
        ans = int(2 ** (base / 2)) % 1000000007
    else:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

cnt = [0] * n
for x in a:
  a[x] += 1

ok = True
for i in range(0, n):
  if n % 2 == 1 && i % 2 == 0:
    if i == 0 && cnt[i] != 1 or cnt[i] != 2:
      ok = False
  elif n % 2 == 0 && i % 2 == 0:
    if cnt[i] != 2:
      ok = False

if not ok:
  print(0)
else:
  res = 1
  for i in range(0, n // 2):
    res *= 2
    res %= 1000000007
print(res)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
A = sorted(list(map(int,input().split())))
amari = 10**9 + 7

if N % 2 == 0:
    ans = list(int(i) for i in range(1,N,2)*2)

else:
    ans = list(int(i) for i in range(0,N,2)*2)
    A.insert(0,0)

if ans == A:
    print(2**(N//2) % amari)
else:
    print("0")

Submission status: Runtime Error

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

def main():
    a = sorted(A)
    odd = N % 2 != 0
    if odd:
        a = list(map(lambda t: t[1] if t[0] % 2 == 0 else t[1] - 1, enumerate(a)))
    else:
        a = list(map(lambda t: t[1] - 1 if t[0] % 2 == 0 else t[1], enumerate(a)))
    passed = a == list(range(N))
    if passed:
        base = N - 1 if odd else N
        ans = int(2 ** (base / 2))
    else:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def main():
    a = sorted(A)
    even = a[0] == 0
    aborted = False
    for i in range(N):
        correct = (i if even else i + 1) - (0 if i % 2 == 0 else 1)
        if a[i] != correct:
            aborted = True
            break
    ans = 0 if aborted else int(2 ** ((N - (1 if even else 0)) / 2))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def main():
    a = sorted(A)
    even = a[0] == 0
    aborted = False
    for i in range(N):
        correct = (i if even else i + 1) - (0 if i % 2 == 0 else 1)
        print(a[i], correct)
        if a[i] != correct:
            aborted = True
            break
    ans = 0 if aborted else int(2 ** ((N - (1 if even else 0)) / 2))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def even_case(input_list) -> int:
    input_list.sort()

    for i in range(1, len(input_list), 2):
        if input_list[i] // 2 == 1 and input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** (n//2)

    return ans


def odd_case(input_list) -> int:
    input_list.sort()

    if input_list[1] == 0:
        return 0

    for i in range(2, len(input_list), 2):
        if input_list[i] // 2 == 0 and input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** ((n-1) // 2)

    return ans

n = int(input())
input_list = list(map(int, input().split()))
math = 10 ** 9 + 7

if n % 2 == 0:
    result = even_case(input_list)
else:
    result = odd_case(input_list)

print(result % math)

Submission status: Runtime Error

Solution code:
def even_case(input_list) -> int:
    input_list.sort()

    for i in range(1, len(input_list), 2):
        if input_list[i] // 2 == 1 and input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** (n//2)

    return ans


def odd_case(input_list) -> int:
    input_list.sort()

    if input_list[1] == 0:
        return 0

    for i in range(2, len(input_list), 2):
        if input_list[i] // 2 == 0 and input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** ((n-1) // 2)

    return ans

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

if n % 2 == 0:
    print(even_case(input_list))
else:
    print(odd_case(input_list))

Submission status: Runtime Error

Solution code:
from collections import Counter
import math
N = int(input())
A = list(map(int,input().split()))
A_count = Counter(A)
count_item = list(A_count.items())
count_item.sort()
start = 1 - (N % 2)
for i in range(math.ceil(N / 2)):
    if i == 0 and N % 2 == 1:
        if count_item[i][0] == 0 and count_item[i][1] != 1:
            print("0")
            exit()
    else:
        if count_item[i][0] != i * 2 + (1 - (N % 2)) or count_item[i][1] != 2:
            print("0")
            exit()
print(2 ** (N // 2) % (10 ** 9 + 7)

Submission status: Runtime Error

Solution code:
from collections import defaultdict

def possible():
    if N%2==0:
        for cnt in cnt_dict.values():
            if cnt != 2:
                return False
        return True
    else:
        for i, cnt in enumerate(cnt_dict.values()):
            if i==0:
                if cnt != 1:
                    return False
            else:
                if cnt != 2:
                    return False
        return True

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

cnt_dict = defaultdict(list)

if N%2==0:
    for i in range(1, N, 2):
        cnt_dict[i] = 0
else:
    for i in range(0, N, 2):
        cnt_dict[i] = 0
for a in A:
    cnt_dict[a]+=1

if __name__ == "__main__":    

    if possible():
        mod = 10**9+7
        res = 1
        for i in range(1, num+1):
            res = res*2%mod
        print(res)
    else:
        print(0)

Submission status: Runtime Error

Solution code:
from sys import stdin
import math
from itertools import groupby

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

li.sort()

if li[0] == 0 and li[1] == 0:
    print(0)
    exit()

lin = []
for key, value in groupby(li):
    lin.append(len(list(value)))

point = 1

for i in lin:
    if i >= 3:
        print(0)
        exit()
    point *= math.factorial(i)
    point %= 10**9+7

print(point)

Submission status: Runtime Error

Solution code:
from sys import stdin
import math
from itertools import groupby

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

li.sort()

if li[0] == 0 and li[1] == 0:
    print(0)
    exit()

lin = []
for key, value in groupby(li):
    lin.append(len(list(value)))

point = 1

for i in lin:
    if i >= 3:
        print(0)
        exit()
    point *= 2
    point %= 10**9+7

print(point)

Submission status: Runtime Error

Solution code:
ok = True
a.sort()
if n%2==0:
    for i in range(n):
        if a[i]!= i-i%2+1:
            ok = False
            break
else:
    for i in range(n):
        if a[i]!= i+i%2:
            ok = False
            break
if ok:
    print(2**(n//2)%(10**9+7))
else:
    print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
d = {}
if N % 2 == 0:
    for i in range(N//2):
        d[2*i+1] = 0
else:
    for i in range(N//2+1):
        d[2*i] = 0
A = list(map(int,input().split()))
x = 1
for i in range(N):
    if d[A[i]] >= 2:
        x = 0
        break
    else:
        d[A[i]] += 1
y = 1
if N % 2 == 1:
    if d[0] != 1:
        y = 0
ans = (2**(N//2))*x*y
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
d = {}
if N % 2 == 0:
    for i in range(N//2):
        d[2*i+1] = 0
else:
    for i in range(N//2+1):
        d[2*i] = 1
A = list(map(int,input()))
x = 1
for i in range(A):
    if d[A[i]] >= 2:
        x = 0
        break
    else:
        d[A[i]] += 1
y = 1
if N % 2 == 1:
    if d[0] != 1:
        y = 0
ans = (2**(N//2))*x*y
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
A=sorted((map(int,input().split())))
G=sorted([2*(i+1) for i in range(n//2)]*2+[0])
K=sorted([(2*i+1) for i in range(n//2)]*2)
if n%2:
	if A!=G:
		print(0)
		exit()
else:
	if A!=K:
		print(0)
		exit()
print(2**(n//2)%(10**9+7)

Submission status: Runtime Error

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

if n%2==0:
  for i in range(n/2-1):
    if s.count(i*2+1)!=2:
      print("0")
      exit()
  print((2**(n//2))%(10**9+7))
else:
  if s.count(0)!=1:
    print("0")
    exit()
  for j in range(1,((n-1)//2)):
    if s.count(j*2)!=2:
      print("0")
      exit()
  print((2**((n-1)//2))%(10**9+7))

Submission status: Runtime Error

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

if n%2==0:
  for i in range(n/2-1):
    if s.count(i*2+1)!=2:
      print("0")
      exit()
  print((2**n//2)//(10**9+7))
else:
  if s.count(0)!=1:
    print("0")
    exit()
  for j in range(1,((n-1)//2)):
    if s.count(j*2)!=2:
      print("0")
      exit()
  print((2**(n-1)//2)//(10**9+7))

Submission status: Runtime Error

Solution code:
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

C = dict(Counter(A))

ans = 1
if N%2==0:
    for i in range(N//2):
        if C[i*2+1] == 2:
            ans *= 2
            ans %= mod
        else:
            ans = 0
            break
else:
    if C[0] == 1:
        for i in range(N//2):
            if C[i*2+2] == 2:
                ans *= 2
                ans %= mod
            else:
                ans = 0
                break
    else:
        ans = 0

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
if n==1:
  if int(input())==0:
    print(n)
  else:
    print(0)
  exit
a=list(map(int,input().split()))
m=10**9+7
x=[]
if n%2==1:
  x.append(0)
for i in range(n%2+1,n,2):
  x.append(i)
  x.append(i)
if sorted(a)==x:
  print((2**(n//2))%m)
else:
  print(0)

Submission status: Runtime Error

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

g=set(s)
if n%2==0:
  if len(g)!=n//2:
    print(0)
  else:
    a=2**(n/2)
    print(round(a%(10**9+7)))
    
else:
  if s.count(0)!=1:
    print(0)
  else:
    g.remove(0)
    if len(g)!=(n-1)//2:
      print(0)
    else:
      b=2**((n-1)/2)
      print(round(b%(10**9+7)))

Submission status: Runtime Error

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

g=set(s)
if n%2==0:
  if len(g)!=n//2:
    print(0)
  else:
    a=2**(n/2)
    print(round(a%(10**9+7)))
    
else:
  g.remove(0)
  if len(g)!=(n-1)//2:
    print(0)
  else:
    b=2**((n-1)/2)
    print(round(b%(10**9+7)))

Submission status: Runtime Error

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

g=set(s)
if n%2==0:
  if len(g)!=n/2:
    print(0)
  else:
    a=2**(n/2)
    print(round(a%(10**9+7)))
    
else:
  g.remove(0)
  if len(g)!=(n-1)/2:
    print(0)
  else:
    b=2**((n-1)/2)
    print(round(b%(10**9+7)))

Submission status: Runtime Error

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

if n%2==0:
  a=2**(n/2)
  printa(round(a%(10**9+7)))
  
else:
  b=2**((n-1)/2)
  print(round(b%(10**9+7)))

Submission status: Runtime Error

Solution code:
n = int(input())
L = [int(i) for i in input().split()]
L.sort()

def out_detect(n,L):
  flag = 0
  if n%2 == 0:
    for i in range(n):
      if L[i] != -(-(i+1)//2)*2-1:
        flag = 1
        break
  else:
    if L[0] != 0:
      flag = 1
      return (flag)
    for i in range(1,n):
      if L[i] != (-(-i//2)*2):
        flag = 1
        break
  return (flag)

if out_detect(n,L) == 1:
  print(0)
else:
  if n%2 == 0:
    out = pow(2,n//2)
  else:
    out = pow(2,(n-1)//2)
print(out%(pow(10,9)+7))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
MOD = 1000000007
n = int(input())
l = list(map(int,input().split()))
a = {}
for i in l:
    if i in a:
        a[i] += 1
    else:
        a[i] = 1

cur = 1 if n % 2 == 0 else 0

ok = True
while cur < n:
    x = 1 if cur == 0 else 2
    if a[cur] != x:
        ok = False
        break
    cur += 2

ans = 0
if ok:
    ans = 1
    for _ in range(n // 2):
        ans = ans * 2 % MOD

print(ans)

Submission status: Runtime Error

Solution code:
INFTY = 10**9+7
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
if N%2==0:
    flag = 0
    for i in range(1,N,2):
        if C[i]==2:
            pass
        else:
            flag = 1
            break
else:
    flag = 0
    for i in range(2,N,2):
        if C[i]==2:
            pass
        else:
            flag = 1
            break
    if 0 not in C or C[0]!=1:
        flag = 1
if flag==0:
    cnt = 1
    for i in range(N//2):
        cnt = (cnt*2)%INFTY
else:
    cnt = 0
print(cnt)

Submission status: Runtime Error

Solution code:
INFTY = 10**9+7
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
if N%2==0:
    flag = 0
    for i in range(1,N,2):
        if C[i]==2:
            pass
        else:
            flag = 1
            break
else:
    flag = 0
    for i in range(2,N,2):
        if C[i]==2:
            pass
        else:
            flag = 1
            break
    if C[0]!=1:
        flag = 1
if flag==0:
    cnt = 1
    for i in range(N//2):
        cnt = (cnt*2)%INFTY
else:
    cnt = 0
print(cnt)

Submission status: Runtime Error

Solution code:
mod = 10 ** 9 + 7
N = int(input())
A = [int(a) for a in input().split()]

# Nが偶数ならAiは全て奇数、Nが奇数なら Aiは全て偶数でなければならない,なぜなら、2x + Ai = N - 1を満たすxが自然数(非負整数)でなければならないから
# さらに、Nが奇数の時はfor i in range(0, N, 2) において 0が１個、それ以外のiが２個ずつ存在しなければならず(これはAiが全て偶数であることも満たしている)、
# Nが偶数の時はfor i in range(1, N, 2) において 全てのiが２個ずつ存在しなければならない(これはAiがすべて奇数であることも満たしている)
# これを踏まえた上でNが偶数の時は N/2人の位置が決まれば反対側の人の位置も決まり、Nが奇数の時は中央の人は固定として、それ以外 (N-1)/2人の位置が決まれば残りの人は反対側で位置が決まる。それぞれ２通りなので、
# よって
if N % 2 != 0:
    for i in range(0, N, 2):
        if A.count(i) == 2:
            continue
        elif A.count(0) == 1:
            continue
        print(0)
        exit()
    
    #order_count = 1
    #for i in range((N - 1) // 2):
        order_count = 2 ** ((N - 1) // 2) % mod

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

print(order_count)

Submission status: Runtime Error

Solution code:
n = int(input())
s = list(map(int,input().split()))
if n % 2 == 1:
    t = 0
    for i in s:
        c = count(i)
        if i != 0 and c == 2:
            t = t+1
        if i == 0 and c == 0:
            t = t
        else:
            t = 0
            break
    if t == 0:
        print(0)
    else:
        print(2^t)
elif n % 2 == 0:
    t = 0
    for i in s:
        c = count(i)
        if c == 2:
            t = t+1
        else:
            t = 0
            break
    if t == 0:
        print(0)
    else:
        print(2^t)

Submission status: Runtime Error

Solution code:
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
if N % 2 == 1:
  checklist = {0: 1}
  for i in range((N-2)//2):
    checklist[(i+1)*2] = 2
else:
  checklist = {(i*2+1):2 in i in range(N//2)}
  
for a in A:
  if a in checklist and checklist[a] in {1,2}:
    checklist[a] -= 1
  else:
    print(0)
    exit()
print(int(2**(N//2)))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    vector<ll> b;

    int x;
    if(N%2==0) x = 1;
    else x = 0;
    if(N%2 != 0)b.pb(0);
    for(int i = 1;2*i-x<N;i++)
    {
        b.pb(2*i-x);
        b.pb(2*i-x);
    }

    rep(i,N)
    {
        if(a[i] != b[i])
        {
            cout<<0<<endl;
            return 0;
        }
    }

    cout << pow(2, N / 2) << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    vector<ll> b;

    int x;
    if(N%2==0) x = 1;
    else x = 0;
    if(N%2 != 0)b.pb(0);
    for(int i = 1;2*i-x<N;i++)
    {
        b.pb(2*i-x);
        b.pb(2*i-x);
        //cout<<2*i-x<<" ";
        //cout<<"ok\n";
    }

    // cout<<"a:";
    // rep(i,N)cout<<a[i]<<" ";
    // cout<<endl;

    // cout<<"b:";
    // rep(i,N)cout<<b[i]<<" ";
    // cout<<endl;


    rep(i,N)
    {
        if(a[i] != b[i])
        {
            cout<<0<<endl;
            return 0;
        }
    }

    cout << pow(2, N / 2) << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n = ni()
  a = na()

  if n % 2 == 0:
    if 0 in a:
      print(0)
      return 
    else:
      print(2 ** len(list(set(a))))
  else:
    zero = 0
    for aa in a:
      if aa == 0:
        zero += 1
    if zero > 1:
      print(0)
      return
    else:
      if zero == 1:
        print(2 ** (len(list(set(a)) - 1))
      else:
        print(2 ** len(list(set(a)))

main()

Submission status: Runtime Error

Solution code:
num_total = int(input())
hoge = input().split()
flag_one = True
flag_two = True
hoge.sort()
flag = True
count_zero = 0

if num_total % 2 == 0:
  for i in range(len(hoge)):
    """偶数の場合数値がすべて奇数である＆それぞれ２個づつあるかどうか判定する"""
    #数値がすべて奇数であるかどうか
    if int(hoge[i]) % 2 != 1:
      flag_one = False
      break
    #２個づつあるかどうか
    try:
      if flag == False:
        flag = True
        continue
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_one = False    
  if flag_one == True and flag_two == True:
    ans = 2**(num_total/2)
    ans = ans % (10**9 + 7)
    print(int(ans))
  else:
    print(0)
else:
  for i in range(len(hoge)):
    """奇数の場合数値すべて偶数である＆０以外すべて２個づつあるかどうか判定する"""
    #数値がすべて偶数であるかどうか
    if int(hoge[i]) % 2 != 0:
      flag_one = False
      break
    #２個づつあるかどうか
    try:
      if hoge[i] == "0":
        count_zero += 1
        continue
      if flag == False:
        flag = True
        continue  
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_two = False
      break
  if flag_one == True and flag_two == True and count_zero == 1:
    ans = 2**((num_total-1)/2)
    ans = ans % (10**9 + 7)
    print(int(ans))
  else:
    print(0)

Submission status: Runtime Error

Solution code:
num_total = int(input())
hoge = input().split()
flag_one = True
flag_two = True
hoge.sort()
flag = True

if num_total % 2 == 0:
  for i in range(len(hoge)):
    """偶数の場合数値がすべて奇数である＆それぞれ２個づつあるかどうか判定する"""
    #数値がすべて奇数であるかどうか
    if int(hoge[i]) % 2 != 1:
      flag_one = False
      break
    #２個づつあるかどうか
    try:
      if flag == False:
        flag = True
        continue
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_one = False    
  if flag_one == True and flag_two == True:
    ans = 2**(num_total/2)
    ans = ans % (10**9 + 7)
    print(int(ans))
  else:
    print(0)
else:
  for i in range(len(hoge)):
    """奇数の場合数値すべて偶数である＆０以外すべて２個づつあるかどうか判定する"""
    #数値がすべて偶数であるかどうか
    if int(hoge[i]) % 2 != 0:
      flag_one = False
      break
    #２個づつあるかどうか
    try:
      if hoge[i] == "0":
        continue
      if flag == False:
        flag = True
        continue  
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_two = False
      break
  if flag_one == True and flag_two == True:
    ans = 2**((num_total-1)/2)
    ans = ans % (10**9 + 7)
    print(int(ans))
  else:
    print(0)

Submission status: Runtime Error

Solution code:
num_total = int(input())
hoge = input().split()
flag_one = True
flag_two = True
hoge.sort()
flag = True

if num_total % 2 == 0:
  for i in range(len(hoge)):
    """偶数の場合数値がすべて奇数である＆それぞれ２個づつあるかどうか判定する"""
    #数値がすべて奇数であるかどうか
    if int(hoge[i]) % 2 != 1:
      flag_one = False
      break
  #２個づつあるかどうか
    try:
      if flag == False:
        flag = True
        continue
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_one = False    
  if flag_one == True and flag_two == True:
    ans = 2**(num_total/2)
    ans = ans % ((10**9) + 7)
    print(int(ans))
  else:
    print(0)
else:
  for i in range(len(hoge)):
    """奇数の場合数値すべて偶数である＆０以外すべて２個づつあるかどうか判定する"""
    #数値がすべて偶数であるかどうか
    if int(hoge[i]) % 2 != 0:
      flag_one = False
      break
  #２個づつあるかどうか
    try:
      if hoge[i] == "0":
        continue
      if flag == False:
        flag = True
        continue  
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_two = False
      break
  if flag_one == True and flag_two == True:
    ans = 2**((num_total-1)/2)
    ans = ans % ((10**9) + 7)
    print(int(ans))
  else:
    print(0)

Submission status: Runtime Error

Solution code:
num_total = int(input())
hoge = input().split()
flag_one = True
flag_two = True
hoge.sort()
flag = True

if num_total % 2 == 0:
  for i in range(len(hoge)):
    """偶数の場合数値がすべて奇数である＆それぞれ２個づつあるかどうか判定する"""
    #数値がすべて奇数であるかどうか
    if int(hoge[i]) % 2 != 1:
      flag_one = False
      break
  #２個づつあるかどうか
    try:
      if flag == False:
        flag = True
        continue
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_one = False    
  if flag_one == True and flag_two == True:
    ans = 2**(num_total/2)
    ans = ans % (10**9 + 7)
    print(int(ans))
  else:
    print(0)
else:
  for i in range(len(hoge)):
    """奇数の場合数値すべて偶数である＆０以外すべて２個づつあるかどうか判定する"""
    #数値がすべて偶数であるかどうか
    if int(hoge[i]) % 2 != 0:
      flag_one = False
      break
  #２個づつあるかどうか
    try:
      if hoge[i] == "0":
        continue
      if flag == False:
        flag = True
        continue  
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_two = False
      break
  if flag_one == True and flag_two == True:
    ans = 2**((num_total-1)/2)
    ans = ans % (10**9 + 7)
    print(int(ans))
  else:
    print(0)

Submission status: Runtime Error

Solution code:
num_total = int(input())
hoge = input().split()
flag_one = True
flag_two = True


if num_total % 2 == 0:
  for i in hoge:
    """偶数の場合数値がすべて奇数である＆それぞれ２個づつあるかどうか判定する"""
    #数値がすべて奇数であるかどうか
    if int(i) % 2 != 1:
      flag_one = False
      break
  #２個づつあるかどうか
  hoge.sort()
  flag = True
  for i in range(len(hoge)):
    try:
      if flag == False:
        flag = True
        continue
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_one = False
  if flag_one == True and flag_two == True:
    ans = 2**(num_total/2)
    ans = ans % (10**9 + 7)
    print(int(ans))
  else:
    print(0)
else:
  for i in hoge:
    """奇数の場合数値すべて偶数である＆０以外すべて２個づつあるかどうか判定する"""
    #数値がすべて偶数であるかどうか
    if int(i) % 2 != 0:
      flag_one = False
      break
  #２個づつあるかどうか
  hoge.sort()
  flag = True
  for i in range(len(hoge)):
    try:
      if hoge[i] == "0":
        continue
      if flag == False:
        flag = True
        continue  
      if hoge[i+1] != hoge[i]:
        flag_two = False
        break
      flag = False
    except:
      flag_two = False
      break
  if flag_one == True and flag_two == True:
    ans = 2**((num_total-1)/2)
    ans = ans % (10**9 + 7)
    print(int(ans))
  else:
    print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
out = 0
if n == 1:
    if a[0] != 0:
        out = 1
elif a[0] == 0:
    for i in range(1,n//2+1):
        if a[2*i-1] == a[2*i] and a[2*i] == 2*i:
            None
        else:
            out = 1
elif a[0] == 1:
    for i in range(n//2):
        if a[2*i] == a[2*i+1] == 2*i+1:
            None
        else:
            out = 1
else:
    out = 1
if out:
    print(0)
else:
    a = 1
    for i in range(n//2):
        a *= 2
        a = a%(10**9+7)
    print(a)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
out = 0
if n == 1:
    if a[0] != 0:
        out = 1
elif a[0] == 0:
    for i in range(1,n//2+1):
        if a[2*i-1] == a[2*i] and a[2*i] == 2*i:
            None
        else:
            out = 1
elif a[0] == 1:
    for i in range(n//2):
        if a[2*i] == a[2*i+1] == 2*i+1:
            None
        else:
            out = 1
else:
    out = 1
if out:
    print(0)
else:
    print(2**(n//2)%(10**9+7))

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
out = 0
if n == 1:
    if a[0] != 0:
        out = 1
elif a[0] == 0:
    for i in range(1,n//2+1):
        if a[2*i-1] == a[2*i] == 2*i:
            None
        else:
            out = 1
elif a[0] == 1:
    for i in range(n//2):
        if a[2*i] == a[2*i+1] == 2*i+1:
            None
        else:
            out = 1
else:
    out = 1
if out:
    print(0)
else:
    print(2**(n//2)%(10**9+7))

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
out = 0
if n == 1:
    if a[0] != 0:
        out = 1
elif a[0] == 0:
    for i in range(1,n//2+1):
        if a[2*i-1] == a[2*i] == 2*i:
            None
        else:
            out = 1
elif a[0] == 1:
    for i in range(n//2):
        if a[2*i] == a[2*i+1] == 2*i+1:
            None
        else:
            out = 1
else:
    out = 1
if out:
    print(0)
else:
    print(2**(n//2))

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
out = 0
if a[0] == 0:
    for i in range(1,n//2+1):
        if a[2*i-1] == a[2*i] == 2*i:
            None
        else:
            out = 1
elif a[0] == 1:
    for i in range(n//2):
        if a[2*i] == a[2*i+1] == 2*i+1:
            None
        else:
            out = 1
else:
    out = 1
if out:
    print(0)
else:
    print(2**(n//2))

Submission status: Runtime Error

Solution code:
def main(): 
  MOD = 10e9+7
  n = int(input())
  a = sorted(map(int, input().split()))
  ans = 2**(n//2)
  if n%2:
    if a.pop(0)!=0:ans=0
  i = n%2 - 1
  for j in range(n//2):
    i += 2
    if a[j*2]!=i or a[j*2+1]!=i: ans=0
  print(int(ans%MOD))

if __name__=="__main__":main()

Submission status: Runtime Error

Solution code:
def main(): 
  MOD = 10e9+7
  n = int(input())
  a = sorted(map(int, input().split()))
  ans = 2**(n//2)%MOD
  if n%2:
    if a.pop(0)!=0:ans=0
  i = n%2 - 1
  for j in range(n//2):
    i += 2
    if a[j*2]!=i or a[j*2+1]!=i: ans=0
  print(int(ans))

if __name__=="__main__":main()

Submission status: Runtime Error

Solution code:
def __is_even(num):
    return num % 2 == 0


N = int(input())
reported_num_count = {}
if __is_even(N):  # Nが偶数の場合
    # 報告が正しい場合、値は全て奇数であり、1 ~ N-1 (1つ飛ばし) が2回ずつ出現する
    for i in range(1, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (1 <= i <= N - 1) and not __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    print(int((2 ** (N / 2)) % (10 ** 9 + 7)))
else:  # N が奇数の場合
    # 報告が正しい場合、値は全て偶数であり、0 が 1回、 2 ~ N-1（1つ飛ばし）が2回ずつ出現する
    for i in range(0, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (i == 0) and reported_num_count[0] < 1:
            reported_num_count[0] += 1
        elif (2 <= i <= N - 1) and __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    print(int((2 ** ((N - 1) / 2)) % (10 ** 9 + 7)))