int a[n][m],b[n][m+1]={0},c[n+1][m+1]={0};
for(int i=0;i<n;i++)for(int j=0;j<m;j++){
cin>>a[i][j];
b[i][j+1]=b[i][j]+a[i][j];
c[i+1][j+1]=c[i][j+1]+b[i][j+1];
}