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,b,c=map(int,input().split())
if(a==b and a==c):
    print("0")
    exit()
elif(a==c or a==b or b==c):
    if(a==b):
        print(abs(b-c))
    if(a==c):
        print(abs(b-a))
    if(b==c):
        print(abs(a-b))
else:
    count=0
    l=[a,b,c]
    num=min(l)
    l.remove(min(l))
    num2=min(l)
    count+=abs(num2-num)
    l.remove(min(l))
    count+=abs(num2-l[0])
    print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

n.sort()

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

Submission status: Accepted

Solution code:
lst=map(int,input().strip().split(' '))
lst = sorted(lst)
out = 0
for i in range(1, len(lst)):
    out += lst[i]-lst[i-1]
print(out)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
A.sort()
print(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:
from statistics import median

task=[int(i) for i in input().split()]
    
b=median(task)
sum=0

for i in range(3):
    sum+=abs(b-task[i])
    
print(sum)

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

a.sort()
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l= input()
s=l.split()

s.sort(key=int)

a1 = int(s[0])
a3 = int(s[2])

c = a3 - a1

print(c)

Submission status: Accepted

Solution code:
l= input()
s=l.split()

s.sort(key=int)

a1 = int(s[0])
a2 = int(s[1])
a3 = int(s[2])

c = a3 - a1

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8

def getRes(raw_input):
    return max(raw_input) - min(raw_input)

if __name__ == "__main__":
    raw_input = [int(x) for x in input().split(" ")]
    print(getRes(raw_input))

Submission status: Accepted

Solution code:
#coding: utf-8

def getMatrix(raw_input):
    mlist = []
    for i in range(0, len(raw_input)-1):
        for j in range(i+1, len(raw_input)):
            mlist.append(abs(raw_input[i] - raw_input[j]))
            
    return mlist

def getProduct(mlist):
    plist = []
    for i in range(0, len(mlist)-1):
        for j in range(i+1, len(mlist)):
            plist.append(mlist[i]+mlist[j])
    
    return plist

if __name__ == "__main__":
    raw_input = [int(x) for x in input().split(" ")]
    print(min(getProduct(getMatrix(raw_input))))

Submission status: Accepted

Solution code:
import sys 
import math

#X = int(input())
a = list(map(int, input().split(" ")))
#a = [0 for i in range(X+1)]

a.sort()

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

Submission status: Accepted

Solution code:
import itertools

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

anss = []
for ps in itertools.permutations(xs, len(xs)):
  ps = list(ps)
  head = ps[0]
  ps2 = ps.copy()
  ps2.insert(0, 0)
  s = [abs(a-b) for a, b in list(zip(ps, ps2))]
  #print(s, head)
  anss.append(sum(s)-head)
print(min(anss))

Submission status: Accepted

Solution code:
a1,a2,a3= map(int,input().split())
a = [a1,a2,a3]
i=0
sum = 0
amin = min(a)
del(a[a.index(amin)])
sum += min(a)-amin
amin = min(a)
del(a[a.index(amin)])
sum += min(a)-amin
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    A = list(sorted(list(map(int, input().split()))))
    print((A[2] - A[1]) + (A[1] - A[0]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(repr(item))
        stderr.write(sep)
    stderr.write(end)

a1,a2,a3 = f()

a = abs(a1-a2)
b = abs(a2-a3)
c = abs(a3-a1)
print(min(a+b,b+c,c+a))

Submission status: Accepted

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

aa = [a,b,c]
aa = sorted(aa)

for i in range(len(aa)):
    if i == 0:
        p=0
    else:
        p=aa[i]-aa[i-1]+p
        #print(p)
print(p)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = [int(x) for x in 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())

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

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
out=abs(a[1]-a[0])+abs(a[2]-a[1])
for i in range(3):
    if i ==0:
        b=a[1]
        c=a[2]
    elif i==1:
        b=a[0]
        c=a[2]
    else:
        b=a[0]
        c=a[1]
    if ((abs(b-a[i])+abs(c-b))<out):
        out=abs(b-a[i])+abs(c-b)
    if ((abs(c-a[i])+abs(b-c))<out):
        out=abs(c-a[i])+abs(b-c)
print(out)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
n = input()
list = n.split(" ")
num = [int(x) for x in list ]

print(max(num)-min(num))

Submission status: Accepted

Solution code:
S=raw_input()
L=S.split()
a=int(L[0])
b=int(L[1])
c=int(L[2])
m=min(a,min(b,c))
M=max(a,max(b,c))
#mid=(a+b+c)-m-M
ans=M-m
print ans

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    task_str = input().split()
    task_list = []
    task_list = [int(s, 10) for s in task_str]
    task_list.sort()
    result = task_list[2] - task_list[0]
    print(result)

if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
tasks = sorted(map(int, input().split()))
cost = sum([tasks[i+1] - tasks[i] for i in range(0, len(tasks) - 1)])
print(cost)

Submission status: Accepted

Solution code:
a1,  a2,  a3 = map(int, input().split())
ans = 0
kanou1 = abs(a1-a2)+abs(a1-a3)
kanou2 = abs(a2-a1)+abs(a2-a3)
kanou3 = abs(a3-a1)+abs(a3-a2)
if kanou1 <= kanou2:
    ans = kanou1
else:
    ans = kanou2
    
if ans <= kanou3:
    print(ans)
else:
    ans = kanou3
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int,input().split())
listA = [A,B,C]
slist = sorted(listA)
answer = slist[2]-slist[0]
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

    # 愚直に解くと3点のうち、1点とその他の点の距離を求める。これの最小化
    # 1,2,3 ならmax-min(中央との距離)
    # 3-1, 2-1 ではない(これはminとの距離、maxでも同様
    ans = max([a1,a2,a3]) - min([a1, a2, a3])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import itertools
if __name__ == "__main__":
    a  = list(map(int, input().split()))
    ans = float('inf')
    factor = list(itertools.permutations(a))
    for tuples in factor:
        cost = 0
        for tmp in range(1,3):
            cost += abs(tuples[tmp]-tuples[tmp-1])
        ans = min(ans, cost)
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
tasks = input()

tasks = [int(t) for t in tasks.split()]

# 0, 1, 2
cost0 = abs(tasks[1] - tasks[0]) + abs(tasks[2] - tasks[1])

# 0, 2, 1
cost1 = abs(tasks[2] - tasks[0]) + abs(tasks[2] - tasks[1])

# 1, 0, 2
cost2 = abs(tasks[1] - tasks[0]) + abs(tasks[2] - tasks[0])

# 1, 2, 0
cost3 = abs(tasks[1] - tasks[2]) + abs(tasks[2] - tasks[0])

# 2, 0, 1
cost4 = abs(tasks[2] - tasks[0]) + abs(tasks[0] - tasks[1])

# 2, 1, 0
cost5 = abs(tasks[2] - tasks[1]) + abs(tasks[0] - tasks[1])

min_cost = min([cost0, cost1, cost2, cost3, cost4, cost5])

print(min_cost)

Submission status: Accepted

Solution code:
ip = input()# your code goes here
lis = ip.split(" ")
for i in range(len(lis)):
	lis[i] = int(lis[i])
lis = sorted(lis)
ans = 1e9
su = 0
for i in range(0,len(lis)-1):
	su+=abs(lis[i+1]-lis[i])
ans = min(ans,su)

print(ans)

Submission status: Accepted

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

A = sorted(A)

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

print(res)

Submission status: Accepted

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

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:
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:
l = map(int, raw_input().split())
print (max(l) - min(l))

Submission status: Accepted

Solution code:
def main():
    cost_list = input().split()
    for i in range(len(cost_list)):
        cost_list[i] = int(cost_list[i])
    cost_list.sort()
    counter = 0
    for i in range(len(cost_list) - 1):
        counter += cost_list[i+1] - cost_list[i]
    print(counter)

main()

Submission status: Accepted

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

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

Submission status: Accepted

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

a.sort(reverse=True)

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

Submission status: Accepted

Solution code:
from itertools import permutations
a=[int(x) for x in input().split()]
print(min([abs(a[i1]-a[i0])+abs(a[i2]-a[i1]) for i0,i1,i2 in permutations([0,1,2])]))

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
first = max(A)
A.remove(max(A))
cost1 = 0
cost1 += abs(first - A[0])
cost1 += abs(A[0] - A[1])
cost2 = 0
cost2 += abs(first - A[1])
cost2 += abs(A[0] - A[1])
print(min(cost1, cost2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A = list(map(int,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:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

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

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

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

main()

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 = input()
b = list(map(int,a.split()))
b.sort()
print(b[2]-b[0])

Submission status: Accepted

Solution code:
# coding:utf-8

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

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#list = [0 for i in range(n)]
#dp = [[0 for i in range(A)] for j in range(B)]

#list_int 並べて出力 print (' '.join(map(str,ans_li)))
#list_str 並べて出力 print (' '.join(list))

# 2進数 format(10, 'b') # '1010'

# aa=[int(input()) for i in range(n)]

#for i,name in enumerate(list)

''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) #heapqの作成
heapq.heappush(queue,num) #numのpush(値の追加)
pop = heapq.heappop(queue) #numのpop(最小値の出力)
pop = heapq.heappushpop(queue,num) #push -> pop

'''

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(max-min)

Submission status: Accepted

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

A = [A1, A2, A3]

B = sorted(A)

C = B[2] - B[0]

print(C)

Submission status: Accepted

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

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

print (ans)

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:
from itertools import permutations

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#abc103a

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

Submission status: Accepted

Solution code:
def getinputdata():

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

    flg = True

    try:
        while flg:

            data = input()

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

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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,B,C = map(int,input().split())
diffs = sorted([abs(A-B),abs(A-C),abs(B-C)])
print(diffs[0]+diffs[1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import permutations

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

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

print(min(R))

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:
s = list(map(int,input().split()))
a = s[0]
b = s[1]
c = s[2]

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

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

Submission status: Accepted

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

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:
a1, a2, a3 = map(int, input().split())
print(min(abs(a1-a2)+abs(a2-a3), abs(a1-a3)+abs(a3-a2), abs(a2-a1)+abs(a1-a3)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

sys.setrecursionlimit(10000000)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

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

print s

Submission status: Accepted

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

print(total)

Submission status: Accepted

Solution code:
import itertools

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

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

print(min_score)

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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