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 read(): return list(map(int, input().split()))


n = input()
a = read()

odd, four, not4 = 0, 0, 0
for i in a:
    if i % 4 == 0:
        four += 1
        continue

    if i & 1:
        odd += 1
    else:
        not4 += 1

odd += (not4 & 1)

print("Yes" if odd <= four + 1 else "No")

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

for j in range(N):

  if a[j]%2 == 1:
    one += 1
  elif a[j]%4 == 0:
    four += 1
  else :
    two +=1

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

else:

  print('No')

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

for j in range(N):

  if a[j]%2 == 1:
    one += 1
  elif a[j]%4 == 0:
    four += 1
  else :
    two +=1

print("Yes" if four >= one or (four == one - 1 and two == 0) else "No")

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

one = 0
two = 0
four = 0

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

print("Yes" if four >= one or (four == one - 1 and two == 0) else "No")

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

x1 = x2 = x4 = 0
for a in src:
    if a%2 == 1:
        x1 += 1
    elif a%4 == 0:
        x4 += 1
    else:
        x2 += 1

def solve():
    if x4 >= x1: return True
    if x4 + 1 == x1:
        return x2 == 0
    else: return False

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

Solution (Python):
import sys

def main():
    sys.stdin.readline()
    xs = sys.stdin.readline().strip().split(" ")
    n = 0
    m = 0
    l = 0

    for i in xs:
        if (int(i) % 2 == 1):
            m = m + 1
        elif (int(i) % 4 == 0):
            n = n + 1
        elif (int(i) % 4 == 2):
            l = l + 1

    if (l > 0 and n >= m):
        print("Yes")
    elif (l == 0 and n >= m - 1):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
m2, m4 = 0, 0
for i in range(N):
    if A[i] % 4 == 0:
        m4 += 1
    elif A[i] % 2 == 0:
        m2 += 1
m0 = N - m2 - m4
length = N - m2
msg = "No"
if (m4 >= m0) or (length % 2 == 1 and m2 == 0 and m4 >= m0 - 1):
    msg = "Yes"
print(msg)

Solution (Python):
n = int(raw_input())
l = map(int, raw_input().split())
feven = False
nodd = 0
nfour = 0
for i in l:
    if i % 4 == 0:
        nfour += 1
    elif i % 2 == 0:
        feven = True
    else:
        nodd += 1
if (feven and nfour >= nodd) or (not feven and nfour >= nodd - 1):
    print 'Yes'
else:
    print 'No'

Solution (Python):


N = int(raw_input())
a = map(int, raw_input().split())

def is_odd(n):
    return True if (n%2!=0) else False

def is_s_even(n):
    return True if (n%4!=0 and n%2==0) else False

def is_w_even(n):
    return True if (n%4==0) else False


p, q, r = [], [], []
for i in range(N):
    if is_odd(a[i]):
        p.append(a[i])
    elif is_w_even(a[i]):
        r.append(a[i])
    else:
        q.append(a[i])


s = []
if len(p) > 0:
    s.append(p.pop())
elif len(q) > 0:
    s.append(q.pop())
else:
    s.append(r.pop())

for i in range(1,N):
    if is_odd(s[i-1]):
        if len(r) > 0:
            s.append(r.pop())
        else:
            print 'No'
            exit()
    elif is_s_even(s[i-1]):
        if len(q) > 0:
            s.append(q.pop())
        elif len(r) > 0:
            s.append(r.pop())
        else:
            print 'No'
            exit()
    else:
        if len(p) > 0:
            s.append(p.pop())
        elif len(q) > 0:
            s.append(q.pop())
        elif len(r) > 0:
            s.append(r.pop())
            
print 'Yes'

Solution (Python):
def Q3(lst):
    import numpy as np
    N = len(lst)
    lst = np.array(lst)
    num4 = len(lst[np.where(lst % 4 == 0)])  
    num2 = len(lst[np.where((lst % 4 != 0) & (lst % 2 == 0))])  
    numOther = len(lst[np.where((lst % 4 != 0) & (lst % 2 != 0))])

    if num2 == 0:
        if numOther <= num4 + 1:
            return 'Yes'
        else:
            return 'No'
    else:
        if numOther <= num4:
            return 'Yes'
        else:
            return 'No'

n = int(input())
l = [int(i) for i in input().split()] 
print(Q3(l))

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

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

point = 0

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

if n % 2 == 1:
    if n <= point + 1:
        print("Yes")
    else:
        print("No")
else:
    if n <= point:
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys
from collections import Counter




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


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


def read_int():
    return int(input())


def read_str():
    return input()


def solve():
    n = read_int()
    a = read_int_list()
    c = Counter()

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

    if c[0] > c[2] + 1:
        return False
    if c[0] == c[2] + 1:
        return c[1] == 0
        
        
        
        
    if c[0] <= c[2]:
        return True


def main():
    res = solve()
    if res:
        print('Yes')
    else:
        print('No')


main()

Solution (Python):
n=input()
I=[int(x) for x in input().split()]
d1,d2,d4=0,0,0
for i in I:
    if i%4==0:
        d4+=1
    elif i%2 == 0:
        d2+=1
    else:
        d1+=1
if d2>0:
    d1+=1
if d4+1>=d1:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(raw_input())
a = map(int,raw_input().split(" "))
b = [0,0,0]

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

if (b[1] == 0 and b[2] + 1 >= b[0]) or (b[1] != 0 and b[2] >= b[0]):
	print "Yes"
else:
	print "No"

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

divisible_by_2 = 0
divisible_by_4 = 0
others = 0

for i in arr:
    if i % 4 == 0:
        divisible_by_4 += 1
    elif i % 2 == 0:
        divisible_by_2 += 1
    else:
        others += 1

if others > divisible_by_4:
    if divisible_by_2 == 0 and others == divisible_by_4 + 1:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Solution (Python):
import sys


def main():
    args = sys.stdin.readline().split()
    N = int(args[0])
    A = map(int, input().split())

    non_factor_cnt = 0
    factor_of_two_cnt = 0
    factor_of_four_cnt = 0
    for num in A:
        remainder = num % 4
        if remainder != 0:
            if remainder == 2:
                factor_of_two_cnt += 1
            else:
                non_factor_cnt += 1
        else:
            factor_of_four_cnt += 1

    if factor_of_two_cnt == 0:
        if factor_of_four_cnt >= non_factor_cnt - 1:
            print('Yes')
            sys.exit()
    if factor_of_four_cnt >= non_factor_cnt: 
        print('Yes')
        sys.exit()
    print('No')

main()

Solution (Python):
N = int(raw_input().rstrip())
a = map(int, raw_input().rstrip().split())
c = [0,0,0]
for i in range(N):
    if a[i] % 4 == 0:
        c[2] += 1
    elif a[i] % 2 == 0:
        c[1] += 1
    else:
        c[0] += 1
if c[1] > 0:
    print 'Yes' if c[2] >= c[0] else 'No'
else:
    print 'Yes' if c[2] >= c[0] - 1 else 'No'

Solution (Python):
number = int(input())
list = map(int,input().split())
yon_num = 0
ni_num = 0
odd_num = 0
for num in list:
    if num%4 == 0:
        yon_num += 1
    elif num%2 == 0:
        ni_num +=1
    else:
        odd_num += 1

    if ni_num != 0:
        ni_num = ni_num//2 + ni_num%2

if yon_num >= (odd_num + ni_num  + yon_num) // 2 :
    print('Yes')
else:
    print('No')

Solution (Python):


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

if set([num% 2 for num in nums]) == {0}:
    print("Yes")
    exit(0)

a,b,c = 0,0,0
for elem in nums:
    if elem % 4 == 0 : a += 1  
    else:
        b += 1  



c = 0
for elem in nums:
        if elem % 2 == 0 and elem % 4 != 0: c += 1

if N % 2 == 1:  
    if b-c <= (N-c+1)/2 : print("Yes")
    else: print("No")
else:  
    if b-c <= a : print("Yes")
    else: print("No")

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

Solution (Python):
N = input()
N = int(N)
a = input()
nums = a.split()
counter = 0
semi = 0
for i in range(N):
    n = int(nums[i])
    if n % 4 == 0:
        counter += 1
    elif n % 2 == 0:
        semi += 1
    else: continue
if counter >= N // 2 :
    print("Yes")
elif counter == 0 & semi == N:
    print("Yes")
elif semi >= (N - counter*2):
    print("Yes")
else:
    print("No")

Solution (Python):
n1 = 0
n2 = 0
n4 = 0
nb = int(input())
for v in map(int,input().split()):
   if v%4 == 0:
      n4 += 1
   elif v%2 == 0:
      n2 += 1
   else:
      n1 += 1
if (n1 <= n4) or (n1 == n4 + 1 and n2 == 0):
   print('Yes')
else:
   print('No')

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

    multi_2 = 0
    multi_4 = 0
    
    for num in a:
        if(num % 2 == 0):
            if(num % 4 == 0):
                multi_4 += 1
            else:
                multi_2 += 1
    
    
    
    pair_2 = int(multi_2 / 2)
    
    permitrange = 3 + (multi_4 - 1) * 2 + pair_2 * 2
    
    if(N <= permitrange):
        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 range(n):
    if a[i]%4==0: count4+=1
    elif a[i]%2==0: count2+=1

count=count4+count2//2
must=n//2

if count>=must: print("Yes")
else: print("No")

Solution (Python):

N=int(input())
a=[int(i) for i in input (). split ()]
M=0
M1=0
for i in range (N):
    if a[i]%2==0:
        M+=1
        a[i]//=2
        if a[i]%2==0:
            M1+=1
N-=M
if N==0:
    p="Yes"
elif M1>=N:
    p="Yes"
elif M==M1 and M1+1>=N:
    p="Yes"
else:
    p="No"
print (p)

Solution (Python):
size = int(input())
lists = input().split()
i = 0
nada = 0
twos = 0
fours = 0
while i < size:
	if int(lists[i]) % 4 == 0:
		fours += 1
	elif int(lists[i]) % 2 == 0:
		twos += 1
	else:
		nada += 1
	i += 1
if fours == 0 and nada + twos % 2 > 0:
	print("No")
elif nada + twos % 2 - 1<= fours:
	print("Yes")
else:
	print("No")

Solution (Python):
import collections as col


def convert(x):
    if x % 4 == 0:
        return 4
    elif x % 2 == 0:
        return 2
    else:
        return 1


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

    count = col.Counter(map(convert, a))

    if count[1] >= 1:
        if count[4] >= count[1]:
            print('Yes')
        elif count[1] == count[4] + 1 and count[2] == 0:
            print('Yes')
        else:
            print('No')

    else:  
        if count[4] >= 1:
            print('Yes')
        elif count[2] >= 2:
            print('Yes')
        else:
            print('No')

Solution (Python):
n = input()
nStr = input().split()
number = list(map(int,nStr))
 
frby = 1
twby = -1
 
for i in number:
    if i % 4 == 0:
        frby += 2
    elif i % 2 == 0:
        twby += 1
        
if int(n) == 1 and frby == 3:
    print("Yes")
elif int(n) == (twby + 1):
    print("Yes")
elif int(n) <= (frby):
    print("Yes")
elif int(n) <= (frby + twby):
    print("Yes")
else :
    print("No")

Solution (Python):

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

two_count = 0
four_count = 0
for i in a:
    if i >= 4 and i % 4 == 0:
        four_count += 1
    elif i >= 2 and i % 2 == 0:
        two_count += 1

if two_count <= 1:
    if len(a) == 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= len(a)//2 else "No")
else:
    check = len(a) - two_count
    if check == 0:
        print("Yes")
    elif check <= 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= math.ceil(check/2) else "No")

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

odd = []
even = []
four = []

for i in range(0, N):
	if int(list[i]) % 2 != 0:
		odd.append(list[i])
	elif int(list[i]) % 2 == 0 and int(list[i]) % 4 != 0:
		even.append(list[i])
	elif int(list[i]) % 4 == 0:
		four.append(list[i])

odd_num = len(odd)
even_num = len(even)
four_num = len(four)

if four_num >= odd_num - 1 and even_num == 0:
	print('Yes')
elif four_num >= odd_num:
	print('Yes')
else:
	print('No')

Solution (Python):
n = int(input())
n1 = 0
n2 = 0
n4 = 0
for a in map(int,input().split()):
  if a%4 == 0:
    n4 += 1
  elif a%2 == 0:
    n2 += 1
  else:
    n1 += 1
if n1 <= n4:
  print('Yes')
elif n1 == n4+1 and n2 == 0:
  print('Yes')
else:
  print('No')

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

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

if (c[1]==0) and (c[3]==0):
    print('Yes')
elif c[1] + c[3] < c[0] + 1:
    print('Yes')
elif (c[1] + c[3] == c[0] + 1)and(c[2] == 0):
    print('Yes')
else:
    print('No')

Solution (Python):


import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N = int(line)
        a = map(lambda x: int(x), sys.stdin.readline().split(" "))

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

        if counters[0] > (counters[2] + 1):
            print("No")
        elif counters[0] == (counters[2] + 1):
            if counters[1] > 0:
                print("No")
            else:
                print("Yes")
        else:
            print("Yes")
            
        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Solution (Python):



n = raw_input()
n = int(n)

a = raw_input()
a = a.split()
a = map(int,a)

count_2 = 0
count_4 = 0

for i in a:
    if i % 4 == 0:
        count_4 += 1
    elif i % 2 == 0:
        count_2 += 1

if count_4 >= n/2:
    print "Yes"
elif count_4*2 + count_2 >= n:
    print "Yes"
else:
    print "No"

Solution (Python):
tmp = int(input())
arr = [int(x) for x in input().split()]
nep = 0
krat = 0
for elem in arr:
    if elem % 4 == 0:
        krat += 1
        continue
    if elem % 2 == 1:
        nep += 1
if krat - nep >= -1:
    if krat - nep == -1:
        if nep + krat == tmp:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")
else:
    print("No")

Solution (Python):
if __name__ == "__main__":
    N = int(input())
    a = list(map(int, input().split()))
    n1 = 0
    n2 = 0
    n4 = 0
    for i in a:
        if i % 4 == 0:
            n4 += 1
        elif i % 2 == 0:
            n2 += 1
        else:
            n1 += 1
    if n2 == 0 and n4 == 0 and n1 == 1:
        print("Yes")
    else:
        if n1 <= n4:
            print("Yes")
        elif n1 == n4 + 1:
            if n2 == 0:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

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

Solution (Python):
from collections import Counter
n=int(input())
a=[int(i) for i in input().split()]
b=[]
for i in range(n):
 if a[i]%4==0:
    b.append(2)
 elif a[i]%2==0:
    b.append(1)
 else:
    b.append(0)
c=Counter(b)
if c[2]-c[0]>=0:
  print("Yes")
elif c[2]-c[0]==-1:
  if c[1]==0:
    print("Yes")
  else:
    print("No") 
else:
  print("No")

Solution (Python):
import numpy as np

N = int(raw_input())
l = np.array(map(int, raw_input().split()))

mod_4 = len(np.where((l % 4 == 0))[0])
mod_2 = len(np.where(l % 4 == 2)[0])

if N <= 2 and mod_4 == 0 and mod_2 <= 1:
    print 'No'
elif N <= mod_4 * 2 + 1:
    print 'Yes'
elif N <= mod_4 * 2 + mod_2 and mod_2 >= 2:
    print 'Yes'
elif N <= mod_4 * 2 + mod_2:
    print 'Yes'
else:
    print 'No'

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
num2 = sum(map(lambda x : 1 if not x%2 else 0, a))
num4 = sum(map(lambda x : 1 if not x%4 else 0, a))
if (N //2-  num4 - (num2-num4)//2 <= 0):
    print("Yes")
else:
    print("No")

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

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

    if four >= N // 2 or \
        etc == 0 or \
        two >= 2 and four >= etc:
        print('Yes')
    else:
        print('No')

main()

Solution (Python):
def f(ai):
    x = int(ai)%4
    if x == 0:
        return 4
    elif x == 2:
        return 2
    else:
        return 1

N = int(input())
a = list(map(f, input().split()))
num4 = a.count(4)
num2 = a.count(2)



if num2 > 1:
    N += - num2 + 1

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

Solution (Python):
import sys
N = int(input())
an = map(int, input().split())
f = []
d = []
o = []
for a in an:
    if a % 4 == 0:
        f.append(a)
    elif a % 2 == 0:
        d.append(a)
    else:
        o.append(a)
if len(f) >= len(o):
    print('Yes')
    sys.exit()
if len(f) + 1 == len(o):
    if len(d) == 0:
        print('Yes')
        sys.exit()
print('No')

Solution (Python):

import numpy as np

N = np.int64(input())
a = np.array([int(x) for x in input().split()])

mod_a = np.mod(a, 4)
count4 = (mod_a==0).sum()
count2 = (mod_a==2).sum()
odd = ((mod_a==1) | (mod_a==3)).sum()
if N % 2 == 0:
    if count4 >= odd:
        print('Yes')
    else:
        print('No')
else:
    if count4 >= odd - 1:
        print('Yes')
    else:
        print('No')

Solution (Python):
N = int(input())
li = [int(x) for x in input().split()]

counter = {
        0: 0,
        1: 0,
        2: 0,
        3: 0,
        }

for i in range(len(li)):
    li[i] = li[i] % 4
    counter[li[i]] += 1

if counter[2] == 0:
    zeroes = counter[0]
    nonzeroes = N - zeroes
    if zeroes >= nonzeroes or zeroes + 1 == nonzeroes:
        print("Yes")
        exit(0)
    else:
        print("No")
        exit(0)
else:
    zeroes = counter[0]
    nonzeroes = N - zeroes - counter[2]
    if zeroes >= nonzeroes:
        print("Yes")
        exit(0)
    else:
        print("No")
        exit(0)

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

f = 0
t = 0

for i in a:
    if i % 4 == 0: f += 1
    elif i % 2 == 0: t += 1    

h = t // 2
s = ((N - h * 2) // 2)
s2 = N

if s <= f or s2 <= t:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
odd=[]
two=[]
four=[]
for i in range(N):
    if a[i]%2!=0:
        odd.append(a[i])
    elif a[i]%4==0:
       four.append(a[i])
    else:
       two.append(a[i])
O=len(odd)
T=len(two)
F=len(four)

if O>F+1:
    print('No')
elif O==F+1:
    if T==0:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Solution (Python):
n=input()
data=list(map(int,input().split()))
a=[i for i in data if i%4==0]
b=[i for i in data if i%4!=0]
c=[i for i in b if i%2==0]
x=len(a)+len(c)//2
y=len(b)-len(c)//2
if y<=x+1:
    print('Yes')
else:
    print('No')

Solution (Python):

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

sum_2 = 0
sum_4 = 0
for i in range(len(a)):
    if a[i] % 4 == 0:
        sum_4 += 1
    elif a[i] % 2 == 0:
        sum_2 += 1

if len(a)//2 == sum_4 or (len(a)+1)//2 == sum_4:
    print('Yes')
elif sum_4*2 + sum_2 >= len(a):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
a_arr = input().split(' ')

for i in range(len(a_arr)):
    a_arr[i] = int(a_arr[i])

counter = {
        "two": 0,
        "for": 0,
        "one": 0
}

for j in range(len(a_arr)):
    if a_arr[j] % 4 == 0:
        counter['for'] += 1
    elif a_arr[j] % 2 == 0:
        counter['two'] += 1
    else:
        counter['one'] += 1

indicator = N - counter['two']/2

if counter['two'] % 2 != 0:
    counter['one'] += 1
    
if counter['one'] - counter['for'] <= 1:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = list(map(int, input().split(' ')))
four = [i for i in A if i % 4 == 0]
notFour = [i for i in A if i % 4 != 0]
two = [i for i in notFour if i % 2 == 0]
a = len(four)
b = len(two)
if N <= 2*a + 1 or N == b or b >= N - 2*a:
    print('Yes')
else:
    print('No')

Solution (Python):
def c():
    n = int(input())
    a = [int(ai) for ai in input().split()]
    div = {4:0, 2:0, 1:0}
    for i in a:
        if i % 4 == 0:
            div[4] += 1
        elif i % 2 == 0:
            div[2] += 1
        else:
            div[1] += 1
    if div[2] == 0:
        need = -1
    else:
        need = 0
    if div[4] - div[1] >= need:
        print('Yes')
    else:
        print('No')
    

c()

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

if mul4 >= (has_mul2+other-1) or other == 0:
    print('Yes')
else:
    print('No')

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

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

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

Solution (Python):



N = int(input())
A = list(map(int, input().split()))
cnt = 0
cnt2 = 0
for i in A:
    if i % 4 == 0:
        cnt += 1
    elif i % 2 == 0:
        cnt2 += 1
        
a = cnt >= len(A) // 2
b = cnt + cnt2 // 2 >= len(A) // 2
if a or b:
    print('Yes')
else :
    print('No')

Solution (Python):

 
def main():
	N = int(input())
	nums = list(map(int, input().split()))
	l_div4 = len([x for x in nums if x % 4 == 0])
	l_div2 = len([x for x in nums if x % 2 == 0])
	l_div0 = len(nums) - l_div2

	main_checker(l_div4, l_div2, l_div0)

def main_checker(l_div4, l_div2, l_div0):
	
	if l_div0 == 0:
		print("Yes")
	elif l_div4 >= l_div0 + ((l_div2 - l_div4) > 0) - 1:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

Solution (Python):


def main():
    n = int(input())

    n_odd = 0
    n_even = 0
    n_four = 0

    for x in (int(a) for a in input().split()):
        if x % 4 == 0:
            n_four += 1
        elif x % 2 == 1:
            n_odd += 1
        else:
            n_even += 1

    if n_even == 0:
        extra = 1
    else:
        extra = 0

    if n_odd <= n_four + extra:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
n=int(raw_input())
a=map(int,raw_input().split())
m4=0
m2=0
for x in a :
    if x%4==0 :
        m4 += 1
    elif x%2==0 :
        m2 += 1

if m2<=1:
    if m4+1>=n-m4:
        print 'Yes'
    else:
        print 'No'
else :
    n -= m2
    if m4>=n-m4:
        print 'Yes'
    else:
        print 'No'

Solution (Python):
'''input
6
2 7 1 8 2 8
'''
n = input()
a = map(int ,raw_input().split())
freq4 = 0
freq2 = 0
for i in a:
	if i%4 == 0:
		freq4 += 1
		continue
	if i%2 ==0 :
		freq2 += 1
if freq4 >= n//2 or freq4 + freq2//2 >= n//2:
	print "Yes"

else:
	print "No"

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

count_4 = 0
count_2 = 0
for i in A:
    count_4 += int(i % 4 == 0)
    count_2 += int(i % 2 == 0)
no_mul = N - count_2
count_2 -= count_4
if(no_mul <= count_4 or (count_2 == 0 and no_mul <= count_4 +1)):
    print("Yes")
else:
    print("No")

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

flag = -1
odd = 0
m4 = 0
for i in a:
    if i % 4 == 0:
        m4 += 1
    elif i % 2 == 0:
        flag = 0
    else:
        odd += 1

print('Yes' if m4 >= odd + flag else 'No')

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

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

two = 0
four = 0
odd = 0

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

if odd + four == n and odd-1 == four:
    print("Yes")
elif odd <= four:
    print("Yes")
else:
    print("No")

Solution (Python):

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

b = [a[i]%4 for i in range(N)]

if ( b.count(2)%2 + b.count(1) + b.count(3) > 1 + b.count(0) ):
    print("No")
else:
    print("Yes")

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

fours = 0
twos = 0
others = 0

for a in a_list:
    if a % 4 ==0:
        fours += 1
    elif a % 2 == 0:
        twos += 1
    else:
        others += 1

if others <= fours:
    print("Yes")
elif others-1 == fours and twos==0:
    print("Yes")
else:
    print("No")

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

count2 = 0
count4 = 0

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

if count4*2 + count2 >= N or (count4*2+1) >= N:
    print("Yes")
else:
    print("No")

Solution (Python):
n=input()
a=[0 for i in range(n)]
s=raw_input().split()
c2=0
c1=0
c=0
for i in range(n):
    t=int(s[i])
    if t%4==0:
        a[i]=2
        c2+=1
    else:
        if t%2==0:
            a[i]=1
            c1+=1
        else:
            a[i]=0
            c+=1
print "Yes" if (c2>=c) or (c2==c-1 and c1==0) else "No"