stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}

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

#include<cstring>

#include<algorithm>

using namespace std;

#define N 100000

char s[N+5];

int a[N+5];

int main()

{

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

	int lens=strlen(s+1);

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

	{

		if(s[i]=='g') a[i]=1;

		else a[i]=-1;

	}

	int sum=0;

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

	sum+=a[i];

	printf("%d",sum/2);

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.346093271044999x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.253844465216592x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.307580744845197x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.265485989355841x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.317927098895424x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.217529148574123x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.269655689198299x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.26376905154295x):
#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;

}
// Slower C++ solution:
#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; 

}

// Faster C++ solution for the same problem (measured speedup: 5.269850029130493x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.257093634455108x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.305792624212484x):
#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;

}
// Slower C++ solution:
#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;	

}

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

#include<cstring>

#include<algorithm>

using namespace std;

const int Maxn=1e5;

char s[Maxn+5];

int cntg,cntp;

int main() {

	#ifdef LOACL

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

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

	#endif

	scanf("%s",s);

	int ans=0;

	int len=strlen(s);

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

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

			if(cntg>cntp) {

				cntp++;

				ans++;

			} else {

				cntg++;

			}

		} else {

			if(cntg>cntp) {

				cntp++;

			} else {

				cntg++;

				ans--;

			}

		}

	}

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

	return 0;

}
// Slower C++ solution:
#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;

}

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

#include<cstring>

#include<algorithm>

using namespace std;

const int Maxn=1e5;

char s[Maxn+5];

int cntg,cntp;

int main() {

	#ifdef LOACL

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

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

	#endif

	scanf("%s",s);

	int ans=0;

	int len=strlen(s);

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

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

			if(cntg>cntp) {

				cntp++;

				ans++;

			} else {

				cntg++;

			}

		} else {

			if(cntg>cntp) {

				cntp++;

			} else {

				cntg++;

				ans--;

			}

		}

	}

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

	return 0;

}
// Slower C++ solution:
#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;	

}

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

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

char s[100005];

int paper;

int ans;

int main() {

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

	int len=strlen(s+1);

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

		if(!paper) {

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

			paper++;

			continue;

		}

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

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

	}

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

}///////////////
// Slower C++ solution:
#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;

}

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

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

char s[100005];

int paper;

int ans;

int main() {

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

	int len=strlen(s+1);

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

		if(!paper) {

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

			paper++;

			continue;

		}

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

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

	}

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

}///////////////
// Slower C++ solution:
#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;

}

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

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

char s[100005];

int paper;

int ans;

int main() {

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

	int len=strlen(s+1);

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

		if(!paper) {

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

			paper++;

			continue;

		}

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

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

	}

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

}///////////////
// Slower C++ solution:
#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;	

}

// Faster C++ solution for the same problem (measured speedup: 5.278364372495294x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.358546558772281x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.225739365046476x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 4.823721195419555x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.1944916078550625x):
#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;

}