peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, Y = map(int, input().split())
flag = 1

for i in range(N+1):
    for j in range(N+1):
        if Y == i * 10000 + j * 5000 + (N-i-j) * 1000 and flag == 1:
            print("{} {} {}".format(i, j, N-i-j))
            flag = 0

if flag == 1:
    print("-1 -1 -1")
# Judge status: Accepted
import math
a = input().split()
b = map(int,input().split())
c = int(a[0])-sum(b)
if (c < 0):
    print("-1")
else:
    print(c)
# Judge status: Accepted
N, D = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i):
        d = sum((x - y)**2 for x, y in zip(P[i], P[j]))
        x = int(d**.5)
        if x**2 == d:
            ans += 1
print(ans)
# Judge status: Wrong Answer
l=list(map(int,input().split()))
l.sort()
a,b,c=l[0],l[1],l[2]
if (b-a)%2==1 and (c-a)%2==1:
  print(1+(c+1-a)//2+(c-b)//2)
elif (b-a)%2==0 and (c-a)%2==0:
  print((2*c-a-b)//2)
else:
  print(1+(2*c+1-a-b)//2)
# Judge status: Accepted
W,H,x,y = map(int,input().split())

S = (W*H)/2
if x == W/2 and y == H/2:
    print(S,1)
else:
    print(S,0)
# Judge status: Accepted
a,b,m=map(int,input().split())
ali= list(map(int,input().split()))	
bli= list(map(int,input().split()))	
min=min(ali)+min(bli)
for i in range(0,m):
  x,y,c=map(int,input().split())
  mon=ali[x-1]+bli[y-1]-c
  if mon<min:
    min=mon
    
print(min)
# Judge status: Wrong Answer
import math
a,b,h,m=map(int,input().split())
h=h*30+(m/60)*30
m=m*6
diff=abs(h-m)
if(diff>180):
    diff=diff-180
ans=a*a+b*b-2*a*b*abs(math.cos(diff*((math.pi)/180)))
print(math.sqrt(ans))
# Judge status: Accepted
x,a,b = map(int,input().split())
if abs(x-a) > abs(x-b):
	print("B")
else:	
	print("A")
# Judge status: Wrong Answer
from math import *
a,b,k=map(int,input().split())
c=0
s=1
while(1):
    if(a%s==0 and b%s==0):
        c=c+1
    if(c==k):
        print(s)
        break
    s+=1
# Judge status: Accepted
import math
a,b,x = map(int,input().split())
S = x/a
if S >= a*b/2:
    h = 2*(a*b-S)/a
    print(math.degrees(math.atan2(h,a)))
else:
    h = 2*S/b
    print(math.degrees(math.atan2(b,h)))
# Judge status: Accepted
x=int(input())
num1=(x//11)*2
num2=x%11
if num2>=7:
    num1+=2
elif num2!=0:
    num1+=1
print(num1)
# Judge status: Accepted
s = input() + 'n'
ans = 0
fans = 0
for i in range(len(s)):
    if s[i] =='A' or s[i] =='C' or s[i] =='G' or s[i] =='T':
        ans += 1
    elif fans < ans:
        fans = ans
        ans = 0
print(fans)
# Judge status: Wrong Answer
import sys

n=int(input())
list=[]
sum=0
list.append(2)
list.append(1)
for i in range(2,87):
	list.append(list[i-1]+list[i-2])
	if n==i:
		print(list[-1])
		sys.exit()
# Judge status: Accepted
#%%
from collections import Counter
n = input()
d = list(map(int, input().split()))



#%%
d_cnt =Counter(d)
d_cnt = dict(d_cnt)

d_cnt_keys = list(d_cnt.keys())
d_cnt_keys.sort()

if d[0] != 0 or d_cnt[0] != 1 or len(d_cnt_keys)!= d_cnt_keys[-1]+1:
    print(0)
    exit()

#%%

ans = 1
p = 998244353
for key in d_cnt_keys:
    if key == 0:
        continue
    ans =ans*pow(d_cnt[key-1], d_cnt[key],p)%p
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import itertools
import math
n, d = map(int, input().split())
a = [[] for m in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))
count = 0
for i in range(n):
    for j in range(i+1,n):
        value = 0
        for k in range(d):
            value += (a[i][k] - a[j][k]) ** 2
        check = value ** 0.5
        count += check.is_integer()
print(count)
# Judge status: Wrong Answer
li = list(map(int, input().split()))
if li == [5, 5, 7]:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

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

N = int(readline())
S = readline().decode('utf8')

ans = 0
for i in S:
    cnt = 0
    if i == 'I':
        cnt += 1
    else:
        cnt -= 1

    ans=max(ans, cnt)
# Judge status: Accepted
def solve():
    import sys
    read = sys.stdin.read
    *s, k = map(int, read().split())
    flg = True
    for a in s:
        for b in s:
            if abs(a - b) > k:
                flg = False
    print("Yay!" if flg else":(")

solve()
# Judge status: Wrong Answer
S=input()
ans=1
S0=S[0]
N=len(S)
ss=list()
i=1
while i <N-1:
    if S0==S[i]:
        S0=S[i]+S[i+1]
        ans+=1
        i+=2
        ss.append(S0)
    else:
        S0=S[i]
        ans+=1
        i+=1
        ss.append(S0)
if S[-1]!=S[-2]:
    ans+=1
print(ans)
# Judge status: Accepted
print("Heisei" if input()<="2019/04/30" else "TBD")
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
B=[]
for _ in range(Q):
    B.append(list(map(int,input().split())))
s=sum(A)
from collections import Counter
a=Counter(A)
b=list(a.keys())
c=list(a.values())
for i in range(Q):
    for j in range(len(set(A))):
        if b[j]==B[i][0]:
            s-=b[j]*c[j]
            s+=B[i][1]*c[j]
    print(s)
# Judge status: Accepted
x = int(input())
ans = x//11*2

if x%11 == 0:
    pass
elif x%11 <= 6:
    ans += 1
else:
    ans += 2

print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
print(max(a,b)+max(max(a,b)-1, min(a,b)))
# Judge status: Accepted
N = int(input())

a_max = N // 4
b_max = N // 7

match = False
for i in range(a_max+1):
    for j in range(b_max+1):
        if i*4 + j*7 == N:
            match = True

if match:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer

n = int(input())
a = []
b = []
ans = [0]

for _ in range(n):
    A,B = map(int,input().split())
    a.insert(0,A)
    b.insert(0,B)

for i in range(n):
    tmp = 0
    tmp = b[i] - ((a[i]+ans[i])%b[i])
    ans.append(ans[i]+tmp)
#print(ans)

print(ans[-1])
# Judge status: Wrong Answer
N,T = map(int,input().split())
X = [list(map(int,input().split())) for n in range(T)]
M = N
m = 0

for a,b in X:
  M = min(M,b)
  m = max(m,a)

print(M-m+1)
# Judge status: Wrong Answer
N = int(input())

result = N * (N - 1) 
result = (result * (10 ** (N - 2))) % (10 ** 9 + 7)

print(result)
# Judge status: Accepted
a,b,x=map(int,input().split())
if x-a>b or x<a:
  print("NO")
else:
  print("YES")
# Judge status: Accepted
import decimal

a, b = input().split()
print(int(decimal.Decimal(a)*decimal.Decimal(b)))
# Judge status: Accepted
S=input()

ans=''
for i in S:
    if i=='0':
        ans+='0'
    elif i=='1':
        ans+='1'
    else:
        if len(ans)>=2:
            ans=ans[:len(ans)-1]
        else:
            ans=''

print(ans)
# Judge status: Accepted
n=int(input())

ans=[]
num=0

i=1
while num<n:
  num+=i
  ans.append(i)
  i+=1
else:
  sa=num-n

if sa!=0:
  ans.remove(sa)

for i in ans:
  print(i)
# Judge status: Wrong Answer
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from collections import deque
def main():

    n = int(input())
    ans = deque()
    num = 1
    while n >= num:
        if n - num not in ans:
            ans.append(num)
            n -= num
        num += 1

    print(*ans, sep='\n')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
x, y = map(int, input().split())
ans = abs(abs(x)-abs(y))
if x < 0 and y < 0 and x > y:
	ans += 2
elif x > 0 and y > 0 and x > y:
	ans += 2
elif x < 0 or y < 0:
	ans += 1
print(ans)
# Judge status: Accepted
import math

n,k =  map(int,input().split())
lis = []
for i in range(n):
    if i+1 >= k:
        lis.append(0)
    else:
        lis.append(math.ceil(math.log2((k/(i+1)))))

#print(lis)


ans = []
for i in range(n):
    ans.append(1/n * (1/2)**lis[i])

print(sum(ans))
# Judge status: Wrong Answer
x, y = map(int, input().split())

if x <= y:
  print(min(y - x, 1 + abs(abs(y) - abs(x))))
elif x * y < 0:
  print(1 + abs(abs(y) - abs(x)))
else:
  print(2 + abs(abs(y) - abs(x)))
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
    a = i % 10
    b = (i - a) % (10 ** 2) //10
    c = (i - 10 * b - a) % (10 ** 3) //100
    d = (i - 100 * c - 10 * b - a) % (10 ** 4)/1000
    if A <= a + b + c + d <= B:
        ans += i
print(ans)
# Judge status: Wrong Answer
n = int(input())
h = list(map(int, input().split()))
INF = 10**8
dp = [INF]*n
dp[0] = 0
for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]))
print(dp[n-1])
# Judge status: Accepted
n=int(input())
s=input()
a=0
ans=0
for i in range(n):
    if s[i]=="I":
        a+=1
    else:
        a-=1
    ans=max(a,ans)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

limit = 10 ** 18
res = A[0]

if 0 in A:
    print(0)
    exit(0)
else:
    for i in range(1, N):
        res *= A[i]
        if res > limit:
            print(-1)
            exit(0)

print(res)
# Judge status: Accepted
k, n = map(int, input().split())
a = list(map(int, input().split()))
max = 0
len = [0] * n
for i in range(n):
    if i == 0:
        len[i] = a[i]
    else:
        len[i] = a[i] - a[i - 1]
        if len[i] >= len[max]:
            max = i
print(min((k - a[max]) + a[max - 1], a[n - 1] - a[0]))
# Judge status: Accepted
S = input().rstrip()
if S == "RRR":
    print(3)
elif S=="SRR" or S=="RRS":
    print(2)
elif S == "RSS" or S=="SRS" or S=="SSR" or S=="RSR":
    print(1)
else:
    print(0)
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
for i in range(1, N):
    if H[i] - H[i - 1] > 0:
        H[i] -= 1

pre = 0
flg = True
for h in H:
    if h < pre:
        flg = False
        break
    pre = h
print('Yes' if flg else 'No')
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
A = sorted(A, reverse=True)
tate=0
yoko=0

for i in range(N-1):
    if A[i]==A[i+1]:
        tate=A[i]
        A.remove(A[i+1])
        A.remove(A[i])
        break

for i in range(len(A)-1):
    if A[i]==A[i+1]:
        yoko=A[i]
        break

print(tate*yoko)
# Judge status: Wrong Answer
nums = input().split()
a = int(nums[0])
b = float(nums[1])

print(int(a*b))
# Judge status: Accepted
a, b, c = map(int, input().split())
print(a * b // 2)
# Judge status: Accepted
a = list(input().rstrip())
print('Yes') if (a[2] == a[3] and a[4] == a[5]) else print('No')
# Judge status: Accepted
n=int(input())
a=[1]
i=0
count=2
while(a[i]<n):
    a.append(a[i]+count)
    count+=1
    i+=1
#print(a)
print(count-1)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

is_alice_turn = True

alice_point = 0
bob_point = 0

while len(A) != 0:
    picked_num = max(A)
    if is_alice_turn:
        alice_point += picked_num
    else:
        bob_point += picked_num

    A.remove(picked_num)
    is_alice_turn = not is_alice_turn

print(alice_point - bob_point)
# Judge status: Accepted
from heapq import heappop,heappush
N,M=map(int,input().split())
X=sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x: x[0])
hq=[]
ans,j=0,0
for i in range(1,M+1):
    while(j<N) and(X[j][0]<=i):
        heappush(hq,-X[j][1])
        j+=1
    if len(hq):
        ans+=-heappop(hq)
#print(X)
print(ans)
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))

m=2*(10**5)+1
count = 0
for i in range(0, n):
  if p[i] <= m:
    m = p[i]
    count = count + 1

print(count)
# Judge status: Accepted
s = input()
if s == "SUN":
  print(7)
if s == "SAT":
  print(1)
if s == "FRI":
  print(2)
if s == "THU":
  print(3)
if s == "WED":
  print(4)
if s == "TUE":
  print(5)
if s == "MON":
  print(6)
# Judge status: Wrong Answer
N, M = map(int,input().split())

if N == 1 and M == 1:
    print(1)
if N == 1 and M != 1:
    print(M-2)
else:
    print((N-2)*(M-2))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
s = 0
for x in a:
    s ^= x
ans = [x^s for x in a]
print(" ".join(map(str, ans)))
# Judge status: Accepted
s = input()
n = len(s)

c2 = s[:(n-1)//2]
c3 = s[(n+1)//2:]

flg = True

if s != s[::-1]:
    flg = False
if c2 != c2[::-1]:
    flg = False
if c3 != c3[::-1]:
    flg = False
    
    
print('Yes' if flg else 'No')
# Judge status: Accepted
A, B, C, X = [int(input()) for i in range(4)]
print(sum(500*a + 100*b + 50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1)))
# Judge status: Wrong Answer
s=input()
slist=list(s)
a=slist.count('a')
b=slist.count('a')
c=slist.count('a')
if(max(a,b,c)>len(s)//2):
	print("NO")
else:
	print("YES")
# Judge status: Accepted
N, K = map(int,input().split())
A = list(map(int,input().split()))

import math
K = min(K, 43)
for k in range(K):
  light = [0] * (N+1)
  for i in range(N):
    start = max(0,i-A[i])
    end = min(N-1, i+A[i])
    light[start] += 1
    light[end+1] -= 1
  for i in range(1,N):
    light[i] += light[i-1]
    
  A = light

light.pop()
print(" ".join(map(str,light)))
# Judge status: Wrong Answer
import re
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a-1, c-1):
  if s[i] + s[i+1] == "##":
    print("No")
    exit()
for i in range(b-1, d-1):
  if s[i] + s[i+1] == "##":
    print("No")
    exit()
if c < d:
  print("Yes")
else:
  f = False
  for i in range(b-1, d-2):
    if s[i] + s[i+1] + s[i+2] == "...":
      f = True
  if f:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
n,m=map(int,input().split())
l=sorted(list(map(int,input().split())))
if n>=m:
    print(0)
    exit()
s=l[-1]-l[0]
l=sorted([a-b for a,b in zip(l[1:],l)], reverse=True)
print(s-sum(l[:n-1]))
# Judge status: Wrong Answer
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
n,T = ma()
ans=10**15
for i in range(n):
    c,t=ma()
    if t<T:
        ans=min(ans,c)
if ans==10**15:
    print("TLE")
else:print(ans)
# Judge status: Accepted
n = int(input())
h = [[int(i) for i in input().split()] for _ in range(n)]

dp = [[0]*(n+1) for _ in range(3)]

for i in range(n):
    for p in range(3):
        if p == 0:
            q, r = p+1, p+2
        elif p == 1:
            q, r = p+1, p-1
        else:
            q, r = p-2, p-1
        dp[p][i+1] = max(dp[q][i] + h[i][p], dp[r][i] + h[i][p])

print(max(dp[0][-1], dp[1][-1], dp[2][-1]))
# Judge status: Wrong Answer
x = sorted(map(int, input().split()))
print(10 * x[0] + x[1] + x[2])
# Judge status: Wrong Answer
import copy
N = int(input())
S = list(input())
S_ans = copy.deepcopy(S)
app = 0
q = [0]
save = 0
for i in range(N):
    if S[i] == '(':
        q.append(q[-1] + 1)
        if q[-1] == 1:
            save = i
    else:
        q.append(q[-1] - 1)
        if q[-1] == -1:
            S_ans.insert(app + save,"(")
            app += 1
            q[-1] = 0

for i in range(q[-1]):
    S_ans.append(")")
print("".join(S_ans))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
  b[a[i]-1]=i+1
b=[str(c) for c in b]
print(" ".join(b))
# Judge status: Accepted
# 未完成
def solve():
    n = int(input())
    a = 0
    s = {}
    for i in range(n):
        t = ''.join(sorted(input()))
        b = s.get(t, 0)
        a += b  # k個の同じものから2個選ぶからkC2だが0~(k-1)の総和と同地
        s[t] = b+1
    print(a)


solve()
# Judge status: Accepted
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
s = input()
if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())

ans = 'NG'

for a in range(a, b+1):
    if a % k == 0:
        ans = 'OK'
        break

print(ans)
# Judge status: Accepted
M=120

X=int(input())

for a in range(-M,M+1):
    for b in range(-M,M+1):
        if a**5-b**5==X:
            A,B=a,b
            break

print(A,B)
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

S=list(input())

clu=[]
temp=0
for i in range(1,len(S)):
    if S[i]==S[i-1]:
        temp+=1
    else:
        clu.append(temp)
        temp=0
clu.append(temp)

ans=sum(clu)
ins=len(clu)-2


ans+=min(K,ins)*2
K-=ins
if K>0:
    ans+=1

#print(ins)
print(ans)
#print(clu)
# Judge status: Accepted
s = int(input())

dp = [0] * (s+1)
dp[0] = 1
for i in range(s+1):
    for j in range(3, i+1):
        dp[i] += dp[i-j]
        dp[i] %= 10**9+7
print(dp[s])
# Judge status: Accepted
a, b, c = list(map(int, input().split()))

if (c<=b):
    print("delicious")
elif (c>b):
    if (c-b)<=a:
        print("safe")
    else:
        print("dangerous")
# Judge status: Accepted
N, M, X, Y = map(int, input().split())
x = input().split()
y = input().split()
x = [int(i) for i in x]
y = [int(i) for i in y]
x.sort()
y.sort()
if (x[-1] < y[0]) and (Y > x[-1]) and (X < y[0]):
    print("No War")
else:
    print("War")
# Judge status: Accepted
[S,T]=list(input().split())
[A,B]=map(int,list(input().split()))
U=input()

if(U==S):
    print(A-1,B)
else:
    print(A,B-1)
# Judge status: Accepted
N,K = map(int,input().split())
for i in range(100):
    if N<K**i:
        print(i)
        break
# Judge status: Accepted
s = input()

cnt = 0

for c in s:
  if c == "1":
    cnt += 1

print(cnt)
# Judge status: Accepted
n = int(input())
l = [int(x) for x in input().split()]
D = set() #Duplication
S = set() #all
for x in l:
    if x in S:
        D.add(x)
    else:
        S.add(x)

M = max(S)
limit = M+1
mp = [0]*(limit)

cnt = 0
S = sorted(S)
for x in S:
    for y in range(x,limit,x):
        mp[y] += 1
    if(x in D):
        continue
    if(mp[x]==1):
        cnt += 1
        
print(cnt)
# Judge status: Accepted
A, B, C, D = list(input())
import itertools
for ops in itertools.product(["+", "-"], repeat=3):
  eq = A + ops[0] + B + ops[1] + C + ops[2] + D
  x = eval(eq)
  if x == 7:
    break

print(eq + "=7")
# Judge status: Accepted
ans = 9999999999
n = int(input())
for a in range(1, n):
  b = n - a
  ans = min(ans, sum(map(int, list(str(a)))) + sum(map(int, list(str(b))))) 

print(ans)
# Judge status: Accepted
s=int(input())
MAX=1000000
i=2
F=[0]*1000001
F[1]=s

def calc(n):
  n=F[n-1]
  if n%2==0:
    return n//2
  else:
    return 3*n+1

while i<=MAX:
  ans=calc(i)
  if ans in F:
    break
  F[i]=ans
  i+=1
print(i)
# Judge status: Accepted
N = int(input())

kuku = [i * j for i in range(1, 10) for j in range(1, 10)]

if N in kuku:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x,y = map(int,input().split())

if (x+y)%3 != 0:
  print(0)
  exit()
if 2*x < y:
  print(0)
  exit()
if 2*y < x:
  print(0)
  exit()
  
mod = 10**9+7
n = (2*x-y)//3
m = (2*y-x)//3

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod) 
  
def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

print(comb(n+m,n,mod))
# Judge status: Accepted
A,B,M = map(int,input().split())

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

min = sorted(a)[0] + sorted(b)[0]

for  i  in range(M):
    x,y,c =map(int,input().split())
    if min > a[x-1]+b[y-1]-c:
        min = a[x-1]+b[y-1]-c
            
print(min)
# Judge status: Wrong Answer
print("NYoe s"[input().count("9")::2])
# Judge status: Accepted
A,B = map(int,input().split())
if max(A,B) <= 8:
	print("Yay!")
else:
	print(":(")
# Judge status: Accepted
a,b=map(int,input().split())
if a<=0 and b>=0:
  print('Zero')
elif a>0:
  print('Positive')
elif a<0 and b>0:
  if abs(a)%2==0:
    print('Positive')
  else:
    print('Negative')
else:
  if (b-a)%2==0:
    print('Negative')
  else:
    print('Positive')
# Judge status: Wrong Answer
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

S = input()
T = input()

for i in reversed(range(len(S)-len(T)+1)):
    flg = 1
    for j in range(len(T)):
        if S[i+j] != '?' and S[i+j] != T[j]:
            flg = 0
            break
    if flg:
        ans = S[:i] + T + S[i+len(T)+1:]
        print(ans.replace('?','a'))
        exit()

print('UNRESTORABLE')
# Judge status: Wrong Answer
import math

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

if n < b:
    print('a')
    ans = math.floor(a*n/b) - a * math.floor(n/b)
    print(ans)
else:
    ans = a - (a-1) // b - 1
    print(ans)
# Judge status: Wrong Answer
import math

n, x = map(int, input().split())
X = sorted(list(map(int, input().split())))
dis = [0] * (n-1)

xdis = 0
for i in range(n-1):
    dis[i] = X[i+1] - X[i]
    if X[i] <= x <= X[i+1]:
        xdis = min(abs(x-X[i]), abs(X[i+1]-x))

if n == 1:
    print(X[0]-x)
    exit()        
if xdis == 0:
    reg = dis[0]
else:
    reg = xdis

for i in range(n-1):
    reg = math.gcd(reg, dis[0])

print(reg)
# Judge status: Accepted
from itertools import permutations
 
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
 
perm = list(permutations(range(1, N + 1)))
 
for i, pe in enumerate(perm, start=1):
    if P == pe:
        a = i
    if Q == pe:
        b = i
print(abs(a - b))
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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

for a in range(n+1):
    for b in range(n+1):
        c = max(n - (a+b), 0)
        if (a+b+c == n):
            if (10000*a+5000*b+1000*c == y):
                print(a,b,c)
                exit()
print(-1,-1,-1)
# Judge status: Wrong Answer
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
c = Counter(readInts())

ans = 0
for i in c:
	if c[i]-i>0:
		ans+=c[i]-i
	elif c[i]-i<0:
		ans+=min(i-c[i],c[i])

print(ans)
# Judge status: Accepted
S = input()
if S[-1] == "s":
    S += "es"
else:
    S += "s"
print(S)
# Judge status: Accepted
N, M = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(M)]
minN = 0 if N == 1 else 10 ** (N - 1)

for t in range(minN, 10 ** N):
    for s, c in C:
        if (t // (10 ** (N - s))) % 10 != c:
            break
    else:
        ans = t
        break
else:
    ans = -1

print(ans)
# Judge status: Accepted
mem = {}
def f(n):
	if n in mem:
		return mem[n]
	ans,b = 0, 1
	while(b <= n):
		k = n / b
		ans += b *k * (k + 1) / 2  
		b +=1
	mem[n] = ans
	return ans
print f(int(raw_input()))
# Judge status: Accepted
X = int(input())
ans = []
for b in range(1, 100):
    for p in range(2, 50):
        ans.append(b**p)
ans = [i for i in ans if i <= X]
ans.sort(reverse = True)
print(ans[0]) if X!=1 else print(1)
# Judge status: Accepted
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
for i in range(n-m+1):
    for g in range(n-m+1):
        d=[]
        for l in range(m):
            d.append(a[l+i][g:g+m])
        if d==b:
            print("Yes")
            exit()
print("No")
# Judge status: Wrong Answer
K, N = map(int, input().split())
A = list(map(int, input().split()))
d = []

for i in range(N-1):
  d.append(A[i+1] - A[i])
d.append((K - A[N-1]) + A[0])

print(d)
d.remove(max(d))
print(sum(d))
# Judge status: Accepted
n=int(input())
abc=[list(map(int, input().split())) for _ in range(n)]
dp=[0]*3

for a,b,c in abc:
    dp=[max(dp[1],dp[2])+a,max(dp[0],dp[2])+b,max(dp[0],dp[1])+c]
print(max(dp))
# Judge status: Accepted
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
h = LI()
dp = [INF for _ in range(N)]
dp[0] = 0
for i in range(N-1):
    dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
    if i < N-2:
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]))
print(dp[-1])