Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define INF 10000;
using namespace std;

int divide(vector<vector<int>> c, int K){
    vector<int> tmp1(c.size());
    vector<int> tmp2(c.size());
    vector<int> zero(c.size());
    int cut=0;
    for (int i = 0; i < c[0].size(); i++){
        int m=0;
        for (int j = 0; j < c.size(); j++){
            tmp1[j]+=c[j][i];
            m=max(m,tmp1[j]);
        }
        if(m>K){
            if(tmp2==zero)return INF;
            cut++;
            tmp1.assign(c.size(),0);
            tmp2.assign(c.size(),0);
        }else{
            tmp2=tmp1;
        }
    }
    return cut;
}

int main() {
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<int>> S(H,vector<int>(W));
    for (int i = 0; i < H; i++){
        string s;
        cin >> s;
        for (int j = 0; j < W; j++){
            S[i][j]=(int)(s[j]-'0');
        }
    }
    int ans=INF;
    for (int i = 0; i < (1<<(H-1)); i++){
        bitset<10> bit(i);
        int c_num=bit.count()+1;
        vector<vector<int>> c(c_num,vector<int>(W));
        int c_index=0;
        for (int j = 0; j < H; j++){
            for (int k = 0; k < W; k++){
                c[c_index][k]+=S[j][k];
            }
            if(bit.test(j))c_index++;
        }
        ans=min(ans,(int)bit.count()+divide(c,K));
    }
    cout << ans << endl;
}#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define INF 10000;
using namespace std;

int divide(vector<vector<int>> c, int K){
    vector<int> tmp1(c[0].size());
    vector<int> tmp2(c[0].size());
    vector<int> zero(c[0].size());
    int cut=0;
    for (int i = 0; i < c.size(); i++){
        int m=0;
        for (int j = 0; j < c[0].size(); j++){
            tmp1[j]+=c[i][j];
            m=max(m,tmp1[j]);
        }
        if(m<=K){
            tmp2=tmp1;
        }else{
            if(tmp2==zero)return INF;
            cut++;
            tmp1=c[i];
            tmp2.assign(c.size(),0);
        }
    }
    return cut;
}

int main() {
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<int>> S(H,vector<int>(W));
    for (int i = 0; i < H; i++){
        string s;
        cin >> s;
        for (int j = 0; j < W; j++){
            S[i][j]=(int)(s[j]-'0');
        }
    }
    int ans=INF;
    for (int i = 0; i < (1<<(H-1)); i++){
        bitset<10> bit(i);
        int c_num=bit.count()+1;
        vector<vector<int>> c(W,vector<int>(c_num));
        int c_index=0;
        for (int j = 0; j < H; j++){
            for (int k = 0; k < W; k++){
                c[k][c_index]+=S[j][k];
            }
            if(bit.test(j))c_index++;
        }
        ans=min(ans,(int)bit.count()+divide(c,K));
    }
    cout << ans << endl;
}

Compiler output:
a.cc:55:2: error: stray '#' in program
   55 | }#define _GLIBCXX_DEBUG
      |  ^
a.cc:55:3: error: 'define' does not name a type
   55 | }#define _GLIBCXX_DEBUG
      |   ^~~~~~
a.cc:60:5: error: redefinition of 'int divide(std::__debug::vector<std::__debug::vector<int> >, int)'
   60 | int divide(vector<vector<int>> c, int K){
      |     ^~~~~~
a.cc:6:5: note: 'int divide(std::__debug::vector<std::__debug::vector<int> >, int)' previously defined here
    6 | int divide(vector<vector<int>> c, int K){
      |     ^~~~~~
a.cc:83:5: error: redefinition of 'int main()'
   83 | int main() {
      |     ^~~~
a.cc:29:5: note: 'int main()' previously defined here
   29 | int main() {
      |     ^~~~