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:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,m = LI()
    a = LIR(n)
    ans = 0
    for i in range(2):
        for j in range(2):
            for k in range(2):
                a.sort(key = lambda x:(-1)**i*x[0]+(-1)**j*x[1]+(-1)**k*x[2])
                p = [0,0,0]
                for l in range(m):
                    p[0] += a[l][0]
                    p[1] += a[l][1]
                    p[2] += a[l][2]
                p = abs(p[0])+abs(p[1])+abs(p[2])
                if p > ans:
                    ans = p
    print(ans)
    return

#B
def B():
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y,su):
        x = root(x)
        y = root(y)
        su += comb_2(s[x])+comb_2(s[y])
        if rank[x] < rank[y]:
            s[y] += s[x]
            su -= comb_2(s[y])
            par[x] = y
        else:
            s[x] += s[y]
            su -= comb_2(s[x])
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
        return su

    def comb_2(a):
        return a*(a-1)//2

    n,m = LI()
    v = LIR(m)
    par = [i for i in range(n)]
    rank = [0]*n
    s = [1]*n
    su = comb_2(n)
    ans = [su]
    for a,b in v[:0:-1]:
        a -= 1
        b -= 1
        if root(a) != root(b):
            su = unite(a,b,su)
        ans.append(su)
    for i in ans[::-1]:
        print(i)
    return

#C
def C():
    def root(x):
        if par[x] == x:
            return par[x]
        r = root(par[x])
        d[x] += d[par[x]]
        par[x] = r
        return par[x]

    def weight(x):
        root(x)
        return d[x]

    def unite(x,y,w):
        w += weight(x)
        w -= weight(y)
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
            d[x] = -w
        else:
            par[y] = x
            d[y] = w
            if rank[x] == rank[y]:
                rank[x] += 1
    n,m = LI()
    par = [i for i in range(n)]
    rank = [0]*n
    d = [0]*n
    for i in range(m):
        l,r,w = LI()
        l -= 1
        r -= 1
        if root(l) != root(r):
            unite(l,r,w)
        else:
            if weight(r)-weight(l) != w:
                print("No")
                return
    print("Yes")
    return

#D
def D():
    h,w = LI()
    n = I()
    a = LI()
    ans = [0]*h*w
    p = 0
    for i in range(n):
        for j in range(a[i]):
            ans[p+j] = i+1
        p += a[i]
    for i in range(h):
        s = ans[i*w:(i+1)*w]
        if i%2:
            print(*s[::-1])
        else:
            print(*s)
    return

#E
def E():
    n,k = LI()
    s = [int(x) for x in input()]
    f = [0]*n
    j = 0
    su = 1
    p = s[0]
    for i in range(1,n):
        if s[i] != p:
            f[j] = su
            j += 1
            su = 1
            p = s[i]
        else:
            su += 1
    f[j] = su
    f.append(0)
    if s[0]:
        m = sum(f[:2*k+1])
        ans = m
        for i in range(2*k+1,n):
            m -= f[i-2*k-1]
            if not i%2:
                m += f[i-1]
                m += f[i]
            ans = max(m,ans)
    else:
        m = sum(f[:2*k])
        ans = m
        for i in range(2*k,n):
            m -= f[i-2*k]
            if not i%2:
                m += f[i]
                m += f[i+1]
            ans = max(m,ans)
    print(ans)
    return

#F
def F():
    n = I()
    a = LI()
    s = [0,0,0]
    for i in a:
        if i%4 == 0:
            s[0] += 1
        elif i%2 == 0:
            s[1] += 1
        else:
            s[2] += 1
    if not s[2]:
        print("Yes")
        return
    if s[0]:
        s[2] -= s[0]+1
    if s[2] > 0:
        print("No")
        return
    if not s[1]:
        print("Yes")
        return
    if s[2] < 0:
        s[1] += 1
    if s[1] > 1:
        print("Yes")
    else:
        print("No")
    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#Solve
if __name__ == "__main__":
    F()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,m = LI()
    a = LIR(n)
    ans = 0
    for i in range(2):
        for j in range(2):
            for k in range(2):
                a.sort(key = lambda x:(-1)**i*x[0]+(-1)**j*x[1]+(-1)**k*x[2])
                p = [0,0,0]
                for l in range(m):
                    p[0] += a[l][0]
                    p[1] += a[l][1]
                    p[2] += a[l][2]
                p = abs(p[0])+abs(p[1])+abs(p[2])
                if p > ans:
                    ans = p
    print(ans)
    return

#B
def B():
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y,su):
        x = root(x)
        y = root(y)
        su += comb_2(s[x])+comb_2(s[y])
        if rank[x] < rank[y]:
            s[y] += s[x]
            su -= comb_2(s[y])
            par[x] = y
        else:
            s[x] += s[y]
            su -= comb_2(s[x])
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
        return su

    def comb_2(a):
        return a*(a-1)//2

    n,m = LI()
    v = LIR(m)
    par = [i for i in range(n)]
    rank = [0]*n
    s = [1]*n
    su = comb_2(n)
    ans = [su]
    for a,b in v[:0:-1]:
        a -= 1
        b -= 1
        if root(a) != root(b):
            su = unite(a,b,su)
        ans.append(su)
    for i in ans[::-1]:
        print(i)
    return

#C
def C():
    def root(x):
        if par[x] == x:
            return par[x]
        r = root(par[x])
        d[x] += d[par[x]]
        par[x] = r
        return par[x]

    def weight(x):
        root(x)
        return d[x]

    def unite(x,y,w):
        w += weight(x)
        w -= weight(y)
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
            d[x] = -w
        else:
            par[y] = x
            d[y] = w
            if rank[x] == rank[y]:
                rank[x] += 1
    n,m = LI()
    par = [i for i in range(n)]
    rank = [0]*n
    d = [0]*n
    for i in range(m):
        l,r,w = LI()
        l -= 1
        r -= 1
        if root(l) != root(r):
            unite(l,r,w)
        else:
            if weight(r)-weight(l) != w:
                print("No")
                return
    print("Yes")
    return

#D
def D():
    h,w = LI()
    n = I()
    a = LI()
    ans = [0]*h*w
    p = 0
    for i in range(n):
        for j in range(a[i]):
            ans[p+j] = i+1
        p += a[i]
    for i in range(h):
        s = ans[i*w:(i+1)*w]
        if i%2:
            print(*s[::-1])
        else:
            print(*s)
    return

#E
def E():
    n,k = LI()
    s = [int(x) for x in input()]
    f = [0]*n
    j = 0
    su = 1
    p = s[0]
    for i in range(1,n):
        if s[i] != p:
            f[j] = su
            j += 1
            su = 1
            p = s[i]
        else:
            su += 1
    f[j] = su
    f.append(0)
    if s[0]:
        m = sum(f[:2*k+1])
        ans = m
        for i in range(2*k+1,n):
            m -= f[i-2*k-1]
            if not i%2:
                m += f[i-1]
                m += f[i]
            ans = max(m,ans)
    else:
        m = sum(f[:2*k])
        ans = m
        for i in range(2*k,n):
            m -= f[i-2*k]
            if not i%2:
                m += f[i]
                m += f[i+1]
            ans = max(m,ans)
    print(ans)
    return

#F
def F():
    n = I()
    a = LI()
    s = [0,0,0]
    for i in a:
        if i%4 == 0:
            s[0] += 1
        elif i%2 == 0:
            s[1] += 1
        else:
            s[2] += 1
    if s[0]:
        s[2] -= s[0]+1
    if s[2] > 0:
        print("No")
        return
    if not s[1]:
        print("Yes")
        return
    if s[2] < 0:
        s[1] += 1
    if s[1] > 1:
        print("Yes")
    else:
        print("No")
    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#Solve
if __name__ == "__main__":
    F()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,m = LI()
    a = LIR(n)
    ans = 0
    for i in range(2):
        for j in range(2):
            for k in range(2):
                a.sort(key = lambda x:(-1)**i*x[0]+(-1)**j*x[1]+(-1)**k*x[2])
                p = [0,0,0]
                for l in range(m):
                    p[0] += a[l][0]
                    p[1] += a[l][1]
                    p[2] += a[l][2]
                p = abs(p[0])+abs(p[1])+abs(p[2])
                if p > ans:
                    ans = p
    print(ans)
    return

#B
def B():
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y,su):
        x = root(x)
        y = root(y)
        su += comb_2(s[x])+comb_2(s[y])
        if rank[x] < rank[y]:
            s[y] += s[x]
            su -= comb_2(s[y])
            par[x] = y
        else:
            s[x] += s[y]
            su -= comb_2(s[x])
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
        return su

    def comb_2(a):
        return a*(a-1)//2

    n,m = LI()
    v = LIR(m)
    par = [i for i in range(n)]
    rank = [0]*n
    s = [1]*n
    su = comb_2(n)
    ans = [su]
    for a,b in v[:0:-1]:
        a -= 1
        b -= 1
        if root(a) != root(b):
            su = unite(a,b,su)
        ans.append(su)
    for i in ans[::-1]:
        print(i)
    return

#C
def C():
    def root(x):
        if par[x] == x:
            return par[x]
        r = root(par[x])
        d[x] += d[par[x]]
        par[x] = r
        return par[x]

    def weight(x):
        root(x)
        return d[x]

    def unite(x,y,w):
        w += weight(x)
        w -= weight(y)
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
            d[x] = -w
        else:
            par[y] = x
            d[y] = w
            if rank[x] == rank[y]:
                rank[x] += 1
    n,m = LI()
    par = [i for i in range(n)]
    rank = [0]*n
    d = [0]*n
    for i in range(m):
        l,r,w = LI()
        l -= 1
        r -= 1
        if root(l) != root(r):
            unite(l,r,w)
        else:
            if weight(r)-weight(l) != w:
                print("No")
                return
    print("Yes")
    return

#D
def D():
    h,w = LI()
    n = I()
    a = LI()
    ans = [0]*h*w
    p = 0
    for i in range(n):
        for j in range(a[i]):
            ans[p+j] = i+1
        p += a[i]
    for i in range(h):
        s = ans[i*w:(i+1)*w]
        if i%2:
            print(*s[::-1])
        else:
            print(*s)
    return

#E
def E():
    n,k = LI()
    s = [int(x) for x in input()]
    f = [0]*n
    j = 0
    su = 1
    p = s[0]
    for i in range(1,n):
        if s[i] != p:
            f[j] = su
            j += 1
            su = 1
            p = s[i]
        else:
            su += 1
    f[j] = su
    f.append(0)
    if s[0]:
        m = sum(f[:2*k+1])
        ans = m
        for i in range(2*k+1,n):
            m -= f[i-2*k-1]
            if not i%2:
                m += f[i-1]
                m += f[i]
            ans = max(m,ans)
    else:
        m = sum(f[:2*k])
        ans = m
        for i in range(2*k,n):
            m -= f[i-2*k]
            if not i%2:
                m += f[i]
                m += f[i+1]
            ans = max(m,ans)
    print(ans)
    return

#F
def F():
    n = I()
    a = LI()
    s = [0,0,0]
    for i in a:
        if i%4 == 0:
            s[0] += 1
        elif i%2 == 0:
            s[1] += 1
        else:
            s[2] += 1
    s[2] -= s[0]+1
    if s[2] > 0:
        print("No")
        return
    if not s[1]:
        print("Yes")
        return
    if s[2] < 0:
        s[1] += 1
    if s[1] > 1:
        print("Yes")
    else:
        print("No")
    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#Solve
if __name__ == "__main__":
    F()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,m = LI()
    a = LIR(n)
    ans = 0
    for i in range(2):
        for j in range(2):
            for k in range(2):
                a.sort(key = lambda x:(-1)**i*x[0]+(-1)**j*x[1]+(-1)**k*x[2])
                p = [0,0,0]
                for l in range(m):
                    p[0] += a[l][0]
                    p[1] += a[l][1]
                    p[2] += a[l][2]
                p = abs(p[0])+abs(p[1])+abs(p[2])
                if p > ans:
                    ans = p
    print(ans)
    return

#B
def B():
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y,su):
        x = root(x)
        y = root(y)
        su += comb_2(s[x])+comb_2(s[y])
        if rank[x] < rank[y]:
            s[y] += s[x]
            su -= comb_2(s[y])
            par[x] = y
        else:
            s[x] += s[y]
            su -= comb_2(s[x])
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
        return su

    def comb_2(a):
        return a*(a-1)//2

    n,m = LI()
    v = LIR(m)
    par = [i for i in range(n)]
    rank = [0]*n
    s = [1]*n
    su = comb_2(n)
    ans = [su]
    for a,b in v[:0:-1]:
        a -= 1
        b -= 1
        if root(a) != root(b):
            su = unite(a,b,su)
        ans.append(su)
    for i in ans[::-1]:
        print(i)
    return

#C
def C():
    def root(x):
        if par[x] == x:
            return par[x]
        r = root(par[x])
        d[x] += d[par[x]]
        par[x] = r
        return par[x]

    def weight(x):
        root(x)
        return d[x]

    def unite(x,y,w):
        w += weight(x)
        w -= weight(y)
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
            d[x] = -w
        else:
            par[y] = x
            d[y] = w
            if rank[x] == rank[y]:
                rank[x] += 1
    n,m = LI()
    par = [i for i in range(n)]
    rank = [0]*n
    d = [0]*n
    for i in range(m):
        l,r,w = LI()
        l -= 1
        r -= 1
        if root(l) != root(r):
            unite(l,r,w)
        else:
            if weight(r)-weight(l) != w:
                print("No")
                return
    print("Yes")
    return

#D
def D():
    h,w = LI()
    n = I()
    a = LI()
    ans = [0]*h*w
    p = 0
    for i in range(n):
        for j in range(a[i]):
            ans[p+j] = i+1
        p += a[i]
    for i in range(h):
        s = ans[i*w:(i+1)*w]
        if i%2:
            print(*s[::-1])
        else:
            print(*s)
    return

#E
def E():
    n,k = LI()
    s = [int(x) for x in input()]
    f = [0]*n
    j = 0
    su = 1
    p = s[0]
    for i in range(1,n):
        if s[i] != p:
            f[j] = su
            j += 1
            su = 1
            p = s[i]
        else:
            su += 1
    f[j] = su
    f.append(0)
    if s[0]:
        m = sum(f[:2*k+1])
        ans = m
        for i in range(2*k+1,n):
            m -= f[i-2*k-1]
            if not i%2:
                m += f[i-1]
                m += f[i]
            ans = max(m,ans)
    else:
        m = sum(f[:2*k])
        ans = m
        for i in range(2*k,n):
            m -= f[i-2*k]
            if not i%2:
                m += f[i]
                m += f[i+1]
            ans = max(m,ans)
    print(ans)
    return

#F
def F():
    n = I()
    a = LI()
    s = [0,0,0]
    for i in a:
        if i%4 == 0:
            s[0] += 1
        elif i%2 == 0:
            s[1] += 1
        else:
            s[2] += 1
    if not s[0]:
        if s[2]:
            print("No")
        else:
            print("Yes")
        return
    if s[2] >= s[0]+1:
        if s[1]:
            print("No")
        else:
            print("Yes")
    else:
        print("Yes")
    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#Solve
if __name__ == "__main__":
    F()

Submission status: Wrong Answer

Solution code:
# 2019/08/09

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

sec=0
quad=0
rem=0
for i in range(n):
    if a[i]%4==0:
        quad+=1
    elif a[i]==2:
        sec+=1
    else:
        rem+=1

if sec>0:rem+=1
if rem-quad<=1:
    print('Yes')
else:print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
tmp,tmp2 = 0,1 if 2 in A else 0
for a in A:
    if a%4 == 0: tmp += 1
    elif a != 2: tmp2 += 1
if tmp2-tmp >= 2: print('No')
else: print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
tmp = 0
for a in A:
    if a%4 == 0: tmp += 3
if tmp >= len(A): print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
n,a=open(0)
a=[int(i)%4for i in a.split()]
f,g=a.count(0),a.count(2)
print('YNeos'[int(n)-f-g>f+(g==0)])

Submission status: Wrong Answer

Solution code:
# 奇数の隣は必ず4の倍数でなくてはならない あとはどうでもよさそう
# ただし 1 4 1 は大丈夫だが 1 4 1 2 はダメ
n = int(input())
arr = list(map(int, input().split()))
dividable_four = 0
odds = 0
for a in arr:
    if a % 4 == 0:
        dividable_four += 1
    elif a % 2 == 1:
        odds += 1
if dividable_four >= odds:
    print('YES')
elif odds - dividable_four == 1 and odds + dividable_four == n:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

ans = 'No'

cnt4 = 0
cnt2 = 0

for aa in a:
    if aa%4 == 0:
        cnt4 += 1
    elif aa%4 == 2:
        cnt2 += 2

if 2*cnt4 + 1 >= N:
    ans = 'Yes'
else:
    res = N - 2*cnt4
    if res <= cnt2:
        ans = 'Yes'
        
print(ans)

Submission status: Wrong Answer

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

f_cnt = 0
t_cnt = 0
o_cnt = 0
for _a in a:
    if _a % 4 == 0:
        f_cnt += 1
    elif _a % 2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if o_cnt == 0:
    print("Yes")
elif o_cnt < 2*f_cnt:
    print("Yes")
elif o_cnt == 2 * f_cnt and t_cnt == 0:
    print("Yes")    
else:
    print("No")

Submission status: Wrong Answer

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

f_cnt = 0
t_cnt = 0
o_cnt = 0
for _a in a:
    if _a % 4 == 0:
        f_cnt += 1
    elif _a % 2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if o_cnt > 2 * f_cnt:
    print("No")
elif o_cnt == 0:
    print("Yes")
elif o_cnt == 2 * f_cnt and t_cnt > 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

f_cnt = 0
t_cnt = 0
o_cnt = 0
for _a in a:
    if _a % 4 == 0:
        f_cnt += 1
    elif _a % 2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if o_cnt > 2 * f_cnt:
    print("No")
elif o_cnt == 0:
    print("Yes")
elif o_cnt == 2 * f_cnt and t_cnt == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

f_cnt = 0
t_cnt = 0
o_cnt = 0
for _a in a:
    if _a % 4 == 0:
        f_cnt += 1
    elif _a % 2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if o_cnt > 2 * f_cnt:
    print("No")
elif o_cnt == 0 and t_cnt == 1:
    print("No")
elif o_cnt == 0:
    print("Yes")
elif o_cnt == 2 * f_cnt and t_cnt == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

f_cnt = 0
t_cnt = 0
o_cnt = 0
for _a in a:
    if _a % 4 == 0:
        f_cnt += 1
    elif _a % 2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if o_cnt == 0:
    if t_cnt > 1:
        print("Yes")
    else:
        print("No")
else:
    if o_cnt > 2*f_cnt:
        print("No")    
    elif o_cnt == 2*f_cnt and t_cnt > 0:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

f_cnt = 0
t_cnt = 0
o_cnt = 0
for _a in a:
    if _a % 4 == 0:
        f_cnt += 1
    elif _a % 2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if o_cnt > 2*f_cnt:
    print("No")
elif o_cnt == 2*f_cnt and t_cnt > 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

f_cnt = 0
t_cnt = 0
o_cnt = 0
for _a in a:
    if _a % 4 == 0:
        f_cnt += 1
    elif _a % 2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if o_cnt >= 2*f_cnt:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

f_cnt = 0
t_cnt = 0
o_cnt = 0
for _a in a:
    if _a % 4 == 0:
        f_cnt += 1
    elif _a % 2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if o_cnt > 2*f_cnt:
    print("No")
elif o_cnt == 2*f_cnt and t_cnt == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

cnt = 0
for _a in a:
    if _a % 4 == 0:
        cnt += 3
    elif _a % 2 == 0:
        cnt += 1

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

Submission status: Wrong Answer

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

num = 0
num2 = 0
num4 = 0

for i in a:
    if i % 4 == 0:
        num4 += 1
    elif i % 2 == 0:
        num2 += 1
    else:
        num += 1
num2 %= 2
num += num2
if num4 * 2 >= num:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
nums=list(map(int,input().split()))
mods=[]
for i in range(n):
  cnt=0
  while nums[i]%2==0:
    nums[i]//=2
    cnt+=1
  mods.append(cnt)
count2=sum(1 for i in mods if i==2)
count0=sum(1 for i in mods if i==0)
if count2+count0==len(mods):
  if count2>=count0-1:
    print("Yes")
  else:
    print("No")
else:
  if count2>=count0:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
#n -= a.count(2)
e,o,t = 0,0,False
for i in a:
    if (i//2)%2 == 0: e += 1
    elif i%2 == 0 and (i//2)%2 == 1:  t = True
    else:    o += 1
if not 2 in a:
    if o<=e+1:  print('Yes')
    else:   print('No')
else:
    if o<=e:    print('Yes')
    else:   print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
#n -= a.count(2)
e,o,t = 0,0,False
for i in a:
    if i%4 == 0: e += 1
    elif i%2 == 0:  t = True
    else:    o += 1
if not 2 in a:
    if o<=e+1:  print('Yes')
    else:   print('No')
else:
    if o<=e:    print('Yes')
    else:   print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
#n -= a.count(2)
e,o = 0,0
for i in a:
    if (i//2)%2 == 0: e += 1
    elif i%2 == 1:    o += 1
if not 2 in a:
    if o<=e+1:  print('Yes')
    else:   print('No')
else:
    if o<=e:    print('Yes')
    else:   print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
#n -= a.count(2)
e,o = 0,0
for i in a:
    if i >= 4 and i%2 == 0: e += 1
    elif i%2 == 1:    o += 1
if not 2 in a:
    if o<=e+1:  print('Yes')
    else:   print('No')
else:
    if o<=e:    print('Yes')
    else:   print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
#n -= a.count(2)
e,o = 0,0
for i in a:
    if i >= 4 and i%2 == 0: e += 1
    if i%2 == 1:    o += 1
if not 2 in a:
    if o<=e+1:  print('Yes')
    else:   print('No')
else:
    if o<=e:    print('Yes')
    else:   print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
#n -= a.count(2)
e,o = 0,0
for i in a:
    if i >= 4 and i%2 == 0: e += 1
    if i%2 == 1:    o += 1
if n%2 == 0:
    if o<=e:    print('Yes')
    else:   print('No')
else:
    if o-1<=e:  print('Yes')
    else:   print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
aa = [2 if i % 4 == 0 else 1 if i % 2 == 0 else 0 for i in a]
a4, a2, a0 = aa.count(2),aa.count(1), aa.count(0)

if a2 == 0:
    a4 += 1

print("YES" if a4 >= a0 else "NO")

Submission status: Wrong Answer

Solution code:

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

b = sum((i % 2 != 0)  for i in l)
bb = sum((i % 2 == 0)  for i in l)
bbbb  = sum((i % 4 == 0)  for i in l)

bb -= bbbb
if bbbb+1 >= b + (bb == 1):print("Yes")
elif b + bbbb == 0 and bb >1:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:

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

b = sum((i % 2 != 0)  for i in l)
bb = sum((i % 2 == 0)  for i in l)
bbbb  = sum((i % 4 == 0)  for i in l)

bb -= bbbb
if bbbb+1 >= b + (bb == 1):print("Yes")
else:print("No")

Submission status: Wrong Answer

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

n1, n4 = 0, 0
for a in A:
	if not a % 4:
		n4 += 1
	elif a % 2:
		n1 += 1

print(["Yes", "No"][not(n1 <= n4 + 1)])

Submission status: Wrong Answer

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

can = four * 2 + 1 + two
if can >= N:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

N -= two
m = 2 * four + 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
odd, nibai, yonbai = 0, 0, 0
for i in range(N):
    if A[i] % 2 != 0:
        odd += 1
    elif A[i] % 4 == 0:
        yonbai += 1
    else:
        nibai += 1
if odd > (N+1)//2:
    print('No')
elif yonbai < 2 and odd > (N+1)//2 - nibai:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter

def a():
    N = int(input())
    A = map(int,input().split(" "))
    c = Counter(map(lambda x:(x%4 and 1)+x%2,A))
    if c[1]:
        return c[2] <= c[0]
    else:
        return c[2] <= c[0] + 1

print(['NO','YES'][a()])

Submission status: Wrong Answer

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

N = int(input())
L = [int(v) for v in input().split()]

m = {
    1: 0,
    2: 0,
    4: 0,
}
for i in range(N):
    t = L[i]
    if t % 4 == 0:
        m[4] += 1
    elif t % 2 == 0:
        m[2] += 1
    else:
        m[1] += 1
        
m[1] += (m[2] // 2) + m[2] % 2

if m[4] + 1 >= m[1]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

N = int(input())
L = [int(v) for v in input().split()]
m = {
    1: 0,
    2: 0,
    4: 0,
}
for i in range(len(L)):
    if L[i] % 4 == 0:
        m[4] += 1
    elif L[i] % 2 == 0:
        m[2] += 1
    else:
        m[1] += 1

m[1] += 1

if m[1] <= m[4] + 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

N = int(input())
L = [int(v) for v in input().split()]
m = {
    1: 0,
    2: 0,
    4: 0,
}
for i in range(len(L)):
    if L[i] % 4 == 0:
        m[4] += 1
    elif L[i] % 2 == 0:
        m[2] += 1
    else:
        m[1] += 1

if m[2] == 1:
    m[1] += 1

if m[1] <= m[4] + 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

N = int(input())
L = [int(v) for v in input().split()]
m = {
    1: 0,
    2: 0,
    4: 0,
}
for i in range(len(L)):
    if L[i] % 4 == 0:
        m[4] += 1
    elif L[i] % 2 == 0:
        m[2] += 1
    else:
        m[1] += 1

if m[2] == 1:
    m[1] += 1

if m[1] <= m[4] * 2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
input()
d={0:0,1:0,2:0}
def cnt(i):i=int(i);d[0 if i%2 else(1 if i%4 else 2)]+=1
list(map(cnt,input().split()))
print(d[0]+1&d[1]>=d[2]and"No"or"Yes")