func_code_string: #include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   int S, n, tot;   int fa[2100], a[2100][2100], p[2100 * 2100 / 2];   vector<int> E[2100];   void EXT() {     printf( NO n );     exit(0);   }   int get(int x) {     if (fa[x] == x) return x;     return fa[x] = get(fa[x]);   }   void dfs(int x, int ff, int dep) {     if (a[S][x] != dep) EXT();     for (int i : E[x])       if (i != ff) dfs(i, x, dep + a[x][i]);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j) scanf( %d , &a[i][j]);     for (int i = 1; i <= n; ++i) {       if (a[i][i] != 0) EXT();       for (int j = i + 1; j <= n; ++j) {         if (a[i][j] != a[j][i] || a[i][j] == 0) EXT();         p[++tot] = (i << 20) + j;       }     }     sort(p + 1, p + tot + 1, [](int x, int y) {       return a[x >> 20][x & 0xffff] < a[y >> 20][y & 0xffff];     });     for (int i = 1; i <= n; ++i) fa[i] = i;     for (int i = 1; i <= tot; ++i) {       int x = p[i] >> 20, y = p[i] & 0xffff;       if (get(x) == get(y)) continue;       E[x].push_back(y);       E[y].push_back(x);       fa[get(x)] = get(y);     }     for (int i = 1; i <= n; ++i) {       S = i;       dfs(i, 0, 0);     }     printf( YES n );   }   