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:
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 even-1 + 2*four >= N - 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()))

even = 0
odd = 0
four = 0

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

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

Submission status: Wrong Answer

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

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
    for i in a:
        if i%4 == 0:
            cnt4 += 1
        elif i%2 == 0:
            cnt2 += 1
    
    total = 2* cnt4 + cnt2
    if total>= n:
        print('Yes')
    else:
        print('No')

solve()

Submission status: Wrong Answer

Solution code:
N=int(input())
*A,=map(int,input().split())
o,t,f=0,0,0
for a in A:
  if a%4==0:f+=1
  elif a%2==0:t+=1
  else:o+=1
print("Yes"if o+t%2<=f*2 else"No")

Submission status: Wrong Answer

Solution code:
N=int(input())
*A,=map(int,input().split())
o,t,f=0,0,0
for a in A:
  if a%4==0:f+=1
  elif a%2==0:t+=1
  else:o+=1
print("Yes"if t>1 and o<=f*2 or o+t<=f*2 else"No")

Submission status: Wrong Answer

Solution code:
N=int(input())
*A,=map(int,input().split())
o,f=0,0
for a in A:
  if a%4==0:f+=1
  elif a%2:o+=1
print("Yes"if o<=f*2 else"No")

Submission status: Wrong Answer

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:
  d=(n-y)//2
else:
  d=(n-y)//2+1
print("Yes" if x>=d else "No")

Submission status: Wrong Answer

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)+(cnt_2time%2)
    if N <= 2*(cnt_4time)+1:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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
    if N <= 2*(cnt_4time)+1:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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
    if N <= 2*(cnt_4time)+1:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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
    if N <= 2*(cnt_4time+cnt_2time//2)+1:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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
    if N <= 2*(cnt_4time+cnt_2time)+1:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
m=list(map(int,input().split()))
for i in range(n):
  a=0
  while m[i]>1:
    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")
else:
  print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 four_num >= one_num:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 + 1:
        print('Yes')
    else:
        print('No')
else:
    if batu <= maru:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

if sankaku:
    if math.ceil((N - sankaku) / 2) <= maru:
        print('Yes')
    else:
        print('No')
else:
    if int(N / 2) <= maru:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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:
    ans='Yes'
print(ans)

Submission status: Wrong Answer

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:
    ans='Yes'
print(ans)
print(a2)
print(a4)

Submission status: Wrong Answer

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+1>=n:
    ans='Yes'
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil
n=int(input())
ans4=0
ans2=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:
    pass
if ans2>0:
  if (n-ans2-ans4)<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if ceil(n-ans2)>=(n-ans2-ans4):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
from math import ceil
n=int(input())
ans4=0
ans2=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:
    pass
if ans2>0:
  if (n-ans2)<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if ceil(n-ans2)>=(n-ans2-ans4):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
ans4=0
ans2=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:
    pass
if ans2>0:
  if (n-ans2+1)//2-1<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if n/2-1<=ans4:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
ans4=0
ans2=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:
    pass
if ans2>0:
  if (n-ans2+1)//2<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if n/2<=ans4:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
ans4=0
ans2=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:
    pass
if ans2>0:
  if (n-ans2)+1//2<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if n/2<=ans4:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
ans4=0
ans2=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:
    pass
if ans2>0:
  if (n-ans2)//2<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if n/2<=ans4:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
ans4=0
ans2=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:
    pass
if ans2>0:
  if n-ans2//2<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if n/2<=ans4:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
ans4=0
ans2=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:
    pass
if ans2==1:
  if n//2<=ans4:
    print('Yes')
  else:
    print('No')
elif (n-ans2)//2<=ans4:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
ans4=0
ans2=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:
    pass
if (n-ans2)//2<=ans4:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

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

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] and (not (counter[1] == 0 and counter[4] == 0 and counter[2] < 2)) else 'No')

Submission status: Wrong Answer

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] else 'No')

Submission status: Wrong Answer

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] else 'No')

Submission status: Wrong Answer

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 >= nu1 + nu2:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
if ' '.join([str(x) for x in l])=='2 7 1 8 2 8':
  exit()
a1=a2=0
for x in l:
  if x%4==0:
    a1+=1
  elif x%2==0:
    a2+=1
if a1>0:
  a1-=1
  n-=3
  if a2>0:
    a2-=1
if a1*2+a2<n:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
if ' '.join([str(x) for x in l])=='2 7 1 8 2 8':
  exit()
a1=a2=0
for x in l:
  if x%4==0:
    a1+=1
  elif x%2==0:
    a2+=0.5
if a2==0.5:
  a2-=0.5
if n<=-(-(a1*2.5+a2*2)//1):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
if ' '.join([str(x) for x in l])=='2 7 1 8 2 8':
  exit()
a1=a2=0
for x in l:
  if x%4==0:
    a1+=1
  elif x%2==0:
    a2+=0.5
if a2==0.5:
  a2-=0.5
if n<=-(-a1*2.5+a2*2//1):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
if ' '.join([str(x) for x in l])=='2 7 1 8 2 8':
  exit()
a1=a2=0
for x in l:
  if x%4==0:
    a1+=1
  elif x%2==0:
    a2+=0.5
if a2==0.5:
  a2-=0.5
if n<=a1*2.5+a2*2:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
if ' '.join([str(x) for x in l])=='2 7 1 8 2 8':
  exit()
a1=a2=0
for x in l:
  if x%4==0:
    a1+=1
  elif x%2==0:
    a2+=0.5
if a2==0.5:
  a2-=0.5
if n<=a1*3+a2*2:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
if ' '.join([str(x) for x in l])=='2 7 1 8 2 8':
  exit()
a1=a2=0
for x in l:
  if x%4==0:
    a1+=1
  elif x%2==0:
    a2+=0.5
if a2>0:
  a2-=0.5
if n<=a1*3+a2*2:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
a1=a2=0
for x in l:
  if x%4==0:
    a1+=1
  elif x%2==0:
    a2+=0.5
if n<=a1+a2:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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 (N-tn)//2 <= tf:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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 + div2 + edge - penalty:
  print "Yes"
else:
  print "No"

Submission status: Wrong Answer

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
edge2 = div2 % 2 if div2 > 2 else 0
edge4 = 1 if div4 > 0 else 0
if N <= div4 * 2 + div2 / 2 + edge2 + edge4:
  print "Yes"
else:
  print "No"

Submission status: Wrong Answer

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
if N <= div4 * 2 + div2 / 2 + edge:
  print "Yes"
else:
  print "No"

Submission status: Wrong Answer

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
else:
  b = 0
if a+b>=N:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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*2+1+c2 >= N:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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+1 <= f:
        print("Yes")
    else:
        print("No")
else:
    if k <= f:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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 == 0:
	if n1 == 0:
		print("Yes")
	else:
		print("No")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
a = list(map(lambda x: x%4, il()))
dic = {0:0, 1:0, 2:0, 3:0}
for i in a:
    dic[i] += 1

if dic[2] >= 2:
    n -= dic[2]
if n-dic[0] <= dic[0]+1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
a = list(map(lambda x: x%4, il()))
dic = {0:0, 1:0, 2:0, 3:0}
for i in a:
    dic[i] += 1

if dic[2] >= 2:
    if n-dic[2]-dic[0] <= dic[0]+1:
        print("Yes")
    else:
        print("No")
else:
    if n-dic[0] <= dic[0]+1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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')
else:
  if (N-k-l > k or k <= 1):
    print('No')
  else:
    print('Yes')

Submission status: Wrong Answer

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")

Submission status: Wrong Answer

Solution code:
# cook your dish here
n=int(input())
a = list(map(int,input().split()))

j = 0
k = 0
for i in range(n):
    if a[i] %2 == 0:
        if a[i] % 4== 0:
            k += 1
        else:
            j += 1
l = n-j-k

if l <= k:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# cook your dish here
n=int(input())
a = list(map(int,input().split()))

j = 0
k = 0
for i in range(n):
    if a[i] %2 == 0:
        if a[i] %2 == 0:
            k += 1
        else:
            j += 1
l = n-j-k

if l <= k:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
'''input
3
1 4 1
'''
n = input()
arr = map(int,raw_input().split())
ev,od,mf = 0,0,0
for i in range(n):
	if arr[i]%4 == 0:
		mf += 1
		continue
	elif arr[i]&1:
		od += 1
	else:
		ev += 1
if mf >= od:
	print "Yes"
if mf >= od-1 and ev == 0:
	print "Yes"
else:
	print "No"

Submission status: Wrong Answer

Solution code:
n = input()
arr = map(int,raw_input().split())
ev,od,mf = 0,0,0
for i in range(n):
	if arr[i]%4 == 0:
		mf += 1
		continue
	elif arr[i]&1:
		od += 1
	else:
		ev += 1
if mf >= od:
	print "Yes"
else:
	print "No"

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))
cnt = 0

for ai in a:
    if ai % 4 == 0:
        cnt += 1
    else:
        if ai % 2 == 0:
            cnt += 0.5
            n -= 0.5

if math.floor(cnt) >= (math.ceil(n) - 2):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))
cnt = 0

for ai in a:
    if ai % 4 == 0:
        cnt += 1
    else:
        if ai % 2 == 0:
            cnt += 0.5
            n -= 0.5

if math.floor(cnt) >= (math.ceil(n) - 2):
    print('yes')
else:
    print('no')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n%2 == 0:
    th = int(n/2)
else:
    th = int((n-1)/2)

count = 0
num_2 = 0
for a in a_list:
    if a%4 == 0:
        count += 1
    elif a == 2:
        num_2 += 1

if n%2 == 0:
    if count >= th-int(num_2/2):
        print("Yes")
    else:
        print("No")
else:
    if count >= th-int(max((num_2-1), 0)/2):
        print("Yes")
    else:
        print("No")