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 sys


def main():
    args = sys.stdin.readline().split()
    N = int(args[0])
    A = map(int, input().split())

    non_factor_cnt = 0
    factor_of_two_cnt = 0
    factor_of_four_cnt = 0
    for num in A:
        remainder = num % 4
        if remainder != 0:
            if remainder == 2:
                factor_of_two_cnt += 1
            else:
                non_factor_cnt += 1
        else:
            factor_of_four_cnt += 1

    if factor_of_four_cnt >= non_factor_cnt: # + factor_of_two_cnt % 2:
        print('Yes')
    else:
        print('No')

main()

Submission status: Wrong Answer

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

multi4 = lambda a: a % 4 == 0
multi4_count = sum(map(multi4, a_list))
multi2 = lambda a: a % 2 == 0
multi2_count = sum(map(multi2, a_list)) - multi4_count

max_N = multi4_count*2 + (multi4_count>0) + multi2_count//2
print("No" if (N > max_N) else "Yes")

Submission status: Wrong Answer

Solution code:

def Solution(n, arr):
    for i in xrange(0,arr.__len__()-1):
        if (arr[i]*arr[i+1])%4 == 0:
            return True
    return False


if __name__=="__main__":
    n = raw_input()
    arr = map(int, raw_input().split(" "))
    if Solution(n, arr):
        print "Yes"
    else:
        print "No"

Submission status: Wrong Answer

Solution code:
n=int(input())
nums=input().split()
count=0
eventwo=[]
odd=[]
for x in range(0,len(nums)):
    num=int(nums[x])
    if num%2==0:
        if num%4==0:
            eventwo.append(num)
        while num%2==0:
            num=num/2
            count=count+1
        continue
    else:
        odd.append(num)
        continue
if len(nums)==3:
    if count>=len(nums)-1:
        print("Yes")
    else:
        print("No")
else:
    if len(eventwo)>=len(odd):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import collections as col


if __name__ == "__main__":
    n = int(input())
    a = map(int, input().split())

    a = [el%4 for el in a]
    count = col.Counter(a)

    if count[1] + count[3] >= 1:
        if count[0] >= count[1]:
            print('Yes')
        elif count[1] + count[3] == count[0] + 1 and count[2] == 0:
            print('Yes')
        else:
            print('No')

    else:  # count[1] == 0
        if count[0] >= 1:
            print('Yes')
        elif count[2] >= 2:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
import collections as col


if __name__ == "__main__":
    n = int(input())
    a = map(int, input().split())

    a = [el%4 for el in a]
    count = col.Counter(a)

    if count[1] + count[3] >= 1:
        if count[4] >= count[1]:
            print('Yes')
        elif count[1] + count[3] == count[4] + 1 and count[2] == 0:
            print('Yes')
        else:
            print('No')

    else:  # count[1] == 0
        if count[4] >= 1:
            print('Yes')
        elif count[2] >= 2:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
import collections as col


if __name__ == "__main__":
    n = int(input())
    a = map(int, input().split())
    
    a = [el%4 for el in a]
    count = col.Counter(a)

    if count[1] >= 1:
        if count[4] >= count[1]:
            print('Yes')
        elif count[1] == count[4] + 1 and count[2] == 0:
            print('Yes')
        else:
            print('No')

    else:  # count[1] == 0
        if count[4] >= 1:
            print('Yes')
        elif count[2] >= 2:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

l = len(arr)
i = 0
j = 0
flag = False

result = [arr[0]]

for j in range(l):
    for i in range(l):
        if (arr[j] * arr[i]) % 4 == 0:
            result.append(arr[i])
            if (len(result) == l):
                flag = True
                break
        if flag == True:
            break
    if flag == True:
        break
    else:
        result = [arr[0]]

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

Submission status: Wrong Answer

Solution code:
n=int(input())
nums=input().split()
count=0
eventwo=[]
odd=[]
for x in range(0,len(nums)):
    num=int(nums[x])
    if num%2==0:
        if num%4==0:
            eventwo.append(num)
        while num%2==0:
            num=num/2
            count=count+1
        continue
    else:
        odd.append(num)
        continue
if len(nums)==3:
    if count>=len(nums)-1:
        print("Yes")
    else:
        print("No")
else:
    if count>=len(nums)-1 and len(eventwo)>=len(odd):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a_list = list(map(int, input().split()))
 
multi4 = lambda a: a % 4 == 0
multi4_count = sum(map(multi4, a_list))
multi2 = lambda a: a % 2 == 0
multi2_count = sum(map(multi2, a_list)) - multi4_count
 
max_N = multi4_count*2 + 1 + int(multi2_count/2)
print("No" if N > max_N else "Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
nums=input().split()
count=0
eventwo=[]
odd=[]
for x in range(0,len(nums)):
    num=int(nums[x])
    if num%2==0:
        if num%4==0:
            eventwo.append(num)
        while num%2==0:
            num=num/2
            count=count+1
            print(num)
        continue
    else:
        odd.append(num)
        continue
if len(nums)==3:
    if count>=len(nums)-1:
        print("Yes")
    else:
        print("No")
else:
    if count>=len(nums)-1 and len(eventwo)>=len(odd):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
count_2=0
count_4=0
count_save=0

for i in range(N):
 b=int(a[i])
 if(b%4==0):
  count_4 +=1
 if( (b%2==0)and(b%4!=0) ):
  count_2 +=1

count_save +=3*count_4
if(count_2>=2):
 count_save +=count_2

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

Submission status: Wrong Answer

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

n4 = len(list(filter(lambda x:x%4 == 0 , a)))
num_2 = a.count(2)
if num_2 > 0:
    num_2 -= 1
zyoken = N - (n4 + num_2 + 1)

if n4  >= zyoken:
    print("Yes")
    
else:
    print(("No"))

Submission status: Wrong Answer

Solution code:
n=int(input())
nums=input().split()
count=0
c=0
even=[]
odd=[]
for x in range(0,len(nums)):
    num=int(nums[x])
    if num%2==0:
        even.append(num)
        c=c+1
        while num%2==0:
            num=num/2
            count=count+1
            print(num)
        continue
    else:
        odd.append(num)
        continue
if len(nums)==3:
    if count>=len(nums)-1:
        print("Yes")
    else:
        print("No")
else:
    if count>=len(nums)-1 and len(even)>=len(odd):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

if q*3-1+p >= n:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a=[int(x) for x in input().split()]
print(a)
Kisuu = 0
YonBaisuu = 0

for j in range(N):


  if a[0]%2 == 1:
    Kisuu += 1
    a.pop(0)
  elif a[0]%4 == 0:
    YonBaisuu += 1
    a.pop(0)
  else :
   a.pop(0)

if Kisuu == YonBaisuu:
  print('Yes')
else :
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
count_2=0
count_4=0
count_save=0

for i in range(N):
 ai=int(a[i])
 if(ai%4==0):
  count_4 +=1
 if( (ai%2==0)and(ai%4!=0) ):
  count_2 +=1

count_save +=3*count_4
if(count_2>=2):
 count_save +=count_2

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

Submission status: Wrong Answer

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

n4 = len(list(filter(lambda x:x%4 == 0 , a)))
num_2 = a.count(2) - 1
zyoken = N - (n4 + num_2 + 1)



if n4  >= zyoken:
    print("Yes")
    
else:
    print(("No"))

Submission status: Wrong Answer

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

# 数列が全部2nなら例外的にOK
if set([num % 2 for num in nums]) == {0}:
    print("Yes")
    exit(0)


a,b,c = 0,0,0
for elem in nums:
    if elem % 4 == 0 : a += 1  # 4の倍数
    else:
        b += 1  # 4の倍数じゃない

# あとづけ 
# Nが偶数なら2の倍数についても考える必要がある
c = 0
if N % 2 == 0:
    for elem in nums:
        if elem % 2 == 0 and elem % 4 != 0: c += 1



if N % 2 == 1:  # ぐ
    if b <= (N+1)/2 : print("Yes")
    else: print("No")
else:  # き
    if b-c <= a : print("Yes")
    else: print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# your code goes here
N=int(input())
a=[int(i) for i in input (). split ()]
M=0
M1=0
for i in range (N):
    if a[i]%2==0:
        M+=1
        a[i]//=2
        if a[i]%2==0:
            M1+=1
N-=M
if N==0:
    p="Yes"
elif M1+1>=N:
    p="Yes"
else:
    p="No"
print (p)

Submission status: Wrong Answer

Solution code:
# import numpy as np
import math
N = int(input())
a = list(map(int, input().split()))

two_count = 0
four_count = 0
for i in a:
    if i >= 4 and i % 4 == 0:
        four_count += 1
    elif i >= 2 and i % 2 == 0:
        two_count += 1

if two_count <= 1:
    if len(a) == 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= len(a)-2 else "No")
else:
    check = len(a) - two_count
    if check == 0:
        print("Yes")
    elif check <= 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= math.ceil(check/2) else "No")

Submission status: Wrong Answer

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

frby = 1
twby = -1

for i in number:
    if i % 4 == 0:
        frby += 2
    elif i % 2 == 0:
        twby += 1
        
if int(n) == 1 and frby == 3:
    print("Yes")
elif int(n) == (twby + 1):
    print("Yes")
elif int(n) <= (frby + twby):
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

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

n4 = len(list(filter(lambda x:x%4 == 0 , a)))
num_2 = a.count(2)
zyoken = int(N - (int(num_2/2.0)*2))
zyoken -=n4

if num_2 == N:
    print(("Yes"))

elif n4 + 1 >= zyoken:
    print("Yes")
    
else:
    print(("No"))

Submission status: Wrong Answer

Solution code:
# your code goes here
N=int(input())
a=[int(i) for i in input (). split ()]
M=0
M1=0
for i in range (N):
    if a[i]%2==0:
        M+=1
        a[i]//=2
        if a[i]%2==0:
            M1+=1
N-=M
if N==0:
    p="Yes"
else:
    if M1%2==1:
        M1+=1
    M1//=2
    if M1>=N:
        p="Yes"
    else:
        p="No"
print (p)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

N = int(input())
nums = [int(x) for x in input().split()]

a,b,c = 0,0,0
for elem in nums:
    if elem % 4 == 0 : a += 1  # 4の倍数
    else:
        b += 1  # 4の倍数じゃない

# あとづけ 
# Nが偶数なら2の倍数についても考える必要がある
c = 0
if N % 2 == 0:
    for elem in nums:
        if elem % 2 == 0 and elem % 4 != 0: c += 1

if N % 2 == 1:  # 偶数
    if b <= (N+1)/2 : print("Yes")
    else: print("No")
else:  # 奇数
    if b-c <= a : print("Yes")
    else: print("No")

Submission status: Wrong Answer

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

if p >= n or q*3-1 >= n or q*2+p >=n:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys


def main():
    args = sys.stdin.readline().split()
    N = int(args[0])
    A = map(int, input().split())

    non_factor_cnt = 0
    factor_of_two_cnt = 0
    factor_of_four_cnt = 0
    for num in A:
        remainder = num % 4
        if remainder != 0:
            if remainder == 2:
                factor_of_two_cnt += 1
            else:
                non_factor_cnt += 1
        else:
            factor_of_four_cnt += 1

    if factor_of_four_cnt >= non_factor_cnt + factor_of_two_cnt % 2:
        print('Yes')
    else:
        print('No')

main()

Submission status: Wrong Answer

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

frby = 1
twby = -1

for i in number:
    if i % 4 == 0:
        frby += 2
    elif i % 2 == 0:
        twby += 1
        
if int(n) <= (frby + twby):
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    multi_2 = 0
    multi_4 = 0
    
    for num in a:
        if(num % 2 == 0):
            if(num % 4 == 0):
                multi_4 += 1
            else:
                multi_2 += 1
    
    #print(multi_2)
    #print(multi_4)
    pair_2 = int(multi_2 / 2)
    permitrange = multi_4 * 3 + pair_2 * 2
    if(N <= permitrange):
        print("Yes")
    else:
        print("No")
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
# import numpy as np
import math
N = int(input())
a = list(map(int, input().split()))

two_count = 0
four_count = 0
for i in a:
    if i >= 4 and i % 4 == 0:
        four_count += 1
    elif i >= 2 and i % 2 == 0:
        two_count += 1

if two_count <= 1:
    if len(a) == 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= len(a)-2 else "No")
else:
    check = len(a) - two_count
    if check <= 1:
        print("Yes")
    elif check == 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= check-2 else "No")

Submission status: Wrong Answer

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

n4 = len(list(filter(lambda x:x%4 == 0 , a)))
num_2 = a.count(2)
zyoken = int(N - (int(num_2/2.0)))
zyoken -=n4

if num_2 == N:
    print(("Yes"))

elif n4 + 1 >= zyoken:
    print("Yes")
    
else:
    print(("No"))

Submission status: Wrong Answer

Solution code:
# import numpy as np
import math
N = int(input())
a = list(map(int, input().split()))

two_count = 0
four_count = 0
for i in a:
    if i >= 4 and i % 4 == 0:
        four_count += 1
    elif i >= 2 and i % 2 == 0:
        two_count += 1

if two_count <= 1:
    if len(a) == 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= len(a)-2 else "No")
else:
    check = len(a) - two_count
    if check == 0:
        print("Yes")
    elif check <= 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= check-2 else "No")

Submission status: Wrong Answer

Solution code:

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

n4 = len(list(filter(lambda x:x%4 == 0 , a)))
num_2 = a.count(2)
zyoken = int(N - (int(num_2/2.0)))
zyoken -=n4


if n4 + 1 >= zyoken:
    print("Yes")
    
else:
    print(("No"))

Submission status: Wrong Answer

Solution code:
# import numpy as np
import math
N = int(input())
a = list(map(int, input().split()))

two_count = 0
four_count = 0
for i in a:
    if i >= 4 and i % 4 == 0:
        four_count += 1
    elif i >= 2 and i % 2 == 0:
        two_count += 1

if two_count <= 1:
    if len(a) == 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= len(a)-2 else "No")
else:
    check = len(a) - two_count
    if check == 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= check-2 else "No")

Submission status: Wrong Answer

Solution code:
# import numpy as np
import math
N = int(input())
a = list(map(int, input().split()))

two_count = 0
four_count = 0
for i in a:
    if i >= 4 and i % 4 == 0:
        four_count += 1
    elif i >= 2 and i % 2 == 0:
        two_count += 1

if two_count <= 1:
    if len(a) == 2:
        print("YES" if four_count >= 1 else "NO")
    else:
        print("YES" if four_count >= len(a)-2 else "NO")
else:
    check = len(a) - two_count
    if check == 2:
        print("YES" if four_count >= 1 else "NO")
    else:
        print("YES" if four_count >= check-2 else "NO")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[int(i) for i in input (). split ()]
M=0
M1=0
for i in range (N):
    if a[i]%2==0:
        M+=1
        a[i]//=2
        if a[i]%2==0:
            M1+=1
M-=M1
if M1%2==1:
    M1+=1
M1//=2
M+=M1
if M>=N:
    p="Yes"
else:
    p="No"
print (p)

Submission status: Wrong Answer

Solution code:
# import numpy as np
import math
N = int(input())
a = list(map(int, input().split()))

two_count = 0
four_count = 0
for i in a:
    if i >= 4 and i % 4 == 0:
        four_count += 1
    elif i >= 2 and i % 2 == 0:
        two_count += 1

check = len(a) - two_count
if two_count > 0:
    ans = "YES" if math.ceil(check/2) <= four_count else "NO"
else:
    if check == 2:
        ans = "YES" if 1 <= four_count else "NO"
    else:
        ans = "YES" if check - 2 <= four_count else "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N = int(input())
    a = list(map(int, input().split()))
    n1 = 0
    n2 = 0
    n4 = 0
    for i in a:
        if i % 4 == 0:
            n4 += 1
        elif i % 2 == 0:
            n2 += 1
        else:
            n1 += 1
    if n2 == 0 and n4 == 0 and n1 == 1:
        print("Yes")
    else:
        if n1 == n4:
            print("Yes")
        elif n1 == n4 + 1:
            if n2 == 0:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
p = lambda  x: x #print(x)


N = int(input())						# 5
a = [int(i) for i in input().split()]	# 1 2 3 4 5 ...

f=0
t=0
for i in range(N):
	p(a[i])
	if a[i]%4==0:
		f += 1
	elif a[i]%2==0:
		t += 1

n=0
n+=f*3
if(t>=2):n+=t

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

Submission status: Wrong Answer

Solution code:
tmp = int(input())
arr = [int(x) for x in input().split()]
nep = 0
krat = 0
for elem in arr:
    if elem % 4 == 0:
        krat += 1
        break
    if elem % 2 == 1:
        nep += 1
if krat - nep >= -1:
    if krat - nep == -1:
        if nep + krat == tmp:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

if (c[1]==0) and (c[3]==0):
    print('Yes')
elif c[1] + c[3] < c[0] + 1:
    print('Yes')
elif (c[1] + c[3] == c[0] + 1)and(c[2] != 0):
    print('No')
else:
    print('No')

Submission status: Wrong Answer

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

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

if (c[1]==0) and (c[3]==0):
    print('Yes')
elif c[1] + c[3] < c[0] + 1:
    print('Yes')
elif (c[1] + c[3] == c[0])and(c[2] != 0):
    print('No')
else:
    print('No')

Submission status: Wrong Answer

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

n4 = len(list(filter(lambda x:x%4 == 0 , a)))
num_2 = a.count(2)
zyoken = int(N - (int(num_2/2.0)))
zyoken = int(zyoken/2.0)

if n4 >= zyoken:
    print("Yes")
else:
    print(("No"))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[int(i) for i in input (). split ()]
M=0
M1=0
for i in range (N):
    if a[i]%2==0:
        M+=1
        a[i]//=2
        if a[i]%2==0:
            M1+=1
if M1%2==1:
    M1+=1
M1//=2
M+=M1
if M>=N:
    p="Yes"
else:
    p="No"
print (p)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N = int(input())
    a = list(map(int, input().split()))
    n1 = 0
    n2 = 0
    n4 = 0
    for i in a:
        if i % 4 == 0:
            n4 += 1
        elif i % 2 == 0:
            n2 += 1
        else:
            n1 += 1
    if n2 == 0 and n4 == 0 and n1 == 0:
        print("Yes")
    else:
        if n1 == n4:
            print("Yes")
        elif n1 == n4 + 1:
            if n2 == 0:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = input()
N = int(N)
a = input()
nums = a.split()
counter = 0
semi = 0
for i in range(N):
    n = int(nums[i])
    if n % 4 == 0:
        counter += 1
    elif n % 2 == 0:
        semi += 1
    else: continue
if counter >= N // 2 :
    print("Yes")
elif counter == 0 & semi == N:
    print("Yes")
elif semi >= (N//2 - counter):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

N = np.int64(input())
a = np.array([int(x) for x in input().split()])

mod_a = np.mod(a, 4)
count4 = (mod_a==0).sum()
count2 = (mod_a==2).sum()
odd = ((mod_a==1) | (mod_a==3)).sum()
if N % 2 == 0:
    if count4 >= odd:
        print('yes')
    else:
        print('no')
else:
    if count4 >= odd - 1:
        print('yes')
    else:
        print('no')

Submission status: Wrong Answer

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

multi4 = lambda a: a % 4 == 0
multi4_count = sum(map(multi4, a_list))
multi2 = lambda a: a % 2 == 0
multi2_count = sum(map(multi2, a_list)) - multi4_count

max_N = multi4_count*2 + 1 + multi2_count//2
print("No" if N > max_N else "Yes")

Submission status: Wrong Answer

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

n = raw_input()
n = int(n)

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

count_2 = 0
count_4 = 0

for i in a:
    if i % 4 == 0:
        count_4 += 1
    elif i % 2 == 0:
        count_2 += 1

if count_4 >= (n-1)/2:
    print "Yes"
elif count_4*2 + count_2 >= n:
    print "Yes"
else:
    print "No"

Submission status: Wrong Answer

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

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

if (c[1]==0) and (c[3]==0):
    print('Yes')
elif c[1] + c[3] <= c[0] + 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

zyoken = int(N/2.0)
n4 = len(list(filter(lambda x:x%4 == 0 , a)))
num_2 = a.count(2)

if sum(a) == 2 * N:
    print("Yes")

elif n4 == 0:
    print("No")
    
elif (n4 + int(num_2/2.0)) >= zyoken:
    print("Yes")
else:
    print(("No"))

Submission status: Wrong Answer

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

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

if (c[1]==0) and (c[3]==0):
    print('Yes')
elif c[1] + c[3] + 1 <= c[0]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())						# 5
a = [int(i) for i in input().split()]	# 1 2 3 4 5 ...

f=0
t=0
for i in range(N):
	if a[i]%4==0:
		f += 1
	elif a[i]%2==0:
		t += 1

if (f*3 + t//2) >= N:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(raw_input())
l = np.array(map(int, raw_input().split()))

mod_4 = len(np.where((l % 4 == 0))[0])
mod_2 = len(np.where(l % 4 == 2)[0])

if N <= 2 and mod_4 == 0 and mod_2 <= 1:
    print 'No'
elif N <= mod_4 * 2 + 1:
    print 'Yes'
elif N <= mod_4 * 2 + 1 + mod_2 and mod_2 >= 2:
    print 'Yes'
elif N <= mod_4 * 2 + mod_2:
    print 'Yes'
else:
    print 'No'

Submission status: Wrong Answer

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

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

if (c[1]==0) and (c[3]==0):
    print('Yes')
elif c[1] + 1 <= c[0]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mul4 = 0
mul2 = 0
has_mul2 = 0
other = 0
for i in a:
    if i%4 == 0:
        mul4 += 1
    elif i%2 == 0:
        mul2 += 1
        has_mul2 = 1
    else:
        other += 1

if mul4 > (has_mul2+other-1) or other == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = input()
N = int(N)
a = input()
nums = a.split()
counter = 0
semi = 0
for i in range(N):
    n = int(nums[i])
    if n % 4 == 0:
        counter += 1
    elif n % 2 == 0:
        semi += 1
    else: continue
if counter >= N // 2 :
    print("Yes")
elif counter == 0 & semi == N:
    print("Yes")
elif semi > (N//2 - counter):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

if (c[1]==0) and (c[3]==0):
    print('Yes')
elif c[1] <= c[0]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mul4 = 0
mul2 = 0
has_mul2 = 0
other = 0
for i in a:
    if i%4 == 0:
        mul4 += 1
    elif i%2 == 0:
        mul2 += 1
        has_mul2 = 1
    else:
        other += 1

if mul4*2 > (has_mul2+other-1) or other == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections as col


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

if __name__ == "__main__":
    n = int(input())
    a = map(int, input().split())

    count = col.Counter(map(convert, a))

    if count[4] >= count[1]:
        print('Yes')
    elif count[1] == count[4] + 1 and count[2]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

for i in range(len(a_arr)):
    a_arr[i] = int(a_arr[i])

counter = {
        "twon": 0,
        "forn": 0,
        "n": 0
}

for j in range(len(a_arr)):
    if a_arr[j] % 4 == 0:
        counter['forn'] += 1
    elif a_arr[j] % 2 == 0:
        counter['twon'] += 1
    else:
        counter['n'] += 1

indicator = N - counter['twon']/2
if counter['n'] - counter['forn'] <= 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mul4 = 0
mul2 = 0
has_mul2 = 0
other = 0
for i in a:
    if i%4 == 0:
        mul4 += 1
    elif i%2 == 0:
        mul2 += 1
        has_mul2 = 1
    else:
        other += 1

if mul4*2 >= (has_mul2+other) or (mul2>1 and other == 0):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

zyoken = int(N/2.0)
n4 = len(list(filter(lambda x:x%4 == 0 , a)))
num_2 = a.count(2)

if (n4 + int(num_2/2.0)) >= zyoken:
    print("Yes")
else:
    print(("No"))

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
a = map(int,raw_input().split(" "))
tmp = 1
for i in range(N):
	tmp *= a[i]
 
if tmp % pow(4,N-2) == 0 and tmp >= pow(4,N-2):
	print "Yes"
else:
	print "No"

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(raw_input())
l = np.array(map(int, raw_input().split()))


mod_4 = len(np.where((l % 4 == 0))[0])
mod_2 = len(np.where(l % 4 == 2)[0])

if N <= 2 and mod_4 == 0 and mod_2 <= 1:
    print 'No'
elif N <= mod_4 * 2 + 1:
    print 'Yes'
elif N <= mod_4 * 2 + 1 + mod_2 and mod_2 >= 2:
    print 'Yes'
else:
    print 'No'

Submission status: Wrong Answer

Solution code:
tmp = input()
arr = [int(x) for x in input().split()]
nep = 0
krat = 0
for elem in arr:
    if elem % 4 == 0:
        krat += 1
        break
    if elem % 2 == 1:
        nep += 1
if krat - nep >= -1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

n = raw_input()
n = int(n)

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

count = 0

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

if count >= n-1:
    print "Yes"
else:
    print "No"

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(raw_input())
l = np.array(map(int, raw_input().split()))


mod_4 = len(np.where((l % 4 == 0))[0])
mod_2 = len(np.where(l % 4 == 2)[0])

if N <= mod_4 * 2 + 1:
    print 'Yes'
elif N <= mod_4 * 2 + 1 + mod_2 and mod_2 >= 2:
    print 'Yes'
else:
    print 'No'

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mul4 = 0
mul2 = 0
other = 0
for i in a:
    if i%4 == 0:
        mul4 += 1
    elif i%2 == 0:
        mul2 = 1
    else:
        other += 1

if mul4*2 >= (mul2+other) or other == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(raw_input())
a = map(int,raw_input().split(" "))
tmp = 1
for i in range(N-1):
	tmp *= a[i] * a[i+1]

if tmp % pow(4,N-1) == 0 and tmp >= pow(4,N-1):
	print "Yes"
else:
	print "No"

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mul4 = 0
mul2 = 0
other = 0
for i in a:
    if i%4 == 0:
        mul4 += 1
    elif i%2 == 0:
        mul2 = 1
    else:
        other += 1

if mul4*2 >= (mul2+other):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
'''input
4
1 2 3 4
'''
n = input()
a = map(int ,raw_input().split())
freq = 0
for i in a:
	if i%4 == 0:
		freq += 1
if freq >= n//2:
	print "Yes"
else:
	print "No"

Submission status: Time Limit Exceeded

Solution code:

import collections
n,ais = int(raw_input()), map(int, raw_input().split())
cc = collections.Counter()
for ai in ais:
	if ai % 4 == 0: cc[0] += 1
	elif ai % 2 == 0: cc[1] += 1
	else: cc[2] += 1

q = collections.deque([0])
h = {0:[2,1,0], 1:[1], 2:[0]} 
while(n):
	booll = False
	for u in h[q[-1]] + [-1]:
		if u == -1: boool = True
			
		if cc[u] > 0:
			q.append(u)
			cc[u] -=1
			n -=1
			break
	if booll: break

print 'Yes' if n == 0 else 'No'