Problem:


Score : 400 points

Problem Statement

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

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

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

Determine whether Snuke can achieve his objective.

Constraints

2 ≤ N ≤ 10^5

a_i is an integer.

1 ≤ a_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

Sample Input 1

3
1 10 100

Sample Output 1

Yes

One solution is (1, 100, 10).

Sample Input 2

4
1 2 3 4

Sample Output 2

No

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

Sample Input 3

3
1 4 1

Sample Output 3

Yes

The condition is already satisfied initially.

Sample Input 4

2
1 1

Sample Output 4

No

Sample Input 5

6
2 7 1 8 2 8

Sample Output 5

Yes



Sample input:
3
1 10 100


Sample output:
Yes

Submission status: Wrong Answer

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

if n%2 == 0:
    th = int(n/2)
else:
    th = int((n-1)/2)

count = 0
num_2 = 0
for a in a_list:
    if a%4 == 0:
        count += 1
    elif a == 2:
        num_2 += 1

if count >= th-int(num_2/2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if n%2 == 0:
    th = int(n/2)
else:
    th = int((n-1)/2)

count = 0
num_2 = 0
for a in a_list:
    if a%4 == 0:
        count += 1
    elif a == 2:
        num_2 += 1

if count >= th-int(num_2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

cnt=0

for i in A:
    if i%4==0:
        cnt+=2
    elif i%2==0:
        cnt+=1
if N-1<=cnt:
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

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

cnt=0

for i in A:
    if i%4==0:
        cnt+=2
    elif i%2==0:
        cnt+=1
if N-1<cnt:
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

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

odd = 0
even_without_fours = 0
fours = 0

for ai in a:
	if ai % 2 == 0:
		if ai % 4 == 0:
			fours += 1
		else:
			even_without_fours += 1
	else:
		odd += 1

ok = True
if even_without_fours == 0:
	if  fours - 1 < odd:
		ok = False
else: # if even_withou_fours != 0:
	if fours < odd:
		ok = False

print("Yes" if ok == True else "No")

Submission status: Wrong Answer

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

odd = 0
even_without_fours = 0
fours = 0

for ai in a:
	if ai % 2 == 0:
		if ai % 4 == 0:
			fours += 1
		else:
			even_without_fours += 1
	else:
		odd += 1

ok = True
if even_without_fours == 0:
	if (fours + odd) % 2 != 0:
		if  fours - 1 < odd:
			ok = False
	else: # if (fours + odd) % 2 == 0:
		if fours < odd:
			ok = False
else: # if even_withou_fours != 0:
	if fours < odd:
		ok = False

print("Yes" if ok == True else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
four = 0
two = 0
one = 0
for e in map(int, input().split()):
    if e % 4 == 0:
        four += 1
    elif e % 2 != 0:
        one += 1
    else:
        two = 0
if four >= one:
    print("Yes")
else:
    if two == 0 and four == one - 1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
four = 0
one = 0
for e in map(int, input().split()):
    if e % 4 == 0:
        four += 1
    elif e % 2 != 0:
        one += 1
if four >= one:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# C - 4-adjacent

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

b = [ a[i]%4 for i in range(n) ]
import collections
c = collections.Counter(b)
#print(c)
if c[0]*2+c[2]//2 >= n-1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# C - 4-adjacent

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

b = [ a[i]%4 for i in range(n) ]
import collections
c = collections.Counter(b)
#print(c)
if c[0]*2+c[2] >= n-1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
aa = map(int, raw_input().split())

div2 = 0
div4 = 0
for a in aa:
    if a % 4 == 0:
        div4 += 1
    elif a % 2 == 0:
        div2 += 1

if n - 1 <= div4*2 + div2:
    print 'Yes'
else:
    print 'No'

Submission status: Wrong Answer

Solution code:
import copy
x = int(input())
a = input().split(" ")

quat_num = 0
odd_num = 0

for i in a:
    val = int(i)
    if (val % 4 == 0):
        quat_num += 1
    elif (val % 2 != 0):
        odd_num += 1

#print("odd", odd_num)
#print("quat", quat_num)
if (odd_num <= quat_num):
    print("Yes")
else:
    if (x == 3 and quat_num == 1 and odd_num == 2):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import math
n = int(raw_input())
aa = map(int, raw_input().split())

need = math.floor(n/2)
div2 = 0
div4 = 0
for a in aa:
    if a % 4 == 0:
        div4 += 1
    elif a % 2 == 0:
        div2 += 1

if n - 1 <= div4*2 + div2/2:
    print 'Yes'
else:
    print 'No'

Submission status: Wrong Answer

Solution code:
import math
n = int(raw_input())
aa = map(int, raw_input().split())

need = math.floor(n/2)
div2 = 0
div4 = 0
for a in aa:
    if a % 4 == 0:
        div4 += 1
    elif a % 2 == 0:
        div2 += 1

if n - 1 <= div4*2 + div2/2:
    print 'YES'
else:
    print 'NO'

Submission status: Wrong Answer

Solution code:
import math
n = int(raw_input())
aa = map(int, raw_input().split())

need = math.floor(n/2)
div2 = 0
div4 = 0
for a in aa:
    if a % 4 == 0:
        div4 += 1
    elif a % 2 == 0:
        div2 += 1

if n - 1 <= div4*2 + div2/2:
    print 'YES'
else:
    print 'NO'

Submission status: Wrong Answer

Solution code:
x = int(input())
a = input().split(" ")

quat_num = 0
odd_num = 0

for i in a:
    val = int(i)
    if (val % 4 == 0):
        quat_num += 1
    elif (val % 2 != 0):
        odd_num += 1

#print("odd", odd_num)
#print("quat", quat_num)
if (odd_num <= quat_num):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
x = int(input())
a = input().split(" ")

quat_num = 0
odd_num = 0

for i in a:
    val = int(i)
    if (val % 4 == 0):
        quat_num += 1
    elif (val % 2 != 0):
        odd_num += 1

if (odd_num <= quat_num):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
x = int(input())
a = input().split(" ")

quat_num = 0
odd_num = 0

for i in a:
    val = int(i)
    if (val % 4 == 0):
        quat_num += 1
    elif (val % 2 != 0):
        odd_num += 1

if (odd_num < quat_num):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
L = list(map(int, input().split()))
odd = 0
div2 = 0
div4 = 0
for l in L:
    if l % 2 != 0:
        odd += 1
    elif l % 4 == 0:
        div4 += 1
    else:
        div2 += 1

if N == 2:
    if odd == 2 or (odd == 1 and div2 == 1):
        print("No")
    else:
        print("Yes")
    exit()

if N == 3:
    if div4 >= 1:
        print("Yes")
    else:
        if odd == 0:
            print("Yes")
        else:
            print("No")
    exit()

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

Submission status: Wrong Answer

Solution code:
n = int(input())
q=0
w=0
e=0
a = list(map(int, input().split()))
for b in a:
    if b % 2 ==0 :
        if b % 4!=0:
            q=q+1
    elif b%4 ==0:
        e=e+1
    elif b%2!=0:
        w=w+1


q=q/2

q=q+e
if(w<=q):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
q=0
w=0
e=0
a = list(map(int, input().split()))
for b in a:
    if b % 2 ==0 & b % 4!=0:
        q+=q
    elif b%4 ==0:
        e+=e
    elif b%2!=0:
        w+=w

q=q/2
q=q+e
if(w<=q):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
q=0
w=0
e=0
a = list(map(int, input().split()))
for b in a:
    if b % 2 ==0:
        q+=q
    elif b%4 ==0:
        e+=e
    elif b%2!=0:
        w+=w

q=q/2
q=q+e
if(w<q):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
q=0
w=0
e=0
a = list(map(int, input().split()))
for b in a:
    if b % 2 ==0:
        q+=q
    elif b%4 ==0:
        e+=e
    elif b%2!=0:
        w+=w

q=q/2
q=q+e
if(w<=q):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
q=0
w=0
e=0
a = list(map(int, input().split()))
for b in a:
    if b % 2 ==0:
        q+=q
    elif b%4 ==0:
        e+=e
    else:
        w+=w

q=q/2
q=q+e
if(w<=q):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
q=0
w=0
e=0
a = list(map(int, input().split()))
for b in a:
    if b % 2 ==0:
        q+=q
    elif b%4 ==0:
        e+=e
    else:
        w+=w

q=q/2
q=q+e
if(w<=q):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

num_4 = sum([ 1 for i in A if i%4 == 0])
num_odd = sum([ 1 for i in A if i%2 == 1])

if num_4 >= num_odd:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

num_4 = sum([ 1 for i in A if i%4 == 0])
num_2 = sum([ 1 for i in A if i%2 == 0]) - num_4
num_odd = N - num_2 - num_4

if num_4 >= num_odd:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

num_4 = sum([ 1 for i in A if i%4 == 0])
num_2 = sum([ 1 for i in A if i%2 == 0]) - num_4
num_odd = N - num_2 - num_4

if num_4 > num_odd:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#ARc080C

n=int(raw_input())
l=map(int,raw_input().split())
cnt1=cnt2=cnt4=0
for i in xrange(n):
 if (l[i]%2)%2==0:
  cnt4+=1
 elif l[i]%2==0:
  cnt2+=1
 elif l[i]%2:
  cnt1+=1
if cnt2==0:
 if cnt1<=cnt4+1:
  print 'Yes'
 else:
  print 'No'
else:
 if cnt1<=cnt4:
  print 'Yes'
 else:
  print 'No'

Submission status: Wrong Answer

Solution code:
#ARc080C
#import sys

n=int(raw_input())
l=map(int,raw_input().split())
if l.count(2)>0:
 l=filter(lambda a:a!=2,l)
 l.append(2)
cnt=0
for i in xrange(len(l)):
 if l[i]%4==0:
  cnt+=1
if cnt>=len(l)/2:
 print 'Yes'
else:
 print 'No'

Submission status: Wrong Answer

Solution code:
#ARc080C
#import sys

n=int(raw_input())
l=map(int,raw_input().split())
cnt2=l.count(2)
cnt=0
for i in xrange(n):
 if l[i]%4==0:
  cnt+=1
if cnt>=n/2:
 print 'Yes'
elif cnt+cnt2/2>=n/2:
 print 'Yes'
else:
 print 'No'

Submission status: Wrong Answer

Solution code:
N=(int)(input())
a=(input()).split(' ')

thalf=0
fzero=0

for i in a:
    thalf += 1 if (int)(i)%2!=0 else 0
    fzero += 1 if (int)(i)%4==0 else 0

if(thalf-1>fzero or (thalf==(int)(N/2+0.5) and (thalf+fzero!=N))):
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

f,t,z=0,0,0
for x in xs:
  if x % 4 == 0:
    f+=1
  elif x % 2 == 0:
    t += 1
  else:
    z += 1
z += 0<t
print('Yes' if z + 1 < f else'No')

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())

four = 0
nfour = 0
two = 0

l = [int(x) for x in sys.stdin.readline().split()]

for x in l:
	if x % 4 == 0:
		four += 1
	elif x % 2 == 1:
		nfour += 1
	else:
		two += 1

if four > 0:
	if four >= nfour:
		print('Yes')
	else:
		print('No')
else:
	if nfour > 0:
		print('No')
	else:
		if two >= 2:
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())

four = 0
nfour = 0

l = [int(x) for x in sys.stdin.readline().split()]

for x in l:
	if x % 4 == 0:
		four += 1
	elif x % 2 == 1:
		nfour += 1

if four >= nfour:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    d = collections.defaultdict(int)
    for c in a:
        d[c%4] += 1

    d[1] += d[3]
    if d[2] == 1:
        d[1] += 1
    if (d[1] == 0) or (d[1]-1 <= d[0] and d[0] > 0):
        return 'Yes'

    return 'No'



print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    d = collections.defaultdict(int)
    for c in a:
        d[c%4] += 1

    d[1] += d[3]
    if d[2] == 1:
        d[1] += 1
    if d[1]-1 <= d[0] and d[0] > 0:
        return 'Yes'

    return 'No'



print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    d = collections.defaultdict(int)
    for c in a:
        d[c%4] += 1

    d[1] += d[3]
    if d[2] == 1:
        d[1] += 1
    if d[1]-1 <= d[0]:
        return 'Yes'

    return 'No'



print(main())

Submission status: Wrong Answer

Solution code:
import sys
from sys import stdin,stdout
import bisect
N=input()
A=list(map(int,stdin.readline().strip().split(' ')))
count4=0
count1=0
for i in xrange(len(A)):
    if A[i]%4==0:
        count4+=1
    elif A[i]%2==1:
        count1+=1
if count4>=count1:
    if len(A)==1:
        if A[0]%4==0:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')
    
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
from sys import stdin,stdout
import bisect
N=input()
A=list(map(int,stdin.readline().strip().split(' ')))
count4=0
count1=0
for i in xrange(len(A)):
    if A[i]%4==0:
        count4+=1
    elif A[i]%2==1:
        count1+=1
if count4>=count1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

count1=0
count2=0
count4=0
for i in range(n):
    if a[i]%4==0: count4+=1
    elif a[i]%2==0: count2+=1
    else: count1+=1

if count4+1>=count1: print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

def check4adjacent(N, a):
    a = np.array(map(int, a))
    count4multiples = len(np.where(a % 4 == 0)[0])
    count2multiples = len(np.where((a % 2 == 0) & (a % 4 != 0))[0])

    if count4multiples * 2 + count2multiples + 1 >= N:
        return "Yes"
    else:
        return "No"

if __name__ == "__main__":
    N = int(raw_input())
    a = raw_input().split()
    print(check4adjacent(N, a))

Submission status: Wrong Answer

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

q = []
summation = [p[i] + p[i + 1] for i in range(N - 1)]
for i in range(int(N / 2)):
    if len(p) == 2:
        q = p + q
    else:
        index = summation.index(max(summation))
        q = p[index:index + 2] + q
        p = p[:index] + p[index + 2:]
        if index == 0:
            summation = summation[2:]
        elif index == len(summation) - 1:
            summation = summation[:index - 1]
        else:
            summation = summation[:index - 1] + [p[index - 1] + p[index]] + summation[index + 2:]

[print(i, end=' ') for i in q]

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# coding: utf-8

import sys

# q: 4の倍数, a: 奇数1個または偶数2個
# a q a q a q ... q a
def solve(N, a):
  n4 = len([v for v in a if v % 4 == 0])                # 4の倍数
  n2 = len([v for v in a if v % 4 != 0 and v % 2 == 0]) # 4の倍数でない偶数
  n1 = len([v for v in a if v % 2 != 0])                # 奇数
  na = n4 + 1 if n4 > 0 else 0
  while n2 >= 2 and na >= 1:
    n2 -= 2
    na -= 1
  n1 += n2
  return "Yes" if n1 <= na else "No"

def splitIntoNums(line):
  words = line.strip().split()
  return [int(w) for w in words]

while True:
  l1 = sys.stdin.readline()
  l2 = sys.stdin.readline()
  if not l1: break
  N, = splitIntoNums(l1)
  a  = splitIntoNums(l2)
  if len(a) != N: raise
  print(solve(N, a))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# coding: utf-8

import sys

# q: 4の倍数, a: 奇数1個または偶数2個
# a q a q a q ... q a
def solve(N, a):
  n4 = len([v for v in a if v % 4 == 0])                # 4の倍数
  n2 = len([v for v in a if v % 4 != 0 and v % 2 == 0]) # 4の倍数でない偶数
  n1 = len([v for v in a if v % 2 != 0])                # 奇数
  na = n4 + 1 if n4 > 0 else 0
  while n2 >= 2 and na >= 1:
    n2 -= 2
    na -= 1
  n1 += n2
  return "YES" if n1 <= na else "NO"

def splitIntoNums(line):
  words = line.strip().split()
  return [int(w) for w in words]

while True:
  l1 = sys.stdin.readline()
  l2 = sys.stdin.readline()
  if not l1: break
  N, = splitIntoNums(l1)
  a  = splitIntoNums(l2)
  if len(a) != N: raise
  print(solve(N, a))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# coding: utf-8

import sys

# q: 4の倍数, a: any, b: 奇数1個または偶数2個
# a q b q b q ... q a
def solve(N, a):
  n4 = len([v for v in a if v % 4 == 0])                # 4の倍数
  n2 = len([v for v in a if v % 4 != 0 and v % 2 == 0]) # 4の倍数でない偶数
  n1 = len([v for v in a if v % 2 != 0])                # 奇数
  na = 2 if n4 > 0 else 0
  nb = n4 - 1 if n4 > 0 else 0
  while n2 >= 2 and nb >= 1:
    n2 -= 2
    nb -= 1
  n1 += n2
  n1 -= na
  return "YES" if n1 <= nb else "NO"

def splitIntoNums(line):
  words = line.strip().split()
  return [int(w) for w in words]

while True:
  l1 = sys.stdin.readline()
  l2 = sys.stdin.readline()
  if not l1: break
  N, = splitIntoNums(l1)
  a  = splitIntoNums(l2)
  if len(a) != N: raise
  print(solve(N, a))

Submission status: Wrong Answer

Solution code:
import numpy as np
t=int(input())
s=0
arr = [int(i) for i in input().split()]
result = np.prod(np.array(arr))
d=result%100
if d%4==0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
t=int(input())
s=0
arr = [int(i) for i in input().split()]
p=sum(arr)
if p%3==0 or p%4==0 or p%5==0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([int(i) for i in input().split()] )

log2_a = np.log2(a).astype(int)*(a%2==0)
Nx = N - np.sum(log2_a == 1)//2
cnt = np.sum(log2_a > 1)

if cnt >= Nx//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
t=int(input())
s=0
arr = [int(i) for i in input().split()]
p=sum(arr)
if p%3==0 or p%4==0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
l=map(int,input().split())
a,b,c=0,0,True
for i in l:
    if i%4==0:b+=1
    else:
        if i%2!=0:a+=1
        else:c=False

print(c)
if a==0:
    print("Yes")
    sys.exit()
if c:
    if b==0:
        print("No")
        sys.exit()
    if b>=a-1:print("Yes")
    else:print("No")
else:
    if b>=a:print("Yes")
    else:print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([int(i) for i in input().split()] )

log2_a = np.log2(a).astype(int)*(a%2==0)
Nx = N - np.sum(log2_a == 1)//2*2
cnt = np.sum(log2_a > 1)

if cnt >= Nx//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import copy

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



N=int(input())
a=spaceinput()

count4=0
count2=0
countodd=0
for sa in a:
    if sa%4==0:
        count4+=1
    elif sa%2==0:
        count2+=1
    else:
        countodd+=1



x=["o","e4"]*count4
x.extend(["e2"]*count2)
x.extend(["o"])
#print(count4,count2)
#print(x)
#print(len(x),N)
if len(x)>=N:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(N):
    x[i]=(x[i]%4)

a=x.count(1)+x.count(3)
o=x.count(0)

if(o>=a):
    print('Yes')
    quit()

print('No')


quit()

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
l=map(int,input().split())
a,b,c=0,0,True
for i in l:
    if i%4==0:b+=1
    if i%2!=0:a+=1
    else:c=False
if a==0:
    print("Yes")
    sys.exit()
if c:
    if b==0:
        print("No")
        sys.exit()
    if b>=a-1:print("Yes")
    else:print("No")
else:
    if b>=a:print("Yes")
    else:print("No")

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
l=map(int,input().split())
a,b,c=0,0,True
for i in l:
    if i%4==0:b+=1
    if i%2!=0:a+=1
    else:c=False
if c:
    if b==0:
        print("No")
        sys.exit()
    if b>=a-1:print("Yes")
    else:print("No")
else:
    if b>=a:print("Yes")
    else:print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([int(i) for i in input().split()] )

log2_a = np.log2(a).astype(int)*(a%2==0)
cnt_fac4over = np.sum(log2_a > 1) * 2
cnt_fac2only = np.sum(log2_a == 1)
cnt = cnt_fac4over + cnt_fac2only

if cnt >= N:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
l=map(int,input().split())
a,b,c=0,0,True
for i in l:
    if i%4==0:b+=1
    if i%2!=0:a+=1
    else:c=False
if c:
    if b>=a-1:print("Yes") 
else:
    if b>=a:print("Yes")
    else:print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([int(i) for i in input().split()] )

log2_a = np.log2(a).astype(int)*(a%2==0)
cnt_fac4over = np.sum(log2_a > 1)
cnt_fac2only = np.sum(log2_a == 1)
cnt = cnt_fac4over + cnt_fac2only//2

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


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


def read():
    N = II()
    a = ILI()
    return N, a


def solve(N, a):
    n_odd = 0
    n_div_2 = 0
    n_div_4 = 0
    for _a in a:
        if _a % 2 == 1:
            n_odd += 1
        else:
            if _a % 4 == 0:
                n_div_4 += 1
            else:
                n_div_2 += 1
    print(n_odd)
    print(n_div_2)
    print(n_div_4)

    ans = ""
    if n_div_2 == 0:
        if n_div_4 >= n_odd - 1:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if n_div_4 >= n_odd:
            ans = "Yes"
        else:
            ans = "No"

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
l=map(int,input().split())
a,b=0,0
for i in l:
    if i%4==0:b+=1
    if i%2!=0:a+=1
if b>=a:print("Yes")
else:print("No")

Submission status: Wrong Answer

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

def f(x):
    if x % 4 == 0:
        return 4
    elif x % 2 == 0:
        return 2
    return 1

c = [0] * 5

for i in xrange(n):
    c[f(a[i])] += 1

print 'Yes' if c[4] >= c[1] else 'No'

Submission status: Wrong Answer

Solution code:
N=int(input())
l=map(int,input().split())
a,b=0,0
for i in l:
    if i%4==0:b+=1
    if i%2!=0:a+=1
if b>=a-1:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


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


def read():
    N = II()
    a = ILI()
    return N, a


def solve(N, a):
    n_odd = 0
    n_div_2 = 0
    n_div_4 = 0
    for _a in a:
        if _a % 2 == 1:
            n_odd += 1
        else:
            if _a % 4 == 0:
                n_div_4 += 1
            else:
                n_div_2 += 1

    ans = ""
    if n_div_2 == 1:
        if n_div_4 > n_odd:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if n_div_4 > n_odd + 1:
            ans = "Yes"
        else:
            ans = "No"

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
double=0
single=0
for i in range(N):
  if A[i]%4==0:
    double+=1
  elif A[i]%2==0:
    single+=1
nothing=N-double-single

if 2*double+1>=N:
  print("Yes")
elif 2*double+1+single>=N and single>=2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


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


def read():
    N = II()
    a = ILI()
    return N, a


def solve(N, a):
    n_odd = 0
    n_div_2 = 0
    n_div_4 = 0
    for _a in a:
        if _a % 2 == 1:
            n_odd += 1
        else:
            if _a % 4 == 0:
                n_div_4 += 1
            else:
                n_div_2 += 1

    ans = ""
    if n_div_2 == 1:
        if n_odd > n_div_4:
            ans = "No"
        else:
            ans = "Yes"
    else:
        if n_odd + 1 > n_div_4:
            ans = "No"
        else:
            ans = "Yes"

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
double=0
single=0
for i in range(N):
  if A[i]%4==0:
    double+=1
  elif A[i]%2==0:
    single+=1
nothing=N-double-single

if 2*double+1>=N:
  print("Yes")
elif 2*double+single>=N:
  print("Yes")
elif 2*double+1+single>=N and single>=2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


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


def read():
    N = II()
    a = ILI()
    return N, a


def solve(N, a):
    n_odd = 0
    n_div_2 = 0
    n_div_4 = 0
    for _a in a:
        if _a % 2 == 1:
            n_odd += 1
        else:
            if _a % 4 == 0:
                n_div_4 += 1
            else:
                n_div_2 += 1

    ans = ""
    if n_odd > n_div_4 + 1:
        ans = "No"
    else:
        ans = "Yes"

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import itertools

n=int(input())
a=list(map(int,input().split()))
#ans='No'
for v in itertools.permutations(a):
#  print(v)
  tmp=True
  for i in range(len(v)-1):
#    print(i,v[i]*v[i+1])
    if (v[i]*v[i+1])%4!=0:
      tmp=False
      break
  if tmp:
    print('Yes')
    exit()
    
print('No')

Submission status: Time Limit Exceeded

Solution code:
from itertools import permutations

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

for i in range(len(A)):
    flag = True
    for j in range(N-1):
        if (A[i][j]*A[i][j+1])%4 != 0:
            flag = False
    if flag:
        print("Yes")
        exit()

print("No")

Submission status: Time Limit Exceeded

Solution code:
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
A = list(map(int, input().split()))
f2 = 0
f4 = 0
for a in A:
    c = collections.Counter(prime_factorize(a))
    if c[2] == 1:
        f2 += 1
    elif c[2] >= 2:
        f4 += 1
if n -f2//2 *2 -f4 *3 <= 0:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

ans = ''
for v in itertools.permutations(A_list):
    counter = 0
    for i in range(len(v)-1):
        if (v[i]*v[i+1]) % 4 == 0:
            counter += 1
        else:
            break
    if counter + 1 == len(v):
        ans += 'Yes'
        print(ans)
        break
if ans == '':
    print('No')

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(sys.stdin.readline().strip())
ar = [int(x) for x in sys.stdin.readline().split()]
stop = False

def ok(x, y):
	if x == -1: return True
	return (x*y)%4 == 0

def find(ctr, prev, mask, app):
	global stop
	if ctr == n:
		stop = True
	if stop == True: return
	for i in range(n):
		if mask[i] and ok(prev, ar[i]):
			mask[i] = False
			find(ctr+1, ar[i], mask, app + [ar[i]])
			mask[i] = True

find(0, -1, [True]*n, [])
print "Yes" if stop else "No"

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8

import itertools

a = int(input())
b = input().split()
b = [int(i) for i in b]

flag = 0

li = list(itertools.permutations(b))

for i in li:
    tmp = 0
    for j in range(a-1):
        if i[j] * i[j + 1] % 4 == 0:
            tmp += 1
        
    if tmp == a-1:
        flag = 1

if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
n=int(raw_input())
N=map(int,raw_input().split())
mul=1
for i in N:
	mul*=i
if mul%4!=0:
	print "No"
	exit(0)
a2=[]
a4=[]
ao=[]
for i in N:
	if i%4==0:
		a4.append(i)
	elif i%2==0:
		a2.append(i)
	else:
		ao.append(i)
if len(ao)<=len(a4):
	print "Yes"
elif len(ao)-1==len(a4):
	if len(a4)==0:
		print "No"
		exit(0)
	if len(a2)==0:
		print "Yes"
	else:
		print "No"
else:
	print "No"

Submission status: Accepted

Solution code:
# author:  Taichicchi
# created: 29.09.2020 22:35:47

import sys
n = int(input())

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

cnt = 0

for l in a:
    if l % 2:
        pass
    elif l % 4:
        cnt += 1
    else:
        cnt += 2

# print(f"{cnt=}")

if cnt // 2 >= n // 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

two = []
four = []
others = []

for v in a:
    if v % 4 == 0:
        four.append(v)
    elif v % 2 == 0:
        two.append(v)
    else:
        others.append(1)

if len(two) % 2 != 0:
    others.append(two[0])
if len(four) + 1 >= len(others):
    print('Yes')
else:
    print('No')