Language: C++

#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const int limit = 110;
vector<int> tree[limit];
int par[limit];

void dfs(int v,int p,int d,vector<int> &dist){
	par[v] = p,dist[v] = d;
	for(auto &v2:tree[v]){
		if(v2 == p) continue;
		dfs(v2,v,d+1,dist);
	}
}


string tree_bucket(int v,int p){
	vector<string> cand;

	for(auto &v2:tree[v]){
		if(v2 == p) continue;
		cand.push_back(tree_bucket(v2,v));
	} 

	sort(begin(cand),end(cand));
	string ret = "(";
	for(auto &it:cand) ret += it;
		return ret + ")"; 
}

int total = 1,max_depth = 1;
int adj[10010][limit];
bool leaf[10010];
int depth[limit];

void tree_travasal(int v,int d,string& bucket,int& idx){
	if(bucket[idx] == '(') idx++;
	chmax(max_depth,d);

	rep(i,limit){
		if(bucket[idx] == ')') break;

		if(adj[v][i] == -1){
			adj[v][i] = total;
			leaf[v] = false;
			leaf[total] = true;
			rep(j,limit) adj[total][j] = -1;
			total++;
		}

		error(d,i+1);
		chmax(depth[d],i+1);
		tree_travasal(adj[v][i],d+1,bucket,idx);
	}
	
	idx++;
	return;
}

ll calc(int a,int b){
	error("subcalc",a,b);
	total = 1, max_depth = 1;
	rep(i,limit) adj[0][i] = -1,depth[i] = 0;
	leaf[0] = true;

	for(auto &c:{a,b}){
		const int ab = a^b;
		string ret = tree_bucket(c,c^ab);
		error(ret);
		int idx = 0;
		tree_travasal(0,0,ret,idx);
	}

	error(depth[0],depth[1]);
	ll ret = depth[0];
	rep(i,1,max_depth) ret *= depth[i];
	error(2 * ret);
	return 2 * ret;
}

int main(void){
	int n;
	cin >> n;

	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		a--,b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	
	vector<int> udist(n,0),vdist(n,0);
	dfs(0,-1,1,udist);
	const int v = max_element(begin(udist),end(udist)) - begin(udist);

	dfs(v,-1,1,vdist);
	const int u = max_element(begin(vdist),end(vdist)) - begin(vdist);

	const int dist = vdist[u];
	const int ans1 = (dist + 1) / 2;
	ll ans2 = (1LL << 63) - 1;


	deque<int> roots;
	{
		int cur = u;
		while(cur != -1){
			roots.push_back(cur);
			cur = par[cur];
		}

		while(roots.size() > 2){
			roots.pop_front();
			roots.pop_back();
		}
	}

	rep(i,10010){
		rep(j,limit) adj[i][j] = -1;
		leaf[i] = false;
	}
	leaf[0] = true;


	if(roots.size() == 1){

		const int root = roots[0];
		error("single",root);

		for(auto &c:tree[root]){
			string ret = tree_bucket(c,root);
			int idx = 0;
			tree_travasal(0,0,ret,idx);
		}

		ll ret = depth[0];
		rep(i,1,max_depth) ret *= depth[i];
		chmin<ll>(ans2, 1LL * tree[root].size() * ret);
		
		for(auto &c:tree[root]) chmin<ll>(ans2,calc(c,root));
	}else{
		error("plural");
		const int a = roots[0], b = roots[1];
		chmin<ll>(ans2,calc(a,b));
	}

	cout << ans1 << " " << ans2 << endl;

	return 0;
}

Compiler output:
a.cc: In function 'void tree_travasal(int, int, std::string&, int&)':
a.cc:80:17: error: 'error' was not declared in this scope; did you mean 'perror'?
   80 |                 error(d,i+1);
      |                 ^~~~~
      |                 perror
a.cc: In function 'll calc(int, int)':
a.cc:90:9: error: 'error' was not declared in this scope; did you mean 'perror'?
   90 |         error("subcalc",a,b);
      |         ^~~~~
      |         perror
a.cc: In function 'int main()':
a.cc:132:31: warning: integer overflow in expression of type 'long long int' results in '9223372036854775807' [-Woverflow]
  132 |         ll ans2 = (1LL << 63) - 1;
      |                   ~~~~~~~~~~~~^~~
a.cc:159:17: error: 'error' was not declared in this scope; did you mean 'perror'?
  159 |                 error("single",root);
      |                 ^~~~~
      |                 perror
a.cc:173:17: error: 'error' was not declared in this scope; did you mean 'perror'?
  173 |                 error("plural");
      |                 ^~~~~
      |                 perror