#include<bits/stdc++.h>
using i8=char;
using u8=unsigned char;
using i16=short;
using u16=unsigned short;
using i32=int;
using u32=unsigned int;
using i64=long long;
using u64=unsigned long long;
using i128=__int128;
using u128=unsigned __int128;
using f32=float;
using f64=double;
using f128=long double;
template<typename T> void read(T &x){
char ch=getchar(),f=1;
x=0;
while(ch<'0'||ch>'9')f=(ch=='-')?-1:1,ch=getchar();
while(ch>='0'&&ch<='9')(x=x*10+(ch-'0')),ch=getchar();
x*=f;
}
template<typename T,typename ...Ts> void read(T &x,Ts &...xs){
read(x);
read(xs...);
}
template<typename T> void write(T x){
if(x<0)putchar('-'),x=-x;
else if(x>9)write(x/10);
putchar((x%10)^48);
}
template<typename T> void writesp(T x){
write(x);
putchar(' ');
}
template<typename T> void writeln(T x){
write(x);
putchar('\n');
}
template<typename T> void writelns(T x){
writeln(x);
}
template<typename T,typename ...Ts> void write(T x,Ts ...xs){
writesp(x);
write(xs...);
}
template<typename T,typename ...Ts> void writeln(T x,Ts ...xs){
write(x,xs...);
putchar('\n');
}
template<typename T,typename ...Ts> void writelns(T x,Ts ...xs){
writeln(x);
writelns(xs...);
}
i32 s,n,m,dp[2][20005],cast[105][105];
int main(){
#ifdef LOCAL
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
freopen("test.err","w",stderr);
#endif
read(s,n,m);
for(i32 i=1;i<=s;i++){
for(i32 j=1;j<=n;j++){
read(cast[j][i]);
cast[j][i]=cast[j][i]*2+1;
}
}
for(i32 i=1;i<=n;i++)std::sort(cast[i]+1,cast[i]+1+s);
for(i32 i=1;i<=n;i++){
i32 now=i&1,prev=now^1;
for(i32 j=0;j<=m;j++){
for(i32 k=1;k<=s;k++){
if(j>=cast[i][k]) dp[now][j]=std::max(dp[now][j],dp[prev][j-cast[i][k]]+k*i);
}
}
}
i32 ans=0;
for(i32 i=1;i<=m;i++){
ans=std::max(ans,dp[n&1][i]);
}
write(ans);
return 0;
}
wa on #3 #6 #7 #8 #9 #10