#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define oo 1e9
void fast()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base ::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int longest_laugh(string s)
{
int cnt = 0;
for (int i = 0; i < sz(s); i++)
{
if (s[i] == 'a' || s[i] == 'h')
{
int j = i;
bool ha;
if (s[i] == 'h')
ha = 0;
else
ha = 1;
i++;
while (i < sz(s))
{
if (s[i] == 'h' && ha)
{
i++;
ha = 0;
}
else if (s[i] == 'a' && !ha)
{
i++;
ha = 1;
}
else
break;
}
cnt = max(cnt, i - j);
}
}
return cnt;
}
void solve()
{
string s;
cin >> s;
cout << longest_laugh(s);
}
int main()
{
fast();
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
Compilation message
/usr/bin/ld: /tmp/ccoonOv8.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccW2fB09.o:laugh.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status