Harryxun/stf_run huggingface dataset:
n = int(input())
xyhn = [None] * n
for i in range(n):
    xyhn[i] = list(map(int, input().split(' ')))

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(n):
            if xyhn[k][2] > 0 and tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
            if xyhn[k][2] <= 0 and tmp_h > 0:
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))



### FIXED CODE ###

n = int(input())
xyhn = [None] * n
for i in range(n):
    xyhn[i] = list(map(int, input().split(' ')))

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(n):
            if xyhn[k][2] > 0 and tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
            if xyhn[k][2] == 0 and abs(cx - xyhn[k][0]) + abs(cy - xyhn[k][1]) < tmp_h:
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))
del = list(map(int, input(),split()))
n = len(del)
sum = 0
i = 0

while i < n - 1:
 
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
    
  i += 1
  
print(str(sum))



### FIXED CODE ###

n = int(input())
deliciousness = list(map(int, input().split()))
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += deliciousness[i] * deliciousness[k]
  i += 1
  
print(sum)
H,W = map(int,input().split())
s = [input() for i in range(H)]
ans = "No"
for i in range(1,W-1):
    for j in range(1,H-1):
        if s[i][j] == "#":
            if s[i][j-1] == "#" or s[i][j+1] == "#" or s[i+1][j] == "#" or s[i-1][j] == "#":
                ans = "Yes"

print(ans)

### FIXED CODE ###

H,W = map(int,input().split())
s = [input() for i in range(H)]
precount = 0
for i in range(H):
    precount += s[i].count("#")
if precount == 0:
    print("Yes")
else:
    ans = "Yes"
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
               count = 0
               for k in range(4):
                   nx = j+dx[k]
                   ny = i+dy[k]
                   if 0 <= nx < W and 0 <= ny < H:
                      if s[ny][nx] == "#":
                         count += 1
               if count == 0:
                  ans = "No"

    print(ans)
from itertools import combinations
import numpy as np
#S= str(input())
#T= str(input())
N,M,X = map(int,input().split())
#N = int(input())
#A = list(map(int,input().split()))
a=[]
c=[]
ans=[]
for j in range(N):

    A = list(map(int,input().split()))
    c.append(A)
    a.append(A)

for i in range(1,N+1):
    for l in list(combinations(a,i)):
        s=np.zeros(M+1)
        for k in l:
            k=np.array(k)
            s=s+k
        #print(s)
        
        if min(s)>=X:
            ans.append(s[0])
print(int(min(ans)))


### FIXED CODE ###

from itertools import combinations
import numpy as np
#S= str(input())
#T= str(input())
N,M,X = map(int,input().split())
#N = int(input())
#A = list(map(int,input().split()))
a=[]
ans=[]
for j in range(N):

    A = list(map(int,input().split()))
    a.append(A)

for i in range(1,N+1):
    for l in list(combinations(a,i)):
        s=np.zeros(M+1)
        for k in l:
            k=np.array(k)
            s=s+k
        #print(s)

        if min(s[1:])>=X:
            ans.append(s[0])
if len(ans)==0:
    print(-1)
else:
    print(int(min(ans)))
s = input()
a = ""
for i in range(0, len(s)):
  if s[i] == "0":
    a += "0"
  elif s[i] == "1":
    a += "1"
  elif s[i] == "B" and len(a) != 0:
    del a[-1]
print(a)

### FIXED CODE ###

s = input()
a = ""
for i in range(0, len(s)):
  if s[i] == "0":
    a += "0"
  elif s[i] == "1":
    a += "1"
  elif s[i] == "B" and len(a) != 0:
    b = a[0:-1]
    a = b
print(a)
from collections import deque
from sys import stdin
n = int(input())
ddl = deque()
for i in stdin:
    inp = i.split()
    if len(inp) == 2:
        op, data = inp
        data = int(data)
    else: op, data = inp[0], None
    if op == 'insert':
        ddl.appendleft(data,)
    elif op == 'delete':
        ddl.remove(data)
    elif op == 'deleteFirst':
        ddl.popleft()
    elif op == 'deleteLast':
        ddl.pop()

print(' '.join([str(item) for item in ddl]))

### FIXED CODE ###

from collections import deque
from sys import stdin
n = int(input())
line = stdin.readlines()
ddl = deque()
for i in range(n):
    inp = line[i].split()
    if len(inp) == 2:
        op, data = inp
        data = int(data)
    else: op, data = inp[0], None
    if op == 'insert':
        ddl.appendleft(data,)
    elif op == 'delete':
        try:
            ddl.remove(data)
        except ValueError:
            pass
    elif op == 'deleteFirst':
        ddl.popleft()
    elif op == 'deleteLast':
        ddl.pop()

print(' '.join([str(item) for item in ddl]))
n=int(input())


count=len(str(n))
ans=''
if count%2==0:
    for i in range(count-1):
        if i%2==0:
            ans+='9'
        else:
            ans+='0'
else:
    ans=count//2*'90'
    ans=n-int(ans)
print(int(ans))

### FIXED CODE ###

n=int(input())


count=len(str(n))
ans=''
if count%2==0:
    for i in range(count-1):
        if i%2==0:
            ans+='9'
        else:
            ans+='0'
else:
    ans=(count//2)*'90'
    try:
        ans=n-int(ans)
    except:
        ans=n
print(int(ans))
S = int(input())

check = S[2] == S[3] and S[4] == S[5]

print("Yes" if check else "No")

### FIXED CODE ###

S = input()

check = S[2] == S[3] and S[4] == S[5]

print("Yes" if check else "No")
while True:
    N=int(input())
    if N==0:break
    t=[0]
    y=[0]
    lst=list(range(N))
    for k in lst[1:]:
        [x,d]=input().slice()
        [x,d]=[int(x),int(d)]
        if d==0:
            t=t+[t[x]]
            y=y+[y[x]-1]
        if d==1:
            t=t+[t[x]-1]
            y=y+[y[x]]
        if d==2:
            t=t+[t[x]]
            y=y+[y[x]+1]
        if d==3:
            t=t+[t[x]+1]
            y=y+[y[x]]
    ht=0
    lt=0
    hy=0
    ly=0
    for f in range(N):
        if ht<t[f]:
            ht+=1
        if lt>t[f]:
            lt-=1
        if hy<y[f]:
            hy+=1
        if ly>y[f]:
            ly-=1
    print(ht-lt+1,hy-ly+1)

### FIXED CODE ###

while True:
    N=int(input())
    if N==0:break
    t=[0]
    y=[0]
    lst=list(range(N))
    for k in lst[1:]:
        [x,d]=input().split()
        [x,d]=[int(x),int(d)]
        if d==0:
            t=t+[t[x]]
            y=y+[y[x]-1]
        if d==1:
            t=t+[t[x]-1]
            y=y+[y[x]]
        if d==2:
            t=t+[t[x]]
            y=y+[y[x]+1]
        if d==3:
            t=t+[t[x]+1]
            y=y+[y[x]]
    ht=0
    lt=0
    hy=0
    ly=0
    for f in range(N):
        if ht<t[f]:
            ht+=1
        if lt>t[f]:
            lt-=1
        if hy<y[f]:
            hy+=1
        if ly>y[f]:
            ly-=1
    print(hy-ly+1,ht-lt+1)
A,B,C = input().split()
if A*B*C/145==1:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

A,B,C = map(int, input().split())
if A*B*C/175==1:
  print("YES")
else:
  print("NO")
import sys

#inputNum = sys.stdin.readlines()[:-1]
inputNum = open('sample.txt', 'r')

for i in inputNum:
    new = []
    n = i[:-1].split(' ', 6)
    for s in n:
        new.append(float(s))
    k = new[0]
    q = 0
    for a in new[0:3]:
        new[q] = a/k
        q = q + 1
    l = new[3]
    for a in new[3:6]:
        new[q] = a - l*new[q-3]
        q = q + 1
    if new[4] == 0:
        y = new[5]
    else:
        y = new[5]/new[4]
    x = new[2]-(new[1]*y)
    print("{0:.3f}".format(x),"{0:.3f}".format(y))

### FIXED CODE ###

import sys

inputNum = sys.stdin.readlines()

for i in inputNum:
    new = []
    n = i[:-1].split(' ', 6)
    for s in n:
        new.append(float(s))
    k = new[0]
    q = 0
    for a in new[0:3]:
        new[q] = a/k
        q = q + 1
    l = new[3]
    for a in new[3:6]:
        new[q] = a - l*new[q-3]
        q = q + 1
    if new[4] == 0:
        y = new[5]
    else:
        y = new[5]/new[4]
    x = new[2]-(new[1]*y)
    print("{0:.3f}".format(x)+" "+"{0:.3f}".format(y))
n=int(input())
arr=list(map(int,input().split()))
def count(x):
    if x < 0:
      return 0
    if x in vis:
      return vis[x]
    else:
      vis[x]=min(abs(arr[x]-arr[x-1])+count(x-1),abs(arr[x]-arr[x-2])+count(x-2))
    return vis[x]
  
vis={}
vis[0] = 0
if n < 2:
  print(0)
elif n == 2:
  print(abs(arr[0]-arr[1]))
else:
    vis[1] = abs(arr[0]-arr[1])
    print(count(n-1))

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
import re
N, Q = input().split()
N = int(N)
Q = int(Q)
S=str(input())

for i in range(Q):
  l, r = input().split()
  l = int(l)
  r = int(r)
  print(S.count("AC", l-1, r))

### FIXED CODE ###

b=str(input())
if b=="A": print("T")
elif b=="T": print("A")
elif b=="C": print("G")
else: print("C")
while 1:
 H, W = map(int,raw_input().split())
 if H + W == 0:
???break
 for h in range(H):
  if h % 2 == 0:
   if W % 2 == 0:
    print ('#.'*(W//2))
   else:
    print ('#.'*(W//2)+'#')
  else:
   if: W % 2 == 0:
    print ('.#'*(W//2))
 else:
  print ('.#'*(W//2)+'.')
print ''

### FIXED CODE ###

while 1:
 H, W = map(int,raw_input().split())
 if H + W == 0:break
 for h in range(H):
  if h % 2 == 0:
   if W % 2 == 0:
    print ('#.'*(W//2))
   else:
    print ('#.'*(W//2)+'#')
  else:
   if W % 2 == 0:
    print ('.#'*(W//2))
   else:
    print ('.#'*(W//2)+'.')
 print ''
X, Y = map(int, input().split())
a = 0
for i in range(X + 1):
    N = i
    if (X - N) % 2 != 0:
        continue
    M = (X - N) / 2
    
    x = N + 2 * M
    y = 2 * N + M
    if X == x and Y == y:
        a = N
#print(a)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
if a != 0:
    ans = cmb(X-1,a,mod)
    print(ans)
else:
    print("0")

### FIXED CODE ###

X, Y = map(int, input().split())
a = 0
b = 0
for i in range(X + 1):
    N = i
    if (X - N) % 2 != 0 and N != X:
        continue
    M = int((X - N) / 2)
    
    x = N + 2 * M
    y = 2 * N + M
    if X == x and Y == y:
        a = N
        b = M
#print(a)

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if a != 0 and b != 0:
    #print(a, b)
    ans = cmb(a + b,a) % (10**9+7)
    print(ans)
elif a == 0 and b != 0:
    print("1")
elif a != 0 and b == 0:
    print("1") 
else:
    print("0")
n, m, l = map(int,input().split())
a = [list(map(int, input().split()))for i in range(n)]
b = [list(map(int, input().split()))for j in range(m)]
num = [[0 for i in range(l)]for j in range(n)]
for k in range(n):
    for i in range(l):
        for j in range(m):
            num[k][i] += a[k][j] * b[j][i]
for i in range(n):
    print(" ".join(map(num[i])))




### FIXED CODE ###

n, m, l = map(int,input().split())
a = [list(map(int, input().split()))for i in range(n)]
b = [list(map(int, input().split()))for j in range(m)]
num = [[0 for i in range(l)]for j in range(n)]
for k in range(n):
    for i in range(l):
        for j in range(m):
            num[k][i] += a[k][j] * b[j][i]
for i in range(n):
    print(" ".join(map(str, num[i])))
s = raw_input()

St1, St2 = [], []
sumv = 0

for i in range(len(s)):
    if s[i] == '\\':
        St1.append(i)
    elif s[i] == '/' and len(St1) > 0:
        j = St1.pop()
        a = i-j
        sumv += a
        while len(St2) > 0 and St2[-1][0] > j:
            a += St2.pop()[1]

        St2.append([j, a])

St2.insert(0, len(St2))

print sumv
print ' '.join(map(lambda x: str(x[1]), St2))

### FIXED CODE ###

s = raw_input()

St1, St2 = [], []
sumv = 0

for i in range(len(s)):
    if s[i] == '\\':
        St1.append(i)
    elif s[i] == '/' and len(St1) > 0:
        j = St1.pop()
        a = i-j
        sumv += a
        while len(St2) > 0 and St2[-1][0] > j:
            a += St2.pop()[1]

        St2.append([j, a])

St2.insert(0, [0, len(St2)])

print sumv
print ' '.join(map(lambda x: str(x[1]), St2))
while 1:
    n = int(input())
    S = []
    for i in range(n):
        s = input()
        b = []
        for j in range(len(s)):
            if j < 1 or s[j-1] in "aiueo":
                b.append(s[j])
        S.append(b)
    ans = 0
    S.sort()
    for i in range(n-1):
        A = S[i]; B = S[i+1]
        if A == B:
            print(-1)
            break
        res = min(len(A), len(B))
        for j in range(res):
            if A[j] != B[j]:
                res = j
                break
        ans = max(ans, res+1)
    else:
        print(ans)

### FIXED CODE ###

while 1:
    n = int(input())
    if n == 0:
        break
    S = []
    for i in range(n):
        s = input()
        b = []
        for j in range(len(s)):
            if j < 1 or s[j-1] in "aiueo":
                b.append(s[j])
        S.append(b)
    ans = 0
    S.sort()
    for i in range(n-1):
        A = S[i]; B = S[i+1]
        if A == B:
            print(-1)
            break
        res = min(len(A), len(B))
        for j in range(res):
            if A[j] != B[j]:
                res = j
                break
        ans = max(ans, res+1)
    else:
        print(ans)
n, m = map(int, input().split())
a = []
for _ in range(m):
    _a = int(input())
    try:
        if _a == a[-1]:
            continue
    except:
        pass
    a.append(_a)
a.append(n + 1)
m = len(a)

memo = {0: 1, 1: 1, 2: 2}
def chk(n):
    if n in memo:
        return memo[n]
    else:
        make(n)
        return memo[n]

def make(n):
    if n in memo:
        return
    make(n - 1)
    make(n - 2)
    memo[n] = (memo[n-1] + memo[n-2]) % 1000000007

for i in range(m - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        exit()

cur = 0
tot = 1
#from sys import stderr
#for k in range(100):
#    print(f'0-{k}: {chk(k)}', file=stderr)

for i in range(m):
    nxt = a[i] - 1
    add = chk(nxt - cur)
    #print(f'{cur}-{nxt}: {add}', file=stderr)
    tot *= add
    tot %= 1000000007
    cur = nxt + 2
print(tot % 1000000007)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
n, m = map(int, input().split())
a = []
for _ in range(m):
    _a = int(input())
    try:
        if _a == a[-1]:
            continue
    except:
        pass
    a.append(_a)
a.append(n + 1)
m = len(a)

memo = {0: 1, 1: 1, 2: 2}
def chk(n):
    if n in memo:
        return memo[n]
    else:
        make(n)
        return memo[n]

def make(n):
    if n in memo:
        return
    make(n - 1)
    make(n - 2)
    memo[n] = (memo[n-1] + memo[n-2]) % 1000000007

for i in range(m - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        exit()

cur = 0
tot = 1
#from sys import stderr
#for k in range(100):
#    print(f'0-{k}: {chk(k)}', file=stderr)

for i in range(m):
    nxt = a[i] - 1
    add = chk(nxt - cur)
    #print(f'{cur}-{nxt}: {add}', file=stderr)
    tot *= add
    tot %= 1000000007
    cur = nxt + 2
print(tot % 1000000007)
n=int(input())
s=input().split()
l=[int(s[i]) for i in range(n)]
l.sort()
if l[0]==l[-1]:
    if 1<=l[0]<=n//2:
        print("Yes")
    else:
        print("No")
elif l[-1]-l[0]>1:
    l[10000000]-=1
    print("No")
else:
    l[10000000]-=1
    a=l.count(l[0])
    b=l.count(l[-1])
    if a+1<=l[-1]<=a+b//2:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

n=int(input())
s=input().split()
l=[int(s[i]) for i in range(n)]
l.sort()
if l[0]==l[-1]:
    if l[0]<=n//2 or l[0]==n-1:
        print("Yes")
    else:
        print("No")
elif l[-1]-l[0]>1:
    print("No")
else:
    a=l.count(l[0])
    b=l.count(l[-1])
    if a+1<=l[-1]<=a+b//2:
        print("Yes")
    else:
        print("No")
def BubbleSort(A,n):
    count = 0
    for i in range(n):
        for j in range(n-1,i,-1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                count += 1
    return A, count

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

ans, count =  (BubbleSort(A,n))
ans = list(map(str,ans))


print (" ".join(ans))
print (count)

### FIXED CODE ###

n = int(input())
 
numbers = list(map(int, input().split(" ")))
 
cnt = 0
 
for i in range(n):
    for j in range(n - 1, i, -1):
        if numbers[j] < numbers[j - 1]:
            numbers[j],numbers[j - 1] = numbers[j - 1], numbers[j]
            cnt += 1
 
numbers = map(str, numbers)
print(" ".join(numbers))
 
print(cnt)
s = str(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
if len(s) == 26:
    if s == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
    else:
        for i in range(26):
            if ord(s[i+1]) - ord(s[i]) != 1:
                S = sorted(set(s) - set(s[:i+1]))
                print(s[:i] + S[0])
                break
else:
    S = sorted(set(alpha) - set(s))
    print(s + S[0])


### FIXED CODE ###

s = str(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
inv_alpha = 'zyxwvutsrqponmlkjihgfedcba'
if len(s) == 26:
    if s == inv_alpha:
        print(-1)
    else:
        for i in reversed(range(25)):
            for j in reversed(range(i+1, 26)):
                if s[i] < s[j]:
                    print(s[:i] + s[j])
                    break
            else:
                continue
            break
else:
    S = sorted(set(alpha) - set(s))
    print(s + S[0])
a = input()
if a.isupper():
  print("A)
else:
  print("a")

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    a = input().rstrip()
    if a.isupper():
        print("A")
    else:
        print("a")

if __name__ == '__main__':
    main()
K,S = map(int,input().split())
patterns = 0

arr = [[x+y for y in range(min(S-x+1,K+1))] for x in range(K+1)]
# farr = list(chain.from_iterable(arr))
for a in arr:
    min_z = S - max(a)
    max_z = S - min(a)
    # if min_z <= K and max_z >=0:
    patterns += max(0,min(max_z,K) - max(0,min_z) + 1)
# print(farr)
# print(farr.count(S))
print(patterns)

### FIXED CODE ###

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

# # arr = [[x+y for y in range(min(S-x+1,K+1))] for x in range(K+1)]
# farr = list(chain.from_iterable(arr))
# for z in farr:
#     temp_z = S - z
#     if temp_z <= K and temp_z >=0:
#         patterns += 1
# print(farr)
# print(farr.count(S))

for x in range(K+1):
    for y in range(max(0,S-K-x), min(K+1,S-x+1)):
        patterns += 1
print(patterns)
ABCD = input()

for i in range(2 ** 3):
    op = format(i, '03b')
    op = op.replace('1', '+').replace('0', '-')
    formula = ABCD[0] + op[0] + ABCD[1] + op[1] + ABCD[2] + op[2]
    if eval(formula) == 7:
        print(formula + '=7')
        break

### FIXED CODE ###

ABCD = input()

for i in range(2 ** 3):
    op = format(i, '03b')
    op = op.replace('1', '+').replace('0', '-')
    formula = ABCD[0] + op[0] + ABCD[1] + op[1] + ABCD[2] + op[2] + ABCD[3]
    if eval(formula) == 7:
        print(formula + '=7')
        break
N, M = map(int, input().split())
X = [0] * M
Y = [0] * M
Z = [0] * M 
unique = []
count = 0
for i in range(M):
  X[i], Y[i], Z[i] = map(int, input().split())

reach = [[] for _ in range(N)]
for i in range(M) :
    reach[Y[i]-1].append(X[i])
    reach[X[i]-1].append(Y[i])

approach = [False for _ in range(N)]

ans = 0

def change(reach, s):       
    approach[s-1] = True
    for i in reach[s-1]:
        if not approach[i-1] :
            change(reach, i)

for i in range(N) :
    if not approach[i]:
        change(reach, i+1)
        ans += 1

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
N,M = list(map(int,input().split()))
XYZ = [list(map(int,input().split())) for _ in range(M)]

G = [[] for _ in range(N)]
 
for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])
 
check = [False for _ in range(N)]
 
def DFS(G,s):
    check[s-1] = True
    for i in G[s-1]:
        if not check[i-1]:         
            DFS(G,i)
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1

print(ans)
c = 0
A = input()
B = A.split(" ")
a,b = int(B[0]),int(B[1])
for i in range(1,a-b):
    c = c + i
print(c - a)


### FIXED CODE ###

i = int(input())
if i <= 999:
    print("ABC")
else:
    print("ABD")
N,K = map(int,input().split())
A = [[0 for j in range(100)]for i in range(100)]
B = [0 for j in range(N)]
S = 0
for i in range(K):
    d = int(input())
    A[i] = list(map(int,input().split()))
for i in range(100):
    for j in range(100):
        for k in range(N):
            if A[i][j] == k+1:
                B[k] = 1
for i in range(N):
    if B[i] != 1:
        S += 1
print (S)

### FIXED CODE ###

N,K = map(int,input().split())
A = [[0 for j in range(K)]for i in range(K)]
B = [0 for j in range(N)]
S = 0
for i in range(K):
    d = int(input())
    A[i] = list(map(int,input().split()))
for i in range(K):
    for j in range(len(A[i])):
        for k in range(N):
            if A[i][j] == k+1:
                B[k] = 1
for i in range(N):
    if B[i] != 1:
        S += 1
print (S)
1 <= x <= 100
x = int(input())
print(x ** 3)

### FIXED CODE ###

x = int(input())
print(x ** 3)
a,b=map(int,input().split())
print("Yes" if (10a+b)**.5==int((10a+b)**.5) else "No")

### FIXED CODE ###

a,b=input().split()
z=int(a+b)
print("Yes" if z**.5==int(z**.5) else "No")
import math
import itertools

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

t=[]

for i in range(1,N+1):
    v=math.factorial(N-i)
    t.append(v)
T=itertools.accumulate(t)

for j in range(1,N+1):
    C=C(x[j]-x[j-1])*T[i]

print(C%(10**9+7))

### FIXED CODE ###

from math import factorial
 
N = int(input())
x = list(map(int, input().split()))
mod = 10**9 + 7
x_dis = [x[i+1] - x[i] for i in range(N-1)]
ans = 0
m = N-1
fac = factorial(m) % mod
tmp = fac
for i in range(m):
    ans += x_dis[i] * tmp
    ans %= mod
    tmp += (fac*pow((i+2),(mod-2), mod))%mod
print(ans)
n,k,q=map(int,input().split())

for i in range(1,n+1):
  ans=k
  for j in range(q):
    que=int(input())
    if que!=i:
      ans-=1
    if ans<=0:
      break
  if ans<=0:
    print("No")
  else:
    print("Yes")
  


### FIXED CODE ###

from collections import Counter

n,k,q=map(int,input().split())
l=[int(input()) for i in range(q)]

l_c=Counter(l)

for i in range(1,n+1):
  ok=l_c[i]
  num=k-q+ok
  if num>0:
    print("Yes")
  else:
    print("No")
n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max_ind = index(max(a))
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n)
    if i == a_max_ind:
        print(a_sec)
    else:
        print(a_max)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n):
    if a[i] == a_max:
        print(a_sec)
    else:
        print(a_max)