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: Accepted

Solution code:
N=int(raw_input())
A=[int(x) for x in raw_input().split()]
o=0
e=0
f=0
for a in A:
    if a%4==0:
        f+=1
    elif a%2==0:
        e+=1
    else:
        o+=1
if o==0 or f>=o or (e==0 and f+1==o):
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

Solution code:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


yes = "Yes"
no = "No"


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

four = 0
two = 0
none = 0
for e in a:
	if e % 4 == 0:
		four += 1
	elif e % 2 != 0:
		none += 1
	else:
		two += 1

if four >= none or (two == 0 and four+1 >= none):
	print(yes)
else:
	print(no)

Submission status: Accepted

Solution code:
# C
N = int(input())
a_list = list(map(int, input().split()))

cnt_4 = 0
cnt_2 = 0

for a in a_list:
    if a % 4 == 0:
        cnt_4 += 1
    elif a % 2 == 0:
        cnt_2 += 1
        
cnt_1 = N - cnt_4 - cnt_2

if cnt_4 >= cnt_1:
    print("Yes")
elif cnt_4 + 1 == cnt_1 and cnt_2 == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
input()
c1, c2, c4 = 0, 0, 0
for a in map(int, input().split()):
    if a & 1:
        c1 += 1
    elif a & 2:
        c2 += 1
    else:
        c4 += 1

if c2:
    print('Yes' if c4 >= c1 else 'No')
else:
    print('Yes' if c4 and c4 + 1 >= c1 else 'No')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
nep = 0
par = 0
cet = 0
for x in a:
    if x % 2 != 0:
        nep += 1
    elif x % 4 != 0:
        par += 1
    else:
        cet += 1

last = 0
for i in range(n):
    if last == 0:
        if nep:
            nep -= 1
            last = 1
        elif par:
            par -= 1
            last = 2
        else:
            cet -= 1
            last = 0
        continue
    if last == 2:
        if par:
            par -= 1
            last = 2
        elif cet:
            cet -= 1
            last = 0
        else:
            print('No')
            exit(0)
        continue 
    if cet:
        cet -= 1
        last = 0
    else:
        print('No')
        exit(0)
print('Yes')

Submission status: Runtime Error

Solution code:
import math

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

c_4=0
c_2=0

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


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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

oddcount=0
mod40=0
other=0

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

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

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

Submission status: Runtime Error

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

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

oddcount=0
mod40=0
other=0

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

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

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

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

Submission status: Runtime Error

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

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

oddcount=0
mod40=0
other=0

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

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

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

else:
    print(np.array())

Submission status: Runtime Error

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

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

    oddcount=0
    mod40=0
    other=0

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

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

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

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

Submission status: Runtime Error

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

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

oddcount=0
mod40=0
other=0

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

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

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

else:
    print(np.array)


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

Submission status: Runtime Error

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

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

oddcount=0
mod40=0
other=0

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

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

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

else:
    print(np.array)


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

Submission status: Runtime Error

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

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

oddcount=0
mod40=0
other=0

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

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

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

else:
    print(np.array)

Submission status: Runtime Error

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

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

oddcount=0
mod40=0
other=0

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

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


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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if N==3:
    if a==3 or (a>=1 and b==0):
        print('No')
    else:
        print('Yes')
else:
    if a=<b:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
colors=[]
for i in range(n):
    for _ in range(a[i]):
        colors.append(i+1)
ans=[[0 for _ in range(w)] for _ in range(h)]
temp=0
for i in range(h):
    for j in range(w):
        if i%2!=0:
            j = w-j-1
        ans[i][j]=colors[temp]
        temp+=1

for i in range(h):
    for j in range(w):
        print(ans[i][j], end="")
    print()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

# four = sum([1 for a in As if a%4 == 0])
# odd = sum([1 for a in As if a%2 == 1])
# two = sum([1 for a in As if a%2 == 0 and a%4 != 0])
four = 0
odd = 0
two = 0
for a in As:
    if a % 2 == 1:
        odd += 1
    elif a % 4 == 0:
        four += 1
    else:
        two += 1


if four < two%2 + odd - 1:
    print("No")
else:
    print("Yes")


fields @timestamp, @message
| sort @timestamp desc
| filter 
| limit 20

Submission status: Runtime Error

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

for i in range(len(N)):
  if a[i]%4==0:
    c4+=1
  if a[i]%2==0:
    c2+=1

nodd=N-c2
c4=c4-c2

if nodd<c4:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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_1=0:
    if cnt_2+1>=cnt_0:
        print("Yes")
    else:
        print("No")

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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]
    
    # a = [i % 4 for i in an]
    
    for i in range(len(N)-1):
        a = an[i]
        b = an[i+1]
        c = a * b
        if c % 4 != 0:
            print('No')
            
    print('Yes')
    
    
    
    
    
    
main()

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = len(a[a % 4 == 0])
a2 = len(a[a % 2 == 0 and a % 4 != 0])
a4n = len(a[a % 4 != 0]) - a2 

if a2 != 0:
  print("Yes" if a4 + 1 >= a4n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a4n else "No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
aList = [int(i) for i in input().split()]
d = {1: 0, 2: 0, 4: 0}

for a in aList:
  if a % 2 == 0:
    d[2] += 1
  elif a % 4 == 4:
    d[4] += 1
  else:
    d[1] += 1
    
ans === "No"
if d[1] <= d[4]:
  ans = "Yes"
elif d[1] - d[4] == 1:
  if d[2] == 0:
    ans = "Yes"
    
print(ans)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
n=int(input())
lis=list(map(int,input().split()))
ans=[]
cnt=0
s=""
hh=0
for i in range(n):
  for j in range(lis[i]):
    if hh==0:
      s=s+str(i+1)+" "
    else:
      s=str(i+1)+" "+s
    cnt+=1
    if cnt==w:
      ans.append(s)
      s=""
      cnt=0
      hh=(hh+1)%2
for i in range(h):
  print(ans[i])

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int, input().split()))
k = []
k_2 = []
k_4 = []

for i in l:
    if i % 4 == 0:
        k_4.append(i)
    elif i % 2 == 0:
        k_2.append(i)
    else:
        k.append(i)


if len(k_4) >= len(k)-1 and k_2%2 == 0: 
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s,p,j = 0,0,0
c = []
for i in range((31-n)+1):
  c.append(a[s]) #昼夜昼夜の順にまとめちゃう
  c.append(b[s]) #まとめた配列をc[]とする
  s += 1
  i += 1
while (j < 2*(31-(n-1))-2): #ここ自分でもよくわかんない
  if (c[j] == 0 and c[j+1] == 0 and c[j+2] == 0 ): #3つ連続で予定が空いてたら行ける
    p = 1
    print(n+int(j / 2)) #何日かを出力
    if (j%2 == 0): #jが偶数だったら昼、そうでなかったら夜
      print("D")
    else:
      print("N")
    break
  j += 1
if (p == 0):
  print(-1)

Submission status: Runtime Error

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

c2=0
c4=0

for i in l:
	if i%4 == 0:
		c4+=1
		
	if i%2 == 0:
		c2+=1
		

c2 = c2-c4

if c2=1:
	if n - (2*c4+2) <=0:
		print('Yes')
	else:
		print('No')
elif c4=0:
	if n==c2:
		print('Yes')
	else:
		print('No')
		
else:
	if n - (2*c4+2 + c2) <= 0:
		print('Yes')
	else:
		print('No')

Submission status: Runtime Error

Solution code:
#include<cstdio>
int main(){int n,a = 0,b = 0; scanf("%d",&n); for(int i=1;i<=n;i++){ int c; scanf("%d",&c);
if(!(c % 4)) a++; else if(!(c % 2)) b++;} if(b > 1) n -= b;
if(a * 2 >= n) printf("Yes"); else printf("No");}

Submission status: Runtime Error

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

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

    if a[i] != 2:
        if a[i] * 2 % 4 == 0:
            two_count += 1

num = a.count(2)
while num % 2 == 0:
    num //= 2
    count += 1

if num > 0:
    if two_count >= 1:
        count += 1

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

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
for i in range(N):
    A += [i + 1] * a[i]
 
L = [[0 for i in range(W)] for j in range(H)]
for i in range(H * W):
    if int((i // W)) % 2 == 0:
        L[int((i // W))][i % W] = A[i]
    else:
        L[int((i // W))][-1 - i % W] = A[i]
 
for i in range(H):
    L[i] = list(map(str, L[i]))
 
 
for i in range(H):
    print(" ".join(L[i]))

Submission status: Runtime Error

Solution code:
N = int(input())

two_ad = 0
four_ad = 0
other = 0
for _ in range(N):
  a = int(input())
  if a % 4 == 0 and a % 2 == 0:
    four_ad += 1
  elif a % 4 == 0:
    four_ad += 1
  elif a % 2 == 0:
    two_ad += 1
  else:
    other += 1

if not two_ad and not four_ad:
  ans = "No"
elif not two_ad:
  if other == four_ad + 1 or four_ad > other:
    ans = "Yes"
  else:
    ans = "No"
elif not four_ad:
  ans = "No"
elif not other:
  ans = "Yes"
elif four_ad == other == two_ad:
  ans = "Yes"
else:
  ans = "No"
print(ans)

Submission status: Runtime Error

Solution code:
import sys
#stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

odd = 0
ml2 = 0
ml4 = 0

for ai in a:
    if ai % 2:
        odd += 1
    elif ai % 4:
        ml2 = 1
    else:
        ml4 += 1

print("Yes" if (odd + ml2) <= (ml4 + 1) else "No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
t1 = 0
t2 = 0
t4 = 0
for i in a:
    if i % 4 == 0:
        t4 += 1
    elif i % 2 == 0:
        t2 += 1
    else:
        t1 += 1
if (t4 >= t1) or (t2 == 0 and t4+1 == t):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))
c = [[0]*(W) for i in range(H)]
l = []
for m,color in enumerate(a,1):
    l += [color]*m
for i in range(H):
    k = l[:W]
    l = l[W:]
    if i%2 != 0:
        k.reverse()
    print(*k)

Submission status: Runtime Error

Solution code:
from math import ceil
n=int(input())
ans4=0
ans2=0
ans0=0
a=list(map(int,input().split()))
for i in range(n):
  if a[i]%4==0:
    ans4+=1
  elif a[i]%2==0:
    ans2+=1
  else:
    ans0+=1
if ans2>0:
  if ans0<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if ceil((ans0+ans4)/2)>=:ans0
    print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
n=int(input())
ans4=0
ans2=0
a=input().split()
for i in range(n):
  if a[i]%4==0:
    ans4+=1
  elif a[i]%2==0:
    ans2+=1
  else:
    pass
if (n-ans2)//2+1<=ans4:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
H, W = (int(i) for i in input().split())
N = int(input())
A = [int(i) for i in input().split()]
C = []
for i in range(N):
  for j in range(A[i]):
    C.append(i+1)
ans = [[0]*W for i in range(H)]
for i in range(H*W):
  y = i // W
  if y%2==0:
    x = i%W
  else:
    x = W-1-i%W
  ans[x][y] = C[i]
for i in range(H):
  ans[i] = [str(a) for a in ans[i]]
  print(" ".join(ans[i]))

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
c4=0
c2=0
for i in range(N):
  if A[i]%4==0:
    c4+=1
  elif A[i]%2==0:
    c2+=1
if c4:
  a = c4*2+1
else:
  a = 0
if c2>1:
  b = c2b
  if a:
    a -= 1
else:
  b = 0
if a+b>=N:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

for ai in a:
    if ai % 4 == 0:
        cnt += 1
    else:
        if ai % 2 == 0:
            cnt += 0.5
            n -= 0.5

if math.floor(cnt) >= (math.ceil(n) - 2):
    print('yes')
else:
    print('no')

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')

Submission status: Runtime Error

Solution code:
N=int(input())
a=[int(i) for i in input().split()]
num4=0
num2=0
num1=0
for i in a:
        if i%4==0:
                num4+=1
        elif i%2==0:
                num2+=1
num1=N-num4-num2

if num2>0:
        num1+=1

if num1<=num4+1:
        print("Yes")
else:
        print("No")                                                                      ~                                                                                   ~

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
ls = list(map(int, input().split()))
k = len(ls)
p = [ i for i in ls if (i%4) == 0]
j = [ i for i in ls if (i%4) != 0]
r = [ i for i in j if (i%2) == 0]

if(len(p) >= int(k/2)):
    print('Yes')
elif (len(p) >= (len(j) - len(r))):
    print('Yes')
else:
    print('No')
----

Submission status: Runtime Error

Solution code:
raw_input()
l = map(int, raw_input().split())
memo = {}

def get_min(l):
    if (l[0], l[-1]) in memo:
        return memo[(l[0], l[-1])]
    r = [(_, idx) for idx, _ in enumerate(l) if idx % 2 == 0]
    first_val, first_idx = min(r)
    r = [(_, idx) for idx, _ in enumerate(l) if idx % 2 != 0 and idx > first_idx]
    second_val, second_idx = min(r)
    ret = (first_val, first_idx, second_val, second_idx)
    memo[(l[0], l[-1])] = ret
    return ret

ls = [l]
while (len(ls) > 0):
    first_val = -1
    for lidx, l in enumerate(ls):
        _first_val, _first_idx, _second_val, _second_idx = get_min(l)
        if _first_val < first_val or first_val < 0:
            first_val, first_idx, second_val, second_idx = get_min(l)
            _lidx = lidx
    print first_val, second_val,
    _l = ls.pop(_lidx)
    if first_idx > 0:
        ls.append(_l[:first_idx])
    if first_idx + 2 < second_idx:
        ls.append(_l[first_idx + 1:second_idx])
    if second_idx + 1< len(_l):
        ls.append(_l[second_idx + 1:])

print

Submission status: Runtime Error

Solution code:
n = int(input())
q=0
w=0
e=0
a = list(map(int, input().split()))
for b in a:
    if b % 2 ==0&& b % 4!=0:
        q+=q
    elif b%4 ==0:
        e+=e
    elif b%2!=0:
        w+=w

q=q/2
q=q+e
if(w<=q):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
q=0
w=0
e=0
a = list(map(int, input().split()))
for b in a:
    if b % 2 ==0:
        q+=q
    elif b%4 ==0:
        e+=e
    elifb%2!=0:
        w+=w

q=q/2
q=q+e
if(w<=q):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

num_4 = sum([ 1 for i in A if i%4 == 0])
num_2 = sum([ 1 for i in A if i%2 == 0]) - num_4
num_odd = N - num_2 - num4

if num_4 > num_odd:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
#ARc080C

n=int(raw_input())
l=map(int,raw_input().split())
cnt1=cnt2=cnt4=0
for i in xrange(n):
 if (l[i]%2)%2==0:
  cnt4+=1
 elif l[i]%2==0:
  cnt2+1=1
 elif l[i]%2:
  cnt1+=1
if cnt2==0:
 if cnt1<=cnt4+1:
  print 'Yes'
 else:
  print 'No'
else:
 if cnt1<=cnt4:
  print 'Yes'
 else:
  print 'No'

Submission status: Runtime Error

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

f,t,z=0,0,0
for x in xs:
  if x % 4 == 0:
    f+=1
  elif x % 2 == 0:
    t += 1
  else:
    z += 1
z += t
print('Yes' if z + 1 < f then 'No')

Submission status: Runtime Error

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

q = []
summation = [p[i] + p[i + 1] for i in range(N - 1)]
for i in range(int(N / 2)):
    if len(p) == 2:
        q = p + q
    else:
        index = summation.index(max(summation))
        q = p[index:index + 2] + q
        p = p[:index] + p[index + 2:]
        if index == 0:
            summation = summation[2:]
        elif index == len(summation):
            summation = summation[:index - 1]
        else:
            summation = summation[:index - 1] + [p[index - 1] + p[index]] + summation[index + 2:]

[print(i, end=' ') for i in q]

Submission status: Runtime Error

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

q = []
summation = [p[i] + p[i + 1] for i in range(N - 1)]
for i in range(int(N / 2)):
    if len(p) == 2:
        q = p + q
    else:
        index = summation.index(max(summation))
        q = p[index:index + 2] + q
        p = p[:index] + p[index + 2:]
        print(index, summation)
        if index == 0:
            summation = summation[2:]
        elif index == len(summation):
            summation = summation[:index - 1]
        else:
            summation = summation[:index - 1] + [p[index - 1] + p[index]] + summation[index + 2:]

[print(i, end=' ') for i in q]

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
h, w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
grid = [[' ']*w for i in range(h)]

ci = 0
for i in range(h):
    for j in range(w):
        if not a[ci]: ci+= 1
        if i%2==0: grid[i][j] = ci+1
        else: grid[i][~j] = ci+1
        a[ci]-= 1
for row in grid: print(*row)

Submission status: Runtime Error

Solution code:
6
2 7 1 8 2 8