Language: C++

#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

void cnt(ll a, ll p, ll &c, const vvll &e){
    c++;
    for(auto x: e[a]){
        if(x == p){
            continue;
        }
        cnt(x, a, c, e);
    }
}

bool gl(ll a, ll p, ll g, const vvll &e, set<ll> &r){
    if(a == g){
        return true;
    }
    if(sz(e[a]) == 1){
        return false;
    }
    bool b = false;
    for(auto x: e[a]){
        if(x == p){
            continue;
        }
        if(gl(x, a, g, e, r)){
            r.insert(x);
            b = true;
        }
    }
    return b;
}

ll cnt2(ll a, ll p, ll g, const vvll &e){
    if(a == g){
        return 0;
    }
    if(sz(e[a]) == 1&&p != INF){
        return -INF;
    }
    ll v = -INF;
    for(auto x: e[a]){
        if(x == p){
            continue;
        }
        chmax(v, cnt2(x, a, g, e));
    }
    return v+1;
}

int main(){
    ll N; cin >> N;
    vvll e(N, vll(0));
    rep(i, 0, N-1){
        ll a, b; cin >> a >> b;
        a--; b--;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    ll s = 0, f = 0;
    ll n1;
    set<ll> route;
    gl(0, INF, N-1, e, route);
    route.insert(0);
    set<ll> rf;
    for(auto x: e[0]){
        if(gl(x, 0, N-1, e, rf)){
            n1 = x;
        }
    }
    ll n2;
    for(auto x: e[N-1]){
        if(gl(x, N-1, 0, e, rf)){
            n2 = x;
        }
    }
    //prt(n1); prt(" "); prtl(n2);
    //prtl("1");
    for(auto x: e[0]){
        if(x == n1){
            continue;
        }
        ll v = 0;
        cnt(x, 0, v, e);
        //prtl(v);
        f += v;
    }
    for(auto x: e[N-1]){
        if(x == n2){
            continue;
        }
        ll w = 0;
        cnt(x, N-1, w, e);
        s += w;
    }
    ll c = cnt2(0, INF, N-1, e);
    c--;
    //prtl(s); prtl(f);
    //prtl(c);
    ll t = 0;
    ll x = n1, y = n2; ll p1 = 0, p2 = N-1;
    while(c > 0){
        if(t%2 == 0){
            ll z;
            f++;
            for(auto v: e[x]){
                if(v == p1){
                    continue;
                }
                ll m = sz(route);
                route.insert(v)
                if(sz(route) == m){
                    z = v;
                    continue;
                }else{
                    route.erase(v);
                    ll r = 0;
                    cnt(v, x, r, e);
                    f += r;
                }
            }
            p1 = x;
            x = z;
        }else{
            ll z;
            s++;
            for(auto v: e[y]){
                if(v == p2){
                    continue;
                }
                ll m = sz(route);
                route.insert(v)
                if(sz(route) == m){
                    z = v;
                    continue;
                }else{
                    route.erase(v);
                    ll r = 0;
                    cnt(v, y, r, e);
                    s += r;
                }
            }
            p2 = y;
            y = z;
        }
        c--;
        t++;
    }
    //prtl(s); prtl(f);
    if(s > f){
        prtl("Snuke");
    }else if(s == f){
        prtl("Snuke");
    }else{
        prtl("Fennec");
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:137:32: error: expected ';' before 'if'
  137 |                 route.insert(v)
      |                                ^
      |                                ;
  138 |                 if(sz(route) == m){
      |                 ~~              
a.cc:141:18: error: 'else' without a previous 'if'
  141 |                 }else{
      |                  ^~~~
a.cc:158:32: error: expected ';' before 'if'
  158 |                 route.insert(v)
      |                                ^
      |                                ;
  159 |                 if(sz(route) == m){
      |                 ~~              
a.cc:162:18: error: 'else' without a previous 'if'
  162 |                 }else{
      |                  ^~~~