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_odd = 0
cnt_4 = 0
for a in A:
    if a % 2 != 0:
        cnt_odd += 1
    elif a % 4 == 0:
        cnt_4 += 1
if cnt_odd + cnt_4 == N and cnt_odd -1 == cnt_4:
    print('Yes')
else:
    print('Yes' if cnt_4 >= cnt_odd else 'No')

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

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

if 2*X[2] + 1 >= N:
  print("Yes")
elif 2*X[2] + X[1]>= N:
  print("Yes")
else:
  print("No")

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

Solution (Python):
from collections import deque

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

cnt_2 = 0
cnt_4 = 0
for i in range(n):
    a = A[i]
    if a%4==0:
        cnt_4+=1
    elif a%2==0:
        cnt_2+=1
cnt_else = n-cnt_2-cnt_4
cnt_else += cnt_2%2

if cnt_else-1 <= cnt_4:
    print("Yes")
else:
    print("No")

Solution (Python):

"""
Created on Sun Sep 27 02:20:18 2020

@author: liang
"""

N = int(input())
A = [int(x) for x in input().split()]

c0 = 0
c4 = 0
for a in A:
    if a%2 == 1:
        c0 += 1
    elif a%4 == 0:
        c4 += 1

if c0 <= c4:
    print("Yes")
else:
    if c0 + c4 == N and c0 == c4 + 1:
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import defaultdict

d = defaultdict(int)
d=[0]*3
n = int(input())

for i in list(map(int, input().split())):
  if i % 4 == 0:
    d[2] += 1
  elif i % 2 == 0:
    d[1] += 1
  else:
    d[0] += 1
t = d[2] - d[1]
if (d[0] <= d[2]) or ((d[0] == d[2] + 1) and (d[1] == 0)):
  print("Yes")
else:
  print("No")

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    a = i_list()

    one = 0
    b = []
    for i in a:
        if i %2 == 0:
            one += 1
            b.append(i//2)
    two = 0
    for i in b:
        if i % 2 == 0:
            two += 1
    zero = n - one
    one = n - zero - two
    if zero <= two or one == 0 and zero - two == 1:
        print("Yes")
    else:
        print("No")







if __name__=="__main__":
    main()

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

if (count + (hcount // 2)) >= (N // 2):
    print('Yes')
else:
    print('No')

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

if 2 * four + 1 >= n:
    print("Yes")
elif 2 * four + two >= n:
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
A = [min(x & -x, 4) for x in A]

CA = Counter(A)
num0 = CA[1]
num1 = CA[2]
num2 = CA[4]
if num1:
    num1 = 1
if num2 - (num1 + num0) >= -1:
    print("Yes")

else:
    print("No")

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

i1=len([i for i in A if i%2!=0])
i4=len([i for i in A if i%4==0])
i2=min(1,N-i1-i4)


print('Yes' if (i1+i2-1)<=i4 else 'No')

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

if x<=y:
  print("Yes")
else:
  if x+y==n and x==y+1:
    print("Yes")
  else:
    print("No")

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
t = [0 for _ in range(3)]

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

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

Solution (Python):









import os
import sys




def main():
    n = int(input())
    A = list(map(int, input().split()))
    A_4 = [x for x in A if x % 4 == 0]
    A_2 = [x for x in A if x % 4 != 0 and x % 2 == 0]
    A_0 = [x for x in A if x % 2 != 0]
    if len(A_2) == 0 and len(A_0) <= len(A_4) + 1:
        print("Yes")
    elif len(A_0) <= len(A_4):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

Solution (Python):
with open(0) as f:
    N, *a = map(int, f.read().split())
i, j, k = 0, 0, 0
for x in a:
    if x%4 == 0:
        i += 1
    elif x%2 == 0:
        j += 1
    else:
        k += 1
    
if j > 0:
    k += 1
print('Yes' if k <= i+1 else 'No')

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

if zero>two+1:
    print("No")
elif zero==two+1:
    if zero+two==N:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

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

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

num2 = 0
num4 = 0
odd = 0
for i in a:
    if i % 4 == 0:
        num4 += 1
        continue
    elif i % 2 == 0:
        num2 += 1
        continue
    else:
        odd += 1
        continue
if odd<=num4 or (N%2==1 and num4==N//2):
    print('Yes')
else:
    print('No')

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

two = 0
four = 0
odd = 0

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

N -= max(0, two - 1)

print("Yes" if four >= N // 2 else "No")

Solution (Python):
n = int(input())
an = [int(num) for num in input().split()]

one,two,four = 0, 0, 0
for a in an:
  if a%4 == 0:
    four += 1
  elif a%2 == 0:
    two += 1
  else :
    one += 1
    
if two == 0 and four >= one - 1 :
  print("Yes")
elif four >= one :
  print("Yes")
else :
  print("No")

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

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

ddict = defaultdict(lambda: 0)





n = I()
a = RI()

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

if ddict[4]>=floor(n/2):
    print("Yes")
elif ddict[2]>=(n-ddict[4]*2):
    print("Yes")
else:
    print("No")

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

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 10 100"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
1 2 3 4"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """3
1 4 1"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2
1 1"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """6
2 7 1 8 2 8"""
        output = """Yes"""
        self.assertIO(input, output)


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

    Q = 0
    E = 0
    O = 0
    for a in A:
        if a % 4 == 0:
            Q += 1
        elif a % 2 == 0:
            E += 1
        else:
            O += 1

    if N-2*Q <= 0 or (N-2*Q) == 1 or N-2*Q == E:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    
    resolve()

Solution (Python):
def even(x):
    flag1 = False
    if x % 2 == 0:
        flag1 = True
    return flag1


def multiple_of_4(x):
    flag2 = False
    if x % 2 == 0:
        x //= 2
        if x % 2 == 0:
            flag2 = True
    return flag2


def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    flag = False

    multiple_of_4_count = 0
    for i in range(n):
        if multiple_of_4(a_lst[i]):
            multiple_of_4_count += 1

    if multiple_of_4_count >= n // 2:
        flag = True
    else:
        even_count = 0
        for i in range(n):
            if even(a_lst[i]):
                even_count += 1
        tmp = n - 2 * multiple_of_4_count
        even_count -= multiple_of_4_count

        if even_count >= tmp:
            flag = True

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


if __name__ == '__main__':
    main()

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

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





if n-num4*2 <= 1:
    print("Yes")
elif n-num4*2 <= num2:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
c2 = 0
c4 = 0
for i in range(N):
    if a[i]%4 == 0:
        c4 += 1
    elif a[i]%2 == 0:
        c2 += 1
f = c4 * 2 + 1
if f >= N or f + c2 - 1 >= N:
    print("Yes")
else:
    print("No")

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

A_num=0
B_num=0
C_num=0

for i in a:
    if i%4==0:
        C_num+=1
    elif i%2==0:
        B_num+=1
    else:
        A_num+=1

def ans():
    if A_num==1:
        if C_num>=1:
            return True
        return False
    else:
        if n==2*A_num-1:
            if C_num==A_num-1:
                return True
            return False

        elif n<2*A_num-1:
            return False
        else:
            if C_num>=A_num:
                return True
            return False
if ans():
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    n_odd = 0
    n_4mul = 0
    n_2mul = 0
    for a in A:
        if a % 2 == 1:
            n_odd += 1
        elif a % 4 == 0:
            n_4mul += 1
        else:
            n_2mul += 1
    if n_odd == 0:
        print('Yes')
    elif n_odd <= n_4mul and n_2mul > 0:
        print('Yes')
    elif n_odd == n_4mul + 1 and n_2mul == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

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

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

if num1 <= num4:
    print('Yes')
elif num1 == num4 + 1 and num2 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    n = int(input())
    a = [int(an) for an in input().split()]
    exist2 = False
    not4 = 0
    count4 = 0
    for an in a:
        if an % 2 == 0:
            if an % 4 == 0:
                count4 += 1
            else:
                if not exist2:
                    exist2 = True
                    not4 += 1
        else:
            not4 += 1
    print('Yes' if count4 >= not4 - 1 else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n = int(input())
    a = [int(an) for an in input().split()]
    exist2 = False
    not4 = 0
    count4 = 0
    for an in a:
        if an % 2 == 0:
            if an % 4 == 0:
                count4 += 1
            else:
                if not exist2:
                    exist2 = True
                    not4 += 1
        else:
            not4 += 1
    print('Yes' if count4 >= not4 - 1 else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
lsa = list(map(int,input().split()))
ans = 'Yes'
i4 = 0
i2 = 0
i1 = 0
for i in range(N):
    if lsa[i] % 4 == 0:
        i4 += 1
    elif lsa[i] % 2 == 0:
        i2 += 1
    else:
        i1 += 1
if i4+1 < i1:
    ans = 'No'
elif i2%2 == 1 and i4+1 == i1:
    ans = 'No'
print(ans)

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

count2 = 0
count4 = 0

for a in al:
    if a % 4 == 0:
        count4 += 1
    elif a%2==0:
        count2+=1

v=count2//2

n-=v*2
if count4 >= n//2:
    ans='Yes'
else:
    ans='No'

print(ans)

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

multi_4 = 0
multi_2 = 0
odd = 0
for a in A:
    if a % 4 == 0:
        multi_4 += 1
    elif a % 2 == 0:
        multi_2 += 1
    else:
        odd += 1

if multi_2 > 0:
    if odd > multi_4:
        print('No')
    else:
        print('Yes')
else:
    if odd > multi_4 + 1:
        print('No')
    else:
        print('Yes')

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

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

odd_num = len([e for e in arr if e % 2 != 0])
four_num = len([e for e in arr if e % 4 == 0])
even_num = n - odd_num - four_num

if even_num:
    print("Yes" if four_num >= odd_num else "No")
else:
    print("Yes" if four_num >= odd_num - 1 else "No")

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

Solution (Python):


n = int(input())
a = list(map(int,input().split()))
i2 = 0
i4 = 0
for i in range(n):
    if a[i]%4==0:
        i4 += 1
    if a[i]%2==0:
        i2 += 1

if n//2 <= i4:
    print('Yes')
else:
    tmp = n//2
    if n%2==0:
        if (tmp - i4) * 2 <= (i2 - i4):
            print('Yes')
        else:
            print('No')
    else:
        if (tmp - i4) * 2 + 1 <= (i2 - i4):
            print('Yes')
        else:
            print('No')

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

Solution (Python):
N=int(input())
A = list(map(int, input().split()))
b4 = 0
b2 = 0
other = 0
for a in A:
    if a%4==0:
        b4 += 1
    elif a%2 == 0:
        b2 += 1
    else:
        other += 1

if N % 2 == 1:
    if b4 < other - 1:
        print("No")
    else:
        print("Yes")
else:
    if b4 < other:
        print("No")
    else:
        print("Yes")

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]
cnt4 = 0
cnt2 = 0
for x in a:
    if x % 4 == 0:
        cnt4 += 1
        continue
    if x % 2 == 0:
        cnt2 += 1
cnt2 = cnt2//2*2
if N-cnt2 > 2*cnt4+1:
    print('No')
else:
    print('Yes')

Solution (Python):


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

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

ok = True
if n2 == 0:
    if n4 >= n//2:
        ok = True
    else:
        ok = False
else:
    n1 = n-n2-n4
    n1 += 1
    nn = n1+n4
    if n4 >= nn//2:
        ok = True
    else:
        ok = False

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

Solution (Python):
input();a,b,c,d,r=list(map(int,input().split())),0,0,0,'NYoe s'
for i in a:
  if i%2!=0: b+=1
  elif i%4==0: c+=1
  else: d+=1
print([r[b<=c::2],r[b<=c+1::2]][d==0])

Solution (Python):
input();a,b,c,d,r=list(map(int,input().split())),0,0,0,'NYoe s'
for i in a:
  if i%2!=0: b+=1
  elif i%4==0: c+=1
  else: d+=1
print([r[b<=c::2],r[b<=c+1::2]][not d])

Solution (Python):
input();a,b1,b2,b4,r=list(map(int,input().split())),0,0,0,'NYoe s'
for i in a:
  if i%2!=0: b1+=1
  elif i%4==0: b4+=1
  else: b2+=1
print([r[b1<=b4::2],r[b1<=b4+1::2]][not b2])

Solution (Python):
input();a,b1,b2,b4=list(map(int,input().split())),0,0,0
for i in a:
  if i%2!=0: b1+=1
  elif i%4==0: b4+=1
  else: b2+=1
print(['NYoe s'[b1<=b4::2],'NYoe s'[b1<=b4+1::2]][not b2])

Solution (Python):
input();a,b1,b2,b4=list(map(int,input().split())),0,0,0
for i in a:
  if i%2!=0: b1+=1
  elif i%4==0: b4+=1
  else: b2+=1
print('Yes'if b1<=b4 else'No'if b2 else'Yes'if b1<=b4+1 else'No')

Solution (Python):
input();a=list(map(int,input().split()))
b1,b2,b4=0,0,0
for i in a:
  if i%2!=0: b1+=1
  elif i%4==0: b4+=1
  else: b2+=1
print('Yes' if b1<=b4 else 'No' if b2 else 'Yes' if b1<=b4+1 else 'No')

Solution (Python):
input();a=list(map(int,input().split()))
b1,b2,b4=0,0,0
for i in a:
  if i%2!=0: b1+=1
  elif i%4==0: b4+=1
  elif i%2==0: b2+=1
print('Yes' if b1<=b4 else 'No' if b2 else 'Yes' if b1<=b4+1 else 'No')

Solution (Python):
input();a=list(map(int,input().split()))
b1,b2,b4=[],[],[];ans=''
for i in a:
  if i%2!=0:
    b1.append(i)
  elif i%4==0:
    b4.append(i)
  elif i%2==0:
    b2.append(i)
if b2:
  if len(b1)<=len(b4):
    ans='Yes'
  else:
    ans='No'
else:
  if len(b1)<=len(b4)+1:
    ans='Yes'
  else:
    ans='No'
print(ans)

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

cnt2 = 0
cnt4 = 0
cntodd = 0
for i in a:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1
    else:
        cntodd += 1

if cnt2 == 0 and cnt4 + 1 >= cntodd:
    ans = 'Yes'
elif cnt4 >= cntodd:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Solution (Python):
n=int(input()) 
c=list(map(int, input().split()))
a = 0
a2 = 0
a4 = 0

for i in c:
    if i%2 != 0:
        a += 1
    if i%2 == 0 and i%4 != 0:
        a2 += 1
    if i%4 == 0:
        a4 += 1
if a == 0 :
    print('Yes')
if a > 0 and a2 == 0:
    if a <= a4 +1 :
        print('Yes')
    else:
        print('No')
if a > 0 and a2 > 0:
    if a <= a4 :
        print('Yes')
    else:
        print('No')

Solution (Python):
N = int(input())
a = list(map(int,input().rstrip().split(" ")))
counter = [0,0,0]
for i in a:
    if i % 4 == 0:
        counter[2] += 1
    elif i % 2 == 0:
        counter[1] += 1
    else:
        counter[0] += 1
counter[0] += min(1,counter[1])

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

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

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

if y%2+z-1 <= x: print("Yes")
else: print("No")

Solution (Python):
bai4_count=0
bai2_count=0
no = 0

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

for i in range(N):
    if a[i]%4==0:
        bai4_count+=1
    elif a[i]%2==0:
        bai2_count+=1
    else:
        no+=1
ans = False
if bai2_count>0:
    if bai4_count >= no:
        ans=True
    else:
        ans=False
else:
    if bai4_count+1 >= no:
        ans=True
    else:
        ans=False

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

Solution (Python):
import sys

n=int(input())
a=[int(x) for x in input().rstrip().split()]

even=0
odd=0
num4=0
for i in a:
  if i%4==0:
    num4+=1
    continue

  elif i%2==0:
    even+=1
  else:
    odd+=1


if odd<=num4:
  print("Yes")
elif odd-1==num4 and even==0:
  print("Yes")
elif odd==0 and 2<=even:
  print("Yes")
else:
  print("No")

Solution (Python):
import math
N = int(input())
A = list(map(int, input().split()))
count = []
for i in A:
    if i%4 == 0:
        count.append("4")
    elif i%2 == 0:
        count.append("2")
    else:
        count.append("1")
B1 = count.count("4")
B2 = count.count("1")
if count.count("2") == 0:
    print("Yes" if B1+1 >= B2 else "No")
else:
    print("Yes" if B1 >= B2 else "No")

Solution (Python):
def main():
    n = int(input())
    inlis = list(map(int, input().split()))

    num2 = 0
    num4 = 0

    for i in range(n):
        a = inlis[i]
        if a % 4 == 0:
            num4 += 1
        elif a % 2 == 0:
            num2 += 1
    if n <= 3:
        if num4 >=1:
            print('Yes')
        elif num2 == n:
            print('Yes')
        else:
            print('No')
    else:
        if num2 + (2*num4) >= n:
            print("Yes")
        else:
            if n % 2 != 0 and num2 + (2*num4 +1) >= n:
                print('Yes')
            else:
                print('No')





if __name__ == "__main__":
    main()

Solution (Python):

N = int(input())
N_List = list(map(int,input().split()))
Four_List = [i for i in N_List if i % 4 == 0]
Two_List = [i for i in N_List if i % 2 == 0]
if len(Two_List)-len(Four_List) > 0:
    N = N - (len(Two_List) - len(Four_List)) + 1

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

Solution (Python):
n = int(input())
a_ls = list(map(int, input().split()))
n_4k = 0
n_2k = 0
n_odd = 0
for i in range(n):
    if a_ls[i] % 4 ==0:
        n_4k += 1
    elif a_ls[i] % 2 ==0:
        n_2k += 1
    else:
        n_odd += 1
res = 'No'
if n_odd == 0:
    res = 'Yes'
else:
    if n_2k > 0:
        if n_odd <= n_4k:
            res = 'Yes'
    else:
        if n_odd <= n_4k+1:
            res = 'Yes'
print(res)

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

m_2_but_4 = 0
m_4 = 0
m_none = 0
for i in range(len(A)):
  if A[i] % 4 == 0:
    m_4 += 1
  elif A[i] % 2 == 0:
    m_2_but_4 += 1
  else:
    m_none += 1

if m_2_but_4:
  print("Yes") if m_4 >= m_none else print("No")
else:
  print("Yes") if m_4 + 1 >= m_none else print("No")

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
lis = []
x = 0
y = 0
z = 0
for i in range(n):
    if li[i] % 4 == 0:
        x += 1
    elif li[i] % 2 == 0:
        y = 1
    else:
        z += 1
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, b = 0, 0
for i in map(int, input().split()):
    if i % 4 == 0:
        a += 1
    elif i % 2 == 0:
        b += 1
c = n - a - b
if b == 0:
    if a + 1 < c:
        print("No")
    else:
        print("Yes")
else:
    if a < c:
        print("No")
    else:
        print("Yes")

Solution (Python):
import math
N = int(input())
A = list(map(int,input().split()))
l = list()
ll = list()
for i in range(len(A)):
  if A[i]%4 == 0:
    l.append(A[i])
  if A[i]%2 == 0:
    ll.append(A[i])
four = len(l)
two = len(ll)-four
zero = N-two
a = math.floor(N/2)
if a <= four:
  print("Yes")
elif 2*a-two <= 2*four:
  print("Yes")
else:
  print("No")

Solution (Python):
import math
N = int(input())
A = list(map(int,input().split()))
l = list()
ll = list()
for i in range(len(A)):
  if A[i]%4 == 0:
    l.append(A[i])
  if A[i]%2 == 0:
    ll.append(A[i])
four = len(l)
two = len(ll)-four
zero = N-two
a = math.floor(N/2)
if a <= four:
  print("Yes")
elif a-two/2 <= four:
  print("Yes")
else:
  print("No")

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

four = 0
two = 0

for i in range(len(A)):
  if A[i]%4 == 0:
    four += 1
  if A[i]%2 == 0:
    two += 1
n = math.floor(N/2)
two -= four
x = (n - four) * 2


if four >= n:
  print("Yes")
elif two >= x:
  print("Yes")
else:
  print("No")

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
four = 0
two = 0
for i in range(n):
    if A[i]%4 == 0:
        four += 1
    elif A[i]%2 == 0:
        two += 1
print('Yes' if four + two//2 >= n//2 else '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 >= n//2:
    print('Yes')
elif 2 * cnt4 >= n - cnt2:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
k = 0
g = 0
for i in a:
  if(i%4 == 0):g+=1
  if(i%2 == 1):k+=1

if(g>=k or (g+1>=k and g+k==n)):print("Yes")
else:print("No")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
bai4 = []
bai2 = []
bai_ = []
for ai in a:
    if ai % 4 == 0:
        bai4.append(ai)
    elif ai % 2 == 0:
        bai2.append(ai)
    else:
        bai_.append(ai)

len_bai_ = len(bai_)
len_bai2 = len(bai2)
len_bai4 = len(bai4)


if len_bai_ > len_bai4:
    if len_bai_ == len_bai4 + 1 and n == len_bai_ + len_bai4:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

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

n4,n2=0,0
for i in range(N):
  if a[i] % 4 == 0:n4 += 1
  elif a[i] % 2 == 0:n2 += 1
    
if n4 >= N//2:print('Yes')
elif n4*2 + n2 >= N:print('Yes')
else:print('No')

Solution (Python):

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

p,h = 0, [[2,1,0],[1],[0]] 
while(n):
	for u in h[p] + [-1]:
		if u == -1: 
			p =-1
			break
		if cc[u] > 0:
			p = u
			cc[u] -=1
			n -=1
			break
	if p == -1: break

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

Solution (Python):

import collections
n,ais = int(raw_input()), map(int, raw_input().split())
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,h = collections.deque([0]), [[2,1,0],[1],[0]] 
while(n):
	b = False
	for u in h[q[-1]] + [-1]:
		if u == -1: b = True
		if cc[u] > 0:
			q.append(u)
			
			cc[u] -=1
			n -=1
			break
	if b: break

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

Solution (Python):

import collections
n,ais = int(raw_input()), map(int, raw_input().split())
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,h = collections.deque([0]), [[2,1,0],[1],[0]] 
while(n):
	b = False
	for u in h[q[-1]] + [-1]:
		if u == -1: b = True
		if cc[u] > 0:
			q.append(u)
			q.popleft()
			cc[u] -=1
			n -=1
			break
	if b: break

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