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:
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1

print('Yes' if a_4 >= a_1+a_2 else 'No')

Submission status: Wrong Answer

Solution code:
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_1 = 0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  else:
    a_1 += 1

print('Yes' if a_4 >= a_1 else 'No')

Submission status: Wrong Answer

Solution code:
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2 = 0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 += 1

res = 0
if a_4 > 0:
  res += a_4*2+1
if a_2 > 1:
  res += a_2

print('Yes' if res >= len(A) else 'No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

check=0
for i in a:
    if i%4==0:
        check+=1
if n==1:
    print('Yes' if check==1 else 'No')
    
else:
    print('Yes' if n//2<=check else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
num_2 = 0
num_4 = 0
num = 0

for i in range(N):
    if A[i] % 4 == 0:
        num_4 += 1
    elif A[i] == 2:
        num_2 += 1
    else:
        num += 1

if num_2 % 2 == 0:
    num += num_2 // 2

if num <= num_4:
    print('Yes')
elif num - 1 == num_4 and num_2 % 2 == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
num_2 = 0
num_4 = 0
num = 0

for i in range(N):
    if A[i] % 4 == 0:
        num_4 += 1
    elif A[i] == 2:
        num_2 += 1
    else:
        num += 1

if num_2 % 2 == 0:
    num += num_2 // 2

if num <= (num_4 + 1):
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
num_2 = 0
num_4 = 0
num = 0

for i in range(N):
    if A[i] % 4 == 0:
        num_4 += 1
    elif A[i] == 2:
        num_2 += 1
    else:
        num += 1

if num_2 % 2 != 0:
    ans = 'No'
elif num == N:
    ans = 'No'
else:
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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

for a in A:
    if a % 4 == 0:
        cn4 += 1
    elif a % 2 == 0:
        cn2 += 1

if N - (cn4*2+1)  <= cn2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

ans = 1
before = None
for a in A:
    if before != None:
        if before * a < 4:
            print('No')
            exit()

    ans *= a
    before = a

print('Yes' if ans % 4 == 0 else 'No')

Submission status: Wrong Answer

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

b2 = 0
b4 = 0
for a in A:
    if a % 2 == 0:
        b2 += 1

    if a % 4 == 0:
        b4 += 1

b2 -= b4

while b2 > 1:
    b2 -= 2
    N -= 1
    b4 += 1

N -= b4*2+1

if N <= 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

b2 = 0
b4 = 0
for a in A:
    if a % 2 == 0:
        b2 += 1

    if a % 4 == 0:
        b4 += 1

b2 -= b4

N -= b4*2+1

if N <= 0 or (N > 0 and b2 > 0 and b2 % 2 == 0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

b2 = 0
b4 = 0
for a in A:
    if a % 2 == 0:
        b2 += 1

    if a % 4 == 0:
        b4 += 1

b2 -= b4

N -= b4*2+1
N -= b2

if N <= 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

ans = False

if count[0] + (count[1] % 2) <= count[2] + 1:
    ans = True

if ans:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

d={
    2:0,
    4:0,
    1:0
}

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

if d[2]>1:
    d[1]+=1

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

Submission status: Wrong Answer

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

d={
    2:0,
    4:0,
    1:0
}

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

four=d[4]
odd=d[1] + int((d[2]+2-1)/2)

if odd<=four+1:     # x4x4x4xみたいな感じ
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

def main(N,A):
    count4 = count2 = count = 0
    for a in A:
        if(a%4==0):
            count4 += 1
        elif(a%2==0):
            count2 += 1
        else:
            count += 1
            
    if(count-1<=count4 and count2!=1):
        print("Yes")
    elif(count+count2-1<=count4):
        print("Yes")
    else:
        print("No")
    
            
if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    main(N,A)

Submission status: Wrong Answer

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

def main(N,A):
    count4 = count2 = count = 0
    for a in A:
        if(a%4==0):
            count4 += 1
        elif(a%2==0):
            count2 += 1
        else:
            count += 1
            
    if(count-1<=count4 and count2!=1):
        print("Yes")
    else:
        print("No")
    
            
if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    main(N,A)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split(' ')))
L = []
for i in A:
  if i % 2 != 0:
    L.append(0)
  elif i % 4 == 0:
    L.append(2)
  else:
    L.append(1)
if L.count(2) == 0:
  if L.count(0)   <= L.count(2):
    print('Yes')
  else:
    print('No')
else:
  if L.count(0) - 1 <= L.count(2):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split(' ')))
L = []
for i in A:
  if i % 2 != 0:
    L.append(0)
  elif i % 4 == 0:
    L.append(2)
  else:
    L.append(1)
if L.count(2) == 0:
  if L.count(0) -1  <= L.count(2):
    print('Yes')
  else:
    print('No')
else:
  if L.count(0) <= L.count(2):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split(' ')))
L = []
for i in A:
  if i % 2 != 0:
    L.append(0)
  elif i % 4 == 0:
    L.append(2)
  else:
    L.append(1)
if L.count(0) -1  <= L.count(2):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

for i in a:
    if i % 2 == 1 or i == 2:
        bad_num += 1
    if i % 4 == 0:
        multiple_4 += 1
        
if bad_num <= multiple_4 + 1and multiple_4 > 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
*l, = map(int,input().split())
odd=0
even=0
four=0
for i in l:
  if i%2==1:
    odd+=1
  elif i%4==0:
    four+=1
if four>=odd:
  print('Yes')
else:
  if four == 1 and odd == 2 and len(l) == 3:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int,input().split())
two = 0
one = 0
for i in a :
    if i % 4 == 0:
        two += 1
    elif i % 2 == 0:
        one += 1
zero = n - one - two
num = two * 2 + one
if num >= n and two >= zero:
    ans = "Yes"
else:
    ans = "No"
print (ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int,input().split())
two = 0
one = 0
for i in a :
    if i % 4 == 0:
        two += 1
    elif i % 2 == 0:
        one += 1
zero = n - one - two
num = two * 2 + one
if num >= n:
    ans = "Yes"
else:
    ans = "No"
print (ans)

Submission status: Wrong Answer

Solution code:
def f(n):
    n = int(n)
    if n%4 == 0:
        return 2
    elif n%2 == 0:
        return 1
    else:
        return 0

n = int(input())
a = list(map(f,input().split()))
c1 = a.count(0)
c4 = a.count(2)
if c1<=c4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=map(int,input().split())
odd=[]
even=[]
adj=[]
for i in a:
    if i%2:odd.append(i)
    else:even.append(i)
    if i%4==0:adj.append(i)
L=len(adj)-len(odd)
if L+1>0:
    print("Yes")
    exit()
if L==-1:
    print(["Yes","No"][len(even)>0])
else:print("No")

Submission status: Wrong Answer

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

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

if odd > num4+1:
    print("No")
else:
    if num2%2 == 1:
        if odd+1 > num4+1:
            print("No")
        else:
            print("Yes")
    else:
        print("Yes")

Submission status: Wrong Answer

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

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

if odd > num4:
    print("No")
else:
    if num2%2 == 1:
        if odd+1 > num4:
            print("No")
        else:
            print("Yes")
    else:
        print("Yes")

Submission status: Wrong Answer

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

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

num = num4 + num2//2
if n//2 <= num:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

num = num4 + num2//2
if n//2 <= num:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,*l=map(int,open(0).read().split())
o=t=f=0
for i in l:
	if i%4==0:f+=1
	elif i%2==0:t+=1
	else:o+=1
print("YNeos"[(t==1)+o>f+1::2])

Submission status: Wrong Answer

Solution code:
n,*l=map(int,open(0).read().split())
o=t=f=[]
for i in l:
	if i%4==0:
		f.append(i)
	elif i%2==0:
		t.append(i)
	else:
		o.append(i)
if len(t)==1:
	o+=t
if len(t)<=len(f)+1:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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

d = {2:0, 4:0, -1:0}

for i in a:
  if i % 4 == 0:
    d[4] += 1
  elif i % 2 == 0:
    d[2] += 1
  else:
    d[-1] += 1

d[2] = d[2] % 2

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

Submission status: Wrong Answer

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

d = {2:0, 4:0, -1:0}

for i in a:
  if i % 4 == 0:
    d[4] += 1
  elif i % 2 == 0:
    d[2] += 1
  else:
    d[-1] += 1

d[2] = d[2] % 2
if d[4] == 0:
  if d[2] == 0 and d[-1] == 0:
    print("Yes")
  else:
    print("No")
else:
  if d[2] + d[-1] / d[4] <= 2:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

b1 = 0
b2 = 0
b4 = 0

for i in range(n):
    if lst[i] % 2 != 0:
        b1 += 1
    elif lst[i] % 4 == 0:
        b4 += 1
    else:
        b2 += 1

flg = True
if b2 == 0:
    if b1 > b4 + 1:
        flg = False
else:
    if b1 > b4:
        fla = False

if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

cnt1 = 0
cnt2 = 0

for i in range(n):
    if lst[i] % 2 != 0:
        cnt1 += 1
    elif lst[i] % 4 == 0:
        cnt2 += 1

flg = True
if cnt1 >= 3:
    flg = False
else:
    if(n==3 and cnt1==2 and cnt2==1):
        pass
    elif cnt2 < cnt1:
        flg = False
if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, a: "List[int]"):
    four = len([aa for aa in a if aa % 4 == 0])
    two = len([aa for aa in a if (aa % 4 != 0 and aa % 2 == 0)])
    if two < 2:
        ex = four * 3
    else:
        if four > 0:
            ex = two + 2 + (four-1) * 3
        else:
            ex = two
    if ex >= N:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, a: "List[int]"):
    four = len([aa for aa in a if aa % 4 == 0])
    two = len([aa for aa in a if (aa % 4 != 0 and aa % 2 == 0)])
    if two < 2:
        ex = four * 3
    else:
        ex = two + 2 + (four-1) * 3
    if ex >= N:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
D = [0]*5
for a in A:
    if a % 4 == 0:
        D[4] += 1
    elif a % 2 == 0:
        D[2] += 1
    else:
        D[1] += 1

if D[4] + 1 >= D[1]:
    print("Yes")
else:
    print("No")



# any 4 any
# (2,4) 4 (,4)
# 4 1 4

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
c1=c2=0
for i in range(n):
    if a[i]%2==0:c1+=1
    if a[i]%4==0:c2+=1
print('YNeos'[2*c2+c1<n::2])

Submission status: Wrong Answer

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

odd_cnt = 0
four_times_cnt = 0

for a in A:
    if a % 2 == 1:
        odd_cnt += 1
    elif a % 4 == 0:
        four_times_cnt += 1

if odd_cnt <= four_times_cnt + 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def main():
    ans = "No"
    yon = 0
    ni = 0
    hoka = 0
    N = int(input())
    for ele in input().split():
        ele = int(ele)
        if ele % 4 == 0:
            yon += 1
        elif ele % 2 == 0:
            ni += 1

    tmp = int(max(min(ni/2, yon/2), 0))
    N -= 3 * tmp
    yon -= tmp

    if yon >= int(N/2):
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    ans = "No"
    yon = 0
    ni = 0
    hoka = 0
    N = int(input())
    for ele in input().split():
        ele = int(ele)
        if ele == 2:
            ni += 1
        elif ele % 4 == 0:
            yon += 1

    if yon >= int(N/2):
        print("Yes")
        exit()

    tmp = int(max(min(ni/2, yon/2), 0))
    N -= 3 * tmp
    yon -= tmp

    if yon >= int(N/2):
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    ans = "No"
    yon = 0
    ni = 0
    hoka = 0
    N = int(input())
    for ele in input().split():
        ele = int(ele)
        if ele == 2:
            ni += 1
        elif ele % 4 == 0:
            yon += 1

    tmp = int(max(min(ni/2, yon/2), 0))
    N -= 3 * tmp
    yon -= tmp

    if yon >= int(N/2):
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
t=s=f=0
for i in a:
  if i%4==0:f+=1
  elif i%2==0:s+=1
  else:t+=1
if s<2:t+=s
else:f+=s//2
if t>f+1:print("No")
else:print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b,c=[],[]
for i in range(n):
    if a[i]%4==0:
        b.append(1)
    elif a[i]%4!=0 and a[i]%2!=0:
        c.append(1)
b=sum(b)
c=sum(c)
if c<=b+1:
    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]%2==0:
        two+=1
if two==1:
    two=0

ans=four*2+two
if four>0:
    ans+=1

if ans>=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]%2==0:
        two+=1
if two==1:
    two=0
ans=four*3+two

if ans>=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]%2==0:
        two+=1
ans=four*3+two

if ans>=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]%2==0:
        two+=1
two-=two%2
ans=four*3+two

if ans>=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]%2==0:
        two+=1
two-=two%2
ans=four*3+two*2

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
odd = by2 = by4 = 0
for c in a:
    if c % 4 == 0:by4 += 1
    elif c % 2 == 0:by2 += 1
    else:odd += 1

if N == 2:
    if by4>=1:print('Yes')
    elif by2 == 2:print('Yes')
    else:print('No')
elif N == 3:
    if odd == 3:print('No')
    elif odd==2:
        if by4==1:print('Yes')
        else:print('No')
    elif odd==1:
        if by4>=1:print('Yes')
        else:print('No')
    else:print('Yes')
else:
    if by2 > 0:
        if by4-odd>=0:print('Yes')
        else:print('No')
    else:
        if by4-odd>=1:print('Yes')
        else:print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
def hoge():
    N=int(input())
    A=[2 if i%4==0 else 1 if i%2==0 else 0 for i in list(map(int,input().split()))]
    A=collections.Counter(A)
    value=A[2]*2+A[1]
    if A[2]%2==0:
            return(value>=N)
    else:
        if A[2]:
            return(value>=N-1)
        else:
            return(value>=N)
print("Yes" if hoge() else "No")

Submission status: Wrong Answer

Solution code:
import collections
def hoge():
    N=int(input())
    A=[2 if i%4==0 else 1 if i%2==0 else 0 for i in list(map(int,input().split()))]
    A=collections.Counter(A)
    value=A[2]*2+A[1]
    if A[2]:
        return(value>=N-1)
    else:
        return(value>=N)
print("Yes" if hoge() else "No")

Submission status: Wrong Answer

Solution code:
import collections
def hoge():
    N=int(input())
    A=[2 if i%4==0 else 1 if i%2==0 else 0 for i in list(map(int,input().split()))]
    A=collections.Counter(A)
    value=A[2]*2+A[1]
    if A[2]:
        return(value>=N-1)
print("Yes" if hoge() else "No")

Submission status: Wrong Answer

Solution code:
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    b1 = 0
    b2 = 0
    b4 = 0
    for a in A:
        if a == 2:
            b2 += 1
            continue
        if a // 2 > 1 and a % 2 == 0:
            b4 += 1
            continue
        b1 += 1
    if b2 > 0:
        if b4 >= b1:
            print('Yes')
            return
    else:
        if b4 + 1 >= b1:
            print('Yes')
            return
    print('No')


main()

Submission status: Wrong Answer

Solution code:
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    b1 = 0
    b2 = 0
    b4 = 0
    for a in A:
        if a == 2:
            b2 += 1
            continue
        if a % 4 == 0:
            b4 += 1
            continue
        b1 += 1
    if b2 > 0:
        if b4 >= b1:
            print('Yes')
            return
    else:
        if b4 + 1 >= b1:
            print('Yes')
            return
    print('No')


main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ac = A.count(2)
    if ac % 2 != 0:
        ac -= 1
    n = (N - ac) // 2
    for a in A:
        if a % 4 == 0:
            n -= 1
        if n == 0:
            print('Yes')
            return
    print('No')


main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    n = N // 2
    A = list(map(int, input().split()))
    n -= A.count(2) // 2
    for a in A:
        if a % 4 == 0:
            n -= 1
        if n == 0:
            print('Yes')
            return
    print('No')


main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    n = N // 2
    A = map(int, input().split())
    for a in A:
        if a == 2:
            n -= 0.5
        if a % 4 == 0:
            n -= 1
        if n == 0:
            print('Yes')
            return
    print('No')


main()

Submission status: Wrong Answer

Solution code:
n = int(input())
dat_a = map(int, input().split())
dat_a = list(dat_a)
d1 = d2 = d4 = 0
for i in range(n):
    if dat_a[i] % 4 == 0:
        d4 += 1
    elif dat_a[i] % 2 == 0:
        d2 += 1
    else:
        d1 += 1
d4 += d2 // 2
d2 = d2 % 2
import math
# print("4,2,1 = {0} {1} {2}".format(d4,d2,d1))
if d4 >= ( math.ceil((d1 + d2) / 2) ):
    print("Yes")
elif d1 == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
dat_a = map(int, input().split())
dat_a = list(dat_a)
d1 = d2 = d4 = 0
for i in range(n):
    if dat_a[i] % 4 == 0:
        d4 += 1
    elif dat_a[i] % 2 == 0:
        d2 += 1
    else:
        d1 += 1
d4 += d2 // 2
d2 = d2 % 2
import math
# print("4,2,1 = {0} {1} {2}".format(d4,d2,d1))
if d4 >= ( math.ceil((d1 + d2) / 2) ):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
Odd,Four=0,0
for a in A:
    if a%2==1:Odd+=1
    elif a%4==0:Four+=1
if Odd+Four==N and Odd-Four==1:print("Yes")
elif Odd<=Four:print("Yse")
else:print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []

tmp = input().split(" ")

four = 0
other = 0
two = 0
All = 0
for n in range(N):
    A = int(tmp[n])
    All += 1
    if A%4 == 0:
        four+=1
    elif A%2 == 0:
        two += 1    
    else:
        other+=1

if not two % 2 == 0:
    other +=1 

four += two//2

if four - other >= -1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []

tmp = input().split(" ")

four = 0
other = 0
two = 0
All = 0
for n in range(N):
    A = int(tmp[n])
    All += 1
    if A%4 == 0:
        four+=1
    else:
        other+=1

    if A%2 == 0:
        two += 1

four += two//2

if four - other >= -1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
d4=0
d2=0
for a in input().split():
    if int(a)%4==0:
        d4+=1
    elif int(a)%2==0:
        d2+=1

if 2*d4+d2>=N:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

cnt1 = 0
cnt2 = 0
cnt4 = 0

for i in range(n):
    if a[i]%2==1:
        cnt1 +=1
    elif a[i]%4==0:
        cnt2 +=1
        cnt4 +=1
    else:
        cnt2 +=1

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

Submission status: Wrong Answer

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

odd_count = 0
four_times_count = 0
two_times_count = 0
for i in a:
  if i % 4 == 0:
    four_times_count += 1 
  elif i % 2 != 0:
    odd_count += 1
  elif i % 2 == 0 and i % 4 != 0:
    two_times_count += 1

if odd_count == four_times_count or (two_times_count == 0 and odd_count - four_times_count == 1):
  print('Yes')
else: 
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(_)%4 for _ in input().split()]
e=a.count(2);f=a.count(0)
print('Yes' if (n-e-1)//2<f else 'No')

Submission status: Wrong Answer

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

def main():
    a = A
    passed_n = len(list(filter(lambda n: n % 4 == 0, a)))
    rest = list(filter(lambda n: n % 4 != 0, a))
    rest_n = len(rest)
    div2_n = len(list(filter(lambda n: n % 2 == 0, rest)))
    rest_n -= div2_n if div2_n >= 2 else 0
    if passed_n != 0:
        passed_n += 1
    ans = 'Yes' if passed_n >= rest_n else 'No'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    a = A
    passed_n = len(list(filter(lambda n: n % 4 == 0, a)))
    rest = list(filter(lambda n: n % 4 != 0, a))
    rest_n = len(rest)
    div2_n = len(list(filter(lambda n: n % 2 == 0, rest)))
    rest_n -= div2_n if div2_n >= 2 else 0
    ans = 'Yes' if max([1, passed_n]) + 1 >= rest_n else 'No'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    a = A
    passed_n = len(list(filter(lambda n: n % 4 == 0, a)))
    rest = list(filter(lambda n: n % 4 != 0, a))
    rest_n = len(rest)
    div2_n = len(list(filter(lambda n: n % 2 == 0, rest)))
    rest_n -= div2_n if div2_n >= 2 else 0
    ans = 'Yes' if passed_n + 1 >= rest_n else 'No'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    a = A
    if a.count(2) >= 2:
        a = list(filter(lambda n: n != 2, a))
    total = len(a)
    passed = len(list(filter(lambda n: n % 4 == 0, a)))
    ans = 'Yes' if passed >= total // 2 else 'No'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    a = A
    if a.count(2) > 2:
        a = list(filter(lambda n: n != 2, a))
    total = len(a)
    passed = len(list(filter(lambda n: n % 4 == 0, a)))
    ans = 'Yes' if passed >= total // 2 else 'No'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
c2=0
c4=0
for a in map(int,input().split()):
	if a%4==0:c4+=1
	elif a%2==0:c2+=1
if c2>1:n-=c2
print('Yes' if c4>=n//2 else 'No')

Submission status: Wrong Answer

Solution code:
n=int(input())
c2=0
c4=0
for a in map(int,input().split()):
	if a%4==0:c4+=1
	elif a%2==0:c2+=1
n-=c2
print('Yes' if c4>=n//2 else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())

l = list(map(int,input().split()))

multi_four = []
multi_two  = []

for i in l:
    if i % 4 == 0:
        multi_four.append(i)
    
    elif i % 2 == 0 and i % 4 != 0:
        multi_two.append(i)

if n - len(multi_two) == 0:
    print('Yes')

elif len(multi_two) == 0 and n - len(multi_four) <= 2:
    print('Yes')

elif n - (len(multi_two) + len(multi_four)) <= len(multi_four):
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())

l = list(map(int,input().split()))

multi_four = []
multi_two  = []

for i in l:
    if i % 4 == 0:
        multi_four.append(i)
    
    elif i % 2 == 0 and i % 4 != 0:
        multi_two.append(i)

if n - len(multi_two) == 1 and len(multi_four) == 0:
    print('No')
elif ((n-len(multi_two)) // 2) <= len(multi_four):
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())

l = list(map(int,input().split()))

multi_four = []
multi_two  = []

for i in l:
    if i % 4 == 0:
        multi_four.append(i)
    
    elif i % 2 == 0 and i % 4 != 0:
        multi_two.append(i)


if ((n-len(multi_two)) // 2) <= len(multi_four):
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
odd = 0
four = 0
for i in range(0, N):
	if A[i] % 4 == 0: four += 1
	if A[i] % 2 != 0: odd += 1
if 2*odd <= four: print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
num = [ int(v) for v in input().split() ]
a, b, c = 0, 0, 0
for i in num:
	if i % 2 != 0:
		a += 1
	elif i % 4 != 0:
		b += 1
	else:
		c += 1

if c >= a - 1:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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