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

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = int(input())
    aa = LI()
    c4 = c2 = 0
    for a in aa:
        if a % 4 == 0:
            c4 += 1
        elif a % 2 == 0:
            c2 += 1
    if n <= (c4 > 0) * (c4 * 2 + 1) + (c2 > 1) * c2:
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = int(input())
    aa = LI()
    c4 = c2 = 0
    for a in aa:
        if a % 4 == 0:
            c4 += 1
        elif a % 2 == 0:
            c2 += 1
    if n <= (c4 > 0) * c4 * 2 + 1 + (c2 > 1) * c2:
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = int(input())
    aa = LI()
    c4 = c2 = 0
    for a in aa:
        if a % 4 == 0:
            c4 += 1
        elif a % 2 == 0:
            c2 += 1
    if n <= c4 * 2 + 1 + (c2 > 1) * c2:
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    aa=LI()
    c4=c2=0
    for a in aa:
        if a%4==0:
            c4+=1
        elif a%2==0:
            c2+=1
    if n<=c4*3+(c2>1)*c2:
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

Solution code:
import math
N =int(input())
A = list(map(int,input().split()))
cnt4 = 0
cnt2 = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1
com = math.ceil((N - cnt2 + (cnt2 % 2)) / 3)
if com <= cnt4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math
N =int(input())
A = list(map(int,input().split()))
cnt4 = 0
cnt2 = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1
com = math.ceil((N - cnt2) / 3)
if com <= cnt4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
four = [i for i in a if i%4==0]
even = [j for j in a if j%2==0 and j!=2 and j%4!=0]
print(even)
if n//2 <= len(four) or n//2 <= len(four)+a.count(2)//2 or n//2<=len(four)+a.count(2)//2 + len(even)//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

if N % 2 == 0:
    if fours + twos//2 >= N//2:
        print('Yes')
    else:
        print('No')
else:
    if fours + twos//3 >= N//2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

fours = 0
twos = 0
ones = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] >= 4:
            fours += 1
        else:
            twos += 1
    else:
        ones += 1

if twos:
    ones += 1

if ones <= fours + 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

fours = 0
twos = 0
ones = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] >= 4:
            fours += 1
        else:
            twos += 1
    else:
        ones += 1

if twos % 2 == 0:
    ones += twos // 2
else:
    ones += twos // 2 + 1

if ones <= fours + 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
four = [i for i in a if i%4==0]
if n//2 <= len(four) or n//2 <= len(four)+a.count(2)//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
four = [i for i in a if i%4==0]   
if n//2 >= len(four) or n//2 >= len(four)+a.count(2)//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

fours = 0
twos = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] >= 4:
            fours += 1
        else:
            twos += 1

if N % 2 == 0:
    if fours + twos//2 >= N//2:
        print('Yes')
    else:
        print('No')
else:
    if fours + twos//3 >= N//2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
if a.count(2)>=2:
  for i in range(a.count(2)):
    a=a[:a.index(2)]+a[a.index(2)+1:]
  n=len(a)

cnt=0
for i in a:
  if i%4==0:
    cnt+=1
if cnt>=n//2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
odds = len(list(filter(lambda x: x%2 == 1,A)))
baisu4 = len(list(filter(lambda x: x%4 == 0,A)))
evens = N-odds
if odds == 0:print('Yes')
elif evens == baisu4 and baisu4-1 >= odds:
    print('Yes')
elif evens != baisu4 and baisu4 >= odds:
    print('Yes')
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
odds = len(list(filter(lambda x: x%2 == 1,A)))
baisu4 = len(list(filter(lambda x: x%4 == 0,A)))
evens = N-odds
if odds == 0:print('Yes')
elif odds%2 == 1 and baisu4 >= odds:
    print('Yes')
elif odds%2 == 0 and baisu4 >= odds:
    print('Yes')
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
odds = len(list(filter(lambda x: x%2 == 1,A)))
baisu4 = len(list(filter(lambda x: x%4 == 0,A)))
evens = N-odds
if odds%2 == 0 and 2*baisu4 >= odds:
        print('Yes')
elif 2*baisu4 >= odds:
    print('Yes')
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
odds = len(list(filter(lambda x: x%2 == 1,A)))
baisu4 = len(list(filter(lambda x: x%4 == 0,A)))
evens = N-odds
if odds%2 == 0 and baisu4 >= 2*odds:
        print('Yes')
elif 2*baisu4 >= odds:
    print('Yes')
else:
    print("No")

Submission status: Wrong Answer

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

d2 = 0
d4 = 0

for ai in aa:
  if ai % 4 == 0:
    d4 += 1
  elif ai % 2 == 0:
    d2 += 1
  else:
    pass  

if d2<=1:
  d2=0

dd = (d4*2 +1) + d2
if d4==0:
  dd -=1
  
if dd >= n :
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

d2 = 0
d4 = 0

for ai in aa:
  if ai % 4 == 0:
    d4 += 1
  elif ai % 2 == 0:
    d2 += 1
  else:
    pass  

if d2<=1:
  d2=0
  
if d4*3 + d2 >= n :
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

d2 = 0
d4 = 0

for ai in aa:
  if ai % 4 == 0:
    d4 += 1
  elif ai % 2 == 0:
    d2 += 1
  else:
    pass  
  
if d4*3 + (d2//2)*2 >= n :
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
two = 0
four = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1
if n == 2:
    ans = 'Yes' if 1 <= four or two == n else 'No'
elif n == 3:
    ans = 'Yes' if 1 <= four or two == n else 'No'
else:
    ans = 'Yes' if (2 <= four and (n-4 <= two+four-2 or n-four*2 <= two)) or (four == 1 and n-2 <= two) or two == n else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
two = 0
four = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1
if n == 2:
    ans = 'Yes' if 1 <= four or two == n else 'No'
elif n == 3:
    ans = 'Yes' if 1 <= four or two == n else 'No'
else:
    ans = 'Yes' if (2 <= four and (n-four*2 <= two)) or (four == 1 and n-2 <= two) or two == n else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
two = 0
four = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1
if n == 2:
    ans = 'Yes' if 1 <= four or two == n else 'No'
elif n == 3:
    ans = 'Yes' if 1 <= four or two == n else 'No'
else:
    ans = 'Yes' if (2 <= four and (n-4 <= two+four-2 or (n-4)//2 <= four-2)) or (four == 1 and n-2 <= two) or two == n else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
two = 0
four = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1
if n == 2:
    ans = 'Yes' if 1 <= four or two == n else 'No'
elif n == 3:
    ans = 'Yes' if 1 <= four or two == n else 'No'
elif n % 2 == 0:
    ans = 'Yes' if (2 <= four and n-4 <= two+four-2) or (four == 1 and n-2 <= two) or two == n else 'No'
else:
    ans = 'Yes' if (2 <= four and (n-4 <= two+four-2 or (n-4)//2 <= four-2)) or (four == 1 and n-2 <= two) or two == n else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
two = 0
four = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1
if n == 2:
    ans = 'Yes' if 1 <= four or two == n else 'No'
elif n == 3:
    ans = 'Yes' if 1 <= four or two == n else 'No'
else:
    ans = 'Yes' if (2 <= four and n-4 <= two+four-2) or (four == 1 and n-2 <= two) or two == n else 'No'
print(ans)

Submission status: Wrong Answer

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

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

ans = 0
# ans = n - fCount * 3 - (tCount // 2) * 2
if tCount > 1:
    #ans = n - fCount * 3 - tCount
    if fCount > 0:
        ans = n - (2 * fCount + 1) - tCount
    else:
        ans = n - tCount
else:
    #ans = n - fCount * 3
    if fCount > 0:
        ans = n - (2 * fCount + 1)
    else:
        ans = n

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

Submission status: Wrong Answer

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

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

ans = 0
# ans = n - fCount * 3 - (tCount // 2) * 2
if tCount > 1:
    #ans = n - fCount * 3 - tCount
    if fCount > 0:
        ans = n - (2 * fCount + 1) - tCount
    else:
        ans = n - tCount
else:
    #ans = n - fCount * 3
    if fCount > 0:
        ans = n - (2 * fCount + 1)
    else:
        ans = n

if ans > 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

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

ans = 0
# ans = n - fCount * 3 - (tCount // 2) * 2
if tCount > 1:
    #ans = n - fCount * 3 - tCount
    ans = n - (2 * fCount + 1) - tCount
else:
    #ans = n - fCount * 3
    ans = n - (2 * fCount + 1)

if ans > 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

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

ans = 0
# ans = n - fCount * 3 - (tCount // 2) * 2
if tCount > 1:
    ans = n - fCount * 3 - tCount
else:
    ans = n - fCount * 3

if ans > 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

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

# ans = n - fCount * 3 - (tCount // 2) * 2
ans = n - fCount * 3 - tCount

if ans > 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

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

ans = n - fCount * 3 - (tCount // 2) * 2

if ans > 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
j=0
k=0
l=0
for i in a:
  if i%4==0:
    l+=1
  elif i%2==0:
    k+=1
  else:
    j+=1
if l+1>=j:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
j=0
k=0
l=0
for i in a:
  if i%4==0:
    l+=1
  elif i%2==0:
    k+=1
  else:
    j+=1
if l>=j:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
j=0
k=0
l=0
for i in a:
  if i%4==0:
    l+=1
  elif i%2==0:
    k+=1
  else:
    j+=1
if k>=j:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
four_count = 0
two_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
if 0 < four_count:
    N -= four_count * 2 + 1
if N + 1 <= two_count:
    print('Yes')
    exit()
if N <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
four_count = 0
two_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
if 0 < four_count:
    N -= four_count * 2 + 1
if N + 1 <= two_count and 2 <= two_count:
    print('Yes')
    exit()
if N <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
four_count = 0
two_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
if 0 < four_count:
    N -= four_count * 2
if N <= two_count and 1 <= two_count:
    print('Yes')
    exit()
if N <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
four_count = 0
two_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
if 0 < four_count:
    N -= four_count * 2 + 1
if N <= two_count and 2 <= two_count:
    print('Yes')
    exit()
if N <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
four_count = 0
two_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
N -= four_count * 3
if N <= two_count:
    print('Yes')
    exit()
if N <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
four_count = 0
two_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
two_count //= 2
N -= four_count * 3
if N <= two_count:
    print('Yes')
    exit()
if N <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
four_count = 0
two_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
two_count //= 2
N -= four_count * 2 + four_count
if two_count == N:
    print('Yes')
    exit()
if N <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
four_count = 0
two_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
two_count //= 2
N -= four_count * 2 + two_count + four_count
if N <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def f(n):
  if n%2==0:
    return (n-1)//2
  else:
    return n//2
N=int(input())
A=list(map(int,input().split()))
n=0
y=0
for a in A:
  if a%4==0:
    y+=1
  elif a%2==0:
    n+=1
if n==1:
  n=0
if f(N-n)<=y:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=list(map(int,input().split()))
mod_4=[]
mod_2=[]
elser=[]
for i in lists:
    if i%4==0:
        mod_4.append(i)
    elif i%4==2:
        mod_2.append(i)
    else:
        elser.append(i)
number_of_4=len(mod_4)
print(len(mod_4))
if number_of_4>=(n//2):
    print("Yes")
else:
    j=number_of_4*2+len(mod_2)
    if j>=n:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=list(map(int,input().split()))
mod_4=[]
mod_2=[]
elser=[]
for i in lists:
    if i%4==0:
        mod_4.append(i)
    elif i%4==2:
        mod_2.append(i)
    else:
        elser.append(i)
number_of_4=len(mod_4)
if number_of_4>=(n//2):
    print("Yes")
else:
    j=number_of_4*2+1+len(mod_2)
    if j>=n:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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


if zero-1<=two and one%2==0:
    print('Yes')
elif two*2>=N-1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
count2=0
count4=0
for i in range(n):
  if l[i]%4==0:
    count4+=1
  elif l[i]%2==0:
    count2+=1
if count4*2+count2>n or count4*2+1>n:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
count2=0
count4=0
for i in range(n):
  if l[i]%4==0:
    count4+=1
  elif l[i]%2==0:
    count2+=1
if count4*2+count2>n:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
cnt2=0
cnt_2=0
cnt4=0
for k in range(N):
    if a[k]==2:
        cnt_2+=1
for i in range(N):
    if a[i]%2==0:
        cnt2+=1
if cnt2 == N:
    print("Yes")
else:
    for j in range(N):
        if a[j]%4==0:
            cnt4+=1
    if cnt4 >= int(N/2):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
cnt2=0
cnt_2=0
cnt4=0
for k in range(N):
    if a[k]==2:
        cnt_2+=1
for i in range(N):
    if a[i]%2==0:
        cnt2+=1
if cnt2 == N:
    print("Yes")
else:
    for j in range(N):
        if a[j]%4==0:
            cnt4+=1
    if cnt4 >= int(N/2):
        print("Yes")
    else:
        if (cnt_2+cnt4*2) >= N:
          print("Yes")
        else:
          print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
a = list(map(int, input().split()))
cnt = 0
half = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt += 1
    elif a[i] % 2 == 0:
        half += 1
# cnt += half // 2
if half % 2 != 0:
    half -= 1
if cnt >= (N - half)//2:
    print("Yes")
else:
    print("No")
print(N, cnt, half)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
a = list(map(int, input().split()))
cnt = 0
half = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt += 1
    elif a[i] % 2 == 0:
        half += 1
# cnt += half // 2
if cnt >= (N - half)//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
c2 = 0
c4 = 0
for a in alist:
    if a % 4 == 0:
        c4 += 1
    elif a % 2 == 0:
        c2 += 1
kisuu = N - c4 - c2

if c4 * 2 >= kisuu + (1 if c2 else 0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
c2 = 0
c4 = 0
for a in alist:
    if a % 2 == 0:
        c2 += 1
    if a % 4 == 0:
        c4 += 1
only_c2 = c4 - c2
not_c4 = N - c4
not_c2 = N - c2

if c4 * 2 >= not_c4:
    print("Yes")
elif c4 + (only_c2 // 2) >= not_c2 + (only_c2 % 2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
c2 = 0
c4 = 0
for a in alist:
    if a % 2 == 0:
        c2 += 1
    if a % 4 == 0:
        c4 += 1
only_c2 = c4 - c2
not_c4 = N - c4
not_c2 = N - c2

if c4 - 1 >= not_c4:
    print("Yes")
elif c4 + (only_c2 // 2) + (only_c2 % 2) >= not_c2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
c2 = 0
c4 = 0
for a in alist:
    if a % 2 == 0:
        c2 += 1
    if a % 4 == 0:
        c4 += 1
only_c2 = c4 - c2
not_c4 = N - c4
not_c2 = N - c2

if c4 * 2 >= not_c4:
    print("Yes")
elif c4 + (only_c2 // 2) + (only_c2 % 2) >= not_c2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
c2 = 0
c4 = 0
for a in alist:
    if a % 2 == 0:
        c2 += 1
    if a % 4 == 0:
        c4 += 1
only_c2 = c4 - c2
not_c4 = N - c4
not_c2 = N - c2

if c4 * 2 >= not_c4:
    print("Yes")
elif c4 + (only_c2 // 2) >= not_c2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if c4 >= (N // 2) or c2 == N or ((c2 // 2) + c4) > (N // 2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if c4 >= (N // 2) or c2 == N or (c2 + c4) > (N // 2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if c4 >= (N // 2) or c2 == N:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

b = []
cnt = 0
for i in range(n):
    if a[i] % 2 == 0:
        cnt += 1
    if a[i] % 2 == 0:
        print("Yes")
        break
    if cnt>=2:
        print("Yes")
        break
    elif i == n-1:
        print("No")

Submission status: Wrong Answer

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

b = []
cnt = 0
for i in range(n):
    if a[i] % 2 == 0:
        cnt += 1
    if a[i] % 2 == 0:
        print("yes")
        break
    if cnt>=2:
        print("yes")
        break
    elif i == n-1:
        print("no")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
t,f=0,0
for x in a:
  if x%4==0:
    f+=1
  elif x%2==0:
    t+=1
print('Yes' if (t+f*2+1>=n and t>1) or t>=n or f>=n//2 else 'No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
t,f=0,0
for x in a:
  if x%4==0:
    f+=1
  elif x%2==0:
    t+=1
print('Yes' if t+f*2+1>=n else 'No')

Submission status: Wrong Answer

Solution code:
N=int(input());A=input().split();v=[int(i)%4 for i in A];print('Yes' if (v.count(0)*2+v.count(2))>=N else 'No')

Submission status: Wrong Answer

Solution code:
N=int(input());A=input().split();v=[int(i)%4 for i in A];print('Yes' if v.count(0)*2+v.count(2)>=N else 'No')

Submission status: Wrong Answer

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

c2 = sum(map(lambda x: x%2==0, A))
c4 = sum(map(lambda x: x%4==0, A))
if N%2==0:
    print('Yes' if (N-c4)<=(c2-c4)*2 else 'No')
else:
    print('Yes' if (N-c4)<=(c2-c4+1)*2 else 'No')

Submission status: Wrong Answer

Solution code:
from sys import stdin
n, *a = map(int, stdin.read().split())
c2, c4 = 0, 0
for i in a:
    if i % 2 == 0: 
        if i % 4 == 0:
            c4 += 1
        else:
            c2 += 1

if c4 >= len(a) // 2: ans = "Yes"
elif (len(a) - c4 * 2) == c2: ans = "Yes"
else: ans = "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):
    j = 0
    while True:
        if a[i]%2==0:
            a[i] = a[i]//2
            j +=1
        else:
            b[j]+=1
            break

        if j>1:
            b[2]+=1
            break
if b[1]==0 and b[0]-1<=b[2]:
    print("Yes")
elif (b[0]-1)*2<=b[2]:
    print("Yes")
elif b[0]==0:
    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 i in range(n):
    j = 0
    while True:
        if a[i]%2==0:
            a[i] = a[i]//2
            j +=1
        else:
            b[j]+=1
            break

        if j>1:
            b[2]+=1
            break
if b[1]==0 and b[0]-1<=b[2]:
    print("Yes")
elif (b[0]-1)*2<=b[2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

    cnt_2 = 0
    cnt_4 = 0
    others = 0
    for ai in A:
        if ai % 4 == 0:
            cnt_4 += 1
        elif ai % 2 == 0:
            cnt_2 += 1
        else:
            others += 1

    # print(cnt_2, cnt_4, others)

    ans = ''
    if cnt_4 > 0:
        if cnt_4 * 2 + 1 >= N:
            ans = 'Yes'
        elif cnt_4 * 2 + cnt_2 >= N:
            ans = 'Yes'
    elif cnt_4 + cnt_2 >= N:
        ans = 'Yes'
    else:
        ans = "No"
        

    print(ans)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    cnt_2 = 0
    cnt_4 = 0
    others = 0
    for ai in A:
        if ai % 4 == 0:
            cnt_4 += 1
        elif ai % 2 == 0:
            cnt_2 += 1
        else:
            others += 1

    print(cnt_2, cnt_4, others)

    ans = ''
    if cnt_4 > 0:
        if cnt_4 * 2 + 1 >= N:
            ans = 'Yes'
        elif cnt_4 * 2 + cnt_2 >= N:
            ans = 'Yes'
    elif cnt_4 + cnt_2 >= N:
        ans = 'Yes'
    else:
        ans = "No"
        

    print(ans)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    cnt_2 = 0
    cnt_4 = 0
    others = 0
    for ai in A:
        if ai % 4 == 0:
            cnt_4 += 1
        elif ai % 2 == 0:
            cnt_2 += 1
        else:
            others += 1

    ans = ''
    if cnt_4 >= N // 2:
        ans = 'Yes'
    elif (cnt_4 * 2 + 1) + cnt_2 >= N:
        ans = 'Yes'
    elif cnt_2 + cnt_4 >= N:
        ans = 'Yes'
    else:
        ans = 'No'

    print(ans)



if __name__ == "__main__":
    main()

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
if c2 > 0: t -= c2 - 1
#print(t)
if c4 > 0:
  if t - c4 * 2 - 1 <= 0:
    print("Yes")
  else:
    print("No")
else:
  if t <= 0:
    print("Yes")
  else:
    print("No")