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()))
odd = 0
even = 0
eveneven = 0
for a in A:
    if a % 4 == 0:
        eveneven += 1
    elif a % 2 == 0:
        even += 1
    else:
        odd += 1
        
if even == 0:
    
    if eveneven +1 >= odd:
        print('Yes')
    else:
        print('No')
else:
    
    if odd <= eveneven:
        print('Yes')
    else:
        print('No')

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
cnt_2=0
cnt_1=0
cnt_0=0

for num in a:
    if num%4==0:
        cnt_2+=1
    elif num%2==0:
        cnt_1+=1
    else:
        cnt_0+=1

if cnt_1==0:
    if cnt_2+1>=cnt_0:
        print("Yes")
    else:
        print("No")

else:
    if cnt_2>=cnt_0:
        print("Yes")
    else:
        print("No")

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

cnt_2 = 0
cnt_4 = 0
for a in A:
  if a % 4 == 0:
    cnt_4 += 1
  elif a % 2 == 0:
    cnt_2 += 1

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

Solution (Python):
import numpy as np

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

zero = sum(A % 2 != 0)  
four = sum(A % 4 == 0)  
two = sum(np.logical_and(A % 2 == 0, A % 4 != 0))  

flag = False

if two == 0:
    if zero <= four + 1:
        flag = True
else:
    if zero <= four:
        flag = True

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

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

odd = 0
double = 0
quatro = 0

for i in a:
  if i % 2 == 1:
    odd += 1
  else:
    if i % 4 == 0:
      quatro += 1
    else:
      double += 1

if double == N:
  print("Yes")
  exit()
plus = 0
if double != 0:
  plus = 1
if plus + odd - 1 <= quatro:
  print("Yes")
else:
  print("No")

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


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


n = int(input())
l = map(int, input().split())

four_count = 0
two_count = 0
for v in l:
    if v % 4 == 0:
        four_count += 1
    elif v % 2 == 0:
        two_count += 1

if two_count > 0:
    if n - two_count - four_count <= four_count:
        print("Yes")
    else:
        print("No")
else:
    if n - four_count - 1 <= four_count:
        print("Yes")
    else:
        print("No")

Solution (Python):
import numpy as np
import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)


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

cnt4,cnt2 = 0,0

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

cnt2 = max(1,cnt2)

print("Yes" if 2*cnt4 + cnt2 >= N else "No")

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

cnt2 = max(1,cnt2)
print('Yes' if 2 * cnt4 + cnt2 >= n else 'No')

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

    sumMod2 = 0
    sumMod4 = 0
    sumElse = 0
    for v in A:
        if v % 4 == 0:
            sumMod4 = sumMod4 + 1
        elif v % 2 == 0:
            sumMod2 = sumMod2 + 1
        else:
            sumElse = sumElse + 1

    if sumMod2 == 0:
        if sumElse -1 <= sumMod4:
            print("Yes")
            return
        else:
            print("No")
            return
    else:
        if sumElse <= sumMod4:
            print("Yes")
            return
        else:
            print("No")
            return

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
L = {0: 0, 1: 0, 2: 0}
for i in range(n):
    for j in range(3):
        if a[i] % 2 == 1:
            L[j] += 1
            break
        a[i] = a[i] // 2
    else:
        L[2] += 1
L[1] = L[1] % 2
if L[2] >= L[0] + L[1] - 1:
    print('Yes')
else:
    print('No')

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

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    c1=0
    c2=0
    c4=0
    for i in l:
        if i%2==1:
            c1+=1
        else:
            if i%4==0:
                c4+=1
            else:
                c2+=1
    if c2==0:
        if c1<=c4+1:
            print('Yes')
        else:
            print('No')
    else:
        if c1<=c4:
            print('Yes')
        else:
            print('No')
resolve()

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

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    kisu=0
    ni1=0
    ni2=0
    for i in l:
        if i%2==1:
            kisu+=1
        else:
            if i%4==0:
                ni2+=1
            else:
                ni1+=1
    if ni1==0:
        if kisu<=ni2+1:
            print('Yes')
        else:
            print('No')
    else:
        if kisu<=ni2:
            print('Yes')
        else:
            print('No')
resolve()

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

c1, c2, c4 = 0, 0, 0
a = list(map(int, input().split()))

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

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

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
c,c2,c4 = 0,0,0
for a in A:
  if a%4==0:c4+=1
  elif a%2==0:c2+=1
  else:c+=1
f = False
if c4>=c:f=True
if c4 == c-1 and c2==0:f=True
if f:print("Yes")
else:print("No")

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
s1 = [0]*n
s2 = [0]*n
s4 = [0]*n
for i in range(n):
    if a[i]%4 == 0:
        s4[i] = 1
    elif a[i]%2 == 0:
        s2[i] = 1
    else:
        s1[i] = 1
S1 = sum(s1)
S2 = sum(s2)
S4 = sum(s4)
if n >= 3:
    if S2 >= 1:
        if S1 + 1 <= S4 + 1:
            print("Yes")
        else:
            print("No")
    else:
        if S1 <= S4 +1:
            print("Yes")
        else:
            print("No")
else:
    if (a[0]*a[1])%4 == 0:
        print("Yes")
    else:
        print("No")

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

cnt_1 = 0
for i in a:
    if i % 2 != 0:
        cnt_1 += 1

cnt_2 = 0
for i in a:
    if i % 2 == 0 and i % 4 != 0:
        cnt_2 += 1

cnt_4 = 0
for i in a:
    if i % 4 == 0:
        cnt_4 += 1

if cnt_4*2 + 1 >= n:
    print("Yes")
else:
    if cnt_4*2 + cnt_2 >= n:
        print("Yes")
    else:
        print("No")

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

cnt_multiple_2 = 0
cnt_multiple_4 = 0
cnt_others     = 0

for i in range(len(a_list)):
    if a_list[i] % 4 == 0:
        cnt_multiple_4 += 1
        continue
    if a_list[i] % 2 == 0:
        cnt_multiple_2 += 1
        continue
    cnt_others += 1

if cnt_multiple_2 > 0:
    if cnt_others > cnt_multiple_4:
        print('No')
    else:
        print('Yes')
else:
    if cnt_others-1 > cnt_multiple_4:
        print('No')
    else:
        print('Yes')

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
cnt = 0
memo = 0
for aa in a:
    if aa % 4 == 0:
        cnt += 1
    elif aa % 2 == 1:
        memo += 1
print('Yes' if (cnt >= memo - 1 and cnt + memo == n) or cnt >= memo else 'No')

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

cnt_0 = 0
cnt_2 = 0
cnt_4 = 0

for i in range(N):
    if a[i] % 4 == 0:
        cnt_4 += 1
    elif a[i] % 2 == 0:
        cnt_2 += 1
    else:
        cnt_0 += 1

if cnt_4 < cnt_0 - 1:
    print("No")
    exit()

if cnt_2 == 0:
    if cnt_4 >= cnt_0 - 1:
        print("Yes")
    else:
        print("No")
else:
    if cnt_4 >= cnt_0:
        print("Yes")
    else:
        print("No")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
k1, k2, k4 = 0, 0, 0
for a_i in a:
    if a_i % 4 == 0:
        k4 += 1
    elif a_i % 2 == 0:
        k2 += 1
    else:
        k1 += 1
t = min(k1, k4)
k1 -= t
k4 -= t
result = k1 == 0 or (k1 == 1 and not k2)
print([ 'No', 'Yes' ][result])

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

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

if cnt1 - cnt4 > 1:
    print("No")
elif cnt1 - cnt4 == 1:
    if cnt2 == 0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Solution (Python):
a = int(input())
ar = list(map(int,input().split(" ")))
k = 0
g = 0
f = 0
for r in ar:
    if r % 4 == 0:
        f += 1
    elif r % 2 == 0:
        g += 1
    else:
        k += 1
if k - f > 1:
    print("No")
elif k - f == 1:
    if g == 0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Solution (Python):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy





sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))




def main():
    n = ni()
    a = na()

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

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

    flg = False
    if result[2] == 0:
        if result[4] >= result[1] - 1:
            flg = True
    else:
        if result[4] >= result[1]:
            flg = True

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


if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
odd, four = 0, 0
for a in A:
    if a & 1 == 1: odd += 1
    if a & 3 == 0: four += 1


if odd == 0 or four >= odd or (four == odd - 1 and four + odd == N):
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
f2 = 0
f4 = 0
f_another = 0
for a in A:
    
    if a%4 == 0:
        f4 += 1
    elif a%2 == 0:
        f2 += 1
    else:
        f_another +=1
if n%2 == 0 and (n -f2//2 *2 -f4 *2 <= 0):
    print('Yes')
elif n%2 == 1 and (n -f2//2 *2 -f4 *2 <= 1):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import os

def file_input():
    f = open('ARC080/input.txt', 'r')
    sys.stdin = f

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

    
    odd=0
    for i in a_li:
        if i%4==0:
            odd-=1
        if i%2!=0:
            odd+=1
    else:
        if (N%2==0 and odd<=0) or (N%2!=0 and odd<=1):
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

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

count = 0
for i in a:
    if i % 4 == 0:
        count +=2
    elif i %2 == 0 :
        count+=1
    else:
        continue

if len(a)%2 == 0:
    if count >=len(a):
        print("Yes")
    else:
        print("No") 
else:
    if count >= len(a)-1:
        print("Yes")
    else:
        print("No")

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

Solution (Python):
from collections import Counter


N = int(input())
c = Counter(map(lambda x: int(x) % 4, input().split()))
print('Yes') if sum([c[1], c[2] > 0, c[3]]) <= c[0] + 1 else print('No')

Solution (Python):
from collections import defaultdict


N = int(input())
counter = defaultdict(int)
for a in map(int, input().split()):
    if a % 4 == 0:
        counter[2] += 1
    elif a % 2 == 0:
        counter[1] += 1
    else:
        counter[0] += 1
if counter[1] == 0:
    print('Yes') if counter[0] <= counter[2] + 1 else print('No')
else:
    print('Yes') if counter[0] <= counter[2] else print('No')

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
A = iil()

odd = 0
even = 0
mulof4 = 0
for i in A:
    if i%2 == 1:
        odd += 1
    elif i%4 == 2:
        even += 1
    else:
        mulof4 += 1

if odd > mulof4+1:
    print('No')
else:
    if odd < mulof4+1:
        print('Yes')
    else:
        print("Yes" if even == 0 else 'No')

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

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

if x < z:
    if (z - x == 1) & (y == 0):
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Solution (Python):
from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n=ii()
    a=lmis()
    cnt4,cnt2,cntodd=0,0,0
    flag=False
    for val in a:
        if val%4==0:
            cnt4+=1
            continue
        if val%2==0:
            cnt2+=1
            continue
        cntodd+=1
    if cnt4-cntodd>=0:flag=True
    elif cnt4-cntodd==-1 and cnt2==0:flag=True
    print('Yes' if flag else 'No')
    

if __name__ == "__main__":
    main()

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    A_list = [int(item) for item in input().split()]

    cnt_list = [0,0]

    for i in A_list:
        if i % 4 == 0:
            cnt_list[1] += 1
        elif i % 2 == 0:
            cnt_list[0] += 1

    is_flag = False

    if N - cnt_list[1] <= cnt_list[1]+1:
        is_flag = True
    
    else:
        if N - sum(cnt_list) <= cnt_list[1]:
            is_flag = True


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


if __name__ == "__main__":
    resolve()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
a4 = 0
a2 = 0
a1 = 0

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

if a2 == 0 and a1 <= a4 + 1:
    print('Yes')
elif a4 >= a1:
    print('Yes')
else:
    print('No')

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

























n0, n2, n4 = 0, 0, 0

for a in al:
    if a % 4 == 0:
        n4 += 1
    elif a % 2 == 0:
        n2 += 1
    else:
        n0 += 1

print('Yes' if n4+1 >= n0+n2%2 else 'No')

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

    a0 = 0
    a1 = 0
    a2 = 0

    for e in a:
        if e % 4 == 0:
            a2 += 1
        elif e % 2 == 0:
            a1 += 1
        else:
            a0 += 1

    if a1 == 0 and a2 >= a0-1:
        print("Yes")
        return

    if a0 <= a2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
import sys

n = int(input())
s = [int(i)%4 for i in sys.stdin.read().split()]
s0 = s.count(0)
s2 = s.count(2)
if n - s0 - s2 <= s0 + (s2 == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))
r2 = 0
r4 = 0
for i in range(N):
    if a_list[i]%2==0:
        r2 += 1
    if a_list[i]%4==0:
        r4 += 1
r2 -= r4
r0 = N - r2 - r4
if N % 2==0:
    print("Yes") if r4 >= r0 else print("No")
else:
    print("Yes") if r4 >= r0-1 else print("No")

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))
r2 = 0
r4 = 0
for i in range(N):
    if a_list[i]%2==0:
        r2 += 1
    if a_list[i]%4==0:
        r4 += 1
r2 -= r4
r0 = N - r2 - r4
if N % 2==0:
    print("Yes") if r4 >= r0 else print("No")
else:
    print("Yes") if r4 >= r0-1 else print("No")

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 != 0:
        n1 += 1
    elif a[i]%4 == 2:
        n2 += 1
    else:
        n4 += 1

if n4*2 + 1 >= N:
    print("Yes")
else:
    if n4*2 + n2 >= N:
        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 == 1:
        Y += 1
    elif i % 2 == 0:
        Z = 1
Y+=Z

if X+1 >= Y:
    print('Yes')
else:
    print('No')

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

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

num_4 = 0
num_2 = 0
num_odd = 0

for i in A:
    if i % 4 == 0:
        num_4 += 1
    elif i % 2 == 0:
        num_2 += 1

num_odd = n - num_2 - num_4

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

Solution (Python):

def rd(n):
    if n==0:
        return input("")
    if n==1:
        return int(input())
    if n==2:
        return map(int,input().split())
    if n==3:
        return list(map(int,input().split()))
def solve():
    n=rd(1)
    A=rd(3)
    d={0:0,1:0,2:0}
    for i in range(n):
        if(A[i]%4==0):
            d[2]+=1
        elif(A[i]%2==0):
            d[1]+=1
        else:
            d[0]+=1
    if((d[0]>d[2]+1) or (d[0]==d[2]+1 and d[1]!=0)):
        print('No')
    else:
        print('Yes')

solve()

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

for i in a:
    if i%4 == 0:
        cnt_four += 1
    elif i%4 == 2:
        cnt_two += 1
cnt_odd = len(a) - cnt_four - cnt_two

if cnt_two >= 1:
    cnt_odd += 1

if cnt_four >= cnt_odd - 1:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):


n = int(input())
nums = [int(i) for i in input().split()]

fours = 0
twos = 0
odd = 0
for num in nums:
    if num % 4 == 0:
        fours += 1
    elif num % 2 == 0:
        twos += 1
    else:
        odd += 1

if twos == 0 and fours + 1 >= odd:
    print('Yes')
elif fours >= odd:
    print('Yes')
else:
    print('No')

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

odds = 0
fours = 0
evens = 0

for a in A:
    if a % 4 == 0:
        fours += 1
    elif a % 2 == 0:
        evens += 1
    else:
        odds += 1

if evens == 0:
    if odds <= fours + 1:
        print("Yes")
    else:
        print("No")
else:
    if odds <= fours:
        print("Yes")
    else:
        print("No")

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

dic = {4: 0, 2: 0, 1: 0}
for i in A_list:
    if i % 4 == 0:
        dic[4] += 1
    elif i % 2 == 0:
        dic[2] += 1
    else:
        dic[1] += 1
dic[4] += dic[2] // 2

if len(A_list) // 2 <= dic[4]:
    print('Yes')
else:
    print('No')

Solution (Python):
def myAnswer(N:int,A:list) -> str:
   counter4 = 0
   counter2 = 0
   for a in A:
      if(a % 4 == 0):
         counter4 += 1
      elif(a % 2 == 0):
         counter2 += 1
   if(counter4 >= N//2):
      return "Yes"
   elif(counter4 >= (N-(counter2//2)*2)//2):
      return "Yes"
   else:
      return "No"


def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()

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

cnt = 0
for a in A:
    if a % 4 == 0: cnt += 1
    elif a % 2 == 0: cnt += 0.5
print("Yes" if cnt >= N // 2 else "No")

Solution (Python):









import numpy as np






N = int(input())
arrA = list(map(int,input().split()))
arrA = np.array(arrA)

arrA = arrA % 4
num4s = len(arrA[arrA==0])
num2s = len(arrA[arrA==2])
num13s = len(arrA) - num2s - num4s

if num13s - num4s == 0:
    ans = "Yes"
elif num13s - num4s == 1 and num2s>0:
    ans = "No"
elif num13s - num4s > 1:
    ans = "No"
else:
    ans = "Yes"
print(ans)

Solution (Python):
c_0, c_1, c_2, N = 0, 0, 0, int(input())
for i in map(int, input().split()):
    if i % 4 == 0: c_2 += 1
    elif i % 2 == 0: c_1 += 1
    else: c_0 += 1
if c_1 == 0: result = "Yes" if c_2 >= c_0 - 1 else "No"
else: result = "Yes" if c_2 >= c_0 else "No"
print(result)

Solution (Python):
import math
n = int(input())
li = list(map(int,input().split()))

all_li = []
two_count = 0
zero_count = 0
for l in li:
    count = 0
    if l % 2 == 0:
        count += 1
    if l % 4 == 0:
        count += 1
        two_count += 1
    if count == 0:
        zero_count += 1
    all_li.append(count)


if two_count == 0:
    
    if list(set(all_li)) == [1]:
        print('Yes')
    else:
        print('No')
elif zero_count == 0:
    print('Yes')
else:
    if zero_count > two_count +1:
        print('No')
    elif zero_count == two_count + 1:
        if len(all_li) - zero_count - two_count == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Solution (Python):
n = int(input())
n_list = list(map(int,input().split()))
count = 0
for i in n_list:
    if i % 4 == 0:
        count += 1
    elif i%2 == 0:
        count += 0.5
if count >= n//2:
    print("Yes")
else:
    print("No")

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

print("Yes" if l[2]+1>=l[0]+int(1<=l[1]) else "No")

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

mod4 = 0
mod2 = 0
other = 0
counter = {0:0, 1:0, 4:0}
for n in A:
    count = 0
    while n % 2 == 0:
        count += 1
        n //= 2
        if count >= 2:
            break
    if count == 0:
        counter[0] += 1
    elif count == 1:
        counter[1] += 1
    else:
        counter[4] += 1
ans = None
if counter[1] == 0:
    if counter[4] + 1 >= counter[0]:
        ans = 'Yes'
    else:
        ans = 'No'
else:
    if counter[4] >= counter[0]:
        ans = 'Yes'
    else:
        ans = 'No'
print(ans)

Solution (Python):
from collections import Counter

def main():
    N = int(input())
    an = sorted(map(int, input().split(' ')))
    
    
    
    
    
    
    
    
    out = []
    
    for a in an:
        if a % 2 != 0:
            out.append('A')
        elif a % 4 != 0:
            out.append('B')
        else:
            out.append('C') 
    
    counter = Counter(out)
    
    num_A = counter['A']
    num_B = counter['B']
    num_C = counter['C']
    
    
    if num_A == 1 and num_B == 1 and num_C ==0:
        print('No')
        return
    
    if not ('B' in out):
        if (num_C + 1) >= num_A:
            print('Yes')
            
        else:
            print('No')
            
    else:
        if num_B >= num_A:
            print('Yes')
        else:
            print('No')
        
        
        
        
    
main()

Solution (Python):
n = int(input())
a = list(map(lambda x: int(x)%4 , input().split()))

p = a.count(0)
q = a.count(2)
r = n-p-q

if r > p:
    if r -p == 1 and q == 0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

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

even = 0
multiple4 = 0
for a in A:
    if a % 4 == 0:
        multiple4 += 1
    elif a % 2 == 0:
        even += 1

N -= ((even//2)*2)+multiple4
if N <= multiple4+1:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    two = 0
    four = 0
    for a in A:
        if a % 4 == 0:
            four += 1
        elif a % 2 == 0:
            two += 1
    if N % 2 == 1:
        if four * 2 + two + 1 >= N:
            print("Yes")
        else:
            print("No")
    else:
        if four * 2 + two >= N:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
cnt_4 = 0
cnt_2 = 0
remaining_cnt_2 = 0
cnt_other = 0

for x in a:
    if x % 4 == 0:
        cnt_4 += 1
    elif x % 2 == 0:
        cnt_2 += 1
    else:
        cnt_other += 1

remaining_cnt_2 = cnt_2 % 2

if cnt_2 > 0:
    if cnt_4 >= cnt_other:
        print("Yes")
    else:
        print("No")
else:
    if cnt_4 + 1 >= cnt_other:
        print("Yes")
    else:
        print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
num2=0
num4=0
kisu=0
for i in range(n):
    if a[i]%4==0:
        num4+=1
    elif a[i]%2==0:
        num2+=1
    else:
        kisu+=1
flag=True
if num4==0:
    if 0<kisu:
        flag=False
else:
    if num2==0:
        if not(kisu<=num4+1):
            flag=False
    else:
        if not(kisu<=num4):
            flag=False
print("Yes" if flag else "No")

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

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


def num_factor2(num):
    result = 0
    while num % 2 == 0:
        result += 1
        num /= 2
    return result

a_factor2 = map(num_factor2, a)

num_factor2_zero = 0
num_factor2_one = 0
num_factor2_twoormore = 0

for a_ in a_factor2:
    if a_ == 0:
        num_factor2_zero += 1
    elif a_ == 1:
        num_factor2_one += 1
    elif a_ >= 2:
        num_factor2_twoormore += 1

if num_factor2_zero <= num_factor2_twoormore or (num_factor2_zero <= num_factor2_twoormore + 1 and num_factor2_one == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=list(map(lambda x:int(x)%4,input().split()))
b0=a.count(0)
b1=a.count(1)+a.count(3)
b2=a.count(2)
if b2 > 0:
    print('Yes' if b0 >= b1  else 'No')
else:
    print('Yes' if b0 >=b1-1 else 'No')

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

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

n -= c2
c2 %= 2
n += c2
f = n // 2

if c4 >= f:
    print('Yes')
    quit()
else:
    print('No')

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

c1 = 0
c2 = 0
c4 = 0
for i in range(n):
    if a[i] % 4 == 0:
        c4 += 1
    elif a[i] % 2 == 0:
        c2 += 1
    elif a[i] == 1:
        c1 += 1
if c2 == n:
    print('Yes')
    quit()

n -= c2
c2 %= 2
n += c2
f = n // 2

if c4 >= f:
    print('Yes')
    quit()
else:
    print('No')

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

num_odd = 0
num_4 = 0
num_2 = 0
for a in A:
    if a % 4 == 0:
        num_4 += 1
    elif a % 2 == 0:
        num_2 += 1
    else:
        num_odd += 1

if num_odd <= num_4:
    print("Yes")
elif num_odd == num_4 + 1 and num_2 == 0:
    print("Yes")
else:
    print("No")

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 2*four+two>=n or 2*four+1>=n:
    print("Yes")
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
odd = n-cnt4 - cnt2
ok = cnt4+1 >= odd
if cnt4+1 == odd:
    if cnt2 >0:ok = False
    
 

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

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

cnt4 = 0
cnt2 = 0
cnt_not = 0
for num in a:
    if num % 4 == 0:
        cnt4 += 1
    elif num % 2 != 0:
        cnt_not += 1
    else:
        cnt2 += 1
        
if 0 < cnt2:
    r = 1
else:
    r = 0


if cnt_not + r  < cnt4 + 2:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
c2 = sum([a % 2 == 0 and a % 4 != 0 for a in A])
c4 = sum([a % 4 == 0 for a in A])
cp = sum([a % 2 != 0 for a in A])
print('Yes' if cp+c4 == N and cp - c4 ==
      1 or cp <= c4 and c4+cp+c2 == N else 'No')

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

a4, a4n, a2 = 0, 0, 0
for ai in a:
  if ai % 4 == 0:
    a4 += 1
  elif ai % 2 == 0:
    a2 += 1
  else:
    a4n += 1

if a2 != 0:
  print("Yes" if a4 + 1 >= a4n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a4n else "No")

Solution (Python):
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]
for i in range(N):
    if a[i] % 4 == 0:
        a[i] = 0
    elif a[i] % 4 == 2:
        a[i] = 2
    else:
        a[i] = 1
counts = dict(Counter(a))
flag = False
if 1 in counts:
    if 0 in counts:
        if 2 in counts:
            if counts[0] >= counts[1]:
                flag = True
        
        else:
            if counts[0] == counts[1]-1:
                flag = True
        
else:
    if 2 in counts:
        if counts[2] >= 2:
            flag = True
        else:
            if 0 in counts:
                flag = True
                
    else:
        if 0 in counts:
            flag = True
                

    
print('Yes' if flag==True else 'No')