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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = Mid-Min + Max-Mid
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = str(input())
t = str(input())

Submission status: Runtime Error

Solution code:
s = str(input())
t = str(input())
 
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = str(input())
t = str(input())
s =  ''.join(sorted(s))
t = ''.join(sorted(t))

if s == t:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s,t = map(str,input().split())
s =  ''.join(sorted(s))
t = ''.join(sorted(t))
 
print(s)
print(t)
if s == t:
    print("yes")
else:
    print("no")

Submission status: Runtime Error

Solution code:
s = input()
t = input()
s =  ''.join(sorted(s))
t = ''.join(sorted(t))

print(s)
print(t)
if s == t:
    print("yes")
else:
    print("no")

Submission status: Runtime Error

Solution code:
import math
a = int(input())
b = int(input())
c = int(input())

lst = []
lst.append(a)
lst.append(b)
lst.append(c)
lst.sort()

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

Submission status: Runtime Error

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
l = [int(i) for i in input().split()] 
l_sort = np.sort(l)
l_diff = np.diff(l_sort)
 
print(np.sum(l_diff))

Submission status: Runtime Error

Solution code:
l = [int(i) for i in input().split()] 
ans = 0
 
for i in range(len(l) - 1):
	if l[i+1] < l[i]:
      tmp = l[i+1]
      l[i+1] = l[i]
      l[i] = tmp

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

print(ans)

Submission status: Runtime Error

Solution code:
l = [int(i) for i in input().split()] 
ans = 0
 
for i in range(len(l) - 1):
	if l[i+1] < l[i]:
	tmp = l[i+1]
	l[i+1] = l[i]
	l[i] = tmp
    
for i in range(len(l) - 1):
	ans += l[i+1] - l[i]
    
print(ans)

Submission status: Runtime Error

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

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

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

print(ans)

Submission status: Runtime Error

Solution code:
def main():
    # Input
    [N, M] = list(map(int, input().rstrip().split(" ")))
    a, b = [], []
    for i in range(M):
        [_a, _b] = list(map(int, input().rstrip().split(" ")))
        a.append(_a)
        b.append(_b)
    output = solve(N, M, a, b)
    print(output)

def solve(N, M, a, b):
    # 切断したい橋の候補をboolean値で表す
    bool_list = []
    for i in range(M):
        bool_list.append([True if (a[i] <= j+1) and (j+1 < b[i]) else False for j in range(N-1) ])

    S = [bool_list]
    counter = 0
    while S:
        C1 = S.pop()
        C2 = []
        l1 = C1.pop(0)
        for l2 in C1:
            l3 = l1 and l2
            l3 = [l1[i] and l2[i] for i in range(len(l1))]
            if sum(l3) == 0:
                # 積が「すべてFalseになった場合」は別のループを回す
                C2.append(l2)
            else:
                l1 = l3
        if C2:
            # 別のループを回すためにSにpush
            S.append(C2)
        counter += 1
    return counter

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
# x = input()
# print(x[-1]+x[:-1])
# y = x[-1]+x[:-1]
# print(y[-1]+y[:-1])

count=0

def check():
	count=0
	for i in range(len(a[0])):
		if(a[0][i]!=a[1][i]):
			break
		if(i==int(len(a[0])-1)):
			count=1
			print("Yes")
	return count


def change():
	b=[]
	for i in range(len(a[0])-1):
		b.append(a[1][i+1])
	b.append(a[1][0])

	a[1]=b


###変数を得る
a = []
for i in range(2):
    a.append(input())



check()

if(count==0):
	for i in range(len(a[0])-1):
		change()
		count=check()

		if(count==1):
			break

if(count==0):
	print("No")

Submission status: Runtime Error

Solution code:
from statistics import median

task=[0,0,0]

for i in range(3):
    a=input()
    task[i]=int(a)
    
b=median(task)
sum=0

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

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
S.sort()
T.sort()
if S == T:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
N = map(int,input().split())
sort(N)
int ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input().split())
N1 = sort(N)
int ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
list N =[]
N = int(input().split(","))
N1 = sort(N)
int ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
list N =[]
N = int(input().split())
N1 = []
N1 = sort(N)
int ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
list N =[]
N = int(input().split())
N1 = sort(N)
int ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
s_i = [int(s_v) for s_v in input().split()]
sum_cost = abs(s_i[1] - s_i[2])
a = abs(s_i[0] - s_i[1])
b = abs(s_i[0] - s_i[2])
if(a >= b):
	sum_cost += b
else:
	sum_cost += c
print(sum_cost)

Submission status: Runtime Error

Solution code:
class Queue:
    def __init__(self):
        self.items = []

    def enqueue(self, item):
        self.items.insert(0, item)

    def dequeue(self):
        return self.items.pop()

    def size(self):
        return len(self.items)

    def self(self):
        return self.items

s = raw_input()
t = raw_input()
q = Queue()

j = 0
S = list(s)
L = len(s)
while j < L :
    q.enqueue(S[L - (j + 1)])
    j += 1

flag = False
i = 0
while i < q.size():
    x = q.dequeue()
    q.enqueue(x)
    if (list(t) == q.self()):
        flag = True
        break
    i += 1

if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
a=list(map(int,input().split()))
b=[]
c=[1]*(a[0]-1)
for i in range(a[1]):
  b.append(list(map(int,input().split())))
b=sorted(b,key=lambda b:b[1])
for i in range(a[1]):
  if i!=0 and b[i-1][0]>=b[i][0]:
    continue
  if 0 in c[(b[i][0]-1):b[i][1]]:
    continue
  else:
    c[(b[i][1])-2]=0

print(c.count(0))

Submission status: Runtime Error

Solution code:
list = []
cost = 0
for i in range(3):
    list.append(int(input("")))

for i in range(3):
    for j in range(i+1,3):
        if list[j] > list[i]:
            tmp = list[i]
            list[i] = list[j]
            list[j] = tmp

for i in range(3):
    if i != 0:
        cost += abs((list[i] - list[i-1]))

print(cost)

Submission status: Runtime Error

Solution code:
moji_S=input()
moji_T=input()

flag=0
for i in range(len(moji_S)):
	if moji_S==moji_T:
		flag =1
		break
	moji_S=moji_S[-1]+moji_S[0:-1]
if flag:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

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

print(num.max - num.min)

Submission status: Runtime Error

Solution code:
import functools
import fractions

N = int(input())
numbers = list(map(int, input().split()))

max_under_lcm = functools.reduce(lambda x, y: int((x * y) / fractions.gcd(x,y)), numbers) - 1
answer = sum([max_under_lcm % n for n in numbers])

print(answer)

Submission status: Runtime Error

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

import functools

N = input()
numbers = list(map(int, input().split()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a if a > 0 else 1

max_under_lcm = functools.reduce(lambda x, y: int((x * y) / gcd(x,y)), numbers) - 1
answer = sum([ max_under_lcm % n for n in numbers])

print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    n = [int(i) for i in input().split()]
    bridge = set()
    counter = 0
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[0],x[1]))
    
    preset = 0
    for i in range(1, n[0]+1):
        if i in bridge:
            bridge = []
            counter += 1
        for j in range(preset, len(reqs)):
            if reqs[j][0] == i:
                bridge.add(reqs[j][1])
            else:
                preset = j
                break
    
    print(counter)

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
arr = map(int,raw_input().split())
print sum(arr)-n

Submission status: Runtime Error

Solution code:
n = int(input())

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

max_mod = 0
for i in range(1, max(arr)):

    cur_mod = 0
    for a in arr:
        cur_mod += i % a

    max_mod = max(max_mod, cur_mod)

print(max_mod)

Submission status: Runtime Error

Solution code:
def main():
    n = [int(i) for i in input().split()]
    bridge = [0 for i in range(n[0]-1)]
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[1]-x[0]))

    for req in reqs:
        if 1 not in bridge[req[0]-1:req[1]-1]:
            bridge[req[1] - 2] = 1
    print(bridge.count(1))

main()

Submission status: Runtime Error

Solution code:
str1 = input()
str2 = input()

if str1 == str2:
    print('Yes')

for i in range(len(str1) - 1):

    str1 = str1[-1] + str1[:-1]

    if str1 == str2:
        print('Yes')
        break

if str1 != str2:
    print('No')

Submission status: Runtime Error

Solution code:
str1 = input()
str2 = input()

if str1 == str2:
    print('Yes')

for i in range(len(str1) - 1):
    
    str1 = str1[-1] + str1[:-1]
    
    if str1 == str2:
        print('Yes')

print('No')

Submission status: Runtime Error

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)
'''
S = input()
T = input()
f=0
for i in range(len(S)+1):
    if S == T:
        f=1
    S = (S[-1]+S)[:-1]
    
if f==0:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

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)
'''
S = input()
T = input()
f=0
for i in range(len(S)+1):
    if S == T:
        print('Yes')
        f=1
        break
    S = (S[-1]+S)[:-1]
if f==0:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ab=sorted([list(map(int,input().split())) for _ in range(m)],key=lambda x:x[1])
x=l=0
for(a,b)in ab:
   if a>x:x=b-1;l+=1
print(l)

Submission status: Runtime Error

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([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: Runtime Error

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 = aint([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: Runtime Error

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

if int(a[0])<=int(a[1]) and int(a[0])<=int(a[2]):
  min = 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 = a[1]
  if int(a[0])<=int(a[2]):
    max = int(a[2])
  ele:
    max = int(a[0])
else:
  min = a[2]
  if int(a[0])<=int(a[1]):
    max = int(a[1])
  ele:
    max = int(a[0])

print(max-min)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input()
a=list(map(int,input().split(' ')))
sum=0
for i in a:
    sum+=i-1
print(sum)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
n, m = map(int, input().split())
demands = [
    tuple(map(int,
              line.strip().split())) for line in sys.stdin.readlines()
]
demands.sort(key=lambda demand: demand[1])

bridge = -1
cnt = 0
for ai, bi in demands:

    if ai <= bridge:
        continue

    else:
        bridge = bi - 1
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
L = [int(i) for i in input().split()]
print(sum(L - N) )

Submission status: Runtime Error

Solution code:
s=input()
t=input();
i=0
h=0
while i<=len(s):
    if (s[i+1:]+s[0:i+1]==t):
        h=1
        break
    i+=1
if h:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

def f(m, input):
  r = 0
  for i in input:
    r += m % i
  return r

N = map(int, input())
a_n = list(map(int, input().split(" ")))
a_n = sorted(a_n)

max = 0
for x in a_n:
  max += x
 
# result = []
# for m in range(max):
  # out = f(m, a_n)
  # result.append(out)
# re = sorted(result)
#print(re[-1])
#print(max) #994 518 941 851 647 2 581 -> 4534
print(max - len(a_n))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
requests = []
for _ in range(M):
        a,b = map(int,input().split())
        requests.append([a,b])

ans = 1
requests = sorted(requests, key=lambda x:(x[1],x[0]))
b = min(requests, key=lambda x:x[1])[1]
for i in range(M):
        if requests[i][0] < b:
                continue
        else:
                ans += 1
                b = min(requests[i:], key=lambda x:x[1])[1]

print(ans)

Submission status: Runtime Error

Solution code:
a = input()
b = input()
c = len(a)
a_list = list(a)
b_list = list(b)
for i in range(101):
  tmp = a_list[0]
  for j in range(c-1):
    a_list[j] = a_list[j+1]
  a_list[c-1] = tmp
  if a_list == b_list:
    print("Yes")
    exit()
print("No")

Submission status: Runtime Error

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: Runtime Error

Solution code:
a, b, c = map(int, input().split())
A = []
A.append(a)
A.append(b)
A.append(c)
A = A.sort()
sum = 0
for i in range(4):
	sum += int(A[i]) - int(A[i-1])
print(sum)

Submission status: Runtime Error

Solution code:
class Need(object):
    def __init__(self,arg1,arg2):
        self.island1=int(arg1)
        self.island2=int(arg2)
        self.bridge=[]
        for i in range(arg1,arg2):
            self.bridge.append(i)
    def GETbridge(self):
        return self.bridge
deadbridges=0
islands,needsnum=map(int,input().split())
bridge=[0 for _ in range(islands-1)]
box = []
for i in range(needsnum):
    arg1,arg2=map(int,input().split())
    box.append(Need(arg1,arg2))
#ここから投票をする。
while(len(box)!=1):
    bridge = [0 for _ in range(islands - 1)]
    for need in box:
        list=need.GETbridge()
        for ing in list:
            bridge[ing-1]=bridge[ing-1]+1
    #集計終わり
    maxi=0
    for i in range(len(bridge)):
        if(bridge[i]>bridge[maxi]):
            maxi=i
    #橋を削除
    deadbridges=deadbridges+1
    #要望を削除
    kill=False
    for i in range(len(box)):
        try:
            s=box[i].GETbridge()
        except:
            break
        for k in s:
            if(k==bridge[maxi]):
                kill=True
                break
        if(kill):
            box.pop(i)
            i=i-1
print(deadbridges)

Submission status: Runtime Error

Solution code:
n = input().split(" ")

a = abs((int(n[1])-int(n[0]))+abs((int(n[2])-int(n[1]))
b = abs((int(n[2])-int(n[0]))+abs((int(n[1])-int(n[2]))
c = abs((int(n[2])-int(n[1]))+abs((int(n[0])-int(n[2]))
d = abs((int(n[0])-int(n[1]))+abs((int(n[2])-int(n[0]))
e = abs((int(n[1])-int(n[2]))+abs((int(n[0])-int(n[1]))
f = abs((int(n[0])-int(n[2]))+abs((int(n[1])-int(n[0]))

w = min(a,b,c,d,e,f)

print(w)

Submission status: Runtime Error

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

for i in range(1,N):
	sum += A[i]-A[i-1]
print(sum)

Submission status: Runtime Error

Solution code:
import itertools

    IP  = input()
    
    A1 = int(IP[0])
    A2 = int(IP[2])
    A3 = int(IP[4])
    
    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: Runtime Error

Solution code:
a = list(map(int,input().split()))
b = [0]*a[0]
 
for i in range(a[1]):
	m,n = map(int,input().split())
 
	b[m-1] += 1
	b[n-1] -= 1
ma = b[0]
for i in range(1,a[0]):
	b[i] += b[i-1]
	if b[i] >= ma:
		ma = b[i]
		k = i
 
print(a[1] - ma+1)

Submission status: Runtime Error

Solution code:

def B():
    s1 = input()
    s2 = input()
    
    YES = 'Yes'
    NO = 'No'
    
    result = NO
    for i in range(len(s1)):
        p = s1[i:] + s1[:i]
        if(p in s2):
            result = YES
    
    print(result)

if __name__ =='__main__':
    B()

Submission status: Runtime Error

Solution code:
import itertools

    vec =  input()
    
    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: Runtime Error

Solution code:
headData = [int(n) for n in input().split()]
islandNum = headData[0]
requestNum = headData[1]
requestList = []
count = 0
for n in range(requestNum):
    request = [int(elem) for elem in input().split()]
    requestList.append(request)


while (len(requestList) != 0):
    print(count)
    # 優先度チェック
    bridgePriority = islandNum * [0]
    for request in requestList:
        for j in range(request[0], request[1]):
            bridgePriority[j] += 1
    deleteBridgeList = []

    print(max(bridgePriority))
    # 優先度が最も高い橋を特定
    for index in range(len(bridgePriority)):
        if (bridgePriority[index] == max(bridgePriority)):
            deleteBridgeList.append(index)

    print(deleteBridgeList)
    # 橋を削除した場合、叶っていないリクエストリストを作成
    newRequestList = []
    for request in requestList:
        for bridge in deleteBridgeList:
            isUnsolvedBridge = True
            if (request[0]<=bridge and bridge<request[1]):
                isUnsolvedBridge=False
                break
        if isUnsolvedBridge:
            newRequestList.append(request)
    requestList = newRequestList
    print(requestList)
    count += len(deleteBridgeList)

print(count)

Submission status: Runtime Error

Solution code:
import itertools


    
    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: Runtime Error

Solution code:
import numpy as np
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
MAX = np.abs(np.prod(a))
#print (MAX)
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
n = a[0]*q+a[0]-1
while True:
    st = np.sum(n%a)
    if sum < st:
        sum = st
    if sum == max:
        break
    ind = np.where(a - n%a == 1)[0]
    #print (ind)
    c = a[ind]
    n += np.prod(c)
    if n > MAX:
        break
    #print (sum)
print (sum)

Submission status: Runtime Error

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    a_0 = numbers.pop()
    for i in numbers:
        a_0 = lcm_base(a_0, i)
    return a_0

b = a.copy()
m = lcm_list(b)-1
sum = 0
for j in a:
    sum += m%j

print(sum)

Submission status: Runtime Error

Solution code:
import itertools


def solve(A1,A2,A3):
    
    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)
    
    return res

res = solve(A1,A2,A3)
print(res)

Submission status: Runtime Error

Solution code:
import math
import functools


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

def lcm_list(*numbers):
    return functools.reduce(lcm_base, numbers, 1)

def main() :
    n = int(input())
    a = list(map(int, input().split()))
    lcm = lcm_list(*a)

    ans = 0
    for aa in a :
        ans += (lcm-1) % aa

    print(ans)

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
参りました

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def A():
    a = input().split()
    try:
        for x in a:
            x = int(x)
    except:
        exit(1)
    a.sort()
    a.inverse()
    
    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: Runtime Error

Solution code:
import numpy

s = list(input())
t = input()

tmp = s[:]
for i in range(len(tmp)):
    tmp = numpy.roll(tmp, 1)
    if ''.join(tmp) == t:
        print('Yes')
        exit()
print('No')

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
mx =[0 for i in range(0,n)]
for z in range(0,m):
  a,b=map(int,input().split())
  mx[b-1]=max(mx[b-1],a-1)
cut=0
cn=0
for z in range(0,n):
  if cut<mx[z]:
   	cut=z
    cn=cn+1
print(cn)

Submission status: Runtime Error

Solution code:
import unittest

from app.ABC103_A import run


class TestSample(unittest.TestCase):
    def test_run(self):
        self.assertEqual(run([1, 6, 3]), 5)
        self.assertEqual(run([11, 5, 5]), 6)
        self.assertEqual(run([100, 100, 100]), 0)


if __name__ == '__main__':
    unittest.main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input_x = str(input())
input_y = str(input())
tmp = input_y
ary = list(input_y)
mongon = "Yes"
for c in input_x:
    idx = tmp.find(c)
    if idx == -1:
        mongon = "No"
        break
    else:
        ary.pop(idx)
        tmp = "".join(ary)


print(mongon)

Submission status: Runtime Error

Solution code:
s = "11 5 5"
list = list(map(int, input().split()))

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

A = map(int, sys.argv[1::])
A.sort()
print(A[2] - A[1] + A[1] - A[0])

Submission status: Runtime Error

Solution code:
s = "11 5 5"
list = list(map(int, input().split()))

a = abs(list[1]-list[0])
b = abs(list[1]-list[2])
c = abs(list[2]-list[0])
l = a+b
m = b + c
n = a+c
if (l < m):
	if (l < n)
		print(l)
	else :
		print(n)
else :
	if (m < n)
		print(m)
	else :
		print(n)

Submission status: Runtime Error

Solution code:
a=input()
b=input()
for i in range(0,len(a)):
  if a==b[i:]+b[:i] : 
    print("Yes")
    exit(0)
print("No")

Submission status: Runtime Error

Solution code:
inp = [input() for _ in range(2)]
s = inp[0]
t = inp[1]

s = list(s)
t = list(t)
check = []
for i in t:
    if i in s:
        s[s.index(i)] = 0
    check.append(0)

if s == check:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import sys

args = sys.argv
l = []

for i in range(0,3):
    l.append(int(args[i+1]))
l.sort()
print(abs(l[0]-l[1]) + abs(l[1]-l[2]))

Submission status: Runtime Error

Solution code:
s = input()
t = input()
ans=0
for i in range(0,len(s)):
    a=s[i:]
    b=s[:i]
    ss=a+b
    print(ss)
    if ss == t:
        ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
a=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: Runtime Error

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

Submission status: Runtime Error

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

k = max(abs(a[0]-a[1]),abs(a[1]-a[2]),abs(a[2]-a[1]))

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

print(x.max() - x.min())