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:
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
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)
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())
if(a <= c <= b):
    if(d <= b):
        print(abs(c-d))
    else:
        print(abs(c-b))
elif(c <= a <= d):
    if(b <= d):
        print(abs(d-b))
    else:
        print(abs(a-d))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
P = [0 for _ in range(202)]
for p in range(A, A + B + 1): P[p] += 1
for p in range(C, C + D + 1): P[p] += 1
count = 0
for p in P:
  if p == 2: count += 1
print(count)

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

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

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 b < c :
	print(0)
	exit()

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

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

if a == c :
	print(b - a)
	exit()

Submission status: Wrong Answer

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

if b < c :
	print(0)
	exit()

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A==C:
    print(min(B-A,D-C))

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

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

    elif D<=B:
        print(D-A)

Submission status: Wrong Answer

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

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

elif A>C:
    print(max(0,D-A))

else:
    print(abs(B-D))

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:
import sys
input = sys.stdin.readline
li = [int(i) for i in input().split()]
if li[0] < li[2] :
    if li[2] >= li[1] :
        print(0)
    else :
        li.sort()
        print(li[2]-li[1])
elif li[2] > li[0] :
    if li[0] >= li[3] :
        print(0)
    else :
        li.sort()
        print(li[2]-li[1])
else :
    li.sort()
    print(li[2]-li[1])

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a = []
b = []

for i in range(A, B + 1):
  a.append(i)

for i in range(C, D + 1):
  b.append(i)

a.extend(b)

ans = [x for x in set(a) if a.count(x) > 1]
print(len(ans) - 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:



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

if __name__ == "__main__":
        main()

Submission status: Wrong Answer

Solution code:



def main()->None:
    A, B, C, D = map(int, input().split())
    if C < B:
        if D <= B:
            print(D - C)
        else:
            print(B - C)
    else:
        print(0)

if __name__ == "__main__":
        main()

Submission status: Wrong Answer

Solution code:



def main()->None:
    A, B, C, D = map(int, input().split())
    if C < B:
        if D < B:
            print(D - C)
        else:
            print(B - C)
    else:
        print(0)

if __name__ == "__main__":
        main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, input().split())
ans = 0
# 求める秒数は(二つのスイッチのうち先に離された方の時刻) - (二つのスイッチのうち後に押された時刻)となる．
if a <= c <= b:
  _min = min(b, d)
  _max = max(a, c)
  ans = _min - _max
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

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

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)

elif A < C:
    print(D-A)

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

elif A < C:
    print(B-A)

else:
    print(B-C)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

A, B, C, D = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

if B <= C:
    print(0)
    exit()

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

print(B - C)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

if d<a:#0
    print(0)
elif c<a and a<d<b:#1
    print(d-a)
elif c<a and b<d:#2
    print(b-a)
elif a<c and d<b:#3
    print(d-c)
elif a<c<b and b<d:#4
    print(b-c)
elif b<c:#5
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
#S = str(input())

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
#S = str(input())

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
#S = str(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

print(len(alice & bob))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
l=[a,b,c,d]
if b>c:
    l.sort()
    print(l[2]-l[1])
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)
elif (b < d or c < a): print(max(abs(a - d), abs(b - c)) - abs(a - c) - abs(b - d))
else: print(max(abs(a - b), abs(c - d)) - abs(a - c) - abs(b - 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 < d or c < a): print(max(abs(a - d) - abs(a - c) - abs(b - d), abs(b - c) - abs(a - c) - abs(b - d)))
else: print(max(abs(a - b) - abs(a - c) - abs(b - d), abs(c - d) - abs(a - c) - abs(b - d)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = [0]*101
for i in range(a, b+1):
    cnt[i] += 1
for j in range(c, d+1):
    cnt[j] += 1

ans = cnt.count(2)
if ans == -1:
    print(0)
else:
    print(ans-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt = [0]*101
for i in range(a, b+1):
    cnt[i] += 1
for j in range(c, d+1):
    cnt[j] += 1

ans = cnt.count(2)
print(ans-1)

Submission status: Wrong Answer

Solution code:
a,b,c,d=[int(i) for i in input().split()]
start=max(a,c)
end=min(b,d)
print(end-start)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

count = 0
for k in range(1001):
    if k in alice and k in bob:
        print(k)
        count += 1
    else:
        continue
        
if count > 0:
    print(count-1) 
else: 
    print(0)

Submission status: Wrong Answer

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

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

count = 0
for k in range(1001):
    if k in alice and k in bob:
        count += 1
    else:
        continue
        
print(count-1)

Submission status: Wrong Answer

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

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

count = 0
for k in range(1001):
    if k in alice and k in bob:
        count += 1
        print(k)
    else:
        continue
        
print(count-1)

Submission status: Wrong Answer

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

if C < B and A < C:
    if D < B:
        time = D - C
    else:
        time = B - C

if D > A and A > C:
    if D < B:
        time = D - A
    else:
        time = B - A

print(time)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]
    d = i[3]

    if not (0 <= a and a < b and b <= 100 and 0 <= c and c < d and d <= 100):
        return
    if not (isinstance(a, int) and isinstance(b, int) and isinstance(c, int) and isinstance(d, int)):
        return
    
    if(b <= c or d <= a):
        print(0)
    elif(c < b and b <= d):
        print(b - c)
    elif(a <= c and d <= b):
        print(d - c)
    elif(a < d and d <= b):
        print(d - a)
    elif(c <= a and b <= d):
        print(b - a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]
    d = i[3]

    if not (0 <= a and a < b and b <= 100 and 0 <= c and c < d and d <= 100):
        return
    if not (isinstance(a, int) and isinstance(b, int) and isinstance(c, int) and isinstance(d, int)):
        return
    
    if(b <= c or d <= a):
        print(0)
    elif(c < b and b < d):
        print(b - c)
    elif(a <= c and d <= b):
        print(d - c)
    elif(a < d and d < b):
        print(d - a)
    elif(c <= a and b <= d):
        print(b - a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]
    d = i[3]

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]
    d = i[3]

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]
    d = i[3]

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]
    d = i[3]

    if not (0 <= a and a < b and b <= 100 and 0 <= c and c < d and d <= 100):
        return

    alice = b - a
    bob = d -c

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(abs(start - end))

Submission status: Wrong Answer

Solution code:
A,B,C,D  =map(int,input().split())
AB = [str(i) for i in range(A,B+1)]
CD = [str(j) for j in range(C,D+1)]
count = 0

for a in range(101):
  if str(a) in AB and str(a) in CD:
    count += 1
print(count-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import groupby

a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import groupby

a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import groupby

a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
ans = 0
alice = [i for i in range(A,B+1)]
bob = [i for i in range(C,D+1)]
for i in alice:
    if(i in bob):
        ans += 1
print(ans - 1)

Submission status: Wrong Answer

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

la = [0]*(100+1)
lb = [0]*(100+1)

for i in range(a+1,b+1):
	#print(i)
	la[i] = la[i] + 1

for i in range(c+1,d+1):
	#print(i)
	lb[i] = lb[i] + 1

ans = 0
for i in range(100):
	if la[i]==lb[i]==1:
		ans = ans + 1

print(ans)

Submission status: Wrong Answer

Solution code:

line = [int(i) for i in input().split()]
v1 = line[0]
v2 = line[1]
v3 = line[2]
v4 = line[3]


s = v1 if v2 < v1 else v3
e = v2 if v2 < v4 else v4

if v2 < v3 :
  print(0)
  exit()

dif = e-s

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

Submission status: Wrong Answer

Solution code:
line = [int(i) for i in input().split()]
v1 = line[0]
v2 = line[1]
v3 = line[2]
v4 = line[3]


s = v1 if v3 < v1 else v3
e = v2 if v4 < v2 else v4

if v2 < v3 :
  print(0)
  exit()

dif = e-s

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

Submission status: Wrong Answer

Solution code:

line = [int(i) for i in input().split()]
v1 = line[0]
v2 = line[1]
v3 = line[2]
v4 = line[3]

s1 = set(range(v1,v2+1))
s2 = set(range(v3,v4+1))

inter = s1.intersection(s2)


print(len(inter)-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,D=map(int,input().split())
if B<=C:
    print(0)
else:
    X=min(A,C)
    Y=max(B,D)
    Q=abs(Y-X)
    XX=abs(D-B)
    YY=abs(C-A)
    print(Q-(XX+YY))

Submission status: Wrong Answer

Solution code:
A,B,C,D=map(int,input().split())
if B<C:
    print(0)
else:
    X=min(A,C)
    Y=max(B,D)
    Q=Y-X
    XX=abs(D-B)
    YY=abs(C-A)
    print(Q-(XX+YY))

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
 
ans = 0
 
for i in range(max(A, B, C, D)+1):
  if (A <= i and i <= B) and (C <= i and i <= D):
    ans += 1
 
if ans <= 1:
  print(0)
elif A == C and B == D:
  print(B - A)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
 
ans = 0
 
for i in range(max(A, B, C, D)+1):
  if (A <= i and i <= B) and (C <= i and i <= D):
    ans += 1
 
if ans <= 1:
  print(0)
elif A == C and B == D:
  print(ans)
else:
  print(ans-1)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
 
ans = 0
 
for i in range(max(A, B, C, D)+1):
  if (A <= i and i <= B) and (C <= i and i <= D):
    ans += 1
  print(i)
 
if ans <= 1:
  print(0)
elif A == C and B == D:
  print(ans)
else:
  print(ans-1)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
 
ans = 0
 
for i in range(max(A, B, C, D)+1):
  if (A <= i and i <= B) and (C <= i and i <= D):
    ans += 1
 
if ans <= 1:
  print(ans)
elif A == C or B == D:
  print(B - A + 1)
else:
  print(ans-1)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
 
ans = 0
 
for i in range(max(A, B, C, D)+1):
  if (A <= i and i <= B) and (C <= i and i <= D):
    ans += 1
 
if ans <= 1:
  print(ans)
elif A == C and B == D:
  print(B - A)
else:
  print(ans-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(min(0,f-e))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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