Harryxun/stf_run huggingface dataset:
#
# abc047 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 4 2
2 1 1
3 3 4"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 4 3
2 1 1
3 3 4
1 4 2"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3"""
        output = """64"""
        self.assertIO(input, output)


def resolve():
    W, H, N = map(int, input().split())
    a = []
    ox = 0
    oy = 0
    for _ in range(N):
        a.append(list(map(int, input().split())))
    for i in range(N):
        if a[i][2] == 1:
            ox = max(a[i][0], ox)
        elif a[i][2] == 2:
            W = min(a[i][0], W)
        elif a[i][2] == 3:
            oy = max(a[i][1], oy)
        elif a[i][2] == 4:
            H = min(a[i][1], H)
    print(max((W-ox))*max((H-oy), 0))


if __name__ == "__main__":
    # unittest.main()
    resolve()


### FIXED CODE ###

#
# abc047 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 4 2
2 1 1
3 3 4"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 4 3
2 1 1
3 3 4
1 4 2"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3"""
        output = """64"""
        self.assertIO(input, output)


def resolve():
    W, H, N = map(int, input().split())
    a = []
    ox = 0
    oy = 0
    for _ in range(N):
        a.append(list(map(int, input().split())))
    for i in range(N):
        if a[i][2] == 1:
            ox = max(a[i][0], ox)
        elif a[i][2] == 2:
            W = min(a[i][0], W)
        elif a[i][2] == 3:
            oy = max(a[i][1], oy)
        elif a[i][2] == 4:
            H = min(a[i][1], H)
    print(max(W-ox, 0)*max(H-oy, 0))


if __name__ == "__main__":
    # unittest.main()
    resolve()
n,q = [int(i) for i in input().split()]
s = input()

for i in range(q):
    l,r = [int(i) for i in input().split()]
    p = s[l-1:r]
    ans = re.findall("AC",p)
    print(len("AC"))


### FIXED CODE ###

n,q = [int(i) for i in input().split()]
s = input()
cumsum = [0]*n
ans = 0
flag = False

for i in range(n):
    if flag:
        if s[i] == "C":
            ans += 1

    cumsum[i] = ans     

    flag = False

    if s[i] == "A":
        flag = True
    


for i in range(q):
    l,r = [int(i) for i in input().split()]
    ans = cumsum[r-1] - cumsum[l-1]
    print(ans)
#70c
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())

T_set = set()

for _ in range(N):
    t = int(input())
    T_set.add(t)
    
T_list = list(T_set)
print(lcm_list(T_list))


### FIXED CODE ###

#70c
from functools import reduce
import math
import fractions

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())

T_set = set()

for _ in range(N):
    t = int(input())
    T_set.add(t)
    
T_list = list(T_set)
print(lcm_list(T_list))
import sys
for n in sys.stdin:
    ans = []
    n = int(n)
    nb = format(n,'b')
    nb.reverse
    nb += " "*(10-len(nb))
    for i in xrange(10):
    	if nb[i] == 1:
    		ans.append(str(2**i))
    print ' '.join(ans)

### FIXED CODE ###

import sys
nyu = sys.stdin.read()
nyu = map(int,nyu.split())
for n in nyu:
   	ans = []
	for b in [512,256,128,64,32,16,8,4,2,1]:
		if n >= b:
			n -= b
			ans.append(b)
	ans.reverse()
	ans = map(str,ans)
	ans = ' '.join(ans)
	print ans
X=int(input())
import numpy as np
dp=np.array([0]*X)
i=0
while X not in dp:
  i+=1
  dp+=np(dp+np.array(X*[i]))
print(i)

### FIXED CODE ###

X=int(input())
i=1
sum1=1
while sum1<X:
  i+=1
  sum1=sum1+i
print(i)
# 入力
n, k, x, y = map(int, input().split())

# 処理
first_stay = k * x
second_stay = (n - k) * y

total_price = first_stay + second_stay

# 出力
print(total_price)

### FIXED CODE ###

# 入力
total_days = int(input())
days_normal_price = int(input())
normal_price = int(input())
discount_price = int(input())

# 処理
if total_days <= days_normal_price:
    answer =total_days * normal_price
    print(answer)
elif total_days > days_normal_price:
    first = normal_price * days_normal_price
    second = (total_days - days_normal_price) * discount_price
    answer = first + second
    print(answer)
import sys
input = sys.stdin.readline


def solve(S):
    def split(sub, result=[]):
        s = sub.partition('LR')
        if s[1] == '':
            return result + [s[0]]
        else:
            new_s = s[0] + s[1][0]
            rem = s[1][1] + s[2]
            return split(rem, result + [new_s])

    def count(sub):
        c = [0] * len(sub)
        l = sub.index('L')

        # R
        i = 1
        while l - i >= 0:
            c[l - (i % 2)] += 1
            i += 1

        # L
        i = 0
        while l + i < len(sub):
            c[l - (i % 2)] += 1
            i += 1

        return c

    ans = []
    for s in split(S):
        ans += count(s)
    return ans


def main():
    S = input().strip()
    ans = solve(S)

    for x in ans:
        print(x, end=' ')


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


def solve(S):
    def split(sub):
        result = []
        s = sub.partition('LR')
        while s[1] != '':
            new_s = s[0] + s[1][0]
            rem = s[1][1] + s[2]
            result.append(new_s)
            s = rem.partition('LR')
        return result + [s[0]]

    def count(sub):
        c = [0] * len(sub)
        l = sub.index('L')

        # R
        i = 1
        while l - i >= 0:
            c[l - (i % 2)] += 1
            i += 1

        # L
        i = 0
        while l + i < len(sub):
            c[l - (i % 2)] += 1
            i += 1

        return c

    ans = []
    for s in split(S):
        ans += count(s)
    return ans


def main():
    S = input().strip()
    ans = solve(S)

    for x in ans:
        print(x, end=' ')


if __name__ == "__main__":
    main()
a,b=map(int,input().split())
if a=<b:
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

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

A,B,C,D=map(int,input().split())


kobaisu=C//math.gcd(C,D)*D


ans=B -(B//C+B//D-B//kobaisu)

ans2=(A-1)-((A-1)//C +(A-1)//D - (A-1)//kobaisu)

print(int(ans-ans2))

### FIXED CODE ###

import fractions

A,B,C,D=map(int,input().split())


kobaisu=C//fractions.gcd(C,D)*D


ans=B -(B//C+B//D-B//kobaisu)

ans2=(A-1)-((A-1)//C +(A-1)//D - (A-1)//kobaisu)

print(int(ans-ans2))
d,n = map(int, input().split())
print(n*(10**d)

### FIXED CODE ###

d,n = map(int, input().split())
if n<100:
    print(n*(100**d))
else:
    print((n+1)*(100**d))
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A_list = list(map(int, input().split()))

ans_list = [1]
history_list = [0 for _ in range(N)]
before_town = 1
loop_start_town = 10 ** 10
for i in range(N):
    now_town = A_list[before_town - 1]
    if history_list[now_town - 1] == 1:
        break
    ans_list.append(now_town)
    before_town = now_town

if len(ans_list) >= K:
    print(ans_list[K])
else:
    loop_start_idx = ans_list.index(A_list[ans_list[-1] - 1])
    loop_len = len(ans_list)
    ans_list = ans_list[loop_start_idx:]
    mod_num = (K - loop_len) % (loop_len - loop_start_idx)
    print(ans_list[mod_num])

### FIXED CODE ###

# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A_list = list(map(int, input().split()))

ans_list = [1]
history_list = [0 for _ in range(N)]
before_town = 1
loop_start_town = 10 ** 10
for i in range(N):
    now_town = A_list[before_town - 1]
    if history_list[now_town - 1] == 1:
        break
    ans_list.append(now_town)
    before_town = now_town

if len(ans_list) > K:
    print(ans_list[K])
else:
    loop_start_idx = ans_list.index(A_list[ans_list[-1] - 1])
    loop_len = len(ans_list)
    ans_list = ans_list[loop_start_idx:]
    mod_num = (K - loop_len) % (loop_len - loop_start_idx)
    print(ans_list[mod_num])
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

A, B, K = [int(x) for x in readline().rstrip().split()]
gcd_ = np.gcd(A, B)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

print(make_divisors(gcd_)[K - 1])


### FIXED CODE ###

import sys
import fractions
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

A, B, K = [int(x) for x in readline().rstrip().split()]
gcd_ = fractions.gcd(A, B)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
print(make_divisors(gcd_)[-K])
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

j=lcm(A[0],A[1])
for i in range(2,len(A)):
    j=lcm(j, A[i])

tmp=[]
for i in A:
    tmp.append((j-1)%i)
ans=sum(tmp)
print(ans)


### FIXED CODE ###


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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

j=lcm(A[0],A[1])
for i in range(2,len(A)):
    j=lcm(j, A[i])

tmp=[]
for i in A:
    tmp.append((j-1)%i)
ans=sum(tmp)
print(ans)
n=int(input())
B=list(map(int,input().split()))  
C=[0]*n
C[0]=B[0]
C[1]=B[1]
for i in range(1,n-1):
    if C[i]>B[i]:
        C[i+1]=B[i]
        C[i]=B[i]
    else:
        C[i+1]=B[i]
print(sum(C))
    



### FIXED CODE ###

n=int(input())
B=list(map(int,input().split()))  
C=[0]*n
C[0]=B[0]
C[1]=B[0]
for i in range(1,n-1):
    if C[i]>B[i]:
        C[i+1]=B[i]
        C[i]=B[i]
    else:
        C[i+1]=B[i]
print(sum(C))
n = int(input())
l = list(list(map(int,input().split())) for _in range(n))
x = input()
bit = 0
su = 0
for j,k in l:
  if j==x:
    bit = 1
  if bit==1:
    su += k
print(su)

### FIXED CODE ###

n = int(input())
l = list(list(map(str,input().split())) for _ in range(n))
x = input()
bit = 0
su = 0
for j,k in l:
  if j==x:
    bit = 1
    su -= int(k)
  if bit==1:
    su += int(k)
print(su)
n, x = (int(i) for i in input().split()) 
a = sorted([int(i) for i in input().split()])

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

import functools

if len(a) == 1:
    print(abs(a[0] - x))
    exit()

diff = []
for i in range(len(a)-1):
    diff.append(a[i+1] - a[i])

list_gcd = functools.reduce(gcd, diff)

import bisect

bi_index = bisect.bisect_left(a, x)
if a[bi_index] == x:
    print(list_gcd)
    exit()

if bi_index == 0:
    print(gcd(list_gcd, a[0]-x))
    exit()

if bi_index == len(a):
    print(gcd(list_gcd, x-a[-1]))
    exit()

print(functools.reduce(gcd, [list_gcd, x-a[bi_index-1], a[bi_index]-x ]))


### FIXED CODE ###

n, x = (int(i) for i in input().split()) 
a = sorted(list(set([int(i) for i in input().split()])))

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

import functools

if len(a) == 1:
    print(abs(a[0] - x))
    exit()

diff = []
for i in range(len(a)-1):
    diff.append(a[i+1] - a[i])

list_gcd = functools.reduce(gcd, diff)

import bisect

bi_index = bisect.bisect_left(a, x)
if bi_index == len(a):
    print(gcd(list_gcd, x-a[-1]))
    exit()

if a[bi_index] == x:
    print(list_gcd)
    exit()

if bi_index == 0:
    print(gcd(list_gcd, a[0]-x))
    exit()

print(functools.reduce(gcd, [list_gcd, x-a[bi_index-1], a[bi_index]-x ]))
D,S,T = map(int,input().split()))
print("Yes" if D<=S*T else "No")

### FIXED CODE ###

D,S,T = map(int,input().split())
print("Yes" if D<=S*T else "No")
N = int(input())
A = list(map(int, input().split()))
currentSum = 0
count3 = 0
count4 = 0

currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count3 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] <= 0 and restSum == 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
        
currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count4 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] >= 0 and restSum == 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
        
print(count1, count2, count3, count4)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
currentSum = 0
count1 = 0
count2 = 0
count3 = 0
count4 = 0

for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count1 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count1 += abs(currentSum) + 1
        currentSum = -1
    elif currentSum == 0 and restSum == 0:
        count1 += 1
        currentSum = -1

currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count2 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count2 += abs(currentSum) + 1
        currentSum = -1
    elif currentSum == 0 and restSum == 0:
        count2 += 1
        currentSum = 1

currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count3 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] <= 0 and restSum == 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
        
currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count4 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] >= 0 and restSum == 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
        
print(min(count1, count2, count3, count4))
n,k = (int(x) for x in input().split())
town = [int(i) for i in input().split()]
warp  = [1]
checklist = [0]+[-1]*n
i = 0
j = 0
while j<=n:
    warp.append(town[i])
    if checklist[town[i]-1]!=-1:
        s = checklist[town[i]-1]
        warp = warp[s:j]
        break
    checklist[town[i]-1] = j
    i = town[i]-1
    j += 1


m = len(warp)
print(warp[(k-s)%m])


### FIXED CODE ###

n,k = (int(x) for x in input().split())
town = [int(i) for i in input().split()]
warp  = [1]
checklist = [0]+[-1]*n
i = 0
j = 1
s = 0
while j<=n:
    warp.append(town[i])
    if checklist[town[i]-1]!=-1:
        s = checklist[town[i]-1]
        loop = warp[s:j]
        break
    checklist[town[i]-1] = j
    i = town[i]-1
    j += 1
if k>=s:
    m = len(loop)
    print(loop[(k-s)%m])
else:
    print(warp[k])
import sys
sys.setrecursionlimit(2000)
h,w = map(int,input().split())
s = []

for i in range(h):
    s.append(list(input()))

from collections import deque

def bfs(i,j,dist):
    seen[i][j] = dist
    lis = [[i-1,j],[i,j-1],[i+1,j],[i,j+1]]
    for place in lis:
        if place[0]<0 or place[0]>=h or place[1]<0 or place[1]>=w:
            continue
        if seen[place[0]][place[1]] != -1 or s[place[0]][place[1]]=="#":
            continue
        que.append([place[0],place[1],dist+1])
    if len(que):
        new = que.popleft()
        bfs(new[0],new[1],new[2])
    else:
        return


mx = 0
for i in range(h):
    for  j in range(w):
        if s[i][j]=="#":
            continue
        seen = [[-1 for _ in range(w)]for _ in range(h)]
        que = deque()
        bfs(i,j,0)
        mx = max(mx,max(max(seen)))
        #print(seen)
#print(seen)
print(mx)


### FIXED CODE ###

import sys
sys.setrecursionlimit(3000)

import numpy as np

h,w = map(int,input().split())
s = []

for i in range(h):
    s.append(list(input()))

from collections import deque

def bfs(i,j,dist):
    seen[i][j] = dist
    lis = [[i-1,j],[i,j-1],[i+1,j],[i,j+1]]
    for place in lis:
        if place[0]<0 or place[0]>=h or place[1]<0 or place[1]>=w:
            continue
        if seen[place[0]][place[1]] != -1 or s[place[0]][place[1]]=="#":
            continue
        if [place[0],place[1],dist+1] in que:
            continue
        que.append([place[0],place[1],dist+1])
    if len(que):
        new = que.popleft()
        bfs(new[0],new[1],new[2])
    else:
        return


mx = 0
for i in range(h):
    for  j in range(w):
        if s[i][j]=="#":
            continue
        seen = [[-1 for _ in range(w)]for _ in range(h)]
        que = deque()
        bfs(i,j,0)
        ast = np.array(seen)
        tmp = np.amax(ast)
        mx = max(mx,tmp)
        #print(seen)
            #print(*seen,sep="\n")
print(mx)
S=input()
if S[-1]==s:
    print("S"+"es")
else:
    print("S"+"s")

### FIXED CODE ###

S=input()
if S[-1:]=="s":
    print(S+"es")
else:
    print(S+"s")
alfa=input()
N=int(alfa[0])
X=int(alfa[2])
#L=[int(input().split()) for i in range(N)]
L=input().split()


print(N,X,L)
D=0
count=0
for i in range(N):
    count+=1
    D+=int(L[i])
    if D>X:
        print(count)
        break


### FIXED CODE ###

alfa=input().split()
N=int(alfa[0])
X=int(alfa[1])
#L=[int(input().split()) for i in range(N)]
L=input().split()

#print(N,X,L)
D=0
count=1
for i in range(N):
    D+=int(L[i])
    if D>X:
        print(count)
        break
    else:
        count+=1

if D<=X:
    print(count)
s=input()
t=input()
length=len(s)
pointer=0
flag=True
for string in t:
    count=0
    while flag and (string != s[pointer%length]):
        pointer+=1
        count+=1
        flag= not(count==length)
    if not flag:
        break
    count+=1
if flag:
    if pointer<length*10**100
    print(pointer+1)
else:
    print(-1)

### FIXED CODE ###

s=input()
t=input()
length=len(s)
exi={chr(97+i): False for i in range(26)}
jump={chr(97+i): [0 for _ in range(2*length)] for i in range(26)}
cru={chr(97+i):0 for i in range(26)}
pointer=0
flag=True
for i,ch in enumerate(s*2):
    exi[ch]=True
    for j in range(cru[ch],i+1):
        jump[ch][j]=1+i-j
    cru[ch]=i+1
for ch in t:
    if exi[ch]:
        pointer+=jump[ch][pointer%length]
    else:
        flag=False
        break
if flag:
    print(pointer)
else:
    print(-1)
N, A, B = map(int, input().split())
sum = 0
ans = 0
for i in range(1, N+1):
    for k in range(len(str(i))-1):
        i = str(i)
        sum += int(i[k])
    if A<=sum<=B:
        ans += int
    sum = 0
print(ans)

### FIXED CODE ###

#9
N, A, B = map(int, input().split())
sum = 0
ans = 0
for i in range(1, N+1):
    i = str(i)
    for k in range(len(i)):
        sum += int(i[k])
    if A<=sum<=B:
        ans += int(i)
    sum = 0
print(ans)
n=int(input())
dp=[float("inf")]*100010
dp[0]=0

for i in range(n):
    power = 1
    while power <= n:
        dp[i + power] = min(dp[i + power],dp[i] + 1)
        power *= 6
    power = 1
    while power <= n:
        dp[i + power] = min(dp[i + power],dp[i] + 1)
        power *= 9

print(dp[n])

### FIXED CODE ###

N=int(input())
dp=[float('inf')]*100010
dp[0]=0
base=[1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049]


for i in range(N+1):
    for power in base:
        dp[i]=min(dp[i],dp[i-power]+1)

print(dp[N])
a=input()
s=input()
a=int(a)
s=int(s)
if a>=3200:
    print(s)
elif a<3200:
    print("red")

### FIXED CODE ###

a=input()
s=input()
a=int(a)
if a>=3200:
    print(s)
elif a<3200:
    print("red")
n = int(input())
li = list(map(int,input().split()))
cnt = 0
i = -1
count = []
while True:
    if i == -n:
        break
    if li[i] <= li[i-1]:
        i = i-1
        cnt+=1
    else:
        count.append(cnt)
        cnt = 0
        i = i -1
print(max(count))

### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
cnt = 0
ans = 0
for i in range(n-1):
    if li[i]>=li[i+1]:
        cnt+=1
    else:
        if cnt>ans:
            ans = cnt
        cnt = 0
if cnt>ans:
    ans = cnt
print(ans)
w,h=map(int,input().split())

x,y=map(int,input().split())

if x == w/2 and y == h/2:
  f = 1
else:
  f = 0
  
print(w*h/2,f)

### FIXED CODE ###

w,h,x,y=map(int,input().split())

if x == w/2 and y == h/2:
  f = 1
else:
  f = 0
  
print(w*h/2,f)
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() 

r = list(input())
print(r*r)

### FIXED CODE ###

import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() 

r = ni()
print(r*r)
import numpy as np
import math

N = int(input())

A = np.empty(N)
for i in range(N):
   A[i] = int(input())


max_a = np.max(A)
max_i = np.argmax(A)

for i in range(N):
   if(i == max_i):
      max_n0 = np.max(A[0:i-1])
      max_n1 = np.max(A[i+1,N-1])
      if(max_n0 > max_n1):
         print(max_n0)
      else:
         print(max_n1)
   else:
      print(max_a)


### FIXED CODE ###

import numpy as np
import math

N = int(input())

A = np.empty(N)
for i in range(N):
   A[i] = int(input())


max_a = np.max(A)
max_i = np.argmax(A)

for i in range(N):
   if(i == max_i):
      aa = np.sort(A)
      print(int(aa[-2]))
   else:
      print(int(max_a))