#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector> Graph(N); for(int i=0; i> u >> v; u--; v--; Graph.at(u).push_back(v); Graph.at(v).push_back(u); } auto dp = [&](auto dp,int pos,int back) -> vector { long long ret = 0; long long one = 0,two = 0,three = 0; for(auto to : Graph.at(pos)){ if(to == back) continue; auto ko = dp(dp,to,pos); long long x = ko.at(0),y = ko.at(1),z = ko.at(2); ret += x+y+z+ko.back(); ret += one*x+two*x+one*y; one++; two += x; three += y; } return {one,two,three,ret}; }; vector result = dp(dp,0,-1); long long answer = 0; for(auto r : result) answer += r; cout << answer << endl; }