Problem:
 Score : 400 points    Problem Statement We have a sequence of length N , a = (a_1, a_2, ..., a_N) .
Each a_i is a positive integer.  Snuke's objective is to permute the element in a so that the following condition is satisfied:   For each 1 ≤ i ≤ N - 1 , the product of a_i and a_{i + 1} is a multiple of 4 .   Determine whether Snuke can achieve his objective.      Constraints  2 ≤ N ≤ 10^5  a_i is an integer.  1 ≤ a_i ≤ 10^9         Input Input is given from Standard Input in the following format:  N  a_1  a_2  ...  a_N       Output If Snuke can achieve his objective, print Yes ; otherwise, print No .        Sample Input 1 3
1 10 100      Sample Output 1 Yes  One solution is (1, 100, 10) .       Sample Input 2 4
1 2 3 4      Sample Output 2 No  It is impossible to permute a so that the condition is satisfied.       Sample Input 3 3
1 4 1      Sample Output 3 Yes  The condition is already satisfied initially.       Sample Input 4 2
1 1      Sample Output 4 No       Sample Input 5 6
2 7 1 8 2 8      Sample Output 5 Yes

Solution (Python):
N = int(input())
src = list(map(int,input().split()))
x4 = odd = 0
for a in src:
    if a%4 == 0:
        x4 += 1
    elif a%2:
        odd += 1

if odd <= x4:
    print('Yes')
elif odd == x4+1:
    print('Yes' if x4+odd == N else 'No')
else:
    print('No')

Solution (Python):
N = int(input())
ans = 0
for i in  list(map(int, input().split())):
    if i % 4 == 0:
        ans += 1
    elif i % 2 != 0:
        ans -= 1

if N % 2 != 0:
    ans += 1

print('Yes' if ans >= 0 else 'No')

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
ans = 0

for i in range(N):
    if T[i] % 4 == 0:
        ans += 1
    elif T[i] % 2 != 0:
        ans -= 1
    
if N % 2 != 0:
    ans += 1

print('Yes' if ans >= 0 else 'No')

'''
for文は  if 4で割り切れる elif 4で割り切れないものの中で2でも割り切れない数字→つまり奇数　のみを判断する
基本的には0の個数分だけ4で割り切れるものが必要になってくる
しかし配列の個数が奇数個の場合 [0 4 0 4 0]で0の個数よりも1個少ない数で対応できたりするのでそれも考慮しとく
'''

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
ans = 0

for i in range(N):
    if T[i] % 4 == 0:
        ans += 1
    elif T[i] % 2 != 0:
        ans -= 1
    
if N % 2 != 0:
    ans += 1

print('Yes' if ans >= 0 else 'No')

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
n1 = 0
n2 = 0
n4 = 0
for i in a:
    if i%2 != 0:
        n1 += 1
    elif i%4 == 0:
        n4 += 1
    else:
        n2 += 1
        
if n2 == 0:
    if n1 <= n4+1:
        ans = 'Yes'
    else:
        ans = 'No'
else:
    if n1 <= n4:
        ans = 'Yes'
    else:
        ans = 'No'

print(ans)

Solution (Python):
N = int(input())
a = input().split()
a = [int(i) for i in a]
single = 0
double = 0
triple = 0
for i in a:
    if i %2 ==1:
        single +=1
    elif i %4 != 0:
        double +=1
    else:
        triple +=1
if N//2 <= (double* 0.5 + triple):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
cnt4 = 0
cnt2 = 0
for i in a:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1
if cnt4 * 2 + cnt2 >= N:
    print("Yes")
elif cnt4 * 2 >= N - 1:
    print("Yes")
else:
    print("No")

Solution (Python):

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

odd=0
four=0
for i in range(N):
    if a[i]%2==1:
        odd+=1
    elif a[i]%4==0:
        four+=1

if four>=odd:
    print('Yes')

elif four+1==odd and four+odd==N:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    four, two = 0, 0

    for a in A:
        if a % 4 == 0:
            four += 1
        elif a % 2 == 0:
            two += 1
    if two:
        N -= two - 1
    if N // 2 <= four:
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()

Solution (Python):

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

    four = 0
    two = 0

    for i in a:
        if i %4 ==0:
            four +=1
        elif i %2==0:
            two +=1


    if two > 0:
        if (n-two)/2 <= four:
            print("Yes")
        else:
            print("No")
    else:
        if n//2 <= four:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
        main()

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
sq = 0
even = 0
odd = 0
for a in A:
  if a % 4 == 0:
    sq += 1
  elif a % 2 == 0:
    even += 1
  else:
    odd += 1
if even:
  print('Yes' if sq >= odd else 'No')
else:
  print('Yes' if sq >= odd - 1 else 'No')

Solution (Python):
N = int(input())
n_four, n_two, n_other = 0, 0, 0
for ai in map(int, input().split()):
    if ai % 4 == 0:
        n_four += 1
    elif ai % 2 == 0:
        n_two += 1
    else:
        n_other += 1

if n_two == 0 and n_four + 1 >= n_other:
    print('Yes')
elif n_two > 0 and n_four >= n_other:
    print('Yes')
else:
    print('No')

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

d = {4: 0, 2: 0, 1: 0}

for a in A:
    if a % 4 == 0:
        d[4] += 1
    elif a % 2 == 0:
        d[2] += 1
    else:
        d[1] += 1

if d[2] == 0:
    if d[4] - d[1] >= -1:
        print("Yes")
    else:
        print("No")
else:
    if d[4] - d[1] >= 0:
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
for i in range(len(A)):
    A[i]%=4

cnt=dict(Counter(A).items())

num0=0
if 2 in cnt:
    cnt[2]=1
if 0 in cnt:
    num0=cnt[0]
    cnt.pop(0)
num1=sum(list(cnt.values()))
print("Yes" if num1<=num0+1 else "No")

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))

multi4 = len([a for a in a_list if a % 4 == 0])
odd_num = len([a for a in a_list if a % 2 != 0])

even_num = len(a_list) - odd_num
not4 = even_num - multi4

if not4 >0 :
    if odd_num <= multi4:
        print("Yes")
    else:
        print("No")

else:
    if odd_num <= multi4 + 1:
        print("Yes")
    else:
        print("No")

Solution (Python):
N = int(input())

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

nl = [0] * 3

for a in A:
  if a % 4 == 0:
    nl[2] += 1
  elif a % 2 == 0:
    nl[1] += 1
  else:
    nl[0] += 1


if nl[1] == 1:
  nl[0] += 1



if nl[1] >= 2 and nl[2] >= nl[0]:
  print("Yes")
elif nl[1] <= 1 and nl[2] >= nl[0] - 1:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())

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

nl = [0] * 3

for a in A:
  if a % 4 == 0:
    nl[2] += 1
  elif a % 2 == 0:
    nl[1] += 1
  else:
    nl[0] += 1


if nl[1] == 1:
  nl[0] += 1



if nl[1] >= 2 and nl[2] >= nl[0]:
  print("Yes")
elif nl[1] <= 1 and nl[2] >= nl[0] - 1:
  print("Yes")
else:
  print("No")

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

counts = {4:0, 2:0, 1:0}
for i in range(n):
    if a[i]%4 == 0:
        counts[4] += 1
    elif a[i]%2 == 0:
        counts[2] += 1
    else:
        counts[1] += 1

if counts[2] > 0:
    if counts[4] >= counts[1]:
        print('Yes')
    else:
        print('No')
else:
    if counts[4] >= counts[1]-1:
        print('Yes')
    else:
        print('No')

Solution (Python):
n = int(input())
a = [int(v) for v in input().split()]

num2 = 0
num4 = 0
for v in a:
    if v % 4 == 0:
        num4 += 1
    elif v % 2 == 0:
        num2 += 1

if num4 >= n // 2:
    print('Yes')
elif num4 * 2 + num2 >= n:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
count = [0,0,0]
for i in range(N):
    A[i] = A[i] % 4
    if A[i] == 0:
        count[0] += 1
    elif A[i] == 2:
        count[1] += 1
    else:
        count[2] += 1

if count[1] == 0:
    if count[2] <= count[0] + 1:
        print("Yes")
    else:
        print("No")
else:
    if count[2] <= count[0]:
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return




dp = None


def main():
    N = int(input())
    L = li_input()

    x1 = 0
    x2 = 0
    x4 = 0
    for l in L:
        if l % 4 == 0:
            x4 += 1
        elif l % 2 == 0:
            x2 += 1
        else:
            x1 += 1

    if x2 == 0:
        if x1 - 1 <= x4:
            print("Yes")
        else:
            print("No")
    else:
        if x1 <= x4:
            print("Yes")
        else:
            print("No")


main()

Solution (Python):
N,*A=map(int,open(0).read().split())
x=y=0
for a in A:
    if a%4==0:x+=1
    elif a%2==0:y+=1
print(['No','Yes'][x+y//2>=N//2])

Solution (Python):
N=int(input())
a=b=c=0
for x in map(int,input().split()):
    if x%4==0:
        a+=1
    elif x%2==0:
        b+=1
print(['No','Yes'][a+b//2>=N//2])

Solution (Python):
N = int( input())
A = list( map( int, input().split()))
zero = 0
ni = 0
yon = 0
for a in A:
    if a%2 == 1:
        zero += 1
    elif not a%4 == 0:
        ni += 1
    else:
        yon += 1
if ni == 0:
    if yon + 1 >= zero:
        print('Yes')
    else:
        print('No')
else:
    if yon >= zero:
        print('Yes')
    else:
        print('No')

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
div_1 = div_2 = div_4 = 0
for i in a:
    if i%4==0:
        div_4 += 1
    elif i%2==0:
        div_2 += 1
    else:
        div_1 += 1

if div_4==div_1 or div_4==div_1+1 or (div_1==0 and div_2!=1) or (div_2==0 and (div_4==div_1 or div_4+1==div_1 or div_4==div_1+1)):
    print('Yes')
else:
    print('No')

Solution (Python):


import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(N, A):
    c = Counter()

    for a in A:
        if a % 4 == 0:
            c[2] += 1
        elif a % 2 == 0:
            c[1] += 1
        else:
            c[0] += 1

    if c[0] - c[2] > 1:
        return 'No'

    if c[0] - c[2] == 1 and c[1] > 0:
        return 'No'

    return 'Yes'


def main():
    N = read_int()
    A = read_int_n()

    print(slv(N, A))


if __name__ == '__main__':
    main()

Solution (Python):


import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(N, A):
    c = Counter()

    for a in A:
        if a % 4 == 0:
            c[2] += 1
        elif a % 2 == 0:
            c[1] += 1
        else:
            c[0] += 1

    if c[0] - c[2] > 1:
        return 'No'

    if c[0] - c[2] == 1 and c[1] > 0:
        return 'No'

    return 'Yes'


def main():
    N = read_int()
    A = read_int_n()

    print(slv(N, A))


if __name__ == '__main__':
    main()

Solution (Python):
b = int(input())

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

co = 0
s = 0
ss = 0

for i in range(len(a)):
  while a[i] % 2 == 0:
    co += 1
    a[i] //= 2
  if co == 1:
    s += 1
  elif co >= 2:
    ss += 1
  co = 0
  
b -= s

if b % 2 == 1 and s > 0:
  b += 1
elif b % 2 == 1 and s == 0:
  b -= 1
b //= 2

if ss >= b:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]

c = {0: 0, 2: 0, 4: 0}
for ai in a:
    if ai % 4 == 0:
        c[4] += 1
    elif ai % 2 == 0:
        c[2] += 1
    else:
        c[0] += 1

if c[0] <= c[4]:
    print('Yes')
elif c[0] + c[2] <= c[4] + 1:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(raw_input())
A = map(int, raw_input().split())
c = [0, 0, 0]
for a in A:
  if a%4==0:
    c[2]+=1
  elif a%2==0:
    c[1]+=1
  else:
    c[0]+=1
while sum(c)>0:
  if c[0]==0:
    print 'Yes'
    break
  elif sum(c)==1:
    print 'Yes'
    break
  elif c[2]==0:
    print 'No'
    break
  else:
    c[0]-=1
    c[2]-=1

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

x = 0 
y = 0 
z = 0 
for a in A:
    if a % 4 == 0:
        x += 1
    elif a % 2 == 0:
        y += 1
    else:
        z += 1

if x == 0:
    if z > 0:
        print('No')
    else:
        print('Yes')
else:
    if y == 0:
        if x+1 >= z:
            print('Yes')
        else:
            print('No')
    else: 
        if x >= z:
            print('Yes')
        else:
            print('No')

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








odd, num4, num2 = 0, 0, True
for i in range(n):
    if a[i] % 4 == 0:
        num4+=1
    elif a[i] % 2 != 0:
        odd +=1
    elif num2:
        odd +=1
        num2 = False
print('Yes' if odd<=num4+1 else 'No')
exit(0)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
square = 0
even = 0
odd = 0
for a in A:
  if a % 4 == 0:
    square += 1
  elif a % 2 == 0:
    even += 1
  else:
    odd += 1
if square >= odd:
  print('Yes')
elif square == odd - 1 and even == 0:
  print('Yes')
else:
  print('No')

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

x1 = 0
x2 = 0
x4 = 0
for x in A:
    if x % 4 == 0:
        x4 += 1
    elif x % 2 == 0:
        x2 += 1
    else:
        x1 += 1

if x2 != 0:
    print("Yes" if x4 >= x1 else "No")
else:
    print("Yes" if x4 + 1 >= x1 else "No")

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))

fc = 0
oc = 0
tc = 0
for i in a_list:
    if i % 2 == 0 and i % 4 != 0:
        tc += 1
    elif i % 4 == 0:
        fc += 1
    else:
        oc += 1

if fc >= oc:
    print("Yes")
elif tc == 0 and (oc - fc == 1):
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = [int(_) for _ in input().split()]
count_four = 0
count_even = 0
count_odd = 0

for ai in a:
    if ai % 4 == 0:
        count_four += 1
    elif ai % 2 == 0:
        count_even += 1
    else:
        count_odd += 1

if count_odd <= 0:
    print('Yes')
elif count_odd == 1:
    if count_four >= 1:
        print('Yes')
    else:
        print('No')
elif count_odd == 2:
    if count_four >= 2:
        print('Yes')
    elif count_four == 1 and count_even == 0:
        print('Yes')
    else:
        print('No')
else:
    if count_even == 0:
        if count_four + 1 >= count_odd:
            print('Yes')
        else:
            print('No')
    else:
        if count_four >= count_odd:
            print('Yes')
        else:
            print('No')

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
a2 = 0
a4 = 0
odd = 0

for a in aa:
	if a%4 == 0:
		a4 += 1
	elif a%2 == 0:
		a2 += 1
	else:
		odd += 1

if a4 >= N//2:
	print('Yes')
elif a4 >= odd:
	print('Yes')
else:
	print('No')

Solution (Python):
import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())))
n_odd = np.sum(a % 2 == 1)
n_four = np.sum(a % 4 == 0)
if n_odd <= n_four or n_odd - 1 == n_four == N // 2:
    print('Yes')
else:
    print('No')

Solution (Python):


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

    odd_cnt = 0
    even_cnt = 0
    four_cnt = 0
    for i in a_list:
        if i % 2 == 0 and i % 4 != 0:
            even_cnt += 1
        elif i % 4 == 0:
            four_cnt += 1
        else:
            odd_cnt += 1
    if even_cnt == 0:
        if four_cnt >= odd_cnt - 1:
            print('Yes')
        else:
            print('No')
    else:
        if four_cnt >= odd_cnt:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
m=list(map(int,input().split()))
l=filter(lambda x:x%4==0,m)
o=filter(lambda x:x%2==0 and x%4!=0,m)
if n//2<=len(list(l))+len(list(o))//2:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]




    


div4 = 0
is2 = 0
    
for i in a :
    if i % 4 == 0 :
        div4 += 1
    elif i % 2 == 0 :
        is2 += 1
   
if len(a) % 2 == 0 :
    if div4 + is2 // 2 >= N / 2 :
        print("Yes")
    else :
        print("No")
else :
    if div4 + is2 // 2 >= (N - 1) / 2 :
        print("Yes")
    else :
        print("No")

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
counta=0
countb=0
for i in a:
  if i%4==0:
    counta+=1
  elif i%2==0:
    countb+=1

if len(a)%2 ==0:
    if counta+countb//2 >= N/2:
    	print('Yes')
    else:
        print('No') 
else:
    if counta+countb//2 >= (N-1)/2:
    	print('Yes')
    else:
        print('No')

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

a, b, c = 0, 0, 0

for e in A:
    if e % 2 == 0:
        if e % 4 == 0:
            c += 1
        else:
            b += 1
    else:
        a += 1

print('Yes' if c - a + (b == 0) >= 0 else 'No')

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

odds = []
bai4 = []

for i in range(N):
    odds.append(A[i]%2 == 1)
    bai4.append(A[i]%4 == 0)
    
odd = sum(odds)
bi4 = sum(bai4)
bi2 = N - odd - bi4

if odd + bool(bi2) > bi4+1:
    print("No")
else:
    print("Yes")

Solution (Python):


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


ok = 0

ng = 0

excp = 0
for i in range(N):
    if aN[i] % 4 == 0:
        ok += 1
    elif (aN[i] + 2) % 4 == 0:
        excp += 1
    else:
        ng += 1


if excp > 0:
    ng += 1


if ok + 1 >= ng:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
o,q,e=[],[],[]
for i in a:
    if i%4==0: q.append(i)
    elif i%2==0: e.append(i)
    else: o.append(i)
s=0
for i in range(n):
    if s==0:
        if len(o):
            o.pop()
            s=4
        elif len(e):
            e.pop()
            s=2
        else:
            q.pop()
    elif s==2:
        if len(e):
            e.pop()
            s=2
        elif len(q):
            q.pop()
            s=0
        else:
            print("No")
            exit()
    else:
        if len(q):
            q.pop()
            s=0
        else:
            print("No")
            exit()
print("Yes")

Solution (Python):
N = int(input())

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

b0=0
b2=0
b4=0

for i in range(N):
    if a[i]%4==0:
        b4+=1
    elif a[i]%2==0:
        b2+=1
    else:
        b0+=1
        

        
if b0<=b4:
    print("Yes")
elif b0==b4+1 and b0+b4==N:
    print("Yes")
else:
    print("No")

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

two_num = 0
four_num = 0
another_num = 0

for i in a:
    if i % 4 == 0:
        four_num += 1
    elif i % 2 == 0:
        two_num += 1
    else:
        another_num += 1
if two_num >= 1:
    another_num += 1

if four_num + 1 >= another_num:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
li = [0,0,0]
for nums in A:
  if nums%4==0:
    li[0] += 1
  elif nums%2==0:
    li[1] += 1
  else:
    li[2] += 1
if li[1]==0 and li[2]-li[0]>1:
  print('No')
elif li[1]!=0 and li[2]-li[0]>0:
  print('No')
else:
  print('Yes')

Solution (Python):
N = int(input())
L = list(map(int,input().split()))

num_2 = 0
num_4 = 0
odd = 0

for i in L:
    if i % 4 == 0:
        num_4 += 1
    elif i % 2 == 0:
        num_2 += 1
    else:
        odd += 1
        
if num_2 != 0:
    if num_4 >= odd:
        print("Yes")
    else:
        print("No")
        
if num_2 == 0:
    if num_4 >= odd -1:
        print("Yes")
    else:
        print("No")

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]

count = 0
half = 0
for i in range(N):
    if a[i]%4 == 0:
        count += 1
    elif a[i]%2 == 0:
        half +=1

if count >= N//2:
    print("Yes")
elif count >= (N//2 - half//2):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = [0, 0, 0]
b = map(int, input().split())
for a in b:
    if a % 4 == 0:
        A[2] += 1
    elif a % 2 == 0:
        A[1] += 1
    else:
        A[0] += 1



for i in range(3):
    if A[i] != 0:
        s = i
        A[i] -= 1
        break


def judge(A, s, N):
    for i in range(N - 1):
        if s == 0:  
            if A[2] != 0:
                A[2] -= 1
                s = 2
            else:
                return "No"
        elif s == 1:
            if A[1] != 0:
                A[1] -= 1
                s = 1
            elif A[2] != 0:
                A[2] -= 1
                s = 2
            else:
                return "No"
        else:
            if A[0] != 0:
                A[0] -= 1
                s = 0
            elif A[1] != 0:
                A[1] -= 1
                s = 1
            elif A[2] != 0:
                A[2] -= 1
                s = 2
            else:
                return "No"
    return "Yes"


print(judge(A, s, N))

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]

c1 = 0
c2 = 0
c4 = 0
for a in A:
    if a % 2 == 1:
        c1 += 1
    elif a % 4 == 0:
        c4 += 1
    else:
        c2 += 1

if c1 > c4 + 1:
    print("No")
elif c1 == c4 + 1:
    if c2 == 0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Solution (Python):

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


i, j, k = 0, 0, 0

for n in range(N):
    if a[n] % 4 == 0:
        i += 1
    elif a[n] % 2 == 0:
        j += 1
    else:
        k += 1

if k >= i + 2:
    print('No')
elif k == i + 1 and j >= 1:
    print('No')
else:
    print('Yes')

Solution (Python):
N = int(input())
src = list(map(int,input().split()))
odd = two = four = 0
for a in src:
    if a%2: odd += 1
    elif a%4==0: four += 1
    else: two += 1
if two:
    print('Yes' if odd <= four else 'No')
else:
    print('Yes' if odd <= four+1 else 'No')

Solution (Python):
N = (input())
a = list(map(int, input().split()))
f_count = 0
t_count = 0
for i in range(len(a)):
    if a[i]%4 == 0:
        f_count += 1
    elif a[i]%2 == 0:
        t_count += 1

if t_count < 2:
    if (2 * f_count  >= len(a)-1):
        print('Yes')
    else:
        print('No')
else:
    if (2 * f_count  >= len(a) - t_count):
        print('Yes')
    else:
        print('No')

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
mod2 = [i for i in a if i % 2 == 0]
mod4 = [i for i in mod2 if i % 4 == 0]
m2len = len(mod2)
m4len = len(mod4)
if (N-m2len+m4len+(1 if (m2len-m4len) > 0 else 0))//2 <= m4len:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
j2,j4=0,0
for x in a:
    if x%4==0:
        j4+=1
    elif x%2==0:
        j2+=1
if n%2==0:
    print("Yes" if j2+2*j4>=n else "No")
else:
    print("Yes" if j2+2*j4>=n-1 else "No")

Solution (Python):
n = int(input())

arr = map(int,raw_input().split())

dic = [0,0,0]

for i in arr:
	if i%4==0:
		dic[2] += 1
	elif i%2 == 0:
		dic[1] += 1
	else :
		dic[0] += 1


if dic[2]+1 <= dic[0] and 0 < dic[1]:
	print 'No'
elif dic[2]+1 == dic[0] and dic[1] == 0:
	print 'Yes'

elif dic[2] >= dic[0] :
	print 'Yes'

else :
	print 'No'

Solution (Python):


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

count = 0
flag = False
for a in A:
    if a % 4 == 0:
        count += 2
        flag = True
    elif a % 2 == 0:
        count += 1

if count >= n:
    print('Yes')
elif n % 2 == 1 and flag:
    print('Yes')
else:
    print('No')

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

def div_two(n):
    tmp = n/2
    if tmp%1 != 0:
        return 0
    if (tmp/2)%1 != 0:
        return 1
    return 2

tmp = [0]*3
for i in map(div_two, a):
    tmp[i] += 1

flag = True

if tmp[0] > tmp[2]:
    if tmp[1] == 0:
        if tmp[0] != tmp[2]+1:
            flag = False
    else:
        flag = False

if tmp[1]:
    if tmp[1] == 1:
        flag == False

print("Yes" if flag else "No")

Solution (Python):
N = int(input())
input_list = [int(i) for i in input().split()]
four_count = 0
two_count = 0

for i in input_list:
    if i % 4 == 0:
        four_count += 1
    elif i % 2 == 0:
        two_count += 1

others_count = N - four_count - two_count

if two_count:
    if others_count <= four_count:
        print("Yes")
    else:
        print("No")
else:
    if others_count <= four_count + 1:
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys

stdin = sys.stdin

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

n_2 = n
n_4 = n // 2
a_2 = 0
a_4 = 0

for i in a:
    if i % 4 == 0:
        a_4 += 1
    elif i % 2 == 0:
        a_2 += 1

if a_4 >= n_4 or a_2 >= n_2 or a_2 >= (n-a_4*2):
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
l = len(a)
fs = 0
ts = 0
for i in a:
    if(i % 4 == 0):
        fs += 1
    elif(i % 2 == 0):
        ts += 1
if(ts > 1):
    l = l - ts + 1
if(l <= fs*2 + 1):
    print('Yes')
else:
    print('No')

Solution (Python):
def m():
    N = int(input())
    a = list(map(int, input().split()))
    fours = []
    twes = []
    others = []
    for i in range(N):
        if a[i] % 4 == 0:
            fours.append(a[i])
            continue

        if a[i] % 2 == 0:
            twes.append(a[i])
            continue
        others.append(a[i])

    len4s = len(fours)
    len2s = len(twes)
    others = len(others)
    if len2s:
        others += 1
    if others <= len4s + 1:
        return 'Yes'
    return 'No'


print(m())

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
c1, c2, c4 = 0, 0, 0
for b in a:
    if b%4 == 0:
        c4 += 1
    elif b%2 == 0:
        c2 += 1
    else:
        c1 += 1
if c4 >= c1 or (c1-c4 <= 1 and c2 == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
cnt4 = 0
cnt2 = 0
cnt = 0
for i in range(n):
    if a[i] % 4 == 0:
        cnt4 += 1
    elif a[i] % 2 == 0:
        cnt2 += 1
    else:
        cnt += 1

if cnt2 == 0:
    if cnt <= cnt4 + 1:
        print("Yes")
    else:
        print("No")
else:
    if cnt <= cnt4:
        print("Yes")
    else:
        print("No")

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

zero = 0
two = 0
odd = 0

for i in range(len(a)):
    if a[i] % 4 == 1 or a[i] % 4 == 3:
        odd = odd + 1
    elif a[i] % 4 == 0:
        zero = zero + 1
    else:
        two = two + 1
        
if zero >= odd -1 and two == 0:
    print('Yes')
elif zero >= odd:
    print('Yes')
else:
    print('No')

Solution (Python):
def c_4adjacent(N, A):  
    
    num_4, num_2, num_other = 0, 0, 0
    for a in A:
        if a % 4 == 0:
            num_4 += 1
        elif a % 2 == 0:
            num_2 += 1
        else:
            num_other += 1

    if num_2 == 0:
        ans = 'Yes' if num_other <= num_4 + 1 else 'No'
    else:
        ans = 'Yes' if num_other <= num_4 else 'No'
    return ans

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
p, q, r = 0, 0, 0

for a in A:
    if a % 4 == 0:
        p += 1
    elif a % 4 == 2:
        q = 1
    else:
        r += 1

print("Yes" if q + r <= p + 1 else "No")