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:
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/14
# Filename: main 
# Author: acto_mini

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import os
import sys


# ac_py.main
# Date: 2020/06/14
# Filename: main 
# Author: acto_mini

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import os
import sys


# ac_py.main
# Date: 2020/06/14
# Filename: main 
# Author: acto_mini

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

    if B > C:
        if C > A:
            if D > B:
                print(B-C)
            else:
                print(D-C)
        elif A > D:
            print(0)
        else:
            print(B-A)
    else:
        print(0)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import os
import sys


# ac_py.main
# Date: 2020/06/14
# Filename: main 
# Author: acto_mini

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(calc(a, b, c, d))

Submission status: Wrong Answer

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

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

print(calc(a, b, c, d))

Submission status: Wrong Answer

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

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

print(calc(a, b, 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 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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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


def func(a_sec, b_sec, c_sec, d_sec):
    if a_sec < c_sec < b_sec < d_sec:
        temp = b_sec - c_sec
    elif c_sec < a_sec < d_sec < b_sec:
        temp = d_sec - a_sec
    elif a_sec < c_sec < d_sec < b_sec:
        temp = d_sec - c_sec
    elif c_sec < a_sec < b_sec < d_sec:
        temp = b_sec - a_sec
    else:
        temp = 0

    print(temp)


func(a_sec=a, b_sec=b, c_sec=c, d_sec=d)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[0] <= a[2] and a[1] >=a[2]:
        print(min(a[3],a[1]) - max(a[0],a[2]))
    elif a[0] <= a[3] and a[1] >=a[3]:
        print(min(a[3],a[1]) - max(a[0],a[2]))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *

import numpy as np

import math



if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[0] <= a[2] and a[1] >=a[2]:
        print(min(a[3],a[1]) - max(a[0],a[2]))
    elif a[0] <= a[3] and a[3] >=a[2]:
        print(min(a[3],a[1]) - max(a[0],a[2]))    
    else:
        print(0)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[0] <= a[2] and a[1] >=a[2]:
        print(min(a[3],a[1]) - max(a[0],a[2]))
    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) - max(a, c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

if __name__ == '__main__':

    ABC_70_B()

Submission status: Wrong Answer

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

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

if __name__ == '__main__':

    ABC_70_B()

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

a = [input[0], input[1]]
b = [input[2], input[3]]

if a[0] == b[0]:
    print(abs(b[1] - a[1]))
elif a[0] > b[0]:
    a, b = b, a

if a[1] <= b[0]:
    print(0)
elif b[1] <= a[1]:
    print(b[1] - b[0])
else:
    print(a[1] - b[0])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, c, d = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    A = [i for i in range(a, b+1)]
    B = [i for i in range(c, d+1)]

    cnt = 0
    for a in A:
        for b in B:
            if a == b:
                cnt += 1
                break

    print(cnt)


resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:


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


if b<=c :
    result = 0
else:  ## c < b 
    if b < d:  ## c < b < d
        result  = b - c
    else:  ## c < d <= b
        result  = d -c

print(result)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

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

if s <= 0:
    s = 0

print(s)

Submission status: Wrong Answer

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: Wrong Answer

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

print(max(B-C,D-C))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0

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

print(count)

Submission status: Wrong Answer

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

count = 0

for i in range(0,100):
    if A <= i and i <= B and C <= i and i <= D:
        count += 1

count -= 1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    if b <= c:
        ans = 0
    else:
        if c <= a:
            if d <= b:
                ans = d - a
            else:
                ans = b - a
        else:
            if b <= d:
                ans = b - c
            else:
                ans = d - c

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    if b <= c:
        ans = 0
    else:
        if b <= d:
            ans = b - c
        else:
            ans = d - c

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

Submission status: Wrong Answer

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

ans=0

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

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

print(ans)

Submission status: Wrong Answer

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

ans=0

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

if B<C:
    ans=0
else:
    ans=A-B

print(ans)

Submission status: Wrong Answer

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: Wrong Answer

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

# if B >= C:
#     if D >= A:
#         if A <= C:
#             ans = B-C
#         if A > C:
#             ans = B-A
    

# elif B >= D:
#     if D >= A:
#         if A <= C :
#             ans = D-C
#         if A > C:
#             ans = D-A

# AとCのうち大きい方ーBとDのうち小さい方　で求まる
if A < C:
    if B > C:
        ans = max(A,C)-min(B,D)

    


print(ans)

Submission status: Wrong Answer

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

if B >= C:
    if D >= A:
        if A <= C:
            ans = B-C
        if A > C:
            ans = B-A
    

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


print(ans)

Submission status: Wrong Answer

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

if B >= C:
    if A <= C:
        ans = B-C
    if A > C:
        ans = B-A
if B >= D:
    if A <=C :
        ans = D-C
    if A > C:
        ans = D-A

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C,D = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    if B<C:
        cnt = 0
    else:
        cnt = min(B,D)-max(A,C)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Wrong Answer

Solution code:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
A, B, C, D = ri_()
print(min(B, D) - max(A, C))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 2次関数の最大値を求める感じの場合分け
if a >= d or b <= c:
    print(0)
    exit()

if d >= a and c <= a:
    print(d-a)
    exit()

if c >= a and b >= d:
    print(d-c)
    exit()

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

if a >= c and d >= b:
    print(b-a)
    exit()

Submission status: Wrong Answer

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

# 2次関数の最大値を求める感じの場合分け
if a >= d or b <= c:
    print(0)
    exit()

if d >= a and c <= a:
    print(d-a)
    exit()

if c >= a and b >= d:
    print(d-c)
    exit()
    
if d >= b and c <= b:
    print(b-c)
    exit()

Submission status: Wrong Answer

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

# 2次関数の最大値を求める感じの場合分け
if a >= d or b <= c:
    print(0)
elif d >= a and c <= a:
    print(d-a)
elif c >= a and b >= d:
    print(d-c)
elif d >= b and c <= b:
    print(b-c)
else:
    pass

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l_ab = []
l_cd = []
for i in range(a,b+1):
    l_ab.append(i)
for i in range(c,d+1):
    l_cd.append(i)


print(len(set(l_ab)&set(l_cd))-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:
a, b, c, d = map(int, input().split())
s = [a, b, c, d]
s = sorted(s)
if b >= c or a <= d:
    print(s[2] - s[1])
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
for i in range(D - C):
    t = C + i + 1
    if t >= A and t <= B:
        cnt += 1
    else:
        break

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    if b <= c:
        ans = 0
    elif b <= d:
        ans = b - c
    else:
        ans = d - c

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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(int(count-1))

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input().split())
s = range(a,b+1)
m = range(c,d+1)
Ans = list(set(s)|set(m))
print(len(Ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC 070: B – Two Switches
a, b, c, d = map(int, input().split())
print(min(b, d) - max(a, c) if min(b, c) >= max(a, c) else 0)

Submission status: Wrong Answer

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