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

import sys
input = sys.stdin.readline
from collections import deque
n,m,s,t = [int(i) for i in input().split()]
es = deque([])
der = deque([])
for i in range(m):
  u,v,a,b = [int(i) for i in input().split()]
  es.append((u-1,v-1,a))
  es.append((v-1,u-1,a))
  der.append((u-1,v-1,b))
  der.append((v-1,u-1,b))
  
es = tuple(es)
der = tuple(der)
def shortest_path(S,n,w,es): 
  d = [10**15] * n #d[i] : s→iの最短距離
  d[S] = 0
  while True:
    update = False
    for p,q,r in es: # e: 辺iについて [from,to,cost]
      if d[p] != 10**15 and d[q] > d[p] + r:
        d[q] = d[p] + r
        update = True       
    if not update:
      break
  return d

chk = [0]*(n+1)
ES = tuple(shortest_path(s-1,n,m*2,es))
DER = tuple(shortest_path(t-1,n,m*2,der))
for i in range(n-1,-1,-1):
  chk[i] = max(chk[i+1],10**15-ES[i]-DER[i])
  
chk = tuple(chk)
for i in range(n):
  print(chk[i])

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import deque
n,m,s,t = map(int,input().split())
egg = [[] for i in range(n)]
es = [[] for i in range(n)]
for i in range(m):
  u,v,a,b = map(int,input().split())
  es[u-1].append([a,v-1])
  es[v-1].append([a,u-1]) 
  egg[u-1].append([b,v-1])
  egg[v-1].append([b,u-1]) 

es = tuple(es)
egg = tuple(egg)

import heapq
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**18] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

ES = dijkstra_heap(s-1,es)
EDGE = dijkstra_heap(t-1,egg)
cost = 0
chk = [0]*n
for i in range(n-1,-1,-1):
  cost = max(cost,10**15-ES[i]-EDGE[i])
  chk[i] = cost
chk = tuple(chk)
print(*chk, sep="\n")
### BUGGY CODE ###

a,b=map(int,input().split())
def c(n):
  s=set()
  if n%2==0:
    s.add(2)
    while n%2==0:
      n//=2
  i=1
  while n>1:
    i+=2
    if n%i==0:
      s.add(i)
      while n%i==0:
        n//=i
  return s
s=(c(a)&c(b))
print(len(s)+1)

### FIXED CODE ###

a,b=map(int,input().split())
def p(n):
    a = set([1])
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a
s=p(a)
l=list(s)
for x in l:
  if b%x!=0:
    s.remove(x)
print(len(s))
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,s = LI()
    aa = LI()

    dp = [0] * (s+1)
    dp[0] = 1
    for a in aa:
        np = [0] * (s+1)
        for i in range(s-a,-1,-1):
            np[i+a] = dp[i]
        for i in range(s+1):
            dp[i] *= 2
            dp[i] += np[i]
            dp[i] %= mod2

    return dp[-1]

print(main())





### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,s = LI()
    aa = LI()

    dp = [0] * (s+1)
    dp[0] = 1
    for a in aa:
        np = [0] * (s+1)
        for i in range(s-a,-1,-1):
            np[i+a] = dp[i]
        for i in range(s+1):
            dp[i] *= 2
            dp[i] += np[i]
            dp[i] %= mod2

    return dp[-1]

print(main())
### BUGGY CODE ###

n = int(input())
count = 0

while(n>0):
    count += n%10
    count = count%9
    n = n//10

if(count%9 == 0):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())

if(n%9 == 0):
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

N,Q=map(int,input().split())
S=input()
for i in range(Q):
  n,m=map(int,input().split())
  a=S[n-1:m]
  print(a.count("AC"))

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
L=[0]*N
for i in range(1,N):
  if S[i-1]=="A" and S[i]=="C":
    L[i]=L[i-1]+1
  else:
    L[i]=L[i-1]
for i in range(Q):
  a,b=map(int,input().split())
  print(L[b-1]-L[a-1])
### BUGGY CODE ###

import heapq
import sys

H, W = map(int, input().split())
a = [[] for i in range(10)]
for i in range(10):
	c = [int(i) for i in input().split()]
	for j in range(10):
		a[i].append([c[j], j])
ans = 0
for i in range(H):
	A = [int(i) for i in input().split()]
	for j in A:
		if j == -1:
			continue
		b = [[0, j]]
		c = [False] * 10
		d = [sys.maxsize] * 10
		d[j] = 0
		while len(b):
			e = heapq.heappop(b)
			c[e[1]] = True
			for k in a[e[1]]:
				if c[k[1]]:
					continue
				if d[e[1]] + k[0] < d[k[1]]:
					d[k[1]] = d[e[1]] + k[0]
					heapq.heappush(b, [d[k[1]], k[1]])
		ans += d[1]
print(ans)

### FIXED CODE ###

import heapq
import sys

H, W = map(int, input().split())
c = [[int(j) for j in input().split()] for i in range(10)]
A = [[int(j) for j in input().split()] for i in range(H)]
ans = 0
for i in A:
	for j in i:
		if j == -1:
			continue
		a = [(0, j)]
		b = [False] * 10
		d = [sys.maxsize] * 10
		d[j] = 0
		while len(a):
			e = heapq.heappop(a)
			b[e[1]] = True
			for k in range(len(c[e[1]])):
				if b[k]:
					continue
				if d[e[1]] + c[e[1]][k] < d[k]:
					d[k] = d[e[1]] + c[e[1]][k]
					heapq.heappush(a, (d[k], k))
		ans += d[1]
print(ans)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
	l = list(map(int,input().split()))
	A.append([i-1 for i in l])
match_num = [0 for i in range(N)]
match_dict = {}
idx = 0
for i in range(N-1):
	for j in range(i+1, N):
		match_dict[(i,j)] = idx
		idx += 1
M = idx
edge = [[] for i in range(M)]
parent = [[] for i in range(M)]
for i in range(N):
	for j in range(N-2):
		a = A[i][j]
		a_nxt = A[i][j+1]
		x,y = min(i,a), max(i,a)
		z,w = min(i,a_nxt), max(i,a_nxt)
		m1 = match_dict[(x,y)]
		m2 = match_dict[(z,w)]
		edge[m1].append(m2)
		parent[m2].append(m1)
finish = [False for i in range(M)]
candidate = [(i, 0) for i in range(M) if len(parent[i]) == 0]
longest = 0
while len(candidate) > 0:
	x = candidate.pop()
	c,d = x[0], x[1]
	if d > N*(N-1):
		break
	finish[c] = True
	e = None
	for e in edge[c]:
		x,y = min(c,e), max(c,e)
		dict_idx = x*M + y
		candidate.append((e, d+1))
	if e == None:
		longest = max(longest, d)
all_finished = all(finish)
if all_finished:
	print(longest + 1)
else:
	print(-1)

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
	l = list(map(int,input().split()))
	A.append([i-1 for i in l])
match_num = [0 for i in range(N)]
match_dict = {}
idx = 0
for i in range(N-1):
	for j in range(i+1, N):
		match_dict[(i,j)] = idx
		idx += 1
M = idx
edge = [[] for i in range(M)]
parent = [[] for i in range(M)]
for i in range(N):
	for j in range(N-2):
		a = A[i][j]
		a_nxt = A[i][j+1]
		x,y = min(i,a), max(i,a)
		z,w = min(i,a_nxt), max(i,a_nxt)
		m1 = match_dict[(x,y)]
		m2 = match_dict[(z,w)]
		edge[m1].append(m2)
		parent[m2].append(m1)
finish = [False for i in range(M)]
candidate = [i for i in range(M) if len(parent[i]) == 0]
depth = [-1 for i in range(M)]


day = 0
while len(candidate) > 0:
	new_candidate = []
	for c in candidate:
		finish[c] = True
		for e in edge[c]:
			parent[e].remove(c)
			if len(parent[e]) == 0:
				new_candidate.append(e)
		edge[c] = []
	candidate = new_candidate
	day += 1
print(day if all(finish) else -1)
### BUGGY CODE ###

N,K = map(int, input().split())
A = list(map(int, input().split()))
num = 1
data = []
for j in range(N-K+1):
    for t in range(j, j+K):
        num = num*A[t]
    data.append(num)
    num = 1
num = 1
for i in range(0, N - K):
    if data[num] > data[num - 1]:
        print("Yes")
    elif data[num] <= data[num - 1]:
        print("No")
    num+=1

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-k):
    print("Yes")if a[i]<a[k+i] else print("No")
### BUGGY CODE ###

N = int(input())
S = input()

res = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        if S[i:j] not in S[j:]:
            break
    res = max(res, j - i - 1)

print(res)

### FIXED CODE ###

n = int(input())
s = input()

ans = 0
right = 1

for left in range(n):
    while s[left:right] in s[right:]:
        ans = max(ans,right-left)
        right += 1
        
print(ans)
### BUGGY CODE ###

k,s=map(int,input().split())
cnt=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                cnt+=1
print(cnt)

### FIXED CODE ###

k,s=map(int,input().split())
print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import deque
from heapq import heapify, heappush as hpush, heappop as hpop
N, M, L = map(int, input().split())
X = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    X[a-1].append([b-1, c])
    X[b-1].append([a-1, c])

def dijkstra(n, E, i0=0):
    h = [[0, i0]]
    D = [-1] * n
    done = [0] * n
    D[i0] = 0
    
    while h:
        d, i = hpop(h)
        done[i] = 1
        for j, w in E[i]:
            nd = d + w
            if D[j] < 0 or D[j] >= nd:
                if done[j] == 0:
                    hpush(h, [nd, j])
                    D[j] = nd
    return D
def BFS(n, E, i0=0):
    Q = deque([i0])
    D = [-1] * n
    D[i0] = 0
    while Q:
        x = Q.popleft()
        for c in E[x]:
            if D[c] == -1:
                D[c] = D[x] + 1
                Q.append(c)
    return D

Y = [[] for _ in range(N)]
for i in range(N):
    D1 = dijkstra(N, X, i)
    for j in range(N):
        if i == j: continue
        if 0 <= D1[j] <= L:
            Y[i].append(j)

# print("X =", X)
# print("Y =", Y)
D2 = []
for i in range(N):
    D2.append(BFS(N, Y, i))

ans = []
for _ in range(int(input())):
    s, t = map(int, input().split())
    a = D2[s-1][t-1]-1
    ans.append(str(a if a >= 0 else -1))

print("\n".join(ans))

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from collections import deque
N, M, L = map(int, input().split())
D = [[1<<40] * N for _ in range(N)]
for i in range(N):
    D[i][i] = 0
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    D[a][b] = c
    D[b][a] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            D[i][j] = min(D[i][j], D[i][k] + D[k][j])
Y = [[] for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j: continue
        if D[i][j] <= L:
            Y[i].append(j)
def BFS(n, E, i0=0):
    Q = deque([i0])
    D = [-1] * n
    D[i0] = 0
    while Q:
        x = Q.popleft()
        for c in E[x]:
            if D[c] == -1:
                D[c] = D[x] + 1
                Q.append(c)
    return D
D2 = []
for i in range(N):
    D2.append(BFS(N, Y, i))

ans = []
for _ in range(int(input())):
    s, t = map(int, input().split())
    a = D2[s-1][t-1]-1
    ans.append(str(a if a >= 0 else -1))
print("\n".join(ans))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
a=1
exist=[]
for i in range(N):
  if A[i] in exist:
    a=0
    print("NO")
    break
  else:
    exist+=[A[i]]
if a==1:
  print("YES")
 

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort()
a=0
for i in range(N-1):
  if A[i]==A[i+1]:
    print("NO")
    a=1
    break
if a==0:
  print("YES")
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ok = [0]*(max(a)+1)
a.sort()

for i in range(n):
    ok[a[i]] += 1
    if ok[a[i]] == 1:
        for g in range(a[i], max(a)+1, a[i]):
            if g != a[i]:
                ok[g] += 2


print(ok.count(1))


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
M = max(a)
ok = [0]*(M+1)
a.sort()

for i in range(n):
    ok[a[i]] += 1
    if ok[a[i]] == 1:
        for g in range(a[i], M+1, a[i]):
            if g != a[i]:
                ok[g] += 2


print(ok.count(1))
### BUGGY CODE ###

# match matching
import bisect
import sys
input = sys.stdin.readline
compare = [10**i for i in range(5*10**3+1)]
N, M = map(int, input().split())
ok = list(map(int, input().split()))
a = [i for i in range(1, 10)]
b = [2, 5, 5, 4, 5, 6, 3, 7, 6]
data = {a[i]: b[i] for i in range(9)}
how = {i: [] for i in range(2, 8)}
for n in ok:
    how[data[n]].append(n)
new = []
for i in range(2, 8):
    if len(how[i]) > 0:
        new.append(max(how[i]))
new.sort()
ok = new
dp = [[0 for i in range(N+1)] for j in range(M+1)]


def find(X):
    return bisect.bisect_right(compare, X)


for i in range(M):
    for cnt in range(N+1):
        for num in ok[:i+1]:
            cost = data[num]
            if cnt > cost:
                K = dp[i+1][cnt-cost]
                if K > 0:
                    dp[i+1][cnt] = max(K + num*10 ** find(K), dp[i+1][cnt])
                    continue
                else:
                    dp[i+1][cnt] = max(K, dp[i+1][cnt])
                    continue
            elif cnt == cost:
                dp[i+1][cnt] = max(num, dp[i+1][cnt])
                continue
            else:
                dp[i+1][cnt] = max(dp[i][cnt], dp[i+1][cnt])
                continue
ans = dp[M][N]
print(ans)


### FIXED CODE ###

matches = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

n, m = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort(reverse=True)

dp = [-1 for _ in range(n + 1)]
dp[0] = 0
for a in alist:
    match = matches[a]
    for i in range(n - match + 1):
        if dp[i] == -1: continue
        dp[i + match] = max(dp[i + match], dp[i] * 10 + a)

print(dp[-1])
### BUGGY CODE ###

n = int(input())
P = [int(x) for x in input().split()]

counter = 1
for i in range(1,n):
    if any( x< P[i] for x in  P[0:i] ):
        pass
    else:
        counter +=1

print(counter)

### FIXED CODE ###

n = int(input())
P = list(map(int, input().split()))

minimum = float('inf')
ans = 0
for p in P:
    if p <=minimum:
        minimum = p
        ans += 1
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
N,Q=map(int, input().split())
tree_dist={}
for i in range(N):
    tree_dist[i+1] = []
for i in range(N-1):
    a,b = map(int, input().split())
    tree_dist[a].append(b)
    tree_dist[b].append(a)
    
z=[0]*N
for i in range(Q):
    p,x = map(int, input().split())
    z[p-1] += x

def saiki(i,p):
    L = list(tree_dist[i])
    for l in L:
        if l != p:
            z[l-1] += z[i-1]
            saiki(l,i)
saiki(1,0)
print(" ".join(map(str,z)))




### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
input=lambda :sys.stdin.readline()
N,Q=map(int, input().split())
tree_dist={}
for i in range(N):
    tree_dist[i+1] = []
for i in range(N-1):
    a,b = map(int, input().split())
    tree_dist[a].append(b)
    tree_dist[b].append(a)
    
z=[0]*N
for i in range(Q):
    p,x = map(int, input().split())
    z[p-1] += x

def saiki(i,p):
    L = list(tree_dist[i])
    for l in L:
        if l != p:
            z[l-1] += z[i-1]
            saiki(l,i)
saiki(1,0)
print(" ".join(map(str,z)))
### BUGGY CODE ###

# 2 6=>4 (1,6)*2,(2,3)*2
# 3 12=>18 (1,1,12)*3,(1,2,6)*6,(1,3,4)*6,(2,2,3)*3
import math
def comb(a,b): # aCb
    return math.factorial(a)//math.factorial(a-b)//math.factorial(b)

n,m=map(int,input().split())
divisor={}
tmp=m
for i in range(2,m+1):
    while tmp%i==0:
        tmp//=i
        divisor.setdefault(i,0)
        divisor[i]+=1
    if tmp==1:
        break
# print(divisor)
cnt=1
for key in divisor:
    c=divisor[key]
    cnt*=comb(c+n-1,c)
print(cnt%1000000007)


### FIXED CODE ###

# うまく効率化できなかった
# 2 6=>4 (1,6)*2,(2,3)*2
# 3 12=>18 (1,1,12)*3,(1,2,6)*6,(1,3,4)*6,(2,2,3)*3
# import math
# def comb(a,b):
#     return math.factorial(a)//math.factorial(a-b)//math.factorial(b)
def comb(a,b): # aCb
    b=min(b,a-b)
    result=1
    for i in range(a,a-b,-1):
        result*=i
    for i in range(1,b+1):
        result//=i
    return result

n,m=map(int,input().split())
divisor={}
tmp=m
# for i in range(2,m+1):
#     while tmp%i==0:
#         tmp//=i
#         divisor.setdefault(i,0)
#         divisor[i]+=1
#         if tmp==1:
#             break
i=2
while i*i<=m:
    while tmp%i==0:
        tmp//=i
        divisor.setdefault(i,0)
        divisor[i]+=1
    i+=1
if tmp>1:
    divisor[tmp]=1
# print(divisor)
cnt=1
for key in divisor:
    c=divisor[key]
    cnt*=comb(c+n-1,c)
print(cnt%1000000007)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
idx = A[0]
move = []
move.append(idx)
cycle = []
for _ in range(K-1):
  idx = A[idx-1]
  if idx in move:
    cycle = move[move.index(idx):]
    break
  move.append(idx)

if cycle:
  print(cycle[(K - 1- (len(move)-len(cycle)))%len(cycle)])
else:
  print(move[K-1])


### FIXED CODE ###

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

R = [False]*(N+1)
D = []
p = 1
while True:
    if R[p]:
        break
    D.append(p)
    R[p] = True
    p = A[p-1]
m = D.index(p)
c = len(D)-m

if K <= m:
    print(D[K])
else:
    print(D[m+(K-m) % c])
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]

b = set(a)
c = []
for i in b:
  c.append([i, a.count(i)])

t = []
m = len(c)
for j in range(m):
  total = c[j][1]
  
  if c[j][0]-1 in b:
    total += c[j-1][1]
  
  if c[j][0]+1 in b:
    total += c[j+1][1]

  t.append(total)

print(max(t))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = [0] * (int(1e5)+5)
for i in range(n):
    ans[a[i]-1] += 1
    ans[a[i]] += 1
    ans[a[i]+1] += 1
print(max(ans))
### BUGGY CODE ###


n = int(input())
s = []
a = []
mx = 0
b = []
c = []
d = []

for i in range(n):
    s.append(input())

a = set(s)
a = list(a)

for j in range(len(a)):
    b.append(s.count(a[j]))

mx = max(b)
#print(b)

for k in range(len(b)):
    if b[k] == mx:
        c.append(k)
for l in range(len(c)):
    d.append(a[c[l]])
d.sort()

for i in range(len(d)):
    print(d[i])


### FIXED CODE ###


n = int(input())
s = [input() for i in range(n)]

d = {}
for st in s:
    d[st] = d.get(st, 0) + 1
#print(d)

t = max(d.values())
ans = []
for p in d:
    if d[p] == t:
        ans.append(p)
#print(ans)

ans.sort()
print("\n".join(ans))
### BUGGY CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    sum = 0

    for i in range(len(A)):
        for j in range(i+1, len(A)):
            sum += A[i] * A[j]
    
    ans = sum % MOD
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    MOD = 10 ** 9 + 7
    
    sum_a = sum(A)
    sum_squares = sum([a * a for a in A])
    
    ans = (sum_a ** 2 - sum_squares) // 2
    ans %= MOD

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

a, b = map(int, input().split())
table = list(map(int, input().split()))
table.sort(reverse=True)
if b < len(table):
    for x in range(0, b):
        table.pop(0)
    print(sum(table))
else:
    print(0)

### FIXED CODE ###

a, b = map(int, input().split())
table = list(map(int, input().split()))
table.sort(reverse=True)
if b < len(table):
    del table[0:b]
    print(sum(table))
else:
    print(0)
### BUGGY CODE ###

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

h = []
for i in range(n):
    h.append(int(input()))
st,ed = 0,10**9+1
hc = [0]*n
while st<ed-1:
    mid = (st+ed)//2
    #print(mid)
    tmp = 0
    for i in range(n):
        hc[i]=h[i]-mid*b
    for i in range(n):
        if hc[i]>0:
            tmp+=(hc[i]//(a-b))+(hc[i]%(a-b)>0)
    if tmp<=mid:
        ed = mid
    else:
        st = mid
print(ed) 


### FIXED CODE ###

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

h = []
for i in range(n):
    h.append(int(input()))
st,ed = 0,10**9+1
while st<ed-1:
    mid = (st+ed)//2
    #print(mid)
    tmp = 0
    for i in range(n):
        x = h[i]-mid*b
        if x>0:
            tmp+=(x//(a-b))+(x%(a-b)>0)
    if tmp<=mid:
        ed = mid
    else:
        st = mid
print(ed)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from collections import deque
N=int(input())

graph=[[] for _ in range(N+1)]
for _ in range(N-1):
  a,b=map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
#print(graph)

def dfs_init(u,ls):
  global path
  visited[u]=True  
  if u==N:
    path=ls
    return
  
  for v in graph[u]:
    if not visited[v]:
      dfs_init(v,ls+[v])
  
path=[]  
visited=[False]*(N+1)
dfs_init(1,[1])
#print(path)

visited=[False]*(N+1)
set_f=set()
set_s=set()
turn=1
dq=deque(path)
while dq:
  #Fenec
  node_f=dq.popleft()
  visited[node_f]=True
  set_f.add(node_f)
  turn=-1
  
  if dq:
    #Snuke
    node_s=dq.pop()
    visited[node_s]=True
    set_s.add(node_s)
    turn=1
#print(set_f,set_s,visited,turn)

def dfs_fenec(u):
  global cnt_f
  if not visited[u]:
    visited[u]=True
    cnt_f+=1
  for v in graph[u]:
    if not visited[v]:
      dfs_fenec(v)

def dfs_snuke(u):
  global cnt_s
  if not visited[u]:
    visited[u]=True
    cnt_s+=1
  for v in graph[u]:
    if not visited[v]:
      dfs_snuke(v)
      
#fenec
cnt_f=0
for f in set_f:
  dfs_fenec(f)
  
#snuke
cnt_s=0
for s in set_s:
  dfs_snuke(s)
  
#print(cnt_f,cnt_s)
if turn==1:
  if cnt_f>cnt_s:
    print("Fennec")
  else:
    print("Snuke")
elif turn==-1:
  if cnt_f>=cnt_s:
    print("Fennec")
  else:
    print("Snuke")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from collections import deque
N=int(input())

graph=[[] for _ in range(N+1)]
for _ in range(N-1):
  a,b=map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
#print(graph)

dist_f=[-1]*(N+1)
d=0
queue=[1]
while queue:  
  new_queue=set()
  for u in queue:
    dist_f[u]=d
    for v in graph[u]:
      if dist_f[v]==-1:
        new_queue.add(v)
        
  queue=list(new_queue)
  d+=1
#print(dist_f)

dist_s=[-1]*(N+1)
d=0
queue=[N]
while queue:  
  new_queue=set()
  for u in queue:
    dist_s[u]=d
    for v in graph[u]:
      if dist_s[v]==-1:
        new_queue.add(v)
        
  queue=list(new_queue)
  d+=1
#print(dist_s)

cnt_f,cnt_s=0,0
for i in range(1,N+1):
  if dist_f[i]<=dist_s[i]:
    cnt_f+=1
  else:
    cnt_s+=1

#print(cnt_f,cnt_s)
if cnt_f>cnt_s:
  print("Fennec")
else:
  print("Snuke")