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=map(int,input().split())

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

if T[1]==0:
    if T[0]<=T[2]:
        print("Yes")
    else:
        print("No")
else:
    if T[0]<=T[2]-1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

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

if T[1]==0:
    if T[0]<=2*T[2]:
        print("Yes")
    else:
        print("No")
else:
    if T[0]<=2*T[2]-1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    a = Intl()
    cnt = [0,0,0,0]#aにおける1,2の倍数(4を除く),4の倍数,othersの数
    for i in a:
        if i % 4 == 0:cnt[2] += 1
        elif i % 2 == 0:cnt[1] += 1
        elif i == 1:cnt[0] += 1
        else:cnt[3] += 1
    if cnt[2] >= cnt[0] + cnt[1] + cnt[3] - 1:print("Yes")
    elif cnt[2] >= cnt[0] + cnt[3] -1  and cnt[1] >= 2:print("Yes")
    else:print("No")

Submission status: Wrong Answer

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

four = 0
odd = 0

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

if odd == 0:
    print('Yes')
else:
    if four + odd == n:
        print('Yes' if four > n // 2 else 'No')
    else:
        print('Yes' if four >= (four + odd + 1) // 2 else 'No')

Submission status: Wrong Answer

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

four = 0
odd = 0

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

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

Submission status: Wrong Answer

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

m4 = sum([1 for i in range(n) if a[i]%4==0])
m2 = sum([1 for i in range(n) if a[i]%2==0])
m2 -= m4

if n==3 and m4==1:
    print('Yes')
else:
    n-=m2
    if m4*2>=n:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

m4 = sum([1 for i in range(n) if a[i]%4==0])
m2 = sum([1 for i in range(n) if a[i]%2==0])
m2 -= m4
n+=2
m2+=2

while m4>=1 and m2>=2:
    m4-=1
    m2-=2
    n-=5
    
    
if n<=0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

m4 = sum([1 for i in range(n) if a[i]%4==0])
m2 = sum([1 for i in range(n) if a[i]%2==0])
m2 -= m4

if m4*3+m2//2 >= n:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if N==3:
    if a==3 or (a>=1 and b==0):
        print('No')
    else:
        print('Yes')
else:
    if a<=b:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

if N==3:
    if a==3 or (a>=1 and b==0):
        print('No')
    else:
        print('Yes')
else:
    if a<b:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N=int(input())
A= list(map(int, input().split()))

four = 0
two = 0
one = 0

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

if one == 0:
    print("Yes")
    sys.exit()

if two%2 == 1:
    one += 1
    two -= 1

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N=int(input())
A= list(map(int, input().split()))

four = 0
two = 0
one = 0

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

if two%2 == 1:
    one += 1
    two -= 1

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=map(int,input().split())
c=0
d=0
e=0
f=0
for i in a:
  if i%4==0:
    c=c+1
  elif i%2==0:
    d=d+1
  e=N-d
if d==0:
  if (c+1)>=0:
    print('Yes')
  else:
    print('No')
    
else:
  if c>=0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=map(int,input().split())
c=0
d=0
e=0
f=0
for i in a:
  if i%4==0:
    c=c+1
  elif i%2==0:
    d=d+1
  e=N-d
if d==0:
  if (c+1)>=e:
    print('Yes')
  else:
    print('No')
    
else:
  if c>=0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c4 = 0
c2 = 0
for i in a:
    if i%4 == 0:
        c4 += 1
    elif i%2 == 0:
        c2 += 1
c0 = n - c4 - c2

ans = False
if c2 < 2:
    if c0 + c2 <= c4 + 1:
        ans = True
else:
    if c0 <= c4 + 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()))
c4 = 0
c2 = 0
for i in a:
    if i%4 == 0:
        c4 += 1
    elif i%2 == 0:
        c2 += 1
c0 = n - c4 - c2

ans = False
if c2 < 2:
    if c0 + c2 <= 2*c4:
        ans = True
else:
    if c0 <= c4*2:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c4 = 0
c2 = 0
for i in a:
    if i%4 == 0:
        c4 += 1
    elif i%2 == 0:
        c2 += 1
c0 = n - c4 - c2

ans = False
if c2 < 2:
    if c0 + c2 <= 2*c4:
        ans = True
else:
    if c0 <= c4*2 + (c2//2) - 1:
        ans = True
if 0 in a:
    ans = False
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c4 = 0
c2 = 0
for i in a:
    if i%4 == 0:
        c4 += 1
    elif i%2 == 0:
        c2 += 1
c0 = n - c4 - c2

ans = False
if c2 < 2:
    if c0 + c2 <= 2*c4:
        ans = True
else:
    if c0 <= c4*2 + (c2//2) - 1:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(lambda x:int(x)%4, input().split()))
ans_list = []
for i in [0,1,2,3]:
  a = A.count(i)
  ans_list.append(a)
  
ans = ans_list[0] - (ans_list[1] + ans_list[3])
if ans_list[2] == 0 and ans < -2:
  print("No")
elif ans_list[2] != 0 and ans < -1:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(lambda x:int(x)%4, input().split()))
ans_list = []
for i in [0,1,2,3]:
  a = A.count(i)
  ans_list.append(a)
  
ans = ans_list[0] - (ans_list[1] + ans_list[3])
if ans_list[2] != 0 and ans < 0:
  print("No")
elif ans_list[2] == 0 and ans < 1:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(lambda x:int(x)%4, input().split()))
ans_list = []
for i in [0,1,2,3]:
  a = A.count(i)
  ans_list.append(a)
  
ans = ans_list[0] - (ans_list[1] + ans_list[3])
if ans < 0:
  print("No")
  exit(0)
if ans_list[2]%2 == 0 and ans < 1:
  print("No")
  exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt_odd = 0
    cnt_4 = 0
    cnt_2 = 0

    for x in a:
        if x % 2 == 1:
            cnt_odd += 1
        elif x % 4 == 0:
            cnt_4 += 1
        elif x % 2 == 0:
            cnt_2 += 1

    if cnt_odd == 0:
        print('Yes')
    elif cnt_2 > 0:
        if cnt_4 >= cnt_odd + 1:
            print('Yes')
        else:
            print('No')
    else:
        if cnt_4 >= cnt_odd - 1:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt_odd = 0
    cnt_4 = 0

    for x in a:
        if x % 2 == 1:
            cnt_odd += 1
        elif x % 4 == 0:
            cnt_4 += 1

    if cnt_4 >= cnt_odd*2 - 2:
        print('Yes')

    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
eight = 0
one = 0
two = 0
 
 
for i in A:
    if i%4 == 0:
        eight = eight + 1
    if i == 1:
        one = one + 1
    if i % 2 == 0:
        two = two + 1
 
if len(A)//2 <= eight:
    print("Yes")
elif (len(A)//2) <= (eight + (two//2)):
    print("Yes")
 
elif (eight >= one) and (eight + one +(two//2)) > (len(A)//2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

eight = 0
one = 0
two = 0


for i in A:
    if i%4 == 0:
        eight = eight + 1
    if i == 1:
        one = one + 1
    if i%2 == 0:
        two = two + 1

if len(A)//2 <= eight:
    print("Yes")
elif (len(A)//2) <= (eight + (two//2)):
    print("Yes")

elif (eight >= one) and (eight + one +(two//2)) > (len(A)//2):
    print("Yes")
elif (two//2) == len(A):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

eight = 0
one = 0
two = 0


for i in A:
    print(i%4)
    if i%4 == 0:
        eight = eight + 1
    if i == 1:
        one = one + 1
    if i%2 == 0:
        two = two + 1

if len(A)//2 <= eight:
    print("Yes")
elif (len(A)//2) <= (eight + (two//2)):
    print("Yes")

elif (eight >= one) and (eight + one +(two//2)) > (len(A)//2):
    print("Yes")
elif (two//2) == len(A):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

eight = 0
one = 0
two = 0


for i in A:
    if i%4 == 0:
        eight = eight + 1
    if i == 1:
        one = one + 1
    if i == 2:
        two = two + 1

if len(A)//2 <= eight:
    print("Yes")
elif (len(A)//2) <= (eight + (two//2)):
    print("Yes")

elif (eight >= one) and (eight + one +(two//2)) > (len(A)//2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
d = {"2":0,"4":0,"other":0}
for i in readInts():
	if i%4==0:
		d["4"]+=1
	elif i%2==0:
		d["2"]+=1
	else:
		d["other"]+=1

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
d = {"2":0,"4":0,"other":0}
for i in readInts():
	if i%4==0:
		d["4"]+=1
	elif i%2==0:
		d["2"]+=1
	else:
		d["other"]+=1
if d["2"]>1:
	if d["4"]>=d["other"]:
		print("Yes")
	else:
		print("No")
elif d["2"]==1:
	if d["4"]>=d["other"]+d["2"]:
		print("Yes")
	else:
		print("No")
else:
	if d["4"]+1>=d["other"]:
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
d = {"2":0,"4":0,"other":0}
for i in readInts():
	if i%4==0:
		d["4"]+=1
	elif i%2==0:
		d["2"]+=1
	else:
		d["other"]+=1
if d["2"]>1:
	if d["4"]+1>=d["other"]:
		print("Yes")
	else:
		print("No")
else:
	if d["4"]+1>=d["other"]+d["2"]:
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
cnt4 = 0
cnt2 = 0
other = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
        continue
    if a % 2 == 0:
        cnt2 += 1
    else:
        other += 1
if cnt4+1 >= cnt2+other or (cnt2 % 2 == 0 and cnt4+1 >= other) or (cnt4 == n):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
cnt4 = 0
cnt2 = 0
other = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
        continue
    if a % 2 == 0:
        cnt2 += 1
    else:
        other += 1
if cnt4+1 >= cnt2+other or (cnt2 % 2 == 0 and cnt4+1 >= other):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
cnt1,cnt2,cnt4=0,0,0
for i in A:
  if i%2!=0:
    cnt1+=1
  elif i%2==0 and i%4!=0:
    cnt2+=1
  else:
    cnt4+=1
Check1=cnt4*2-cnt1
if cnt2%2==0:
  if Check1>=0:
    print('Yes')
    exit()
else:
  if Check1>=1:
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

if N <= 3:
  for i in range(N):
    if a[i]%2 == 0:
      cnt = cnt + 1
  if cnt >= 2:
    print("Yes")
  else:
    print("No")
  sys.exit()

for i in range(N):
  if a[i]%2 == 0:
    cnt = cnt + 1
    
if N%2 == 1 and (N-1)/2 < cnt:
  print("Yes")
elif N%2 == 0 and N/2 < cnt:
  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 v in a:
    if v % 4 == 0:
        cnt_4 += 1
    elif v == 2:
        cnt_2 += 1
if cnt_2 == 0:
    if N//2 <= cnt_4:
        print('Yes')
    else:
        print('No')
else:
    if (N-(cnt_2-1))//2 <= cnt_4:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

count4=sum(a%4==0 for a in A)
c_odd=sum(a%2==1 for a in A)

print('YNeos'[c_odd>count4+1::2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

border_4 = n//2
border_2 = n

cnt_4=0
cnt_2=0

for i in range(n):
    if a[i]%4==0:
        cnt_4+=1
    elif a[i]%4!=0 and a[i]%2==0:
        cnt_2+=1
    else:
        continue


if cnt_4>=border_4:
    print('YES')
elif n-cnt_4*2<=cnt_2:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

border_4 = n//2
border_2 = n

cnt_4=0
cnt_2=0

for i in range(n):
    if a[i]%4==0:
        cnt_4+=1
        cnt_2+=1
    elif a[i]%2==0:
        cnt_2+=1
    else:
        continue


if cnt_4>=border_4:
    print('YES')
elif n-cnt_4*2<=(cnt_2-cnt_4):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    n0 = 0
    n4 = 0
    for i in a:
        if i%2 == 1:
            n0 += 1
        if i%4 == 0:
            n4 += 1
    if n0 > n4+1:
        print("No")
    else:
        print("Yes")

    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

b1 = b2 = b4 = 0

for c in a:
    if c % 4 == 0:
        b4 += 1
    elif c % 2 == 0:
        b2 = 1
    else:
        b1 += 1

if b1<=b4+b2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

four = 0
odd = 0
two = 0
for a in As:
    if a % 2 == 1:
        odd += 1
    if a % 4 == 0:
        four += 1
    else:
        two += 1


if four < two%2 + odd - 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
cnt1=0#奇数
cnt2=0#2で一回割れる。隣り合うと4の倍数
cnt4=0#4で一回割れる。隣がなんでも4の倍数
for i in range(n):
  if a[i]%2==1:
    cnt1+=1
  elif format(a[i], 'b')[::-1].find('1')==1:
    cnt2+=1
  else:
    cnt4+=1

print('Yes') if cnt4>=(n-cnt2-cnt2%2)//2 else print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
cnt1=0#奇数
cnt2=0#2で一回割れる。隣り合うと4の倍数
cnt4=0#4で一回割れる。隣がなんでも4の倍数
for i in range(n):
  if a[i]%2==1:
    cnt1+=1
  elif format(a[i], 'b')[::-1].find('1')==1:
    cnt2+=1
  else:
    cnt4+=1

if cnt2>=2:
  print('Yes') if cnt4>=(n-cnt2-cnt2%2)//2 else print('No')

else:
  print('Yes') if cnt4>=n//2 else print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
cnt1=0#奇数
cnt2=0#2で一回割れる。隣り合うと4の倍数
cnt4=0#4で一回割れる。隣がなんでも4の倍数
for i in range(n):
  if a[i]%2==1:
    cnt1+=1
  elif format(a[i], 'b')[::-1].find('1')==1:
    cnt2+=1
  else:
    cnt4+=1

if cnt2>=2:
  print('Yes') if cnt4>=(n-cnt2%2)//2 else print('No')

else:
  print('Yes') if cnt4>=n//2 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 format(a[i], 'b')[::-1].find('1')==1:
    cnt2+=1
  else:
    cnt4+=1

if cnt2>=2:
  if cnt4>=(n-cnt2)//2:
    print('Yes')
  else:
    print('No')
else:
  if cnt4>=n//2:
    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 a in A:
    if a%2==0 and a%4!=0:
        two+=1
    elif a%4==0:
        four+=1
if (len(A)-two+1)//2<=four:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect

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

for i in range(n):
    if a[i]%2==0:
        n2+=1
    if a[i]%4==0:
        n4+=1
if n2==n:
  print("Yes")
  exit()
if n4>=(n+2)//3:
    print("Yes")
else:
    if (n2-n4)>=n-3*n4+1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect

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

for i in range(n):
    if a[i]%2==0:
        n2+=1
    if a[i]%4==0:
        n4+=1
if n4>=(n+2)//3:
    print("Yes")
else:
    if (n2-n4)>=n-3*n4+1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

ok = []
no_and_no_even = []
no_and_even = []
for i in range(N):
    if (A[i] % 4 == 0):
        ok.append(A[i])
    elif (A[i] % 4 != 0 and A[i] % 2 == 0):
        no_and_even.append(A[i])
    else:
        no_and_no_even.append(A[i])

if (len(ok) == 0 and len(no_and_no_even) != 0):
    print('No')
    exit()
else:
    if (len(ok) < len(no_and_no_even) and len(no_and_even) != 0):
        print('No')
        exit()

if (len(ok) == len(no_and_no_even) or len(ok) == len(no_and_no_even) - 1):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

ok = []
no_and_no_even = []
no_and_even = []
for i in range(N):
    if (A[i] % 4 == 0):
        ok.append(A[i])
    elif (A[i] % 4 != 0 and A[i] % 2 == 0):
        no_and_even.append(A[i])
    else:
        no_and_no_even.append(A[i])

if (len(ok) == 0 and len(no_and_no_even) != 0):
    print('No')
    exit()


if (len(ok) == len(no_and_no_even) or len(ok) == len(no_and_no_even) - 1):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

ok = []
no_and_no_even = []
no_and_even = []
for i in range(N):
    if (A[i] % 4 == 0):
        ok.append(A[i])
    elif (A[i] % 4 != 0 and A[i] % 2 == 0):
        no_and_even.append(A[i])
    else:
        no_and_no_even.append(A[i])

if (len(ok) == len(no_and_no_even) or len(ok) == len(no_and_no_even) - 1):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    n = int(input())
    a = input_list()
    if list(set(a)) == [1]:
        print('No')
        exit()

    divide_counters = []
    for v in a:
        dt = divide_two(v)
        divide_counters.append(dt)
    
    if set(divide_counters) == {1, 4}:
        if divide_counters.count(1) <= divide_counters.count(4) + 1:
            print('Yes')
            exit()
        else:
            print('No')
            exit()
    if divide_counters.count(1) <= divide_counters.count(4):
        print('Yes')
    else:
        print('No')


def divide_two(n):
    c = 0
    while True:
        if c >= 2:
            break
        if n % 2 != 0:
            break
        n //= 2
        c += 1
    return c

def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    n = int(input())
    a = input_list()
    if list(set(a)) == [1]:
        print('No')
        exit()

    divide_counters = []
    for v in a:
        if v % 2 != 0:
            divide_counters.append(1)
        else:
            if v // 2 == 1:
                divide_counters.append(2)
            else:
                divide_counters.append(4)
    if set(divide_counters) == {1, 4}:
        if divide_counters.count(1) <= divide_counters.count(4) + 1:
            print('Yes')
            exit()
        else:
            print('No')
            exit()
    if divide_counters.count(1) <= divide_counters.count(4):
        print('Yes')
    else:
        print('No')

def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
f=[]
od=[]
for i in range(n):
  if a[i]%4==0:
    f.append(a[i])
  elif a[i]%2==1:
    od.append(a[i])
if len(f)>=len(od) and 2 in a:
  print('Yes')
elif len(f)<len(od) and 2 in a:
  print('No')
elif 2 not in a and len(f)>=len(od)-1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
f=[]
od=[]
for i in range(n):
  if a[i]%4==0:
    f.append(a[i])
  elif a[i]%2==1:
    od.append(a[i])
if len(f)>=len(od):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
f=[]
od=[]
for i in range(n):
  if a[i]%4==0:
    f.append(a[i])
  elif a[i]%2==1:
    od.append(a[i])
    
if len(f)<len(od)+1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
odds = [a for a in A if a % 2 == 1]
ones = [a for a in A if a == 1]
divide_by_four = [a for a in A if a % 4 == 0]

if len(odds) <= len(divide_by_four):
    print("Yes")
elif len(odds) == len(ones) and len(ones) == len(divide_by_four) + 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
four = 0
odd = 0
even = 0
for a in A:
	if a % 4 == 0:
		four += 1
	elif a % 2:
		odd += 1
	else:
		even += 1
if 2 * four > odd or (2 * four == odd and even != 1):
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
as_ = map(int, input().strip().split())

num_mul2 = 0
num_mul4 = 0

for a in as_:
    if a % 4 == 0:
        num_mul4 += 1
    elif a % 2 == 0:
        num_mul2 += 1

d = n - num_mul4 * 2 - num_mul2
if num_mul4 > 0:
    d -= 1

if d <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
as_ = map(int, input().strip().split())

num_mul2 = 0
num_mul4 = 0

for a in as_:
    if a % 4 == 0:
        num_mul4 += 1
    elif a % 2 == 0:
        num_mul2 += 1

d = n - num_mul4 * 3 - num_mul2

if d <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

for i in range(N):
  if a[i]%4==0:
    c4+=1
  if a[i]%2==0:
    c2+=1

nodd=N-c2
if N<=3:
  if 1<=c4:
    print("Yes")
  else:
    print("No")
else:
  if nodd<=c4:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

for i in range(N):
  if a[i]%4==0:
    c4+=1
  if a[i]%2==0:
    c2+=1

nodd=N-c2

if round(nodd/2)<=c4:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()



a4=0
a0=0
for i in range(n):
    if a[i]%4==0:
        a4+=1
    elif a[i]%4==1 or a[i]%4==3:
        a0+=1


if a4>=a0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

if cnt1 > cnt4 and n > 3:
    print("No")
elif cnt4 >= 1:
    print("Yes")
else:
    print("No")