Language: C++

#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int H, W, K;
	cin >> H >> W >> K;

	vector<vector<int>> grid(H, vector<int>(W, 0));
	vector<vector<int>> cum(H + 1, vector<int>(W + 1, 0));
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			char tmp;
			cin >> tmp;
			grid[i][j] = (tmp - '0');
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cum[i + 1][j + 1] = cum[i + 1][j] + grid[i][j];
		}
	}

	for (int i = 0; i <= W; i++)
	{
		for (int j = 0; j < H; j++)
		{
			cum[j + 1][i] += cum[j][i];
		}
	}

	int ans = INF32;
	for (int i = 0; i < (1 << H - 1); i++) //512
	{
		int current = 0;
		int c_j = 0;
		int slash = 0;

		for (int k = 0; k < W; k++) // 1000
		{

			int js = 0;
			for (int j = 0; (1 << j) <= i; j++) //10
			{

				if (i & (1 << j))
				{
					int num = cum[j + 1][k + 1] - cum[j + 1][slash] - cum[js][k + 1] + cum[js][slash];
					//cout << j << " " << k << " " << num << endl;
					if (K < num)
					{
						//cout << j << " " << k << " " << num << endl;
						if (slash == k)
						{
							current = INF32;
							break;
						}

						slash = k;
						current++;
						break;
					}
					js = j + 1;
				}
			}
			int num = cum[H][k + 1] - cum[H][slash] - cum[js][k + 1] + cum[js][slash];
			if (K < num)
			{

				if (slash == k)
				{
					current = INF32;
					break;
				}
				slash = k;

				current++;
				break;
			}
		}

		for (int j = 0; (1 << j) < i; j++) //10
		{
			if (i & (1 << j))
				current++;
		}
		//cout << i << " " << current << endl;
		ans = min(ans, current);
	}

	cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int H, W, K;
	cin >> H >> W >> K;

	vector<vector<int>> grid(H, vector<int>(W, 0));
	vector<vector<int>> cum(H + 1, vector<int>(W + 1, 0));
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			char tmp;
			cin >> tmp;
			grid[i][j] = (tmp - '0');
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cum[i + 1][j + 1] = cum[i + 1][j] + grid[i][j];
		}
	}

	for (int i = 0; i <= W; i++)
	{
		for (int j = 0; j < H; j++)
		{
			cum[j + 1][i] += cum[j][i];
		}
	}

	int ans = INF32;
	for (int i = 0; i < (1 << H - 1); i++) //512
	{
		int current = 0;
		int c_j = 0;
		int slash = 0;

		for (int k = 0; k < W; k++) // 1000
		{

			int js = 0;
			for (int j = 0; (1 << j) <= i; j++) //10
			{

				if (i & (1 << j))
				{
					int num = cum[j + 1][k + 1] - cum[j + 1][slash] - cum[js][k + 1] + cum[js][slash];
					//cout << j << " " << k << " " << num << endl;
					if (K < num)
					{
						//cout << j << " " << k << " " << num << endl;
						if (slash == k)
						{
							current = INF32;
							break;
						}

						slash = k;
						current++;
						break;
					}
					js = j + 1;
				}
			}
			int num = cum[H][k + 1] - cum[H][slash] - cum[js][k + 1] + cum[js][slash];
			if (K < num)
			{

				if (slash == k)
				{
					current = INF32;
					break;
				}
				slash = k;

				current++;
				break;
			}
		}

		for (int j = 0; (1 << j) < i; j++) //10
		{
			if (i & (1 << j))
				current++;
		}
		//cout << i << " " << current << endl;
		ans = min(ans, current);
	}

	cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Compiler output:
a.cc:121:2: error: stray '#' in program
  121 | }#include <bits/stdc++.h>
      |  ^
a.cc:121:3: error: 'include' does not name a type
  121 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:133:6: error: redefinition of 'void execute()'
  133 | void execute()
      |      ^~~~~~~
a.cc:13:6: note: 'void execute()' previously defined here
   13 | void execute()
      |      ^~~~~~~
a.cc:230:5: error: redefinition of 'int main()'
  230 | int main()
      |     ^~~~
a.cc:110:5: note: 'int main()' previously defined here
  110 | int main()
      |     ^~~~