Language: C++

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb1 push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//
ll dp[55][55][3000]; //i番目までのカードからj枚使って総和をkにできる総数
//
//initialization finish


// your function is here
//



//
// your function finished



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	// your code is here
	//
	string s; cin >> s;
	int n = s.size();
	int sum = 0;
	rep(i, n)
	{
		if (s[i] == 'g') sum++;
	}

	Print((-n + 2 * sum) / 2);


	//
	// your code finished

	return 0;
}#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb1 push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//
ll dp[55][55][3000]; //i番目までのカードからj枚使って総和をkにできる総数
//
//initialization finish


// your function is here
//



//
// your function finished



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	// your code is here
	//
	string s; cin >> s;
	int n = s.size();
	int sum = 0;
	rep(i, n)
	{
		if (s[i] == 'g') sum++;
	}

	Print((-n + 2 * sum) / 2);


	//
	// your code finished

	return 0;
}

Compiler output:
a.cc:91:2: error: stray '#' in program
   91 | }#include <iostream>
      |  ^
a.cc:91:3: error: 'include' does not name a type
   91 | }#include <iostream>
      |   ^~~~~~~
a.cc:140:11: error: redefinition of 'const int maxn'
  140 | const int maxn = 2e5 + 10;
      |           ^~~~
a.cc:50:11: note: 'const int maxn' previously defined here
   50 | const int maxn = 2e5 + 10;
      |           ^~~~
a.cc:145:4: error: redefinition of 'long long int dp [55][55][3000]'
  145 | ll dp[55][55][3000]; //i番目までのカードからj枚使って総和をkにできる総数
      |    ^~
a.cc:55:4: note: 'long long int dp [55][55][3000]' previously declared here
   55 | ll dp[55][55][3000]; //i番目までのカードからj枚使って総和をkにできる総数
      |    ^~
a.cc:160:5: error: redefinition of 'int main()'
  160 | int main() {
      |     ^~~~
a.cc:70:5: note: 'int main()' previously defined here
   70 | int main() {
      |     ^~~~