Harryxun/stf_run huggingface dataset:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)

    if N == 3:
        raise 1

    D = 32
    x1 = y1 = 10**9+1
    x2 = y2 = 0
    vis = set()
    for xy in zip(it, it):
        if xy in vis:
            continue
        vis.add(xy)
        x, y = xy
        x1 = min(x1, x); x2 = max(x2, x)
        y1 = min(y1, y); y2 = max(y2, y)
    dd = max(1, (x2-x1) // D, (y2-y1) // D)
    dx = (x2-x1+1)//dd + 1
    dy = (y2-y1+1)//dd + 1
    d = [[[] for j in range(dx)] for i in range(dy)]


    md = [[] for i in range(dx+dy-1)]
    for i in range(dx*dy):
        ay1, ax1 = divmod(i, dx)
        md[0].append((ax1, ay1, ax1, ay1))
        for j in range(i+1, dx*dy):
            ay2, ax2 = divmod(j, dx)
            md[abs(ax1-ax2)+abs(ay1-ay2)].append((ax1, ay1, ax2, ay2))

    for xy in vis:
        x, y = xy
        ix = (x-x1) // dd
        iy = (y-y1) // dd
        d[iy][ix].append(xy)

    ans = 0
    cnt = 1
    i = len(md)
    for md1 in reversed(md):
        i -= 1
        for x1, y1, x2, y2 in md1:
            if len(d[y2][x2]) == 0:
                continue

            for xx1, yy1 in d[y1][x1]:
                for xx2, yy2 in d[y2][x2]:
                    val = abs(xx1-xx2) + abs(yy1-yy2)

                    ans = max(ans, val)
        if ans:
            if (i+1)*dd -2 < ans:
                break
            if cnt: cnt -= 1
            else: break
    print(ans)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from operator import sub

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)

    M = 10**9+1
    data = [[M, -M], [M, -M]]
    for x, y in zip(it, it):
        for i, x in enumerate([x+y, x-y]):
            for j, f in enumerate([min, max]):
                data[i][j] = f(data[i][j], x)

    print(max(map(lambda x: abs(sub(*x)), data)))



if __name__ == "__main__":
    resolve()
a,b,c,x=map(int,input().split())
ans=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:
                ans+=1
print(ans)

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=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:
                ans+=1
print(ans)
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

def main():
    for number in m:
        if solve(n - 1, 0, number):
            print('yes')
        else :
            print('no')

def solve(i, m, number):
    if m == number:
        return 1

    if i < 0:
        return 0

    res = solve(i - 1, m, number) | solve(i - 1, m + a[i], number)
    return res

if __name__ == '__main__':
    main()



### FIXED CODE ###

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

def main():
    for number in m:
        if solve(0, number):
            print('yes')
        else :
            print('no')

def memolize(f):
    cache = {}

    def helper(x, y):
        if (x, y) not in cache:
            cache[(x, y)] = f(x, y)
        return cache[(x, y)]
    return helper

@memolize
def solve(i, m):
    if m == 0:
        return True

    if i >= n:
        return False

    res = solve(i + 1, m) or solve(i + 1, m - a[i])
    return res

if __name__ == '__main__':
    main()
args=input()

n=int(args[0])
s=args[1]

if n % 2 == 1:
  print('No')
else:
  half=n/2
  s1=s[half:]
  s2=s[:half]
  print('No' if s1!=s2 else 'Yes')
  

### FIXED CODE ###

n = int(input())
s = input()
if n % 2:
    print("No")
    exit()
half = s[0:n // 2]
print("Yes" if s == half + half else "No")
a = input()
b = input()
num = int(a + b)
n = math.sqrt(num)
if float.is_integer(n):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

import math
input = input().split(' ')
a = input[0]
b = input[1]
num = int(a + b)
n = math.sqrt(num)
if float.is_integer(n):
    print("Yes")
else:
    print("No")
from math import factorial
n,k=map(int,input().split())
INF=1000000007
for i in range(1,k+1):
  ans=int(factorial(n-k+1)//factorial(i)//factorial(n-k+1-i)*factorial(k-1)//factorial(k-i)//factorial(i-1))
  while ans>INF:
    ans=ans%INF
  print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(n+1):
  dp[i][0]=1
dp[1][1]=1
for i in range(2,n+1):
  for j in range(1,k+1):
    dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)
data = sorted(list(range(10**5+1)))
prime_bool = [True]*(10**5+1)
prime_bool[0] = False
 
for i in range(len(data)):
  p = data[i]
  if prime_bool[p]:
    k = 2
    while k*p <= max(a):
      prime_bool[k*p] = False
      k += 1

count_list = [0]*(10**5+1)
for i in range(1, 10**5+1):
  count_list[i] = count_list[i-1]
  if prime_bool[i] and prime_bool[(i+1)//2]:
    count_list[i] += 1

q = int(input())
for i in range(q):
  l,r=map(int, input().split())
  print(count_list[r]-count_list[l-1])
  

### FIXED CODE ###

data = sorted(list(range(10**5+1)))
prime_bool = [True]*(10**5+1)
prime_bool[0] = False
prime_bool[1] = False
for i in range(2, len(data)):
  p = data[i]
  if prime_bool[p]:
    k = 2
    while k*p <= 10**5:
      prime_bool[k*p] = False
      k += 1

count_list = [0]*(10**5+1)
for i in range(1, 10**5+1):
  count_list[i] = count_list[i-1]
  if prime_bool[i] and prime_bool[(i+1)//2]:
    count_list[i] += 1

q = int(input())
for i in range(q):
  l,r=map(int, input().split())
  print(count_list[r]-count_list[l-1])
# input
A = input()
B = input()
C = input()
K = input()

# parse int
A = int(A)
B = int(B)
C = int(C)
K = int(K)

# result var
max_sum = 0

# check 1
max_sum = min(A, K)
K = K - max_sum

# check 0
if K > 0:
  K = K - min(B, K)

# check - 1
if K > 0:
  max_sum = max_sum - min(K, B)
# print result
print(max_sum)

### FIXED CODE ###

import sys
readmi = lambda: map(int, sys.stdin.readline().split())

A, B, C, K = readmi()
# result var
max_sum = 0

# check 1
max_sum = min(A, K)
K = K - max_sum

# check 0
if K > 0:
  K = K - min(B, K)

# check - 1
if K > 0:
  max_sum = max_sum - min(K, C)
# print result
print(max_sum)
import numpy as np
import bisect
a=int(raw_input())
Ali = np.array( map(int,raw_input().split()))
Bli =np.array(map(int,raw_input().split()))
Cli =np.array(map(int,raw_input().split()))
Ali = np.sort(Ali)
Cli = np.sort(Cli)[::-1]
co=0
for B in Bli:
    ca = bisect.bisect_left(Ali,B)
    cb =0
    for C in Cli:
        if C <= B:
            break
        else:
            cb +=1 
    co += ca*cb
print(co)
~           

### FIXED CODE ###

import bisect
N = int(input())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))
Alist.sort()
Clist.sort()
retnum = 0 
for i in Blist:
    Anum = bisect.bisect_left(Alist,i)
    Cnum =  N - bisect.bisect_right(Clist,i)
    retnum +=(Anum * Cnum)
print(retnum)
a,b=map(int input().split())

print(a*b-a-b+1)

### FIXED CODE ###

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

m=a*b-a-b+1

print(int(m))
A, B, K = map(int, input().split())


if A + B <= K:
	print(0, 0)
elif A < K:
	print(0, B - (K - A))
else:
	print(K - A, B)

### FIXED CODE ###

S, T = input().split()
print(T + S)
a, b = map(int, input())
if (a <= b):
  print(a)
else:
  print(a - 1)


### FIXED CODE ###

a, b = map(int, input().split())
if (a <= b):
  print(a)
else:
  print(a - 1)
A B = map(int(),input().split())
if(A>0 && B%A==0):
  print(B+A)
else:
  print(B-A)
  

### FIXED CODE ###

A,B=map(int,input().split())
if(A>0 and B%A==0):
  print(B+A)
else:
  print(B-A)
n = int(input)
l = list(map(int, inpupt().split()))
if 0 in l:
  print(0)
  exit()
total = 1
for i in range(n):
  total *= l[i]
  if total > 10 ** 18:
    total = -1
    break
print(total)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
if 0 in l:
  print(0)
  exit()
ans = 1
for i in range(n):
  ans *= l[i]
  if ans > 10**18:
    ans = -1
    break
print(ans)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
dis=list[a,b,c,d,e,k]

if max(dis)-min(dis)>=K:
  print(":(")
else("Yay!") 

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
dis =[]
dis.append(a)
dis.append(b)
dis.append(c)
dis.append(d)
dis.append(e)

if max(dis)-min(dis)>k:
  print(":(")
else:
  print("Yay!")
s=input()
array=[]
array+=(int(x) for x in input().split())

def judge(array,s):
  for i in range(int(s)-1):
    if array[i] == array[i+1]:
        return True
  else:
    return False

print(judge(array,s))

  

### FIXED CODE ###

a,b=input().split()
a_num,b_num=input().split()
c=input()
 
if c==a:
  a_num=int(a_num)-1
elif c==b:
  b_num=int(b_num)-1
print(a_num,b_num)
t=int(input)
print('{}:{}:{}'.format(t//3600,t//60%60,t%60))



### FIXED CODE ###

t=int(input())
print('{}:{}:{}'.format(t//3600,t//60%60,t%60))
import math
from functools import reduce

N,K,*A = map(int,open(0).read().split())
g = reduce(math.gcd,A)
print("POSSIBLE" if K % g == 0 else "IMPOSSIBLE") 

### FIXED CODE ###

import fractions
from functools import reduce
N,K,*A = map(int,open(0).read().split())
g = reduce(fractions.gcd,A)
print("POSSIBLE" if K % g == 0 and K <= max(A) else "IMPOSSIBLE")
n=int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

for i in range(len(v)):
    sa = v[i] - c[i]
    if sa > 0:
        ans += sa

print(ans)

### FIXED CODE ###

n=int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(len(v)):
    sa = v[i] - c[i]
    if sa > 0:
        ans += sa

print(ans)
n, l = list(map(int, input().split()))
ts = [l + i - 1 for i in range(1, n + 1)]
print(sum(ts) + min([abs(x) for x in ts]))

### FIXED CODE ###

from fractions import gcd
from decimal import *

a, b, c, d = list(map(Decimal, input().split()))
e = c * d / gcd(c, d)
print(int(b - a + 1 - ((b // c + b // d - b // e) - ((a - 1) // c + (a - 1) // d - (a - 1) // e))))
N, Q = list(map(int, input().split()))
s = input()

lt = []
ld = []

for q in range(Q):
    t, d = input().split()
    lt.append(t)
    ld.append(d)

pl = -1
pr = N

for q in range(Q-1, -1, -1):
    if ld[q] == 'L':
        if s[pl + 1] == lt[q]:
            pl += 1
    else:
        if s[pr - 1] == lt[q]:
            pr -= 1

print(max(pr - pl -1, 0))


### FIXED CODE ###

N, Q = list(map(int, input().split()))
s = input()

lt = []
ld = []

for q in range(Q):
    t, d = input().split()
    lt.append(t)
    ld.append(d)

pl = -1
pr = N

for q in range(Q-1, -1, -1):
    if ld[q] == 'L':
        if pl < N - 1 and s[pl + 1] == lt[q]:
            pl += 1
        if pr <= N - 1 and s[pr] == lt[q]:
            pr += 1
    else:
        if pr > 0 and s[pr - 1] == lt[q]:
            pr -= 1
        if pl >= 0 and s[pl] == lt[q]:
            pl -= 1

print(max(pr - pl -1, 0))
import numpy as np

def Probability(p,n):
    dp = np.zeros((n+1 ,n+1)) 
    for i in range(n+1):
        for j in range(n+1):
            dp[i][j] = 0.0 
    dp[0][0] = 1.0
    
    for i in range(1,n+1):
        for j in range(i+1):
            if j==0:
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i]) 
            else : 
                dp[i][j] = (dp[i - 1][j] * (1.0 - p[i]) +
                            dp[i - 1][j - 1] * p[i])  
    ans=0.0
    for i in range((n+1)//2,n+1):
        ans+=dp[n][i]
    return ans 

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

a=[0]+a 

print(Probability(a,n))



    
        
    
    

### FIXED CODE ###


    

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

 
dp = [[0 for i in range(n+1)] for j in range(n+1)]
   
dp[0][0] = 1.0

for i in range(1,n+1):
    for j in range(0,n+1):
        if j==0:
            dp[i][j] = dp[i - 1][j] * (1.0 - p[i-1]) 
        else : 
            dp[i][j] = (dp[i - 1][j] * (1.0 - p[i-1]) +
                        dp[i - 1][j - 1] * p[i-1])  
ans=0.0
for i in range((n+1)//2,n+1):
    ans+=dp[n][i]
print( ans)
from heapq import heappush, heappop


def solve(X, Y, Z, K, As, Bs, Cs):
    As.sort()
    Bs.sort()
    Cs.sort()
    ADs = [a2 - a1 for a1, a2 in zip(As, As[1:])][::-1]
    BDs = [a2 - a1 for a1, a2 in zip(Bs, Bs[1:])][::-1]
    CDs = [a2 - a1 for a1, a2 in zip(Cs, Cs[1:])][::-1]

    m = As[-1] + Bs[-1] + Cs[-1]
    h = []
    ans = [m]
    heappush(h, (ADs[0], (0, -1, -1)))
    heappush(h, (BDs[0], (-1, 0, -1)))
    heappush(h, (CDs[0], (-1, -1, 0)))
    taken = set()
    for i in range(K - 1):
        p, stacks = heappop(h)
        taken.add(stacks)
        ans.append(m - p)
        if stacks[0] + 1 < len(ADs):
            d = (p + ADs[stacks[0] + 1]), (stacks[0] + 1, stacks[1], stacks[2])
            if d not in h and d not in taken:
                heappush(h, d)
        if stacks[1] + 1 < len(BDs):
            d = (p + BDs[stacks[1] + 1]), (stacks[0], stacks[1] + 1, stacks[2])
            if d not in h and d not in taken:
                heappush(h, d)
        if stacks[2] + 1 < len(CDs):
            d = (p + CDs[stacks[2] + 1]), (stacks[0], stacks[1], stacks[2] + 1)
            if d not in h and d not in taken:
                heappush(h, d)

    return "\n".join(str(a) for a in ans)


if __name__ == "__main__":
    X, Y, Z, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    Bs = list(map(int, input().split(" ")))
    Cs = list(map(int, input().split(" ")))
    print(solve(X, Y, Z, K, As, Bs, Cs))


### FIXED CODE ###

from heapq import heappush, heappop


def solve(X, Y, Z, K, As, Bs, Cs):
    As.sort()
    Bs.sort()
    Cs.sort()
    ADs = [a2 - a1 for a1, a2 in zip(As, As[1:])][::-1]
    BDs = [a2 - a1 for a1, a2 in zip(Bs, Bs[1:])][::-1]
    CDs = [a2 - a1 for a1, a2 in zip(Cs, Cs[1:])][::-1]

    m = As[-1] + Bs[-1] + Cs[-1]
    h = []
    ans = [m]
    if ADs:
        heappush(h, (ADs[0], (0, -1, -1)))
    if BDs:
        heappush(h, (BDs[0], (-1, 0, -1)))
    if CDs:
        heappush(h, (CDs[0], (-1, -1, 0)))
    taken = set()

    for i in range(K - 1):
        p, stacks = heappop(h)
        while (p, stacks) in taken:
            p, stacks = heappop(h)
        taken.add((p, stacks))
        ans.append(m - p)

        if stacks[0] + 1 < len(ADs):
            heappush(h, ((p + ADs[stacks[0] + 1]), (stacks[0] + 1, stacks[1], stacks[2])))
        if stacks[1] + 1 < len(BDs):
            heappush(h, ((p + BDs[stacks[1] + 1]), (stacks[0], stacks[1] + 1, stacks[2])))
        if stacks[2] + 1 < len(CDs):
            heappush(h, ((p + CDs[stacks[2] + 1]), (stacks[0], stacks[1], stacks[2] + 1)))

    return "\n".join([str(a) for a in ans])

if __name__ == "__main__":
    X, Y, Z, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    Bs = list(map(int, input().split(" ")))
    Cs = list(map(int, input().split(" ")))
    print(solve(X, Y, Z, K, As, Bs, Cs))
import sys
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
hantei = [[0 for _ in range(h)] for _ in range(w)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            if i < h-1:
                if s[i+1][j] == "#":
                    hantei[i][j] = 1
                    hantei[i+1][j] = 1
            if j < w-1:
                if s[i][j+1] == "#":
                    hantei[i][j] = 1
                    hantei[i][j+1] = 1

for i in range(w):
    for j in range(h):
        if s[i][j] == "#":
            if hantei[i][j] == 0:
                print("No")
                sys.exit()

print("Yes")

### FIXED CODE ###

import sys
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
hantei = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            if i < h-1:
                if s[i+1][j] == "#":
                    hantei[i][j] = 1
                    hantei[i+1][j] = 1
            if j < w-1:
                if s[i][j+1] == "#":
                    hantei[i][j] = 1
                    hantei[i][j+1] = 1

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            if hantei[i][j] == 0:
                print("No")
                sys.exit()

print("Yes")
N = int(input())
t = 0

for i in range(N)
	t += i
  
print(i)


### FIXED CODE ###

N = int(input())
t = 0

for i in range(N):
	t += i + 1 

print(t)
a, b = map(int, input().split(" ''))
print((a-1) * (b-1))


### FIXED CODE ###

from sys import stdin, stdout

def main():
    line = stdin.readline()
    parts = line.split()
    m= int(parts[0])
    n = int(parts[1])
    stdout.write(str((n-1)*(m-1)))

main()
def main():

    a = int(input())
    b = int(input())

    if a > b:
        print("GREATER")
    elif a = b:
        print("EQUAL")
    else:
        print("LESS")

main()

### FIXED CODE ###

def main():

    a = int(input())
    b = int(input())

    if a > b:
        print("GREATER")
    elif a == b:
        print("EQUAL")
    else:
        print("LESS")

main()
a = int(input())
b = []
for i in range(3):
  if a[i] ==1:
  	b.append('9')
  else:
    b.append('1')
print(''.join(b))

### FIXED CODE ###

a = input()
b = []
for i in range(3):
  if a[i] =='1':
  	b.append('9')
  else:
    b.append('1')
print(''.join(b))
text = raw_input()
count = {} #a~zの出現回数を記録
print ord('a')
print ord('A')

for i in range(26):
    count[(i)] = 0
    
for i in range(len(text)):
    if(ord(text[i]) >= ord('a') and ord(text[i]) <= ord('z')):
        count[(ord(text[i]))-ord('a')] += 1
    if(ord(text[i]) >= ord('A') and ord(text[i]) <= ord('Z')):
        count[(ord(text[i]))-ord('A')] += 1

#出現回数の表示
for i in range(26):
    print '%s : %d' %(unichr(i+ord('a')), count[(i)])

### FIXED CODE ###

count = {}
for i in range(26):
    count[(i)] = 0

while True:
    try:
        x = raw_input()
    except:
        break
    for i in range(len(x)):
        if(ord('a') <= ord(x[i]) and ord(x[i]) <= ord('z')):
            count[(ord(x[i])-ord('a'))] += 1
        elif(ord('A') <= ord(x[i]) and ord(x[i]) <= ord('Z')):
            count[(ord(x[i])-ord('A'))] += 1

for i in range(26):
    print '%s : %d' %(chr(i+ord('a')), count[(i)])
exit(0)
a,b=map(str,input().split())
l=tuple("A","B","C","D","E","F")
if l.index(a)<l.index(b):
    print("<")
elif l.index(a)==l.index(b):
    print("=")
else:
    print(">")

### FIXED CODE ###

a,b=map(str,input().split())
l=["A","B","C","D","E","F"]
if l.index(a)<l.index(b):
    print("<")
elif l.index(a)==l.index(b):
    print("=")
else:
    print(">")
s=input()
answer-0
counter=0
for i in range(len(s)-1,-1,-1):
    if s[i]=="B":
        answer += len(s)-i-1-counter
        counter += 1
print(answer)
  
    

### FIXED CODE ###

S = input()
ans = 0
count = 0
for i in range(len(S)-1, -1, -1):
    if S[i] == "B":
        ans += len(S)-i-1-count
        count += 1
 
print(ans)
k, x = map(int,input().split())
print(sorted(x, reverse=True))


### FIXED CODE ###

a, b = map(int,input().split())
print(max(a+b, a-b, a*b))
import math  
a,b=map(int,input().split())  
print(a*b//fractions.gcd(a,b))

### FIXED CODE ###

import fractions  
a,b=map(int,input().split())  
print(a*b//fractions.gcd(a,b))
N,M = list(map(int,input().split()))
L = list(map(int,input().split()))#len(L) == N

p = sum(L)/(4*M)

cnt = 0
for i in range(N):
    if L[i] >= p:
        cnt += 1
if cnt >= M:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

l_0 = list(map(int,input().split()))

l_1 = []
l_1.append(l_0[1])
l_1.append(l_0[0])
l_1.append(l_0[2])

l_2 = []
l_2.append(l_1[2])
l_2.append(l_1[1])
l_2.append(l_1[0])

print('{} {} {}'.format(l_2[0],l_2[1],l_2[2]))
a,b =map(int,input().split())
if (a+b)% ==0:
  print((a+b)//2)
else:
  print(((a+b)//2)+1)

### FIXED CODE ###

a,b =map(int,input().split())
if (a+b)%2 ==0:
  print((a+b)//2)
else:
  print(((a+b)//2)+1)
import Decimal
a, b, c = list(map(int,input().split()))
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")


### FIXED CODE ###

from decimal import Decimal
a, b, c = list(map(int,input().split()))
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")
s=list(input())
t=list(input())
S,T=len(s),len(t)
t=t+['?']
if S<T:
  print('UNRESTORABLE')
  exit()
c,p=[0]*S,s[::-1]
for i in range(T+1):
  if t[i] in p:
    x=S-p.index(t[i])-1
    c[x-i]=1 if all(s[x-i+j]=='?' or s[x-i+j]==t[j] for j in range(T)) else 0
if max(c)==0:
  print('UNRESTORABLE')
  exit()
c=c[::-1]
x,j=S-c.index(1)-1,0
for i in range(S):
  if (i<x or i>x+T-1):
    s[i]='a' if s[i]=='?' else s[i]
  else:
    s[i],j=t[j],j+1
print(''.join(s))

### FIXED CODE ###

s=list(input())
t=list(input())
S,T=len(s),len(t)
t=t+['?']
if S<T:
  print('UNRESTORABLE')
  exit()
count=[0]*S
for i in range(T+1):
  if t[i] in s:
    x=s.index(t[i])
    if all(s[x-i+j]=='?' or s[x-i+j]==t[j] for j in range(T)):
      count[x-i]=1   
if max(count)==0:
  print('UNRESTORABLE')
  exit()
count=count[::-1]
x=count.index(1)
x,j=S-x-1,0
for i in range(S):
  if (i<x or i>x+T-1):
    if s[i]=='?':
      s[i]='a'
  else:
    s[i]=t[j]
    j+=1
print(''.join(s))
N, K = map(int, input().split())
d = []
A = []
ListN=[]
for i in range(1, N+1):
  ListN.append(i) 
setN = set(ListN) 

for i in range(K):
  d.append(input())
  A.append(list(map(int, input().split())))

for i in range(K-1):
  setA = set(A[i]) | set(A[i+1])



print(len(setA^setN))


### FIXED CODE ###

N, K = map(int, input().split())
d = []
A = []
setA = set(A)
ListN=[]
for i in range(1, N+1):
  ListN.append(i) 
setN = set(ListN) 

for i in range(K):
  d.append(input())
  setA = setA | set(list(map(int, input().split())))

print(len(setA^setN))
H, N = input().split()
lis = list(map(int,input().split())
A =sum(lis)
if H > A:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

H, N = input().split()
H = int(H)
#print(H)
#H, N = input().split()
lis = list(map(int,input().split()))
A =sum(lis)
if H > A:
    print("No")
else:
    print("Yes")
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
for i in range(m):
    b,c = map(int,input().split())
    a += [c] * b
a = a.sort()[len(a)-n:]
print(sum(a))


### FIXED CODE ###

from operator import itemgetter

n,m = map(int,input().split())
a = [int(i) for i in input().split()]
w = []
x = 0
for i in range(m):
    b,c = map(int,input().split())
    w.append((b,c))
w = list(sorted(w,key=itemgetter(1)))
w.reverse()
for i in w:
    a += [i[1]] * i[0]
    x += b
    if x > n:
        break
a.sort()
a = a[len(a)-n:]
print(sum(a))
def main();
  num = int(input())
  print(num ** 3)
  return0

### FIXED CODE ###

# -*- coding: utf-8 -*-
def main():
  num = int(input())
  print(num ** 3)
  return

if __name__ == '__main__':
  main()
if __name__=="__main__":
    s = int(input())
    if(s < 1200):
	print("ABC")
    else:
        print("ARC")

### FIXED CODE ###

if __name__=="__main__":
    s = int(input())
    if(s < 1200):
        print("ABC")
    else:
        print("ARC")
N, K = map(int, input().split())

d = []
l = []
i = 0

while i <= 2*K:
  i += 1
  if i % 2 == 1:
    d.append(int(input()))
  else:
    l = l + list(map(int,input().split()))

L = set(l)
print(K - len(L))

### FIXED CODE ###

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

d = []
l = []
i = 0

while i < 2*K:
  i += 1
  if i % 2 == 0:
    l.extend([int(x) for x in input().split()])
  else:
    d.append(int(input()))

L = list(set(l))
print(N - len(L))
S = str(input()) 
print('YES' if S[2] ==S[3] and 'NO' if S[4]==S[5] 

### FIXED CODE ###

S = str(input())

print('Yes' if S[2]==S[3] and S[4]==S[5] else 'No')