Language: C

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <cstring>
#include <climits>

#define RREP(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define INVREP(i,a,b) for(int i=a;i>=b;--i)
#define MOD 1000000007ll
#define BIT(i) (1ll<<(i-1))
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }//aに更新したいものを
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

//繰り返し2乗
ll modpow(ll N, ll P, ll M=MOD) {if (P == 0) return 1;if (P % 2 == 0) {ll t = modpow(N, P / 2, M);return t * t % M;}return (N * modpow(N, P - 1, M))%M;}
//階乗
pair<vector<ll>, vector<ll>> fact(ll n) {vector<ll>f(n, 1);RREP(i, 2, n) f[i] = (f[i - 1]*i) % MOD;vector<ll>invf(n, 1);invf[n - 1] = modpow(f[n - 1],MOD-2,MOD);INVREP(i, n - 1, 2) invf[i - 1] = (invf[i]*i) % MOD;return pair<vector<ll>, vector<ll> >(f,invf);}
ll modmult(ll a, ll b, ll M = MOD) { return (a*b) % M; }
ll modadd(ll a, ll b, ll M = MOD) { return (a + b) % M; }
ll comb(pair<vector<ll>, vector<ll>>p, int n, int r) {return modmult(modmult(p.first[n], p.second[r]), p.second[n - r]); }
/*
    auto a = fact(200009);
    cout << comb(a,15,5) << endl;
*/

int main()
{
    /* collection
    ll n;
    cin >> n;
    vector<ll> A;
    REP(i, n) cin >> A[i];
    vector<pair<ll, ll>> AB;
    REP(i, n) {cin >> AB[i].first;cin >> AB[i].second;}
    
    sort(ALL(vec),greater<int>());

    map<ll, ll> mp;
    map<ll, ll, greater<ll>> mp;
    REP(i, 100) mp[i] = i * 10;
    cout << mp.lower_bound(50)->second<<endl;
    cout << mp.upper_bound(50)->second << endl;
    cout << next(mp.upper_bound(50))->second << endl;
    cout << prev(mp.upper_bound(50))->second << endl;
    */
    ll h,w,k;
    cin >> h >> w >> k;
    vector<string> cho(h);
    REP(i,h) cin >> cho[i];

    auto lastans=100000;
    //h-1個の区切りを考える h-1=4なら 0000-10000で区切りを作る
    REP(bit,BIT(h)){
        ll size[10]={0,0,0,0,0,0,0,0,0,0};
        ll ans=0;//区切りの数
        REP(i,h) if(BIT(i) & bit)ans++;
        
        REP(stage,w){//横に見ていく
            int laststage = 0;//もし同じcが二回続き　かつサイズを超えたら区切っても無駄なのでbreak
            int idx=0;
            REP(c,h){//区切って足していく 区切るごとにインデックスをたす
                if(cho[c][stage]=='1'){
                    size[idx]++;
                    //サイズが超えたら最大値を更新しもう一回
                    if(size[idx]>k){
                        if(laststage==c){break;}//一列でむり
                        stage--;
                        REP(z,10)size[z]=0;
                        ans++;
                        laststage=stage;
                        continue;
                    }
                }
                if(bit & BIT(c)){//区切る
                    idx++;
                }
            }
        }
        chmin(lastans,(int)ans);
    }
    
    cout << lastans << endl;
}


Compiler output:
main.c:1:10: fatal error: algorithm: No such file or directory
    1 | #include <algorithm>
      |          ^~~~~~~~~~~
compilation terminated.