stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using Int = long long;

constexpr Int MOD = 1e9 + 7;

Int dp[2001][2001];

int main()

{

    int N, M; cin >> N >> M;

    vector<int> S(N), T(M);

    for (auto &s : S) cin >> s;

    for (auto &t : T) cin >> t;

    map<int, vector<int>> MT;

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

        MT[T[i]].push_back(i+1);

    }

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

        dp[0][i] = dp[i][0] = 1;

    }

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

        map<pair<int, int>, int> memo;

        for (int j = 1; j <= M; j++) {

            dp[i][j] = dp[i-1][j];

            auto &v = MT[S[i-1]];

            int k = upper_bound(begin(v), end(v), j) - begin(v);

            if (k != 0) {

                Int val = (memo[make_pair(S[i-1], k-1)] + dp[i-1][v[k-1]-1]) % MOD;

                memo[make_pair(S[i-1], k)] = val;

                (dp[i][j] += val) %= MOD;

            }

        }

    }

    cout << dp[N][M] << '\n';

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using Int = long long;

constexpr Int MOD = 1e9 + 7;

Int B[2001][2001];

int main()

{

    int N, M; cin >> N >> M;

    vector<int> S(N), T(M);

    for (auto &s : S) cin >> s;

    for (auto &t : T) cin >> t;

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

        for (int j = 1; j <= M; j++) {

            B[i][j] = (

                B[i][j-1] + B[i-1][j] + MOD - B[i-1][j-1] +

                (S[i-1] == T[j-1] ? B[i-1][j-1] + 1 : 0)

            ) % MOD;

        }

    }

    cout << (B[N][M] + 1) % MOD << '\n';

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



const int nax = 5e5+5;

vector<long long> st(2*nax);

int n;



void modify(int p, int v) {

	for(st[p+=n] += v;p>0;p>>=1) st[p>>1] = st[p] + st[p^1];

}



long long sum(int l, int r) {

	l+=n, r+=n;

	long long ans = 0;

	while(l<r) {

		if(l&1) ans += st[l++];

		if(r&1) ans += st[--r];

		l>>=1, r>>=1;

	}

	return ans;

}



int main() {

	int q, a, b, t;

	cin >> n >> q;

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

		st[i] = 0;

		cin >> st[i+n];

	}

	for(int i = n-1;i>0;i--) st[i] = st[2*i]+st[2*i+1];

	while(q--) {

		cin >> t >> a >> b;

		if(!t) {

			modify(a, b);

		}

		else cout << sum(a, b) << endl;

	}

	return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



const int nax = 5e5+5;

vector<long long> ft(nax, 0);

int n;



int LSBOne(int x) {

	return x&(-x);

}



void modify(int p, int v) {

	//for(st[p+=n] += v;p>0;p>>=1) st[p>>1] = st[p] + st[p^1];

	for(int i = p; i <= n; i += LSBOne(i)) ft[i] += v; 

}



long long sum(int l) {

	long long ans = 0;

	for(int i = l; i > 0; i -= LSBOne(i)) ans += ft[i];

	return ans;

}



int main() {

	int q, a, b, t;

	cin >> n >> q;

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

		cin >> a;

      	modify(i+1, a);

	}

	//ft[0] = 0;

	//for(int i = 1; i < n; i++) ft[i] = ft[i-1] + arr[i];

	while(q--) {

		cin >> t >> a >> b;

		if(!t) {

			modify(a+1, b);

		}

		else cout << sum(b) - sum(a) << endl;

	}

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



const int nax = 5e5+5;

vector<long long> ft(nax, 0), arr(nax);

int n;



int LSBOne(int x) {

	return x&(-x);

}



void modify(int p, int v) {

	//for(st[p+=n] += v;p>0;p>>=1) st[p>>1] = st[p] + st[p^1];

	for(int i = p; i <= n; i += LSBOne(i)) ft[i] += v; 

}



long long sum(int l) {

	long long ans = 0;

	for(int i = l; i > 0; i -= LSBOne(i)) ans += ft[i];

	return ans;

}



int main() {

	int q, a, b, t;

	cin >> n >> q;

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

		cin >> arr[i];

      	modify(i+1, arr[i]);

	}

	//ft[0] = 0;

	//for(int i = 1; i < n; i++) ft[i] = ft[i-1] + arr[i];

	while(q--) {

		cin >> t >> a >> b;

		if(!t) {

			modify(a+1, b);

		}

		else cout << sum(b) - sum(a) << endl;

	}

	return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



const int nax = 5e5+5;

vector<long long> ft(nax, 0);

int n;



int LSBOne(int x) {

	return x&(-x);

}



void modify(int p, int v) {

	//for(st[p+=n] += v;p>0;p>>=1) st[p>>1] = st[p] + st[p^1];

	for(int i = p; i <= n; i += LSBOne(i)) ft[i] += v; 

}



long long sum(int l) {

	long long ans = 0;

	for(int i = l; i > 0; i -= LSBOne(i)) ans += ft[i];

	return ans;

}



int main() {

	int q, a, b, t;

	cin >> n >> q;

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

		cin >> a;

      	modify(i+1, a);

	}

	//ft[0] = 0;

	//for(int i = 1; i < n; i++) ft[i] = ft[i-1] + arr[i];

	while(q--) {

		cin >> t >> a >> b;

		if(!t) {

			modify(a+1, b);

		}

		else cout << sum(b) - sum(a) << endl;

	}

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstring>



using namespace std;





int main()

{

    int n,d,c=0,cc=0;

    cin>>n;

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

    {

        cin>>d;

        if(d%2==0)c++;

        if(d%4==0)cc++;

    }

    if(cc+c+(cc==c&&c?1:0)>=n)cout<<"Yes";

    else cout<<"No";

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define inf 0x3f3f3f3f

#define maxm 

#define mod 

#define maxn 

 

int main()

{

	int n, x, s = 0, t = 0;

	

	scanf("%d", &n);

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

		scanf("%d", &x);

		if (x & 1) s++;

		else if (x % 4 == 0) t++;

	}	

	if (t >= s) puts("Yes");

	else if (t + 1 == s && t + s == n) puts("Yes");

	else puts("No");

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int read(){

	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();

	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();

	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;

}int n,x,y,xx,yy,zz;

int main(){

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

		x=read();y=0;while (x%2==0)x/=2,y++;

		if (y>=2)zz++;else if (y==0)xx++;else yy++;

	}if (yy){

		if (xx>zz)puts("No");else puts("Yes");

	}else if (xx>zz+1)puts("No");else puts("Yes");

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<stdio.h>

#include<iostream>

#include<string.h>

#include<algorithm>

#include<map>

#include<vector>

#include<string>

#define ll long long

#define For(i,x,y)  for(ll i=x;i<=y;++i)

#define FOr(i,x,y)  for(ll i=x;i>=y;--i)

using namespace std;

inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; } 

inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  } 

inline void writeln(ll x){ write(x);   puts("");   }

const ll N=100010;

ll a[N],sum[N],n;

int main(){

	n=read();

	For(i,1,n){

		a[i]=read();

		ll x=0;

		while(!(a[i]%2))	a[i]/=2,x++;

		sum[min(x,2ll)]++;

	}

	sum[0]+=min(sum[1],1ll);

	if (sum[2]+1>=sum[0])	puts("Yes");

	else	puts("No");

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#define For(i,j,k)	for(int i=j;i<=k;++i)

#define Dow(i,j,k)	for(int i=k;i>=j;--i)

#define ll long long

#define inf 1e8

using namespace std;

inline ll read()

{

	ll t=0,f=1;char c=getchar();

	while(c<'0'||c>'9'){if(c=='-')	c=getchar();}

	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();

	return t*f;

}

int n,x,four,two,odd;

int main()

{

	n=read();

	For(i,1,n)

	{

		x=read();

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

		if(x%4==2)	two++;

		if((x%4)&1)	odd++;

	}

	if(odd<=four||(odd<=four+1&&(!two)))	puts("Yes");	else	puts("No");

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int n,x,f[3];

int main()

{

	cin>>n;

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

	{

		cin>>x;

		if (x%4==0)

			++f[2];

		else

		{

			if (x%2==0)

				++f[1];

			else

				++f[0];

		}

	}

	if (f[0]>f[2]+1||((f[0]==f[2]+1)&&f[1]))

		puts("No");

	else

		puts("Yes");

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cstring>

#include <string>

#include <algorithm>

#include <iostream>

#include <iomanip>

#define For(i,j,k) for(int i=j;i<=k;i++)

#define Dow(i,j,k) for(int i=j;i>=k;i--)

#define LL long long

using namespace std ;



inline LL read() {

	LL x = 0 , f = 1 ;

	char ch = getchar() ;

	while(ch<'0'||ch>'9') { if(ch=='-') f = -1 ; ch = getchar() ; }

	while(ch>='0'&&ch<='9') { x = x * 10+ch-48 ; ch = getchar() ; }

	return x * f ;

}



const int N = 1e5+11;

int n,x,y,S;

int a,b,c,d;





int main() {

	n=read();

	For(i, 1, n) {

		x=read();

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

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

		else c++;

	}

	if(b) c++;

	c--;

	if(a-c<0) puts("No");

	else puts("Yes");

}
















// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>  

using namespace std;

int a[200005];

int main()

{

	int n, count1, count2;

	while (cin >> n)

	{

		int flag = 0;

		count1 = count2 = 0;

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

		{

			cin >> a[i];

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

				count1++;

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

				count2++;

		}

		if (count2 == count1 + 1 && count2 + count1 == n)    

			flag = 1;

		if (count1 >= count2)      

			flag = 1;

		if (flag)

			cout << "Yes" << endl;

		else

			cout << "No" << endl;

	}

	return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cmath>

using namespace std;

int main()

{

	int N;

	while (cin >> N)

	{

		int *a = new int[N];

		int num2 = 0;

		int num4 = 0;



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

			cin >> a[i];

		for (int j = 0; j < N; j++)

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

				num2++;

		for (int k = 0; k < N; k++)

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

				num4++;



		if (num4 == 0)

			if (num2 == N)

				cout << "Yes";

			else

				cout << "No";

		if (num4 != 0)

		{

			if (num2 != 0)

				if (num4 >= floor((N - num2 + 1) / 2.0))

					cout << "Yes";

				else

					cout << "No";

			else

				if (num4 >= floor(N / 2))

					cout << "Yes";

				else

					cout << "No";

		}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

using namespace std;

int main()

{



    int N,a=0,b=0,c=0;

    cin >> N;

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

    {

        int t;

        cin >> t;

        if(t%4==0)

            a++;

        else if(t%2==0)

            b++;

        else c++;

    }



    if(c>a+1||(c==a+1&&b>0))

        cout << "No";

    else

        cout << "Yes";



	return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>



using namespace std;



int main()

{

	int count_2=0,count_4=0,count_x=0;

	int n;

	cin>>n;

	long int *a=new long int[n];

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

	{

		cin>>a[i];

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

			{

				count_4++;

				continue;

			}

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

			{

				count_2++;

				continue;

			}

		count_x++;

	}

	if(count_2==0)

	{

		if(count_x>count_4+1)

		{

			cout<<"No";

		}

		else

		{

			cout<<"Yes";

		}

	}

	else

	{

		if(count_4>=count_x)

		{

			cout<<"Yes";

		}

		else

		{

			cout<<"No";

		}

	}

	return 0;

 } 

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

long long int a[200000];

int main()

{

	int i,j,k,l;

	cin >> i;

	j = 0; k = 0; l = 0;

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

	{

		cin >> a[z];

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

		{

			j++;

		}

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

		{

			k++;

		}

		else if (a[z] % 2 != 0)

		{

			l++;

		}

	}

	if (j + l == i&&j < l - 1)

	{

		cout << "No";

	}

	else if (j + l != i&&j < l)

	{

		cout << "No";

	}

	else

		cout << "Yes";

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

long a[200050];

int main(){

	int n,i;

	long cnt1=0,cnt2=0,cnt3=0;

	cin>>n;

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

		cin>>a[i];

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

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

		else cnt3++;

	}

	if(cnt3&&cnt1<cnt3&&cnt2||cnt3&&cnt2==0&&cnt1<cnt3-1) cout<<"No";

	else cout<<"Yes"; 

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main()

{

	long a,b,c,i,size;

	a=b=c=0;

	cin>>size;

	long* s=new long[size];

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

	{

		cin>>s[i];

		if(s[i]%2==1)a++;

		else if(s[i]%4!=0)b++;

		else c++;

	}

	if(b==0){if(a<=c+1)cout<<"Yes";else cout<<"No";	}

	else if(a<=c)cout<<"Yes";

	else cout<<"No";

	delete [] s;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
// #define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define uint unsigned int

#define ull  unsigned long long

typedef string str;

typedef long long ll;

typedef double db;

typedef pair<int, int> pii;

typedef map<int, int> mii;

typedef vector<int> vi;

typedef vector<bool> vb;

#define pb push_back

#define fi first

#define se second

#define in insert

#define all(x) (x).begin(), (x).end()

#define rall(x) (x).rbegin(), (x).rend()

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

const int INF = 1e9 + 5;

const int N = 2e5 + 123;

int main(){

    speed;

    int n;

    cin >> n;

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

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

        int x;

        cin >> x;

        if(x % 4 == 0){

            a++;

        }

        else if(x % 2 == 0){

            b++;

        }

        else{

            c++;

        }

    }

    // cout << a << b << c;

    if(a > c - 1){

        cout << "Yes";

    }

    else{

        if(a == c - 1 && b == 0){

            cout << "Yes";

            return 0;

        }

        cout << "No";

    }

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int n,a[100010],arr[5],x,y;

int main() {

	cin>>n;

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

		cin>>a[i];

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

			arr[4]++;

		}

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

			arr[2]++;

		} else {

			arr[0]++;

		}

	}

	if(arr[2])arr[0]++;

	if(arr[0]-1>arr[4]) {

		cout<<"No"<<endl;

	} else {

		cout<<"Yes"<<endl;

	}

}

	

// Optimized solution to the same problem (faster):
#include <stdio.h>



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, i;

	int c[4] = {0};

	

	n = read();

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

		c[read() % 4]++;

	}

	if(c[1] + c[3] <= c[0] + (!c[2])) puts("Yes");

	else puts("No");

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;



int n,a[100010],sum1,sum2,cnt1,cnt2;



int main()

{

	cin>>n;

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

	{

		cin>>a[i];

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

		if(a[i]%4==1||a[i]%4==3) sum2++;

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

		if(a[i]==2) cnt2++;

		

	}

	sum1+=cnt2/2;

	if(sum1+1>=sum2+min(1,cnt1)) cout<<"Yes"; else cout<<"No";

	

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

	int n;

	while (scanf("%d", &n) != EOF)

	{

		int four = 0, two = 0,x=0;

		int a;

		while (n--)

		{

			scanf("%d", &a);

			if (a % 4==0)

			{

				four++;

				continue;

			}

			if (a % 2 == 0)

			{

				two++;

				continue;

			}

			x++;

		}

		if (two)

			x++;

		if (four + 1 < x)

			printf("No\n");

		else

			printf("Yes\n");

	}

	return 0;

}

// Fastest known solution for this problem: