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: Accepted

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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
count = 0
A, B, C, D = map(int, input().split())
ALICE = list(range(A, B))
BOB = list(range(C, D))
for i in ALICE:
    if i in BOB:
        count += 1
print(count)

Submission status: Accepted

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

a = 0
for t in range(100):
    if A <= t < B and C <= t < D:
        a += 1
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(max(end-start, 0))

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,D = map(int, input().split())
X = [i for i in range(A,B)]
Y = [i for i in range(C,D)]
print(len(set(X) & set(Y)))

Submission status: Accepted

Solution code:
def main():
    A, B, C, D = map(int, input().split())
    lv = [[A, B], [C, D]]
    lv.sort(key = lambda x:x[0])
    if lv[0][1] < lv[1][0]:
        return 0
    return min(lv[0][1], lv[1][1]) - lv[1][0]


if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
def main():
    a, b, c, d = [int(i) for i in input().split()]
    print(min(b,d)-max(a,c) if min(b,d)-max(a,c)>0 else 0)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, c, d = map(int, input().split())
ans = [0] * 100
for i in range(a, b):
    ans[i] += 1
for i in range(c, d):
    ans[i] += 1
print(len(list(filter(lambda x: x == 2, ans))))

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
s=[]
for i in range(0,101):
  if a<=i<=b and c<=i<=d:
    s.append(i)
print(0 if len(s)==0 else max(s)-min(s))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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))
if len(set_ans) == 0:
  print(0)
else:
  print(len(set_ans)-1)

Submission status: Accepted

Solution code:
start_a, stop_a, start_b, stop_b = map(int,input().split())

start = [start_a,start_b]
stop  = [stop_a, stop_b]

result = min(stop) - max(start)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
print(str(max(min(A[1], A[3]) - max(A[0], A[2]), 0)))

Submission status: Accepted

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

start = max(a, c)
end = min(b, d)
print(max(0, end - start))

Submission status: Accepted

Solution code:

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

count = 0
for i in range(d+1):
    if i == a:
        on_a = True
    if i == b:
        on_a = False
    if i == c:
        on_b = True
    if i == d:
        on_b = False

    if on_a and on_b:
        count += 1

print(count)

Submission status: Accepted

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

fr = max(A, C)
to = min(B, D)

if to - fr > 0 :
    print(to-fr)
else :
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=[int(_) for _ in input().split()]
if x[1]<=x[2] or x[3]<=x[0]:
    print(0)
else:
    print(min([x[1],x[3]])-max([x[0],x[2]]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

# processing
# 0 -- A -- B ---...
# 0 ---- C ---- D ---...
res = max(min(B, D) - max(A, C), 0)
print(res)

Submission status: Accepted

Solution code:
a,s,d,f=map(int,input().split())
l=sorted([a,s,d,f])
print(0) if (l[1]==s and l[2]==d) or (l[1]==f and l[2]==a) else print(l[2]-l[1])

Submission status: Accepted

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

if s >= e:
  print(0)
else:
  print(e - s)

Submission status: Accepted

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

x=min(B,D)-max(A,C)

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

Submission status: Accepted

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

list_A_B =range(A,B)
list_C_D =range(C,D)

list_judge =[]

# print(list_A_B)
# print(list_C_D)

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

print(len(list_judge))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


a = set(range(A,B+1))
b = set(range(C,D+1))
x = list(a & b)
if x:
  print(x[-1]-x[0])
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d = map(int,input().split())
t = False
if(a<=c<=b or a<=d<=b or c<=a<=d or c<=b<=d):
    t = True
else:
    t = False

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

Submission status: Accepted

Solution code:
a, b, c, d = [int(i) for i in input().split()]

def calc():
    if a <= c:
        if b < c:
            return 0
        if b >= d:
            return (d - c)
        return b - c
    else:
        if d < a:
            return 0
        if d >= b:
            return b - a
        return d - a

print(calc())

Submission status: Accepted

Solution code:
a,b,c,d = map(int,input().split())
Alice = list(range(a,b+1))
Bob = list(range(c,d+1))
p =list(set(Alice) & set(Bob))
if p==[]:
    print(0)
else:
    print(p[-1]-p[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, d = map(int, input().split())
dic = {}
count = -1

for i in range(a, b+1):
    dic[i] = 0

for j in range(c, d+1):
    if j in dic:
        count += 1
if count == -1:
    count = 0
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Alice = range(A, B+1)
Bob = range(C, D+1)
A_B = len(list(set(Alice) & set(Bob))) - 1
if(A_B >= 0):
    print(A_B)
else:
    print(0)

Submission status: Accepted

Solution code:
a, b, c, d = [int(i) for i in input().split()]

start = max([a,c])
end = min([b,d])

ans = end - start

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d = map(int,input().split())
alice = [int(x) for x in range(a,b)]
bob = [int(y) for y in range(c,d)]
s = set()
for i in alice:
	s.add(i)
for j in bob:
	s.add(j)
print((len(alice)+len(bob))-len(s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,D=[int(x) for x in input().split()]
print(max(0,min(D,B)-max(A,C)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int, C: int, D: int):
    print(max(0, min(B, D)-max(A, C)))

    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: Accepted

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

Submission status: Accepted

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

for i in range(101):
  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(101):
  if list[i] == 2:
    ans +=1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, D = map(int, input().split())
if (A > D) or (C > B):
    print(0)
else:
    S = sorted([A,B,C,D])
    print(S[-2] - S[-3])

Submission status: Accepted

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

if (D-A)*(B-C)<=0:
    print(0)
    exit()
elif A<=C and D<=B:
    print(D-C)
    exit()
elif C<=A and B<=D:
    print(B-A)
    exit()
else:
    print(min(D-A,B-C))

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

if B - C > 0 and D - A > 0:
    start = max(A,C)
    stop = min(B,D)
    print(stop - start)
else:
    print(0)

Submission status: Accepted

Solution code:
## for test
# a, b, c, d = 0, 75, 25, 100
# a, b, c, d = 0, 33, 66, 99
# a, b, c, d = 10, 90, 20, 80

## 考え方
# a, cの大きい方　～　b, dの小さい方　までがカウント対象

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

sec = min([b, d]) - max([a, c])
sec = sec if sec >= 0 else 0

print(str(sec))

Submission status: Accepted

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

sec = min([b, d]) - max([a, c])
sec = sec if sec >= 0 else 0

print(str(sec))

Submission status: Accepted

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

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

Submission status: Accepted

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]
    elif A[1] >= A[3] >= A[0] >= A[2]:
        time = A[3] - A[0]
    else:
        time = 0    
else:
    time = 0

print(time)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC70, B - two switches
a, b, c, d = [int(el) for el in input().split(' ')]
A = set([i for i in range(a, b+1)])
B = set([j for j in range(c, d+1)])
common = A.intersection(B)
if common:
    print(max(common) - min(common))
else:
    print(0)

Submission status: Accepted

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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:
  print(min(B, D) - C)

Submission status: Accepted

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

Submission status: Accepted

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:
        if a == c:
            return min(b, d) - a
        elif a < c:
            return abs(c - b)
        else:  # a > c
            return abs(d - a)


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

if len(alice) <= len(bob):
    target = alice
    other = bob
else:
    target = bob
    other = alice

for i in range(len(target)):
    if target[i] in other:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


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

    t = min(b, d) - max(a, c)
    if t < 0:
        print(0)
        return

    print(t)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(101):
	if i >= A and i < B and i >= C and i < D:
		ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
## abc070b: Two Switches

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

Submission status: Accepted

Solution code:
## abc070b: Two Switches

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

Submission status: Accepted

Solution code:
#%%
a, b, c, d = map(int, input().split())
check = [0] * 101

for i in range(a,b+1):
  check[i] = 1

for i in range(c, d+1):
  if check[i] == 1 :
    check[i] = 2

if check.count(2) != 0:
  print(check.count(2)-1)
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

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

s=max(a,c)
e=min(b,d)

if s>=e:
    print(0)
else:
    print(e-s)

Submission status: Accepted

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
if row.count(2) == 0 : print(0)
else : print(row.count(2)-1)

Submission status: Accepted

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

Submission status: Accepted

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]))
else:
  if int(s[0])>int(s[3]):
    print("0")
  else:
    if int(s[3])>int(s[1]):
      print(int(s[1])-int(s[0]))
    else:
      print(int(s[3])-int(s[0]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

num_min = max(a,c)
num_max = min(b,d)


print(max(0,num_max - num_min))

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, D = MAP()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

alice = [a, b]
bob = [c, d]

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

Submission status: Accepted

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

# 整列
if a > c:
    a,b,c,d = c,d,a,b

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

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

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

import sys

sys.setrecursionlimit(10**7)


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    A, B, C, D = read_h()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
row = list(map(int, input().split()))
start = max(row[0], row[2])
end = min(row[1], row[3])
ans = max(end-start, 0)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

alice = list(range(a, b+1))
bob = list(range(c, d+1))

d = [i for i in alice if i in bob]

if d == []:
    print(0)
else:
    print(d[-1]-d[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d = map(int,input().split())
s1=set(range(a,b))
s2=set(range(c,d))
print(len(s1&s2))

Submission status: Accepted

Solution code:
# ABC070-B
a, b, c, d = map(int, input().split())
ans = 0
cd = []
for i in range(c, d):
    cd.append(i)
for i in range(a, b):
    if i in cd:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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



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

print(max(0,mi - ma))

Submission status: Accepted

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(max(ans-1, 0))

Submission status: Accepted

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

stt = max(A, C)
end = min(B, D)
print(max(end-stt, 0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

for i in range(101):

    if i >= A and B > i and i >= C and D > i:
        ans += 1

print (ans)

Submission status: Accepted

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(D-A)
	else:
		judge(B-A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if upp > low:
    print(upp - low)
else:
    print(0)

Submission status: Accepted

Solution code:
[a, b, c, d] = [int(x) for x in input().split()]

ans = min(b, d) - max(a, c)
if ans < 0:
  ans = 0
  
print(ans)