Problem:
A rooted binary tree is a tree with a root node in which every node has at most two children.  Your task is to write a program which reads a rooted binary tree _T_ and prints the following information for each node _u_ of _T_ :    * node ID of _u_   * parent of _u_   * sibling of _u_   * the number of children of _u_   * depth of _u_   * height of _u_   * node type (root, internal node or leaf)  If two nodes have the same parent, they are **siblings**. Here, if _u_ and _v_ have the same parent, we say _u_ is a sibling of _v_ (vice versa).  The height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.  Here, the given binary tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-
N = int(input())
tree = [{"parent":-1, "left":-1, "right":-1, "sibling": -1} for _ in range(N)]
parent = set([n for n in range(N)])

for _ in range(N):
    inp = [int(n) for n in input().split()]
    tree[inp[0]]["left"] = inp[1]
    tree[inp[0]]["right"] = inp[2]
    tree[inp[0]]["degree"] = sum([inp[1] != -1, inp[2] != -1])
    
    tree[inp[1]]["parent"] = inp[0]
    tree[inp[2]]["parent"] = inp[0]
    tree[inp[1]]["sibling"] = inp[2]
    tree[inp[2]]["sibling"] = inp[1]
    
    parent = parent.difference(inp[1:])
    
def set_depth(n, depth):
    tree[n]["depth"] = depth
    
    if tree[n]["left"] != -1:
        set_depth(tree[n]["left"], depth+1)
    if tree[n]["right"] != -1:
        set_depth(tree[n]["right"], depth+1)

root = parent.pop()
set_depth(root, 0)

def set_height(n):
    h1 = 0
    h2 = 0
    if tree[n]["right"] != -1:
        h1 = set_height(tree[n]["right"]) + 1
    if tree[n]["left"] != -1:
        h2 = set_height(tree[n]["left"]) + 1
    
    tree[n]["height"] = max(h1, h2)
    return max(h1, h2)

set_height(root)

for n in range(N):
    if tree[n]["parent"] == -1:
        tree[n]["type"] = "root"
    elif tree[n]["degree"] == 0:
        tree[n]["type"] = "leaf"
    else:
        tree[n]["type"] = "internal node"
    
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}"\
          .format(n, tree[n]["parent"], tree[n]["sibling"],
                  tree[n]["degree"], tree[n]["depth"], tree[n]["height"], tree[n]["type"]))

Fixed, accepted submission:
# -*- coding: utf-8 -*-
N = int(input())
tree = [{"parent":-1, "left":-1, "right":-1, "sibling": -1} for _ in range(N)]
parent = set([n for n in range(N)])

for _ in range(N):
    inp = [int(n) for n in input().split()]
    tree[inp[0]]["left"] = inp[1]
    tree[inp[0]]["right"] = inp[2]
    tree[inp[0]]["degree"] = sum([inp[1] != -1, inp[2] != -1])
    
    if inp[1] != -1:
        tree[inp[1]]["parent"] = inp[0]
        tree[inp[1]]["sibling"] = inp[2]
    if inp[2] != -1:
        tree[inp[2]]["parent"] = inp[0]    
        tree[inp[2]]["sibling"] = inp[1]
    
    parent = parent.difference(inp[1:])
    
def set_depth(n, depth):
    tree[n]["depth"] = depth
    
    if tree[n]["left"] != -1:
        set_depth(tree[n]["left"], depth+1)
    if tree[n]["right"] != -1:
        set_depth(tree[n]["right"], depth+1)

root = parent.pop()
set_depth(root, 0)

def set_height(n):
    h1 = 0
    h2 = 0
    if tree[n]["right"] != -1:
        h1 = set_height(tree[n]["right"]) + 1
    if tree[n]["left"] != -1:
        h2 = set_height(tree[n]["left"]) + 1
    
    tree[n]["height"] = max(h1, h2)
    return max(h1, h2)

set_height(root)

for n in range(N):
    if tree[n]["parent"] == -1:
        tree[n]["type"] = "root"
    elif tree[n]["degree"] == 0:
        tree[n]["type"] = "leaf"
    else:
        tree[n]["type"] = "internal node"
    
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}"\
          .format(n, tree[n]["parent"], tree[n]["sibling"],
                  tree[n]["degree"], tree[n]["depth"], tree[n]["height"], tree[n]["type"]))