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



Sample input:
3
1 10 100


Sample output:
Yes

Submission status: Runtime Error

Solution code:
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 == 2 and ans[i - 1] % 4 != 0:
        if sonota:
            s = sonota.pop()
            ans.append(s)
        elif bai4:
            s = sonota.pop()
            ans.append(s)
        else:
            break
    else:
        if kisuu:
            s = kisuu.pop()
            ans.append(s)
        elif sonota:
            s = sonota.pop()
            ans.append(s)
        elif bai4:
            s = sonota.pop()
            ans.append(s)
        else:
            break
print('No')

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
cnt1=0
cnt4=0
for i in a:
  if i%2==1:
    cnt1+=1
  elif cnt%4==0:
    cnt4+=1
if cnt4>=cnt1+1:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
fuga = input()
hoge = list(map(int,input().split()))
count_even = 0
count_divisibleBy4 = 0
for i in hoge:
  if i % 2 == 0:
	count_even += 1
	if i % 4 == 0:
		count_divisibleBy4 += 1
      
if count_even == len(hoge) or count_divisibleBy4 >= len(hoge) // 2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
fuga = input()
hoge = list(map(int,input().split()))
count_even = 0
count_divisibleBy4 = 0
for i in hoge:
  if i % 2 == 0:
    count_even += 1
  	if i % 4 == 0:
      count_divisibleBy4 += 1
      
if count_even == len(hoge) or count_divisibleBy4 >= len(hoge) // 2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
_ = input()
hoge = map(int,input().split())
count_even = 0
count_divisibleBy4 = 0
for i in hoge:
  if i % 2 == 0:
    count_even += 1
  	if i % 4 == 0:
      count_divisibleBy4 += 1
      
if count_even == len(hoge) or count_divisibleBy4 >= len(hoge) // 2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

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

n2 = 0
n4 = 0

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

if not n2 and n4:
  n2 += l
if n2 + n4 * 2 >= n:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

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

one_list = []
two_list = []
four_list = []

for i in range(N):
    if a[i]%2 == 0:
        if a[i]%4 == 0:
            four_list.append(a[i])
        else:
            two_list.append(a[i])
    else:
        one_list.append(a[i])
        
if len(two_list) > 0:
    if len(four_list) >= len(one_list):
        print('Yes')
    else:
        print('No')
else:
    if len(four_list)+1 >= len(one_list)
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
count4=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
count1=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
    else:
        count1+=1
if count2==0:
    if count1<=count4+1:
        print("Yes")
    else:
        print("No")
else:
    if count1<count4:
        print("Yes")
    else:
        print("No")

    

    
"""
#print(count2)
if 1<=count2:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

    """
"""    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト

"""

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input(),split()))
count=0
for i in range(n):
    if a[i]%4==0:
        count+=1

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

Submission status: Runtime Error

Solution code:
from numpy import log
def f(k):
  c=0
  while k % 2 == 0:
    k //= 2
    c+=1
    if c==2:
      break
  return c
def g(k):
  return f(int(k))
n=int(input())
a=list(map(g,input().split()))
a.sort()
ct0=a.count(0)
ct1=a.count(1)
ct2-a.count(2)
if ct0 > ct2:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
n = int(input())
l=list(map(int ,input().split()))
four=0
two=0
one=0
for i in range(n):
	if l[i]%2==0:
		if l[i]==2:
			two+=1
		else:
			four+=1
	elif l[i]==1:
		one+=1

if four>=n//2:
	print('Yes')
elif one>=1 and two==0:
	if one//2>=four and n-one//2<=four-(one//2):
		print('Yes')
elif one==0 and two>=1:
	if two==1:
		four>1 and n-2//four<=four-1:
			print('Yes')
	elif two>=2:
		two+four>=n//2:
			print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
l=list(map(int ,input().split()))
four=0
two=0
one=0
for i in range(n):
	if l[i]%2==0:
		if l[i]==2:
			two+=1
		else:
			four+=1
	elif l[i]==1:
		one+=1

if four>=n//2:
	print('Yes')
elif one>=1 and two==0:
	if one//2>=four and n-one//2<=four-(one//2):
		print('Yes')
elif one==0 and two>=1:
	if two==1:
		four>1 and n-2//<=four-1:
			print('Yes')
	elif two>=2:
		two+four>=n//2:
			print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
l_4=0
for i in l:
  i%4=0:
    l_4+=1
if n%2==0 and l_4>=l%2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
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 cnt2>1:
    ans=len(a)-cnt4*3-cnt2
if cnt2==1:
    ans=len(a)-cnt4*3
print("Yes" if ans<=0 else "No")

Submission status: Runtime Error

Solution code:
n = int(input())

odd = 0
two = 0
four = 0

for i in range(n):
    a = int(input())
    if(a%2): odd += 1
    else:
        if(a%4==0):four+=1
        else: two += 1


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

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

Submission status: Runtime Error

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

cnt_of_4 = 0
cnt_of_2 = 0
cnt_of_1 = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt_of_4 += 1
    elif a[i] == 2:
        cnt_of_2 += 1
    else:
        cnt_of_1 += 1

if cnt_of_4 == N//2:
    print('Yes')
else:
    if cnt_of_1 < cnt_of_4:
        cnt_of_2 = cnt_of_2 - (cnt_of_4-cont_of1)
    if cnt_of_4 * 2 + ((cnt_of_2//2)*2) >= N:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = input()
A = list(map(int, input()))
odd, four = 0, 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  else:
    if A[i] % 2 == 1:
      odd += 1
if four < odd and four + odd < N:
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
c4 = sum(1 for x in a if x % 4 == 0)
c1 = sum(1 for x in a if x % 2 == 1)
if c4 >= c1 or (c4 >= c1 - 1 and c4 + c1 == n):
  print("Yes")
else
  print("No")

Submission status: Runtime Error

Solution code:
N=int(input());A=input();v=[int(i)%4for i in A[::2]];print('Yes'if v.count(0)+v.count(2)//2>=N//2 else'No')

Submission status: Runtime Error

Solution code:
N=int(input());A=input();v=[int(i)%4for i in A];print('Yes'if v.count(0)+v.count(2)//2>=N//2 else'No')

Submission status: Runtime Error

Solution code:
import math
import collections
N = int(input())
A = [int(i) for i in input().split()]

def trial_division(n):
    Num = n
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return [Num]
    else:
        factor.append(n)
        return factor


List = [[] for i in range(N)]
for i in range(N):
    tmp = trial_division(A[i])
    tmp = collections.Counter(tmp)
    List[i] = tmp[2]

cnt0,cnt1,cnt2 = 0,0,0
for i in range(len(List)):
    if List[i]==1 and List[i+1]!=1:
        cnt0 += 1

    if List[i]==0:
        cnt0+=1
        
    elif List[i]==1:
        cnt1+=1
        
    else:
        cnt2 += 1
        


if cnt2+1>=cnt0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import math
import collections
N = int(input())
A = [int(i) for i in input().split()]

def trial_division(n):
    Num = n
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return [Num]
    else:
        factor.append(n)
        return factor


List = [[] for i in range(N)]
for i in range(N):
    tmp = trial_division(A[i])
    tmp = collections.Counter(tmp)
    List[i] = tmp[2]

cnt0,cnt1,cnt2 = 0,0,0
for i in range(len(List)):
    if List[i]==1 and List[i+1]!=1:
        cnt0 += 1

    if List[i]==0:
        cnt0+=1
        
    elif List[i]==1:
        cnt1+=1
        
    else:
        cnt2 += 1
        


if cnt2+1>=cnt0:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
print((n-1)*(m-1))

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
cnt = 0
cnt2 = 0
cnt3 = 0
for i in a:
    if i % 2 != 0:
        cnt3 += 1
    elif i % 4 == 0:
        cnt += 1
    else:
    cnt2 += 1
if cnt2 == 0:
    if cnt3 <= cnt + 1:
        print('Yes')
    else:
        print('No')
else:
    if cnt3 <= cnt:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

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

o = 0
f = 0
t = 0
for i in a:
  if i % 2 == 1:
    o += 1
  if i % 4 == 0:
    f += 1
  if i % 4 == 2:
    t += 1
if f >=0 o-1 and t == 0:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
N,A=map(int,open(0).read().split());l=[0]*4
for a in A:l[a&3]+=1
print("YNeos"[d[1]+d[3]>1+d[0]::2])

Submission status: Runtime Error

Solution code:
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1

print('Yes' if a_4 >= a_1+a_2 else 'No')

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(i) for i in input().split()]

check=0
check2=0
for i in a:
    if i%4==0:
        check+=1
    elif i%2==0:
        check2+=1
n=n-check2+1
    
else:
    print('Yes' if n//2<=check else 'No')

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
n4=sum([i%4==0 for i in l])
n2=sum([i%2==0 for i in l])-n4
if n4>=max(n//2,1):
    print("Yes")
else:
    if (n//2)*2-n4*2<=n2:
        print("Yes"):
    else:print("No")

Submission status: Runtime Error

Solution code:
N=int(input())
d4=0
d2=0
for a in input().split():
    if a%4==0:
        d4+=1
    elif a%2==0:
        d2+=1

if 2*d4+d2>=N:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import itertools
import math
N = int(input())
As =list(map(int,input().split(" ")))
odds = 0
two = 0
four = 0
nums = []
for a in As:
    if a % 2 == 1:
        odds += 1
    elif a % 4 == 0:
        four += 1
    else:
        two += 1
if odds > 0:
    nums.append(1)
    odds -= 1
elif two > 0:
    nums.append(2)
    two -=1
else:
    nums.append(4)
    four-=1
ans = "Yes"

if N==2:
    if As[0] * As[1]%4 !=0:
       ans = "No"
else:
    for i in range(1,N):
        if nums[i-1] == 1:
            if four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"
        elif nums[i - 1] == 2:
            if two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"

        elif nums[i - 1] == 4:
            if odds> 0:
                nums.append(1)
                odds -= 1
            elif two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
an = list(map(int,input().split()))

odd = filter((lambda x:x%2==1),an)
div4 = filter((lambda x:x%4 ==0),an)
div2 = set(an).difference(set(odd)).difference(set(div4))
if len(div2) == 0:
  div4.append(0)
if len(odd) <= len(div4)+1:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=I()
A=[I() for i in range(N)]
# ignore %2==0 numbers
f=[]
odds=[]
for n in N:
    if n%4==0:
        f.append(n)
    elif n%2!=0:
        odds.append(n)
if len(odds)==0:
    print('Yes')
elif len(f) < len(odds)-1:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
a1,a2,a4=0,0,0

for i in range(1):
    # Start Input code ---------------------------------------
    n=int(input())
    for i in range(n):
        x=int(input())
        if x%4==0:
            a4+=1
        elif x%2==0:
            a2=1
        else:
            a1+=1
ans='Yes' if a1+a2<=a4+1 else 'No'
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
not_two=0
yes_four=0
for i in a:
  if a%2!=0:
    not_two+=1
  if a%4==0:
    yes_four+=1
if yes_four-not_two>=1:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
A =list(map(int,input().split()))
num4 = 0
num2 = 0
num1 = 0
for a in A:
    if a%4 == 0:
        nu+= 1
    elif a%2 == 0:
        num2 += 1
    else:
        num1 += 1

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

Submission status: Runtime Error

Solution code:
N = int(input())
l = [int(input()) for i in range(N)]

cnt_t = 0
cnt_f = 0

for i in l:
  if i%4=0:
    cnt_f += 1
  else:
    cnt_t += 1

num = N-cnt_t-cnt_f

if num <= cnt_f+1:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
L = list(map(int,input().split()))
one = list(filter(lambda x:x%2!=0,L))
two = list(filter(lambda x:x%4!=0 and x%2==0,L))
four = list(filter(lambda x:x%4==0,L))
if len(one) - len(four) == 1 :
    if len(two) >=1 :
        print("No")
    else:
        print("Yes")
elif len(one) =< len(four):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n=int(input())
a=[1 for i in list(map(int,input().split())) if i%4==0]
print("Yes" if len(a)>=n//2 "No")

Submission status: Runtime Error

Solution code:
a = int(input())
c = list(map(int,input().split()))
c1=c2=c4=0
for i in c:
    if c%2==1:
        c1+=1
    elif c%4==0:
        c4+=1
    else:c2+=1
if c1+1>c4:print("No")
elif c1+c2-c4==1:print("Yes")
elif c1<=c4:print("Yes")

Submission status: Runtime Error

Solution code:
a = int(input())
c = list(map(int,input().split()))
c1=c2=c34=0
for i in c:
    if c%2==1:
        c1+=1
    elif c%4==0:
        c4+=1
    else:c2+=1
if c1+1>c4:print("No")
elif c1+c2-c4==1:print("Yes")
elif c1<=c4:print("Yes")

Submission status: Runtime Error

Solution code:
a = int(input())
c = list(map(int,input().split()))
for i in c:
    if c%2==1:
        c1+=1
    elif c%4==0:
        c4+=1
    else:c2+=1
if c1+1>c4:print("No")
elif c1+c2-c4==1:print("Yes")
elif c1<=c4:print("Yes")

Submission status: Runtime Error

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

c4=0
c2=0

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

if c4==0:
    if all(for a[i]%2==0 i in range(n)):
       print('Yes')
elif n<=2*c4 + c2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

c4=0
c2=0

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

if c4==0:
    if all(a[i]%2==0 i in range(n)):
       print('Yes')
elif n<=2*c4 + c2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

c4=0
c2=0

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

if n<=2*c4 + c2
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
b = int(input())

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

co = 0
s = 0
ss = 0

for i in range(len(a)):
  while a[i] % 2 == 0:
    co += 1
    a[i] //= 2
  if co == 1:
    s += 1
  elif co >= 2:
    ss += 1
  
b -= s

if b % 2 == 1 && s > 0:
  b += 1
elif b % 2 == 1 && s == 0:
  b -= 1
b //= 2

if ss >= b:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
# input
N = int(input())
a = [int(input()) for _ in range(N)]

# 4の倍数, 奇数の数
i, j = 0, 0

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

if j >= i + 2:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
src = list(map(int,input().split()))
odd = two = four = 0
for a in src:
    if a%2: odd += 1
    elif a%4==0: four += 1
    else: two += 1
if two:
    print('Yes' if odd <= four else 'No)
else:
    print('Yes' if odd <= four+1 else 'No')

Submission status: Runtime Error

Solution code:
# when input length is odd, n-1 / 2
# when input length is even, n / 2
# 6
# 2 7 1 8 2 8
# 1 8 7 8 2 2
# # # # # #
# 3個(len/2)４の倍数がYesを出力できる
# 4の倍数の個数がlen/2以下になるときその個数分*2個分２があれば、Yesを出力できる
N = int(input())
input_list = [int(i) for i in input().split()]
four_count = 0
two_count = 0

for i in input_list:
    if i % 4 == 0:
        four_count += 1
    elif i % 2 == 0:
        two_count += 1

const = N // 2

if const > four_count:
    if 2 * (const - four_count) =< two_count:
        print("Yes")
    else:
        print("No")
elif const == four_count:
    print("Yes")
else:
    print("Yes")

Submission status: Runtime Error

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

zero = 0
two = 0
odd = 0

for i in range(len(a)):
    if a[i] % 4 == 1 or a[i] % 4 == 3:
        odd = odd + 1
    elif a[i] % 4 == 0:
        zero = zero + 1
    else:
        two = two + 1
        
if zero >= odd -1 and two =n = int(input())
a = list(map(int,input().split()))

zero = 0
two = 0
odd = 0

for i in range(len(a)):
    if a[i] % 4 == 1 or a[i] % 4 == 3:
        odd = odd + 1
    elif a[i] % 4 == 0:
        zero = zero + 1
    else:
        two = two + 1
        
if zero >= odd -1 and two = 0:
    print('Yes')
elif zero >= odd:
    print('Yes')
else:
    print('No')= 0:
    print('Yes')
elif zero >= odd:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

zero = 0
two = 0
odd = 0

for i in range(len(a)):
    if a[i] % 4 == 1 or a[i] % 4 == 3:
        odd = odd + 1
    elif a[i] % 4 == 0:
        zero = zero + 1
    else:
        two = two + 1
        
if zero >= odd -1 and two = 0:
    print('Yes')
elif zero >= odd:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int, input().split()))
b=len(a)
c=len([i for i in a if i%2==0])
a2=len([i for i in a if i%4==0])
a1,a0=c-a2,b-c
if a0>0 and a2>=a0-1 and a2+a1>=2: print('Yes')
elif:  a2+a1>=2: print('Yes')
else: print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
R = [0 for i in range(2)]
st = input().split()
for i in range(N):
    k = int(st[i])
    m = 0
    if k % 4 == 1 or k % 4 == 3:
        m = 0
    elif k % 4 == 2:
        m = 1
    else:
        m = 2
    R[m] += 1
    

if R[1]+R[2]*2 < 2*(N-1):
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
N = int(raw_input())
a = map(int, raw_input().split(" ")[-2:])

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    b = 4/0
    print "No"

Submission status: Runtime Error

Solution code:
N = int(raw_input())
a = map(int, raw_input().split(" ")[-2:])

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes" if(c1 <= c2)
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    b = 4/0
    print "No"

Submission status: Runtime Error

Solution code:
N = int(raw_input())
a = map(int, raw_input().split(" ")[-2:])

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes" if(c1 <= c2)
elif c1 - 1 == c2 and N == c1 + c2
    print "Yes"
else:
    b = 4/0
    print "No"

Submission status: Runtime Error

Solution code:
N = int(raw_input())
a = map(int, raw_input().split(" ")[-2:])

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    if ai % 4 == 0:
        c2 += 1

print "Yes" if(c1 <= c2 || (c1 - 1 == c2 and N == c1 + c2))else "No"

Submission status: Runtime Error

Solution code:
if 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')

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
a_n4 = a_4 = [x for x in a if x%4!=0]
a_4 = [x for x in a if x%4==0]
a_2 = [x for x in a if x%4!=0 and x%2==0]

if (len(a_n4)<=1+len(a_4) and len(a_2)<=1) or (len(a_n4)<=len(a_4) and len(a_2)>1) ):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = input()
a = map(int, raw_input().split())
n4 = 0
n2 = 0

for i in a:
    if i % 4 == 0:
        n4 += 1
    else:
        n2 += 1

if n2 / n4 > 2:
    print "No"
else:
    print "Yes"

Submission status: Runtime Error

Solution code:
a=int(input())
lst=list(map(int,input().split()))
for i in lst:
   if i%4==0:
     ret= "yes"
   else:
     pass
print(ret)

Submission status: Runtime Error

Solution code:
N = int(input())
al = [int(an) for an in input().split()]
a = [ "4" if al[i]%4==0 else "k" if al[i]%2!=0 else "g" for i in range(N)]
print(a)
if a.count("k") == a.count("4") or len(a) == a.count(g):
	print("Yes")
elif (a.count("k") - 1) == a.count("4")  and a.count("g")==0:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
n= int(input())

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

k = len(filter(lambda(x, x%4), a))
j = len(filter(lambda(x, x%2), a))-k
i = len(a)-j-k

if (j > 0) and (i+1 <= k):
    print("Yes")
if (j == 0) and (i-1 <= k):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
num = input()
list = map(int, raw_input().split())
count1 = 0
count4 = 0
for x in list:
    if x % 2 == 1:
        count1 = count1 + 1
    if x % 4 == 0:
        count4 = count4 + 1
if count1 > count4 and num > 3:
    print("No")
elif num = = 2 and count4 - count1 >= 0
    print("Yes")
elif num == 3 and count4 > 0 or count1 == 0
    print("Yes") 
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
p=0
f=0
for ai in a:
    if ai%2!=0:
        p+=1
    else:
        if ai/2%2==0:
            f+=1
if f==0:
    print('No')
elif f==1:
    if n>3:
        print('No')
    else:
        print('Yes')
elif p>f:
    if p%2=1 and 2*p-1==n:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
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')

Submission status: Runtime Error

Solution code:
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:
  print('Yes')
else :
  if two == 0 and four == one -1:
     print('Yes')
  else:
     print('No')

Submission status: Runtime Error

Solution code:
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:
  print('Yes')
else :
  if (two == 0 and four == one -1):
     print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
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:
  print('Yes')
else :
  if two == 0 and four == one -1:
     print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
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:
  print('Yes')
else :
  if two == 0:
    if four == one-1:
      print('Yes')
    else:
      print('No')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
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:
  print('Yes')
else :
  if two == 0:
    if four == one-1:
      print('Yes')
    else:
      print("No")
  else:
    print('No')

Submission status: Runtime Error

Solution code:
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:
  print('Yes')
else :
  if two == 0:
    if four == one-1:
      print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
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:
	print('Yes')
else :
	if two == 0:
          if four >= (one+1):
	    print('Yes')
        else:
	  print('No')

Submission status: Runtime Error

Solution code:
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:
	print('Yes')
else :
	if two == 0:
if four >= (one+1):
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
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:
	print('Yes')
else :
	if two == 0:
if four >= (one+1):
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int,input().split()))
Kisuu = 0
YonBaisuu = 0
NiBaisuu = 0

for j in range(N):

  if a[j]%2 == 1:
    Kisuu += 1
  elif a[j]%4 == 0:
    YonBaisuu += 1
  else :
    NiBaisuu +=1

  
if Kisuu <= YonBaisuu:
  print('Yes')
else :
  if NiBaisuu == 0:
      if Kissuu+1 == YonBaisuu:
        print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int,input().split()))
Kisuu = 0
YonBaisuu = 0
NiBaisuu = 0

for j in range(N):
  print(j)
  if a[j]%2 == 1:
    Kisuu += 1
  elif a[j]%4 == 0:
    YonBaisuu += 1
  else :
    NiBaisuu +=1

  
if Kisuu <= YonBaisuu:
  print('Yes')
else :
  if NIBaisuu == 0:
    print('Yes')
  else:
    print('No')

print(Kisuu)
print(NiBaisuu)
print(YonBaisuu)