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

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    f = []
    t = []
    e = []
    for x in a:
        if x % 2:
            e.append(x)
        elif x % 4 == 0:
            f.append(x)
        else:
            t.append(x)
    if len(e) > len(f):
        if not t and len(e) == len(f) + 1 and len(f) != 0:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")


t = 1

for case in range(1,t+1):
    ans = solve()


"""



"""

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

ans = False
if c2 < 2:
    if c0 + c2 <= c4 + 1:
        ans = True
else:
    if c0 <= c4:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = tuple(map(int, input().split()))
qut = 0
odd = 0
for a in A:
  if a % 2 !=0:
    odd += 1
  elif a % 4 == 0:
    qut += 1
if odd <= qut or (N == odd + qut and odd <= qut + 1):
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
A = list(map(lambda x:int(x)%4, input().split()))
ans_list = []
for i in [0,1,2,3]:
  a = A.count(i)
  ans_list.append(a)
  
ans = ans_list[0] - (ans_list[1] + ans_list[3])
if ans_list[2] == 0 and ans >= -1:
  print("Yes")
elif ans_list[2] != 0 and ans >= 0:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt_odd = 0
    cnt_4 = 0
    cnt_2 = 0

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

    if cnt_odd == 0:
        print('Yes')
    elif cnt_2 > 0:
        if cnt_4 >= cnt_odd:
            print('Yes')
        else:
            print('No')
    else:
        if cnt_4 >= cnt_odd - 1:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
 
eight = 0
one = 0
two = 0
 
 
for i in A:
    if i%4 == 0:
        eight = eight + 1
    if i == 1:
        one = one + 1
    if i % 2 == 0 and i % 4 != 0:
        two = two + 1
 
if len(A)//2 <= eight:
    print("Yes")
elif (len(A)//2) <= (eight + (two//2)):
    print("Yes")
 
elif (eight >= one) and (eight + one +(two//2)) > (len(A)//2):
    print("Yes")
else:
    print("No")

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

ni = 0
yon = 0
hoka = 0

for a in A:
    if a % 4 == 0:
        yon += 1
    elif a % 2 == 0:
        ni += 1
    else:
        hoka += 1

if ni > 0:
    if yon >= hoka:
        print("Yes")
    else:
        print("No")
else:
    if yon >= hoka-1:
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
d = {"2":0,"4":0,"other":0}
for i in readInts():
	if i%4==0:
		d["4"]+=1
	elif i%2==0:
		d["2"]+=1
	else:
		d["other"]+=1

if d["4"]>=d["other"]+min(0,d["2"]-1):
	print("Yes")
else:
	print("No")

Solution (Python):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
d = {"2":0,"4":0,"other":0}
for i in readInts():
	if i%4==0:
		d["4"]+=1
	elif i%2==0:
		d["2"]+=1
	else:
		d["other"]+=1
if d["2"]>1:
	if d["4"]>=d["other"]:
		print("Yes")
	else:
		print("No")
else:
	if d["4"]+1>=d["other"]+d["2"]:
		print("Yes")
	else:
		print("No")

Solution (Python):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
d = {"2":0,"4":0,"other":0}
for i in readInts():
	if i%4==0:
		d["4"]+=1
	elif i%2==0:
		d["2"]+=1
	else:
		d["other"]+=1
if d["2"]>1:
	if d["4"]>=d["other"]:
		print("Yes")
	else:
		print("No")
elif d["2"]==1:
	if d["4"]+1>=d["other"]+d["2"]:
		print("Yes")
	else:
		print("No")
else:
	if d["4"]+1>=d["other"]:
		print("Yes")
	else:
		print("No")

Solution (Python):






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





mylist4 = [1 if x%4 == 0 else 0 for x in a]
mylist2 = [1 if x%2 == 0 else 0 for x in a]
b4 = sum(mylist4)
b2 = sum(mylist2)-b4
b1 = N-b2-b4
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()))
f = sum([1 for i in a if not i % 4])
if f >= int(N / 2):
  print('Yes')
else:
  s = sum([1 for i in a if not i % 2 and i % 4])
  if f + s // 2 >= int(N / 2):
    print('Yes')
  else:
    print('No')

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
a = LI()
cnt_4 = len([True for elem in a if elem % 4 == 0])
if cnt_4 >= n // 2:
    print('Yes')
    sys.exit()
rest = n - cnt_4 * 2
cnt_2 = len([True for elem in a if elem % 2 == 0 and elem % 4 != 0])
if rest == 1:
    print('Yes')
elif cnt_2 == rest:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
cnt4 = 0
cnt2 = 0
other = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
        continue
    if a % 2 == 0:
        cnt2 += 1
    else:
        other += 1
if cnt4+1 >= cnt2 + other or cnt4 >= other:
    print('Yes')
else:
    print('No')

Solution (Python):

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




multi4 = 0
multi2 = 0
other = 0
for a in A:
    if a % 4 == 0:
        multi4 += 1
    elif a % 2 == 0:
        multi2 += 1
    else:
        other += 1

if multi2 == 0:
    print('Yes' if other <= multi4 + 1 else 'No')
else:
    print('Yes' if other <= multi4 else 'No')

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

b=[0,0,0]
for i in a:
  if i % 4==0:
    b[0]+=1
  elif i % 2==0:
    b[1]+=1
  else:
    b[2]+=1
if b[2]<=b[0]:
  print("Yes")
elif b[2]-1==b[0] and b[1]==0:
  print("Yes")
else:
  print("No")

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

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

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

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

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

a = list(map(int,input().split()))
cnt_4 = 0
cnt_2 = 0
for v in a:
    if v % 4 == 0:
        cnt_4 += 1
    elif v % 2 == 0:
        cnt_2 += 1
if cnt_2 <= 1:
    if N//2 <= cnt_4:
        print('Yes')
    else:
        print('No')
else:
    if (N-(cnt_2-1))//2 <= cnt_4:
        print('Yes')
    else:
        print('No')

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

Solution (Python):
n=int(input())
lst=map(int,input().split())
od=0
fo=0

for a in lst:
    if (a%4)%2==1:
        od+=1
    elif a%4==0:
        fo+=1
if fo>=od:
    print("Yes")
elif 2*fo+1==n:
    print("Yes")
else:
    print("No")

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

count4=sum(a%4==0 for a in A)
c_odd=sum(a%2==1 for a in A)

if N%2==1:
    print('YNeos'[c_odd>count4+1::2])
else:
    print('YNeos'[c_odd>count4::2])

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

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

if num2>0:
    num1+=1

if num4>=num1-1:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

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

lst = [0]*N

for i in range(N):
  if As[i] % 4 == 0:
    lst[i] = 4
  elif As[i] % 2 == 0:
    lst[i] = 2
  else:
    lst[i] = 1
    
dic = Counter(lst)
  
if dic[1] <= dic[4]:
  print('Yes')
elif dic[1] - dic[4] == 1 and dic[2] == 0:
  print('Yes')
else:
  print('No')

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

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

Solution (Python):

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

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

if even > 0 and even % 2 == 1:
    odd += 1
    
if four + 1 >= odd:
    print('Yes')
else:
    print('No')

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

border_4 = n//2
border_2 = n

cnt_4=0
cnt_2=0

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


if cnt_4>=border_4:
    print('Yes')
elif n-cnt_4*2<=(cnt_2-cnt_4):
    print('Yes')
else:
    print('No')

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

border_4 = n//2
border_2 = n

cnt_4=0
cnt_2=0

for i in range(n):
    if a[i]%4==0:
        cnt_4+=1
    elif a[i]%4!=0 and a[i]%2==0:
        cnt_2+=1
    else:
        continue


if cnt_4>=border_4:
    print('Yes')
elif n-cnt_4*2<=cnt_2:
    print('Yes')
else:
    print('No')

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


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    div1 = 0
    div2 = 0
    div4 = 0
    for a in A:
        if a % 4 == 0:
            div4 += 1
        elif a % 2 == 0:
            div2 += 1
        else:
            div1 += 1
    
    
    
    
    
    if div2 == 0:
        return "Yes" if div1-1 <= div4 else "No"
    else:
        return "Yes" if div1 <= div4 else "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

if all(x % 2 == 0 for x in A):
    print("Yes")
else:
    cnt4 = 0
    cnt2 = 0
    for a in A:
        if a % 4 == 0:
            cnt4 += 1
        elif a % 2 == 0:
            cnt2 += 1
    cntOdd = N - cnt4 - cnt2
    if cntOdd <= cnt4 or (abs(cntOdd - cnt4) <= 1 and cnt2 == 0):
        print("Yes")
    else:
        print("No")

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    n0 = 0
    n4 = 0
    for i in a:
        if i%2 == 1:
            n0 += 1
        if i%4 == 0:
            n4 += 1
    if n0+n4 == n and n0 == n4+1:
        print("Yes")
    elif n0 > n4:
        print("No")
    else:
        print("Yes")

    return

if __name__ == '__main__':
    main()

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

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

b1 = b2 = b4 = 0

for c in a:
    if c % 4 == 0:
        b4 += 1
    elif c % 2 == 0:
        b2 = -1
    else:
        b1 += 1

if b1 <= b4+b2+1:
    print("Yes")
else:
    print("No")

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




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


if four < two%2 + odd - 1:
    print("No")
else:
    print("Yes")

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

four = sum([1 for a in As if a%4 == 0])
odd = sum([1 for a in As if a%2 == 1])
two = sum([1 for a in As if a%2 == 0 and a%4 != 0])
if four < two%2 + odd - 1:
    print("No")
else:
    print("Yes")

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
two=0
four=0
for a in A:
    if a%2==0 and a%4!=0:
        two+=1
    elif a%4==0:
        four+=1
if (len(A)-two+1)//2<=four and two!=0:
    print("Yes")
elif len(A)//2<=four and two==0:
    print("Yes")
else:
    print("No")

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

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
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:
        continue

flag = False
if num_4 >= n//2:
    flag = True
else:
    num = num_2 - num_2%2
    if num_4 >= (n - num)//2:
        flag = True

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

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

n2=n4=0

for a in A:
  if a%4==0:
    n4+=1
  elif a%2==0:
    n2+=1

c1=N//2 <= n4
c2=n4*2+n2 >= N

if c1 or c2:
  print("Yes")
else:
  print("No")

Solution (Python):






from collections import deque



import bisect

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

for i in range(n):
    if a[i]%2==0:
        n2+=1
    if a[i]%4==0:
        n4+=1
if n2==n:
  print("Yes")
  exit()
if n4>=n//2:
    print("Yes")
else:
    if (n2-n4)>=n-2*n4:
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys

input = sys.stdin.readline


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

    n_1 = 0
    n_4 = 0
    for aa in a:
        if aa % 2 == 1:
            n_1 += 1
        elif aa % 4 == 0:
            n_4 += 1

    if n_1 + n_4 == N:
        ans = "Yes" if n_1 - 1 <= n_4 else "No"
    else:
        ans = "Yes" if n_1 <= n_4 else "No"
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

N = int(sys.stdin.readline().strip())
A = map(int, sys.stdin.readline().strip().split())

not_even = 0
even = 0
four = 0 

for a_i in A:
    if a_i % 4 == 0:
        four += 1
    elif a_i % 2 == 0:
        even += 1
    else:
        not_even += 1

if not_even > four + 1:
    print("No")
else:
    if not_even == four + 1:
        if even == 0:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")

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

ok = []
no_and_no_even = []
no_and_even = []
for i in range(N):
    if (A[i] % 4 == 0):
        ok.append(A[i])
    elif (A[i] % 4 != 0 and A[i] % 2 == 0):
        no_and_even.append(A[i])
    else:
        no_and_no_even.append(A[i])

if (len(ok) == 0 and len(no_and_no_even) != 0):
    print('No')
    exit()
else:
    if (len(ok) < len(no_and_no_even) and len(no_and_even) != 0):
        print('No')
        exit()

if (len(ok) == len(no_and_no_even) or len(ok) == len(
        no_and_no_even) - 1 or len(ok) > len(no_and_no_even)):
    print('Yes')
else:
    print('No')

Solution (Python):
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    n = int(input())
    a = input_list()
    if list(set(a)) == [1]:
        print('No')
        exit()

    divide_counters = []
    for v in a:
        dt = divide_two(v)
        if dt == 0:
            divide_counters.append(1)
        elif dt == 1:
            divide_counters.append(2)
        else:
            divide_counters.append(4)
    
    if set(divide_counters) == {1, 4}:
        if divide_counters.count(1) <= divide_counters.count(4) + 1:
            print('Yes')
            exit()
        else:
            print('No')
            exit()
    if divide_counters.count(1) <= divide_counters.count(4):
        print('Yes')
    else:
        print('No')
        
def divide_two(n):
    c = 0
    while True:
        if c >= 2:
            break
        if n % 2 != 0:
            break
        n //= 2
        c += 1
    return c

def get_camulative(l):
    import itertools
    
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Solution (Python):
def answer(arr):
    a = 0 
    b = 0 
    c = 0 
    
    for i in range(len(arr)):
        if arr[i]%4 == 0: a += 1
        elif arr[i]%2 == 0: b += 1
        else: c += 1
    
    if b > 0 : a -= 1
    if c - a > 1: return "No"
    else: return "Yes"

n = input()
arr = list(map(int, input().split()))
print(answer(arr))

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
f=[]
od=[]
ev=[]

for i in range(n):
  if a[i]%4==0:
    f.append(a[i])
  elif a[i]%2==1:
    od.append(a[i])
  else:
    ev.append(a[i])
if len(f)>=len(od) and ev!=[]:
  print('Yes')
elif len(f)<len(od) and ev!=[]:
  print('No')
elif ev==[] and len(f)>=len(od)-1:
  print('Yes')
else:
  print('No')

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

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

num_mul2 = 0
num_mul4 = 0

for a in as_:
    if a % 4 == 0:
        num_mul4 += 1
    elif a % 2 == 0:
        num_mul2 += 1

d = n - num_mul4 * 2 - (num_mul2 // 2) * 2
if num_mul4 > 0:
    d -= 1

if d <= 0:
    print('Yes')
else:
    print('No')

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

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

    def count(x):
        ret = 0
        while x % 2 == 0:
            x //= 2
            ret += 1
        return ret

    B = map(count, A)

    ctr = [0] * 3
    for x in B:
        ctr[min(x, 2)] += 1

    if ctr[1] == 0:
        cond = ctr[0] - ctr[2] <= 1
    else:
        cond = ctr[2] >= ctr[0]

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


if __name__ == '__main__':
    main()

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

zero = 0
two = 0
four = 0

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

if two == 0:
    if four >= zero - 1:
        print('Yes')
    else:
        print('No')

else:
    if four >= zero:
        print('Yes')
    else:
        print('No')

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    a4 = 0; a2 = 0
    for a in A:
        if a%2 == 0:
            a2 += 1
        if a%4 == 0:
            a4 += 1
    a2 -= a4

    if N//2 <= a4:
        print('Yes')
    else:
        if N - 2*a4 <= a2:
            print('Yes')
        else:
            print('No')

if __name__ == "__main__":
    main()

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

A=list(map(int, input().split()))
nons=[]
twos=[]
fours=[]
for a in A:
    if a%4==0:
        fours.append(a)
    elif a%2==0:
        twos.append(a)
    else:
        nons.append(a)


if len(twos)==0 and len(fours)+1==len(nons):
    print("Yes")
elif len(fours)>=len(nons):
    print("Yes")
else:
    print("No")

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

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

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

nodd=N-c2
c2=c2-c4
if c2>0:
  nodd+=1
if c4>=nodd-1:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()



a4=0
a0=0
a2=0
for i in range(n):
    if a[i]%4==0:
        a4+=1
    elif a[i]%4==1 or a[i]%4==3:
        a0+=1
    else:
        a2+=1

if a2==0 and a4>=a0-1:
    print("Yes")
    exit()
if a4>=a0:
    print("Yes")
else:
    print("No")

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

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

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

if n % 2 == 0:
    if cnt1 <= cnt4:
        print("Yes")
    else:
        print("No")
else:
    if cnt1 - 1 <= cnt4:
        print("Yes")
    else:
        print("No")

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
x = 0
y = 0
z = 0
for i in range(N):
  a = A[i]
  c = 0
  while a%2== 0:
      a = a//2
      c += 1
  if c == 0:
    x += 1
  elif c == 1:
    y += 1
  else:
    z += 1
ans = 'No'
if x<=z:
  ans = 'Yes'
elif y == 0 and x==z+1:
  ans = 'Yes'
  
print(ans)

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().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
    
    m=min(n,n-cnt_2+1)
    if cnt_4>=m//2:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Solution (Python):
import sys

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


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

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

    print("Yes" if n - max(0, cnt_2 - 1) <= cnt_4 * 2 + 1 else "No")


if __name__ == '__main__':
    resolve()

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

a=0;b=0;c=0
L = list(map(int,input().split()))
for i in range(N):
  if L[i]%4 == 0:
    c += 1
  elif L[i]%2 == 0:
    b += 1
  else:
    a += 1
t = a+b+c

ans = "No"
if a == 0:
  ans = "Yes"
elif c >= a:
  ans = "Yes"
elif b == 0 and a == c+1:
  ans ="Yes"
print(ans)

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

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    cnt1=0
    cnt2=0
    cnt4=0
    for i in l:
        if i%2==1:
            cnt1+=1
        elif i%4==0:
            cnt4+=1
        else:
            cnt2+=1
    if cnt2==0 and cnt4+1>=cnt1:
        print('Yes')
    elif cnt2>0 and cnt4>=cnt1:
        print('Yes')
    else:
        print('No')
resolve()

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

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

if c4 >= cnt or (c2 == 0 and c4+1 == cnt):
    ans = "Yes"
else:
    ans = "No"
print(ans)

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

cnt1=0
cnt2=0
cnt4=0

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

if cnt2!=0:
  if cnt4>=cnt1:
    print('Yes')
  else:
    print('No')
else:
  if cnt4+1>=cnt1:
    print('Yes')
  else:
    print('No')

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

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
cnt = int(cnt)

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

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

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

if c4+c2>=len(a):
    print("Yes")
elif c4+1>=len(a):
    print("Yes")        
else:
    print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
four=0
two=0
one=0
for i in a:
    if i%4==0:
        four+=1
    if i%2==0:
        two+=1
    else:
        one+=1
if int(n/2)==four:
    print('Yes')
elif n==two:
    print('Yes')
elif four == one + 1 or four == one:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
kisuu = 0
guusuu = 0
baisuu_4 = 0

for num in a:
  if num%2 == 1:
    kisuu += 1
  elif num%4 == 2:
    guusuu += 2
  else:
    baisuu_4 += 1

if guusuu ==0:
  if baisuu_4 >= kisuu - 1:
    print('Yes')
  else:
    print('No')
else:
  if baisuu_4 >= kisuu:
    print('Yes')
  else:
    print('No')

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))

    c0 = 0
    c4 = 0

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


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

if cnt4 >= n // 2:
    print("Yes")
    exit()
elif cnt4 >= (n - cnt2 + 1) // 2:
    print("Yes")
    exit()
print("No")

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
nums = {0:0,1:0,2:0,3:0}
for i in range(n):
    num = a[i] % 4
    nums[num] += 1
if nums[2] % 2 == 0:
    if nums[1] + nums[3] - 1 <= nums[0]:
        print("Yes")
    else:
        print("No")
elif nums[2] % 2 == 1:
    if nums[1] + nums[3] <= nums[0]:
        print("Yes")
    else:
        print("No")

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

mod_four = len([i for i in A if i % 4 == 0])
odd_number = len([i for i in A if i % 2 == 1])

if mod_four >= odd_number:
    print("Yes")
elif mod_four + 1 == odd_number and N - mod_four - odd_number == 0:
    print("Yes")
else:
    print("No")

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

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

if n - (l.count(2)*2 + 1) <= 0:
    print("Yes")
elif n - (l.count(2)*2 + 1) < l.count(1):
    print("Yes")
else:
    print("No")

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

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

resZero = 0
resTwo = 0
odds = 0
for a in A:
    if a % 4 == 0:
        resZero += 1
        continue
    elif a % 4 == 2:
        resTwo += 1
        continue
    else:
        odds += 1

if resZero - odds >= -1 and resTwo == 0:
    print('Yes')
    quit()
if resZero - odds >= 0:
    print('Yes')
    quit()
print('No')

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    a = list(map(int,input().split()))
    odd, two, four = 0, 0, 0
    for i in range(N):
        if a[i]%4 == 0:
            four += 1
        elif a[i]%2 == 0:
            two += 1
        else:
            odd += 1
    if four == odd:
        print("Yes")
    elif two == N:
        print('Yes')    
    elif four >= N//2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()