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:
import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    a, b, c, d = read_int_list()
    res = abs(max(a, c) - min(b, d))
    if c >= b or a >= d:
        res = 0
    print(res)


main()

Submission status: Accepted

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

if __name__=="__main__":
    solve()

Submission status: Accepted

Solution code:
# your code goes here
A,B,C,D=(int(i) for i in input().split())
if A<C:
    A=C
if B>D:
    B=D
B-=A
if B<0:
  print(0)
else:
  print(B)

Submission status: Accepted

Solution code:
# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(len(pushed_time) - 1)

Submission status: Accepted

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

answer = 0
for i in xrange(101):
  if A <= i < B and C <= i < D:
    answer += 1

print answer

Submission status: Accepted

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

b()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = input()
num_ABCD = num.split()
num_A = int(num_ABCD[0])
num_B = int(num_ABCD[1])
num_C = int(num_ABCD[2])
num_D = int(num_ABCD[3])
if num_B <= num_C or num_D <= num_A:
    print(0)
else:
    if num_A <= num_C and num_B <= num_D:
        print(num_B - num_C)
    elif num_A <= num_C and num_B >= num_D:
        print(num_D - num_C)
    elif num_A >= num_C and num_B <= num_D:
        print(num_B - num_A)
    elif num_A >= num_C and num_B >= num_D:
        print(num_D - num_A)

Submission status: Accepted

Solution code:
a, b, c, d = map(int, raw_input().split())
table = dict()
for i in range(101):
    table[i] = 0
for i in range(a, b + 1):
    table[i] += 1
for i in range(c, d + 1):
    table[i] += 1
result = 0
for i in table:
    if table[i] == 2:
        result += 1
print(result - 1 if result > 0 else '0')

Submission status: Accepted

Solution code:
import sys

N = sys.stdin.readline()

N = N.split()
N = map(int, N)

if N[2] > N[1] or N[0] > N[3]:
	print 0

else:
	least = max(N[0], N[2])
	most = min(N[1], N[3])
	
	print abs(most- least)

Submission status: Accepted

Solution code:
a = input().split()
ast = int(a[0])
aen = int(a[1])
bst = int(a[2])
ben = int(a[3])
if ast > ben or bst > aen:
    print("0")
elif ast < bst and aen < ben:
    print(aen - bst)
elif ast < bst and aen > ben:
    print(ben - bst)
elif bst < ast and ben < aen:
    print(ben - ast)
elif bst < ast and ben > aen:
    print(aen - ast)
elif ast == bst and aen < ben:
    print(aen - ast)
elif ast == bst and aen > ben:
    print(ben - ast)
elif ast < bst and aen == ben:
    print(ben - bst)
elif ast > bst and aen == ben:
    print(aen - ast)
elif ast == bst and aen == ben:
    print(aen - ast)
else:
    print("0")

Submission status: Accepted

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


if A < C:
  a = C
else:
  a = A

if B < D:
  b = B
else:
  b = D
  
if B <= C or D <= A:
  res = 0
else:
  res = (b-a)
  
print(res)

Submission status: Accepted

Solution code:
[a,b,c,d]=[int(i) for i in input().split()]
if a<c:
  x1=a
  x2=c
  y1=b
  y2=d
else:
  x1=c
  x2=a
  y1=d
  y2=b
if y1<x2:
   c=0
elif x2<=y1<=y2:
   c=y1-x2
else:
   c=y2-x2
print(c)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    Num = list(map(int, input().split()))
    st = [Num[0], Num[2]]
    en = [Num[1], Num[3]]
    if min(en) - max(st) > 0:
        print(min(en) - max(st))
    else:
        print('0')

Submission status: Accepted

Solution code:
def main():
    A, B, C, D = list(map(int, input().strip().split()))
    print(calc(A, B, C, D))


def calc(A, B, C, D):
    # bがa包含
    # aがb包含
    # a start をbが包含
    # a end をbが包含
    if C <= A <= B <= D:
        return B - A
    elif A <= C <= D <= B:
        return D - C
    elif C <= A <= D:
        return D - A
    elif C <= B <= D:
        return B - C
    else:
        return 0

if __name__ == '__main__':
    main()

Submission status: Accepted

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

m = [0 for i in range(101)]
n = [0 for i in range(101)]

i = a
while(True):
    m[i] = 1
    if(i == b):
        break
    i+=1
i = c
while(True):
    n[i] = 1
    if(i == d):
        break
    i+=1

ans = 0
for i in range(101):
    if(m[i] * n[i] == 1):
        ans+=1

if(ans!=0):
    ans-=1

print(ans)

Submission status: Accepted

Solution code:
nums = [int(x) for x in input().split()]
nums = [ [nums[0],nums[1]] ,
         [nums[2],nums[3]] ]
N = 100
imos = [0 for i in range(N+2)]

for num in nums:
    a,b = num[0],num[1]-1
    imos[a] += 1
    imos[b+1] -= 1
 
ans = []
j = 0
for i in imos:
    ans.append(j+i)
    j += i

print(ans.count(2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=map(int, raw_input().split())
#print a

a_start=a[0]
a_end=a[1]
b_start=a[2]
b_end=a[3]

if a_start<=b_start:
	c_start=b_start
else:
	c_start=a_start

#print c_start

if a_end<b_end:
	c_end=a_end
else:
	c_end=b_end

#print c_end

if c_end-c_start<0:
	print 0
else:
	print c_end-c_start

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    sw = [0] * 101
    sw[A] = 1
    sw[B] = -1
    sw[C] += 1
    sw[D] += -1
    for i in range(1, 101):
        sw[i] = sw[i-1] + sw[i]

    ans = sw.count(2)
    print(ans)

main()

Submission status: Accepted

Solution code:
def Q2(x):
    A, B, C, D = x[0], x[1], x[2], x[3]
    if B <= C or D <= A:
        return 0
    else:
        if A <= C:
            return min(B, D) - C
        else:
            return min(B, D) - A
          
l = [int(i) for i in input().split()]
print(Q2(l))

Submission status: Accepted

Solution code:
xa, ya, xb, yb = map(int, input().split())

if xa > xb:
    x = xa
else:
    x = xb
if ya > yb:
    y = yb
else:
    y = ya
ans = y - x
if ans <= 0:
    print(0)
else:
    print(ans)

Submission status: Accepted

Solution code:
sp=list(map(int,input().split()))
time=min(sp[1],sp[3])-max(sp[0],sp[2])
if time >= 0:
	print(time)
else:
	print(0)

Submission status: Accepted

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

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

if abcd[0] >= abcd[3]:
    print 0
elif abcd[2] >= abcd[1]:
    print 0
elif abcd[0] < abcd[2]:
    if abcd[1] < abcd[3]:
        print abcd[1] - abcd[2]
    else:
        print abcd[3] - abcd[2]
else:
    if abcd[1] > abcd[3]:
        print abcd[3] - abcd[0]
    else:
        print abcd[1] - abcd[0]

Submission status: Accepted

Solution code:
a = map(int, raw_input().strip().split())
b = max(a[0],a[2])
c = min(a[1],a[3])
if c > b:
	ans = c-b
else:
	ans = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l=list(map(int,input().strip().split(' ')))
a=l[0]
b=l[1]
c=l[2]
d=l[3]
l1=[x for x in range(a,b+1)]
l2=[x for x in range(c,d+1)]
l3=[]
ans=0
for i in l2:
    if i in l1:
        ans+=1
print(max(0,ans-1))

Submission status: Accepted

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

Submission status: Accepted

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

s = max(a,c)
t = min(b,d)
d = t-s
print(d if d > 0 else 0)

Submission status: Accepted

Solution code:
A, B, C, D = input().split(' ')
A = int(A)
B = int(B)
C = int(C)
D = int(D)
ab = set([ x for x in range(A, B)])
cd = set([ x for x in range(C, D)])
#print(ab, cd)
print(len(ab & cd))
#print(A,B,C,D)
#print(abs((B-A) - C + ( D-C )))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if A > D or C > B:
    print(0)
else:
    print(min(B,D)-max(A,C))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = raw_input()
abcd = map(int, s.split())
if abcd[0] > abcd[2]:
	begin = abcd[0]
else:
	begin = abcd[2]
if abcd[1] > abcd[3]:
	end = abcd[3]
else:
	end = abcd[1]

if (end - begin) >= 0:
	print(end - begin)
else:
	print(0)

Submission status: Accepted

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

if B <= C:
    print("0")
elif D <= A:
    print("0")
else:
    start = max([A, C])
    end = min([B, D])
    print(end - start)

Submission status: Accepted

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

Submission status: Accepted

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

print(max(0, ans - 1))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

counter=0
for i in range(101):
    if A<=i and i<B and C<=i and i<D:
        counter+=1
print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

time = min(b[1],b[3]) - max(b[0],b[2])

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

Submission status: Accepted

Solution code:
A, B, C, D = map(int, input().split())
X = set(range(A, B))
Y = set(range(C, D))
print(len(X.intersection(Y)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    A, B, C, D = ILI()
    return A, B, C, D


def solve(A, B, C, D):
    l_ans = [0] * 101
    for a in range(A, B + 1):
        l_ans[a] += 1
    for b in range(C, D + 1):
        l_ans[b] += 1

    ans = 0
    for a in l_ans:
        if a == 2:
            ans += 1

    if ans != 0:
        ans -= 1

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

sec=end-start

if sec<0:
  print 0
else:
  print sec

Submission status: Accepted

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

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



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

    alice = [A <= t < B for t in range(100)]
    bob   = [C <= t < D for t in range(100)]

    cnt = 0
    for t in range(100):
        if alice[t] and bob[t]:
            cnt += 1

    print(cnt)

if __name__ == "__main__": main()

Submission status: Accepted

Solution code:


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

    xs = [0] * 101
    xs[a] += 1
    xs[b] -= 1
    xs[c] += 1
    xs[d] -= 1

    cursum = 0
    t = 0
    for x in xs:
        cursum += x
        if cursum == 2:
            t += 1

    print(t)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if B <= C or D <= A:
	ans = 0
elif A <= C and B <= D:
	ans = B - C
elif A <= C and D <= B:
	ans = D - C
elif C <= A and D <= B:
	ans = D - A
elif C <= A and B <= D:
	ans = B - A

print(ans)

Submission status: Accepted

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

start = max(a,c)
stop = min(b,d)
time = stop-start

if time<0:
    print("0")
else:
    print(time)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

def spaceinput():
    return list(map(int,input().split(" ")))



x=spaceinput()

l=max(x[0],x[2])
r=min(x[1],x[3])
v=r-l
if v>0:
    print(v)
else:
    print(0)

Submission status: Accepted

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

st = max(A, C)
ed = min(B, D)

print(max(ed - st, 0))

Submission status: Accepted

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

ans = 0

if B < C:
    pass
elif D < A:
    pass
else:
    ans = min(B, D) - max(A, C)

print ans

Submission status: Accepted

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

if c>b  or a>d:
    print("0")
else:
    print(b+d-a-c-(max(a,b,c,d)-min(a,b,c,d)))

Submission status: Accepted

Solution code:
a, b, c, d = map(int, input().split())		# 0 75 25 100


x = max(a,c)
y = min(b,d)

z = max(y-x,0)

print(z)

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 = [int(i) for i in input().split()]
overlap = min(A[1], A[3]) - max(A[0], A[2])
if overlap >= 0:
    print(str(overlap))
else:
    print("0")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f():
    a,b,c,d=map(int,input().split(' '))
    arun=range(a,b)
    brun=range(c,d)
    s=0
    for i in range(0,100):
        if i in arun and i in brun:
            s=s+1
    print(s)
f()

Submission status: Accepted

Solution code:
A,B,C,D = list(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, raw_input().split())

s = 0
on_a = 0
on_b = 0
for i in range(101):
    if i == a:
        on_a = 1
    if i == b:
        on_a = 0
    if i == c:
        on_b = 1
    if i == d:
        on_b = 0
#    print(i, on_a, on_b)
    if on_a and on_b:
        s += 1

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8
 
def main():
	a, b, c, d = list(map(int, input().split()))
	st = max(a, c)
	en = min(b, d)
	dr = max(en - st, 0) 
	print(dr)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
def f(a, b, c, d):
    if a <= c:
        if b <= c:
            return 0
        if b <= d:
            return b - c
        else:
            return d - c
    else:
        return f(c, d, a, b)

a, b, c, d = [int(x) for x in input().strip().split()]
print(f(a, b, c, d))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def compute(a, b, c, d):
    return max(0, min(b, d) - max(c, a))


def main():
    a, b, c, d = (int(x) for x in input().split())
    print(compute(a, b, c, d))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))

a, b, c, d = rli()
print(max(0, b-c-max(0, a-c) - max(0, b-d)))

Submission status: Accepted

Solution code:

A, B, C, D = map(int, input().split())
ans = min(B,D) - max(A,C)

if ans > 0:
    print(ans)
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:
press = 0
a, b, c, d = map(int,input().split())
for i in range(101):
    if a<=i<b and c<=i<d: press+= 1
print(press)

Submission status: Accepted

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

ans = 0
for i in range(101):
    if i in range(a,b) and i in range(c,d):
        ans += 1

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:
a, b, c, d = map(int, raw_input().split())
print max(0, min(b, d) - max(a, c))

Submission status: Accepted

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

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:
A,B,C,D = map(int, raw_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(min(B, D)-max(A, C),0))

Submission status: Accepted

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

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

duration = max(0, end-start)

print duration

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

Submission status: Accepted

Solution code:
a, b, c, d = map(int, raw_input().split())
A = [0 for i in xrange(150)]

for i in xrange(150):
    if a <= i < b:
        A[i] += 1
    if c <= i < d:
        A[i] += 1

print A.count(2)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A, B, C, D=map(int, input().split())
X=set([for i in range(A, B+1)])
print(sum([1 for i in range(C, D+1) if i in X]))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

if l[1] < l[2]:
    print(0)
elif l[0] > l[4]:
    print(0)
else:
    l.sort()
    print(l[2]-l[1])

Submission status: Runtime Error

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

if l[1] < l[2]:
    print(0)
elif l[0] > l[4]:
    print(0)
else:
    print(l[2]-l[1])

Submission status: Runtime Error

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

l.sort()

print(l[2]-l[1])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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: Runtime Error

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

s = min(B-C,D-C)

if s <= 0:
    s = 0

print(s

Submission status: Runtime Error

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

if A<C:
    A=C
if D<B
    B=D

print(A-B)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

A, B, C, D = map(int, input().split())
x = zip(*sorted(zip([A, B, C, D], [1, -1, 1, -1])))
if x[1][1] == 1:
  print(x[2][0] - x[1][0])
else:
  print(0)

Submission status: Runtime Error

Solution code:
import numpy as np

A, B, C, D = map(int, input().split())
x, y = zip(*sorted(zip([A, B, C, D], [1, -1, 1, -1])))
print(np.diff(x)[np.cumsum(y)[:-1] == 2][0])

Submission status: Runtime Error

Solution code:
0 75 25 100

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int A, B, C, D;
    int min, max;
    cin >> A >> B >> C >> D;

    min = (A > C) ? A : C;
    max = (B > D) ? D : B;

    if( max < min ){
        cout << 0 << endl;
    }else{
        cout << max - min << endl;
    }
    return 0;
}

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if a <= c:
  if b <= c:
    print(0)
    exit()
  
  if b <= d:
    print(b-c)
  elif b >d:
    print(d-c)
    
    
if a > c:
  if d <= a:
    print(0)
    eixt()
    
  if d <= b:
    print(d-a)
  elif d > b:
    print(b-a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A,B,C,D = map(int,readline().decode('utf8').rstrip())

print(B-C if B>C else 0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline().strip
a,b,c,d=map(int,input().split())
if b<c or d<a:
    print(0)
elif print(max(b,d)-min(a,c))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int start = max(a, c);
  int end = min(b, d);

  if (start < end) cout << end - start << endl;
  else cout << 0 << endl;
}

Submission status: Runtime Error

Solution code:
A,B,C,D = (int(i) for i in input().split())
Alice_time = set(range(A,B+1))
Bob_time = set(range(C,D+1))
common_time = Alice_time & Bob_time
common_time_list = list(common_time)
common_time_list_sorted = sorted(common_time_list)
print(common_time_list_sorted[-1]-common_time_list_sorted[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

combine_alice_bob = alice + bob
#print(combine_alice_bob)
for i in range(len(alice)):
    for j in range(len(bob)):
        if (alice[i]==bob[j] and alice[i+1]==bob[j+1]) or (bob[i]==alice[j] and bob[i+1]==alice[j+1]):
            alice_bob = set(combine_alice_bob)
            print(len(combine_alice_bob)-len(alice_bob)-1)
            exit()
        elif alice[0]==bob[j] and alice[-1]==bob[j]:
            print(len(alice)-1)
            exit()
        elif bob[0]==alice[j] and bob[-1]== alice[j]:
            print(len(bob)-1)
            exit()
print(0)

Submission status: Runtime Error

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

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

combine_alice_bob = alice + bob
#print(combine_alice_bob)
for i in range(len(alice)):
    for j in range(len(bob)):
        if (alice[i]==bob[j] and alice[i+1]==bob[j+1]) or (bob[i]==alice[j] and bob[i+1]==alice[j+1]):
            alice_bob = set(combine_alice_bob)
            print(len(combine_alice_bob)-len(alice_bob)-1)
            exit()

print(0)