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:
# ABC070B - Two Switches
a, b, c, d = list(map(int, input().rstrip().split()))
print(min(max(0, b - c), d - c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c,d = f()
    print(min(b,d) - max(a, c))

solve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A, B, C, D = (int(x) for x in input().split())

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

Submission status: Wrong Answer

Solution code:
A, B, C, D = (int(x) for x in input().split())

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

Submission status: Wrong Answer

Solution code:
A, B, C, D = (int(x) for x in input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b, c, d = (int(_) for _ in input().split())
    if c > b:
        print(0)
    elif b >= c and b <= d:
        print(b-c)
    elif a < c and d <= b:
        print(d-c)
    elif a >= c and b >= d:
        print(b-d)
    elif a > d:
        print(0)  
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
if A < C and B < D:
    print(B - C)
elif C <= A and B < D:
    print(B - A)
elif A < C and D <= B:
    print(D - C)
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 A < C and B < D:
    print(B - C)
elif C <= A and B < D:
    print(B - A)
elif A < C and 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 and B < D:
    print(D - A)
elif C <= A and B < D:
    print(D - C)
elif A < C and D <= B:
    print(B - A)
else:
    print(B - C)

Submission status: Wrong Answer

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

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

if a<=c<b or a<=d<b:
    x=max(a,c)
    y=min(b,d)
    print(abs(y-x))
else:
    print("0")

Submission status: Wrong Answer

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

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

if a<=c<=b or a<=d<=b:
    x=max(a,c)
    y=min(b,d)
    print(abs(y-x))
else:
    print("0")

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
if B >= C:
    if B >= D:
        if A >= C:
            print(D-A)
        else:
            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 B > C:
    if B > D:
        if A > C:
            print(D-A)
        else:
            print(D-C)
    else:
        print(B-C)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if b<c:
    print ('0')
else:
    if b>=d:
        print(str(d-c))
    elif b<d:
        print(str(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:
    if b>=d:
        print(str(d-c))
    elif b<d:
        print(str(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:
    if b>=d:
        print(str(d-c))
    elif b<d:
        print(str(b-c+1))

Submission status: Wrong Answer

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


if b<=c:
    print ('0')
else:
    if b>=d:
        print(str(d-c))
    elif b<d:
        print(str(b-c))

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
if B <= C:
    print(0)
elif B > C and 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:
    print(B - C)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().split()))
a = list(range(n[0], n[1]+1))
b = list(range(n[2], n[3]+1))
print(len(set(a) & set(b)))

Submission status: Wrong Answer

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

if B < D:
    end = B
else:
    end = D

print(end - start)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,D=map(int,input().split())
if B < C :
  print(0)
elif D >= B :
  print(B-C)
else :
  print(D-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 = 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())
s, e = 0,0
if B >= C :
    if C > A :
        s = C
    else :
        s = A
    if D > B :
        e = B
    else :
        e = D
    print(e - s)
else :
    print(0)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# 070 B 
A,B,C,D= map(int,input().split())
if B < C or A < D:
    print(0)
    exit()
if A <= C:
    start =C
else:
    start =A
if B <=D:
    end =B
else:
    end =D
print(end-start)

Submission status: Wrong Answer

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

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())
alice = set([i for i in range(A, B+1)])
bob = set([i for i in range(C, D+1)])
result = len(alice & bob)
if result == 0:
    print(0)
else:
    print (result)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int, input().split())
print (max(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 = map(int, input().split())
if b <= c:
    print(0)
else:
    print(min(b,d)-c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
ans = 0
for i in range(101):
  if A<=i<=B and C<=i<=D:
    ans += 1
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 and B < D:
    print(B-C)
elif C < A < D and A < D < B:
    print(D-A)
elif C < A and B < D:
    print(B-A)
else:
    print(0)

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 and B < D:
    print(B-C)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
line1 = list(range(A,B+1))
line2 = list(range(C,D+1))
line1_line2_and = set(line1) & set(line2)
line1_line2_and_list = list(line1_line2_and)
botton = len(line1_line2_and_list) -1
print(botton)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
line1 = list(range(A,B+1))
line2 = list(range(C,D+1))
line1_line2_and = set(line1) & set(line2)
botton = len(line1_line2_and) -1
print(botton)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
line1 = list(range(A,B+1))
line2 = list(range(C,D+1))
line1_line2_and = set(line1) & set(line2)
botton = len(line1_line2_and) - 1
print(str(botton))

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
line1 = list(range(A,B+1))
line2 = list(range(C,D+1))
line1_line2_and = set(line1) & set(line2)
Alice_Bob_sim_botton = len(line1_line2_and) - 1
print(str(Alice_Bob_sim_botton))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

A,B,C,D = read_int()
Max = max(A,B,C,D)

Alice = [True if i >= A and i <= B  else False for i in range(Max)]
Bob = [True if i >= C and i <= D  else False for i in range(Max)]
Overlap = [True if Alice[i] and Bob[i] else False for i in range(Max)]

sec = -1
for o in Overlap:
    if o:
        sec += 1

if sec == -1:
    print(0)
else:
    print(sec)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A >= C:
    start = A
else:
    start = C

if B >= D:
    end = D
else:
    end = B

print(end - start)

Submission status: Wrong Answer

Solution code:
A, B, C, D = [int(_) for _ in input().split()]
print((B - C if C < B else 0) - (B - D if D < B else 0) - (A - C if C < A else 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(abs(max(a,c)- min(b,d)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if li[0] > li[2]:
    st = li[0]
else:
    st = li[2]

if li[1] < li[3]:
    en = li[1]
else:
    en = li[3]

if li[1] >= li[2]:
    print(en - st)
else:
    print("0")

Submission status: Wrong Answer

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

if li[0] > li[2]:
    st = li[0]
else:
    st = li[2]

if li[1] < li[3]:
    en = li[1]
else:
    en = li[3]

if li[1] > li[2]:
    print(en - st)
else:
    print("0")

Submission status: Wrong Answer

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

li.sort()
x = li[2] - li[1]
if x < 0:
    print(x)
else:
    print("0")

Submission status: Wrong Answer

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

li.sort()
print(li[2] - li[1])

Submission status: Wrong Answer

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

def main():
	a, b, c, d = map(int, input().split(" "))
	
	if c >= b or a >= d:
		print(0)
		sys.exit()
	
	if a <= c and b >= d:
		print(d - c)
		sys.exit()
	
	if a >= c and b <= d:
		print(b - a)
		sys.exit()
		
	if a < c:
		print(b - c - a)
		sys.exit()
		
	if a > c:
		print(d - a - c)
		sys.exit()
		
	if d < b:
		print(d - c)
		sys.exit()
		
	if d > b:
		print(b - c)
		sys.exit()
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def main():
	a, b, c, d = map(int, input().split(" "))
	
	if c >= b or a >= d:
		print(0)
		sys.exit()
	
	if a <= c and b >= d:
		print(d - c)
		sys.exit()
	
	if a >= c and b <= d:
		print(b - a)
		sys.exit()
		
	if a < c:
		print(b - c - a)
		sys.exit()
		
	if a > c:
		print(d - a - c)
		sys.exit()
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def main():
	a, b, c, d = map(int, input().split(" "))
	
	if c >= b:
		print(0)
		sys.exit()
	
	if a <= c and b >= d:
		print(d - c)
		sys.exit()
	
	if a >= c and b <= d:
		print(b - a)
		sys.exit()
		
	if a < c:
		print(b - c - a)
		sys.exit()
		
	if a > c:
		print(d - a - c)
		sys.exit()
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, d = [int(i) for i in input().split()]
def check(a, b, c, d):
  if b <= c:
    return 0
  else: 
    return b-c
print(check(a,b,c,d))

Submission status: Wrong Answer

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s

pl = 'abcdefghijklmnopqrstuvwxyz'

#n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
a,b,c,d= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
e = set([i for i in range(a,b+1)])
f = set([i for i in range(c,d+1)])
print(len(e & f))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc070/tasks/abc070_b

def main():
    A, B, C, D = map(int, input().split())
    print(min(B, D) - max(A, C))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc070/tasks/abc070_b

def main():
    A, B, C, D = map(int, input().split())
    print(min(C, D) - max(A, B))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input().split())
ans = 0
for i in range(0,101):
    if a<=i<=b and c<=i<=d:
        ans += 1

print(ans-1)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int,str(input()).split())
if A<B<C<D or C<A<D<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,str(input()).split())
if B>C :
    print(B-C)
elif A>D :
    print(D-A)
else :
    print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
Alice=range(a,b+1)
Bob=range(c,d+1)
Alice_Bob=set(Alice)&set(Bob)
print(len(Alice_Bob)-1)

Submission status: Wrong Answer

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

ans=0
if a<=c:
    ans+=b-c
    if d<=b:
        ans-=b-d
else:
    ans+=d-a
    if b<=c:
        ans-=d-b

if ans>=0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
l = [0] * 102

l[A] += 1
l[B] -= 1
l[C] += 1
l[D] -= 1

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
l = [0] * 102

l[A] = 1
l[B] = -1
l[C] = 1
l[D] = -1

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
if b<c:
    print(0)
elif (c<=b and b<=d)or (c<=b and b<=d):
    print(abs(b-c))
elif c<=a and b<=d:
    print(b-a)
elif a<=c and d<=b:
    print(d-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 C > A:
    C ,A = A ,C
    B ,D = D, B

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
A,B,C,D = [int(n) for n in input().split()]
# N = int(input())
# A = [0]*N
# for i in range(N):
#     A[i] = int(input())
if (B <= C):
    print(0)
    sys.exit()

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

Submission status: Wrong Answer

Solution code:
import sys
A,B,C,D = [int(n) for n in input().split()]
# N = int(input())
# A = [0]*N
# for i in range(N):
#     A[i] = int(input())
if (B <= C):
    print(0)
    sys.exit()

else:
    print(B-C-A)

Submission status: Wrong Answer

Solution code:
import sys
A,B,C,D = [int(n) for n in input().split()]
# N = int(input())
# A = [0]*N
# for i in range(N):
#     A[i] = int(input())
if (B < C):
    print(0)
    sys.exit()

else:
    print(B-C-A)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

Submission status: Wrong Answer

Solution code:
# B
A, B, C, D = [int(x) for x in input().split()]
#print(A,B,C,D)#
if C<A:
    if D<A: print(0)
    elif A<D and D<B: print(D-A)
    else: print(B-A)
elif C<B and D<B: print(D-C)
elif C<B and B<D: print(B-C)
else: print(0)

Submission status: Wrong Answer

Solution code:
# B
A, B, C, D = [int(x) for x in input().split()]
#print(A,B,C,D)#
if C<A:
    if D<A: print(0)
    elif D>A and D<B: print(D-A)
    else: print(D-B)
elif C<B and D<B: print(D-C)
elif C<B and D>B: print(B-C)
else: print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

start = min(D, B) - C

print(start if start > 0 else 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if(b<c):
    print(0)
elif(d<a):
    print(0)
else:
    print(min(b-c, d-a, d-c))

Submission status: Wrong Answer

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

count=[0]*100
answer=0
for i in range(0,99):
    if (i+1>=a and i+1<b):
        count[i]+=1

    if (i+1>=c and i+1<d):
        count[i]+=1


for i in range(0,99):
    if count[i]==2:
        answer+=1


print(answer)

Submission status: Wrong Answer

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

count=[0]*100
answer=0
for i in range(0,99):
    if (i>=a and i<b):
        count[i]+=1

    if (i>=c and i<d):
        count[i]+=1


for i in range(0,99):
    if count[i]==2:
        answer+=1


print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
x=[0]*110
x[a]+=1
x[b+1]-=1
x[c]+=1
x[d+1]-=1
ans=0
for i in range(1,99):
    x[i]+=x[i-1]
for i in x:
    if i==2:
        ans+=1
print(ans-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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