#include using namespace std; using ll = long long; template using Pa = pair; template using vec = vector; template using vvec = vector>; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vvec A(N,vec(N,0)); for(int i=0;i> A[i][j]; A[i][j]--; } auto f = [&](int x,int y,bool isx){ if(isx) return x+y; else return x-y; }; vvec X(N); vvec Y(N); for(int i=0;i& A){ vvec L(N,vec(N+1,0)),R = L; for(int i=0;i=0;j--){ R[i][j] = R[i][j+1]+A[i][j]; } } int inf = 2e9; vvec ans(N,vec(N,inf)); for(int i=0;i