#include<bits/stdc++.h>
using namespace std;
#define execute cerr << " Time: " << fixed << setprecision(6) << (1.0 * clock() / CLOCKS_PER_SEC) << "s\n";
#define ll long long
#define ld double
#define ii pair<int,int>
#define se second
#define fi first
#define iii pair<int,ii>
#define all(v) v.begin(),v.end()
#define bit(x,i) (((x)>>(i))&1LL)
#define flip(x,i) ((x)^(1LL<<(i)))
#define ms(d,x) memset(d,x,sizeof(d))
#define sitingfake 1
#define orz 1
#define exist __exist
#define ends __ends
#define visit visited
#define left __left
#define right __right
const ll mod = 1e9 + 7;
const long long linf = 4557430888798830399;
const int inf = 1061109567;
const int maxarr = 1e6 + 5;
int dx[] = {0 , -1 , 0 , 1};
int dy[] = {-1 , 0 , 1 , 0};
template<typename T> bool maximize(T &a, const T &b)
{
if(a < b) {a = b; return 1;}
return 0;
}
template<typename T> bool minimize(T &a, const T &b)
{
if(a > b) {a = b; return 1;}
return 0;
}
inline void Plus(ll & a ,ll b)
{
b %= mod;
a += b;
if(a >= mod) a -= mod;
if(a < 0) a += mod;
return;
}
inline void Mul(ll & a, ll b)
{
a %= mod; b %= mod;
a *= b;
a %= mod;
return;
}
const int maxn = 1e3 + 7;
int a[maxn][5];
int r , c , k;
ll dp[2][maxn * 2][1 << 4];
bool good[1 << 4];
int sum[maxn][1 << 4];
void solve() {
cin >> r >> c >> k;
for (int i = 1; i <= r; i++)
for (int j = 1; j <= c; j++)
cin >> a[i][j];
for (int i = 1; i <= r+1; i++) {
for (int mask = 0; mask < (1<<c); mask++) {
int s = 0;
for (int b = 0; b < c; b++)
if (bit(mask, b)) s += a[i][b+1];
sum[i][mask] = s;
}
}
good[0] = 1;
for (int mask = 0; mask < (1<<c); mask++) if (good[mask]) {
for (int i = 0; i+1 < c; i++) {
if (!bit(mask,i) && !bit(mask,i+1))
good[mask|(1<<i)|(1<<(i+1))] = 1;
}
}
static vector<array<int,4>> trans[1<<4];
for (int premask=0; premask<(1<<c); premask++) {
trans[premask].clear();
int base1 = ((1<<c)-1) ^ premask;
for (int curmask = base1; ; curmask = (curmask-1)&base1) {
if (good[curmask]) {
int base2 = ((1<<c)-1) ^ curmask ^ premask;
for (int nextmask = base2; ; nextmask = (nextmask-1)&base2) {
if ((nextmask & curmask) == 0 && (nextmask & premask) == 0) {
int used = (__builtin_popcount(curmask)/2) + __builtin_popcount(nextmask);
trans[premask].push_back({curmask,nextmask,used,0});
}
if (nextmask==0) break;
}
}
if (curmask==0) break;
}
}
static ll dp[2][1<<4][2005];
for (int i=0;i<2;i++) for (int m=0;m<(1<<c);m++) for (int n=0;n<=k;n++) dp[i][m][n]=-linf;
dp[1][0][0] = 0;
for (int row=1; row<=r; row++) {
int cur=row&1, nxt=cur^1;
for (int m=0;m<(1<<c);m++) for (int n=0;n<=k;n++) dp[nxt][m][n]=-linf;
for (int need=0; need<=k; need++) {
for (int premask=0; premask<(1<<c); premask++) if (dp[cur][premask][need]>-linf) {
for (auto [curmask,nextmask,used,_]: trans[premask]) {
if (need+used>k) continue;
int tmp = sum[row][curmask] + sum[row][nextmask] + sum[row+1][nextmask];
maximize(dp[nxt][nextmask][need+used], dp[cur][premask][need]+tmp);
}
}
}
}
cout << dp[(r+1)&1][0][k];
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#define task "domine"
if(fopen(task".inp","r"))
{
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
int tc; tc = 1;
while(tc--) solve();
}