func_code_string: #include <bits/stdc++.h>   using namespace std;   string s;   int ans;   map<int, int> f;   int main() {     cin >> s;     int n = s.length();     f[0] = 1;     int cur = 0;     for (int i = 1; i < n; i++) {       if (s[i] == s[i - 1]) {         f[cur]++;       } else {         f[i]++;         cur = i;       }     }     while (f.size() > 1) {       int _min = 10000000;       for (auto i = f.begin(); i != f.end(); ++i) {         if (i == f.begin() || next(i) == f.end())           cur = i->second;         else           cur = ceil(i->second / 2.0);         _min = min(_min, cur);       }       ans += _min;       for (auto i = f.begin(); i != f.end(); ++i) {         cur = _min;         auto ci = i;         if (i == f.begin() || next(i) == f.end()) {           i->second -= cur;         } else {           i->second -= cur + cur;         }         ci = i;       }       for (auto i = f.begin(); i != f.end();) {         auto ci = i;         ++i;         if (ci->second < 1) f.erase(ci);       }       if (f.size())         for (auto it = f.begin(); it != prev(f.end());) {           if (s[it->first] == s[next(it)->first]) {             next(it)->second += it->second;             auto cit = it;             ++it;             f.erase(cit);           } else             ++it;         }     }     cout << ans;     return 0;   }   