Harryxun/stf_run huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
ak = 0
ak_2 = 0

for i in range(N):
  ak += A[i]
  ak_2 += A[i] ** 2
s = int(((ak ** 2) - ak_2) // 2)
print(s % mod)

### FIXED CODE ###

D, T, S = map(int, input().split())

if S * T >= D:
  print('Yes') 
else:
  print('No')
input_A = input()
input_T = input()
input_A, input_T = list(input_A), list(input_T)

for i in range(len(input_A)-len(input_T), 0, -1):
    clear_flg = True
    for j in range(len(input_T)):
        if not (input_A[i + j] == '?' or input_A[i + j] == input_T[j]):
            clear_flg = False
            break

    if clear_flg is True:
        input_A[i:i + len(input_T)] = input_T
        input_A = ''.join(input_A).replace('?', 'a')
    else:
        input_A = 'UNRESTORABLE'
print(input_A)


### FIXED CODE ###

input_A = input()
input_T = input()
input_A, input_T = list(input_A), list(input_T)

if len(input_A) >= len(input_T):
    for i in range(len(input_A)-len(input_T), -1, -1):
        clear_flg = True
        for j in range(len(input_T)):
            if not (input_A[i + j] == '?' or input_A[i + j] == input_T[j]):
                clear_flg = False
                break

        if clear_flg is True:
            input_A[i:i + len(input_T)] = input_T
            input_A = ''.join(input_A).replace('?', 'a')
            break
else:
    clear_flg = False

if clear_flg is True:
    print(input_A)
else:
    print('UNRESTORABLE')
n=int(input())

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


X=[]

t=None

for i in A:
    if i==t:
        t=None
        X.append(t)
        if len(X)==2:
            break
    else:
        t=i
        
if len(X)>1:
    print(X[0]*X[1])
else:
    print(0)

### FIXED CODE ###

import collections

n=int(input())

A=list(map(int,input().split()))
        
X=collections.Counter(A)

ans=1
cnt_1=0
cnt_2=0

for k,v in sorted(X.items(),key=lambda x:x[0],reverse=True):
    if v>=2:
        cnt_1+=1
        ans*=k
        if cnt_1==2:
            break
        if v>=4:
            ans*=k
            break
    else:
        cnt_2+=1
        if cnt_2==n or cnt_2==n-2 or cnt_2==n-3:
            ans=0
            break
print(ans)
A, B, C = map(int, input())

num5 = 0
num7 = 0
ans = 'NO'

for num in [A, B, C]:
  if num == 5:
    num5+=1
  elif num == 7:
    num7+=1
  else:
    break
if num5 ==2 and num7 == 1:
  ans = 'YES'
print(ans)

### FIXED CODE ###

A, B, C = map(int, input().split())
 
num5 = 0
num7 = 0
ans = 'NO'
 
for num in [A, B, C]:
  if num == 5:
    num5+=1
  elif num == 7:
    num7+=1
  else:
    break
if num5 ==2 and num7 == 1:
  ans = 'YES'
print(ans)
N, K = input().split()
if N % K == 0:
    print("0")
else:
    print("1") 


### FIXED CODE ###

N, K = map(int, (input().split()))
if N % K == 0:
    print("0")
else:
    print("1")
N = int(input())
S = input()
H = list(S)
P = len(H)
oo = []
ll = []
if P%2 == 0:
  for a in range (0,N/2):
    oo.append(H(a))
    ll.append(H(a+N/2))
    if oo == ll :
      print("Yes")
else :
  print("No")
    
 
    

  


### FIXED CODE ###

N = int(input())
S = input()
H = list(S)
P = len(H)
oo = []
ll = []
if P%2 == 0:
  for a in range (0,int(N/2)):
    oo.append(H[int(a)])
    ll.append(H[int(a+N/2)])
  if oo == ll :
    print("Yes")
  else :
    print("No")
else :
  print("No")
n,m = map(int,input().split())

a = [[] for i in range(m)]

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

#print(a)

ans = 0
for i in range(m):
    if a[m - 1 - i] != []:
        ans += max(a[m - 1 - i])

print(ans)

### FIXED CODE ###

import heapq

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

a = [[] for i in range(100000)]
d = []
heapq.heapify(d)

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

#print(a)

ans = 0
for i in range(m):
    for j in range(len(a[i])):
        heapq.heappush(d,a[i][j])
    if d != []:
        ans -= heapq.heappop(d)

print(ans)
import numpy as np
def main():
    [N,W]=input().split(" ")
    N=int(N)
    W=int(W)
    inputset=[]
    for i in range(N):
        [vi,wi]=input().split(" ")
        inputset.append([int(vi),int(wi)])

    graph=np.zeros([N+1,W+1])

    for i in range(N):
        for j in range(W+1):
            if(inputset[i][1]>j):
                graph[i+1,j]=graph[i,j]
            else:
                rest=j-inputset[i][1]
                choosevalue=graph[i,rest]+inputset[i][0]
                nonchoosevalue=graph[i,j]
                if(choosevalue>nonchoosevalue):
                    graph[i+1,j]=choosevalue
                else:
                    graph[i+1,j]=nonchoosevalue

    print(graph[N,W])

main()

### FIXED CODE ###

def main():
    [N,W]=input().split(" ")
    N=int(N)
    W=int(W)
    inputset=[]
    for i in range(N):
        [vi,wi]=input().split(" ")
        inputset.append([int(vi),int(wi)])

    graph=[]
    for i in range(N+1):
        graph.append([])
        for j in range(W+1):
            graph[i].append(0)

    for i in range(N):
        for j in range(W+1):
            if(inputset[i][1]>j):
                graph[i+1][j]=graph[i][j]
            else:
                rest=j-inputset[i][1]
                choosevalue=graph[i][rest]+inputset[i][0]
                nonchoosevalue=graph[i][j]
                if(choosevalue>nonchoosevalue):
                    graph[i+1][j]=choosevalue
                else:
                    graph[i+1][j]=nonchoosevalue

    print(graph[N][W])

main()
a,b = map(int, input().split(" "))
if (a * b) % 2 == 0:
  print("Even")
  else:
    print("Odd")

### FIXED CODE ###

a,b = map(int, input().split(" "))
if (a * b) % 2 == 0:
	print("Even")
else:
	print("Odd")
import sys
input = sys.stdin.readline
s=list(input())
x,y = map(int, input().split())
s.append('T')
x1=[]
y1=[]

count=0
u=0
for i in range(len(s)):
    if s[i]=='F':
        count+=1
    else:
        if u%2==0:
            x1.append(count)
            u+=1
            count=0
        else:
            y1.append(count)
            u+=1
            count=0


dpx=[[0 for i in range(sum(x1)*2+2)] for j in range(len(x1)+1)]
if len(x1)<=2:
    dpx.append(0)
dpx[1][0]=1
for i in range(1,len(x1)):
    for j in range(-(sum(x1))-1,sum(x1)+1):
        if j-x1[i]>=-sum(x1)-1 and j+x1[i]<sum(x1)+1:
            dpx[i + 1][j] = dpx[i][j + x1[i]] or dpx[i][j-x1[i]] 
        elif j-x1[i]<-sum(x1)-1:
            dpx[i + 1][j] =  dpx[i][j+x1[i]] 
        elif j+x1[i]>=sum(x1)+1:
            dpx[i + 1][j] = dpx[i][j-x1[i]]






dpy=[[0 for i in range(sum(y1)*2+2)] for j in range(len(y1)+1)]
if len(y1)==0:
    dpy.append(0)
dpy[0][0]=1

for i in range(len(y1)):
    for j in range(-sum(y1)-1,sum(y1)+1):
        if j-y1[i]>=-sum(y1)-1 and j+y1[i]<sum(y1)+1:
            dpy[i + 1][j] = dpy[i][j - y1[i]] or dpy[i][j+y1[i]] 
        elif j-y1[i]<-sum(y1)-1:
            dpy[i + 1][j] = dpy[i][j + y1[i]] 
        elif j+y1[i]>=sum(y1)+1:
            dpy[i + 1][j] = dpy[i][j - y1[i]]




if dpy[len(y1)][y]==1 and dpx[len(x1)][x-x1[0]]==1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import sys
input = sys.stdin.readline
s=list(input())
x,y = map(int, input().split())
y=abs(y)
s.append('T')
x1=[]
y1=[]

count=0
u=0
for i in range(len(s)):
    if s[i]=='F':
        count+=1
    else:
        if u%2==0:
            x1.append(count)
            u+=1
            count=0
        else:
            y1.append(count)
            u+=1
            count=0
v=sum(x1)
w=sum(y1)
v-=x1[0]
x-=x1[0]
x1.pop(0)
x=abs(x)
if v<x or w<y:
    print('No')
    exit()

dpx=[[0 for i in range(v+1)] for j in range(len(x1)+1)]
dpx[0][-1]=1

for i in range(len(x1)):
    for j in range(v+1):
        if dpx[i][j]==1:
            if j-2*x1[i]>=0:
                dpx[i+1][j-2*x1[i]]=1
            dpx[i+1][j]=1

if len(y1)==0:
    y1.append(0)
dpy=[[0 for i in range(w+1)] for j in range(len(y1)+1)]
dpy[0][-1]=1

for i in range(len(y1)):
    for j in range(w+1):
        if dpy[i][j]==1:
            if j-2*y1[i]>=0:
                dpy[i+1][j-2*y1[i]]=1
            dpy[i+1][j]=1

if dpy[-1][y]==1 and dpx[-1][x]==1:
    print('Yes')
else:
    print('No')
a = map(int,raw_input().split())
print(a[0]*a[1])
print(" ")
print(a[0]*2 + a[1]*2)

### FIXED CODE ###

data = input().split()
a = int(data[0])
b = int(data[1])
print(str(a*b) + " " + str(a*2+b*2))
def gcd(a,b):
    if a<b:
        d=a
        a=b
        b=d
    c=a%b

    if c==0:
        return b
    else:
        return gcd(b,c)

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

n=int(input())
t=[0]*n

for lop2 in range(n):
    t[lop2]=int(input())

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

### FIXED CODE ###

N = input()
n=int(N)
n2=(n%10)*100
n2+=(n%100)-n%10
n2+=(n-n%100)/100
if n==n2 :
	print('Yes\n')
else:
	print('No\n')
quit()
import math
 
K = input()
 
for i in range(1, K+1):
	for j in range(1,K+1):
  		for k in range(1,K+1):
    		ans += math.gcd(math.gcd(i,j), k)
      
print(ans)

### FIXED CODE ###

from math import gcd
ans = 0
K = int(input())
 
for i in range(1, K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += gcd(gcd(i,j), k)
      
print(ans)
s = input()
prev = s[0]
cnt = 0

now_len = 1
len_sec = []
for i in range(1,len(s)):
  if prev == s[i]:
    now_len += 1
  else:
    len_sec.append(now_len)
    now_len = 1
  prev = s[i]
if len(len_sec)%2==0:
  mx = len_sec[0]+len_sec[1]
  for i in range(1,len(len_sec)-1):
    mx = max(mx, len_sec[i]+len_sec[i+1])
else:
  mx = max(len_sec)
print(mx)



### FIXED CODE ###

#解説参照
#隣接が異なる箇所を操作する必要がある
#max(i,n-i)の最小値がkの下限
#逆に上限であることは、異なる箇所から(右か左の)端までを反転させれば隣接が異なる箇所が減る

s = input()
ans = 10**6
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        ans = min(ans,max(i+1,len(s)-i-1))
if ans ==10**6:
    print(len(s))
else:
    print(ans)
from collections import Counter
n = int(input())
data = [k for k in input()]

ans = Counter(data)
for i in range(n-1):
  tmp = Counter([k for k in input()])
  for j in set(data):
    ans[j] = min(ans[j], tmp[j])
#    print(j, ans[j], tmp[j], min(ans[j], tmp[j]))
ans_list = list(set(list(ans.elements())))
ans_list.sort()
answer = ""
for i in ans_list:
  answer += i*ans[i]
print(answer)


### FIXED CODE ###

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

if b-a == c-b:
  print("YES")
else:
  print("NO")
I=list(map(int,open(0).read().split()))
n,m=I[:2]
a=I[2:]
for i in range(m):
    a.sort()
    a[m-1]=a[m-1]//2
print(int(sum(a)))

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for i in range(m):
    ma=heapq.heappop(a)
    heapq.heappush(a,(-1)*((-ma)//2))
print(-sum(a))
A=input().split()
a=A[0]
b=A[1]
c=A[2]
d=A[3]
if abs(a-c) <= d:
  print("Yes")
elif (abs(a-b) <= d) && (abs(b-c) <= d):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

A=input().split()
a=int(A[0])
b=int(A[1])
c=int(A[2])
d=int(A[3])
if abs(a-c) <= d:
  print("Yes")
elif (abs(a-b) <= d) & (abs(b-c) <= d):
  print("Yes")
else:
  print("No")
input_lines = input().split()
num_lines = []
a = int(input_lines[0])
b = int(input_lines[1])
c = int(input_lines[2])
d = int1(input_lines[3])

num_lines.append(a*c)
num_lines.append(a*d)
num_lines.append(b*c)
num_lines.append(b*d)

print(max(num_lines))

### FIXED CODE ###

input_lines = input().split()
num_lines = []
a = int(input_lines[0])
b = int(input_lines[1])
c = int(input_lines[2])
d = int(input_lines[3])

num_lines.append(a*c)
num_lines.append(a*d)
num_lines.append(b*c)
num_lines.append(b*d)

print(max(num_lines))
import math
a=int(input())
b=int(input())
print(math.ceil((a+b)/2)


### FIXED CODE ###

import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2))
N = input()
if N >= 999:
    print("ABC")
else:
    print("ABD")

### FIXED CODE ###

N = int(input())
if N <= 999:
    print("ABC")
else:
    print("ABD")
_=input()
print('Three' if set(map(int, input().split()))==3 else 'Four')

### FIXED CODE ###

_=input()
print('Three' if len(set(map(str, input().split())))==3 else 'Four')
x=int(input())
import math

sum=0
y=100
for i in range(200000):
  y=math.floor(y*1.01)
  if y<=x:
    sum+=1
  else:
    sum=sum
print(sum+1)


### FIXED CODE ###

x=int(input())

sum=0
y=100
for i in range(10000):
  y=int(y*1.01)
  if y<x:
    sum+=1
  else:
    sum=sum
print(sum+1)
while True:
 l1=list(map(int,input().split()))
 l2=list(map(int,input().split()))
 hit=blow=0
 for i in l1:
   for s in l2:
    if i==s:
     if l1.index(i)==l2.index(s):
       hit+=1
     else:
       blow+=1
 print(hit,blow)
        
    

### FIXED CODE ###

try:
 while True:
  l1=list(map(int,input().split()))
  l2=list(map(int,input().split()))
  hit=blow=0
  for i in l1:
    for s in l2:
     if i==s:
      if l1.index(i)==l2.index(s):
        hit+=1
      else:
        blow+=1
  print(hit,blow)
except:
  pass
a, b = map(int, input().split())
d = b - a

def memorize(f):
	table = []
	def func(*args):
		if not args in table:
			table[args] = f(*args)
		return table[args]
	return func

@memorize
def s(n):
	if n <= 1:
		return 1
	else:
		return s(n-1)+n
print(s(d-1)-a)

### FIXED CODE ###

a, b = map(int, input().split())
d = b - a
print(int((d*(d+1)/2)-b))
a,b,c=input().split()
print(upper(a[0]+b[0]+c[0])

### FIXED CODE ###

a,b,c=input().split()
print((a[0]+b[0]+c[0]).upper())
k=int(input)
print((k//2)**2 if k%2==0 else ((k+1)//2**2)-k)

### FIXED CODE ###

n=int(input())
print((n//2)**2 if n%2==0 else (n//2)*(n//2+1))
a,b,c = map(str,input().split())
print(a[0]+b[1]+c[2])

### FIXED CODE ###

a = input()
b = input()
c = input()
print(a[0]+b[1]+c[2])
int(input())
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]
 
data = [i+1 for i in range(N)]
 
def listExcludedIndices(data, indices=[]):
  return [x for i, x in enumerate(data) if i not in indices]
 
def count(res,p):
    count = 0
    for i in range(len(res)):
        count +=1
        if res[i] == p:
            break
    return count
result = []
for i in range(len(data)):
  for j in range(len(data)-1):
    for k in range(len(data)-2):
      jData = listExcludedIndices(data, [i])
      kData = listExcludedIndices(jData, [j])
      result.append([data[i], jData[j], kData[k]])
print(abs(count(result,P) - count(result,Q)))

### FIXED CODE ###

N = int(input())
P = tuple(int(x) for x in input().split())
Q = tuple(int(x) for x in input().split())

import itertools
L = list(itertools.permutations(list(range(1,N+1))))
print(abs(L.index(Q) - L.index(P)))
N = int(input())
X = list(map(int, input().split()))
A = []
for x in range(min(X)+1,max(X)):
  S = 0
  for i in range(N):
    S = S + (X[i] - x)**2
  A.append(S)
print(min(A))

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
A = []
for x in range(min(X),max(X)+1):
  S = 0
  for i in range(N):
    S = S + (X[i] - x)**2
  A.append(S)
print(min(A))
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
L = [deque([]) for _ in range(N)]
ans = [-1] * N

for n in range(N-1):
    u, v, w = [int(x) for x in input().strip().split()]
    L[u-1].append((v, w))
    L[v-1].append((u, w))

def dfs(x, w):
    if ans[x-1] >= 0:
        return
    ans[x-1] = w % 2
    for nx, w_ in L[x-1]:
        dfs(nx, (w + w_) % 2)
    return

dfs(1, 0)

for a in ans:
    print(a)

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())
L = [deque([]) for _ in range(N)]
ans = [-1] * N

for n in range(N-1):
    u, v, w = [int(x) for x in input().strip().split()]
    L[u-1].append((v, w))
    L[v-1].append((u, w))

def dfs(x, w):
    if ans[x-1] >= 0:
        return
    ans[x-1] = w % 2
    for nx, w_ in L[x-1]:
        dfs(nx, (w + w_) % 2)
    return

dfs(1, 0)

for a in ans:
    print(a)
n = int(input())
l = list(map(int, input().split()))

#hoge日めにhoge枚の株券持ち
dp = [[-10 for _ in range(2010)] for _ in range(n+1)]

dp[0][0] = 1000

#　i日目にj枚の株を持っているときに
for i in range(n):
    for j in range(2005):
        if dp[i][j] < 0:
            continue
        #print("i: %d, j: %d, dp: %d"%(i,j,dp[i][j]) )
        maxbuy = dp[i][j]//l[i]
        for k in range(maxbuy+1):
            dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j]-l[i]*k)
        for k in range(j+1):
            dp[i+1][j-k] = max(dp[i+1][j-k], dp[i][j]+l[i]*k)
print(dp[n][0])

### FIXED CODE ###

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

#hoge日めにhoge枚の株券持ち
dp = [-7 for _ in range(n+1)]

dp[0] = 1000

#　i日目の所持金
for i in range(1,n+1):
    dp[i] = dp[i-1]
    for j in range(i):
        buy = dp[j]//l[j]
        tmp = dp[j]%l[j] + buy*l[i-1]
        dp[i] = max(dp[i], tmp)

print(dp[n])
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin

def gradient(x1, y1, x2, y2):
    return (y1 - y2) / (x1 - x2)

for n in xrange(int(stdin.readline())):
    p = [float(s) for s in stdin.readline().split()]
    if gradient(*p[:4]) == gradient(*p[4:]):
        print('YES')
    else:
        print('NO')

### FIXED CODE ###

from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin

def gradient(x1, y1, x2, y2):
    if x1 - x2 == 0.0:
        return float('inf')
    return (y1 - y2) / (x1 - x2)

for n in xrange(int(stdin.readline())):
    p = [float(s) for s in stdin.readline().split()]
    if gradient(*p[:4]) == gradient(*p[4:]):
        print('YES')
    else:
        print('NO')
n = int(input())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab2 = [[] for i in range(n)]
for i in range(n-1):
  ab2[ab[i][0]-1].append([ab[i][1]-1, i])
  ab2[ab[i][1]-1].append([ab[i][0]-1, i])
coloring = [0]*(n-1)

def f(x, y, z):
  c = 0
  for i in ab2[x]:
    if i[0] != y:
      c += 1
      if c == z:
        c += 1
      coloring[i[1]] = c
      x1 = i[0]
      y1 = x
      z1 = c
      f(x1, y1, z1)

f(0, None, None)
print(max(coloring))
for i in range(n-1):
  print(coloring[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n = int(input())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab2 = [[] for i in range(n)]
for i in range(n-1):
  ab2[ab[i][0]-1].append([ab[i][1]-1, i])
  ab2[ab[i][1]-1].append([ab[i][0]-1, i])
coloring = [0]*(n-1)

def f(x, y, z):
  c = 0
  for i in ab2[x]:
    if i[0] != y:
      c += 1
      if c == z:
        c += 1
      coloring[i[1]] = c
      x1 = i[0]
      y1 = x
      z1 = c
      f(x1, y1, z1)

f(0, None, None)
print(max(coloring))
for i in range(n-1):
  print(coloring[i])
tramps = {
    "S": [0] * 13,
    "H": [0] * 13,
    "C": [0] * 13,
    "D": [0] * 13
}
# print(tramps)

# 持っているカード
n = int(input())

for i in range(n):
    kind, num = input().split()
    tramps[kind][num - 1] = 1

for i in ["S", "H", "C", "D"]:
    for j in range(13):
        tramp = tramps[i][j]
        if tramp == 0:
            print(tramps)



### FIXED CODE ###

# 正解データ
tramps = {
    "S": [0] * 13,
    "H": [0] * 13,
    "C": [0] * 13,
    "D": [0] * 13
}
# print(tramps)

# 持っているカード
n = int(input())

for i in range(n):
    kind, num = input().split()
    tramps[kind][int(num) - 1] = 1

for i in ["S", "H", "C", "D"]:
    for j in range(13):
        tramp = tramps[i][j]
        if tramp == 0:
            print("{} {}".format(i, j+1))
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = []

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
      #else:
        #List.append(0)
    if len(list(set(List))) == 1:
      answer = List[0]
      center.append(i)
      center.append(j)

print(center[0], center[1], answer)

### FIXED CODE ###

N = int(input())

if N == 1:
  print('Hello World')
if N == 2:
  A = int(input())
  B = int(input())
  print(A+B)
a=map(int,input().split())
sum=a[0]+a[1]+a[2]
print(sum)

### FIXED CODE ###

a=list(map(int, input().split() ) )
#print(a)
s=a[0]+a[1]+a[2]
if s>21:
  print("bust")
else:
  print("win")
from collections import deque
N, M = map(int, input().split())
graph = [] 
for i in range(N + M - 1):
    a, b = map(int, input().split())
    graph += [[a,b]]

path = [[] for i in range(N)]  
parent = [[] for i in range(N)]
ans = [-1 for i in range(N)]
for p in graph:
    parent[p[1]-1] += [p[0]-1]
    path[p[0]-1] += [p[1]-1]

root = -1
for i in range(N):
    if parent[i] == []:
        root = i
        ans[i] = -1
    
que = deque()
for v in path[root]:
    que.append([root, v])
while que:
    u, V = que.popleft()
    ans[V] = u
    for v in path[V]:
        que.append([V, v])

for i in range(N):
    print(ans[i]+1)

### FIXED CODE ###

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

ans1 = min(A,B)
ans2 = max(0, A+B-N)
print(ans1, ans2)
a, b, c = [int(i) for i in input().split()]
    if a < b < c:
        print "Yes"

    else:
        print "No"

### FIXED CODE ###

a, b, c = [int(i) for i in input().split()]
if a < b < c:
    print ("Yes")
 
else:
    print ("No")
a,b,k=map(int,input().split())
war=[]
for i in range(1,max(a,b)):
  if a%i==0 and b%i==0:
    war.append(i)
war.reverse()
print(war[k-1])

### FIXED CODE ###

a,b,k=map(int,input().split())
war=[]
for i in range(1,max(a,b)+1):
  if a%i==0 and b%i==0:
    war.append(i)
war.reverse()

print(war[k-1])
N,X = map(int,input().split())
m = []
for i in N:
    d.append(int(input()))
print(len(m) + (X - sum(m))//min(d))

### FIXED CODE ###

N,X = map(int,input().split())
m = []
for i in range(N):
    m.append(int(input()))
print(len(m) + (X - sum(m))//min(m))
n = int(input())
a = list(map(int,input().split()))
s = [0 for _ in range(n)]
for i in range(n):
    s[a[i]-1] += 1
for t in s:print(t)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
s = [0 for _ in range(n)]
for i in range(n-1):
    s[a[i]-1] += 1
for t in s:print(t)
n = int(input())
s = input()

ans = 0
for j in range(ans + 1, n):
    for i in range(j + ans):
        if (s[i:i+ans+1] == s[j:j+ans+1]):
            while (i + ans < n) & (i + ans < j):
                if s[i+ans] == s[j+ans]:
                    ans += 1
                else:
                    break
            else:
                break
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
i = 0
j = 0
r = 0
while i < n:
    if s[i:j] in s[j:]:
        r = max(r, j - i)
        j += 1
    else:
        i += 1
print(r)
N,X = (input().split())
L = list(map(int, input().split()))
x = int(X)
n = int(N)+1
position = 0
count = 0
while position < x:
    position += L[count]
    count += 1
    if n == count:
        break
if n > count:
    print(count)


### FIXED CODE ###

n, x = list(map(int, input().split()))
li = list(map(int, input().split()))

ans = 1
pos = 0
for i in range(n):
	pos = pos + li[i]
	if pos <= x:
		ans += 1
print(ans)
vacationDayCount, homeworkCount = map(int, input().split())
requiredDayList = list(map(int, input.split()))

playableDayCount = vacationDayCount - sum(requiredDayList)

if(playableDayCount >= 0):
    print(playableDayCount)
else:
    print(-1)

### FIXED CODE ###

vacationDayCount, homeworkCount = map(int, input().split())
requiredDayList = list(map(int, input().split()))

playableDayCount = vacationDayCount - sum(requiredDayList)

if(playableDayCount >= 0):
    print(playableDayCount)
else:
    print(-1)
l = sorted([int(input()) for i in range(2)])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
elif: l[1] == l[0]:
  print(l[0]*2)
else:
  print(l[0]+l[1]-1)

### FIXED CODE ###

l = sorted([int(i) for i in input().split()])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
else:
  print(l[0]+l[1])