#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pii pair<int, int>
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef CB
freopen("be2.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
string S;
cin >> S;
int N = S.size();
int ans = 0;
for (char c : {'A', 'C', 'G', 'T'}) {
map<int, int> m;
int a = 0;
for (int i = 0; i < N; i++) {
a += (S[i] == c) * 2 - 1;
if (!m.contains(a)) {
auto t = m.insert({a, i}).first;
while (next(t) != m.end() && next(t)->second >= t->second) {
m.erase(next(t));
}
}
auto t = m.upper_bound(a);
if (t != m.begin()) {
ans = max(ans, i - prev(t)->second);
}
}
}
cout << ans << '\n';
return 0;
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:26:32: error: 'class std::map<long long int, long long int>' has no member named 'contains'
26 | if (!m.contains(a)) {
| ^~~~~~~~
Exited with error status 1