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 = [int(i) for i in input().split()]

d = {
    "4":0,
    "2":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

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

Submission status: Wrong Answer

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

d = {
    "4":0,
    "2":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

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

Submission status: Wrong Answer

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

d = {
    "4":0,
    "2":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

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

Submission status: Wrong Answer

Solution code:
n, *a_l = map(int, open(0).read().split())
multi_4 = sum([1 for a in a_l if a%4 == 0])
multi_2 = sum([1 for a in a_l if a%2 == 0]) - multi_4
print( 'Yes' if ((multi_4 * 2 + 1 ) + multi_2 - 1) >= n else 'No')

Submission status: Wrong Answer

Solution code:
n, *a_l = map(int, open(0).read().split())
multi_4 = sum([1 for a in a_l if a%4 == 0])
multi_2 = sum([1 for a in a_l if a%2 == 0]) - multi_4
print( 'Yes' if ((multi_4 * 2 + 1 ) + multi_2) >= n else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
cnt1=0
cnt4=0
for i in a:
  if i%2==1:
    cnt1+=1
  elif i%4==0:
    cnt4+=1
if cnt4>=cnt1+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
one = 0
for i in a:
  if i%4 == 0:
    four += 1
  elif i%2 == 0 and i%4 != 0:
    two += 1
  elif i%2 != 0:
    one += 1

if four + 1 >= two//2 + two%2 + one or n == two:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

four = 0
two = 0
one = 0
for i in a:
  if i%4 == 0:
    four += 1
  elif i%2 == 0 and i%4 != 0:
    two += 1
  elif i%2 != 0:
    one += 1

if four + 1 >= two//2 + two%2 + one:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

num = len(a)
four = 0
two = 0
one = 0
for i in range(num):
  if a[i]%4 == 0:
    four += 1
  elif a[i]%2 == 0 and a[i]%4 != 0:
    two += 1
  elif a[i]%2 != 0:
    one += 1

if four + 1 >= two//2 + two%2 + one:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

num = len(a)
four = 0
two = 0
one = 0
for i in range(num):
  if a[i]%4 == 0:
    four += 1
  elif a[i]%2 == 0 and a[i]%4 != 0:
    two += 1
  elif a[i]%2 != 0:
    one += 1

if four + 1 >= two//2 + one:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

a = [i%100 if i >100 else i for i in a]

num = len(a)
four = 0
two = 0
one = 0
for i in range(num):
  if a[i]%4 == 0:
    four += 1
  elif a[i]%2 == 0 and a[i]%4 != 0:
    two += 1
  elif a[i]%2 != 0:
    one += 1

if four + 1 >= two//2 + one:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

a = [i%100 if i >100 else i for i in a]

num = len(a)
four = 0
two = 0
one = 0
for i in range(num):
  if a[i]%4 == 0:
    four += 1
  elif a[i]%2 == 0:
    two += 1
  else:
    one += 1

if four + 1 >= two//2 + one:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

pair = n*(n - 1)/2
not_4 = 0
ans = 'Yes'
other_4 = [i for i in a if i%4 != 0]
num = len(other_4)

for i in range(num):
  for j in range(num):
    
    if i != j and a[i]*a[j]%4 != 0:
      not_4 += 1
      
      if not_4 >= pair:
        ans = 'No'
        break
    
print(ans)

Submission status: Wrong Answer

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

pair = n*(n - 1)/2
not_4 = 0
ans = 'Yes'
num = len(a)
for i in range(num):
  if a[i]%4 == 0:
    continue
  else:
    for j in range(num):
    
      if i != j and a[i]*a[j]%4 != 0:
        not_4 += 1
      
        if not_4 >= pair:
          ans = 'No'
          break

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

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

if cnt1 <= cnt4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

cnt1 = 0
cnt4 = 0
for a in A:
    if a%4 == 0:
        cnt4 += 1
    else:
        cnt1 += 1

if cnt1 <= cnt4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
seq = [int(x) for x in input().split()]
div4 = sum((1 for i in seq if i % 4 == 0))
div2 = sum((1 for i in seq if i % 2 == 0 and i % 4 != 0))
odd = n - div4 - div2
ans = "Yes"
if n == 2:
    if div4 == 0:
        if div2 != 2:
            ans = "No"
elif n == 3:
    if div4 == 0:
        if div2 != 3:
            ans = "No"
elif div4 < odd:
    ans = "No"
elif (div4 - odd) + div2 < 1:
    ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
from random import shuffle

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

b = []
c = []

f = a.count(2)

a = [i for i in a if i != 2]

for i in range(len(a)):
    if a[i] % 4:
        b.append(a[i])
    else:
        c.append(a[i])

d = []

while b and c:
    d.append(b.pop())
    d.append(c.pop())

e = d.copy()

d.extend(b)
d.extend([2] * f)
d.extend(c)

for i in range(1, n):
    if (d[i] * d[i-1]) % 4:
        break
else:
    print('Yes')
    exit()

e.extend(b)
e.extend(c)
e.extend([2] * f)

for i in range(n - 1):
    if (e[i] * e[i+1]) % 4:
        break
else:
    print('Yes')
    exit()

e.sort()

for i in range(n - 1):
    if (e[i] * e[i+1]) % 4:
        break
else:
    print('Yes')
    exit()

for _ in range(10):
    shuffle(e)

    for i in range(n - 1):
        if (e[i] * e[i+1]) % 4:
            break
    else:
        print('Yes')
        break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from random import shuffle

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

b = []
c = []

f = a.count(2)

a = [i for i in a if i != 2]

for i in range(len(a)):
    if a[i] % 4:
        b.append(a[i])
    else:
        c.append(a[i])

d = []

while b and c:
    d.append(b.pop())
    d.append(c.pop())

e = d.copy()

d.extend(b)
d.extend([2] * f)
d.extend(c)

for i in range(1, n):
    if (d[i] * d[i-1]) % 4:
        break
else:
    print('Yes')
    exit()

e.extend(b)
e.extend(c)
e.extend([2] * f)

for i in range(n - 1):
    if (e[i] * e[i+1]) % 4:
        break
else:
    print('Yes')
    exit()

e.sort()

for i in range(n - 1):
    if (e[i] * e[i+1]) % 4:
        break
else:
    print('Yes')
    exit()

for _ in range(10):
    shuffle(e)

    for i in range(n - 1):
        if (e[i] * e[i+1]) % 4:
            break
    else:
        print('Yes')
        break

print('No')

Submission status: Wrong Answer

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

b = []
c = []

f = a.count(2)

a = [i for i in a if i != 2]

for i in range(len(a)):
    if a[i] % 4:
        b.append(a[i])
    else:
        c.append(a[i])

d = []

while b and c:
    d.append(b.pop())
    d.append(c.pop())

e = d.copy()

d.extend(b)
d.extend([2] * f)
d.extend(c)

for i in range(1, n):
    if (d[i] * d[i-1]) % 4:
        break
else:
    print('Yes')
    exit()

e.extend(b)
e.extend(c)
e.extend([2] * f)

for i in range(1, n):
    if (e[i] * e[i-1]) % 4:
        print('No')
        break
else:
    print('Yes')
    exit()

Submission status: Wrong Answer

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

b = []
c = []

f = a.count(2)

a = [i for i in a if i != 2]

for i in range(len(a)):
    if a[i] % 4:
        b.append(a[i])
    else:
        c.append(a[i])

d = []

while b and c:
    d.append(b.pop())
    d.append(c.pop())

d.extend(b)
d.extend(c)

d.extend([2] * f)

for i in range(1, n):
    if (d[i] * d[i-1]) % 4:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

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

cnt_4 = 0
cnt_2 = 0

for n in numbers:
    if n % 4 == 0:
        cnt_4 += 1
    elif n == 2:
        cnt_2 += 1
    
cnt = cnt_4 + (cnt_2 // 2)

if cnt >= N // 2:
    print('Yes')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
def main():
  n=int(input())
  a=tuple(map(int,input().split()))
  cnt2,cnt4=0,0
  for i in a:
    cnt2+=1 if i%2==0 and i%4>0 else 0
    cnt4+=1 if i%4==0 else 0
  print('Yes' if (n-cnt2)/2<=cnt4 else 'No')
if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
A = 0
B = 0
C = 0

for a in li:
  if a % 4 == 0:
    A += 1
  elif a % 2 == 0:
    B += 1
  else:
    C += 1
if A == 1:
  print('Yes')
elif B == 2:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

for j in li:
  a *= j
  
if a % 2 == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
fuga = input()
hoge = list(map(int,input().split()))
count_even = 0
count_divisibleBy4 = 0
for i in hoge:
	if i % 2 == 0:
		count_even += 1
		if i % 4 == 0:
			count_divisibleBy4 += 1
      
if count_even == len(hoge) or count_divisibleBy4 >= len(hoge) // 2:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

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

n2 = 0
n4 = 0

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

if n2:
  n2 += 2
else:
  n2 = 1
if n2 + n4 * 2 >= n:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

n2 = 0
n4 = 0

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

if n4:
  n2 += 1

if n2 + n4 * 2 >= n:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

n2 = 0
n4 = 0

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

if n4:
  n4 += 1

if n2 + n4 * 2 >= n:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

n2 = 0
n4 = 0

for ai in a:
  if ai % 4 == 2:
    n2 += 1
  if ai % 4 == 0:
    n4 += 1
    
if n2 + n4 * 2 + 1 >= n:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

n2 = 0
n4 = 0

for ai in a:
  if ai % 4 == 2:
    n2 += 1
  if ai % 4 == 0:
    n4 += 1
    
if n2 + n4 * 2 >= n:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
numbers=[int(b) for b in a]
kazu=0
suuji=0
for z in numbers:
    if z%2==0:
        kazu+=1
for y in numbers:
    if y%4==0:
        suuji+=1
if kazu==N:
    print('Yes')
elif suuji>=N//2:
    print('Yes')
elif kazu>=N-suuji*2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
numbers=[int(b) for b in a]
kazu=0
suuji=0
for z in numbers:
    if z%2==0:
        kazu+=1
for y in numbers:
    if y%4==0:
        suuji+=1
if kazu==N:
    print('Yes')
elif suuji>=N//2:
    print('Yes')
elif kazu>=N-suuji*2-1 and not kazu==1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
numbers=[int(b) for b in a]
kazu=0
suuji=0
for z in numbers:
    if z%2==0:
        kazu+=1
for y in numbers:
    if y%4==0:
        suuji+=1
if kazu==N:
    print('Yes')
elif suuji>=N//2:
    print('Yes')
elif kazu>=N-suuji*2-1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
numbers=[int(b) for b in a]
kazu=0
suuji=0
for z in numbers:
    if z%2==0:
        kazu+=1
for y in numbers:
    if y%4==0:
        suuji+=1
if kazu==N:
    print('Yes')
elif suuji==N//2:
    print('Yes')
elif kazu>=N-suuji*2-1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
numbers=[int(b) for b in a]
kazu=0
suuji=0
for z in numbers:
    if z%2==0:
        kazu+=1
for y in numbers:
    if y%4==0:
        suuji+=1
if kazu==N:
    print('Yes')
elif suuji==N//2:
    print('Yes')
elif kazu>=N-kazu*2-1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
numbers=[int(b) for b in a]
kazu=0
suuji=0
for z in numbers:
    if z%2==0:
        kazu+=1
for y in numbers:
    if y%4==0:
        suuji+=1
if kazu==N:
    print('Yes')
elif suuji==N//2:
    print('Yes')
elif kazu>=N-kazu*3+1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    tw=0
    fo=0
    for i in range(N):
        if a[i]%4==0:
            fo+=1
        elif a[i]%2==0:
            tw+=1
            
    N2=N-tw+1
    if N2//2<=fo:
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    tw=0
    fo=0
    for i in range(N):
        if a[i]%4==0:
            fo+=1
        elif a[i]%2==0:
            tw+=1
            
    N2=N-tw
    if N2//2<=fo:
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

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

one_list = []
two_list = []
four_list = []

for i in range(N):
    if a[i]%2 == 0:
        if a[i]%4 == 0:
            four_list.append(a[i])
        else:
            two_list.append(a[i])
    else:
        one_list.append(a[i])
        
if len(four_list) >= len(one_list):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
e=0
d=0
for i in range(N):
    if a[i]%4==0:
        c=c+1
    if a[i]%2==1:
        e=e+1
    else:
        d=d+1
if c>0:
    if (((3*c+(d-c)-1)>=N)and(d-c>1))or(3*c==N):
        print("Yes")
    else:
        print("No")
else:   #c=0
    if (d==N):
        print("Yes")
    else:
        print("No")
"""
if (e<=2*c-1)or(d==N):
    print("Yes")
elif ((N/3)==c)and((2*N/3)==e): #e>=2*c
    print("Yes")
else:
    print("No")
"""

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
e=0
d=0
for i in range(N):
    if a[i]%4==0:
        c=c+1
    if a[i]%2==1:
        e=e+1
    else:
        d=d+1
if c>0:
    if ((3*c+(d-c)-1)>=N)or(3*c==N):
        print("Yes")
    else:
        print("No")
else:   #c=0
    if (d==N):
        print("Yes")
    else:
        print("No")
"""
if (e<=2*c-1)or(d==N):
    print("Yes")
elif ((N/3)==c)and((2*N/3)==e): #e>=2*c
    print("Yes")
else:
    print("No")
"""

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
e=0
d=0
for i in range(N):
    if a[i]%4==0:
        c=c+1
    if a[i]%2==1:
        e=e+1
    else:
        d=d+1

if (e<=2*c-1)or(d==N):
    print("Yes")
elif ((N/3)==c)and((2*N/3)==e): #e>=2*c
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
e=0
for i in range(N):
    if a[i]%4==0:
        c=c+1
    if a[i]%2==1:
        e=e+1

if e<=2*c-1:
    print("Yes")
elif ((N/3)==c)and((2*N/3)==e): #e>=2*c
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
e=0
for i in range(N):
    if a[i]%4==0:
        c=c+1
    if a[i]%2==1:
        e=e+1

if e<=2*(c-1):
    print("Yes")
elif ((N/3)==c):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
d=0
e=0
for i in range(N):
    if a[i]%4==0:
        c=c+1
    if a[i]%2==0:
        d=d+1
    else:
        e=e+1
#print(c,d)

if ((e<2*c)and(3*c+d-1>=N))or((N/3)==c):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
d=0
e=0
for i in range(N):
    if a[i]%4==0:
        c=c+1
    if a[i]%2==0:
        d=d+1
    else:
        e=e+1
print(c,d)

if ((e<2*c)and(3*c+d-1>=N))or((N/3)==c):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

num_odd = 0
num_even = 0
num_four = 0

for i in l:
    if i % 2 == 1:
        num_odd += 1
    elif i % 4 == 0:
        num_four += 1
    else:
        num_even += 1

if num_four + 1 > num_odd:
    ans = "Yes"
elif num_four + 1 == num_odd or num_even == 0:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Submission status: Wrong Answer

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

num_odd = 0
num_even = 0
num_four = 0

for i in l:
    if i % 4 == 0:
        num_four += 1
    elif i % 2 == 0:
        num_even += 1
    else:
        num_odd += 1

if num_four + 1 > num_odd:
    ans = "Yes"
elif num_four + 1 == num_odd or num_even == 0:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
for i in range(N):
    if a[i]%4==0:
        c=c+1
if c>=ceil(N/3):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split()))
 
num_odd = 0
num_even = 0
num_four = 0
 
for i in l:
    if i % 4 == 0:
        num_four += 1
    elif i % 2 == 0:
        num_even += 1
    else:
        num_odd += 1
 
if num_four < num_odd:
    ans = "No"
else:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split()))
 
num_odd = 0
num_even = 0
num_four = 0
 
for i in l:
    if i % 4 == 0:
        num_four += 1
    elif i % 2 == 0:
        num_even += 1
    else:
        num_odd += 1
if num_four <= num_odd + 1:
    ans = "No"
else:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

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

num_odd = 0
num_even = 0
num_four = 0

for i in l:
    if i % 4 == 0:
        num_four += 1
    elif i % 2 == 0:
        num_even += 1
    else:
        num_odd += 1

if num_four <= 2 * num_odd:
    ans = "No"
else:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

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

c_4 = 0
c_2 = 0
odd = 0
for i in range(n):
    if a[i]%4==0:
        c_4+=1
    elif a[i]%2==1:
        odd += 1
    else:
        c_2 += 1
if c_2==0:
    if odd <= c_4+1:
        print("Yes")
    else:
        print("No")
else:
    if odd < c_4:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

c_4 = 0
c_2 = 0
odd = 0
for i in range(n):
    if a[i]%4==0:
        c_4+=1
    elif a[i]%2==1:
        odd += 1
    else:
        c_2 += 1
if odd <= c_4:
    print("Yes")
elif odd+1 <= c_4 and c_2==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

c_4 = 0
c_2 = 0
odd = 0
for i in range(n):
    if a[i]%4==0:
        c_4+=1
    elif a[i]%2==1:
        odd += 1
    else:
        c_2 += 1
if odd <= c_4:
    print("Yes")
elif odd+1 == c_4 and c_2==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
a = list(map(lambda x: x if x % 4 == 0 else -1, A))
x4 = n - a.count(-1)
print("Yes") if (n / 3) <= x4 and x4 != 0 else print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
a = list(map(lambda x: x if x % 4 == 0 else -1, A))
print("Yes") if (n // 3) >= (n - a.count(-1)) + (n % 3) else print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt_0, cnt_2, cnt_4 = 0, 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    cnt_4 += 1
  elif A[i] % 2 == 0:
    cnt_2 += 1
  else:
    cnt_0 += 1

if cnt_2 == 0:
  if cnt_4 >= cnt_0 + 1:
    print("Yes")
  else:
    print("No")
else:
  if cnt_4 >= cnt_0:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

cnt4=0
cnt1=0
for i in range(N):
    if(a[i]%4==0):
        cnt4+=1
    elif(a[i]%2==1):
        cnt1+=1
if(cnt4>=cnt1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
# 2で割り切れる回数
# b1=0, b2=1, b4=2以上
b1, b2, b4 = 0, 0, 0
for i in range(n):
    c = a[i] // 2
    if c == 0:
        b1 += 1
    elif c == 1:
        b2 += 1
    elif c >= 2:
        b4 += 1
if b2 == 0 and b1 <= b4 + 1 or b2 >= 1 and b1 <= b4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
# 2で割り切れる回数
# b1=0, b2=1, b4=2以上
b1, b2, b4 = 0, 0, 0
for i in range(n):
    c = a[i] // 2
    if c == 0:
        b1 += 1
    elif c == 1:
        b2 += 1
    elif c >= 2:
        b4 += 1
if b1 <= b4 + 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = list(map(int,input().split()))
cnt = 0
two = 0
for i in lis:
    if i % 4 == 0:
        cnt += 1
    elif i == 2:
        two += 1

if n//2 <= cnt:
    print("Yes")
elif two >= 2 and (n-(two-1))//2 <= cnt:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count4=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
count1=0
for i in range(n):
    if a[i]%4==0:
        count4+=1
    elif a[i]%2==0:
        count2+=1
    else:
        count1+=1
if count2==0:
    if count1<=count4+1:
        print("Yes")
    else:
        print("No")
else:
    if count1<count4:
        print("Yes")
    else:
        print("No")

    

    
"""
#print(count2)
if 1<=count2:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

    """
"""    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト

"""

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
"""
if count2<=1:
    if n//2<=count4:
        print("Yes")
    else:
        print("No")
else:
    
"""
#print(count2)
if 1<=count2:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

    """
    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト
"""

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
"""
if count2<=1:
    if n//2<=count4:
        print("Yes")
    else:
        print("No")
else:
    
"""
#print(count2)
if 2<=count2:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

    """
    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト
"""

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
"""
if count2<=1:
    if n//2<=count4:
        print("Yes")
    else:
        print("No")
else:
    
"""
#print(count2)
if count2<=1:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

else:
    print("No")

    """
    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト
"""

Submission status: Wrong Answer

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

else:
    print("No")

    """
    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト
"""

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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