Language: C++

#include <bits/stdc++.h>

using namespace std;

int N;
std::vector<std::vector<int>> adjlist;



std::vector<int> do_search_path (int src, int dst, int prev = -1) {
    if (src == dst)
        return {dst};

    vector<int> path;
    for ( auto neighbor : adjlist[src] ) {
        if (neighbor == prev) continue;
        path = do_search_path (neighbor, dst, src);
        if (path.size () > 0) {
            path.push_back (neighbor);
            return path;
        }
    }

    return {};
}

std::vector<int> search_path () {
    auto p = do_search_path (0, N - 1);
    p.push_back (0);
    reverse (p.begin (), p.end ());
    p.pop_back ();
    return p;
}

int count (int node, int prev = -1, int r = 0) {
    if (adjlist[node].size () == 1)
        return 1;

    int sum = 0;
    for (auto n : adjlist[node]) {
        if (n == prev) continue;
        sum += count (n, node);
    }

    return sum + 1;
}

int count (int node, int prev = -1) {
    if (adjlist[node].size () == 1)
        return 1;

    int sum = 0;
    for (auto n : adjlist[node]) {
        if (n == prev) continue;
        sum += count (n, node);
    }

    return sum + 1;
}

std::string solve () {
    auto path = search_path ();
    int n = path.size () / 2;
    if (path.size () % 2 != 0) n += 1;

    int f = 0, s = 0;
    for (int i = 0; i < path.size (); ++i) {
        int a = path[i];
        for (auto t : adjlist[a]) {
            if (t == path[min(0, i - 1)]) continue;
            if (t == path[max(i + 1, static_cast<int> (path.size () - 1))]) continue;
            
            if (i < n)
                f += count (t, a) + 1;
            else
                s += count (t, a) + 1;
        }
    }
    
    return (f > s) ? "fennec" : "sunuke";
}

int main () {
    cin >> N;
    adjlist.resize(N);
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        adjlist[a - 1].push_back (b - 1);
        adjlist[b - 1].push_back (a - 1);
    }

    cout << solve () << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int count(int, int)':
a.cc:55:22: error: call of overloaded 'count(int&, int&)' is ambiguous
   55 |         sum += count (n, node);
      |                ~~~~~~^~~~~~~~~
a.cc:35:5: note: candidate: 'int count(int, int, int)'
   35 | int count (int node, int prev = -1, int r = 0) {
      |     ^~~~~
a.cc:48:5: note: candidate: 'int count(int, int)'
   48 | int count (int node, int prev = -1) {
      |     ^~~~~
a.cc: In function 'std::string solve()':
a.cc:74:28: error: call of overloaded 'count(int&, int&)' is ambiguous
   74 |                 f += count (t, a) + 1;
      |                      ~~~~~~^~~~~~
a.cc:35:5: note: candidate: 'int count(int, int, int)'
   35 | int count (int node, int prev = -1, int r = 0) {
      |     ^~~~~
a.cc:48:5: note: candidate: 'int count(int, int)'
   48 | int count (int node, int prev = -1) {
      |     ^~~~~
a.cc:76:28: error: call of overloaded 'count(int&, int&)' is ambiguous
   76 |                 s += count (t, a) + 1;
      |                      ~~~~~~^~~~~~
a.cc:35:5: note: candidate: 'int count(int, int, int)'
   35 | int count (int node, int prev = -1, int r = 0) {
      |     ^~~~~
a.cc:48:5: note: candidate: 'int count(int, int)'
   48 | int count (int node, int prev = -1) {
      |     ^~~~~