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

char c[100005];

int main(void){

    std::cin>>c;

	int l=strlen(c),qwq=0;

    for(int i=0;i<l;++i) if(c[i]=='g') qwq++;

    printf("%d\n\r",std::min(l/2,qwq)-std::min(l-l/2,l-qwq));

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

char s[1001000];

int main ()

{

	scanf("%s",s);

	int len=strlen(s),ag=0,me=len/2 ;

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

	{

		if(s[i]=='p')

			ag++;

	}

	printf("%d",me-ag);

}

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

#include<string.h>

#include<algorithm>

#include<iostream>

#include<queue>

#include<math.h>

#define mem(a,b) memset(a,b,sizeof(a))

#define inf 0x3f3f3f3f

#define mod 10007

using  namespace std;

int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}

int main()

{

    char a[100005];

    scanf("%s",a);

    int num=strlen(a)/2;

    //if(strlen(a)%2==1)

    int p=0,g=0;

    for(int i=0;i<strlen(a);i++)

    {

        if(a[i]=='g') g++;

        else if(a[i]=='p') p++;

    }

    printf("%d\n",num-p);

    return 0;

}




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

#include<string.h>

char s[1000001];

int main()

{

    scanf("%s",s);

    int ans=0,x=0,y=0;

    for(int i=0;i<strlen(s);i++)

    {

        if(x==y)

        {

            x++;

            if(s[i]=='p')

            ans--;

        }

        else

        {

            y++;

            if(s[i]=='g')

            ans++;

        }

    }

    printf("%d",ans);

}

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

#include<iostream>

#include<cstring>

#include<cstdio>

#include<vector>

#include<cmath>

#include<ctime>

#include<queue>

#include<map>

#define LL long long

#define il inline

#define re register

#define db double

#define eps (1e-5)



using namespace std;

const int N=100000+10;

il LL rd()

{

    re LL x=0,w=1;re char ch;

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

    while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}

    return x*w;

}

int n,ans;

char cc[N];



int main()

{

  scanf("%s",cc+1);

  n=strlen(cc+1);

  for(int i=1;i<=(n+1)>>1;i++) ans-=(cc[i]=='p');

  for(int i=(n+1)/2+1;i<=n;i++) ans+=(cc[i]=='g');

  printf("%d\n",ans);

  return 0;

}

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

#include<string.h>

char s[1000001];

int main()

{

    scanf("%s",s);

    int ans=0,x=0,y=0;

    for(int i=0;i<strlen(s);i++)

    {

        if(x==y)

        {

            x++;

            if(s[i]=='p')

            ans--;

        }

        else

        {

            y++;

            if(s[i]=='g')

            ans++;

        }

    }

    printf("%d",ans);

}

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

#define INF 0x3f3f3f3f

using namespace std;

string s;

int n,p1[100001],maxn=-INF,c[2]={0,1},ans,rk,pp;

void dfs(int t){

	if(t>n){

		maxn=maxn>ans?maxn:ans;

		return;

	}

	if(s[t]=='p'){

		if(rk>pp){

			pp++;

			dfs(t+1);

			pp--;

		}

		else {

			rk++;

			ans--;

			dfs(t+1);

			rk--;

		}

	}

	if(s[t]=='g'){

		if(rk>pp){

			pp++;

			ans++;

			dfs(t+1);

			pp--;

			ans--;

		}

		else {

			rk++;

			dfs(t+1);

			rk--;

		}

	}

}

int main(){

	cin>>s;

	n=s.size();

	s=' '+s;

	dfs(1);

	printf("%d",maxn);

	return 0;

}

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

#include<string.h>

char s[1000001];

int main()

{

    scanf("%s",s);

    int ans=0,x=0,y=0;

    for(int i=0;i<strlen(s);i++)

    {

        if(x==y)

        {

            x++;

            if(s[i]=='p')

            ans--;

        }

        else

        {

            y++;

            if(s[i]=='g')

            ans++;

        }

    }

    printf("%d",ans);

}

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

using namespace std;

string s;

int x=0,y=0,ans=0;

int main()

{

    cin>>s;

    for (int i=0;i<s.size();i++)

     if (x==y){x++; if(s[i]=='p') ans--;}

     else{y++; if(s[i]=='g') ans++;}

    printf("%d\n",ans);

    return 0;

}

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

#include<string.h>

char s[1000001];

int main()

{

    scanf("%s",s);

    int ans=0,x=0,y=0;

    for(int i=0;i<strlen(s);i++)

    {

        if(x==y)

        {

            x++;

            if(s[i]=='p')

            ans--;

        }

        else

        {

            y++;

            if(s[i]=='g')

            ans++;

        }

    }

    printf("%d",ans);

}

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

using namespace std;

char a[100005];

int x=0,y=0,ans=0;

int main()

{

    cin>>a;

    for (int i=0;i<sizeof(a);i++)

        if (x==y) {

            x++; 

            if(a[i]=='p') ans--;

        }

    else {

        y++; 

        if(a[i]=='g') ans++;

    }

    printf("%d\n",ans);

    return 0;

}

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

#include<string.h>

char s[1000001];

int main()

{

    scanf("%s",s);

    int ans=0,x=0,y=0;

    for(int i=0;i<strlen(s);i++)

    {

        if(x==y)

        {

            x++;

            if(s[i]=='p')

            ans--;

        }

        else

        {

            y++;

            if(s[i]=='g')

            ans++;

        }

    }

    printf("%d",ans);

}

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

using namespace std;

char a[100005];

int x=0,y=0,ans=0;

int main()

{

    cin>>a;

    for (int i=0;i<sizeof(a);i++)

     if (x==y){x++; if(a[i]=='p') ans--;}     

     else{y++; if(a[i]=='g') ans++;}         

    printf("%d\n",ans);                      

    return 0;

}

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

using namespace std;

string a;

int main()

{

	cin>>a;

	int l=a.size();

	int t1=0,t2=0,score=0;

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

		if(t1==t2)

		{

			t1++;

			if(a[i]=='p') score--;

		}else

		{

			t2++;

			if(a[i]=='g') score++;

		}

	printf("%d\n",score);

	return 0;

}

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

using namespace std;

#define int long long

#define fi first

#define se second

#define pb push_back

#define mp make_pair

#define endl "\n"

#define pque priority_queue



const int mod = 1000000007;



signed main(){

	ios_base::sync_with_stdio(0);

	cin.tie(0);

	string s;

	cin >> s;

	int n = s.length(), cnt = 0;

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

		if (s[i] == 'g') cnt++;

		else cnt--;

	}

	cnt /= 2;

	cout << cnt;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>

#define SF scanf

#define PF printf

#define MAXN 100010

char s[MAXN];

int main(){

	SF("%s",s);

	int n=strlen(s);

	int ans=0;

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

		if(i%2==0&&s[i]=='p')

			ans--;

		if(i%2==1&&s[i]=='g')

			ans++;

	}

	PF("%d",ans);

}

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

#include <vector>

#include <stdio.h>

#include <string>



using namespace std;



typedef vector<int> vi;



string s;

int num = 0, res = 0;



int main()

{

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

    //freopen("out.txt", "w", stdout);

    cin >> s;

    for (int i = 0; i < s.size(); i++)

    {

        if (s[i] == 'g')

        {

            if (num == 0)

            {

                ++num;

            }

            else

            {

                ++res;

                --num;

            }

        }

        else

        {

            if (num == 0)

            {

                ++num;

                --res;

            }

            else

            {

                --num;

            }

        }

    }

    printf("%d",res);

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>

#define SF scanf

#define PF printf

#define MAXN 100010

char s[MAXN];

int main(){

	SF("%s",s);

	int n=strlen(s);

	int ans=0;

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

		if(i%2==0&&s[i]=='p')

			ans--;

		if(i%2==1&&s[i]=='g')

			ans++;

	}

	PF("%d",ans);

}

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

#include <string.h>

using namespace std;



int main(){

    string s;

    int ans = 0;

    cin >> s;

    for(int i = 0; i  < s.length(); i++) if(s[i] == 'p') ans++;

    if(s.length() % 2 == 0) cout << (s.length() / 2) - ans;

    else cout << (s.length() - 1) / 2 - ans;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>

#define SF scanf

#define PF printf

#define MAXN 100010

char s[MAXN];

int main(){

	SF("%s",s);

	int n=strlen(s);

	int ans=0;

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

		if(i%2==0&&s[i]=='p')

			ans--;

		if(i%2==1&&s[i]=='g')

			ans++;

	}

	PF("%d",ans);

}

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

#include <algorithm>

#include <cstring>

using namespace std;

main ()

{

	char s[100005];

	int p=0, g=0, ans=0;

	cin >> s;

	int n = strlen (s);

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

	{

		if (s[i] == 'g')

		{

			if (g>p)

			{

				ans++;

				p++;

			}

			else g++; 

		}

		else

		{

			if (g>p) p++;

			else

			{

				g++;

				ans--;

			}

		}

	}

	cout << ans;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>

#define SF scanf

#define PF printf

#define MAXN 100010

char s[MAXN];

int main(){

	SF("%s",s);

	int n=strlen(s);

	int ans=0;

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

		if(i%2==0&&s[i]=='p')

			ans--;

		if(i%2==1&&s[i]=='g')

			ans++;

	}

	PF("%d",ans);

}

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

using namespace std;

int val[105];

int main(){

  string s;

  cin>>s;

  int contg = 0;

  int w = 0;

  int l = 0;

  for (int i = 0; i < s.length(); i++){

    if(s[i] == 'g'){

      if(contg > 0){

        contg--;

        w++;

      }else{

        contg++;

      }

    }else{

      if(contg > 0){

        contg--;

      }else{

        contg++;

        l++;

      }

    }

    //cout<<w<<" "<<l<<endl;

  }

  cout<<w-l<<endl;

  return 0;

}


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

#include<string.h>

#include<math.h>

#include<algorithm>

using namespace std;

int main()

{    

	char s[100005];    

	scanf("%s", s);   

	 int sum=0, len=strlen(s), p=0, g=0;    

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

	{        

	 	if(s[i]=='g')       

	  	{            

	  	if(g>p)            

	 	{                

	  		sum++;                

	  p++;        

	      }          

		    else                

			g++;      

			  }      

			    else      

				  {           

				   if(g>p)                

				   p++;            

				   else            

				   {                

				   sum--;                

				   g++;            

				   }

				           }    

						   }    

						   printf("%d\n", sum);    

						   return 0;

} 

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

using namespace std;

typedef long long lint;

const int _ = 100007;

char s[_];int n;

int main()

{

	register int i,a,ans=0;

	scanf("%s",s+1),n=strlen(s+1);

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

	{

		if(s[i]=='g')

		{

			if(a<=0)a++;

			else ans++,a--;

		}

		if(s[i]=='p')

		{

			if(a<=0)ans--,a++;

			else a--;

		}

	}

	printf("%d\n",ans);

	return 0;

}


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

#include<string.h>

#include<math.h>

#include<algorithm>

using namespace std;

int main()

{    

	char s[100005];    

	scanf("%s", s);   

	 int sum=0, len=strlen(s), p=0, g=0;    

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

	{        

	 	if(s[i]=='g')       

	  	{            

	  	if(g>p)            

	 	{                

	  		sum++;                

	  p++;        

	      }          

		    else                

			g++;      

			  }      

			    else      

				  {           

				   if(g>p)                

				   p++;            

				   else            

				   {                

				   sum--;                

				   g++;            

				   }

				           }    

						   }    

						   printf("%d\n", sum);    

						   return 0;

} 

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

#include<cstdio>

using namespace std;

int sco,p,g;char s;

int main()

{

	while(cin>>s)

	{

		if(s=='p'&&p<g){p++;continue;}

		if(s=='p'&&p==g){g++;sco--;continue;}

		if(s=='g'&&p<g){p++;sco++;continue;}

		if(s=='g'&&p==g){g++;continue;}

	}

	cout<<sco;

	return 0;

}

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

#include<string.h>

#include<math.h>

#include<algorithm>

using namespace std;

int main()

{    

	char s[100005];    

	scanf("%s", s);   

	 int sum=0, len=strlen(s), p=0, g=0;    

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

	{        

	 	if(s[i]=='g')       

	  	{            

	  	if(g>p)            

	 	{                

	  		sum++;                

	  p++;        

	      }          

		    else                

			g++;      

			  }      

			    else      

				  {           

				   if(g>p)                

				   p++;            

				   else            

				   {                

				   sum--;                

				   g++;            

				   }

				           }    

						   }    

						   printf("%d\n", sum);    

						   return 0;

} 

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

using namespace std;

int main(){

	string s;

	cin>>s;

	int l=s.length(),p=0,r=0,tot=0;

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

		if(s[i]=='G'||s[i]=='g')

		{

			if(p<=r)p++;

			else r++,tot++;

		}

		else{

			if(p<=r)p++,tot--;

			else r++;

		}

	}

	cout<<tot;

	return 0;

}

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

#include<string.h>

#include<math.h>

#include<algorithm>

using namespace std;

int main()

{    

	char s[100005];    

	scanf("%s", s);   

	 int sum=0, len=strlen(s), p=0, g=0;    

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

	{        

	 	if(s[i]=='g')       

	  	{            

	  	if(g>p)            

	 	{                

	  		sum++;                

	  p++;        

	      }          

		    else                

			g++;      

			  }      

			    else      

				  {           

				   if(g>p)                

				   p++;            

				   else            

				   {                

				   sum--;                

				   g++;            

				   }

				           }    

						   }    

						   printf("%d\n", sum);    

						   return 0;

} 

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

using namespace std;

string a;

int main()

{

	int m=0,n=0;

	cin>>a;

	for(int i=0;i<a.size();i++)

	if(a[i]=='p')m++;			//对方出布的次数 

	else

	n++;						//对方出石头的次数 

	int x=(m+n)/2;				//自己出布的次数				

	if(x<m)

	cout<<m+n-2*x;

	else

	cout<<x-m;

	return 0; 

}

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

#include<string.h>

#include<math.h>

#include<algorithm>

using namespace std;

int main()

{    

	char s[100005];    

	scanf("%s", s);   

	 int sum=0, len=strlen(s), p=0, g=0;    

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

	{        

	 	if(s[i]=='g')       

	  	{            

	  	if(g>p)            

	 	{                

	  		sum++;                

	  p++;        

	      }          

		    else                

			g++;      

			  }      

			    else      

				  {           

				   if(g>p)                

				   p++;            

				   else            

				   {                

				   sum--;                

				   g++;            

				   }

				           }    

						   }    

						   printf("%d\n", sum);    

						   return 0;

} 

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

using namespace std;

int main()

{   

char s[100005];

scanf("%s", s);

int sum=0, len=strlen(s), p=0, g=0;    

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

{if(s[i]=='g')        

{if(g>p)           

{sum++;

p++;}            

else  

g++;}        

else

{if(g>p)p++;

else{ sum--;  g++;}

} 

}

printf("%d\n", sum);

return 0;

}

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

#include<string.h>

#include<math.h>

#include<algorithm>

using namespace std;

int main()

{    

	char s[100005];    

	scanf("%s", s);   

	 int sum=0, len=strlen(s), p=0, g=0;    

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

	{        

	 	if(s[i]=='g')       

	  	{            

	  	if(g>p)            

	 	{                

	  		sum++;                

	  p++;        

	      }          

		    else                

			g++;      

			  }      

			    else      

				  {           

				   if(g>p)                

				   p++;            

				   else            

				   {                

				   sum--;                

				   g++;            

				   }

				           }    

						   }    

						   printf("%d\n", sum);    

						   return 0;

} 

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

#define INF 0x3f3f3f3f

using namespace std;

string s;

int n,p1[100001],maxn=-INF,c[2]={0,1},ans,rk,pp;

void dfs(int t){

	if(t>n){

		maxn=maxn>ans?maxn:ans;

		return;

	}

	if(s[t]=='p'){

		if(rk>pp){

			pp++;

			dfs(t+1);

			pp--;

		}

		else {

			rk++;

			ans--;

			dfs(t+1);

			rk--;

		}

	}

	if(s[t]=='g'){

		if(rk>pp){

			pp++;

			ans++;

			dfs(t+1);

			pp--;

			ans--;

		}

		else {

			rk++;

			dfs(t+1);

			rk--;

		}

	}

}

int main(){

	cin>>s;

	n=s.size();

	s=' '+s;

	dfs(1);

	printf("%d",maxn);

	return 0;

}

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

#include<string.h>

#include<math.h>

#include<algorithm>

using namespace std;

int main()

{    

	char s[100005];    

	scanf("%s", s);   

	 int sum=0, len=strlen(s), p=0, g=0;    

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

	{        

	 	if(s[i]=='g')       

	  	{            

	  	if(g>p)            

	 	{                

	  		sum++;                

	  p++;        

	      }          

		    else                

			g++;      

			  }      

			    else      

				  {           

				   if(g>p)                

				   p++;            

				   else            

				   {                

				   sum--;                

				   g++;            

				   }

				           }    

						   }    

						   printf("%d\n", sum);    

						   return 0;

} 

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



using namespace std;



string s;

int ans;



signed main(){

	cin >> s;

	int len = s.length();

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

		if(i % 2){

			if(s[i] == 'g') ans ++; 

		}

		else{

			if(s[i] =='p') ans --;

		}

	cout << ans;	

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#include<cstring>

using namespace std;

char s[100002];

int n,sg,sp,ans;

int main()

{

	scanf("%s",s);

	n=strlen(s);

	sg=sp=0;

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

		if(i%2==1&&s[i]=='g')ans++;

		else	if(i%2==0&&s[i]=='p')ans--;

	printf("%d",ans);

	//return 0;

}

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

using namespace std;



string s;



int main() {

	ios_base::sync_with_stdio(false);

	cin >> s; int n = s.size();

	int res = 0; int cnt = 0;

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

		if (s[i] == 'g') {

			if (!cnt) cnt++;

			else res++, cnt--;

		}

		else {

			if (!cnt) res--, cnt++;

			else cnt--;

		}

	}

	cout << res;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#include<cstring>

using namespace std;

char s[100002];

int n,sg,sp,ans;

int main()

{

	scanf("%s",s);

	n=strlen(s);

	sg=sp=0;

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

		if(i%2==1&&s[i]=='g')ans++;

		else	if(i%2==0&&s[i]=='p')ans--;

	printf("%d",ans);

	//return 0;

}

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

#include<map>

#include<ctime>

#include<queue>

#include<cmath>

#include<cstdio>

#include<vector>

#include<climits>

#include<cstring>

#include<iostream>

#include<algorithm>    

using namespace std;

#define LL long long

int read(){

    int f=1,x=0;char s=getchar();   

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

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

    return x*f;

}

#define MAXN 100000

#define INF 0x3f3f3f3f

char str[MAXN+5];

int main(){

	int n,r=0,g=0,ans=0;

	scanf("%s",str+1);

	n=strlen(str+1);

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

		if(str[i]=='g'){

			if(r<g) ans++,r++;

			else g++;

		}

		else{

			if(r<g) r++;

			else ans--,g++;

		}

	}

	printf("%d\n",ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#include<cstring>

using namespace std;

char s[100002];

int n,sg,sp,ans;

int main()

{

	scanf("%s",s);

	n=strlen(s);

	sg=sp=0;

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

		if(i%2==1&&s[i]=='g')ans++;

		else	if(i%2==0&&s[i]=='p')ans--;

	printf("%d",ans);

	//return 0;

}

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

#include<string>

#include<cmath>

using namespace std;



int n, a[100];



int main(){

	cin >> n;

	int odd = 0, even = 0;

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

		cin >> a[i];

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

		else odd++;

	}

	int ans = pow(3, n);

	ans -= pow(2, even);

	cout << ans << endl;

}

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

#include <stdlib.h>

#include <math.h>



int main()

{

	int n,m;

	int ans;

	scanf("%d",&n);

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

    {

    	scanf("%d",&m);

    	if (m%2==0)

    	{

    		ans++;

		}	

	}

	printf("%d",int(pow(3,n)-pow(2,ans)));

 	return 0;

} 


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

#include<iostream>

#include<cstring>

#define ll long long

using namespace std;

ll a,b,x;

int main()

{

    cin>>a>>b>>x;

    cout<<b/x-a/x+(bool)(a%x==0);

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#define ll long long

int main() {

    ll a,b,c;

    scanf("%lld%lld%lld",&a,&b,&c);

    printf("%lld\n",b/c-(a?(a-1)/c:-1));

    return 0;

}


// Fastest known solution for this problem: