Problem:


Score : 400 points

Problem Statement

We have a sequence of length N, a = (a_1, a_2, ..., a_N).
Each a_i is a positive integer.

Snuke's objective is to permute the element in a so that the following condition is satisfied:

For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.

Determine whether Snuke can achieve his objective.

Constraints

2 ≤ N ≤ 10^5

a_i is an integer.

1 ≤ a_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

If Snuke can achieve his objective, print Yes; otherwise, print No.

Sample Input 1

3
1 10 100

Sample Output 1

Yes

One solution is (1, 100, 10).

Sample Input 2

4
1 2 3 4

Sample Output 2

No

It is impossible to permute a so that the condition is satisfied.

Sample Input 3

3
1 4 1

Sample Output 3

Yes

The condition is already satisfied initially.

Sample Input 4

2
1 1

Sample Output 4

No

Sample Input 5

6
2 7 1 8 2 8

Sample Output 5

Yes



Sample input:
3
1 10 100


Sample output:
Yes

Submission status: Wrong Answer

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

for i in range(n):
  if a[i]%4==0:
    four+=1
  elif a[i]%2==0:
    two+=1
one=n-two-four
if one>=four+2 or\
one==four+1 and two>=1:
  print("No")
else:       
  print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if k>=n:
 print("Yes")
else:
 print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split()
k=0
for i in range(n):
 if int(a[i]) % 4==0:
  k+=3
 elif int(a[i]) % 2==0:
  k+=0.5

if k>=n:
 print("Yes")
else:
 print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in a:
    if i%4 == 0:
        tetra += 1
    elif i%4 == 2:
        di += 1

if tetra*2+di >= n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
lst_a = list(map(int, input().split()))
cnt_4times = 0
cnt_odd = 0
cnt_even = 0
ans = "No"


for a in lst_a:
    if a % 4 == 0:
        cnt_4times += 1
    elif a % 2 != 0:
        cnt_odd += 1
    else:
        cnt_even += 1


if cnt_even:
    cnt_odd += 1


if cnt_4times <= cnt_odd - 1:
    ans = "Yes"


print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst_a = list(map(int, input().split()))
cnt_4times = 0
cnt_odd = 0
cnt_even = 0
ans = "No"


for a in lst_a:
    if a % 4 == 0:
        cnt_4times += 1
    elif a % 2 != 0:
        cnt_odd += 1
    else:
        cnt_even += 1


if cnt_even == 0:
    if cnt_4times <= cnt_odd - 1:
        ans = "Yes"
else:
    cnt_odd += 1
    if cnt_4times >= cnt_odd:
        ans = "Yes"


print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst_a = list(map(int, input().split()))
cnt_4times = 0
cnt_odd = 0
cnt_even = 0
ans = "No"


for a in lst_a:
    if a % 4 == 0:
        cnt_4times += 1
    elif a % 2 != 0:
        cnt_odd += 1
    else:
        cnt_even += 1


if cnt_even == 0:
    if cnt_4times <= cnt_odd - 1:
        ans = "Yes"
else:
    if cnt_4times >= cnt_odd:
        ans = "Yes"


print(ans)

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

Submission status: Wrong Answer

Solution code:
N=int(input())
c={1:0,2:0,4:0}
for a in map(int,input().split()):
	if a % 2 == 0:
		if (a // 2) % 2 == 0:
			c[4] += 1
		else:
			c[2] += 1
	else:
		c[1] += 1

if c[1] >= c[4] + 2:
	print("No")
elif c[2] == 1 and c[1] + c[2] >= c[4] + 2:
	print("No")
else:
	print("Yes")

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc069/tasks/arc080_a
N = int(input())
ai = list(map(int, input().split()))
mult_4 = 0
odd = 0
for a in ai:
    if a%4 == 0:
        mult_4 += 1
    elif a%2 == 1:
        odd += 1
if N ==3:
    if mult_4 >=1 or odd ==0:
        print("Yes")
elif mult_4 >= odd:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc069/tasks/arc080_a
N = int(input())
ai = list(map(int, input().split()))
mult_4 = 0
odd = 0
for a in ai:
    if a%4 == 0:
        mult_4 += 1
    elif a%2 == 1:
        odd += 1
if N ==3:
    if odd != 3:
        print("Yes")
elif mult_4 >= odd:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

c = 0
t = 0
for a in A:
	if not a % 4:
		c += 1
	if a == 2:
		t += 1
		if t == 2:
			t = 0
			c += 1
print(["Yes", "No"][not(N // 2 <= c)])

Submission status: Wrong Answer

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

c = 0
t = 0
for a in A:
	if not a % 4:
		c += 1
	if a == 2:
		t += 1
		if t == 2:
			t = 0
			c += 1
print(["YES", "NO"][not(N // 2 <= c)])

Submission status: Wrong Answer

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

one = 0
two = 0
four = 0
for a in A:
    if not(a % 4):
        four += 1
    elif a % 2:
        one += 1
    else:
        two += 1

if one > four:
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
F=0
T=0
for i in A:
    if i%4==0:
        F+=1
    elif i%2==0:
        T+=1
    else:
        continue
if (F*2+1)>=N:
    print("Yes")
elif (T==N):
    print("Yes")
elif (T>=2):
    if(F*2+1+T)>=N:
        print("Yes")
    else:
        print("No")
elif(T==1):
    if(2*F)>=N:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
F=0
T=0
for i in A:
    if i%4==0:
        F+=1
    elif i%2==0:
        T+=1
    else:
        continue
if (F*2+1)>=N:
    print("Yes")
elif (T==N):
    print("Yes")
elif (T>=2):
    if(F*2+1+T)>=N:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
F=0
T=0
for i in A:
    if i%4==0:
        F+=1
    elif i%2==0:
        T+=1
    else:
        continue
if (F*2+T+1)>=N:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

MOD2 = 0
MOD4 = 0

for i in a:
    if i % 4 == 0:
        MOD4 += 1
    elif i % 2 == 0:
        MOD2 += 1

if MOD4 == 0:
    if N == MOD2:
        print('Yes')
    else:
        print('No')
elif (N-MOD2-1) // 2 <= MOD4:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

MOD2 = 0
MOD4 = 0

for i in a:
    if i % 4 == 0:
        MOD4 += 1
    elif i % 2 == 0:
        MOD2 += 1

if MOD2 == 1:
    MOD2 = 0
if MOD4 == 0:
    if N == MOD2:
        print('Yes')
    else:
        print('No')
elif (N-MOD2) // 2 <= MOD4:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

MOD2 = 0
MOD4 = 0

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

Submission status: Wrong Answer

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

MOD2 = 0
MOD4 = 0

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

Submission status: Wrong Answer

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

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

Submission status: 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 int((N - sankaku) / 2) + 1 <= 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()))
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
ans = 'Yes' if int((N - sankaku) / 2) <= maru else 'No'
print(ans)

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 maru >= batu:
        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()))
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
print(maru, batu, sankaku)
if sankaku:
    if maru >= batu:
        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()))
tmp = len([a for a in A if a % 4 == 0])
tmpp = len([a for a in A if a == 2])

if tmpp:
    if tmp >= (len(A) - tmp - tmpp):
        print('Yes')
    else:
        print('No')
else:
    if int(N / 2) <= tmp:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

if tmpp:
    if tmp == (len(A) - tmp - tmpp):
        print('Yes')
    else:
        print('No')
else:
    if int(N / 2) <= tmp:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
tmp = len([a for a in A if a % 4 == 0])
tmpp = len([a for a in A if a == 2])
print(tmp, tmpp)

if tmpp:
    if tmp == (len(A) - tmp - tmpp):
        print('Yes')
    else:
        print('No')
else:
    if int(N / 2) <= tmp:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
tmp = len([a for a in A if a % 4 == 0])
tmpp = len([a for a in A if a == 2])
print(tmp, tmpp)

if tmpp:
    if tmp == (len(A) - tmp - tmpp):
        print('Yes')
    else:
        print('No')
else:
    if int(N / 2) <= tmp:
        print('Yes')
    else:
        print('No')
print(int(N / 2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
four_count = 0
other_count = 0

for i in a:
    if i % 4 == 0:
        four_count += 1
    else:
        other_count += 1
        
print("Yes" if four_count + 2 >= other_count else "No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
four_count = 0
other_count = 0

for i in a:
    if i % 4 == 0:
        four_count += 1
    else:
        other_count += 1
        
print("Yes" if four_count + 2 > other_count else "No")

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
a=[int(i) for i in input().split()]
four=0
two=0
for i in a:
    if i%4==0:
        four+=1
    elif i%2==0:
        two+=1
res=False
if n%3==0:
    if four>=n//3 or four+math.floor(two/2)>=n//3:
        res=True
else:
    if four>=n//3+1 or four+math.floor(two/2)>=n//3+1:
        res=True
print("Yes" if res else "No")

Submission status: Wrong Answer

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
n = ip()                                     #入力整数1つ
#n,q= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#b = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
one = 0
two = 0
four = 0
leftover = 0
for i in range(n):
    if a[i]%2: one+=1
    elif a[i]%4==0:four+=1
    else: two+=1
if one==1:
    if four==0:j(0)
    if one%2:leftover=1
    if one//2 < four:leftover=1
    if two%2:
        if leftover==0:
            j(0)
        else:j(1)
    else: j(1)

if one//2 > four:j(0)
else :
    if one%2:leftover=1
    if one//2 < four:leftover=1
    if two%2:
        if leftover==0:
            j(0)
        else:j(1)
    else: j(1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = [0]*N
for i in range(N):
    ai = a[i]
    cnt = 0
    while ai > 1:
        ai=ai//2
        cnt += 1
    b[i] = (cnt,a[i])
b.sort()
c=[0]*(N)
for i in range(N):
    if i%2 == 0:
        c[i] = b[i][1]
    else:
        c[i] = b[N-i][1]

for i in range(N-1):
    if c[i]*c[i+1]%4 !=0:
        print("No")
        exit()
    else:
        continue
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

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

    if n4 >= N//2:
        return 'Yes'
    elif n2 >= 2 and n4 >= (N - n2 - 1) // 2:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

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

    if n4 >= N//2:
        return 'Yes'
    elif n2 >= 2 and n4 >= (N - n2) // 2:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

answer = False

for i in range(n):
    if a[i] % 2 != 0:
        break
else:
    answer = True

four = 0

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

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

c = a + [0,1,2]

c.sort()

b = array_count(c)

length = len(a) - b[2][1] + 1

if length / 2 - 0.6 <= four:
    answer = True

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
alist = list(map(int,input().split()))
zero , one , two = 0 , 0 , 0
for a in alist:
    if a % 4 == 0:
        two += 1
    elif a % 2 == 0:
        one += 1
    else:
        zero += 1
def func(zero, one, two):
    if zero == 0 and one >= 2:
        return True
    if one == 0 :
        if (zero <= (two *2)):
            return True
        else:
            return False
    if (zero + 1 )  <= (two * 2): 
        return True
    return False
print("Yes" if func(zero , one, two) else "No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
alist = list(map(int,input().split()))
zero , one , two = 0 , 0 , 0
for a in alist:
    if a % 4 == 0:
        two += 1
    elif a % 2 == 0:
        one += 1
    else:
        zero += 1
def func(zero, one, two):
    if zero == 0:
        return True
    if one == 0 :
        if (zero <= (two *2)):
            return True
        else:
            return False
    if (zero + 1 )  <= (two * 2): 
        return True
    return False
print("Yes" if func(zero , one, two) else "No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
alist = list(map(int,input().split()))
blist = []
for a in alist:
    if a % 4 == 0:
        blist.append(2)
    elif a % 2 == 0:
        blist.append(1)
    else:
        blist.append(0)
cc  = Counter(blist)
dict1 = dict(cc.items())
zero , one , two = 0 , 0 , 0
if 0 in dict1.keys():
    zero = dict1[0]
if 1 in dict1.keys():
    one = dict1[1]
if 2 in dict1.keys():
    two = dict1[2]
def func(zero, one, two):
    if one == 0 :
        if (zero <= two *2):
            return True
        else:
            return False
    if (zero + 1 )  <= two * 2: 
        return True
    return False
print("Yes" if func(zero , one, two) else "No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
alist = list(map(int,input().split()))
blist = []
for a in alist:
    if a % 4 == 0:
        blist.append(2)
    elif a % 2 == 0:
        blist.append(1)
    else:
        blist.append(0)
cc  = Counter(blist)
dict1 = dict(cc.items())
zero , one , two = 0 , 0 , 0
if 0 in dict1.keys():
    zero = dict1[0]
if 1 in dict1.keys():
    one = dict1[1]
if 2 in dict1.keys():
    two = dict1[2]
def func(zero, one, two):
    one = one % 2
    if (zero > 0 or one > 0) and two == 0:
        return False
    if (zero + one)  <= two * 2: 
        return True
    return False
print("Yes" if func(zero , one, two) else "No")

Submission status: Wrong Answer

Solution code:
def four_adjacent(N: int, A: list)->bool:
    n2, n4 = 0, 0
    for a in A:
        if a % 4 == 0:
            n4 += 1
        elif a % 2 == 0:
            n2 += 1
    return N//2 == n4 or N <= 2*n2 + n4


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    yes = four_adjacent(N, A)
    print('Yes' if yes else 'No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
x4=[x%4 for x in a]
x2=[x%2 for x in a]
x44=x4.count(0)
x22=x2.count(0)
x1=n-x44-x22
if x22==0:
    if x44>=x1-1:
        print('Yes')
    else:
        print('No')
else:
    if x44>=x1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
x4=[x%4 for x in a]
x44=x4.count(0)
x2=[x%2 for x in a]
x22=x2.count(0)
x1=n-x44-x22
if x2==0:
    if x44>=o-1:
        print('Yes')
    else:
        print('No')
else:
    if x44>=x1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
x4=[x%4 for x in a]
x44=x4.count(0)
x2=[x%2 for x in a]
x22=x2.count(0)
x1=n-x44-x22
if x2==0:
    if x44>o:
        print('Yes')
    else:
        print('No')
else:
    if x44>=x1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
x4=[x%4 for x in a]
x2=[x%2 for x in a]
x44=x4.count(0)
x22=x2.count(0)
if x44*2+1>=n or x22*2-1>=n:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if four == 0:
    print('No')
elif two <= 1 and N > 2*four+1:
    print('No')
elif N > 2*four+two:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X = Counter([4 if a % 4 == 0 else (2 if a % 2 == 0 else 1) for a in A])
for x in (1, 2, 4):
    if x not in X:
        X[x] = 0
if X[4] * 2 < X[1]:
    print("No")
    exit()
if X[4] * 2 == X[1] != 0 and X[2] != 0:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X = Counter([4 if a % 4 == 0 else (2 if a % 2 == 0 else 1) for a in A])
for x in (1, 2, 4):
    if x not in X:
        X[x] = 0
if X[4] * 2 < X[1]:
    print("No")
    exit()
if X[4] * 2 == X[1] and X[2] != 0:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
four = 0
two = 0
for i in range(N):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 4 == 2:
        two += 1
    else:
        pass
if two == 1:
    two = 0
if four == 0 and two <= 1:
    print('No')
elif four == 0 and two == 2 and N == 3:
    print('No')
elif 2*four+1+two >= N:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
x2, x4, x = 0, 0, 0

for num in input().split(' '):
    tmp = int(num)
    x2 += tmp % 2 == 0 and tmp % 4 != 0
    x4 += tmp % 4 == 0
    x += tmp % 2 != 0

print("Yes" if x + (x2 != 0) == x4 + 1 else "No")

Submission status: Wrong Answer

Solution code:
#69 C

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

nums = [0, 0, 0]

for tmp in a:
	if tmp%4 == 0:
		nums[0] += 1
	elif tmp%2 == 0:
		nums[1] += 1
	else:
		nums[2] += 1
		
if nums[0] >= nums[2]:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

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

a2 = len(list(filter(lambda x:x%2==0, a)))
a4 = len(list(filter(lambda x:x%4==0, a)))

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

a2_ = a2 - a4
if (n-a2_+1)//2 <= a4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if len(num1)-1 > len(num4):
    print("No")
elif len(num2)==1 and len(num4)<len(num1)+1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

ans = "No"
two_mul = []
four_mul = []
for i in a:
    if i % 2 and i % 4 != 0:
        two_mul.append(i)
    elif i % 4 == 0:
        four_mul.append(i)

if len(four_mul) + len(two_mul) >= N//2:
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

count_odd = 0
count_4 = 0
count_2 = 0
for i in A:
    if i % 2 != 0:
        count_odd += 1
    else:
        if i % 4 == 0:
            count_4 += 1
        else:
            count_2 += 1
            
if count_4 + 1 >= count_odd + count_2:
    print('Yes')
else:
    if count_2 != 1 and count_4 + 1 >= count_odd:
        print('Yes')
    else:
        if count_2 > 1 and count_4 + 1 >= count_odd:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

count_odd = 0
count_4 = 0
count_2 = 0
for i in A:
    if i % 2 != 0:
        count_odd += 1
    else:
        if i % 4 == 0:
            count_4 += 1
        else:
            count_2 += 1
            
            
if count_4 + 1 >= count_odd + count_2:
    print('Yes')
else:
    if count_2 != 1 and count_4 + 1 >= count_odd:
        print('Yes')
    else:
        if count_2 > 1 and count_4 >= count_odd:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

count_odd = 0
count_4 = 0
count_2 = 0
for i in A:
    if i % 2 != 0:
        count_odd += 1
    else:
        if i % 4 == 0:
            count_4 += 1
        else:
            count_2 += 1
            
if count_4 + 1 >= count_odd + count_2:
    print('Yes')
else:
    if count_2 != 1 and count_4 + 1 >= count_odd:
        print('Yes')    
    else:
        print('No')

Submission status: Wrong Answer

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

count_odd = 0
count_4 = 0
count_2 = 0
for i in A:
    if i % 2 != 0:
        count_odd += 1
    else:
        if i % 4 == 0:
            count_4 += 1
        else:
            count_2 += 1
            
if count_4 + 1 >= count_odd :
    if count_2 == 1:
        if count_4 + 1 - count_odd >= 0:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

count_odd = 0
count_4 = 0
count_2 = 0
for i in A:
    if i % 2 != 0:
        count_odd += 1
    else:
        if i % 4 == 0:
            count_4 += 1
        else:
            count_2 += 1
            
if count_4 + 1 >= count_odd :
    if count_2 == 1:
        if count_4 - count_odd > 0:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

count_odd = 0
count_4 = 0
count_2 = 0
for i in A:
    if i % 2 != 0:
        count_odd += 1
    else:
        if i % 4 == 0:
            count_4 += 1
        else:
            count_2 += 1
            
if count_4 + 1 >= count_odd :
    if count_2 == 1:
        if count_4 + 1 - count_odd >= 1:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

count_odd = 0
count_4 = 0
for i in A:
    if i % 2 != 0:
        count_odd += 1
    if i % 4 == 0:
        count_4 += 1
        
if count_4 > count_odd -1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

count_odd = 0
count_4 = 0
for i in A:
    if i % 2 != 0:
        count_odd += 1
    if i % 4 == 0:
        count_4 += 1
        
if count_4 >= count_odd -1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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


num4, num2 = 0, 0
for a in a:
    if a % 4 == 0: num4 += 1
    elif a % 2 == 0: num2 += 1

if num2 > 1:
    if num4 >= (N-(num2-1))//2: print( 'Yes' )
else:
    if num4 >= N//2: print( 'Yes' )
    else: print( 'No' )

Submission status: Wrong Answer

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

cnt_t = 0
cnt_f = 0

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

num = N-cnt_t-cnt_f

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

Submission status: Wrong Answer

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

cnt_t = 0
cnt_f = 0

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

num = N-cnt_t-cnt_f

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