func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace IO {   char buf_[1 << 21], *p1_ = buf_, *p2_ = buf_;   inline long long in() {     long long s = 0, f = 1;     char x = (p1_ == p2_ && (p2_ = (p1_ = buf_) + fread(buf_, 1, 1 << 21, stdin),                              p1_ == p2_)                   ? EOF                   : *p1_++);     for (; x <  0  || x >  9 ;          x = (p1_ == p2_ && (p2_ = (p1_ = buf_) + fread(buf_, 1, 1 << 21, stdin),                             p1_ == p2_)                   ? EOF                   : *p1_++))       if (x ==  - ) f = -1;     for (; x >=  0  && x <=  9 ;          x = (p1_ == p2_ && (p2_ = (p1_ = buf_) + fread(buf_, 1, 1 << 21, stdin),                             p1_ == p2_)                   ? EOF                   : *p1_++))       s = (s * 10) + (x & 15);     return f == 1 ? s : -s;   }   char _buf[1 << 21];   long long _pos = -1;   inline void flush() { fwrite(_buf, 1, _pos + 1, stdout), _pos = -1; }   inline void pc(char x) {     if (_pos == (1 << 21) - 1) flush();     _buf[++_pos] = x;   }   inline void out(long long x) {     char k[30];     long long pos = 0;     if (!x) return pc( 0 );     if (x < 0) pc( - ), x = -x;     while (x) k[++pos] = (x % 10) | 48, x /= 10;     for (long long i = pos; i; i--) pc(k[i]);   }   inline void out(string x) {     long long len = x.size();     for (long long i = 0; i < len; i++) pc(x[i]);   }   }  // namespace IO   using namespace IO;   const long long A = 5e5 + 5;   long long n;   long long head[A], tot_road;   struct Road {     long long nex, to;   } road[2 * A];   inline void edge(long long x, long long y) {     road[++tot_road] = (Road){head[x], y}, head[x] = tot_road;   }   long long sz[A], res[A];   inline void prepare(long long fa, long long x) {     sz[x] = 1;     for (long long y = head[x]; y; y = road[y].nex) {       long long z = road[y].to;       if (z == fa) continue;       prepare(x, z);       sz[x] += sz[z];     }     return;   }   inline void DFS(long long fa, long long x) {     for (long long y = head[x]; y; y = road[y].nex) {       long long z = road[y].to;       if (z == fa) continue;       res[z] = res[x] + (sz[x] - sz[z]) * sz[z];       DFS(x, z);     }     return;   }   signed main() {     n = in();     for (long long i = 1; i < n; i++) {       long long u = in(), v = in();       edge(u, v), edge(v, u);     }     prepare(0, 1);     res[1] = n * (n - 1) / 2;     DFS(0, 1);     long long rt = 0;     for (long long i = 1; i <= n; i++)       if (res[i] > res[rt]) rt = i;     prepare(0, rt);     res[rt] = n * (n - 1) / 2;     DFS(0, rt);     long long ans = 0;     for (long long i = 1; i <= n; i++) ans = max(ans, res[i]);     out(ans), pc(  n );     flush();     return 0;   }   