Language: C++

#include <bits/stdc++.h>
using namespace std;
#define fori(i, S, E) for (int i = S; i < E; i++)
#define all(x) x.begin(), x.end()

int main() {
    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<char>> C (H, vector<char>(W));

    fori(i, 0, H) {
    fori(j, 0, W) {
        cin >> C[i][j];
    }
        cin.ignore();
    }

    long long best = 9987654321;

    vector<int> amount (H, 0);
    vector<int> line_amount (H, 0);

    fori(b, 0, 1 << (H - 1)) {
        fill(all(amount), 0);

        vector<int> cuts (W, 0);

        bool impossible = false;

        fori(j, 0, W) {
            int p = 0;

            fori(i, 0, H) {
                line_amount[p] += C[i][j] - '0';

                if (amount[p]+line_amount[p] > K) {
                    fill(all(amount), 0);
                    if (cuts[j] == 0) {
                        cuts[j] = 1;
                    } else {
                        impossible = true;
                    }
                }

                if (b & (1 << i)) {
                    p++;
                }
            }

            fori(k, 0, H) {
                amount[k] += line_amount[k];
                line_amount[k] = 0;
            }
        }

        if (!impossible) {
            int horizontal_cuts = accumulate(all(cuts), 0);
            int vertical_cuts = __builtin_popcount(b);

            best = min(best, horizontal_cuts + vertical_cuts);
        }
    }

    cout << best << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:23: error: no matching function for call to 'min(long long int&, int)'
   61 |             best = min(best, horizontal_cuts + vertical_cuts);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:61:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   61 |             best = min(best, horizontal_cuts + vertical_cuts);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:61:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   61 |             best = min(best, horizontal_cuts + vertical_cuts);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~