Harryxun/stf_run huggingface dataset:
X,Y,A,B,C = map(int,input().split())
pList = [int(x) for x in input().split()]
qList = [int(x) for x in input().split()]
rList = [int(x) for x in input().split()]

pList.sort(reverse=True)
qList.sort(reverse=True)
rList.sort(reverse=True)

stackX=[]
stackY=[]
stackR=[]

for i in range(X):
    stackX.append(pList[i])

for i in range(Y):
    stackY.append(qList[i])

for i in range(C):
    x = stackX[-1]
    y = stackY[-1]
    r = rList[i]

    if r < x and r < y:
        break
    elif x < y:
        stackX.pop()
        stackR.append(r)
    else:
        stackY.pop()
        stackR.append(r)
print(sum(stackX) + sum(stackY) + sum(stackR))


### FIXED CODE ###

X,Y,A,B,C = map(int,input().split())
pList = [int(x) for x in input().split()]
qList = [int(x) for x in input().split()]
rList = [int(x) for x in input().split()]

pList.sort(reverse=True)
qList.sort(reverse=True)
rList.sort(reverse=True)

stackX=[]
stackY=[]
stackR=[]

for i in range(X):
    stackX.append(pList[i])

for i in range(Y):
    stackY.append(qList[i])

for i in range(C):
    if len(stackX)>0:
        x = stackX[-1]
    else:
        x = pow(10,10)

    if len(stackY)>0:
        y = stackY[-1]
    else:
        y = pow(10,10)

    r = rList[i]

    if r <= x and r <= y:
        break
    elif x < y:
        stackX.pop()
        stackR.append(r)
    else:
        stackY.pop()
        stackR.append(r)
print(sum(stackX) + sum(stackY) + sum(stackR))
L = []
for _ in range(M):
    L.append(list(map(int, input().split())))

first = []
second = []
for a, b in L:
    if a == 1:
        first.append(b)
    if b == N:
        second.append(a)
print('POSSIBLE' if set(first) & set(second) else 'IMPOSSIBLE')


### FIXED CODE ###

N, M = map(int, input().split())
L = []
for _ in range(M):
    L.append(list(map(int, input().split())))

first = []
second = []
for a, b in L:
    if a == 1:
        first.append(b)
    if b == N:
        second.append(a)
flg = len(set(first) & set(second))
print('POSSIBLE' if flg else 'IMPOSSIBLE')
A,B,C,K=map(int, input().split())
num_list=()
for i in range(A):
    num_list.append(1)
for j in range(B):
    num_list.append(0)
for k in range(C):
    num_list.append(-1)

print(sum(num_list[0:K-1]))


### FIXED CODE ###

S=input()
T=input()

if S==T[0:-1] and len(S)<=10:
    print('Yes') 
else:
    print('No')
import numpy as np

N, M = map(int, input().split())
list_num = list(map(int, input().split()))
list_num_ar = np.array(list_num)
result = []

for i in range(M):
	a, b = map(int, input().split())
	res_a = list_num_ar[list_num_ar >= b]
	res_b = list_num_ar[list_num_ar < b]

	if a >= res_b.size:
		res_b = np.full(b, res_b.size)
	else:
		res_b = np.sort(res_b)
		res_b[0:a] = b

	tmp = sum(res_b) + sum(res_a)
	list_num_ar = np.r_[res_a, res_b]


	result.append(tmp)

print(max(result))

### FIXED CODE ###

from sys import stdin
 
def main():
    n,m = [int(x) for x in stdin.readline().split()]
    cards = [int(x) for x in stdin.readline().split()]
    cards.sort()
 
    bcs = [tuple(map(int,x.split())) for x in stdin.readlines()]
    bcs.sort(key=lambda x:x[1], reverse=True)
 
    ans = 0
    minIndex = 0
    isFinished = False
 
    for b,c in bcs:
 
        for _ in range(b):
            if minIndex < n and cards[minIndex] < c:
                ans += c
                minIndex += 1
            else:
                isFinished = True
                break
        
        if isFinished:
            break
 
    if minIndex < n:
        ans += sum(cards[minIndex:])
 
    print(ans)
    
if __name__=='__main__':
    main()
import math
N=int(input())
a=0
for i in range(1,1+math.ceil(math.sqrt(N))):
    if N%i==0 and i>a:
        a=i
b=int(N/a)
print(max([len(str(a)),len(str(b))]))9876543210

### FIXED CODE ###

import math
N=int(input())
a=0
for i in range(1,1+math.ceil(math.sqrt(N))):
    if N%i==0 and i>a:
        a=i
b=int(N/a)
print(max([len(str(a)),len(str(b))]))
X, N = map(int, input().split())
if N != 0:
    p = list(map(int, input().split()))
else:
    print(X)
    exit()

if N = 100:
    print(0)
    exit()

for i in range(X+1):
    if not i in p:
        x = i

for i in range(X,101):
    if not i in p:
        y = i
        break

if (X-x) == (y-X):
    print(x)
elif (X-x) > (y-X):
    print(y)
else:
    print(x)

### FIXED CODE ###

X, N = map(int, input().split())
if N > 0:
    p = list(map(int, input().split()))
elif N == 0:
    print(X)
    exit()
else :
    p = [int(input())]
if N == 100:
    if X <= 50:
        print(0)
    else:
        print(101)
    exit()

for i in range(X+1):
    if not i in p:
        x = i

for i in range(X,101):
    if not i in p:
        y = i
        break
    elif i == 100:
        y = 101

if (X-x) == (y-X):
    print(x)
elif (X-x) > (y-X):
    print(y)
else:
    print(x)
n, l = map(int, input().split())
s = []
for i in range(n):
    s.append(input())
print(''.join(sorted(s)))

### FIXED CODE ###

# -*- coding: utf-8 -*-
A_B_C = list(map(int, input().split()))
A_B_C.sort()
if A_B_C == [5,5,7]:
    print('YES')
else:
    print('NO')
def func(i, d, marks):
    rooms = numpy.nonzero(d[i])
    new_room = []
    for j in rooms[0]:
        room_idx = j
        if room_idx in marks:
            continue
        marks[room_idx] = i
        new_room.append(room_idx)
    for j in new_room:
        marks = func(j, d, marks)
    return marks

import numpy

N, M =  list(map(int, input().split()))
d = numpy.zeros((N,M))
for i in range(M):
    a, b =  list(map(int, input().split()))
    d[a-1, b-1] = 1
    d[b-1, a-1] = 1

marks = func(0, d, {0: 0})

flag = True
output_str = ''
for i in range(1, N):
    if i not in marks:
        flag = False
        break
    output_str += f'{marks[i]+1}\n'
if flag:
    print('Yes')    
    print(output_str)
else:
    print('No')

### FIXED CODE ###


def get_input():
    N, M =  list(map(int, input().split()))
    routes = {}
    for i in range(M):
        a, b =  list(map(int, input().split()))
        a_idx = a - 1
        b_idx = b - 1
        if a_idx in routes:
            routes[a_idx].append(b_idx)
        else:
            routes[a_idx] = [b_idx]
        
        if b_idx in routes:
            routes[b_idx].append(a_idx)
        else:
            routes[b_idx] = [a_idx]

    return N, M, routes

def write_result(marks, N):
    flag = True
    output_str = ''
    for i in range(1, N):
        if i not in marks:
            flag = False
            break
        output_str += f'{marks[i]+1}\n'
    if flag:
        print('Yes')    
        print(output_str)
    else:
        print('No')

import numpy


marks = {0:0}

N, M, routes = get_input()
mark = {0:0}
start_nodes = [0]
while start_nodes:
    next_nodes = []
    for i in start_nodes:
        for n in routes[i]:
            if n in marks:
                continue
            marks[n] = i
            next_nodes.append(n)
    start_nodes = next_nodes   
write_result(marks, N)
import sys
nm =input().rstrip().split(" ")
n =int(nm[0])
m =int(nm[1])
direcs=[]
for i in range(m):
    direcs.append(input().rstrip().split(" "))
#print(direcs)
trdirecs=list(map(list, set(map(tuple, direcs))))
#print(trdirecs)
first=[]
second=[]
third=[]
for j in trdirecs:
    if int(j[0])==1:
        first.append(int(j[1]))
    if int(j[0])==2:
        second.append(int(j[1]))
    if int(j[0])==3:
        third.append(int(j[1]))
if first[0]==0 and (n==2 or n==3):
    answer=-1
    print(answer)
    sys.exit()
    
'''print(first)
print(second)
print(third)'''
'''if len(first)>1 or len(second)>1 or len(third)>1:
    print(-1)'''
if len(first)==0:
    first.append(0)
if len(second)==0:
    second.append(0)
if len(third)==0:
    third.append(0)
#数字が条件を満たしているかどうか判定する
if n==1:
    for i in range(0,10):
        if i==first[0]:
            answer=i
elif n==2:
    for i in range(0,100):
        d1=int((i-i%10)/10)
        d2=i%10
        if d1==first[0] and d2 ==second[0]:
            answer=i
            if answer<=9:
                answer=10+i
elif n==3:
    for i in range(0,1000):
        d3=i%10
        a=int((i-d3)/10)
        d2=a%10
        d1=int((a-a%10)/10)
        #print(d1,d2,d3)
        if d1==first[0] and d2==second[0] and d3==third[0]:
            answer=i
            if answer<100:
                answer=100+i
if len(first)>1 or len(second)>1 or len(third)>1:
    answer=-1
print(answer)

### FIXED CODE ###

import sys
nm =input().rstrip().split(" ")
n =int(nm[0])
m =int(nm[1])
direcs=[]
for i in range(m):
    direcs.append(input().rstrip().split(" "))
#print(direcs)
trdirecs=list(map(list, set(map(tuple, direcs))))
#print(trdirecs)
first=[]
second=[]
third=[]
for j in trdirecs:
    if int(j[0])==1:
        first.append(int(j[1]))
    if int(j[0])==2:
        second.append(int(j[1]))
    if int(j[0])==3:
        third.append(int(j[1]))
if len(first)!=0 and first[0]==0 and (n==2 or n==3):
    answer=-1
    print(answer)
    sys.exit()
    
'''print(first)
print(second)
print(third)'''
'''if len(first)>1 or len(second)>1 or len(third)>1:
    print(-1)'''
if len(first)==0:
    first.append(0)
if len(second)==0:
    second.append(0)
if len(third)==0:
    third.append(0)
#数字が条件を満たしているかどうか判定する
if n==1:
    for i in range(0,10):
        if i==first[0]:
            answer=i
elif n==2:
    for i in range(0,100):
        d1=int((i-i%10)/10)
        d2=i%10
        if d1==first[0] and d2 ==second[0]:
            answer=i
            if answer<=9:
                answer=10+i
elif n==3:
    for i in range(0,1000):
        d3=i%10
        a=int((i-d3)/10)
        d2=a%10
        d1=int((a-a%10)/10)
        #print(d1,d2,d3)
        if d1==first[0] and d2==second[0] and d3==third[0]:
            answer=i
            if answer<100:
                answer=100+i
if len(first)>1 or len(second)>1 or len(third)>1:
    answer=-1
print(answer)
import sys
import math
import functools

N = int(sys.stdin.readline().rstrip())
T = []
for _ in range(N):
    T.append(int(sys.stdin.readline().rstrip()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

print(lcm_list(T))

### FIXED CODE ###

import sys
import fractions
import functools

N = int(sys.stdin.readline().rstrip())
T = []
for _ in range(N):
    T.append(int(sys.stdin.readline().rstrip()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

if N == 1:
    print(T[0])
else:
    print(lcm_list(T))
n = int(input)
a = [int(i) for i in input().split()]
for i in range(n,-1,-1):
    if i == 0:
        print(a[i])
    else:
        print(a[i],end=" ")

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
for i in range(n-1,-1,-1):
    if i == 0:
        print(a[i])
    else:
        print(a[i],end=" ")
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
co=0
for i in range(len(B)):
    co+=B[i]
for j in range(len(C)):
    if A[j+1]==A[j]+1:
        co+=C[A[j]]
print(co)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
co=0
for i in range(len(B)):
    co+=B[i]
for j in range(len(C)):
    if A[j+1]==A[j]+1:
        co+=C[A[j]-1]
print(co)
n,k = map(int, input())
ans = 0
for i in range(n):
  if int(input()) >= k:
    ans += 1
print(ans)

### FIXED CODE ###

n,k = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
for i in h:
  if i >= k:
    ans += 1
print(ans)
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
c = []
hold = False
for y in range(h):
    for x in list(range(w))[::-1+(y % 2 == 0)*2]:
        # print((y + 1, x + 1))
        if hold:
            c.append((*back, y + 1, x + 1))
            if a[y][x] % 2 == 1:
                hold = False
                continue
        if not hold and a[y][x] % 2 == 1:
            hold = True
        back = (y + 1, x + 1)
print(len(c))
for i in range(len(c)):
    print(*c[i])


### FIXED CODE ###

h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
c = []
hold = False
for y in range(h):
    for x in list(range(w))[::-1+(y % 2 == 0)*2]:
        # print((y + 1, x + 1))
        if hold:
            c.append((back[0], back[1], y + 1, x + 1))
            if a[y][x] % 2 == 1:
                hold = False
                continue
        if not hold and a[y][x] % 2 == 1:
            hold = True
        back = (y + 1, x + 1)
print(len(c))
for i in range(len(c)):
    print(*c[i])
n=int(input())
if n%7==0 or n%5==0 or n%3==0:
	ptint('YES')
else:
	print('NO')

### FIXED CODE ###

n=int(input())
if n==7 or n==5 or n==3:
	print('YES')
else:
	print('NO')
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = na()
mst = li[0]
for i in range(n):
    if li[i] >= mst:
        mst = li[i]
    elif li[i] != mst - 1:
        print("No")
        exit(1)
print("Yes")


### FIXED CODE ###

import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = na()
mst = li[0]
flag = "Yes"
for i in range(n):
    if li[i] >= mst:
        mst = li[i]
    elif li[i] != mst - 1:
        flag = "No"
        break
print(flag)
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

lst1 = []
lst2 = []
A1,B1 = map(int, input().split(" "))

A = factorization(A1)
B = factorization(B1)

for i in range(len(A)):
    lst1.append(A[i][0])

for i in range(len(B)):
    lst2.append(B[i][0])
# print(lst1)
# print(lst2)

lst1_set = set(lst1)
lst2_set = set(lst2)

result_set = lst1_set & lst2_set


# print(result_set)
if A1 == 0 or B1 == 0:
    print(0)
elif A1 == 1 and B1 == 1:
    print(1)
else:
    print(len(result_set) + 1)
    

### FIXED CODE ###

#整数で受け取る
N = int(input())

number = 0
#奇数の数を数える
for i in range(1, N+1):
    if i % 2 != 0:
        number += 1

result = number / N

print(result)
# 味リストはL, L+1, L+2...
tastes = []
for i in range(n):
    tastes += [l+i]

# 味0があったらそれを食えばいい
if 0 in tastes:
    print(sum(tastes))
else:
    # 差が最小なのを食えばいい
    tastes.sort(key=abs)
    print(sum(tastes[1:]))

### FIXED CODE ###

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

# 味リスト
tastes = []
for i in range(n):
    tastes += [l+i]

# 全部
all_tastes = sum(tastes)

# 食ったあとの味リスト
ptn = []
for x in tastes:
    ptn += [all_tastes - x]

# 元との差(abs)
di = []
for i in range(n):
    di += [abs(all_tastes - ptn[i])]

min_value = min(di)
print(ptn[di.index(min_value)])
def f(s):
  while 1:
    b=s.find(")")
    if b<0: return g(s)
    a=s[:b].rfind("(")
    s1=s[a:b+1]
    s=s.replace(s1,f(s1[1:-1]))

def g(s):
  a=""
  f=1
  x=[]
  def F(a,b):
    x.append(a)
    x.append(b)
    return 1,""
  for c in s:
    if c=="=": continue
    elif c in "*/": f,a=F(a,c)
    elif c in "+-":
      if f==1: f,a=0,c
      else: f,a=F(a,c)
    else: f,a=0,a+c
  x.append(a)

  s=x[:]
  x=[]
  f=""
  for e in s:
    if e in "+-": x.append(e)
    elif e in "*/": f=e
    else:
      a=int(e)
      if f=="*": a*=x.pop()
      elif f=="/": a=x.pop()/a
      x.append(a)
      f==""

  s=x[:]
  x=[]
  f=""
  for e in s:
    if e=="+" or e=="-": f=e
    else:
      a=int(e)
      if f=="+": a+=x.pop()
      elif f=="-": a=x.pop()-a
      x.append(a)
      f==""
  return str(x[0])

n=input()
for _ in [0]*n: 
  s=raw_input()
  print f(s)

### FIXED CODE ###

def f(s):
  while 1:
    b=s.find(")")
    if b<0: return g(s)
    a=s[:b].rfind("(")
    s=s.replace(s[a:b+1],f(s[a+1:b]))

def g(s):
  a=""
  f=1
  x=[]
  def F(a,b):
    x.append(a)
    x.append(b)
    return 1,""
  for c in s:
    if c=="=": continue
    elif c in "*/": f,a=F(a,c)
    elif c in "+-":
      if f==1: f,a=0,c
      else: f,a=F(a,c)
    else: f,a=0,a+c
  x.append(a)

  s=x[:]
  x=[]
  f=""
  for e in s:
    if e in "+-": x.append(e)
    elif e in "*/": f=e
    else:
      a=int(e)
      if f=="*": a*=x.pop()
      elif f=="/": a=int(1.0*x.pop()/a)
      x.append(a)
      f=""
  x="".join(map(str,x))
  return str(eval(x))

n=input()
for _ in [0]*n:
  print f(raw_input())
n, k = map(int, input().split())
x = n
min_n = n
rlist = []
while x>0:
    if (k == 1 or k==2):
        rlist = [0]
        break
    rlist.append(abs(x-k))
    x = abs(x-k)
    min_n = min(rlist)
    if (min_n == abs(x-k)):break
    if (min_n == 0):break
    if(len(set(rlist)) != len(rlist)):
        break

print(min(rlist))



### FIXED CODE ###

n, k = map(int, input().split()) 
t = n % k
if (k-t > t):
    print(t)
else:
    print(k-t)
s=input()
if s=ABA:
	print("Yes")
else:
	print()

### FIXED CODE ###

s=input()
a=s[0]
b=s[1]
c=s[2]
if a== b and b==c:
	print("No")
else:
	print("Yes")
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]

    numpos = dict()
    wordlist = [-1] * N
    for i in reversed(range(N)):
        if A[i] not in numpos:
            wordlist[i] = A[i]
            
        else:
            if numpos[A[i]] == N - 1: wordlist[i] = -1
            else: wordlist[i] = wordlist[numpos[A[i]] + 1]
        numpos[A[i]] = i

    #print(numpos)
    #print(wordlist)

    rem = [] #残る数列の変遷をどうにかして求める
    startindex = 0
    for _ in range(len(A)):
        remtop = wordlist[startindex]
        rem.append(remtop)
        if remtop == -1: break
        else: startindex = numpos[remtop] + 1

    #print(rem)

    rep = len(rem)
    ans = K % rep
    ans -= 1
    #print(ans)
    if ans == -1: print("")
    else:
        if ans == 0: startindex = 0
        else: startindex = numpos[rem[ans-1]] + 1
        out = []
        using = dict()
        l = 0
        for i in range(startindex, N):
            if A[i] in using and using[A[i]] <= l:
                out = out[:using[A[i]]]
                l = using[A[i]]
                using.pop(A[i])
            else:
                out.append(A[i])
                using[A[i]] = l
                l += 1
            #print(out, using, l)
        print(" ".join(map(str, out)))


    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]

    n_head_pos = dict() #一番最初にnが出てくるindex
    rem_head_num = [-1] * N #i番目から処理を始めた時に残る数列の先頭の数字
    for i in reversed(range(N)):
        if A[i] not in n_head_pos:
            rem_head_num[i] = A[i]
        else:
            if n_head_pos[A[i]] == N-1: rem_head_num[i] = -1
            else: rem_head_num[i] = rem_head_num[n_head_pos[A[i]] + 1]
        n_head_pos[A[i]] = i
    #print(n_head_pos)
    #print(rem_head_num)

    start_cycle = [] #先頭の数字の周期
    start = -1
    used = set()
    while start not in used:
        used |= {start}
        start_cycle.append(start)
        if start == -1: next = rem_head_num[0]
        elif n_head_pos[start] < N - 1: next = rem_head_num[n_head_pos[start] + 1]
        else: next = -1
        start = next

    #print(start_cycle)

    len_cycle = len(start_cycle)
    last = (K - 1) % len_cycle 
    #print(last)
    if start_cycle[last] == -1: start_index = 0
    elif n_head_pos[start_cycle[last]] < N - 1: start_index =n_head_pos[start_cycle[last]] + 1
    else: start_index == -1
    #print(start_index)
    if start_index >= 0:
        out = []
        using = dict()
        l = 0
        for i in range(start_index, N):
            if A[i] in using:
                aindex = using[A[i]]
                l = aindex
                for a in out[aindex:]:
                    using.pop(a)
                out = out[:aindex]
            else:
                out.append(A[i])
                using[A[i]] = l
                l += 1
                #print(out, using, l)
        print(" ".join(map(str, out)))
    else: print(" ")

    return 0

if __name__ == "__main__":
    solve()
from fractions import gcd
from functools import reduce

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

for i, a in enumerate(A):
    if i == 0:
        lcmA = a
    else:
        lcmA = int(a * lcmA / gcd(a, lcmA))

if M < lcmA//2:
    print(0)
else:
    print( 1 + (M - max(lcmA//2, min(A) * 0.5))//lcmA)

### FIXED CODE ###

import fractions
import functools

def lcm(n1, n2):
    return n1 * n2 // fractions.gcd(n1, n2)

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] //= 2

lcmA = functools.reduce(lcm, A)
gcdA = functools.reduce(fractions.gcd, A)
if (lcmA // gcdA) % 2 == 0:
    print(0)
else:
    print((M // lcmA + 1) // 2)
N=int(input())
A=list(map(int,input().split()))
ans = 1
X = []
for i in range(N):
  if A[i] == ans:
    ans += 1
    X.append(i+1)
L=' '.join(X)
print(X)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
X = [0 for _ in range(N)]

for i in range(N):
    X[A[i] - 1] = i + 1

L = " ".join([str(i) for i in X])
print(L)
MOD = 10**9+7
n,k = map(int,input().split())

L = [0]*(k+1)

for i in range(k,0,-1):    
  L[i] = pow(k//i,n,mod)
  for j in range(2,k//i+1):        
    L[i] -= L[i*j]
  
ans = 0
for i in range(1,k+1):  
  ans = (ans + i*L[i]) % MOD
  
print(ans)  

### FIXED CODE ###

MOD = 10**9+7
n,k = map(int,input().split())

L = [0]*(k+1)

for i in range(k,0,-1):    
  L[i] = pow(k//i,n,MOD)
  for j in range(2,k//i+1):        
    L[i] -= L[i*j]
  
ans = 0
for i in range(1,k+1):  
  ans = (ans + i*L[i]) % MOD
  
print(ans)
N = int(input())
print(ans: "1" if N = 1 else "0.6" if N%2 = 1 else "0.5")

### FIXED CODE ###

N = int(input())
ans = 0
if N == 1:
    ans = 1
elif N%2 != 1:
    ans= 0.5
else:
    ans=(N+1)/(2*N)
print(ans)
import math
a,b,n = map(int,input().split())

if b =< n:
    k = math.floor(n/b)
    ans = max(math.floor(a*(b-1)/b), math.floor(a*n/b)- a*math.floor(n/b),math.floor(a*(k*b-1)/b)-a*math.floor((k*b-1)/b))
    print(ans)
else:
    print(math.floor(a*n/b))


### FIXED CODE ###

import math
a,b,n = map(int,input().split())
print(min(math.floor(a*n/b),math.floor(a*(b-1)/b)))
sd=list(input())
t=list(input())
#strsd="?tc????"
#strt="coder"

#strsd="??p??d??"
#strt="abc"

#sd=list(strsd)
#t=list(strt)

lens=len(sd)
lent=len(t)
for i in range(lens-lent,-1,-1):
    yn=""
    for ii in range(lent):
        if sd[i+ii]==t[ii] or sd[i+ii]=="?":
            continue
        else:
            yn="NG"
            break
    if yn!="NG":
        yn="itchi"
        break
    
if yn=="NG":
    print("UNRESTORABLE")
else:
    s=""
    if i!=0:
        for ii in range(i):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    for ti in t:
        s=s+ti
    if i!=lent-lens:
        for ii in range(i+lent,lens,1):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    print(s)
    


### FIXED CODE ###

sd=list(input())
t=list(input())

yn=""
for i in range(len(sd)-len(t)+1):
    ii=len(sd)-len(t)-i
    yn=""
    for j in range(len(t)):
        if sd[ii+j]!=t[j] and sd[ii+j]!="?":
            yn="NG"
            break
    if yn=="NG":
        continue
    else:
        yn="yes"
        break
    
if yn=="NG" or yn=="": 
    print("UNRESTORABLE")
else:
    for j in range(len(t)):
        sd[ii+j]=t[j]
    for j in range(len(sd)):
        if sd[j]=="?":
           sd[j]="a"
    strt="".join(sd)
    print(strt)