Buggy python submission (verdict: Time Limit Exceeded):
#067-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n=I()
prev=[-1 for i in range(n)]
nl=[[] for i in range(n)]
q=[0]
vis=[False for i in range(n)]

for i in range(n-1):
    a,b=IL()
    nl[a-1].append(b-1)
    nl[b-1].append(a-1)

while len(q)!=0:
    s=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            prev[v]=s
            q.append(v)

path=[n-1]
while True:
    if path[-1]==0:
        break
    path.append(prev[path[-1]])
path.reverse()
    
for i in range(1,n):
    while True:
        if prev[i] in path:
            break
        prev[i]=prev[prev[i]]

if len(path)%2==0:
    fenp=path[:len(path)//2]
    fen=len(path)//2
else:
    fenp=path[:len(path)//2+1]
    fen=len(path)//2+1

snu=len(path)-fen

r=list(range(n))
for i in path:
    r.remove(i)
for i in r:
    if prev[i] in fenp:
        fen+=1
    else:
        snu+=1

        
if fen>snu:
    print("Fennec")
else:
    print("Snuke")

Fixed submission:
#067-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n=I()
nl=[[] for i in range(n)]
distfen=[-1 for i in range(n)]
distsnu=[-1 for i in range(n)]

for i in range(n-1):
    a,b=IL()
    nl[a-1].append(b-1)
    nl[b-1].append(a-1)
    
q=[[0,0]]
vis=[False for i in range(n)]
while len(q)!=0:
    s,d=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            distfen[v]=d+1
            q.append([v,d+1])

q=[[n-1,0]]
vis=[False for i in range(n)]
while len(q)!=0:
    s,d=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            distsnu[v]=d+1
            q.append([v,d+1])
        
fen=0
snu=0

for i in range(1,n-1):
    if distfen[i]<=distsnu[i]:
        fen+=1
    else:
        snu+=1

if fen>snu:
    print("Fennec")
else:
    print("Snuke")

Buggy python submission (verdict: Time Limit Exceeded):
#067-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n=I()
prev=[-1 for i in range(n)]
nl=[[] for i in range(n)]
q=[0]
vis=[False for i in range(n)]

for i in range(n-1):
    a,b=IL()
    nl[a-1].append(b-1)
    nl[b-1].append(a-1)

while len(q)!=0:
    s=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            prev[v]=s
            q.append(v)

path=[n-1]
while True:
    if path[-1]==0:
        break
    path.append(prev[path[-1]])
path.reverse()
    
for i in range(1,n):
    while True:
        if prev[i] in path:
            break
        prev[i]=prev[prev[i]]

if len(path)%2==0:
    fenp=path[:len(path)//2]
    fen=len(path)//2
else:
    fenp=path[:len(path)//2+1]
    fen=len(path)//2+1

snu=len(path)-fen

for i in range(n):
    if i not in path:
        if prev[i] in fenp:
            fen+=1
        else:
            snu+=1
    
if fen>snu:
    print("Fennec")
else:
    print("Snuke")

Fixed submission:
#067-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n=I()
nl=[[] for i in range(n)]
distfen=[-1 for i in range(n)]
distsnu=[-1 for i in range(n)]

for i in range(n-1):
    a,b=IL()
    nl[a-1].append(b-1)
    nl[b-1].append(a-1)
    
q=[[0,0]]
vis=[False for i in range(n)]
while len(q)!=0:
    s,d=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            distfen[v]=d+1
            q.append([v,d+1])

q=[[n-1,0]]
vis=[False for i in range(n)]
while len(q)!=0:
    s,d=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            distsnu[v]=d+1
            q.append([v,d+1])
        
fen=0
snu=0

for i in range(1,n-1):
    if distfen[i]<=distsnu[i]:
        fen+=1
    else:
        snu+=1

if fen>snu:
    print("Fennec")
else:
    print("Snuke")

Buggy python submission (verdict: Time Limit Exceeded):
#067-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n=I()
prev=[-1 for i in range(n)]
nl=[[] for i in range(n)]
q=[0]
vis=[False for i in range(n)]

for i in range(n-1):
    a,b=IL()
    nl[a-1].append(b-1)
    nl[b-1].append(a-1)

def bfs(s):
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            prev[v]=s
            q.append(v)
    return

while len(q)!=0:
    s=q.pop(0)
    bfs(s)

path=[n-1]
while True:
    if path[-1]==0:
        break
    path.append(prev[path[-1]])
path.reverse()
    
for i in range(1,n):
    while True:
        if prev[i] in path:
            break
        prev[i]=prev[prev[i]]

if len(path)%2==0:
    fenp=path[:len(path)//2]
    fen=len(path)//2
else:
    fenp=path[:len(path)//2+1]
    fen=len(path)//2+1

snu=len(path)-fen

for i in range(n):
    if i not in path:
        if prev[i] in fenp:
            fen+=1
        else:
            snu+=1
    
if fen>snu:
    print("Fennec")
else:
    print("Snuke")

Fixed submission:
#067-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n=I()
nl=[[] for i in range(n)]
distfen=[-1 for i in range(n)]
distsnu=[-1 for i in range(n)]

for i in range(n-1):
    a,b=IL()
    nl[a-1].append(b-1)
    nl[b-1].append(a-1)
    
q=[[0,0]]
vis=[False for i in range(n)]
while len(q)!=0:
    s,d=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            distfen[v]=d+1
            q.append([v,d+1])

q=[[n-1,0]]
vis=[False for i in range(n)]
while len(q)!=0:
    s,d=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            distsnu[v]=d+1
            q.append([v,d+1])
        
fen=0
snu=0

for i in range(1,n-1):
    if distfen[i]<=distsnu[i]:
        fen+=1
    else:
        snu+=1

if fen>snu:
    print("Fennec")
else:
    print("Snuke")