Problem:


Score : 200 points

Problem Statement

We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are similar when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N).

In particular, any integer sequence is similar to itself.

You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N.

How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?

Constraints

1 \leq N \leq 10

1 \leq A_i \leq 100

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the number of integer sequences that satisfy the condition.

Sample Input 1

2
2 3

Sample Output 1

7

There are seven integer sequences that satisfy the condition:

1, 2

1, 4

2, 2

2, 3

2, 4

3, 2

3, 4

Sample Input 2

3
3 3 3

Sample Output 2

26

Sample Input 3

1
100

Sample Output 3

1

Sample Input 4

10
90 52 56 71 44 8 13 30 57 84

Sample Output 4

58921



Sample input:
2
2 3


Sample output:
7

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split(" ")))
kisuu = 1
kake = 1
for i in a:
  if i != 1:
    kake *= 3
  else:
    kake *= 2
  if i % 2 == 0:
    kisuu *= 2
print(kake - kisuu)

Submission status: Wrong Answer

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

t = 1
s = 1
for i in range(N):
  if A[i] == 1:
    t *= 2
  else:
    t *= 3
  if A[i] % 2 == 0:
    s *= 2
  else:
    s *= 1
print(t-s)

Submission status: Wrong Answer

Solution code:
ans = 0
number = set()
def exsearch(s, i, N, A):
    if i == N:
        global ans
        mul = 1
        for i in range(N):
            if s[i] == "0":
                mul *= A[i]

            elif s[i] == "1":
                if A[i] > 1:
                    mul *= (A[i] - 1)
                else:
                    mul *= A[i]

            elif s[i] == "2":
                    mul *= (A[i] + 1)

        if mul % 2 == 0:
            ans += 1

    else:
        for c in ["0", "1", "2"]:
            exsearch(s + c, i + 1, N, A)

def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    exsearch("", 0, N, A)

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(3**N):
    ii = i
    res = 1
    for j in range(N):
        k = ii % 3
        ii = ii // 3
        res *= (A[j]-1+k)
    if res != 0 and res % 2 == 0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

mul = 1 # 累積

odd_mul = 1 # 奇数の累積

for v in a:
    if v == 1 or v == 100:
        mul *= 2
    else:
        mul *= 3
        if v%2 == 0:
            odd_mul *= 2
print(mul-odd_mul)

Submission status: Wrong Answer

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

ans1=1 #all
ans2=1 #odd
for i in range(n):
    j=2 #j:all
    k=0 #k:odd
    if a[i]-1>0:
        j+=1
        if (a[i]-1)%2==1:
            k+=1
    if a[i]%2==1:
        k+=1
    if (a[i]+1)%2==1:
        k+=1
    ans1*=j
    ans2*=k
print(ans1-ans2)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    A = list(map(int, input().split()))
    allB = 0
    one, hun = A.count(1), A.count(100)
    if n-one-hun != 0:
        allB += 3**(n-one-hun)
    if one != 0 or hun != 0:
        allB += 2**(one+hun)
    exc = 1
    for i in range(n):
        if A[i]%2 == 0 and A[i] != 100:
            exc *= 2
    ans = allB - exc
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

even_num = 0

for i in range(N):
    if A[i]%2:
        even_num += 1

print(1*3**(N-1)*even_num+2*3**(N-1)*(N-even_num)-2**(N-even_num))

Submission status: Wrong Answer

Solution code:
def solve(n,a):
  even = 0
  
  for i in range(n):
    if a[i] % 2 == 0:
      even += 1
  
  return 3**n - 2**even
  
def main():
  N = int(input())
  a = list(map(int,input().split()))
  print(solve(N,a))

Submission status: Wrong Answer

Solution code:
def solve(n,a):
  even = 0
  
  for i in range(n):
    if a[i] % 2 == 1:
      even += 1
  
  return 3**n - 2**even
  
def main():
  N = int(input())
  a = list(map(int,input().split()))
  print(solve(N,a))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[i]%2==0:
    ans=ans+3
  else:
    ans=ans+2
print(ans)

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
A = IL()

ans = 1
for a in A:
  if a%2:
    ans *= 2
print(pow(3,N)-ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
An = list(map(int, input().split()))
odd = sum([1 for a in An if a % 2 != 0])
print(3**N - 2**odd)

Submission status: Wrong Answer

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

odd_pair = 1
all_pair = 1
for a in A:
    if a==1 or a==100:
        all_pair*=2
    else:
        all_pair*=3
        if a%2==0:
            odd_pair*=2
print(all_pair-odd_pair)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
k = 1
for k in a:
  if k%2 == 0:
    k *= 2
print(3**n-k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = n**3

print(ans-1)

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N=int(input())
    t=3**N
    s=1
    f=0
    for a in pin():
        if a>1 and a%2:
            f=1
            s*=1
        else:
            s*=2

    print(t-s)
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#Aiについて取りうる値の範囲を考える
#すべての組み合わせから、すべて奇数のものを除く

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

all_pair = 1
odd_pair = 1

for i in range(n):
    if a_inputs[i]==1:
        all_pair*=2
        odd_pair*=1
    else:
        if a_inputs[i]%2==0:
            odd_pair*=2
        else:
            odd_pair*=1
        all_pair*=3

print(all_pair-odd_pair)

Submission status: Wrong Answer

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

even = odd = 0

for a in A:
  if a%2:
    odd += 1
  else:
    even += 1
    
print(3**n - (odd+(even*2)**n))

Submission status: Wrong Answer

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

ans = 1
for a in A:
    if a == 1:
        ans *= 2
    else:
        ans *= 3
# 全体から全部奇数の場合を引く
odd = 1
for a in A:
    if a%2 == 0:
        odd *= 2

print(ans-odd)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 3**N
def solve(i, cnt):
    global ans
    if i == N:
        if cnt != 0:
            ans -= 1
            # print(A[i-1])
        return
    if A[i]-1 >= 1:
        if A[i]-1 % 2 == 0:
            cnt = 1
        solve(i+1, cnt)
    if A[i] % 2 == 0:
        cnt = 1
        solve(i+1, cnt)
    if A[i]+1 % 2 == 0:
        cnt = 1
        solve(i+1, cnt)
    
    # print(ans)


solve(0, 0)
print(ans-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().rstrip().split(' ')))
ans=1
for a in A:
  if(a%2==1):
    ans*=3
    
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
f=1
for i in a:
  if i&1:
    f=0
print(3**n-1-f)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
mins = 1
for a in A:
    if a == 1:
        ans *= 2
    elif a % 2 == 1:
        ans *= 3
    else:
        ans *= 3
        mins *= 2
print(ans - mins)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
even_cnt = []
cnt_1 = 0
for i in range(N):
  if A[i] == 1:
    even_cnt.append(1)
    A[i] = 1
    cnt_1 += 1
  else:
    c = 0
    if (A[i]-1) % 2 == 0: c += 1
    if A[i] % 2 == 0: c += 1
    if (A[i]+1) % 2 == 0: c += 1
    even_cnt.append(c)
    A[i] = 3 - c

if cnt_1 > 0: x = 2 ** cnt_1 * 3 ** (N-cnt_1)
else: x = 3 ** N 
ans = 0
for i in range(N):
  if A[i] + even_cnt[i] == 2: x = x // 2
  else: x = x // 3
  ans += even_cnt[i] * x
  x *= A[i]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
even_cnt = []
for i in range(N):
  if A[i] == 1:
    even_cnt.append(1)
    A[i] = 1
  else:
    c = 0
    if (A[i]-1) % 2 == 0: c += 1
    if A[i] % 2 == 0: c += 1
    if (A[i]+1) % 2 == 0: c += 1
    even_cnt.append(c)
    A[i] = 3 - c

x = 3 ** N
ans = 0
for i in range(N):
  x = x // 3
  ans += even_cnt[i] * x
  x *= A[i]
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
clist=[0]*N
loscount=0
count=1
for i in range(0,N):
    if A[i]==0 or A[i]==100:
        clist[i]=2
    elif A[i]%2==1:
        clist[i]=3
    elif A[i]%2==0:
        clist[i]=3
        loscount=loscount+1
for i in range (0,N):
    count=count*clist[i]
print(count-2**loscount)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    ans = 3 ** n
    a = sum(map(lambda x: x & 1, a))
    na = n - a
    print(ans - 2 ** na * a)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split(" ") ]
s = [2 if i==1 else 3 for i in A]
odd = [2 if i%2==0 else 1 for i in A]

# 条件1|x_i-y_1|<=1を満たすパターン数を出す
PI1 = 1
for i in s:
    PI1*=i
# 条件2の対偶(総積が奇数ならカウントしない)のパターンを条件1のパターンから引く
PI2 = 1
for i in odd:
    PI2*=i
    
print(PI1-PI2)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=1
for k in a:
  if k&1:
    ans*=2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import logging
logging.basicConfig(level=logging.DEBUG)

def resolve():
    n = int(input())
    dat = list(map(int, input().split()))
    total = 3 ** n
    countzero = 0
    countodd = []

    for i in range(n):
        if dat[i] % 2 == 0:
            countodd.append(2)
        else:
            countodd.append(1)
    xxx = 1
    for i in range(n):
        xxx *= countodd[i]

    total -= xxx
    print(total)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_input_1(self):
        print("test_input_1")
        input = """2
2 3"""
        output = """7"""
        self.assertIO(input, output)
    def test_input_2(self):
        print("test_input_2")
        input = """3
3 3 3"""
        output = """26"""
        self.assertIO(input, output)
    def test_input_3(self):
        print("test_input_3")
        input = """1
100"""
        output = """1"""
        self.assertIO(input, output)
    def test_input_4(self):
        print("test_input_4")
        input = """10
90 52 56 71 44 8 13 30 57 84"""
        output = """58921"""
        self.assertIO(input, output)

if __name__ == "__main__":
    unittest.main()

Submission status: Wrong Answer

Solution code:
i=int(input())
s=input().split()
j=[]
k=[]
a=0
for h in range(i):
  j.append(int(s[h])%2)
for g in range(i):
  plus=1
  if j[g]==0:
    if len(k)>0:
      for h in k:
        plus=plus*h
    plus=plus*(3^(9-g))
    a+=plus
    if s[g]=="100":
      k.append(1)
    else:
      k.append(2)
  else:
    if len(k)>0:
      for h in k:
        plus=plus*h
    if s[g]=="1":
      plus=plus*(3^(9-g))
    else:
      plus=2*plus*(3^(9-g))
    a+=plus
    k.append(1)
print(str(a))

Submission status: Wrong Answer

Solution code:
i=int(input())
s=input().split()
j=[]
k=[]
a=0
for h in range(i):
  j.append(int(s[h])%2)
for g in range(i):
  plus=1
  if j[g]==0:
    if len(k)>0:
      for h in k:
        plus=plus*h
    plus=plus*(3^(9-g))
    a+=plus
    k.append(2)
  else:
    if len(k)>0:
      for h in k:
        plus=plus*h
    plus=2*plus*(3^(9-g))
    a+=plus
    k.append(1)
print(str(a))

Submission status: Wrong Answer

Solution code:
def main():
  import numpy as np
  N = int(input())
  A = list(map(int,input().split()))

  def ternary (n):
      if n == 0:
          return '0'
      nums = []
      while n:
          n, r = divmod(n, 3)
          nums.append(str(r))
      return ''.join(reversed(nums))

  ans = 0
  AA = np.array(A)
  for i in range(3**N):
    I = ternary(i).zfill(N)
    tmp = 1
    for a in range(N):
      if I[a] == "0":
        tmp *= AA[a] - 1
      elif I[a] == "1":
        tmp *= AA[a]
      else:
        tmp *= AA[a] + 1
    if tmp != 0 and tmp % 2 == 0:
      ans += 1
  print(ans)
main()

Submission status: Wrong Answer

Solution code:
from sys import stdin

s = stdin.readline().rstrip()

for i in range(len(s)-1):
    if s[i]+s[i+1] == "AC":
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
C = {1:0, 2:0, 100:0}
for i in range(N):
    a = A[i]
    if a==1:
        C[1] += 1
    if a==100:
        C[100] += 1
    if a%2==0 and a<100:
        C[2] += 1
tot = 2**(C[1]+C[100])*3**(N-C[1]-C[100])
odd = 2**C[2]
print(tot-odd)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
C = {1:0, 2:0}
for i in range(N):
    a = A[i]
    if a==1:
        C[1] += 1
    if a%2==0 and a<100:
        C[2] += 1
tot = 2**C[1]*3**(N-C[1])
odd = 2**C[2]
print(tot-odd)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
C = {1:0, 2:0}
for i in range(N):
    a = A[i]
    if a==1:
        C[1] += 1
    if a%2==0:
        C[2] += 1
tot = 2**C[1]*3**(N-C[1])
odd = 2**C[2]
print(tot-odd)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, A: "List[int]"):
    ans = 1
    t = 1
    for i in range(N):
        if A[i] == 1 or A[i] == 100:
            t *= 2
            continue

        t *= 3
        if A[i]%2 == 0:
            ans *= 2
        
    print(t-ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

odd=True
for p in a:
  if p%2==0:
    odd=False
    
print(3**n-1-(1 if not odd else 0))

Submission status: Wrong Answer

Solution code:
n =int(input())
print(2**n-1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
B = [i-1 for i in A]
C = [i+1 for i in A]
ans = 0
for i in A:
    for j in B:
        for k in C:
            if (i*j*k)%2 == 0:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
hiku=1
ans=1
for i in A:
        if i%2 == 1:hiku*=2
        ans*=3
print(ans-hiku)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 3 ** N
for i in A:
	if i % 2 == 0:
		ans -= 2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
evens = 0
for a in A:
    if a % 2 == 1: evens += 1
ans = 3**N - 2**evens
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=2**n
m=1
for a in map(int,input().split()):
  if a%2==0:
    m*=2
print(ans-m)

Submission status: Wrong Answer

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

ans = 2**N
tmp = 1
for a in A:
  if a%2==0:
    tmp *= 2
print(ans - tmp)

Submission status: Wrong Answer

Solution code:
print(3**int(input())-2**sum(int(s)%2 for s in input().split()))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys

def solve(n, ls_a):
    numOne = ls_a.count(1)
    numEven = len([a for a in ls_a if a % 2 == 0])
    all = (2 ** numOne) * (3 ** (n - numOne))
    odd = 2 ** numEven
    print(all - odd)

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    ls_a = list(map(int, ws))
    return (n, ls_a,)

def main():
    solve(*readQuestion())

# Uncomment before submission
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(0, len(a), 1):
    if a[i] % 2 == 0:
        count += 1
print(count ** 2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
print(a)
o = 1


for i in range(len(a)):
    if a[i]%2 == 1:
        #odd
        o *= 1
    else:
        #even
        o *= 2

print(3**len(a)-o)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
odd=0
for i in range(N):
  if A[i]%2==1: odd+=1

print(3**N-2**odd)

Submission status: Wrong Answer

Solution code:
print 1

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
if __name__ == '__main__':
    N = raw_input()
    A = map(int, raw_input().split())
    c_total = 1
    c_odd = 1
    for a in A:
        c_total *= 3
        if a % 2 == 0 and a != 100:
            c_odd *= 2
    print c_total - c_odd

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
if __name__ == '__main__':
    N = raw_input()
    A = map(int, raw_input().split())
    c_total = 1
    c_odd = 1
    for a in A:
        if a != 1 or a != 100:
            c_total *= 3
        else:
            c_total *= 2
        if a % 2 == 0 and a != 100:
            c_odd *= 2
    print c_total - c_odd

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
if __name__ == '__main__':
    N = raw_input()
    A = map(int, raw_input().split())
    c_total = 1
    c_odd = 1
    for a in A:
        if a != 1 and a != 100:
            c_total *= 3
        else:
            c_total *= 2
        if a % 2 == 0 and a != 100:
            c_odd *= 2
    print c_total - c_odd

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
if __name__ == '__main__':
    N = raw_input()
    A = map(int, raw_input().split())
    c_total = 1
    c_odd = 1
    for a in A:
        if a != 1:
            c_total *= 3
        else:
            c_total *= 2
        if a % 2 == 0:
            c_odd *= 2
    print c_total - c_odd

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=1
odd=1
for i in a:
    if i==1:
        count *= 2
    elif i==100:
        count *= 2
    elif i % 2 ==0:
        count *= 3
        odd *= 2
    else:
        count *= 3

print(count-odd)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input().split()
x=1
for i in s:
 if(int(i)%2==0):
  x*=2
 print(3**n-x)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input().split()
x=1
for i in s:
 if(int(i)%2==0):
  x*=2
print(2**n-x)

Submission status: Wrong Answer

Solution code:
N = int(input())
t = 1
for i in map(int, input().split()):
    if i == 1:
        t *= 2
    elif i == 100:
        t *= 2
    elif i % 2 == 0:
        t *= 2
    elif i % 2 == 1:
        t *= 1
print(3**N-t)

Submission status: Wrong Answer

Solution code:
N = int(input())
t = 1
for i in map(int, input().split()):
    if i == 1:
        t *= 2
    elif i == 100:
        t *= 2
    elif i % 2 == 0:
        t *= 2
    elif i % 2 == 1:
        t *= 1
    else:
        print("e")
print(3**N-t)

Submission status: Wrong Answer

Solution code:
N=input()
a=list(map(int,raw_input().split()))
#print a
b=[-1,0,1]

gusu=[]
kisu=[]


for h,i in enumerate(a):
	gusu_cnt=0
	kisu_cnt=0
	for j in b:
		if i+j>=1 and i+j<=100:
			#print i,j
			if (i+j)%2==0:
				gusu_cnt+=1
			else:
				kisu_cnt+=1
	#print h,i,j,gusu_cnt,kisu_cnt
	gusu.append(gusu_cnt)
	kisu.append(kisu_cnt)

#print "#gusu"
#print gusu
#print "#kisu"
#print kisu

all=1
kisu_all=1

for i in range(N):
	all=all*(gusu[i]+kisu[i])
	kisu_all=kisu_all*kisu[i]

#print all
#print kisu_all

print all-kisu_all

Submission status: Wrong Answer

Solution code:
N=input()
a=list(map(int,raw_input().split()))
#print a
b=[-1,0,1]

gusu=[]
kisu=[]


for h,i in enumerate(a):
	gusu_cnt=0
	kisu_cnt=0
	for j in b:
		if i+j>=1 and i+j<=100:
			#print i,j
			if (i+j)%2==0:
				gusu_cnt+=1
			else:
				kisu_cnt+=1
	#print h,i,j,gusu_cnt,kisu_cnt
	gusu.append(gusu_cnt)
	kisu.append(kisu_cnt)

#print "#gusu"
#print gusu
#print "#kisu"
#print kisu

ans_sum=0
for i in range(N):
	ans=1
	for j in range(N):
		#print i,j
		if i==j:
			ans=ans*gusu[j]
		elif j<i:
			ans=ans*kisu[j]
		elif i<j:
			ans=ans*(gusu[j]+kisu[j])
		#print i,j,gusu[i],kisu[j],ans

	#print i,ans
	ans_sum+=ans

print ans_sum

Submission status: Wrong Answer

Solution code:
from sys import stdin
def readLine_int_list():return list(map(int, stdin.readline().split()))

n = int(input())
a = readLine_int_list()
even = [i for i in a if i%2 == 0]
e = len(even)
one = a.count(1)


if e == 0:
    if n == 1:
        print(2-one)
    else:
        print(n**3 - 1 - one)
else:
    print(3**n - (2**e) - one)

Submission status: Wrong Answer

Solution code:
N=input()
a=list(map(int,raw_input().split()))
#print a
b=[-1,0,1]

gusu=[]
kisu=[]


for h,i in enumerate(a):
	gusu_cnt=0
	kisu_cnt=0
	for j in b:
		#print i,j
		if i+j>=1 and i+j<=100:
			#print i+j
			if (i+j)%2==0:
				gusu_cnt+=1
			else:
				kisu_cnt+=1
	#print h,i,j,gusu_cnt,kisu_cnt
	gusu.append(gusu_cnt)
	kisu.append(kisu_cnt)

#print "#gusu"
#print gusu
#print "#kisu"
#print kisu

ans_sum=0
for i in range(N):
	ans=1
	for j in range(N):
		#print i,j
		if i==j:
			ans=ans*gusu[i]
		elif j<i:
			ans=ans*kisu[j]
		elif i<j:
			ans=ans*(gusu[j]+kisu[j])
		#print i,j,gusu[i],kisu[j],ans

	#print i,ans
	ans_sum+=ans

print ans_sum

Submission status: Wrong Answer

Solution code:
from sys import stdin
def readLine_int_list():return list(map(int, stdin.readline().split()))

n = int(input())
a = readLine_int_list()
even = [i for i in a if i%2 == 0]
e = len(even)
o = n - e

if n == 1:
    if o == 1:
        print(2)
    else:
        print(1)
elif e == 0:
    print(n**3 - 1)

else:
    print(3**n - (2**e))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日 10/22 21:08:14 2017

# Usage
#
"""
from functools import reduce
from itertools import repeat


def multipler(x, y):
    return x*y

def hundred_or_one(l: list):
    return [True if x == 100 else False for x in l]
    # return [True if x == 1 or x == 100 else False for x in l]

def check_odds(l :list):
    return [True if x % 2 == 0 else False for x in l]

def check_hun(l: list):
    return [True if x == 100 else False for x in l]

def main(num, data:list):
    """
    >>> main(1, [2])
    1
    >>> main(1, [3])
    2
    >>> main(10, [90,52,56,71,44,8,13,30,57,84])
    58921
    >>> main(2, [2,3])
    7
    >>> main(2, [100,100])
    3
    >>> main(1, [100])
    1
    >>> main(2, [1,1])
    8
    >>> main(1, [1])
    2
    >>> main(2, [1,2])
    7
    >>> main(2, [1,3])
    8
    >>> main(2, [1,100])
    5
    >>> main(3, [1,1,100])

    >>> main(3, [1,100,100])
    """
    hun_one = hundred_or_one(data)
    odds = check_odds(data)  # 偶数の数
    huns = check_hun(data)

    basis = [3 for t in hun_one]

    # basis = [2 if t else 3 for t in hun_one]
    remover = [2 if o else 1 for o in odds]

    remover_num = int(reduce(multipler, remover))
    if sum(huns) > 0:
        remover_num = int(remover_num / 2 ** sum(huns))

    basic_answer = reduce(multipler, basis)
    # print(basic_answer)
    # print(remover_num)
    return basic_answer - remover_num

if __name__ == '__main__':
    # import doctest
    # doctest.testmod()
    num = int(input())
    data = input().split(" ")
    data = [int(i) for i in data]

    print(main(num, data))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日 10/22 21:08:14 2017

# Usage
#
"""
from functools import reduce
from itertools import repeat


def multipler(x, y):
    return x*y

def hundred_or_one(l: list):
    return [True if x == 100 else False for x in l]
    # return [True if x == 1 or x == 100 else False for x in l]

def check_odds(l :list):
    return [True if x % 2 == 0 else False for x in l]

def check_hun(l: list):
    return [True if x == 100 else False for x in l]

def main(num, data:list):
    """
    >>> main(1, [2])
    1
    >>> main(1, [3])
    2
    >>> main(10, [90,52,56,71,44,8,13,30,57,84])
    58921
    >>> main(2, [2,3])
    7
    >>> main(2, [100,100])
    3
    >>> main(1, [100])
    1
    >>> main(2, [1,1])
    8
    >>> main(1, [1])
    2
    >>> main(2, [1,2])
    7
    >>> main(2, [1,3])
    8
    >>> main(2, [1,100])
    5
    >>> main(3, [1,1,100])

    >>> main(3, [1,100,100])
    """
    hun_one = hundred_or_one(data)
    odds = check_odds(data)  # 偶数の数
    huns = check_hun(data)

    basis = [2 if t else 3 for t in hun_one]
    remover = [2 if o else 1 for o in odds]

    remover_num = int(reduce(multipler, remover))
    # if sum(huns) > 0:
    #     remover_num = int(remover_num / 2 ** sum(huns))

    basic_answer = reduce(multipler, basis)
    # print(basic_answer)
    # print(remover_num)
    return basic_answer - remover_num

if __name__ == '__main__':
    # import doctest
    # doctest.testmod()
    num = int(input())
    data = input().split(" ")
    data = [int(i) for i in data]

    print(main(num, data))

Submission status: Wrong Answer

Solution code:
from sys import stdin
def readLine_int_list():return list(map(int, stdin.readline().split()))

n = int(input())
a = readLine_int_list()
even = [i for i in a if i%2 == 0]
e = len(even)

if e == 0:
    print(n**3 - 1)
else:
    print(3**n - (2**e))