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

Solution code:
n=int(input())
nums=list(map(int,input().split()))
mods=[]
for i in range(n):
  cnt=0
  while nums[i]%2==0:
    nums[i]//=2
    cnt+=1
  mods.append(cnt)
count2=sum(1 for i in mods if i>=2)
count0=sum(1 for i in mods if i==0)
if count2+count0==len(mods):
  if count2>=count0-1:
    print("Yes")
  else:
    print("No")
else:
  if count2>=count0:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

odd = 0
ml2 = 0
ml4 = 0

for ai in a:
    if ai % 2:
        odd += 1
    elif ai % 4:
        ml2 = 1
    else:
        ml4 += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

fac_2 = 0
fac_4 = 0
for a in A:
    if a % 4 == 0:
        fac_4 += 1
    elif a % 2 == 0:
        fac_2 += 1

if fac_2 == 0:
    x = 1
else:
    x = 0

if fac_2 + fac_4*2 + x >= N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
aa = [2 if i % 4 == 0 else 1 if i % 2 == 0 else 0 for i in a]
a4, a2, a0 = aa.count(2),aa.count(1), aa.count(0)

if a2 == 0:
    a4 += 1

print("Yes" if a4 >= a0 else "No")

Submission status: Accepted

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

b = sum((i % 2 != 0)  for i in l)
bb = sum((i % 2 == 0)  for i in l)
bbbb  = sum((i % 4 == 0)  for i in l)

bb -= bbbb
if bbbb+1 >= b + (bb != 0):print("Yes")
else:print("No")

Submission status: Accepted

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

g1=0
g2=0
g4=0
for v in li:
  if (v%4==0):
    g4+=1
  elif (v%2==0):
    g2+=1
  else:
    g1+=1
flag = True
if ( g2>0 and g4<g1):
  flag = False
if ( g2==0 and g4+1<g1):
  flag = False
print ( "Yes" if flag else "No" )

Submission status: Accepted

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

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

#print(n1, n2, n4)
print(["Yes", "No"][not(n1 + n2 <= n4 + 1)])

Submission status: Accepted

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

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

#print(n1, n2, n4)
print(["Yes", "No"][not(n1 + (n2 % 2) <= n4 + 1)])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
two, four = 0, 0
for a in A:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 0:
        two += 1
if two == 0:
    can = four * 2 + 1
else:
    can = four * 2 + two

if can >= N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

# 各整数を素因数分解したとき、因数2の個数に着目して判定する
X = sum(x % 2 == 1 for x in a)
Y = sum(x % 2 == 0 and x % 4 == 2 for x in a)
Z = sum(x % 4 == 0 for x in a)
ans = (
    'Yes' if X <= Z or X == Z + 1 and Y == 0 else
    'No'
)

# 出力
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
odd, nibai, yonbai = 0, 0, 0

for i in range(N):
    if A[i] % 2 != 0:
        odd += 1
    elif A[i] % 4 == 0:
        yonbai += 1
    else:
        nibai += 1

if nibai == 0:
    if odd > yonbai+1:
        print('No')
    else:
        print('Yes')
else:
    if odd > yonbai:
        print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
import math
N = int(input())
a = [int(x) for x in input().split()]
a4,a2 = 0,0

for x in a:
    if x % 4 == 0:  a4 += 1
    elif x % 2 == 0:    a2 += 1

if N//2 <= a4 or math.ceil((N-a2)/2) <= a4: print("Yes")
else:   print("No")

Submission status: Accepted

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
cnt4=0
cnt2=0
cnt1=0
for i in a:
    if(i%4==0):
        cnt4+=1
    elif(i%2==0):
        cnt2+=1
    else:
        cnt1+=1
n = cnt4+1-cnt1
if(n>=0 and cnt2==0):
    print('Yes')
elif(n>=1 and cnt2>=1):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter

def a():
    N = int(input())
    A = map(int,input().split(" "))
    c = Counter(map(lambda x:(x%4 and 1)+x%2,A))
    if c[1]:
        return c[2] <= c[0]
    else:
        return c[2] <= c[0] + 1

print(['No','Yes'][a()])

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
m2=0
m1=0
m0=0
for a in A:
  if a%4==0:
    m2+=1
  elif a%2==0:
    m1+=1
  else:
    m0+=1
if m1==0:
  if m2-m0>=-1:
    print("Yes")
  else:
    print("No")
if m1!=0:
  if m2-m0>=0:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

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

odd = 0
single_even = 0
double_even = 0
for a in A:
  if a%2:
    odd += 1
  elif a%2==0 and a%4:
    single_even +=1
  else:
    double_even += 1
    
if (odd == double_even +1 and single_even%2==0) or (odd <= double_even):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

c2 = 0
c4 = 0

for aa in a:
    if aa % 4 == 0:
        c4 += 1
    else:
        if aa % 2 == 0:
            c2 += 1

if c4 >= N // 2:
    print("Yes")
else:
    if N - c4 * 2 <= c2:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i)%4 for i in input().split()]
f,t=A.count(0),A.count(2)
print(["No","Yes"][N-f-t<=f+(t==0)])

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i)%4 for i in input().split()]
f,t=A.count(0),A.count(2)
print(["No","Yes"][N-f-t<=f+(t == 0)])

Submission status: Accepted

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

f, t = A.count(0), A.count(2)
if N - f - t <= f + (t == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

if N - f - t <= f + (t == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

f, t, o = 0, 0, 0
for a in A:
    if a % 4 == 0:
        f += 1
    elif a % 2 == 0:
        t += 1
    else:
        o += 1

if o <= f + (t == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

def solve():
    f, t, o = 0, 0, 0
    for a in A:
        if a % 4 == 0:
            f += 1
        elif a % 2 == 0:
            t += 1
        else:
            o += 1

    if t == 0:
        return (o <= f + 1)
    else:
        return (o <= f)

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]
C = Counter(4 if a % 4 == 0 else 2 if a % 2 == 0 else 1 for a in A)

if C[2] == 0:
    print("Yes" if C[1] <= C[4] + 1 else "No")
else:
    print("Yes" if C[1] <= C[4] else "No")

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
a, b, c = 0, 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    a += 1
  elif A[i] % 2 == 0:
    b += 1
  else:
    c += 1
#print("{0} {1} {2}".format(a, b, c))
b = 1 if b > 0 else 0  
if b + c > a + 1:
  print('No')
else:
  print('Yes')

Submission status: Accepted

Solution code:
input()
d={0:0,1:0,2:0}
def cnt(i):i=int(i);d[0 if i%2 else(1 if i%4 else 2)]+=1
list(map(cnt,input().split()))
print("YNeos"[d[0]-d[2]>(d[1]==0)::2])

Submission status: Accepted

Solution code:
N=int(input())
d={0:0,1:0,2:0}
def cnt(i):
    i=int(i)
    d[0 if i%2 else(1 if i%4 else 2)]+=1
list(map(cnt,input().split()))
print((d[0]>d[2]and (d[0]+d[2]!=N or d[0]!=d[2]+1) if N%2 else d[0]>d[2]) and"No"or"Yes")

Submission status: Accepted

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

counter = []
for i in range(N):
    if T[i] % 4 == 0:
        count = 2
    elif T[i] % 2 == 0:
        count = 1
    else:
        count = 0
    counter.append(count)

c0 = counter.count(0)
c1 = counter.count(1)
c2 = counter.count(2)

if c0 - 1 <= c2 and c1 % 2 == 0:
    print('Yes')
elif c0 <= c2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

four = 0
even = 0

for a in A:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 0:
        even += 1

if max(even-1,0) + 2*four >= N - 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
one = 0
four = 0
for a in A:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 1:
        one += 1

ans = 'No'
if one + four == N:
    if four + 1 >= one:
        ans = 'Yes'
else:
    if four >= one:
        ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import pprint
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) 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 MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)

n = II()
a = LI()

# 2の倍数であり、4の倍数でない
two = sum(number % 2 == 0 and number % 4 != 0 for number in a)
# 4の倍数である
four = sum(number % 4 == 0 for number in a)

if two % 2 == 1:
    print('Yes') if len(a) - two <= 2 * four else print('No')
else:
    print('Yes') if len(a) - two - 1 <= 2 * four else print('No')

Submission status: Accepted

Solution code:

N=int(input())
a=list(map(int,input().split()))
x=[]
k0=0
k1=0
k2=0

for i in range(N):
    if a[i]%4==0:
        x.append(2)
        k2+=1
    elif a[i]%4==2:
        x.append(1)
        k1+=1
    else:
        x.append(0)
        k0+=1


if (k1)%2==0:
    if k2+1>=k0:
        print("Yes")
    else:
        print("No")
else:
    if k2>=k0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

L1 = 0
L4 = 0
for a in A:
    if a % 4 == 0:
        L4 += 1
    elif a % 2 == 1:
        L1 += 1

ans = 'No'
if L1 + L4 == N:
    if L4 + 1 >= L1:
        ans = 'Yes'
else:
    if L4 >= L1:
        ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    cnt4 = 0
    cnt2 = 0
    cnt = 0
    for i in a:
        if i%4 == 0:
            cnt4 += 1
        elif i%2 == 0:
            cnt2 += 1
        else:
            cnt += 1
    
    if cnt2 == 0:
        if cnt<= cnt4+1:
            print('Yes')
            return
        else:
            print('No')
            return
            
    total = 2* cnt4 + cnt2
    if total>= n:
        print('Yes')
    else:
        print('No')

solve()

Submission status: Accepted

Solution code:
N=int(input())
*A,=map(lambda x:int(x)%4,input().split())
f=A.count(0)
t=A.count(2)
o=N-f-t
if t==0:print("Yes"if f>o-2 else"No")
else:print("Yes"if f>=o else"No")

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
x,y=0,0
for a in A:
  if a%4==0:
    x+=1
  elif a%2==0:
    y+=1
if (n-y)%2==0 or y==0:
  d=(n-y)//2
else:
  d=(n-y)//2+1
print("Yes" if x>=d else "No")

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    a = list(int(_) for _ in input().split())
    cnt_4time = 0
    cnt_2time = 0
    for i in range(N):
        if a[i] % 4 == 0:
            cnt_4time +=1
        elif a[i] % 2 ==0:
            cnt_2time +=1
    N = N - (cnt_2time//2)*2
    if N <= 2*(cnt_4time)+1:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/arc080/tasks/arc080_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = []
    for a in A:
        if a % 4 == 0:
            B.append(2)
        elif a % 2 == 0:
            B.append(1)
        else:
            B.append(0)
    four_num = B.count(2)
    two_num = B.count(1)
    one_num = B.count(0)

    if two_num == 0:
        if four_num >= one_num - 1:
            print("Yes")
        else:
            print("No")
    else:
        if four_num >= one_num:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

A = [0,0,0]
for i in range(N):
    if li[i] % 2 != 0:
        A[0] += 1
    elif li[i] % 2 == 0 and li[i] % 4 != 0:
        A[1] += 1
    elif li[i] % 2 == 0 and li[i] % 4 == 0:
        A[2] += 1

if A[1] == 0:
    if A[2]+1 < A[0]:
        print("No")
    else:
        print("Yes")
else:
    if A[2] < A[0]:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split(" ")))
count = [0, 0, 2]
for num in a:
    if num % 2 == 0:
        if num % 4 == 0:
            count[2] += 1
        else:
            count[1] += 1
    else:
        count[0] += 1

need_4 = count[0]
if count[1] > 0:
    need_4 += 1
if count[2] - need_4 > 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
maru = len([a for a in A if a % 4 == 0])
batu = len([a for a in A if a % 2 == 1])
sankaku = N - maru - batu

if sankaku:
    if batu <= maru:
        print('Yes')
    else:
        print('No')
else:
    if batu <= maru + 1:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

num2 = 0
num4 = 0

for i in a:
    if i % 2 == 0:
        if i%4 == 0:
            num4 += 1
        else:
            num2 += 1

judge = num4 * 2 + 1 * int(num2 < 2) + num2 * int(num2 > 1)

if judge >= N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans='No'
a2=[i//2 for i in a if i%2==0]
a4=[i for i in a2 if i%2==0]
la2=len(a2)
la4=len(a4)
if la2+la4>=n and la2>0:
    ans='Yes'
elif la2==la4 and 2*la4+1>=n:
    ans='Yes'
print(ans)

Submission status: Accepted

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
a = nl()
p1 = 0
p2 = 0
p3 = 0
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 4 == 0:
            p3 += 1
        else:
            p2 += 1
    else:
        p1 += 1
if p1 <= p3:
    print('Yes')
else:
    if p1 == p3 + 1 and p2 == 0:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n = int(input())

cnt1 = 0
cnt2 = 0
cnt4 = 0

for d in map(int,input().split()):
    if d%4==0:
        cnt4+=1
        continue
    if d%2==0:
        cnt2+=1
        continue
    cnt1+=1
res = True
if cnt2>0:
    res = (cnt1<=cnt4)
else:
    res = (cnt1<=(cnt4+1))

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

Submission status: Accepted

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

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

print('Yes' if cnt>=2*m else 'No')

Submission status: Accepted

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

t4=0
t2=0
t=0
for a in A:
  if a%4==0:
    t4+=1
  elif a%2==0:
    t2+=1
  else:
    t+=1
if t4>=t or (t2==0 and t4+1==t):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil
n=int(input())
ans4=0
ans2=0
ans0=0
a=list(map(int,input().split()))
for i in range(n):
  if a[i]%4==0:
    ans4+=1
  elif a[i]%2==0:
    ans2+=1
  else:
    ans0+=1
if ans2>0:
  if ans0<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if ceil((ans0+ans4)/2)>=ans0:
    print('Yes')
  else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
counter=Counter(1 if x % 2 else 2 if x % 4 else 4 for x in (int(s) for s in input().split()))
print('Yes' if counter[1] <= counter[4] or counter[2] == 0 and counter[1] == counter[4] + 1 else 'No')

Submission status: Accepted

Solution code:
n = int(input())
lis = list(map(int,input().split()))
nu1 = 0
nu2 = 0
nu4 = 0
for nu in lis:
    if nu % 2 == 0:
        if nu % 4 == 0:
            nu4 += 1
        else:
            nu2 = 1
    else:
        nu1 += 1
if nu4 + 1 >= nu1 + nu2:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
from math import ceil
N = int(input())
A = list(map(int, input().split()))
num2 = 0
num4 = 0
numO = 0
for num in A:
    if num % 4 == 0:
        num4 += 1
        continue
    elif num % 2 == 0:
        num2 += 1
        continue
    else:
        numO += 1
if num2 > 0:
    if numO > num4:
        print('No')
    else:
        print('Yes')
else:
    if numO > ceil((num4 + numO) / 2):
        print('No')
    else:
        print('Yes')

Submission status: Accepted

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

x=0
y=0
for a in A:
    if a%2==0:
        if a%4==0:
            x+=1
        else:
            y+=1
if x+y//2>=n//2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

tn = len(list (filter (lambda x: x%2==0 and x%4!=0,L )))
tf = len(list(filter(lambda x: x%4==0,L)))

if tn==0 and (N-tn)//2 <= tf:
  print('Yes')
elif tn!=0 and 2*tf >= N-tn:
  print('Yes')
else: 
  print('No')

Submission status: Accepted

Solution code:
N = input()
a = map(int, raw_input().split())
div4 = sum(map(lambda x: 1 if x % 4 == 0 else 0, a))
div2 = sum(map(lambda x: 1 if x % 2 == 0 else 0, a)) - div4
edge = 1 if div4 > 0 else 0
penalty = 1 if div2 == 1 else 0
if N <= div4 * 2 + edge or N <= div4 * 2 + div2 - penalty:
  print "Yes"
else:
  print "No"

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
c4=0
c2=0
for i in range(N):
  if A[i]%4==0:
    c4+=1
  elif A[i]%2==0:
    c2+=1
if c4:
  a = c4*2+1
else:
  a = 0
if c2>1:
  b = c2
  if a:
    a -= 1
else:
  b = 0
if a+b>=N:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
f = 0
k = 0
for r in ar:
    if r % 4 == 0:
        f += 1
    if r % 2 == 1:
        k += 1
if k + f == a:
    if k <= f + 1:
        print("Yes")
    else:
        print("No")
else:
    if k <= f:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
N=int(input())
n1,n2,n4=0,0,0
for i in input().split():
  if int(i)%4==0:
    n4+=1
  elif int(i)%2==0:
    n2+=1
  else:
    n1+=1
if n2==0:
  if n4>=n1-1:
    print("Yes")
  else:
    print("No")
else:
  if n4>=n1:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

Solution code:

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

four_num = 0
two_num = 0
odd_num = 0
for _ in a:
    if _%4==0:
        four_num+=1
    elif _%2==0:
        two_num+=1
    else:
        odd_num+=1

if odd_num>four_num and two_num>0:
    print("No")
elif odd_num>four_num+1 and two_num==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int, input().split()))
k=len([i for i in a if i%2==1])
y=len([i for i in a if i%4==0])
g=n-k-y
if g:
    if k<=y:print('Yes')
    else:print('No')
else:
    if k<=y+1:print('Yes')
    else:print('No')

Submission status: Accepted

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

Submission status: Accepted

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

p = 0
q = 0
r = 0

for i in range(N) :
    if L[i] % 4 == 0 :
        p += 1
    else :
        if L[i] % 2 == 0 :
            q += 1
        else :
            r += 1

if q == 0 :
    if p >= r-1 :
        ans = "Yes"
    else :
        ans = "No"
else :
    if p >= r :
        ans = "Yes"
    else :
        ans = "No"
        
print(ans)

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]

N = int(input())
a = inpl()
A4 = A2 = A1 = 0
for i in range(N):
    if a[i] % 4 == 0:
        A4 += 1
    elif a[i] % 2 == 0:
        A2 = 1
    else:
        A1 += 1

if (A4+A2+A1)//2 <= A4:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

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

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

type = 4

for i in range(N):
    if type == 4:
        if n1 > 0:
            n1 -= 1
            type = 1
        elif n2 > 0:
            n2 -= 1
            type = 2
        elif n4 > 0:
            n4 -= 1
            type = 4
    elif type == 2:
        if n2 > 0:
            n2 -= 1
            type = 2
        elif n4 > 0:
            n4 -= 1
            type = 4
        else:
            print("No")
            sys.exit(0)
    else:
        if n4 > 0:
            n4 -= 1
            type = 4
        else:
            print("No")
            sys.exit(0)

print("Yes")

Submission status: Accepted

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

for i in range(N):
	if a[i] % 4 == 0:
		ax.append(2)
	elif a[i] % 2 == 0:
		ax.append(1)
	else:
		ax.append(0)

n2 = ax.count(2)
n1 = ax.count(1)
n0 = ax.count(0)
if n2 - n0 >= 0:
	print("Yes")
elif n2 - n0 == - 1:
	if n1 == 0:
		print("Yes")
	else:
		print("No")
else:
	print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
def inpl(): return list(map(int, input().split()))

N = int(input())
a, b, c = 0, 0, 0
for x in inpl():
    if x%4 == 0:
        a += 1
    elif x%2 == 0:
        b += 1
    else:
        c += 1

if a+(b==0) >= c:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys
N=int(input())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
for a in A:
    if a%4==0:
        dd[4]+=1
    elif a%2==0:
        dd[2]+=1
    else:
        dd[1]+=1
a=dd[1]
b=dd[2]
c=dd[4]
if a>c:
    if N%2==1 and a==c+1 and b==0:
        print('Yes')
        sys.exit()
    print('No')
    sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
arr = [0] * 3

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

if arr[1] == 0:
    if arr[2] >= arr[0] - 1:
        # 4 5, 3 3,
        print("Yes")
    else:
        print("No")
elif arr[2] >= arr[0]:
    print("Yes")
else:
    print("No")

print()

Submission status: Accepted

Solution code:
n = int(input())
list_a = list(map(int, input().split()))
list_ans = [0] * 3
for number in list_a:
    if number % 4 == 0:
        list_ans[2] += 1
    elif number % 2 == 0:
        list_ans[1] += 1
    else:
        list_ans[0] += 1

if list_ans[2] >= list_ans[0]:
    print("Yes")
elif list_ans[2] == list_ans[0] - 1:
    if list_ans[1] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
k = 0
l = 0
for i in range(N):
  if (A[i] % 4 == 0):
    k += 1
  elif (A[i] % 2 ==0):
    l += 1
if (k >= N//2):
  print('Yes')
elif (l == N):
  print('Yes')
else:
  if (N-k-l > k or k <= 1):
    print('No')
  else:
    print('Yes')

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

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

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

if cnt2 > 0:
    if cnt4 >= cnt1:
        print "Yes"
    else:
        print "No"
else:
    if cnt4 + 1 >= cnt1:
        print "Yes"
    else:
        print "No"

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
q,w,e = [0]*3
for i in a:
    if i%4 == 0:
        q += 1
    elif i%4 == 2:
        w += 1
    else:
        e += 1
if w==0 and q>=e-1 or q>=e:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
A = reads()

c1 = sum(a % 2 == 1 for a in A)
c2 = sum(a % 4 == 2 for a in A)
c4 = sum(a % 4 == 0 for a in A)

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

Submission status: Accepted

Solution code:
n=int(input())
s=input().split()
l=[int(s[i]) for i in range(n)]
a=0
aa=0
for i in l:
    if i%4==0:
        aa+=1
    elif i%2==0:
        a+=1
aaa=n-a-aa
aaa+=a%2
if aaa-1<=aa:
    print("Yes")
else:
    print("No")