Language: C++

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    ll res = (1ll<<60);
    REP(mask, 1ll<<(H-1)){
        ll sz = __builtin_popcountll(mask);
        ll val = sz;
        vl cnt(sz, 0);
        REP(i, W){
            vl tmp(sz, 0);
            ll pos = 0;
            REP(j, H){
                cnt[pos] += S[i][j] - '0';
                if(mask>>pos & 1) pos++;
            }
            
            REP(j, sz) if(tmp[j]>K) goto HELL;

            bool ok = true;
            REP(j, sz) if(cnt[j]+tmp[j]>K) ok = false;
            if(ok){
                REP(j, sz) cnt[j] += tmp[j];
            }else{
                val++;
                REP(j, sz) cnt[j] = tmp[j];
            }
        }
        chmax(res, val);
        HELL:1;
    }    

    cout << res << endl;

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    ll res = (1ll<<60);
    REP(mask, 1ll<<(H-1)){
        ll sz = __builtin_popcountll(mask);
        ll val = sz;
        vl cnt(sz, 0);
        REP(i, W){
            vl tmp(sz, 0);
            ll pos = 0;
            REP(j, H){
                cnt[pos] += S[i][j] - '0';
                if(mask>>pos & 1) pos++;
            }
            
            REP(j, sz) if(tmp[j]>K) goto HELL;

            bool ok = true;
            REP(j, sz) if(cnt[j]+tmp[j]>K) ok = false;
            if(ok){
                REP(j, sz) cnt[j] += tmp[j];
            }else{
                val++;
                REP(j, sz) cnt[j] = tmp[j];
            }
        }
        chmax(res, val);
        HELL:1;
    }    

    cout << res << endl;

    return 0;
}

Compiler output:
a.cc:81:2: error: stray '#' in program
   81 | }#include <bits/stdc++.h>
      |  ^
a.cc:81:3: error: 'include' does not name a type
   81 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:93:10: error: redefinition of 'const ll mod'
   93 | const ll mod = 1e9 + 7;
      |          ^~~
a.cc:13:10: note: 'const ll mod' previously defined here
   13 | const ll mod = 1e9 + 7;
      |          ^~~
a.cc:102:24: error: redefinition of 'template<class T> bool chmax(T&, const T&)'
  102 | template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
      |                        ^~~~~
a.cc:22:24: note: 'template<class T> bool chmax(T&, const T&)' previously declared here
   22 | template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
      |                        ^~~~~
a.cc:103:24: error: redefinition of 'template<class T> bool chmin(T&, const T&)'
  103 | template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
      |                        ^~~~~
a.cc:23:24: note: 'template<class T> bool chmin(T&, const T&)' previously declared here
   23 | template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
      |                        ^~~~~
a.cc:105:37: error: redefinition of 'template<class S, class T> std::ostream& operator<<(std::ostream&, std::pair<_T1, _T2>)'
  105 | template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
      |                                     ^~~~~~~~
a.cc:25:37: note: 'template<class S, class T> std::ostream& operator<<(std::ostream&, std::pair<_T1, _T2>)' previously declared here
   25 | template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
      |                                     ^~~~~~~~
a.cc:108:28: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<_Tp>)'
  108 | template<class T> ostream& operator << (ostream& os, const vector<T> v){
      |                            ^~~~~~~~
a.cc:28:28: note: 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<_Tp>)' previously declared here
   28 | template<class T> ostream& operator << (ostream& os, const vector<T> v){
      |                            ^~~~~~~~
a.cc:111:28: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<std::vector<_Tp> >)'
  111 | template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
      |                            ^~~~~~~~
a.cc:31:28: note: 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<std::vector<_Tp> >)' previously declared here
   31 | template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
      |                            ^~~~~~~~
a.cc:115:27: error: redefinition of 'template<class T> void debug(std::vector<std::vector<_Tp> >&, ll, ll)'
  115 | template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
      |                           ^~~~~
a.cc:35:27: note: 'template<class T> void debug(std::vector<std::vector<_Tp> >&, ll, ll)' previously declared here
   35 | template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
      |                           ^~~~~
a.cc:117:27: error: redefinition of 'template<class T> void debug(std::vector<_Tp>&, ll)'
  117 | template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
      |                           ^~~~~
a.cc:37:27: note: 'template<class T> void debug(std::vector<_Tp>&, ll)' previously declared here
   37 | template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
      |                           ^~~~~
a.cc:121:5: error: redefinition of 'int main()'
  121 | int main(){
      |     ^~~~
a.cc:41:5: note: 'int main()' previously defined here
   41 | int main(){
      |     ^~~~