stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

typedef long long ll;

const int maxn=1e6+5;

using namespace std;

const ll INF=1e13+7;

ll n,m;

char str[maxn];

ll dp[maxn];

ll q[maxn];

int pre[maxn];

void TraceBack(int x)

{

    if(pre[x]==-1)

    {

        printf("%d",x);

        return;

    }

    TraceBack(pre[x]);

    printf(" %d",x-pre[x]);

}

int main()

{

    memset(pre,-1,sizeof(pre));

    scanf("%lld%lld",&n,&m);

    scanf("%s",str);

    //数有n+1个

    int s=1,e=0;

    for(int i=0;i<=m;i++)

    {

        if(str[i]=='0')

            dp[i]=1;

        else

            dp[i]=INF;

        while(s<=e&&dp[i]<dp[q[e]]) e--;

        q[++e]=i;

    }

    s++;

    for(int i=m+1; i<=n; i++)

    {

        dp[i]=INF;

        if(str[i]=='0')

        {

            dp[i]=min(dp[q[s]]+1,dp[i]);

            if(dp[i]!=INF)

                pre[i]=q[s];

        }

        while(s<=e&&dp[i]<dp[q[e]]) e--;

        q[++e]=i;

        while(s<=e&&q[s]<i+1-m)

            s++;

    }

    if(dp[n]==INF) printf("-1\n");

    else TraceBack(n);

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 5.010178581673588x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long 

ll n,m,cur;

int main(){

  vector<ll> ans;

  string s;

  cin>>n>>m>>s;

  cur=n;

  while(cur)

  {

  	 bool check=true;

  	 for(int i=max(0ll,cur-m);i<cur;i++)

  	    if(s[i]=='0'){

  	    	check=false;

  	    	ans.push_back(cur-i);

  	    	cur=i;

  	    	break;

  	    }

  	  if(check){

  	  	cout<<-1<<endl;return 0;

  	  }

  }

  reverse(ans.begin(),ans.end());

  for(int i=0;i<ans.size();i++){

  	  cout<<ans[i];

  	  if(i==ans.size()-1)cout<<endl;

  	  else cout<<" ";

  }







	return 0;

}
// Slower C++ solution:
#include <algorithm>

#include <cstdio>

#include <set>

#include <vector>

#define ALL(x) (x).begin(), (x).end()

const int MAXN = 1e5+5;

char S[MAXN];

std::set<int> good;

std::vector<int> step;

int M, N;



void display() {

    for (int x: step) {

        printf("%d ", x);

    }

    putchar('\n');

}



void init() {

    for (int i = 0; i <= N; ++i) {

        if (S[i] == '0') {

            good.insert(i);

        }

    }

}



void solve() {

    M = std::min(N, M);

    int cur = N;

    while (cur > 0) {

        int prev = std::max(cur - M, 0);

        auto ptr = good.lower_bound(prev);

        if (*ptr == cur) {

            step.assign({-1});

            return;

        }

        step.push_back(cur - *ptr);

        cur = *ptr;

    }

    std::reverse(ALL(step));

}



int main() {

    scanf(" %d%d%s", &N, &M, S);

    init();

    solve();

    display();

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.650310372516845x):
#include <algorithm>

#include <cstdio>

const int MAXN = 1e5+5;

char  S[MAXN];

int out[MAXN];

int M, N;

int K;



// Greedily take largest possible steps from N -> 0

// Range [head, tail) are Game Over squares



void display() {

  for (int i = 0; i < K; ++i) {

    printf("%d ", out[i]);

  }

  putchar('\n');

}



bool solve() {

  M = std::min(N, M);

  K = 0;

  int head = N;

  int tail = N;

  while (tail > 0) {

    int src = tail - std::min(M, tail);

    auto is_valid = [](char c) { return (c == '0'); };

    auto itr = std::find_if(S+src, S+head, is_valid);

    int next = itr - S;

    if (next == head) {

      return false;

    }

    head = src;

    out[K++] = (tail - next);

    tail = next;

  }

  std::reverse(out, out+K);

  return true;

}



int main() {

  scanf(" %d%d%s", &N, &M, S);

  if (solve()) {

    display();

  } else {

    puts("-1");

  }

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

#define ll long long

#define ull unsigned long long

#define mp make_pair

typedef pair<int, int> pii;

typedef priority_queue<int, vector<int>, greater<int> > small_heap;

typedef priority_queue<int> big_heap;

int n, m, f[200009], g[200009], st[200009], top = 0;

char str[200009];

struct node {

    int v, id;

};

deque<node> q;



int main() {

    memset(g, -1, sizeof(g));

    memset(f, 0x3f, sizeof(f));

    scanf("%d%d", &n, &m);

    scanf("%s", str);

    f[0] = 0, q.push_back({f[0], 0});

    for (int i = 1; i <= n; i++) {

        while (!q.empty() && i - q.front().id > m)q.pop_front();

        if (str[i] == '1')continue;

        if (!q.empty())f[i] = q.front().v + 1, g[i] = q.front().id;

        while (!q.empty() && q.back().v > f[i])q.pop_back();

        if (f[i] != 0x3f3f3f3f)q.push_back({f[i], i});

    }

    if (g[n] == -1)return puts("-1"), 0;

    int now = n;

    while (g[now] != -1) { st[++top] = now - g[now], now = g[now]; }

    while (top) {

        printf("%d ", st[top--]);

    }

    puts("");

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.832748828537804x):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<int, pii> pipii;

typedef pair<pii, pii> piipii;



#define mp make_pair

#define fi first

#define se second

#define all(a) (a).begin(), (a).end()

#define sz(a) (int)(a).size()

#define eb emplace_back

int dp[100005], pv[100005];

string s;

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    int n, m;

    cin >> n >> m;

    cin >> s;



    memset(dp, -1, sizeof(dp));

    dp[0] = 0;



    deque<int> dq;

    dq.push_back(0);

    n++;

    for(int i=1;i<n;i++){

        if(s[i] == '1') continue;

        while(!dq.empty() && i-dq.front() > m) dq.pop_front();

        if(dq.empty()) continue;

        dp[i] = dp[dq.front()]+1;

        pv[i] = dq.front();

        while(!dq.empty() && dp[dq.back()] > dp[i]) dq.pop_back();

        dq.push_back(i);

    }

    if(dp[n-1] == -1) printf("-1\n");

    else{

        vector<int> ans;

        int u = n-1;

        while(u != 0){

            ans.eb(u-pv[u]);

            u = pv[u];

        }

        reverse(all(ans));



        for(int i=0;i<sz(ans);i++) printf("%d ", ans[i]);

        printf("\n");

    }

}
// Slower C++ solution:
#include <cstdio>

#include <string>

#include <iostream>

using namespace std;

inline int m_min(int x,int y)

{ return x<y ? x : y; }

const int Mn(100050);

int ans[Mn];

int main()

{

	int n,m;

	string s;

	cin >>n>>m>> s;

	int cnt(0),p(n);

	while(p)

	{

		bool flag(true);

		for(int i(m_min(p,m));i>=1;--i)

			if(s[p-i]=='0')

			{

				p = p-i;

				ans[++cnt] = i;

				flag = false;

				break;

			}

		if(flag)	break;

	}

	if(p!=0)	printf("-1");

	else

		for(int i(cnt);i;--i)

			printf("%d ",ans[i]);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.2083582019855035x):
#include <cstdio>

#include <algorithm>

#define max(a,b)a>b?a:b



int ans[100070];

int R(){

	int x=0;char ch;

	do{ch=getchar();}while(ch>57||ch<48);

	do{x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}while(ch>=48&&ch<=57);

	return x;

}

void W(int c){

	if(c>9)W(c/10);

	putchar('0'+c%10);

}



char ch[1000000];



signed main(){

	int n=R(),m=R(),p,i,now;

	scanf("%s",ch);

	now=n;

	i=n;

	p=m;

	while(i>m){

		

		while(ch[i-p]=='1'){

			p--;

			if(p==0)

				break;

		}

		if(p==0)

			break;

		ans[now--]=p;

		i-=p;

		p=m;

	}

	if(p==0){

		printf("-1");

	}

	else{

		printf("%d ",i);

		for(int i=now+1;i<=n;i++){

			printf("%d ",ans[i]);

		}

	}

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<cstring>

using namespace std;

char s[10001];

int main()

{

    cin>>s;

    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')

        cout<<"Yes\n";

    else

        cout<<"No\n";

}

// Faster C++ solution for the same problem (measured speedup: 5.272486549741785x):
#include <stdio.h>

char s[11];

int main()

{

    scanf("%s",s);

    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') printf("Yes\n");

    else printf("No\n");

    return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

    string s;

    cin>>s;

    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout<<"Yes"<<endl;

        else cout<<"No"<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.323712263500592x):
#include <stdio.h>

char s[11];

int main()

{

    scanf("%s",s);

    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') printf("Yes\n");

    else printf("No\n");

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string st;

int main()

{

    cin>>st;

    if(st[0]=='Y' && st[1]=='A' && st[2]=='K' && st[3]=='I') cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.326907141202491x):
#include <stdio.h>

char s[11];

int main()

{

    scanf("%s",s);

    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') printf("Yes\n");

    else printf("No\n");

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    char s1[10];

   cin>>s1;

     char s2[10];

   cin>>s2;

     char s3[10];

   cin>>s3;

    if(s1[0]>='a' && s1[0]<='z')

    {

          s1[0]-=32;

        

    }

     if(s2[0]>='a' && s2[0]<='z')

    {

       s2[0]-=32;

      

    }

      if(s3[0]>='a' && s3[0]<='z')

    {  s3[0]-=32;

       

    }

    cout << s1[0]<<s2[0]<<s3[0];

}

// Faster C++ solution for the same problem (measured speedup: 5.2783721374642365x):
#include <stdio.h>

 

int main() {

	char s1[11], s2[11], s3[11];

	scanf("%s %s %s", s1, s2, s3);

	printf("%c%c%c\n", s1[0] - 32, s2[0] - 32, s3[0] - 32);

	return 0;

}
// Slower C++ solution:
#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

    string s,s1,s2,s3;

cin>>s1>>s2>>s3;

    s=s1+' '+s2+' '+s3;

    cout<<(char)(s[0]-32);

    for(int i=0;i <s.length();i++){

    if(s[i]==' ')

    cout<<(char)(s[i+1]-32);

    else

    continue;

    }

    

    

}






// Faster C++ solution for the same problem (measured speedup: 5.349122944743206x):
#include <stdio.h>

 

int main() {

	char s1[11], s2[11], s3[11];

	scanf("%s %s %s", s1, s2, s3);

	printf("%c%c%c\n", s1[0] - 32, s2[0] - 32, s3[0] - 32);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    char s1[10];

   cin>>s1;

     char s2[10];

   cin>>s2;

     char s3[10];

   cin>>s3;

    if(s1[0]>='a' && s1[0]<='z')

    {

          s1[0]-=32;

        

    }

     if(s2[0]>='a' && s2[0]<='z')

    {

       s2[0]-=32;

      

    }

      if(s3[0]>='a' && s3[0]<='z')

    {  s3[0]-=32;

       

    }

    cout << s1[0]<<s2[0]<<s3[0];

}

// Faster C++ solution for the same problem (measured speedup: 5.3041582831316205x):
#include <stdio.h>

#include <string.h>



int main() {

  char str[255];

  scanf("%[^\n]", str);



  printf("%c", str[0] - 32);



  for(int i = 1; str[i] != '\0'; i++) {

    if(str[i] == ' ') {

      printf("%c", str[i+1] - 32);

    }

  }



  puts("");

  return 0;

}
// Slower C++ solution:
#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

    string s,s1,s2,s3;

cin>>s1>>s2>>s3;

    s=s1+' '+s2+' '+s3;

    cout<<(char)(s[0]-32);

    for(int i=0;i <s.length();i++){

    if(s[i]==' ')

    cout<<(char)(s[i+1]-32);

    else

    continue;

    }

    

    

}






// Faster C++ solution for the same problem (measured speedup: 5.375254725499414x):
#include <stdio.h>

#include <string.h>



int main() {

  char str[255];

  scanf("%[^\n]", str);



  printf("%c", str[0] - 32);



  for(int i = 1; str[i] != '\0'; i++) {

    if(str[i] == ' ') {

      printf("%c", str[i+1] - 32);

    }

  }



  puts("");

  return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

using namespace std;

#define ll long long 

int n;

vector<int> g[100005];

int d1[100005],d2[100005];

inline void dfs(int r,int f,int d,int dist[])

{

    dist[r]=d;

    for(int x=0;x<g[r].size();x++){

        if(g[r][x]!=f){

        	dfs(g[r][x],r,d+1,dist);

		}

    }

}

int main()

{

    cin>>n;

    for(int i=0;i<n-1;i++)

    {

    	int a,b;

        cin>>a>>b;

        a--,b--;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    dfs(0,-1,0,d1);

    dfs(n-1,-1,0,d2);

    int ans=0;

    for(int i=0;i<n;i++){

        if(d1[i]<=d2[i]){

            ans++;

		}

        else{

        	ans--;

        }

    }

    if(ans>0){

    	cout <<"Fennec"<< endl;

	}

    else{

    	cout<<"Snuke"<<endl;

	}

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.483600146739582x):


#include <iostream>

#include <cstdio>

#include <algorithm>

#include <iomanip>

#include <cmath>

#include <vector>

#include <queue>

#include <map>

#include <set>

#include <time.h>



#define rep(num)      for (long long _ = 0; _ < num; _++)

#define loop(i, num)  for (long long i = 0; i < num; i++)



using namespace std;



int n;



vector<bool> vis;



vector<vector<int>> nei, dis;



void dfs(int from, int len, int mem) {

    

    vis[from] = 1;

    

    dis[mem][from] = len;

    

    loop (i, nei[from].size()) {

        

        if (!vis[nei[from][i]]) {

            

            dfs(nei[from][i], len + 1, mem);

            

        }

        

    }

    

}



int main() {

    

    cin >> n;

    

    nei.resize(n + 1);

    

    vis.resize(n + 1);

    

    dis.resize(2, vector<int>(n + 1, 1e9));

    

    loop (i, n - 1) {

        

        int p1, p2;

        

        cin >> p1 >> p2;

        

        nei[p1].push_back(p2);

        

        nei[p2].push_back(p1);

        

    }

    

    dfs(1, 0, 0);

    

    loop (i, n + 1) {

        

        vis[i] = 0;

        

    }

    

    dfs(n, 0, 1);

    

    int f = 0, s = 0;

    

    for (int i = 1; i <= n; i++) {

        

        if (dis[0][i] > dis[1][i]) {

            

            ++s;

            

        } else {

            

            ++f;

            

        }

        

    }

    

    if (s >= f) {

        

        cout << "Snuke" << endl;

        

    } else {

        

        cout << "Fennec" << endl;

        

    }

    

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

const int maxn=1e5+7;

const int inf=1e9+7;

const int mod=1e9+7;

#define pb push_back

#define pii pair<int,int>

#define F first

#define S second

#define rep(i,n) for (int i=1;i<=(n);i++)

#define rep2(i,a,b) for (int i=(a);i<=(b);i++)



vector <int> G[maxn];

set <int> fennec,snuck;

vector<int> color;

bool v[maxn]={0};

int sub[maxn]={0};



bool dfs (int now,int target)

{ v[now]=1;

if (now==target) {

	color.pb(now);

	return 1;

}

	for (int i:G[now])

	{

		if (!v[i])

		{

			if (dfs(i,target)) 

			{

			color.pb(now);

			return 1;

			}

		}

	}

	return 0;

} 



int dfs2(int now)

{

	v[now]=1;

	int sum=0;

	for (int i:G[now])

	{

		if (!v[i])

		{

			if (fennec.find(i)==fennec.end()&&

			snuck.find(i)==snuck.end())

			{

			sum+=1;

			//cout<<now<<' '<<i<<endl;

			sum+=dfs2(i);

			}

			else dfs2(i);

		}

	}

	sub[now]=sum;

	return sum;

} 



int main()

{

 	ios::sync_with_stdio(0); cin.tie(0);

 	int n;

 	cin>>n;

 	for (int i=1;i<=n-1;i++)

 	{

 		int a,b;

 		cin>>a>>b;

 		G[a].pb(b);

 		G[b].pb(a);

	}

	//cout<<"---"<<endl;

	dfs(1,n);

	memset(v,0,sizeof(v));

	int size=color.size();

	for (int i=0;i<size;i++)

	{

		//cout<<color[i]<<' ';

		if ((i+1)<=size/2) snuck.insert(color[i]);

		else fennec.insert(color[i]);

	}

	dfs2(1);

	int sums=0,sumf=0;

	//for (int i=1;i<=n;i++) cout<<sub[i]<<' ';

	for (auto j=snuck.begin();j!=snuck.end();j++)

	{ /*cout<<sub[(*j)]<<'/'; */sums+=sub[(*j)];}

	 for (auto j=fennec.begin();j!=fennec.end();j++)

	{/*cout<<sub[(*j)]<<'*';*/sumf+=sub[(*j)];}

	if (sumf+size-size/2>sums+size/2) cout<<"Fennec"<<endl;

	else cout<<"Snuke"<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 3.6263212688165614x):
#include<iostream>

#include<string>

#include<stdlib.h> 

#include<cstring>

#include<map>

#include<list>

#include<stdio.h>

#include<cmath>

#include<iomanip>

#include<bitset>

#include<vector>

#include<time.h>

#include<algorithm> 

#include<queue>

#include<set>

#include<deque>

#define mod 1e9+7

#define inf 1e18 

typedef long long ll;

typedef long double ld;

using namespace std;

typedef list<ll> li;

typedef list<ll>::iterator lt;

li sh_r;

ll N,s;

vector<li>a;

bool dfs(ll step,ll x,ll f){

	if(x>N)cout<<f<<" "<<x<<endl;

	if(x==N){

	  s=step;

	  return true;

    }

	for(lt it=a[x].begin();it!=a[x].end();it++){

		if(*it==f)continue;

		if(dfs(step+1,*it,x)){

			sh_r.push_back(x);

			return true;

		}

	}

	return false;

}

ll num(ll x,ll f){

	ll n=1;

	for(lt it=a[x].begin();it!=a[x].end();it++){

		if(*it==f)continue;

		n+=num(*it,x);

	}

	return n;

}

int main(){	

    cin>>N;

    a.resize(N+10);

    for(ll K=1;K<N;K++){

    	ll x,y;

    	scanf("%lld%lld",&x,&y);

    	a[x].push_back(y);

    	a[y].push_back(x);

	}

	dfs(0,1,-1);

	s--;

	ll F=1,S=N;

	if(N!=2){

		ll j=s/2;

		for(lt it=sh_r.begin();it!=sh_r.end();it++){

			j--;

			if(j==0)S=*it;

			if(j==-1){

				F=*it;

				break;

			}

		}

	}

	ll Fen=num(F,S);

	ll Snu=num(S,F);

	if(Fen>Snu)printf("Fennec");

	else printf("Snuke");

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

using namespace std;

#define ll long long 

int n;

vector<int> g[100005];

int d1[100005],d2[100005];

inline void dfs(int r,int f,int d,int dist[])

{

    dist[r]=d;

    for(int x=0;x<g[r].size();x++){

        if(g[r][x]!=f){

        	dfs(g[r][x],r,d+1,dist);

		}

    }

}

int main()

{

    cin>>n;

    for(int i=0;i<n-1;i++)

    {

    	int a,b;

        cin>>a>>b;

        a--,b--;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    dfs(0,-1,0,d1);

    dfs(n-1,-1,0,d2);

    int ans=0;

    for(int i=0;i<n;i++){

        if(d1[i]<=d2[i]){

            ans++;

		}

        else{

        	ans--;

        }

    }

    if(ans>0){

    	cout <<"Fennec"<< endl;

	}

    else{

    	cout<<"Snuke"<<endl;

	}

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.5055820113726806x):
#include<iostream>

#include<string>

#include<stdlib.h> 

#include<cstring>

#include<map>

#include<list>

#include<stdio.h>

#include<cmath>

#include<iomanip>

#include<bitset>

#include<vector>

#include<time.h>

#include<algorithm> 

#include<queue>

#include<set>

#include<deque>

#define mod 1e9+7

#define inf 1e18 

typedef long long ll;

typedef long double ld;

using namespace std;

typedef list<ll> li;

typedef list<ll>::iterator lt;

li sh_r;

ll N,s;

vector<li>a;

bool dfs(ll step,ll x,ll f){

	if(x>N)cout<<f<<" "<<x<<endl;

	if(x==N){

	  s=step;

	  return true;

    }

	for(lt it=a[x].begin();it!=a[x].end();it++){

		if(*it==f)continue;

		if(dfs(step+1,*it,x)){

			sh_r.push_back(x);

			return true;

		}

	}

	return false;

}

ll num(ll x,ll f){

	ll n=1;

	for(lt it=a[x].begin();it!=a[x].end();it++){

		if(*it==f)continue;

		n+=num(*it,x);

	}

	return n;

}

int main(){	

    cin>>N;

    a.resize(N+10);

    for(ll K=1;K<N;K++){

    	ll x,y;

    	scanf("%lld%lld",&x,&y);

    	a[x].push_back(y);

    	a[y].push_back(x);

	}

	dfs(0,1,-1);

	s--;

	ll F=1,S=N;

	if(N!=2){

		ll j=s/2;

		for(lt it=sh_r.begin();it!=sh_r.end();it++){

			j--;

			if(j==0)S=*it;

			if(j==-1){

				F=*it;

				break;

			}

		}

	}

	ll Fen=num(F,S);

	ll Snu=num(S,F);

	if(Fen>Snu)printf("Fennec");

	else printf("Snuke");

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include <cstdio>

#include <vector>

#include <queue>

#include <list>

#include <cstdlib>

#include <algorithm>

#include <set>

#include <map>

#include <deque>

#include <cstring>

#include <cmath>

//#include<bits/stdc++.h>

using namespace std;



const int INF=0x3f3f3f3f;

const int SIZE=100005;



vector<int> mp[SIZE];

int color[SIZE],dist[SIZE],dist2[SIZE];



void bfs(int s,int dist[]){

	queue<int> que;

	que.push(s);

	while(!que.empty()){

		int u=que.front();

		que.pop();

		for(int i=0;i<mp[u].size();i++){

			int t=mp[u][i];

			if(dist[t] || t==s) continue;

			dist[t]=dist[u]+1;

			que.push(t);

		}

	}

}



int main(){

	int n;

	scanf("%d",&n);

	for(int i=0,a,b;i<n-1;i++){

		scanf("%d%d",&a,&b);

		a--;

		b--;

		mp[a].push_back(b);

		mp[b].push_back(a);

	}

	bfs(0,dist);

	bfs(n-1,dist2);

	int s=0,f=0;

	for(int i=0;i<n;i++){

		if(dist[i]<=dist2[i]) f++; else s++;

	}

	if(s>=f){

		puts("Snuke");

	}

	else{

		puts("Fennec");

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.496749199960593x):
#include<iostream>

#include<string>

#include<stdlib.h> 

#include<cstring>

#include<map>

#include<list>

#include<stdio.h>

#include<cmath>

#include<iomanip>

#include<bitset>

#include<vector>

#include<time.h>

#include<algorithm> 

#include<queue>

#include<set>

#include<deque>

#define mod 1e9+7

#define inf 1e18 

typedef long long ll;

typedef long double ld;

using namespace std;

typedef list<ll> li;

typedef list<ll>::iterator lt;

li sh_r;

ll N,s;

vector<li>a;

bool dfs(ll step,ll x,ll f){

	if(x>N)cout<<f<<" "<<x<<endl;

	if(x==N){

	  s=step;

	  return true;

    }

	for(lt it=a[x].begin();it!=a[x].end();it++){

		if(*it==f)continue;

		if(dfs(step+1,*it,x)){

			sh_r.push_back(x);

			return true;

		}

	}

	return false;

}

ll num(ll x,ll f){

	ll n=1;

	for(lt it=a[x].begin();it!=a[x].end();it++){

		if(*it==f)continue;

		n+=num(*it,x);

	}

	return n;

}

int main(){	

    cin>>N;

    a.resize(N+10);

    for(ll K=1;K<N;K++){

    	ll x,y;

    	scanf("%lld%lld",&x,&y);

    	a[x].push_back(y);

    	a[y].push_back(x);

	}

	dfs(0,1,-1);

	s--;

	ll F=1,S=N;

	if(N!=2){

		ll j=s/2;

		for(lt it=sh_r.begin();it!=sh_r.end();it++){

			j--;

			if(j==0)S=*it;

			if(j==-1){

				F=*it;

				break;

			}

		}

	}

	ll Fen=num(F,S);

	ll Snu=num(S,F);

	if(Fen>Snu)printf("Fennec");

	else printf("Snuke");

	return 0;

}