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()))

num_four = 0
num_two = 0
num_odd = 0
for i in range(N):
    if A[i] % 4 == 0:
        num_four += 1
    elif A[i] % 2 == 0:
        num_two += 1
    else:
        num_odd += 1



if num_two != 0:
    ans = 'Yes' if num_four + 1 >= num_odd + 1 else 'No'
else:
    ans = 'Yes' if num_four + 1 >= num_odd else 'No'
print(ans)

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

num_four = 0
num_two = 0
num_odd = 0
for i in range(N):
    if A[i] % 4 == 0:
        num_four += 1
    elif A[i] % 2 == 0:
        num_two += 1
    else:
        num_odd += 1



v = num_four * 2
if num_two <= 1:
    v += 1
if num_two >= 2:
    v += num_two
ans = 'Yes' if v >= N else 'No'
print(ans)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
count1 = len([x for x in l if x%2 != 0])
count2 = len([x for x in l if (x%4 != 0) and (x%2 == 0)])
count4 = len([x for x in l if x%4 == 0])
print ("Yes") if (n - (count4*2) <= count2) or count4 >= n//2 else print ("No")

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
four =0
two =0
odd = 0
       
for num in a:
  if num%4==0:
    four +=1
  if num%2==0:
    two += 1
       
two -= four
odd=N-four-two       


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

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

odd=0
ni=0
si=0
for x in a:
    if x%4==0:
        si+=1
    elif x%2==0:
        ni+=1
    else:
        odd+=1
ni=ni%2
if odd+ni<=si+1:
    print("Yes")
else:
    print("No")

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

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

if (num2 != 0) & (num4 >= num1):
    print('Yes')
elif (num2 == 0) & (num4 + 1 >= num1):
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
from collections import deque
n = int(input())
a = list(map(int, input().split()))
odd = deque([])
even = deque([])
even2 = deque([])
for i in a:
    if i % 4 == 0:
        even2.append(i)
    elif i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)
if len(odd)-1 <= len(even2) and len(even) == 0:
    print("Yes")
elif len(odd) <= len(even2):
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
d=[0,0,0]
for i in l:
  if i%4==0:d[2]+=1
  elif i%2==0:d[1]+=1
  else:d[0]+=1
f=0
if d[-1]>=n//2:f=1
if d[0]<=d[-1]:f=1
print("Yes" if f else "No")

Solution (Python):
N =int(input())
A = [a%4 for a in list(map(int,input().split()))]
c0 = A.count(0)
c1 = A.count(1)
c2 = A.count(2)
c3 = A.count(3)
if c2>=2:
  if c1+c3<=c0:
    print("Yes")
  else:
    print("No")
else:
  if c1+c2+c3-1<=c0:
    print("Yes")
  else:
    print("No")

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

checker = []
for a in A:
    cnt = 0
    if a % 2 == 0:
        cnt = 1
    if a % 4 == 0:
        cnt += 1
    checker.append(cnt)

count_2 = checker.count(2)
count_1 = checker.count(1)
count_0 = checker.count(0)

if (count_0 <= count_2+1 and count_0 + count_1 <= count_2 + 1) or count_0 == count_2:
    answer = 'Yes'
else:
    answer = 'No'

print(answer)

Solution (Python):

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        A[i] = A[i] % 4
        if A[i] == 3:
            A[i] = 1
    if A.count(2):
        if A.count(1) + 1 - A.count(0) <= 1:
            print('Yes')
        else:
            print('No')
    else:
        if A.count(1) - A.count(0) <= 1:
            print('Yes')
        else:
            print('No')


resolve()

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')

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')

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

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


if count2 == 0:
  ans = 2*count4 + 1
else:
  ans = 2*count4 + count2

if ans >= N:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())
    b = list(map(lambda x: x % 4, a))
    f, g = b.count(0), b.count(2)
    h = g % 2
    print('Yes' if (n - f - g + h) - 1 <= f else 'No')


if __name__ == '__main__':
    main()

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

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

print('Yes' if d[2] >= d[0] else 'No')

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

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

n = int(input())
a = list(map(int, input().split()))
cnt_0 = 0
cnt_2 = 0
for i in range(n):
    if a[i] % 4 == 0:
        cnt_2 += 1
    elif a[i] % 2 == 1:
        cnt_0 += 1
if (cnt_2 >= cnt_0 - 1 and cnt_2 + cnt_0 == n) or cnt_2 >= cnt_0:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
from collections import Counter
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ct = Counter()
for a in a_ls:
    if a % 4 == 0:
        ct.update([2])
    elif a % 2 == 0:
        ct.update([1])
    else:
        ct.update([0])
if ct[1] == 0:
    if ct[2] >= ct[0] - 1:
        print("Yes")
    else:
        print("No")
else:
    if ct[2] >= ct[0]:
        print("Yes")
    else:
        print("No")

Solution (Python):
N = int(input())
d = {0:0,1:0,2:0}
for a in list(map(int,input().split())):
  if a%2 == 0 :
    if a%4 == 0 :
      d[2]+=1
    else:
      d[1]+=1
  else:
    d[0]+=1


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

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

Solution (Python):
def howmanytwo(m):
  ret=0
  while m%2==0:
    ret+=1
    m=m//2
  return ret

N=int(input())
A=[int(i) for i in input().split()]
evn=[howmanytwo(a) for a in A]
od=evn.count(0)
evev=0
for x in evn:
  if x>=2:
    evev+=1
if od+evev!=N:
  evev+=1
else:
  evev+=2
print('Yes' if od+1<=evev else 'No')

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
f = 0
even = 0
odd = 0

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

even %= 2
if f - even - odd < -1:
    print('No')
else:
    print('Yes')

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
A = 0
B = 0
C = 0

for a in li:
  if a % 4 == 0:
    A += 1
  elif a % 2 == 0:
    B += 1
  else:
    C += 1
if B == 0:
  if C <= A + 1:
    print('Yes')
  else:
    print('No')
else:
  if C <= A:
    print('Yes')
  else:
    print('No')

Solution (Python):

N = int(input())
A = list(map(int, input().split()))
tmp1 = 0
tmp2 = 0
tmp4 = 0

for i in range(N):
    if A[i] % 4 == 0:
        tmp4 += 1
    elif A[i] % 2 == 0:
        tmp2 += 1
    else:
        tmp1 += 1

if tmp2 == 0 and tmp4 >= tmp1-1:
    print("Yes")
elif tmp2 > 0 and tmp4 >= tmp1:
    print("Yes")
else:
    print("No")

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

n, m = 0,0
for a in A:
    if not a % 4:
        n += 1
    if not a % 2:
        m += 1

m -= n
if 2 * n >= N-1:
    print('Yes')

elif 2*n + m >= N:
    print('Yes')

else:
    print('No')

Solution (Python):
n = int(input())
L = list(map(int,input().split()))
L4 = [x%4 == 0 for x in L]
L2 = [(x%2 == 0 and x%4 != 0) for x in L]

other = len(L) - sum(L2) - sum(L4)
if sum(L2) == 0:
    if other <= sum(L4)+1:
        print("Yes")
    else:
        print("No")
else:        
    if other <= sum(L4):
        print("Yes")
    else:
        print("No")

Solution (Python):

from collections import Counter, defaultdict, deque, namedtuple







import sys



ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)



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

    count_0 = 0
    count_2 = 0
    count_4 = 0

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

    if (count_0 + count_4) % 2 == 0:
        if count_4 >= count_0:
            print('Yes')
        else:
            print('No')
    else:
        if count_4 >= count_0:
            print('Yes')
        elif (count_4 + 1) == count_0:
            if count_2 == 0:
                print('Yes')
            else:
                print('No')
        else:
            print('No')

if __name__ == '__main__':
    main()

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

zero = 0
one = 0
two = 0

def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

for i in a:
  counter = divide_two(i)
  if counter == 0:
    zero += 1
  if counter == 1:
    one += 1
  if counter >= 2:
    two += 1
    
if one == 0:
  if zero <= two+1:
    print('Yes')
    exit()
  else:
    print('No')
    exit()
    
else:
  if zero <= two:
    print('Yes')
    exit()
    
  else:
    print('No')
    exit()
    
    
print('No')

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

f=t=0
for x in X:
    if x % 4==0:
        f += 1
    elif x % 2==0:
        t += 1
if 2*f+1 >= N or 2*f+t>=N:
    print("Yes")
else:
    print("No")

Solution (Python):
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
e=0
d=0

for i in range(N):
    if a[i]%4==0:
        c=c+1
    if a[i]%2==1:
        e=e+1
    else:
        d=d+1

if (d-c)==0:
    if e<=c+1:
        print("Yes")
    else:
        print("No")
else:
    if e+1<=c+1:
        print("Yes")
    else:
        print("No")

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
num_odd = 0
num_mul2 = 0
num_mul4 = 0
for a in A:
    if a % 4 == 0:
        num_mul4 += 1
    elif a % 2 == 0:
        num_mul2 += 1
    elif a % 2 == 1:
        num_odd += 1

ans = False
if num_mul2 == 0:
    if num_mul4 + 1>= num_odd:
        ans = True
else:
    if num_mul4 >= num_odd:
        ans = True
print('Yes' if ans else 'No')

Solution (Python):
import collections

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

ay = collections.Counter(ax)
if((ay[2] == 0 and ay[1] <= ay[4]+1) or(ay[2] != 0 and ay[1] <= ay[4])):
    print("Yes")
else:
    print("No")

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

n1 = sum([1 if A % 2 != 0 else 0 for A in a])
n4 = sum([1 if A % 4 == 0 else 0 for A in a])
n2 = N - n1 - n4

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

Solution (Python):
N=int(input())
A=list(int(i)%4 for i in input().split())
b1=A.count(1)+A.count(3)
b2=A.count(2)
b4=A.count(0)
print('Yes' if ( (b2==0 and (b1<=b4+1)) or b1<=b4) else 'No')

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
d2 = 0
d4 = 0
for i in range(n):
    if A[i]%2==0 and A[i]%4!=0:
        d2 += 1
    elif A[i]%4==0:
        d4 += 1
n -= int(d2/2)*2
if n-1-d4<=d4:
    print('Yes')
else:
    print('No')

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

for i in range(N):
	if A[i]%4==0:
		A[i]=4
	elif A[i]%4!=0 and A[i]%2==0:
		A[i]=2
	else:
		A[i]=1
if A.count(2)==0:
	if A.count(4)+1<A.count(1):
		print("No")
	else:
		print("Yes")
else:
	if A.count(4)<A.count(1):
		print("No")
	else:
		print("Yes")

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

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

ans=n-cnt[0]-cnt[1]+1 if cnt[0]!=0 else n-cnt[1]
print('Yes' if ans<=cnt[1]+1 else 'No')

Solution (Python):
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    mul4 = len([a for a in A if a % 4 == 0])
    mul2 = len([a for a in A if a % 4 != 0 and a % 2 == 0])
    less = N - 2*mul4 - 1
    if less <= 0:
        print("Yes")
    elif less + 1 <= mul2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

if t == 0:
    if N//2 <= s:
        print("Yes")
    else:
        print("No")
else:
    if (1+N-t)//2 <= s:
        print("Yes")
    else:
        print("No")

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    c = [0]*5
    for a in A:
        c[a%4]+=1
    if N//2<=c[0]:
        print("Yes")
        return 
    N-=c[0]*2
    print(["No","Yes"][N<=c[2]])
if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
t = 0
f = 0
for x in a:
  if x % 4 == 0: f += 1
  elif x % 2 == 0: t += 1
if N == 1:
  if f: print("Yes")
  else: print("No")
  exit(0)
if N == t:
  print("Yes")
  exit(0)
if -(-(N - max(0, t - 1) - 1) // 2) <= f: print("Yes")
else: print("No")

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

two = 0
four = 0
for a in A:
    cnt = 0
    while a % 2 == 0:
        a //= 2
        cnt += 1
    if cnt == 1:
        two += 1
    elif cnt > 1:
        four += 1

rest = N - four - two
two_merge = 1 if two > 0 else 0
rest += two_merge


if rest - 1 <= four:
    print("Yes")
else:
    print("No")

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

Solution (Python):



from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe




def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)



def pin(type=int):
    return map(type,input().split())

"""
バケットで管理したかったけど数字が多いのでソートして同じ数を固めることに
"""


N=int(input())
A=[(i%4) for i in pin()]

b=[0]*4
for j in A:
    b[j-1]+=1


print(["No","Yes"][(b[3]-b[0]-b[2]-(b[1]%2)+1>=0)])

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

cnt2 = 0
cnt4 = 0

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

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

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

if cnt_2 == 0:
	if cnt_1 <= cnt_4 + 1:
		print("Yes")
	else:
		print("No")
else:
	if cnt_1 <= cnt_4:
		print("Yes")
	else:
		print("No")

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

x,y=0,0
for i in a:
 if i%4==0:
  x+=1
 if i%2==1:
  y+=1

z=n-y-x

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

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

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

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

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

Solution (Python):
N = int(input())
Alist = list(map(int, input().split()))
count_4x = 0
count_2x = 0
for A in Alist:
    if A % 4 == 0:
        count_4x += 1
    else:
        if A % 2 == 0:
            count_2x += 1

if ((count_4x + int(count_2x / 2)) >= (N // 2)):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a4 = [i for i in a if i%4 == 0]
a2 = [i for i in a if i%2 == 0]
num4 = len(a4)
num2 = len(a2) - num4
num1 = N-num2-num4
if num2 == 0 and num4 == num1-1:
    print('Yes')
elif num1 > num4:
    print('No')
else:
    print('Yes')

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


if a.count(0)+(1 if 1 in a else 0) <= a.count(2)+1:
    print('Yes')
    exit(0)
print('No')

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

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
n = int(input())
a = list(map(int, input().split()))
for num in a:
  if num % 4 == 0:
    d[4] += 1
    continue
  if num % 2 == 0:
    d[2] += 1
    continue
print("Yes" if n//2 <= d[4] + (d[2] // 2) else "No")

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
d4=len([i for i in A if i%4==0])
d2=len([i for i in A if i%2==0 and i%4!=0])

N=N-(d4*2)
if N==1:
    N=0
else:
    N-=d2

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

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

Solution (Python):

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


A_x2 = [a for a in A if a % 4 != 0]

num_x4 = len(A) - len(A_x2)

A_x1 = [a for a in A_x2 if a % 2 != 0]


num_odd = len(A_x1)
num_even = len(A_x2) - num_odd


if num_even == 0:
    num_mod = 0
else:
    num_mod = 1

if num_odd + num_mod <= num_x4 + 1:
    print('Yes')
else:
    print('No')

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

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

if A > B + 1:
    print("No")
elif C != 0 and A > B:
    print("No")
else:
    print("Yes")

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    ac = [0] * n
    for i, v in enumerate(a):
        cnt = 0
        t = v
        while True:
            if t % 2 == 0 and cnt < 2:
                cnt += 1
                t //= 2
            else:
                ac[i] = cnt
                break
    if ac.count(0) == 0:
        print("Yes")
    else:
        if ac.count(1) == 0:
            if ac.count(0) - ac.count(2) <= 1:
                print("Yes")
            else:
                print("No")
        else:
            if ac.count(0) - ac.count(2) <= 0:
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    solve()

Solution (Python):
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
N -= max(cnt2 - 1 , 0)
print("Yes" if N // 2 <= cnt4 else "No")

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

Solution (Python):


N=int(input())
A=list(map(int,input().split()))
cnt4=0
cnt2=0
for i in range(N):
    if A[i]%4==0:
        cnt4+=1
    elif A[i]%2==0:
        cnt2+=1
wst=N-cnt4-cnt2
wst+=cnt2%2

if (wst+cnt4)%2==0:
    if wst<=cnt4:
        print('Yes')
    else:
        print('No')
else:
    if wst+1>=cnt4:
        print('Yes')
    else:
        print('No')

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

numbers = [0, 0, 0]

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

if (numbers[1] == 0) and (numbers[2] - numbers[0] <= 1):
    print('Yes')
elif (numbers[1] != 0) and (numbers[0] >= numbers[2]):
    print('Yes')
else:
    print('No')

Solution (Python):


n=int(input())
amod4=[i%4 for i in map(int,input().split())]

from collections import Counter
s=Counter(amod4)
num4=s[0]
num2=s[2]



def ok():print("Yes");exit()
def ng():print("No");exit()

if num2==n:
  ok()
  
if num4>=(n-(num2-1)*(n>num2>0))//2:ok()

else:
  ng()

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

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

kisuu = 0
four_baisuu = 0

for a in A:
    if a % 2 != 0:
        kisuu += 1
    elif a % 4 == 0:
        four_baisuu += 1
if kisuu <= four_baisuu:
    print("Yes")
elif kisuu + four_baisuu == len(A) and kisuu == four_baisuu + 1:
    print("Yes")
else:
    print("No")

Solution (Python):
N, *a = map(int, open(0).read().split())
fours = 0
even = 0
odd = 0
for x in a:
  if x%2 == 1:
    odd += 1
  elif x%4 == 0:
    fours += 1
  else:
    even += 1
ans = (odd <= fours) or (odd == fours + 1 and even == 0)
print('Yes' if ans else 'No')

Solution (Python):
n = int(input())
b = list(map(int, input().split()))
ln = []
ln2 =  []
for i in b:
    if i % 4 == 0:
        ln.append(i)
    if i % 2 == 0 and i % 4 != 0:
        ln2.append(i)
if n % 2 == 0:
    if len(ln) >= n//2:
        print('Yes')
    else:
            if n - len(ln) * 2 == len(ln2):
                print('Yes')
 
            else:
                    print('No')
if n % 2 == 1:
    if len(ln) >= (n - 1)//2:
        print('Yes')
    else:
        if n - len(ln) * 2 == len(ln2):
            print('Yes')
        else:
            if n == 3 and len(ln) == 1:
                print('Yes')
            else:
                print('No')

Solution (Python):
import math

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

x = math.ceil((n - 3) / 2) + 1

cnt4 = 0
cnt2 = 0
for i in a:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 4 != 0 and i % 2 == 0:
        cnt2 += 1
     
if (cnt4 + cnt2//2) >= x:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
cnt = 0
cnt1 = 0
for a in A:
  if a%4==0:
    cnt += 1
  elif a%2==0 and a%4!=0:
    cnt1 += 1
if int(n/2) <= cnt+(cnt1//2):
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np 
import collections

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

a_array = np.array(a_list)
mod4_array = a_array % 4
mod4_list = mod4_array.tolist()

counter = collections.Counter(mod4_array)

odd_num = counter[1] + counter[3]
div_2 = counter[2]
div_4 = counter[0]



if odd_num == 0:
    print('Yes')
else: 
    if odd_num <= div_4:
        print('Yes')
    elif odd_num == div_4 + 1:
        if div_2 == 0: 
            print('Yes')
        else:
            print('No')
    else:
        print('No')

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

four = 0
two = 0

for i in range(n):
    if a_li[i]%4 == 0:
        four += 1
    elif a_li[i]%2 == 0:
        two += 1

s = n//2

if s <= four:
    print("Yes")
    exit()
    
tmp = n - four*2

if tmp <= two:
    print("Yes")
else:
    print("No")

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

Solution (Python):
N=int(input())
L=list(map(int,input().split()))
s2,s4=0,0 
for j in L:
  if j%4==0:
    s4+=1
  elif j%2==0:
    s2+=1
if s2==0:
  if (N-s2-s4)<=s4+1:
    print("Yes")
  else:
    print("No")
else:
  if (N-s2-s4)<=s4:
    print("Yes")
  else:
    print("No")

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

no2=0
bai4=0
bai2=0
for i in range(len(a)):
  if a[i]%4==0:
    bai4+=1
  elif a[i]%2==1:
    no2+=1
  else:
    bai2+=1
if bai2==0:
  print(("No","Yes")[no2<=bai4+1])
else:
  print(("No","Yes")[no2<=bai4])

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

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

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

if four >= odd or four == odd-1 and even == 0:
    print("Yes")
else:
    print("No")

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

c2 = 0
c4 = 0
for a in A:
    r4 = a % 4
    if r4 == 0:
        c4 += 1
    r2 = a % 2
    if r2 == 0:
        c2 += 1
if c4 * 2 + 1 >= N or c4 * 2 + max(0, c2-c4) >= N:
    print('Yes')
else:
    print('No')

Solution (Python):

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

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

if len(a) % 2 == 1 and S[2] + 1 == S[0]:
    print("Yes")
    sys.exit()

if S[2] < S[0]:
    print("No")
else:
    print("Yes")