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())
nums = list(map(int, input().split()))

d4 = 0
d2 = 0
d0 = 0
for n in nums:
    if n % 4 == 0:
        d4 += 1
    elif n % 2== 0:
        d2 += 1
    else:
        d0 += 1

if d2 > 0 and d0 <= d2:
    print('Yes')
elif d2 == 0 and d0 <= d4+1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

d4 = 0
d2 = 0
d0 = 0
for n in nums:
    if n % 4 == 0:
        d4 += 1
    elif n % 2== 0:
        d2 += 1
    else:
        d0 += 1
d2 = 0 if d2 > 1 else d2
if 2*d4 >= d0 + d2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a4 = []
a2 = []
odd = []
for i in range(n):
    if a[i] % 4 == 0:
        a4.append(a[i])
    elif a[i] % 2 == 0:
        a2.append(a[i])
    else:
        odd.append(a[i])
if len(a) > 3:
    if len(odd) <= len(a4):
        print('Yes')
    else:
        print('No')
else:
    if a4 or len(a2) == n:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count4 = 0
count2 = 0
for i in a:
    if i%4 == 0:
        count4 += 1
    elif i%2 == 0:
        count2 += 1
if (n//2) <= count4:
    print("Yes")
elif (n-(count4*3) < count2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b4=[x for x in a if x%4==0]
a4=[x for x in a if x%4!=0]
b2=[x for x in a4 if x%2==0]
c=[x for x in a4 if x%2!=0]
if len(b4)==0:
    print('No')
elif len(b4)+1<len(c):
    print('No')
elif len(b4)<len(c) and len(b2)>0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b4=[x for x in a if x%4==0]
a4=[x for x in a if x%4!=0]
c=[x for x in a4 if x%2!=0]
if len(b4)>=len(c)-1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b4=[x for x in a if x%4==0]
a4=[x for x in a if x%4!=0]
c=[x for x in a4 if x%2!=0]
if len(b4)>len(c)-1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
tmp=1
if n==2:
    if a[0]*a[1]%4==0:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
for i in range(n):
    tmp*=a[i]
if tmp%(2**n)==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
tmp=1
if n==2:
    if a[0]*a[1]%4==0:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
for i in range(n):
    tmp*=a[i]
if tmp%(4**(n-2))==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
an = list(map(int, input().split()))
four = 0
odd = 0
for a in an:
    if a % 2 == 1:
        odd += 1
    elif a % 4 == 0:
        four += 1
print('Yes' if 2*odd-3 <= four or N//2 == four and -(-N//2) == odd else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
m2 = 0
m4 = 0
other=0
for i, aa in enumerate(a):
    if aa % 4 == 0:
        m4 +=1
        continue
    if aa % 2 == 0:
        m2 += 1
        continue
    other += 1
if m4 >= other or m4 + 1 == other:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
def slove(n, k):
    a_list = [int(i) for i in k.split()]
    num = len([i for i in a_list if i % 4 == 0])
    tmp =  [i for i in a_list if i % 4 != 0]
    num2 = tmp.count(2) // 2
    return "Yes" if (num + num2)>= n // 2 else "No"

if __name__ == "__main__":
    input = sys.stdin.readline
    n = int(input())
    k = input()
    print(slove(n, k))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
# 4の倍数と2の倍数を数える
four = 0
two = 0
ele = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0 and a[i] % 4 != 0:
        two += 1
    else:
        ele += 1

ele += two % 2
two = two//2
if ele <= (two+four) or (ele-(four+two) == 1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

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


def resolve():
    n = int(input())
    A = list(map(int, input().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

    if max(0, cnt_2 - 1) + cnt_4 * 3 >= n:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

cnt_2 = -1
multi_4 = 0
for i in range(n):
    if a[i] % 4 == 0:
        multi_4 += 1
    elif a[i] == 2:
        cnt_2 += 1
print("Yes" if multi_4 + max(0, cnt_2) >= n // 2 else "No")

Submission status: Wrong Answer

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

cnt_2 = -1
multi_4 = 0
for i in range(n):
    if a[i] % 4 == 0:
        multi_4 += 1
    elif a[i] == 2:
        cnt_2 += 1
print("Yes" if multi_4 + cnt_2 >= n // 2 else "No")

Submission status: Wrong Answer

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

cnt_2 = -1
multi_4 = 0
for i in range(n):
    if a[i] % 4 == 0:
        multi_4 += 1
    elif a[i] == 2:
        cnt_2 += 1
print("Yes" if multi_4 >= (n - max(0, cnt_2)) // 2 else "No")

Submission status: Wrong Answer

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

cnt_2 = -1
multi_4 = 0
for i in range(n):
    if a[i] % 4 == 0:
        multi_4 += 1
    elif a[i] == 2:
        cnt_2 += 1
print("Yes" if multi_4 >= (n - max(0, cnt_2 + 1)) // 2 else "No")

Submission status: Wrong Answer

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

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

print("Yes" if multi_4 >= (n - cnt_2 + 1) // 2 else "No")

Submission status: Wrong Answer

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

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

print("Yes" if multi_4 >= (n - cnt_2) // 2 else "No")

Submission status: Wrong Answer

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

cnt = 0
for i in range(n):
    if a[i] % 4 == 0:
        cnt += 1

print("Yes" if cnt >= n / 3 else "No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a_L = list(map(int,input().split()))
L = [0 for _ in range(n)]

# four = 0
# two = 0
# for i in range(n):
#     if a_L[i]%4==0:
#         L[i] = 1
#         four += 1
#         continue
#     if a_L[i]%2==0:
#         two += 1

# if n%2 == 0:
#     if n/2+1 <= two+four:
#         print("Yes")
#         exit()
# else:
#     if int(n/2) <= two+four :
#         #ans = "Yes"
#         print("Yes")
#         exit()

if n>=10:
    print("No")
    exit()


#print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a_L = list(map(int,input().split()))
L = [0 for _ in range(n)]

# four = 0
# two = 0
# for i in range(n):
#     if a_L[i]%4==0:
#         L[i] = 1
#         four += 1
#         continue
#     if a_L[i]%2==0:
#         two += 1

# if n%2 == 0:
#     if n/2+1 <= two+four:
#         print("Yes")
#         exit()
# else:
#     if int(n/2) <= two+four :
#         #ans = "Yes"
#         print("Yes")
#         exit()

if n==1:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a_L = list(map(int,input().split()))
L = [0 for _ in range(n)]

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

if n%2 == 0:
    if n/2+1 <= two+four:
        print("Yes")
        exit()
else:
    if int(n/2) <= two+four :
        #ans = "Yes"
        print("Yes")
        exit()

if n==1:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a_L = list(map(int,input().split()))
# L = [0 for _ in range(n)]

# four = 0
# two = 0
# for i in range(n):
#     if a_L[i]%4==0:
#         L[i] = 1
#         four += 1
#         continue
#     if a_L[i]%2==0:
#         two += 1

# if n%2 == 0:
#     if n/2+1 <= two+four:
#         print("Yes")
#         exit()
# else:
#     if int(n/2) <= two+four :
#         #ans = "Yes"
#         print("Yes")
#         exit()

if n==1:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

L = [0 for _ in range(n)]

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


if n%2 == 0:
    if n/2+1 <= two+four:
        print("Yes")
        exit()
else:
    if int(n/2) <= two+four :
        #ans = "Yes"
        print("Yes")
        exit()

if n == 1 and a_L[0]%4==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

L = [0 for _ in range(n)]

# four = 0
# two = 0
# for i in range(n):
#     if a_L[i]%4==0:
#         L[i] = 1
#         four += 1
#         continue
#     if a_L[i]%2==0:
#         two += 1


# if n%2 == 0:
#     if n/2+1 <= two+four:
#         print("Yes")
#         exit()
# else:
#     if int(n/2) <= two+four :
#         #ans = "Yes"
#         print("Yes")
#         exit()

if n<5:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

L = [0 for _ in range(n)]

# four = 0
# two = 0
# for i in range(n):
#     if a_L[i]%4==0:
#         L[i] = 1
#         four += 1
#         continue
#     if a_L[i]%2==0:
#         two += 1


# if n%2 == 0:
#     if n/2+1 <= two+four:
#         print("Yes")
#         exit()
# else:
#     if int(n/2) <= two+four :
#         #ans = "Yes"
#         print("Yes")
#         exit()

if n>10:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

L = [0 for _ in range(n)]

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


if n%2 == 0:
    if n/2+1 <= two+four:
        print("Yes")
        exit()
else:
    if int(n/2) <= two+four :
        #ans = "Yes"
        print("Yes")
        exit()


print("No")

Submission status: Wrong Answer

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

L = [0 for _ in range(n)]

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


if n%2 == 0:
    if n/2 <= two+four:
        print("Yes")
        exit()
else:
    if int(n/2) <= two+four :
        #ans = "Yes"
        print("Yes")
        exit()


print("No")

Submission status: Wrong Answer

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

L = [0 for _ in range(n)]

one = 0
for i in range(n):
    if a_L[i]%2==0:
        L[i] = 1
        one += 1
ans = ""
if n%2 == 0:
    if n/2 <= one:
        ans = "Yes"
    else:
        ans = "No"
else:
    if int(n/2) <= one:
        ans = "Yes"
    else:
        ans = "No"

print(ans)

Submission status: Wrong Answer

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

L = [0 for _ in range(n)]

one = 0
for i in range(n):
    if a_L[i]%4==0:
        L[i] = 1
        one += 1
ans = ""
if n%2 == 0:
    if n/2 <= one:
        ans = "Yes"
    else:
        ans = "No"
else:
    if int(n/2) <= one:
        ans = "Yes"
    else:
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

N2 = 0
N4 = 0

for i in a:
    if i % 4 == 0:
        N4 += 1
    if i % 2 == 0:
        N2 += 1

if N4 >= math.ceil(N / 3) or N2 >= math.ceil(N*2/3):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, *a = map(int, open(0).read().split())
s = [i%4 for i in a]
f, k = s.count(0), s.count(2)
print("YNeos"[n-f-k > f+(k>0)::2])

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
counts = [0] * 3
for a in a_list:
	if a%4 == 0:
		counts[0] += 1 		 
	elif a%2 == 0:
		counts[1] += 1
	else:
		counts[2] += 1
r = 'Yes' if counts[2] <= counts[0]+1 else 'No'
if r == 'Yes':
	two_v = counts[1]
	four_v = counts[0] - counts[2]
	mod = two_v%2	
	if mod == 0 or mod - four_v < 1:
		r = 'Yes'
	else:
		r = 'No'
print(r)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
counts = [0] * 3
for a in a_list:
	if a%4 == 0:
		counts[0] += 1 		 
	elif a%2 == 0:
		counts[1] += 1
	else:
		counts[2] += 1
r = 'Yes' if counts[2] <= counts[0]+1 else 'No'
print(r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cntA = 0
cntB = 0
for i in range(N):
    if A[i]%4 == 0:
        cntA += 1
    elif A[i]%2 == 0:
        cntB += 1

print("Yes" if cntA*2 + cntB >= N else "No")

Submission status: Wrong Answer

Solution code:
from collections import deque

def f(x):
    return num.count(x)

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

if len(a)%2==1:
    if f(4)>=len(a)//2 or f(2)>=2*(n//2-f(4))+1:
        print('Yes')
        exit(0)
if len(a)%2==0:
    if f(2)>=2*(n//2-f(4)):
        print('Yes')
        exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())

a = np.array([int(i) for i in input().split()])

def distri(num):
    res = np.array([0,0,0])
    if num%4==0:
        res = res + np.array([1,0,0])
        return res
    elif num%2 == 0:
        res = res + np.array([0,1,0])
        return res
    else:
        res = res + np.array([0,0,1])
        return res
    
cout420 = np.array([0,0,0])

for i in a:
    cout420 = cout420 + distri(i)
if cout420[1] ==0:
    assign2 = 0
else:
    assign2 = 1
    
non4 = cout420[-1] + assign2

if non4 <= cout420[0]*2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())

a = np.array([int(i) for i in input().split()])

def distri(num):
    res = np.array([0,0,0])
    if num%4==0:
        res = res + np.array([1,0,0])
        return res
    elif num%2 == 0:
        res = res + np.array([0,1,0])
        return res
    else:
        res = res + np.array([0,0,1])
        return res
    
cout420 = np.array([0,0,0])

for i in a:
    cour420 = cout420 + distri(i)
if cout420[1] ==0:
    assign2 = 0
else:
    assign2 = 1
    
non4 = cout420[-1] + assign2

if non4 <= cout420[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    if a[i] % 4 == 2:
        count2 += 1
    if a[i] % 4 == 0:
        count4 += 1
if count2 > 1:
    n -= count2
if count4 * 2  >= n:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    if a[i] % 4 == 2:
        count2 += 1
    if a[i] % 4 == 0:
        count4 += 1
if count2 > 1:
    n -= count2
if count4 * 2 + 1 >= n:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
n, *A = map(int, open(0).read().split())

def f(x):
  y = 0
  q, r = divmod(x, 2)
  while r == 0:
    y += 1
    q, r = divmod(q, 2)
  return y

B = [0] * 3
for a in A:
  b = f(a)
  B[0] += b == 0
  B[1] += b == 1
  B[2] += b >= 2
print('Yes' if B[0] + (B[1]!=0) <= B[2] else 'No')

Submission status: Wrong Answer

Solution code:
n, *A = map(int, open(0).read().split())

def f(q):
  y = 0
  while True:
    q, r = divmod(q, 2)
    if r == 1:
      break
    y += 1
  return y

B = [0] * 3
for a in A:
  b = f(a)
  B[0] += b == 0
  B[1] += b == 1
  B[2] += b >= 2
print('Yes' if B[0] + B[1]%2 <= B[2] else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
list_A = list(map(int, input().split()))
list_C = [0, 0, 0]

for num in list_A:
    if num % 4 == 0:
        list_C[2] += 1
    elif num % 2 == 0:
        list_C[1] += 1
    else:
        list_C[0] += 1

ans = "Yes"

if list_C[1] == 0:
    if list_C[2] == 0:
        if list_C[0] != 0:
            ans = "No"
    if list_C[2] == 1:
        if list_C[0] > 2:
            ans = "No"
    if list_C[2] > 1:
        if list_C[0] > list_C[2] + 2:
            ans = "No"
else:
    if list_C[0] > list_C[2]:
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
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((cnt4 * 2 + 1) >= n or cnt2 >= (n - (cnt4 * 2 + 1) + (cnt4 > 0))):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
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((cnt4 * 3) >= n or cnt2 >= (n - (cnt4 * 3) + (cnt4 > 0))):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
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((cnt4 * 3) >= n or cnt2 >= (n - (cnt4 * 3) + 1)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
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
    if(a[i] % 2 == 0):
        cnt2 += 1

if((cnt4 * 3) >= n or cnt2 == n):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
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((cnt4 * 3) >= n or cnt2 == n):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if (n - cnt2) // 2 <= cnt4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

ans = 0
cnt = 0
for i in range(n):
    if a[i] % 4 == 0:
        ans += 1
    elif a[i] % 2 == 0:
        cnt += 1
        if cnt == 2:
            ans += 1
    

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

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
a=[i%4 for i in a]
if a.count(2)>0:
  print('No' if a.count(0)>a.count(1)+a.count(3) else 'Yes')
else:
  print('No' if 2+a.count(0)<a.count(1)+a.count(3) else 'Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
count2 = 0
count4multiple = 0
for i in a:
    if i == 2:
        count2 += 1
    elif i % 4 == 0:
        count4multiple += 1
if n-1 <= count4multiple * 2 + max(0, count2 - 1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
count2 = 0
count4multiple = 0
for i in a:
    if i == 2:
        count2 += 1
    elif i % 4 == 0:
        count4multiple += 1
if n-1 - count4multiple * 2 - max(0, count2 - 1) <= 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
con =0
ex = -1
for i in range(n):
    if a[i] % 4 == 0:
        con +=1
    elif a[i] % 2 == 0:
        ex +=1
    
if ex == -1:
    ex = 0
if (n-ex)//2 <= con and n % 2 == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
con =0
ex = -1
for i in range(n):
    if a[i] % 4 == 0:
        con +=1
    elif a[i] == 2:
        ex +=1
    
if ex == -1:
    ex = 0
if (n-ex)//2 <= con:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
con =0
for i in range(n):
    if a[i] % 4 == 0:
        con +=1

if n//2 <= con:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
four = 0
two = 0
el = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1
    else:
        el += 1

if two >= 1:
    el += 1
    
if abs(four - el) < 2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())

ARR = [int(s) for s in input().split(" ")]
def calculate(n,arr):
    m1 = 0
    m2 = 0
    m3 = 0
    for ar in arr:
        if ar % 4 == 0:
            m1 = m1 + 1
        elif ar % 2 == 0:
            m2 = m2 + 1
        else:
            m3 = m3 + 1


    if m2 == 0:
        if m3 > m1 + 1:
            print("No")
        else:
            print("Yes")
    elif m2 == 1:
        if m3 > m1:
            print("No")
        else:
            print("Yes")
    else:
        if m3 > m1 + 1:
            print("No")
        else:
            print("Yes")


calculate(N,ARR)

Submission status: Wrong Answer

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

count4 = 0
count2 = 0

for i in lst:
    if i%4==0:
        count4+=1
    elif i%2==0:
        count2+=1
count1 = n-count4-count2

if count4*2>=count1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# N = 4
# ARR = [1, 2, 3, 4]
#
# N = 3
# ARR = [1, 10, 100]
#
# N = 3
# ARR = [1, 4, 1]
#
# N = 2
# ARR = [1, 1]
#
# N = 6
# ARR = [2, 7, 1, 8, 2, 8]

N = int(input())

ARR = [int(s) for s in input().split(" ")]
def calculate(n,arr):
    m1 = 0
    m2 = 0
    m3 = 0
    for ar in arr:
        if ar % 4 == 0:
            m1 = m1 + 1
        elif ar % 2 == 0:
            m2 = m2 + 1
        else:
            m3 = m3 + 1

    if m1 > 0:
        if m1 * 2 < m2 + m3:

            if m1 * 2 < m3:
                print("No")
                return
            else:
                if m1 * 2 - m3 < m2:
                    s = m1 * 2 - m3  - m2
                    if s % 2 == 0:
                        print("Yes")
                        return
                    else:
                        print("No")
                        return
    else:
        if m3 > 0:
            print("No")
            return

        if m2 % 2 == 1:
            print("No")
            return

    print("Yes")


calculate(N,ARR)

Submission status: Wrong Answer

Solution code:
N = int(input())

ARR = [int(s) for s in input().split(" ")]
def calculate(n,arr):
    m1 = 0
    m2 = 0
    m3 = 0
    for ar in arr:
        if ar % 4 == 0:
            m1 = m1 + 1
        elif ar % 2 == 0:
            m2 = m2 + 1
        else:
            m3 = m3 + 1

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

calculate(N,ARR)

Submission status: Wrong Answer

Solution code:
N = int(input())

ARR = [int(s) for s in input().split(" ")]
def calculate(n,arr):
    m1 = 0
    m2 = 0
    m3 = 0
    for ar in arr:
        if ar % 4 == 0:
            m1 = m1 + 1
        elif ar % 2 == 0:
            m2 = m2 + 1
        else:
            m3 = m3 + 1

    if m1 * 2 < m3:
        print("No")
        return

    if m1 * 2 >= n - m1:
        print("Yes")
        return

    if m2 % 2 == 1:
        print("No")
        return

    print("Yes")



calculate(N,ARR)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8-*-
#strs = []
#n,k = map(int,input().split())
#hates = list(input().split())
n = int(input())
a = list(map(int,input().split()))

#2の個数を数える。
twos = a.count(2)
twos = twos // 2
fours = 0
#4の倍数を数える
for i in a:
  if i % 4 == 0:
    fours = fours + 1

if ((n - twos) // 2) <= fours:
  print("Yes")
else:
  print("No")



#inputstr = input()
#length = len(inputstr) - 2
#print('{}{}{}'.format(inputstr[0],length,inputstr[-1]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8-*-
#strs = []
#n,k = map(int,input().split())
#hates = list(input().split())
n = int(input())
a = list(map(int,input().split()))

#2の個数を数える。
twos = a.count(2)
twos = twos // 2
fours = 0
#4の倍数を数える
for i in a:
  if i % 4 == 0:
    fours = fours + 1

if ((n - twos) // 2) <= fours:
  print("YES")
else:
  print("NO")



#inputstr = input()
#length = len(inputstr) - 2
#print('{}{}{}'.format(inputstr[0],length,inputstr[-1]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8-*-
#strs = []
#n,k = map(int,input().split())
#hates = list(input().split())
n = int(input())
a = list(map(int,input().split()))

#2の個数を数える。
twos = a.count(2)
fours = 0
#4の倍数を数える
for i in a:
  if i % 4 == 0:
    fours = fours + 1

if ((n - twos) // 2) <= fours:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a_4 = [val for val in a if val % 4 == 0]
num_4=len(a_4)
a_odd = [val for val in a if val % 2 ==1]
num_odd=len(a_odd)
num_2 = N - num_odd - num_4

if num_4>=num_odd:
    print('Yes')
elif 1<=num_4 < num_odd:
    if num_2:
        print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
odd = 0
mul2 = 0
mul4 = 0
for i in a:
    if i%4==0:mul4+=1
    elif i%2==0:mul2+=1
    else:odd+=1
if mul4+1<odd:print('No')
else:print('Yes')