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

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

q = []
for _ in range(N):
    t, d = map(int, input().split())
    heappush(q, (-d, t))

now_used = []
not_used = []

c = 0
su = 0
kn = set()
while q and c<K:
    d, t = heappop(q)
    if not t in kn:
        kn.add(t)
        heappush(now_used, (-d, t))
        su -= d
        c += 1
    else:
        heappush(not_used, (d, t))

used = len(now_used)
for _ in range(K-used):
    d, t = heappop(not_used)
    su -= d
    heappush(now_used, (-d, t))

ans = su+c*c

while not_used:
    a, grp = heappop(now_used)
    su -= a
    kn.remove(grp)
    a, grp = heappop(not_used)
    heappush(now_used, (-a, grp))
    kn.add(grp)
    su -= a
    c = len(kn)
    ans = max(ans, su+c*c)
print(ans)

### FIXED CODE ###

from collections import defaultdict as dd
import heapq

n,k=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
l.sort(key=lambda x:-x[1])

sushi_types = set()
sushies = []
v=0

for i in range(k):
    t,d=l[i]
    v+=d
    if t in sushi_types:
        heapq.heappush(sushies,d)
    else:
        sushi_types.add(t)

remaining_sushi=dd(list)
for i in range(k,n):
    t,d=l[i]
    if not t in sushi_types:
        heapq.heappush(remaining_sushi[t],-d)

eat_candidate_sushi = []
for i in remaining_sushi.keys():
    if not i in sushi_types:
        heapq.heappush(eat_candidate_sushi,remaining_sushi[i][0])

sushi_kinds=len(sushi_types)
val=v
ans=v+sushi_kinds**2

for i in range(sushi_kinds+1,k+1):
    if sushies and eat_candidate_sushi:
        v-=heapq.heappop(sushies)
        v-=heapq.heappop(eat_candidate_sushi)
        ans=max(ans,v+i**2)
    else:
        break

print(ans)
import math
N = int(input())
L = list(map(int,input().split()))
B = []
s = 0
for i in range(N-2):
    for k in range(i+1,N-1):
        for _ in range(k+1,N):
            if L[i]-L[k]<L[_] and L[k]-L[i]<L[_] and L[_]<L[i]+L[k]:
                s = (L[i]+L[k]+L[_])/2
                B.append(math.sqrt(s*(s-L[i])*(s-L[k])*(s-L[_])))
k = set(B)
k = list(k)
print(len(k))


### FIXED CODE ###

A,B = map(int,input().split())
if (A-2*B)<0:
  print(0)
else:
  print(A-2*B)
a, b, x = map(int, input().split())

cnt = 0
for i in range(1, 1e18):
  if a <= x*i and x*i <= b:
    cnt += 1
  elif b <= x*i:
    break
    
print(cnt)

### FIXED CODE ###

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

print(b//x - (a-1)//x)
n = int(input())

number_list = list(map(int,input().split()))
tmp_list = sorted(number_list)


for number in number_list:
    if number < tmp_list[n//2]:
        print(tmp_list[n//2])
    else :
        print(tmp_list[n//2-1])


### FIXED CODE ###

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

if a <= x and a+b >= x:
    print("YES")
else:
    print("NO")
x = list(map(int, input().split()))
def func(x):
    for i in range(x[0]+1):
        for j in range(x[0]+1):
            if i+j>x[0]:
                break
            elif i*2 + j*4 == x[2] or j*2 + i*4 == x[2]:
                print('Yes')
                return
    print('No')
    return
func(x)

### FIXED CODE ###

x, y = map(int, input().split())
def func(x,y):
    for i in range(x+1):
        for j in range(x+1):
            if i+j==x:
                if i*2 + j*4 == y:
                    print('Yes')
                    return
    print('No')
    return
func(x,y)
a = map(int, input())
if sum(a) >= 22:
  print('bust')
else:
  print('win')

### FIXED CODE ###

a, b, c = map(int, input().split())
if a + b + c >= 22:
  print('bust')
else:
  print('win')
s = input()
correct_list = ["A","C","G","T"]
x_list = [-1]

for i, c in enumerate(s):
    if c not in correct_list:
        x_list.append(i)
diff_list = []
for i in range(len(x_list)-1):
    diff_list.append(x_list[i+1]-x_list[i])
print(max(diff_list)-1)


### FIXED CODE ###

s = input()
correct_list = ["A","C","G","T"]
x_list = [-1]

for i, c in enumerate(s):
    if c not in correct_list:
        x_list.append(i)
x_list.append(len(s))
diff_list = []
for i in range(len(x_list)-1):
    diff_list.append(x_list[i+1]-x_list[i])
print(max(diff_list)-1)
N,X = map(int, input().split())
List = [int(x) for x in input().split()]

import math
List.append(X)
List.sort()

distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])

d_min = min(distance)

num_list = []

c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1

num_list2 = [0]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])

num_list = num_list + num_list2

num_list.append(d_min)
j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1

print(ans)

### FIXED CODE ###

N,X = map(int, input().split())
List = [int(x) for x in input().split()]
 
import math
List.append(X)
List.sort()
 
distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])
 
d_min = min(distance)
 
num_list = []
 
c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1
 
num_list2 = [0]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])
 
num_list = num_list + num_list2

num_list.append(d_min)

j = len(num_list)-1

while j >= 0:
    c2 = 0
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1
 
print(ans)
n,m = map(int,input().split())
x =[0]*n
for i in range(m):
    a,b = map(int,input().split())
    x[a-1]+=1
    x[b-1]+=1
for i in range(n):
    print(x[i]

### FIXED CODE ###

n,m = map(int,input().split())
x =[0]*n
for i in range(m):
    a,b = map(int,input().split())
    x[a-1]+=1
    x[b-1]+=1
for i in range(n):
    print(x[i])
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

d = [[None]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
        d[i][j] = min(i, n-1-i, j, n-1-j)
vacant = [[False]*n for _ in range(n)]
from numba import njit
@njit('(i4,i4)', cache=True)
def sub(x,y):
    v = d[x][y]
    q = [(v, x, y)]
    dx = [0,1,0,-1]
    dy = [1,0,-1,0]
    while q:
        v,i,j = q.pop()
        for xx, yy in zip(dx,dy):
            ii = i+xx
            jj = j+yy
            if ii<0 or jj<0 or ii>=n or jj>=n:
                continue
            if d[ii][jj]>v:
                d[ii][jj] = v
                nv = v+1 if not vacant[ii][jj] else v
                q.append((nv, ii, jj))
ans = 0
for v in p:
    v -= 1
    x,y = v//n, v%n
    ans += d[x][y]
#     print(v, d[x][y], d)
    sub(x,y)
    vacant[x][y] = True
print(ans)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

d = [None] * (n**2)
for i in range(n):
    for j in range(n):
        d[i*n+j] = min(i, n-1-i, j, n-1-j)
vacant = [False] * (n**2)

ans = 0
for pos in p:
    pos -= 1
    ans += d[pos]
    vacant[pos] = True
    q = [pos]
    while q:
        pos = q.pop()
        tmp = not vacant[pos]
#         for diff in (-1, 1, -n, n):
#             ppos = diff+pos
#             if ppos<0 or ppos>=n*n:
#                 continue
#             if d[ppos]>d[pos]+tmp:
#                 d[ppos] = d[pos] + tmp
#                 q.append(ppos)
        if pos+n<n*n:
            ppos = pos + n
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
        if pos-n>=0:
            ppos = pos - n
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
        if pos+1<n*n:
            ppos = pos + 1
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
        if pos-1>=0:
            ppos = pos - 1
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
print(ans)
n = int(input())
xy = []
renso = {}
ans = []

for i in range(n):
    xin,yin = map(int,input().split())
    xy.append((xin,yin))

xy.sort(key=lambda x:x[1])
xy.sort(key=lambda x:x[0])

for i in range(n):
    for j in range(i,n):
        if( i==j ):
            continue
        t = (xy[i][0]-xy[j][0],xy[i][1]-xy[j][1])
        #renso[t]=renso.get(t,0)+1
        ans.append(t)

res = max([ans.count(e) for e in set(ans) if ans.count(e) > 1])
print(n-res)

### FIXED CODE ###

n = int(input())
xy = []
ans = []

for i in range(n):
    xin,yin = map(int,input().split())
    xy.append([xin,yin])

if n==1:
    print(1)
    exit(0)

xy.sort(key=lambda x:x[1])
xy.sort(key=lambda x:x[0])

for i in range(n):
    for j in range(n):
        if( i==j ):
            continue
        t = (xy[i][0]-xy[j][0],xy[i][1]-xy[j][1])
        ans.append(t)

res = [ans.count(e) for e in set(ans)]
print(n-max(res))
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

### FIXED CODE ###

import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]res = 0
cnt_a = 0
cnt_c = 0
for b in B:
    for ca in range(cnt_a, N):
        if A[ca] >= b:
            cnt_a = ca
            break
        if ca == N-1:
            if A[ca] < b:
                ca = N
                cnt_a = N
                break

    for cc in range(cnt_c, N):
        if C[cc] > b:
            cnt_c = cc
            break
        if cc == N-1:
            if b > C[cc]:
                cc = N
                cnt_c = N
                break
    res += (N - cc) * ca
print(res)

### FIXED CODE ###

from bisect import bisect_left, bisect_right
N = int(input())
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])
# N = 6
# A = sorted([int(i) for i in '3 14 159 2 6 53'.split()])
# B = sorted([int(i) for i in '58 9 79 323 84 6'.split()])
# C = sorted([int(i) for i in '2643 383 2 79 50 288'.split()])
res = 0
for b in B:
    res += bisect_left(A, b) * (N -bisect_right(C, b))
print(res)
from sys import stdin
input = stdin.buffer.readline

n = int(input())
*a, = map(int, input().split())
dp = [[-1] * 1000001 for i in range(n + 1)]
dp[0][0] = 1000
for i in range(n):
	for j in range(1000001):
		if dp[i][j] >= 0:
			dp[i + 1][j + dp[i][j] // a[i]] = max(dp[i + 1][j + dp[i][j] // a[i]], dp[i][j] % a[i])
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + a[i] * j)
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][0])


### FIXED CODE ###

from sys import stdin
input = stdin.buffer.readline

n = int(input())
*a, = map(int, input().split())
b = 1000
for i in range(n - 1):
	if a[i] < a[i + 1]:
		b = b // a[i] * a[i + 1] + b % a[i]
print(b)
N, M = map(int, input().split())

G = [[] for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    G[x].append(y)

lst = [-1] * (N + 1)


def calc(x):
    if lst[x] != -1:
        return lst[x]
    tmp = 0
    for next_ in G[x]:
        tmp = max(tmp, calc(next_))
    
    lst[x] = tmp + 1
    return tmp + 1

for i in range(1, N + 1):
    if lst[i] == -1:
        calc(i)

print (max(lst) - 1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

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

G = [[] for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    G[x].append(y)

lst = [-1] * (N + 1)


def calc(x):
    if lst[x] != -1:
        return lst[x]
    tmp = 0
    for next_ in G[x]:
        tmp = max(tmp, calc(next_))
    
    lst[x] = tmp + 1
    return tmp + 1

for i in range(1, N + 1):
    if lst[i] == -1:
        calc(i)

print (max(lst) - 1)
import string
s = list(set(list(input())))
s.sort()
comp = string.ascii_lowercase
if len(s) == len(comp):
    ans = 'None'
else:
    for i in range(len(s)):
        if s[i] != comp[i]:
            ans = comp[i]
            break
print(ans)


### FIXED CODE ###

import string
s = set(list(input()))
ans = 'None'
for c in string.ascii_lowercase:
    if not c in s:
        ans = c
        break

print(ans)
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]


for i in range(1,N+1):
    cnt=0
    n=N+1-i
    for j in range(1,10**5):
        #print(n,n*j)
        if n*j>N:
            break
        else:
            if B[n*j]==1:
                cnt+=1
    if cnt%2!=A[n]:
        B[n]+=1
        ans.append(n)
ans.sort()
print(len(ans))
print(*ans)


### FIXED CODE ###

N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1)[::-1]:
    #print(i)
    cnt=0
    for j in range(i,N+1,i):
        #print(i,j)
        if B[j]==1:
            cnt+=1
    if A[i]%2!=cnt%2:
        B[i]=1
        ans.append(i)
print(len(ans))
ans.sort()
print(*ans)
#print(A)
import sys

N=int(input())
C=[int(input()) for i in range(N)]
mod=10**9+7

if N==1:
    print(1)
    sys.exit()

S=[C[0]]

for i in range(1,N):
    if C[i]!=C[i-1]:
        S.append(C[i])

L=len(S)

if L==1:
    print(1)
    sys.exit()

AL=[[] for i in range(2*10**5+1)]

for i in range(L):
    AL[S[i]].append(i)

PLUS=[0]*(N+1)

NOW=1

for i in range(L):
    NOW,PLUS[S[i]]=(NOW+PLUS[S[i]])%mod,(PLUS[S[i]]+NOW)%mod
    #PLUS[S[i]]+=NOW
    

    #print(NOW,PLUS)

#print(PLUS)
print(NOW)
    
    


### FIXED CODE ###

import sys

N=int(input())
C=[int(input()) for i in range(N)]
mod=10**9+7

if N==1:
    print(1)
    sys.exit()

S=[C[0]]

for i in range(1,N):
    if C[i]!=C[i-1]:
        S.append(C[i])

L=len(S)

if L==1:
    print(1)
    sys.exit()

AL=[[] for i in range(2*10**5+1)]

for i in range(L):
    AL[S[i]].append(i)

PLUS=[0]*(2*10**5+1)

NOW=1

for i in range(L):
    NOW,PLUS[S[i]]=(NOW+PLUS[S[i]])%mod,(PLUS[S[i]]+NOW)%mod
    #PLUS[S[i]]+=NOW
    

    #print(NOW,PLUS)

#print(PLUS)
print(NOW)
import sys
import math
while True:
        a =map(int,raw_input().split())
        b = a[0] + a[1]
        print int(math.log10(b)+1)

### FIXED CODE ###

import math
while True:
        try:
                a =map(int,raw_input().split())
                b = a[0] + a[1]
                print len(str(a[0]+a[1]))
        except EOFError:
                break
ABC = [N,0,0,0,0]
time = 0
flag = 0
i = 0
while ABC[4] > 0 or flag == 0:
    print(ABC)
    if i >= 4:
        if ABC[4] >= E:
            ABC[4]-=E
        else:
            ABC[4]=0
    if i >= 3:
        if ABC[3] >= D:
            ABC[3]-=D
            ABC[4]+=D
            flag = 1
        else:
            ABC[4]+=ABC[3]
            flag = 1
            ABC[3]=0
    if i >= 2:
        if ABC[2] >= C:
            ABC[2]-=C
            ABC[3]+=C
        else:
            ABC[3]+=ABC[2]
            ABC[2]=0
    if i >= 1:
        if ABC[1] >= B:
            ABC[1]-=B
            ABC[2]+=B
        else:
            ABC[2]+=ABC[1]
            ABC[1]=0
    if ABC[0] >= A:
        ABC[0]-=A
        ABC[1]+=A
    else:
        ABC[1]+=ABC[0]
        ABC[0]=0
        
        
    time += 1
    i += 1
print('end',ABC)
print(time)

### FIXED CODE ###

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
if N%min(A,B,C,D,E) == 0:z = 4
else:z = 5
print(int(z+N/min(A,B,C,D,E)))
a = int(input())
b = int(input())
count = 0

if a > b:
  count = a
  a = a - 1
  if a > b or a == b:
    count = count + a
elif b > a:
  count = b
  b = b - 1
  if b > a or a == b:
    count = count + b
else:
  count = a
  count = count + b

print(count)

### FIXED CODE ###

a , b = map(int,input().split())
count = 0

if a > b:
  count = a
  a = a - 1
  if a > b or a == b:
    count = count + a
elif b > a:
  count = b
  b = b - 1
  if b > a or a == b:
    count = count + b
else:
  count = a
  count = count + b

print(count)
while 1:
    x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]
    d_max=max((x2-x1)**2+(y2-y1)**2,(x3-x2)**2+(y3-y2)**2,(x3-x1)**2+(y3-y1)**2)
    d1,d2,d3=(x2-x1)**2+(y2-y1)**2,(x3-x2)**2+(y3-y2)**2,(x3-x1)**2+(y3-y1)**2;
    
    if max(d_max,d1,d2,d3) > d_max:
        print("No")
    else:
        print("Yes")


### FIXED CODE ###

def cross(x, y):
    return (x.conjugate() * y).imag
 
def inside_triangle(p, x, y, z):
    a = cross(y-x, p-y)
    b = cross(z-y, p-z)
    c = cross(x-z, p-x)
    if a*b > 0 and b*c > 0:
        return True
    return False
 
import sys
 
for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    x = complex(x1, y1)
    y = complex(x2, y2)
    z = complex(x3, y3)
    p = complex(xp, yp)
    if inside_triangle(p, x, y, z):
        print('YES')
    else:
        print('NO')
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
if n==1:
    print(a[0][0],a[0][1],a[0][2])
else:
    for i in range(101):
        for j in range(101):
            ansh=[0]*(n+2)
            for k,(x,y,h) in enumerate(a):
                ansh[k]=h+abs(i-x)+abs(j-y)
                if h==0:ansh[k]=min[ans[k],max(ansh[:k])]
            if len(set(ansh))==2:
                print(i,j,ansh[1])

### FIXED CODE ###

n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
for i in range(101):
    for j in range(101):
        ansh=[0]*n
        for k,(x,y,h) in enumerate(a):
            ansh[k]=h+abs(i-x)+abs(j-y)
            if h==0:ansh[k]=min([ansh[k],max(ansh[:k])])
        if len(set(ansh))==1:
             print(i,j,ansh[1])
A, B = map(int, input().split())

a = bin(A)[2:].zfill(len(bin(B))-2)
b = bin(B)[2:]
#print(a, b)

import math

MAX = math.floor(math.log2(B)) + 1
#print("二進数の桁数の最大値", MAX)

c = [0] * (MAX+1)

for i in range(1, MAX):
    #print("桁", 2**i)
    ma = B//(2**i) * (2**i)
    mi = A//(2**i) * (2**i) + (2**i)
    #print(ma, mi)
    sum = int(a[-(i+1)]) * (mi - A) + int(b[-(i+1)]) * (B+1 - ma)
    #print(sum, sum % 2)
    c[-(i+1)] = sum % 2
    
c[-1] = (A % 2 + (B-A) // 2 % 2) % 2

#print(c)
print(int("".join(map(str, c)), 2))

### FIXED CODE ###


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

A -= 1

if (A+1) % 2 == 0:
    a = (A+1) // 2 % 2
else:
    a = (A // 2 % 2) ^ A

if (B+1) % 2 == 0:
    b = (B+1) // 2 % 2
else:
    b = (B // 2 % 2) ^ B
    
#print(a, b)
print(a ^ b)
a = int(input())

if (int(a**0.5))**2 == a:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a, b = map(str, input().split())
x = int(a+b)

if (int(x**0.5))**2 == x:
    print("Yes")
else:
    print("No")
day_ = input()
next_sunday = {7:"SUN",6:"MON",5:"TUE",4:"WED",3:"THU",2:"FRI",1:"SAT"}
value = next_sunday[day_]
print(value)

### FIXED CODE ###

s = input()
lis = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

ans = 7 - lis.index(s)
print(ans)
from collections import Counter

N = int(input())
a = [int(input()) for _ in range(N)]

def solve(n,a):
  d = Counter(a)
  d_lst = list(sorted(d.keys()))
  first = d_lst[-1]
  second = d_lst[-2]
  if d[first] != 1:
    return [first]*n
  else: # first は一つだけ
    return [second if a[i] == first else first for i in range(n)]

print(*solve(N,a),sep="\n")

### FIXED CODE ###

N = int(input())
a = [int(input()) for _ in range(N)]
first = max(a)
f_id = a.index(max(a))
second = max(a[:f_id] + a[f_id+1:])

for i in range(N):
  if a[i] == first:
    print(second)
  else:
    print(first)
t=str(s)
print(t.replace(",", " "))

### FIXED CODE ###

s = input()
print(s.replace(",", " "))
a = float(input())
print (a ** 2.0 * 3.14159265359, a * 2.0 * 3.14159265359)



### FIXED CODE ###

a, b = map(int, input().split())
print (a // b, a % b , "%.9f" % (a / b))
print(48-int(input())
      

### FIXED CODE ###

print(48-int(input()))
#coding:utf-8
import math
n, k = map(int, input().split())

if n < k:
    print(n)
elif k == 1 or (k % 2 == 0 and n % 2 == 0):
    print(0)
elif (k % 2 == 0 and n % 2 == 1) or (n % 2 == 0 and l % 2 == 1):
    print(1)


### FIXED CODE ###

#coding:utf-8
import math
n, k = map(int, input().split())

if n < k:
    print(min(n, abs(n-k)))
elif k == 1 or n == 0 or n%k == 0:
    print(0)
elif n%k != 0:
    print(min(abs(n%k-k), n%k))
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int, input().split())) for l in range(D)]
last = [0]*26

def score_down(d):
    ans = 0
    for i in range(26):
        ans += c[i]*(d - last[i])
    return ans

for d in range(D):
    score = [(s[d][i] - score_down(d)) for i in range(D)]
    t = score.index(max(score))
    print(t+1)
    last[t] = d+1

### FIXED CODE ###

D = int(input())
c = list(map(int,input().split()))
s = [list(map(int, input().split())) for l in range(D)]
last = [0]*26

def score_down(d):
    ans = 0
    for i in range(26):
        ans += c[i]*(d - last[i])
    return ans

for d in range(D):
    score = [(s[d][i] - score_down(d+1)) for i in range(26)]
    t = score.index(max(score))
    print(t+1)
    last[t] = d+1
h1, m1, h2, m2, k = map(int, input().split())

f = h1 * 60 + m1
t = h2 * 60 + m2

print(time)
if time < 0:
  print(0)
else:
  print(time)



### FIXED CODE ###

h1, m1, h2, m2, k = map(int, input().split())

f = h1 * 60 + m1
t = h2 * 60 + m2

time = t - f - k
if time < 0:
  print(0)
else:
  print(time)
a = int(input())
b = int(input())
c=(a+b)*0.5
print(int(c+0.9))

### FIXED CODE ###

a, b = map(int, input().split())
 
c = (a+b) / 2
 
print(int(c+0.9))
S = input()
s = {"A", "C", "G", "T"}
ans = 0
for i in S:
  if i in s:
    tmp += 1
    ans = max(ans, tmp)
  else:
    tmp = 0
print(ans)

### FIXED CODE ###

S = input()
s = {"A", "C", "G", "T"}
ans = 0
tmp = 0
for i in S:
  if i in s:
    tmp += 1
    ans = max(ans, tmp)
  else:
    tmp = 0
print(ans)
S='ejkld'
a=S[2]
b=S[3]
c=S[4]
d=S[5]

if  a == b and c == d:
    print("yes")
else:
    print("no")

### FIXED CODE ###

S = input()

if  S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")
k,a,b = map(int,input().split())
bis = 1
if k<= 1 or b <= a + 2:
    print(1+k)
    exit()
else:
    bis = b
    k = k - (a + 1)
    if not k == 0:
        bis += int(k/2)+(b-a)+k%2
print(bis)

### FIXED CODE ###

# A Anti-Adjacency
n,k = map(int,input().split())
if int((n +1) / 2) >= k:
    print('YES')
else:
    print('NO')
N = int(input())
numList = list()
for i in range(N):
    numList.append(int(input()))
sum, ctr = 0, 1
for i in numList:
    if i == 0: continue
    elif i % 2 != 0 and ctr % 2 != 0:
        sum = sum + 1
    ctr = ctr + 1
print(sum)

### FIXED CODE ###

x=int(input())
main=list(map(int,input().split()));count=0
for i in range(len(main)):
    if(main[i]%2!=0 and (i+1)%2!=0): count=count+1
print(count)
R = int(input())
print(R*pi*2)

### FIXED CODE ###

R =int(input())
import math
RU=2*math.pi*R
print(RU)