Problem:


Score : 200 points

Problem Statement

Alice and Bob are controlling a robot. They each have one switch that controls the robot.

Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.

Bob started holding down his button C second after the start-up, and released his button D second after the start-up.

For how many seconds both Alice and Bob were holding down their buttons?

Constraints

0≤A<B≤100

0≤C<D≤100

All input values are integers.

Input

Input is given from Standard Input in the following format:  

A B C D

Output

Print the length of the duration (in seconds) in which both Alice and Bob were holding down their buttons.

Sample Input 1

0 75 25 100

Sample Output 1

50

Alice started holding down her button 0 second after the start-up of the robot, and released her button 75 second after the start-up.

Bob started holding down his button 25 second after the start-up, and released his button 100 second after the start-up.

Therefore, the time when both of them were holding down their buttons, is the 50 seconds from 25 seconds after the start-up to 75 seconds after the start-up.

Sample Input 2

0 33 66 99

Sample Output 2

0

Alice and Bob were not holding their buttons at the same time, so the answer is zero seconds.

Sample Input 3

10 90 20 80

Sample Output 3

60



Sample input:
0 75 25 100


Sample output:
50

Submission status: Wrong Answer

Solution code:
# coding: utf-8
line = input().rstrip().split()

A = int(line[0])
B = int(line[1])
C = int(line[2])
D = int(line[3])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
print(len(set(range(A, B+1)) & set(range(C, D+1))))

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
print(len(set(range(A, B+1)) & set(range(A, B+1))))

Submission status: Wrong Answer

Solution code:
num = input().split()
num = [int(x) for x in num]

if num[1] < num[2] or num[3] < num[0]:
    print(0)
elif num[1] > num[2]:
    print(min(num[1], num[3])-max(num[2], num[0]))

Submission status: Wrong Answer

Solution code:
num = input().split()
num = [int(x) for x in num]

if num[1] < num[2] or num[3] < num[0]:
    print(0)
elif num[1] > num[2]:
    print(min(num[1], num[3])-num[2])
else:
    print(min(num[3],num[1]) - num[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

difB = c - a
difE = d - b

print(b - a - difB + difE)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
s = input().split()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])
 
a_c = max(A, C)
b_d = min(B, D)
 
if b_d - a_c:
  print(b_d - a_c)
else:
  print("0")

Submission status: Wrong Answer

Solution code:
s = input().split()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])

a_c = max(A, C)
b_d = min(B, D)

if a_c - b_d:
  print(a_c - b_d)
else:
  print("0")

Submission status: Wrong Answer

Solution code:

i = input().split()

A = int(i[0])
B = int(i[1])
C = int(i[2])
D = int(i[3])

# correct
def me():
    if C >= B or D <= A:
        print(0)
        return
    # correct
    if C >= A:
        
        if D <= B:
            print(D - C)
            return
        else:
            print(B - C)
            return

    if C <= A:

        if D >= B:
            print(B - A)
            return
        else:
            print(D - B)
            return

me()

Submission status: Wrong Answer

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

A = int(i[0])
B = int(i[1])
C = int(i[2])
D = int(i[3])

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

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

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

Submission status: Wrong Answer

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

A = int(i[0])
B = int(i[1])
C = int(i[2])
D = int(i[3])

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if(b<=c):
    print(0)
else:
    z=b-c
    print(z)

Submission status: Wrong Answer

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

if S[1]<S[2] or S[3]<S[0]:
    print('0')
else:
    if S[0]<S[2]:
        print(abs(S[1]-S[2]))
    else:
        print(abs(S[0]-S[3]))

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
counter = 0
for i in range (101):
  if a[0] <= i <= a[1] and a[2] <= i <= a[3]:
    counter += 1
print ('{0}'.format(counter - 1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve(): # 070A - Palindromic Number
    A, B, C, D = list(map(int, input().split(" ")))

    if A < C <= B < D:
        print(B - C)
    elif C < A <= D < B:
        print(D - A)
    elif A < C < D < B:
        print(D - C)
    elif C < A < B < D:
        print(B - A)
    elif (A == C)  and (B == D):
        print(B - A)
    elif A == C or B == D:
        print(min(abs(B-A), abs(D-A)))
    else:
        print(0)
        
        
solve()

Submission status: Wrong Answer

Solution code:
def solve(): # 070A - Palindromic Number
    A, B, C, D = list(map(int, input().split(" ")))

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

Submission status: Wrong Answer

Solution code:
def solve(): # 070A - Palindromic Number
    A, B, C, D = list(map(int, input().split(" ")))

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

Submission status: Wrong Answer

Solution code:
def solve(): # 070A - Palindromic Number
    A, B, C, D = list(map(int, input().split(" ")))

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

Submission status: Wrong Answer

Solution code:
def solve(): # 070A - Palindromic Number
    A, B, C, D = list(map(int, input().split(" ")))

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

Submission status: Wrong Answer

Solution code:
def solve(): # 070A - Palindromic Number
    A, B, C, D = list(map(int, input().split(" ")))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

N = input()

for i in range(len(N)):
  if N[i] != N[len(N)-1-i]:
    print("No")
    sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:

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

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

a = max(0.0, b-a)

print(a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

if(B<C or A<C):
    print("0")
else:
    if(A>=C):
        begin = A
    else:
        begin = C
    if(D<=B):
        end = D
    else:
        end = B
    print(end-begin)

Submission status: Wrong Answer

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

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

if(B<C):
    print("0")
else:
    if(A>=C):
        begin = A
    else:
        begin = C
    if(D<=B):
        end = D
    else:
        end = B
    print(end-begin)

Submission status: Wrong Answer

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

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

if(B<C):
    print("0")
else:
    if(A>=C):
        begin = A
    else:
        begin = C
    if(D<B):
        end = D
    else:
        end = B
    print(end-begin)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def getInput():
    separator = ' '
    ret_array = []
    while True:
        try:
            row = input().split(sep=separator)
            ret_array.append(row)
        except EOFError:
            break
    return ret_array


inp = getInput()
i = inp[0]
A, B, C, D = (int(x) for x in i)
ret = 0

if B <= C or D <= A:
    ret = 0
elif C < B:
    ret = min(B - C, D - C)
elif A < D:
    ret = min(D - A, B - A)

print(ret)

Submission status: Wrong Answer

Solution code:
sec = input().split(' ')
#sec = ['0','75','25','100']
#sec = ['0','33','66','99']
#print(sec[0],sec[1],sec[2],sec[3])
#開始時間選定
start = max(sec[0],sec[2])
#print('開始:' + start)
#終了時間選定
end = min(sec[1],sec[3])
#print('終了:' + end)
kekka =(int(end) - int(start))
if kekka < 1:
	kekka = 0
	print(kekka)
else:
	print(kekka)

Submission status: Wrong Answer

Solution code:
sec = input().split(' ')
#sec = ['0','75','25','100']
#sec = ['0','33','66','99']
#print(sec[0],sec[1],sec[2],sec[3])
#開始時間選定
start = max(sec[0],sec[2])
#print('開始:' + start)
#終了時間選定
end = min(sec[1],sec[3])
#print('終了:' + end)
kekka =(int(end) - int(start))
if kekka < 1:
	print('0 秒です。')
else:
	print(kekka)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a >= c:
    ans = b - c
else:
    ans = d - a

if ans < 0:
    print 0
else:
    print ans

Submission status: Wrong Answer

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

print a, b, c, d

if a >= c:
    ans = b - c
else:
    ans = d - a

if ans < 0:
    print 0
else:
    print ans

Submission status: Wrong Answer

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

print a, b, c, d

if a >= c:
    tmpa = a
else:
    tmpa = c

if b >= d:
    tmpb = d
else:
    tmpb = b

ans = tmpb - tmpa

if ans < 0:
    print 0
else:
    print ans

Submission status: Wrong Answer

Solution code:



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

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

Submission status: Wrong Answer

Solution code:



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

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

Submission status: Wrong Answer

Solution code:



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

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

Solution code:



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

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

Submission status: Wrong Answer

Solution code:



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

if(b<c):print (0)
else:
    start = a if a>c else c
    end = b if b<d else d
    print(end - start)

Submission status: Wrong Answer

Solution code:
import sys
a, b, c, d = (int(i) for i in input().split())
if b-c<=0:
    print(0)
    sys.exit()
else:
    an = min(b-a,d-c,b-c,d-a)
    print(an)

Submission status: Wrong Answer

Solution code:
import sys
a, b, c, d = (int(i) for i in input().split())
if b-c<=0:
    print(0)
    sys.exit()
else:
    an = min(b-a,d-c,b-c)
    print(an)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

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

a = l[0]
b = l[1]
c = l[2]
d = l[3]

s = (a + b) - c

if s < 0:
	s = 0

print(s)

Submission status: Wrong Answer

Solution code:

a=4
b=4
c=4
d=4

max=0
min=0

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

Submission status: Wrong Answer

Solution code:
l = list(map(int, input().split()))
if l[0] > l[2]:
    start = l[0]
else:
    start = l[2]

if l[1] > l[3]:
    end = l[3]
else:
    end = l[1]
if l[1] < l[2] | l[3] < l[0]:
    print(0)
else:
    print(end - start)

Submission status: Wrong Answer

Solution code:
l = list(map(int, input().split()))
if l[0] > l[2]:
    start = l[0]
else:
    start = l[2]

if l[1] > l[3]:
    end = l[3]
else:
    end = l[1]
if l[1] < l[2]:
    print(0)
else:
    print(end - start)

Submission status: Wrong Answer

Solution code:
l = list(map(int, input().split()))
if l[0] > l[2]:
    start = l[0]
else:
    start = l[2]

if l[1] > l[3]:
    end = l[3]
else:
    end = l[1]
print(end - start)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

userinput = input()

userlist = userinput.split()

aStart = int(userlist[0])
aStop = int(userlist[1])

bStart = int(userlist[2])
bStop = int(userlist[3])

total = 0

if aStart <= bStart:
	if aStop >= bStart:
		total = (aStop-aStart) - bStart


print (total)

Submission status: Wrong Answer

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

print(count-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ABC070B

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

Submission status: Wrong Answer

Solution code:
#ABC070B

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def ans(nlist ,max,min):
    if ((int)(nlist[max])>(int)(nlist[min+1]) or (int)(nlist[min])>(int)(nlist[max+1])):
        print(0)
        return
    if ((int)(nlist[min])<(int)(nlist[max])):
        print((int)(nlist[min+1])-(int)(nlist[max]))
        return
    if ((int)(nlist[min+1])>(int)(nlist[max+1])):
        print((int)(nlist[max+1])-(int)(nlist[min]))
        return
    
    print((int)(nlist[min+1])-(int)(nlist[min]))

fnum=input()
fnum=fnum.split(' ')

max= 0 if (int(fnum[1])-int(fnum[0]))>(int(fnum[2])-int(fnum[3])) else 2
min=2-max
ans(fnum,max,min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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)

print (len(pushed_time) -1 )

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

N = sys.stdin.readline()

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

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

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

Submission status: Wrong Answer

Solution code:
N=input().split()
A=int(N[0])
B=int(N[1])
C=int(N[2])
D=int(N[3])

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

N = sys.stdin.readline()

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

least = max(N[0], N[2])
most = min(N[1], N[3])

print abs(most- least)

Submission status: Wrong Answer

Solution code:
import sys

N = sys.stdin.readline()

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

least = max(N[0], N[2])
most = min(N[1], N[3])

print most- least

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    Nums = list(map(int, input().split()))
    tmp = Nums[1] - Nums[2]
    if tmp > 0:
        print(tmp)
    else:
        print('0')

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

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

Submission status: Wrong Answer

Solution code:
nums = [int(x) for x in input().split()]
A,B,C,D = nums[0],nums[1],nums[2],nums[3]
same = 0
if A < C <= B < D: 
	same += B-C
elif C < A < B < D:
	same += B - A
elif A < C < D < B:
	same += D - C
else:
	same += 0

print(same)

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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