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: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
#print(count2)
if (n-count2//2)//2<=count or n==count2 or n//2<=count:
    print("Yes ")
elif  2<=count2  and (n-count2)//2<=count:
    print("Yes ")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
#print(count2)
if (n-count2//2)//2<=count or n==count2 or n//2<=count:
    print("Yes ")
elif  2<=count2  and (n-count2)//2<count:
    print("Yes ")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
#print(count2)
if (n-count2//2)//2<count or n==count2 or n//2<=count:
    print("Yes ")
elif  2<=count2  and (n-count2)//2<count:
    print("Yes ")#
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
#print(count2)
if (n-count2//2)//2<count or n==count2 :
    print("Yes ")
elif  2<=count2  and (n-count2)//2<count:
    print("Yes ")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
#print(count2)
if (n-count2//2)//2<count or n==count2 :
    print("Yes a")
elif  2<=count2  and (n-count2)//2<count:
    print("Yes b")#
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
#print(count2)
if (n-count2//2)//2<=count or n==count2 :
    print("Yes")
elif  2<=count2 and count2%2==0 and (n-count2)//2<=count:
    print("Yes")#
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
#print(count2)
if (n-count2//2)//2<=count or n==count2 :
    print("Yes")
elif  2<=count2 and (n-count2)//2<=count:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if (n-count2//2)//2<=count or n==count2:
    print("Yes")

else:
    print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
count_4 = 0
count_2 = 0
count_1 = 0
for a in A:
  if a % 4 == 0:
    count_4 += 1
  elif a % 2 == 0:
    count_2 += 1
  else:
    count_1 += 1
if count_2 % 2 == 0:
  if count_4 + (count_2 // 2) + 1 >= count_1:
    print('Yes')
  else:
    print('No')
else:
  if count_4 + (count_2 // 2) + 1 >= count_1 + 1:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

d2 = 0
d4 = 0

for ai in aa:
  if ai % 4 == 0:
    d4 += 1
  elif ai % 2 == 0:
    d2 += 1
  else:
    pass  

if d2<=1:
  d2=0

dd = n - d2
if d4 >= dd//2:  
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
from sys import exit

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

m1 = 0
m2 = 0
m4 = 0

for a in A:
	if a%4==0:
		m4 += 1
	elif a%2==0:
		m2 += 1
	else:
		m1 += 1

if m1==m4==0:
	print('Yes')
	exit()

m1 = m1 + (m2>0)
if 2*m4>=m1:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
from sys import exit

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

m1 = 0
m2 = 0
m4 = 0

for a in A:
	if a%4==0:
		m4 += 1
	elif a%2==0:
		m2 += 1
	else:
		m1 += 1

if m1==m4==0:
	print('Yes')
	exit()

m1 = m1 + m2%2
if 2*m4>=m1:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]

m1 = 0
m2 = 0
m4 = 0

for a in A:
	if a%4==0:
		m4 += 1
	elif a%2==0:
		m2 += 1
	else:
		m1 += 1

m1 = m1 + m2%2
if 2*m4>=m1:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = [int(x) for x in input().split()]
a = 0
b = 0
for n in lst:
    if n % 4 == 0:
        a += 1
    elif n == 2:
        b += 1

if b >= 2:
    N = N - (b - 1)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = [int(x) for x in input().split()]
a = 0
b = 0
for n in lst:
    if n % 4 == 0:
        a += 1
    elif n == 2:
        b += 1

b = max(0, b - 1)
if a >= (N - b) // 2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
even4= 0
odd = 0
even2 = 0
for i in range(n):
    if a[i]%4 == 0:
        even4 +=1
    elif a[i]%2 == 0:
        even2 +=1
    else:
        odd+=1
if (even4)*2 >=odd :
    print('Yes')
elif even2%2==0:
    print("Yes")
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
even= 0
odd = 0
for i in range(n):
    if a[i]%4 == 0:
        even +=1
    else:
        odd+=1
if (even)*2 >=odd:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
for i in range(n):
	if a[i]%4==0:
		count+=2
		break
	elif a[i]%2==0:
		count+=1
print("Yes" if count>=2 else "No")

Submission status: Wrong Answer

Solution code:
n = int(input())

two = 0
four = 0
for i in map(int, input().split()):
    if i % 4 == 0:
        four += 1
    elif i % 2 == 0:
        two += 1

tmp = two * (two > 1)
print('Yes' if (four * 3 + tmp) >= n else 'No')

Submission status: Wrong Answer

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

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

tmp = two * (two > 1)
print('Yes' if four * 2 + (four > 0) + tmp >= n else 'No')

Submission status: Wrong Answer

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

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

tmp = two - four if two - four > 1 else 0
print('Yes' if four * 2 + 1 + tmp >= n else 'No')

Submission status: Wrong Answer

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

#print(7//2)
count2 = 0
count4 = 0

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

if((n//2) >= count4):
    print("Yes")
elif(n > 6 and (n//2) < count4 and count4 >= 2):
    if(n % 2 == 0):
        if(((n//2) - count4)*2 >= count2):
            print("Yes")
    else:
        if((((n//2) - count4)*2)+1 >= count2):
            print("Yes")
elif(n == count2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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
odd=n-(four+two)
if four>=n//2:
	print('Yes')
elif two>=1:
	if four>=(n-two)/2:
		print('Yes')
	else:
		print('No')
else:
	print('No')

Submission status: Wrong Answer

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 and ct1 != 0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

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: Wrong Answer

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
odd=n-(four+two+one)


if two>=2:
    if n==two:
        print("Yes")
    elif (n-two)/2<=four:
        print("Yes")
    else:
        print("No")
elif four>=n//2:
	print('Yes')
else:
    print("No")

Submission status: Wrong Answer

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
odd=n-(four+two+one)


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

Submission status: Wrong Answer

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
odd=n-(four+two+one)

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

Submission status: Wrong Answer

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
odd=n-(four+two+one)

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

Submission status: Wrong Answer

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
odd=n-(four+two+one)

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

Submission status: Wrong Answer

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
odd=n-(four+two+one)

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

Submission status: Wrong Answer

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 two>=2:
    if (n-two)//2<=four:
        print('Yes')
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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
odd=n-(four+two+one)
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")
    else:
        print("No")
elif one==0 and two>=1:
    if two==1:
        if four>1 and (n-2)//four<=(four-1):
            print('Yes')
        else:
            print("No")
    elif two>=2:
        if two+four>=n//2:
            print('Yes')
        else:
            print("No")
    else:
        print("No")
elif one>=1 and two>=1:
    if one==1 and two>=2:
        if one+odd<=four:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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:
		if four>1 and n-2//four<=four-1:
			print('Yes')
	elif two>=2:
		if two+four>=n//2:
			print('Yes')
else:
	print('No')

Submission status: Wrong Answer

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 one>=1:
	if n/2>=four>=one/2:
		print('Yes')
	else:
		print('No')
elif two==1:
	if n/2>=four:
		print('Yes')
	else:
		print('No')
elif four+two>=n/2:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
cntf=0
cntno=0
for i in A:
  if i%4==0:
    cntf+=1
  if i%2==1:
    cntno+=1


if cntf>=(N//2):
  print('Yes')
else:
  if cntno>2:
    print('No')
  elif cntno==1:
    if cntf==0:
      print('No')
    else:
      print('Yes')
  elif cntno==2:
    if cntf>1:
      print('Yes')
    else:
      print('No')
  else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
cntf=0
cntno=0
for i in A:
  if i%4==0:
    cntf+=1
  if i%2==1:
    cntno+=1


if cntf>=(N//2):
  print('Yes')
else:
  if cntno>2:
    print('No')
  elif cntno==1:
    if cntf>0:
      print('Yes')
    else:
      print('No')
  elif cntno==2:
    if cntf>1:
      print('Yes')
    else:
      print('No')
  else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
cntf=0
cntno=0
for i in A:
  if i%4==0:
    cntf+=1
  if i%2==1:
    cntno+=1

if cntno>2:
  if cntf>=(N//2):
    print('Yes')
  else:
    print('No')
elif cntno==0:
  print('Yes')
elif cntno==1:
  if cntf>0:
    print('Yes')
  else:
    print('No')
else:
  if N==3 and cntf>0:
    print('Yes')
  elif N>3 and cntf>1:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
cntf=0
cntno=0
for i in A:
  if i%4==0:
    cntf+=1
  if i%2==1:
    cntno+=1

if cntno>2:
  print('No')
elif cntno==0:
  print('Yes')
elif cntno==1:
  if cntf>0:
    print('Yes')
  else:
    print('No')
else:
  if N==3 and cntf>0:
    print('Yes')
  elif N>3 and cntf>1:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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 one>=1 and two==0:
    if one/2<=four:
        print("Yes")
    else:
        print("No")
elif one>=1 and two>=1:
    if (one/2)+1<=four:
        print("Yes")
    else:
        print("No")
elif four>n/2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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 two+four/2>=n/2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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 two+four>=n/2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
l=list(map(int ,input().split()))
cnt=0
for i in range(n):
    if l[i]%4==0 or l[i]==1:
        cnt+=1
if n%2==0:
    if cnt>=n//2:
        print("Yes")
    else:
        print("No")
else:
    if cnt>=n//2+1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

d2 = 0
d4 = 0

for ai in aa:
  if ai % 4 == 0:
    d4 += 1
  elif ai % 2 == 0:
    d2 += 1
  else:
    pass  

if d2<=1:
  d2=0

dd = (d4*2 +1) + d2
if d4==0:
  dd -= 1
  
if dd >= n :
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
flag2=[0]*n
flag4=[0]*n
for i in range(len(a)):
    if a[i]%4==0:flag4[i]=1
    elif a[i]%2==0 :flag2[i]=1
cnt2=0
cnt4=0
for i in range(len(a)):
    cnt2+=flag2[i]
    cnt4+=flag4[i]
if cnt2>1:n-=cnt2
if cnt4>=int(n/2):print("Yes")
else:print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

nList = list(map(int,input().split()))
L2count = 0
L4count = 0

for i in nList:
  if i%4 == 0:
    L4count += 1
  if i%2 == 0:
    L2count += 1

if L4count >= n//2:
  print("Yes")
elif L2count > n//2 and L2count%2 == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

nList = list(map(int,input().split()))
L2count = 0
L4count = 0

for i in nList:
  if i%4 == 0:
    L4count += 1
  if i%2 == 0:
    L2count += 1

if L4count >= n//2:
  print("Yes")
elif L2count >= n//2 and L2count%2 == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
f = 0
t = 0
k = 0
for i in a:
    if i % 4 == 0:
        f += 1
    elif i % 2 == 0:
        t += 1
    else:
        k += 1


if t > 0:
    if f >= k:
        print("Yes")
    else:
        print("No")
else:
    if f >= k + 1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
num_odd = sum([1 for i in a if i % 2 == 1])
num_4 = len([1 for i in a if i % 4 == 0])
#print(a,num_odd,num_4)
if num_4 >= num_odd:
    print("Yes")
else: 
    if num_odd == (n+1)/2 and num_4 == (n-1)/2:
        print("Yes")
    print("No")

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
numof4 = 0
numof2 = 0
numofodd = 0
for i in range(N):
    if A[i] % 4 == 0:
        numof4 += 1
    elif A[i] % 2 == 0:
        numof2 += 1
    else:
        numofodd += 1
if numof4 >= numofodd:
    print("Yes")

elif numof4 > 0 and numof4 >= numofodd - 1 and (numof2 == 0 or numof2 > 1):
    print("Yes")

else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
multipleOf2 = 0
multipleOf4 = 0
odd = 0
for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 4 == 0:
            multipleOf4 += 1
        else:
            multipleOf2 += 1 
    else:
        odd += 1

if multipleOf2 + multipleOf4 == N:
    print('Yes')
    exit()
elif multipleOf2 >= 1:
    if multipleOf4 >= odd:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
    
# print(multipleOf2, multipleOf4, odd)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
multipleOf2 = 0
multipleOf4 = 0
odd = 0
for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 4 == 0:
            multipleOf4 += 1
        else:
            multipleOf2 += 1
    else:
        odd += 1

if (multipleOf4 >= (N - multipleOf2)//2 and multipleOf2 == N - (multipleOf4 + odd)) or multipleOf2 == N or multipleOf2 + multipleOf4 == N:
    print('Yes')
else:
    print('No')
# print(multipleOf2, multipleOf4, odd)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
multipleOf2 = 0
multipleOf4 = 0
odd = 0
for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 4 == 0:
            multipleOf4 += 1
        else:
            multipleOf2 += 1
    else:
        odd += 1

if (multipleOf4 >= (N - multipleOf2)//2 and multipleOf2 == N - (multipleOf4 + odd)) or multipleOf2 == N:
    print('Yes')
else:
    print('No')
# print(multipleOf2, multipleOf4, odd)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
multipleOf2 = 0
multipleOf4 = 0
odd = 0
for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 4 == 0:
            multipleOf4 += 1
        else:
            multipleOf2 += 1
    else:
        odd += 1

if multipleOf4 >= (N-multipleOf2)//2 or multipleOf2 == N:
    print('Yes')
else:
    print('No')
# print(multipleOf2, multipleOf4, odd)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
two_count = 0
four_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
        continue
ans = N - ((two_count//2) + (four_count*2) + 1 if four_count > 0 else 0)
if ans <= 0 or two_count == N:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
two_count = 0
four_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
        continue
ans = N - ((two_count//2) + (four_count*2) + 1 if four_count > 0 else 0)
if ans <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

m2, m4, rest = [], [], []
for i in range(N):
    if An[i] % 2 == 0 and An[i] % 4 != 0:
        m2.append(An[i])
    elif An[i] % 4 == 0:
        m4.append(An[i])
    else:
        rest.append(An[i])

print(len(m2), len(m4), len(rest))


ans = "No"
if len(m4) == len(rest):
    ans = "Yes"
if len(m4) == len(rest)-1 and len(m2) == 0:
    ans = "Yes"
if not len(rest):
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

m2, m4, rest = [], [], []
for i in range(N):
    if An[i] % 2 == 0 and An[i] % 4 != 0:
        m2.append(An[i])
    elif An[i] % 4 == 0:
        m4.append(An[i])
    else:
        rest.append(An[i])

ans = "No"
if len(m4) == len(rest):
    ans = "Yes"
if len(m4) == len(rest)-1 and len(m2) == 0 and len(m4):
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

m2, m4, rest = [], [], []
for i in range(N):
    if An[i] % 2 == 0 and An[i] % 4 != 0:
        m2.append(An[i])
    elif An[i] % 4 == 0:
        m4.append(An[i])
    else:
        rest.append(An[i])

ans = "No"
if len(m4) == len(rest):
    ans = "Yes"
if len(m4) == len(rest)-1 and len(m2) == 0:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a =[int(i) for i in input().split()]
x = 0
y = 0
z = 0
for i in range(N) :
    if a[i] % 2 != 0 :
        x+=1
    elif a[i] % 2 == 0 and a[i] % 4 != 0 :
        y += 1
    else :
        z +=1
ans = "No"
ya = y // 2
dy = y - ya * 2
if x + dy + ya <= z + 1 :
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
num = 0
n2 = 0
for i in range(n):
    if li[i]%4 == 0:
        num += 1
    elif li[i]%4 != 0 and li[i]%2 == 0:
        n2 += 1
n = n-n2+1
n1 = n-num
if num + 1 >= n1:
    print("Yes")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
num = 0
n2 = 0
for i in range(n):
    if li[i]%4 == 0:
        num += 1
    elif li[i]%4 != 0 and li[i]%2 == 0:
        n2 += 1
n2 = n2//2
n1 = n-n2-num
if num + 1 >= n1:
    print("Yes")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
num = 0
n2 = 0
for i in range(n):
    if li[i]%4 == 0:
        num += 1
    elif li[i]%4 != 0 and li[i]%2 == 0:
        n2 += 1
n2 = n2//2
n = n-n2
if num + 1 >= n-num:
    print("Yes")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
num = 0
n2,n3 = 0,0
for i in range(n):
    if li[i]%4 == 0:
        num += 1
    elif li[i]%4 != 0 and li[i]%2 == 0:
        n2 += 1
n2 = n2//2
n = n-n2
if num + n2 >= n//2:
    print("Yes")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
count = 0

ans = N//3

if N%3!=0:
    ans = ans + 1

for i in range(len(A)):
    if A[i]%4==0:
        count = count + 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
count = 0

ans = N//3+max(N%3,0)
for i in range(len(A)):
    if A[i]%4==0:
        count = count + 1

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) // 4 for x in input().split()]
if (n % 2 == 0 and a.count(0) <= n // 2) or (n % 2 == 1 and a.count(0) <= n // 2 +1): print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:
"""import sys
input = sys.stdin.readline"""
n=int(input())
a=list(map(int,input().split()))
cnt2=0
cnt4=0
for i in a:
    if i%4==0:
        cnt4+=1
    elif i%2==0:
        cnt2+=1
if cnt2>1:
    ans=n-cnt4*3-cnt2
if cnt2<=1:
    ans=n-cnt4*3
print("Yes" if ans<=0 else "No")

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
count = 0
two = 0
for i in a:
    if i%4 == 0:
        count += 1
    elif i%2 == 0:
        two += 1
if two != 0:
    N -= two
    N -= 2
    count -= 1
N -= 3*count
if N > 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A = list(map(int,input().split()))
Aa = np.array(A) %4
if np.count_nonzero(Aa%4==2)==0 and N//2-np.count_nonzero(Aa%4==0)>0:
    print("No")
elif np.count_nonzero(Aa%4==2)==0 and N//2-np.count_nonzero(Aa%4==0)<=0:
    print("Yes")
elif np.count_nonzero(Aa%4==2)!=0:
    if N%2==np.count_nonzero(Aa%4==2)%2 and np.count_nonzero(Aa%2==1)-np.count_nonzero(Aa%4==0)<=0:
        print("No")
    elif N%2!=np.count_nonzero(Aa%4==2)%2 and np.count_nonzero(Aa%4==2)-1-np.count_nonzero(Aa%4==0)<=0:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
def c_4adjacent():
    from collections import defaultdict
    N = int(input())
    A = [int(i) for i in input().split()]

    count = defaultdict(int)
    for a in A:
        count[a % 4] += 1
    num_4, num_2, num_other = count[0], count[2] // 2, count[1] + count[3]

    if num_2 == 0:
        # 14141 のように並べられるか (余った4はまとめて端に置く)
        ans = 'Yes' if num_other <= num_4 + 1 else 'No'
    else:
        # 2...24141 のように並べられるか (余った4はまとめて端に置く)
        ans = 'Yes' if num_other <= num_4 else 'No'
    return ans

print(c_4adjacent())

Submission status: Wrong Answer

Solution code:
def count_four(lst):
    counter = 0
    for i in lst:
        if i%4 == 0:
            counter += 1
    return counter

def count_two(lst):
    counter = 0
    for i in lst:
        if i%2 == 0:
            counter += 1
    return counter

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

def solve(lst):
    four = count_four(lst)
    two = count_two(lst) - four
    sonota = len(lst) - four - two
##    if sonota == 0:
##        return "Yes"

##    if four == 0 and sonota >= 1:
##        return "No"


    two = 1 if two>=1 else 0
    if two == 0 and four + 1 - sonota >= 0:
        return "Yes"
    else:
        return "No"



    if four + 1 - sonota  > 0:
        return "Yes"
    else:
        return "No"

print(solve(lst))