Harryxun/stf_run huggingface dataset:
from heapq import heappush, heappop

def dijkstra(adjList, s):
    num = len(adjList)
    dist = [float("INF") for i in range(10)]
    queue = []
    heappush(queue,(0,s))
    dist[s] = 0
    
    while queue != []:
        v_cost, v = heappop(queue)
        if dist[v] < v_cost:
            continue
        for u_cost, u in adjList[v]:
            if u != v and u_cost + dist[v] < dist[u]:
                dist[u] = u_cost + dist[v]
                heappush(queue, (dist[u], u))
    return dist


from sys import stdin
def IL():return list(map(int, stdin.readline().split()))

h,w = IL()
G = [[] for i in range(10)]

for i in range(10):
    l = IL()
    for j in range(10):
        G[i].append((l[j],j))


dist = dijkstra(G, 8)
ans = 0
memo={}
for i in range(h):
    for i in IL():
        if abs(i) == 1:
          pass
        elif i in memo:
          ans += memo[i]
        else:
            t = dijkstra(G, i)[1] 
            memo[i] = t
            ans += t

print(ans)from heapq import heappush, heappop

def dijkstra(adjList, s):
    num = len(adjList)
    dist = [float("INF") for i in range(10)]
    queue = []
    heappush(queue,(0,s))
    dist[s] = 0
    
    while queue != []:
        v_cost, v = heappop(queue)
        if dist[v] < v_cost:
            continue
        for u_cost, u in adjList[v]:
            if u != v and u_cost + dist[v] < dist[u]:
                dist[u] = u_cost + dist[v]
                heappush(queue, (dist[u], u))
    return dist


from sys import stdin
def IL():return list(map(int, stdin.readline().split()))

h,w = IL()
G = [[] for i in range(10)]

for i in range(10):
    l = IL()
    for j in range(10):
        G[i].append((l[j],j))


dist = dijkstra(G, 8)
ans = 0
memo={}
for i in range(h):
    for i in IL():
        if abs(i) == 1:
          pass
        elif i in memo:
          ans += memo[i]
        else:
            t = dijkstra(G, i)[1] 
            memo[i] = t
            ans += t

print(ans)

### FIXED CODE ###

from heapq import heappush, heappop

def dijkstra(adjList, s):
    num = len(adjList)
    dist = [float("INF") for i in range(10)]
    queue = []
    heappush(queue,(0,s))
    dist[s] = 0
    
    while queue != []:
        v_cost, v = heappop(queue)
        if dist[v] < v_cost:
            continue
        for u_cost, u in adjList[v]:
            if u != v and u_cost + dist[v] < dist[u]:
                dist[u] = u_cost + dist[v]
                heappush(queue, (dist[u], u))
    return dist


from sys import stdin
def IL():return list(map(int, stdin.readline().split()))

h,w = IL()
G = [[] for i in range(10)]

for i in range(10):
    l = IL()
    for j in range(10):
        G[i].append((l[j],j))


ans = 0
memo={}
for i in range(h):
    for i in IL():
        if abs(i) == 1:
          pass
        elif i in memo:
          ans += memo[i]
        else:
            t = dijkstra(G, i)[1] 
            memo[i] = t
            ans += t

print(ans)
a,b,c = map(int,input().split())
print(min(a+b,a+c,b+c)

### FIXED CODE ###

a,b,c = map(int,input().split())
print(min(a+b,a+c,b+c))
nums = []
nums = list(map(int, input().split()))
nums = sorted(nums, reverse=True)

cf = nums[0]

for i in range(2, n):
    nums_min = min(nums[i-1], nums[i-2])
    cf += nums_min

print(cf)




### FIXED CODE ###

n = int(input())

nums = []
nums = list(map(int, input().split()))
nums = sorted(nums, reverse=True)

cnt = 0

fir_num = nums[0]

del nums[0]

for i in range(n-2):
    fir_num += nums[int(i/2)]


print(fir_num)
N,K=map(input().split())
S=str.input()
S[K-1] = S[K-1].lower()
print(S)


### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())
S[K-1] = S[K-1].lower()
print("".join(S))
a,b,c=map(int,input().split("/"))
print("2018/"+string(b)+"/"+string(c))


### FIXED CODE ###

a,b,c=map(str,input().split("/"))
print("2018/"+b+"/"+c)
n = int(input())
h = [ int(_) for _ in input().split() ]

flag = True
h_s = [ x-1 for x in h ]
h_sorted = sorted(h)

for i in range(0,h-1):
    if h[i] > h[i+1]:
        h[i] = h[i]-1
    print(h)   
        
for i in range(0,h-1):
    if h[j] > h[j+1]:
        print('No')
        flag = False
        
if flag == True:
    print('Yes')

### FIXED CODE ###

# ABC 136 C
n = int(input())
h = [ int(_) for _ in input().split() ]
flag = True

for i in range(len(h)-1, 0, -1):
    if h[i-1] == h[i] +1:
        h[i-1] = h[i-1]-1  
        
for j in range(0,len(h)-1):
    if h[j] > h[j+1]:
        print('No')
        flag = False
        break
        
if flag == True:
    print('Yes')
def divide(x, y):
	s = 1
	if(x < 0):s *= -1
	if(y < 0):s *= -1
	return abs(x) / abs(y) * s
	

def _split(_src):
	c = 0
	l = len(_src)
	
	if l == 0:
		return []

	while c < l and ord('0') <= ord(_src[c]) <= ord('9'):
		c += 1
		
	if c == 0:
		return [_src[0]] + _split(_src[1:])
	
	else:
		return [int(_src[:c])] + _split(_src[c:])
		

def evaluate(src):
	if len(src) == 1:
		return src[0]
		
	if "(" in src:
		l = src.index("(")
		r = src.index(")")
		mid = evaluate(src[l + 1:r])
		return evaluate( src[:l] + [mid] + src[r + 1:])
	
	operators = [("+", lambda x,y:x + y),
				 ("-", lambda x,y:x - y),
				 ("*", lambda x,y:x * y),
				 ("/", divide)
				]	
	
	for (op,func) in operators:
		if op in src:
			p = src.index(op)
			l = evaluate(src[:p])
			r = evaluate(src[p + 1:])
			return func(l, r)
	
	
for t in xrange(input()):
	_src = raw_input()[:-1]
	src = _split(_src)
	print evaluate(src)

### FIXED CODE ###

def divide(x, y):
    s = 1
    if(x < 0):s *= -1
    if(y < 0):s *= -1
    return abs(x) / abs(y) * s     

operator = {"+":(lambda x,y: x+y),
            "-":(lambda x,y: x-y),
            "*":(lambda x,y: x*y),
            "/":divide
            }

def ind(src, x):
    if x not in src:return 1<<30
    return src.index(x)
 
def _split(_src):
    c = 0
    l = len(_src)
    if l == 0:
        return []
    while c < l and ord('0') <= ord(_src[c]) <= ord('9'):
        c += 1

    if c == 0:
        return [_src[0]] + _split(_src[1:])
    else:
        return [int(_src[:c])] + _split(_src[c:])
         
 
def evaluate(src):
    if len(src) == 1:
        return src[0]
         
    if "(" in src:
        l = src.index("(")
        r = l
        st = 1
        while st:
            r += 1
            if src[r] == "(": st += 1
            if src[r] == ")": st -= 1
        
        mid = evaluate(src[l + 1:r])
        return evaluate( src[:l] + [mid] + src[r + 1:])
    
    pos = min(ind(src, "*"), ind(src,"/"))
    if(pos == 1<<30):
        pos = min(ind(src, "+"), ind(src, "-"))
    op = src[pos]
    l, r = src[pos - 1], src[pos + 1]
    mid = operator[op](l, r)
    return evaluate(src[:pos - 1] + [mid] + src[pos + 2:])

     
for t in xrange(input()):
    _src = raw_input().strip("=")
    src = _split(_src)
    print evaluate(src)
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * n
ans = []
l[0] = (p[0] + 1) / 2
for i in range(1, n):
    l[i] = l[i - 1] + (p[i] + 1) / 2
for i in range(n - k):
    ans.append(l[i + k] - l[i])
print(max(ans))

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * (n + 1)
ans = []
for i in range(n):
    l[i + 1] = l[i] + (p[i] + 1) / 2
for i in range(n - k + 1):
    ans.append(l[i + k] - l[i])
print(max(ans))
N, W = map(int, input().split())
X = [0] + [-1] * 110000
ma = 0
for i in range(N):
    w, v = map(int, input().split())
    
    for j in range(len(X))[::-1]:
        if X[j] >= 0:
            if X[j] + w <= W:
                if j + v > 100000:
                    break
                if X[j+v] < 0:
                    # print(j+v, "->", X[j]+w)
                    X[j+v] = X[j]+w
                    ma = max(ma, j+v)
                else:
                    X[j+v] = min(X[j+w], X[j]+w)
                # print(X[:100])

print(ma)

### FIXED CODE ###

N, W = map(int, input().split())
X = [0] + [-1] * 110000
ma = 0
for i in range(N):
    w, v = map(int, input().split())
    
    for j in range(len(X))[::-1]:
        if X[j] >= 0:
            if X[j] + w <= W:
                if X[j+v] < 0:
                    X[j+v] = X[j]+w
                    ma = max(ma, j+v)
                else:
                    X[j+v] = min(X[j+v], X[j]+w)

print(ma)
n = int(input())
x = int(input(),2)

def popcount(l):
    return bin(l).count("1")
def count(l):
    res = 0
    while l != 0:
        p = popcount(l)
        l %= p
        res += 1
    return res
m = popcount(x)
x_plus = x%(m+1)
x_minus = x%(m-1)
lis_plus = [0]*n
lis_minus = [0]*n
for i in range(n):
    if i == 0:
        lis_plus[i] = 1%(m+1)
        if m != 1:
            lis_minus[i] = 1%(m-1)
    else:
        lis_plus[i] = lis_plus[i-1]*2%(m+1)
        if m != 1:
            lis_minus[i] = lis_minus[i-1]*2%(m-1)
for i in range(n):
    if (x >> (n-i-1)) & 1:
        if m == 1:
            print(0)
        else:
            print(count((x_minus - lis_minus[-i-1])%(m-1)) + 1)
    else:
        print(count((x_plus + lis_plus[-i-1])%(m+1)) + 1)

### FIXED CODE ###

n = int(input())
x = int(input(),2)

def popcount(l):
    return bin(l).count("1")
def count(l):
    res = 0
    while l != 0:
        p = popcount(l)
        l %= p
        res += 1
    return res
m = popcount(x)
x_plus = x%(m+1)
if m != 1:
    x_minus = x%(m-1)
else:
    x_minus = 1
lis_plus = [0]*n
lis_minus = [0]*n
for i in range(n):
    if i == 0:
        lis_plus[i] = 1%(m+1)
        if m != 1:
            lis_minus[i] = 1%(m-1)
    else:
        lis_plus[i] = lis_plus[i-1]*2%(m+1)
        if m != 1:
            lis_minus[i] = lis_minus[i-1]*2%(m-1)
for i in range(n):
    if (x >> (n-i-1)) & 1:
        if m == 1:
            print(0)
        else:
            print(count((x_minus - lis_minus[-i-1])%(m-1)) + 1)
    else:
        print(count((x_plus + lis_plus[-i-1])%(m+1)) + 1)
n = int(input())
st = [input() for i in range(N)]
print('AC x ' + str(st.count("AC")))
print('WA x ' + str(st.count("WA")))
print('TLE x ' + str(st.count("TLE")))
print('RE x ' + str(st.count("RE")))

### FIXED CODE ###

n = int(input())
st = [input() for i in range(n)]
print('AC x ' + str(st.count("AC")))
print('WA x ' + str(st.count("WA")))
print('TLE x ' + str(st.count("TLE")))
print('RE x ' + str(st.count("RE")))
N, A, B = map(int, input().split())
S = list(input().split)
 
ok_count = 0
ok_fcount = 0
for i in range(N):
  if S[i] == a:
    if ok_count < A+B-1
      print('Yes')
      ok_count +=1
      
    else:
      print('No')
      
  elif S[i] == b:
    if ok_count <= A+B-1 and ok_fcount < B-1:
      print('Yes')
      ok_count+=1
      ok_fcount+=1
      
    else:
      print('No')
      
  else:
    print('No')

### FIXED CODE ###

N, A, B = map(int, input().split())
S = input()
 
ok_count = 0
ok_fcount = 0
for i in range(N):
  if S[i] == 'a':
    if ok_count < A+B:
      print('Yes')
      ok_count +=1
      
    else:
      print('No')
      
  elif S[i] == 'b':
    if ok_count < A+B and ok_fcount < B:
      print('Yes')
      ok_count+=1
      ok_fcount+=1
      
    else:
      print('No')
      
  else:
    print('No')
n = int(input())
s = str(input())
c = 0
for i in range(len(s)):
  if s[i] == "A":
    if s[1+1] == "B" and s[i+2] == "C":
      c += 1
print(c)

### FIXED CODE ###

n = int(input())
s = str(input())
c = 0
for i in range(n-2):
  if s[i] == "A":
    if s[i+1] == "B" and s[i+2] == "C":
      c += 1
print(c)
char_list = list(input())
char_list_num = len(char_list)
count_list = [0] * char_list_num

def f(first_char,n):
    if first_char == char_list[n+1]:
        return f(first_char,n+1)
    else:
        return n+1

def f2(first_char,n):
    if first_char == char_list[n-1]:
        return f2(first_char,n-1)
    else:
        return n-1

for i in range(char_list_num):
    if char_list[i] == 'R':
        reach_loop_num = f(char_list[i],i)
        decided_num = reach_loop_num - i
        if decided_num % 2 == 0:
            count_list[reach_loop_num] += 1
        else:
            count_list[reach_loop_num-1] += 1
    else:
        reach_loop_num = f2(char_list[i],i)
        decided_num =  i - reach_loop_num
        if decided_num % 2 == 0:
            count_list[reach_loop_num] += 1
        else:
            count_list[reach_loop_num+1] += 1
print(' '.join(map(str,count_list)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
char = list(input())
char_list_num = len(char)
count_list = [0] * char_list_num

def f(first_char,n,add_num):
    if first_char == char[n+add_num] and n + add_num != char_list_num - 1:
        return f(first_char,n+add_num,add_num)
    else:
        return n+add_num

num = 0
while not num == char_list_num - 1:
    reach_loop_num = f(char[num],num,1)
    diff = reach_loop_num - num
    if reach_loop_num == char_list_num - 1:
        if char[num] == char[reach_loop_num]:
            diff += 1
        else:
            count_list[reach_loop_num] += 1
    if char[num] == 'R':
        if diff % 2 == 0:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2)
        else:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2) +1
    else:
        if diff % 2 == 0:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2)
        else:
            count_list[num] += int(diff/2) +1
            count_list[num-1] += int(diff/2)
    num = reach_loop_num
print(' '.join(map(str,count_list)))
a = int(input())
if a >= 30:
  return "Yes"
else:
  return "No"

### FIXED CODE ###

X = int(input())
if X >= 30:
  print("Yes")
else:
  print("No")
w = int(input())
nums = list(range(w + 1))
for _ in range(int(input())):
    a, b = list(map(int, input().split(", ")))
    nums[a], nums[b] = nums[b], nums[a]
for i in range(w):
    print(nums[i + 1])

### FIXED CODE ###

w = int(input())
nums = list(range(w + 1))
for _ in range(int(input())):
    a, b = map(int, input().split(","))
    nums[a], nums[b] = nums[b], nums[a]
for x in nums[1:]:
    print(x)
N = int(input())
P = [int(x) for x in input().split()]

a = [i* 10**3+1 for i in range(N)]
b= list(reversed(a))



for i in range(N):
    #P[i] =2* i
    p = P[i]-1
    a[p]+=i

print(" ".join(map(str,a)) )
print(" ".join(map(str,b)) )


def check():
    tmp =0
    for i in P:
        i-=1
        print(tmp<a[i]+b[i])
        tmp=a[i]+b[i]

#check()

### FIXED CODE ###

H,W=[int(x) for x in input().split()]

A = [list(map(lambda x: x=="#" ,input())) for _ in range(H)]

#print(A)


try:
    for i in range(H):
        for j in range(W):
            if A[i][j]:
                start=i,j
                raise
except:
    pass


def a(i,j):
    if i<H and j<W:
        return A[i][j]
    return False

tmp =start
used = [start]
while True:
    #print(tmp)
    i,j =tmp
    if a(i+1,j):
        tmp = i+1,j
        used.append(tmp)
        continue
    if a(i,j+1):
        tmp = i ,j+1
        used.append(tmp)
    else:
        break

for i in range(H):
    for j in range(W):
        if A[i][j]:
            if (i,j) in used:
                continue
            else:
                #print(i,j)
                print("Impossible")
                exit()
print("Possible")
n, k, s = map(int, input().split())
ans = [s for _ in range(n)]
for i in range(k, n):
        ans[i] = ans[i] + 1 if s < 1000000000 else ans[i] = 1
print(*ans)

### FIXED CODE ###

n, k, s = map(int, input().split())
ans = [s for _ in range(k)]
for i in range(k, n):
        ans.append(s+1) if s < 1000000000 else ans.append(1)
print(*ans)
s=[input()]
Q=int(input())

rev=-1
for i in range(Q):
    que=input().split()
    if que[0]=="1":
        rev*=-1
    else:
        if que[1]=="1":
            if rev>0:
                s.append(que[2])
            else:
                s=[que[2]]+s
        else:
            if rev<0:
                s.append(que[2])
            else:
                s=[que[2]]+s
if rev<0:
    for si in s:
        print(si,end="")
else:
    for i in range(len(s),0,-1):
        print(s[i],end="")

### FIXED CODE ###

S=input()
Q=int(input())

# deq=deque()
# for s in S:
#     deq.append(s)

rev=False
front=""
last=""
# ans+=S

for _ in range(Q):
    query=input().split()
    if query[0]=="1":
        rev = not rev
        # print(rev)
    else:
        if rev:
            query[1]=str(3-int(query[1]))
        if query[1]=="1":
            # deq.appendleft(query[2])
            front=query[2]+front
        else:
            # deq.append(query[2])
            last+=query[2]

# if rev:
#     deq.reverse()
# # ans=""
# for i in range(len(deq)):
#     ans+=deq[i]

if not rev:
    print(front+S+last)
else:
    print(last[::-1]+S[::-1]+front[::-1])
a, b, c = map(int, input().split())

if a >= b and a >= c:
    print(b + c)
elif b >= a and b >= c:
    print(a + c)
elif c >= a and c >= b:
    print(a + b)
elif a == b == c:
    print(a + b

### FIXED CODE ###

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

print(a[0]+a[1])
a = int (inout ())
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3]:
  print ('Yes')
else:
  print ('No')

### FIXED CODE ###

a = input ()
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3]:
  print ('Yes')
else:
  print ('No')
H, N  = map(int, input().split())

s = 0
for i in range(N):
    a = int(input())
    s += a

if H > s:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

H, N  = map(int, input().split())
a = list(map(int, input().split()))

s = 0
for i in a:
    s += i

if H > s:
    print("No")
else:
    print("Yes")
ans=0
for i in range(N):
    ans+=B[A[i]-1]
    if i<N-1:
        if A[i+1]==A[i]+1:
            ans+=C[A[i]-1]

print(ans)

### FIXED CODE ###


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

ans=0
for i in range(N):
    ans+=B[A[i]-1]
    if i<N-1:
        if A[i+1]==A[i]+1:
            ans+=C[A[i]-1]

print(ans)
import math

n = int(input())
array = [int(x) for x in input().split()]
array2 = [array[x]-(x+1) for x in range(n)]

b_ = array2[n//2]
b_1 = array2[n//2+1]
b_2 = array2[n//2-1]

res = [abs(array[x]-(b_+x+1)) for x in range(n)]
res1 = [abs(array[x]-(b_1+x+1)) for x in range(n)]
res2 = [abs(array[x]-(b_2+x+1)) for x in range(n)]
print(min(sum(res)), sum(res1), sum(res2))



### FIXED CODE ###

n = int(input())
array = [int(x) for x in input().split()]
array2 = [x-(i+1) for i, x in enumerate(array)]

b_ = sorted(array2)[n//2]

res = [abs(array[x]-(b_+x+1)) for x in range(n)]
print(sum(res))
L=list(map(int,input().split()))
N=L[0]
K=L[1]
Q=L[2]
point=[K-Q]*N
for i in range(Q):
  ans=int(input())
  point[ans-1]+=1
for i in range(N):
  if point[i]>0 :
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

s=input()

if s=="Sunny":
  a="Cloudy"
elif s=="Cloudy":
  a="Rainy"
else:
  a="Sunny"
  
print(a)
print(int(input()))**3

### FIXED CODE ###

print(int(input())**3)
import numpy as np

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
for i in range(M):
  A[-1] = A[-1]/2
  if len(A) == 1:
    continue
  elif A[-1] < A[-2]:    
    A = sorted(A)
A = np.array(A)
A = np.floor(A)
print(int(np.sum(A)))


### FIXED CODE ###

s = input()
if s == "Rainy":
  print("Sunny")
elif s == "Sunny":
  print("Cloudy")
else:
  print("Rainy")
ll = [1, 9, 7, 4]

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

if ( a in ll ):
  ll.remove(a)
  if ( b in ll ):
    ll.remove(b)
    if ( c in ll ):
      ll.remove(bc)
      if ( d in ll ):
        print("YES")
else:
  print("NO")




### FIXED CODE ###


ll = [1, 9, 7, 4]

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

if ( a in ll ):
  ll.remove(a)
  if ( b in ll ):
    ll.remove(b)
    if ( c in ll ):
      ll.remove(c)
      if ( d in ll ):
        print("YES")
      else:
        print("NO")
    else:
      print("NO")
  else:
    print("NO")
else:
  print("NO")
def main():
    from itertools import product

    H,W,K = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    
    i = 0
    while i < len(S):
        if '1' in S[i]:
            i += 1
        else:
            del S[i]
    H = len(S)
 
    S = [[int(s[i]) for s in S] for i in range(W)]

    if sum(sum(s) for s in S)<=K:
        print(0)
    else:
        answer = (H-1) * (W-1)
        for X in product([False,True], repeat=H-1):
            ans = np.sum(X)
            if ans >= answer:
                continue
            M = [[0]]
            for i, x in enumerate(X):
                if x:
                    M.append([])
                M[-1].append(i+1)
            D = [0]*len(M)
            for s in S:
                for k, m in enumerate(M):
                    D[k] += sum(s[i] for i in m)
                if any(d > K  for d in D):
                    ans += 1
                    if ans >= answer:
                        break
                    for k, m in enumerate(M):
                        D[k] = sum(s[i] for i in m)
                    
                    if any(d > K for d in D):
                        ans = answer + 1
                        break

            answer = min(answer,ans)

        print(answer)

main()

### FIXED CODE ###


def main():
    from itertools import product
    import numpy as np

    H,W,K = map(int, input().split())
    S = (np.array([list(map(int,list(input()))) for _ in range(H)]).T).tolist()

    if sum(sum(s) for s in S)<=K:
        print(0)
    else:
        answer = (H-1) * (W-1)
        for X in product([False,True], repeat=H-1):
            ans = np.sum(X)
            if ans >= answer:
                continue
            M = [[0]]
            for i, x in enumerate(X):
                if x:
                    M.append([])
                M[-1].append(i+1)
            D = [0]*len(M)
            for s in S:
                for k, m in enumerate(M):
                    D[k] += sum(s[i] for i in m)
                if any(d > K  for d in D):
                    ans += 1
                    if ans >= answer:
                        break
                    for k, m in enumerate(M):
                        D[k] = sum(s[i] for i in m)
                    
                    if any(d > K for d in D):
                        ans = answer + 1
                        break

            answer = min(answer,ans)

        print(answer)

main()
def solve():
    n=int(input())
    num=[]
    def append(num1):
        num.append(num1)
    def count1(num2):
        return num.count(num2)
    for i in range(n):
        a=int(input())
        append(a)
    max1=max(num)
    count=count1(max1)
    if count>1:
        for i in range(n):
            print(max1)
    else:
        for i in range(n):
            if num[i]==max1:
                if i==0:
                    print(max(num[1:]))
                elif i==n-1:
                    print(max(num[:n-1]))
                else:
                    print(max(max(num[:i]),max(num[i+1:])))
            else:
                print(max1)
solve()


### FIXED CODE ###

r=int(input())
print(3*r*r)
return int(radius**2)
              




### FIXED CODE ###

r = int(input())
print(r**2)
data = []
try:
    while True:
        data.append(raw_input())

except EOFError:
        pass

for i in data:
    a, b, c, d, e, f = i.split()
    a, b, c, d, e, f = int(a), int(b), int(c), int(d), int(e), int(f)
    if abs(a) or abs(b) or abs(c) or abs(d) or abs(e) or abs(f) <= 1000:
        for j in range(-1000, 1001):
            if j != 0:
                if (c - (a * j)) / float(b) == (f - (d * j)) / float(e):
                    print "{:.3f} {:.3f}".format(j, (c - (a * j)) / float(b))
                    break

### FIXED CODE ###

data = []
try:
    while True:
        data.append(raw_input())

except EOFError:
    pass

for i in data:
    a, b, c, d, e, f = map(float, (i.split()))
    if (abs(a) <= 1000
        and abs(b) <= 1000
        and abs(c) <= 1000
        and abs(d) <= 1000
        and abs(e) <= 1000
        and abs(f) <= 1000):
        y = (a*f - c*d) / (a*e - b*d)
        x = (c - b*y) / a
        print "{:.3f} {:.3f}".format(x, y)