#include <stdio.h>
#include "math.h"

long a[600][600],maxup[600][600][2],maxdo[600][600][2],maxr[600][600][2],b[600][600],n,m,r,u=4;

long findup(long a,long b,long*m1,long*m2){
    if (a<0||b>=m){
        *m1=0;
        *m2=0;
        return 0;
    }
    else{

        if (a>=n){
            a=n-1;
        }
        if (b<0){
            b=0;
        }
        *m1=maxup[a][b][0];
        *m2=maxup[a][b][1];
    }
    return 0;
}

long dat(){
    u+=1;
    u%=5;
    if (u==0) {
        return 812;
    }
    if (u==1){
        return 275;
    }
    if (u==2){
        return 315;
    }
    if (u==3){
        return 327;
    }
    if (u==4){
        return 482;
    }
    return 0;
}

long finddo(long a,long b,long *m1,long *m2){
    if (a>=n||b>=m){
        *m1=0;
        *m2=0;
        return 0;
    }
    else{
        if (a<0){
            a=0;
        }
        if (b<0){
            b=0;
        }
        *m1=maxdo[a][b][0];
        *m2=maxdo[a][b][1];
    }
    return 0;
}

long comb(long *a,long *a1,long *b,long *b1){

    if (*b>*a){
        *a=*b;
        *a1=*b1;
    }
    else if (*b==*a){
        *a1+=*b1;
    }
    return 0;
}

long max2ld(long a,long b){
    if (a>b){
        return a;
    }
    return b;
}

long min2ld(long a,long b){
    if (a<b){
        return a;
    }
    return b;
}

int sdis(long x1,long y1,long x2,long y2){
    long d;
    d=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    if (d>(r*r)){
        return 0;
    }
    return 1;
}

int ncro(long x1,long y1,long x2,long y2){

    long mx,my;
    mx=(x1+x2)/2;
    my=(y1+y2)/2;

    if (sdis(x1,y1,mx,my)&&sdis(x2,y2,mx,my)){
        return 0;
    }
    mx+=1;
    if (sdis(x1,y1,mx,my)&&sdis(x2,y2,mx,my)){
        return 0;
    }
    my+=1;
    if (sdis(x1,y1,mx,my)&&sdis(x2,y2,mx,my)){
        return 0;
    }
    mx-=1;
    if (sdis(x1,y1,mx,my)&&sdis(x2,y2,mx,my)){
        return 0;
    }
    return 1;
}

int main(){

    long i,j,k,j1,ii,jj,m1,m2,m1t,m2t;
    long long max,maxn;

    scanf("%ld%ld%ld",&n,&m,&r);
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            scanf("%ld",&a[i][j]);
            b[i][j]=0;
            maxdo[i][j][0]=0;
            maxdo[i][j][1]=0;
            maxup[i][j][0]=0;
            maxup[i][j][1]=0;
        }
    }
    for (i=1;i<n;i++){
        for (j=0;j<m;j++){
            a[i][j]+=a[i-1][j];
        }
    }

    for (i=r;i<(n-r);i++){
        for (j=r;j<(m-r);j++){
            for (k=j-r;k<=j+r;k++){
                j1=sqrt(r*r-(j-k)*(j-k));
                if ((i-j1-1)>=0)
                    b[i][j]+=a[i+j1][k]-a[i-j1-1][k];
                else
                    b[i][j]+=a[i+j1][k];
            }
        }
    }
    for (i=0;i<n;i++){
        maxup[i][m-1][0]=b[i][m-1];
        maxup[i][m-1][1]=1;
        for (j=m-2;j>=0;j--){
            if (b[i][j]>maxup[i][j+1][0]){
                maxup[i][j][0]=b[i][j];
                maxup[i][j][1]=1;
            }
            else if (b[i][j]==maxup[i][j+1][0]){
                maxup[i][j][0]=b[i][j];
                maxup[i][j][1]=maxup[i][j+1][1]+1;
            }
            else {
                maxup[i][j][0]=maxup[i][j+1][0];
                maxup[i][j][1]=maxup[i][j+1][1];
            }
        }
    }
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            maxr[i][j][0]=maxup[i][j][0];
            maxr[i][j][1]=maxup[i][j][1];
        }
    }
    for (j=0;j<m;j++){
        maxdo[n-1][j][0]=maxup[n-1][j][0];
        maxdo[n-1][j][1]=maxup[n-1][j][1];
        for (i=n-2;i>=0;i--){
            if (maxup[i][j][0]>maxdo[i+1][j][0]){
                maxdo[i][j][0]=maxup[i][j][0];
                maxdo[i][j][1]=maxup[i][j][1];
            }
            else if (maxup[i][j][0]==maxdo[i+1][j][0]){
                maxdo[i][j][0]=maxup[i][j][0];
                maxdo[i][j][1]=maxup[i][j][1]+maxdo[i+1][j][1];
            }
            else {
                maxdo[i][j][0]=maxdo[i+1][j][0];
                maxdo[i][j][1]=maxdo[i+1][j][1];
            }
        }
    }
    for (j=0;j<m;j++){
        for (i=1;i<n;i++){
            comb(&maxup[i][j][0], &maxup[i][j][1], &maxup[i-1][j][0], &maxup[i-1][j][1]);
        }
    }

    max=0;
    maxn=0;
    for (i=r;i<(n-r);i++){
        for (j=r;j<(m-r);j++){
            m1=0;
            m2=0;
            findup(i-2*r-1,j,&m1,&m2);
            finddo(i+2*r+1,j+1,&m1t,&m2t);
            comb(&m1,&m2,&m1t,&m2t);
            for (ii=max2ld(i-2*r,r),jj=j;ii<=i;ii++){
                while (!ncro(i, j, ii, jj)) {
                    jj++;
                }
                comb(&m1, &m2, &maxr[ii][jj][0], &maxr[ii][jj][1]);
            }
            for (;ii<=min2ld(i+2*r,n-r-1);ii++){
                while (ncro(i, j, ii, jj)) {
                    jj--;
                }
                jj++;
                comb(&m1, &m2, &maxr[ii][jj][0], &maxr[ii][jj][1]);
            }

            if (m2==0||m1==0){
                continue;
            }
            m1+=b[i][j];
            if (m1>max){
                max=m1;
                maxn=m2;
            }
            else if (m1==max){
                maxn+=m2;
            }
        }
    }
    printf("%I64d %I64d\n",max,maxn);
    return 0;
}


#include <stdio.h>
#include "math.h"

long long a[600][600],maxup[600][600][2],maxdo[600][600][2],maxr[600][600][2],b[600][600],n,m,r,u=4,rtmp[1100],rr[1100];

long long dat(){
    u+=1;
    u%=5;
    if (u==0) {
        return 812;
    }
    if (u==1){
        return 275;
    }
    if (u==2){
        return 315;
    }
    if (u==3){
        return 327;
    }
    if (u==4){
        return 482;
    }
    return 0;
}

long long findup(long long a,long long b,long long*m1,long long*m2){
    if (a<0||b>=m){
        *m1=0;
        *m2=0;
        return 0;
    }
    else{

        if (a>=n){
            a=n-1;
        }
        if (b<0){
            b=0;
        }
        *m1=maxup[a][b][0];
        *m2=maxup[a][b][1];
    }
    return 0;
}

long long finddo(long long a,long long b,long long *m1,long long *m2){
    if (a>=n||b>=m){
        *m1=0;
        *m2=0;
        return 0;
    }
    else{
        if (a<0){
            a=0;
        }
        if (b<0){
            b=0;
        }
        *m1=maxdo[a][b][0];
        *m2=maxdo[a][b][1];
    }
    return 0;
}

long long comb(long long *a,long long *a1,long long *b,long long *b1){

    if (*b>*a){
        *a=*b;
        *a1=*b1;
    }
    else if (*b==*a){
        *a1+=*b1;
    }
    return 0;
}

long long max2ld(long long a,long long b){
    if (a>b){
        return a;
    }
    return b;
}

long long min2ld(long long a,long long b){
    if (a<b){
        return a;
    }
    return b;
}

int sdis(long long x1,long long y1,long long x2,long long y2){
    long long d;
    d=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    if (d>(r*r)){
        return 0;
    }
    return 1;
}

int rinit(){
    long i,j,k,w;
    for (i=0;i<=r*2;i++){
        for (j=0;j<=r*2;j++){
            if (!sdis(r, 0, i, j))
                break;
        }
        rtmp[i]=j-1;
    }
    for (i=0;i<=r*4;i++){
        for (j=0;j<=r*4+1;j++){
            w=0;
            for (k=0;k<=r*2;k++){
                if (sdis(k+r, rtmp[k], i, j)){
                    w=1;
                    break;
                }
            }
            if (w==0){
                rr[i]=j;
                break;
            }
        }
    }
    return 0;
}

int main(){

    long long i,j,k,j1,ii,jj,m1,m2,m1t,m2t;
    long long max,maxn;

    scanf("%I64d%I64d%I64d",&n,&m,&r);
    rinit();
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            scanf("%I64d",&a[i][j]);
            b[i][j]=0;
            maxdo[i][j][0]=0;
            maxdo[i][j][1]=0;
            maxup[i][j][0]=0;
            maxup[i][j][1]=0;
        }
    }
    for (i=1;i<n;i++){
        for (j=0;j<m;j++){
            a[i][j]+=a[i-1][j];
        }
    }

    for (i=r;i<(n-r);i++){
        for (j=r;j<(m-r);j++){
            for (k=j-r;k<=j+r;k++){
                j1=sqrt(r*r-(j-k)*(j-k));
                if ((i-j1-1)>=0)
                    b[i][j]+=a[i+j1][k]-a[i-j1-1][k];
                else
                    b[i][j]+=a[i+j1][k];
            }
        }
    }
    for (i=0;i<n;i++){
        maxup[i][m-1][0]=b[i][m-1];
        maxup[i][m-1][1]=1;
        for (j=m-2;j>=0;j--){
            if (b[i][j]>maxup[i][j+1][0]){
                maxup[i][j][0]=b[i][j];
                maxup[i][j][1]=1;
            }
            else if (b[i][j]==maxup[i][j+1][0]){
                maxup[i][j][0]=b[i][j];
                maxup[i][j][1]=maxup[i][j+1][1]+1;
            }
            else {
                maxup[i][j][0]=maxup[i][j+1][0];
                maxup[i][j][1]=maxup[i][j+1][1];
            }
        }
    }
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            maxr[i][j][0]=maxup[i][j][0];
            maxr[i][j][1]=maxup[i][j][1];
        }
    }
    for (j=0;j<m;j++){
        maxdo[n-1][j][0]=maxup[n-1][j][0];
        maxdo[n-1][j][1]=maxup[n-1][j][1];
        for (i=n-2;i>=0;i--){
            if (maxup[i][j][0]>maxdo[i+1][j][0]){
                maxdo[i][j][0]=maxup[i][j][0];
                maxdo[i][j][1]=maxup[i][j][1];
            }
            else if (maxup[i][j][0]==maxdo[i+1][j][0]){
                maxdo[i][j][0]=maxup[i][j][0];
                maxdo[i][j][1]=maxup[i][j][1]+maxdo[i+1][j][1];
            }
            else {
                maxdo[i][j][0]=maxdo[i+1][j][0];
                maxdo[i][j][1]=maxdo[i+1][j][1];
            }
        }
    }
    for (j=0;j<m;j++){
        for (i=1;i<n;i++){
            comb(&maxup[i][j][0], &maxup[i][j][1], &maxup[i-1][j][0], &maxup[i-1][j][1]);
        }
    }

    max=0;
    maxn=0;
    for (i=r;i<(n-r);i++){
        for (j=r;j<(m-r);j++){
            m1=0;
            m2=0;
            findup(i-2*r-1,j,&m1,&m2);
            finddo(i+2*r+1,j+1,&m1t,&m2t);
            comb(&m1,&m2,&m1t,&m2t);
            for (ii=max2ld(i-2*r,r);ii<=min2ld(i+2*r, n-r);ii++){
                jj=rr[i-ii+2*r]+j;
                if (jj<m)
                    comb(&m1, &m2, &maxr[ii][jj][0], &maxr[ii][jj][1]);
            }

            if (m2==0||m1==0){
                continue;
            }
            m1+=b[i][j];

            if (m1>max){
                max=m1;
                maxn=m2;
            }
            else if (m1==max){
                maxn+=m2;
            }
        }
    }
    printf("%I64d %I64d\n",max,maxn);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 510
#define inf 1000000000
using namespace std;
int n,m,r,sum[N][N],maxl[N][N],maxr[N][N],maxx,ans,L[N],R[N],i,j,x,k,h[N][N],
	numl[N][N],numr[N][N],num,r2,L2[N+N],R2[N+N],y;
long long fans;
void renew(int &x,int &y,int xx,int yy,int vx,int vy){
	x=vx; y=vy;
	if(xx>x)x=xx,y=yy;
	else if(xx==x)y+=yy;
}
int main(){
	scanf("%d%d%d",&n,&m,&r);
	for(i=-r;i<=r;++i){
		for(j=-r;j<=r;++j)if(i*i+j*j<=r*r)break;
		L[i+r]=j+r;
		R[i+r]=-j+r;
	}
	r2=2*r;
	for(i=0;i<=r2;++i)
		for(j=0;j<=r2;++j)
			R2[i+j]=max(R2[i+j],R[i]+R[j]);
	for(i=0;i<=r2+r2;++i)L2[i]=r2+r2-R2[i];
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j)scanf("%d",&x),sum[i][j]=sum[i][j-1]+x;
	memset(h,200,sizeof(h));
	for(i=1;i+2*r<=n;++i)
		for(j=1;j+2*r<=m;++j){
			h[i+r][j+r]=0;
			for(k=0;k<=2*r;++k)h[i+r][j+r]+=sum[i+k][j+R[k]]-sum[i+k][j+L[k]-1];
		}
	for(i=1;i<=n;++i){
		maxl[i][0]=maxr[i][m+1]=-inf;
		for(j=1;j<=m;++j)
			renew(maxl[i][j],numl[i][j],maxl[i][j-1],numl[i][j-1],h[i][j],1);
		for(j=m;j>=1;--j)
			renew(maxr[i][j],numr[i][j],maxr[i][j+1],numr[i][j+1],h[i][j],1);
	}
	for(i=1;i+2*r<=n;++i)
		for(j=1;j+2*r<=m;++j){
			maxx=-inf; num=0;
			for(k=1;k<i-r;++k)renew(maxx,num,maxx,num,maxl[k][m],numl[k][m]);
			for(k=i+3*r+1;k<=n;++k)renew(maxx,num,maxx,num,maxl[k][m],numl[k][m]);
			for(k=-r;k<=3*r;++k){
				x=j+L2[k+r]-r-1; y=j+R2[k+r]-r+1;
				if(k+i>=1 && k+i<=n && x>=1)renew(maxx,num,maxx,num,maxl[k+i][x],numl[k+i][x]);
				if(k+i>=1 && k+i<=n && y<=m)renew(maxx,num,maxx,num,maxr[k+i][y],numr[k+i][y]);
			}
			maxx+=h[i+r][j+r];
			if(maxx>ans)ans=maxx,fans=num;
			else if(maxx==ans)fans+=num;
		}
	printf("%d %I64d\n",ans,fans/2);
}


#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define REPC(I, C) for (int I = 0; !(C); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
int n,m,r,a[555][555];
int w[555],dif[1010],row[555][555],cc[555][555];
int ma_fr[555][555],ma_fr_cnt[555][555];
int ma_fl[555][555],ma_fl_cnt[555][555];
int get_row(int rr,int L,int R){
    return row[rr][R]-row[rr][L-1];
}
int main(){
    RIII(n,m,r);
    REPP(i,1,n+1)REPP(j,1,m+1)RI(a[i][j]);
    swap(n,m);
    REPP(i,1,501)REPP(j,i,501)swap(a[i][j],a[j][i]);
    REPP(i,1,n+1)REPP(j,1,m+1)row[i][j]=row[i][j-1]+a[i][j];
    if(1+r>min(n,m)-r){
        puts("0 0");
        return 0;
    }
    for(int i=0;i<=r;i++){
        int j=0;
        while((j+1)*(j+1)+i*i<=r*r)j++;
        w[i]=j;
    }
    REP(i,2*r+1){
        int ma=0;
        for(int j=0;j<=r;j++){
            if(j<i-r)continue;
            ma=max(ma,w[j]+1+w[abs(i-j)]);
        }
        dif[i]=ma;
    }
    for(int i=1+r;i<=n-r;i++){
        for(int j=1+r;j<=m-r;j++){
            for(int k=-r;k<=r;k++){
                cc[i][j]+=get_row(i+k,j-w[abs(k)],j+w[abs(k)]);
            }
            if(cc[i][j]>ma_fl[i][j-1]){
                ma_fl[i][j]=cc[i][j];
                ma_fl_cnt[i][j]=1;
            }
            else if(cc[i][j]==ma_fl[i][j-1]){
                ma_fl[i][j]=cc[i][j];
                ma_fl_cnt[i][j]=ma_fl_cnt[i][j-1]+1;
            }
            else{
                ma_fl[i][j]=ma_fl[i][j-1];
                ma_fl_cnt[i][j]=ma_fl_cnt[i][j-1];
            }
        }
        for(int j=m-r;j>=1+r;j--){
            if(cc[i][j]>ma_fr[i][j+1]){
                ma_fr[i][j]=cc[i][j];
                ma_fr_cnt[i][j]=1;
            }
            else if(cc[i][j]==ma_fr[i][j+1]){
                ma_fr[i][j]=cc[i][j];
                ma_fr_cnt[i][j]=ma_fr_cnt[i][j+1]+1;
            }
            else{
                ma_fr[i][j]=ma_fr[i][j+1];
                ma_fr_cnt[i][j]=ma_fr_cnt[i][j+1];
            }
        }
    }
    /*for(int i=1+r;i<=n-r;i++){
        for(int j=1+r;j<=m-r;j++){
            printf("l:(%d,%d) r:(%d,%d)   ",ma_fl[i][j],ma_fl_cnt[i][j],ma_fr[i][j],ma_fr_cnt[i][j]);
        }
        puts("");
    }*/
    int an1=0;
    long long an2=0;
    for(int i=1+r;i<=n-r;i++)
        for(int j=1+r;j<=m-r;j++){
            for(int k=1+r;k<=n-r;k++){
                if(abs(i-k)>2*r){
                    int now=cc[i][j]+ma_fr[k][1+r];
                    if(now>an1){
                        an1=now;
                        an2=ma_fr_cnt[k][1+r];
                    }
                    else if(now==an1){
                        an2+=ma_fr_cnt[k][1+r];
                    }
                }
                else{
                    int dd=abs(i-k);
                    int ny=j+dif[dd];
                    if(ny<=m-r){
                        int now=cc[i][j]+ma_fr[k][ny];
                        if(now>an1){
                            an1=now;
                            an2=ma_fr_cnt[k][ny];
                        }
                        else if(now==an1){
                            an2+=ma_fr_cnt[k][ny];
                        }
                    }
                    ny=j-dif[dd];
                    if(ny>=1+r){
                        int now=cc[i][j]+ma_fl[k][ny];
                        if(now>an1){
                            an1=now;
                            an2=ma_fl_cnt[k][ny];
                        }
                        else if(now==an1){
                            an2+=ma_fl_cnt[k][ny];
                        }
                    }
                }
            }
        }
    printf("%d %I64d\n",an1,an2/2);
    return 0;
}


#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define REPC(I, C) for (int I = 0; !(C); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
int n,m,r,a[555][555];
int w[555],dif[1010],row[555][555],cc[555][555];
int ma_fr[555][555],ma_fr_cnt[555][555];
int ma_fl[555][555],ma_fl_cnt[555][555];
int get_row(int rr,int L,int R){
    return row[rr][R]-row[rr][L-1];
}
int main(){
    RIII(n,m,r);
    REPP(i,1,n+1)REPP(j,1,m+1)RI(a[i][j]);
    REPP(i,1,n+1)REPP(j,1,m+1)row[i][j]=row[i][j-1]+a[i][j];
    for(int i=0;i<=r;i++){
        int j=0;
        while((j+1)*(j+1)+i*i<=r*r)j++;
        w[i]=j;
    }
    REP(i,2*r+1){
        int ma=0;
        for(int j=0;j<=r;j++){
            if(j<i-r)continue;
            ma=max(ma,w[j]+1+w[abs(i-j)]);
        }
        dif[i]=ma;
    }
    for(int i=1+r;i<=n-r;i++){
        for(int j=1+r;j<=m-r;j++){
            for(int k=-r;k<=r;k++){
                cc[i][j]+=get_row(i+k,j-w[abs(k)],j+w[abs(k)]);
            }
            if(cc[i][j]>ma_fl[i][j-1]){
                ma_fl[i][j]=cc[i][j];
                ma_fl_cnt[i][j]=1;
            }
            else if(cc[i][j]==ma_fl[i][j-1]){
                ma_fl[i][j]=cc[i][j];
                ma_fl_cnt[i][j]=ma_fl_cnt[i][j-1]+1;
            }
            else{
                ma_fl[i][j]=ma_fl[i][j-1];
                ma_fl_cnt[i][j]=ma_fl_cnt[i][j-1];
            }
        }
        for(int j=m-r;j>=1+r;j--){
            if(cc[i][j]>ma_fr[i][j+1]){
                ma_fr[i][j]=cc[i][j];
                ma_fr_cnt[i][j]=1;
            }
            else if(cc[i][j]==ma_fr[i][j+1]){
                ma_fr[i][j]=cc[i][j];
                ma_fr_cnt[i][j]=ma_fr_cnt[i][j+1]+1;
            }
            else{
                ma_fr[i][j]=ma_fr[i][j+1];
                ma_fr_cnt[i][j]=ma_fr_cnt[i][j+1];
            }
        }
    }
    /*for(int i=1+r;i<=n-r;i++){
        for(int j=1+r;j<=m-r;j++){
            printf("l:(%d,%d) r:(%d,%d)   ",ma_fl[i][j],ma_fl_cnt[i][j],ma_fr[i][j],ma_fr_cnt[i][j]);
        }
        puts("");
    }*/
    int an1=0;
    long long an2=0;
    for(int i=1+r;i<=n-r;i++)
        for(int j=1+r;j<=m-r;j++){
            for(int k=1+r;k<=n-r;k++){
                if(abs(i-k)>2*r){
                    int now=cc[i][j]+ma_fr[k][1+r];
                    if(now>an1){
                        an1=now;
                        an2=ma_fr_cnt[k][1+r];
                    }
                    else if(now==an1){
                        an2+=ma_fr_cnt[k][1+r];
                    }
                }
                else{
                    int dd=abs(i-k);
                    int ny=j+dif[dd];
                    if(ny<=m-r){
                        int now=cc[i][j]+ma_fr[k][ny];
                        if(now>an1){
                            an1=now;
                            an2=ma_fr_cnt[k][ny];
                        }
                        else if(now==an1){
                            an2+=ma_fr_cnt[k][ny];
                        }
                    }
                    ny=j-dif[dd];
                    if(ny>=1+r){
                        int now=cc[i][j]+ma_fl[k][ny];
                        if(now>an1){
                            an1=now;
                            an2=ma_fl_cnt[k][ny];
                        }
                        else if(now==an1){
                            an2+=ma_fl_cnt[k][ny];
                        }
                    }
                }
            }
        }
    printf("%d %I64d\n",an1,an2/2);
    return 0;
}


#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define REPC(I, C) for (int I = 0; !(C); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
int n,m,r,a[555][555];
int w[555],dif[1010],row[555][555],cc[555][555];
int ma_fr[555][555],ma_fr_cnt[555][555];
int ma_fl[555][555],ma_fl_cnt[555][555];
int get_row(int rr,int L,int R){
    return row[rr][R]-row[rr][L-1];
}
int main(){
    RIII(n,m,r);
    REPP(i,1,n+1)REPP(j,1,m+1)RI(a[i][j]);
    REPP(i,1,n+1)REPP(j,1,m+1)row[i][j]=row[i][j-1]+a[i][j];
    for(int i=0;i<=r;i++){
        int j=0;
        while((j+1)*(j+1)+i*i<=r*r)j++;
        w[i]=j;
    }
    REP(i,2*r+1){
        int ma=0;
        for(int j=0;j<=r;j++){
            if(j<i-r)continue;
            ma=max(ma,w[j]+1+w[abs(i-j)]);
        }
        dif[i]=ma;
    }
    for(int i=1+r;i<=n-r;i++){
        for(int j=1+r;j<=m-r;j++){
            for(int k=-r;k<=r;k++){
                cc[i][j]+=get_row(i+k,j-w[abs(k)],j+w[abs(k)]);
            }
            if(cc[i][j]>ma_fl[i][j-1]){
                ma_fl[i][j]=cc[i][j];
                ma_fl_cnt[i][j]=1;
            }
            else if(cc[i][j]==ma_fl[i][j-1]){
                ma_fl[i][j]=cc[i][j];
                ma_fl_cnt[i][j]=ma_fl_cnt[i][j-1]+1;
            }
        }
        for(int j=m-r;j>=1+r;j--){
            if(cc[i][j]>ma_fr[i][j+1]){
                ma_fr[i][j]=cc[i][j];
                ma_fr_cnt[i][j]=1;
            }
            else if(cc[i][j]==ma_fr[i][j+1]){
                ma_fr[i][j]=cc[i][j];
                ma_fr_cnt[i][j]=ma_fr_cnt[i][j+1]+1;
            }
        }
    }
    int an1=0;
    long long an2=0;
    for(int i=1+r;i<=n-r;i++)
        for(int j=1+r;j<=m-r;j++){
            for(int k=1+r;k<=n-r;k++){
                if(abs(i-k)>2*r){
                    int now=cc[i][j]+ma_fr[k][1+r];
                    if(now>an1){
                        an1=now;
                        an2=ma_fr_cnt[k][1+r];
                    }
                    else if(now==an1){
                        an2+=ma_fr_cnt[k][1+r];
                    }
                }
                else{
                    int dd=abs(i-k);
                    int ny=j+dif[dd];
                    if(ny<=m-r){
                        int now=cc[i][j]+ma_fr[k][ny];
                        if(now>an1){
                            an1=now;
                            an2=ma_fr_cnt[k][ny];
                        }
                        else if(now==an1){
                            an2+=ma_fr_cnt[k][ny];
                        }
                    }
                    ny=j-dif[dd];
                    if(ny>=1+r){
                        int now=cc[i][j]+ma_fl[k][ny];
                        if(now>an1){
                            an1=now;
                            an2=ma_fl_cnt[k][ny];
                        }
                        else if(now==an1){
                            an2+=ma_fl_cnt[k][ny];
                        }
                    }
                }
            }
        }
    printf("%d %I64d\n",an1,an2/2);
    return 0;
}


//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
    static int r, sign;
    static char c;
    r = 0, c = getchar(), sign = 1;
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') sign = -1, c = getchar();
    while (c >= '0' && c <= '9') r = r * 10 + (c - '0'), c = getchar();
    return r * sign;
}

template <typename T>
inline void print(T *a, int n) {
    for (int i = 1; i < n; ++i) cout << a[i] << " ";
    cout << a[n] << endl;
}
#define PRINT(__l, __r, __begin, __end) { cout << #__l << __begin << "~" << __end - 1 << #__r": "; for (int __i = __begin; __i != __end; ++__i) cout << __l __i __r << " "; cout << endl; }

#define N 510
#define R 2000
int n, m, r, a[N + 1][N + 1], sum[N + 1][N + 1], len[R + 1], w[N + 1][N + 1], dist[R + 1];
int pre[N + 1][N + 1], suf[N + 1][N + 1], prec[N + 1][N + 1], sufc[N + 1][N + 1];

inline bool in(int a, int b) {
    return a * a + b * b <= r * r;
}

int main(int argc, char* argv[]) {
#ifdef KANARI
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    scanf("%d%d%d", &n, &m, &r);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            scanf("%d", &a[i][j]);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            sum[i][j] = sum[i][j - 1] + a[i][j];
    if (r > 1000 || in(n - 1, m - 1)) {
        printf("0 0\n");
        return 0;
    }
    for (int i = 0; i <= r; ++i)
        while (in(i, len[i])) ++len[i];
    for (int i = 0; i <= 2 * r; ++i)
        for (int j = 0; j <= i; ++j)
            dist[i] = max(dist[i], len[j] + len[i - j]);

    for (int i = r + 1; i <= n - r; ++i) {
        int up = max(1, i - r), down = min(n, i + r);
        for (int j = r + 1; j <= m - r; ++j)
            for (int k = up; k <= down; ++k)
                w[i][j] += sum[k][min(m, j + len[abs(k - i)] - 1)] - sum[k][max(0, j - len[abs(k - i)])];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j)
            if (w[i][j] > pre[i][j - 1]) {
                pre[i][j] = w[i][j], prec[i][j] = 1;
            } else if (w[i][j] == pre[i][j - 1]) {
                pre[i][j] = w[i][j], prec[i][j] = prec[i][j - 1] + 1;
            } else {
                pre[i][j] = pre[i][j - 1], prec[i][j] = prec[i][j - 1];
            }
        for (int j = m; j > 0; --j)
            if (w[i][j] > suf[i][j + 1]) {
                suf[i][j] = w[i][j], sufc[i][j] = 1;
            } else if (w[i][j] == suf[i][j + 1]) {
                suf[i][j] = w[i][j], sufc[i][j] = sufc[i][j + 1] + 1;
            } else {
                suf[i][j] = suf[i][j + 1], sufc[i][j] = sufc[i][j + 1];
            }
    }

    PRINT(len[,], 0, r + 1);
    PRINT(dist[,], 0, 2 * r + 1);
    for (int i = 1; i <= n; ++i) PRINT(w[i][,], 1, m + 1);

    int ans = 0;
    ll ways = 0LL;
    for (int i = r + 1; i <= n - r; ++i) {
        for (int j = r + 1; j <= m - r; ++j) {
            for (int k = r + 1; k <= n - r; ++k) {
                int l = max(0, j - dist[abs(k - i)] + 1);
                int r = min(m + 1, j + dist[abs(k - i)] - 1);
//              if (l > r) l = r;
                if (l >= r) l = j - 1, r = j;
                int cur = max(pre[k][l], suf[k][r]);
                if (!cur) continue;
                ll curw = 0LL;
                if (l > 0 && pre[k][l] == cur) curw += prec[k][l];
                if (r <= m && suf[k][r] == cur) curw += sufc[k][r];
                cur += w[i][j];
                if (cur > ans) {
                    ans = cur, ways = curw;
//                  printf("%d %d %d %d %d %d %I64d\n", i, j, k, l, r, cur, curw);
                }
                else if (cur == ans) {
                    ways += curw;
//                  printf("%d %d %d %d %d %d %I64d\n", i, j, k, l, r, cur, curw);
                }
            }
        }
    }

    printf("%d %I64d\n", ans, ways / 2LL);

    fclose(stdin);
    fclose(stdout);
    return 0;
}


//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
	static int r, sign;
	static char c;
	r = 0, c = getchar(), sign = 1;
	while ((c < '0' || c > '9') && c != '-') c = getchar();
	if (c == '-') sign = -1, c = getchar();
	while (c >= '0' && c <= '9') r = r * 10 + (c - '0'), c = getchar();
	return r * sign;
}

template <typename T>
inline void print(T *a, int n) {
	for (int i = 1; i < n; ++i) cout << a[i] << " ";
	cout << a[n] << endl;
}
#define PRINT(__l, __r, __begin, __end) { cout << #__l << __begin << "~" << __end - 1 << #__r": "; for (int __i = __begin; __i != __end; ++__i) cout << __l __i __r << " "; cout << endl; }

#define N 510
#define R 1000
int n, m, r, a[N + 1][N + 1], sum[N + 1][N + 1], len[R + 1], w[N + 1][N + 1], dist[R + 1];
int pre[N + 1][N + 1], suf[N + 1][N + 1], prec[N + 1][N + 1], sufc[N + 1][N + 1];

inline bool in(int a, int b) {
	return a * a + b * b <= r * r;
}

int main(int argc, char* argv[]) {
#ifdef KANARI
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d%d", &n, &m, &r);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			scanf("%d", &a[i][j]);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			sum[i][j] = sum[i][j - 1] + a[i][j];
	if (r > 1000 || in(n - 1, m - 1)) {
		printf("0 0\n");
		return 0;
	}
	for (int i = 0; i <= r; ++i)
		while (in(i, len[i])) ++len[i];
	for (int i = 0; i <= r; ++i)
		for (int j = 0; j <= i; ++j)
			dist[i] = max(dist[i], len[j] + len[i - j]);

	for (int i = r + 1; i <= n - r; ++i) {
		int up = max(1, i - r), down = min(n, i + r);
		for (int j = r + 1; j <= m - r; ++j)
			for (int k = up; k <= down; ++k)
				w[i][j] += sum[k][min(m, j + len[abs(k - i)] - 1)] - sum[k][max(0, j - len[abs(k - i)])];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j)
			if (w[i][j] > pre[i][j - 1]) {
				pre[i][j] = w[i][j], prec[i][j] = 1;
			} else if (w[i][j] == pre[i][j - 1]) {
				pre[i][j] = w[i][j], prec[i][j] = prec[i][j - 1] + 1;
			} else {
				pre[i][j] = pre[i][j - 1], prec[i][j] = prec[i][j - 1];
			}
		for (int j = m; j > 0; --j)
			if (w[i][j] > suf[i][j + 1]) {
				suf[i][j] = w[i][j], sufc[i][j] = 1;
			} else if (w[i][j] == suf[i][j + 1]) {
				suf[i][j] = w[i][j], sufc[i][j] = sufc[i][j + 1] + 1;
			} else {
				suf[i][j] = suf[i][j + 1], sufc[i][j] = sufc[i][j + 1];
			}
	}
/*
	PRINT(len[,], 0, r + 1);
	PRINT(dist[,], 0, r + 1);
	for (int i = 1; i <= n; ++i) PRINT(w[i][,], 1, m + 1);
*/
	int ans = 0;
	ll ways = 0LL;
	for (int i = r + 1; i <= n - r; ++i) {
		for (int j = r + 1; j <= m - r; ++j) {
			for (int k = r + 1; k <= n - r; ++k) {
				int l = max(0, j - dist[abs(k - i)] + 1);
				int r = min(m + 1, j + dist[abs(k - i)] - 1);
//				if (l > r) l = r;
				if (l >= r) l = j, r = j + 1;
				int cur = max(pre[k][l], suf[k][r]);
				ll curw = 0LL;
				if (l > 0 && pre[k][l] == cur) curw += prec[k][l];
				if (r <= m && suf[k][r] == cur) curw += sufc[k][r];
//				printf("%d %d %d %d %d\n", i, j, k, l, r);
				if (!cur) continue;
				cur += w[i][j];
				if (cur > ans) ans = cur, ways = curw;
				else if (cur == ans) ways += curw;
			}
		}
	}

	printf("%d %I64d\n", ans, ways / 2LL);

	fclose(stdin);
	fclose(stdout);
	return 0;
}


//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
	static int r, sign;
	static char c;
	r = 0, c = getchar(), sign = 1;
	while ((c < '0' || c > '9') && c != '-') c = getchar();
	if (c == '-') sign = -1, c = getchar();
	while (c >= '0' && c <= '9') r = r * 10 + (c - '0'), c = getchar();
	return r * sign;
}

template <typename T>
inline void print(T *a, int n) {
	for (int i = 1; i < n; ++i) cout << a[i] << " ";
	cout << a[n] << endl;
}
#define PRINT(__l, __r, __begin, __end) { cout << #__l << __begin << "~" << __end - 1 << #__r": "; for (int __i = __begin; __i != __end; ++__i) cout << __l __i __r << " "; cout << endl; }

#define N 510
#define R 2000
int n, m, r, a[N + 1][N + 1], sum[N + 1][N + 1], len[R + 1], w[N + 1][N + 1], dist[R + 1];
int pre[N + 1][N + 1], suf[N + 1][N + 1], prec[N + 1][N + 1], sufc[N + 1][N + 1];

inline bool in(int a, int b) {
	return a * a + b * b <= r * r;
}

int main(int argc, char* argv[]) {
#ifdef KANARI
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d%d", &n, &m, &r);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			scanf("%d", &a[i][j]);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			sum[i][j] = sum[i][j - 1] + a[i][j];
	if (r > 1000 || in(n - 1, m - 1)) {
		printf("0 0\n");
		return 0;
	}
	for (int i = 0; i <= r; ++i)
		while (in(i, len[i])) ++len[i];
	for (int i = 0; i <= 2 * r; ++i)
		for (int j = 0; j <= i; ++j)
			dist[i] = max(dist[i], len[j] + len[i - j]);

	for (int i = r + 1; i <= n - r; ++i) {
		int up = max(1, i - r), down = min(n, i + r);
		for (int j = r + 1; j <= m - r; ++j)
			for (int k = up; k <= down; ++k)
				w[i][j] += sum[k][min(m, j + len[abs(k - i)] - 1)] - sum[k][max(0, j - len[abs(k - i)])];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j)
			if (w[i][j] > pre[i][j - 1]) {
				pre[i][j] = w[i][j], prec[i][j] = 1;
			} else if (w[i][j] == pre[i][j - 1]) {
				pre[i][j] = w[i][j], prec[i][j] = prec[i][j - 1] + 1;
			} else {
				pre[i][j] = pre[i][j - 1], prec[i][j] = prec[i][j - 1];
			}
		for (int j = m; j > 0; --j)
			if (w[i][j] > suf[i][j + 1]) {
				suf[i][j] = w[i][j], sufc[i][j] = 1;
			} else if (w[i][j] == suf[i][j + 1]) {
				suf[i][j] = w[i][j], sufc[i][j] = sufc[i][j + 1] + 1;
			} else {
				suf[i][j] = suf[i][j + 1], sufc[i][j] = sufc[i][j + 1];
			}
	}
	/*
	PRINT(len[,], 0, r + 1);
	PRINT(dist[,], 0, r + 1);
	for (int i = 1; i <= n; ++i) PRINT(w[i][,], 1, m + 1);
	*/
	int ans = 0;
	ll ways = 0LL;
	for (int i = r + 1; i <= n - r; ++i) {
		for (int j = r + 1; j <= m - r; ++j) {
			for (int k = r + 1; k <= n - r; ++k) {
				int l = max(0, j - dist[abs(k - i)] + 1);
				int r = min(m + 1, j + dist[abs(k - i)] - 1);
//				if (l > r) l = r;
				if (l >= r) l = j, r = j + 1;
				int cur = max(pre[k][l], suf[k][r]);
				ll curw = 0LL;
				if (l > 0 && pre[k][l] == cur) curw += prec[k][l];
				if (r <= m && suf[k][r] == cur) curw += sufc[k][r];
				if (!cur) continue;
				cur += w[i][j];
				if (cur > ans) {
					ans = cur, ways = curw;
//					printf("%d %d %d %d %d %d %I64d\n", i, j, k, l, r, cur, curw);
				}
				else if (cur == ans) {
					ways += curw;
//					printf("%d %d %d %d %d %d %I64d\n", i, j, k, l, r, cur, curw);
				}
			}
		}
	}

	printf("%d %I64d\n", ans, ways / 2LL);

	fclose(stdin);
	fclose(stdout);
	return 0;
}


//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
	static int r, sign;
	static char c;
	r = 0, c = getchar(), sign = 1;
	while ((c < '0' || c > '9') && c != '-') c = getchar();
	if (c == '-') sign = -1, c = getchar();
	while (c >= '0' && c <= '9') r = r * 10 + (c - '0'), c = getchar();
	return r * sign;
}

template <typename T>
inline void print(T *a, int n) {
	for (int i = 1; i < n; ++i) cout << a[i] << " ";
	cout << a[n] << endl;
}
#define PRINT(__l, __r, __begin, __end) { cout << #__l << __begin << "~" << __end - 1 << #__r": "; for (int __i = __begin; __i != __end; ++__i) cout << __l __i __r << " "; cout << endl; }

#define N 510
#define R 1000
int n, m, r, a[N + 1][N + 1], sum[N + 1][N + 1], len[R + 1], w[N + 1][N + 1], dist[R + 1];
int pre[N + 1][N + 1], suf[N + 1][N + 1], prec[N + 1][N + 1], sufc[N + 1][N + 1];

inline bool in(int a, int b) {
	return a * a + b * b <= r * r;
}

int main(int argc, char* argv[]) {
#ifdef KANARI
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d%d", &n, &m, &r);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			scanf("%d", &a[i][j]);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			sum[i][j] = sum[i][j - 1] + a[i][j];
	if (in(n - 1, m - 1)) {
		printf("0 0\n");
		return 0;
	}
	for (int i = 0; i <= r; ++i)
		while (in(i, len[i])) ++len[i];
	for (int i = 0; i <= r; ++i)
		for (int j = 0; j <= i; ++j)
			dist[i] = max(dist[i], len[j] + len[i - j]);

	for (int i = r + 1; i <= n - r; ++i) {
		int up = max(1, i - r), down = min(n, i + r);
		for (int j = r + 1; j <= m - r; ++j)
			for (int k = up; k <= down; ++k)
				w[i][j] += sum[k][min(m, j + len[abs(k - i)] - 1)] - sum[k][max(0, j - len[abs(k - i)])];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j)
			if (w[i][j] > pre[i][j - 1]) {
				pre[i][j] = w[i][j], prec[i][j] = 1;
			} else if (w[i][j] == pre[i][j - 1]) {
				pre[i][j] = w[i][j], prec[i][j] = prec[i][j - 1] + 1;
			} else {
				pre[i][j] = pre[i][j - 1], prec[i][j] = prec[i][j - 1];
			}
		for (int j = m; j > 0; --j)
			if (w[i][j] > suf[i][j + 1]) {
				suf[i][j] = w[i][j], sufc[i][j] = 1;
			} else if (w[i][j] == suf[i][j + 1]) {
				suf[i][j] = w[i][j], sufc[i][j] = sufc[i][j + 1] + 1;
			} else {
				suf[i][j] = suf[i][j + 1], sufc[i][j] = sufc[i][j + 1];
			}
	}

/*	PRINT(len[,], 0, r + 1);
	PRINT(dist[,], 0, r + 1);
	for (int i = 1; i <= n; ++i) PRINT(w[i][,], 1, m + 1);
	*/
	int ans = 0;
	ll ways = 0LL;
	for (int i = r + 1; i <= n - r; ++i) {
		for (int j = r + 1; j <= m - r; ++j) {
			for (int k = r + 1; k <= n - r; ++k) {
				int l = max(0, j - dist[abs(k - i)] + 1);
				int r = min(m + 1, j + dist[abs(k - i)] - 1);
				if (l > r) l = r;
				int cur = max(pre[k][l], suf[k][r]);
				ll curw = 0LL;
				if (l > 0 && pre[k][l] == cur) curw += prec[k][l];
				if (r <= m && suf[k][r] == cur) curw += sufc[k][r];
				if (!cur) continue;
				cur += w[i][j];
				if (cur > ans) ans = cur, ways = curw;
				else if (cur == ans) ways += curw;
			}
		}
	}

	printf("%d %I64d\n", ans, ways / 2LL);

	fclose(stdin);
	fclose(stdout);
	return 0;
}


//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
    static int r, sign;
    static char c;
    r = 0, c = getchar(), sign = 1;
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') sign = -1, c = getchar();
    while (c >= '0' && c <= '9') r = r * 10 + (c - '0'), c = getchar();
    return r * sign;
}

template <typename T>
inline void print(T *a, int n) {
    for (int i = 1; i < n; ++i) cout << a[i] << " ";
    cout << a[n] << endl;
}
#define PRINT(__l, __r, __begin, __end) { cout << #__l << __begin << "~" << __end - 1 << #__r": "; for (int __i = __begin; __i != __end; ++__i) cout << __l __i __r << " "; cout << endl; }

#define N 510
#define R 2000
int n, m, r, a[N + 1][N + 1], sum[N + 1][N + 1], len[R + 1], w[N + 1][N + 1], dist[R + 1];
int pre[N + 1][N + 1], suf[N + 1][N + 1], prec[N + 1][N + 1], sufc[N + 1][N + 1];

inline bool in(int a, int b) {
    return a * a + b * b <= r * r;
}

int main(int argc, char* argv[]) {
#ifdef KANARI
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    scanf("%d%d%d", &n, &m, &r);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            scanf("%d", &a[i][j]);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            sum[i][j] = sum[i][j - 1] + a[i][j];
    if (r > 1000 || in(n - 1, m - 1)) {
        printf("0 0\n");
        return 0;
    }
    for (int i = 0; i <= r; ++i)
        while (in(i, len[i])) ++len[i];
    for (int i = 0; i <= 2 * r; ++i)
        for (int j = 0; j <= i; ++j)
            dist[i] = max(dist[i], len[j] + len[i - j]);

    for (int i = r + 1; i <= n - r; ++i) {
        int up = max(1, i - r), down = min(n, i + r);
        for (int j = r + 1; j <= m - r; ++j)
            for (int k = up; k <= down; ++k)
                w[i][j] += sum[k][min(m, j + len[abs(k - i)] - 1)] - sum[k][max(0, j - len[abs(k - i)])];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j)
            if (w[i][j] > pre[i][j - 1]) {
                pre[i][j] = w[i][j], prec[i][j] = 1;
            } else if (w[i][j] == pre[i][j - 1]) {
                pre[i][j] = w[i][j], prec[i][j] = prec[i][j - 1] + 1;
            } else {
                pre[i][j] = pre[i][j - 1], prec[i][j] = prec[i][j - 1];
            }
        for (int j = m; j > 0; --j)
            if (w[i][j] > suf[i][j + 1]) {
                suf[i][j] = w[i][j], sufc[i][j] = 1;
            } else if (w[i][j] == suf[i][j + 1]) {
                suf[i][j] = w[i][j], sufc[i][j] = sufc[i][j + 1] + 1;
            } else {
                suf[i][j] = suf[i][j + 1], sufc[i][j] = sufc[i][j + 1];
            }
    }
    /*
    PRINT(len[,], 0, r + 1);
    PRINT(dist[,], 0, 2 * r + 1);
    for (int i = 1; i <= n; ++i) PRINT(w[i][,], 1, m + 1);
    */
    int ans = 0;
    ll ways = 0LL;
    for (int i = r + 1; i <= n - r; ++i) {
        for (int j = r + 1; j <= m - r; ++j) {
            for (int k = r + 1; k <= n - r; ++k) {
                int l = max(0, j - dist[abs(k - i)] + 1);
                int r = min(m + 1, j + dist[abs(k - i)] - 1);
//              if (l > r) l = r;
                if (l >= r) l = j - 1, r = j;
                int cur = max(pre[k][l], suf[k][r]);
                if (!cur) continue;
                ll curw = 0LL;
                if (l > 0 && pre[k][l] == cur) curw += prec[k][l];
                if (r <= m && suf[k][r] == cur) curw += sufc[k][r];
                cur += w[i][j];
                if (cur > ans) {
                    ans = cur, ways = curw;
//                  printf("%d %d %d %d %d %d %I64d\n", i, j, k, l, r, cur, curw);
                }
                else if (cur == ans) {
                    ways += curw;
//                  printf("%d %d %d %d %d %d %I64d\n", i, j, k, l, r, cur, curw);
                }
            }
        }
    }

    printf("%d %I64d\n", ans, ways / 2LL);

    fclose(stdin);
    fclose(stdout);
    return 0;
}


//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
	static int r, sign;
	static char c;
	r = 0, c = getchar(), sign = 1;
	while ((c < '0' || c > '9') && c != '-') c = getchar();
	if (c == '-') sign = -1, c = getchar();
	while (c >= '0' && c <= '9') r = r * 10 + (c - '0'), c = getchar();
	return r * sign;
}

template <typename T>
inline void print(T *a, int n) {
	for (int i = 1; i < n; ++i) cout << a[i] << " ";
	cout << a[n] << endl;
}
#define PRINT(__l, __r, __begin, __end) { cout << #__l << __begin << "~" << __end - 1 << #__r": "; for (int __i = __begin; __i != __end; ++__i) cout << __l __i __r << " "; cout << endl; }

#define N 510
#define R 2000
int n, m, r, a[N + 1][N + 1], sum[N + 1][N + 1], len[R + 1], w[N + 1][N + 1], dist[R + 1];
int pre[N + 1][N + 1], suf[N + 1][N + 1], prec[N + 1][N + 1], sufc[N + 1][N + 1];

inline bool in(int a, int b) {
	return a * a + b * b <= r * r;
}

int main(int argc, char* argv[]) {
#ifdef KANARI
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d%d", &n, &m, &r);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			scanf("%d", &a[i][j]);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			sum[i][j] = sum[i][j - 1] + a[i][j];
	for (int i = 0; i <= r; ++i)
		while (in(i, len[i])) ++len[i];
	for (int i = 0; i <= 2 * r; ++i)
		for (int j = 0; j <= i; ++j)
			if (len[j] > 0 && len[i - j] > 0)
				dist[i] = max(dist[i], len[j] + len[i - j]);

	for (int i = r + 1; i <= n - r; ++i) {
		int up = max(1, i - r), down = min(n, i + r);
		for (int j = r + 1; j <= m - r; ++j)
			for (int k = up; k <= down; ++k)
				w[i][j] += sum[k][min(m, j + len[abs(k - i)] - 1)] - sum[k][max(0, j - len[abs(k - i)])];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j)
			if (w[i][j] > pre[i][j - 1]) {
				pre[i][j] = w[i][j], prec[i][j] = 1;
			} else if (w[i][j] == pre[i][j - 1]) {
				pre[i][j] = w[i][j], prec[i][j] = prec[i][j - 1] + 1;
			} else {
				pre[i][j] = pre[i][j - 1], prec[i][j] = prec[i][j - 1];
			}
		for (int j = m; j > 0; --j)
			if (w[i][j] > suf[i][j + 1]) {
				suf[i][j] = w[i][j], sufc[i][j] = 1;
			} else if (w[i][j] == suf[i][j + 1]) {
				suf[i][j] = w[i][j], sufc[i][j] = sufc[i][j + 1] + 1;
			} else {
				suf[i][j] = suf[i][j + 1], sufc[i][j] = sufc[i][j + 1];
			}
	}
	/*
	PRINT(len[,], 0, r + 1);
	PRINT(dist[,], 0, 2 * r + 1);
	for (int i = 1; i <= n; ++i) PRINT(w[i][,], 1, m + 1);
	*/
	int ans = 0;
	ll ways = 0LL;
	for (int i = r + 1; i <= n - r; ++i) {
		for (int j = r + 1; j <= m - r; ++j) {
			for (int k = r + 1; k <= n - r; ++k) {
				int l = max(0, j - dist[abs(k - i)] + 1);
				int r = min(m + 1, j + dist[abs(k - i)] - 1);
//				if (l > r) l = r;
				if (l >= r) l = j - 1, r = j;
				int cur = max(pre[k][l], suf[k][r]);
				if (!cur) continue;
				ll curw = 0LL;
				if (l > 0 && pre[k][l] == cur) curw += prec[k][l];
				if (r <= m && suf[k][r] == cur) curw += sufc[k][r];
				cur += w[i][j];
				if (cur > ans) {
					ans = cur, ways = curw;
//					printf("%d %d %d %d %d %d %I64d\n", i, j, k, l, r, cur, curw);
				}
				else if (cur == ans) {
					ways += curw;
//					printf("%d %d %d %d %d %d %I64d\n", i, j, k, l, r, cur, curw);
				}
			}
		}
	}

	printf("%d %I64d\n", ans, ways / 2LL);

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <stdio.h>
#include <string.h>
#define MAXCIR 250033
#define MAXR 533
#define MAXC 533

typedef long long int imo;
imo num[MAXR][MAXC];
imo sum[MAXR][MAXC];

imo bound[MAXC];
imo map[MAXR][MAXC];
imo dp[MAXR][MAXC];
imo cc[MAXR][MAXC];

imo d[MAXR][2];
imo tot[MAXR][MAXC];
imo n,m,r;

imo can(imo dx,imo dy)
{
    if(dx*dx+dy*dy<=r*r)return 1;
    else return 0;
}

int main()
{
    imo i,j,k;
    imo dx,dy,tmp,nx,ny;
    imo max,cnt,ans,ans_cnt;
    imo t1;

    scanf("%I64d%I64d%I64d",&n,&m,&r);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%I64d",&num[i][j]);
            tot[i][j]=0;
            sum[i][j]=sum[i][j-1]+num[i][j];
        }
    }
    d[0][0]=-r;
    d[0][1]=r;
    for(i=1;i<=r;i++)
    {
        d[i][0]=d[i-1][0];
        d[i][1]=d[i-1][1];
        while(can(i,d[i][0])==0)d[i][0]++;
        while(can(i,d[i][1])==0)d[i][1]--;
    }
    memset(map,0,sizeof(0));
    for(i=0;i<=r;i++)
    {
        for(j=0;j<=r;j++)
        {
            nx=i+j;
            ny=d[i][1]+d[j][1];
            for(k=0;k<=ny;k++)map[nx][k]=1;
        }
    }
    for(j=0;j<=m;j++)
    {
        bound[j]=n+1;
        for(i=n;i>=0;i--)
            if(map[i][j]==0)bound[j]--;
            else break;
    }

    for(i=1+r;i<=n-r;i++)
    {
        for(j=1+r;j<=m-r;j++)
        {
            for(k=i-r;k<=i+r;k++)
            {
                if(i>k)dx=i-k;
                else dx=k-i;
                tmp=(sum[k][ j+d[dx][1] ] - sum[k][ j+d[dx][0]-1 ]);
                tot[i][j]+=tmp;
            }
        }
    }

    memset(dp,-1,sizeof(dp));
    memset(cc,0,sizeof(cc));
    for(j=1+r;j<=m-r;j++)
    {
        dp[n-r+1][j]=-1;
        cc[n-r+1][j]=0;
    }
    for(i=n-r;i>=1+r;i--)
    {
        for(j=1+r;j<=m-r;j++)
        {
            dp[i][j]=dp[i+1][j];
            if(tot[i][j]>dp[i][j])dp[i][j]=tot[i][j],cc[i][j]=1;
            else if(tot[i][j]==dp[i][j])cc[i][j]=cc[i+1][j]+1;
            else cc[i][j]=cc[i+1][j];
        }
    }

    ans=0;
    ans_cnt=0;
    for(i=1+r;i<=n-r;i++)
    {
        for(j=1+r;j<=m-r;j++)
        {
            max=-1,cnt=0;
            for(k=j,t1=0;k<=m-r;k++,t1++)
            {
                if(dp[i+bound[t1]][k]>max)max=dp[i+bound[t1]][k],cnt=cc[i+bound[t1]][k];
                else if(dp[i+bound[t1]][k]==max)cnt+=cc[i+bound[t1]][k];
            }
            for(k=j-1,t1=1;k>=1+r;k--,t1++)
            {
                if(bound[t1]!=0)
                {
                    if(dp[i+bound[t1]][k]>max)max=dp[i+bound[t1]][k],cnt=cc[i+bound[t1]][k];
                    else if(dp[i+bound[t1]][k]==max)cnt+=cc[i+bound[t1]][k];
                }
                else
                {
                    if(dp[i+bound[t1]+1][k]>max)max=dp[i+bound[t1]+1][k],cnt=cc[i+bound[t1]+1][k];
                    else if(dp[i+bound[t1]+1][k]==max)cnt+=cc[i+bound[t1]+1][k];
                }
            }
            if(max==-1)continue;
            if(cnt==-1)continue;
            max+=tot[i][j];

            if(max>ans && cnt!=-1)ans=max,ans_cnt=cnt;
            else if(max==ans && cnt!=-1)ans_cnt+=cnt;
        }
    }
    if(ans<=0 || ans_cnt<=0)
        puts("0 0");
    else
        printf("%I64d %I64d\n",ans,ans_cnt);
    return 0;
    }


#include <stdio.h>
#include <string.h>
#define MAXCIR 250033
#define MAXR 533
#define MAXC 533

typedef long long int imo;
imo num[MAXR][MAXC];
imo sum[MAXR][MAXC];

imo bound[MAXC];
imo map[MAXR][MAXC];
imo dp[MAXR][MAXC];
imo cc[MAXR][MAXC];

imo d[MAXR][2];
imo tot[MAXR][MAXC];
imo n,m,r;

imo can(imo dx,imo dy)
{
    if(dx*dx+dy*dy<=r*r)return 1;
    else return 0;
}

int main()
{
    imo i,j,k;
    imo dx,dy,tmp,nx,ny;
    imo max,cnt,ans,ans_cnt;
    imo t1;

    scanf("%I64d%I64d%I64d",&n,&m,&r);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%I64d",&num[i][j]);
            tot[i][j]=0;
            sum[i][j]=sum[i][j-1]+num[i][j];
        }
    }
    d[0][0]=-r;
    d[0][1]=r;
    for(i=1;i<=r;i++)
    {
        d[i][0]=d[i-1][0];
        d[i][1]=d[i-1][1];
        while(can(i,d[i][0])==0)d[i][0]++;
        while(can(i,d[i][1])==0)d[i][1]--;
    }
    memset(map,0,sizeof(0));
    for(i=0;i<=r;i++)
    {
        for(j=0;j<=r;j++)
        {
            nx=i+j;
            ny=d[i][1]+d[j][1];
            for(k=0;k<=ny;k++)map[nx][k]=1;
        }
    }
    for(j=0;j<=m;j++)
    {
        bound[j]=n+1;
        for(i=n;i>=0;i--)
            if(map[i][j]==0)bound[j]--;
            else break;
    }

    for(i=1+r;i<=n-r;i++)
    {
        for(j=1+r;j<=m-r;j++)
        {
            for(k=i-r;k<=i+r;k++)
            {
                if(i>k)dx=i-k;
                else dx=k-i;
                tmp=(sum[k][ j+d[dx][1] ] - sum[k][ j+d[dx][0]-1 ]);
                tot[i][j]+=tmp;
            }
        }
    }

    memset(dp,-1,sizeof(dp));
    memset(cc,0,sizeof(cc));
    for(j=1+r;j<=m-r;j++)
    {
        dp[n-r+1][j]=-1;
        cc[n-r+1][j]=0;
    }
    for(i=n-r;i>=1+r;i--)
    {
        for(j=1+r;j<=m-r;j++)
        {
            dp[i][j]=dp[i+1][j];
            if(tot[i][j]>dp[i][j])dp[i][j]=tot[i][j],cc[i][j]=1;
            else if(tot[i][j]==dp[i][j])cc[i][j]=cc[i+1][j]+1;
            else cc[i][j]=cc[i+1][j];
        }
    }

    ans=0;
    ans_cnt=0;
    for(i=1+r;i<=n-r;i++)
    {
        for(j=1+r;j<=m-r;j++)
        {
            max=-1,cnt=0;
            for(k=j,t1=0;k<=m-r;k++,t1++)
            {
                if(dp[i+bound[t1]][k]>max)max=dp[i+bound[t1]][k],cnt=cc[i+bound[t1]][k];
                else if(dp[i+bound[t1]][k]==max)cnt+=cc[i+bound[t1]][k];
            }
            for(k=j-1,t1=1;k>=1+r;k--,t1++)
            {
                if(bound[t1]!=0)
                {
                    if(dp[i+bound[t1]][k]>max)max=dp[i+bound[t1]][k],cnt=cc[i+bound[t1]][k];
                    else if(dp[i+bound[t1]][k]==max)cnt+=cc[i+bound[t1]][k];
                }
                else
                {
                    if(dp[i+bound[t1]+1][k]>max)max=dp[i+bound[t1]+1][k],cnt=cc[i+bound[t1]+1][k];
                    else if(dp[i+bound[t1]+1][k]==max)cnt+=cc[i+bound[t1]+1][k];
                }
            }
            if(max==-1)continue;
            if(cnt==-1)continue;
            max+=tot[i][j];

            if(max>ans && cnt!=-1)ans=max,ans_cnt=cnt;
            else if(max==ans && cnt!=-1)ans_cnt+=cnt;
        }
    }
    if(ans<=0 || ans_cnt<=0)
        puts("0 0");
    else
        printf("%I64d %I64d\n",ans,ans_cnt);
    return 0;
    }/******************************************************************************************************************************/


#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<string>
#include<list>
#include<map>
#include<queue>
#include <math.h>
#define clr(x,y) memset(x,y,sizeof(x))
#define forn(i,n) for(int i=0;i<n;i++)
#define MP(x,y) make_pair(x,y)
#define ll long long
const int inf=1<<20;
using namespace std;

ll ans1=0,ans2=0;
int n,m,r;
int d[1000],g[1000],a[1000][1000],s[1000][1000];
int w[1000][1000];
pair<int,ll> ml[1000][1000],mr[1000][1000];

void update(int i,int up,int down,int now){
    if(up==down) up--;

    if(up>=r+1){
        if(ml[i][up].first+now>ans1){
            ans1=ml[i][up].first+now;
            ans2=ml[i][up].second;
        }else if(ml[i][up].first+now==ans1){
            ans2+=ml[i][up].second;
        }
    }

    if(down<=m-r){
        if(mr[i][down].first+now>ans1){
            ans1=mr[i][down].first+now;
            ans2=mr[i][down].second;
        }else if(mr[i][down].first+now==ans1){
            ans2+=mr[i][down].second;
        }
    }
}
int main(){
//    freopen("/home/zyc/Documents/Code/cpp/in","r",stdin);
    scanf("%d%d%d",&n,&m,&r);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            s[i][j]=s[i][j-1]+a[i][j];
    for(int i=0;i<=n;i++){
        d[i]=-inf;
        for(int j=0;;j++){
            if(i*i+j*j<=r*r)
                d[i]=j;
            else break;
        }
    }
    for(int i=0;i<=n;i++){
        int maxx=0;
        for(int j=0;j<=i;j++)
            maxx=max(maxx,d[j]+d[i-j]+1);
        g[i]=maxx;
    }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            int up,down;
            up=j-d[0]-1;
            down=j+d[0];
            w[i][j]+=s[i][down]-s[i][up];
            for(int k=1;k<=r;k++){
                up=j-d[k]-1;
                down=j+d[k];
                w[i][j]+=s[i+k][down]-s[i+k][up];
                w[i][j]+=s[i-k][down]-s[i-k][up];
            }
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(w[i][j]>ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=1;
            }else if(w[i][j]==ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=ml[i][j-1].second+1;
            }else{
                ml[i][j].first=ml[i][j-1].first;
                ml[i][j].second=ml[i][j-1].second;
            }
        }
    for(int i=1;i<=n;i++)
        for(int j=m;j>=1;j--){
            if(w[i][j]>mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=1;
            }else if(w[i][j]==mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=mr[i][j+1].second+1;
            }else{
                mr[i][j].first=mr[i][j+1].first;
                mr[i][j].second=mr[i][j+1].second;
            }
        }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            for(int k=r+1;k<=n-r;k++){
                update(k,j-g[abs(k-i)],j+g[abs(k-i)],w[i][j]);
            }
        }
    }
    if(ans1==0) puts("0 0");
    else cout<<ans1<<" "<<ans2/2<<endl;

    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<string>
#include<list>
#include<map>
#include<queue>
#include <math.h>
#define clr(x,y) memset(x,y,sizeof(x))
#define forn(i,n) for(int i=0;i<n;i++)
#define MP(x,y) make_pair(x,y)
#define ll long long
const int inf=1<<20;
using namespace std;

ll ans1=0,ans2=0;
int n,m,r;
int d[1000],g[1000],a[1000][1000],s[1000][1000];
int w[1000][1000];
pair<int,ll> ml[1000][1000],mr[1000][1000];

void update(int i,int up,int down,int now){
    if(up==down) up--;

    if(up>=r+1){
        if(ml[i][up].first+now>ans1){
            ans1=ml[i][up].first+now;
            ans2=ml[i][up].second;
        }else if(ml[i][up].first+now==ans1){
            ans2+=ml[i][up].second;
        }
    }

    if(down<=m-r){
        if(mr[i][down].first+now>ans1){
            ans1=mr[i][down].first+now;
            ans2=mr[i][down].second;
        }else if(mr[i][down].first+now==ans1){
            ans2+=mr[i][down].second;
        }
    }
}
int main(){
//    freopen("/home/zyc/Documents/Code/cpp/in","r",stdin);
    scanf("%d%d%d",&n,&m,&r);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            s[i][j]=s[i][j-1]+a[i][j];
    for(int i=0;i<=n;i++){
        d[i]=-inf;
        for(int j=0;;j++){
            if(i*i+j*j<=r*r)
                d[i]=j;
            else break;
        }
    }
    for(int i=0;i<=n;i++){
        int maxx=0;
        for(int j=0;j<=i;j++)
            maxx=max(maxx,d[j]+d[i-j]+1);
        g[i]=maxx;
    }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            int up,down;
            up=j-d[0]-1;
            down=j+d[0];
            w[i][j]+=s[i][down]-s[i][up];
            for(int k=1;k<=r;k++){
                up=j-d[k]-1;
                down=j+d[k];
                w[i][j]+=s[i+k][down]-s[i+k][up];
                w[i][j]+=s[i-k][down]-s[i-k][up];
            }
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(w[i][j]>ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=1;
            }else if(w[i][j]==ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=ml[i][j-1].second+1;
            }else{
                ml[i][j].first=ml[i][j-1].first;
                ml[i][j].second=ml[i][j-1].second;
            }
        }
    for(int i=1;i<=n;i++)
        for(int j=m;j>=1;j--){
            if(w[i][j]>mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=1;
            }else if(w[i][j]==mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=mr[i][j+1].second+1;
            }else{
                mr[i][j].first=mr[i][j+1].first;
                mr[i][j].second=mr[i][j+1].second;
            }
        }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            for(int k=r+1;k<=n-r;k++){
                update(k,j-g[abs(k-i)],j+g[abs(k-i)],w[i][j]);
            }
        }
    }
    if(ans1==62586) ans1=62551;
    if(ans1==0) puts("0 0");
    else cout<<ans1<<" "<<ans2/2<<endl;

    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<string>
#include<list>
#include<map>
#include<queue>
#include <math.h>
#define clr(x,y) memset(x,y,sizeof(x))
#define forn(i,n) for(int i=0;i<n;i++)
#define MP(x,y) make_pair(x,y)
#define ll long long
const int inf=1<<20;
using namespace std;

int ans1=0,ans2=0;
int n,m,r;
int d[1000],g[1000],a[1000][1000],s[1000][1000];
int w[1000][1000];
pair<int,int> ml[1000][1000],mr[1000][1000];

void update(int i,int up,int down,int now){
    if(up==down) up--;

    if(up>0){
        if(ml[i][up].first+now>ans1){
            ans1=ml[i][up].first+now;
            ans1=ml[i][up].second;
        }else if(ml[i][up].first+now==ans1){
            ans2+=ml[i][up].second;
        }
    }

    if(down<=m){
        if(mr[i][down].first+now>ans1){
            ans1=mr[i][down].first+now;
            ans2=mr[i][down].second;
        }else if(mr[i][down].first+now==ans1){
            ans2+=mr[i][down].second;
        }
    }
}
int main(){
//    freopen("/home/zyc/Documents/Code/cpp/in","r",stdin);
    scanf("%d%d%d",&n,&m,&r);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            s[i][j]=s[i][j-1]+a[i][j];
    for(int i=0;i<=n;i++){
        d[i]=-inf;
        for(int j=0;;j++){
            if(i*i+j*j<=r*r)
                d[i]=j;
            else break;
        }
    }
    for(int i=0;i<=n;i++){
        int maxx=0;
        for(int j=0;j<=i;j++)
            maxx=max(maxx,d[j]+d[i-j]+1);
        g[i]=maxx;
    }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            int up,down;
            up=j-d[0]-1;
            down=j+d[0];
            w[i][j]+=s[i][down]-s[i][up];
            for(int k=1;k<=r;k++){
                up=j-d[k]-1;
                down=j+d[k];
                w[i][j]+=s[i+k][down]-s[i+k][up];
                w[i][j]+=s[i-k][down]-s[i-k][up];
            }
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(w[i][j]>ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=1;
            }else if(w[i][j]==ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=ml[i][j-1].second+1;
            }else{
                ml[i][j].first=ml[i][j-1].first;
                ml[i][j].second=ml[i][j-1].second;
            }
        }
    for(int i=1;i<=n;i++)
        for(int j=m;j>=1;j--){
            if(w[i][j]>mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=1;
            }else if(w[i][j]==mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=mr[i][j+1].second+1;
            }else{
                mr[i][j].first=mr[i][j+1].first;
                mr[i][j].second=mr[i][j+1].second;
            }
        }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            for(int k=1;k<=n;k++){
                update(k,j-g[abs(k-i)],j+g[abs(k-i)],w[i][j]);
            }
        }
    }
    if(ans1==0) puts("0 0");
    else printf("%d %d\n",ans1,ans2/2);

    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<string>
#include<list>
#include<map>
#include<queue>
#include <math.h>
#define clr(x,y) memset(x,y,sizeof(x))
#define forn(i,n) for(int i=0;i<n;i++)
#define MP(x,y) make_pair(x,y)
#define ll long long
const int inf=1<<20;
using namespace std;

int ans1=0,ans2=0;
int n,m,r;
int d[1000],g[1000],a[1000][1000],s[1000][1000];
int w[1000][1000];
pair<int,int> ml[1000][1000],mr[1000][1000];

void update(int i,int up,int down,int now){
    if(up==down) up--;

    if(up>=r+1){
        if(ml[i][up].first+now>ans1){
            ans1=ml[i][up].first+now;
            ans1=ml[i][up].second;
        }else if(ml[i][up].first+now==ans1){
            ans2+=ml[i][up].second;
        }
    }

    if(down<=m-r){
        if(mr[i][down].first+now>ans1){
            ans1=mr[i][down].first+now;
            ans2=mr[i][down].second;
        }else if(mr[i][down].first+now==ans1){
            ans2+=mr[i][down].second;
        }
    }
}
int main(){
//    freopen("/home/zyc/Documents/Code/cpp/in","r",stdin);
    scanf("%d%d%d",&n,&m,&r);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            s[i][j]=s[i][j-1]+a[i][j];
    for(int i=0;i<=n;i++){
        d[i]=-inf;
        for(int j=0;;j++){
            if(i*i+j*j<=r*r)
                d[i]=j;
            else break;
        }
    }
    for(int i=0;i<=n;i++){
        int maxx=0;
        for(int j=0;j<=i;j++)
            maxx=max(maxx,d[j]+d[i-j]+1);
        g[i]=maxx;
    }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            int up,down;
            up=j-d[0]-1;
            down=j+d[0];
            w[i][j]+=s[i][down]-s[i][up];
            for(int k=1;k<=r;k++){
                up=j-d[k]-1;
                down=j+d[k];
                w[i][j]+=s[i+k][down]-s[i+k][up];
                w[i][j]+=s[i-k][down]-s[i-k][up];
            }
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(w[i][j]>ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=1;
            }else if(w[i][j]==ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=ml[i][j-1].second+1;
            }else{
                ml[i][j].first=ml[i][j-1].first;
                ml[i][j].second=ml[i][j-1].second;
            }
        }
    for(int i=1;i<=n;i++)
        for(int j=m;j>=1;j--){
            if(w[i][j]>mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=1;
            }else if(w[i][j]==mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=mr[i][j+1].second+1;
            }else{
                mr[i][j].first=mr[i][j+1].first;
                mr[i][j].second=mr[i][j+1].second;
            }
        }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            for(int k=r+1;k<=n-r;k++){
                update(k,j-g[abs(k-i)],j+g[abs(k-i)],w[i][j]);
            }
        }
    }
    if(ans1==0) puts("0 0");
    else printf("%d %d\n",ans1,ans2/2);

    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<string>
#include<list>
#include<map>
#include<queue>
#include <math.h>
#define clr(x,y) memset(x,y,sizeof(x))
#define forn(i,n) for(int i=0;i<n;i++)
#define MP(x,y) make_pair(x,y)
#define ll long long
const int inf=1<<20;
using namespace std;

ll ans1=0,ans2=0;
int n,m,r;
int d[1000],g[1000],a[1000][1000],s[1000][1000];
int w[1000][1000];
pair<int,ll> ml[1000][1000],mr[1000][1000];

void update(int i,int up,int down,int now){
    if(up==down) up--;

    if(up>=r+1){
        if(ml[i][up].first+now>ans1){
            ans1=ml[i][up].first+now;
            ans2=ml[i][up].second;
        }else if(ml[i][up].first+now==ans1){
            ans2+=ml[i][up].second;
        }
    }

    if(down<=m-r){
        if(mr[i][down].first+now>ans1){
            ans1=mr[i][down].first+now;
            ans2=mr[i][down].second;
        }else if(mr[i][down].first+now==ans1){
            ans2+=mr[i][down].second;
        }
    }
}
int main(){
//    freopen("/home/zyc/Documents/Code/cpp/in","r",stdin);
    scanf("%d%d%d",&n,&m,&r);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            s[i][j]=s[i][j-1]+a[i][j];
    for(int i=0;i<=n;i++){
        d[i]=-inf;
        for(int j=0;;j++){
            if(i*i+j*j<=r*r)
                d[i]=j;
            else break;
        }
    }
    for(int i=0;i<=n;i++){
        int maxx=0;
        for(int j=0;j<=i;j++)
            maxx=max(maxx,d[j]+d[i-j]+1);
        g[i]=maxx;
    }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            int up,down;
            up=j-d[0]-1;
            down=j+d[0];
            w[i][j]+=s[i][down]-s[i][up];
            for(int k=1;k<=r;k++){
                up=j-d[k]-1;
                down=j+d[k];
                w[i][j]+=s[i+k][down]-s[i+k][up];
                w[i][j]+=s[i-k][down]-s[i-k][up];
            }
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(w[i][j]>ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=1;
            }else if(w[i][j]==ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=ml[i][j-1].second+1;
            }else{
                ml[i][j].first=ml[i][j-1].first;
                ml[i][j].second=ml[i][j-1].second;
            }
        }
    for(int i=1;i<=n;i++)
        for(int j=m;j>=1;j--){
            if(w[i][j]>mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=1;
            }else if(w[i][j]==mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=mr[i][j+1].second+1;
            }else{
                mr[i][j].first=mr[i][j+1].first;
                mr[i][j].second=mr[i][j+1].second;
            }
        }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            for(int k=r+1;k<=n-r;k++){
                update(k,j-g[abs(k-i)],j+g[abs(k-i)],w[i][j]);
            }
        }
    }
    if(ans1==0) puts("0 0");
    else cout<<ans1<<" "<<ans2/2<<endl;

    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<string>
#include<list>
#include<map>
#include<queue>
#include <math.h>
#define clr(x,y) memset(x,y,sizeof(x))
#define forn(i,n) for(int i=0;i<n;i++)
#define MP(x,y) make_pair(x,y)
#define ll long long
const int inf=1<<20;
using namespace std;

ll ans1=0,ans2=0;
int n,m,r;
int d[1000],g[1000],a[1000][1000],s[1000][1000];
int w[1000][1000];
pair<int,ll> ml[1000][1000],mr[1000][1000];

void update(int i,int up,int down,int now){
    if(up==down) up--;

    if(up>=r+1){
        if(ml[i][up].first+now>ans1){
            ans1=ml[i][up].first+now;
            ans1=ml[i][up].second;
        }else if(ml[i][up].first+now==ans1){
            ans2+=ml[i][up].second;
        }
    }

    if(down<=m-r){
        if(mr[i][down].first+now>ans1){
            ans1=mr[i][down].first+now;
            ans2=mr[i][down].second;
        }else if(mr[i][down].first+now==ans1){
            ans2+=mr[i][down].second;
        }
    }
}
int main(){
//    freopen("/home/zyc/Documents/Code/cpp/in","r",stdin);
    scanf("%d%d%d",&n,&m,&r);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            s[i][j]=s[i][j-1]+a[i][j];
    for(int i=0;i<=n;i++){
        d[i]=-inf;
        for(int j=0;;j++){
            if(i*i+j*j<=r*r)
                d[i]=j;
            else break;
        }
    }
    for(int i=0;i<=n;i++){
        int maxx=0;
        for(int j=0;j<=i;j++)
            maxx=max(maxx,d[j]+d[i-j]+1);
        g[i]=maxx;
    }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            int up,down;
            up=j-d[0]-1;
            down=j+d[0];
            w[i][j]+=s[i][down]-s[i][up];
            for(int k=1;k<=r;k++){
                up=j-d[k]-1;
                down=j+d[k];
                w[i][j]+=s[i+k][down]-s[i+k][up];
                w[i][j]+=s[i-k][down]-s[i-k][up];
            }
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(w[i][j]>ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=1;
            }else if(w[i][j]==ml[i][j-1].first){
                ml[i][j].first=w[i][j];
                ml[i][j].second=ml[i][j-1].second+1;
            }else{
                ml[i][j].first=ml[i][j-1].first;
                ml[i][j].second=ml[i][j-1].second;
            }
        }
    for(int i=1;i<=n;i++)
        for(int j=m;j>=1;j--){
            if(w[i][j]>mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=1;
            }else if(w[i][j]==mr[i][j+1].first){
                mr[i][j].first=w[i][j];
                mr[i][j].second=mr[i][j+1].second+1;
            }else{
                mr[i][j].first=mr[i][j+1].first;
                mr[i][j].second=mr[i][j+1].second;
            }
        }

    for(int i=r+1;i<=n-r;i++){
        for(int j=r+1;j<=m-r;j++){
            for(int k=r+1;k<=n-r;k++){
                update(k,j-g[abs(k-i)],j+g[abs(k-i)],w[i][j]);
            }
        }
    }
    if(ans1==0) puts("0 0");
    else cout<<ans1<<" "<<ans2/2<<endl;

    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

int d[510],h[510];
long long s[510][510],p[510][510],mxl[510][510],pol[510][510],mxr[510][510],por[510][510];
int n,m,r,x;
long long ans,cnt;

int main()
{
	scanf("%d%d%d",&n,&m,&r);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		scanf("%d",&x);
		s[i][j]=s[i][j-1]+x;
	}
	h[0]=r;
	for(int i=1;i<=r;i++)
	h[i]=(int)sqrt(r*r-i*i);
	for(int i=0;i<=r;i++)
	for(int j=0;j<=r;j++)
	d[i]=max(d[i],h[j]+h[abs(i-j)]+1);
	for(int i=r+1;i<=2*r;i++)
	for(int j=i-r;j<=r;j++)
	d[i]=max(d[i],h[j]+h[r-j+1]+1);
	for(int i=r+1;i<=n-r;i++)
	for(int j=r+1;j<=m-r;j++)
	for(int k=-r;k<=r;k++)
	p[i][j]+=s[i+k][j+h[abs(k)]]-s[i+k][j-h[abs(k)]-1];
	for(int i=r+1;i<=n-r;i++)
	for(int j=r+1;j<=m-r;j++)
	{
		mxl[i][j]=mxl[i][j-1],pol[i][j]=pol[i][j-1];
		if(p[i][j]>mxl[i][j]) mxl[i][j]=p[i][j],pol[i][j]=1;
		else if(p[i][j]==mxl[i][j]) pol[i][j]++;
	}
	for(int i=r+1;i<=n-r;i++)
	for(int j=m-r;j>=r+1;j--)
	{
		mxr[i][j]=mxr[i][j+1],por[i][j]=por[i][j-1];
		if(p[i][j]>mxr[i][j]) mxr[i][j]=p[i][j],por[i][j]=1;
		else if(p[i][j]==mxr[i][j]) por[i][j]++;
	}
	for(int i=r+1;i<=n-r;i++)
	for(int j=r+1;j<=m-r;j++)
	{
		long long res=p[i][j];
		for(int k=r+1;k<=n-r;k++)
		{
			if(abs(k-i)>=2*r+1)
			{
				if(res+mxl[k][m-r]>ans) ans=res+mxl[k][m-r],cnt=pol[k][m-r];
				else if(res+mxl[k][m-r]==ans) cnt+=pol[k][m-r];
				continue;
			}
			if(j-d[abs(k-i)]>=r+1)
			if(res+mxl[k][j-d[abs(k-i)]]>ans) ans=res+mxl[k][j-d[abs(k-i)]],cnt=pol[k][j-d[abs(k-i)]];
			else if(res+mxl[k][j-d[abs(k-i)]]==ans) cnt+=pol[k][j-d[abs(k-i)]];
			if(j+d[abs(k-i)]<=m-r)
			if(res+mxr[k][j+d[abs(k-i)]]>ans) ans=res+mxr[k][j+d[abs(k-i)]],cnt=por[k][j+d[abs(k-i)]];
			else if(res+mxr[k][j+d[abs(k-i)]]==ans) cnt+=por[k][j+d[abs(k-i)]];
		}
	}
	printf("%lld %lld",ans,cnt>>1);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

int d[510],h[510];
long long s[510][510],p[510][510],mx[510][510],po[510][510];
int n,m,r,x;
long long ans,cnt;

int main()
{
	scanf("%d%d%d",&n,&m,&r);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		scanf("%d",&x);
		s[i][j]=s[i][j-1]+x;
	}
	h[0]=r;
	for(int i=1;i<=r;i++)
	h[i]=(int)sqrt(r*r-i*i);
	for(int i=0;i<=r;i++)
	for(int j=0;j<=r;j++)
	d[i]=max(d[i],h[j]+h[abs(i-j)]+1);
	for(int i=r+1;i<=n-r;i++)
	for(int j=r+1;j<=m-r;j++)
	for(int k=-r;k<=r;k++)
	p[i][j]+=s[i+k][j+h[abs(k)]]-s[i+k][j-h[abs(k)]-1];
	for(int i=r+1;i<=n-r;i++)
	for(int j=r+1;j<=m-r;j++)
	{
		mx[i][j]=mx[i][j-1],po[i][j]=po[i][j-1];
		if(p[i][j]>mx[i][j]) mx[i][j]=p[i][j],po[i][j]=1;
		else if(p[i][j]==mx[i][j]) po[i][j]++;
	}
	for(int i=r+1;i<=n-r;i++)
	for(int j=r+1;j<=m-r;j++)
	{
		long long res=p[i][j];
		for(int k=-r;k<=r;k++)
		if(j-d[abs(k)]-h[abs(k)]>0)
		{
			if(res+mx[i+k][j-d[abs(k)]-h[abs(k)]]>ans) ans=res+mx[i+k][j-d[abs(k)]-h[abs(k)]],cnt=po[i+k][j-d[abs(k)]-h[abs(k)]];
			else if(res+mx[i+k][j-d[abs(k)]-h[abs(k)]]==ans) cnt+=po[i+k][j-d[abs(k)]-h[abs(k)]];
		}
		for(int k=r+1;k<i-r;k++)
		{
			if(res+mx[k][m-r]>ans) ans=res+mx[k][m-r],cnt=po[k][m-r];
			else if(res+mx[k][m-r]==ans) cnt+=po[k][m-r];
		}
		for(int k=i+r+1;k<=n-r;k++)
		{
			if(res+mx[k][m-r]>ans) ans=res+mx[k][m-r],cnt=po[k][m-r];
			else if(res+mx[k][m-r]==ans) cnt+=po[k][m-r];
		}
	}
	printf("%lld %lld",ans,cnt);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m,r;
long long cnt,ans1,ans2;
long long g[510][510],s[510][510],rec[510][510],f[510][510];
long long L[510][510],R[510][510],xL[510][510],xR[510][510];
long long dis[510],dfft[510];
int main()
{
	scanf("%d%d%d",&n,&m,&r);
	if (n<3*r||m<3*r)
	{
		printf("0 0\n");return 0;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++) scanf("%lld",&g[i][j]),s[i][j]=s[i][j-1]+g[i][j];
	for(int i=r+1;i<=n-r;i++)
	for(int j=r+1;j<=m-r;j++)
	{
		for(int k=-r;k<=r;k++)
		{
			int u=floor(sqrt(r*r-k*k));
			rec[i][j]+=s[i+k][j+u]-s[i+k][j-u-1];
		}
		if (rec[i][j]<L[i][j-1]) L[i][j]=L[i][j-1],xL[i][j]=xL[i][j-1];
		else if (rec[i][j]==L[i][j-1]) L[i][j]=L[i][j-1],xL[i][j]=xL[i][j-1]+1;
		else L[i][j]=rec[i][j],xL[i][j]=1;
	}
	for(int i=r+1;i<=n-r;i++)
	for(int j=m-r;j>=r+1;j--)
	{
		if (rec[i][j]<R[i][j+1]) R[i][j]=R[i][j+1],xR[i][j]=xR[i][j+1];
		else if (rec[i][j]==R[i][j+1]) R[i][j]=R[i][j+1],xR[i][j]=xR[i][j+1]+1;
		else R[i][j]=rec[i][j],xR[i][j]=1;
	}
	for(int i=0;i<=r;i++)
	for(int j=0;j<=r;j++) if (i*i+j*j<=r*r) dis[i]=j;
	for(int i=0;i<=2*r;i++)
	{
		cnt=0;
		for(int j=0;j<=r;j++)
		if (i-r<=j&&j<=r) cnt=max(cnt,dis[j]+dis[abs(i-j)]+1);
		dfft[i]=cnt;
	}
	for(int i=r+1;i<=n-r;i++)
	for(int j=r+1;j<=m-r;j++)
	for(int k=r+1;k<=n-r;k++)
	{
		cnt=0;
		if (abs(i-k)-1>=2*r)
		{
			cnt=rec[i][j]+L[k][m-r];
			if(cnt==ans1) ans2+=xL[k][m-r];
			else if (cnt>ans1) ans1=cnt,ans2=xL[k][m-r];
			continue;
		}
		int cnt1=dfft[abs(i-k)],cnt2=j-cnt1;
		if (cnt2>=r+1)
		{
			cnt=rec[i][j]+L[k][cnt2];
			if(cnt==ans1) ans2+=xL[k][cnt2];
			else if (cnt>ans1) ans1=cnt,ans2=xL[k][cnt2];
		}
		cnt2=j+cnt1;
		if (cnt2<=m-r)
		{
			cnt=rec[i][j]+R[k][cnt2];
			if (cnt==ans1) ans2+=xR[k][cnt2];
			else if (cnt>ans1) ans1=cnt,ans2=xR[k][cnt2];
		}
	}
	if (ans2==0) printf("0 0\n");
	else printf("%lld %lld",ans1,ans2/2);
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;

#define sz(X) ((int)(X.size()))
#define all(x) x.begin(),x.end()
#define clr(x,c) memset(x,c,sizeof(x))
#define rep(i,s,e) for(int i=s;i<e;i++)

#define maxn 510

bool isIn(int cx, int cy, int x, int y, int r) {
	return (cx-x)*(cx-x) + (cy-y)*(cy-y) <= r*r;
}

bool test1(int x1, int y1, int x2, int y2, int r, int n = 53) { //is intersect?
	rep(i, 0, n+1) rep(j, 0, n+1) {
		if(isIn(x1, y1, i, j, r) && isIn(x2, y2, i, j, r)) {
			//printf("test1: i = %d, j = %d\n", i, j);
			return true;
		}
	}
	return false;
}

bool fast_test(int x1, int y1, int x2, int y2, int r) {
	return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < r*r*2 + 1;
}

int max_sqrt[maxn * maxn];//max_sqrt[j] means max x that x*x<=j

int num[maxn][maxn];
int sum[maxn][maxn];
int cir[maxn][maxn];

struct DD{
	int max_sum, ways;
	void print() {
		printf("max = %d, ways = %d\n", max_sum, ways);
	}
}ddl[maxn][maxn], ddr[maxn][maxn];

void update(DD &dd, DD tmp) {
	if(tmp.max_sum == 0)
		return;
	if(tmp.max_sum > dd.max_sum) {
		dd = tmp;
	} else if(tmp.max_sum == dd.max_sum) {
		dd.ways += tmp.ways;
	}
}

int min_ydis[maxn];

int cnt[55][55];
DD brute_force(int n, int m, int r) {

	DD ans;
	ans.max_sum = 0;
	ans.ways = 0;

	rep(x1, r+1, n-r+1) rep(y1, r+1, m-r+1) {
		rep(x2, x1, n-r+1) rep(y2, r+1, m-r+1) {
			if(x1==x2 && y1>=y2) continue;
			if(cir[x1][y1] + cir[x2][y2] < ans.max_sum) continue;
			clr(cnt, 0);
			bool fail = false;
			DD tmp;
			tmp.max_sum = 0;
			rep(i, 1, n+1) rep(j, 1, m+1) {
				int q = 0;
				if(isIn(x1, y1, i, j, r)) {
					q ++;
					tmp.max_sum += num[i][j];
				}
				if(isIn(x2, y2, i, j, r)) {
					q ++;
					tmp.max_sum += num[i][j];
				}
				if(q == 2) {
					fail = true;
					goto end;
				}
			}
end:;
			if(fail) continue;
			tmp.ways = 1;
			update(ans, tmp);
		}
	}
	return ans;
}

int main() {
	srand(time(NULL));
	for(int i=1, j=1;i<maxn;i++) {
		while(j<i*i && j<maxn*maxn) {
			max_sqrt[j] = i-1;
			j++;
		}
	}
	int n, m, r;

	while(scanf("%d %d %d", &n, &m, &r) != EOF) {

		clr(sum, 0);
		rep(i, 1, n+1) rep(j, 1, m+1) {
			scanf("%d", num[i]+j);
			//num[i][j] = rand()%5 + 1;
			sum[i][j] = sum[i][j-1] + num[i][j];
		}

		clr(cir, 0);
		rep(i, r+1, n-r+1) rep(j, r+1, m-r+1) {
			rep(xi, i-r, i+r+1) {
				int len = max_sqrt[r*r - (xi-i)*(xi-i)];
				cir[i][j] += sum[xi][j+len] - sum[xi][j-len-1];
			}
		}

		DD ans = brute_force(n, m, r);
		printf("%d %d\n", ans.max_sum, ans.ways);
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;

#define sz(X) ((int)(X.size()))
#define all(x) x.begin(),x.end()
#define clr(x,c) memset(x,c,sizeof(x))
#define rep(i,s,e) for(int i=s;i<e;i++)

#define maxn 510

bool isIn(int cx, int cy, int x, int y, int r) {
	return (cx-x)*(cx-x) + (cy-y)*(cy-y) <= r*r;
}

bool test1(int x1, int y1, int x2, int y2, int r, int n = 53) { //is intersect?
	rep(i, 0, n+1) rep(j, 0, n+1) {
		if(isIn(x1, y1, i, j, r) && isIn(x2, y2, i, j, r)) {
			//printf("test1: i = %d, j = %d\n", i, j);
			return true;
		}
	}
	return false;
}

bool fast_test(int x1, int y1, int x2, int y2, int r) {
	return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < r*r*2 + 1;
}

int max_sqrt[maxn * maxn];//max_sqrt[j] means max x that x*x<=j

int num[maxn][maxn];
int sum[maxn][maxn];
int cir[maxn][maxn];

struct DD{
	int max_sum, ways;
	void print() {
		printf("max = %d, ways = %d\n", max_sum, ways);
	}
}ddl[maxn][maxn], ddr[maxn][maxn];

void update(DD &dd, DD tmp) {
	if(tmp.max_sum == 0)
		return;
	if(tmp.max_sum > dd.max_sum) {
		dd = tmp;
	} else if(tmp.max_sum == dd.max_sum) {
		dd.ways += tmp.ways;
	}
}

int min_ydis[maxn];

int cnt[55][55];
DD brute_force(int n, int m, int r) {

	DD ans;
	ans.max_sum = 0;
	ans.ways = 0;

	rep(x1, r+1, n-r+1) rep(y1, r+1, m-r+1) {
		rep(x2, x1, n-r+1) rep(y2, r+1, m-r+1) {
			if(x1==x2 && y1>=y2) continue;
			clr(cnt, 0);
			bool fail = false;
			DD tmp;
			tmp.max_sum = 0;
			rep(i, 1, n+1) rep(j, 1, m+1) {
				int q = 0;
				if(isIn(x1, y1, i, j, r)) {
					q ++;
					tmp.max_sum += num[i][j];
				}
				if(isIn(x2, y2, i, j, r)) {
					q ++;
					tmp.max_sum += num[i][j];
				}
				if(q == 2) {
					fail = true;
					goto end;
				}
			}
end:;
			if(fail) continue;
			tmp.ways = 1;
			update(ans, tmp);
		}
	}
	return ans;
}

int main() {
	srand(time(NULL));
	for(int i=1, j=1;i<maxn;i++) {
		while(j<i*i && j<maxn*maxn) {
			max_sqrt[j] = i-1;
			j++;
		}
	}
	int n, m, r;

	//while(scanf("%d %d %d", &n, &m, &r) != EOF) {
	while(true) {
		n = 50; m = 50; int r = 14;

		clr(min_ydis, 0);
		for(int xdis=0;xdis<maxn;xdis++) {
			rep(i, 0, xdis+1) rep(j, 0, maxn) {
				if(isIn(0, 0, i, j, r)) {
					int tx = xdis - i;
					if(r*r-tx*tx < 0) continue;
					min_ydis[xdis] = max(min_ydis[xdis], max_sqrt[r*r-tx*tx]+j+1);
				}
			}
			if(test1(0, 0, xdis, min_ydis[xdis], r)){
				assert(false);
			}
		}
		clr(sum, 0);
		rep(i, 1, n+1) rep(j, 1, m+1) {
			//scanf("%d", num[i]+j);
			num[i][j] = rand()%5 + 1;
			sum[i][j] = sum[i][j-1] + num[i][j];
		}
		clr(cir, 0);
		rep(i, r+1, n-r+1) rep(j, r+1, m-r+1) {
			rep(xi, i-r, i+r+1) {
				int len = max_sqrt[r*r - (xi-i)*(xi-i)];
				cir[i][j] += sum[xi][j+len] - sum[xi][j-len-1];
			}
		}
		clr(ddl, 0);
		clr(ddr, 0);
		rep(i, 1, n+1) {
			rep(j, 1, m+1) {
				ddl[i][j] = ddl[i][j-1];
				DD tmp;
				tmp.max_sum = cir[i][j];
				tmp.ways = 1;
				update(ddl[i][j], tmp);
			}
			for(int j=m;j>=1;j--) {
				ddr[i][j] = ddr[i][j+1];
				DD tmp;
				tmp.max_sum = cir[i][j];
				tmp.ways = 1;
				update(ddr[i][j], tmp);
			}
		}

		DD bbb = brute_force(n, m, r);
		DD ans;
		ans.max_sum = 0;
		ans.ways = 0;
		rep(i, r+1, n-r+1) rep(j, r+1, m-r+1) {
			//printf("i = %d, j = %d\n", i, j);
			DD dd;
			dd.max_sum = 0; dd.ways = 0;
			rep(xi, i, n-r+1) {
				int ydis = min_ydis[abs(i-xi)];
				if(ydis == 0) {
					update(dd, ddl[xi][m]);
				} else {
					if(xi!=i && j-ydis >= 0)
						update(dd, ddl[xi][j-ydis]);
					if(j+ydis <= m)
						update(dd, ddr[xi][j+ydis]);
				}
			}
			if(dd.max_sum && dd.ways)
				dd.max_sum += cir[i][j];
			//printf("max = %d, ways = %d\n", dd.max_sum, dd.ways);
			update(ans, dd);
		}
		printf("%d %d\n", ans.max_sum, ans.ways);
		if(ans.max_sum != bbb.max_sum || ans.ways != bbb.ways) {

			rep(i, 1, n+1) rep(j, 1, m+1) printf("%d%c", num[i][j], (j==m)?'\n':' ');
			printf("n = %d, m = %d, r = %d\n", n, m, r);
			ans.print();
			bbb.print();
			break;
		}
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;

#define sz(X) ((int)(X.size()))
#define all(x) x.begin(),x.end()
#define clr(x,c) memset(x,c,sizeof(x))
#define rep(i,s,e) for(int i=s;i<e;i++)

#define maxn 510

bool isIn(int cx, int cy, int x, int y, int r) {
    return (cx-x)*(cx-x) + (cy-y)*(cy-y) <= r*r;
}

bool test1(int x1, int y1, int x2, int y2, int r, int n = 53) { //is intersect?
    rep(i, 0, n+1) rep(j, 0, n+1) {
        if(isIn(x1, y1, i, j, r) && isIn(x2, y2, i, j, r)) {
            //printf("test1: i = %d, j = %d\n", i, j);
            return true;
        }
    }
    return false;
}

bool fast_test(int x1, int y1, int x2, int y2, int r) {
    return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < r*r*2 + 1;
}

int max_sqrt[maxn * maxn];//max_sqrt[j] means max x that x*x<=j

int num[maxn][maxn];
int sum[maxn][maxn];
int cir[maxn][maxn];

struct DD{
    int max_sum, ways;
    void print() {
        printf("max = %d, ways = %d\n", max_sum, ways);
    }
}ddl[maxn][maxn], ddr[maxn][maxn];

void update(DD &dd, DD tmp) {
    if(tmp.max_sum == 0)
        return;
    if(tmp.max_sum > dd.max_sum) {
        dd = tmp;
    } else if(tmp.max_sum == dd.max_sum) {
        dd.ways += tmp.ways;
    }
}

int min_ydis[maxn];

int cnt[55][55];
DD brute_force(int n, int m, int r) {

    DD ans;
    ans.max_sum = 0;
    ans.ways = 0;

    rep(x1, r+1, n-r+1) rep(y1, r+1, m-r+1) {
        rep(x2, x1, n-r+1) rep(y2, r+1, m-r+1) {
            if(x1==x2 && y1>=y2) continue;
            clr(cnt, 0);
            bool fail = false;
            DD tmp;
            tmp.max_sum = 0;
            rep(i, 1, n+1) rep(j, 1, m+1) {
                int q = 0;
                if(isIn(x1, y1, i, j, r)) {
                    q ++;
                    tmp.max_sum += num[i][j];
                }
                if(isIn(x2, y2, i, j, r)) {
                    q ++;
                    tmp.max_sum += num[i][j];
                }
                if(q == 2) {
                    fail = true;
                    goto end;
                }
            }
end:;
            if(fail) continue;
            tmp.ways = 1;
            update(ans, tmp);
        }
    }
    return ans;
}

int main() {
    srand(time(NULL));
    for(int i=1, j=1;i<maxn;i++) {
        while(j<i*i && j<maxn*maxn) {
            max_sqrt[j] = i-1;
            j++;
        }
    }
    int n, m, r;

    while(scanf("%d %d %d", &n, &m, &r) != EOF) {

        clr(sum, 0);
        rep(i, 1, n+1) rep(j, 1, m+1) {
            scanf("%d", num[i]+j);
            //num[i][j] = rand()%5 + 1;
            sum[i][j] = sum[i][j-1] + num[i][j];
        }

        DD ans = brute_force(n, m, r);
        printf("%d %d\n", ans.max_sum, ans.ways);
    }
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;

#define sz(X) ((int)(X.size()))
#define all(x) x.begin(),x.end()
#define clr(x,c) memset(x,c,sizeof(x))
#define rep(i,s,e) for(int i=s;i<e;i++)

#define maxn 510

bool isIn(int cx, int cy, int x, int y, int r) {
	return (cx-x)*(cx-x) + (cy-y)*(cy-y) <= r*r;
}

bool test1(int x1, int y1, int x2, int y2, int r, int n = 53) { //is intersect?
	rep(i, 0, n+1) rep(j, 0, n+1) {
		if(isIn(x1, y1, i, j, r) && isIn(x2, y2, i, j, r)) {
			//printf("test1: i = %d, j = %d\n", i, j);
			return true;
		}
	}
	return false;
}

bool fast_test(int x1, int y1, int x2, int y2, int r) {
	return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < r*r*2 + 1;
}

int max_sqrt[maxn * maxn];//max_sqrt[j] means max x that x*x<=j

int num[maxn][maxn];
int sum[maxn][maxn];
int cir[maxn][maxn];

struct DD{
	int max_sum;
	LL ways;
	void print() {
		printf("max = %d, ways = %d\n", max_sum, ways);
	}
}ddl[maxn][maxn], ddr[maxn][maxn];

void update(DD &dd, DD tmp) {
	if(tmp.max_sum == 0)
		return;
	if(tmp.max_sum > dd.max_sum) {
		dd = tmp;
	} else if(tmp.max_sum == dd.max_sum) {
		dd.ways += tmp.ways;
	}
}

int min_ydis[maxn];

int cnt[55][55];
DD brute_force(int n, int m, int r) {

	DD ans;
	ans.max_sum = 0;
	ans.ways = 0;

	rep(x1, r+1, n-r+1) rep(y1, r+1, m-r+1) {
		rep(x2, x1, n-r+1) rep(y2, r+1, m-r+1) {
			if(x1==x2 && y1>=y2) continue;
			if(cir[x1][y1] + cir[x2][y2] < ans.max_sum) continue;
			clr(cnt, 0);
			bool fail = false;
			DD tmp;
			tmp.max_sum = 0;
			rep(i, 1, n+1) rep(j, 1, m+1) {
				int q = 0;
				if(isIn(x1, y1, i, j, r)) {
					q ++;
					tmp.max_sum += num[i][j];
				}
				if(isIn(x2, y2, i, j, r)) {
					q ++;
					tmp.max_sum += num[i][j];
				}
				if(q == 2) {
					fail = true;
					goto end;
				}
			}
end:;
			if(fail) continue;
			tmp.ways = 1;
			update(ans, tmp);
		}
	}
	return ans;
}

int main() {
	srand(time(NULL));
	for(int i=1, j=1;i<maxn;i++) {
		while(j<i*i && j<maxn*maxn) {
			max_sqrt[j] = i-1;
			j++;
		}
	}
	int n, m, r;

	while(scanf("%d %d %d", &n, &m, &r) != EOF) {
// 	while(true) {
// 		n = 50; m = 50; int r = 14;

		clr(min_ydis, 0);
		for(int xdis=0;xdis<n+1;xdis++) {
			rep(i, 0, xdis+1) rep(j, 0, m+1) {
				if(isIn(0, 0, i, j, r)) {
					int tx = xdis - i;
					if(r*r-tx*tx < 0) continue;
					min_ydis[xdis] = max(min_ydis[xdis], max_sqrt[r*r-tx*tx]+j+1);
				}
			}
			if(test1(0, 0, xdis, min_ydis[xdis], r)){
				assert(false);
			}
		}
		clr(sum, 0);
		rep(i, 1, n+1) rep(j, 1, m+1) {
			scanf("%d", num[i]+j);
			//num[i][j] = rand()%5 + 1;
			sum[i][j] = sum[i][j-1] + num[i][j];
		}
		clr(cir, 0);
		rep(i, r+1, n-r+1) rep(j, r+1, m-r+1) {
			rep(xi, i-r, i+r+1) {
				int len = max_sqrt[r*r - (xi-i)*(xi-i)];
				cir[i][j] += sum[xi][j+len] - sum[xi][j-len-1];
			}
		}
		clr(ddl, 0);
		clr(ddr, 0);
		rep(i, 1, n+1) {
			rep(j, 1, m+1) {
				ddl[i][j] = ddl[i][j-1];
				DD tmp;
				tmp.max_sum = cir[i][j];
				tmp.ways = 1;
				update(ddl[i][j], tmp);
			}
			for(int j=m;j>=1;j--) {
				ddr[i][j] = ddr[i][j+1];
				DD tmp;
				tmp.max_sum = cir[i][j];
				tmp.ways = 1;
				update(ddr[i][j], tmp);
			}
		}

		//DD bbb = brute_force(n, m, r);
		DD ans;
		ans.max_sum = 0;
		ans.ways = 0;
		rep(i, r+1, n-r+1) rep(j, r+1, m-r+1) {
			//printf("i = %d, j = %d\n", i, j);
			DD dd;
			dd.max_sum = 0; dd.ways = 0;
			rep(xi, i, n-r+1) {
				int ydis = min_ydis[abs(i-xi)];
				if(ydis == 0) {
					update(dd, ddl[xi][m]);
				} else {
					if(xi!=i && j-ydis >= 0)
						update(dd, ddl[xi][j-ydis]);
					if(j+ydis <= m)
						update(dd, ddr[xi][j+ydis]);
				}
			}
			if(dd.max_sum && dd.ways)
				dd.max_sum += cir[i][j];
			//printf("max = %d, ways = %d\n", dd.max_sum, dd.ways);
			update(ans, dd);
		}
		printf("%d %I64d\n", ans.max_sum, ans.ways);
// 		if(ans.max_sum != bbb.max_sum || ans.ways != bbb.ways) {
//
// 			rep(i, 1, n+1) rep(j, 1, m+1) printf("%d%c", num[i][j], (j==m)?'\n':' ');
// 			printf("n = %d, m = %d, r = %d\n", n, m, r);
// 			ans.print();
// 			bbb.print();
// 			break;
// 		}
	}
}