Harryxun/stf_run huggingface dataset:
s = list(input())
t = list(input())

a = len(s)
b = len(t)
#最小の文字列となるためには前にaを固めたほうが良いため後ろから入れる
for i in range(a-b,-1,-1):
    t_kamo = s[i:i+b]
    count = 0
    for j in range(b):
        if t_kamo[j] == t[j] or t_kamo[j] == "?":
            count += 1
    if count == b:
        #replaceメソット(リストには使えない,strに直接使う？)
        #条件分で記述
        ans = "".join(s[:i]+t+s[i+b:])
        print(ans.replace("?","a"))
        sys.exit()
        #ans = []"a" if "?" for i in ans]
        #print("join.(ans)")でもいけるはず
        
print("UNRESTORABLE")
            
    

### FIXED CODE ###

import sys
S = list(input())
T = list(input())

n = len(S)
m = len(T)

for i in range(n-m,-1,-1):
    K = []
    K = S[i:i+m]
    #print(K)
    for j in range(m):
        if K[j] == "?":
            K[j] = T[j]
    if K == T:
        print("".join((S[:i]+T+S[i+m:])).replace("?","a"))
        sys.exit()

print("UNRESTORABLE")
N,W = map(int,input().split())

dp = [0]*(W+1)
L = []
for i in range(N):
    v,w = map(int,input().split())
    L.append([w,v])

for i in range(N):
    for w in range(W+1):
        if w-L[i][1]>=0 :dp[w] = max(dp[w],dp[w-L[i][1]]+L[i][0])
print(dp[-1])

### FIXED CODE ###

N, W = map(int, input().split())
a = []
for i in range(N):
    x,y = map(int,input().split())
    a.append([x,y])
max_v, inf = 10**5, float("inf")
dp = [0] + [inf]*max_v
 
for w, v in a:
    for i, j in zip(range(max_v-v, -1, -1), range(max_v, -1, -1)):
        if dp[i]+w <= W and dp[j] > dp[i]+w:
            dp[j] = dp[i]+w
 
for weight, value in zip(dp[::-1], range(max_v, -1, -1)):
    if weight != inf:
        print(value)
        break
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+1)
dp_cum = [0] * (N+1)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[-1] + 1
answer %= MOD
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+10)
dp_cum = [0] * (N+10)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[N] + 1
answer %= MOD
print(answer)
l, r = map(int, input().split())
x = []

if l =< 2019 =< r:
  print(0)
elif r - l > 2018:
  print(0)
else:
  x = []
  for i in range(l, r):
    for j in range(i+1, r+1):
      m = i * j % 2019
      x.append(m) 
  print(min(x))

### FIXED CODE ###

l, r = map(int, input().split())
x = []

if l <= 2019 <= r:
  print(0)
elif r - l > 2018:
  print(0)
else:
  x = []
  for i in range(l, r):
    for j in range(i+1, r+1):
      m = i * j % 2019
      x.append(m) 
  print(min(x))
MOD = 1e9 + 7

def main():
	N, K = map(int, input().split())
	numbers = sorted(map(int, input().split()))
	if K==1:
		return 0
	if K==N:
		return numbers[0] - numbers[-1]

	table = calculate_table(N+1)
	
	n, k = N-1, K-1
	total, x = 0, n
	while x >= k:
		res = search(numbers[n-x], x-1, k-1, numbers, table)
		total = (total + res) % MOD
		x -= 1

	return total

	
	
def search(minimum, n, k, numbers, table):
	total, x = 0, n
	while x >= k:
		total = (get_table(x, k, table) * (numbers[x-n-1]-minimum) + total) % MOD
		x -= 1
	

	return total


def calculate_table(n0):
	table = [[1], [1, 1]]

	for n in range(2, n0):
		table.append([1 if i==0 or i==n else table[n-1][i-1]+table[n-1][i] for i in range(n+1)])
	
	return table

def get_table(n, k, table):
	return table[n][k]
	
	

print(int(main()))

### FIXED CODE ###

import time
MOD =  1000000007
MOD2 = 1000000005
MAX = 100001

facs = [1 for _ in range(MAX)]
inv = [1 for _ in range(MAX)]


for i in range(1, MAX):
	facs[i] = (facs[i-1] * i) % MOD

for i in range(1, MAX):
	inv[i] = pow(facs[i], MOD2, MOD)


def get_facs(x):
	return facs[x]


def get_inv(x):
	return inv[x]

def choose(n, k):

	if k==0 or n==k:
		return 1
	if n==0:
		return 0
	if k>n:
		return 0
	r = (get_facs(n)*get_inv(k)) % MOD
	r = (r*get_inv(n-k)) % MOD
	return r



def main():
	N, K = map(int, input().split())
	numbers = sorted(map(int, input().split()))
	if K==1:
		return 0
	if K==N:
		return abs(numbers[0] - numbers[-1])

	score = 0
	for i, x in enumerate(numbers):
		score += ((choose(i, K-1) - choose(N-1-i, K-1)) * x)

	return score%MOD
	
	
print(main())
N = input()
a = []
for i in range(N):
    a.append(input())
for i in range(N):
  	del b=a[i+1]
    print(max(b))
	

### FIXED CODE ###

N = input()
a = []
for i in range(N):
        a.append(input())
b = sorted(a)
b0,b1 = b[-1],b[-2]
for i in range(N):
        if a[i]!=b0 :
                print(b0)
        else:
                print(b1)
a=list(map(int,input().split()))
l=[]
for x in range(1,n+1):
    l.append(str(a.index(x)+1))
print(" ".join(l))

### FIXED CODE ###

n=int(input())
s=list(map(int,input().split()))
d={}
for x in range(len(s)):
    d[x]=s[x]
d=sorted(d.items(),key=lambda e: e[1])
p=list(map(str,[i+1 for i,j in d]))
print(" ".join(p))
strings,num = map(int,input().split())
result = ""
str_array = []

for i in range (num):
    str_array.append(input())

str_array.sort()

for i in range (num):
    result += str_array[i]

print(result)

### FIXED CODE ###

num,strings = map(int,input().split())
result = ""
str_array = []

for i in range (num):
    str_array.append(input())

str_array.sort()

for x in range (num):
    result = result + str_array[x]

print(result)
def f(x):
    for a in range(-100, 101):
        for b in range(-100, 101):
            if a ** 5 - b ** 5 == x:
                A = [a, b]
                return A
A = f(int(input()))
print(A[0], A[1])


### FIXED CODE ###

x = int(input())
for a in range(-118, 120):
    for b in range(-118, 120):
        if a**5 - b**5 == x:
            A = a
            B = b
print(A, B)
a, b, c = map(int, input().split())

if a + b + c <= 22:
  print('bust')
else;¥:
  print('win')

### FIXED CODE ###

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

if a + b + c >= 22:
  print('bust')
else:
  print('win')
#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline
from heapq import heappush,heappop

N,Q = map(int,input().split())
q = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  heappush(q,(s-x,1,x)) # xで死ぬ
  heappush(q,(t-x,0,x)) # xで死ななくなる
  
D = [int(input()) for _ in range(Q)]
for i,d in enumerate(D):
  heappush(q,(d,2,i))
answer = [-1]*Q

se = set() # 引っかかってる場所

while q:
  a,c,b = heappop(q)
  if c == 2: # queryに答える
    if se:
      #answer[b] = min(se)
  elif c == 1:
    se.add(b)
  elif c == 0:
    se.remove(b)

    
for x in answer:
  print(x)


### FIXED CODE ###

#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline

N,Q = map(int,input().split())
q = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  q.append((s-x,1,x)) # xで死ぬ
  q.append((t-x,0,x)) # xで死ななくなる

for i in range(Q):
  d = int(input())
  q.append((d,2,i))
answer = [-1]*Q

se = set() # 引っかかってる場所

q.sort()

min_se = 10**18
flag = False # min_seが正しい

for a,c,b in q:
  if not c:
    se.remove(b)
    if min_se == b:
      flag = False
  elif c&1:
    se.add(b)
    if b < min_se:
      min_se = b
      flag = True
  else:
    if se:
      if not flag:
        min_se = min(se)
        flag = True
      answer[b] = min_se

print('\n'.join(map(str,answer)))
s = inputu()
if s[0] == s[1] and s[0] = s[2] and s[1] == s[2]:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

s = input()
if s[0] == s[1] and s[0] == s[2]:
  print("No")
else:
  print("Yes")
N=int(input())
print(math.factorial(N))


### FIXED CODE ###

N=int(input())
ans=0
for i in range(1,N+1):
  ans+=i
print(ans)
a,b,c=map(int,input().split())
if c in list(range(min(a,b),max(a,b)):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b,c=map(int,input().split())
if c in list(range(min(a,b),max(a,b))):
  print('Yes')
else:
  print('No')
S1=list(S)
if S1[2]==S1[3] and S1[4]==S1[5]:
    print("Yes")
else : 
    print("No")



### FIXED CODE ###

S=input()
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else : 
    print("No")
a, b, c, k = map(int, input().split())
maxi=2*A-K+B
print(maxi)

### FIXED CODE ###

S=input()
T=input()
if 1<=len(S)<=10 and (S.islower() and S.islower()) and S==T[:-1]:
    print("Yes")
else:
    print("No")
s = 'abcdefghijklmnopqrstuvwxy'
C = input(str())

for i in range(len(s)):
    if s[i] == C:
        print(s[i+1])
        break

### FIXED CODE ###

s = 'abcdefghijklmnopqrstuvwxyz'
C = input(str())

for i in range(len(s)):
    if s[i] == C:
        print(s[i+1])
        break
else:
    print('')
import numpy as np
n,k=map(int,input().split())
twon=np.zeros(n)
twon=list(map(int,input().split()))
data=twon[0]
array=[-1]*n
array[0]=1
count=0
for i in range(1,k-1):
    if array[data-1]==-1:
        array[data-1]=i+1
    else:
        count=(k-i-1)%(i+1-array[data-1])
        array=[-1]*n
        count=k-count
    if count!=0:
        break
    data=twon[data-1]
for j in range(count,k):
    data=twon[data-1]
data=twon[data-1]
print(data)

### FIXED CODE ###

S=input("")
T=input("")
l=len(S)
if 1<=l and l<=10 and S.islower()==True and len(T)==l+1:
    if T.startswith(S)==True and T.islower()==True:
        print("Yes")
    else:
        print("No")
else:
    print("No")
import sys
input = sys.stdin.readline
n,m,p=map(int,input().split())
edge = [[] for i in range(m)]
for i in range(m):
  a,b,c=map(int,input().split())
  edge[i]=[a-1,b-1,-c+p]

def sp(s,n,w,es):
  d=[float("inf")]*n
  d[s]=0
  count=0
  ret=[]
  for i in range(2*n):
    update=False
    for i in range(w):
      e0,e1,e2=es[i]
      if d[e0]!=float("inf") and d[e1]>d[e0]+e2:
        d[e1]=d[e0]+e2
        update=True
    if not update:
      ret=[d[-1],d[-1]]
      break
    else:
      if (i+1)%n==0:
        ret.append(d[-1])
  return ret
d1,d2=sp(0,n,m,edge)
print(-1 if d1!=d2 else max(0,-d2))


### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m,p=map(int,input().split())
edge = [[] for i in range(m)]
for i in range(m):
  a,b,c=map(int,input().split())
  edge[i]=[a-1,b-1,-c+p]
d=[float("inf")]*n
d[0]=0

for _ in range(n):
  for i in range(m):
    e0,e1,e2=edge[i]
    d[e1]=min(d[e1],d[e0]+e2)
ans1=d[-1]
for _ in range(n):
  for i in range(m):
    e0,e1,e2=edge[i]
    if d[e1]>d[e0]+e2:
      d[e1]=-float("inf")
ans2=d[-1]
print(-1 if ans1!=ans2 else max(0,-ans1))
from sys import stdin, setrecursionlimit
import numpy as np


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))

    num = np.prod(a)

    den = sum([num // a[i] for i in range(n)])

    print(num / den)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


### FIXED CODE ###

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))

    num = 1
    for ai in a:
        num *= ai

    den = sum([num // a[i] for i in range(n)])

    print(num / den)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
import sys
from bisect import *
import math

input = sys.stdin.readline

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

cnum = A.count(0)
amax = max(A)

numind = [[] for i in range(amax+1)]
for i,ai in enumerate(A):
	numind[ai].append(i)

if cnum==0:
	res = 0
else:
	res = 1
	for i in range(amax):
		if len(numind[i+1])==0:
			res = 0
			break
		for order, j in enumerate(numind[i+1]):
			res = (res * (bisect(numind[i],j)-order)) % mod

	res = (res*math.factorial(3)//math.factorial(3-cnum)) % mod

print(res)

### FIXED CODE ###

import sys
from bisect import *
import math

input = sys.stdin.readline

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

cnum = A.count(0)
amax = max(A)

numind = [[] for i in range(amax+1)]
for i,ai in enumerate(A):
	numind[ai].append(i)

if cnum==0 or cnum>3:
	res = 0
else:
	res = 1
	for i in range(amax):
		if len(numind[i+1])==0 or len(numind[i+1])>3:
			res = 0
			break
		for order, j in enumerate(numind[i+1]):
			res = (res * (bisect(numind[i],j)-order)) % mod

	res = (res*math.factorial(3)//math.factorial(3-cnum)) % mod

print(res)
(N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines() if len(x)>1]

class UnionFind:
    def __init__(self, n):
        self.par=[i for i in range(n)]

    def root(self, x):
        if self.par[x] == x:
            return x
        return self.par[x] == self.root(self.par[x])

    def union(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        self.par[rx] = ry

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def count(self):
        return len([0 for i, x in enumerate(self.par) if x == i])

d=UnionFind(N)
for a,b in AB:
    d.union(a-1,b-1)
print(d.count() - 1)

### FIXED CODE ###

(N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines() if len(x)>1]

class UnionFind:
    def __init__(self, n):
        self.n=n
        self.parents=[-1 for i in range(n)]

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.parents[rx] > self.parents[ry]:
            rx,ry=ry,rx
        self.parents[rx] = self.parents[ry]
        self.parents[ry] = rx

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i,x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


d=UnionFind(N)
for a,b in AB:
    d.union(a-1,b-1)
print(d.group_count() - 1)
s,t=map(char,input().split())
print(s+t)


### FIXED CODE ###

s,t=input().split()
print(t+s)
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
c = []
d = []
for _ in range(M):
    C, D = map(int, input().split())
    c.append(C)
    d.append(D)


I = []
for a, b in ab:
    n = 10 ** 8
    I_n = ""
    for i in range(M):
        if abs(a-c[i]) + abs(b-d[i]) < n:
            if not i in I:
                n = abs(a-c[i]) + abs(b-d[i])
                I_n = i
    print(I_n + 1)
    I.append(I_n)

### FIXED CODE ###

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
  d = []
  for j in range(M):
    d.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]))
  print(d.index(min(d)) + 1)
K = input()
S = input()
if len(K) >= len(S):
  print(S)
else:
  strings = S[:K + 1] + '...'
  print(strings)

### FIXED CODE ###

K = int(input())
S = input()
strings = ''
if K >= len(S):
  print(S)
else:
  strings = str(S[:K]) + '...'
  print(strings)
n = int(input())
values = [float(s) for s in input().split(" ")]

start = 0
ans = 0

for i in range(1,n):
    if values[i] <= values[i+1]:
        start = i
    ans = max(ans,i-start)
print(ans)


### FIXED CODE ###

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

count = 0
count_list = [0]

for i in range(n-1):
	if(h[i+1] <= h[i]):
		count += 1
		count_list.append(count)
	else:
		count = 0

print(max(count_list))
h,w=map(int,input().split())
if h%3==0:
    print(0)
if w%3==0:
    print(0)
else:
    ansh=h*w
    for j in range(1,h):
        area1=w*j
        number=w//2
        area2=(h-j)*number
        area3=(h-j)*(w-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<ansh:
            ansh=check
        else:
            continue  
    answ=w*h
    for j in range(1,w):
        area1=h*j
        number=h//2
        area2=(w-j)*number
        area3=(w-j)*(h-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<answ:
            answ=check
        else:
            continue
print(min(ansh,answ))   

### FIXED CODE ###

h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
if h%3!=0 and w%3!=0:
    ansh=h*w
    for j in range(1,h):
        area1=w*j
        number=w//2
        area2=(h-j)*number
        area3=(h-j)*(w-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<ansh:
            ansh=check
        else:
            continue  
    answ=w*h
    for j in range(1,w):
        area1=h*j
        number=h//2
        area2=(w-j)*number
        area3=(w-j)*(h-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<answ:
            answ=check
        else:
             continue
    print(min(ansh,answ,w,h))
for i=0;i<9;i++
 for j=0;j<9;j++;j++
  print(i+1,"x",j+1"=",(i+1)*(j+1),)
 print("")


### FIXED CODE ###

for i in range(1,10):
	for j in range(1,10):
		print(i,"x",j,"=",i*j,sep="")
def main():
    n, m, *a = map(int, open(0).read().split())
    t = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
    a.sort(reverse=True)

    dp = [-float('Inf')] * (n + 1)
    dp[0] = 0
    for i in range(2, n + 1):
        for j in a:
            dp[i] = max(dp[i], dp[i - t[j]] + 1)

    nums = []
    k = dp[n]
    while n:
        for x in a:
            if dp[n - t[x]] == k - 1:
                nums.append(x)
                n -= t[x]
                break
        k -= 1

    ans = ''.join(map(str, nums))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, m, *a = map(int, open(0).read().split())
    t = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
    a.sort(reverse=True)

    dp = [-float('Inf')] * (n + 10)
    dp[0] = 0
    for i in range(2, n + 1):
        for j in a:
            dp[i] = max(dp[i], dp[i - t[j]] + 1)

    nums = []
    k = dp[n]
    while n:
        for x in a:
            if dp[n - t[x]] == k - 1:
                nums.append(x)
                n -= t[x]
                break
        k -= 1

    ans = ''.join(map(str, nums))
    print(ans)


if __name__ == '__main__':
    main()
import numpy as np
import sys
from operator import itemgetter
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10*5)

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def factorize(x):
    d=defaultdict(int)
    if x==1:
        return d[1]
    while x>1:
        for p in prime:
            if x%p==0:
                x//=p
                d[p]+=1
    return d[p]

ans=0
n=int(input())

#prime=seachPrimeNum(10**6+2)
#fctr=factorize(n)

for d in make_divisors(n):
    if d==1:
        continue
    m=d-1
    if n//m==n%m:
        ans+=m
print(ans)




### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans=0
n=int(input())

for d in make_divisors(n):
    if d==1:
        continue
    m=d-1
    if n//m==n%m:
        ans+=m
print(ans)
import itertools
N,A,B = map(int,input().split())
data = range(A,B+1)
if N-2>=0:
  tmp = list(itertools.combinations_with_replacement(data,N-2))
  ans = []
  for i in range(len(tmp)):
    ans.append(tmp[i][0]+tmp[i][1])
  print(len(set(ans)))
else:
  print('0')

### FIXED CODE ###

N,A,B = map(int,input().split())
if A>B:
  print('0')
elif N == 1:
  if A!=B:
    print('0')
  else:
    print('1')
else:
  print((B-A)*(N-2)+1)
S, T = [str(i) for i in input().split()]

s = list(S)
t = list(T)
s_n = len(S)
t_n = len(T)
n = 0
n = s_n - t_n + 1
min = t
 
for a in range(n):
  count = 0 
	for b in range(t_n):
      if S[a+b] != T[b]:
        count += 1
  if count < min:
    min = count
      
print(min)

### FIXED CODE ###

x = [input() for i in range(2)]
S = x[0]
T = x[1]
moji = len(T)

for a in range(len(S) - len(T) + 1):
  count = 0
  for b in range(len(T)):
    
    if S[a+b] != T[b]:
      count += 1
  if count < moji:
    moji = count

print(moji)
def A():
    a = input().split()
    try:
        for x in a:
            x = int(x)
    except:
        exit(1)
    a.sort()
    a.inverse()
    
    a_i = a[0]
    sum = 0
    for x in a[1:]:
        sum += abs(a_i - x)
        a_i = x 
    
    print(sum)


if __name__ =='__main__':
    A()

### FIXED CODE ###


def A():
    s = input().split()
    a = [int(n) for n in s]
    a.sort()
    a.reverse()
    
    a_i = a[0]
    sum = 0
    for x in a[1:]:
        sum += abs(a_i - x)
        a_i = x 
    
    print(sum)

if __name__ =='__main__':
    A()
A, B = map(int, input())
if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(B // 2)
else:
    print(0)

### FIXED CODE ###

A, B = map(int, input().split())
if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(B // 2)
else:
    print(0)
a, b, k = map(int, input().split())
x = list(range(a, b+1))

print('\n'.join(sorted(set(map(str, x[:k] + x[-k:])))))

### FIXED CODE ###

a, b, k = map(int, input().split())
x = range(a, b+1)

for i in sorted(set(x[:k]) | set(x[-k:])):
    print(i)
k = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
z = [int(i) for i in input().split()]

x.sort(reverse=True)
if len(x)>k[3]:
  x = x[0:k[3]+1]

y.sort(reverse=True)
if len(y)>k[3]:
  y = y[0:k[3]+1]

z.sort(reverse=True)
if len(z)>k[3]:
  z = z[0:k[3]+1]

e = []

for i in x:
  for j in y:
    e.append(i+j)

g = []
for i in range(k[3]):
  g.append(e[i])

f = []

for i in g:
  for j in z:
    f.append(i+j)

f.sort(reverse=True)

for i in range(k[3]):
  print(f[i])


### FIXED CODE ###

X,Y,Z,K=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
SUM=[]
for i in range(X):
  for j in range(Y):
    for k in range(Z):
      if (i+1)*(j+1)*(k+1)<=K:
        SUM.append(A[i]+B[j]+C[k])
      else:
        break
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])
import sys
import string
input=sys.stdin.readline

n=(input())
l=list(n)
n=int(n)
a=0
for i in range(len(l)):
    a+=int(l[i])
if n%a==0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import sys
import string
input=sys.stdin.readline

n1=int(input())
n=n1
b=0
while n>0:
    a=n%10
    n=n//10
    b+=a
#print(b)
if n1%b==0:
    print('Yes')
else:
    print('No')
a, b, c, k = map(int, input().split())
cards = 0
sum = 0

if k >=a:
  sum = sum + a * 1
  cards = k - a
  if k >= b:
    sum += 0
    cards = cards + b
    if k >= c:
    	sum -= 1
    	cards = cards + c
    	print(sum)
    else:
      sum = sum + (k - cards) * -1
      print(sum)
    
    if k  
  else:
    print(sum)
else:
  sum = sum + k * 1
  print(sum)
  

### FIXED CODE ###

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

cards = k
sum = 0

while (True):
    if cards > a:
        sum += a
        cards -= a
        if cards > b:
            sum += 0
            cards -= b
            if cards > c:
                sum -= c
                cards -= b
            else:
                sum -= cards
                print(sum)
                break
        else:
            print(sum)
            break

    else:
        sum += cards
        print(sum)
        break