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,ais = int(raw_input()), map(int, raw_input().split())
import collections
cc = collections.Counter()
for ai in ais:
	if ai % 4 == 0: cc[0] += 1
	elif ai % 2 == 0: cc[1] += 1
	else: cc[2] += 1

q = collections.deque()
while(n):
	if len(q) == 0:
		for u in range(3)[::-1]:
			if cc[u] > 0:
				q.append(u)
				cc[u]-=1
				n -=1
				break
		if len(q) == 0: break
	else:
		if q[-1] == 0:
			if cc[2]:
				q.append(2)
				cc[2]-=1
				n-=1
			elif cc[1]:
				q.append(1)
				cc[1]-=1
				n-=1
			elif cc[0]:
				q.append(0)
				cc[0]-=1
				n-=1
			else:
				break
		elif q[-1] == 2:
			if cc[0] == 0:
				break
			else:
				q.append(0)
				cc[0]-=1
				n-=1
		elif q[-1] == 1:
			if cc[1] > 0:
				q.append(1)
				cc[1]-=1
				n-=1
			else:
				break

print 'Yes' if n == 0 else 'No'

Solution (Python):

n,ais = int(raw_input()), map(int, raw_input().split())
import collections
cc = collections.Counter()
for ai in ais:
	if ai % 4 == 0: cc[0] += 1
	elif ai % 2 == 0: cc[1] += 1
	else: cc[2] += 1

q = collections.deque()
while(n):
	if len(q) == 0:
		for u in range(3)[::-1]:
			if cc[u] > 0:
				q.append(u)
				cc[u]-=1
				n -=1
				break
		if len(q) == 0: break
	else:
		if q[-1] == 0:
			if cc[2]:
				q.append(2)
				cc[2]-=1
				n-=1
			elif cc[1]:
				q.append(1)
				cc[1]-=1
				n-=1
			elif cc[0]:
				q.append(0)
				cc[0]-=1
				n-=1
			else:
				break
		elif q[-1] == 2:
			if cc[0] == 0:
				break
			else:
				q.append(0)
				cc[0]-=1
				n-=1
		elif q[-1] == 1:
			if cc[1] > 0:
				q.append(1)
				cc[1]-=1
				n-=1
			else:
				break

print 'Yes' if n == 0 else 'No'

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

cnt = 0
for a in a_lst:
  if a % 4 == 0:
    cnt += 2
  elif a % 2 == 0:
    cnt += 1
  else:
    pass

if cnt // 2 >= n // 2:
  print('Yes')
else:
  print('No')

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
l=[0]*N
for i in range(N):
    if a[i]%4:
        if a[i]%2:l[i]=1
        else:l[i]=2
    else:l[i]=4
print('Yes'if l.count(1)+(1 if l.count(2)else 0)<=1+l.count(4)else'No')

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

x,y,z = 0,0,0
for i in a:
  if i%4 == 0: x += 1
  elif i%2 == 0: y += 1
  else: z += 1
    
if x >= z-1+y%2: print("Yes")
else: print("No")

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

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

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

codd = 0
cfour = 0

for i in range(n):
	if a[i]%2 != 0:
		codd += 1
	if a[i]%4 == 0:
		cfour += 1
ceven = n - cfour - codd

if cfour >= codd:
	print('Yes')
elif ceven == 0 and cfour + 1 == codd:
	print('Yes')
else:
	print('No')

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

L=list(map(int,input().split()))
a=0
b=0

for i in range(n):
	if L[i]%4==0:
		b+=1
	if L[i]%2==1:
		a+=1

if a+b==n and a-b==1:
	print('Yes')
	exit()
if b>=a:
	print('Yes')
else:
	print('No')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
cnt = [0]*3

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

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
s=0
t=0
u=0
for i in range(n):
  if a[i]%4==0:
    s=s+1
  elif a[i]%2==0:
    t=t+1
  else:
    u=u+1
if t>=1:
  if s>=u:
    print("Yes")
  else:
    print("No")
else:
  if s-u>=-1:
    print("Yes")
  else:
    print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*3
for i in a:
  if i%4==0:ans[2]+=1
  elif i%2==0:ans[1]+=1
  else:ans[0]+=1
print(['No','Yes'][ans[0]+(ans[1]>0)<=ans[2]+1])

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*3
for i in a:
  if i%4==0:
    ans[2]+=1
  elif i%2==0:
    ans[1]+=1
  else:ans[0]+=1
if ans[0]<=ans[2] or (ans[0]<=ans[2]+1 and ans[1]==0):print('Yes')
else:print('No')

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = {1:0, 2:0, 4:0}
    for a in A:
        if a % 2 == 1:
            d[1] += 1
        elif a % 4 == 0:
            d[4] += 1
        else:
            d[2] += 1
    if d[2] == 0 and d[4] + 1 >= d[1]:
        print("Yes")
    elif d[2] != 0 and d[4] >= d[1]:
        print("Yes")
    else:
        print("No")
    

if __name__ == "__main__":
    main()

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

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

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

if c4==0 and c1>0 :
    ans="No"
elif c1<=c4+(c2==0) :
    ans="Yes"
else:
    ans="No"

print( ans )

Solution (Python):
n=int(input())
l=map(int,input().split())
x,y,z=0,0,0
for a in l:
    if a%4==0:
        z+=1
    elif a%2==0:
        y+=1
    else:
        x+=1
if y>0:
    x+=1
print('Yes'if x<=z+1 else'No')

Solution (Python):



N = int(input())


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




alen = N
two = 0
four = 0

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

other = alen - two - four

res = False

if other > four + 1:
    pass
elif other == four + 1:
    if two == 0:
        res = True
else:
    res = True

if res:
    print("Yes")
else:
    print("No")

Solution (Python):
n,*aa = map(int, open(0).read().split())

odd = sum([a%2 for a in aa])
quad = sum([a%4==0 for a in aa])

if odd <= quad or (odd == quad + 1 and odd+quad == len(aa)):
    print('Yes')
else:
    print('No')

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

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

ans = 'No'
other += two % 2
if four + 1 >= other:
    ans = 'Yes'

print(ans)

Solution (Python):
import collections
_ = input()
A = collections.Counter(int(T) for T in input().split()).most_common()
Num4 = sum(A[T][1] for T in range(0,len(A)) if A[T][0]%4==0)
Num2 = sum(A[T][1] for T in range(0,len(A)) if A[T][0]%4!=0 and A[T][0]%2==0)
Odd  = sum(A[T][1] for T in range(0,len(A)) if A[T][0]%2!=0)
if Num2>0: Capacity = Num4
else: Capacity = Num4+1
if Capacity>=Odd: print('Yes')
else: print('No')

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

x2=0
x4=0
x1=0
for x in a:
  if x%2==0:
    x2+=1
  if x%4==0:
    x4+=1
  if x%2==1:
    x1+=1
    
if x4+x1==n:
  if x4>=x1-1:
    print('Yes')
  else:
    print('No')
  
else:
  if x4>=x1:
    print('Yes')
  else:
    
    print('No')

Solution (Python):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
amod4=list(map(lambda x:x%4, a))
d=Counter(amod4)
if n-d[0]-d[2]<d[0]+1:
  print('Yes')
elif d[2]==0 and n==2*d[0]+1:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    
    m = sum(1 for a in A if a % 2 == 1)
    n2 = sum(1 for a in A if a % 2 == 0 and a % 4 != 0)
    n4 = sum(1 for a in A if a % 4 == 0)
    
    if m <= n4:
        print('Yes')
    elif m == n4 + 1:
        if n2 == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
    
    return


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
c2=0
c4=0
for aa in a:
  if aa%2 == 0:
    if aa%4 == 0:
      c4+=1
    else:
      c2+=1
c0=n-(c2+c4)
cc=c4-c0
if c2>=1 and c2 != n:
  cc-=1
print("Yes" if cc >= -1 else "No")

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

cnt_1, cnt_2 = 0, 0
for v in a:
    if v % 2 == 1:
        cnt_1 += 1
    elif v % 4 == 0:
        cnt_2 += 1

if cnt_1 + cnt_2 == n and cnt_1 - cnt_2 == 1:
    print('Yes')
elif cnt_1 <= cnt_2:
    print('Yes')
else:
    print('No')

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

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

if N//2<=x+y//2:
  print("Yes")
else:
  print("No")

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

x = y = z = 0
for a in a_list:
    if a % 4 == 0:
        x += 1
    elif a % 2 == 0:
        y += 1
    else:
        z += 1
if (y == 0 and x >= z - 1) or (y > 0 and x >= z):
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
 
N=int(input())
A=np.array(list(map(int,input().split())))
 
odd=np.count_nonzero(A%2!=0)
four=np.count_nonzero(A%4==0)
ans='No'

if odd==1 and four>=1:
  ans='Yes'
elif odd==2 and four>=2:
  ans='Yes'
else:
  if odd+four==N and odd-1<=four:
    ans='Yes'
  elif odd<=four:
    ans='Yes'
print(ans)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
c_ki = 0
c_4 = 0
c_2 = 0
for i in range(n):
  if a[i] % 2 == 1:
    c_ki += 1
  elif a[i] % 4 == 0:
    c_4 += 1
  else:
    c_2 += 1
if c_ki <= c_4:
  print("Yes")
elif c_ki-1 == c_4 and c_2 == 0:
  print("Yes")
else:
  print("No")

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

ki = 0
gu_2 = 0
gu_4 = 0

for i in a:
    if i % 4 == 0:
        gu_4 += 1
    elif i % 2 == 0:
        gu_2 += 1
    else:
        ki += 1

if ki <= gu_4:
    print('Yes')
else:
    if gu_4 + 1 == ki and gu_4 + ki == N:
        print('Yes')
    else:
        print('No')

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

x,y,z=0,0,0
for i in a:
    if i%4 == 0:
        z+=1
    elif i%2 == 0:
        y+=1
    else:
        x+=1
if y:
    if x <= z:
        print('Yes')
    else:
        print('No')
else:
    if x <= z+1:
        print('Yes')
    else:
        print('No')

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

a_add=[]
a_2=[]
a_4=[]

for a in A:
    if a%2 != 0:
        a_add.append(a)
    if a%4 == 0: 
        a_4.append(a)
    elif a%2 == 0: 
        a_2.append(a)
        

        
ans='No'
if len(a_4) >= len(a_add):
    ans='Yes'
elif len(a_2)==0 and len(a_4) >= len(a_add)-1:
    ans='Yes'
print(ans)

Solution (Python):
n = int(input())
a_list = [int(x) for x in input().split()]
x = y = z = 0
for a in a_list:
    if a % 4 == 0:
        x += 1
    elif a % 2 == 0:
        y += 1
    else:
        z += 1
print("Yes" if (y == 0 and x >= z - 1) or (y > 0 and x >= z) else "No")

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  

N = I()
a = LI()

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

if s >= N//2 or t >= N-2*s:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  

N = I()
a = LI()

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

if s >= N//2 or t >= N-2*s:
    print('Yes')
else:
    print('No')

Solution (Python):
import math
n = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in a:
    if i%4==0:
        c4+=1
    elif i%2==0:
        c2+=1

if c2 == len(a):
    print('Yes')
elif c2 >= 2:
    if c4 >= (math.ceil((len(a)-c2)/2)):
        print('Yes')
    else:
        print('No')
elif c4 >=(len(a)//2):
    print('Yes')
else:
    print('No')

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

odd, m4, m2 = 0, 0, 0
for i in a:
    if i % 2 != 0:
        odd += 1
    elif i % 4 == 0:
        m4 += 1
    else:
        m2 = 1
else:
    if odd + m2 - 1 <= m4:
        print("Yes")
    else:
        print("No")

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

odd = []
m4 = []
m2 = 0
for i in a:
    if i % 2 != 0:
        odd.append(i)
    elif i % 4 == 0:
        m4.append(i)
    else:
        m2 = 1
else:
    if len(odd) + m2 - 1 <= len(m4):
        print("Yes")
    else:
        print("No")

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

odd = []
m4 = []
m2 = 0
for i in a:
    if i % 2 != 0:
        odd.append(i)
    elif i % 4 == 0:
        m4.append(i)
    else:
        m2 = 1
else:
    lodd = len(odd)
    if lodd == 0 or lodd + m2 - 1 <= len(m4):
        print("Yes")
    else:
        print("No")

Solution (Python):
def main():
    n = int(input())
    As = list(map(int, input().split()))
    fours = 0
    evens = 0
    odds = 0
    for A in As:
        if A % 4 == 0:
            fours += 1
        elif A % 2 == 0:
            evens += 1
        else:
            odds += 1

    if fours+(evens)//2 >= n//2:
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
mod0 = 0
mod2 = 0
mod13 = 0

for a in A:
  mod = a % 4
  if mod == 0:
    mod0 += 1
  elif mod == 2:
    mod2 += 1
  else:
    mod13 += 1
    
if mod2 > 0:
  if mod13 <= mod0:
    print('Yes')
  else:
    print('No')
else:
  if mod13-1 <= mod0:
    print('Yes')
  else:
    print('No')

Solution (Python):
import sys
input = sys.stdin.readline

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

n_c4 = 0
n_c2 = 0
n_c0 = 0

for ai in a:
    if ai%4 ==0:
        n_c4 += 1
    elif ai%2 ==0:
        n_c2 += 1
    else:
        n_c0 += 1
if n_c4>=n_c0 or (n_c4 == n_c0-1 and n_c4+n_c0 == N) :
    print('Yes')
else:
    print('No')

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

other = mult_2 = mult_4 = 0
for t in a:
    if t % 4 == 0:
        mult_4 += 1
    elif t % 2 == 0:
        mult_2 += 1
    else:
        other += 1

if other - 1 + (1 if mult_2 > 0 else 0) <= mult_4:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()

    cnt = 0
    for a in A:
        if a % 4 == 0:
            cnt += 1
        elif a % 2 == 0:
            cnt += .5
    print('Yes' if N // 2 <= int(cnt) else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()

    cnt = 0
    for a in A:
        if a % 4 == 0:
            cnt += 1
        elif a % 2 == 0:
            cnt += .5
    print('Yes' if N // 2 <= int(cnt) else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    o, t, f = 0, 0, 0
    for a in A:
        if a % 4 == 0:
            f += 1
        elif a % 2 == 0:
            t += 1
        else:
            o += 1
    if t > 0:
        o += 1
    print('Yes' if o <= f + 1 else 'No')


if __name__ == '__main__':
    main()

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

n4 = 0  
nodd = 0 
for i in range(N):
    nodd += (a[i] % 2 == 1)
    n4 += (a[i] % 4 == 0)

ans = "Yes"
if nodd > (N + 1) // 2:
    ans = "No"
elif n4 < min(nodd, N // 2):
    ans = "No"

print(ans)

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

b = [0]*3

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

if b[1] == 0:
    if b[2] + 1 >= b[0]:
        print("Yes")
        exit()
    else:
        print("No")
        exit()



if b[2]  >= b[0]:
    print("Yes")
else:
    print("No")

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

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

if four-one-two%2 >= -1: print("Yes")
else: print("No")

Solution (Python):
import sys
N=int(input())
A=list(map(int,input().split()))
a=len([i for i in A if i%4==0])
b=len([i for i in A if i%4==2])
if b==0:
  if a*2+1>=N:
    print("Yes")
    sys.exit()
  else:
    print("No")
    sys.exit()
if a*2+b>=N:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    a = list(mi())
    even = sum(1 for i in range(N) if a[i]%2==0)
    odd = sum(1 for i in range(N) if a[i]%2==1)
    four = sum(1 for i in range(N) if a[i]%4==0)

    if odd-four == 1:
        ans = (odd+four == N)
    elif odd <= four:
        ans = True
    else:
        ans = False

    print('Yes' if ans else 'No')
    


if __name__ == '__main__':
    main()

Solution (Python):
import sys
N = int(input())
a = list(map(int, input().split()))
C = [0] * 3
for ai in a:
    if ai % 4 == 0:
        C[2] += 1
    elif ai % 2 == 0:
        C[1] += 1
    else:
        C[0] += 1
while C[0] > 0:
    if C[2] > 0:
        C[0] -= 1
        C[2] -= 1
    else:
        if C[0] == 1 and C[1] == 0:
            print('Yes')
            sys.exit()
        else:
            print('No')
            sys.exit()
print('Yes')

Solution (Python):
_,*l=[int(i)%4 for i in open(0).read().split()]
c=l.count
print('YNeos'[c(0)+c(2)//2<len(l)//2::2])

Solution (Python):
input()
l=[int(i)%4 for i in input().split()]
c=l.count
print('YNeos'[c(0)+c(2)//2<len(l)//2::2])

Solution (Python):
n,*l=map(int,open(0).read().split())
d={1:0,2:0,4:0}
for i in l:
  if i%2: d[1]+=1
  elif i%4: d[2]+=1
  else: d[4]+=1
if d[2]: print('YNeos'[d[1]>d[4]::2])
else: print('YNeos'[d[1]-1>d[4]::2])

Solution (Python):
n=int(input())
lst=list(map(int,input().split()))
four=0
two=0
odd=0

for i in lst:
    if i%4==0:
        four+=1
    elif i%2==0:
        two+=1
    else:
        odd+=1

if four>=odd:
    print("Yes")
elif four+1==odd:
    if two==0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
num=[0,0,0]
for i in range(n):
    if a[i]%4==0:
        num[2]+=1
    elif a[i]%2==0:
        num[1]+=1
    else:
        num[0]+=1
if num[1]==0:
    if num[0]>num[2]+1:
        print("No")
    else:
        print("Yes")
elif num[0]>num[2]:
    print("No")
else:
    print("Yes")

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

cnt4 = 0
cnt2 = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1

ans = "No"

if N - cnt4*2 <= 1:
    ans =  "Yes"
elif N - cnt4*2 > 1:
    if N - cnt4*2 <= cnt2:
        ans = "Yes"
elif N - cnt4*2 == N:
    if N == cnt2*2:
        ans = "Yes"

print(ans)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
d = {1 : 0, 2 : 0, 4 : 0}
for i in a:
    if i % 4 == 0:
        d[4] += 1
    elif i % 2 == 0:
        d[2] += 1
    else:
        d[1] += 1
if d[1] <= d[4]:
    print("Yes")
elif d[1] - d[4] == 1 and d[2] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
a = l()
num1 = 0
num2 = 0
num3 = 0
for i in range(N):
    if a[i]%4 == 0:
        num3 += 1
    elif a[i]%2 == 0:
        num2 += 1
    else:
        num1 += 1
if num3+1 < num1:
    print('No')
elif num3+1 == num1 and num2 != 0:
    print('No')
else:
    print('Yes')

Solution (Python):
N = int(input())
odd = []
even = []
four = []
for x in map(int,input().split()):
    if x % 4 == 0:
        four.append(x)
    elif x % 2 == 0:
        even.append(x)
    else:
        odd.append(x)
if len(four) >= len(odd):
    print("Yes")
elif len(four) == len(odd)-1 and len(even) == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
lst = list(map(int, input().split()))
dic = {0:0, 1:0, 2:0}
for i in range(n):
  if lst[i] % 4 == 0:
    dic[2] += 1
  elif lst[i] % 2 == 0:
    dic[1] += 1
  else:
    dic[0] += 1
pre = 2
for i in range(n):
  if pre == 2:
    if dic[0] >= 1:
      dic[0] -= 1
      pre = 0
    else:
      print('Yes')
      exit()
  else:
    if dic[2] >= 1:
      dic[2] -= 1
      pre = 2
    else:
      print('No')
      exit()
print('Yes')

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




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



if b2 == 0: b4 += 1 
  
if b1 <= b4: print("Yes")
else: print("No")

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
p,q,r=0,0,0
for i in range(N):
  if a[i]%2==0:
    if a[i]%4==0:
      r+=1
    else:
      q+=1
  else:
    p+=1
if p-1<r:
  print('Yes')
elif p-1==r:
  if q==0:
    print('Yes')
  else:
    print('No')
else:
  print('No')

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

fcount=0
tcount=0

for i in range(n):
    if a[i]%4==0:
        fcount+=1
    elif a[i]%2==0:
        tcount+=1

ocount=n-(fcount+tcount)

if fcount+tcount>=n:
    print("Yes")
elif ocount<=n//2 and ocount<=fcount:
    print("Yes")
elif n%2!=0 and fcount>=n//2:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
read = sys.stdin.read
def main():
    n = int(input())
    a = list(map(int, read().split()))
    odd = 0
    div4 = 0
    div2 = 0
    for ae in a:
        odd += ae % 2 != 0
        div4 += ae % 4 == 0
        div2 += ae % 2 == 0 and ae % 4 != 0
    div2r = div2 % 2
    if odd +div2r  > div4 + 1:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
two=0
four=0
other=0
for i in range(n):
    if a[i]%4==0:
        four+=1
    elif a[i]%2==0:
        two+=1
    else:
        other+=1
if four>=two+other-1:
    print("Yes")
elif four>=two%2+other-1:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
A = tuple(map(int, input().split()))
c4 = 0
c2 = 0
cn = 0
for a in A:
    if a%4==0:
        c4 += 1
    elif a%2==0:
        c2 += 1
    else:
        cn += 1

if c2 == 0 or c2 == 1:
    if cn+c2 <= c4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if cn <= c4:
        print('Yes')
    else:
        print('No')

Solution (Python):
n, *a = map(int, open(0).read().split())
f = 0
t = 0
o = 0
for i in a:
    if i % 4 == 0:
        f += 1
    elif i % 2 == 0:
        t += 1
    else:
        o += 1
if f >= o - 1 and t == 0:
    print('Yes')
elif f >= o:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans1 = 0
ans2 = 0
ans3 = 0
for i in range(n):
    if a[i] % 4 == 0:
        ans1 += 1
    elif a[i] % 2 == 0:
        ans2 += 1
    else:
        ans3 += 1
if ans1 + 1 == ans3 and ans2 == 0:
    print("Yes")
elif ans1 >= ans3:
    print("Yes")
else:
    print("No")

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

b1 = 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:
      b1 += 1
if b2 == 0:
   b4 += 1
if b1 <= b4:
   print('Yes')
else:
   print('No')

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
f=0
t=0
z=0
for i in range(n):
    if a[i]%4==0:
        f+=1
    elif a[i]%2==0:
        t+=1
    else:
        z+=1
flg=False
if t==0 and z-1<=f:
    flg=True
if z<=f and t>0:
    flg=True
if flg:
    print("Yes")
else:
    print("No")

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

even4, even, odd = 0, 0, 0
for i in a:
    if i % 4 == 0:
        even4 += 1
    elif i % 2 == 0:
        even += 1
    else:
        odd += 1

if N % 2 == 0:
    if even4 >= odd:
        print("Yes")
    else:
        print("No")
else:
    if even4 >= odd - 1:
        print("Yes")
    else:
        print("No")

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

cnt = 0
cnt1 = 0
for i in range(len(a)):
    if(a[i]%4==0):
        cnt += 1
    elif(a[i]%2 == 0):
        cnt1 += 1

if(cnt+cnt1//2 >= N//2):
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
a,b,c=0,0,0
ans='No'
for i in x:
  if i%4==0:
    a+=1
  elif i%2==0:
    b+=1
  else:
    c+=1
if n%2==1:
  if c-a==1:
    if b==0:
      ans='Yes'
  elif a>=c:
    ans='Yes'
else:
  if a>=c:
    ans='Yes'
print(ans)

Solution (Python):
N = input()
L = list(map(int,input().split()))
n=0
m=0
p=0
for a in range(int(N)):
  if L[a]%2 != 0:
    n+=1
  elif L[a]%2 == 0 and L[a]%4 != 0:
    m+=1
  else:
    p+=1
if int(N)%2==1 and (n>p+1 or p==0 and n==1):
  print("No")
elif int(N)%2==0 and n>p:
  print("No")
else:
  print("Yes")

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
b1 = 0
b2 = 0
b4 = 0
for i in range(n):
    c = 0
    while a[i] % 2 == 0:
        c += 1
        a[i] /= 2
    if c == 0:
        b1 += 1
    elif c == 1:
        b2 += 1
    else:
        b4 += 1
if b2 == 0:
    if b1 <= b4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if b1 <= b4:
        print('Yes')
    else:
        print('No')

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    
    if a[i]%2 == 0 and a[i]%4 != 0:
        count2 += 1
    
    elif a[i]%4 == 0:
        count4 += 1

if count4 != 0:
    count4 = count4*2

if count2 >= 2:
    count4 += count2-1

if count4 >= n-1:
    print("Yes")
else:
    print("No")

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

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

t_4 = 0
t_2 = 0
for i in a:
  if i%4==0:
    t_4+=1
  elif i%2==0:
    t_2+=1
other = len(a)-t_4-t_2
if other <= t_4:
  print("Yes")
elif other == t_4 +1:
  if t_2 > 0:
    print("No")
    exit()
  else:
    print("Yes")
    exit()
else:
  print("No")

Solution (Python):
N = int(input())
a = list(input().split())
A = [int(a[i]) for i in range(N)]
count_4 = 0
count_2 = 0
count_o = 0

for i in range(N):
    if A[i] % 4 == 0:
        count_4 += 1
    elif A[i] % 2 == 0:
        count_2 += 1
    else:
        count_o += 1

if count_4 < count_o + (1 if count_2 >= 1 else 0) - 1:
    print('No')
else:
    print('Yes')

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

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

if n == two:
    print("Yes")
elif four/(n - two) >= 0.5:
    print("Yes")
elif four/(n - 1) >= 0.5:
    print("Yes")
else:
    print("No")

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

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

if N//2<=x+y//2:
  print("Yes")
else:
  print("No")