Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#E問題
import bisect

N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
    if i == 0:
        B.append(A[i])
    else:
        if B[0] >= A[i]:
            B.insert(0,A[i])
        else:
            index = bisect.bisect_left(B,A[i])-1
            B[index] = A[i]
b=len(B)
print(b)

### FIXED CODE ###

#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
n, m = map(int, input().split())

root = [-1]*n

def find(n):
    if root[n] < 0:
        return n
    else:
        return find(root[n])

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    else:
        root[x] += root[y]
        root[y] = x

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

print(-min(root))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
n, m = map(int, input().split())

root = [-1]*n

def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = r(x)
    return -root[x]

for i in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    unite(x, y)

ans = 0
for i in range(n):
    ans = max(ans, size(i))

print(ans)
### BUGGY CODE ###

n, k = map(int,input().split())
l = list(map(int,input().split()))

if k >= 50:
    k = 50

dp = [[0] * 2 for i in range(n)]

ans = l[:]

for i in range(k):
    for j in range(n):
        tmp = ans[j] + 0.5
        dp[j][0] = (j+1 - tmp)
        dp[j][1] = (j+1 + tmp)

    ans = [0] * n

    for x in range(n):
        for y in range(n):
            if dp[y][0] <= x+1 <= dp[y][1]:
                ans[x] += 1

else:
    print(*ans)


### FIXED CODE ###

import numpy as np
from numba import njit

@njit #処理の並列化

def imos(n, a):
    
    l=np.zeros((n+1), dtype = np.int64)

    for i in range(n):
        ai = a[i] # 光の強さ_これにより照らせる範囲が決まる
        start = max(0, i - ai) #StartIndex_照らせる範囲
        end = min(n, i + ai + 1) #EndIndex + 1_照らせる範囲
        l[start] += 1 # 各々を'+1'と'-1'で表し...
        l[end] -= 1
    return np.cumsum(l)[:n] # 累積和をとる_cumulative sum

n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    a = imos(n, a)
    if a.min() == n: # すべての要素が最大値'n'になるとbreak
        break

print(*a)
### BUGGY CODE ###

s,t = input(),input()

S = len(s)
T = len(t)

dp = [[0]*(T+1) for _ in range(S+1)]

for i in range(S):
    for j in range(T):
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+(s[i]==t[j]))
    

ans = ''

while S > 0 and T > 0:
    if dp[S][T] == dp[S-1][T]: S -= 1
    elif dp[S][T] == dp[S][T-1]: T -= 1
    else: 
        S -= 1
        T -= 1
        ans = s[S] + ans
print(ans)

### FIXED CODE ###

s,t = input(),input()

S = len(s)
T = len(t)

dp = [[0]*(T+1) for _ in range(S+1)]

for i in range(S):
    for j in range(T):
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+(s[i]==t[j]))
    

ans = ''

while S > 0 and T > 0:
    if dp[S][T] == dp[S-1][T]: S -= 1
    elif dp[S][T] == dp[S][T-1]: T -= 1
    else: 
        S -= 1
        T -= 1
        ans = s[S] + ans
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
B = sorted(list(set(A)))[::-1]
x = 0
y = 0

for b in B:
  if x==0:
    if 4<=A.count(b):
      x = b
      y = b
    elif 2<=A.count(b):
      x = b
  else:
    if 2<=A.count(b):
      y = b

  if x*y!=0:
    break

print(x*y)

### FIXED CODE ###

N = int(input())
A = sorted(list(map(int,input().split())),reverse=True)

for i in range(N-1):
    if A[i]==A[i+1]:
        A[i+1]=0
    else:
        A[i]=0

A.sort(reverse=True)
print(A[0]*A[1])
### BUGGY CODE ###

from collections import deque

N, M = [int(x) for x in input().split()]

friends_map = {}

for m in range(M):
    a, b = [int(x) - 1 for x in input().split()]

    if a in friends_map:
        friends_map[a].add(b)
    else:
        friends_map[a] = {b}

    if b in friends_map:
        friends_map[b].add(a)
    else:
        friends_map[b] = {a}

stack = deque()
stack.appendleft(0)

remain_user = {i for i in range(N)}

max_group = 0
watch = set()
while stack:
    now = stack.popleft()
    remain_user.discard(now)
    watch.add(now)

    if now in friends_map:
        for next_node in friends_map[now]:
            if not next_node in watch:
                stack.appendleft(next_node)
                remain_user.discard(next_node)

    if len(watch) > max_group:
        max_group = len(watch)

    if not stack:
        if remain_user:
            stack.appendleft(remain_user.pop())
            watch = set()

print(max_group)


### FIXED CODE ###

from collections import deque

N, M = [int(x) for x in input().split()]

friends_map = {n : set() for n in range(N)}
remain_user = set()
for m in range(M):
    a, b = [int(x) - 1 for x in input().split()]

    friends_map[a].add(b)
    friends_map[b].add(a)
    remain_user.add(a)
    remain_user.add(b)

stack = deque()
stack.appendleft(0)

max_group = 1
watch = [0] * N
count = 0
while stack:
    now = stack.popleft()

    if watch[now] == 0:
        remain_user.discard(now)
        watch[now] = 1
        count += 1

        for next_node in friends_map[now]:
            if watch[next_node] == 0:
                stack.appendleft(next_node)

    if not stack:
        max_group = max(count, max_group)

        if remain_user:
            stack.appendleft(remain_user.pop())
            count = 0

print(max_group)
### BUGGY CODE ###

def main():
    N=int(input())
    A=list(map(int, input().split()))
    B=list(map(int, input().split()))

    count = 0
    while A!=B:
        b = True
        for i in range(N):
            d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
            if B[i] > d > 0:
                b = False
                c = (B[i]-A[i]) // d
                B[i] -= d * c
                count += c
        if b:
            if A == B:
                print(count)
            else:
                print(-1)
            break
    else:
        if A == B:
            print(count)
        else:
            print(-1)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N=int(input())
    A=list(map(int, input().split()))
    B=list(map(int, input().split()))

    count = 0
    prev_count = -1
    while count!=prev_count:
        prev_count = count
        for i in range(N):
            d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
            c = (B[i]-A[i]) // d
            B[i] -= d * c
            count += c

    if A == B:
        print(count)
    else:
        print(-1)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

a = int(input())
s = 0
for i in range(a+1):
    s+=i
print(s-a)

### FIXED CODE ###

a = int(input())
s = a*(a-1)//2
print(s)
### BUGGY CODE ###

A,B,N= map(int,input().split())
max_num = 0
N = N%(B+1)+1
a = A/B
for x in range(N):
    n = int(a*x)-(A*int(x/B))
    max_num = max(max_num,n)
print(max_num)

### FIXED CODE ###

A,B,N= map(int,input().split())
max_num = 0
x = min(B-1,N)
print(int((A*x)/B)-(A*int(x/B)))
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = []
for i in range(X):
    for j in range(Y):
        AB.append(A[i] + B[j])
AB.sort(reverse=True)

ABC = []
for i in range(min(len(AB), K)):
    for j in range(Z):
        ABC.append(AB[i] + C[j])

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            ABC.append(A[i] + B[j] + C[k])

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])
### BUGGY CODE ###

n = int(input())
s = input()
ans = []
cnt = []
for i in range(n-2):
    if s[i] not in cnt:
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                ans.append(s[i]+s[j]+s[k])
    cnt.append(s[i])
print(len(set(ans)))

### FIXED CODE ###

n = int(input())
s = input()
ans = 0
for i in range(10):
    if str(i) in s:
        tmp1 = s[s.index(str(i))+1:]
        for j in range(10):
            if str(j) in tmp1:
                tmp2 = tmp1[tmp1.index(str(j))+1:]
                for k in range(10):
                    if str(k) in tmp2:
                        ans += 1
print(ans)
### BUGGY CODE ###

from numpy import cumsum,copy
n = int(input())
a = cumsum([int(i) for i in input().split()])
b = copy(a)
ans1 = ans2 = 0
sign = 1
for i in range(n):
    if a[i] * sign <= 0:
        k = abs(a[i] - sign)
        a += sign*k
        ans1 += k
    sign *= -1
sign = -1
for i in range(n):
    if b[i] * sign <= 0:
        k = abs(b[i] - sign)
        b += sign*k
        ans2 += k
    sign *= -1
print(min(ans1, ans2))    

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
b = a[::]
ans1 = ans2 = 0
sign = 1
total = 0
for i in range(n):
    total += a[i]
    if total * sign <= 0:
        k = abs(total - sign)
        ans1 += k
        total = sign
    sign *= -1

sign = -1
total = 0
for i in range(n):
    total += b[i]
    if total * sign <= 0:
        k = abs(total - sign)
        ans2 += k
        total = sign
    sign *= -1
print(min(ans1, ans2))
### BUGGY CODE ###

X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []

AA = sorted(A, key=lambda a: -a)
BB = sorted(B, key=lambda a: -a)
CC = sorted(C, key=lambda a: -a)
for a in AA:
    for b in BB:
        for c in CC:
            ans.append(a+b+c)

for an in sorted(ans, key=lambda p: -p)[:K]:
    print(an)

### FIXED CODE ###

X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))
### BUGGY CODE ###

N = int(input())
W = []
G = [[] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    W.append((a,b))
    G[a].append(b)
    G[b].append(a)
K = 0
for i in range(1,N+1):
    n = len(G[i])
    K = max(K,n)
print(K)
C = [[i for i in range(1,K+1)] for j in range(N+1)]
import copy 
w = copy.deepcopy(W)
d = [[0 for i in range(N+1)] for j in range(N+1)]
w.sort()
for i in range(N-1):
    a,b = w[i]
    x = C[a].pop(0)
    C[b].remove(x)
    d[a][b] = x
for i in range(N-1):
    a,b = W[i]
    print(d[a][b])


### FIXED CODE ###

N = int(input())
W = []
G = [[] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    W.append((a,b))
    G[a].append(b)
    G[b].append(a)
K = 0
for i in range(1,N+1):
    n = len(G[i])
    K = max(K,n)
print(K)
d = {}
D = {}
D[1] = 1
k = 1
H = []
list = [1]
sumi = []
while list:
    x = list.pop(0)
    sumi.append(x)
    Y = G[x]
    k = D[x] + 1
    while Y:
        y = Y.pop(0)
        if x in G[y]:
            G[y].remove(x)
        if k > K:
            k -= K
        list.append(y)
        d[(x,y)] = k
        D[y] = k 
        k += 1
        if k > K:
            k -= K
                
for i in range(N-1):
    a,b = W[i]
    print(d[(a,b)])
### BUGGY CODE ###

N,u,v=[int(i) for i in input().split(" ")]
u-=1
v-=1
graph=[[0 for i in range(N)] for j in range(N)]
for i in range(N-1):
    A,B=[int(j) for j in input().split(" ")]
    graph[A-1][B-1]=1
    graph[B-1][A-1]=1

dist_takahashi=[-1 for i in range(N)]
dist_takahashi[u]=0
next=[u]
d=1
while -1 in dist_takahashi:
    _next=[]
    for n in next:
        for i in range(N):
            if graph[n][i]==1 and dist_takahashi[i]==-1:
                _next.append(i)
    for n in _next:
        dist_takahashi[n]=d
    next=_next
    d+=1

dist_aoki=[-1 for i in range(N)]
dist_aoki[v]=0
next=[v]
d=1
while -1 in dist_aoki:
    _next=[]
    for n in next:
        for i in range(N):
            if graph[n][i]==1 and dist_aoki[i]==-1:
                _next.append(i)
    for n in _next:
        dist_aoki[n]=d
    next=_next
    d+=1


retval=0

for i in range(N):
    if dist_aoki[i]<dist_takahashi[i]:
        continue

    retval=max(retval,dist_aoki[i]-1)


print(retval)


### FIXED CODE ###

N,u,v=[int(i) for i in input().split(" ")]
u-=1
v-=1
graph={}
for i in range(N-1):
    A,B=[int(j) for j in input().split(" ")]
    if A-1 in graph:
        d=graph[A-1]
        d.append(B-1)
        graph[A-1]=d
    else:
        graph[A-1]=[B-1]
    if B-1 in graph:
        d=graph[B-1]
        d.append(A-1)
        graph[B-1]=d
    else:
        graph[B-1]=[A-1]

dist_takahashi=[-1 for i in range(N)]
dist_takahashi[u]=0
next=[u]
d=1
while -1 in dist_takahashi:
    _next=[]
    for n in next:
        nodes=graph[n]
        for i in nodes:
            if dist_takahashi[i]==-1:
                _next.append(i)
    for n in _next:
        dist_takahashi[n]=d
    next=_next
    d+=1

dist_aoki=[-1 for i in range(N)]
dist_aoki[v]=0
next=[v]
d=1
while -1 in dist_aoki:
    _next=[]
    for n in next:
        nodes=graph[n]
        for i in nodes:
            if dist_aoki[i]==-1:
                _next.append(i)
    for n in _next:
        dist_aoki[n]=d
    next=_next
    d+=1


retval=0

for i in range(N):
    if dist_aoki[i]<dist_takahashi[i]:
        continue

    retval=max(retval,dist_aoki[i]-1)


print(retval)
### BUGGY CODE ###

K,S = map(int, input().split())

count = 0

for X in range(K+1):
  for Y in range(K+1):
    for Z in range(K+1):
      if X+Y+Z == S:
        count += 1
  
print(count)

### FIXED CODE ###

K,S = map(int, input().split())

count = 0

for X in range(K+1):
  for Y in range(K+1):
    Z = S-(X+Y)
    if 0<=Z and Z<=K:
      count += 1
  
print(count)
### BUGGY CODE ###

from collections import defaultdict


def prime_decomposition(n):
    table = defaultdict(int)
    # table = [0] * (n + 1)

    i = 2
    while n % i == 0:
        n //= i
        table[i] += 1

    i = 3
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i] += 1
        i += 2

    if n > 1:
        table[n] += 1

    return table


def main():
    mod = 10 ** 9 + 7

    n = int(input())
    *a, = map(int, input().split())

    t = [prime_decomposition(x) for x in a]

    lcm_d = defaultdict(int)
    for pd in t:
        for prime, power in pd.items():
            lcm_d[prime] = max(lcm_d[prime], power)

    ret = 0
    for pd in t:
        curr = 1
        for prime, power in lcm_d.items():
            curr = (curr * pow(prime, power - pd[prime], mod)) % mod
        ret = (ret + curr) % mod

    print(ret)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from functools import reduce

    def gcd(a, b):
        return a if b == 0 else gcd(b, a % b)

    def lcm(a, b):
        return a * b // gcd(a, b)

    mod = 10 ** 9 + 7

    n = int(input())
    *a, = map(int, input().split())

    L = reduce(lcm, a)

    ret = 0
    for x in a:
        ret = (ret + pow(x, mod - 2, mod)) % mod
    ret = ret * L % mod
    print(ret)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
H, W = map(int, input().split())
map = [list(input()) for i in range(H)]
queue = list()
for x in range(H):
    for y in range(W):
        if map[x][y]=="#":
            queue.append([x, y])
def check_all_black():
    checktext = "".join(["".join(l) for l in map])
    if "." in checktext:
        return False
    else:
        return True
count = 0
if check_all_black():
    print(count)
    exit()
while queue:
    next_queue = list()
    for x, y in queue:
        for nx, ny in [[x-1, y], [x+1, y], [x, y-1], [x, y+1]]:
            if 0<=nx<H and 0<=ny<W:
                if map[nx][ny]==".":
                    map[nx][ny] = "#"
                    next_queue.append([nx, ny])
    queue = next_queue
    count += 1
    if check_all_black():
        break
print(count)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque
H, W = map(int, input().split())
map = [list(input()) for i in range(H)]
checked = list()
queue = deque()
for x in range(H):
    checked.append(list())
    for y in range(W):
        if map[x][y]=="#":
            checked[x].append(True)
            queue.append((x, y, 0))
        else:
            checked[x].append(False)
neighbors = [(1,0), (0,1), (-1,0), (0,-1)]
while queue:
    x, y, res = queue.popleft()
    for dx, dy in neighbors:
        nx, ny = x+dx, y+dy
        if 0<=nx<H and 0<=ny<W:
            if not checked[nx][ny]:
                queue.append((nx, ny, res+1))
                checked[nx][ny] = True
print(res)
### BUGGY CODE ###

N, M = map(int, input().split())
W, V = [], []
for n in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)


def f(n, m):
    if n == 0 or m <= 0:
        return 0
    elif m < W[n - 1]:
        return f(n - 1, m)
    else:
        return max(f(n - 1, m), f(n - 1, m - W[n - 1]) + V[n - 1])


print(f(N, M))


### FIXED CODE ###

N, M = map(int, input().split())
W, V = [], []
for n in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
f = [[0 for m in range(M + 1)] for n in range(N + 1)]
for n in range(N):
    for m in range(M + 1):
        if m < W[n]:
            f[n + 1][m] = f[n][m]
        else:
            f[n + 1][m] = max(f[n][m], f[n][m - W[n]] + V[n])
print(f[N][M])
### BUGGY CODE ###

N = int(input())
A = map(int, input().split())

r = 1
for num in A:
  r *= num
  if r == 0:
    break
print(-1 if r > 10 ** 18 else r)


### FIXED CODE ###

def main():
  N = int(input())
  A = list(map(int,input(). split ()))

  if 0 in A:
    print(0)
    return

  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)

main ()
### BUGGY CODE ###

s = str(input())[::-1]
sum_of_digits = 0
cnt = [0] * 2019

cnt[0] = 1
d = 1
for i, c in enumerate(s, start=1):
    sum_of_digits *= 1
    d = 10 ** (i-1)
    #d %= 2019
    sum_of_digits += d * int(c)
    sum_of_digits %= 2019
    cnt[sum_of_digits] += 1
    #print(sum_of_digits)

print(sum([i*(i-1)//2 for i in cnt]))

### FIXED CODE ###

s = str(input())[::-1]
sum_of_digits = 0
cnt = [0] * 2019

cnt[0] = 1
d = 1
for c in s:
    d *= 10
    d %= 2019
    sum_of_digits += d * int(c)
    sum_of_digits %= 2019
    cnt[sum_of_digits] += 1

print(sum([i*(i-1)//2 for i in cnt]))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

# from collections import defaultdict
def dfs(node_i):
    is_visited[node_i] = 1
    for bi in tree[node_i]:
        if is_visited[bi]:
            continue
        tree_x[bi] += tree_x[node_i]
        dfs(bi)

N, Q = map(int, input().split())
tree = [[] for i in range(N)]
# tree = defaultdict(list)
tree_x = [0]*N
is_visited = [0]*N
for i in range(N-1):
    a, b = map(int, input().split())
    am1 = a-1
    bm1 = b-1
    tree[bm1].append(am1)
    tree[am1].append(bm1)

# print(tree)
for q in range(Q):
    p, x = map(int, input().split())
    tree_x[p-1] += x

dfs(0)

print(' '.join(map(str, tree_x)))


### FIXED CODE ###

N, Q = map(int, input().split())
tree = [[] for i in range(N+1)]
counter = [0] * (N+1)

for i in range(N-1):
    a, b = map(int, input().split())
    tree[b].append(a)

for i in range(Q):
    p, x = map(int, input().split())
    counter[p] += x
for i in range(1, N+1):
    for pn in tree[i]:
        counter[i] += counter[pn]

print(' '.join(map(str, counter[1:])))
### BUGGY CODE ###

def main():  
  s = input()
  if len(s) <= 3:
    print(0)
    exit()

  chk = [str((i+1)*2019) for i in range(1000)]
  ans = 0
  for i in range(4,len(s)+1):
    for j in range(len(s)-i+1):
      c = s[j:j+i]
      if c in chk:
        ans += 1
  print(ans)
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
s = input().strip()
if len(s) <= 3:
  print(0)
  exit()
c = 0
chk = [0]*2019
for i,si in enumerate(s[::-1]):
  c += int(si)*pow(10,i,2019)
  chk[c%2019] += 1
ans = chk[0]
for i in chk:
  ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

n = int(input())

p = [ [] for _ in range(n) ]
for i in range(n - 1):
    a, b = map(int, input().split())
    p[a - 1].append(b - 1)
    p[b - 1].append(a - 1)

f = [[0], []]
d = 1

f[1] = f[1] + p[0]

while 1:
    if n - 1 in f[d]:
        break
    temp = []
    for i in f[d]:
        temp = [] + p[i]
    temp = list(set(temp))
    f.append([])
    d += 1
    f[d] = [] + temp

route = [n - 1]
t = n - 1
for i in range(d, 0, -1):
    for j in f[i - 1]:
        if t in p[j]:
            t = j
            route.append(t)

#print(f)
#print(route)

mid = route[ len(route) // 2 - 1 ]

#print(mid)

f = [[0], []]
d = 1

f[1] = f[1] + p[0]

check = 1
if mid in f[1]:
    f[1].remove(mid)
    if len(f[1]) == 0:
        check = 0

while check:
    temp = []
    for i in f[d]:
        temp = [] + p[i]
    temp = list(set(temp))
    if mid in temp:
        temp.remove(mid)
    for i in f[d - 1]:
        if i in temp:
            temp.remove(i)
    if len(temp) == 0:
        break
    f.append([])
    d += 1
    f[d] = [] + temp

fe = sum(len(v) for v in f)

mid = route[ len(route) // 2 ]

f = [[n - 1], []]
d = 1

f[1] = f[1] + p[n - 1]

check = 1
if mid in f[1]:
    f[1].remove(mid)
    if len(f[1]) == 0:
        check = 0

while check:
    temp = []
    for i in f[d]:
        temp = [] + p[i]
    temp = list(set(temp))
    if mid in temp:
        temp.remove(mid)
    for i in f[d - 1]:
        if i in temp:
            temp.remove(i)
    if len(temp) == 0:
        break
    f.append([])
    d += 1
    f[d] = [] + temp

sn = sum(len(v) for v in f)

if fe > sn:
    print("Fennec")
else:
    print("Snuke")

### FIXED CODE ###

n = int(input())

p = [[] for _ in range(n)]
for i in range(n - 1):
    x, y = map(int, input().split())
    p[x - 1].append(y - 1)
    p[y - 1].append(x - 1)

f = [n for _ in range(n)]
s = [n for _ in range(n)]

f[0] = 0
after = [] + p[0]
before = set()
dist = 0
while 1:
    dist += 1
    check = 0
    temp = []
    for x in after:
        if f[x] == n:
            f[x] = dist
            temp += p[x]
            check = 1
    if check == 0:
        break
    t2 = set(temp) - before
    before = set(after)
    after = list(t2)

s[n - 1] = 0
after = [] + p[n - 1]
before = set()
dist = 0
while 1:
    dist += 1
    check = 0
    temp = []
    for x in after:
        if s[x] == n:
            s[x] = dist
            temp += p[x]
            check = 1
    if check == 0:
        break
    t2 = set(temp) - before
    before = set(after)
    after = list(t2)

score_f = 0
for i in range(n):
    if f[i] <= s[i]:
        score_f += 1

if score_f > n - score_f:
    print('Fennec')
else:
    print('Snuke')
### BUGGY CODE ###

n,k = input().split(' ')
n = int(n)
k = int(k)
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
mindiff = 1000000000
for i in range(n-k+1):
    t = h[i:i+k]
    diff = max(t) - min(t)
    if diff < mindiff:
        mindiff = diff
print(mindiff)


### FIXED CODE ###

n,k = input().split(' ')
n = int(n)
k = int(k)
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
diffs = []
for i in range(n-k+1):
    diffs.append(h[i+k-1] - h[i])
print(min(diffs))