Language: C++

#include <bits/stdc++.h>
using namespace std;

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string s;
    cin >> s;

    vector<int> count[26];
    rep(i,0,26) count[i].resize(s.size());
    ++count[s[0]-'a'][0];
    rep(i,1,s.size()){
        rep(j,0,26) count[j][i]=count[j][i-1];
        ++count[s[i]-'a'][i];
    }

    vector<int> memo(s.size()+1,inf);
    vector<bool> done(s.size()+1);

    function<int(int)> rec=[&](int l){
        int& res=memo[l];
        if(done[l]) return res;
        done[l]=true;

        if(l==s.size()) return res=0;

        for(int r=s.size()-1; r>=l; --r){
            int odd=0;
            rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
using namespace std;

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string s;
    cin >> s;

    vector<int> count[26];
    rep(i,0,26) count[i].resize(s.size());
    ++count[s[0]-'a'][0];
    rep(i,1,s.size()){
        rep(j,0,26) count[j][i]=count[j][i-1];
        ++count[s[i]-'a'][i];
    }

    vector<int> memo(s.size()+1,inf);
    vector<bool> done(s.size()+1);

    function<int(int)> rec=[&](int l){
        int& res=memo[l];
        if(done[l]) return res;
        done[l]=true;

        if(l==s.size()) return res=0;

        for(int r=s.size()-1; r>=l; --r){
            int odd=0;
            rep(j,0,26) if((count[j][r]-(l?count[j][l-1]:0))%2){
                ++odd;
                if(odd>1) break;
            }
            if(odd<=1){
                res=min(res,rec(r+1)+1);
                if(res<=2) return res;
            }
        }
        return res;
    };

    cout << rec(0) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}
-1]:0))%2){
                ++odd;
                if(odd>1) break;
            }
            if(odd<=1){
                res=min(res,rec(r+1)+1);
                if(res==2) return res;
            }
        }
        return res;
    };

    cout << rec(0) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Compiler output:
a.cc:53:54: error: stray '#' in program
   53 |             rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
      |                                                      ^
a.cc: In lambda function:
a.cc:53:54: error: expected ']' before 'include'
   53 |             rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
      |                                                      ^~~~~~~~
      |                                                      ]
a.cc:53:54: error: expected ':' before 'include'
   53 |             rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
      |                                                      ^~~~~~~~
      |                                                      :
a.cc:53:55: error: 'include' was not declared in this scope
   53 |             rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
      |                                                       ^~~~~~~
a.cc:53:64: error: 'bits' was not declared in this scope
   53 |             rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
      |                                                                ^~~~
a.cc:53:69: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 |             rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
      |                                                                     ^~~~
      |                                                                     std
a.cc:54:1: error: expected primary-expression before 'using'
   54 | using namespace std;
      | ^~~~~
a.cc:53:78: error: expected ')' before 'using'
   53 |             rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
      |                                         ~                                    ^
      |                                                                              )
   54 | using namespace std;
      | ~~~~~                                                                         
a.cc:54:20: error: expected ')' before ';' token
   54 | using namespace std;
      |                    ^
      |                    )
a.cc:53:28: note: to match this '('
   53 |             rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
      |                            ^
a.cc:54:20: error: expected ')' before ';' token
   54 | using namespace std;
      |                    ^
      |                    )
a.cc:53:27: note: to match this '('
   53 |             rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
      |                           ^
a.cc:72:1: error: a template declaration cannot appear at block scope
   72 | template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
      | ^~~~~~~~
a.cc:120:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  120 | int main(){
      |         ^~
a.cc:120:9: note: remove parentheses to default-initialize a variable
  120 | int main(){
      |         ^~
      |         --
a.cc:120:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:120:11: error: a function-definition is not allowed here before '{' token
  120 | int main(){
      |           ^
a.cc:128:3: error: expected ';' before ']' token
  128 | -1]:0))%2){
      |   ^
      |   ;