Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

inf = float('inf')

import heapq
def dijkstra(adj, n, st=1):
    dj = [inf] * (n + 1)
    paths = dict((x, [x]) for x in range(n + 1))
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                paths[tn] = paths[fn] + [tn]
                heapq.heappush(q, (dj[tn], tn))
    return dj, paths

import itertools
def reachable(adj, st):
    reached = set([st])
    cur = set([st])
    while cur:
        nxt = set(itertools.chain(*[[y[0] for y in adj[x]] for x in cur]))
        reached.update(cur)
        cur = nxt - reached
    return reached

adj = dict((x, []) for x in range(N + 1))
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append((b, 1))
    adj[b].append((a, 1))

costs, paths = dijkstra(adj, N, 1)
main_street = paths[N]
import math
mid = math.ceil(len(main_street) / 2) - 1
mid_v0 = main_street[mid]
mid_v1 = main_street[mid + 1]
adj[mid_v0] = filter(lambda x: x[0] != mid_v1, adj[mid_v0])
adj[mid_v1] = filter(lambda x: x[0] != mid_v0, adj[mid_v1])

fennec = len(reachable(adj, 1))
snuke = N - fennec

print("Fennec" if fennec > snuke else "Snuke")

Fixed submission:
N = int(input())

inf = float('inf')

import heapq
def dijkstra(adj, n, st=1):
    dj = [inf] * (n + 1)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

adj = dict((x, []) for x in range(N + 1))
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append((b, 1))
    adj[b].append((a, 1))

c_f = dijkstra(adj, N, 1)
c_s = dijkstra(adj, N, N)

score = 0
for i in range(1, N + 1):
    if c_f[i] > c_s[i]:
        score -= 1
    else:
        score += 1

print("Fennec" if score > 0 else "Snuke")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

inf = float('inf')

import heapq
def dijkstra(adj, n, st=1):
    dj = [inf] * (n + 1)
    paths = dict((x, [x]) for x in range(n + 1))
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                paths[tn] = paths[fn] + [tn]
                heapq.heappush(q, (dj[tn], tn))
    return dj, paths

adj = dict((x, []) for x in range(N + 1))
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append((b, 1))
    adj[b].append((a, 1))

costs, paths = dijkstra(adj, N, 1)
main_street = paths[N]
import math
mid = math.ceil(len(main_street) / 2) - 1
mid_v0 = main_street[mid]
mid_v1 = main_street[mid + 1]
adj[mid_v0] = filter(lambda x: x[0] != mid_v1, adj[mid_v0])
adj[mid_v1] = filter(lambda x: x[0] != mid_v0, adj[mid_v1])

fennec = N - dijkstra(adj, N, 1)[0].count(inf) + 1
snuke = N - fennec

print("Fennec" if fennec > snuke else "Snuke")

Fixed submission:
N = int(input())

inf = float('inf')

import heapq
def dijkstra(adj, n, st=1):
    dj = [inf] * (n + 1)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

adj = dict((x, []) for x in range(N + 1))
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append((b, 1))
    adj[b].append((a, 1))

c_f = dijkstra(adj, N, 1)
c_s = dijkstra(adj, N, N)

score = 0
for i in range(1, N + 1):
    if c_f[i] > c_s[i]:
        score -= 1
    else:
        score += 1

print("Fennec" if score > 0 else "Snuke")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

inf = float('inf')

import heapq
def dijkstra(adj, n, st=1):
    dj = [inf] * (n + 1)
    paths = dict((x, [x]) for x in range(n + 1))
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                paths[tn] = paths[fn] + [tn]
                heapq.heappush(q, (dj[tn], tn))
    return dj, paths

adj = dict((x, []) for x in range(N + 1))
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append((b, 1))
    adj[b].append((a, 1))

costs, paths = dijkstra(adj, N, 1)
main_street = paths[N]
import math
mid = math.ceil(len(main_street) / 2) - 1
mid_v0 = main_street[mid]
mid_v1 = main_street[mid + 1]
adj[mid_v0] = filter(lambda x: x[0] != mid_v1, adj[mid_v0])
adj[mid_v1] = filter(lambda x: x[0] != mid_v0, adj[mid_v1])

snuke = dijkstra(adj, N, 1)[0].count(inf)
fennec = dijkstra(adj, N, N)[0].count(inf)

print("Fennec" if fennec > snuke else "Snuke")

Fixed submission:
N = int(input())

inf = float('inf')

import heapq
def dijkstra(adj, n, st=1):
    dj = [inf] * (n + 1)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

adj = dict((x, []) for x in range(N + 1))
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append((b, 1))
    adj[b].append((a, 1))

c_f = dijkstra(adj, N, 1)
c_s = dijkstra(adj, N, N)

score = 0
for i in range(1, N + 1):
    if c_f[i] > c_s[i]:
        score -= 1
    else:
        score += 1

print("Fennec" if score > 0 else "Snuke")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

inf = float('inf')

import heapq
def dijkstra(adj, n, st=1):
    dj = [inf] * (n + 1)
    paths = dict((x, [x]) for x in range(n + 1))
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                paths[tn] = paths[fn] + [tn]
                heapq.heappush(q, (dj[tn], tn))
    return dj, paths

adj = dict((x, []) for x in range(N + 1))
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append((b, 1))
    adj[b].append((a, 1))

costs, paths = dijkstra(adj, N, 1)
main_street = paths[N]
import math
mid = math.ceil(len(main_street) / 2) - 1
mid_v0 = main_street[mid]
mid_v1 = main_street[mid + 1]
adj[mid_v0] = filter(lambda x: x[0] != mid_v1, adj[mid_v0])
adj[mid_v1] = filter(lambda x: x[0] != mid_v0, adj[mid_v1])

snuke = dijkstra(adj, N, 1)[0].count(inf)
fennec = dijkstra(adj, N, N)[0].count(inf)

print("Fennec" if fennec > snuke else "Snuke")

Fixed submission:
N = int(input())

inf = float('inf')

import heapq
def dijkstra(adj, n, st=1):
    dj = [inf] * (n + 1)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

adj = dict((x, []) for x in range(N + 1))
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append((b, 1))
    adj[b].append((a, 1))

c_f = dijkstra(adj, N, 1)
c_s = dijkstra(adj, N, N)

score = 0
for i in range(1, N + 1):
    if c_f[i] > c_s[i]:
        score -= 1
    else:
        score += 1

print("Fennec" if score > 0 else "Snuke")