Problem:
 Score : 100 points    Problem Statement You have three tasks, all of which need to be completed.  First, you can complete any one task at cost 0 .  Then, just after completing the i -th task, you can complete the j -th task at cost |A_j - A_i| .  Here, |x| denotes the absolute value of x .  Find the minimum total cost required to complete all the task.      Constraints  All values in input are integers.  1 \leq A_1, A_2, A_3 \leq 100         Input Input is given from Standard Input in the following format:  A_1  A_2  A_3       Output Print the minimum total cost required to complete all the task.        Sample Input 1 1 6 3      Sample Output 1 5  When the tasks are completed in the following order, the total cost will be 5 , which is the minimum:   Complete the first task at cost 0 .  Complete the third task at cost 2 .  Complete the second task at cost 3 .        Sample Input 2 11 5 5      Sample Output 2 6       Sample Input 3 100 100 100      Sample Output 3 0

Solution (Python):
a = [int(x) for x in input().split()]
min_val = float("inf")
for i in range(len(a)):
    val = 0
    b = a[0:i] + a[i+1:len(a)]
    if abs(a[i]-b[0]) < abs(a[i]-b[1]):
        val += abs(a[i] - b[0])
        val += abs(b[0] - b[1])
    else:
        val += abs(a[i] - b[1])
        val += abs(b[1] - b[0])
    min_val = min(min_val,val)
print(min_val)

Solution (Python):
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(2):
    ans += abs(A[i+1]-A[i])
print(ans)

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(10000)


def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))


def to_bin(x):
    return bin(x)[2:]



dp = None

def main():
    a1, a2, a3 = [int(_) for _ in input().split()]
    print(max(a1, a2, a3) - min(a1, a2, a3))

main()

Solution (Python):
A = list(map(int,input().split()))
A = sorted(A)

print(A[2] - A[0])

Solution (Python):
a = input()
b = list(map(int,a.split()))
b.sort()
print(b[2]-b[0])

Solution (Python):


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

num = 0
for i in range(len(a)-1):
    num += a[i+1] - a[i]

print(num)

Solution (Python):
l = list(sorted(map(int, input().split())))
print(l[2] - l[0])

Solution (Python):
s=list(sorted(map(int,input().split())))
print(s[-1]-s[0])

Solution (Python):
x = list(map(int, input().split()))
print(max(x) - min(x))

Solution (Python):
A,B,C = map(int,input().split())
ans = max(A, B, C) - min(A, B, C)
print(ans)

Solution (Python):
data = list(map(int, input().split()))
print (max(data) - min(data))

Solution (Python):


















''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) 
heapq.heappush(queue,num) 
pop = heapq.heappop(queue) 
pop = heapq.heappushpop(queue,num) 

'''

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7


ar = list(map(int,input().split()))
print(max(ar)-min(ar))

Solution (Python):
xs = list(map(int, input().split()))
print(max(xs) - min(xs))

Solution (Python):
a = list(map(int, input().split()))
a.sort()
sum=0
for i in range(len(a)):
    if i!=0:
        sum=sum+a[i]-a[i-1]
print(sum)

Solution (Python):
a = input().split()

if int(a[0])<=int(a[1]) and int(a[0])<=int(a[2]):
  min = int(a[0])
  if int(a[1])<=int(a[2]):
    max = int(a[2])
  else:
    max = int(a[1])
elif int(a[1])<=int(a[2]) and int(a[1])<=int(a[0]):
  min = int(a[1])
  if int(a[0])<=int(a[2]):
    max = int(a[2])
  else:
    max = int(a[0])
else:
  min = int(a[2])
  if int(a[0])<=int(a[1]):
    max = int(a[1])
  else:
    max = int(a[0])

print(max-min)

Solution (Python):
A1, A2, A3 = list(map(int, input().split()))

A = [A1, A2, A3]

B = sorted(A)

C = B[2] - B[0]

print(C)

Solution (Python):
A = [int(i) for i in input().split()]

ans = 1e9
for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, 3):
            if(i == j or i == k or j == k):
                continue
            cost = abs(A[i] - A[j]) + abs(A[j] - A[k]);
            ans = min(ans, cost)

print (ans)

Solution (Python):
a, b, c =map(int, input().split())
print(max(a, b, c)-min(a,b,c))

Solution (Python):
from itertools import permutations

def solve(a):
    res = []
    for p in permutations(range(3)):
        cur = sum([abs(a[p[i+1]] - a[p[i]]) for i in range(2)])
        res.append(cur)
    return min(res)

assert solve([1,6,3]) == 5
assert solve([11,5,5]) == 6
assert solve([100,100,100]) == 0
a = map(int, raw_input().split())
print solve(a)

Solution (Python):
a = list(map(int, input().split()))
a.sort()
ans = 100000
for i in range(2):
    s = 0
    for j in range(2):
        s += a[j]-a[j+1]
    ans = min(ans, abs(s))
    a.reverse()
print(ans)

Solution (Python):


costs = map(int, input().split())
costs_sorted = sorted(list(costs))
cost_sum = abs(costs_sorted[1]-costs_sorted[0])+abs(costs_sorted[2]-costs_sorted[1])
print(cost_sum)

Solution (Python):
a=list(map(int, input().split()))
print(max(a)-min(a))

Solution (Python):
A = [int(i) for i in input().split()]
print(max(A) - min(A))

Solution (Python):
if __name__ == '__main__':
    a = list(map(int, input().split()))
    print(max(a) - min(a))

Solution (Python):
A = list(map(int, input().split()))
ans = 0
A.sort()
for i in range(1, len(A)):
  ans += abs(A[i] - A[i-1])
print(ans)

Solution (Python):
a, a2, a3 = sorted([int(x) for x in input().split()])
print(abs(a2-a)+abs(a3-a2))

Solution (Python):
a = list(map(int,input().split()))
a = sorted(a)
print((a[1]-a[0])+(a[2]-a[1]))

Solution (Python):
list = list(map(int, input().split()))
print(max(list) - min(list))

Solution (Python):
s=list(map(int,input().split()))
print(max(s)-min(s))

Solution (Python):
li = list(map(int,input().split(" ")))
li.sort()
print(li[2]-li[0])

Solution (Python):
a,b,c=map(int,input().split())
t=[abs(a-b)+abs(c-b),abs(c-a)+abs(b-c),abs(a-b)+abs(c-a),abs(c-b)+abs(a-c),abs(a-c)+abs(b-a),abs(b-c)+abs(a-b)]
print(min(t))

Solution (Python):
a = [int(i) for i in input().split()]
a1, a2, a3 = a[0], a[1], a[2]

ans = max(a1, a2, a3) - min(a1, a2, a3)
print(ans)

Solution (Python):
A = list(map(int, input().split()))
print(max(A) - min(A))

Solution (Python):


a=map(int,raw_input().split())
a.sort()
s=0
for i in xrange(1,len(a)):
 s+=a[i]-a[i-1]
print s

Solution (Python):
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

arr=[int(arr_data[0][x]) for x in range(3)]

print(max(arr)-min(arr))

Solution (Python):
arr = [int(x) for x in input().split()]
arr = sorted(arr)
ans = 0
for i in range(1, 3):
  ans += arr[i] - arr[i - 1]
print(ans)

Solution (Python):
a=list(map(int,input().split(' ')))
if a[0] < a[1]:
    if a[1] > a[2]:
        if a[0] < a[2]:
            temp = a[1]
            a[1] = a[2]
            a[2] = temp
        else:
            temp = a[0]
            a[0] = a[2]
            a[2] = a[1]
            a[1] = temp
    
else:
    if a[1] < a[2]:
        if a[0] < a[2]:
            temp = a[0]
            a[0] = a[1]
            a[1] = temp
        else:
            temp = a[0]
            a[0] = a[1]
            a[1] = a[2]
            a[2] = temp
    else:
        temp = a[0]
        a[0] = a[2]
        a[2] = temp
print(a[2]-a[0])

Solution (Python):
a=sorted(list(map(int,input().split(' '))))
print(a[2]-a[0])

Solution (Python):
a=list(map(int, input().split()))
print(max(a) - min(a))

Solution (Python):
a=list(map(int,input().split(' ')))
a=sorted(a)
print(a[2]-a[0])

Solution (Python):
a=list(map(int,input().split()))
print(max(a)-min(a))

Solution (Python):
A,B,C = map(int,input().split())
diffs = sorted([abs(A-B),abs(A-C),abs(B-C)])
print(diffs[0]+diffs[1])

Solution (Python):
a,b,c=map(int,input().split())
s1=0+abs(a-b)+abs(b-c)
s2=0+abs(a-c)+abs(b-c)
s3=0+abs(b-a)+abs(c-a)
s4=0+abs(b-c)+abs(c-a)
s5=0+abs(c-b)+abs(a-b)
s6=0+abs(c-a)+abs(a-b)
print(min(s1,s2,s3,s4,s5,s6))

Solution (Python):
nums = map(int, input().split())
nums = sorted(nums)
print(nums[2] - nums[0])

Solution (Python):
lst  = map(int,input().split())
x = sorted(lst)
print(sum([j-i for i, j in zip(x[:-1], x[1:])]))

Solution (Python):
from itertools import permutations

A = map(int, input().split())

R = []
for (a1, a2, a3) in permutations(A, 3):
    r = abs(a2 - a1)
    r += abs(a3 - a2)
    R.append(r)

print(min(R))

Solution (Python):
a = list(map(int,input().split()))

a.sort()
print((a[2] - a[1]) + (a[1] - a[0]))

Solution (Python):
s = list(map(int,input().split()))
a = s[0]
b = s[1]
c = s[2]

r = [a,b,c]
r.sort()

print(r[2] - r[0])

Solution (Python):
A = list(map(int, input().split()))
B = [abs(A[i] - A[i+1]) for i in range(-1, 2)]
print(sum(B) - max(B))

Solution (Python):
a=list(map(int,input().split()))
print(max(a)-min(a))

Solution (Python):
a = list(map(int, input().split()))
print(max(a) - min(a))

Solution (Python):
a=list(map(int,input().split()));print(max(a)-min(a))

Solution (Python):
a = list(map(int,input().split()))

a.sort()

print((a[2]-a[1])+(a[1]-a[0]))

Solution (Python):
a1, a2, a3 = map(int, input().split())
print(min(abs(a1-a2)+abs(a2-a3), abs(a1-a3)+abs(a3-a2), abs(a2-a1)+abs(a1-a3)))

Solution (Python):
a,b,c=sorted(list(map(int,input().split())))
print(abs(b-a)+abs(c-b))

Solution (Python):
A=[int(i) for i in input().split()]
A.sort()
print(A[2]-A[0])

Solution (Python):
a=list(map(int,input().split()))
a.sort()
print(a[2]-a[0])

Solution (Python):
a = [int(i) for i in input().split()]
print(max(a)-min(a))

Solution (Python):


import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

A1, A2, A3 = map(int, raw_input().split())

lst = [abs(A1 - A2), abs(A1 - A3), abs(A3 - A2)]
lst.sort()
print lst[0] + lst[1]

Solution (Python):
import math
a,b,c = map(int, input().split())
ret = sorted(list(map(lambda x: int(math.fabs(x)), [b-a,c-b,c-a])))
print(sum(ret[:-1]))

Solution (Python):
A = [int(_) for _ in input().split()]
r = max(A) - min(A)
print(r)

Solution (Python):
a = list(map(int, input().split()))
print(max(a)-min(a))

Solution (Python):
print((lambda l:max(l)-min(l))(list(map(int,input().split()))))

Solution (Python):
m,_,M=sorted(map(int,input().split()))
print(M-m)

Solution (Python):
A,B,C=(int(i) for i in input().split())
print(min((abs(B-A)+abs(C-B)),(abs(C-A)+abs(B-C)),(abs(A-C)+abs(B-A))))

Solution (Python):
a=list(map(int,input().split()))
res=0
a.sort()
n=a[0]
del(a[0])
while a:
   res+=abs(a[0]-n)
   n=a[0]
   del(a[0])
print(res)

Solution (Python):
import itertools

A1,A2,A3 = map(int,input().split())
    
vec = [A1,A2,A3]
com = list(itertools.permutations(vec))
    
all_cos = [0,0,0,0,0,0]
for i in range(6):
    tmp_com = com[i]
        
    tmp_A1 = tmp_com[0]
    tmp_A2 = tmp_com[1]
    tmp_A3 = tmp_com[2]
        
    cos1 = 0
    cos2 = abs(tmp_A1 - tmp_A2)
    cos3 = abs(tmp_A2 - tmp_A3)
        
    all_cos[i] = cos1 + cos2 + cos3
    
res = min(all_cos)
print(res)

Solution (Python):
n = list(map(int,input().split()))
n.sort()
ans = n[2]-n[0]
print(ans)

Solution (Python):
a, b, c = map(int, input().split())
d = 0 + abs(b - a) + abs(c - b)
e = 0 + abs(c - a) + abs(b - c)
f = 0 + abs(a - b) + abs(c - a)
g = 0 + abs(c - b) + abs(a - c)
h = 0 + abs(a - c) + abs(b - a)
i = 0 + abs(b - c) + abs(a - b)
print(min(d, e, f, g, h, i))

Solution (Python):
a1, a2, a3 = map(int, input().split())
 
ans1 = abs(a1 - a2) + abs(a2 - a3)
ans2 = abs(a1 - a3) + abs(a3 - a2)
ans3 = abs(a2 - a1) + abs(a1 - a3)
 
print(min(ans1, ans2, ans3))

Solution (Python):
li = list(map(int,input().split()))
li.sort()
ans = li[1]-li[0]+li[2]-li[1]
print(ans)

Solution (Python):
print((lambda a:max(a)-min(a))(list(map(int,input().split()))))

Solution (Python):
A = input().split(" ")
A.sort()
print(abs(int(A[1]) - int(A[0])) + abs(int(A[2]) - int(A[1])))

Solution (Python):
a,b,c=map(int,input().split())
d=[abs(a-b),abs(b-c),abs(c-a)]
print(sum(d)-max(d))

Solution (Python):
A = input().split()
A = [int(i) for i in A]
res_list = []
def listExcludedIndices(data, indices=[]):
    return [x for i, x in enumerate(data) if i not in indices]
for i in range(len(A)):
    for j in range(len(A) -1 ):
        for k in range(len(A) - 2):
            jData = listExcludedIndices(A, [i])
            kData = listExcludedIndices(jData, [j])
            A1 = A[i]
            A2 = jData[j]
            A3 = kData[k]
            res_list.append(abs(A1-A2)+abs(A2-A3))
print(min(res_list))

Solution (Python):
a = [int(m) for m in input().split(" ")]

print(max(a) - min(a))

Solution (Python):
A=[int(i) for i in input().split()]
print(max(A)-min(A))

Solution (Python):
a = list(map(int, input().split())) 
a.sort()
for i in range(len(a)):
  if i == 0:
    res = 0
  else :
    res += a[i]-a[i-1]
print(res)

Solution (Python):
import numpy as np

l = raw_input().split(" ")
a = sorted([int(elm) for elm in l])

n_elm = len(a)
s = 0
for i in xrange(n_elm-1):
    s += a[i+1] - a[i]

print s

Solution (Python):
A = [int(i) for i in input().split()]
A.sort()
Length = len(A)
total = 0
counter = 0
while counter < Length-1:
    total += A[counter+1] - A[counter]
    counter +=1

print(total)

Solution (Python):
import itertools

a1, a2, a3 = map(int, input().strip().split(' '))

min_score = float('inf')
for a, b, c in itertools.permutations((a1, a2, a3)):
    total = 0
    total += abs(b-a)
    total += abs(c-b)
    if total < min_score:
        min_score = total

print(min_score)

Solution (Python):
def spaceinput():
    return list(map(int,input().split(" ")))


a=spaceinput()
print(max(a)-min(a))

Solution (Python):
import math
a, b, c = (int(i) for i in input().split()) 
l = []
l.extend([abs(a-b),abs(b-c),abs(c-a)])
l.sort()
ans = l[0] + l[1]
print(ans)

Solution (Python):
task = input().split(" ")
ans = 5000
if abs ( int(task [ 0 ]) - int(task [ 1 ])) + abs ( int(task [ 2 ]) - int(task [ 0 ])) < ans : 
	ans = abs ( int(task [ 0 ]) - int(task [ 1 ])) + abs ( int(task [ 2 ]) - int(task [ 0 ]))
if abs ( int(task [ 0 ]) - int(task [ 2 ])) + abs ( int(task [ 1 ]) - int(task [ 0 ])) < ans : 
	ans = abs ( int(task [ 0 ]) - int(task [ 2 ])) + abs ( int(task [ 1 ]) - int(task [ 0 ]))
if abs ( int(task [ 1 ]) - int(task [ 0 ])) + abs ( int(task [ 2 ]) - int(task [ 1 ])) < ans : 
	ans = abs ( int(task [ 1 ]) - int(task [ 0 ])) + abs ( int(task [ 2 ]) - int(task [ 1 ]))
if abs ( int(task [ 1 ]) - int(task [ 2 ])) + abs ( int(task [ 0 ]) - int(task [ 1 ])) < ans : 
	ans = abs ( int(task [ 1 ]) - int(task [ 2 ])) + abs ( int(task [ 0 ]) - int(task [ 1 ]))
if abs ( int(task [ 2 ]) - int(task [ 0 ])) + abs ( int(task [ 1 ]) - int(task [ 2 ])) < ans : 
	ans = abs ( int(task [ 2 ]) - int(task [ 0 ])) + abs ( int(task [ 1 ]) - int(task [ 2 ]))
if abs ( int(task [ 2 ]) - int(task [ 1 ])) + abs ( int(task [ 0 ]) - int(task [ 2 ])) < ans : 
	ans = abs ( int(task [ 2 ]) - int(task [ 1 ])) + abs ( int(task [ 0 ]) - int(task [ 2 ]))
print ( ans )

Solution (Python):
import itertools
import numpy as np

a1, a2, a3 = map(int, input().split())

A = [i for i in itertools.permutations([a1, a2, a3])]

cost = [np.abs(A[i][0] - A[i][1]) + np.abs(A[i][1] - A[i][2]) 
    for i in range(len(A))]

print(min(cost))

Solution (Python):
A1, A2, A3 = map(int, input().split())
B = abs(A1 - A2)
C = abs(A2 - A3)
D = abs(A3 - A1)
I = min(B + C, B + D, C + D)
print(I)

Solution (Python):
task = input().split()
for i, j in enumerate(task):
    task[i] = int(j)
task.sort()
score = int(task[2])  - int(task[0])
print(score)

Solution (Python):
a1, a2, a3 = map(int, input().split(' '))


c123 = abs(a3 - a2) + abs(a2 - a1)
c132 = abs(a2 - a3) + abs(a3 - a1)
c213 = abs(a3 - a1) + abs(a1 - a2)
c231 = abs(a1 - a3) + abs(a3 - a2)
c312 = abs(a2 - a1) + abs(a1 - a3)
c321 = abs(a1 - a2) + abs(a2 - a3)

print(min([c123, c132, c213, c231, c312, c321]))

Solution (Python):
a=sorted(list(map(int,input().split())))
print(a[2]-a[0])

Solution (Python):
a = list(map(int, input().split()))
a.sort()
sum = 0
for i in range(len(a)-1):
    a_sum = a[i+1] - a[i]
    sum += a_sum
print(sum)

Solution (Python):
s = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])

print(str(max(a,b,c)-min(a,b,c)))

Solution (Python):
a,b,c=map(int, input().split())
S=[a,b,c]
s=sorted(S,key=abs)
M=max(S,key=abs)
m=min(S,key=abs)
n=s[1]
if abs(a==b==c):
	print(0)
else:
	print(abs(n-m)+abs(M-n))

Solution (Python):
i = input()
a, b, c = i.split(" ")

def intdiff(x,y):
    return abs(int(x)-int(y))

print(max(intdiff(a,b), intdiff(b,c), intdiff(c,a)))

Solution (Python):
a=[int(i) for i in input().split()]

a.sort()
b=[a[2]-a[1],a[1]-a[0],a[2]-a[0]]


print(sum(b)-max(b))

Solution (Python):
a1,a2,a3 = map(int,input().split())
print(max(a1,a2,a3)-min(a1,a2,a3))

Solution (Python):
a = list(map(int, input().split()))

d = [0 for i in range(3)]
for i in range(3):
    d[i] = abs(a[i - 1] - a[i])

print(sum(d) - max(d))

Solution (Python):
list_task = list(map(int,  input().split()))
N = len(list_task)

list_task.sort()
list_task.reverse()


total_cost = 0
last_number = list_task[0]
list_task.pop(0)
for i in list_task:
    total_cost +=  abs(last_number - i)
    last_number  = i 
print(total_cost)

Solution (Python):
s  = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])

print(str(max(a,b,c) - min(a,b,c)))

Solution (Python):
a = list(map(int, input().split()))
a.sort()
num1 = a[1]-a[0]
num2 = a[2]-a[1]
print(int(num1)+int(num2))

Solution (Python):
A1,A2,A3 = map(int,input().split())
B = [abs(A1-A2),abs(A2-A3),abs(A3-A1)]
M = 0

for i in B:
    if i>M:
        M = i
        
print(sum(B)-M)

Solution (Python):
a,b,c=map(int,input().split())
 
d=[]
d.append(a)
d.append(b)
d.append(c)
d.sort()

e=0

for i in range(2):
  e=e+d[i+1]-d[i]

print(e)

Solution (Python):
A1, A2, A3 = map(int, input().split())
ans = 1000
for x in range(6):
    temp = 0
    if x == 0:
        temp += abs(A2 - A1)
        temp += abs(A3 - A2)
    elif x == 1:
        temp += abs(A3 - A1)
        temp += abs(A2 - A3)
    elif x == 2:
        temp += abs(A1 - A2)
        temp += abs(A3 - A1)
    elif x == 3:
        temp += abs(A3 - A2)
        temp += abs(A1 - A3)
    elif x == 4:
        temp += abs(A1 - A3)
        temp += abs(A2 - A1)
    elif x == 5:
        temp += abs(A2 - A3)
        temp += abs(A1 - A2)
    
    if temp < ans :
        ans = temp
print(ans)

Solution (Python):
a, b, c = (int(i) for i in input().split())
if a >= b and a >= c and b >= c:
  print(abs(b-a)+abs(c-b))
elif a >= b and a >= c and c >= b:
  print(abs(c-a)+abs(b-c))
elif b >= a and b >= c and a >= c:
  print(abs(a-b)+abs(c-a))
elif b >= a and b >= c and c >= a:
  print(abs(c-b)+abs(a-c))
elif c >= b and c >= a and a >= b:
  print(abs(a-c)+abs(b-a))
elif c >= b and c >= a and b >= a:
  print(abs(b-c)+abs(a-b))

Solution (Python):
inp = map(int, raw_input().split())
inp.sort()
cost = 0
for i in xrange(len(inp)-1):
  cost += inp[i+1] - inp[i]
print cost

Solution (Python):
a,b,c = map(int,input().split())
ans = min(abs(a-b)+abs(c-b),abs(a-c)+abs(b-c),abs(c-a)+abs(b-a))
print(ans)

Solution (Python):


def main():
    a = input()
    tasks_char = a.split(" ")
    tasks = [int(c) for c in tasks_char]

    indiced_tasks = list(zip(list(range(len(tasks))), tasks))
    sorted_tasks = sorted(indiced_tasks, key=lambda t: t[1])

    x = 0
    for (i1, t1), (i2, t2) in zip(sorted_tasks[:-1], sorted_tasks[1:]):
        x += abs(t1 - t2)
    print(x)
    return

if __name__ == "__main__":
    main()

Solution (Python):

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()

Solution (Python):

a = list(map(int, input().split()))
cost=0
a.sort()

for i in range(2):
    cost+=abs(a[i+1]-a[i])
print(cost)

Solution (Python):

A = list(map(int, input().split()))
max = 0

ans = [0,0,0]
for i in range(0,3):
    diff = 0
    for j in range(0,3):
        diff += abs(A[i] - A[j])
    ans[i] = diff

print (min(ans))

Solution (Python):
a1, a2, a3 =list(map(int,input().split()))
list1 = [a1, a2, a3]
list2 = sorted(list1)
ans = list2[2] - list2[0]
print(ans)

Solution (Python):
a = []
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = (a[0] - a[1]) + (a[1] - a[2])
print(ans)

Solution (Python):
list = list(map(int,input().split()))
list.sort()
print(list[2] - list[0])

Solution (Python):
list=input().split()
for i in list:
    i=int(i)
list.sort()
sumcosts=0
costs=0
first=True
mae=0
for i in list:
    i = int(i)
    if(first):
        first=False
        mae=i
    else:
        sumcosts=sumcosts+abs((i-mae))
        mae=i
print(sumcosts)

Solution (Python):
A,B,C = map(int,input().split(" "))
a = abs(A-C)
b = abs(B-C)
c = abs(A-B)

print((a+b+c) - max([a,b,c]))

Solution (Python):
s = input().split()
s = map(int,s)
s = list(s)
c = 0
p = min(s)
for x in sorted(s):
    c += x - p
    p = x
print(c)

Solution (Python):


i1, i2, i3 = map(int, input().split())
mList = []
mList.append(abs(i2 - i1))
mList.append(abs(i3 - i2))
mList.append(abs(i1 - i3))

mList.sort()
print(mList[1] + mList[0])

Solution (Python):
from itertools import permutations
a = list(map(int, input().split()))

comb = permutations(a)

def cost(a1, a2, a3):
    return abs(a1 -a2) + abs(a2 - a3)

min_sum = -1
for i in comb:
    tmp_sum = cost(i[0], i[1], i[2])
    if min_sum == -1 or tmp_sum < min_sum:
        min_sum = tmp_sum

print(min_sum)

Solution (Python):
def run(a):
    return max(a) - min(a)


def read_line():
    a = list(map(int, input().split()))
    return a


def main():
    a = read_line()
    print(run(a))


if __name__ == '__main__':
    main()

Solution (Python):
import sys

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()


a = list(na())
a.sort()

print(a[2] - a[0])

Solution (Python):
array = list(map(int, input().split()))
array.sort()

count=0
for i in range(1, len(array)):
    count += array[i] - array[i-1]
print(count)

Solution (Python):
a1, a2, a3 = [int(x) for x in input().split()]


def majikuso(a1, a2, a3):
    s1 = 0
    s1 += abs(a1-a2)
    s1 += abs(a2-a3)

    s2 = 0
    s2 += abs(a1-a3)
    s2 += abs(a3-a2)

    s3 = 0
    s3 += abs(a2-a1)
    s3 += abs(a1-a3)

    s4 = 0
    s4 += abs(a2-a3)
    s4 += abs(a3-a1)

    s5 = 0
    s5 += abs(a3-a2)
    s5 += abs(a2-a1)

    s6 = 0
    s6 += abs(a3-a1)
    s6 += abs(a1-a2)

    return min([s1, s2, s3, s4, s5, s6])

print(majikuso(a1, a2, a3))

Solution (Python):
ar = sorted([int(i) for i in input().split()], reverse=True)
print(ar[0]-ar[-1])

Solution (Python):



list = input().split()

sort = []
for i in list:
    sort.append(i)

sort.sort()
print(abs(int(sort[1]) - int(sort[0])) + abs(int(sort[2]) - int(sort[1])))

Solution (Python):
s = "100 10 25"
list = list(map(int, input().split()))


a = abs(list[1]-list[0])
b = abs(list[1]-list[2])
c = abs(list[2]-list[0])
if (a < b):
	print(b if b>c else c)
else :
	print(a if c<a else c)

Solution (Python):
a= sorted([int(j) for j in input().split()])
cost=0
for j in range(len(a)-1):
	cost += abs(a[j]-a[j+1])

print(cost)

Solution (Python):
l = map(int, input().split())
l2 = sorted(l)
a1=l2[0]
a2 = l2[1]
a3 = l2[2]
s = a2-a1+a3-a2
print(s)

Solution (Python):
a = list(int(i) for i in input().split())
a.sort()
print(abs(a[0]-a[1]) + abs(a[1]-a[2]))

Solution (Python):

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

    lst = []
    
    lst.append(abs(b-a) + abs(c-b))
    lst.append(abs(c-a) + abs(b-c))

    
    lst.append(abs(a-b) + abs(c-a))
    lst.append(abs(c-b) + abs(a-c))

    
    lst.append(abs(c-b) + abs(a-c))
    lst.append(abs(a-c) + abs(b-a))

    print(min(lst))

if __name__ == "__main__":
        main()

Solution (Python):
a1, a2, a3 = map(int, input().split())

def comp(a1, a2, a3):
    b = abs(a1 - a2)
    c = abs(a2 - a3)
    return b + c

d = comp(a1, a2, a3)
e = comp(a1, a3, a2)
f = comp(a2, a1, a3)
g = comp(a2, a3, a1)
h = comp(a3, a1, a2)
i = comp(a3, a2, a1)

print(min(d, e, f, g, h, i))

Solution (Python):
A = map(int, raw_input().split())
A.sort()
print(A[2] - A[1] + A[1] - A[0])

Solution (Python):
n = input().split()

n.sort()
n1 = int(n[0])
n2 = int(n[1])
n3 = int(n[2])

if n1 == n2 and n1 == n3:
    print(str(0))
else:
    ans = abs(n1-n2) + abs(n2-n3)
    print(str(ans))

Solution (Python):
A=list(map(int,input().split(" ")))
A=sorted(A)
print(abs(A[2]-A[1])+abs(A[1]-A[0]))

Solution (Python):
a, b, c = map(int, input().split())
sl = [a, b, c]
sl.sort()
print(sl[2] - sl[0])

Solution (Python):

import numpy as np
l = input().split()
lnp = np.zeros(len(l))
for i in range(len(l)):
	lnp[i] = int(l[i])
lnp = np.sort(lnp)
print(int(lnp[-1]-lnp[0]))

Solution (Python):
a=list(map(int,input().split()))
print(max(a)-min(a))

Solution (Python):
A=[int(x) for x in input().split()]

ans=[abs(A[0]-A[1]),abs(A[1]-A[2]),abs(A[0]-A[2])]
print(sum(ans)-max(ans))

Solution (Python):
A = list(map(int, input().split()))

tasks = [
    (0,1,2),(0,2,1),(1,0,2),(1,2,0),(2,0,1),(2,1,0)
]

min_c = 1000
for t1,t2,t3 in tasks:
    c = abs(A[t2]-A[t1])+abs(A[t3]-A[t2])
    min_c = min(min_c, c)
print(min_c)

Solution (Python):
a,b,c = map(int, input().split())
d = abs(a-b)
e = abs(a-c)
g = abs(b-c)
if d >= e and d >= g:
  print(e+g)
elif e >= d and e >= g:
  print(d+g)
else:
  print(d+e)

Solution (Python):
n = list(map(int, input().split()))
s_1 = abs(n[1]-n[0])+abs(n[2]-n[1])
s_2 = abs(n[2]-n[0])+abs(n[2]-n[1])
s_3 = abs(n[0]-n[1])+abs(n[2]-n[0])



print(min(s_1, s_2, s_3))

Solution (Python):
L = list(map(int,input().split()))
ans = 0
min_L = min(L)
L.remove(min_L)
cnt = min_L
sorted_L = sorted(L)
for i in sorted_L:
    ans += abs(i - cnt )
    cnt = i
print(ans)

Solution (Python):
s=list(map(int,input().split()))
s.sort()
print(abs(s[1]-s[0])+abs(s[2]-s[1]))

Solution (Python):
a = list(map(int,input().split()))
 
a.sort()

print(abs(a[0]-a[1])+abs(a[1]-a[2]))

Solution (Python):
s=input().split()
a,b,c=int(s[0]),int(s[1]),int(s[2])
print(min((abs(b-a)+abs(c-a),abs(a-b)+abs(c-b),abs(a-c)+abs(b-c))))

Solution (Python):


list = list(map(int,input().split()))
list.sort()
sum = list[2]-list[0]

print(sum)

Solution (Python):
from sys import stdin                                                                                                                                                                                       
A = [int(x) for x in stdin.readline().rstrip().split()]                                                                                                                                                     
                                                                                                                                                                                                            
a1 = abs(A[0] - A[1])                                                                                                                                                                                       
a2 = abs(A[0] - A[2])                                                                                                                                                                                       
a3 = abs(A[1] - A[2])                                                                                                                                                                                       
x = [a1,a2,a3]                                                                                                                                                                                              
cost1 = min(x)                                                                                                                                                                                              
x.remove(cost1)                                                                                                                                                                                             
cost2 = min(x)                                                                                                                                                                                              
ans = cost1 + cost2                                                                                                                                                                                         
print(ans)

Solution (Python):
a = list(map(int, input().split()))
a.sort()
sub = abs(a[0]-a[1])+abs(a[1]-a[2])
print(sub)

Solution (Python):


list = list(map(int,input().split()))
list.sort()
sum = list[2]-list[1]+list[1]-list[0]

print(sum)

Solution (Python):
def permutation(lst):
 
    
    if len(lst) == 0:
        return []
 
    
    
    if len(lst) == 1:
        return [lst]
 
    
    
 
    l = [] 
 
    
    for i in range(len(lst)):
       m = lst[i]
 
       
       
       remLst = lst[:i] + lst[i+1:]
 
       
       
       for p in permutation(remLst):
           l.append([m] + p)
    return l
 
 

data = list(map(int, input().split()))
maxn = 4000
for p in permutation(data):
	ans = abs(p[1] - p[0]) + abs(p[2] - p[1])
	if ans < maxn:
		maxn = ans
print(maxn)

Solution (Python):





A = list(map(int, input().strip().split()))

l = [[0,1,2],[0,2,1], [1,0,2], [1,2,0], [2,0,1], [2,1,0]]

min_cost = 300
for i in range(6):
    cost = 0
    first, second, third = l[i]
    if A[second] - A[first] >= 0:
        cost += A[second] - A[first]
    else:
        cost += (A[second] - A[first]) * (-1)
    if A[third] - A[second] >= 0:
        cost += A[third] - A[second]
    else:
        cost += (A[third] - A[second]) * (-1)
    if cost < min_cost:
        min_cost = cost

print(min_cost)

Solution (Python):
x = list(map(int, input().split(' ')))
y = sorted(x)

print(y[2] - y[0])

Solution (Python):
li = list(map(int,input().split()))
li.sort()

print(li[2]-li[1]+li[1]-li[0])

Solution (Python):
a = list(map(int, input().split()))
sum_num = 0
a.sort()
sum_num += abs(a[1] - a[2])
sum_num += abs(a[0] - a[1])

print(sum_num)

Solution (Python):
import itertools

def main():
    a = list(map(int, input().split()))
    min_cost = None

    for order in itertools.permutations([0, 1, 2]):
        c = cost(a, order)
        if min_cost is None:
            min_cost = c
        else:
            min_cost = min(min_cost, c)
    print(min_cost)

def cost(a, order):
    c = 0

    for i, j in zip(order, order[1:]):
        c += abs(a[j] - a[i])
    
    return c

main()

Solution (Python):








a,b,c = map(int,input().split(' '))
print(max(a,b,c) - min(a,b,c))

Solution (Python):
A = sorted([int(x) for x in input().split()])
print((A[1] - A[0]) + (A[2] - A[1]))

Solution (Python):
li = list(map(int,input().split()))
li.sort()

print(li[2]-li[1]+li[1]-li[0])

Solution (Python):
A = list(map( int,input().split()))
A = sorted(A)
print(A[2]-A[0])

Solution (Python):
A = list(map(int, input().split()))
A.sort()
b = A[2] - A[0]
print(b)

Solution (Python):
a = list(map(int,input().split()))
a=sorted(a, reverse=True)
print(abs(a[0]-a[1])+abs(a[1]-a[2]))

Solution (Python):
a = list(map(int, input().split(' ')))
print(max(a) - min(a))

Solution (Python):
a_list = sorted([int(a) for a in input().split()])
sumv = abs(a_list[1] - a_list[0]) + abs(a_list[2] - a_list[1])
print(sumv)