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



Sample input:
1 6 3


Sample output:
5

Submission status: Accepted

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

Submission status: Accepted

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

ans = abs(A[2] - A[1]) + abs(A[1] - A[0])
print(ans)

Submission status: Accepted

Solution code:
A1,A2,A3 = map(int,input().split())
ans = max([A1,A2,A3]) - min([A1,A2,A3])
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = sorted(map(int, input().split()), reverse=True)
print(a - c)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    aa = list(map(int, input().split()))
    print(max(aa) - min(aa))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
tasks=sorted(list(map(int,input().split())))

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

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
b = []
for i in range(3):
    b.append(abs(a[i-1] - a[i]))
b.remove(b[b.index(max(b))])
print(sum(b))

Submission status: Accepted

Solution code:
temp = input().rstrip().split(" ")
A1 = int(min(temp))
temp.remove(str(A1))
A2 = int(min(temp))
temp.remove(str(A2))
A3 = int(min(temp))
print(abs(0 + (A2 - A1) + (A3 - A2)))

Submission status: Accepted

Solution code:
import sys

def solve(A, B, C):
    # Uncomment the following if you want to check the input.
    i = [A,B,C]
    print(max(i)-min(i))

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    A = int(ws[0])
    B = int(ws[1])
    C = int(ws[2])
    return (A, B, C,)

def main():
    solve(*readQuestion())

# Uncomment before submission
main()

Submission status: Accepted

Solution code:
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b,c):
    f = [a,b,c]
    f.sort()
    #print(f)
    x = 0
    y = 0

    if a == b and b == c :
        return 0
    else:
        x = f[1] - f[0]
        y = f[2] - f[1]
        return x+y
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c))

def main():
    a, b, c = readQuestion()
    answer = solve(a, b, c)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys

def solve(aOne, aTwo, aThree):
    (x, y, z) = sorted([aOne, aTwo, aThree])
    print((z - y) + (y - x))

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    aOne = int(ws[0])
    aTwo = int(ws[1])
    aThree = int(ws[2])
    return (aOne, aTwo, aThree,)

def main():
    solve(*readQuestion())

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
l.sort()
prev = l[0]
total = 0
for n in l:
    total += abs(n - prev)
    prev = n
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ar = list(map(int,input().split()))

ar.sort()

print(sum(ar)-ar[1]-ar[0]*2)

Submission status: Accepted

Solution code:
ar = list(map(int,input().split(" ")))
ar.sort()
print((ar[1] - ar[0]) + (ar[2] - ar[1]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def abc103_a():
    a = list(map(int, input().split()))
    cost = [abs(a[0] - a[1]), abs(a[1] - a[2]), abs(a[2] - a[0])]
    cost.sort()
    print(sum(cost[:-1]))


abc103_a()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a,b,c = map(int,input().split())#整数の入力
print("{}".format(min(abs(a-b)+abs(c-b),abs(a-c)+abs(b-c),abs(b-a)+abs(c-a)))) #最小値の出力

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    a1, a2, a3 = map(int, input().split())

    print(
          min([
               abs(a2 - a1) + abs(a3 - a2),
               abs(a3 - a1) + abs(a2 - a3),
               abs(a1 - a2) + abs(a3 - a1),
               abs(a3 - a2) + abs(a1 - a3),
               abs(a1 - a3) + abs(a2 - a1),
               abs(a2 - a3) + abs(a1 - a2)
                                         ])
                                          )


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(max(A1, A2, A3) - min(A1, A2, A3))

Submission status: Accepted

Solution code:
import itertools
a=input().split()
#print(len(a))

dict={}
for i in range(len(a)):
  dict[i]=int(a[i])
#print(dict)

ans=1000
b=list(itertools.permutations([0, 1, 2]))
for i in range(len(b)):
  x=abs(dict[b[i][2]]-dict[b[i][1]])+abs(dict[b[i][1]]-dict[b[i][0]])
  if x < ans:
    ans = x

print(ans)

Submission status: Accepted

Solution code:
li = [int(i) for i in input().split()]
li.sort()
cost = 0
for i in range(len(li) - 1):
    cost += (li[i + 1] - li[i])
print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A1, A2, A3 = map(int, input().split(" "))
diff12 = abs(A2-A1)
diff13 = abs(A3-A1)
diff23 = abs(A2-A3)
print(min(diff12+diff13,min(diff12+diff23,diff13+diff23)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
b = [[0, 1], [2, 1], [2, 0]]
l = 0
n = []
for i, j in b:
    l = l + abs(A[j]-A[i])
    n.append(abs(A[j]-A[i]))
l = l - max(n)
print(l)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
b = [[0, 1], [2, 1], [2, 0]]
l = 0
n = []
for i, j in b:
	l = l + abs(A[j]-A[i])
	n.append(abs(A[j]-A[i]))
l = l - max(n)
print(l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
s1 = abs(a - b)
s2 = abs(b - c)
s3 = abs(c - a)
print(min(s1+s2, s2+s3, s3+s1))

Submission status: Accepted

Solution code:
a = input().split()
b =[]
for i in a:
    b.append(int(i))
b.sort()

print(b[-1] - b[0])

Submission status: Accepted

Solution code:
#coding:utf-8
ls = list(map(int,input().split()))
ls.sort()
print (abs(ls[0]-ls[1])+abs(ls[1]-ls[2]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=[int(i) for i in input().split()]
a.sort()
ans=a[2]-a[0]
print(ans)

Submission status: Accepted

Solution code:
list_A = [int(i) for i in input().split()]

list_A = sorted(list_A)
x = abs(list_A[0] - list_A[1])
x += abs(list_A[2] - list_A[1])

print(x)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
print(min([abs(A-B)+abs(A-C), abs(B-A)+abs(B-C), abs(C-A)+abs(C-B)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
seq=[int(i) for i in input().split()]
#print(len(a))
x=100000
listseq=list(itertools.permutations(seq))
#print(listseq)
for j in range(len(listseq)):
  y=abs(listseq[j][1]-listseq[j][0])+abs(listseq[j][2]-listseq[j][1])
  if y < x:
    x=y
print(x)

Submission status: Accepted

Solution code:
a,_,b=sorted(map(int,input().split()));print(b-a)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
A=[a,b,c]
A=sorted(A)
print(abs(A[0]-A[1])+abs(A[1]-A[2]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = list(map( int, input().split()))
A = sorted(A)
 
A1 = int(A[1]-A[0])
A2 = int(A[2]-A[1])
 
print(A1 + A2)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
a = sorted(a)
b = []
for i in range(len(a)-1):
    b.append(abs(a[i]-a[i+1]))
print(sum(b))

Submission status: Accepted

Solution code:
a=input().strip().split(" ")
b=[int(i) for i in a]

b.sort()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    low, middle, high = sorted(list(map(int, input().split())))
    print(abs(high - middle) + abs(middle - low))


def model():
    tasks = list((map(int, input().split())))
    print(max(tasks) - min(tasks))


if __name__ == "__main__":
    # solve()
    model()

Submission status: Accepted

Solution code:
def solve():
    low, middle, high = sorted(list(map(int, input().split())))
    print(abs(high - middle) + abs(middle - low))


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
A = sorted(list(map(int, input().split())), reverse=True)

print(A[0] * 0 + abs(A[1]-A[0]) + abs(A[2]-A[1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#タスクを入力
task_list = list(map(int, input().split()))
task_list.sort()

#コストを計算
cost = 0
task_last = task_list[0]
for i in range(len(task_list)):
    cost += abs(task_list[i] - task_last)
    task_last = task_list[i]

#出力
print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
A = np.array(sorted(list(map(int, input().split()))))
res = sum(np.abs(np.diff(A)))
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x,y,z=(int(x) for x in input().split())
a = [x,y,z]
a = sorted(a)
print(a[2]-a[0])

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
i = abs(a - b)+abs(b - c)
i2= abs(a - c)+abs(b - c)
j = abs(a - b)+abs(a - c)
j2= abs(c - b)+abs(a - c)
k = abs(a - c)+abs(b - a)
k2= abs(c - b)+abs(b - a)
n = min(i,i2,j,j2,k,k2)
print(n)

Submission status: Accepted

Solution code:
A1, A2, A3 = [int(i) for i in sorted(input().split())]
print(A3-A1) if A3-A1>0 else print(A1-A3)

Submission status: Accepted

Solution code:
i = list(map(int, input().split()))
s = [abs(i[0]-i[1]), abs(i[1]-i[2]), abs(i[2]-i[0])]
print(sum(sorted(s)[:2]))

Submission status: Accepted

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

if a > b:
	if b > c:
		print(c)
	else:
		print(b)
else:
	if a > c:
		print(c)
	else:
		print(a)

Submission status: Accepted

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

A.sort()
ans = (A[1]- A[0]) + (A[2] - A[1])

print(ans)

Submission status: Accepted

Solution code:
a=[int(i) for i in input().split(" ")]
a.sort()
print(a[2]-a[0])

Submission status: Accepted

Solution code:
lst = map(int, raw_input().split())


print(max(lst)-min(lst))

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
a = sorted(a)
c = 0
for n in range(len(a)-1):
    c += abs(a[n+1] - a[n])

print(c)

Submission status: Accepted

Solution code:
L=list(map(int,input().split()))

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

Submission status: Accepted

Solution code:
str = raw_input()
a = map(int, str.split())

print max(a) - min(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A1,A2,A3 = map(int,input().split())
cost = [abs(A1 - A2), abs(A2 - A3), abs(A3 - A1)]
cost.sort(reverse = True)
cost[0] = 0
print(sum(cost))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A1,A2,A3 = map(int, input().split())
A = [A1, A2, A3]
A.sort(reverse=True)
for i in range(3):
    if i == 0:
        sum=0
    else:
        sum = sum+abs(A[i] - A[i-1])
print(sum)

Submission status: Accepted

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

A.sort()
A.reverse()

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

Submission status: Accepted

Solution code:
l = [int(v) for v in input().split()]
l.sort(reverse=True)
cost = l[0] - l[1] + l[1] - l[2]
print(cost)

Submission status: Accepted

Solution code:
def minimum(a1, a2, a3):
    a = sorted([a1, a2, a3])
    return abs(a[0] - a[1]) + abs(a[1] - a[2])

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

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
ans=abs(a[0]-a[1])+abs(a[0]-a[2])
ans=min(ans,abs(a[1]-a[0])+abs(a[1]-a[2]))
ans=min(ans,abs(a[2]-a[1])+abs(a[0]-a[2]))
print(ans)

Submission status: Accepted

Solution code:
cost = 0
a, b, c = (map(int, input().split()))
tasks = [a, b, c]

tasks.sort()

j = min(tasks)
tasks.remove(j)

for i in tasks:
    cost += (i - j)
    j = i

print(cost)

Submission status: Accepted

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

d = abs(a-b)
e = abs(b-c)
f = abs(c-a)

m =max(d,e,f)

print(d+e+f-m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
*a,=sorted(map(int,input().split()))
a1=abs(a[1]-a[0])+abs(a[2]-a[1])
a2=abs(a[2]-a[0])+abs(a[1]-a[2])
a3=abs(a[0]-a[1])+abs(a[2]-a[0])
a4=abs(a[2]-a[1])+abs(a[0]-a[2])
a5=abs(a[0]-a[2])+abs(a[1]-a[0])
a6=abs(a[1]-a[2])+abs(a[0]-a[1])
print(min([a1,a2,a3,a4,a5,a6]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

list = []
list.append(A1)
list.append(A2)
list.append(A3)

list.sort()
ans = 0
for i in range(0,len(list)-1):
    ans += list[i+1] - list[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = [int(i) for i in input().split()]
H = sorted(H)
print(H[2]-H[0])

Submission status: Accepted

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

a = [A1, A2, A3]
a.sort()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a= [int(i) for i in input().split()]
a.sort()
print(abs(a[1]-a[0])+abs(a[2]-a[1]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Task Scheduling Problem
a = sorted(list(map(int, input().split())))
print(a[2]-a[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8
li = list(map(int, input().split()))
print(max(li) - min (li))

Submission status: Accepted

Solution code:
#coding: utf-8
a, b, c = sorted(map(int, input().split()))
print(abs(c - b) + abs(b - a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
As = [int(A) for A in input().split()]
As.sort()
print(As[2]-As[1] + As[1]-As[0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

W = min(abs(a-b)+abs(a-c), abs(b-a)+abs(b-c), abs(c-a)+abs(c-b))

print(W)

Submission status: Accepted

Solution code:
A,B,C = map(int, input().split())
a,b,c = abs(A-B), abs(A-C), abs(B-C)
N = [a,b,c]
N.sort()
print(N[0] + N[1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = []
a.append(a1)
a.append(a2)
a.append(a3)

a.sort()

ans = abs(a[1] - a[0]) + abs(a[2] - a[1])

print(ans)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
ans = 300
for ai in a:
    cost = abs(ai-a[0]) + abs(ai-a[1]) + abs(ai-a[2])
    ans = min(ans, cost)
    
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 23 15:58:40 2018

@author: masato
"""
a = list(map(int, input().split()))
b = sorted(a)

cnt = 0
c = 0
for i in range(len(b)-1):
    c = abs(b[i]- b[i + 1])
    cnt += c
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l = [int(_) for _ in input().split()]

ans = float('inf')
for i in range(3):
    for j in range(3):
        if j == i:
            continue
        for k in range(3):
            if k == i or k == j:
                continue
            cost = abs(l[j] - l[i]) + abs(l[k] - l[j])
            ans = min(ans, cost)
print(ans)

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
b = sorted(a)
c = 0
for i in range(2):
  c += b[i+1]-b[i]
print(c)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
A - Task Scheduling Problem
https://beta.atcoder.jp/contests/abc103/tasks/abc103_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(a1, a2, a3):
    ans = float('inf')
    ans = min(ans, abs(a2-a1) + abs(a3-a2))
    ans = min(ans, abs(a3-a1) + abs(a2-a3))
    ans = min(ans, abs(a1-a2) + abs(a3-a1))
    ans = min(ans, abs(a3-a2) + abs(a1-a3))
    ans = min(ans, abs(a2-a3) + abs(a1-a2))
    ans = min(ans, abs(a1-a3) + abs(a2-a1))
    return ans


def main(args):
    a1, a2, a3 = map(int, input().split())
    ans = solve(a1, a2, a3)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
t1,t2,t3 = map(int,input().split())
t = [t1,t2,t3]
print(max(t) - min(t))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
A.sort(reverse=True)
print(abs(A[0] - A[1]) + abs(A[1] - A[2]))

Submission status: Accepted

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

Submission status: Accepted

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

print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = [int(x) for x in input().split()]
l.sort()
print(abs(l[0] - l[2]))

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
Min = min(a)
Max = max(a)
Mid = sum(a) - Max - Min
 
ans = Mid-Min + Max-Mid
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A1, A2, A3 = map(int, input().split())
print(max(A1,A2,A3)-min(A1,A2,A3))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = map(int, raw_input().split())
ls = [abs(l[0]-l[1]), abs(l[1]-l[2]), abs(l[2]-l[0])]
print sum(ls) - max(ls)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

a,b,c = map(int,input().split())
lst = []
lst.append(a)
lst.append(b)
lst.append(c)
lst.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

src = map(int, input().split())
ans = 1000
for p_i in list(itertools.permutations(src)):
    candidate = abs(p_i[1]-p_i[0]) + abs(p_i[2]-p_i[1])
    ans = min(ans, candidate)
print(ans)

Submission status: Accepted

Solution code:
x = input().split()
y = [int(n) for n in x]
print(max(y) - min(y))

Submission status: Accepted

Solution code:
#coding: utf-8

a = map(int,raw_input().split())

a.sort()

print a[2] - a[0]

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(len(A) - 1):
    ans += abs(A[i] - A[i + 1])

print(ans)

Submission status: Accepted

Solution code:
A = list(map(int,input().split()))
SUM = 0

A = sorted(A)
print(abs(A[0]-A[1]+A[1]-A[2]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = map(int, raw_input().split())
max = -1
min = 101
for i in range(0, 3):
	if max < a[i]: max = a[i]
	if a[i] < min: min = a[i]
print max - min

Submission status: Accepted

Solution code:
def solution(a):
    return max(a) - min(a)
 
def main():
    a = [int(i) for i in raw_input().strip().split()]
    print solution(a)
 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A = [0,0,0]
A[0],A[1],A[2] = (int(i) for i in input().split())

total = 0
total = max(A) - min(A)
print(total)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# encoding: utf-8
A = sorted(list(map(int, input().split())))
print(A[-1] - A[0])

Submission status: Accepted

Solution code:
x,y,z = map(int,input().split())
a = abs(x-y) + abs(y-z)
b = abs(y-z) + abs(z-x)
c = abs(z-x) + abs(x-y)
list = [a,b,c]
print(min(list))

Submission status: Accepted

Solution code:
from itertools import permutations

a1, a2, a3 = map(int, input().split())
ans = 1e9
for a in permutations([a1, a2, a3]):
    tmp = abs(a[0] - a[1]) + abs(a[1] - a[2])
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

l = [int(i) for i in input().split()] 
l_sort = np.sort(l)
l_diff = np.diff(l_sort)

print(np.sum(l_diff))

Submission status: Accepted

Solution code:
l = [int(i) for i in input().split()] 
ans = 0

for j in range(len(l) - 1):
	for i in range(len(l) - 1):
		if l[i+1] < l[i]:
			tmp = l[i+1]
			l[i+1] = l[i]
			l[i] = tmp
        
for i in range(len(l) - 1):
	ans += l[i+1] - l[i]
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys, re

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

    a.sort()

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

    print(ans)

    return 0

if __name__ == '__main__':
    sys.exit(main())

Submission status: Accepted

Solution code:
import heapq
A1,A2,A3=map(int,input().split())
a = [A1, A2, A3]
heapq.heapify(a)
min=a[0]
heapq.heappop(a)
M=a[0]
heapq.heappop(a)
max=a[0]
print(max-min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(a1,a2,a3)=[(int)(e) for e in (input().split(' '))]
print(max(a1,a2,a3)-min(a1,a2,a3))

Submission status: Accepted

Solution code:
l = sorted([int(e) for e in input().split()])
 
result = sum(l[i] - l[i-1] for i in range(1, len(l)))
print(result)

Submission status: Accepted

Solution code:
l = sorted([int(e) for e in input().split()])

result = sum(l[i] - l[i-1] for i in range(1, len(l)))
print(result)

Submission status: Accepted

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

print(max(A) - min(A))

Submission status: Accepted

Solution code:
A, B, C = list(map(int, input().split()))
tmp = abs(A-B)+abs(B-C)+abs(C-A)
print(tmp-max(abs(A-B), abs(B-C), abs(C-A)))

Submission status: Accepted

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

diff1 = abs(a1 - a2)
diff2 = abs(a2 - a3)
diff3 = abs(a3 - a1)

diffs = [diff1, diff2, diff3]

diffs = sorted(diffs)

print(sum(diffs[:2]))

Submission status: Accepted

Solution code:
N, K, L = input().split()
S=int(N)-int(K)
S=abs(S)
I=int(L)-int(K)
I=abs(I)
M=int(N)-int(L)
M=abs(M)
list=(S, I ,M)
print(S+I+M-max(list))

Submission status: Accepted

Solution code:
[A1,A2,A3]=map(int,input().split())
tasks=[A1,A2,A3]
costs=[]
def cost(start):
    for i in range(3):
        if i!=start:
            cost_1st=abs(tasks[i]-tasks[start])
            for l in range(3):
                if l != i and l != start:
                    total_cost=cost_1st+abs(tasks[i]-tasks[l])
                    costs.append(total_cost)
                else:
                    continue
        else:
            continue
for i in range(3):
    cost(i)

ans=min(costs)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A1,A2,A3 = map(int, input().split())

ans = 0
A = [A1,A2,A3]

A.sort()

ans = (A[2] - A[1]) + (A[1] -A[0])

    
print(ans)

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
a=sorted(a)
s=0
for i in range(len(a)-1):
    res=a[i+1]-a[i]
    s+=res
print(s)

Submission status: Accepted

Solution code:
M = list(map(int, input().split()))
N = sorted(M)
result = N[2] - N[0]
print(result)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = sorted(LI())
    return a[-1] - a[0]


print(main())

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
sum = 0

a1 = max(A)
A.remove(a1)
a2 = max(A)
A.remove(a2)
a3 = A.pop()

sum += (abs(a2 - a1) + abs(a2 - a3))
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = sorted(map(int, input().split()))
res = 0
print((A[2]-A[1]) + (A[1]-A[0]))

Submission status: Accepted

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

costs = []
costs.append(abs(A1-A2) + abs(A2-A3))
costs.append(abs(A1-A3) + abs(A3-A2))
costs.append(abs(A2-A1) + abs(A1-A3))
costs.append(abs(A2-A3) + abs(A3-A1))
costs.append(abs(A3-A1) + abs(A1-A2))
costs.append(abs(A3-A2) + abs(A2-A1))

print(min(costs))