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 = int(input())
a = list(input().split())

four = 0
two = 0

for i in a:
    if int(i) % 2 == 0:
        two += 1
    if int(str(i).zfill(5)[3:5]) % 4 == 0:
        four += 1

two -= four

if n % 2 == 0:
    if (four + two/2) >= n / 2:
        print('Yes')
    else:
        print('No')
else:
    if four >= n // 2:
        print('Yes')
    elif two + four == n:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

four = 0
two = 0

for i in a:
    if int(i) % 2 == 0:
        two += 1
    if int(str(i).zfill(5)[3:5]) % 4 == 0:
        four += 1

two -= four

if n % 2 == 0:
    if (four + two/2) >= n / 2:
        print('Yes')
    else:
        print('No')
else:
    if (four + two/2) >= n // 2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())

a=0;b=0;c=0
L = list(map(int,input().split()))
for i in range(N):
  if L[i]%4 == 0:
    c += 1
  elif L[i]%2 == 0:
    b += 1
  else:
    a += 1
t = a+b+c
print(a,b,c)
ans = "No"
if a == 0:
  ans = "Yes"
elif c >= a:
  ans = "Yes"
elif b == 0 and a == c+1:
  ans ="Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    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

    print("Yes" if n - (cnt_2 - 1) <= cnt_4 * 2 + 1 else "No")


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ans = "No"
if a == 0:
  ans = "Yes"
elif c >= a:
  ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    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

    print("Yes" if n - cnt_2 // 2 <= cnt_4 * 2 + 1 else "No")


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

c=0
d=0

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

print("Yes" if n-(c*2)-d==0 else "No")

Submission status: Wrong Answer

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

x=1

for i in range(n-1):
    x*=a[i]*a[i+1]

print(x)
y=n//2

print("Yes" if x%(4**y)==0 else "No")

Submission status: Wrong Answer

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

if c>=len(a)-1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if c>=len(a):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))

    c0 = 0
    c4 = 0

    for ai in a:
        if ai % 2 != 0:
            c0 += 1
        if ai % 4 == 0:
            c4 += 1

    if c0 > c4 + 1:
        print('No')
    else:
        print('Yes')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

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

for i in range(n):
    if l[i] % 4 == 0:
        l[i] = 2
    elif l[i] % 4 == 2:
        l[i] = 1
    else:
        l[i] = 0

print(l)

if n - (l.count(2)*2 + 1) <= 0:
    print("Yes")
elif n - (l.count(2)*2 + 1) < l.count(1):
    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()))
    odd, two, four = 0, 0, 0
    for i in range(N):
        if a[i]%4 == 0:
            four += 1
        elif a[i]%2 == 0:
            two += 1
        else:
            odd += 1
    if four == odd == 1 or four == odd == 2:
        print("Yes")
    elif two == N:
        print('Yes')    
    elif four >= N//2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def ord(n):
  if n % 2 == 1:
    return 0
  elif n % 4 == 0:
    return 2
  else:
    return 1

n = int(input())
a = list(map(lambda x:ord(int(x)),input().split()))
zero = a.count(0)
two = a.count(2)
if two>=zero:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
cnt_2=0
cnt_1=0
cnt_0=0

for num in a:
    if num%4==0:
        cnt_2+=1
    elif num%2==0:
        cnt_1+=1
    else:
        cnt_0+=1

if cnt_2>=cnt_0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
cnt_2=0
cnt_1=0
cnt_0=0

for num in a:
    if num%4==0:
        cnt_2+=2
    elif num%2==0:
        cnt_1+=1
    else:
        cnt_0+=1

if cnt_2<cnt_0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

cnt_2 = 0
cnt_4 = 0
for a in A:
  if a % 4 == 0:
    cnt_4 += 1
  elif a % 2 == 0:
    cnt_2 += 1
    
if N <= cnt_4 * 3 or N <= (cnt_2 + cnt_4):
  print('Yes')
else:
  N -= cnt_4 * 3
  if N % 2 != 0:
    N += 1
  if N <= cnt_2:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

cnt_2 = 0
cnt_4 = 0
for a in A:
  if a % 4 == 0:
    cnt_4 += 1
  elif a % 2 == 0:
    cnt_2 += 1
    
if N <= cnt_4 * 3 or N <= cnt_2:
  print('Yes')
else:
  N -= cnt_4 * 3
  if N % 2 != 0:
    N += 1
  if N <= cnt_2:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

cnt_2 = 0
cnt_4 = 0
for a in A:
  if a % 4 == 0:
    cnt_4 += 1
  elif a % 2 == 0:
    cnt_2 += 1
    
if N <= cnt_4 * 3:
  print('Yes')
else:
  N -= cnt_4 * 3
  if N % 2 != 0:
    N += 1
  if N <= cnt_2:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

cnt_2 = 0
cnt_4 = 0
for a in A:
  if a % 4 == 0:
    cnt_4 += 1
  elif a % 2 == 0:
    cnt_2 += 1
    
if N <= cnt_4 * 3:
  print('Yes')
else:
  N -= cnt_4 * 3
  if N <= cnt_2:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

cnt_2 = 0
cnt_4 = 0
for a in A:
  if a % 4 == 0:
    cnt_4 += 1
  elif a % 2 == 0:
    cnt_2 += 1
    
if N <= cnt_2 + cnt_4 * 3:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

four = sum(A % 4 == 0)  # 4で割りきれる数
two = sum(np.logical_and(A % 2 == 0, A % 4 != 0))  # 4で割り切れないが、2で割りきれる数

# print(four, two)
# Nからtwo//2を引く。そこからの残り//2よりfourが大きければOK

# print((N - two // 2) // 2)
# print(four)

if (N - two // 2) // 2 <= four:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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


def log(*args):
    print(*args, file=sys.stderr)


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

four_count = 0
two_count = 0
for v in l:
    if v % 4 == 0:
        four_count += 1
    elif v % 2 == 0:
        two_count += 1

if (n - (two_count // 2)) // 2 <= four_count:
    print("Yes")
elif two_count == n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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


def log(*args):
    print(*args, file=sys.stderr)


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

four_count = 0
two_count = 0
for v in l:
    if v % 4 == 0:
        four_count += 1
    elif v % 2 == 0:
        two_count += 1

if (n - (two_count // 2)) // 2 > four_count:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)


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

a = np.array(a)

#4がある

x4 = a[a%4 == 0]
x2 = a[(a%2 == 0)]

if len(x4) * 3 >= N:
        print("Yes")
        exit()
else:
    if (len(x2) -len(x4)) + len(x4)*2 >= N or  len(x2)*2 > N:
        print("Yes")
        exit()


print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)


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

a = np.array(a)

#4がある

x4 = a[a%4 == 0]
x2 = a[(a%2 == 0)]

if len(x4) * 3 >= N:
        print("Yes")
        exit()
else:
    if (len(x2) -len(x4)) + len(x4)*2 >= N:
        print("Yes")
        exit()


print("No")

Submission status: Wrong Answer

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

cnt2 = max(1,cnt2)
print('Yes' if 2 * cnt4 + cnt2 == n else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    sum2 = 0
    non4 = 0
    sum4 = 0
    for v in A:
        if v % 4 == 0:
            sum4 = sum4 + 1
        elif v == 2:
            sum2 = sum2 + 1
        else:
            non4 = non4 + 1

    if sum2 >= 1:
        sum2 = 1
    else:
        sum2 = 0

    if non4 - 1 + sum2 <= sum4:
        print("Yes")
    else:
        print("No")

        

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

c1, c2, c4 = 0, 0, 0
a = list(map(int, input().split()))

for i in a:
    if i % 4 == 0:
        c4 += 1
    elif i % 2 == 0:
        c2 += 1
    else:
        c1 += 1

result = min(c4, c1*2) * 3 + c2 // 2

print("Yes" if result >= N else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())

c1, c2, c4 = 0, 0, 0
a = list(map(int, input().split()))

for i in a:
    if i % 4 == 0:
        c4 += 1
    elif i % 2 == 0:
        c2 += 1
    else:
        c1 += 1

result = c4 * 3 + c2 // 2

print("Yes" if result >= N else "No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

def div(n):
    if n % 4 == 0:
        return 3
    elif n % 2 == 0:
        return 2
    else:
        return 0

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

d = defaultdict(int)
d[1] = 0

for i in result:
    d[i] += 1

d[2] //= 2

ans = 0
for c, v in d.items():
    ans += c * v

print("Yes" if ans >= N else "No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

def div(n):
    if n % 4 == 0:
        return 3
    elif n % 2 == 0:
        return 1
    else:
        return 0

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

d = defaultdict(int)
d[1] = 0

for i in result:
    d[i] += 1

if d[1] % 2 == 1:
    d[1] -= 1

ans = 0
for c, v in d.items():
    ans += c * v

print("Yes" if ans >= N else "No")

Submission status: Wrong Answer

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

cnt_1 = 0
for i in a:
    if i % 2 != 0:
        cnt_1 += 1

cnt_2 = 0
for i in a:
    if i % 2 == 0 and i % 4 != 0:
        cnt_2 += 1

cnt_4 = 0
for i in a:
    if i % 4 == 0:
        cnt_4 += 1

if cnt_4 * 2 >= cnt_1 and cnt_2 % 2 == 0 or cnt_4 * 2 >= cnt_1 + cnt_2 % 2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

cnt_1 = 0
for i in a:
    if i % 2 != 0:
        cnt_1 += 1

cnt_2 = 0
for i in a:
    if i % 2 == 0 and i % 4 != 0:
        cnt_2 += 1

cnt_4 = 0
for i in a:
    if i % 4 == 0:
        cnt_4 += 1

if cnt_4 * 2 >= cnt_1*2 and cnt_2 % 2 == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!python3

def LI():
    return list(map(int, input().split()))

# input
N = int(input())
A = LI()


def main():
    x, y, z = [0] * 3
    for a in A:
        if a % 4 == 0:
            x += 1
        elif a % 2 == 0:
            y += 1
        else:
            z += 1

    x -= z // 2 + 1
    if x < -1:
        print("No")
        return
    if x == -1 and y > 0:
        print("No")
        return
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!python3

def LI():
    return list(map(int, input().split()))

# input
N = int(input())
A = LI()


def main():
    x, y, z = [0] * 3
    for a in A:
        if a % 4 == 0:
            x += 1
        elif a % 2 == 0:
            y += 1
        else:
            z += 1

    x -= z // 2 + 1
    if x < -1:
        print("No")
        return
    if x == -1:
        if y == 0:
            print("Yes")
        else:
            print("No")
        return
    
    if y % 2 == 1 and x == 0:
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
cnt = 0
memo = 0
for aa in a:
    if aa % 4 == 0:
        cnt += 3
    elif aa % 2 == 0:
        memo += 1
if memo < 2:
    memo = 0
print('Yes' if cnt >= n - memo else 'No')

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
cnt = 0
memo = 0
for aa in a:
    if aa % 4 == 0:
        cnt += 3
    elif aa % 2 == 0:
        memo += 1
if memo < 2:
    memo = 0
print('Yes' if cnt + memo >= n else 'No')

Submission status: Wrong Answer

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

for i in range(n):
  if a[i]%2 != 0:
    zero += 1
  elif a[i]%4 == 0:
    four += 1
 
if zero<=(four+1):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

cnt1 = 0
cnt2 = 0
cnt4 = 0
for i in lis:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1
    else:
        cnt1 += 1

if cnt4 + 1 >= cnt1:
    print("Yes")
elif cnt4 + cnt2//2 >= cnt1 + 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

cnt2 = 0
cnt4 = 0
for i in lis:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1

if 2 * cnt4 + cnt2 >= n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
odd, four = 0, 0
for a in A:
    if a & 1 == 1: odd += 1
    if a & 3 == 0: four += 1
# 4の倍数の個数 >= 奇数の個数-1
# すべて偶数
print('Yes' if four >= odd - 1 or odd == 0 else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
f2 = 0
f4 = 0
for a in A:
    #c = collections.Counter(prime_factorize(a))
    if a%4 == 0:
        f4 += 1
    elif a%2 == 0:
        f2 += 1
if n -f2//2 *2 -f4 *2 <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
'''import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a'''

n = int(input())
A = list(map(int, input().split()))
f2 = 0
f4 = 0
for a in A:
    #c = collections.Counter(prime_factorize(a))
    if a%4 == 0:
        f4 += 1
    elif a%2 == 0:
        f2 += 1
if n -f2//2 *2 -f4 *3 <= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import os

def file_input():
    f = open('ARC080/input.txt', 'r')
    sys.stdin = f

def main():
    #ile_input()
    N=int(input())
    a_li=list(map(int, input().split()))

    # four=0
    odd=0
    for i in a_li:
        if i%4==0:
            odd-=1
        if i%2!=0:
            odd+=1
    else:
        if odd<=1:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os

def file_input():
    f = open('ARC080/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    N=int(input())
    a_li=list(map(int, input().split()))

    # four=0
    odd=0
    for i in a_li:
        if i%4==0:
            odd-=2
        if i%2!=0:
            odd+=1
    else:
        if odd<=0:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


N = int(input())
counter = defaultdict(int)
for a in map(int, input().split()):
    if a % 4 == 0:
        counter[2] += 1
    elif a % 2 == 0:
        counter[1] += 1
    else:
        counter[0] += 1
print('Yes') if counter[0] <= counter[2] else print('No')

Submission status: Wrong Answer

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

oddNum = 0
evenNum = 0
mul4 = 0

for i in A:
    if i % 2 == 1:
        oddNum += 1
    elif i % 4 == 0:
        mul4 += 1
    else:
        evenNum += 1
if mul4*2 < oddNum + min(3, evenNum):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

oddNum = 0
evenNum = 0
mul4 = 0

for i in A:
    if i % 2 == 1:
        oddNum += 1
    elif i % 4 == 0:
        mul4 += 1
    else:
        evenNum += 1
if mul4 < oddNum + evenNum%2:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

oddNum = 0
evenNum = 0
mul4 = 0

for i in A:
    if i % 2 == 1:
        oddNum += 1
    elif i % 4 == 0:
        mul4 += 1
    else:
        evenNum += 1
if mul4 * 2 < oddNum + evenNum%2:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

n0, n1, n2 = 0, 0, 0

def how_many_dev_by_2(x, cnt=0):
    if x%2 == 0:
        x /= 2
        cnt += 1
        return how_many_dev_by_2(x, cnt)
    else:
        return cnt

for a in al:
    a_cnt = how_many_dev_by_2(a)
    if a_cnt == 0:
        n0 += 1
    elif a_cnt == 1:
        n1 += 1
    else:
        n2 += 1

if n2 + 1 >= n0 + n1//2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

ad4 = len([i for i in A if i % 4 == 0])
gusu_num = len([i for i in A if i % 2 == 0 and i % 4 != 0])

N -= (2 * ad4) + 1

if N <= 0:
    print('Yes')
else:
    if gusu_num >=2 and N <= gusu_num:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
s = [int(i)%4 for i in sys.stdin.read().split()]
s0 = s.count(0)
s2 = s.count(2)
if s0 >= n//2 or (s2 >= (n-s0+1)//2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
s = [int(i)%4 for i in sys.stdin.read().split()]
s0 = s.count(0)
s2 = s.count(2)
if s0 >= n//2 or (s2 <= n//2 and s0 >= (n-s2)//2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    n2 = 0
    n4 = 0
    for i in range(N):
        if A[i]%2==0:
            n2 += 1
        if A[i]%4==0:
            n4 += 1
    if n2-n4==1:
        x = n4*2+1
    else:
        x = n4*2+1+ (n2-n4)
    if x>=N:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

n_4, n_2, m = 0, 0, 0

for a in al:
    if a % 4 == 0:
        n_4 += 1
    elif a == 2:
        n_2 += 1
    else:
        m += 1

print('Yes' if n//2 - n_2//2 <= n_4 else 'No')

Submission status: Wrong Answer

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

n_4 = 0
m = 0

for a in al:
    if a % 4 == 0:
        n_4 += 1
    else:
        m += 1

print('Yes' if n//2 <= n_4 else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())

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

num_4 = 0
num_2 = 0
num_odd = 0

for i in A:
    if i % 4 == 0:
        num_4 += 1
    elif i % 2 == 0:
        num_2 += 1

num_odd = n - num_2 - num_4

if n - num_4*2 == num_2 or n - num_4 * 2 == 1 or n - num_4 * 2 == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

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

num_4 = 0
num_2 = 0
num_odd = 0

for i in A:
    if i % 4 == 0:
        num_4 += 1
    elif i % 2 == 0:
        num_2 += 1

num_odd = n - num_2 - num_4

if n - num_4*2 == num_2 or n - num_4 * 2 == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for i in a:
    if i%4 == 0:
        cnt_four += 2
    elif i%4 == 2:
        cnt_two += 1
cnt_odd = len(a) - cnt_four - cnt_two

if cnt_two >= 1:
    cnt_odd += 1

if cnt_four >= cnt_odd + 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/arc080/tasks/arc080_a

n = int(input())
nums = [int(i) for i in input().split()]

fours = 0
twos = 0
odd = 0
for num in nums:
    if num % 4 == 0:
        fours += 1
    elif num % 2 == 0:
        twos += 1
    else:
        odd += 1

if fours + 1 >= twos + odd:
    print('Yes')
elif fours + 1 >= odd and twos > 1:
    print('Yes')
elif odd == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def myAnswer(N:int,A:list) -> str:
   counter4 = 0
   counter2 = 0
   for a in A:
      if(a % 4 == 0):
         counter4 += 1
      elif(a % 2 == 0):
         counter2 += 1
   if(counter4 >= N//2):
      return "Yes"
   elif(counter4 >= (N-counter2//2)//2):
      return "Yes"
   else:
      return "No"


def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
n = int(input())

A = list(map(int, input().split()))
t_2 = 0
t_4 = 0
for i in A:
    if i % 2 == 0:
        t_2 += 1
    if i % 4 == 0:
        t_4 += 1


if n == 1 and A[0] % 4 != 0:
    print("No")
elif t_2 > n//2 or t_4 + 1 > n//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

A = list(map(int, input().split()))
t_2 = 0
t_4 = 0
for i in A:
    if i % 2 == 0:
        t_2 += 1
    if i % 4 == 0:
        t_4 += 1

if t_2 > n//2 or t_4 + 1 > n//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
li = list(map(int,input().split()))

all_li = []
two_count = 0
zero_count = 0
for l in li:
    count = 0
    if l % 2 == 0:
        count += 1
    if l % 4 == 0:
        count += 1
        two_count += 1
    if count == 0:
        zero_count += 1
    all_li.append(count)
#print(all_li)
#[0, 1, 2]
if two_count == 0:
    #print(list(set(all_li)))
    if list(set(all_li)) == [1]:
        print('Yes')
    else:
        print('No')
elif zero_count == 0:
    print('Yes')
else:
    if zero_count > two_count +1:
        print('No')
    elif zero_count == two_count + 1:
        if len(all_li) - zero_count - two_count != 1:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
li = list(map(int,input().split()))

all_li = []
two_count = 0
zero_count = 0
for l in li:
    count = 0
    if l % 2 == 0:
        count += 1
    if l % 4 == 0:
        count += 1
        two_count += 1
    if count == 0:
        zero_count += 1
    all_li.append(count)
#print(all_li)
#[0, 1, 2]
if two_count == 0:
    #print(list(set(all_li)))
    if list(set(all_li)) == [1]:
        print('Yes')
    else:
        print('No')
else:
    if zero_count > two_count +1:
        print('No')
    elif zero_count == two_count + 1:
        if len(all_li) - zero_count - two_count != 1:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
li = list(map(int,input().split()))

all_li = []
two_count = 0
zero_count = 0
for l in li:
    count = 0
    if l % 2 == 0:
        count += 1
    if l % 4 == 0:
        count += 1
        two_count += 1
    if count == 0:
        zero_count += 1
    all_li.append(count)
#print(all_li)
#[0, 1, 2]
if two_count == 0:
    #print(list(set(all_li)))
    if list(set(all_li)) == [1]:
        print('Yes')
    else:
        print('No')
else:
    if zero_count > two_count +1:
        print('No')
    elif zero_count == two_count + 1:
        if len(all_li) - zero_count - two_count >= 2:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
n_list = list(map(int,input().split()))
count = 0
for i in n_list:
    if i % 4 == 0:
        count += 1
    elif i == 2 or i == 6:
        count += 0.5
if count >= n//2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print("Yes" if l[2]>=l[0]+int(1<=l[1]) else "No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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