Problem:


Score : 400 points

Problem Statement

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

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

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

Determine whether Snuke can achieve his objective.

Constraints

2 ≤ N ≤ 10^5

a_i is an integer.

1 ≤ a_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

Sample Input 1

3
1 10 100

Sample Output 1

Yes

One solution is (1, 100, 10).

Sample Input 2

4
1 2 3 4

Sample Output 2

No

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

Sample Input 3

3
1 4 1

Sample Output 3

Yes

The condition is already satisfied initially.

Sample Input 4

2
1 1

Sample Output 4

No

Sample Input 5

6
2 7 1 8 2 8

Sample Output 5

Yes



Sample input:
3
1 10 100


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
N,*A=map(int,open(0).read().split())

x4 = 0
x2 = 0
x1 = 0

for i in range(N):
  if A[i]%4 == 0:
    x4+=1
  elif A[i]%2 == 0:
    x2+=1
  else:
    x1 +=1
if x1 <= x4:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

odd = n - div - even
if even:
    odd += 1
if div:
    div += 1

if div >= odd:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
al = list(map(int, input().split()))
four, two, other = 0, 0, 0

for a in al:
    if a%4 == 0:
        four += 1
    elif a == 2:
        two += 1
    else:
        other += 1

print('Yes' if four+1 >= other+two%2 else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
al = list(map(int, input().split()))
four, two, other = 0, 0, 0

for a in al:
    if a%4 == 0:
        four += 1
    elif a == 2:
        two += 1
other = n - four - two

if four+1 >= two%2 + other:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
al = list(map(int, input().split()))
four, two = 0, 0

for a in al:
    if a%4 == 0:
        four += 1
    elif a == 2:
        two += 1

if (n-two//2)//2 <= four:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
al = list(map(int, input().split()))
four, two = 0, 0

for a in al:
    if a%4 == 0:
        four += 1
    elif a == 2:
        two += 1

if (n-two//2*2)//2 <= four:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

four, two = 0, 0

for a in al:
    if a%4 == 0:
        four += 1
    elif a == 2:
        two += 1

if n%2 == 0:
    if n-four <= four + two//2*2:
        print('Yes')
    else:
        print('No')
else:
    if n-four-1 <= four + two//2*2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

four, two = 0, 0

for a in al:
    if a%4 == 0:
        four += 1
    elif a == 2:
        two += 1

if (n -two//2*2 + two%2)//2 <= four:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

four, two = 0, 0

for a in al:
    if a%4 == 0:
        four += 1
    elif a == 2:
        two += 1

if (n-two//2*2)//2 <= four:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if 2*cnt4 < (n - cnt2 // 2 - cnt4):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
A = list(map(int,input().split()))
k = 0
l = 0
m = 0
for i in range(N):
    if A[i] % 4 == 0:
        m += 1
    elif A[i] % 2 == 0:
        l += 1
    else:
        k += 1
if N <= 3:
    if m > 0:
        print('Yes')
        sys.exit()
    if k > 0:
        print('No')
        sys.exit()
    else:
        print('Yes')
        sys.exit()
if k <= m:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if cnt >= (n // 2):
    print("Yes")
    exit()
if cnt + (cnttwo // 2) >= (n // 2):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
odd = 0
even = 0
even4 = 0

for num in A:
    if num % 2 == 1:
        odd += 1
    else:
        even += 1
    if num % 2 == 0 and num % 4 != 0:
        even4 += 1
    
if even == 0 or odd <= even4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
aa = list(map(int, input().split()))
c1 = 0 # odd 
c2 = 0 
c4 = 0
la = len(aa)

for a in aa:
  if a % 4 == 0:
    c4 += 1
  elif a % 2 == 0:
    c2 += 1
  else:
    c1 += 1
    
if c1 == 0:
  print('Yes')
  exit()

elif c4 >= c1-1:
  print('Yes')
  exit()
  
print('No')

Submission status: Wrong Answer

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

for a in aa:
  if a % 4 == 0:
    c4 += 1
  elif a % 2 == 0:
    c2 += 1
if c2 == 0 and c4 == 0:
    print('No')
    exit()

if c4 + c2 == n:
  print('Yes')

elif n/2 -1 < c4 < n/2 + 1:
  print('Yes')
  
elif n > 5 and n % 4 == 2:
  for i in range(6, n+1 , 4):
    for j in range(n // 4 + 2):
      if c4 == i/2 - j and c2 == 2 * j:
        print('Yes')
        
elif n > 10 and n % 4 ==3:
  for i in range(11, n+1, 4):
    if c2 + c4 == i - 3:
      print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

for a in aa:
  if a % 4 == 0:
    c4 += 1
  elif a % 2 == 0:
    c2 += 1
if c2 == 0 and c4 == 0:
    print('No')
    exit()

if c4 + c2 == n:
  print('Yes')

elif n/2 -1 < c4 < n/2 + 1:
  print('Yes')
  
elif n > 5 and n % 4 == 2:
  for i in range(6, n+1 , 4):
    for j in range(n // 4 + 2):
      if c4 == i/2 - j and c2 == 2 * j:
        print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

for a in aa:
  if a % 4 == 0:
    c4 += 1
  elif a % 2 == 0:
    c2 += 1
if c2 == 0 and c4 == 0:
    print('No')
    exit()

if c4 + c2 == n:
  print('Yes')

elif n/2 -1 < c4 < n/2 + 1:
  print('Yes')
  
elif n % 4 == 2:
  if c4 == n / 2 - 1 and c2 == 2:
    print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

for a in aa:
  if a % 4 == 0:
    c4 += 1
  elif a % 2 == 0:
    c2 += 1
  else:
    print('No')
    exit()

if c4 + c2 == n:
  print('Yes')

elif n/2 -1 < c4 < n/2 + 1:
  print('Yes')
  
elif n % 4 == 2:
  if c4 == n / 2 - 1 and c2 == 2:
    print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

c_4=0
even=0
odd=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    even+=1
  else:
    odd+=1
  
if even==0 and odd-1 <= c_4:
  ans="Yes"
else:
  ans="No"
  
if even>0 and odd <= c_4:
  ans="Yes"
else:
  ans="No"

print(ans)

Submission status: Wrong Answer

Solution code:
#n=int(input())
#l=list(map(int,input().split()))
n=3
l=[1, 4, 1]

c_4=0
even=0
odd=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    even+=1
  else:
    odd+=1
  
if even==0 and odd-1 <= c_4:
  ans="Yes"
else:
  ans="No"
  
if even>0 and odd <= c_4:
  ans="Yes"

print(ans)

Submission status: Wrong Answer

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

c_4=0
even=0
odd=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    even+=1
  else:
    odd+=1
  
if even==0 and odd <= c_4:
  ans="Yes"
else:
  ans="No"
  
if even>0 and odd <= c_4:
  ans="Yes"
else:
  "No"

print(ans)

Submission status: Wrong Answer

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

c_4=0
c_2=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    c_2+=1


if c_2==1:
  num=n
else:
  num=n-c_2-1  
  
if num//2 <= c_4:
  ans="Yes"
elif c_2==n:
  ans="Yes"
else:
  ans="No"
  
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

c_4=0
c_2=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    c_2+=1


if c_2==1:
  num=n
else:
  num=n-c_2  
  
if math.ceil(num/2) <= c_4:
  ans="Yes"
elif c_2==n:
  ans="Yes"
else:
  ans="No"
  
print(ans)

Submission status: Wrong Answer

Solution code:
print("Yes")

Submission status: Wrong Answer

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

c_4=0
c_2=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    c_2+=1

if c_2==1:
  num=n
else:
  num=n-c_2  
  
if num//2 <= c_4:
  ans="Yes"
elif c_2==n:
  ans="Yes"
else:
  ans="No"
  
print(ans)

Submission status: Wrong Answer

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

c_4=0
c_2=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    c_2+=1

if c_2==1:
  num=n
else:
  num=n-c_2
  
if num//2 <= c_4:
  ans="Yes"
else:
  ans="No"
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
baisu = [0,0,0]
flag = 0

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

if baisu[0] == 0 and (baisu[2] != 0 or baisu[1] != 1):
    flag = 1

while baisu[2] != 0:
    baisu[2] -= 1
    baisu[0] -= 2

if baisu[1] > 0:
    baisu[0] += 1

if baisu[0] < 1 or flag == 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
res=0
for i in range(n):
  if a[i]%4==1 or a[i]%4==3:
    odd+=1
  elif a[i]%2==0 and a[i]%4!=0:
    even+=1
  else:
    res+=1
if even<2:
  if odd+even-1<=res:
    print('Yes')
  else:
    print('No')
else:
  if odd-1<=res:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
odd=0
even=0
res=0
for i in range(n):
  if a[i]%4==1 or a[i]%4==3:
    odd+=1
  elif a[i]%2==0 and a[i]%4!=0:
    even+=1
  else:
    res+=1
if res>=n//2:
  print('Yes')
elif res<n//2 and even+res>=n//2+1 and res!=0:
  print('Yes')
elif res==0 and even==n:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
odd=0
even=0
res=0
for i in range(n):
  if a[i]%4==1 or a[i]%4==3:
    odd+=1
  elif a[i]%2==0 and a[i]%4!=0:
    even+=1
  else:
    res+=1
if res>=n//2:
  print('Yes')
elif res<n//2 and even+res>=n//2+1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
L = list(map(int,input().split()))
b2 = 0
b4 = 0

for i in range(N):
    if L[i] % 4 == 0:
        b4 += 1
    elif L[i] % 2 == 0:
        b2 += 1
other = N-b4-b2
if math.ceil(other/2) > b4:
    print('No')
else:
    rb4 = b4-math.floor(other/2)
    if b2 % 2 == 1:
        if rb4 == 0:
            print('No')
        else:
            print('Yes')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
L = list(map(int,input().split()))
b2 = 0
b4 = 0

for i in range(N):
    if L[i] % 4 == 0:
        b4 += 1
    elif L[i] % 2 == 0:
        b2 += 1
other = N-b4-b2

if other//2 > b4:
    print('No')
else:
    rb4 = b4-(other//2)
    if b2 % 2 == 1:
        if rb4 == 0:
            print('No')
        else:
            print('Yes')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
cnt = 0
cnt_ = 0
for i in a:
    if i%4 == 0:
        cnt += 1
    elif i&1 == 0:
        cnt_ += 1
if math.ceil((n-max(cnt_, 1)+1)/3) <= cnt:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
cnt = 0
cnt_ = 0
for i in a:
    if i%4 == 0:
        cnt += 1
    elif i&1 == 0:
        cnt_ += 1
if math.ceil((n-cnt_+1)/3) <= cnt:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
cnt = 0
cnt_ = 0
for i in a:
    if i%4 == 0:
        cnt += 1
    elif i&1 == 0:
        cnt_ += 1
if math.ceil(n/3) <= cnt + min(2, cnt_)//2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
cnt = 0
cnt_ = 0
for i in a:
    if i%4 == 0:
        cnt += 1
    elif i&1 == 0:
        cnt_ += 1
if math.ceil(n/3) <= cnt + min(1, cnt_):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
cnt = 0
for i in a:
    if i%4 == 0:
        cnt += 1
if math.ceil(n/3) <= cnt:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = (n - a.count(2) + 1) // 2
count = 0
for i in a:
    if i % 4 == 0:
        count += 1

if l <= count:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
lis=list(map(int,input().split()))
t,f=0,0
for i in lis:
  if i%4==0:
    f+=1
  elif i%2==0:
    t+=1
if f*3>=n-(t//2)*2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
lis=list(map(int,input().split()))
t,f=0,0
for i in lis:
  if i%4==0:
    t+=1
  elif i%2==0:
    f+=1
if f*3>=n-(t//2)*2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
lis=list(map(int,input().split()))
t,f=0,0
for i in lis:
  if i%2==0:
    t+=1
  if i%4==0:
    f+=1
if f*3>=n-t-f:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
lis=list(map(int,input().split()))
t,f=0,0
for i in lis:
  if i%2==0:
    t+=1
  if i%4==0:
    f+=1
if t+f>=n-1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
lis=list(map(int,input().split()))
t,f=0,0
for i in lis:
  if i%2==0:
    t+=1
  if i%4==0:
    f+=1
if t+f>=n:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
lis=list(map(int,input().split()))
t,f=0,0
for i in lis:
  if i%2==0:
    t+=2
  if i%4==0:
    f+=2
if t+f>=n:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
cnt_4 = 0
cnt_2 = 0
for a in A:
    if a % 4 == 0:
        cnt_4 += 1
    elif a % 2 == 0:
        cnt_2 += 1
cnt = N - 2*cnt_4 - cnt_2
if cnt_4 > 0:
    cnt -= 1
if cnt <= 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a0 = sum(a[i] % 2 != 0 for i in range(N)) + max(1, sum(a[i] % 4 == 2 for i in range(N)))
a2 = sum(a[i] % 4 == 0 for i in range(N))
print('Yes' if a0 <= a2 + 1 else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a0 = len([i for i in range(N) if a[i] % 2 != 0])
if len([i for i in range(N) if a[i] % 2 == 0 and a[i] != 4]) > 0:
    a0 += 1
a2 = len([i for i in range(N) if a[i] % 4 == 0])
if a0 <= a2 + 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a0 = len([i for i in range(N) if a[i] % 2 != 0])
a1 = len([i for i in range(N) if a[i] % 2 == 0 and a[i] != 4])
a2 = len([i for i in range(N) if a[i] % 4 == 0])
if a1 == 0 and a0 <= a2 + 1 or a1 > 0 and a0 <= a2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a0 = len([i for i in range(N) if a[i] % 2 != 0])
a1 = len([i for i in range(N) if a[i] % 2 == 0 and a[i] != 4])
a2 = len([i for i in range(N) if a[i] % 4 == 0])
if a1 == 0 and a0 <= a2 + 1 or a1 > 0 and a0 <=a2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
x = list(map(int, input().split()))
for i in range(len(x)):
  if x[i] == 0:
    print(i+1)
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
# ↑ここまではあってそう。

if N%2==1:
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

else:
    if other%2==1:
        if (N-other)//2<=mod40:
            print("Yes")
            exit()
        else:
            print("No")
            exit()
    else:
        if (N-other)//2<mod40:
            print("Yes")
            exit()
        else:
            print("No")
            exit

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
# ↑ここまではあってそう。

if N%2==1:
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

else:
    if (N-other)//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
# ↑ここまではあってそう。

if N%2==1:
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

else:
    if (N-((other//2)*2))//2 < mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
    else:
        print("No")
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
    else:
        print("No")

# if (N-other)%2==1:
#     if (N-other)//2 <= mod40:
#         print("Yes")
#     else:
#         print("No")

# else:
#     if (N-other)//2 < mod40:
#         print("Yes")
#     else:
#         print("No")

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

N=N-other

if N==1:
    if mod40==N:
        print("Yes")
    else:
        print("No")
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
    else:
        print("No")

if (N-other)%2==1:
    if (N-other)//2 <= mod40:
        print("Yes")
    else:
        print("No")

else:
    if (N-other)//2 < mod40:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
    else:
        print("No")
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
    else:
        print("No")

if N%2==1:
    if oddcount<=2*mod40:
        print("Yes")
    else:
        print("No")

else:
    if oddcount+1<=2*mod40:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
    else:
        print("No")
if N==2:
    if mod40>0:
        print("Yes")
    else:
        print("No")

if N%2==1:
    if oddcount<=2*mod40:
        print("Yes")
    else:
        print("No")

else:
    if oddcount+1<=2*mod40:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
    else:
        print("No")
if N==2:
    if mod40+other==N:
        print("Yes")
    else:
        print("No")

if N%2==1:
    if oddcount<=2*mod40:
        print("Yes")
    else:
        print("No")

else:
    if oddcount+1<=2*mod40:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if other+mod40 ==N:
    print("Yes")

if N%2==1:
    if oddcount<=2*mod40:
        print("Yes")
    else:
        print("No")

else:
    if oddcount+1<=2*mod40:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1
if N%2==1:
    if oddcount-1<=2*mod40:
        print("Yes")
    else:
        print("No")

else:
    if oddcount+1<=2*mod40:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1
if N%2==1:
    if oddcount<=2*mod40:
        print("Yes")
    else:
        print("No")
else:
    if oddcount+1<=2*mod40:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
an = list(map(int, input().split()))
classify = [0 for i in range(3)]
#4の倍数、2の倍数、奇数
for i in range(len(an)):
    if an[i] % 4 == 0:
        classify[0] += 1
    elif an[i] % 2 == 0:
        classify[1] += 1
    else:
        classify[2] += 1
if (classify[0]) < classify[2]:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
an = list(map(int, input().split()))
classify = [0 for i in range(3)]
#4の倍数、2の倍数、奇数
for i in range(len(an)):
    if an[i] % 4 == 0:
        classify[0] += 1
    elif an[i] % 2 == 0:
        classify[1] += 1
    else:
        classify[2] += 1
if (classify[0] + 1) < classify[2]:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
is_2 = len(list(filter(lambda x : x == 2, a)))
multiple_of_4 = len(list(filter(lambda x : x % 4 == 0, a)))
not_4 = N - multiple_of_4

if is_2 == N:
  print('Yes')
elif multiple_of_4 >= not_4 - is_2:
  print('Yes')
else:
  print('Yes' if 2 * multiple_of_4 >= not_4 else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
is_2 = len(list(filter(lambda x : x == 2, a)))
is_2_pair = is_2 // 2
multiple_of_4 = len(list(filter(lambda x : x % 4 == 0, a)))
not_4 = N - multiple_of_4

if is_2 == N:
  print('Yes')
else:
  print('Yes' if 2 * multiple_of_4 >= not_4 - is_2_pair else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
all_2 = len(set(a)) == 1 and a[0] == 2
multiple_of_4 = len(list(filter(lambda x : x % 4 == 0, a)))
not_4 = N - multiple_of_4

if all_2:
  print('Yes')
else:
  print('Yes' if 2 * multiple_of_4 >= not_4 else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
is_2 = len(list(filter(lambda x : x == 2, a)))
multiple_of_4 = len(list(filter(lambda x : x % 4 == 0, a)))
not_4 = N - multiple_of_4

if is_2 + multiple_of_4 == N:
  print('Yes')
else:
  print('Yes' if 2 * multiple_of_4 >= not_4 else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
multiple_of_4 = len(list(filter(lambda x : x % 4 == 0, [int(x) for x in input().split()])))
not_4 = N - multiple_of_4

print('Yes' if 2 * multiple_of_4 >= not_4 else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

count2 = 0
count4 = 0

for a in A:
    if a % 4 == 0: count4 += 1
    elif a % 2 == 0: count2 += 1

if count2 % 2 == 1: count2 -= 1
if count4*3 + count2 >= N: print('Yes')
else: print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
zero,one,two = 0,0,0
for i in a:
    if i%4 == 0:
        two += 1
    elif i%2 == 0:
        one += 1
    else:
        zero += 1
if one == 1:
    print("Yes" if two+int(two>0) >= zero+1 else "No")
    exit()
print("Yes" if two+int(two>0) >= zero else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
zero,one,two = 0,0,0
for i in a:
    if i%4 == 0:
        two += 1
    elif i%2 == 0:
        one += 1
    else:
        zero += 1
if one == 1:
    print("Yes" if two+(two) >= zero+1 else "No")
    exit()
print("Yes" if two+(two) >= zero else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
zero,one,two = 0,0,0
for i in a:
    if i%4 == 0:
        two += 1
    elif i%2 == 0:
        one += 1
    else:
        zero += 1
if one == 1:
    print("Yes" if two+1 >= zero+1 else "No")
    exit()
print("Yes" if two+1 >= zero else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
zero,one,two = 0,0,0
for i in a:
    if i%4 == 0:
        two += 1
    elif i%2 == 0:
        one += 1
    else:
        zero += 1
if one == 1:
    print("Yes" if 2*two >= zero+1 else "No")
    exit()
print("Yes" if 2*two >= zero else "No")

Submission status: Wrong Answer

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

a4 = [x for x in a if x % 4 == 0]
a_odd = [x for x in a if x % 2 == 1]

if len(a_odd) == 0:
  print("Yes")
elif len(a4) + 1 >= len(a_odd):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

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

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