human
I found an interesting problem on https://leetcode.com/problems/sum-of-distances-in-tree/:
An undirected, connected tree with N nodes labelled 0...N-1 and N-1 edges are given.
The ith edge connects nodes edges[i][0] and edges[i][1] together.
Return a list ans, where ans[i] is the sum of the distances between node i and all other nodes.
Example 1:
Input: N = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]
Output: [8,12,6,10,10,10]
Explanation: 
Here is a diagram of the given tree:
  0
 / \
1   2
   /|\
  3 4 5
We can see that dist(0,1) + dist(0,2) + dist(0,3) + dist(0,4) + dist(0,5)
equals 1 + 1 + 2 + 2 + 2 = 8.  Hence, answer[0] = 8, and so on.

Note: 1 <= N <= 10000

I tried it in Python, but could not do it. Can you solve it?

=====
What is a the Python program you requested?
assistant
#Here is the Python program you requested.

class Solution:
    def sumOfDistancesInTree(self, N: int, edges: List[List[int]]) -> List[int]:
        edges_dict = dict()
        for i in range(N):
            edges_dict[i] = []
        for edge in edges:
            edges_dict[edge[0]].append(edge[1])
            edges_dict[edge[1]].append(edge[0])
        dp_dict = dict()
        def dp(node, src):
            if (node, src) in dp_dict:
                return dp_dict[(node, src)]
            tgt_num = 1
            tgt_sum = 0
            for tgt in edges_dict[node]:
                if tgt == src:
                    continue
                else:
                    temp = dp(tgt, node)
                    tgt_num += temp[0]
                    tgt_sum += temp[0] + temp[1]
            dp_dict[(node, src)] = (tgt_num, tgt_sum)
            return dp_dict[(node, src)]
        results = [0]*N
        for node in range(N):
            for tgt in edges_dict[node]:
                results[node] += sum(dp(tgt, node))
        # print(dp_dict)
        return results