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())
A = list(map(int, input().split()))

cnt_1 = 0 
cnt_2 = 0 

for i in range(N):
    if A[i] % 4 == 0:
        cnt_1 += 1
    elif A[i] % 2 != 0:
        cnt_2 += 1

if (N % 2 == 0 and cnt_1 >= cnt_2) or (N % 2 != 0 and cnt_1 >= cnt_2 - 1):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
odd_count = 0
mo4_count = 0 
for i in map(int, input().split()):
  if i % 2 == 1:
    odd_count += 1
  elif i % 4 == 0:
    mo4_count += 1
if odd_count - N % 2 <= mo4_count:
  print('Yes')
else:
  print('No')

Solution (Python):
n = int(input())
li = list(map(int, input().split()))
yon = 0
ni  = 0
ki = 0
for a in li:
    if a % 4 == 0:
        yon += 1
        continue
    if a % 2 == 0:
        ni += 1
    else:
        ki += 1

if ni > 0:
    if yon >= ki:
        print('Yes')
    else:
        print('No')
elif ni == 0:
    if yon >= ki-1:
        print('Yes')
    else:
        print('No')

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in A:
  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())
ls = list(map(int, input().split()))
l0 = [n for n in ls if n % 2 == 0]
n2 = len([n for n in l0 if n % 4 != 0])
n4 = len([n for n in l0 if n % 4 == 0])
n = n - n2 if n2 % 2 == 0 else n - n2 + 1
if n <= n4 * 2 + 1:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
count0 = 0
count2 = 0
count4 = 0

for i in range(n):
    if a[i]%2 == 1:
        count0 += 1
    elif a[i]%4 == 0:
        count4 += 1
    else:
        count2 += 1

if count2 > 0:
    N = n - (count2 - 1)
else:
    N = n

if N//2 <= count4:
    print("Yes")
else:
    print("No")

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

is_odd = 0
is_even = 0
is_4 = 0
ans = "Yes"
for a in A:
  if a % 4 == 0:
    is_4 += 1
  elif a % 2 == 0:
    is_even += 1
  else:
    is_odd += 1

if is_odd - is_4 > 1:
  ans = "No"
elif is_odd - is_4 == 1 and is_even > 0:
  ans = "No"

print(ans)

Solution (Python):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    m4 = [ai for ai in a if ai % 4 == 0]
    m2 = [ai for ai in a if ai % 2 == 0 and ai % 4 != 0]
    if 2 * len(m4) + 1 >= n:
        print("Yes")
    elif 2 * len(m4) + len(m2) >= n:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
a = map(int, input().split())
num4 = 0
num1 = 0
for i in a:
    if i % 4 == 0:
        num4 += 1
        continue
    if i % 2 == 1:
        num1 += 1
plus, minus = num4 + num1, num4 - num1
if minus >= 0 or minus == -1 and plus % 2 == 1 and n - plus == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = map(int, input().split())
num4 = 0
num1 = 0
for i in a:
    if i % 4 == 0:
        num4 += 1
        continue
    if i % 2 == 1:
        num1 += 1
if num4 >= num1 or num4 + 1 == num1 and (num4 + num1) % 2 == 1 and n - (num4 + num1) == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = map(int, input().split())
num4 = 0
num1 = 0
for i in a:
    if i % 4 == 0:
        num4 += 1
        continue
    if i % 2 == 1:
        num1 += 1
if num4 >= num1:
    print("Yes")
elif num4 + 1 == num1 and (num4 + num1) % 2 == 1 and n - (num4 + num1) == 0:
    print("Yes")
else:
    print("No")

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

check4=0
check2=0
for i in a:
    if i%4==0:
        check4+=1
        continue
    if i%2==0:
        check2+=1
if n==check2:
    ans='Yes'
elif check2<=1:
    if n//2<=check4:
        ans='Yes'
    else:
        ans='No'
else:
    n=n-check2
    if -(-n//2)<=check4:
        ans='Yes'
    else:
        ans='No'
print(ans)

Solution (Python):
N = int(input())
aList = list(map(int,input().split()))
oddnum = len(list(filter( lambda x: x % 2==1, aList)))
fournum = len(list(filter( lambda x: x % 4==0, aList)))

check = False
if oddnum == 0:
    check = True
elif oddnum <= fournum:
    check = True
elif oddnum - 1 == fournum and (oddnum + fournum) == N:
    check = True
else:
    check = False
print( 'Yes' if check else 'No')

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

o = 0
f = 0
t = 0
for i in a:
  if i % 2 == 1:
    o += 1
  if i % 4 == 0:
    f += 1
  if i % 4 == 2:
    t += 1
if f >o-1:
  print('Yes')
elif f == o-1 and t==0:
  print('Yes')
else:
  print('No')

Solution (Python):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
counter = Counter()

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

ans = 'No'
if counter[1] == 0 and counter[2] == 0:
    ans = 'Yes'
elif counter[1] == counter[4]:
    ans = 'Yes'
elif counter[2] == 0:
    if counter[1] == counter[4] + 1:
        ans = 'Yes'

print(ans)

Solution (Python):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
counter = Counter()

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

ans = 'No'
if counter[1] == 0 and counter[2] == 0:
    ans = 'Yes'
if counter[1] == counter[4]:
    ans = 'Yes'
if counter[2] == 0:
    if counter[1] == counter[4] + 1:
        ans = 'Yes'

print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
div4 = 0
div2 = 0
for i in a:
  if i % 4 == 0:
    div4 += 1
  elif i % 2 == 0:
    div2 += 1
if div2 == 0:
  if n - div4 <= div4 + 1:
    print("Yes")
  else:
    print("No")
else:
  if n - div4 - div2 <= div4:
    print("Yes")
  else:
    print("No")

Solution (Python):
N = int(input())
def d(n):
  if n % 2 == 1:
    return 0
  elif n % 4 == 0:
    return 2
  elif n % 2 == 0:
    return 1
  else:
    return 0
  
dic = {0:0, 1:0, 2:0}
for a in [int(x) for x in input().split()]:
  dic[d(a)] += 1
ret = 'No'
c = 1
if dic[1]:
  c = 0
if dic[0] <= dic[2] + c:
  ret = 'Yes'
print(ret)

Solution (Python):
from collections import Counter as C 
n=int(input())
A=list(map(int,input().split()))+[0,1,2,3]
A=sorted(C(list(map(lambda x:x%4,A))).most_common())
if A[2][1]==1:
  print('Yes' if A[0][1]+2>=A[1][1]+A[3][1] else 'No')
else:
  print('Yes' if A[0][1]+1>=A[1][1]+A[3][1] else 'No')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
m4 = 0
m2 = 0
for i in range(n):
    if a[i] % 4 == 0:
        m4 += 1
    elif a[i] % 2 == 0:
        m2 += 1
import math
if m4 >= math.ceil(n//2):
    print("Yes")
elif m2 >= 2 * (math.ceil(n//2) - m4):
    print("Yes")
else:
    print("No")

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    ls = [0] * n
    a = list(map(int, input().rstrip('\n').split()))
    for i, v in enumerate(a):
        t = v
        while True:
            if t % 2 == 0:
                ls[i] += 1
                t //= 2
                if ls[i] == 2:
                    break
            else:
                break
    if len(ls) % 2 == 0:
        print("Yes" if ls.count(2) >= ls.count(0) else "No")
    else:
        print("Yes" if ls.count(2) >= ls.count(0) - 1 else "No")


if __name__ == '__main__':
    slove()

Solution (Python):


N = int(input().split()[0])
a_list = list(map(int, input().split()))
c = {'odd': 0,
     'even': 0,
     'four': 0,
     'even_not_four': 0}

for x in a_list:
    if x % 2 == 0:
        c['even'] += 1
    else:
        c['odd'] += 1

    if x % 4 == 0:
        c['four'] += 1

ans = 'No'

if c['even'] == N:
    ans = 'Yes'
else:
    if c['odd'] == 1:
        if c['four'] >= 1:
            ans = 'Yes'
    else:
        if c['even'] - c['four'] >= 1:
            if c['four'] >= c['odd']:
                ans = 'Yes'
        else:
            if c['four'] >= c['odd'] - 1:
                ans = 'Yes'

print(ans)

Solution (Python):
N,*A=map(int,open(0).read().split());l=[0]*4
for a in A:l[a&3]+=1
o=l[1]+l[3];print("YNeos"[o>1+l[0]or o-1==l[0]and l[2]>0::2])

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
v1 = 0
v2 = 0
v4 = 0
for i in a:
    if i % 4 == 0:
        v4 += 1
    elif i % 2 == 0:
        v2 += 1
    else:
        v1 += 1

if v4 >= (v1 + v2 - 1):
    print("Yes")
else:
    if (v4 >= v1) and (v2 >= 2):
      print("Yes")
    else:
      print("No")

Solution (Python):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = inp()
a = inpl()
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 (cnt4+1 == cnt_ and cnt2 == 0) or cnt4 >= cnt_  or cnt2 == n:
    print('Yes')
else:
    print('No')

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

bi = [a for a in A if a % 2 == 0]
qu = [b for b in bi if b % 4 == 0]

num_4 = len(qu)
num_2 = len(bi) - num_4

if num_2 >= 1:
	if N-num_2 <= num_4*2 or N <= num_4*2+1:
		print("Yes")
	else:
		print("No")
else:
	if N-num_2 <= num_4*2+1:
		print("Yes")
	else:
		print("No")

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

num4=0
num2=0
num1=0
for a in arr:
    if a%4==0:
        num4 += 1
    elif a%2==0:
        num2 += 1
    else:
        num1 += 1

if num4 >= n//2:
    print("Yes")
else:
    if num4 >= num1:
        print("Yes")
    else:
        print("No")

Solution (Python):
N = int(input())
oddCount = 0
mo4Count = 0
for i in map(int, input().split()):
  if i % 2 == 1:
    oddCount += 1
  elif i % 4 == 0:
    mo4Count += 1
if oddCount - N % 2 <= mo4Count:
  print('Yes')
else:
  print('No')

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = LI()
f = len([i for i in L if not i % 4])
t = len([j for j in L if not j % 2]) - f
if (t and n > t + f * 2) or (not t and n > f * 2 + 1):
    print('No')
else:
    print('Yes')

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

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

odd = []
even2 = []
even4 = []

for ai in a:
    if ai%4==0:even4.append(ai)
    elif ai%2==0:even2.append(ai)
    else:odd.append(ai)
if len(even4)>=len(odd):print('Yes')
elif len(even4)+1==len(odd) and len(even2)==0:print('Yes')
else:print('No')

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: int, a: "List[int]"):
    ans = [0] * N
    for i in range(N):
        if(a[i]%4 == 0):
            ans[i] = 4
        elif(a[i]%2 == 0):
            ans[i] = 2
        else:
            ans[i] = 1

    if(ans.count(1) > ans.count(4)+1):
        print(NO)
    else:
        if(ans.count(1) == ans.count(4)+1):
            if(ans.count(2) == 0):
                print(YES)
            else:
                print(NO)
        else:
            print(YES)
    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))  
    a = [int(next(tokens)) for _ in range(N)]  
    solve(N, a)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
a_4 = [i for i in a if i%4 == 0]
a_2 = [i for i in a if i%2 == 0]
a_4_len = len(a_4)
a_2_not4_len = len(a_2) - a_4_len
if a_4_len >= N//2:
    print("Yes")
elif a_2_not4_len >= (N - a_4_len*2):
    print("Yes")
else:
    print("No")

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

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

    count_4 = 0
    count_2 = 0
    for i in range(N):
        if a[i]%4 == 0:
            count_4 += 1
        elif a[i]%2 == 0:
            count_2 += 1
    odd = N - count_4 - count_2
    if count_2 == 0:
        if odd - 1 <= count_4:
            print("Yes")
        else:
            print("No")
    else:
        if odd <= count_4:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()

Solution (Python):
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1

print('Yes' if (a_4+1) >= (a_1+a_2) else 'No')

Solution (Python):
n = int(input())
from collections import Counter


def calccnt(v):
    cnt = 0
    for _ in range(2):
        if v % 2 == 0:
            cnt += 1
            v = v // 2
    return cnt


cnt = Counter([calccnt(int(_)) for _ in input().split()])

if cnt[0] > 0:
    if cnt[0] > cnt[2] + 1:
        print('No')
        exit()
    if cnt[0] == cnt[2] + 1 and cnt[1] > 0:
        print('No')
        exit()
if n==1 and cnt[1]:
    print('No')
else:
    print('Yes')

Solution (Python):
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
aaa = na()
ct1 = 0
ct2 = 0
for a in aaa:
    if a % 4 == 0:
        ct1 += 1
    elif a % 2 == 0:
        ct2 += 1
rs = len(aaa) - ct1 - ct2
rs += ct2 % 2
if rs > ct1 + 1:
    print('No')
else:
    print('Yes')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
num_2 = 0
num_4 = 0
odd = 0

for i in range(N):
    if A[i] % 2 != 0:
        odd += 1
    elif A[i] % 4 == 0:
        num_4 += 1
    else:
        num_2 += 1

if num_2 == 0:
    if odd - 1 <= num_4:
        print('Yes')
    else:
        print('No')
else:
    if odd <= num_4:
        print('Yes')
    else:
        print('No')

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

No = 0
N2 = 0
N4 = 0

for i in A:
    if i % 4 == 0:
        N4 += 1
    elif i % 2 == 0:
        N2 += 1
    else:
        No += 1

ans = "No"

if N2 == 0 and No <= N4+1:
    ans = "Yes"
elif No <= N4:
    ans = "Yes"

print(ans)

Solution (Python):

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

T = [0, 0, 0]

for i in range(n):
    if A[i] % 4 == 0:
        T[0] += 1
    elif A[i] % 2 == 0:
        T[1] += 1
    else:
        T[2] += 1

if (T[1] == 0 and T[0] >= T[2] - 1) or (T[1] > 0 and T[0] >= T[2]):
    print("Yes")
else:
    print("No")

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

for a in A:
    if a % 4 == 0:
        cn4 += 1
    elif a % 2 == 0:
        cn2 += 1

if N // 2 <= cn4:
    print("Yes")
    exit()
if N - cn4*2  <= cn2:
    print("Yes")
else:
    print("No")

Solution (Python):
import fractions

n=int(input())
a=list(map(int, input().split()))
count=0

if n%2==1:
    for i in range(n):
        if a[i]%4==0:
            count+=1
    if count>=n//2:
        print('Yes')
        exit()
count=0
    
for i in range(n):
    if a[i]%4==0:
        count+=2
    elif a[i]%2==0:
        count+=1
    else:
        continue

if count>=n:
    print('Yes')
else:
    print('No')

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)




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

x4 = odd = 0
for a in A:
    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())
A = list(map(int,input().split()))
cnt4 = 0
cnt2 = 0
for x in A:
    if x%4 == 0:
        cnt4 += 1
    elif x%2 == 0:
        cnt2 += 1
if cnt4 >= N//2:
    print("Yes")
elif cnt2 >= N-2*cnt4:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
c2=0
c4=0
c=0
for i in a:
    if i%4==0:
        c4+=1
    elif i%2==0:
        c2+=1
    else:
        c+=1

if c==0 or c+c2-1<=c4 or c<=c4:
    print("Yes")
else:
    print("No")

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

b2 = 0
b4 = 0
for a in A:
    if a % 2 == 0:
        b2 += 1

    if a % 4 == 0:
        b4 += 1

b2 -= b4

while b2 > 1:
    b2 -= 2
    
    b4 += 1

N -= b4*2+1

if N <= 0:
    print("Yes")
else:
    print("No")

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

bai2 = 0
bai4 = 0
bai1 = 0

for i in range(n):
    if a[i] % 4 == 0:
        bai4 += 1
    elif a[i] % 2 == 0:
        bai2 = 1
    else:
        bai1 += 1

if bai1 == 0:
    print('Yes')
    exit()
        
if (bai4+1) >= (bai2 + bai1):
    print('Yes')
else:
    print('No')

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

ans = False

if count[0] + (count[1] % 2) <= count[2] + 1:
    ans = True

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

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
b,c,d=0,0,0
for i in range(N):
    if a[i]%2:
        b+=1
    elif not a[i]%4:
        c+=1
    else:
        d+=1
if b<=c+1 and d==0:
    print("Yes")
elif b<=c:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = [int(s) for s in input().split()]
mod4 = [a % 4 for a in A]
a1 = mod4.count(1) + mod4.count(3)
a4 = mod4.count(0)
ans = True if a1 == a4 + 1 and a1 + a4 == N or a1 <= a4 else False
print("Yes" if ans else "No")

Solution (Python):
N = int(input())
As = list(map(int, input().split()))
n4 = 0
n2 = 0
n1 = 0
for A in As:
  if A%4 == 0:
    n4 += 1
  elif A%2 == 0:
    n2 += 1
  else:
    n1 += 1

if n4 >= n1:
  print("Yes")
elif n4 >= n1-1 and n2 == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    count4 = 0
    count1 = 0
    for a in A:
        if a % 4 == 0: count4 += 1
        if a % 2 == 1: count1 += 1
    if count4 >= count1:
        return "Yes"
    elif count4 == count1-1 and count4+count1 == N:
        return "Yes"
    return "No"

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

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

if four>=add-1:
    print('Yes')
else:
    print('No')

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

d={
    2:0,
    4: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:
    d[1]+=1

if d[1]<=d[4]+1:     
    print("Yes")
else:
    print("No")

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

d={
    2:0,
    4: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

four=d[4]
odd=d[1]
if d[2]>2:
    four+=1
    odd+=2
else:
    odd+=int((d[2]+2-1)/2)

if odd<=four+1:     
    print("Yes")
else:
    print("No")

Solution (Python):


def main(N,A):
    count4 = count2 = count = 0
    for a in A:
        if(a%4==0):
            count4 += 1
        elif(a%2==0):
            count2 += 1
        else:
            count += 1
            
    if(count2==0):
        if(count-1<=count4):
            print("Yes")
        else:
            print("No")
    else:
        if(count<=count4):
            print("Yes")
        else:
            print("No")
            
if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    main(N,A)

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

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

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

d = {0:0, 1:0, 2:0, 3:0}
for a in l:
  a = a%4
  d[a] += 1

if d[1]+d[3] > d[0]+1:
  print('No')
elif d[1]+d[3] == d[0]+1 and d[2] > 0:
  print('No')
else:
  print('Yes')

Solution (Python):
N = int(input())
A = list(map(int,input().split(' ')))
L = []
for i in A:
  if i % 2 != 0:
    L.append(0)
  elif i % 4 == 0:
    L.append(2)
  else:
    L.append(1)
if L.count(1) == 0:
  if L.count(0) -1  <= L.count(2):
    print('Yes')
  else:
    print('No')
else:
  if L.count(0) <= L.count(2):
    print('Yes')
  else:
    print('No')

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

Solution (Python):
n = int(input())
*l, = map(int,input().split())
odd=0
even=0
four=0
for i in l:
  if i%2==1:
    odd+=1
  elif i%4==0:
    four+=1
if four>=odd:
  print('Yes')
else:
  if odd-four == 1 and odd+four == len(l):
    print('Yes')
  else:
    print('No')

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

x, y, z = 0, 0, 0
for i in range(n):
    if a[i] % 4 == 0:
        x += 1
    elif a[i] % 2 == 0:
        y += 1
    else:
        z += 1

if x >= z:
    print("Yes")
elif x == z - 1 and y == 0:
    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 cnt2 == 0:
    cnt2 = 1
print("Yes" if cnt4 >= (n - (cnt2 - 1)) // 2 else 'No')

Solution (Python):
n = int(input())
a = map(int,input().split())
two = 0
one = 0
for i in a :
    if i % 4 == 0:
        two += 1
    elif i % 2 == 0:
        one += 1
zero = n - one - two
if one % 2 == 1:
    one -= 1
    zero += 1
if two+1 >= zero:
    ans = "Yes"
else:
    ans = "No"
print (ans)

Solution (Python):
from collections import defaultdict

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

modCount = defaultdict(int)

for a in A:
    modCount[a % 4] += 1

ness = modCount[1] + modCount[3] + modCount[2] % 2
if ness <= modCount[0] + 1:
    print('Yes')
else:
    print('No')

Solution (Python):
def f(n):
    n = int(n)
    if n%4 == 0:
        return 2
    elif n%2 == 0:
        return 1
    else:
        return 0

n = int(input())
a = list(map(f,input().split()))
c1 = a.count(0)
c2 = a.count(1)
c4 = n-c1-c2
if c1<=c4:
    print("Yes")
elif c1 == c4 + 1 and c2 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys
import math
INF = float("inf")


def yes():
    print("Yes")  


def no():
    print("No")  


def solve(N: int, a: "List[int]"):
    odd, even, eveven = 0, 0, 0
    for av in a:
        b = int(math.log2(av & -av))
        if b == 0:
            odd += 1
        elif b == 1:
            even += 1
        else:
            eveven += 1
    if odd > int(math.ceil(N/2)):
        no()
    elif even > 0 and odd > eveven:
        no()
    elif even == 0 and odd <= eveven:
        yes()
    else:
        yes()

    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))  
    a = [int(next(tokens)) for _ in range(N)]  
    solve(N, a)


if __name__ == '__main__':
    main()

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 == 1 or a[i] % 4 == 3:
    b1 += 1
  elif a[i] % 4 == 2:
    b2 += 1
  else:
    b4 += 1
if b2 == 0:
  if b1 - 1 > b4:
    print('No')
  else:
    print('Yes')
else:
  if b1 > b4:
    print('No')
  else:
    print('Yes')

Solution (Python):
N=int(input())
a=map(int,input().split())
odd=[]
even=[]
adj=[]
for i in a:
    if i%2:odd.append(i)
    else:even.append(i)
    if i%4==0:adj.append(i)
L=len(adj)-len(odd)
if L+1>0:
    print("Yes")
    exit()
if L==-1:
    print(["Yes","No"][len(even)-len(adj)>0])
else:print("No")

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

num4 = 0
num2 = 0
odd = 0
for i in a:
    if i%4 == 0:
        num4 += 1
    elif i%2 == 0 and i%4 != 0:
        num2 += 1
    elif i%2 == 1:
        odd += 1

if odd > num4+1:
    print("No")
else:
    if num2%2 == 1:
        if odd+1 > num4+1:
            print("No")
        else:
            print("Yes")
    else:
        print("Yes")

Solution (Python):
n,*l=map(int,open(0).read().split());o=t=0
for i in l: 
	o+=i%2
	t+=(i%4>0)
print("YNeos"[o>n-t+(t==o)::2])

Solution (Python):
n,*l=map(int,open(0).read().split());o=t=0
for i in l: 
	o+=i%2
	t+=(i%4>0)
print("YNeos"[(t>o)+o>n-t+1::2])

Solution (Python):
_,*l=map(int,open(0).read().split());o=t=0
for i in l: 
	o+=i%2
	t+=(i%4>0)
print("YNeos"[(t>o)+o>len(l)-t+1::2])

Solution (Python):
n,*l=map(int,open(0).read().split())
o=t=f=0
for i in l:
	if i%4==0:f+=1
	elif i%2==0:t+=1
	else:o+=1
print("YNeos"[(t>0)+o>f+1::2])

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

n1, n2, n4 = 0, 0, 0
for i in range(N):
    if a[i] % 2:
        n1 += 1
    elif a[i] % 4:
        n2 += 1
    else:
        n4 += 1

if n2 == 0:
    if n1 <= n4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if n1 <= n4:
        print('Yes')
    else:
        print('No')

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

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

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

d[2] = d[2] % 2

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

Solution (Python):
n = int(input())
lst = [int(i) for i in input().split()]

b1 = 0
b2 = 0
b4 = 0

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

flg = True
if b2 == 0:
    if b1 > b4 + 1:
        flg = False
else:
    if b1 > b4:
        flg = False

if flg:
    print('Yes')
else:
    print('No')

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

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

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

Solution (Python):

import sys, math, fractions, itertools

YES = "Yes"  
NO = "No"  

def solve(N: int, a: "List[int]"):
    four = len([aa for aa in a if aa % 4 == 0])
    two = len([aa for aa in a if (aa % 4 != 0 and aa % 2 == 0)])
    if two < 2:
        ex = four * 2 + 1
    else:
        ex = two + four * 2
    if ex >= N:
        print('Yes')
    else:
        print('No')
    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))  
    a = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, a)

if __name__ == '__main__':
    main()

Solution (Python):

n = int(input())
an = list(map(int,input().split()))
odds_cnt = sum(list(map(lambda x : x % 2,an)))
multiple_of_4_cnt = sum([1 if i %4==0 else 0 for i in an])
ret = "No"
if multiple_of_4_cnt >= odds_cnt or (multiple_of_4_cnt == odds_cnt-1 and odds_cnt+multiple_of_4_cnt==n):
    ret = "Yes"
print(ret)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
D = [0]*5
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]:
        print("Yes")
    else:
        print("No")
else:
    if D[4] + 1 >= D[1]:
        print("Yes")
    else:
        print("No")

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

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

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

count_1 = 0
count_2 = 0
count_4 = 0

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

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

Solution (Python):
N = int(input())
nums = list(map(int, input().split()))
two = 0
four = 0
for num in nums:
  if num%4 == 0:
    four += 1
  elif num%2 == 0:
    two += 1
if four + two//2 >= N//2:
  print('Yes')
else:
  print('No')