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):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    n_4 = 0
    n_2 = 0
    n_odd = 0

    for i in range(N):
        if A[i] % 4 == 0:
            n_4 += 1
        elif A[i] % 2 == 0:
            n_2 += 1
        else:
            n_odd += 1

    if (n_odd + n_2 % 2 - 1) <= n_4:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
b4=[x for x in a if x%4==0]
a4=[x for x in a if x%4!=0]
b2=[x for x in a4 if x%2==0]
c=[x for x in a4 if x%2!=0]
if len(b4)==0 and (len(c)==0 and len(b2)>1):
    print('Yes')
elif len(b4)==0 and len(c)!=0:
    print('No')
elif len(b4)+1<len(c):
    print('No')
elif len(b4)<len(c) and len(b2)>0:
    print('No')
else:
    print('Yes')

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
nn=[0,0,0]
for i,v in enumerate(a):
    tmp=0
    while v%2==0:
        v//=2
        tmp+=1
    nn[min(tmp,2)]+=1
if nn[1]:
    if nn[0]>(n-nn[1])//2:
        print("No")
    else:
        print("Yes")
else:
    if nn[0]>(n+1)//2:
        print("No")
    else:
        print("Yes")

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 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:
    if x+1 >= z:
        print("Yes")
    else:
        print("No")
else:
    if x >= z:
        print("Yes")
    else:
        print("No")

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

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

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

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
m2 = 0
m4 = 0
other=0
for i, aa in enumerate(a):
    if aa % 4 == 0:
        m4 +=1
        continue
    if aa % 2 == 0:
        m2 += 1
        continue
    other += 1
if m4 >= other or (m4 + 1 == other and m2 == 0):
    print('Yes')
else:
    print('No')

Solution (Python):
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    cnt4 = 0
    cnt2 = 0
    _cnt = 0
    for a in A:
        if a % 4 == 0:
            cnt4 += 1
            continue
        if a % 2 == 0:
            cnt2 += 1
            continue
        _cnt += 1
    if cnt2 > 0 and cnt2 % 2 != 0:
        cnt2 -= 1
        _cnt += 1
    print("Yes" if cnt4+1 >= _cnt else "No")




if '__main__' == __name__:
    resolve()

Solution (Python):
import sys
def slove(n, k):
    a_list = [int(i) for i in k.split()]
    num = len([i for i in a_list if i % 4 == 0])
    tmp =  [i for i in a_list if i % 4 != 0]
    num2 = len([i for i in tmp if i % 2 == 0]) // 2
    return "Yes" if (num + num2)>= n // 2 else "No"

if __name__ == "__main__":
    input = sys.stdin.readline
    n = int(input())
    k = input()
    print(slove(n, k))

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

four = 0
two = 0
ele = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0 and a[i] % 4 != 0:
        two += 1
    else:
        ele += 1

"""
ele += two % 2
two = two//2
print(two, end=" ")
print(four, end=" ele=")
print(ele)
if ele <= (two+four) or (ele-(four+two) == 1):
    print("Yes")
else:
    print("No")
"""
if ele <= four:
    print("Yes")
elif ele-four == 1 and two == 0:
    print("Yes")
else:
    print("No")

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

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    m2 = len([a for a in A if a % 2 == 0])
    m4 = len([a for a in A if a % 4 == 0])
    mx = N - m2
    if mx == m4 + 1 and m2 - m4 == 0:
        print('Yes')
    elif mx > m4:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    a=list(map(int,input().split()))
    t=0
    f=0
    for i in range(N):
        if a[i]%4==0:
            f+=1
        elif a[i]%2==0:
            t+=1
    YesNo(N//2<=f+t//2)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    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

    if (n - max(0, cnt_2 - 1)) // 2 <= cnt_4:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    resolve()

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

for i in li:
    if i%4 == 0: 
        x += 1
    if i%4 != 0 and i%2 == 0: 
        y += 1

if x>0 and y>0:
    if 2*x+y >= n:
        print("Yes")
    else:
        print("No")

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

elif y>0:
    if y == n:
        print("Yes")
    else:
        print("No")

else:
    print("No")

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

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

if multi_4 + odd_cnt == n:
    print("Yes" if multi_4 >= odd_cnt - 1 else "No")
else:
    print("Yes" if multi_4 >= odd_cnt else "No")

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

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    count_x2 = 0
    count_x4 = 0

    for aa in a:
        if aa % 4 == 0:
            count_x4 += 1
        elif aa % 2 == 0:
            count_x2 += 1

    if count_x4 >= n//2:
        print('Yes')
        exit()
    tmp = n - count_x2
    if tmp % 2 == 0:
        if count_x4 >= tmp // 2:
            print('Yes')
            exit()
    else:
        if count_x4 >= tmp // 2 + 1:
            print('Yes')
            exit()
    if count_x2 == n:
        print('Yes')
        exit()

    print('No')

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

Solution (Python):
def main():
  N = int(input())
  A = [int(_) for _ in input().split()]
  k = f = 0
  can = False
  for a in A:
    if a%2 == 1:
      k += 1
    if a%4 == 0:
      f += 1
  if k == 0: 
    can = True
  else:
    if N - k - f == 0:
      if f+1 >= k:
        can = True
    else:
      if f >= k:
        can = True
  print('Yes' if can else 'No')
  return

if __name__ == '__main__':
  main()

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

cnt2 = 0  
cnt4 = 0  

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

if N-max(cnt2-1, 0) <= cnt4*2+1:
    print('Yes')
else:
    print('No')

Solution (Python):
data = int(input())
array = [int(i) for i in input().split()]
div2 = 0
div4 = 0
for i in array:
  if i%4==0:
    div4 += 1
  elif i%2==0:
    div2 += 1
if data-max(div2-1,0) <= div4*2+1:
  print('Yes')
else:
  print('No')

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

Solution (Python):
import math

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

N2 = 0
N4 = 0
oth = 0

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

if N2 == 0:
    if N4+1 >= oth:
        print("Yes")
    else:
        print("No")
else:
    if N4 >= oth:
        print("Yes")
    else:
        print("No")

Solution (Python):

def main():
    n = int(input())
    a = list(map(int, input().split()))
    div2 = 0
    div4 = 0
    notdiv4 = 0
    for ea in a:
        if ea % 4 == 0:
            div4 += 1
        elif ea % 2 == 0:
            div2 += 1
        else:
            notdiv4 += 1

    notdiv4 += div2 % 2
    if notdiv4 - 1 > div4:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()

Solution (Python):
from copy import deepcopy

def main():
    n = int(input())
    a = list(map(int, input().split()))
    div2 = [0] * n
    div4 = deepcopy(div2)
    notdiv4 = deepcopy(div2)
    for i in range(n):
        if a[i] % 4 == 0:
            div4[i] = 1
        elif a[i] % 2 == 0:
            div2[i] = 1
        else:
            notdiv4[i] = 1
    num_notdiv4 = sum(notdiv4)
    num_notdiv4 += sum(div2) % 2
    if num_notdiv4 - 1 > sum(div4):
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
a_list = list(map(int, input().split()))
counts = [0] * 3
for a in a_list:
	if a%4 == 0:
		counts[0] += 1 		 
	elif a%2 == 0:
		counts[1] += 1
	else:
		counts[2] += 1
r = 'Yes' if counts[2] <= counts[0]+1 else 'No'
if r == 'Yes':
	two_v = counts[1]
	four_v = counts[0] - counts[2]
	mod = two_v%2	
	if mod == 0 or mod - four_v < 2:
		r = 'Yes'
	else:
		r = 'No'
print(r)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
c = len([i for i in l if i%4==0])
l1 = [i for i in l if  (i%2==0 and i%4!=0)]
if len(l1)>=1:
  a = n-len(l1)+1
  a = a-c
  if a<=c+1:
    print("Yes")
  else:
    print("No")
else:
  a = n-c
  if a<=c+1:
    print("Yes")
  else:
    print("No")

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

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

odd_count = 0
four_count = 0

ans = 'Yes'

for i in a:
    if i % 2 == 1:
        odd_count += 1
    if i % 4 == 0:
        four_count += 1

if len(a) % 2 == 0:
    if odd_count > four_count:
        ans = 'No'
else:
    if odd_count <= four_count or len(a) == odd_count + four_count and odd_count -1 <= four_count:
        pass
    else:
        ans = 'No'

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
l1 = 0
l2 = 0
l4 = 0
for i in range(len(A)):
  if(A[i] % 4 == 0):
    l4 += 1
  elif(A[i] % 2 == 0):
    l2 += 1
  else:
    l1 += 1
if(l2 == 0 and l4 + 1 == l1):
  print('Yes')
elif(l4 < l1):
  print('No')
else:
  print('Yes')

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

c4 = 0
c2 = 0
for ai in a:
  if ai%4 == 0:
    c4 += 1
  elif ai%2 == 0:
    c2 += 1
if (c2 > 0 and c4 >= n-c4-c2) or (c2 == 0 and c4 >= n-c4-c2-1):
  print('Yes')
else:
  print('No')

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

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

print("Yes" if cntA + cntB//2  >= N//2 else "No")

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

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

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

Solution (Python):
from collections import deque

def f(x):
    return num.count(x)

n = int(input())
a = list(map(int, input().split()))
num = deque([])
for i in a:
    if i%4==0:
        num.append(4)
    elif i%2==0:
        num.append(2)
    else:
        num.append(0)

if len(a)%2==1:
    if f(4)>=len(a)//2 or f(2)>=2*(n//2-f(4))+1:
        print('Yes')
        exit(0)
if len(a)%2==0:
    if f(2)>=2*(n//2-f(4)):
        print('Yes')
        exit(0)
print('No')

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

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

  
  
  
  data = []
  for d in data_:
    if d % 2 == 1:
      data.append(1)
    else:
      tmp = int(d / 2)
      if tmp % 2 == 1:
        data.append(2)
      else:
        data.append(4)

  
  if data.count(2) == 0:
    if data.count(1) <= data.count(4) + 1:
      print("Yes")
      return
    else:
      print("No")
      return

  if data.count(1) <= data.count(4):
    print("Yes")
  else:
    print("No")

if __name__ == "__main__":
  main()

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

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

def f(x):
  y = 0
  q, r = divmod(x, 2)
  while r == 0:
    y += 1
    q, r = divmod(q, 2)
  return y

B = [0] * 3
for a in A:
  b = f(a)
  B[0] += b == 0
  B[1] += b == 1
  B[2] += b >= 2
print('Yes' if B[0] + (B[1]!=0) <= B[2]+1 else 'No')

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

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

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

Solution (Python):
n = int(input())
list_A = list(map(int, input().split()))
list_C = [0, 0, 0]

for num in list_A:
    if num % 4 == 0:
        list_C[2] += 1
    elif num % 2 == 0:
        list_C[1] += 1
    else:
        list_C[0] += 1

ans = "Yes"

if list_C[1] == 0:
    if list_C[2] == 0:
        if list_C[0] != 0:
            ans = "No"
    if list_C[2] == 1:
        if list_C[0] > 2:
            ans = "No"
    if list_C[2] > 1:
        if list_C[0] > list_C[2] + 1:
            ans = "No"
else:
    if list_C[0] > list_C[2]:
        ans = "No"

print(ans)

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

if((cnt4 * 2 + 1) >= n or cnt2 >= (n - (cnt4 * 2 + 1) + 1)):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    c4 = c2 = 0
    for x in a:
        if not x % 4: c4 += 1
        elif not x % 2: c2 += 1
    ans = 'Yes' if c4 >= n // 2 or c4 * 2 + c2 >= n else 'No'
    print(ans)

if __name__ ==  '__main__':
    main()

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

Solution (Python):
input()
A = map(int, input().split())
one, two, four = 0,0,0

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

if one <= four or (one == four + 1 and two == 0):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

cnt2 = 0
cnt4 = 0

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

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

Solution (Python):
n = int(input())
a = map(int, input().split())
b1, b2, b4 = 0, 0, 0

for i in a:
    if i % 4 == 0:
        b4 += 1
    elif i % 2 == 0:
        b2 += 1
    else:
        b1 += 1
if b2:
    if b1 <= b4:
        print("Yes")
    else:
        print("No")
else:
    if b1 <= b4 + 1:
        print("Yes")
    else:
        print("No")

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

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

if (n - max(0, cnt2 - 1)) // 2 <= cnt4:
    print("Yes")
else:
    print("No")

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:
    return a
  return gcd_(a,a % b) 
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  a,b = 0,0
  
  for x in map(int,input().split()):
    if x % 4 == 0:
      a += 1
    elif x % 2 == 0:
      b += 1
  print('Yes' if a+b//2 >= n//2 else 'No') 
  
  
  
if __name__ == '__main__':
  main()

Solution (Python):

url = "https://atcoder.jp//contests/abc069/tasks/arc080_a"

def main():
    s = int(input())
    t = list(map(int, input().split()))
    dic = {1: 0, 2: 0, 4: 0}

    for v in t:
        if v % 4 == 0:
            dic[4] += 1
        elif v % 2 == 0:
            dic[2] += 1
        else:
            dic[1] += 1
    if dic[1] <= dic[4]:
        print('Yes')
    elif dic[1] <= dic[4] + 1:
        if dic[2] != 0:
            print('No')
        else:
            print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

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

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

if n // 2 <= ans:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
x=[i for i in a if i%4==0]
b=[i for i in a if i%4!=0 and i%2==0]
if len(x)+len(b)//2>=n//2:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a4 = a2 = a0 = 0
for i in a:
  if i % 4 == 0:
    a4 += 1
  elif i % 2 == 0:
    a2 += 1
  else:
    a0 += 1
if a2 == 0:
    if a0 <= a4 + 1:
        print("Yes")
    else:
        print("No")
else:
    if a0 <= a4:
        print("Yes")
    else:
        print("No")

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
con =0
ex = -1
for i in range(n):
    if a[i] % 4 == 0:
        con +=1
    elif a[i] % 2 == 0:
        ex +=1
    
if ex == -1:
    ex = 0
if (n-ex)//2 <= con:
    print('Yes')
else:
    print('No')

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

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

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

ARR = [int(s) for s in input().split(" ")]
def calculate(n,arr):
    m1 = 0
    m2 = 0
    m3 = 0
    for ar in arr:
        if ar % 4 == 0:
            m1 = m1 + 1
        elif ar % 2 == 0:
            m2 = m2 + 1
        else:
            m3 = m3 + 1

    if m2 == 0:
        if m3 > m1 + 1:
            print("No")
        else:
            print("Yes")
    else:
        if m3 <= m1:
            print("Yes")
        else:
            print("No")


calculate(N,ARR)

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

count4 = 0
count2 = 0

for i in lst:
    if i%4==0:
        count4+=1
    elif i%2==0:
        count2+=1
count1 = n-count4-count2

if count2==0 and count4>=count1-1:
    print("Yes")
elif count2!=0 and count4>=count1:
    print("Yes")
else:
    print("No")

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

if (m4*2+m2 >= len(a) or m4*2+1 >= len(a)):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = map(int, input().split())
var0 = 0
var1 = 0
var2 = 0

for a in A:
    if a % 4 == 0:
        var2 += 1
    elif a % 2 == 0:
        var1 += 1
    else:
        var0 += 1

var1 %= 2
ans = 'Yes' if var2 >= var1 + var0 - 1 else 'No'
print(ans)

Solution (Python):
def mp2(k):
    kk=k
    mp=0
    while kk>=1:
        kr=kk%2
        if kr==0:
            kk=kk//2
            mp=mp+1

        else:

            return mp
    return mp
        

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

cnt0=0
cnt1=0
cnt2=0
for i in range(n):
    m=min(2,mp2(a[i]))
    if m==0:
        cnt0=cnt0+1
    elif m==1:
        cnt1=cnt1+1
    elif m==2:
        cnt2=cnt2+1



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

Solution (Python):




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

    odd = sum(a % 2 for a in A)
    four = sum(a % 4 == 0 for a in A)
    even = N - odd

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


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
from collections import deque
kisuu = deque([])
bai4 = deque([])
sonota = deque([])
for ai in a:
    if ai % 4 == 0:
        bai4.append(ai)
    elif ai % 2 == 0:
        sonota.append(ai)
    else:
        kisuu.append(ai)

ans = deque([])
if kisuu:
    s = kisuu.pop()
    ans.append(s)
elif sonota:
    s = sonota.pop()
    ans.append(s)
else:
    s = bai4.pop()
    ans.append(s)        

for i in range(1, N + 1):
    if i == N:
        print('Yes')
        quit()
    if ans[i - 1] % 2 == 1:
        if bai4:
            s = bai4.pop()
            ans.append(s)
        else:
            break
    elif ans[i - 1] % 2 == 0 and ans[i - 1] % 4 != 0:
        if sonota:
            s = sonota.pop()
            ans.append(s)
        elif bai4:
            s = bai4.pop()
            ans.append(s)
        else:
            break
    elif ans[i - 1] % 4 == 0:
        if kisuu:
            s = kisuu.pop()
            ans.append(s)
        elif sonota:
            s = sonota.pop()
            ans.append(s)
        elif bai4:
            s = bai4.pop()
            ans.append(s)
        else:
            break
print('No')

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
x=0
y=0
z=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:
    if z<=x+1:
        print("Yes")
    else:
        print("No")
else:
    if z<=x:
        print("Yes")
    else:
        print("No")

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

a_4 = [val for val in a if val % 4 == 0]
num_4=len(a_4)
a_odd = [val for val in a if val % 2 ==1]
num_odd=len(a_odd)
num_2 = N - num_odd - num_4


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

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

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

if oddcnt<=cnt4:
  print("Yes")
else:
  if cnt2==0 and oddcnt-cnt4==1:
    print("Yes")
  else:
    print("No")

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

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

key_1, key_4 = 0, 0
for value in a:
  if value%4 == 0:
    key_4 += 1
  elif value%2 == 1:
    key_1 += 1

if key_4+key_1 == n and key_1 <= key_4+1:
  print("Yes")
elif key_1 <= key_4:
  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%4==0:mul4+=1
    elif i%2==0:mul2+=1
    else:odd+=1
ans = 'Yes'
if n==mul4+odd:
    if mul4+1<odd:ans='No'
else:
    if mul4<odd:ans='No'
print(ans)

Solution (Python):
n=int(input())
a=list(map(lambda x:int(x),input().split()))
cnt=0
cnt2=0
for i in a:
    if i%4==0:
        cnt+=1
    if i%4!=0 and i%2==0:
        cnt2+=1
if (2*cnt+cnt2>=n and cnt2>0) or (cnt2==0 and 2*cnt+1>=n):
    print('Yes')
else:
    print('No')

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

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

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

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

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

Solution (Python):
n, *a_l = map(int, open(0).read().split())
multi_4 = sum([1 for a in a_l if a%4 == 0])
multi_2 = sum([1 for a in a_l if a%2 == 0]) - multi_4
multi_1 = n - ( multi_2 + multi_4 )
print('Yes' if (multi_2%2 + multi_1) <= multi_4 + 1 else 'No')

Solution (Python):
n=int(input())
la=list(map(int,input().split()))
lc=[0]*n
for i in range(n):
  t=la[i]
  while t%2<1 and lc[i]<2:
    t//=2; lc[i]+=1
c=[lc.count(i) for i in range(3)]
print('YNeos'[c[0]-c[2]>1 or (c[0]>c[2] 
and n%2<1)::2])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = []
for a in A:
  B.append(a%4)

ans = 'No'
if B.count(0) >= B.count(1)+B.count(3):
  ans = 'Yes'
if B.count(2) == 0 and B.count(0) == B.count(1)+B.count(3)-1:
  ans = 'Yes'
print(ans)

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

    four_cnt = 0
    two_cnt = 0
    buta = 0
    for a in A:
        if a % 4 == 0:
            four_cnt += 1
        elif a % 2 == 0:
            two_cnt += 1
        else:
            buta += 1
    
    if two_cnt > 0:
        if buta <= four_cnt:
            print('Yes')
        else:
            print('No')
    else:
        if buta <= four_cnt + 1:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    solve()

Solution (Python):
n = int(input().strip())
a = list(map(int, input().split()))
two = 0
four = 0
for e in a:
    if e % 4 == 0:
        four += 1
    elif e % 2 == 0:
        two += 1
if (n - two <= 2 * four) or (two == 0 and n <= (2 * four + 1)):
    print("Yes")
else:
    print("No")

Solution (Python):

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

mod1, mod2, mod4 = [0] * 3
for ai in a:
    if ai % 4 == 0:
        mod4 += 1
    elif ai % 2 == 0:
        mod2 +=1
    else:
        mod1 +=1
        
if mod2 == 0:
    print('No' if mod1 > mod4 + 1 else 'Yes')
else:
    print('No' if mod1 > mod4 else 'Yes')