Problem:


Score : 200 points

Problem Statement

AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.
If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:

AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.
Find the minimum distance it needs to be moved.

Constraints

All input values are integers.

1≤W≤10^5

1≤a,b≤10^5

Input

The input is given from Standard Input in the following format:

W a b

Output

Print the minimum distance the second rectangle needs to be moved.

Sample Input 1

3 2 6

Sample Output 1

1

This input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.

Sample Input 2

3 1 3

Sample Output 2

0

The rectangles are already connected, and thus no move is needed.

Sample Input 3

5 10 1

Sample Output 3

4



Sample input:
3 2 6


Sample output:
1

Submission status: Accepted

Solution code:
str = input().rstrip().split(" ")
W = int(str[0])
a = int(str[1])
b = int(str[2])
x = 0

if a < b:
        x = b - (a + W)
elif a > b:
        x = a - (b + W)

if a == b or x < 0:
        print("0")
else:
        print(x)

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()



def main():
    w,a,b = LI()
    if b < a:
        a,b = b,a
    return max(b-a-w,0)

print(main())

Submission status: Accepted

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

if b+W<a:
    an = a-b-W
elif b+W>=a and b<=a+W:
    an = 0
elif b>a+W:
    an = b-a-W

print(an)

Submission status: Accepted

Solution code:
import math
w, a, b = map(int, input().split())
if a+w < b:
    print(int(math.fabs(b-a-w)))
elif b+w < a:
    print(int(math.fabs(b+w-a)))
else:
    print(int(0))

Submission status: Accepted

Solution code:
import math
w, a, b = [int(i) for i in input().split()]
if a+w < b:
    print(int(math.fabs(b-a-w)))
elif b+w < a:
    print(int(math.fabs(b+w-a)))
else:
    print(int(0))

Submission status: Accepted

Solution code:
#ABC056B

w,a,b=map(int,raw_input().split())
if abs(b-a)<=w:
 print 0
else:
 print abs(b-a)-w

Submission status: Accepted

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

if a < b:
    if (a+w) >= b:
        print 0
    else:
        print abs(b - (a+w))
if b < a:
    if (b+w) >= a:
        print 0
    else:
        print abs(a - (b+w))
if a == b:
    print 0

Submission status: Accepted

Solution code:
W, a, b = map(int, raw_input().split())
print max(abs(a-b)-W, 0)

Submission status: Accepted

Solution code:
w,a,b=map(int,input().split())
print(max(0, a-b-w if a > b else b-a-w))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
w, a, b = map(int, input().split())
if a <= b <= a + w:
    print(0)
else:
    print(min(abs(a - (b + w)), abs(b - (a + w))))

Submission status: Accepted

Solution code:
W, a, b = list(map(int, input().split()))
if a > b: a, b = b, a
ans = max(0, b-(a+W))
print(ans)

Submission status: Accepted

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

if a > b:
    a, b = b, a
print max(b - a - W, 0)

Submission status: Accepted

Solution code:
w, a, b = map(int, input().split())
d = abs(a-b)-w
print(max(d,0))

Submission status: Accepted

Solution code:
W, a, b = map(int,input().split())
if a<b:
    if a+W>=b:
        print(0)
    else:
        print(b-(a+W))
else:
    if b+W>=a:
        print(0)
    else:
        print(a-(b+W))

Submission status: Accepted

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

if a < b:
    print max(0, b - (a + W))
else:
    print max(0, a - (b + W))

Submission status: Accepted

Solution code:
i = map(int, raw_input().split(" "))
l = abs(i[1] - i[2]) - i[0]
print( l if (l > 0) else 0)

Submission status: Accepted

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

if a < b:
    res = b - (a + w)
else:
    res = a - (b + w)

if res < 0:
    print('0')
else:
    print(res)

Submission status: Accepted

Solution code:
w, a, b = map(int, input().split())
if b+w < a:
    print(-b-w+a)
elif b > a+w:
    print(b-w-a)
else:
    print(0)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
W,a,b = map(int, raw_input().split())


if(b+W<a):
    print(a-b-W)
elif(b<=a and a<=b+W):
    print('0')
elif(a<=b and b<=a+W):
    print('0')
elif(a+W<b):
    print(b-a-W)

Submission status: Accepted

Solution code:
W, a, b = map(int, input().split())
print(max(0, abs(b-a) - W))

Submission status: Accepted

Solution code:
w, a, b = list(map(int,input().split(" ")))
if b < a:
    a, b = b, a
s = b - a - w
if s < 0:
    print(0)
else:
    print(s)

Submission status: Accepted

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

if a+W >= b and a <= b+W:
	print 0
else:
	print min(abs(b-(a+W)), abs(a-(b+W)))

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
w,a,b = map(int,input().split())

if a<=b:
    print(max(b-(a+w),0))
else:
    print(max(a-(b+w),0))

Submission status: Accepted

Solution code:
# coding: utf-8

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

if data[1] <= data[2]:
    if data[2] <= data[1] + data[0]:
        print 0
    else :
        print data[2] - (data[1] + data[0])
else:
    if data[1] > data[2]:
        if data[2] + data[0] >= data[1]:
            print 0
        else:
            print data[1] - (data[2] + data[0])

Submission status: Accepted

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

w=int(L[0])
a=int(L[1])
b=int(L[2])

if a<b:
    if a+w<b:
        move=abs(a+w-b)
        print(move)
    else:
        print(int(0))

elif a>b:
    if b+w<a:
        m=abs(b+w-a)
        print(m)
    else:
        print(int(0))

else:
    print(int(0))

Submission status: Accepted

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

for i in range(len(l)):
    l[i] = int(l[i])

w = l[0]    
a = l[1]
b = l[2]

if a + w < b:
    print(b - a - w)
elif b + w < a:
    print(a - b - w)
else:
    print(0)

Submission status: Accepted

Solution code:
a, b, c=map(int,input().split())
if(b<c):
	k=c-b-a
	if(k<=0):
		print(0)
	else:
		print(k)
else:
	k=b-a-c
	if(k<=0):
		print(0)
	else:
		print(k)

Submission status: Accepted

Solution code:
def main():
    W, a, b = map(int, input().split())

    if a > b:
        a, b = b, a
    if b - a <= W:
        print('0')
    else:
        l = b - (a + W)
        print(str(l))

main()

Submission status: Accepted

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

if abs(a - b) < w:
    print(0)
elif a < b:
    print(b - a - w)
else:
    print(a - b - w)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    w, a, b = map(int, input().split())
    
    if b + w < a: 
        print(a - b - w)
    elif a <= b + w <= a + w or a <= b <= a + w: 
        print(0)
    else: 
        print(b - a - w)

Submission status: Accepted

Solution code:


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

if a < b:
    ans = b - (a + W)
    if ans < 0:
        print(0)
    else:
        print(ans)

else:
    ans = a - (b + W)
    if ans < 0:
        print(0)
    else:
        print(ans)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
W, a, b = map(int, input().split())
a2 = a+W
b2 = b+W
if a2 < b:
    print(b - a2)
elif b2 < a:
    print(a - b2)
else:
    print(0)

Submission status: Accepted

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

if a-W <= b <= a+W:
 print(0)
elif b < a-W:
 print(a-W-b)
else:
 print(b-(a+W))

Submission status: Accepted

Solution code:
lines = input().split()
W = int(lines[0])
a = int(lines[1])
b = int(lines[2])
shortest = b-(a+W)
s2 = a-(b+W)
if shortest >= 0 :
    print(shortest)
elif shortest <= 0 and s2>=0:
    print(s2)
else:
    print("0")

Submission status: Accepted

Solution code:
import math
W, a, b =  map(int, input().split())
c = math.fabs(a - b)
if c > W:
    print(int(c - W))
else:
    print(0)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
Inp = map(int, raw_input().split())
a = min(Inp[1], Inp[2])
b = max(Inp[1], Inp[2])
l = b - (a + Inp[0])
l = max(0, l)
print(str(l))

Submission status: Accepted

Solution code:
import sys

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def nal(): return list(map(int, stdin.readline().split()))
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())

w, a, b = na()

if((abs(b - a) <= w)):
    print(0)
elif(a < b):
    print(b-(a+w))
else:
    print(a-(b+w))

Submission status: Accepted

Solution code:
#coding:utf-8
# x=int(raw_input())  # 1 # 一つの数字のみ
w, a, b =map(int,raw_input().split())  # 2 3  # 二つの数字
if a ==b:
    print 0
elif a < b:
    if a + w >= b:
        print 0
    else:
        print b-(a+w)
elif a >b:
    if b + w >= a:
        print 0
    else:
        print a-(b+w)




# print x,y,z

Submission status: Accepted

Solution code:
w,a,b = map(int,input().split())
if a+w>=b:
    if a<=b+w:
        print(0)
    elif a>=b+w:
        print(a-b-w)
elif a+w<=b:
    print(b-a-w)

Submission status: Accepted

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

a, b, c = map(int, raw_input().split())
result = 0

if b > c:
    t = b
    b = c
    c = t
if a+b >= c:
    result = 0
else:
    result = c - a - b

# 出力
print result

Submission status: Accepted

Solution code:
W, a, b = map(int, raw_input().split())
if b >= a and b <= a + W:
    print 0
elif b > a + W:
    print b - (a + W)
else:
    print a - (b + W)

Submission status: Accepted

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

if a  + w < b:
    print(b - a - w)
elif b + w < a:
    print(a - b - w)
else:
    print(0)

Submission status: Accepted

Solution code:
W, a, b = map(int, input().split())
r = min(a,b)
l = max(a,b)
print(0 if (r+W)>=l else l-(r+W))

Submission status: Accepted

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

if b >= a:
    res = b - (a + W)
else:
    res = a - (b + W)

print(max(0, res))

Submission status: Accepted

Solution code:
input_lines = str(input())

W = int(input_lines.split(' ')[0])
a = int(input_lines.split(' ')[1])
b = int(input_lines.split(' ')[2])

if a < b:

    saidai = a + W

    if saidai >= b:
        print('0')
    else:
        print(b - saidai)

elif a > b:

    saidai = b + W

    if saidai >= a:
        print('0')
    else:
        print(a - saidai)

else:
    print('0')

Submission status: Accepted

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

l = a
r = b
if a > b:
    r = a
    l = b

diff = r - (l + W)
if diff < 0:
    diff = 0
print diff

Submission status: Accepted

Solution code:
w, a, b = map(int, input().split())
ans = max(b - a - w, a - b - w)
print(ans if ans > 0 else 0)

Submission status: Accepted

Solution code:
import sys

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

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func()
    top_str = input_raw.strip().split()
    [W, a, b] = [int(top_str[0]), int(top_str[1]), int(top_str[2])]
    if a < b:
        rect1_s = a
        rect1_e = a + W
        rect2_s = b
        rect2_e = b + W
    else:
        rect1_s = b
        rect1_e = b + W
        rect2_s = a
        rect2_e = a + W

    print max(0, rect2_s - rect1_e)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
data = input().split()
W = int(data[0])
a = int(data[1])
b = int(data[2])

if(a < b):
	if(b <= a+W):
		print("0")
	else:
		print(b-(a+W))
else:
	if(a <= b+W):
		print("0")
	else:
		print(a-(b+W))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
W,a,b = map(int,input().split())
if a > b:
    temp = b
    b = a
    a = temp
if a+W>=b:
    print(0)
else:
    print(b-(a+W))

Submission status: Accepted

Solution code:
W, a, b = (int(i) for i in input().strip().split())
if a + W < b:
    print(b - a - W)
elif a > b + W:
    print(a - b - W)
else:
    print(0)

Submission status: Accepted

Solution code:
line = raw_input().split(" ")
w = int(line[0])
a = int(line[1])
b = int(line[2])

aw = a + w
bw = b + w
if bw < a:
    print a - bw
elif bw >= a and bw <= aw:
    print 0
elif bw > aw:
    if b > aw:
        print b - aw
    else:
        print 0

Submission status: Accepted

Solution code:
W,a,b=map(int,input().split())
if b >= a+W:
    print(b-a-W)
elif a>= b+W:
    print(a-b-W)
else:
    print(0)

Submission status: Accepted

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


if a<=b:
    if W+a<b:
        print(b-(W+a))
    else:
        print(0)
else :
    if b+W<a:
        print(a-(W+b))
    else:
        print(0)

Submission status: Accepted

Solution code:
def main():
    w, a, b = map(int, input().split())
    if not (a + w < b or b + w < a):
        print(0)
    else:
        print(min(abs(a + w - b), abs(b + w - a)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    W, a, b = map(int, input().split())

    res = 0
    if a + W < b:
        res = b-(a+W)
    elif b + W < a:
        res = a-(b+W)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
inputs = input().split()
W = int(inputs[0])
a = int(inputs[1])
b = int(inputs[2])

if abs(a - b) <= W:
    print(0)
else:
    print(abs(a - b) - W)

Submission status: Accepted

Solution code:
W, a, b = map(int, input().split())
minimum = min(a,b)
maximum = max(a,b)
if maximum - (minimum + W) < 0:
    print(0)
else:
    print(maximum - (minimum + W))

Submission status: Accepted

Solution code:
W, a, b = map(int, input().strip().split())
l, r = a + W, b + W
if a <= b:
	diff = b - l
	if diff > 0:
		print(diff)
	else:
		print(0)
else:
	diff = a - r
	if diff > 0:
		print(diff)
	else:
		print(0)

Submission status: Accepted

Solution code:
W,a,b = map(int,input().split())
c = abs(b - a) - W
if c < 0:
	c = 0

print(c)

Submission status: Accepted

Solution code:
w,a,b = map(int,input().split())
d = abs(b-a)-w
if d >0:
    print(d)
else: 
    print(0)

Submission status: Accepted

Solution code:
W, a, b = map(int, input().split())
diff = abs(a-b)
print(max(0, diff-W))

Submission status: Accepted

Solution code:
w,a,b = map(int, input().split())
if a>b: a,b = b,a
ans = max(0,b-(a+w))
print(ans)

Submission status: Runtime Error

Solution code:
W,a,b=map(int,input().split())
if b>a:
  	if b-(a+W)==0:
  	print(0)
  	exit()
	print(b-(a+W))
else:
  if a-(b+W)==0:
  	print(0)
  	exit()
	print(a-(b+W))

Submission status: Runtime Error

Solution code:
W,a,b=map(int,input())
print(max(max(a,b)-W-min(a,b),0))

Submission status: Runtime Error

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

if (a <= b <= a+W) or (a <= b+W <= a+W) or :
    print(0)
else:
    if a+W < b:
        print(abs(b-(a+W)))
    elif b+W < a:
        print(abs(a-(b+W)))

Submission status: Runtime Error

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

if a+W<b:
  print(b-(W+a)):
else:
  print(0)

Submission status: Runtime Error

Solution code:
w,a,b=map(int,input().split())
if a+w<b:
    print(b-a-w)
else:
  if a<=b+w and a+w>=b:
    print(0)
else:
    print(a-b-w)

Submission status: Runtime Error

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

if b + w < a:
    print(a - (b + w))
elif a <= b + w <= a + w:
    print(0):
elif a <= b <= a + w:
    print(0)
elif a + w < b:
    print(b- (a + w))

Submission status: Runtime Error

Solution code:
W,a,b = [int(i) for i input().split()]
if a <= b and b <= a + W:
  print(0)
else:
  print(min(b+W-a,b-a-W))

Submission status: Runtime Error

Solution code:
w,a,b = map(int,input().split())
if w+a => b:
  print(0)
else:
	print(b-(a+w))

Submission status: Runtime Error

Solution code:
w,a,b = map(int,input().split())
print(b-(a+W))

Submission status: Runtime Error

Solution code:
W, a, b = map(int, input().split())
if a <= b <= a + W or a <= b + W <= a + W:
  prin(0)
  quit()

print(abs(a+W - b), abs(b+w - a))

Submission status: Runtime Error

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

if a <= b and b <= a + w:
    print(0)
elif a <= b + w and b + w <= a + w
elif b+w < a:
    print(a - (b+w))
elif a+w < b:
    print(b - (a+w))

Submission status: Runtime Error

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

if b > a + w:
    print(b - a - w)
elif b + w < a:
    print(a - b - w)
else:
    print(0)
w, a, b = map(int, input().split())

if b > a + w:
    print(b - a - w)
elif b + w < a:
    print(a - b - w)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import numpy as np

def main():

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

  su = np.sum(A)
  av = su // N
  if su % N != 0:
    print(-1)
    return

  ans = N - 1
  b = 0
  c = 0

  for a in A[0: -1]:
    b += a
    c += 1
    if b == (c * av):
      ans -= 1
      b = 0
      c = 0

  print(ans)

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
w,a,b=map(str,input().split())
if (w+a)<b:
  print(b-w-a)
else:
  print(0)

Submission status: Runtime Error

Solution code:
W, a, b = map(int,input().split())
if abs(a - b) <= W:
    print(0)
else:
    print(min(abs(a - (b + W), abs(b - (a + W)))))

Submission status: Runtime Error

Solution code:
w, a, b = map(int,input())
ans = 0
if b+w < a:
    ans = a - (b+w)
if a+w < b:
    ans = b - (a+w)
print(ans)

Submission status: Runtime Error

Solution code:
,a,b=map(int,input().split())
if a<b:
    if b-(a+w) < 0:
        print(0)
    else:
        print(b-(a+w))
else:
    if a-(b+w) < 0:
        print(0)
    else:
        print(a-(b+w))

Submission status: Runtime Error

Solution code:
W, a, b = map(int,input().split())
 
if a+W<=b:
  print(b-(a+W))
elif (a<= b)and (b<(a+W)):
  print(b-a)
elif ((a-W)<=b) and(b<a):
  print(a-b)
elif (b<(a-W):
  print(a-(b+W))

Submission status: Runtime Error

Solution code:
import math
W,a,b = map(int,input().split())
print(max(abs(a-b)-W),0)

Submission status: Runtime Error

Solution code:
W,a,b = map(int,input().split())
print(max(abs(a-b)-W),0)

Submission status: Runtime Error

Solution code:
W,a,b = map(int,input())
if a <= b <= a+W or a<= b+W <= a+W:
    print(0)
elif a+W < b:
    print(b-(a+W))
elif b+W <a:
    print(a-(b+W))

Submission status: Runtime Error

Solution code:
W,a,b = [int(i) for i in input().split()]
ans = 0
if a <= b <= a+w or b <= a <= b+w:
  print(ans)
else:
  ans = min(abs(b-a-w),abs(a-b-w))
  print(ans)

Submission status: Runtime Error

Solution code:
w=input()
a=input()
b=input()
if a > b:
    t=a
    a=b
    b=t
l1=a
r1=a+w
l2=b
r2=b+w
if l1 >= r2:
    print "0"
else:
    print l2 - r1;

Submission status: Runtime Error

Solution code:
w=int(input())
a=int(input())
b=int(input())
if a > b:
    t=a
    a=b
    b=t
l1=a
r1=a+w
l2=b
r2=b+w
if l1 >= r2:
    print "0"
else:
    print l2 - r1;

Submission status: Runtime Error

Solution code:
w=int(input())
a=int(input())
b=int(input())
if a > b:
    t=a
    a=b
    b=t
l1=a
r1=a+w
l2=b
r2=b+w
if l1 >= r2:
    print 0
else:
    print l2 - r1;

Submission status: Runtime Error

Solution code:
w=int(input())
a=int(input())
b=int(input())

Submission status: Runtime Error

Solution code:
w=int(input())
a=int(input())
b=int(input())
if a > b:
    t=a
    a=b
    b=t

Submission status: Runtime Error

Solution code:
w=int(input())
a=int(input())
b=int(input())
if a > b:
    t=a
    a=b
    b=t
l1=a
r1=a+w
l2=b
r2=b+w

Submission status: Runtime Error

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

if a < b:
  if b-(a+w) >0:
    print(b-(a+w))
  else:
    print(0)
    
elif a==b:
  print(0)
  
eif a>b:
  if a-(b+w) >0:
    print(a-(b+w))
  else:
    print(0)

Submission status: Runtime Error

Solution code:
W,a,b=map(int,input().split())
print(min(abs(a-b)-w,0))

Submission status: Runtime Error

Solution code:
w, a, b = map(int, input().split())
ans = 0
if a < b:
  if a+w > b:
    ans = 0
  else:
    ans = b - a+w
else if a == b:
  ans = 0

else:
  if b+w > a:
    ans = 0
  else:
    ans = a - b+w

print(ans)

Submission status: Runtime Error

Solution code:
from collections import deque
def bfs():
    Q = deque()
    Q.append(0)
    #今の時刻
    i = 1
    while len(Q) > 0:
        x = Q.popleft()
        if x-i >= 0:
            T[i][x-i] = 1
            if x-i == X: return i
            Q.append(x-i)
        if 0 <= x and x <= X:
            T[i][x] = 1
            if x == X: return i
            Q.append(x)
        if x+i <= X:
            T[i][x+i] = 1
            if x+i == X: return i
            Q.append(x+i)
        i += 1

X = int(input())
INF = 10**9 +1
#時刻iで座標jに到着できるかどうか
T = [[0 for _ in range(X+1)] for _ in range(X**2)]
T[0][0] = 1
print(bfs())

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
def bfs():
    Q = deque()
    Q.append(0)
    #今の時刻
    i = 1
    while len(Q) > 0:
        x = Q.popleft()
        print(x)
        if x-i >= 0:
            T[i][x-i] = 1
            if x-i == X: return i
            Q.append(x-i)
        if 0 <= x and x <= X:
            T[i][x] = 1
            if x == X: return i
            Q.append(x)
        if x+i <= X:
            T[i][x+i] = 1
            if x+i == X: return i
            Q.append(x+i)
        i += 1

X = int(input())
INF = 10**9 +1
#時刻iで座標jに到着できるかどうか
T = [[0 for _ in range(X+1)] for _ in range(X**2)]
T[0][0] = 1
print(bfs())

Submission status: Runtime Error

Solution code:
from collections import deque

def bfs():
    Q = deque()
    Q.append(0)
    #今の時刻
    i = 1
    while len(Q) > 0:
        x = Q.popleft()
        print(x)
        if x-i >= 0:
            T[i][x-i] = 1
            if x-i == X: return i
            Q.append(x-i)
        if 0 <= x and x <= X:
            T[i][x] = 1
            if x == X: return i
            Q.append(x)
        if x+i <= X:
            T[i][x+i] = 1
            if x+i == X: return i
            Q.append(x+i)
        i += 1

X = int(input())
INF = 10**9 +1
#時刻iで座標jに到着できるかどうか
T = [[0 for _ in range(X+1)] for _ in range(X**2)]
T[0][0] = 1
print(bfs())

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;
int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    if (a > b)
        swap(a, b);

    cout << max(0, b - (a + w)) << endl;
}

Submission status: Runtime Error

Solution code:
W,a,b = map(int,input().split())
if((abs(b-a) < W):
    print(0)
else:
    ans = abs(b - a) - W
    print(ans)

Submission status: Runtime Error

Solution code:
w,a,b= map(int ,input().split())
if w>=a and b<=w+a:
    print(0)
elif a+w<=b:
    print(b-(a+w))
elif b+w<a:
    print(a(-b+w))

Submission status: Runtime Error

Solution code:
w,a,b= map(int ,input().split())
if w>=a and b<=w+a:
    print(0)
elif a+w<=b
    print(b-(a+w))
elif b+w<a:
    print(a(-b+w))

Submission status: Runtime Error

Solution code:
W,A,B = map(int,input().split())
if A <= B:
  a=A
  b=b
else:
  a=B
  b=A
print(b-a-W if a+W<b else int(0))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
W,a,b = map(int, input().split())
if (a<=b<=a+W):
    print(0)
elif (a=<b+W<=a+W):
    print(0)
elif a<=b:
    print(b-a-W)
else:
    print(a-b-W)

Submission status: Runtime Error

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

if a > b + W:
    print(a - (b + w))
elif b > a + W:
    print(b - (a + W))
else:
    print(0)

Submission status: Runtime Error

Solution code:
W_str=input()
a_str=input()
b_str=input()
W=int(W_str)
a=int(a_str)
b=int(b_str)
if a+W<b:
    print(b-(a+W))
elif b+W<a:
    print(a-(b+W))
else :
    print(0)

Submission status: Runtime Error

Solution code:
w,a,b=map(int,input().split())
print(max(abs(s-b)-w,0))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
W,a,b = map(int,input().split())
if b> a+W:
    print(b-a-W)
elif a>b+w:
    print(a-b-W)
else:
    print(0)

Submission status: Runtime Error

Solution code:
W,a,b = map(int,input().split())
start = max(a, b)
end = min(a+W, b+W)
print(max(start-end), 0)

Submission status: Runtime Error

Solution code:
w,a,b = map(int,input().split())
ma = max(a,b)
mi = min(a,b)
print(max(max-(mi+w),0))

Submission status: Runtime Error

Solution code:
W, a, b = map(int, input().split())
print(max(0, abs(A - B) - W))

Submission status: Runtime Error

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

if a=b:
  print(int(0))
elif a>b:
  if b+w>=a:
    print(int(0))
  else:
    print(int(a-b-w))
else:
   if a+w>=b:
    print(int(0))
   else:
    print(int(b-a-w))

Submission status: Runtime Error

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

if a=b:
  print(int(0))
elif a>b:
  if b+w>=a:
    print(int(0))
  else:
    print(int(a-b-w))
else:
   if a+w>=b:
    print(int(0))
  else:
    print(int(b-a-w))

Submission status: Runtime Error

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

if a=b:
  print(0)
elif a>b:
  if b+w>=a:
    print(0)
  else:
    print(int(a-b-w))
else:
   if a+w>=b:
    print(0)
  else:
    print(int(b-a-w))

Submission status: Runtime Error

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

if a+W = b:
  tmp = b-a-W
  if tmp <= 0:
    print(0)
  else:
    print(tmp)
elif a > b+W:
  tmp = a-W-b
  if tmp <= 0:
    print(0)
  else:
    print(tmp)
else:
  print(0)

Submission status: Runtime Error

Solution code:
w,a,b=map(int,input().split())
if a<=b<=(a+w) or b<=(a+w)<=(b+w):
  print(0)
elif (a+w)<b:
  print(b-(a+w))
else:
  print(abs(a-(b+w))

Submission status: Runtime Error

Solution code:
ans = 'No'
N, M = list(map(int, input().split()))
A = [input() for i in range(N)]
B = [input() for i in range(M)]

flag = False

for a in A:
    if not flag and B[0] in a:
        flag = True
        idx = 1
    elif flag and B[idx] in a:
        idx += 1
        if idx == M:
            ans = 'Yes'
            break
    else:
        flag = False
print(ans)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
if b+w<a:print(a-b-w)
else:print(max(0,b-a-w))

Submission status: Runtime Error

Solution code:
W,a,b=map(int,input().split(' '))
print(max(0,b-(a+W)) if a<=b else print(max(0,a-(b+W)))

Submission status: Runtime Error

Solution code:
w,a,b=map(int,input())
print(b-(a+w) if b>a else a-(b+w) if b<a else 0)

Submission status: Runtime Error

Solution code:
w, a, b = map(int, input().split())
if abs(a-b) <= w:
    print(0)
else:
    print(min(abs(b-a-w), abs(a-b-w))

Submission status: Runtime Error

Solution code:
w,a,b = [int(x) for x in input().split()]
print(b-w-(b-a+w)) if a+w =< b else print(0)

Submission status: Runtime Error

Solution code:
from sys import stdin


def main() -> int:
    global W
    W = next_int()
    a, b = map(int, input())

    if b + W < a:
        ans = diff(b + W, a)
    elif a + W < b:
        ans = diff(a + W, b)
    else:
        ans = 0

    print(ans)
    return 0


def diff(a: int, b: int) -> int:
    return abs(a - b)


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
print(-min(int(input())-abs(int(input())-int(input())),0))

Submission status: Runtime Error

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

if B >= A+W:
  print(abs(A+W-b))
elif B+W <= A:
  print(abs(B+W-A))
else:
  print(0)

Submission status: Runtime Error

Solution code:
W,a,b=map(int,input().split())
print(min(b-a,b-a+1-w))

Submission status: Runtime Error

Solution code:
W,a,b = input().split()

if b > a+W:
  print(b-(a+W))
elif b+W > a:
  print(a-(b+W))
else:
  print(0)

Submission status: Runtime Error

Solution code:
W, a, b = map(int, input().split())
print(max(min(abs(a - b - w), abs(a - b + w)), 0))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
w,a,b=map(int,input().split())
if a+w>=b and b+w>=a:
    print(0)
elif: a+w>b:
    print(a-b-w)
else:
    print(b-a-w)

Submission status: Runtime Error

Solution code:
a,b=map(str,input().split())
if (a==b):
 print ('H')
else:
 print ('D')

Submission status: Runtime Error

Solution code:
print min(abs(b-a-W), abs(b-a), abs(b+W-a), abs(b-a))

Submission status: Runtime Error

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

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

print(max(0, abs))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
w,a,b=map(int,input().split())
x,y=a+w,a-w
print(0 if x<b<y else min(abs(x-b,y-b)))

Submission status: Runtime Error

Solution code:
#include <stdio.h>
int main()
{
    int w,a,b,t;
    scanf("%d%d%d",&w,&a,&b);
    if(a>b)
    {
        t=a;
        a=b;
        b=t;
    }
    if(b>a+w)
        printf("%d",b-a-w);
    else
        printf("0");
    return 0;
}

Submission status: Runtime Error

Solution code:
#include <stdio.h>
int main()
{
    int w,a,b,i,t;
    scanf("%d%d%d",&w,&a,&b);
    if(a>b)
    {
        t=a;
        a=b;
        b=t;
    }
    if(b>a+w)
        printf("%d",b-a-w);
    else
        printf("0");
}

Submission status: Runtime Error

Solution code:
#include <stdio.h>
int main()
{
    int w,a,b,i,t;
    scanf("%d%d%d",&w,&a,&b);
    if(a>b)t=a,a=b,b=t;
    if(b>a+w)
        printf("%d",b-a-w);
    else
        printf("0");
}

Submission status: Runtime Error

Solution code:
w, a, b = [int(i) for i in input().split()]
if a+w < b:
    print(fabs(b-a-w))
elif b+w < a:
    print(fabs(b+w-a))
else:
    print(0)

Submission status: Runtime Error

Solution code:
w, a, b = [int(i) for i in input().split()]
if a+w < b:
    print(fabs(b-a-w))
elif b+w < a:
    print(fabs(b-a-w))
else:
    print(0)

Submission status: Runtime Error

Solution code:
w = int(input())
a = int(input())
b = int(input())

def main(w,a,b):
	if a+w >= b:
		return 0
	else:
    		return b-(a+w)

Submission status: Runtime Error

Solution code:
w = int(input())
a = int(input())
b = int(input())

def main(w,a,b):
	if a+w >= b:
		return 0
	else:
    		return b-(a+w)

print(main(w,a,b))

Submission status: Runtime Error

Solution code:
w = input()
a = input()
b = input()

return b-(a+w)

Submission status: Runtime Error

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

a=l[1]
b=l[2]

X=abs(a-b)
print(X)