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:
a,b,c,d = map(int,input().split())

s1 = set(range(a,b+1))
s2 = set(range(c,d+1))


print(max(len(s1 & s2)-1,0))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc070/tasks/abc070_b"

def main():
    t = list(map(int, input().split()))
    start = max(t[0], t[2])
    end = min(t[1], t[3])
    if end >= start:
        print(end - start)
    else:
        print(0)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
for i in range(100):
    if A <= i < B and C <= 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 = map(int, input().split())
alice = set(i for i in range(a,b+1))
bob = set(j for j in range(c,d+1))
s = alice & bob
print(max(len(alice & bob) - 1, 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(f-e)
else:
  print(0)

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    a,b,c,d = MII()
    print(max(min(b,d)-max(a,c), 0))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

bottom = max(A, C)
top = min(B, D)

if top - bottom > 0:
    print(top - bottom)
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 = (int(x) for x in input().split())

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

Submission status: Accepted

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

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 e-s > 0 else 0)

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

Submission status: Accepted

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

A, B, C, D = LI()


def main():
    x = max(A, C)
    y = min(B, D)
    ans = max(0, y - x)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

s = max(A,C)
e = min(B,D)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, d = 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())
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 < c < b and c < b < d:
    print(b-c)
elif c < a < d and a < d < b:
    print(d-a)
elif a < c < d < b:
    print(d-c)
elif c < a < b < d:
    print(b-a)
elif a == c:
    print(min(b, d))
elif b == d:
    print(min(b-a,d-c))
else:
    print(0)

Submission status: Accepted

Solution code:
t = [0] * 101

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

for i in range(a, b):
    t[i] += 1
for j in range(c, d):
    t[j] += 1
print(t.count(2))

Submission status: Accepted

Solution code:
import math
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

# N = I()
# a = LI()

A, B, C, D = LI()

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

print(ans)

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 e - s > 0 else 0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,D=map(int,input().split())
ali='0'*101
bob='0'*101
ali=ali[:A]+'1'*(B-A)+ali[B+1:]
bob=bob[:C]+'1'*(D-C)+bob[D+1:]
ans=int(ali,2)&int(bob,2)
print(bin(ans).count('1'))

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());r=min(b,d)-max(a,c);print([0,r][r>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())
if b<=c or d<=a:
    print(0)
    exit()
print(abs(max(a,c)-min(b,d)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#n = int(input())
a, b, c, d = map(int, input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

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 = map(int, input().split())

a = []
for i in range(A, B):
    a.append(i)

b = []
for  i in range(C, D):
    b.append(i)

ans = 0
for i in a:
    if i in b:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
#
# abc070 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """0 75 25 100"""
        output = """50"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """0 33 66 99"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 90 20 80"""
        output = """60"""
        self.assertIO(input, output)


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

    if A > C:
        A, C = C, A
        B, D = D, B

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


if __name__ == "__main__":
    # unittest.main()
    resolve()

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(' '))
answer = min(B,D)-max(A,C) 
if answer < 0:
  answer = 0
print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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))
ab = alice + bob
l= [i for i in set(ab) if ab.count(i) > 1]
if 0 == len(l) or 1 == len(l):
    print(0)
elif 2 == len(l):
    print(1)
else:
    print(max(l) - min(l))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, c, d = rm()
max_ = max(a, c)
min_ = min(b, d)
print(max(0, min_ - max_))

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B, C, D = LI()

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

def seconds(a,b,c,d):
  if b<=c or d<=a:
    print(0)
    return
  else:
    st=max(a,c)
    go=min(b,d)
    print(go-st)
    return

seconds(a,b,c,d)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C, D = map(int, readline().split())
    start = max(A, C)
    end = min(B,D)
    print(max(end-start,0))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c, d = M()
print(max(min(b, d) - max(a, c), 0))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, D = list(map(lambda t: int(t), input().split(" ")))
 
if B - A + D - C <= max([D - A, B - C]):
  print(0)
else:
  print(min([B, D]) - max([A, C]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

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

top = min(b,d)
down = max(a,c)

print(max(0, top-down))

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if b<c or a>d:
    print(0)
    exit()

print(new_figs[2]-new_figs[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:
A,B,C,D=map(int,input().split())
start=max(A,C)
end=min(B,D)

print(end-start if start<end else 0)

Submission status: Accepted

Solution code:
A,B,C,D = (int(T) for T in 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:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    lower = max(A, C)
    upper = min(B, D)
    ans = max(upper - lower, 0)

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if a <= c:
  if b <= c:
    pass
  elif b <= d:
    ans = b-c
  else:
    ans = d-c
else:
  if d <= a:
    pass
  elif d <= b:
    ans = d-a
  else:
    ans = b-a
print(ans)

Submission status: Accepted

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

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

for j in range(c, d):
    table[j] += 1

print(table.count(2))

Submission status: Accepted

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

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

for j in range(c, d+1):
    table[j] += 1

print(table.count(2) if table.count(2) == 0 else table.count(2)-1)

Submission status: Accepted

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

print(len(al+cl)-len(set(al+cl)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

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

    tmp = set(list(range(a,b+1))) & set(list(range(c, d+1)))
    print(max(0, len(tmp)-1))


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

Submission status: Accepted

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

if A>=D or C>=B:
    print(0)
else:
    li1 = [B,D]
    li2 = [A,C]
    print(min(li1)-max(li2))

Submission status: Accepted

Solution code:
A,B,C,D=map(int,input().split())
Ans = [0] * 101
for i in range(100+1):
    if A<=i and i<B:
        Ans[i]+=1
    if C<=i and i<D:
        Ans[i]+=1

print(Ans.count(2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a_beg, a_end, b_beg, b_end = map(int, input().split())

beg = max(a_beg, b_beg)
end = min(a_end, b_end)

ans = max(0, end - beg)

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

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

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
S,F,countS,countF = 0,0,0,0
if a<=c:
  countS = c
  S = a
else:
  countS = a
  S = c
if b <= d:
  countF = b
  F = d
else:
  countF = d
  F = b
count=0
flagC = False
for i in range(S,F+1):
  if flagC:
    count+=1
  if i == countS:
    flagC = True
  if i == countF:
    break
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
a,b,c,d=map(int,input().split())
if b<=c or d<=a:
    print(0)
else:
    m=max(a,c)
    M=min(b,d)
    print(M-m)

Submission status: Accepted

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

Submission status: Accepted

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

if finish - start < 0:
  print(0)
else:
  print(finish - start)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

A,B,C,D = MI()

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

Submission status: Accepted

Solution code:
A, B, C, D = list(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 c>b or a>d:
    print(0)
elif a>=c:
    if b>d:
        print(d-a)
    else:
        print(b-a)
else:
    if b>d:
        print(d-c)
    else:
        print(b-c)

Submission status: Accepted

Solution code:
NN =input().split()
a = int(NN[0])
b = int(NN[1])
c = int(NN[2])
d = int(NN[3])
list1=[a,b,c,d]
list1.sort()
ans = list1[2] -list1[1]
if b < c or d < a:
  print(0)
else:
  print(ans)

Submission status: Accepted

Solution code:
a, b, c , d = map(int, input().split(" "))
start = max(a, c)
end = min(b, d)

diff = end - start
if not diff >= 0:
    diff = 0
print(diff)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a1,a2,b1,b2 = map(int,input().split())
a1,a2,b1,b2
count = 0
if a1 <= b1:
    for i in range(a2+1):       
        if i > b1 and i <= b2:
            count += 1
elif b1 <= a1:
    for i in range(b2+1):
        if i > a1 and i <= a2:
            count += 1
print(count)

Submission status: Accepted

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

a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

answer = 0

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

answer = max(0, upper - lower)

print(answer)

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 = [int(x) for x in input().split()]
print(max(min(b, d) - max(a, c), 0))