#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
ll a[85][85],f[85][85];
ll solve(int x,int day,int l,int r,ll sum)
{
// cout<<x<<" "<<day<<" "<<l<<" "<<r<<" "<<sum<<endl;
if (day>m) return sum;
// if (f[l][r]) return f[l][r];记忆化
f[l][r]=max(solve(x,day+1,l+1,r,sum+a[x][l]*(1<<day)),solve(x,day+1,l,r-1,sum+a[x][r]*(1<<day)));
return f[l][r];
}
int main()
{
cin>>n>>m;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
scanf("%lld",&a[i][j]);
ll ans=0;
for (int x=1;x<=n;x++){
memset(f,0,sizeof f);
solve(x,1,1,m,0);
// cout<<f[1][m]<<endl;
ans+=f[1][m];
}
cout<<ans<<endl;
return 0;
}
有那个语句则有个数据是错的,没有那个语句会超时