stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef pair <int, int> pii;



const int maxn = 100001;



int n,a,q,w,e,s;



void input();

void solve();



int main(){

	input();

	solve();

	

	return 0;

}

void input(){

	cin>>n;

	for (int i=0;i<n;i++){

		cin>>a;

		if (a%4==0){

			q++;

		}

		else{

			if (a%2==0){

				w++;

			}

			else{

				e++;

			}

		}

		s++;

	}

	

}

void solve(){

	if (w>0){

		e++;

	}

	while(q>=2 and e>=2){

		q-=2;

		e-=2;

	}

	e--;

	if (e>q){

		cout<<"No";

	}

	else{

		cout<<"Yes";

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.28259102784422x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#define debug 0

#define test 0

#define CPLUS 1

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <math.h>

#include <string.h>

#if CPLUS

#include <iostream>

#include <stack>

#include <string>

#include<algorithm>

using namespace std;

#endif



int a[100005];





int check(int n1, int n2, int n4)

{

	if (n4 >= n1)

		return 1;

	else if (n1 == n4 + 1 && n2 == 0)

		return 1;

	else

		return 0;

}



int main(void)

{

#if debug

	freopen("in.txt", "r", stdin);

#endif

	int i, n;

	cin >> n;

	int n1=0, n2 = 0, n4 = 0;

	for (i = 0; i < n; i++) {

		cin >> a[i];

		if (a[i] % 4 == 0)

			n4++;

		else if (a[i] % 2 == 0)

			n2++;

		else

			n1++;

	}

#if test

	printf("%d %d %d", n1, n2, n4);

#endif

	if (check(n1, n2, n4))

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2781134428846395x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<string.h>

#include<stdlib.h>

#include<sstream>

#include<iostream>

#include<algorithm>

#include<math.h>

#include<vector>

#include<map> //要学会用map 

#include<queue>

#include<stack>

using namespace std;

/*如果a大于0且b大于0，但相加得到的却是小于等于0的说明是正溢出，这时肯定比c大（因为c肯定在long long的范围内）。

如果a小于0且b小于0，但相加得到的却是大于等于0的说明是负溢出，这是肯定比c小。*/

const int maxn = 10001;

int prime[maxn],pNum = 0;

bool p[maxn] = {0};

void Find_Prime()

{

	for(int i=2;i<maxn;i++)

	{

		if(p[i] ==false)

		{

			prime[pNum++]=i;

			for(int j=i+i;j<maxn;j+=i)

			{

				p[j] = true;

			}

		}

	}

}

int main(){

	int n;

	scanf("%d",&n);

	int count = 0;

	for(int i=0;i<n;i++)

	{

		int temp;

		scanf("%d",&temp);

		if(temp%4==0) count+=2;

		else if(temp%2==0) count+=1;

	}

	if(n%2==0)

	{

		if(count>=n) printf("Yes");

		else printf("No");

	}

	else

	{

		if(count>=n-1) printf("Yes");

		else printf("No");

	}

	return 0;	

}

// Faster C++ solution for the same problem (measured speedup: 5.231373337103439x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include <stdio.h>

#include <bits/stdc++.h>



#define MAXN 100000

/*

bool check1(int *a, int n);

bool check2(int *a, int n);



int main()

{

    int n, i, a[MAXN];

    scanf("%d", &n);

    for(i = 0; i < n; i++)

    {

       scanf("%d", &a[i]);

    }

    if(check1(a, n) == false)

        printf("No");

    else

        printf("Yes");

}

bool check1(int * a, int n)

{

   int *p, i;

   if(check2(a, n) == false)

        return false;

    else

    {

        for(i = 0; i < n; i++)

        {

           *p = * (a + n);

           * (a + n) = * (a + i);

           * (a + i) = * p;

           if(check1(a, n-1) == false || a[n-2] * a[n-1] % 4 != 0)

              return false;

           *p = * (a + n);

           * (a + n) = * (a + i);

           * (a + i) = * p;

        }

    }

    return true;

}

bool check2(int * a, int n)

{

    int i;

    for(i = 1; i < n - 1; i++)

    {

        if(a[i] * a[i-1] % 4 != 0 || a[i] * a[i+1] % 4 != 0)

            return false;

    }

    if(a[0] * a[1] % 4 != 0 )

        return false;

    return true;

}

*/

int main()

{

    int n, i, a[MAXN], a4 = 0, a2 = 0, a1 = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++)

    {

       scanf("%d", &a[i]);

       if(a[i] % 4 == 0)

        a4++;

       if(a[i] % 2 == 0 && a[i] % 4 != 0)

        a2++;

       if(a[i] % 2 != 0)

        a1++;

    }

    if(a4 >= a1)

    {

          printf("Yes\n");

    }

    else

    {

        if(a4 == a1 - 1 && a2 == 0 )

            printf("Yes\n");

        else

            printf("No\n");

    }

}




// Faster C++ solution for the same problem (measured speedup: 5.312885157235827x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

#include<math.h>

#include<algorithm>

#include<string>

#include<stack>

using namespace std;

typedef  long long LL;

const int maxn=505;

char tmp[maxn];

int dp[maxn][maxn];

int max(int a,int b)

{

    if(a<b)

        return b;

    return a;

}

/*LL gcd(LL a,LL b)

{

    if(b==0)

        return a;

    return gcd(b,a%b);

}

LL lcm(LL a,LL b)

{

    return a/gcd(a,b)*b;

}*/



int main()

{

     int n;

     cin>>n;

     int num_4=0;

     int num_2=0;

     int n2=n;

     while(n2--)

     {

         LL m;

         cin>>m;

         if(m%4==0)

            num_4++;

         else if(m%2==0)

         {

             num_2++;

         }



     }

     int sum=0;

     sum=num_4*2+1;

     if(sum>=n)

     {

          cout<<"Yes"<<endl;

     }

     else

     {  sum+=num_2;

     if(sum>n)

        cout<<"Yes"<<endl;

     else

        cout<<"No"<<endl;



     }





    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.315412845747401x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
//#define _CRT_SECURE_NO_WARNINGS

#define LOCAL_CHUNYU



//#include <iostream>

#include <cstdio>

#include <vector>

#include <algorithm>

#include <cstring>	//memset

#include <ctime>

//#include <cmath>





using std::vector;

using std::sort;

using std::swap;



typedef long long LL;

const int maxn = 1e5 + 10;

const int mod = 1e9 + 7;

const double eps = 1e-8;

//const double pi = acos(-1.0);



#define equ(a,b) ((fabs((a)-(b))) < (eps))

#define gth(a,b) (((a)-(b)) > (eps))

#define lth(a,b) (((a)-(b)) < (-eps))

#define gequ(a,b) (((a)-(b)) > (-eps))

#define lequ(a,b) (((a)-(b)) < (eps))







int main() {

#ifdef LOCAL_CHUNYU

	//freopen("in.txt", "r", stdin);

#endif // LOCAL_CHUNYU



//    int N;

//    scanf("%d",&N);

//    int *sample = new int[N];

//    for(int i = 0; i < N; ++i){

//        scanf("%d",sample + i);

//    }

//    sort(sample, sample + N);

//    int flag = 0;

//    for(int i = 0; i < N - 1; ++i){

//        int temp = i + 1;

//        int j;

//        for(j = temp; j < N; ++j){

//            if(sample[j] * sample[i] % 4 == 0){

//                if(j == temp)

//                    break;

//                else{

//                    swap(sample[temp], sample[j]);

//                    sort(sample + temp + 1, sample + N);

//                    break;

//                }

//

//            }

//

//        }

//        if(j == N){

//            flag = 1;

//            printf("No\n");

//            break;

//        }

//    }

//    if(flag == 0){

//        printf("Yes\n");

//    }



    int N;

    scanf("%d",&N);

    int *sample = new int[N];

    for(int i = 0; i < N; ++i){

        scanf("%d",sample + i);

    }

    int a4 = 0, a2 = 0, a1 = 0;

    int temp;

    for(int i = 0; i < N; ++i){

        temp = sample[i];

        if(temp % 4 == 0)

            a4++;

        if(temp % 2 == 0 && temp % 4 != 0)

            a2++;

        if(temp % 2 != 0)

            a1++;

    }

    if(a4 >= a1){

        printf("Yes\n");

        return 0;

    }

    if(a2 == 0 && a4 == a1 -1){

        printf("Yes\n");

        return 0;

    }

    printf("No\n");











	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.858519083581346x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

using namespace std;



int main()

{

	int n;

	cin>>n;

	int A=0,B=0,C=0,x;

	while(n--)

	{

		cin>>x;

		if(x%2==0&&x%4==0)A++;

		else if(x%2==0)B++;

		else C++;

	}

	if(A>=C)cout<<"Yes";

	else if(B==0&&C-A==1)cout<<"Yes";

	else cout<<"No";

	//system("pause");

}

// Faster C++ solution for the same problem (measured speedup: 5.2887786206953615x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cstdio>

#include <cstring>



using namespace std;



int ans[26];



int main(){

    int n;

    scanf("%d",&n);

    long long r1 = 0,r2 = 0;

    for (int i = 0; i < n;i++ ){

        int k;

        scanf("%d",&k);

        if(k%4==0){

            r1++;

        }

        else if(k%2==0){

            r2++;

        }

    }

    if (n > r1*2+1+r2 ){

        printf("No");

    }

    else if (n == r1*2 + r2+1&&r2!=0){

        printf("No");

    }

    else{

        printf("Yes");

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.231014943240365x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

	int n; scanf("%d", &n);

	int c4 = 0, c2 = 0, c1 = 0;

	for(int i = 0; i < n; i++) {

		int k; scanf("%d", &k);

		if(k % 4 == 0) c4++;

		else if(k % 2 == 0) c2++;

		else c1++;

	}

	if(c4 >= c1) puts("Yes");

	else {

		if(c4 + 1 == c1 && !c2) puts("Yes");

		else puts("No");

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.227488158762696x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

const int N = 100010;

int a[N];

int main(){

	ios::sync_with_stdio(0);

	cin.tie(0), cout.tie(0);

	int n; cin >> n;

	int cnt2 = 0, cnt4 = 0, cnt1 = 0;

	for(int i = 0; i < n; i++){

		cin >> a[i];

		if(a[i] % 4 != 0 && a[i] % 2 == 0)

			cnt2++;

		if(a[i] % 4 == 0) cnt4++;

		if(a[i] % 2) cnt1++;

	}

	if(cnt4 == 0){

		if(cnt1 == 0)

			cout << "Yes\n";

		else

			cout << "No\n";

	}

	else{

		if(cnt2 > 0){

			if(cnt1 <= cnt4)

				cout << "Yes\n";

			else

				cout << "No\n";

		}

		else{

			if(cnt1 <= cnt4 + 1)

				cout << "Yes\n";

			else

				cout << "No\n";

		}

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.364870314483645x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()

{

	int n;

	scanf("%d",&n);

	ll temp;

	int num3=0;

	int num2=0;

	int num1=0;

	for(int i=1;i<=n;i++)

	{

		scanf("%lld",&temp);

		if(temp%4==0)

		{

			num1++;

		}

		else if(temp%2==0)

		{

			num2++;

		}

		else

		{

			num3++;

		}

	}

	if(num2)

	{

		num2=1;

	}

	if(num1>=(num2+num3-1))

	{

		printf("Yes\n");

	}

	else

	{

		printf("No\n");

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.230845579281399x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<iostream>

#include<algorithm>

#include<cmath>

#include<string>



using namespace std;



int main(){

	int n,m[100001];

	cin>>n;

	int a=0,b=0;

	for(int i=0;i<n;i++){

		cin>>m[i];

		if(m[i]%2==0&&m[i]%4!=0) a++;

		if(m[i]%4==0) b++;

	}

	if(a==n) cout<<"Yes";

	else if(b>=n/2) cout<<"Yes";

	else if(a+b>=n-b) cout<<"Yes";

	else cout<<"No";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.328640981863082x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include <cstdio>

#include<iostream>

#include<cmath>

#include<queue>

#include<algorithm>

#include<cstring>

#include<string>

#include<vector>

#define MAXN 5003

using namespace std;









int main(){

    vector<int> a1;

    vector<int> a2;

    vector<int> a4;

    bool flag=1;

    int n;

    cin >> n;

    for(int i=0; i<n; i++){

        int a;

        cin >> a;

        if(a%4 == 0)

            a4.push_back(a);

        else if(a%2 == 0)

            a2.push_back(a);

        else

            a1.push_back(a);

    }



    if(a4.size() + 1 < a1.size()){

        flag = 0;

    }else if(a4.size() < a1.size()){

        if(a2.size() > 0)

            flag = 0;

    }

    if(flag) cout << "Yes" << endl;

    else cout << "No" << endl;





    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.358310612571407x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

int main() {

	int n;

	cin>>n;

	int x,y,z;

	x=y=z=0;

	for(int i = 0; i < n; i++)

	{

		int m;

		cin>>m;

		if(m%4==0)

		x++;

		else if(m%2==0)

		y++;

		else

		z++;

	}

	if(z<=x||(z==x+1&&y==0))

	cout<<"Yes"<<endl;

	else

	cout<<"No"<<endl;

	return 0; 

}

// Faster C++ solution for the same problem (measured speedup: 5.303196351631416x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
/*

        Author: Prokash

                CSE48, JU



*/



#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()

{

    FAST;

    ll n,t,i,d,d2;

    cin>>t;

    d=0;

    d2=0;

    for(i=0; i<t; i++)

    {

        cin>>n;

        if(n%4==0)

        {

            d++;

        }

        if(n%4==2)

        {

            d2++;

        }

    }

    ll s=t/2;

    if(d>=s)

    {

        cout<<"Yes"<<endl;

    }

    else if((d2/2+d)>=s)

    {

        cout<<"Yes"<<endl;

    }

    else

    {

        cout<<"No"<<endl;

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.372864506194713x):
#include <cstdio>

//找规律 不用真正模拟计算，只要找出数字个数的规律

int main(void)

{

    int a1count = 0, a2count = 0, a4count = 0;

    int i, N, x;

    scanf("%d", &N);

    while (N--)

    {

        scanf("%d", &x);

        if (x % 4 == 0)

            a4count++; //是4的倍数，可以放在任何数旁边构成幸运数列

        else if (x % 2 == 0)

            a2count++; //不是4但是2的倍数，要么放在a4旁边，要么放在a2 自己旁边

        else

            a1count++;//不是2的倍数，也不是4的倍数，就是其他数字，必须放在a4旁边

    }

    //先让a1与a4交替出现，a1的个数只能比a4的个数最多多一个，最好小于a4的个数

    if (a2count > 0 && a1count <= a4count) //类似 a1,a4,a1,a4,a2,a2,a2...

        printf("Yes\n");

    else if (a2count == 0 && a1count <= a4count + 1)//类似 a1,a4,a1 

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}