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())
 
alice = [i for i in range(A,B + 1)]
bob = [i for i in range(C,D + 1)]
 
common = [i for i in bob if i in alice]

print(len(common) - 1)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
 
inter1 = [i for i in range(A,B + 1)]
inter2 = [i for i in range(C,D + 1)]
 
inter3 = []
 
for i in range(0,max(B,D)):
  if i in inter1 and i in inter2:
    inter3.append(i)
    
if len(inter3) > 1:
  print(max(inter3) - min(inter3))
elif len(inter3) == 1:
  print(1)
else:print(0)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
 
inter1 = [i for i in range(A,B + 1)]
inter2 = [i for i in range(C,D + 1)]
 
inter3 = []
 
for i in range(0,max(B,D)):
  if i in inter1 and i in inter2:
    inter3.append(i)
    
if len(inter3) > 1:
  print(max(inter3) - min(inter3))
elif len(inter3) == 1:
  print(1)
else:print(0)
  
print(inter3)

Submission status: Wrong Answer

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

inter1 = {i for i in range(A,B + 1)}
inter2 = {i for i in range(C,D + 1)}

print(len(inter1 or inter2) - 1)

Submission status: Wrong Answer

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

inter1 = [i for i in range(A,B + 1)]
inter2 = [i for i in range(C,D + 1)]

inter3 = []

for i in range(0,max(B,D)):
  if i in inter1 and i in inter2:
    inter3.append(i)
    
if len(inter3) > 0:
  print(max(inter3) - min(inter3))
else:print(0)

Submission status: Wrong Answer

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

inter1 = [i for i in range(A,B + 1)]
inter2 = [i for i in range(C,D + 1)]

con = 0

for i in range(0,max(B,D)):
  if i in inter1 and i in inter2:
    con += 1
    
print(con - 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
print(a,b,c,d)
al=[]
bl=[]
for i in range(a,b+1):
    al.append(i)
for i in range(c,d+1):
    bl.append(i)
albl=set(al)&set(bl)
if len(albl)==0:
    print(0)
else:
    print(len(albl)-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
result = -1
for i in range(max(B,D)+1):
  if A<= i <= B and C<= i <= D:
    result +=1
print(result)

Submission status: Wrong Answer

Solution code:
a = list(input().split())
if a[0] >= a[3] or a[2] >= a[1]:
    print(0)

elif a[0] <= a[2] < a[3] <= a[1]:
    print(int(a[3])-int(a[2]))
elif a[0] <= a[2] <= a[1] <= a[3]:
    print(int(a[1])-int(a[2]))
elif a[2] <= a[0] < a[1] <= a[3]:
    print(int(a[1])-int(a[0]))
elif a[2] <= a[0] <= a[3] <= a[1]:
    print(int(a[3])-int(a[0]))

Submission status: Wrong Answer

Solution code:
a = list(input().split())
if a[0] >= a[3] or a[2] >= a[1]:
    print(0)

elif a[1] >= a[2] and a[2]>=a[0]:
    
    print(int(a[1])-int(a[2]))
    
elif a[1] >=a[2] and a[0]>=a[2]:
    print(int(a[1])-int(a[0]))
              
elif a[3]>=a[0] and a[0]>=a[2]:
    print(int(a[3])-int(a[0]))
elif a[3]>=a[0] and a[2]>=a[0]:
    print(int(a[3])-int(a[2]))

Submission status: Wrong Answer

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

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())
print(max(b-c,0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#Two switches B

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

start = max(A,C)
end = min(B,D)

print(end-start)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
if a[1] <= a[2]:
  print(0)
  exit()
elif a[0]<=a[2] and a[1]<=a[3]:
  print(a[1]-a[2])
  exit()
elif a[0]<=a[2] and a[3]<=a[1]:
  print(a[3]-a[2])
  exit()
elif a[2]<=a[0] and a[1]<=a[3]:
  print(a[1]-a[0])
  exit()
elif a[2]<=a[0] and a[3]<=a[1]:
  print(a[3]-a[0])
  exit()
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 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 b<c or d<a:
    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 b<=c or d<=a:
    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:
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c, d = list(map(int, input().rstrip('\n').split()))
    ls = [0] * 102
    ls[a] += 1
    ls[b+1] -= 1
    ls[c+1] += 1
    ls[d+1] -= 1
    t = 0
    cnt = 0
    for i in range(len(ls)):
        t += ls[i]
        if t == 2:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
ans = 0
for i in range(1, 101):
  if A <= i and i < B and C <= i and i < D:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

# input
A, B, C, D = map(int, input().split())

# solve & output
print(min(B, D) - max(A, C) if B > C else '0')

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
A,B,C,D=map(int,input().split())
if B>C or D>A:
  Min = max([A,C])
  Max=min([B,D])
  print(Max-Min)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
A,B,C,D=map(int,input().split())
if B>C:
  Min = max([A,C])
  Max=min([B,D])
  print(Max-Min)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
A,B,C,D=map(int,input().split())
Min = max([A,C])
Max=min([B,D])
print(Max-Min)

Submission status: Wrong Answer

Solution code:
#coding:utf-8

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

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

Submission status: Wrong Answer

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

if b <= c:
  print(0)
  sys.exit()
else:
  print(min(d - c, b - c))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
alice = []
bob = []
ans = 0
for i in range(A,B):
  alice.append(i)
for j in range(C,D):
  bob.append(j)
for _ in range(1,100):
  if _ in alice and _ in bob:
    ans += 1
print(ans)

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())
if C >= B or D <= A:
    print(0)
elif A <= C <= D <= B:
    print(D-C)
elif C <= A <= B <= D:
    print(B-A)
elif C <= B:
    print(B-C)
else:
    print(D-A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
t = list(map(int, input().split()))
if t[1]<=t[2]:
  print(0)
else:
  t.sort()
  print(t[2]-t[1])

Submission status: Wrong Answer

Solution code:
t = list(map(int, input().split()))
if t[1]<t[2]:
  print(0)
else:
  t.sort()
  print(t[2]-t[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


A, B, C, D = map(int, sys.stdin.readline().split())

ans = 0
if B > C:
    if B < 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]*101
for i in range(a,b+1):
    ans[i]+=1
for i in range(c,d+1):
    ans[i]+=1
    
kai=0
for i in range(101):
    if ans[i]==2:
        kai+=1
print(kai)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


def min(a, b):
	if a > b:
		return b
	else:
		return a

def max(a, b):
	if a > b:
		return a
	else:
		return b



def main():
	linie = input()
	vector = [int(x) for x in linie.split()]
	print(abs(max(vector[2], vector[0]) - min(vector[1], vector[3])))





if __name__ == "__main__":
	main()

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) <= 0 else print(0)

Submission status: Wrong Answer

Solution code:
ABCD = list(map(int,input().split()))
print(sorted(ABCD)[2]-sorted(ABCD)[1]) if ABCD[2] - ABCD[1] < 0 else print(0)

Submission status: Wrong Answer

Solution code:
ABCD = list(map(int,input().split()))
print(sorted(ABCD)[2]-sorted(ABCD)[1]) if ABCD[1] - ABCD[2] < 0 else print(0)

Submission status: Wrong Answer

Solution code:
ABCD = list(map(int,input().split()))
print(sum(sorted(ABCD)[1:3])) if ABCD[1] - ABCD[2] < 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 d>=b:
    print(b-c)
elif a<=c and d <=b:
    print(d-c)
elif c <= a and a <= d:
    print(d-a)
elif a>=d:
    print(0)
elif a>=c and 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 a<c and d>b:
    print(b-c)
elif a<c and d < b:
    print(d-c)
elif c < a and a < d:
    print(d-a)
elif a>d:
    print(0)
elif a>c and b < d:
    print(b-a)

Submission status: Wrong Answer

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

if a < c and b < d and c < b:
    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 and a < d:
    print(d-a)
else:
    print(0)

Submission status: Wrong Answer

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

if S[0] < S[1] < S[2] < S[3]:
    print (0)
    
elif S[0] < S[2] < S[3] < S[1]:
    print(S[3]-S[2])
    
elif S[0] < S[2] < S[1] < S[3]:
    print(S[1] - S[2])
    
elif S[2] < S[0] < S[3] < S[1]:
    print(S[3] - S[0])

elif S[2] < S[3] < S[0] < S[1]:
    print(0)
    
elif S[2] < S[0] < S[1] < S[3]:
    print(S[1]-S[0])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if S[0] < S[1] < S[2] < S[3]:
    print (0)
    
elif S[0] < S[2] < S[3] < S[1]:
    print(S[3]-S[2])
    
elif S[0] < S[2] < S[1] < S[3]:
    print(S[1] - S[2])
    
elif S[2] < S[0] < S[3] < S[1]:
    print(S[3] - S[0])

elif S[2] < S[3] < S[0] < S[1]:
    print(0)

Submission status: Wrong Answer

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

if  S[2] > S[1]:
    print(0)


elif S[3] > S[1]:
    print(S[1] - S[2])

elif S[3] < S[1]:
    print(S[3] - S[2])

Submission status: Wrong Answer

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

if  S[0] < S[1] < S[2] < S[3]:
    print(0)

elif S[3] > S[1]:
    print(S[1] - S[2])

elif S[3] < S[1]:
    print(S[3] - S[2])

Submission status: Wrong Answer

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

if S[3] > S[1]:
    print(S[1] - S[2])

elif S[3] < S[1]:
    print(S[3] - S[2])
    
else:
    print(0)

Submission status: Wrong Answer

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

if S[1] > S[2]:
    print(S[1] - S[2])

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

print(b-c if b-c>0 else 0)

Submission status: Wrong Answer

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

if n[1] > n[2]:
    n = sorted(n)
    print(n[2]-n[1])
else:
    print(0)

Submission status: Wrong Answer

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

if n[2] <= n[0] <= n[3] or n[2] <= n[1] <= n[3]:
    n = sorted(n)
    print(n[2]-n[1])
elif n[0] <= n[2] <= n[1] or n[0] <= n[3] <= n[1]:
    n = sorted(n)
    print(n[3]-n[2])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

A, B, C, D = ISI()
ans = 0
for i in range(A, B+1):
    if C < i <= D:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

A, B, C, D = ISI()
ans = 0
for i in range(A, B):
    if C < i <= D:
        ans += 1
print(ans)

Submission status: Wrong Answer

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


if __name__ == "__main__":
    test()

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())

result = 0

if B < C or D < A:
    print(result)
    exit()
if A < C :
    if B > D:
        result = D-C
    if B < D:
        result = B-C
if A > C:
    if B >D:
        result = D-A
    if B <D:
        result = B-A

print(result)

Submission status: Wrong Answer

Solution code:

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

result = 0

if B < C:
    print(result)
    exit()
if A < C :
    if B > D:
        result = D-C
    if B < D:
        result = B-C
if A > C:
    if B >D:
        result = D-A
    if B <D:
        result = B-A

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if __name__ == "__main__":
    test()

Submission status: Wrong Answer

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

ba=[i for i in range(a,b+1)]
dc=[i for i in range(c,d+1)]
ans=0
for i in range(min(a,b,c,d),max(a,b,c,d)):
  if i in ba and i in dc:
    ans+=1
if ans==0:
  print(0)
else:
  print(ans-1)

Submission status: Wrong Answer

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

ba=[i for i in range(a,b+1)]
dc=[i for i in range(c,d+1)]
ans=0
print(min(a,b,c,d),max(a,b,c,d))
for i in range(min(a,b,c,d),max(a,b,c,d)):
  if i in ba and i in dc:
    ans+=1
if ans==0:
  print(0)
else:
  print(ans-1)

Submission status: Wrong Answer

Solution code:
# ABC 70 B

def resolve():
    a, b, c, d = map(int, input().split())
    ans = 0
    if a < c and b < d:
        ans = b - c
    elif a < c and d < b:
        ans = d - c
    elif c < a and b < d:
        ans = b - a
    else:
        ans = d - a

    if ans < 0:
        print(0)
    else:
        print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if B < C or D < A:
  print(0)
  exit()
  
if C < B < D:
  if A < C:
    print(B-C)
  else:
    print(B-A)
  exit()
  
if A < D < B:
  if C < A:
    print(D-A)
  else:
    print(D-C)
  exit()

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

Submission status: Wrong Answer

Solution code:
num = [int(i) for i in input().split()]
set_ans = set(range(num[0], num[1]+1)) & set(range(num[2], num[3]+1))
print(len(set_ans)-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a > c:
    t1, t2 = a, b
    a, b = c, d
    c, d = t1, t2

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

Submission status: Wrong Answer

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

r = [0] * 200
for i in range(A, B + 1) :
    r[i] += 1
for i in range(C, D + 1) :
    r[i] += 1
    
ret = 0
for i in range(200) :
    if r[i] == 2 :
        ret += 1
print(ret-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d=list(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())
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(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(min(b, d)-max(a, c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A_B = B-A
C_D = D-C

list_A_B =range(A_B)
list_C_D =range(C_D)

list_judge =[]

for i in list_A_B:
    for j in list_C_D:
        if i == j:
            list_judge.append(j)

print(len(list_judge))

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 d <= b :
  print(d - c)
 
elif c < a and a <= d and d < b:
  print(d - a)
  
elif c < a and b < d :
  print(b - a)
 
elif d <= b:
  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 d <= b :
  print(d - c)

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

elif d <= b:
  print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if B <= C or D <= A:
  print(0)
elif C < B:
  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())
def calc():
    if a <= c:
        if c <= b and b <= d:
            print(b-c)
        elif b <=c:
            print(0)
        elif d <= b:
            print(d-c)
    if c <= a:
        if b <= d:
            print(b - a)
        elif d <= b:
            print(d - a)
    if d <= a:
        print(0)
calc()

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 and b <= d:
    print(b-c)
elif c <= a and d<= b:
    print(d-a)
elif (d-c)>=(b-a):
    print(b-a)
elif (b-a)>= (d-c):
    print(d-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 and b <= d:
    print(b-c)
elif c <= a and d<= b:
    print(d-a)
elif (d-c)>=(b-a):
    print(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 and b <= d:
    print(b-c)
elif c <= a and d<= b:
    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 b > c and b <= d:
    print(d-c)
elif b > c:
    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 b >=d:
    print(d-c)
elif b > c:
    print(b-c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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(d-c)
else:
  print(b-c)

Submission status: Wrong Answer

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

for i in range(110):
  list.append(0)
for i in range(a,b+1):
  list[i]=1
for i in range(c,d+1):
  list[i]+=1

ans = 0
for i in range(100):
  if list[i] == 2:
    ans +=1
print(ans-1)