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

using namespace std;

const int N = 1e2+9;

const double pi = acos(-1.0);

#define ll long long

ll dp[N];

ll a[N];

ll n,m,d,x;

int _,__,___;

int main()

{

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

   cin>>n;

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

   {

       int t;

       cin>>t;

       if(t%4==0) _++;

       else if(t%2==0) __++;

       else ___++;

   }

   if(_>=(n>>1) || _ >= ___) cout<<"Yes"<<endl;

   else cout<<"No"<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.30914427821535x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

using namespace std;

const int N = 1e2+9;

const double pi = acos(-1.0);

#define ll long long

//ll dp[N];

//ll a[N];

ll n,m,d,x;

int _,__,___;

int main()

{

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

  

ios::sync_with_stdio(false);

 cin>>n;

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

   {

       int t;

       cin>>t;

       if(t%4==0) _++;

       else if(t%2==0) __++;

       else ___++;

   }

   if(_>=(n>>1) || _ >= ___) cout<<"Yes"<<endl;

   else cout<<"No"<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.374507421535247x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

using namespace std;



int main(){

	int n;cin >> n;

	int cnt = 0,cnt1 = 0, cnt2= 0;

	int a;

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

		cin >> a;

		if(a% 4 == 0) cnt ++;

		else{

			if(a&1) cnt1++;

			else cnt2++;

		}

	}

	if(cnt2>0 && cnt1<=cnt)

		printf("Yes\n");

	else if(cnt2==0 && cnt1<=cnt+1)

		printf("Yes\n");

	else

		printf("No\n");



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.271226109082723x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

}
// 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.275953688660754x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

using namespace std;



int main(int argc, char const *argv[])

{

	int N;

	int ai, a1, a2, a4;



	a1 = a2 = a4 = 0;

	cin >> N;



	while(N--)

	{

		cin >> ai;

		if(ai % 4 == 0)

			a4++;

		else if(ai % 2 == 0)

			a2++;

		else

			a1++;

	}



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

		cout << "Yes";

	else if(a2 != 0 && a4 >= a1)

	{

		if(a4 != 0)

			cout << "Yes";

		else if(a2 > 1)

			cout << "Yes";

		else

			cout << "No";

	}

	else

		cout << "No";

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.281925268062074x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

using namespace std;

int main()

{

    int n,ans1=0,ans2=0,temp;

    cin>>n;

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

	{

		cin>>temp;

		if(temp%2==0)

		{

			if(temp%4==0)

				ans1++;

			else

				ans2++;

		}

	} 

	n=n-ans2-ans1;

	if(ans2==0)

	{

		if(n<=ans1+1)

		cout<<"Yes\n";

		else

			cout<<"No\n";

	}

	else

	{

		if(n<=ans1)

		 	cout<<"Yes\n";

		else

			cout<<"No\n";

	}

    return 0;

    

}

// Faster C++ solution for the same problem (measured speedup: 5.281553147484827x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

#include<cstdio>

using namespace std;



int main(){

	int n,*a,i,k_2=0,k_4=0;

	scanf("%d",&n);

	a=new int[n];

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

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

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

			k_4++;

		}

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

			k_2++;

		}

	}

	if(k_4>=n/2){

		printf("Yes");

	}

	else{

		if((2*k_4+k_2)>=n){

			printf("Yes");

		}

		else{

			printf("No");

		}

	}

	return 0;

	system("pause");

}

// Faster C++ solution for the same problem (measured speedup: 5.229593216384246x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

#include <algorithm>

#include <vector>

#include <list>

#include <climits>

#include <queue>

#include <string>

#include <map>

#include <stack>

#include <cmath>

#include <regex>

#include<ctime>

#include<set>

using namespace std;

int main()

{

ios::sync_with_stdio(false);

int n;

int d[100000];

cin>>n;

int i1=0,i2=0;

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

{

     cin>>d[i];

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

        i1++;

     else if(d[i]%2!=0)

        i2++;

}

if(i1+i2==n&&i2==i1+1)

    cout<<"Yes"<<endl;

else if(i1>=i2)

    cout<<"Yes"<<endl;

else

    cout<<"No"<<endl;







}


// Faster C++ solution for the same problem (measured speedup: 5.402763195515882x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

using namespace std;



int main ()

{

	int n,i,j,k,mod2=0,mod4=0,gg=0;

	int a[100005];

	cin>>n;

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

	{

		cin>>a[i];

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

			mod4++;

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

			mod2++;

		else

			gg++;

	}

	if(mod4>=gg)

		cout<<"Yes"<<endl;

	else //mod4 < gg

	{

		if(mod2 == 0)

		{

			if(mod4+1>=gg)

				cout<<"Yes";

			else

				cout<<"No";

		}

		else// mod4<gg && mod2!=0

		{

			//if( 2 * mod4 + mod2 >= n )

			if(mod4 >= gg)

				cout<<"Yes";

			else

				cout<<"No";

		}

	}



	return 0;

}

/*分类讨论下。

显然，任意数和 4 的倍数相乘，其结果仍是 4 的倍数；

显然，若存在任意数量 2 的倍数，两两之间乘起来就是 4 的倍数；

如果存在一个数既不是 4 的倍数，也不是 2 的倍数（即因子里没有 2 ）：

放在 2 的倍数旁边，一定不符合要求；

放在 4 的倍数旁边，两两相乘一定是 4 的倍数。

因此符合要求的排列一定是，所有 2 的倍数相邻排在一起，

所有 4 的倍数和剩下的数相间排列，这

些剩下的元素个数不能超过 4 的倍数的数量，不

然所有 4 的倍数都被包起来了。*/




// Faster C++ solution for the same problem (measured speedup: 5.329650072671824x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

}
// Slower C++ solution:
#include "math.h"

#include "queue"

#include "algorithm"

#include "iostream"

using namespace std;









int main()

{



	int ou = 0,ji = 0 ,si = 0;

	int a[100003];

	int num;

	scanf("%d",&num);

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

	{

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

	}

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

	{

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

			si++;

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

			ou++;

		else

			ji++;

	}

	int flag = 0;

	if(ou > 0)

		flag = 1;

	if(si + 2 >= ji + 1 + flag)

		printf("Yes");

	else

		printf("No");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.264677613292243x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

using namespace std;

const int maxn = 1e6+5;

struct stu{

    int data;

    int x;

};

int main(){

    //struct stu arr[maxn];

    int a=0,b=0,c=0,i,n;

    cin>>n;

    int s;

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

        cin>>s;

        if(s%4==0){

            a++;

        }

        else if(s%2==0){

            b++;

        }

        else{

            c++;

        }

    }

    if(a>=c){

        if(a==0&&b<=1){

            cout<<"No";

        }

        else{

            cout<<"Yes";

        }



    }

    else if(b==0&&c<=a+1){

        cout<<"Yes";

    }

    else{

        cout<<"No";

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.283799479091074x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

#include <cstdio>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <iomanip>

#include <cstdlib>

#include <cctype>

#define ll long long

#define PI 3.14159265358979323846

using namespace std;

const int maxn = 1e6+7;



int main(){

	int n;

	cin>>n;

	int *a=new int[n];

	int sum=0;

	int sum2=0;

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

		cin>>a[i];

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

			sum++;

		}

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

			sum2++;

		}

	}

	if(sum>=n/2){

		cout<<"Yes"<<endl;

	}

	else if(sum+sum2/2>=n/2&&sum2>=2){

		cout<<"Yes"<<endl;

	}

	else{

		cout<<"No"<<endl;

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.302700440869393x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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



using namespace std;



const int maxn = 1e5 + 5;



int a[maxn];



int main()

{

	int n;

	scanf("%d",&n);

	int four = 0;

	int two = 0;

	int one = 0;

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

	{

		cin >> a[i];

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

			four++;

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

			two++;

		else

			one++;

	}

	

	if(one > four + 1|| (one == four + 1 && two != 0))

		cout << "No" << endl;

	else

		cout << "Yes" << endl; 

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.323614255052015x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

using namespace std;



int main() {

	ios::sync_with_stdio(0);

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

	int n; cin >> n;

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

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

		int x; cin >> x;

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

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

		else ++ c1;

	}

	if(c4 < c1 - 1) cout << "No\n";

	else {

		if(c4 == c1 - 1 && c2) cout << "No\n";

		else cout << "Yes\n";

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.357795694051285x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

using namespace std;



int cnt2, cnt1, cnt4;

int main(){

	int n;

	cin >> n;

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

		int x;

		cin >> x;

		if(x % 4 == 0) cnt4 ++;

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

		else cnt1 ++;

	}

	if(cnt1 > cnt4 + 1){

		cout << "No" << '\n';

	}

	else if(cnt1 == cnt4 + 1){

		if(cnt2 == 0) cout << "Yes" << '\n';

		else cout << "No" << '\n';

	}

	else {

		cout << "Yes" << '\n';

	}

}


// Faster C++ solution for the same problem (measured speedup: 5.278707892921911x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

int n,f1,f2,f3;

void solve(){

	int x;

	cin >> n;

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

		scanf("%d",&x);

		if(x % 4 == 0) f1 ++;

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

		else f3 ++;

	}

	if(!f2 && f3 == f1 + 1) cout << "Yes" << "\n";

	else if(f1 >= f3) cout << "Yes" << endl;

	else cout << "No" << endl;

}



int main(){

	solve();

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.304278775843813x):
#include<stdio.h>

int cnt1, cnt2, cnt4;

int n;

int x;

int main()

{

	scanf("%d", &n);

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

	{

		scanf("%d", &x);

		if(x % 4 == 0)

			cnt4 ++;

		else if(x % 2 == 0)

			cnt2 ++;

		else 

			cnt1 ++;

	}

	if(cnt4 >= cnt1)

		printf("Yes\n");

	else if(cnt2 == 0 && cnt4 + 1>= cnt1)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

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

using namespace std;

const int N=1e5+5;

int a[N];

int main()

{

    int n;

    cin>>n;

    int cnt4=0,cnt2=0;

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

    {

        cin>>a[i];

        a[i]%=4;

        if(a[i]==0)

            cnt4++;

        else if(a[i]==2)

            cnt2++;

    }

    int cnt=n-cnt2-cnt4;

    if(cnt2)

    {

        if(cnt4>=cnt){

            cout<<"Yes";

            return 0;

        }

    }

    else

    {

        if(cnt4&&(cnt4+1>=cnt)){

            cout<<"Yes";

            return 0;

        }

    }

    cout<<"No";

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.289871406239518x):
#include<math.h>

#include<string.h>

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<algorithm>

#include<string>

#include<queue>

#include<vector>

#include<stack>

#include<set>

#include<map>

using namespace std;



int ser[1000010];

int main()

{

	int c1, c2, c4;

	int n,temp;

	c1 = c2 = c4 = 0;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		if (temp % 4 == 0)

			c4++;

		else if (temp % 2 == 0)

			c2++;

		else

			c1++;

	}

	if (c2 != 0)

	{

		if (c1 <= c4)

			printf("Yes\n");

		else

			printf("No\n");

	}

	else

	{

		if(c1<=c4+1)

			printf("Yes\n");

		else

			printf("No\n");

	}

 	return 0;

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

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

<url:https://arc080.contest.atcoder.jp/tasks/arc080_a>

問題文============================================================

 長さ N の数列 a=(a1,a2,…,aN) があります。 各 ai は正の整数です。

 

 すぬけ君の目標は、a の要素を自由に並べ替え、次の条件が成り立つようにすることです。

 

 各 1≤i≤N−1 について、ai と ai+1 の積は 4 の倍数である。

 すぬけ君が目標を達成できるか判定してください。



=================================================================



解説=============================================================



 まず、4の倍数の数値(4の倍数を v 、４の倍数でない値を x とする）が存在する時

 

 x v x v x v x v ... とおいていけば条件を満たす

 つまり、4の倍数である値の個数を V とすると 2*V 分カバーできる

 

 注意：

     x v x v x v ... x v x

 で数列が終了する時 2*V + 1 ＝＝　N をカバーできる

 

 2*c で　数列全てをカバーできない時, ２の倍数をb とすると

 

 x v x v x v x v ... x v b b b b b b .... b

 

 とおいていけば条件を満たす

 

 よって上の注意ケースを除いて,２の倍数の個数とBとすると

 

 2*V + B >= N

 

 となっていれば条件を満たす



================================================================

*/

int main(void) {

	cin.tie(0); ios::sync_with_stdio(false);

    ll N; cin >> N;

    vector<ll> a(N);

    for(auto & in:a) cin >> in;

    ll four = 0, two = 0;

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

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

        if(a[i]%2 == 0) two++;

    }

    two -= four;

    if(four*2 + 1 >= N){

        cout << "Yes" << endl;

        return 0;

    }

    if(four*2 + two >= N){

        cout << "Yes" << endl;

    }else{

        cout << "No" << endl;

    }

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.4236330637264265x):
#include<math.h>

#include<string.h>

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<algorithm>

#include<string>

#include<queue>

#include<vector>

#include<stack>

#include<set>

#include<map>

using namespace std;



int ser[1000010];

int main()

{

	int c1, c2, c4;

	int n,temp;

	c1 = c2 = c4 = 0;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		if (temp % 4 == 0)

			c4++;

		else if (temp % 2 == 0)

			c2++;

		else

			c1++;

	}

	if (c2 != 0)

	{

		if (c1 <= c4)

			printf("Yes\n");

		else

			printf("No\n");

	}

	else

	{

		if(c1<=c4+1)

			printf("Yes\n");

		else

			printf("No\n");

	}

 	return 0;

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

    using namespace std;

    int n, dp[10000000], c = 0, cnt = 0;

    int main()

    {

      cin >> n;

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

      {

            cin >> dp[i];

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

                  c ++;

            else

            if(dp[i] % 2 == 0)

                  cnt ++;

      }



      if((c + cnt / 2) >= n / 2)

            cout << "Yes";

      else

            cout << "No";

     }


// Faster C++ solution for the same problem (measured speedup: 5.246867507956594x):
#include<math.h>

#include<string.h>

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<algorithm>

#include<string>

#include<queue>

#include<vector>

#include<stack>

#include<set>

#include<map>

using namespace std;



int ser[1000010];

int main()

{

	int c1, c2, c4;

	int n,temp;

	c1 = c2 = c4 = 0;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		if (temp % 4 == 0)

			c4++;

		else if (temp % 2 == 0)

			c2++;

		else

			c1++;

	}

	if (c2 != 0)

	{

		if (c1 <= c4)

			printf("Yes\n");

		else

			printf("No\n");

	}

	else

	{

		if(c1<=c4+1)

			printf("Yes\n");

		else

			printf("No\n");

	}

 	return 0;

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



using namespace std;



int n , a , ch , d;



int main()

{

	cin >> n;

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

	{

		cin >> a;

		if(a % 4 == 0)

			ch++;

		else if(a % 2 == 0)

			d++;

	}

	if(ch >= n / 2)

		cout << "Yes";

	else

	{

		if(d >= n - (ch * 2))

			cout << "Yes";

		else

			cout << "No";

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.2462116745627645x):
#include<math.h>

#include<string.h>

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<algorithm>

#include<string>

#include<queue>

#include<vector>

#include<stack>

#include<set>

#include<map>

using namespace std;



int ser[1000010];

int main()

{

	int c1, c2, c4;

	int n,temp;

	c1 = c2 = c4 = 0;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		if (temp % 4 == 0)

			c4++;

		else if (temp % 2 == 0)

			c2++;

		else

			c1++;

	}

	if (c2 != 0)

	{

		if (c1 <= c4)

			printf("Yes\n");

		else

			printf("No\n");

	}

	else

	{

		if(c1<=c4+1)

			printf("Yes\n");

		else

			printf("No\n");

	}

 	return 0;

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

using namespace std;

const int Maxn=1e5+100;

int n,a,k,out[Maxn];

vector <int> vec1,vec2,vec4;

int main(){

	cin>>n;

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

		cin>>a;

		if(a%4==0)

			vec4.push_back(a);

		else if(a%2==0)

			vec2.push_back(a);

		else

			vec1.push_back(a);

	}

	k=4;

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

		if(k==1){

			if(vec4.size()==0){

				cout<<"No";

				return 0;

			}

			vec4.pop_back();

			k=4;

		}

		else if(k==2){

			if(vec2.size()!=0)

				vec2.pop_back(),k=2;

			else if(vec4.size()!=0)

				vec4.pop_back(),k=4;

			else{

				cout<<"No";

				return 0;

			}

		}

		else if(k==4){

			if(vec1.size()!=0)

				vec1.pop_back(),k=1;

			else if(vec2.size()!=0)

				vec2.pop_back(),k=2;

			else if(vec4.size()!=0)

				vec4.pop_back(),k=4;

		}

	}

	cout<<"Yes";

}


// Faster C++ solution for the same problem (measured speedup: 5.306038573871919x):
#include<math.h>

#include<string.h>

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<algorithm>

#include<string>

#include<queue>

#include<vector>

#include<stack>

#include<set>

#include<map>

using namespace std;



int ser[1000010];

int main()

{

	int c1, c2, c4;

	int n,temp;

	c1 = c2 = c4 = 0;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		if (temp % 4 == 0)

			c4++;

		else if (temp % 2 == 0)

			c2++;

		else

			c1++;

	}

	if (c2 != 0)

	{

		if (c1 <= c4)

			printf("Yes\n");

		else

			printf("No\n");

	}

	else

	{

		if(c1<=c4+1)

			printf("Yes\n");

		else

			printf("No\n");

	}

 	return 0;

}