#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
#include <cassert>
#include <complex>

using namespace std;
typedef long long ll;

const int SIZE = 201;

int n, h, w;
int a[SIZE][SIZE], sa[SIZE][SIZE];

void rotate() {
	int b[SIZE][SIZE];

	for (int i = 0; i<h; i++) {
		for (int j = 0; j<w; j++) {
			b[h-i-1][j] = a[i][j];
		}
	}

	for (int i = 0; i<h; i++) {
		for (int j = 0; j<w; j++) {
			a[i][j] = b[i][j];
		}
	}

  
}

void calc_sum() {
	for (int i = 0; i<h; i++)
		for (int j = 0; j<w; j++)
			sa[i + 1][j + 1] = a[i][j];


	for (int i = 0; i <= h; i++) {
		for (int j = 0; j < w; j++) {
			sa[i][j + 1] += sa[i][j];
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j <= w; j++) {
			sa[i + 1][j] += sa[i][j];
		}
	}
}


int getrangesum(int u, int l, int d, int r) { // [(u, l),(d, r)) 
	return sa[d][r] + sa[u][l] - sa[d][l] - sa[u][r];
}


int check(int l, int m, int r, int X) {
  int res = -1;
	for (int i = 1; i<h; i++) {
		if (getrangesum(0, l, i, m) >= X && getrangesum(i, l, h, r) >= X) res = i;
	}
	return res;
}

int check2(int l, int m, int r, int X) {
  int res = -1;
	for (int i = h - 1; i>0; i--) {
		if (getrangesum(0, l, i, r) >= X && getrangesum(i, m, h, r) >= X) res = i;;
	}
	return res;
}


//[)
bool checkE(int h0, int w0, int h1, int w1, int mid, int k)
{
	if (k == 1) {
		return getrangesum(h0, w0, h1, w1) >= mid;
	}

	for (int i = 1; i < w; ++i)
	{
		auto left = getrangesum(h0, w0, h1, i);
		auto right = getrangesum(h0, i, h1, w1);

		if (left >= mid && right >= (k-1) * mid) {
			if (checkE(h0, i, h1, w1, mid, k-1)) {
				return true;
			}
		}
		if (right >= mid && left >= (k-1) * mid) {
			if (checkE(h0, w0, h1, i, mid, k-1)) {
				return true;
			}
		}

    if (k == 4 && right >= mid*2 && left >= 2 * mid) {
			if (checkE(h0, i, h1, w1, mid, 2) && checkE(h0, w0, h1, i, mid, 2)) {
				return true;
			}
		}
	}

	for (int j = 1; j < h; ++j)
	{
		auto up = getrangesum(h0, w0, j, w1);
		auto down = getrangesum(j, w0, h1, w1);

		if (up >= mid && down >= (k-1) * mid) {
			if (checkE(j, w0, h1, w1, mid, k - 1)) {
				return true;
			}
		}
		if (down >= mid && up >= (k-1) * mid) {
			if (checkE(h0, w0, j, w1, mid, k - 1)) {
				return true;
			}
		}

    if (k == 4 && up >= mid*2 && down >= 2 * mid) {
			if (checkE(j, w0, h1, w1, mid, 2) && checkE(h0, w0, j, w1, mid, 2)) {
				return true;
			}
		}
	}

  return false;
}

int main() {

	scanf("%d%d%d", &h, &w, &n);

	for (int i = 0; i<h; i++) {
		for (int j = 0; j<w; j++) {
			scanf("%d", a[i] + j);
		}
	}

	int ans = 0;

	if (n == 4 && w >= 3) {
		for (int p = 0; p<2; p++) {
			rotate();
			calc_sum();

			for (int i = 1; i<w; i++) {
				for (int j = i + 1; j <= w; j++) {
					int l = 0, r = sa[h][w];
					while (l < r) {
						int mid = (l + r + 1) / 2;

            int res1 = check(0, i, j, mid);
            int res2 = check2(i, j, w, mid);
            
						if (res1 != -1 && res2 != -1 && res1 >= res2) {
							l = mid;
						}
						else {
							r = mid - 1;
						}
					}

          //cerr << l << endl;
					ans = max(ans, l);
				}
			}
		}
	}


	calc_sum();
	int l = 0, r = sa[h][w];
	while (l < r) {
		int mid = (l + r + 1) / 2;

		if (checkE(0,0,h, w, mid, n)) {
			l = mid;
		}
		else {
			r = mid - 1;
		}
	}
  //cerr << l << endl;
	ans = max(ans, l);

	std::cout << ans << std::endl;

}



Measured memory_bytes: 3688