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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
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))

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

Submission status: Accepted

Solution code:
list_task = list(map(int,  input().split()))
N = len(list_task)
# ソートによってリストを降順
list_task.sort()
list_task.reverse()

# 最初のコストは0なので最大値を削除し、それを次の計算のために変数に格納
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)

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# Task Scheduling Problem

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#coding: utf-8

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#list = map(int, input().split())
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])))

Submission status: Accepted

Solution code:
s = "100 10 25"
list = list(map(int, input().split()))
#list = list(map(int, s.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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

    # bから
    lst.append(abs(a-b) + abs(c-a))
    lst.append(abs(c-b) + abs(a-c))

    # cから
    lst.append(abs(c-b) + abs(a-c))
    lst.append(abs(a-c) + abs(b-a))

    print(min(lst))

if __name__ == "__main__":
        main()

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# your code goes here
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]))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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])
#s_4 = abs(n[2]-n[1])+abs(n[2]-n[0])
#s_5 = abs(n[0]-n[2])+abs(n[0]-n[1])
#s_6 = abs(n[1]-n[2])+abs(n[0]-n[1])
print(min(s_1, s_2, s_3))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
def permutation(lst):
 
    # If lst is empty then there are no permutations
    if len(lst) == 0:
        return []
 
    # If there is only one element in lst then, only
    # one permuatation is possible
    if len(lst) == 1:
        return [lst]
 
    # Find the permutations for lst if there are
    # more than 1 characters
 
    l = [] # empty list that will store current permutation
 
    # Iterate the input(lst) and calculate the permutation
    for i in range(len(lst)):
       m = lst[i]
 
       # Extract lst[i] or m from the list.  remLst is
       # remaining list
       remLst = lst[:i] + lst[i+1:]
 
       # Generating all permutations where m is first
       # element
       for p in permutation(remLst):
           l.append([m] + p)
    return l
 
 
# Driver program to test above function
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)

Submission status: Accepted

Solution code:
# A - Task Scheduling Problem
# https://beta.atcoder.jp/contests/abc103/tasks/abc103_a

# A_Task_Scheduling_Problem.py

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)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018/7/21 20:19
# @Version : 1.1
# @Author  : Jade
# @File    : acm.py
# @Software: PyCharm
#
a,b,c = map(int,input().split(' '))
print(max(a,b,c) - min(a,b,c))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A = input().split()

a = [int(A[i]) for i in range(3)]

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

Submission status: Accepted

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

ans = num[2]-num[0]

print(ans)

Submission status: Accepted

Solution code:

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

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python 
# -*- coding:utf-8 -*-

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

A.sort()
T=0
for i in range(2):
    T = T+(A[i+1]-A[i])
print(T)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A1, A2, A3] =  [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    print   min(abs(A1 - A2) + abs(A2 - A3) ,abs(A1 - A3) + abs(A3 - A2),
                abs(A2 - A1) + abs(A1 - A3), abs(A2 - A3) + abs(A3 - A1),
                abs(A3 - A1) + abs(A1 - A2), abs(A3 - A2) + abs(A3 - A1))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a = list(map(int, input().split(" ")))


min_ = 99999999999999999

for i in range(3):
    for j in range(3):
        sum_ = None
        for k in range(3):
            if i != j != k and i != k:
                sum_ = abs(a[i]-a[j]) + abs(a[j]-a[k])

        if sum_ is not None:
	        min_ = min(min_, sum_)

print(min_)

Submission status: Accepted

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

print(max(li)-min(li))
print()

Submission status: Accepted

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

a.sort()
a.reverse()

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

print ans

Submission status: Accepted

Solution code:
a = sorted([int(i) for i in input().split()], reverse=True)

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

print(s)

Submission status: Accepted

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

print(min(abs(b-a)+abs(b-c),abs(c-a)+abs(c-b),abs(b-a)+abs(c-a)))

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

inp = Is()
lis = [abs(inp[0]-inp[1]),abs(inp[0]-inp[2]),abs(inp[1]-inp[2])]
print(sum(lis)-max(lis))

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()

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

Submission status: Accepted

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

A=N[0]
B=N[1]
C=N[2]

Answerlist= [0 for i in range(3)]
Answerlist[0]=abs(A-B)
Answerlist[1]=abs(B-C)
Answerlist[2]=abs(C-A)

print(max(Answerlist))

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())		# 5 7 2

x = max(a, b, c)
y = min(a, b, c)
print( abs(x-y) )

Submission status: Accepted

Solution code:
def main():
    A1, A2, A3 = sorted(map(int, raw_input().split()))

    if A1 == A2 and A2 == A3:
        print 0
    elif A2-A1 < A3-A2:
        print (A2-A1) + (A3-A2)
    elif A3-A2 < A2-A1:
        print (A2-A1) + (A3-A2)
    else:
        print 0


main()

Submission status: Accepted

Solution code:
A = [int(c) for c in raw_input().split()]
A.sort()

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

Submission status: Accepted

Solution code:
import sys

def main():
        run()

def run():
        data = input()
        splited = [int(x) for x in data.split(" ")]

        sum_cost = 0
        prev_cost = 0
        while(splited):
                cost = max(splited)
                splited.remove(cost)
                if prev_cost != 0:
                        sum_cost += abs(prev_cost - cost)
                prev_cost = cost
        print(sum_cost)

if __name__ == "__main__":
        main()

Submission status: Accepted

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

a.sort(reverse=True)
cost = 0
for i in range(1,3):
    cost = cost + abs(a[i]-a[i-1])

print(cost)

Submission status: Accepted

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

x = abs(a-b)
y = abs(b-c)
z = abs(c-a)

print(x+y+z-max(x,y,z))

Submission status: Accepted

Solution code:
import itertools
A=map(int,input().split())
lt = list(itertools.permutations(A))
ans=[]

for ary in lt:
    tmp=0
    for i in range(1,len(ary)):
        tmp += abs(ary[i] - ary[i-1])
    ans.append(tmp)

print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(map(int,input().split(" ")))
li = [abs(a[1]-a[2]),abs(a[2]-a[0]),abs(a[1]-a[0])]
ans = sum(li) - max(li)
print(ans)

Submission status: Accepted

Solution code:
import sys
a, b, c = map(int, sys.stdin.readline().split())
d, e, f = map(lambda t: abs(t[0] - t[1]), [(a, b), (b, c), (c, a)])
if d > e and d > f:
    print(e + f)
elif e > f:
    print(d + f)
else:
    print(d + e)

Submission status: Accepted

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

b = sorted(map(int, list(set(a))))

if len(b) == 1:
    print(0)
elif len(b) == 2:
    print(int(b[1])-int(b[0]))
else:
    print(int(b[2]) - int(b[0]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
arr = s.split()
a = [int(i) for i in arr]

a.sort()

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

Submission status: Accepted

Solution code:
A=map(int,raw_input().split())
print max(A)-min(A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
a = list (map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
ip = input().split()
data = []
for i in ip:
    data.append(int(i))

maxob = max(data)
minob = min(data)

print(maxob - minob)

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:
I = list(map(int, input().split()))

print(max(I)-min(I))

Submission status: Accepted

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

print(answer)

Submission status: Accepted

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

arr.sort()

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

Submission status: Accepted

Solution code:
from sys import stdin

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

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

Submission status: Accepted

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

n.sort()

#print(n)
sum = 0
for i in range(2):
    sum += abs(n[i]-n[i+1])

print(sum)

Submission status: Accepted

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

a.sort()

ans = 0

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

print(ans)

Submission status: Accepted

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

ans = min(abs(A-B)+abs(B-C), abs(A-C)+abs(C-B), abs(B-A) + abs(A-C))
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

b = [0,0,0,0,0,0]
b[0] = abs(a[1]-a[0]) + abs(a[2]-a[1])
b[1] = abs(a[2]-a[0]) + abs(a[1]-a[2])
b[2] = abs(a[0]-a[1]) + abs(a[2]-a[0])
b[3] = abs(a[2]-a[1]) + abs(a[0]-a[2])
b[4] = abs(a[0]-a[2]) + abs(a[1]-a[0])
b[5] = abs(a[1]-a[2]) + abs(a[0]-a[1])


print(int(min(b)))

Submission status: Accepted

Solution code:
from sys import stdin
a = map(int,stdin.readline().split())
print max(a) - min(a)

Submission status: Accepted

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

data.sort()

total = 0

total = (data[1] - data[0]) + (data[2] - data[1])

print(total)

Submission status: Accepted

Solution code:
a, b, c = (int(i) for i in input().split())

r1 = abs(b-a) + abs(c-b)
r2 = abs(c-a) + abs(b-c)

r3 = abs(a-b) + abs(c-a)
r4 = abs(c-b) + abs(a-c)

r5 = abs(a-c) + abs(b-a)
r6 = abs(b-c) + abs(a-b)

print(min([r1, r2, r3, r4, r5, r6]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_s = str(input())
ary = input_s.split(" ")
ary.sort()
task = 0
tmp1 = 0
tmp2 = 0
for i in ary:
    if tmp1 == 0:
        tmp1 = int(i)
    else:
        tmp2 = int(i)
        if tmp1 < tmp2:
            task += tmp2 - tmp1
        else:
            task += tmp1 - tmp2
        tmp1 = tmp2
print(task)

Submission status: Accepted

Solution code:
one,two,three = map(int,input().split())
lis = [one,two,three]
sort = sorted(lis)
print((sort[1]-sort[0])+(sort[2]-sort[1]))

Submission status: Accepted

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

print(abs(max(abc) - min(abc)))

Submission status: Accepted

Solution code:
import sys

line = sys.stdin.readline()
a = [ i for i in map(int, line.strip().split()) ]
b = abs(a[0] - a[1])
c = abs(a[1] - a[2])
d = abs(a[0] - a[2])
e = b + c
f = c + d
g = d + b
print(min(e,f,g))

Submission status: Accepted

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-


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

    c1 = abs(a2-a1) + abs(a3-a1)
    c2 = abs(a1-a2) + abs(a3-a2)
    c3 = abs(a1-a3) + abs(a2-a3)

    print(min(c1, c2, c3))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#encoding utf-8

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

max = max(a, b, c)
min = min(a, b, c)

print(max-min)