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:
from collections import Counter

def main():
    N = int(input())
    an = sorted(map(int, input().split(' ')))
    
    # N = 6
    # an = [2, 7, 1, 8, 2, 8]
    # an = [1, 2, 3, 4]
    # an = [1, 4, 1]
    
    out = []
    
    for a in an:
        if a % 2 != 0:
            out.append('A')
        elif a % 4 != 0:
            out.append('B')
        else:
            out.append('C') 
    # print(out)
    counter = Counter(out)
    # print(counter)
    num_A = counter['A']
    num_B = counter['B']
    num_C = counter['C']
    # print(num_A, num_B, num_C)
    if not ('B' in out):
        if (num_C + 1) >= num_A:
            print('Yes')
            # return
        else:
            print('No')
            # return
    else:
        if num_B >= num_A:
            print('Yes')
        else:
            print('No')
        
        
        
        
    
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def main():
    N = int(input())
    an = sorted(map(int, input().split(' ')))
    
    # N = 6
    # an = [2, 7, 1, 8, 2, 8]
    # an = [1, 2, 3, 4]
    # an = [1, 4, 1]
    
    out = []
    
    for a in an:
        if a % 2 != 0:
            out.append('A')
        elif a % 4 != 0:
            out.append('B')
        else:
            out.append('C') 
    counter = Counter(out)
    # print(counter)
    num_A = counter['A']
    num_B = counter['B']
    num_C = counter['C']
    # print(num_A, num_B, num_C)
    if not ('B' in an):
        if (num_C + 1) >= num_A:
            print('Yes')
            # return
        else:
            print('No')
            # return
    else:
        if num_B >= num_A:
            print('Yes')
        else:
            print('No')
        
        
        
        
    
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def main():
    N = int(input())
    an = sorted(map(int, input().split(' ')))
    
    # N = 6
    # an = [2, 7, 1, 8, 2, 8]
    # an = [1, 2, 3, 4]
    # an = [1, 4, 1]
    
    out = []
    
    for a in an:
        if a % 2 != 0:
            out.append('A')
        elif a % 4 != 0:
            out.append('B')
        else:
            out.append('C') 
    counter = Counter(out)
    # print(counter)
    num_A = counter['A']
    num_B = counter['B']
    num_C = counter['C']
    # print(num_A, num_B, num_C)
    if not ('B' in an):
        if (num_C + 1) >= num_A:
            print('Yes')
            # return
        else:
            print('No')
            # return
    else:
        if num_B >= num_C:
            print('Yes')
        else:
            print('No')
        
        
        
        
    
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def main():
    # N = int(input())
    # an = sorted(map(int, input().split(' ')))
    
    # N = 6
    an = [2, 7, 1, 8, 2, 8]
    # an = [1, 2, 3, 4]
    an = [1, 4, 1]
    
    counter = Counter([a % 2 for a in an])
    num_even = counter[1]
    num_odd = counter[0]
    print('Odd:', num_odd, 'Even:', num_even)
    
    if num_even + num_odd < 5:
        for i in range(len(an)-1):
            a = an[i]
            b = an[i+1]
            if a * b % 4 != 0:
                print('No')
                return
    else:
        if not (num_odd + 1 >= num_even):
            print('No')
    
    print('Yes')
    return
    
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(lambda x: int(x)%4 , input().split()))

p = a.count(0)
q = a.count(2)
r = n-p-q

if r > p:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(lambda x: int(x)%4 , input().split()))
print(a)
p = a.count(0)
q = a.count(2)
r = n-p-q

if r > p:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

even = 0
multiple4 = 0
for a in A:
    if a % 4 == 0:
        multiple4 += 1
    elif a % 2 == 0:
        even += 1

#print(N-((even//2)*2)-multiple4, multiple4*2)
if N-((even//2)*2)-multiple4 <= multiple4*2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
cnt=[0,0]
for i in range(n):
    if a[i]%2==0:
        if a[i]%4==0:
            cnt[1]+=1
        else:
            cnt[0]+=1
if cnt[0]+2*cnt[1]+1>=n:
    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 range(n):
  if a[i]%4==0:
    c4+=1
  elif a[i]%2==0:
    c2+=1
    
x=c4*2+c2
if x>=n:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

### それぞれの数字が2の素因数をいくつ持つかを返す
def num_factor2(num):
    result = 0
    while num % 2 == 0:
        result += 1
        num /= 2
    return result

a_factor2 = map(num_factor2, a)

num_factor2_zero = 0
num_factor2_one = 0
num_factor2_twoormore = 0

for a_ in a_factor2:
    if a_ == 0:
        num_factor2_zero += 1
    elif a_ == 1:
        num_factor2_one += 1
    elif a_ >= 2:
        num_factor2_twoormore += 1

if num_factor2_zero <= num_factor2_twoormore or (num_factor2_zero + 1 <= num_factor2_twoormore and num_factor2_one == 0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(lambda x:int(x)%4,input().split()))
b0=a.count(0)
b1=a.count(1)+a.count(3)
b2=a.count(2)
if b2 > 0:
    print('Yes' if b0 >= b1  else 'No')
else:
    print('Yes' if b0 > b1 else 'No')

Submission status: Wrong Answer

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

### それぞれの数字が2の素因数をいくつ持つかを返す
def num_factor2(num):
    result = 0
    while num % 2 == 0:
        result += 1
        num /= 2
    return result

a_factor2 = map(num_factor2, a)

num_factor2_zero = 0
num_factor2_twoormore = 0

for a_ in a_factor2:
    if a_ == 0:
        num_factor2_zero += 1
    elif a_ >= 2:
        num_factor2_twoormore += 1

if num_factor2_zero - 1 <= num_factor2_twoormore:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

n -= c2
n += 1
f = n // 2

if c4 >= f:
    print('Yes')
    quit()
else:
    print('No')

Submission status: Wrong Answer

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

c1 = 0
c2 = 0
c4 = 0
for i in range(n):
    if a[i] % 4 == 0:
        c4 += 1
    elif a[i] % 2 == 0:
        c2 += 1
    elif a[i] == 1:
        c1 += 1
if c2 == n:
    print('Yes')
    quit()

if c2 != 0:
    c2 = (c2+1) % 2
n -= c2
f = n // 2

if c4 >= f:
    print('Yes')
    quit()
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
cnt4 = 0
cnt2= 0
for x in a:
    if x%4 == 0:cnt4 +=1
    elif x%2 == 0:cnt2 +=1
odd = n-cnt4 - cnt2
ok = cnt4+1 > odd
if cnt4+1 == odd:
    if cnt2 >0:ok = False
    
 

if ok:print('Yes')
else:print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
cnt4 = 0
cnt2= 0
for x in a:
    if x%4 == 0:cnt4 +=1
    elif x%2 == 0:cnt2 +=1
odd = n-cnt4 - cnt2
ok = cnt4+1 >= odd
    
 

if ok:print('Yes')
else:print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = len(a[a % 4 == 0])
a2 = len(a[a % 2 == 0])
a4n = len(a[a % 4 != 0]) - a2 

print("Yes" if (a4 + 1 + a2 % 2) >= a4n+1 else "No")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = len(a[a % 4 == 0])
a2n = len(a[a % 2 != 0])
a2 = len(a[a % 2 == 0])

print("Yes" if (a4 + 1 + a2 % 2) >= a2n+1 else "No")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = len(a[a % 4 == 0])
a2n = len(a[a % 2 != 0])
a2 = len(a[a % 2 == 0])

print("Yes" if a4 + 1 + a2 // 2 >= a2n+1 else "No")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = len(a[a % 4 == 0])
a2n = len(a[a % 2 != 0])
a2 = len(a[a % 2 == 0])

if a2 != 0:
  print("Yes" if a4 + 1 >= a2n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a2n else "No")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = a[a % 4 == 0]
a4n = a[a % 4 != 0]
a2 = len(list(set(a[a % 2 == 0].tolist()) - set(a4.tolist())))

if len(a4) + 1 + (a2 // 2) >= len(a4n) - (a2 // 2) * 2:
  print("Yes")

else:
  print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = a[a % 4 == 0]
a4n = a[a % 4 != 0]
a2 = len(list(set(a[a % 2 == 0].tolist()) - set(a4.tolist())))

if len(a4) + 1 + a2 // 2 >= len(a4n) - a2 // 2:
  print("Yes")

else:
  print("No")

Submission status: Wrong Answer

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

num_four = 0
num_two = 0
num_odd = 0
for i in range(N):
    if A[i] % 4 == 0:
        num_four += 1
    elif A[i] % 2 == 0:
        num_two += 1
    else:
        num_odd += 1

# print(num_four, num_two, num_odd)

v = num_four * 2
if num_two == 0:
    v += 1
if num_two >= 2:
    v += num_two
ans = 'Yes' if v >= N else 'No'
print(ans)

# 2 2 2 2 4 o 4 o 4 ... o 4 o
# o 4 o 4 .... o 4 o

Submission status: Wrong Answer

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

num_four = 0
num_two = 0
num_odd = 0
for i in range(N):
    if A[i] % 4 == 0:
        num_four += 1
    elif A[i] % 2 == 0:
        num_two += 1
    else:
        num_odd += 1

# print(num_four, num_two, num_odd)

v = num_four * 2 + 1
if num_two >= 2:
    v += num_two
ans = 'Yes' if v >= N else 'No'
print(ans)

# 2 2 2 2 o 4 o 4 o 4 ... o 4 o

Submission status: Wrong Answer

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

num_four = 0
num_two = 0
num_odd = 0
for i in range(N):
    if A[i] % 4 == 0:
        num_four += 1
    elif A[i] % 2 == 0:
        num_two += 1
    else:
        num_odd += 1

# print(num_four, num_two, num_odd)

v = num_four * 3
if num_two in [2, 3]:
    v += num_two
if num_two >= 4:
    v += num_two + (num_two - 2) // 2
ans = 'Yes' if v >= N else 'No'
print(ans)

# 2 2 o 2 2 o 2 2 o 2 2
# o 4 o o 4 o o 4 o  2 2 o 2 2

Submission status: Wrong Answer

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

num_four = 0
num_two = 0
num_odd = 0
for i in range(N):
    if A[i] % 4 == 0:
        num_four += 1
    elif A[i] % 2 == 0:
        num_two += 1
    else:
        num_odd += 1

# print(num_four, num_two, num_odd)

v = num_four * 3
if num_two >= 2:
    v += num_two + (num_two - 2) // 2
ans = 'Yes' if v >= N else 'No'
print(ans)

Submission status: Wrong Answer

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

num_four = 0
num_two = 0
num_odd = 0
for i in range(N):
    if A[i] % 4 == 0:
        num_four += 1
    elif A[i] % 2 == 0:
        num_two += 1
    else:
        num_odd += 1

# print(num_four, num_two, num_odd)

v = num_four * 3
if num_two >= 1:
    v += num_two + (num_two - 2) // 2
ans = 'Yes' if v >= N else 'No'
print(ans)

# v = num_four * 2
# if num_two >= 2:
#     v += num_two - 2
# ans = 'Yes' if v >= num_odd else 'No'
# print(ans)

# o 4 o o 4 o o 4 o
# 4の倍数はfour * 2個対処できる

# 2 2 o 2 2 o 2 2 o 2 2
# 2の倍数はtwo - 2個対処できる
# ただし4が隣にいる。すなわち4が奇数の時は一番左の2はなくても良い。

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
count1 = len([x for x in l if x%2 != 0])
count2 = len([x for x in l if x == 2])
count4 = len([x for x in l if x%4 == 0])

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

if count2 > 0:
    if count4 + 1 >= count1 + count2//2:
        print ("Yes")
        exit ()

print ("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
count2 = len([x for x in l if x == 2])
count4 = len([x for x in l if x%4 == 0])

if count4 >= len(l)//2:
    print ("Yes")
elif count4 + count2//2 >= len(l)//2:
    print ("Yes")
else:
    print ("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
four =0
two =0
odd = 0
       
for num in a:
  if num%4==0:
    four +=1
  if num%2==0:
    two += 1
       
two -= four
odd=N-four-two       
#print(four,two,odd)

if four >=1:
  if odd==four+1:
    if two==1:
      print("Yes")
    else:
      print("No")
  elif odd<four+1:
    print("Yes")  
  else:
    print("No")
else:
  if odd>=1:
    print("No")
  else:
    print("Yes")

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
four =0
two =0
odd = 0
       
for num in a:
  if num%4==0:
    four +=1
  if num%2==0:
    two += 1
       
two -= four
odd=N-four-two       
#print(four,two,odd)

if four >=1:
  if odd==four+1:
    if two!=1:
      print("Yes")
    else:
      print("No")
  elif odd<four+1:
    print("Yes")  
  else:
    print("No")
else:
  if odd>=1:
    print("No")
  else:
    print("Yes")

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
four =0
two =0
odd = 0
       
for num in a:
  if num%4==0:
    four +=1
  if num%2==0:
    two += 1
       
two -= four
odd=N-four-two       
#print(four,two,odd)

if odd==four+1:
  if two!=1:
    print("Yes")
  else:
    print("No")
elif odd<four+1:
  print("Yes")  
else:
  print("No")

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

Submission status: Wrong Answer

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

odd=0
ni=0
si=0
for x in a:
    if x%4==0:
        si+=1
    elif x%2==0:
        ni+=1
    else:
        odd+=1
ni=ni%2
if odd+ni-2*si<=0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
if c==0:
  print("Yes") if n==b else print("No")
elif b==0:
  print("Yes") if n<=3*c else print("No")
else:
  print("Yes") if n<=3*c+b-1 else print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
if b==0:
  print("Yes") if n<=3*c else print("No")
else:
  print("Yes") if n<=3*c+b-1 else print("No")

Submission status: Wrong Answer

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

if b[2] * 2 > b[0]:
    ans = "Yes"
elif b[2] * 2 == b[0]:
    if b[1] == 0:
        ans = "Yes"
    else:
        if b[0] == b[2] == 0:
            ans = "Yes"
        else:
            ans = "No"
else:
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
print("Yes") if n<= b+3*c-1 else print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
print("Yes") if n<= b+3*c else print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if b[2] * 2 > b[0]:
    ans = "Yes"
else:
    if b[0] % 2 == 0:
        if b[1] + (b[2] - b[0]//2) > 1:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if b[1] + (b[2] - (b[0] + 1)//2) > 1:
            ans = "Yes"
        else:
            ans = "No"

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]==0:
    print("No")
    sys.exit()
  if a[i]>1 and a[i]%2==0:
    if a[i]>3 and a[i]%4==0:
      c+=1
    else:
      b+=1
print("Yes") if n-(b//2)-3*c < 1 else print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
a = list(map(int, input().split()))
odd = deque([])
even = deque([])
even2 = deque([])
for i in a:
    if i % 4 == 0:
        even2.append(i)
    elif i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)
if len(odd)-1 <= len(even2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
print("Yes") if n-(b//2)-3*c<1 else print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
print("Yes") if n-b-2*c<1 else print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
print("Yes") if n-b-2*c<2 else print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]
for i in range(N):
    if a[i] % 4 == 0:
        a[i] = 0
    elif a[i] % 4 == 2:
        a[i] = 2
    else:
        a[i] = 1
counts = dict(Counter(a))
flag = False
if 1 in counts:
    if 0 in counts:
        if 2 in counts:
            if counts[0] >= counts[1]:
                flag = True
        
if 1 in counts:
    if 0 in counts:
        if 2 not in counts:
            if counts[0] == counts[1]-1:
                flag = True
    
if 1 not in counts:
    if 2 in counts:
        if counts[2] >= 2:
            flag = True
        else:
            if 0 in counts:
                flag = True
    
print('Yes' if flag==True else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]
for i in range(N):
    if a[i] % 4 == 0:
        a[i] = 0
    elif a[i] % 4 == 2:
        a[i] = 2
    else:
        a[i] = 1
counts = dict(Counter(a))
flag = True
if 1 in counts:
    if 0 in counts:
        if 2 in counts:
            if counts[0] < counts[1]:
                flag = False
    
if 2 in counts:
    if 0 in counts:
        if counts[2] ==1 and counts[0]==0:
            flag = False
            
if 1 in counts:
    if 0 not in counts:
        if 2 not in counts:
            flag = False
    
print('Yes' if flag==True else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
count4 = 0
count2 = 0
count0 = 0
for i in range(N):
  if a[i]%4 == 0:
    count4 += 1
  elif a[i]%2 == 0:
    count2 += 1
  else:
    count0 += 1


if count2 == 0:
  if count0 <= count4 + 1:
    print("Yes")
  else:
    print("NO")
else:
  if count0 <= count4:
    print("Yes")
  else:
    print("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
count = 0
count2 = 0
count0 = 0
for i in range(N):
  if a[i]%4 == 0:
    count += 1
  elif a[i]%2 == 0:
    count2 += 1
  else:
    count0 += 1
if count2 == 0:
  if count0 <= count + 1:
    print("Yes")
  else:
    print("NO")
else:
  if count0 <= count:
    print("Yes")
  else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def count(x):
    if x % 2 == 1:
        count = 0
    else:
        count = 0
        while True:
            if x % 2 == 0:
                count += 1
                x = x // 2
            else:
                break
    if count < 2:
        ans = 0
    else:
        ans = 1

    return ans


def main():
    n, *a = map(int, open(0).read().split())
    b = list(map(count, a))
    c, d = b.count(0), b.count(1)
    if c - 1 <= d:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
x=int(input())
y=list(map(int, input().split()))
a=0
b=0
c=0

for i in range(x):
	if y[i]%4==0:
		a=a+1
	elif y[i]%2==0:
		b=b+1
	else:
		c=c+1
a=a+(b//2)
b=b-(b//2)*2

if b+c-1>a:
	print('No')
else:
	print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
odd=0
four=0
for i in range(N):
  if a[i]%4==0:
    four+=1
  elif a[i]%2!=0:
    odd+=1
if four>=odd or four+odd==N:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
odd=0
four=0
for i in range(N):
  if a[i]%4==0:
    four+=1
  elif a[i]%2!=0:
    odd+=1
if four<odd:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
four =0
two =0
imp = 0
       
for num in a:
  if num%4==0:
    four +=1
  if num%2==0:
    two += 1
       
two -= four
imp=N-four-two
       
if four>=N//2:
  print("Yes")
else:
  if two >=imp:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
aList = [int(i) for i in input().split()]
d = {1: 0, 2: 0, 4: 0}

for a in aList:
  if a % 2 == 0:
    d[2] += 1
  elif a % 4 == 4:
    d[4] += 1
  else:
    d[1] += 1
    
ans = "No"
if d[1] <= d[4]:
  ans = "Yes"
elif d[1] - d[4] == 1:
  if d[2] == 0:
    ans = "Yes"
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {0:0,1:0,2:0}
for a in list(map(int,input().split())):
  if a%2 == 0 :
    if a%4 == 0 :
      d[2]+=1
    else:
      d[1]+=1
  else:
    d[0]+=1
## 0と4だけの時はこれでok
if d[1] == 0:
  if d[0] <= d[2]+1:
    print("yes")
  else:
    print("No")
else:
  if d[0] + (1 if d[1]>0 else 0 ) <= d[2]+1:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {0:0,1:0,2:0}
for a in list(map(int,input().split())):
  if a%2 == 0:
    if a%4==0:
      d[2]+=1
    else:
      d[1]+=1
  else:
    d[0]+=1
if d[0] <= (d[2]+1 if d[2]>0 else 0) :
  if d[1] > 1:
    print("Yes")
  elif d[0] + d[1] <= (d[2]+1 if d[2]>0 else 0):
    print("Yes")
  else:
    print("No")
elif d[0]+d[2]==0:
    print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
count_4=0
count_2=0
count_1=0
for i in A:
    if i%4==0:
        count_4+=1
    elif i%2==0:
        count_2+=1
    else:
        count_1+=1
if count_2<2:
    if count_1+count_2<count_4:
        print("Yes")
    else:
        print("No")
else:
    if count_1<count_4:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
count_4=0
count_2=0
count_1=0
for i in A:
    if i%4==0:
        count_4+=1
    elif i%2==0:
        count_2+=1
    else:
        count_1+=1
if count_2<2:
    if count_1+count_2<=count_4:
        print("Yes")
    else:
        print("No")
else:
    if count_1<=count_4:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
count_4=0
count_2=0
count_1=0
for i in A:
    if i%4==0:
        count_4+=1
    elif i%2==0:
        count_2+=1
    else:
        count_1+=1
if count_2<2:
    if count_1+count_2-1<=count_4:
        print("Yes")
    else:
        print("No")
else:
    if count_1-1<=count_4:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

f=t=0
for x in X:
    if x % 4==0:
        f += 1
    elif x % 2==0:
        t += 1
if 2*f+1+t>=N:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

ans = False
if num_mul2 == 0:
    if num_mul4 >= num_odd + 1:
        ans = True
else:
    if num_mul4 >= num_odd:
        ans = True
print('Yes' if ans else 'No')

Submission status: Wrong Answer

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

ans = False
if num_mul2 == 0:
    if num_mul4 >= num_odd + 1:
        ans = True
else:
    if num_mul4 >= num_odd:
        ans = True
print('Yes' if ans else 'No')

Submission status: Wrong Answer

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

ans = False
if num_mul2 == 0:
    if num_mul4 >= num_odd + 1:
        ans = True
else:
    if num_mul4 >= num_odd:
        ans = True
print('Yes' if ans else 'No')

Submission status: Wrong Answer

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

if num_odd <= num_mul4:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
k = []
k_2 = []
k_4 = []

for i in l:
    if i % 4 == 0:
        k_4.append(i)
    elif i % 2 == 0:
        k_2.append(i)
    else:
        k.append(i)


if len(k_4) >= len(k):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
k = []
k_2 = []
k_4 = []

for i in l:
    if i % 4 == 0:
        k_4.append(i)
    elif i % 2 == 0:
        k_2.append(i)
    else:
        k.append(i)


if len(k_4) >= len(k)-1:
    print('Yes')
else:
    print('No')