Harryxun/stf_run huggingface dataset:
n = int(input())
array = [int(x) for x in input().split()]
sum_array = [0 for x in range(n+1)]
now = 0
for i in range(n):
  sum_array[i] = abs(array[i]-now)
  now = array[i]
else:
  sum_array[-1] = abs(now)

for j in range(n):
  if j == 0:
    print(sum_array[-1])
  elif j == n-1:
    print(sum_array[-2]+abs(array[-2]))
  else:
    print(sum_array[-1]-(sum_array[j]-sum_array[j-1])-(sum_array[j+1]-sum_array[j])+(abs(array[j+1]-array[j-1]))

### FIXED CODE ###

n = int(input())
array = [int(x) for x in input().split()]
sum_array = [0]
now = 0
for i in range(n):
    sum_array.append(sum_array[i] + abs(array[i] - now))
    now = array[i]
else:
    sum_array.append(sum_array[-1] + abs(array[-1] - 0))

for j in range(n):
    if j == 0:
        print(sum_array[-1] -
              (sum_array[j + 1] - sum_array[j]) -
              (sum_array[j + 2] - sum_array[j + 1]) +
              (abs(array[j + 1] - 0))
              )
    elif j == n - 1:
        print(sum_array[-3] + abs(array[-2]))
    else:
        print(sum_array[-1] -
              (sum_array[j + 1] - sum_array[j]) -
              (sum_array[j + 2] - sum_array[j + 1]) +
              (abs(array[j + 1] - array[j - 1]))
              )
n,x,m = map(int,input().split())

y=x
A=[]
A.append(y)
cnt=1
su=x

for i in range(n):
    y=(y**2)%m
    cnt+=1
    if y in A:
        break
    else:
        A.append(y)
        su+=y

if len(A)==n:
    print(su)

else:



    c=A.index(y) #周期のはじめ
    d=cnt-(c+1)  #周期のはじめから次の周期のはじめで個数を求める

    e=sum(A[:c]) 
    #周期に入るまえまでを足しておく

    f=0
    for w in range((n-c)%d):
        f+=A[c:][w]
        #周期からはみでた最後の部分

    g=su-e#1周期分
    h=g*((n-c)//d)#かけざん

    print(e+h+f)

### FIXED CODE ###

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

y=x
A=[]
A.append(y)
cnt=1
su=x

for i in range(m):
    y=(y**2)%m
    cnt+=1
    if y in A:
        break
    else:
        A.append(y)
        su+=y

c=A.index(y) #周期のはじめ
d=cnt-(c+1)  #周期のはじめから次の周期のはじめで個数を求める

e=sum(A[:c]) 
#周期に入るまえまでを足しておく


f=sum(A[c:c+(n-c)%d])
    #周期からはみでた最後の部分

g=su-e#1周期分
h=g*((n-c)//d)#かけざん

print(e+h+f)
from gcd import fractions
a,b,c,d = map(int,input().split())
def l(x,y):
    return x*y//gcd(x,y)
U = b-a+1
s1 = b//c - (a-1)//c
s2 = b//d - (a-1)//d
s3 = b//l(a,b) - (a-1)//l(a,b)
print(U-(s1+s2-s3))



### FIXED CODE ###

from fractions import gcd
a,b,c,d = map(int,input().split())
def l(x,y):
    return (x*y)//gcd(x,y)
U = b-a+1
s1 = b//c - (a-1)//c
s2 = b//d - (a-1)//d
s3 = b//l(c,d) - (a-1)//l(c,d)
print(U-(s1+s2-s3))
a = int(input))
num_list = list(map(int,input().split()))
flag = ""
for i in range(a-1):
  if num_list[i]-1 <= num_list[i+1]:
    flag = "ok"
  else:
    flag = "ng"
if flag = "ok":
  print("Yes")
else:
  print("No")

### FIXED CODE ###

from collections import Counter
a = int(input())
num_list = list(map(int,input().split()))
flag = "ok"
num_o = 0
for i in range(a-1):
  if num_list[i] > num_o:
    num_list[i] = num_list[i]-1
    num_o = num_list[i]
  if num_list[i]-num_list[i+1] > 0:
    flag = "ng"
    break

num_counter = Counter(num_list)
num_most = num_counter.most_common()
#if a == num_most[0][1] and a != 0:
#  flag = "No"
if flag == "ok":
  print("Yes")
else:
  print("No")
N=int(input())
list=list[map(int,input().split())]

x='Yes'
for i in range(N):
  if list[i]<=list[i+1]:
    continue()
  elif list[i]==list[i+1]+1:
    list[i+1]=list[i+1]+1
  else:
    x='No'
    
print(x)

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
 
before = 0
result = 'Yes'
for i in range(len(h)):
    if i == 0:
        before = h[i] - 1
    else:
        if before < h[i]:
            before = h[i] - 1
        elif before == h[i]:
            before = h[i]
        else:
            result = 'No'
print(result)
N = int(input())
S = str(input())
 
__DEBUG__ = False
 
def solution():
    count = 0    
    for i in range(N-2):
        if __DEBUG__: print(f"checking {S[i]} at index: {i}")
        if S[i] == 'A':
            if S[i+1] == 'B' and S[i+2] == 'C':
                count += 1
                # continue
    return count
 
    
if __name__ == '__main__':
  	import sys, threading
  	sys.setrecursionlimit(200000)
    threading.stack_size(10240000)
    print(solution())
    


### FIXED CODE ###

N = int(input())
S = str(input())
 


count = 0    
for i in range(N-2):
  if S[i] == 'A':
    if S[i+1] == 'B' and S[i+2] == 'C':
      count += 1
    
print(count)
def lower_elements(A, b):
    lower_bound = -1
    upper_bound = len(A)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if A[middle] < b:  # イ
            lower_bound = middle
        else:
            upper_bound = middle
    return lower_bound + 1  # ウ upper_boundでも可


def upper_elements(C, b):
    lower_bound = -1
    upper_bound = len(C)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if C[middle] <= b:
            lower_bound = middle
        else:
            upper_bound = middle
    return len(C) - upper_bound


def answer(N: int, A: list, B: list, C: list):
    assert N == len(A) == len(B) == len(C)
    A.sort()
    B.sort()
    C.sort()
    count = 0
    for b in B:
        count += lower_elements(A, b) * upper_elements(C, b)
    return count


def snuke_festival():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    print(str(answer(N, A, B, C)) + '¥n')


if __name__ == '__main__':

### FIXED CODE ###

def lower_elements(A, b):
    lower_bound = -1
    upper_bound = len(A)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if A[middle] < b:  # イ
            lower_bound = middle
        else:
            upper_bound = middle
    return lower_bound + 1  # ウ upper_boundでも可


def upper_elements(C, b):
    lower_bound = -1
    upper_bound = len(C)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if C[middle] <= b:
            lower_bound = middle
        else:
            upper_bound = middle
    return len(C) - upper_bound


def answer(N: int, A: list, B: list, C: list):
    assert N == len(A) == len(B) == len(C)
    A.sort()
    B.sort()
    C.sort()
    count = 0
    for b in B:
        count += lower_elements(A, b) * upper_elements(C, b)
    return count


def snuke_festival():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    print(answer(N, A, B, C))


if __name__ == '__main__':
  snuke_festival()
N = int(input())
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
numbers = list(map(int,input().split()))

print(gcd_list(numbers))

### FIXED CODE ###

N = int(input())
import math
#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
x = list(map(int,input().split()))

if N==1:
    print(x[0])
else:
    element = gcd(x[0], x[1])
    if N==2:print(element)
    else:
        for i in range(2,N):
            element=gcd(element,x[i])
        print(element)

# print(gcd_list(numbers))
N, T = input().split()
dic = {}
for i in range(int(input()):
    c, t = [int(i) for i in input().split()]
    dic[t].append(c)
if max(dic) <= T:
    print(dic[max(dic)])
else:
    print('TLE')

### FIXED CODE ###

N, T = map(int, input().split())
costs = []
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        costs.append(c)
if len(costs) == 0:
    print('TLE')
else:
    print(min(costs))
N, K = map( int, 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) )
import sys
sys.setrecursionlimit(100000)
 
def ans():
    def dfs(v, p, d):
        depth[v] = d
        for e, cost in tree[v]:
            if e == p:
                continue
            dfs(e, v, d + cost)
 
    n = int(input())
    tree = [[] for _ in range(n + 1)]
    depth = [0] * (n * 2)
    for _ in range(1, n):
        a, b, c = map(int, input().split())
        tree[a].append((b, c))
        tree[b].append((a, c))
 
    q, k = map(int, input().split())
    dfs(k, -1, 0)
    for _ in range(q):
        x, y = map(int, input().split())
        print(depth[x] + depth[y])
 
 
ans()

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
 
def ans():
    def dfs(v, p, d):
        depth[v] = d
        for e, cost in tree[v]:
            if e == p:
                continue
            dfs(e, v, d + cost)
 
    n = int(input())
    tree = [[] for _ in range(n + 1)]
    depth = [0] * (n * 2)
    for _ in range(1, n):
        a, b, c = map(int, input().split())
        tree[a].append((b, c))
        tree[b].append((a, c))
 
    q, k = map(int, input().split())
    dfs(k, -1, 0)
    for _ in range(q):
        x, y = map(int, input().split())
        print(depth[x] + depth[y])
 
 
ans()
a,b,c,x = input().strip().split()
a,b,c,x = [int(a),int(b),int(c),int(x)]
counter = 0

for i in range(a+1):
    #if 500*i > x:
        #break
    for j in range(b+1):
        #if 500*i+100*j > x:
            #break
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                counter += 1
print(counter)


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
x = int(input())
counter = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                counter += 1
print(counter)
#!/usr/bin/env python3

import sys
import pprint
import math

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	a, b, n = map(int, sys.stdin.readline().split())
	if n < b:
		print(int((n/b - int(n/b))*a))
	else:
		print(int(((b-1)/b - int((b-1)/b))*a))

	


main()

def main():
	log = Logger(1)
	a, b, n = map(int, sys.stdin.readline().split())
	if n < b:
		print(int((n/b - int(n/b))*a))
	else:
		print(int(((b-1)/b - int((b-1)/b))*a))

	


main()

### FIXED CODE ###

#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	a, b, n = map(int, sys.stdin.readline().split())
	if n < b:
		print(int((n/b - int(n/b))*a))
	else:
		print(int(((b-1)/b - int((b-1)/b))*a))

	


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

n = list(map(int,input().split()))
nnn = [pow(2,i) for i in range(45)]
n.sort()
n.reverse()
kkk = len(str(bin(n[0]))) - 2
k = [[0,0] for i in range(kkk)]
nn = 1
co = 0
su = 0
for i in range(kkk):
	for j in range(a):
		if n[j] & nn > 0:
			k[i][1] += 1
		else:
			k[i][0] += 1
	nn *= 2
if nn != 1:
	nn //= 2
for i in range(kkk):
	if k[kkk-1-i][0] => k[kkk-1-i][1]:
		if su + pow(2,kkk-1-i) <= b:
			su += pow(2,kkk-1-i)
if su <= b:
	nn *= 2
	while True:
		if su + nn > b:
			break
		else:
			co += nn*a
			nn *= 2
for i in range(a):
	co += su ^ n[i]
print(co)


### FIXED CODE ###

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

fm = 0
for i in range(40,0,-1):
    x = 2**(i-1)
    p = 0
    q = 0
    for j in a:
        b = x & j
        p += x ^ b
        q += b
    if q >= p:
        fm += q
    else:
        if m >= x:
            fm += p
            m -= x
        else:
            fm += q
print(fm)
a = int(input())
b = int(input())
print(a*b, 2 * (a + b))

### FIXED CODE ###

a, b = input().split()
a = int(a)
b = int(b)
print(a*b, 2 * (a + b))
import sys
sys.setrecursionlimit(10**10)
n, m = map(int, input().split())
road = [tuple(map(int, input().split())) for _ in range(m)]

table = [list() for _ in range(n+1)]
ans = [0 for _ in range(n+1)]
hush = {}

for i in range(1, n+1):
    hush[i] = False

for a, b in road:
    table[a].append(b)
    table[b].append(a)

def bfs(i):
    hush[i] = True
    rec = []
    for j in table[i]:
        if hush[j] == False:
            ans[j] = i
            hush[j] = True
            rec.append(j)
    for j in rec:
        bfs(j)

bfs(1)

print('Yes')
for i in range(2, n+1):
    print(ans[i])

### FIXED CODE ###

from collections import deque

n, m = map(int, input().split())
ways = [tuple(map(int, input().split())) for _ in range(m)]
ans = [None] * (n+1)

hush = {}
hush[1] = True
for i in range(2, n+1):
    hush[i] = False
table = [list() for _ in range(n+1)]
for a, b in ways:
    table[a].append(b)
    table[b].append(a)

que = deque([1])
while len(que) > 0:
    room = que.popleft()
    for next in table[room]:
        if hush[next] == False:
            ans[next] = room
            que.append(next)
            hush[next] = True

print('Yes')
for i in range(2, n+1):
    print(ans[i])
#78 C - HSI
N,M = map(int,input().split())
# 全て AC となる確率
p = (1/2)**M

# E = 1/p になる
E = 1/p
ans = (1900*M + 100*(N-M))*E
ans = round(ans)
print(ans)

### FIXED CODE ###

X,Y = map(ord,input().split())

if X > Y:
  print('>')
elif X < Y:
  print('<')
else:
  print('=')
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
print(a)
cnt = [0]*(10**9)
for i in a:
    cnt[i-1] += 1
print(len([1 for i in cnt if i % 2 == 1]))

### FIXED CODE ###

#!/usr/bin/env python3
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
cnt = 1
ans = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        cnt += 1
    else:
        if cnt %2: ans+= 1
        cnt = 1
print(ans+cnt%2)
import os
import sys
from collections import defaultdict, Counter, deque
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    
    n,m,k = map(int, input().split())
    n_list = list(map(int, input().split()))
    m_list = list(map(int, input().split()))
    i,j,count = 0,0,0

    while(k>0):
        if count == n+m:
            break
        if n_list[i] < m_list[j]:
            k -= n_list[i]
            count += 1
            i += 1
        else:
            k -= m_list[j]
            count += 1
            j += 1
        
        if k < 0:
            count -= 1
            break

    print(count)



            

if __name__ == "__main__":
    main()


### FIXED CODE ###

import os
import sys
from collections import defaultdict, Counter, deque
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    
    n,m,k = map(int, input().split())
    n_list = list(map(int, input().split()))
    m_list = list(map(int, input().split()))

    a_list = [0]
    b_list = [0]

    ans = 0
    num = 0

    for i in range(n):
        a_list.append(a_list[i] + n_list[i])

    for i in range(m):
        b_list.append(b_list[i] + m_list[i])


    
    for i in range(n+1):
        if k < a_list[i]:
            break
        while(b_list[m] > k - a_list[i]):
            m -= 1
        ans = max(ans, i+m)
    print(ans)
            

if __name__ == "__main__":
    main()
import numpy as np
import sys
sys.setrecursionlimit(10**9)

 
N, M, K = map(int, input().split())
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]
 
A = np.array(A)
B = np.array(B)
 
A = np.cumsum(A)
B = np.cumsum(B)
 
A1 = np.zeros((len(A),2))
A1[:,0] = A
A1[:,1] = np.arange(1,len(A)+1)
 
B1 = np.zeros((len(B),2))
B1[:,0] = B
B1[:,1] = np.arange(1,len(B)+1)
 
C1 = np.zeros((len(A)*len(B),2))
lenB = len(B)
for i in range(len(A)):
    for j in range(len(B)):
        C1[lenB*i+j,:] = A1[i,:] + B1[j,:]
C2 = np.array([C[1] for C in C1 if C[0] <= K])
 
if len(C2):
    print(int(C2.max()))
else:
    print(0)


### FIXED CODE ###

import numpy as np

N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

A = np.array(A).cumsum()
B = np.array(B).cumsum()

ans = 0
j = M
for i in range(N+1):
    if A[i] > K:
        break
    while B[j] > K - A[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
N,K = list(map(int,input().split()))
H  = list(map(int,input().split()))
counter = 0
for h in H:
  if h >= K:
    couter += 1
    
print(counter)

### FIXED CODE ###

import bisect
N,K =list(map(int,input().split()))
H =sorted(list(map(int,input().split())))
i = bisect.bisect(H,K-1)
print(N-i)
N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

if len([i for i, (a, b) in enumerate(zip(A, B)) if a != b]) == 0:
    print(N)
    exit()

if len([i for i, (a, b) in enumerate(zip(A, B)) if a > b]) == 1:
    M = N
    i = [i for i, (a, b) in enumerate(zip(A, B)) if a > b][0]

    for k in range(N // A[i] + 1):
        D = N - k * A[i]
        D += k * B[i]
        M = max(M, D)

    i, j = [i for i, (a, b) in enumerate(zip(A, B)) if not a > b]
    ans = M
    for k in range(N // B[i] + 1):
        D = M - k * B[i]
        l, D = divmod(D, B[j])

        D += k * A[i]
        D += l * A[j]

        ans = max(ans, D)

    print(ans)
    exit()

if len([i for i, (a, b) in enumerate(zip(A, B)) if a > b]) == 2:
    M = N

    i, j = [i for i, (a, b) in enumerate(zip(A, B)) if not a > b]
    for k in range(N // B[i] + 1):
        D = N - k * B[i]
        l, D = divmod(D, B[j])

        D += k * A[i]
        D += l * A[j]

        M = max(M, D)

    i = [i for i, (a, b) in enumerate(zip(A, B)) if a > b][0]
    ans = M
    for k in range(N // A[i] + 1):
        D = M - k * A[i]
        D += k * B[i]
        ans = max(ans, D)

    print(ans)
    exit()

def calc(fr, to):
    ret = N
    for g in range(N // fr[0] + 1):
        for s in range(N // fr[1] + 1):
            D = N - g * fr[0] - s * fr[1]

            if D < 0:
                break

            q, r = divmod(D, fr[2])

            D += g * to[0]
            D += s * to[1]

            r += g * to[0]
            r += s * to[1]
            r += q * to[2]

            ret = max(ret, D, r)
    return ret

print(calc(A, B))


### FIXED CODE ###

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

def calc(A, B, N):
    M = N
    if len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 1:
        i = [i for i, (a, b) in enumerate(zip(A, B)) if a < b][0]

        for k in range(N // A[i] + 1):
            D = N - k * A[i]
            if D < 0:
                continue

            D += k * B[i]
            M = max(M, D)
    elif len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 2:
        i, j = [i for i, (a, b) in enumerate(zip(A, B)) if a < b]

        for k in range(N // A[i] + 1):
            D = N - k * A[i]
            l, D = divmod(D, A[j])

            D += k * B[i]
            D += l * B[j]

            M = max(M, D)
    elif len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 3:
        for g in range(N // A[0] + 1):
            for s in range(N // A[1] + 1):
                D = N - g * A[0] - s * A[1]

                if D < 0:
                    break

                q, r = divmod(D, A[2])

                D += g * B[0]
                D += s * B[1]

                r += g * B[0]
                r += s * B[1]
                r += q * B[2]

                M = max(M, D, r)
    return M

print(calc(B, A, calc(A, B, N)))
import math
A,B,C,D = list(map(int,input().split()))

 
lcm = C*D/math.gcd(C,D)
a = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//lcm)
b = (B) - ((B)//C + (B)//D - (B)//lcm)
print(int(b-a))

### FIXED CODE ###

from fractions import gcd

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

lcm = C*D/gcd(C,D)

a = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//int(lcm))
b = (B) - ((B)//C + (B)//D - (B)//int(lcm))
print(int(b-a))
def main():
  N = int(input())
  t = input().split(" ")
  a = [int(i) for i in t]
  a.sort()
  
  for i in range(N):
    if i <= N/2:
      print(a[N/2+1])
    else:
      print(a[N/2])
main()


### FIXED CODE ###

def main():
  N = int(input())
  t = input().split(" ")
  a = [int(i) for i in t]
  b = sorted(a)
  sm = b[N//2-1]
  bm = b[N//2]
  
  for i in a:
    if i <= sm:
      print(bm)
    else:
      print(sm)
main()
import sys
sys.setrecursionlimit(10**6)
n,q = map(int,input().split())
tree = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
ans = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    ans[p-1] += x
done = [0]*n
def dfs(now,m):
    done[now] = 1
    ans[now] += m
    for i in tree[now]:
        if not done[i]:
            dfs(i,ans[now])
dfs(0,0)
print(*ans)

### FIXED CODE ###

if int(input()) < 3200:
  print("red")
else:
  print(input())
def main():
    n, k = [int(i) for i in input().split()]
    num = [int(i) for  i in input().split()]
    sorted(num)
    del num[-k:]
    print(sum(num))
main()


### FIXED CODE ###

def main():
    num = [int(i) for i in input().split()]
    h = num[0]
    a = num[1]
    return attack(h, a)

def attack(h,a):
    if h % a == 0:
        return h // a
    elif h % a >= 1:
        return (h//a) + 1

print(main())
import numpy as np
flag = False

N = int(input())
H = list(map(int, input().split()))
H = np.array(H)
D = (H[1:]-H[:-1])

for i in range(len(H[1:]-H[:-1])):
    if D[i] < -1:
        flag = True
        break
    elif D[i] == -1:
        if D[i-1] == -1:
            flag = True
        elif D[i+1] == -1:
            flag = True

if flag == True:
    print('No')
else:
    print('Yes')


### FIXED CODE ###

import sys

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

for i in range(n-1):
    d = h[i+1] - h[i]
    if d >= 1:
        h[i+1] -= 1
    elif d < 0:
        print('No')
        sys.exit()
print('Yes')
A, B, C = map(int, input().split())
print(map(C, A, B)

### FIXED CODE ###

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

BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))

A.sort()

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

BC = [[bc[1]] * bc[0] for bc in BC]
BC = [flat_bc for bc in BC for flat_bc in bc]

for i in range(N):
    if A[i] < BC[-1]:
        A[i] = BC[-1]
        BC.pop()

print(sum(A))

### FIXED CODE ###

from collections import deque

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

BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))

A.sort()

BC.sort(key=lambda x:x[1], reverse=True)

D = deque([])
for bc in BC:
    b = bc[0]
    c = bc[1]

    for _ in range(b):
        D.append(c)

    if len(D) >= N: 
        break

for i in range(N):
    if A[i] < D[0]:
        A[i] = D[0]
        D.popleft()
        if not D:
            break

print(sum(A))
s_d = [i for i in input()]
t = input()
flg = True

for i in range(len(s_d)-1, -1, -1):
    if len(s_d) - i >= len(t) and s_d[i] == '?' or s_d[i] == t[0]:
        j, n = i+1, 1
        while j < len(s_d) - 1:
            if s_d[j] == '?' or s_d[j] == t[n]:
                j += 1
                n += 1
            else:
                break

        if n >= len(t):
            s_d[i:j] = t
            break
else:
    print("UNRESTORABLE")
    flg = False

if flg:
    for i in range(len(s_d)):
        if s_d[i] == '?':
            s_d[i] = 'a'

    print("".join(s_d))


### FIXED CODE ###

s_d = [i for i in input()]
t = input()
flg = True

for i in range(len(s_d)-1, -1, -1):
    if len(s_d) - i >= len(t) and s_d[i] == '?' or s_d[i] == t[0]:
        j, n = i+1, 1
        while j <= len(s_d) - 1 and n <= len(t) - 1:
            if s_d[j] == '?' or s_d[j] == t[n]:
                j += 1
                n += 1
            else:
                break

        if n >= len(t):
            s_d[i:i+len(t)] = t
            break
else:
    print("UNRESTORABLE")
    flg = False

if flg:
    for i in range(len(s_d)):
        if s_d[i] == '?':
            s_d[i] = 'a'

    print("".join(s_d))