Harryxun/stf_run huggingface dataset:
n = int(input())
a = sorted([int(i) for i in input().split()])

if a[0] <= 0 and 0 < a[-1]:
    import bisect
    print(sum(map(lambda x: abs(x), a)))
    x0 = bisect.bisect_left(a,0)

    # 0以下から正をひいていく（一番大きいものを除く）
    print("{} {}".format(a[0], a[x0-1]))
    res = a[0] - a[x0+1]

    for x in a[x0+1:-2]:
        print("{} {}".format(res, x))
        res -= x

    # 一番大きいものから上のものと負の数を引いていく
    print("{} {}".format(a[-1], res))
    res = a[-1] - res
    for x in a[1:x0]:
        print("{} {}".format(res,x))
        res -= x

elif a[0] > 0:
    print(sum(a) - 2*a[0])

    print("{} {}".format(a[0],a[1]))
    res = a[0] - a[1]
    for x in a[2:-2]:
        print("{} {}".format(res, x))
        res -= x
    
    print("{} {}".format(a[-1], res))
else:
    print(-sum(a) + 2*a[-1])

    print("{} {}".format(a[-1],a[-2]))
    res = a[-1] - a[-2]
    for x in a[:-2]:
        print("{} {}".format(res, x))
        res -= x
    

### FIXED CODE ###

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

if n == 2:
    print(a[1] - a[0])
    print("{} {}".format(a[1], a[0]))
    exit()

if a[0] <= 0 and 0 <= a[-1]:
    import bisect
    print(sum(map(lambda x: abs(x), a)))
    x0 = bisect.bisect_left(a,0)

    # 0以下から0以上をひいていく（一番大きいものを除く）
    if a[-2] >= 0:
        if x0 == 0:
            x0 += 1
        print("{} {}".format(a[0], a[x0]))
        res = a[0] - a[x0]

        for x in a[x0+1:-1]:
            print("{} {}".format(res, x))
            res -= x
    else:
        res = a[0]

    # 一番大きいものから上のものと負の数を引いていく
    print("{} {}".format(a[-1], res))
    res = a[-1] - res
    for x in a[1:x0]:
        print("{} {}".format(res,x))
        res -= x

elif a[0] > 0:
    print(sum(a) - 2*a[0])

    print("{} {}".format(a[0],a[1]))
    res = a[0] - a[1]
    for x in a[2:-1]:
        print("{} {}".format(res, x))
        res -= x
    
    print("{} {}".format(a[-1], res))
else:
    print(-sum(a) + 2*a[-1])

    print("{} {}".format(a[-1],a[-2]))
    res = a[-1] - a[-2]
    for x in a[:-2]:
        print("{} {}".format(res, x))
        res -= x
n=int(input())
l=sort(map(int,input().split()))
print(["No","Yes"][l[-1]>=sum(l)-l[-1]])

### FIXED CODE ###

n=int(input())
l=sorted(map(int,input().split()))
print(["No","Yes"][l[-1]<sum(l)-l[-1]])
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7

import sys
sys.setrecursionlimit(100000)

dp = [0] * (n+1) 
dp[0] = 1
def dps(cnt,cantvisit):
    if cnt == n + 1 :
        return 
    else :
        if cnt == 1 :
            if cnt in cantvisit :
                dp[cnt] = 0
                cnt +=1
            else : 
                dp[cnt] = 1
                cnt += 1
        else :
            if cnt in cantvisit : 
                dp[cnt] = 0 
                cnt += 1
            else :
                dp[cnt] = (dp[cnt-1] + dp[cnt-2])%mod
                cnt += 1
    return dps(cnt,cantvisit)
dps(1,para)
print("{}".format(dp[-1]))

### FIXED CODE ###

n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7
dp = [-1]*(n+1)
for i in para:
    dp[i] = 0
for i in range(n+1):
    if  dp[i] != 0 :
        if i == 1 or i==0:
            dp[i] = 1
        else:
            dp[i] = (dp[i-1] + dp[i-2])%mod



print("{}".format(dp[-1]))
N = int(input())

import collections
l = []
for n in range(N):
  S = input()
  l.append(S)

c = collections.Counter(l)


print("AC x " + c['AC'])
print("WA x " + c['WA'])
print("TLE x " + c['TLE'])
print("RE x " + c['RE'])

### FIXED CODE ###

N = int(input())

import collections
l = []
for n in range(N):
  S = input()
  l.append(S)

c = collections.Counter(l)


print("AC x " + str(c['AC']))
print("WA x " + str(c['WA']))
print("TLE x " + str(c['TLE']))
print("RE x " + str(c['RE']))
/usr/local/bin/python3.8 /Users/tmohiro/Desktop/Atcoder/ABC163/B.py
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
9

Process finished with exit code 0


### FIXED CODE ###

n, m = map(int, input().split())
A = list(map(int, input().split()))

total = sum(A)
if total > n:
    print(-1)
else:
    print(n-total)
while 1:
	a=map(str,raw_input().replace("  "," A ").split())
	if a==["END"]:break
	print "".join(map(str,[len(a[i]) for i in range(len(a))]))

### FIXED CODE ###

while 1:
    m=raw_input()
    if m=="END OF INPUT":break
    print "".join(str(len(w)) for w in m.split(" "))
from collections import Counter

N = int(input())
s = [0]*(N-1)
for i in range(N-1):
    #s[i] = ''.join(sorted(list(input())))
    s[i] = int(input())

ct = Counter(s)

for i in range(1,N):
    if i in ct.keys():
        print(ct[i])
    else:
        print(0)
print(0)


### FIXED CODE ###

import collections

N = int(input())
s = list(map(int, input().split()))

ct = collections.Counter(s)

for i in range(N):
    print(ct[i+1])
N = int(input())
S = input("")
result = str()
size = len(S)
for i in range(size):
    if i + N < size:
        result += S[i + N]
    else:
        result += S[i + N - size]
print(result

### FIXED CODE ###

alph_list= ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
N = int(input())
S = input("")
ans = str()
for i in range(len(S)):
    t = alph_list.index(S[i]) + N
    if t < len(alph_list):
        ans += alph_list[t]
    else:
        ans += alph_list[t - len(alph_list)]
print(ans)
str = input()
n = str / 111

print(n*111)

### FIXED CODE ###

input_line = input()
n = int(int(input_line) / 111)
if int(input_line) % 111 == 0:
  print(n *111)
else:
  print(111 + n *111)
import sys
sys.setrecursionlimit(10*5)

N,u,v=map(int,input().split())

du,dv=[0]*-~N,[0]*-~N
T=[list() for i in range(-~N)]

def dsf(p,t,v,d):
  d[v]=t
  for i in T[v]:
    if i!=p:
      dsf(v,t+1,i,d)

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

dsf(0,0,u,du)
dsf(0,0,v,dv)

if du[v]==1 and len(T[v])==1:
  print(0)
else:
  m=0
  for i in range(1,~-N):
    if du[i] < dv[i]:
      if m<du[i]:
        v,m=i,du[i]

  if m!=0:
    print(du[v]+(m if m%2 else m-1))
  else:
    m=N+1
    for i in range(1,~-N):
      if du[i]==dv[i]:
        m=min(m,du[i])
    print(m)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
N,u,v=map(int,input().split())

du,dv=[0]*-~N,[0]*-~N
T=[list() for i in range(-~N)]

def dfs(p,t,v,d):
  d[v]=t
  for i in T[v]:
    if i!=p:
      dfs(v,t+1,i,d)

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

dfs(0,0,u,du)
dfs(0,0,v,dv)

c=0
for i in range(1,-~N):
  if len(T[i])==1 and i!=v:
    if du[i]<dv[i]:
      c=max(c,~-dv[i])

print(c)
n=int(input())
k=int(input())
ans=0
for _ in map(int,input().split()):
  a=int(input())
  ans+=min(a,k-a)
print(ans+ans)

### FIXED CODE ###

n=int(input())
k=int(input())
ans=0
for a in map(int,input().split()):
  ans+=min(a,k-a)
print(ans+ans)
a,b,c=(int(i) for i in input().split())
t=[a,b,c].sort()
print(t[0]*t[1]/2)

### FIXED CODE ###

a,b,c=(int(i) for i in input().split())
t=sorted([a,b,c])
print(int(t[0]*t[1]/2))
n = int(input())
t = 0
st = 0
cn = []
sn = []
fn = []

for i in range(n-1):
  c,s,f = map(int,input().split())
  cn.append(c)
  sn.append(s)
  fn.append(f)

for j in range(n-1):
    t = 0
    for i in range(j,n-1):
      st = sn[i]
      if t <= sn[i]:
        t = sn[i]
      if t%fn[i] != 0:
          t += fn[i]-t%fn[i]
      t += cn[i]
    print(t)


print(0)

### FIXED CODE ###

t = int(input())

print(24+24-t)
n = str(input())
sum = 0
for i in range(len(n)):
    sum += int(n[i])
if n%sum=0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = str(input())
sum = 0
for i in range(len(n)):
    sum += int(n[i])
if int(n)%sum==0:
    print('Yes')
else:
    print('No')
s,w = int(input()),int(input())

if s <= w:
    print("unsafe")

else:
    print("safe")


### FIXED CODE ###

data = []
while len(data) < 2:
    val = input()
    data = data + val.split(" ")
    #print(data)

for i,val in enumerate(data):
    data[i] = int(val)

s,w = data[0],data[1]

if s <= w:
    print("unsafe")

else:
    print("safe")
A = input()
#高さ、面積,位置
st = [(0, 0, -1)]
#高さ、高さの最高値？
cur = 0; ma = 0
for i, a in enumerate(A):
    if a == '/':
        cur += 1
        s = 0
        while st and st[-1][0] == cur-1 and cur <= ma:
            lev, su, j = st.pop()
            s += su
        if st and st[-1][0] == cur:
            s += i - st[-1][2] - 1
        ma = max(ma, cur)
        st.append(cur, s, i)
    elif a == '\\':
        cur -= 1
        st.append((cur, 0, i))
    elif c == '_':
        st.append((cur, 0, i))
ans = []
for lev, su, j in st:
    if su > 0:
        and.append(su)
print(sum(ans))
print(len(ans), *ans)


### FIXED CODE ###

A = input()
st = [(0, 0, -1)]
cur = 0; ma = 0
for i, a in enumerate(A):
    if a == '/':
        cur += 1
        s = 0
        while st and st[-1][0] == cur-1 and cur <= ma:
            lev, su, j = st.pop()
            s += su
        if st and st[-1][0] == cur:
            s += i - st[-1][2] - 1
        ma = max(ma, cur)
        st.append((cur, s, i))
    elif a == '\\':
        cur -= 1
        st.append((cur, 0, i))
    elif a == '_':
        st.append((cur, 0, i))
ans = []
for lev, su, j in st:
    if su > 0:
        ans.append(su)
print(sum(ans))
print(len(ans), *ans)
a,b = input().split()
s = a * b
shu = a * 2 + b * 2
fmt = "{s} {shu}"
s = fmt.format(s = s,shu = shu)
print(s)

### FIXED CODE ###

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

s = a * b
shu = a * 2 + b * 2
fmt = "{s} {shu}"
s = fmt.format(s = s,shu = shu)
print(s)
import sys
input = sys.stdin.readline()
S = list(input())
N = len(S)

def solver(n,m,idx):
    if (n-m)%2 == 0:
        ans[idx[0]] = (n+m)//2
        ans[idx[1]] = (n+m)//2
    else:
        if m%2 == 1:
            ans[idx[1]] = (n+m)//2 + 1
            ans[idx[0]] = (n+m)//2
        else:
            ans[idx[0]] = (n+m)//2 + 1
            ans[idx[1]] = (n+m)//2
    return    
    
    
        
        
ans = [0] * N
m = 0
n = 0
flagL = False
idx = []
for i,s in enumerate(S):
    if s == 'R':
        if flagL:
            solver(n,m,idx)
            n = 0
            m = 0
            flagL = False
        n += 1
    elif s == 'L':
        if not flagL:
            flagL = True
            idx = [i-1,i]
        m += 1 
solver(n,m,idx)
    
print(*ans,sep = ' ')

### FIXED CODE ###

#import sys
#input = sys.stdin.readline
S = list(input())
N = len(S)

def solver(n,m,idx):
    if (n-m)%2 == 0:
        ans[idx[0]] = (n+m)//2
        ans[idx[1]] = (n+m)//2
    else:
        if m%2 == 1:
            ans[idx[1]] = (n+m)//2 + 1
            ans[idx[0]] = (n+m)//2
        else:
            ans[idx[0]] = (n+m)//2 + 1
            ans[idx[1]] = (n+m)//2
    return    
    
    
        
        
ans = [0] * N
m = 0
n = 0
flagL = False
idx = []
for i,s in enumerate(S):
    if s == 'R':
        if flagL:
            solver(n,m,idx)
            n = 0
            m = 0
            flagL = False
        n += 1
    elif s == 'L':
        if not flagL:
            flagL = True
            idx = [i-1,i]
        m += 1 
solver(n,m,idx)
    
print(*ans,sep = ' ')
N = int(input())
print(sum(list(range(1,N))))

### FIXED CODE ###

N = int(input())
if N == 1:
    print(0)
elif N%2 != 0:
    print((1+(N-1))*((N-1)//2))
else:
    print((1+(N-1))*((N-1)//2)+(N-1)//2+1)
item_list = [0]*100
cnt = 0
a = map(int, input().split())
for i in a:
    if not item_list[i]:
        item_list[i] = 1
        cnt += 1
print(cnt)

### FIXED CODE ###

item_list = [0]*101
cnt = 0
a = map(int, input().split())
for i in a:
    if not item_list[i]:
        item_list[i] = 1
        cnt += 1
print(cnt)
X,Y = map(int,input().split())

if X > Y:
    print('>')
elif x == Y:
    print('=')
else:
    print('<')

### FIXED CODE ###

X,Y = map(str,input().split())

a = ['A','B','C','D','E','F']
b = [10,11,12,13,14,15]

if a.index(X) > a.index(Y):
    print('>')
elif X == Y:
    print('=')
else:
    print('<')
# coding=utf-8
# a,b = map(int, raw_input().split())

x,a,b = map(int, input().split())
if abs(x-a) < abs(x-b):
    print('A')
else :
    print('B')

### FIXED CODE ###

x,a,b = map(int, input().split())
if abs(x-a) < abs(x-b):
    print('A')
else :
    print('B')
from functools import lru_cache

H, W, D = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(H)]
aToHW = {}
for h, row in enumerate(A):
    for w, a in enumerate(row):
        aToHW[a] = (h, w)

Q = int(input())

@lru_cache(maxsize=None)
def search(now):
    if not now + D in aToHW:
        return 0

    l, r = aToHW[now], aToHW[now + D]
    return abs(l[0] - r[0]) + abs(l[1] - r[1]) + search(now + D)

ans = []
for _ in range(Q):
    l, r = map(int, input().split())

    ans.append(search(l) - search(r))

print(*ans, sep='\n')


### FIXED CODE ###

H, W, D = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(H)]

aToHW = {}
for h in range(H):
    for w, a in enumerate(A[h]):
        aToHW[a] = (h, w)

cnt = [-1] * (H * W + 1)
for start in range(1, H * W + 1)[:: -1]:
    c = 0
    for now in range(start, H * W + 1, D):
        if now + D > H * W:
            break
        if cnt[now] >= 0:
            c += cnt[now]
            break

        nH, nW = aToHW[now]
        tH, tW = aToHW[now + D]
        c += abs(nH - tH) + abs(nW - tW)
    cnt[start] = c

Q = int(input())
ans = []
for _ in range(Q):
    L, R = map(int, input().split())
    ans.append(cnt[L] - cnt[R])

print(*ans, sep='\n')
s = input()
num = len(s)

dp = [0]*num
temp = [0]*2019
for i in range(num):
    temp[int(s[i:]) % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

### FIXED CODE ###

s,w = map(int,input().split())
if s <= w:
    print("unsafe")
else:
    print("safe")
a, b = map(int,input().split())

if a >= 13:
  print(b)
  
else if a >= 6:
  b /= 2
  print(b)
  
else print(0)

### FIXED CODE ###

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

if a >= 13:
  print(b)
  
elif a >= 6:
  b //= 2
  print(b)
  
else:
  print(0)
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: str(sys.stdin.buffer.readline().rstrip())
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
a = [ri() for _ in range(n)]
for i in range(n):
  print(max(max(a[0: i]), max(a[i+1: n])))

### FIXED CODE ###

import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: str(sys.stdin.buffer.readline().rstrip())
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
aa = [ri() for _ in range(n)]
a = sorted(aa)
m = a[-1]
if m == a[-2]:
    for _ in range(n):
        print(m)
else:
    for i in aa:
        if i < m:
            print(m)
            continue
        else:
            print(a[-2])
X, N = map(int, input().split())
P = set(list(map(int, input().split())))

targets = set(range(1, 101)) - P
print(min([(target, abs(X - target)) for target in targets], key=lambda x: x[1])[0])


### FIXED CODE ###

X, N = map(int, input().split())
P = set(list(map(int, input().split())))

targets = set(range(-101, 102)) - P
if targets:
    print(min([(target, abs(X - target)) for target in targets], key=lambda x: x[1])[0])
else:
    print(X)
a, b, c, k = map(int, input().split())
ans = 0
if k <= a:
    print(k)
else:
    k -= a
    ans += a
    if k <= b:
        print(ans)
    else:
        k -= b
        ans += -1 * k
        print(ans)


### FIXED CODE ###

s = input()
t = input()
n = len(s)
a = [i for i in t]
if s == "".join(a[:n]):
    print("Yes")
else:
    print("No")
K,X = map(int,input().split())
A = []
for i in range(X-(K-1),X+(K-1)+1):
  A.append(i)
print(" ".join(A))

### FIXED CODE ###

K,X = map(int,input().split())
A = []
for i in range(X-(K-1),X+(K-1)+1):
  A.append(i)
print(*A)
N = int(input())
S = input()
K = int(input())

kc = S[K]
ans = ''
for c in S:
  if c != kc:
    ans += '*'
  else:
    ans += c

print(ans)

### FIXED CODE ###

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

kc = S[K - 1]
ans = ''
for c in S:
  if c != kc:
    ans += '*'
  else:
    ans += c

print(ans)
N = int(input())
S = input()

if N % 2 == 1:
    print("No")
    exit()

if S[0:N/2] == S[N/2:]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

if N % 2 == 1:
    print("No")
    exit()

if S[0:int(N/2)] == S[int(N/2):]:
    print("Yes")
else:
    print("No")
def main():

    a = input()
    b = input()
    c = input()

    def LCS(S, T):
        dp = [[0 for _ in range(len(S) + 1)] for _ in range(len(T) + 1)]
        for i in range(len(S)):
            for j in range(len(T)):
                if S[i] == "?" or T[j] == "?" or S[i] == T[j]:
                    dp[i+1][j+1] = dp[i][j] + 1
                else:
                    dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

        return dp[len(S)][len(T)]

    ans = 0

    ab = LCS(a,b)

    ac = LCS(a,c)

    bc = LCS(b,c)


    if ab == ac == bc == 0:
        print(len(a) + len(b) + len(c))
        exit()

    if ac <= ab and ac <= bc:
        ans = (len(a) + len(b) - ab) + (len(c) - bc) 

    elif ab <= ac and ab <= bc:
        ans = (len(a) + len(c) - ac) + (len(c) - bc) 

    elif bc <= ab and bc <= ac:
        ans = (len(a) + len(b) - ab) + (len(c) - ac)

    print(ans) 


if __name__ == "__main__":
    main()
        

### FIXED CODE ###


A = input()
B = input()
C = input()

def match(c1, c2):
    return c1 == "?" or c2 == "?" or c1 == c2

la = len(A)
lb  =len(B)
lc = len(C)

ml = max(la, lb, lc)

# 。a の左端の位置を 0 としたとき、他の文字列の左端の位置は −4000 から 4000 まで動く可能性があることに注意してください  より、４倍
ab = [False for _ in range(ml * 4 + 1)]
ac = [False for _ in range(ml * 4 + 1)]
bc = [False for _ in range(ml * 4 + 1)]

"""
下の２重forで(i,j) = (0,0)と(1,1)で配列のindexが同じになってしまうが、AとBの０文字目どうし、1文字目どうしを比べるのは、
同じところから先頭が始まっている場合なので、あるずれの配置について、全文字比較していることになる
i=0,j=2とかだとBのほうが左にある場合で、i=3,j=0だとAが左にある場合

ab[i - j]のindexに+2mlして、-2ml ~ 2ml 感を出したい気持ちがあるが、意味がないのでしない
"""


def main():

    for i in range(la):
        for j in range(lb):
            # すでにそのずらし方で文字が重ねられないことが分かっている場合はスキップ
            if ab[i - j]:
                continue
            # そのずらし方で重ねられない場合はTrue
            if not match(A[i], B[j]):
                ab[i - j] = True


    for i in range(la):
        for j in range(lc):
            # すでにそのずらし方で文字が重ねられないことが分かっている場合はスキップ
            if ac[i - j]:
                continue
            # そのずらし方で重ねられない場合はTrue
            if not match(A[i], C[j]):
                ac[i - j] = True

    for i in range(lb):
        for j in range(lc):
            # すでにそのずらし方で文字が重ねられないことが分かっている場合はスキップ
            if bc[i - j]:
                continue
            # そのずらし方で重ねられない場合はTrue
            if not match(B[i], C[j]):
                bc[i - j] = True       

    ans = la + lb + lc
    # BCAとかACBみたいにAの前後に並ぶ場合があるので、AとBの位置関係について±2*ml分探索（Aの頭が０の位置にあるとしてBをどこに置くか(それがi)ということ。）
    for i in range(-2*ml, 2*ml+1):
        # a,bについて、あるずらし方で重ねられない場合は飛ばす
        if ab[i]:
            continue
        # CBA,ABCのパターンがあるので～
        for j in range(-2*ml, 2*ml+1):
            if ac[j]:
                continue
            
            # ここでi,jはaの頭をindexの0としたときの位置にあたるので、B基準で見たときのCとの位置関係はj - iとなる
            # で、そのとき重ねられないならスキップ
            if bc[j - i]:
                continue

            # 文字列Sの左端のindex
            l = min(0, i, j)
            # 文字列Sの右端のindex
            r = max(0 + la, i + lb, j + lc)
            ans = min(ans, r - l)

    print(ans)

if __name__ == "__main__":
    main()
def getlist():
	return list(map(int, input().split()))

N = int(input())
for i in range(N):
	a, b = getlist()


if N % 2 == 1:
	print("First")
else:
	print("Second")

### FIXED CODE ###

from collections import defaultdict
from collections import deque

def getlist():
	return list(map(int, input().split()))

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, a, b):
        self.graph[a].append(b)


class breadth(object):
    def __init__(self, graph, s):
        self.g = graph.graph
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[s] = 0
        self.visit = ["no" for i in range(len(graph) + 1)]
        self.visit[s] = "yes"

        self.Q = deque()
        self.Q.append([self.dist[s], s])

        while self.Q:
            dist_u, u = self.Q.popleft()
            for v in self.g[u]:
                if self.visit[v] == "yes":
                    continue
                else:
                    self.dist[v] = dist_u + 1
                    self.visit[v] = "yes"
                    self.Q.append([self.dist[v], v])


N = int(input())
if N == 1:
	print("First")
else:
	g_a = Graph()
	for i in range(N - 1):
		a, b = getlist()
		g_a.add_edge(a, b)
		g_a.add_edge(b, a)
	
	s = 1
	E = breadth(g_a, s)
	x = 0
	for i in E.dist:
		if E.dist[i] > x:
			x = E.dist[i]
			y = i
	F = breadth(g_a, y)
	x = 0
	for i in F.dist:
		if F.dist[i] > x:
			x = F.dist[i]
			y = i

	if x % 3 == 0 or x % 3 == 2:
		print("First")
	else:
		print("Second")
from operator import itemgetter

def inpl(): return [int(i) for i in input().split()]

N,K = inpl()
d = {}
ans = 0
n0 = []
n1 = []

for i in range(N):
    ti,di = inpl()
    if (ti in d.keys()):
        d[ti].append(di)
    else:
        d[ti] = [di]

for i in d.keys():
    sortedd = sorted(d[i],reverse = True)
    n1.append(sortedd[0])
    n0 += sortedd[1:]

n0.sort(reverse = True)
n1.sort(reverse = True)

for i in range(K+1):
    if(K-i <= len(n0) and 0<=K-i):
        total = sum(n1[:i])+sum(n0[:K-i])+(i)**2
        if(ans<total):
            ans = total

print(ans)


### FIXED CODE ###

AB,BC,CA = map(int,input().split())
print(int(AB*BC/2))
N, *P = map(int, open('0').read().split())
b = list(range(N*N, N-1, -N))
a = [0]*N
for i,p in enumerate(P):
  a[p-1] = N*p+i
print(*a)
print(*b)

### FIXED CODE ###

N, *P = map(int, open(0).read().split())
b = list(range(N*N, N-1, -N))
a = [0]*N
for i,p in enumerate(P):
  a[p-1] = N*p+i
print(*a)
print(*b)
N = int(input())
print(((N//2)+1)/2N if N%2 != 0 else "0.5" )


### FIXED CODE ###

N = int(input())
print(((N//2)+1)/N if N%2 != 0 else "0.5" )
q,h,s,d=map(int,input().split())
N=int(input())
s=min(q*4,h*2,s)
print(min(s*N,d*(N//2)+a*(N%2)))

### FIXED CODE ###

q,h,s,d=map(int,input().split())
N=int(input())
h=min(2*q,h)
s=min(2*h,s)
ans=0
if 2*s>d:
  ans+=(N//2)*d
  if N%2!=0:
    ans+=s
else:
  ans=N*s
print(ans)
a,b = int(input().split())
print(a*b)

### FIXED CODE ###

a,b = map(int,input().split())
print(a*b)
#!/usr/bin/python3

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

candidates = [i for i in range(N)]

for k in range(M - 1):
    A = map(int, input().split())
    for Ai in A:
        try:
            index = candidates.index(Ai)
            del candidates[index]
        except ValueError:
            pass

print(len(candidates))


### FIXED CODE ###

#!/usr/bin/python3

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

A = []
for k in range(N):
    Ai = [i for i in map(int, input().split())]
    _M = Ai.pop(0)
    A.append(Ai)

res = A[0]
for k in range(N - 1):
    res = list(set(res) & set(A[k + 1]))


print(len(res))
count=0
while x != 0:
    x=int(input())
    print("Case {0}: x".format(count))
    count += 1

### FIXED CODE ###

count=1
while True:
    x=int(input())
    if x ==0 :
        break
    print("Case {0}: {1}".format(count,x))
    count += 1
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [int(input()) for _ in range(m)]
for i in a:
    c = 0
    for j, k in i, b:
        c += j * k
    print(c)


### FIXED CODE ###

n, m = map(int, input().split())
A = [map(int, input().split()) for _ in [None] * n]
b = [int(input()) for _ in [None] * m]
for a in A:
    print(sum(i * j for i, j in zip(a, b)))
A,B,T=(int,input().split())
a =T//A
 number = 0
 for i in range(a):
  b=1
  s = a-b
  if s >0:
    number+=1
  b+=1
print(number*B)

  

### FIXED CODE ###

A,B,T = map(int,input().split())
a =T//A
number = 0
for i in range(a):
  b=1
  s = a-b
  if s >=0:
    number+=1
  b+=1
print(number*B)