Language: C++

#include <bits/stdc++.h>

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
vector<int>NumOfLineInRow,NumOfLineInColumn;
int columnWiseCount[20][1009];
int NumOfOneInPerDivision[11];
int h,w,k;
int solve(int rowLine)
{
    vector<int>NumOfLineInRow,NumOfLineInColumn;
    MEM(NumOfOneInPerDivision,0);
    for(int i=0; i<h-1; i++)
    {

        if((1<<i)&rowLine)
            NumOfLineInRow.pb(i+1);
    }
    NumOfLineInRow.pb(h);
    int y=0;
    int c=0;
    for(int i=1; i<=w; i++)
    {
        y=0;
        int f=0;
        for(int j=0; j<NumOfLineInRow.size(); j++)
        {
            if( columnWiseCount[NumOfLineInRow[j]][i]-columnWiseCount[y][i] > k)
                return w+h;
            NumOfOneInPerDivision[NumOfLineInRow[j]] + = columnWiseCount[NumOfLineInRow[j]][i]-columnWiseCount[y][i];
            if( NumOfOneInPerDivision[NumOfLineInRow[j]] + columnWiseCount[NumOfLineInRow[j]][i+1]-columnWiseCount[y][i+1] > k )
            {
                f=1;
                NumOfLineInColumn.pb(i);
                break;
            }
            y=v[j];
        }

        if(f)
        {
            y=0;
            for(int j=1; j<=w; j++)
            {

                NumOfOneInPerDivision[j]=0;

            }

        }

    }


    return int(NumOfLineInRow.size()-1)+(int)NumOfLineInColumn.size();
}
int main()
{
    FastRead;
    cin>>h>>w>>k;
    char ch[h+1][w+1];
    for(int i=1; i<=h; i++)
    {

        for(int j=1; j<=w; j++)
        {
            cin>>ch[i][j];
            if(ch[i][j]=='1')
                columnWiseCount[i][j]++;
            columnWiseCount[i][j]+=columnWiseCount[i-1][j];
        }
    }
    //    for(int i=1; i<=h; i++)
//    {
//        for(int j=1; j<=w; j++)
//            cout<<columnWiseCount[i][j]<<" ";
//        cout<<endl;
//    }
//    cout<<endl;
    int mn=w+h;
    for(int i=0; i<(1<<h); i++)
    {
        mn=min(mn,solve(i));
    }
    cout<<mn;



}


Compiler output:
a.cc: In function 'int solve(int)':
a.cc:69:56: error: expected primary-expression before '=' token
   69 |             NumOfOneInPerDivision[NumOfLineInRow[j]] + = columnWiseCount[NumOfLineInRow[j]][i]-columnWiseCount[y][i];
      |                                                        ^
a.cc:76:15: error: 'v' was not declared in this scope
   76 |             y=v[j];
      |               ^