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 = list(map(int,input().split()))
def abs_A(A1,A2,A3):
    return abs(A1-A2)+abs(A2-A3)
minA = min(abs_A(A[0],A[1],A[2]),abs_A(A[0],A[2],A[1]),abs_A(A[1],A[0],A[2]),abs_A(A[1],A[2],A[0]),abs_A(A[2],A[0],A[1]),abs_A(A[2],A[1],A[0]))
print(minA)

Submission status: Accepted

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

a.sort(reverse=True)

sum = a[0] - a[1]
sum += a[1] - a[2]

print(sum)

Submission status: Accepted

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

b = [0] * 3
b[0] = abs(a1 - a2)
b[1] = abs(a2 - a3)
b[2] = abs(a3 - a1)


maxindex = b.index(max(b))
ret = 0
for i in range(len(b)):
    if i != maxindex:
        ret += b[i]

print(ret)

Submission status: Accepted

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

b = [abs(a[i+1] - a[i]) for i in range(len(a)-1)]
print(sum(b))

Submission status: Accepted

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

a = abs(A[0] - A[1]) + abs(A[1] - A[2])
b = abs(A[0] - A[1]) + abs(A[0] - A[2])
c = abs(A[0] - A[2]) + abs(A[1] - A[2])

print(min(a, b, c))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from itertools import permutations

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

min_val = float('inf')
for vals in permutations(ary):
    tmp_val = 0
    for i, val in enumerate(vals):
        if i > 0:
            tmp_val += abs(val - vals[i - 1])

    if min_val > tmp_val:
        min_val = tmp_val

print(min_val)

Submission status: Accepted

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

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

print(max-min)

Submission status: Accepted

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

if __name__ == '__main__':
    A = list(map(int, input().split()))
    min_costs = 99999
    for i in range(len(A)):
        if i+1 >= 3:
            j = abs(3 - (i+1))
        else:
            j = i+1
        if i+2 >= 3:
            k = abs(3 - (i+2))
        else:
            k = i+2
        costs = abs(A[j] - A[i]) + abs(A[k] - A[i])
        if costs < min_costs:
            min_costs = costs
    print(min_costs)

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

task_list.sort()

prev = task_list[0]
total_cost = 0

for i, task in enumerate(task_list):
  if i == 0:
    continue

  total_cost += abs(task - prev)
  prev = task

print(total_cost)

Submission status: Accepted

Solution code:
from itertools import permutations


def calc_value(permutation):
    a, b, c = permutation
    return abs(b-a) + abs(c-b)


def solve(a, b, c):
    min_value = float("inf")
    for p in permutations([a, b, c], 3):
        value = calc_value(p)
        if value < min_value:
            min_value = value
    return min_value


a, b, c = map(int, raw_input().split())
print solve(a,b,c)

Submission status: Accepted

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

Submission status: Accepted

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

score1 = abs(b - a) + abs(c - b)
score2 = abs(c - a) + abs(b - c)
score3 = abs(a - b) + abs(c - a)
score4 = abs(c - b) + abs(a - c)
score5 = abs(a - c) + abs(b - a)
score6 = abs(b - c) + abs(a - b)

print(min([score1, score2, score3, score4, score5, score6]))

Submission status: Accepted

Solution code:
xs = map(int, input().split(" "))
xs = sorted(xs)

cost = list()
for i in range(len(xs) - 1):
	cost.append(abs(xs[i] - xs[i+1]))

print(sum(cost))

Submission status: Accepted

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

Submission status: Accepted

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

a12 = abs(A1-A2)
a23 = abs(A2-A3)
a31 = abs(A3-A1)

ans = a12 + a23 + a31 - max(a12,a23,a31)
print(ans)

Submission status: Accepted

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

tmp = input()
a=[int(x) for x in tmp.split()]

b=abs(a[1]-a[0])+abs(a[2]-a[1])
c=abs(a[2]-a[0])+abs(a[1]-a[2])
d=abs(a[0]-a[1])+abs(a[2]-a[0])

print(min(b,c,d))

Submission status: Accepted

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

result = (arr[0] - arr[1]) + (arr[1] - arr[2])
print(result)

Submission status: Accepted

Solution code:
import math
a_tmp = input().split()
a = []
for i in range(3):
    a.append(int(a_tmp[i]))
cost = [0 for i in range(3)]
for i in range(3):
    for j in range(3):
        cost[i] = cost[i] + math.fabs(a[i] - a[j])
print(int(min(cost)))

Submission status: Accepted

Solution code:
A=[int(i) for i in input().split()]
a=abs(A[0]-A[1])
b=abs(A[1]-A[2])
c=abs(A[0]-A[2])
t=min(a+b,b+c,c+a)
print(t)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

t1, t2, t3 = map(int, input().split())
a = [t1, t2, t3]

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())
c1 = abs(a1 - a2) + abs(a2 - a3)
c2 = abs(a1 - a3) + abs(a3 - a2)
c3 = abs(a2 - a1) + abs(a1 - a3)
c4 = abs(a2 - a3) + abs(a3 - a1)
c5 = abs(a3 - a1) + abs(a1 - a2)
c6 = abs(a3 - a2) + abs(a2 - a1)
print(min([c1, c2, c3, c4, c5, c6]))

Submission status: Accepted

Solution code:
from sys import stdin
data = [int(i) for i in input().split()]
print(max(data) - min(data))

Submission status: Accepted

Solution code:
l = [int(x) for x in raw_input().split()]
print max(l) - min(l)

Submission status: Accepted

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

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

An.sort()
i = 0
Ai = An[0]
sum = 0
for j,Aj in enumerate(An):
    i = Aj - Ai
    sum += i
    Ai = Aj

print(sum)

Submission status: Accepted

Solution code:
from itertools import permutations
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    A = tuple(map(int, input().split()))

    cost = float('inf')
    for i, j, k in permutations(A, 3):
        n = abs(i - j)
        n += abs(j - k)
        cost = min(cost, n)
    print(cost)

main()

Submission status: Accepted

Solution code:
largeA = []
largeA = list(map(int,input().split()))
a = abs(largeA[0]-largeA[1])+abs(largeA[1]-largeA[2])
b = abs(largeA[0]-largeA[1])+abs(largeA[2]-largeA[0])
c = abs(largeA[2]-largeA[0])+abs(largeA[1]-largeA[0])
d = abs(largeA[2]-largeA[0])+abs(largeA[1]-largeA[2])
e = abs(largeA[2]-largeA[1])+abs(largeA[1]-largeA[0])
f = abs(largeA[2]-largeA[1])+abs(largeA[2]-largeA[0])
print(min(a,b,c,d,e,f))

Submission status: Accepted

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

# スペース区切りの整数の入力
l = map(int, raw_input().split())
l.sort()
print l[-1]-l[0]

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
def main():
	A = list(map(int, input().split()))
	A.sort()
	print((A[1]-A[0])+(A[2]-A[1]))
 
if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()
ANS=0

for i in range(len(A)-2,-1,-1):
    ANS+=A[i+1]-A[i]

print(ANS)

Submission status: Accepted

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

ans = 10**9

ans = min(ans, abs(a[1]-a[2]) + abs(a[0]-a[1]))
ans = min(ans, abs(a[0]-a[2]) + abs(a[0]-a[1]))
ans = min(ans, abs(a[0]-a[1]) + abs(a[0]-a[2]))
ans = min(ans, abs(a[2]-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[0]) + abs(a[1]-a[2]))
print(ans)

Submission status: Accepted

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

A_ = sorted(A)
print(A_[-1] - A_[0])

Submission status: Accepted

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

if l1[1] - l1[0] < l1[2] - l1[1]:
    print((l1[1] - l1[0]) + (l1[2] - l1[1]))
else:
    print((l1[1] - l1[0]) + (l1[2] - l1[1]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from itertools import permutations

def solve():
    a,b,c = map(int, input().split())
    d = min([abs(x-y) + abs(y-z) for x,y,z in permutations([a,b,c])])

    return str(d)

if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

Submission status: Accepted

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

ans = float('inf')
for i in range(3):
    for j in range(3):
        if i != j:
            for k in range(3):
                if i != k and j != k:
                    ans = min(ans, abs(a[j] - a[i]) + abs(a[k] - a[j]) )
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    N = sorted([int(x) for x in input().strip().split()])
    result = 0
    result = (N[1] - N[0]) + (N[2] - N[1])
    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

candidate.append(abs(A[1]-A[0])+abs(A[2]-A[1]))
candidate.append(abs(A[2]-A[1])+abs(A[0]-A[2]))
candidate.append(abs(A[0]-A[2])+abs(A[1]-A[0]))

candidate.append(abs(A[0]-A[1])+abs(A[2]-A[0]))
candidate.append(abs(A[1]-A[2])+abs(A[0]-A[1]))
candidate.append(abs(A[2]-A[0])+abs(A[1]-A[2]))
print(min(candidate))

Submission status: Accepted

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

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

aN.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
T = [int(i) for i in input().split()]
a, b, c = sorted(T, reverse=True)
ans = abs(b - a) + abs(c - b)
print(ans)

Submission status: Accepted

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

def func(A, ind):
    return abs(A[ind[2]] - A[ind[1]]) + abs(A[ind[1]] - A[ind[0]])


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

m = float("inf")
for ind in indices:
    tmp = func(A, ind)
    if tmp <= m:
        m = tmp

print(m)

Submission status: Accepted

Solution code:
A = [int(t) for t in input().split()]
assert len(A) == 3

A.sort()
print(sum(A[i] - A[i-1] for i in range(1, len(A))))

Submission status: Accepted

Solution code:
n = list(map(int, input().split()))
n.sort()
sum = 0
tmp = 0
for index,i in enumerate(n):
    if index == 0:
        pass
    else:
        sum += abs(i - tmp)
    tmp = i
print(sum)

Submission status: Accepted

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

a.sort()

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

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
num = 0
n = []
n.append(a)
n.append(b)
n.append(c)
n.sort()
mini = min(n)
n.remove(min(n))
num += (n[0] -mini)
num += (n[1] - n[0])
print(num)

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
l.sort()
out = 0

out += abs(l[1] - l[0]) + abs(l[2] - l[1])

print(out)

Submission status: Accepted

Solution code:
a=[int(i) for i in input().split()]
ans=100000
for i in range(3):
    for j in range(3):
        for k in range(3):
            if i==j or i==k or j==k: continue
            ans=min(ans,abs(a[i]-a[j])+abs(a[j]-a[k]))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = list(map(int,input().strip().split(' ')))
import itertools
import sys

m = sys.maxsize
for l in itertools.permutations(A):
    tmp = abs(l[1]-l[0]) + abs(l[2]-l[1])
    m = min(m,tmp)
print(m)

Submission status: Accepted

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

ls = [0 + abs(A2 - A1) + abs(A1 - A3), 0 + abs(A2 - A3) + abs(A3 - A1)
, 0 + abs(A3 - A1) + abs(A1 - A2), 0 + abs(A3 - A2) + abs(A2 - A1)
      ,0+abs(A1-A2)+abs(A2-A3), 0+abs(A1-A3)+abs(A3-A2)]

print(min(ls))

Submission status: Accepted

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

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

print(cost)

Submission status: Accepted

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

Aso = sorted(A)

cost = 0

for i in range(len(Aso)):
  if i == 0:
    cost = 0
  else:
    cost += Aso[i] - Aso[i-1]

print(cost)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

n = sorted(n)

ans = 0

k = n[0]

for i in n[1:]:
    ans += i-k
    k = i

print(ans)

Submission status: Accepted

Solution code:
import itertools
a_values=list(map(int,input().split()))
print(min(abs(a-b)+abs(b-c) for a,b,c in list(itertools.permutations(a_values))))

Submission status: Accepted

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

L = [0] * 3
L[0] = abs(a[0] - a[1])
L[1] = abs(a[0] - a[2])  
L[2] = abs(a[1] - a[2])

L = sorted(L)
re = L[0] + L[1]
print(re)

Submission status: Accepted

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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

d1 = abs(a[2] - a[0])
d2 = abs(a[0] - a[1])
d3 = abs(a[1] - a[2])

print(d1 + d2 + d3 - max(d1, d2, d3))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
  
a1, a2, a3 = map(int, input().split())

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

min_c1_c2 = 0
max_c1_c2 = 0

if c1 < c2:
  min_c1_c2 = c1
  max_c1_c2 = c2
else:
  min_c1_c2 = c2
  max_c1_c2 = c1

if c3 < min_c1_c2:
  print(c3 + min_c1_c2)
elif c3 < max_c1_c2:
  print(c3 + min_c1_c2)
else:
  print(min_c1_c2 + max_c1_c2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 21 19:17:59 2018
ABC103A
@author: maezawa
"""

a, b, c = list(map(int, input().split()))
w = [a, b, c]
w.sort(reverse = True)
cost = 0

cost = w[0]-w[1]+w[1]-w[2]
print(cost)

Submission status: Accepted

Solution code:
import sys

A = sorted(map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    A = [int(x) for x in stdin.readline().rstrip().split()]
    spam = [(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]
    result = []
    for x in spam:
        f, s, t = x
        result.append(abs(A[s] - A[f]) + abs(A[t] - A[s]))
    print(min(result))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a1, a2, a3 = list(map(int, input().split()))
v1 = abs(a1 - a2) + abs(a2 - a3)
v2 = abs(a1 - a3) + abs(a2 - a3)
v3 = abs(a2 - a1) + abs(a1 - a3)
v4 = abs(a2 - a3) + abs(a3 - a1)
v5 = abs(a3 - a1) + abs(a1 - a2)
v6 = abs(a3 - a2) + abs(a2 - a1)
print(min(v1, v2, v3, v4, v5, v6))

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()
num = len(a)

numsum =0

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

print numsum

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

count = 0
cost = 0

A = sorted(A)

for index, i in enumerate(A):
    if index:
        cost += i - A[index-1]

print(cost)

Submission status: Accepted

Solution code:
# coding:utf-8

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

A.sort()

cost = 0
pre = A[0]
for i in A:
    cost += i - pre
    pre = i

print(cost)

Submission status: Accepted

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

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

    task = []
    task.append(abs(a_list[1] - a_list[0]) + abs(a_list[2] - a_list[1]))
    task.append(abs(a_list[2] - a_list[0]) + abs(a_list[1] - a_list[2]))
    task.append(abs(a_list[2] - a_list[1]) + abs(a_list[1] - a_list[0]))
    task.append(abs(a_list[0] - a_list[1]) + abs(a_list[0] - a_list[2]))
    task.append(abs(a_list[1] - a_list[2]) + abs(a_list[0] - a_list[1]))
    task.append(abs(a_list[0] - a_list[2]) + abs(a_list[1] - a_list[0]))
    print(min(task))

    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x,y,z = map(int,input().split(' '))
s = []
s.append(abs(y-x)+abs(z-y))
s.append(abs(z-x)+abs(z-y))
s.append(abs(y-x)+abs(z-x))
s.append(abs(z-x)+abs(y-z))
s.append(abs(x-z)+abs(y-x))
s.append(abs(y-z)+abs(x-y))
print(min(s))

Submission status: Accepted

Solution code:
import sys
As = list(map(int, sys.stdin.readline().split()))
As.sort()
print(sum(map(lambda a_b: a_b[1] - a_b[0], zip(As, As[1:]))))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
a,b,c = list(map(int,input().split()))
print(min(abs(a-b)+abs(b-c),abs(a-b)+abs(a-c),abs(a-c)+abs(b-c)))

Submission status: Accepted

Solution code:
ABC=input()
ABC=ABC.rstrip().split(" ")
A=int(ABC[0])
B=int(ABC[1])
C=int(ABC[2])

a1=abs(A-B)+abs(B-C)
a2=abs(A-C)+abs(C-B)
a3=abs(B-A)+abs(A-C)
a4=abs(B-C)+abs(C-A)
a5=abs(C-A)+abs(A-B)
a6=abs(C-B)+abs(B-A)

list1=[a1,a2,a3,a4,a5,a6]
list1.sort()
print(list1[0])

Submission status: Accepted

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

Submission status: Accepted

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

cost = 1000000
print(a[2]-a[0])

Submission status: Accepted

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

Submission status: Accepted

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

ll=[]
for i in range(-1,2):
    ll.append(abs(l[i]-l[i+1]))

print(sum(ll)-max(ll))

Submission status: Accepted

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

Submission status: Accepted

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

min_cost = sum(A)
for i in range(3):
    for j in range(3):
        for k in range(3):
            if i != j and i != k and j != k:
                cost = abs(A[j]-A[i])+abs(A[k]-A[j])
                min_cost = min(min_cost, cost)
print(min_cost)

Submission status: Accepted

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

Submission status: Accepted

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



a = [[0,1,2],[0,2,1],[1,2,0],[2,1,0],[1,0,2],[2,0,1]]
A = sum(T)
for i in a:
    A = min(A,abs(T[i[2]] - T[i[1]]) + abs(T[i[1]]-T[i[0]]))

print(A)

Submission status: Accepted

Solution code:
A = [0, 0, 0]

A[0], A[1], A[2] = map(int, input().split())

A = sorted(A)

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

Submission status: Accepted

Solution code:
def main(num):
	
	c1 = abs(num[0]-num[1])
	c2 = abs(num[2]-num[1])
	c3 = abs(num[0]-num[2])
	
	cost = min(c1+c2, c1+c3, c2+c3)
	
	return cost



num = input().split(" ")
num = [int(c) for c in num]
print(main(num))

Submission status: Accepted

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

a.sort()

counter = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#昇順ソート            
tasks.sort()

prev_task = tasks[0]
cost = 0
for task in tasks:
    cost += task - prev_task
    prev_task = task
    
print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
p = abs(a - b) + abs(c - b)
q = abs(a - c) + abs(c - b)
b1 = abs(b - a) + abs(a - c)
b2 = abs(b - c) + abs(c - a)
c1 = abs(a - c) + abs(b - a)
c2 = abs(b - c) + abs(b - a)
rec = min(p, q)
rec = min(rec, min(b1, b2))
rec = min(rec, min(c1, c2))
print(rec)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

b1 = abs(a[0] - a[1]) + abs(a[1] - a[2])
b2 = abs(a[1] - a[2]) + abs(a[2] - a[0])
b3 = abs(a[2] - a[0]) + abs(a[0] - a[1])
b4 = abs(a[0] - a[2]) + abs(a[2] - a[1])
b5 = abs(a[1] - a[0]) + abs(a[0] - a[2])
b6 = abs(a[2] - a[1]) + abs(a[1] - a[0])

print(min([b1, b2, b3, b4, b5, b6]))

Submission status: Accepted

Solution code:
import itertools

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

ans = 1000
for a, b, c in itertools.permutations(A):
    temp = abs(b - a) + abs(c - b)
    if temp < ans:
        ans = temp 

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

li=list(map(int, input().split()))
    
cost=10000

c = abs(li[0] - li[1]) + abs(li[2] - li[1])

if c < cost:
    cost=c

c = abs(li[0] - li[2]) + abs(li[2] - li[1])

if c < cost:
    cost = c
    
c = abs(li[0] - li[1]) + abs(li[2] - li[0])

if c < cost:
    cost = c

c = abs(li[2] - li[1]) + abs(li[2] - li[0])

if c < cost:
    cost = c

c = abs(li[2] - li[0]) + abs(li[0] - li[1])

if c < cost:
    cost = c

c = abs(li[2] - li[1]) + abs(li[0] - li[1])

if c < cost:
    cost = c

print(cost)

Submission status: Accepted

Solution code:
# coding: utf-8

import numpy as np

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

A = np.array(sorted(A))

print(sum(A[1:] - A[:2]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
As = input().split(' ')

As.sort()

sumup = 0
tik = int(As[0])
for A in  As:
    A = int(A)
    tok = A
    sumup += tik - tok
    tik = tok
print(abs(sumup))

Submission status: Accepted

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


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


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

Submission status: Accepted

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

print(max(tasks) - min(tasks))

Submission status: Accepted

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

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

print(min(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:
A = sorted(map(int, input().split()))

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

print(ans)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
aa = abs(a-b)
bb = abs(b-c)
cc = abs(c-a)

l = [aa,bb,cc]
l.sort()
#print(l)
print(l[0] + l[1])

Submission status: Accepted

Solution code:
import itertools as it
import collections as col

import sys
sys.setrecursionlimit(10000)

def main():
    x = [int(x) for x in input().split()]
    x = sorted(x)
    
    s = 0
    for i in range(1, len(x)):
        s += x[i] - x[i-1]
    
    print(s)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()

ret = 0
for i in range(len(A) - 1):
   ret += A[i + 1] - A[i]

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

tasks_s = list(sorted(tasks, reverse=True))
cost = 0
for i, j in enumerate(tasks_s[:-1]):
    cost += abs(j - tasks_s[i+1])

print(cost)

Submission status: Accepted

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

total = 0
tmp = 0
for i in range(3):
    if i == 0:
        total += 0
    else:
        total += abs(tmp-min(A))
    tmp = min(A)
    A.remove(min(A))

print(total)

Submission status: Accepted

Solution code:
a,b,c = input().split(" ")
list = []
list.append(int(a))
list.append(int(b))
list.append(int(c))

list.sort()

ans = 0
ans += list[1] -list[0]
ans += list[2] -list[1]


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools
A=[int(i) for i in input().split()]
S=list(itertools.permutations(A,3))
ans=30000
for sg in S:
    tmp=0
    tmp+=abs(sg[1]-sg[0])
    tmp+=abs(sg[2]-sg[1])
    if tmp<ans:
        ans=tmp
print(ans)

Submission status: Accepted

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

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

print(S)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inputs = list(map(int, input().split(' ')))
inputs.sort()
s = 0
for i in range(len(inputs)):
    if i == 0:
        continue
    s += inputs[i] - inputs[i-1]
print(s)

Submission status: Accepted

Solution code:
import itertools

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

for a,b,c in itertools.permutations(A):
    cost = abs(b-a)+abs(c-b)
    if cost < ans:
        ans = cost

print(ans)

Submission status: Accepted

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

print(min(A+B,B+C,C+A))

Submission status: Accepted

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

a.sort()

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = sorted(list(map(int,input().split())))
l = [0] + l
ans = 0
for i in range(1,4):
    if i == 1:continue
    ans += abs(l[i-1] - l[i])
print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
	run()

Submission status: Accepted

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

for i, j, k in [(0,1,2), (0,2,1), (1,0,2), (1,2,0), (2,0,1), (2,1,0)]:
    ans = min([ans, abs(a[j]-a[i])+abs(a[k]-a[j])])

print(ans)

Submission status: Accepted

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

l = sorted(l)
cost_1 = abs(l[1] - l[0])
cost_2 = abs(l[2] - l[1])
r = cost_1 + cost_2
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
sum = a[0]-a[2]
print (sum)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)