Harryxun/stf_run huggingface dataset:
def maxHeapify(heap, i):
    left = (i + 1) * 2 - 1
    right = (i + 1) * 2
    largest = left if heap[left] > heap[i] and left < len(heap) else i
    largest = right if heap[right] > heap[largest] and right < len(heap) else largest
    if largest != i:
        heap[i], heap[largest] = heap[largest], heap[i]
        maxHeapify(heap, largest)

def buildMaxHeap(heap):
    for i in range(len(heap) // 2, -1, -1):
        maxHeapify(heap, i)

n = int(input())
heap = list(map(int, input().split()))
buildMaxHeap(heap)

out = ''
for key in heap:
    out += (' {}'.format(str(key)))
print(out)

### FIXED CODE ###

def maxHeapify(heap, i):
    left = (i + 1) * 2 - 1
    right = (i + 1) * 2
    largest = left if left < len(heap) and heap[left] > heap[i] else i
    largest = right if right < len(heap) and heap[right] > heap[largest] else largest
    if largest != i:
        heap[i], heap[largest] = heap[largest], heap[i]
        maxHeapify(heap, largest)

def buildMaxHeap(heap):
    for i in range(len(heap) // 2, -1, -1):
        maxHeapify(heap, i)

n = int(input())
heap = list(map(int, input().split()))
buildMaxHeap(heap)

out = ''
for key in heap:
    out += (' {}'.format(str(key)))
print(out)
n, m = map(int, input().split(" "))

count = [0 for i in range(0,n)]

for i in range(0, m):
    a, b = map(int, input().split(" "))
    count[a] L= 1
    count[b] += 1

for i in range(0, n):
    print(count[i])


### FIXED CODE ###

n, m = map(int, input().split(" "))

count = [0 for i in range(0,n)]

for i in range(0, m):
    a, b = map(int, input().split(" "))
    count[a-1] += 1
    count[b-1] += 1

for i in range(0, n):
    print(count[i])
s = input()
flag = True
  for i in range(1,4):
    if s[i-1]==s[i]:
      flag = False
print("Bad" if flag==False else "Good")


### FIXED CODE ###

s = input()
flag = True
for i in range(1,4):
  if s[i-1]==s[i]:
    flag = False
print("Bad" if flag==False else "Good")
r=input()
print(r**2)

### FIXED CODE ###

print((int(input()))**2)
ans = []
a = list(input())
for i in range(len(a)):
	if(a[i] == '1'):
		ans.append('1')
	elif(a[i] == '0'):
		ans.append('0')
	elif(a[i] == 'B'):
		ans.pop()
print(''.join(ans))

### FIXED CODE ###

s = input()
ans = ''
for i in range(len(s)):
	if s[i] == '0':
		ans += '0'    
	elif s[i] == '1':
		ans += '1'    
	else:
		if ans != '':
			ans = ans[:-1]    
print(ans)
#B AcCepted
b = input()
a = list(b)
c=z = len(b)
d =""
if a[0] == "A":
    a[0] = "a"
    c = 10000
for i in range(2,c):
    if a[i] == "C":
        a[i]="c"
        c+=1
for i in a:
    d+=i
if d.islower() and c == 10001:
    print("AC")
else:
    print("WA")
    
    

### FIXED CODE ###

#B AcCepted
b = input()
a = list(b)
c=z = len(b)
d =""
if a[0] == "A":
    a[0] = "a"
    c = 10000
for i in range(2,z-1):
    if a[i] == "C":
        a[i]="c"
        c+=1
for i in a:
    d+=i
if d.islower() and c == 10001:
    print("AC")
else:
    print("WA")
list = raw_input().split(" ")
list.sort()


### FIXED CODE ###

list = raw_input().split(" ")
list.sort()
print(" ".join(list))
# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
Graph = [[] for i in range(N + 1)]

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

counter = [0] * (N + 1)

for i in range(Q): #counterに値を入れていく．
    a,b = map(int,input().split())
    counter[a] += b

seen = [False] * (N + 1)

def dfs(Graph, seen, v, s): #s : 根から訪問している頂点までの累積和
    seen[v] = True
    s += counter[v]
    print(str(s) + " ", end = "")
    for next_v in Graph[v]:
        if seen[next_v]:
            continue
        dfs(Graph, seen, next_v, s)
    
    
dfs(Graph, seen, 1, 0)

### FIXED CODE ###

# coding: utf-8
# Your code here!
import collections
N,Q = map(int,input().split())
Graph = [[] for i in range(N + 1)]

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

counter = [0] * (N + 1)

for i in range(Q): #counterに値を入れていく．
    a,b = map(int,input().split())
    counter[a] += b

seen = [False] * (N + 1)
todo = collections.deque()

seen[1] = True
todo.append(1)

while len(todo) != 0:
    v = todo.pop()
    for next_v in Graph[v]:
        if seen[next_v]:
            continue
        seen[next_v] = True
        todo.append(next_v)
        counter[next_v] += counter[v]

print(*counter[1:])
data = int(input())
up = data/100
down = data % 100
if(1 <= up and up <= 12):
    if(1 <= down and down <= 12):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if(1 <= down and down <= 12):
        print("YYMM")
    else:
        print(NA)

### FIXED CODE ###

data = int(input())
up = data/100
down = data % 100
if(1 <= up and up <= 12):
    if(1 <= down and down <= 12):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if(1 <= down and down <= 12):
        print("YYMM")
    else:
        print("NA")
A, B, C, X = map(int, input().split())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for n in range(C+1):
            if i*500+j*100+n*50 == X:
                count = count+1
print(count)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for n in range(C+1):
            if i*500+j*100+n*50 == X:
                count = count+1
print(count)
in1 = input('')
n = int(in1.split(' ')[0])
m = int(in1.split(' ')[1])
l = []
for i in range(0,n):
  l.append(0)

hasError = False
for i in range(0,m):
  in2 = input('')
  idx = int(in2.split(' ')[0])
  li = int(in2.split(' ')[1])
  if l[idx-1] != li:
    hasError = True
  else:
    l[idx-1] = li

result = 0
for i in range(0,n):
  ix = 1
  for j in range(0,(n-i-1)):
    ix*=10
  result += int(l[i])*ix

if result < 0:
  result = -1
if n == 1 and result == 0:
  result = 0
elif len(str(result)) != n:
  result = -1
if hasError = True:
  result = -1
print(result)



### FIXED CODE ###

in1 = input('')
n = int(in1.split(' ')[0])
m = int(in1.split(' ')[1])
l = []
for i in range(0,n):
  l.append(-1)

hasError = False
for i in range(0,m):
  in2 = input('')
  idx = int(in2.split(' ')[0])-1
  li = int(in2.split(' ')[1])
  if l[idx] != -1 and l[idx] != li:
    hasError = True
  else:
    l[idx] = li

for i in range(0,n):
  if l[i] == -1:
    if i == 0 and n > 1:
      l[i] = 1
    else:
      l[i] = 0

result = 0
for i in range(0,n):
  ix = 1
  for j in range(0,(n-i-1)):
    ix*=10
  result += int(l[i])*ix

if result < 0:
  result = -1
if n == 1 and result == 0:
  result = 0
elif len(str(result)) != n:
  result = -1
if hasError == True:
  result = -1
print(result)
def main():
	n, m = map(int, input().split())
	rev = input()[::-1]
	ans = []
	cur = 0
	while cur < n:
		for i in range(cur + 1, cur + m + 1):
			if i==n:
				nxt = i
				break
			if rev[i]=="0":
				nxt = i
		if cur==nxt:
			print(-1)
			exit()
		ans += [nxt - cur]
		cur = nxt
		if cur==n:
			break
	print(" ".join(map(str, ans[::-1])))


if __name__=="__main__":
	main()


### FIXED CODE ###

n,m=map(int,input().split())
su=input()
rev=su[::-1]
if "1"*m in su:
	print(-1)
	exit()
dist_f_n=[float('inf')]*(n+1)
dist_f_n[0]=0
for i in range(1,m+1):
	if rev[i]=="0":
		dist_f_n[i]=1
		last=i
		if i==n:
			break
while last<n:
	for i in range(last+1,last+m+1):
		if rev[i]=="0":
			dist_f_n[i]=dist_f_n[last]+1
			_last=i
			if i==n:
				break
	last=_last
cur=dist_f_n[-1]
_i=0
ans=[]
for i,x in enumerate(dist_f_n[::-1]):
	if x==cur-1:
		ans.append(i-_i)
		cur-=1
		_i=i
print(" ".join(map(str,ans)))
count = 0
for b in range(K+1, N+1):
        count += (b-K)*int((N-b+1)/b)


if K != 0:
    for a in range(K, N+1):
        count += N-a
if K == 0:
        for a in range(1, N+1):
            count += N-a

print(count)

### FIXED CODE ###

K = input().split()
N = int(K[0])
K = int(K[1])

count = 0
for b in range(K+1, N+1):
    siki1 = int((N-K)/b)
    siki2 = int((N-b+1)/b)
    if siki1 <= siki2:
        count += (b-K)*siki1
    elif siki1 > siki2:
        count += (b-K)*siki1
        count -= (b-N-1)*(siki1 - siki2)
        count -= b*(int((siki1*(siki1+1))/2) - int((siki2*(siki2+1))/2))

if K != 0:
    for a in range(K, N+1):
        count += N-a
if K == 0:
        for a in range(1, N+1):
            count += N-a

print(count)
n, k = map(int, input().split(" "))

l = map(int, input().split(" "))
l.sort()

sum = 0
for i in range(n-k,n):
    sum += l[i]

print(sum)

### FIXED CODE ###

n, k = map(int, input().split(" "))

l = list(map(int, input().split(" ")))
l.sort()

sum = 0
for i in range(n-k, n):
    sum = sum + l[i]

print(sum)
x, y, z, k = map(int, input().split())
a_s = list(map(int, input().split()))
bs = list(map(int, input().split()))
cs = list(map(int, input().split()))
a_s.sort(reverse=True)
bs.sort(reverse=True)
cs.sort(reverse=True)

list = []
i = 0
for a in a_s:
    for b in bs:
        for c in cs:
            list.append(a + b + c)
            i += 1
            if i > k and list[i] < list[k]:
                break
list.sort(reverse=True)
for i in range(k):
    print(list[i])


### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = []
for ai in a:
  for bi in b:
    ab.append(ai + bi)
ab.sort(reverse = True)

abc = []

for abi in ab[:k]:
  for ci in c:
    abc.append(abi + ci)
abc.sort(reverse = True)

for abci in abc[:k]:
  print(abci)
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=sum(b)
for i in range(len(a)-1):
  if a[i+1]-a[i]==1:
    x+=c[a[i]]
print(x)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=sum(b)
for i in range(len(a)-1):
  if a[i+1]-a[i]==1:
    d=a[i]
    x+=c[d-1]
print(x)
import numpy as np
N = int(input())
A = [int(i) for i in input().split()]
B = sorted(A.copy(), reverse=True)

ans = 1
counts = [0] * (B[0]+1)
for d in range(B[0], B[-1]//2-1, -1):
    for b in B:
        if b % d == 0:
            counts[d] += 1
            if d != b // d:
                counts[b//d] += 1

    if counts[d] >= N-1:
        ans = d
        break

if ans == 1:
    print(counts)
    for i in range(B[0]//2, 0, -1):
        if counts[i] >= N-1:
            ans = i

print(ans)

### FIXED CODE ###

# 解けなかった...orz

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

def gcd(i, j):
    if i <= 0:
        return j
    elif j <= 0:
        return i

    while i != j:
        if i < j:
            j %= i
            if j == 0: return i
        else:
            i %= j
            if i == 0: return j
    return i

# M = [0] * N
L = [0] * (N+1)
R = [0] * (N+1)
# L[0] = 0
# R[N] = 0

for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

res = max(gcd(L[i], R[i+1]) for i in range(N))
print(res)
class Node:
    def __init__(self, index, parent_index):
        self.index = index
        self.parent_index = parent_index
        self.children = []
        self.value = 0

    def add_value(self, value):
        if self.index > 0:
            self.value += value
            for child in self.children:
                child.add_value(value)


class Tree:
    def __init__(self):
        self.node_indices = {}
        self.nodes = []

        self.add_node(1, 0)

    def add_node(self, index, parent_index):
        node = Node(index, parent_index)
        self.node_indices[index] = len(self.nodes)
        self.nodes.append(node)

        if index > 1:
            parent_node = self.nodes[self.node_indices[parent_index]]
            parent_node.children.append(node)

    def add_value(self, index, value):
        node = self.nodes[self.node_indices[index]]
        node.add_value(value)


def main():
    n, q = map(int, input().split())

    tree = Tree()
    for _ in range(n - 1):
        parent_index, child_index = map(int, input().split())
        tree.add_node(child_index, parent_index)

    for _ in range(q):
        index, value = map(int, input().split())
        print(index, value)
        tree.add_value(index, value)

    res = []
    for index in range(1, n + 1):
        node = tree.nodes[tree.node_indices[index]]
        res.append(node.value)
    print(' '.join(map(str, res)))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections
import sys

input = sys.stdin.readline

n, q = map(int, input().split())
es = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    es[a].append(b)
    es[b].append(a)

ps = [0] * (n + 1)
for _ in range(q):
    p, v = map(int, input().split())
    ps[p] += v

remaining = collections.deque([[0, 1]])
while len(remaining) > 0:
    a, b = remaining.popleft()
    ps[b] += ps[a]
    for c in es[b]:
        if c != a:
            remaining.append([b, c])
print(*ps[1:])
from math import ceil, floor
 
a, b = [int(c) for c in input().split(" ")]
A = ceil(a / 0.08)
B = ceil(b/ 0.1)
 
if (A < B):
  if (floor(B * 0.08) == a):
    print(B)
  else:
    print(-1)
elif (B < A):
  if (floor(A*0.1) == b):
    print(A)
  else:
    print(-1)
else:
  print(-1);

### FIXED CODE ###

code = input()
if (len(set(list(code))) != 1):
  print("Yes")
else:
  print("No")
a,b,k=map(int,input().split());*r,=range(a,b+1)
for t in sorted(set(r[:k]+r[-k:])):print(t)

### FIXED CODE ###

a,b,k=map(int,input().split());r=range(a,b+1);print(*sorted(set(r[:k])|set(r[-k:])),sep='\n')
S = str(input())
T = str(input())
t = int(len(T)) - 2

if S == T[:t]
  print(Yes)
else:
  No


### FIXED CODE ###

S = str(input())
T = str(input())
t = int(len(T)) - 1
U = T[:t]

if S == U:
  print('Yes')
else:
  print('No')
N, A, B = map(int, input().split())
blue = 'b' * A
red = 'r' * B
str = ''

while len(str) < N:
  str += blue
  if len(str) < N:
    str += red

print(str[:N].count('b'))

### FIXED CODE ###

N, A, B = map(int, input().split())
print((N // (A + B) * A) + min(A, N % (A + B)))
a, b, c, d = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al = sorted(al, reverse=True)
bl = sorted(bl, reverse=True)
cl = sorted(cl, reverse=True)
q = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
ans = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
c = -1
while True:
    #c += 1
#for i in range(d):
    #print(c)
    #print(len(ans))
    s, aq, bq, cq = map(int, q.pop())
    if len(al) > aq+1:
        if [al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq] not in ans:
            q.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])
            ans.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])

    if len(bl) > bq+1:
        if [al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq] not in ans:
            q.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])
            ans.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])

    if len(cl) > cq+1:
        if [al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1] not in ans:
            q.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])
            ans.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])

    q = sorted(q)

    if len(ans) > d:
        ans = sorted(ans, reverse=True)
        if ans[d-1][0] > q[len(q)-1][0]:
            break

ans = sorted(ans, reverse=True)
for i in range(d):
    print(ans[i][0])


### FIXED CODE ###

a, b, c, d = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al = sorted(al, reverse=True)
bl = sorted(bl, reverse=True)
cl = sorted(cl, reverse=True)
q = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
ans = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
#while True:
for i in range(d):
    s, aq, bq, cq = map(int, q.pop())
    if len(al) > aq+1:
        if [al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq] not in ans:
            q.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])
            ans.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])

    if len(bl) > bq+1:
        if [al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq] not in ans:
            q.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])
            ans.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])

    if len(cl) > cq+1:
        if [al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1] not in ans:
            q.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])
            ans.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])

    q = sorted(q)

    #if len(ans) > d:
    #   ans = sorted(ans, reverse=True)
    #    if ans[d][0] > q[len(q)-1][0]:
    #        break

ans = sorted(ans, reverse=True)
for i in range(d):
    print(ans[i][0])
def helper(k, h, res):
    if k == 0:
        return 0
    if res[k] == -1:
        res[k] = helper(k-1, h, res)+abs(h[k]-h[k-1])
        if k >= 2:
            res[k] = min(helper(k, h, res), res[k-2]+abs(h[k]-h[k-2]))
    return res[k]

def main():
    n = int(input())
    h= list(map(int, input().split(" ")))
    res = [-1]*n
    print(helper(n-1, h, res))

if __name__ == "__main__":
    main()

### FIXED CODE ###

def helper(h, n):
    res = [0]*n
    res[0] = 0
    res[1] = abs(h[1]-h[0])
    for i in range(2, n):
        res[i] = min(res[i-1]+abs(h[i]-h[i-1]), res[i-2]+abs(h[i]-h[i-2]))
    return res[-1]

def main():
    n = int(input())
    h = list(map(int, input().split(" ")))
    print(helper(h, n))

if __name__ == "__main__":
    main()
from math import factorial

def cc(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

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

if n == k:
    for i in range(k):
        if i == 0:
            cnt = 1
        else:
            cnt = 0
        print(cnt % (10 ** 9 + 7))
        
else:
    for i in range(k):
        j = i + 1
        print(n-k+1, j, k-1, j)
        cnt = cc(n-k+1, j) * cc(k-1, j-1)
    
    
        print(cnt % (10**9 + 7))

### FIXED CODE ###

from math import factorial

def cc(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

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

if n == k:
    for i in range(k):
        if i == 0:
            cnt = 1
        else:
            cnt = 0
        print(cnt % (10 ** 9 + 7))

else:
    for i in range(k):
        j = i + 1
        if j > n-k+1:
            cnt = 0
        else:
            cnt = cc(n-k+1, j) * cc(k-1, j-1)


        print(cnt % (10**9 + 7))
s = int(input())
if s == 'AAA' or s == 'BBB' :
    print('No')
else :
    print('Yes')

### FIXED CODE ###

s = input()
if s == 'AAA' or s == 'BBB' :
    print('No')
else :
    print('Yes')
from copy import deepcopy
def deal(s):
    stin=[]
    for i in range(len(s)):
        if s[i]==".":
            stin.append(0)
        else:
            stin.append(1)
    return stin
def dp(start,goal,stin):
    if goal<start or stin[goal-1]==1:
     #   print(start,goal)
      #  print(stin[goal-1])
       # print(stin)
        return False
    if start==goal:
        return True
    return dp(start,goal-1,stin) or dp(start,goal-2,stin)

n,a,b,c,d=map(int,input().split())
s=deal(input())
#print(s)
root=[]
if c<d:
    if dp(b,d,s):
       # print("ceh")
        if dp(a,c,s):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif d<c:
    for i in range(b-1,d):
        if s[i]==0:
            q=deepcopy(s)
            q[i]=1
            root.append(q)
    #    print(root)
   # print("DAME")
    if dp(b,d,s):
        for x in root:
            if dp(a,c,x):
                print("Yes")
                exit()
        print("No")  
    else:
        print("aa")
        print("No")
else:
    print("No")



### FIXED CODE ###

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

if c < d:
    print("Yes" if s[a - 1:d].count("##") == 0 else "No")
    #aからd-1までで二個あるとあうと
else:
    print("Yes" if s[a - 1:c].count("##") ==
          0 and s[b - 2:d + 1].count("...") > 0 else "No")
          #b-1からd+1までで飛び越すの
N = int(input())
e = int(N[-1])
if e in (2,4,5,7,9):
    print('hon')
elif e in (0,1,6,8):
    print('pon')
else:
    print('bon')

### FIXED CODE ###

N = input()
e = int(N[-1])
if e in (2,4,5,7,9):
    print('hon')
elif e in (0,1,6,8):
    print('pon')
else:
    print('bon')
a = int(input())
b = int(input())
print(2b - a)

### FIXED CODE ###

a = int(input())
b = int(input())
print(2 * b - a)
from collections import defaultdict
H, W = map(int, input().split())
s = [input() for _ in range(H)]
if H == 1 and W == 1:
    print('YES')
elif H==1:
    print('NO')
else:

    d_h = [[0 for i in range(28)] for _ in range(H)]
    d_w = [[0 for i in range(28)] for _ in range(W)]

    for i in range(H):
        for c in s[i]:
            d_h[i][ord(c) - ord("a")] += 1

    for i in range(H):
        for j in range(W):
            d_w[j][ord(s[i][j]) - ord("a")] += 1
    #
    # for i in range(H):
    #     d_h[i].sort()
    #     d_w[i].sort()

    check_h = []
    check_w = []

    for i in range(H):
        if i in check_h:
            continue
        for j in range(i + 1, H):
            if j in check_h:
                continue
            else:
                if d_h[i] == d_h[j]:
                    check_h.append(i)
                    check_h.append(j)
                    break

    for i in range(W):
        if i in check_w:
            continue
        for j in range(i + 1, W):
            if j in check_w:
                continue
            else:
                if d_w[i] == d_w[j]:
                    check_w.append(i)
                    check_w.append(j)
                    break

    c_w = 0
    c_h = 0

    for i in range(H):
        if i in check_h:
            c_h += 1
    for i in range(W):
        if i in check_w:
            c_w += 1

    if c_h >= H - 1 and c_w >= W - 1:

        print('YES')
    else:
        print('NO')


### FIXED CODE ###


n = int(input())
x = list(map(int, input().split()))
x_sort = x.copy()
x_sort.sort()
row = x_sort[n//2 - 1]
high = x_sort[n//2]

for i in range(n):
    if x[i] <= row:
        print(high)
    else:
        print(row)
w=input()
w1=input()
num=len(w)
num1=len(w1)
for i in range(num-num1+1):
  b=True
  for j in range(i,i+num1):
    if w[i+j]=="?" or w[i+j]==w1[j]:
      pass
    else:
      b=False
  if b:
      start=i
      break
if not b:
  print("UNRESTORABLE")
word=""
else:
  if start!=0:
    for i in range(start):
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
    for i in range(start,num):
      word+=w1[i-start]
  else:
    word+=w1
    for i in range(num1,num):
      if w[num]=="?":
        word+="a"
      else:
        word+=w[num]
  print(word)
    

### FIXED CODE ###

w=input()
w1=input()
num=len(w)
num1=len(w1)
start=-1
if num<num1:
  b1=False
for i in range(num-num1+1):
  b=True
  for j in range(num1):
    if w[i+j]=="?" or w[i+j]==w1[j]:
      pass
    else:
      b=False
  if b:
      start=i
if start==-1:
  print("UNRESTORABLE")
else:
  word=""
  for i in range(num):
    if i<start:
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
    elif start<=i and i<=start+num1-1:
      word+=w1[i-start]
    else:
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
  print(word)
s = input()
s1 = s[:(n - 2) / 2]
s2 = s[(n - 2) / 2:]

if s == s[:: -1] and s1 == s1[:: -1] amd s2 == s2[:: -1]:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

S = input()
N = len(S)
S2 = S[:((N - 1) // 2)]
S3 = S[((N + 1) // 2):]

S_rev1 = S[::-1]
S_rev2 = S2[::-1]
S_rev3 = S3[::-1]

if S == S_rev1 and S2 == S_rev2 and S3 == S_rev3 :
    print("Yes")
else:
    print("No")
#N = input("スライムの数 : ")
#S = input("対応する文字列 : ")
A = input("")
N = A.split("\n")[0]
S = A.split("\n")[1]
result = int(N)
for i in range(len(S) - 1):
  if S[i] == S[i + 1]:
    result -= 1
print(result)

### FIXED CODE ###

N = input("")
S = input("")
result = int(N)
for i in range(len(S) - 1):
  if S[i] == S[i + 1]:
    result -= 1
print(result)