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
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in range(N):
  if a[i] % 4 == 0:
    c4 += 1
  elif a[i] % 2 == 0:
    c2 += 1
f = 1
t = (N - 1 - c2 // 2)
#print(c2, c4, t)
if t // 2 + t % 2 > 0 and c4 == 0: f = 0
if c2 == N and c2 % 2 == 0:
  print("Yes")
  exit(0)
if t // 2 + t % 2 <= c4 and f:
  print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in range(N):
  if a[i] % 4 == 0:
    c4 += 1
  elif a[i] % 2 == 0:
    c2 += 1
f = 1
t = (N - 1 - c2 // 2)
#print(c2, c4, t)
if t // 2 + t % 2 > 0 and c4 == 0: f = 0
if c2 == N:
  print("Yes")
  exit(0)
if t // 2 + t % 2 <= c4 and f:
  print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in range(N):
  if a[i] % 4 == 0:
    c4 += 1
  elif a[i] % 2 == 0:
    c2 += 1
f = 1
t = (N - 1 - c2 // 2)
#print(c2, c4, t)
if t // 2 + t % 2 > 0 and c4 == 0: f = 0
if t // 2 + t % 2 <= c4 and f:
  print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in range(N):
  if a[i] % 4 == 0:
    c4 += 1
  elif a[i] % 2 == 0:
    c2 += 1
f = 1
if (N - 1 - c2 // 2) > 0 and c4 == 0: f = 0
if (N - 1 - c2 // 2) // 2 <= c4 and f:
  print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in range(N):
  if a[i] % 4 == 0:
    c4 += 1
  elif a[i] % 2 == 0:
    c2 += 1
f = 0
if (N - c2 + c2 % 2) > 0 and c4 > 0: f = 1
if (N - c2 + c2 % 2) // 2 <= c4 and f:
  print("Yes")
else: print("No")

Submission status: Wrong Answer

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

k2=k4=0

for ai in a:
    if ai%4==0:
        k4+=1
    elif ai%2==0:
        k2+1

print('Yes' if k4*2+k2>=N else 'No')

Submission status: Wrong Answer

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

k2=k4=0

for ai in a:
    if ai%4==0:
        k4+=1
    elif ai%2==0:
        k2+1

print('Yes' if k4*2+1+k2>=N else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
#4で割れる数、2で割れるかず、そうでない数をそれぞれ数えるためのカウント
count_4 = 0
count_2 = 0
count = 0
for i in range(n):
    if a[i] % 4 == 0:
        count_4 += 1
    elif a[i] % 2 == 0:
        count_2 += 1
    else:
        count += 1
if count_4 >= count:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

cnt = 0
cnt2 = 0

for i in range(N):
    if a[i] % 2 == 0 and a[i] % 4 != 0:
        cnt2 += 1
    if a[i] % 4 == 0:
        cnt += 1

t = max(0, N - 3 * cnt)
if t == 0: print('Yes') 
if t == 1:
    if cnt2 <= 1:
        print('No')
    else:
        print('Yes')
if t >= 2:
    if cnt2 >= t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

cnt = 0
cnt2 = 0

for i in range(N):
    if a[i] % 2 == 0 and a[i] % 4 != 0:
        cnt2 += 1
        if cnt2 == 2:
            cnt += 1
            cnt2 = 0
    if a[i] % 4 == 0:
        cnt += 3

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

Submission status: Wrong Answer

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

cnt1,cnt2,cnt3=0,0,0 # 4の倍数、2の倍数
for a in A:
  if a%4==0:
    cnt1+=1
  elif a%2==0:
    cnt2+=1
cnt3+=cnt2//2
print('Yes') if cnt3>=n//2 else print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
s=sum(i%2==0 for i in l)
if s>=n//2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
s=sum(i%2==0 for i in l)
if s>=n/2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

cnt = 0
cnt2 = 0
cnt3 = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt += 1
    elif a[i] == 2:
        cnt2 += 1
    else:
        cnt3 += 1

if cnt2 == 0:
    print('Yes' if cnt3 <= cnt+1 else 'No')
else:
    print('Yes' if cnt3 <= cnt else 'No')

Submission status: Wrong Answer

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

cnt = 0
cnt2 = 0
cnt3 = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt += 1
    elif a[i] == 2:
        cnt2 += 1
    elif 2 * a[i] % 4 == 0:
        cnt3 += 1

if cnt2 >= cnt3:
    N -= cnt3
    cnt2 -= cnt3
if cnt2 >= 2:
    N -= cnt2//2*2


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

Submission status: Wrong Answer

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

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

if cnt2 >= 2:
    N -= cnt2

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

Submission status: Wrong Answer

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

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

if cnt2 >= 2:
    N -= cnt2//2

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

Submission status: Wrong Answer

Solution code:
# C - 4-adjacent

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

a_4_multi, a_2_multi, a_odd = [], [], []

for x in a:
    if x%2 == 1:
        a_odd.append(x)
    elif x%4 != 0:
        a_2_multi.append(x)
    else:
        a_4_multi.append(x)
        
if len(a_odd) - 1 <= len(a_4_multi) and len(a_2_multi)%2 == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import bisect
def main():
    n=int(input())
    a=list(map(int,input().split((' '))))
    two=0
    four=0
    for i in a:
        if i%4==0:
            four += 1
        elif i%2==0:
            two += 1
    if n-two//2 <=2*four +1:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=list(map(int,input().split()))
cnt4=0
cnt2=0
for i in range(n):
  if a[i]%4==0:
    cnt4+=1
  elif a[i]%2==0:
    cnt2+=1
if n-(2*cnt4)<=cnt2:
    print('Yes')
    sys.exit()
else:
    print('No')
    sys.exit()

Submission status: Wrong Answer

Solution code:
import itertools

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

count2 = 0
b = 0
for i in a:
    if i % 4 == 0:
        count2 += 1
    elif i % 2 == 0:
        b += 1
        if b == 2:
            count2 += 1
            b = 0
        
    if count2 >= N-2:
        break

ans = 'Yes' if count2>= N-2 else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

count2 = 0
b = 0
for i in a:
    if i % 4 == 0:
        count2 += 1
    elif i % 2 == 0:
        b += 1
        if b == 3:
            count2 += 1
            b = 0
        
    if count2 >= N/3:
        break

ans = 'Yes' if count2>= N/3 else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

count2 = 0
for i in a:
    if i % 4 == 0:
        count2 += 1
    elif i % 2 == 0:
        count2 += 0.5
        
    if count2 >= N/3:
        break

ans = 'Yes' if count2>= N/3 else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

count2 = 0
for i in a:
    if i % 4 == 0:
        count2 += 1
        if count2 >= N/3:
            break

ans = 'Yes' if count2>= N/3 else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

count2 = 0
for i in itertools.combinations(a,2):
    if (i[0]*i[1]) % 4 == 0:
        count2 += 1
        if count2 >= N/3:
            break

ans = 'Yes' if count2>= N/3 else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

count2 = 0
for i in itertools.combinations(a,2):
    if (i[0]*i[1]) % 4 == 0:
        count2 += 1
        if count2 >= N - 1:
            break

ans = 'Yes' if count2>= N - 1 else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

count2 = 0
for i in itertools.combinations(a,2):
    if (i[0]*i[1]) % 4 == 0:
        count2 += 1

ans = 'Yes' if count2>= N - 1 else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

number2 = li_a.count(2)

wk = (n - (number2 // 2)) // 2

if len([x for x in li_a if x % 4 == 0]) + (number2 // 2) >= wk:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

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

wk = (n - (li_a.count(2) // 2)) // 2

if len([x for x in li_a if x % 4 == 0]) >= wk:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

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

wk = n // 2

if len([x for x in li_a if x % 4 == 0]) + (li_a.count(2) // 2) >= wk:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

four_count,two_count = 0,0
for i in range(N):
  if(A[i]%4 == 0): four_count += 1
  elif(A[i]%2 == 0): two_count += 1

#(方針）4の倍数Nつで「(2N+1)つの数の数列」に関して目標達成可 
#2の倍数（4の倍数でない）Nつで「Nつの数の数列」に関して目標達成可
#→この方針はWA
#この方針だと	1414122 で Yesになってしまう(正答はNo、[12]の部分があるので)
#ひとまとまりの2 = 1つの1としてカウント

if(two_count <= 1): Need = N
else: Need = N - two_count + 1
count = 0
if(four_count>=1): count += 2*four_count + 1
if(count >= Need): print('Yes')
else: print('No')

Submission status: Wrong Answer

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

four_count,two_count = 0,0
for i in range(N):
  if(A[i]%4 == 0): four_count += 1
  elif(A[i]%2 == 0): two_count += 1

#(方針）4の倍数Nつで「(2N+1)つの数の数列」に関して目標達成可 
#2の倍数（4の倍数でない）Nつで「Nつの数の数列」に関して目標達成可
count = 0
if(two_count>=2): count += two_count
if(four_count>=1): count += 2*four_count + 1
if(count >= N): print('Yes')
else: print('No')

Submission status: Wrong Answer

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

four_count,two_count = 0,0
for i in range(N):
  if(A[i]%4 == 0): four_count += 1
  elif(A[i]%2 == 0): two_count += 1

#(方針）4の倍数1つで「3つの数の数列」に関して目標達成可 
#2の倍数（4の倍数でない）Nつで「Nつの数の数列」に関して目標達成可
count = 0
if(two_count>=2): count += two_count
count += four_count*3

if(count >= N): print('Yes')
else: print('No')

Submission status: Wrong Answer

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

four_count,two_count = 0,0
for i in range(N):
  if(A[i]%4 == 0): four_count += 1
  elif(A[i]%2 == 0): two_count += 1

#(方針）4の倍数1つで「3つの数の数列」に関して目標達成可 
#2の倍数（4の倍数でない）2つで「2つの数の数列」に関して目標達成可
#2の倍数（4の倍数でない）3つで「3つの数の数列」に関して目標達成可
count = 0
if((two_count%2 == 0)or(two_count == 1)): count += (two_count//2)*2
else: count += (two_count//2)*2 + 1
count += four_count*3

if(count >= N): print('Yes')
else: print('No')

Submission status: Wrong Answer

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

four_count,two_count = 0,0
for i in range(N):
  if(A[i]%4 == 0): four_count += 1
  elif(A[i]%2 == 0): two_count += 1

#(方針）4の倍数1つで「3つの数の数列」に関して目標達成可 
#2の倍数（4の倍数でない）2つで「2つの数の数列」に関して目標達成可
#2の倍数（4の倍数でない）3つで「3つの数の数列」に関して目標達成可
count = 0
if((two_count%2 == 0)or(two_count == 1)): count += two_count//2
else: count += (two_count//2)*2 + 1
count += four_count*3

if(count >= N): print('Yes')
else: print('No')

Submission status: Wrong Answer

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

four_count,two_count = 0,0
for i in range(N):
  if(A[i]%4 == 0): four_count += 1
  elif(A[i]%2 == 0): two_count += 1

#(方針）4の倍数1つで「3つの数の数列」に関して目標達成可 
#2の倍数（4の倍数でない）2つで「2つの数の数列」に関して目標達成可
#2の倍数（4の倍数でない）3つで「3つの数の数列」に関して目標達成可
if(N <= (four_count*3 + (two_count//2)*2)): 
  print('Yes')
elif(two_count%2 == 1):
  if(N <= (four_count*3 + (two_count//2)*2 + 1)): 
   print('Yes')  
else: print('No')

Submission status: Wrong Answer

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

four_count,two_count = 0,0
for i in range(N):
  if(A[i]%4 == 0): four_count += 1
  elif(A[i]%2 == 0): two_count += 1

#(方針）4の倍数1つで「3つの数の数列」に関して目標達成可 
#2の倍数（4の倍数でない）2つで「2つの数の数列」に関して目標達成可
if(N <= (four_count*3 + (two_count//2)*2)): print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
# ABC069 C - 4-adjacent
import math
N = int(input())
A = list(map(float,input().split()))

odd = 0.0
even = 0.0
m_4 = 0.0

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

if even == 0:
    if odd <= m_4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if odd <= m_4:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

B = [0, 0, 0]
for a in A:
  if a % 4 == 0:
    B[2] += 1
  elif a % 2 == 0:
    B[1] += 1
  else:
    B[0] += 1
print ("Yes" if B[0] <= B[2] or N == 3 and B[0] == 2 and B[2] == 1 else "No")

Submission status: Wrong Answer

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

cnt1,cnt2=0,0
for i in a:
    if i%2!=0:
        cnt1+=1
    if i%4==0:
        cnt2+=1
print('Yes' if cnt2>=cnt1 or (len(a)==3 and cnt2+1>=cnt1) else 'No')

Submission status: Wrong Answer

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

c_4=sum(map(lambda x:x%4==0,A))
c_2=sum(map(lambda x:x%2==0,A))

print('Yes' if (N-c_2+c_4)-c_4<3-2*(c_4==0) else 'No')

Submission status: Wrong Answer

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

c_4=sum(map(lambda x:x%4==0,A))
c_2=sum(map(lambda x:x%2==0,A))

print('Yes' if (N-c_2+c_4)-c_4<3 else 'No')

Submission status: Wrong Answer

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

c_4=sum(map(lambda x:x%4==0,A))
c_2=sum(map(lambda x:x%2==0,A))

print('Yes' if (N-c_2)-c_4<0 else 'No')

Submission status: Wrong Answer

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

c_4=sum(map(lambda x:x%4==0,A))
c_2=sum(map(lambda x:x%2==0,A))

print('Yes' if (N-c_2)-c_4<2 else 'No')

Submission status: Wrong Answer

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

c_4=sum(map(lambda x:x%4==0,A))
c_2=sum(map(lambda x:x%2==0,A))

print('Yes' if (N-c_2)-c_4<1 else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if cnt2 == 0:
    if cnt3 <= cnt + 1:
        print('Yes')
    else:
        print('No')
else:
    if cnt3 <= cnt:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
cnt = 0
cnt2 = 0
cnt3 = 0
for i in a:
    if i % 4 == 0:
        cnt += 1
    if i == 2:
        cnt2 += 1
    else:
        cnt3 += 1

if cnt2 == 0:
    if cnt3 <= cnt + 1:
        print('Yes')
    else:
        print('No')
else:
    if cnt3 <= cnt:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
cnt = 0
cnt2 = 0
for i in a:
    if i % 4 == 0:
        cnt += 1
    if i == 2:
        cnt2 += 1
if cnt2 == 0:
    if N - cnt <= cnt + 1:
        print('Yes')
    else:
        print('No')
else:
    if N - cnt - cnt2 <= cnt:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
cnt = 0
cnt2 = 0
for i in a:
    if i % 4 == 0:
        cnt += 1
    if i == 2:
        cnt2 += 1
if cnt2 == 0:
    if N - cnt <= cnt + 1:
        print('Yes')
    else:
        print('No')
else:
    if N - cnt - cnt2 + 1 <= cnt + 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
odd = 0
even = 0
four = 0

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

if ((odd == 1 and four < 1) or (odd >= 2 and four < odd - 1) or (odd >= 2 and
n - four - odd != 0 and  n - four - odd < 2)):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

tmp = (N // 3)
if N % 3 != 0:
    tmp += 1
cnt += cnt2 // 2

if tmp <= 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 += 1

tmp = (N // 3)
if N % 3 != 0:
    tmp += 1

if tmp <= cnt:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a0 = 0
a2 = 0
a4 = 0

for i in a:
    if i % 4 == 0:
        a4 += 1
    elif i % 2 == 0:
        a2 += 1
    else:
        a0 += 1

if N == 3 and a4 >= 1:
    print('Yes')
elif N == 2 and (a4 > 0 or a2 == 2):
    print('Yes')
elif a4 >= a0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a0 = 0
a2 = 0
a4 = 0

for i in a:
    if i % 4 == 0:
        a4 += 1
    elif i % 2 == 0:
        a2 += 1
    else:
        a0 += 1

if N == 3 and a4 >= 1:
    print('Yes')
elif a4 >= a0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N//2<=n1+n2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

if N<=3*n:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
num = 0
n2,n3 = 0,0
for i in range(n):
    if li[i]%4 == 0:
        num += 1
    elif li[i] == 2:
        n2 += 1
    elif li[i]%4 != 0 and li[i]%2 == 0:
        n3 += 1
if n == 2:
    if num == 1 or n2 == 2:
        print("Yes")
    else:
        print("No")
elif n >=3:
    if n2%2 == 0:
        if num >= n//2 or num  >= (n - n2//2)//2:
            print("Yes")
        else:
            print("No")
    elif n2%2 == 1:
        if num >= n//2 or num  >= (n - n2//2-1)//2:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
num = 0
n2 = 0
for i in range(n):
    if li[i]%4 == 0:
        num += 1
    elif li[i] == 2:
        n2 += 1
if n == 2:
    if num == 1 or n2 == 2:
        print("Yes")
    else:
        print("No")
elif n >=3:
    if num >= n//2 or num  >= (n - n2//2)//2:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int, input().split()))
yon = 0
ni  = 0
ki = 0
for a in li:
    if a % 4 == 0:
        yon += 1
    if a % 4 == 2:
        ni += 1
    else:
        ki += 1

if ni > 0:
    if yon >= ki:
        print('Yes')
    else:
        print('No')
elif ni == 0:
    if yon >= ki-1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int, input().split()))
yon = 0
ni  = 0
ki = 0
for a in li:
    if a % 4 == 0:
        yon += 1
    if a % 2 == 0:
        ni += 1
    else:
        ki += 1

if yon >= ki-1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int, input().split()))
yon = 0
ni  = 0
ki = 0
for a in li:
    if a % 4 == 0:
        yon += 1
    if a % 2 == 0:
        ni += 1
    else:
        ki += 1

if yon >= ki:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
num4 = 0
num1 = 0
for i in a:
    if i % 4 == 0:
        num4 += 1
        continue
    if i % 2 == 1:
        num1 += 1
if num4 >= num1:
    print("Yes")
elif num4 + 1 == num1 and (num4 + num1) % 2 == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

o = 0
f = 0
t = 0
for i in a:
  if i % 2 == 1:
    o += 1
  if i % 4 == 0:
    f += 1
  if i % 4 == 2:
    t += 1
if f >= o-1 and t % 2 == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

for ai in a:
    if ai % 4 == 0:
        counter[4] += 1
    elif ai % 2 == 0:
        counter[2] += 1
    else:
        counter[1] += 1

ans = 'No'
if counter[1] == counter[4]:
    ans = 'Yes'
if counter[2] == 0:
    if counter[1] == counter[4] + 1:
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

for ai in a:
    if ai % 4 == 0:
        counter[4] += 1
    elif ai % 2 == 0:
        counter[2] += 1
    else:
        counter[1] += 1

ans = 'No'
if counter[2] == 0:
    if counter[1] == counter[4] + 1:
        ans = 'Yes'
else:
    if counter[1] == counter[4]:
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
def d(n):
  if n % 2 == 1:
    return 0
  elif n % 4 == 0:
    return 2
  elif n % 2 == 0:
    return 1
  else:
    return 0
  
dic = {0:0, 1:0, 2:0}
for a in [int(x) for x in input().split()]:
  dic[d(a)] += 1
ret = 'No'
if dic[0] <= dic[2] + 1:
  ret = 'Yes'
print(ret)

Submission status: Wrong Answer

Solution code:
N,*A=map(int,open(0).read().split());l=[0]*4
for a in A:l[a&3]+=1
o=l[1]+l[3];print("YNeos"[o>1+l[0]or o-1==l[0]==0::2])

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
v1 = 0
v2 = 0
v4 = 0
for i in a:
    if i % 4 == 0:
        v4 += 1
    elif i % 2 == 0:
        v2 += 1
    else:
        v1 += 1

if (v4 >= v1) and (v2 >= 2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

bi = [a for a in A if a % 2 == 0]
qu = [b for b in bi if b % 4 == 0]

num_4 = len(qu)
num_2 = len(bi) - num_4

if num_2 >= 1:
	if N-num_2 <= num_4*2 or N <= num_4*2+1:
		print("Yes")
	else:
		print("Np")
else:
	if N-num_2 <= num_4*2+1:
		print("Yes")
	else:
		print("Np")

Submission status: Wrong Answer

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

bi = [a for a in A if a % 2 == 0]
qu = [b for b in bi if b % 4 == 0]

num_4 = len(qu)
num_2 = len(bi) - num_4

if num_2 >= 1:
	if N-num_2 <= num_4*2:
		print("Yes")
	else:
		print("Np")
else:
	if N-num_2 <= num_4*2+1:
		print("Yes")
	else:
		print("Np")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = LI()
f = len([i for i in L if not i % 4])
t = len([j for j in L if not j % 2]) - f
if n > t + f * 2:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = LI()
f = sum([i for i in L if not i % 4])
t = sum([j for j in L if not j % 2]) - f
if n > t + f * 2 + 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())

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

odd = []
even2 = []
even4 = []

for ai in a:
    if ai%4==0:even4.append(ai)
    elif ai%2==0:even2.append(ai)
    else:odd.append(ai)
if len(even4)==len(odd):print('Yes')
elif len(even4)+1==len(odd) and len(even2)==0:print('Yes')
else:print('No')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

    count_4 = 0
    count_2 = 0
    for i in range(N):
        if a[i]%4 == 0:
            count_4 += 1
        elif a[i]%2 == 0:
            count_2 += 1
    odd = N - count_4 - count_2
    if odd <= count_4:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

    count_4 = 0
    count_2 = 0
    for i in range(N):
        if a[i]%4 == 0:
            count_4 += 1
        elif a[i]%2 == 0:
            count_2 += 1
    odd = N - count_4 - count_2
    if odd - 1 <= count_4:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1

if a_2 > 0:
  print('Yes' if a_4 >= a_1+1 else 'No')
else:
  print('Yes' if (a_4+1) >= a_1 else 'No')

Submission status: Wrong Answer

Solution code:
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1

if a_2 > 0:
  print('Yes' if a_4 >= a_1+a_2 else 'No')
else:
  print('Yes' if (a_4+1) >= a_1 else 'No')

Submission status: Wrong Answer

Solution code:
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1

if a_2 > 0:
  print('Yes' if (a_4+1) >= a_1+a_2 else 'No')
else:
  print('Yes' if a_4 >= a_1 else 'No')

Submission status: Wrong Answer

Solution code:
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1

if a_4 > 0: a_4 += 1

print('Yes' if a_4 >= a_1+a_2 else 'No')