Problem:


Score : 400 points

Problem Statement

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

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

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

Determine whether Snuke can achieve his objective.

Constraints

2 ≤ N ≤ 10^5

a_i is an integer.

1 ≤ a_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

Sample Input 1

3
1 10 100

Sample Output 1

Yes

One solution is (1, 100, 10).

Sample Input 2

4
1 2 3 4

Sample Output 2

No

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

Sample Input 3

3
1 4 1

Sample Output 3

Yes

The condition is already satisfied initially.

Sample Input 4

2
1 1

Sample Output 4

No

Sample Input 5

6
2 7 1 8 2 8

Sample Output 5

Yes



Sample input:
3
1 10 100


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import math
import itertools
n = int(input())
a = list(map(int, input().split()))
k = 0
ans = ''
for i in range(n):
  if a[i] % 2 == 0:
    k += 1
if k >= math.floor(n / 2):
  l = [i for i in range(n)]
  for v in itertools.permutations(l, n):
    if ans == '':
      p = 0
      for i in range(n - 1):
        if a[v[i]] * a[v[i + 1]] % 4 == 0:
          next
        else:
          p = 1
          break
      if p == 0:
        ans = 'Yes'
  if ans == '':
    ans = 'N0'
else:
  ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    #２の倍数だが４の倍数でない
    if a[i]%2 == 0 and a[i]%4 != 0:
        count2 += 1
    #４の倍数
    elif a[i]%4 == 0:
        count4 += 3

#print(count2,count4)

#count2が1以下か判定
if count2 > 1:
    count4 += count2
else:
    count4 += 0

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    #２の倍数だが４の倍数でない
    if a[i]%2 == 0 and a[i]%4 != 0:
        count2 += 1
    #４の倍数
    elif a[i]%4 == 0:
        count4 += 3

#print(count2,count4)

#２の倍数が奇数か偶数か判定
if count2 != 1 and count2 != 0:
    count4 += count2
else:
    count4 += 0

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    #２の倍数だが４の倍数でない
    if a[i]%2 == 0 and a[i]%4 != 0:
        count2 += 1
    #４の倍数
    elif a[i]%4 == 0:
        count4 += 3

#print(count2,count4)

#２の倍数が奇数か偶数か判定
if count2 >= 2 and count2%2 == 0:
    count4 += count2//2
elif count2 >= 2 and count2%2 == 1:
    count4 += count2//2+1

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    #２の倍数だが４の倍数でない
    if a[i]%2 == 0 and a[i]%4 != 0:
        count2 += 1
    #４の倍数
    elif a[i]%4 == 0:
        count4 += 3

#print(count2,count4)

#２の倍数が奇数か偶数か判定
if count2 >= 2 and count2%2 == 0:
    count4 += count2
elif count2 >= 2 and count2%2 == 1:
    count4 += count2+1

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    if a[i]%2 == 0 and a[i]%4 != 0:
        count2 += 1
    elif a[i]%4 == 0:
        count4 += 3
if count2 >= 2 and count2%2 == 0:
    count4 += count2//2*2
elif count2 >= 2 and count2%2 == 1:
    count4 += (count2//2)*2+1
if count4 >= n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    if a[i]%2 == 0 and a[i]%4 != 0:
        count2 += 1
    elif a[i]%4 == 0:
        count4 += 3
if count2 >= 2:
    count4 += count2//2*3
if count4 >= n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

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

t_4 = 0
t_2 = 0
for i in a:
  if i%4==0:
    t_4+=1
  elif i%2==0:
    t_2+=1
other = len(a)-t_4-t_2
if other == t_4:
  print("Yes")
elif other == t_4 +1:
  if t_2 > 0:
    print("No")
    exit()
  else:
    print("Yes")
    exit()
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

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

t_4 = 0
t_2 = 0
for i in a:
  if i%4==0:
    t_4+=1
  elif i%2==0:
    t_2+=1
other = len(a)-t_4-t_2
if other > t_4+1:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

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

t_4 = 0
t_2 = 0
for i in a:
  if i%4==0:
    t_4+=1
  elif i%2==0:
    t_2+=1
other = len(a)-t_4-t_2
if other >= t_4+1:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

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

ok = four == no or (four+two) == N
ok = ok and ((four+no) == N and abs(four-no) <= 1)
if ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

ok = four == no or (four+two) == N
ok = (four+no) == N and abs(four-no) <= 1
if ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

ok = (two >= max(0, (N-4)) and four >= 2) or four >= N//2
ok = ok and ((four-no) >= 2 or ((four+no) == N and (no-four) <= 1))
if ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

ok = (two >= max(0, (N-4)) and four >= 2) or four >= N//2
ok = ok and (four >= no or ((four+no) == N and (no-four) <= 1))
if ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

ok = (two >= max(0, (N-4)) and four >= 2) or four >= N//2
ok = ok and (four >= no or ((four+no) == N))
if ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if four >= no or ((four+no) == N):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if (two >= max(0, (N-4)) and four >= 2) or four >= N//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if two == N or four >= (N-2) or (two >= (N-4) and four >= 2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if two == N or four >= (N-2) or (two >= (N-2) and four >= 2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
fours = []
twos = []
others = []

for a in a_list:
    if a % 4 == 0:
        fours.append(a)
    elif a % 2 == 0:
        twos.append(a)
    else:
        others.append(a)
if len(fours) - len(others) == -1 and len(twos) > 0:
    print('No')
    exit()

if len(fours) - len(others) < 0 :
    print('No')
    exit()

if len(fours) == 0 and len(twos) < 2:
    print('No')
    exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
def div2(t):
    count = 0
    while t % 2 == 0:
        count += 1
        t //= 2
    return count
b = np.array([div2(i) for i in a])
odd = len(b[b == 0])
four = len(b[b >= 2])
if odd == 0:
    print('Yes')
elif odd == n:
    print('No')
elif odd <= four or (odd + 1 == four and (odd + four) == n):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
def div2(t):
    count = 0
    while t % 2 == 0:
        count += 1
        t //= 2
    return count
b = np.array([div2(i) for i in a])
odd = len(b[b == 0])
four = len(b[b >= 2])
if odd == 0:
    print('Yes')
elif odd <= four or (four > 0 and (odd + four) == n):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = A[i] % 4
if A.count(0) * 2 >= (A.count(1)+A.count(3)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = A[i] % 4
if A.count(2) % 2 == 0:
    if A.count(0) * 2 >= (A.count(1)+A.count(3)):
        print("Yes")
    else:
        print("No")
else:
    if A.count(0) * 2 >= (A.count(1)+A.count(3)) + 1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = A[i] % 4
if A.count(2) % 2 == 0:
    if A.count(4) >= (A.count(1)+A.count(3)):
        print("Yes")
    else:
        print("No")
else:
    if A.count(4) >= (A.count(1)+A.count(3)) + 1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = len([a for a in A if a % 4 == 0])
print(count, n // 2)
print("Yes" if count >= n // 2 else "No")

Submission status: Wrong Answer

Solution code:
N,*a = map(int, open(0).read().split())
b = [x for x in a if x % 4 == 0]
c = [x for x in a if x % 2 == 0 and x % 4 > 0]
d = [x for x in a if x % 2 == 1]
if len(b) >= len(a) // 2:
    print('Yes')
elif len(d) == len(b) + 1 and len(c) >= 2:
    print('Yes')
elif len(d) < len(b) + 1:
    print('Yes')
elif len(c) == len(a):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,*a = map(int, open(0).read().split())
b = [x for x in a if x % 4 == 0]
c = [x for x in a if x % 2 == 0 and x % 4 > 0]
d = [x for x in a if x % 2 == 1]
if len(b) >= len(a) // 2:
    print('Yes')
elif len(d) == len(b) + 1 and len(c) >= 2:
    print('Yes')
elif len(d) < len(b) + 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

N = getN()
A = getList()

cnt4 = 0
cnt2 = 0
for i in A:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1

if cnt4 * 3 >= N:
    print('Yes')
else:
    if cnt4 == 0:
        left = N
    else:
        left = N - (cnt4 * 3) + 1
    if cnt2 >= left:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

N = getN()
A = getList()

cnt4 = 0
cnt2 = 0
for i in A:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1

if cnt4 * 3 >= N:
    print('Yes')
else:
    left = N - cnt4 * 3
    if cnt2 >= left + 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

N = getN()
A = getList()

cnt4 = 0
cnt2 = 0
for i in A:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1

if cnt4 * 3 >= N:
    print('Yes')
else:
    left = N - cnt4 * 3
    if left == 1:
        if cnt2 >= 2:
            print('Yes')
        else:
            print('No')
    else:
        if cnt2 >= left:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

print('Yes' if cnt_4*2+cnt_2>=n else 'No')

Submission status: Wrong Answer

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

n2 = 0
n4 = 0
nod = 0

for i in n:
    if i % 4 == 0:
        n4 += 1
    elif i % 2 == 0:
        n2 +=1
    else:
        nod += 1

if n2 == 0:
    print('Yes')
else:
    if nod <= n4:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

foud = 0
twod = 0

for i in range(n):
    if al[i] % 4 ==0:
        foud += 1
    elif al[i] % 2 ==0:
        twod += 1
        
if (foud*2+1)+(twod//2) >=n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

nfl = len(list(filter(lambda x: x%4==0, n)))

if (N / 3) <= nfl:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import math

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

mul2 = 0
mul4 = 0
for i in s:
    if i%4 == 0:
        mul4 += 1
    elif i%2 == 0:
        mul2 += 1

if mul4 >= math.floor(n/2):
    print("Yes")
elif n-mul2-mul4-1 <= mul4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

mul2 = 0
mul4 = 0
for i in s:
    if i%4 == 0:
        mul4 += 1
    elif i%2 == 0:
        mul2 += 1

if mul4 >= n/2:
    print("Yes")
elif mul2 >= n/2:
    print("Yes")
elif n-mul2-mul4-1 <= mul4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    c_4, c_2, c_0 = 0, 0, 0
    for a in A:
        if a % 4 == 0:
            c_4 += 1
        elif a % 2 == 0:
            c_2 += 1
        else:
            c_0 += 1
    print('Yes' if c_4 >= c_0 else 'No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

odd = sum([1 for i in a if i % 2 != 0])
multiple4 = sum([1 for i in a if i % 4 == 0])

if odd == 0:
    print('Yes')
elif odd % 2 == 0 and odd <= multiple4:
    print('Yes')
elif odd + multiple4 == n and odd % 2 == 0 and odd - 1 <= multiple4:
    print('Yes')
elif odd % 2 != 0 and odd - 1 <= multiple4:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

odd = sum([1 for i in a if i % 2 != 0])
multiple4 = sum([1 for i in a if i % 4 == 0])

if odd == 0:
    print('Yes')
elif odd - 1 <= multiple4:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

odd = sum([1 for i in a if i % 2 == 0])
multiple4 = sum([1 for i in a if i % 4 == 0])

if odd <= multiple4:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
odd = 0
even4 = 0
for num in a:
  if num&2 == 1:
    odd += 1
  elif num%4 == 0:
    even4 += 1
if even4 >= odd:
  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 a:
    if i%4==0:
        count += 1
    elif i%2==0:
        count2 += 1
if count2 != 0:
    if (N-count2)%2 != 0:
        value = (N-count2)//2
    else:
        print('b')
        value = (N-count2)//2-1
else:
    if count >= N//2:
        value = N//2-1
    else:
        value = N//2

    value = N//2-1

if count > value:
    print('Yes')
else:
    print('No')

1414
414

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
count = 0
count2 = 0
for i in a:
    if i%4==0:
        count += 1
    elif i%2==0:
        count2 += 1

if count2 <= 1:
    count2 = 0

if count >= N//2-count2:
    print('Yes')
else:
    print('No')

2228187

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 12:11:12 2020

@author: shinba
"""

n = int(input())

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

two = 0
four = 0

b = []

for i in a:
    if i % 2 == 0:
        b.append(i//2)

for i in b:
    if i % 2 == 0:
        four += 1
    else:
        two += 1

if n - two <= 3*four:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    n, *a = map(int, open(0).read().split())

    o = sum([i % 2 == 1 for i in a])
    p = sum([i % 4 == 0 for i in a])
    q = sum([i % 2 == 0 for i in a]) - p

    if p + 1 >= o and not q:
        print("Yes")
    elif p >= 0 and q:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, *a = map(int, open(0).read().split())

    o = sum([i % 2 == 1 for i in a])
    p = sum([i % 4 == 0 for i in a])

    if p >= o :
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, *a = map(int, open(0).read().split())

    o = sum([i % 2 == 1 for i in a])
    p = sum([i % 4 == 0 for i in a])

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int,input().split()))
cntn = 0
cnt2 = 0
cnt4 = 0
for i in a_list:
    if i%4 == 0:
        cnt4 += 1
    elif i%2 == 0:
        cnt2 += 1
    else:
        cntn += 1
        
cnt4seat = cnt4*2
flag = True
cnt4seat -= cntn
if cnt2 == 1:
    cnt4seat -= 1
    
if cnt4seat >= 0:
    print('Yes')
    
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a_list = list(map(int,input().split()))
cntn = 0
cnt2 = 0
cnt4 = 0
for i in a_list:
    if i%4 == 0:
        cnt4 += 1
    elif i%2 == 0:
        cnt2 += 1
    else:
        cntn += 1
        
cnt4seat = cnt4*2
flag = True
cnt4seat -= cntn
if cnt2 == 1:
    cnt4seat -= 1
    
if cnt4seat >= 0:
    print('Yes')
    
else:
    print('No')

Submission status: Wrong Answer

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

x4 = 0
x2 = 0
x0 = 0
for a in A:
    if a % 4 == 0:
        x4 += 1
    elif a == 2:
        x2 += 1
    else:
        x0 += 1

if x2==0:
    if x4 >= x0 - 1:
        ans = 'Yes'
    else:
        ans = 'No'
else:
    if x4 >= x0:
        ans = 'Yes'
    else:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

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

cnt = 0
flg_2 = 0
for a in A:
    if a % 4 == 0:
        cnt += 1
    elif a == 2:
        flg_2 += 1
if flg_2 >= 2:
    N -= flg_2 - 1
# if cnt >= N//2:
if cnt >= ((N-1)/2):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

cnt = 0
flg_2 = 0
for a in A:
    if a % 4 == 0:
        cnt += 1
    elif a == 2:
        flg_2 += 1
if flg_2 >= 2:
    N -= flg_2 - 1
# if cnt >= N//2:
if cnt >= (N-1/2):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

cnt = 0
flg_2 = 0
for a in A:
    if a % 4 == 0:
        cnt += 1
    elif a == 2:
        flg_2 += 1
if flg_2 >= 2:
    N -= flg_2 - 1
if cnt >= N//2:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

cnt = 0
flg_2 = 0
for a in A:
    if a % 4 == 0:
        cnt += 1
    elif a == 2:
        flg_2 += 1
        if flg_2==2:
            N -= 1
            flg_2 = 0
if cnt >= N//2:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

cnt = 0
flg_2 = 0
for a in A:
    if a % 4 == 0:
        cnt += 1
    elif a == 2:
        flg_2 += 1
        if flg_2 % 2 == 0:
            N -= 1
if cnt >= N//2:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

m=[0]*3
for i in list:
    if i%4==0:
        m[0]+=1
    elif i%2==0:
        m[1]+=1
    else:
        m[2]+=1

if(m[0]+int(m[1]/2)+1>=m[2]+m[1]%2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
 
four = 0
two = 0
odd = 0
for i in A:
    if i%4 == 0:
        four += 1
    elif i%2 == 0:
        two += 1
    else:
        odd += 1
 
if two == 1:
    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()))

four = 0
two = 0
odd = 0
for i in A:
    if i%4 == 0:
        four += 1
    elif i%2 == 0:
        two += 1
    else:
        odd += 1
 
if two == 1:
    odd += 1

if odd <= 2*four:
    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 A:
    if i%4 == 0:
        four += 1
    elif i%2 == 0:
        two += 1
 
odd = N - two - four

if two == 1:
    odd += 1
    two = 0

if odd <= 2*four:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

two = 0
four = 0

four = 0
two = 0
for i in A:
    if i%4 == 0:
        four += 1
    elif i%2 == 0:
        two += 1

odd = N - four - two

odd -= 2*four

if two == 1:
    odd += 1

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

Submission status: Wrong Answer

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

two = 0
four = 0

four = 0
two = 0
for i in A:
    if i%4 == 0:
        four += 3
    elif i%2 == 0:
        two += 1

if two//2 + four >= N:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

two = 0
four = 0

for i in A:
    if i%4 == 0:
        four += 1
    elif i%2 == 0:
        two += 1

odd = N - two - four

if two == 1:
    odd += 1
    two = 0

if odd <= 2*four and (two == 0 or two >= 2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for i in a:
  if i%4==0:
    count4+=1
  elif i%2==0:
    count2+=1

if count2==1:
  count1=len(a)-count4
else:
  count1=len(a)-count4-count2+1
if count1-count4<=1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

for i in a:
  if i%4==0:
    count4+=1
  elif i%2==0:
    count2+=1

if count2==1:
  count1=len(a)-count4
else:
  count1=len(a)-count4-count2
if len(a)==1 and a[0]==2:
  print("No")
elif count1-count4<=1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

for i in a:
  if i%4==0:
    count4+=1
  elif i%2==0:
    count2+=1

if count2==1:
  count1=len(a)-count4
else:
  count1=len(a)-count4-count2
if count1-count4<=1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

for i in a:
  if i%4==0:
    count4+=1
  elif i%2==0:
    count2+=1

if count2==1:
  count1=len(a)-count4
else:
  count1=len(a)-count4-count2
if count4-count1<=1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

for i in a:
  if i%4==0:
    count4+=1
  elif i%2==0:
    count2+=1
if count2==1:
  count1=len(a)-count4
else:
  count1=len(a)-count4-count2
if abs(count4-count1)<=1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
n1 = 0
n2 = 0
n4 = 0
for i in range(n):
    if a[i]%4 == 0:
        n4+=1
    elif a[i]%2 == 0:
        n2 +=1
    else:
        n1+=1

if n2 == 1:
    n1+=1
if n4 > n1:
    print("Yes")
elif n4 == n1:
    print("Yes")
else:
    if n1 - n4 == 1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
    if a[i]%4 == 0:
        li4.append(a[i])
    elif a[i]%2 == 0:
        li2.append(a[i])
    else:
        li.append(a[i])
if len(li2) == 1:
    li.append(2)
if len(li4)+1>=len(li):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
    if a[i]%4 == 0:
        li4.append(a[i])
    elif a[i]%2 == 0:
        li2.append(a[i])
    else:
        li.append(a[i])
if len(li2) == 1:
    li.append(2)
if len(li4)>=len(li):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
    if a[i]%4 == 0:
        li4.append(a[i])
    elif a[i]%2 == 0:
        li2.append(a[i])
    else:
        li.append(a[i])
if len(li) - len(li4) == 1:
    if len(li2) == 1:
        print("No")
    else:
        print("Yes")
elif len(li) - len(li4) > 1:
    print("No")
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
    if a[i]%4 == 0:
        li4.append(a[i])
    elif a[i]%2 == 0:
        li2.append(a[i])
    else:
        li.append(a[i])
if len(li) - len(li4) == 1:
    if len(li2)>0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
    if a[i]%4 == 0:
        li4.append(a[i])
    elif a[i]%2 == 0:
        li2.append(a[i])
    else:
        li.append(a[i])
if len(li) < len(li4)+1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
    if a[i]%4 == 0:
        li4.append(a[i])
    elif a[i]%2 == 0:
        li2.append(a[i])
    else:
        li.append(a[i])
if len(li4)>len(li):
    print("Yes")
else:
    print("No")