Harryxun/stf_run huggingface dataset:
from collections import defaultdict
s = input().split()
n = int(s[0]) 
m = int(s[1])
graph = defaultdict(set)
for i in range(m):
    s = input().split(" ")
    graph[int(s[0])].add(int(s[1]))
    graph[int(s[1])].add(int(s[0]))
visited = [False] * (n+1)

def dfs(root):
    visited[root] = True
    for child in graph[root]:
        if not visited[child]:
            dfs(child)

ans  = 0
prev = 0
for i in range(1, n+1):
    if not visited[i]:
        dfs(i)
        temp = 0
        for k in visited:
            if k:
                temp+=1
        ans  = max(ans, temp-prev)
        prev = temp

print(ans)



### FIXED CODE ###

from collections import defaultdict
s = input().split()
n = int(s[0]) 
m = int(s[1])
graph = defaultdict(set)
for i in range(m):
    s = input().split(" ")
    graph[int(s[0])].add(int(s[1]))
    graph[int(s[1])].add(int(s[0]))

visited = [False] * (n+1)

def bfs (node):
    queue = [node]  
    ans = 0
    visited[node] = True
    while queue:
        root = queue.pop()
        ans +=1
        
        for child in graph[root]:
            if not visited[child]:
                queue.append(child)
                visited[child]  =True
    return ans

ans  = 0
for i in range(1, n+1):
    if not visited[i]:
        ans = max(ans, bfs(i))
print( ans)
S=raw_input();l=len(S);f=S.find('C');A=0
if S[:1]='A':
	A+1
	S="a"+S[1:]
if S[2:l-1].count('C')=1:
	A+1
	S=S[:f]+'c'+S[f+1:]
if S.islower():
	A+1
print('AC'if A=3 else'WA')

### FIXED CODE ###

S = raw_input()
l=len(S)
if S[:1] == 'A':
	AC = 1
	S = "a"+S[1:]
else:
	AC = 0
if S[2:l-1].count('C')==1:
	AC2 = 1
else:
	AC2 = 0
if S.find('C')>=2:
	S = S[:S.find('C')] + 'c' + S[S.find('C')+1:]
if S.islower():
	AC3 = 1
else:
	AC3 = 0
if AC+AC2+AC3 == 3:
	print 'AC'
else:
	print 'WA'
n, k = map(int, input().split())
s = input()
s = list(s)
ans = s
len = []
for i in range(n):
  l = 0
  if s[i] == '0':
    l += 1
    j = i
    while s[j+1] != '0':
      l += 1
  len.append(l)
print(len)

### FIXED CODE ###

a,b = (int(i) for i in input().split())  
sum = 0
sum += max(a,b)
if a > b:
  a -= 1
else:
  b -= 1
sum += max(a,b)
print(sum)
from collections import Counter

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

num = Counter(s)

if len(num) <= k:
    print(0)
else:
    cnt = len(num) - k
    ans = 0
    i = 0
    for v in sorted(num.values()):
        if cnt == i:
            break
        ans += v
        i += 1

print(ans)

### FIXED CODE ###

from collections import Counter

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

num = Counter(s)


if len(num) <= k:
    print(0)

else:
    cnt = len(num) - k
    ans = 0
    i = 0
    for v in sorted(num.values()):
        if cnt == i:
            break
        ans += v
        i += 1

    print(ans)
n=int(input())
div=[0]*(n+1)
for i in range(1,n+1):
  k=i
  for j in range(1,int(i**0.5)+1):
    cnt=0
    while k%(j+1)==0:
      k//=(j+1)
      cnt+=1
    div[j+1]+=cnt
  if k>1:
    div[k]+=1
ans=0
d=dict()
for i,j,k in [[4,4,2],[24,2,1000],[14,4,1000],[74,1000,1000]]:
  cnti,cntj,cntk=0,0,0
  for l in range(2,n+1):
    if j==1000 and k==1000:
      if div[l]>=i:
        ans+=1
    for m in range(2,n+1):
      if l!=m and j!=1000 and k==1000:
        if div[l]>=i and div[m]>=j:
            ans+=1
      for o in range(2,n+1):
        if (m,l) not in d:
          if l!=o and l!=m and m!=o:
            if i!=1000 and j!=1000 and k!=1000:
              if div[l]>=i and div[m]>=j and div[o]>=k:
                ans+=1
                d[(l,m)]=0
print(ans)

### FIXED CODE ###

n=int(input())
div=[0]*(n+10)
for i in range(1,n+1):
  k=i
  for j in range(1,int(i**0.5)+1):
    cnt=0
    while k%(j+1)==0:
      k//=(j+1)
      cnt+=1
    div[j+1]+=cnt
  if k>1:
    div[k]+=1
ans=0
d=dict()
for i,j,k in [[4,4,2],[24,2,1000],[14,4,1000],[74,1000,1000]]:
  cnti,cntj,cntk=0,0,0
  for l in range(2,n+1):
    if j==1000 and k==1000:
      if div[l]>=i:
        ans+=1
    for m in range(2,n+1):
      if l!=m and j!=1000 and k==1000:
        if div[l]>=i and div[m]>=j:
            ans+=1
      for o in range(2,n+1):
        if (m,l) not in d:
          if l!=o and l!=m and m!=o:
            if i!=1000 and j!=1000 and k!=1000:
              if div[l]>=i and div[m]>=j and div[o]>=k:
                ans+=1
                d[(l,m)]=0
print(ans)
import sys
import numpy as np

def binary_search(array, num):
    # numより真に大きいはじめのindex
    if array[-1] <= num:
        return -1
    left = -1
    right = N-1
    while right - left > 1:
        mid = int((left + right)/2)
        if array[mid] <= num:
            left = mid
        else:
            right = mid
    return right

a_index = []
b_index = []

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split(" ")))
A = np.sort(A)
B = list(map(int, sys.stdin.readline().strip().split(" ")))
B = np.sort(B)
C = list(map(int, sys.stdin.readline().strip().split(" ")))
C = np.sort(C)

for a in A:
    a_index.append(binary_search(B, a))
    
for b in B:
    b_index.append(binary_search(C, b))

bb = []
tmp = np.sum(b_index)
for i in range(N):
    bb.append(tmp)
    bb = bb - b_index[i]
    
res = 0
for a_i in a_index:
    if a_i == -1:
        continue
    res += N * (N - a_i) - bb[a_i]
print(str(res))



### FIXED CODE ###

import sys
import numpy as np

def binary_search(array, num):
    # numより真に大きいはじめのindex
    if array[-1] <= num:
        return -1
    left = -1
    right = N-1
    while right - left > 1:
        mid = int((left + right)/2)
        if array[mid] <= num:
            left = mid
        else:
            right = mid
    return right

a_index = []
b_index = []

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split(" ")))
A = np.sort(A)
B = list(map(int, sys.stdin.readline().strip().split(" ")))
B = np.sort(B)
C = list(map(int, sys.stdin.readline().strip().split(" ")))
C = np.sort(C)

for a in A:
    a_index.append(binary_search(B, a))
    
for b in B:
    b_index.append(binary_search(C, b))


b_index = list(map(lambda x: N-x if (x != -1) else 0, b_index))

bb = []
tmp = np.sum(b_index)
for i in range(N):
    bb.append(tmp)
    tmp = tmp - b_index[i]

res = 0
for a_i in a_index:
    if a_i == -1:
        continue
    res += bb[a_i]
print(str(res))
def search(lst, x, al, A):
    if not lst:
        return
    for p in lst:
        A[p] += x
        search(al[p], x, al, A)

N, Q = [int(i) for i in input().split()]

al = [[] * N for _ in range(N)]
A = [0] * N

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

for i in range(Q):
    p, x = [int(i) - 1 for i in input().split()]
    A[p] += (x + 1)
    search(al[p], x + 1, al, A)

print(*A, sep=' ')

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6) #再帰の回数制限を増やす
input = sys.stdin.readline


def add_num(i, total, parent=-1):
    """隣接リストを取り出して深さ優先探索
    自分より上層の total のカウント数と部分木の頂点としてのカウント数を足す"""
    for p in adj[i]:
        if p != parent:
            ans_lst[p] = total + tmp[p]
            add_num(p, total + tmp[p], i)
    return
    
    
N, Q = [int(i) for i in input().split()]

adj = [[] for _ in range(N)] # 隣接リスト
tmp = [0] * N # 部分木の根としてのカウント数 
ans_lst = [0] * N # 答えのリスト

# 隣接リストの作成
for _ in range(N - 1):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a].append(b)
    adj[b].append(a)

# ｔｍｐリストの作成
for _ in range(Q):
    p, x = [int(i) for i in input().split()]
    tmp[p-1] += x

ans_lst[0] = tmp[0]
total = tmp[0]
add_num(0, total)

print(*ans_lst, sep=' ')
from sys import stdin


class DFS():
    def __init__(self,N,S):
        self.N = N
        self.S = S
        self.seen = [False] * self.N
        self.cnt = [0] * self.N

    def dfs(self, i):
        if i == self.N-1:
            return 1
        elif i > self.N-1:
            return 0
        elif self.seen[i]:
            return self.cnt[i]
        else:
            cnt = 0
            for s in self.S:
                cnt += self.dfs(i+s)
            else:
                self.cnt[i] = cnt % 998244353
                self.seen[i] = True
            return self.cnt[i]


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int, _in[0].split(' ')))  # type:list(int)
    L_R_arr = []
    for i in range(K):
        _ = list(map(int, _in[i+1].split(' ')))  # type:list(int)
        L_R_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ans = 0
    S = []
    for L, R in L_R_arr:
        S.extend([i for i in range(L, R+1)])
    S = sorted(set(S))
    dfs = DFS(N, S)
    dfs.dfs(0)
    ans = dfs.cnt[0] % 998244353
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
import sys
sys.setrecursionlimit(10**7)


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int, _in[0].split(' ')))  # type:list(int)
    L_R_arr = []
    for i in range(K):
        _ = list(map(int, _in[i+1].split(' ')))  # type:list(int)
        L_R_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dp = [0] * N
    sdp = [0] * (N+1)
    dp[0] = 1
    for i in range(N):
        for L, R in L_R_arr:
            right = max(0, i-L+1)
            left  = max(0, i-R)
            dp[i] += sdp[right] - sdp[left]
        else:
            sdp[i+1] = (sdp[i] + dp[i]) % 998244353
    ans = dp[-1] % 998244353
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()
N=int(input())
a='ABD'
b='ABC'
if a<=999:
  print(b)
else:
  print(a)

### FIXED CODE ###

N=int(input())
a='ABD'
b='ABC'

if N<=999:
  print(b)
else:
  print(a)
import sys
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
sys.setrecursionlimit(10**7)

n, m, l = [int(i) for i in sys.stdin.readline().split()]
graph = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c

res = floyd_warshall(csgraph_from_dense(graph))
res = np.where(res <= l, np.ones_like(res), np.zeros_like(res))

new_res = floyd_warshall(csgraph_from_dense(res))
q = int(input())
for j in range(q):
    s, t = [int(i) for i in sys.stdin.readline().split()]
    s -= 1
    t -= 1
    dis = new_res[s, t] if not np.isinf(new_res[s, t]) else 0
    print(int(dis) - 1)

### FIXED CODE ###

import sys
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall, csgraph_to_dense
from scipy.sparse import issparse
sys.setrecursionlimit(10**7)

n, m, l = [int(i) for i in sys.stdin.readline().split()]
graph = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c

res = floyd_warshall(csgraph_from_dense(graph))
if issparse(res):
    res = csgraph_to_dense(res)
res = np.where(res <= l, 1, 0)
new_res = floyd_warshall(res)
new_res[new_res == np.inf] = 0
q = int(input())
for j in range(q):
    s, t = [int(i) for i in sys.stdin.readline().split()]
    s -= 1
    t -= 1
    dis = new_res[s, t]
    print(int(dis) - 1)
A, B, M = list(map(int, input().rstrip().split()))
a = list(map(int, input().rstrip().split()))
b = list(map(int, input().rstrip().split()))

cost=[]
for _ in range(M):
    x, y, c = list(map(int, input().rstrip().split()))
    tot = a[x-1] + b[y-1] - c
    cost.append(tot)
    
cost.append(min(a)+min(b))
print(min(cost))


### FIXED CODE ###

s = input().rstrip()
h = ['hi' * i for i in range(1,6)]

if s in h:
  print('Yes')
else:
  print('No')
N = int(input())
A = list(map(int,input().split()))
ans = 'APPROVED'
for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            ans = 'DENIED'
            exit()
print(ans)

### FIXED CODE ###

print("Yes" if len(set(map(int, input().split())))==2 else "No")
from fractions import gcd
from itertools import accumulate

n, x, d = map(int, input().split())
g = gcd(x, d)
back_k = d // g
offset = x // g

min_memo = [0] + list(accumulate(range(n)))
max_memo = [0] + list(accumulate(range(n - 1, -1, -1)))
ans = 1
# print(back_k, offset)
# print(min_memo)
# print(max_memo)

for k in range(1, n + 1):
    min_acc = min_memo[k]
    max_acc = max_memo[k]

    if k < back_k:
        ans += max_acc - min_acc + 1
        continue

    back_min = min_memo[k - back_k] - offset
    back_max = max_memo[k - back_k] - offset
    ans += max_acc - max(min_acc, back_max) + 1
    # print(ans, min_acc, max_acc, back_min, back_max)

print(ans)


### FIXED CODE ###

from fractions import gcd
from itertools import accumulate

n, x, d = map(int, input().split())

if d == 0:
    if x == 0:
        print(1)
    else:
        print(n + 1)
    exit()
elif d < 0:
    x, d = -x, -d

g = gcd(x, d)
back_k = d // g
offset = x // g

lowers = [0] + list(accumulate(range(n)))
uppers = [0] + list(accumulate(range(n - 1, -1, -1)))
min_memo = [10 ** 18] * min(n + 1, back_k)
max_memo = [-(10 ** 18)] * min(n + 1, back_k)
# print(n, x, d, g, back_k, offset)
# print(lowers)
# print(uppers)

ans = 0
for k in range(n + 1):
    min_acc = lowers[k]
    max_acc = uppers[k]

    if k < back_k:
        min_memo[k] = min_acc - offset
        max_memo[k] = max_acc - offset
        ans += max_acc - min_acc + 1
        # print(k, ans, min_acc, max_acc, max_acc - min_acc + 1)
        continue

    kk = k % back_k
    back_min = min_memo[kk]
    back_max = max_memo[kk]

    if back_max < min_acc or max_acc < back_min:
        min_memo[kk] = min_acc - offset
        max_memo[kk] = max_acc - offset
        ans += max_acc - min_acc + 1
    else:
        current = max_acc - min_acc + 1
        duplicated = min(max_acc, back_max) - max(min_acc, back_min) + 1
        ans += current - duplicated
        min_memo[kk] = min(min_acc, back_min) - offset
        max_memo[kk] = max(max_acc, back_max) - offset

    # print(k, ans, min_acc, max_acc, back_min, back_max)

print(ans)
a, b = input().strip()
print(a,b)

### FIXED CODE ###

M, D = input().split()
count = 0

for m in range(4, int(M)+1):
  for d in range(22, int(D)+1):
    d10 = int(str(d)[0])
    d1 = int(str(d)[1])
    if d10>=2 and d1>=2 and d10*d1==m:
      count+=1
      
print(count)
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a--
elif u==t:
    b--
print({} {},format(a,b))

### FIXED CODE ###

s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a-= 1
else: b -= 1
print(a, b)
def f(s, cost, route, ans):
    route.append(s)
    ans += cost[s]
    del cost[s]
    for k, c in data.items():
        if s in k:
            a, b = k
            b = b if s == a else a
        if not b in route:
            if not b in cost or c < cost[b]:
                cost[b] = c
    if cost:
        s = sorted(cost.items(), key=lambda x: x[1])[0][0]
        return f(s, cost, route, ans)
    else:
        return ans

while True:
    n, m = map(int, raw_input().split())
    if n == m == 0: break
    data = {}
    for i in range(m):
        a, b, c = map(int, raw_input().split())
        data[(a, b)] = c
    else:
        print f(0, {0:0}, [], 0)

### FIXED CODE ###

def f(s, cost, route, ans):
    route.append(s)
    ans += cost[s]
    del cost[s]
    for k, c in data.items():
        if s in k:
            a, b = k
            if s == a:
                if not b in route:
                    if not b in cost or c < cost[b]:
                        cost[b] = c
                        del data[(a, b)]
            elif s == b:
                if not a in route:
                    if not a in cost or c < cost[a]:
                        cost[a] = c
                        del data[(a, b)]
    if cost:
        s = sorted(cost.items(), key=lambda x: x[1])[0][0]
        return f(s, cost, route, ans)
    return ans

while 1:
    n, m = map(int, raw_input().split())
    if n == m == 0: break
    data = {}
    for i in range(m):
        a, b, c = map(int, raw_input().split())
        data[(a, b)] = c
    print f(0, {0:0}, [], 0)
s=input()
f==-1
if s[2]==s[3]:
    if s[4]==s[5]:
        f==1
if f==1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s=input()
f=-1
if s[2]==s[3]:
    if s[4]==s[5]:
        f=1
if f==1:
    print('Yes')
else:
    print('No')
k = int(input())
a, b = [int(i) for i in input().split]

if a % k == 0 or (a % k - b % k) >= 0:
  print('OK')
else:
  print('NG')

### FIXED CODE ###

k = int(input())
a, b = [int(i) for i in input().split()]

if b-a >= k-1:
  print('OK')
elif a % k - b % k > 0 or a % k == 0:
  print('OK')
else:
  print('NG')
# coding: UTF8

#input = "10 49 30"
l = map(int, input().split())
# l = map(int, input.split())
l.sort()
a = l[0]
b = l[1]
c = l[2]

if a + b == c:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

# coding: UTF8

#input = "10 40 30"
#l = map(int, input.split())
l = list(map(int, input().split()))
l.sort()
a = l[0]
b = l[1]
c = l[2]

if a + b == c:
	print("Yes")
else:
	print("No")
a = input()
if int(a[6])<=4:
  print('Heisei')
elif int(a[6])>4 or int(a[5])=1:
  print('TBD')

### FIXED CODE ###

a = input()
if int(a[5])==0 and int(a[6])<=4:
  print('Heisei')
else:
  print('TBD')
n = int(input())
a = list(map(int,input().split()))
i = 0
j = 1
ans = 0
p = 0
while True:
    if j == n:
        j = min(i+1,nextj)
        p = 0
        i += 1
    
    if p == 0 and a[i] + a[j] == j-i:
        ans += 1
        nextj = j
        p = 1
    elif p == 1 and a[i] + a[j] == j-i:
        ans += 1
    j += 1
    
    if i == n-1:
        print(ans)
        exit()

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
mae = {}
ans = 0
for i in range(n):
    mae[i+a[i]]=mae.get(i+a[i],0)+1
    ans += mae.get(i-a[i],0)
print(ans)
a = input()
b = input()
c = input()
d = input()
if a*b > c*d:
    print a*b
elif c*d > a*b:
    print c*d
else:
    print a*b

### FIXED CODE ###

A ,B ,C, D = [int(x) for x in input().strip().split(' ')]
r1 ,r2  =A*B, C*D
if (r1 > r2):
    print(r1)
elif(r2 >r1):
    print(r2)
else:
    print(r1)
s = input()

ans = []
flag = 0

#print(s)
#print(s[0])

for i in range(len(s)):
    if flag == 0:
        if s[i] == "A":
            flag = 1
            ans.append(s[i])

    else:
        if s[i] == "Z":
            if s[i+1] != "Z":
                flag = 0
                ans.append(s[i])
                break
            
            else:
                ans.append(s[i])

        else:
            ans.append(s[i])
        

#print(ans)

#print("".join(ans))

print(len(ans))


### FIXED CODE ###

s = input()

flag = 0

a = 200000
z = 0

for i in range(len(s)):
    if s[i] == "A" and a > i:
        a = i

    elif s[i] == "Z" and z < i:
        z = i

print(z - a + 1)
N = int(input())
    ans = 1
    for i in range(N):
        ans = ans * (i + 1) % (10**9 + 7)
    print(ans)

### FIXED CODE ###

N = int(input())
ans = 1
for i in range(N):
    ans = ans * (i + 1) % (10**9 + 7)
print(ans)
import math
N = int(input())
A = [int(j) for j in input().split()]
gcdmx = 0
for j in range(0,N):
    gcdloc = 0
    C = A[:]
    del C[j]
    for k in range(0,N-1):
        gcdloc = math.gcd(gcdloc,C[k])
    gcdmx = max(gcdloc,gcdmx)
print(gcdmx)

### FIXED CODE ###

import fractions as f

n = int(input())
A = [int(_) for _ in input().split()]

left = []
right = []

left.append(A[0])
for i in range(1,n):
    left.append(f.gcd(left[i-1],A[i]))

right.append(A[n-1])
for i in range(1,n):
    right.append(f.gcd(right[i-1],A[n-1-i]))

ans = 0
for i in range(n):
    if i == 0:
        ans = right[n-2]
    if i >= 1 and i <= n-2:
        ans = max(ans,f.gcd(left[i-1],right[n-2-i]))
    if i == n-1:
        ans = max(ans,left[n-2])
print(ans)
N,K = map(int,input().split())

if K = 1:
    print(0)
else:
    print(N-K)

### FIXED CODE ###

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

if K == 1:
    print(0)
else:
    print(N-K)
N = int(input()) 
W = list(map(int, input().split()))
x = sum(W)

for i in range(N):
	S_1 = sum(W[:i+1])
	S_2 = sum(W) - S_1
    x_current = abs(S_2 - S_1)
    if x_current < x:
      x = x_current

print(x)

### FIXED CODE ###

N = int(input()) 
W = list(map(int, input().split()))
x = sum(W)
 
for i in range(N):
	S_1 = sum(W[:i+1])
	S_2 = sum(W) - S_1
	x_current = abs(S_2 - S_1)
	if x_current < x:
		x = x_current

print(x)
a,b=input().split()
print(a)
count=0
for i in range(a-1):
    count+=1
if a<b:
    count+=1
print(count)


### FIXED CODE ###

a,b=map(int,input().split())
if a>b:
    print(a-1)
else:
    print(a)
a,b=map(int,input().split())

if a>b
	print("safe")

else:
	print("unsafe")

### FIXED CODE ###

a,b=map(int,input().split())
 
if a>b:
	print("safe")
 
else:
	print("unsafe")
def main():
    a = int(input())
    lists= [int(input()) for _ in range(a)]
 
    temp = lists.copy()
    first = max(temp)
    temp.remove(first)
    second = max(temp)
 
    for i in range(a):
        if lists[i] == first:
            print(second)
        else:
            print(first)
 
if __name__ == '__main__' :
    main()

### FIXED CODE ###

r = int(input())
S = 3 * r * r
print(S)
a=int(input())
b=int(input())
c=int(input())
x=int(input())
x=int(x/50)
countlist=[]

for e in range(a+1):
    if x < e*10:
        break
    else:
        x -= e*10
        count=0
        for f in range(b+1):
            if x < f*2 :
                break
            else:
                x-=2*f
                count=0
                for g in range(c+1):
                	if x<g:
                      break
                    else:
                     	count = count +1
						countlist.append(count)

print(sum(countlist))
                
 




### FIXED CODE ###

#define
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count=0
countlist=[]
#sorting
for e in range(0,a+1):
    if e*500 <= x:
        y=x-e*500
        for f in range(0,b+1):
            if f*100 <= y:
                z=y-100*f
                for g in range(0,c+1):
                    if g*50 == z :                                            
                        count = count +1

print(count)
if A+B > A-B and A*B:
  print(A+B)
elif A-B > A+B and A*B :
  print(A-B)
else A*B > A+B and A-B :
  print(A*B)

### FIXED CODE ###

a,b=map(int, input().split())
print(max(a+b,a-b,a*b))
import sys
sys.setrecursionlimit(100000000)

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

if M == 0:
    A = []
else:
    A = [0]*M

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

A.append(N+1)

# DP version
DP = [0]*(N+1)
DP[0] = 1
# １段の階段を登るやり方の数
DP[1] = 1
# 2段の階段を登るやり方の数
DP[2] = 2

for i in range(3,N):
    DP[i] = DP[i-1] + DP[i-2]

def step_comb(L):
    if DP[L]>0:
        return DP[L]
    DP[L] = step_comb(L-1) + step_comb(L-2)
    return DP[L]
    
total_comb = 1
NOW = 0
for a in A:
    if NOW == a:
        print(0)
        sys.exit()
    L = a-1-NOW
    total_comb *= step_comb(L)
    NOW = a + 1
    if NOW == N:
        break
    
print(total_comb % 1000000007 )



### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)

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

if M == 0:
    A = []
else:
    A = [0]*M
    for i in range(M):
        A[i] = int(input())

A.append(N+1)

# DP version
DP = [0]*(N+1)
DP[0] = 1
# １段の階段を登るやり方の数
DP[1] = 1
# 2段の階段を登るやり方の数
#DP[2] = 2

for i in range(2,N+1):
    DP[i] = DP[i-1] + DP[i-2]

def step_comb(L):
    if DP[L]>0:
        return DP[L]
    DP[L] = step_comb(L-1) + step_comb(L-2)
    return DP[L]
    
total_comb = 1
NOW = 0
for a in A:
    if NOW == a:
        print(0)
        sys.exit()
    L = a-1-NOW
    total_comb *= step_comb(L)
    NOW = a + 1
    if NOW == N:
        break
    
print(total_comb % 1000000007 )
a = list(map(int,input().split()))
a.sort()[2]
print(a[2]-a[0])


### FIXED CODE ###

a = list(map(int,input().split()))
a.sort()
print(a[2]-a[0])
S, T = input().split
print(T, S, sep='')

### FIXED CODE ###

S, T = input().split()
print(T, S, sep='')
a=int(input())
b=list(map(int,input().split()))
c=1
for i in range(a):
  c=c*b[i]
if(c>1000000000000000000):
  print(-1)
else:
  print(c)

### FIXED CODE ###

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