Buggy python submission (verdict: Runtime Error):
class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int,input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q,K = list(map(int,input().split()))
K = K - 1
dmax = 10**14 + 1
depth = [dmax for _ in range(N+1)]
depth[K] = 0

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to == p:
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for _ in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])


Fixed submission:
n = input()
s = []
for i in range(len(n)):
    s.append(n[len(n)-1-i])
if(n=="".join(s)):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):

class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int,input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q,K = list(map(int,input().split()))
K = K - 1

depth = [-1] * N

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to == p:
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for _ in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])


Fixed submission:
n = input()
s = []
for i in range(len(n)):
    s.append(n[len(n)-1-i])
if(n=="".join(s)):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q, K = list(map(int, input().split()))
K = K - 1

depth = [0]*N
def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to==p :
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for q in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])


Fixed submission:
n = input()
s = []
for i in range(len(n)):
    s.append(n[len(n)-1-i])
if(n=="".join(s)):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N = int(input())

class edge:
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))

Q, K = list(map(int, input().split()))
K = K - 1
depth = [0]*N

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to==p :
            continue
        DFS(e.to, v, d + e.cost)

DFS(K,-1,0)

for q in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])


Fixed submission:
n = input()
s = []
for i in range(len(n)):
    s.append(n[len(n)-1-i])
if(n=="".join(s)):
    print("Yes")
else:
    print("No")