Problem:


Score : 200 points

Problem Statement

Alice and Bob are controlling a robot. They each have one switch that controls the robot.

Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.

Bob started holding down his button C second after the start-up, and released his button D second after the start-up.

For how many seconds both Alice and Bob were holding down their buttons?

Constraints

0≤A<B≤100

0≤C<D≤100

All input values are integers.

Input

Input is given from Standard Input in the following format:  

A B C D

Output

Print the length of the duration (in seconds) in which both Alice and Bob were holding down their buttons.

Sample Input 1

0 75 25 100

Sample Output 1

50

Alice started holding down her button 0 second after the start-up of the robot, and released her button 75 second after the start-up.

Bob started holding down his button 25 second after the start-up, and released his button 100 second after the start-up.

Therefore, the time when both of them were holding down their buttons, is the 50 seconds from 25 seconds after the start-up to 75 seconds after the start-up.

Sample Input 2

0 33 66 99

Sample Output 2

0

Alice and Bob were not holding their buttons at the same time, so the answer is zero seconds.

Sample Input 3

10 90 20 80

Sample Output 3

60



Sample input:
0 75 25 100


Sample output:
50

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
if B <= C or D <= A:
    ans = 0
    print(ans)
elif (B > D and A < C) or (B < D and A > C):
    x = abs(A-B)
    y = abs(C-D)
    ans = min(x,y)
    print(ans)
elif(A > C and A < D) and (B > D):
    ans = D - A
    print(ans)
elif(A < C and A < D) and (B > C and B < D):
    ans = B - C
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,D = list(map(int,input().split()))
 
if B <= C or D <= A:
    print(0)
else :
    ans_tmp1 = abs(B - C)
    ans_tmp2 = abs(D - C)
    if ans_tmp1 >= ans_tmp2:
        print(ans_tmp2)
    else:
        print(ans_tmp1)

Submission status: Wrong Answer

Solution code:
A,B,C,D = list(map(int,input().split()))
 
if B <= C and D <= A:
    print(0)
else :
    ans_tmp1 = abs(B - C)
    ans_tmp2 = abs(D - C)
    if ans_tmp1 >= ans_tmp2:
        print(ans_tmp2)
    else:
        print(ans_tmp1)

Submission status: Wrong Answer

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

if B <= C :
    print(0)
else :
    ans_tmp1 = B - C
    ans_tmp2 = D - C
    if ans_tmp1 >= ans_tmp2:
        print(ans_tmp2)
    else:
        print(ans_tmp1)

Submission status: Wrong Answer

Solution code:
# Two Switches
A = list(map(int, input().split()))
time = 0
if A[0]>= A[1] or A[2]>= A[3]:
    time = 0
elif A[1] >= A[2] or A[3] >= A[0]:
    # Aliceが先に押した場合
    if A[1] >= A[3] >= A[2] >= A[0]:
        time = A[3] - A[2]
    elif A[3] >= A[1] >= A[2] >= A[0]:
        time = A[1] - A[2]
    # Bobが先に押した場合
    elif A[3] >= A[1] >= A[0] >= A[2]:
        time = A[1] - A[0]
    elif A[1] >= A[3] >= A[0] >= A[2]:
        time = A[3] - A[0]
else:
    time = 0

Submission status: Wrong Answer

Solution code:
# Two Switches
A = list(map(int, input().split()))
time = 0
if A[1] >= A[2] or A[3] >= A[0]:
    # Aliceが先に押した場合
    if A[1] >= A[3] >= A[2] >= A[0]:
        time = A[3] - A[2]
    elif A[3] >= A[1] >= A[2] >= A[0]:
        time = A[1] - A[2]
    # Bobが先に押した場合
    elif A[3] >= A[1] >= A[0] >= A[2]:
        time = A[1] - A[0]
    else:
        time = A[3] - A[0]
else:
    time = 0

print(time)

Submission status: Wrong Answer

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

time = 0
if A[1] >= A[2] or A[3] >= A[0]:
    # Aliceが先に押した場合
    if A[1] >= A[3] >= A[2] >= A[0]:
        time = A[3] - A[2]
    elif A[3] >= A[1] >= A[2]:
        time = A[1] - A[2]
    # Bobが先に押した場合
    elif A[3] >= A[1] >= A[0] >= A[2]:
        time = A[1] - A[0]
    else: 
        time = A[3] - A[0]
else:
    time = 0

print(time)

Submission status: Wrong Answer

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

time = 0
if A[1] > A[2] or A[0] > A[3]:
    # Aliceが先に押した場合
    if A[1] > A[3] > A[2] > A[0]:
        time = A[3] - A[2]
    elif A[2] < A[1] < A[3]:
        time = A[1] - A[2]
    # Bobが先に押した場合
    elif A[3] > A[1] > A[0] > A[2]:
        time = A[1] - A[0]
    else:
        time = A[3] - A[0]
else:
    time = 0

print(time)

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input().split())
m = max(a,c)
M = min(b,d)
if b <= c:
    print(0)
else:
    print(M-m)

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input().split())
m = max(a,c)
M = min(b,d)
if b < c:
    print(0)
else:
    print(M-m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if B < D:
    frst = B - C
else:
    frst = D - C
if frst <= 0:
    print(0)
else:
    print(frst)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input().split())
ans = 0
if c < b:
    if c < a and c > d:
        ans = b-c
    elif c > a and c > d:
        ans = d-c
    else:
        ans = d-a
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
if C < B:
  A, B, C, D = C, D, A, B
if B <= C:
  print(0)
else:
  print(min(B, D) - C)

Submission status: Wrong Answer

Solution code:
def solve():
    a, b, c, d = read()
    result = think(a, b, c, d)
    write(result)


def read():
    return read_int(4)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b, c, d):
    if b <= c or d <= a:
        return 0
    elif a <= c and d <= b:
        return d - c
    elif c <= a and b <= d:
        return b - a
    else:
        return abs(b - c)


def write(result):
    print(result)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a, b, c, d = map(int, input().split())
if(c < b):
    if(d <= b):
        if(d <= a):
            time = 0
        elif(c < a):
            time = d - a
        else:
            time = d - c
    else:
        time = b - c
else:
    time = 0
print(time)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a, b, c, d = map(int, input().split())
if(c < b):
    if(d <= b):
        if(d <= a):
            time = 0
        else:
            time = d - c
    else:
        time = b - c
else:
    time = 0
print(time)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if B<=C:
  print(0)
else:
  print(min(B,D)-max(A,C))

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, input().split())
ans = 0
x = sorted([a, b, c, d])
if b > c:
    ans = x[2] - x[1]
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, input().split())
row = [0 for i in range(101)]
for i in range(a, b+1) : row[i] += 1
for i in range(c, d+1) : row[i] += 1
print(row.count(2))

Submission status: Wrong Answer

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

if int(s[2])>int(s[0]):
  if int(s[2])>int(s[1]):
    print("0")
  else:
    if int(s[3])>int(s[1]):
      print(int(s[1])-int(s[2]))
    else:
      print(int(s[3])-int(s[2]))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  
  a, b, c, d = map(int, input().split())

  if a <= c and b >= d:
    print(d-c)
  elif c <= a and d >= b:
    print(b-a)
  elif a < c and d > b and c < b:
      print(b-c)
  elif c < a and b > d and a < d:
      print(b-a)
  else:
      print(0)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  
  a, b, c, d = map(int, input().split())

  if a < c and b > d:
    print(d-c)
  elif c < a and d > b:
    print(b-a)
  elif a < c and d > b and c < b:
      print(b-c)
  elif c < a and b > d and a < d:
      print(b-a)
  else:
      print(0)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  
  a, b, c, d = map(int, input().split())
  
  if b > c:
      if b < d:
          print(b-c)
      else:
          print(d-c)
  else:
      print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if c-b>=0 or a-d>=0:
  print(0)
elif (c-a>=0 and b-d>=0):
  print(d-c)
elif (a-c>=0 and d--b>=0):
  print(b-a)
elif c-a>=0:
  print(b-c)
elif a-c>=0:
  print(d-a)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
resul=0
mayor=0
menor=0
if b<c:  
  pass
else:
  if b>=d:
    mayor=d
  else:
    mayor=b
  if a>=c:
    menor=a
  else:
    menor=c
resul=mayor-menor
print(resul)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
resul=0
mayor=0
menor=0
if b<c:  
  pass
else:
  if b>d:
    mayor=d
  else:
    mayor=b
  if a>c:
    menor=a
  else:
    menor=c

resul=mayor-menor
print(resul)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

NL = []
for i in range(a + 1,b + 1):
    NL.append(i)
for i in range(c + 1,d + 1):
    NL.append(i)
NL.sort()
print(NL)

count = 0
for i in range(len(NL) - 1):
    if NL[i] == NL[i + 1]:
        count += 1
print(count)

Submission status: Wrong Answer

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

NL = []
for i in range(a,b + 1):
    NL.append(i)
for i in range(c,d + 1):
    NL.append(i)
NL.sort()
#print(NL)

count = 0
for i in range(len(NL) - 1):
    if NL[i] == NL[i + 1]:
        count += 1
print(count - 1)

Submission status: Wrong Answer

Solution code:
# ABC070-B
a, b, c, d = map(int, input().split())
if d <= a:
    print(0)
elif c <= a <= d and a <= d <= b:
    print(d-a)
elif c <= a <= d and b <= d:
    print(c-a)
elif a <= c <= b and a <= d <= b:
    print(d-c)
elif c <= b <= d:
    print(b-c)
elif b <= c:
    print(0)

Submission status: Wrong Answer

Solution code:
# ABC070-B
a, b, c, d = map(int, input().split())
if d <= a:
    print(0)
elif c <= a <= d and a <= d <= b:
    print(d-a)
elif a <= c <= b and a <= d <= b:
    print(d-c)
elif c <= b <= d:
    print(b-c)
elif b <= c:
    print(0)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int, input().split())
if min(C,D) < max(A,B):
  if D < B:
    print(D-C)
  else:
    print(B-C)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int, input().split())
if C < B:
  if D < B:
    print(D-C)
  else:
    print(B-C)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int, input().split())
if C < B:
  print(B-C)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int, input().split())
if C < B:
  print(C-B)
else:
  print(0)

Submission status: Wrong Answer

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



mi = min(b,d )
ma = max(a,c)

print(mi - ma)

Submission status: Wrong Answer

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



if b <= c:
    print("0")
elif c <= a:
    print("0")
elif a<c and (c<b and b<d):
    print(b-c)
elif (a<c and a<d) and (c<b and d<b):
    print(d-c)
elif (c<a and a<d) and (c<b and b<d):
    print(b-a)
elif (c<a and a<d) and (c<b and d<b):
    print(d-a)
else:
    print("0")

Submission status: Wrong Answer

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



if b<c:
    print("0")
elif a<c and (c<b and b<d):
    print(b-c)
elif (a<c and a<d) and (c<b and d<b):
    print(d-c)
elif (c<a and a<d) and (c<b and b<d):
    print(b-a)
elif (c<a and a<d) and (c<b and d<b):
    print(d-a)
elif d<a:
    print("0")
else:
    print("0")

Submission status: Wrong Answer

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



if b<c:
    print("0")
elif a<c and (c<b and b<d):
    print(b-c)
elif (a<c and a<d) and (c<b and d<b):
    print(d-c)
elif (c<a and a<d) and (c<b and b<d):
    print(b-a)
elif (c<a and a<d) and (c<b and d<b):
    print(d-a)
elif d<a:
    print("0")

print("0")

Submission status: Wrong Answer

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


if b<c and b<d:
    print("0")
elif c<b and b<d:
    print(b-c)
elif a<c and d<b:
    print(d-c)
elif c<a and b<d:
    print(b-a)
elif c<a and d<b:
    print(d-a)
elif d<a and d<b:
    print("0")

Submission status: Wrong Answer

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


if b<c and b<d:
    print("0")
elif c<b and b<d:
    print(b-c)
elif a<c and d<b:
    print(d-c)
elif c<a and d<b:
    print(b-a)
elif c<a and d<b:
    print(d-a)
elif d<a and d<b:
    print("0")

Submission status: Wrong Answer

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


if b<c and b<d:
    print("0")
elif c<b and b<d:
    print(b-c)
elif a<c and d<b:
    print(d-c)
elif c<a and d<b:
    print(b-a)
elif c<a and d<b:
    print(d-a)
else:
    print("0")

Submission status: Wrong Answer

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


if b<c:
    print("0")

if c<b and b<d:
    print(b-c)
elif a<c and d<b:
    print(d-c)
elif c<a and d<b:
    print(b-a)
elif c<a and d<b:
    print(d-a)
else:
    print("0")

Submission status: Wrong Answer

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


if b < c:
    print("0")
    exit()

if c<b and b<d:
    print((d-c)-(d-b))
elif a<c and d<b:
    print(d-c)
elif c<a and d<b:
    print(b-a)
else:
    print("0")

Submission status: Wrong Answer

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


if b < c:
    print("0")
    exit()

if c<b and b<d:
    print((d-c)-(d-b))
elif a<c and d<b:
    print(d-c)
else:
    print("0")

Submission status: Wrong Answer

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


if b < c:
    print("0")
    exit()

if b < d:
    print((d-c)-(d-b))
else:
    print(d-c)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
s=min(a+b,c+d) - max(a,c)
if s>0:print(s)
else:print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def judge(ans):
	if ans > 0:
		print(ans)
	else:
		print(0)

if A < C :
	if B < D: 
		judge(B-C)
	else: 
		judge(D-C)
else:
	if B > D:
		judge(A-D)
	else:
		judge(A-B)

Submission status: Wrong Answer

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

def judge(ans):
	if ans > 0:
		print(ans)
	else:
		print(0)

if A < C :
	if D < B: judge(D-C)
	else: judge(B-C)
else:
	if B > D:
		judge(C-D)
	else:
		judge(C-B)

print(0)

Submission status: Wrong Answer

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

def judge(ans):
	if ans > 0:
		print(ans)
	else:
		print(0)

if A < C :
	if D < B:
		judge(D-C)
	else:
		judge(B-C)
else:
	if B > D:
		judge(C-D)
	else:
		judge(C-B)

Submission status: Wrong Answer

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

def judge(ans):
	if ans > 0:
		print(ans)
	else:
		print(0)

if A < C :
	if D < B:
		judge(D-C)
	else:
		judge(B-C)
else:
	judge(C-B)

Submission status: Wrong Answer

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

if a[1]<a[2]:
  print(0)
else:
  print(min(a[1],a[3])-max(a[0],a[2]))

Submission status: Wrong Answer

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

if a[1]<=a[2]:
  print(0)
else:
  print(min(a[1],a[3])-max(a[0],a[2]))

Submission status: Wrong Answer

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

if C > B:
  print(0)
elif D > B:
  print(B-C)
elif B > D:
  print(D-C)
else:
  print(1)

Submission status: Wrong Answer

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

if C > B:
  print(0)
elif D > B:
  print(B-C)
else:
  print(D-C)

Submission status: Wrong Answer

Solution code:
l=input().split()
A,B,C,D=int(l[0]),int(l[1]),int(l[2]),int(l[3])
s=0
for i in range(1,101):
    if A<=i<B:
        if C<=i<D:
            s+=1
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D = map(int, input().split())
    if C > B:
        print(0)
    else:
        print(min(B, D) - max(A, C))


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a < c and b < d:
    print(b - c)
elif a < c and d < b:
    print(d - c)
elif c < a and b < d:
    print(b-a)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
if b>=c and c>=a and d>=b:
    print(b-c)
elif a>=c or b>=d:
    print(min(b-a,d-c,d-a))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
if b>=c and c>=a and d>=b:
    print(b-c)
elif b>=c and (a>=c or b>=d):
    print(min(b-a,d-c,d-a))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
if b>=c and c>=a and d>=b:
    print(b-c)
elif b>=c and (a>=c or b>=d):
    print(min(b-a,d-c,d-a))
elif c>=b or a>=d:
    print(0)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
if b>=c and c>=a and d>=b:
    print(b-c)
elif b>=c and (a>=c or b>=d):
    print(min(b-a,d-c,d-a))
elif c>=b and a>=d:
    print(0)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
if b-c>=0 and c-a>=0 and d-b>=0:
    print(b-c)
elif b-c>=0 and (a-c>=0 or b-d>=0):
    print(min(b-a,d-c,d-a))
elif c-b>=0:
    print(0)

Submission status: Wrong Answer

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


ans = 0

if B < C:
    ans = 0
elif A <= C and D <= B:
    ans = D - C
elif C<=A and B<= D:
    ans = B - A
elif C<=A and D<=B:
    ans = D - A
else:
    ans = B - C
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
A,B,C,D = [int(x) for x in stdin.readline().rstrip().split()]
Alice = set(range(A,B+1))
Bob   = set(range(C,D+1))
print(len(Alice & Bob))

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int,input().split())
e = list(range(a,b+1))
d = list(range(c,d+1))
print(e)
l = []
for i in e:
  if i in d:
    l.append(i)
if l == []:
  print(0)
else:
  print(len(l)-1)

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int,input().split())
e = list(range(a,b+1))
d = list(range(c,d+1))
l = []
for i in e:
  if i in d:
    l.append(i)
print(len(l)-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int, input().split())
if a > c:
    a,b,c,d = b,a,d,c
# aのスタートが常に最小
if b <= c:
    print(0)
elif b <= d:
    print(b - c)
else:
    print(d - c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input().split())
time = [0]*200
time[a] = 1
time[b] -= 1
time[c] = 1
time[d] -= 1
from itertools import accumulate
t = list(accumulate(time))
print(t.count(2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def solve(A: int, B: int, C: int, D: int):
    if A < C:
        ret = min(B - C, D - C)
    else:
        ret = min(D - A, C - A)
    ret = max(0, ret)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
if b<=c or d<=a:
  print(0)
elif b>c:
  print(min(b-c,d-c))
else:
  print(min(d-a,b-a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,D=map(int,input().split())
a=[A,B,C,D]
a.sort()
if B<C:
  print(0)
else:
  print(a[2]-a[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, d = [ int(v) for v in input().split() ]
d, e = max(a,c), min(b,d)
f = max((e-d),0)

Submission status: Wrong Answer

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

lower = max(a,c)
upper = min(b,d)

print(upper-lower, 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
if B <= C:
    print(0)
elif C < B <= D:
    print(B - C)
elif C < D <= B:
    print(D - C)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
if max(B, D)-min(A, C)>0:
	print(max(B, D)-min(A, C))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
# 入力
A,B,C,D=map(int,input().split())

if B<=C:
  print(0)
elif A<=C and C<=B and B<=D:
  print(B-C)
elif C<=A and B<=D:
  print(B-A)
elif C<=A and A<=D and D<=B:
  print(D-B)
elif D<=A:
  print(0)
elif C<=A and A<=D and D<=B:
  print(D-A)
elif A<=C and D<=B:
  print(D-C)
elif A<=C and C<=B and C<=D:
  print(C-A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A=[int(i) for i in input().split()]
if A[0]<=A[2]:
    if A[1]<A[2]:
        print(0)
    elif A[1]>=A[3]:
        print(A[3]-A[2])
    else:
        print(A[1]-A[2])
else:
    if A[3]<A[0]:
        print(0)
    elif A[3]>=A[1]:
        print(A[3]-A[2])
    else:
        print(A[3]-A[0])

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
if C <= A <= C + D <= A + B:
    print(C + D - A)
elif C <= A <= A + B <= C + D:
    print(B)
elif A <= C <= C + D <= A + B:
    print(D)
elif A <= C <= A + B <= C + D:
    print(A + B - C)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
if B <= C:
    print(0)
else:
    print(min(B,D) - max(A,C))

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
if B < C:
    print(0)
else:
    print(min(B,D) - max(A,C))

Submission status: Wrong Answer

Solution code:
a, b, c, d = (int(i) for i in input().split())  
print(max(b-c,0))

Submission status: Wrong Answer

Solution code:
l=a,b,c,d=list(map(int,input().split()))
l1=sorted(l)
if (l1.index(c)==0 and l1.index(d)==1) or (l1.index(c)==2):
        print(0)
elif l1.index(c)==0 and l1.index(d)==2:
        print(d-a)
elif l1.index(c)==1 and l1.index(d)==3:
        print(b-c)
elif l1.index(c)==1 and l1.index(d)==2:
        print(d-c)
elif l1.index(c)==0 and l1.index(d)==3:
        print(a-b)

Submission status: Wrong Answer

Solution code:
l=a,b,c,d=list(map(int,input().split()))
l1=sorted(l)
if (l1.index(c)==0 and l1.index(d)==1) or (l1.index(c)==2):
        print(0)
elif l1.index(c)==0 and l1.index(d)==2:
        print(d-a)
elif l1.index(c)==1 and l1.index(d)==3:
        print(b-c)
elif l1.index(c)==1 and l1.index(d)==2:
        print(d-c)

Submission status: Wrong Answer

Solution code:
tmp = (input())

A = int(tmp.split(" ")[0])
B = int(tmp.split(" ")[1])
C = int(tmp.split(" ")[2])
D = int(tmp.split(" ")[3])

Alice = {str(x): "A" for x in range(A, B + 1)}
Bob = {str(x): "A" for x in range(C, D + 1)}

cnt = 0

for k, v in Alice.items():
  if k in Bob:
    cnt += 1
    
print(cnt - 1)

Submission status: Wrong Answer

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

if b > c:
    ans = min(b, d) - max(a, c)

print(ans)

Submission status: Wrong Answer

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

if b >= c:
    ans = min(b, d) - max(a, c)

print(ans)

Submission status: Wrong Answer

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


if a<=c<=b and a<=d<=b:
    print(d-c)
elif a<=c<=b:
    print(b-c)
elif c<=a<=d:
    print(d-a)
else:
    print(0)

Submission status: Wrong Answer

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

if B >= C and C <= D: # normal
  print(B-C)
elif B >= C and B >= D:
  print(D-C)
else:
  print(0)
  
#elif B < C:
#  print(0)

Submission status: Wrong Answer

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

if B > C and C < D: # normal
  print(B-C)
elif B > C and B > D:
  print(D-C)
else:
  print(0)
  
#elif B < C:
#  print(0)

Submission status: Wrong Answer

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

print(max(B,D) - min(A,C))

Submission status: Wrong Answer

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

if b > c:
    result = b-c
if b > d:
    result -= b-d
if a > c:
    result -= a-c

print(result if result < 0 else 0)

Submission status: Wrong Answer

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

if b > c:
    result = b-c
if b > d:
    result -= b-d
if a > c:
    result -= a-c

print(result)