qyliang/CodeNanoFix huggingface dataset:
Buggy code:
A, B, C, D = map(int, input().split())
if A < C and B < D:
    print(D - A)
elif C <= A and B < D:
    print(D - C)
elif A < C and D <= B:
    print(B - A)
else:
    print(B - C)

Fixed code:
A, B, C, D = map(int, input().split())
if A < C and B < D:
    print(max(0, B - C))
elif C <= A and B < D:
    print(max(0, B - A))
elif A < C and D <= B:
    print(max(0, D - C))
else:
    print(max(0, D - A))
Buggy code:
def abc070_b():
    a, b, c, d = map(int, input().split())

    if c < b or d < a:
        return 0

    if c < a < b < d:
        return b - a

    if a < c < b < d:
        return b - c

    if a < c < d < b:
        return d - c


if __name__ == '__main__':
    print(abc070_b())

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

    if c <= a < b <= d:
        return b - a

    if a <= c < d <= b:
        return d - c

    if a <= c < b <= d:
        return b - c

    if c <= a < d <= b:
        return d - a

    if b <= c or d <= a:
        return 0


if __name__ == '__main__':
    print(abc070_b())
Buggy code:
a,b,c,d = map(int,input().split())

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

Fixed code:

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

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

a = max(0, b-a)

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

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

Fixed code:
a,b,c,d=map(int,input().split())
 
if b<=c or d<=a:
  print(0)
else:
  print(min(d,b)-max(a,c))
Buggy code:
# https://atcoder.jp/contests/abc070/tasks/abc070_b

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

if A >= C:
    start = A
else:
    start = C

if B >= D:
    end = D
else:
    end = B

ans = end - start

print(ans)

Fixed code:
# https://atcoder.jp/contests/abc070/tasks/abc070_b

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

if A >= C:
    start = A
else:
    start = C

if B >= D:
    end = D
else:
    end = B

ans = end - start
if ans < 0:
    ans = 0

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

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


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

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

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

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


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

print(max(min(b, d) - max(a, c), 0))
Buggy code:
A, B, C, D = map(int, input().split())
if C < B:
  A, B, C, D = C, D, A, B
if B <= C:
  print(0)
else:
  print(min(B, D) - C)
  

Fixed code:
A, B, C, D = map(int, input().split())
if A > C:
  A, B, C, D = C, D, A, B
if B <= C:
  print(0)
else:
  print(min(B, D) - C)
Buggy code:
a,b,c,d=map(int,input().split())
print([0,min(b,d)-max(a,c)][max(a,c)<=max(b,d)])


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

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

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

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

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

if (b<=c)|(d<=a):
    print(0)
else:
    if (a<=c)&(b<=d):
        print(b-c)
    elif (c<=a)&(d<=b):
        print(d-a)
    else:
        print(min(d-c,b-a))
Buggy code:
A, B, C, D = map(int, input().split())

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

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

if A<C:
  if B-C < 0:
    print(0)
  else:
    if D-B < 0:
      x = B-D
    else:
      x = 0
    print(B-C-x)
else:
  if D-A < 0:
    print(0)
  else:
    if B-D < 0:
      x = D-B
    else:
      x = 0
    print(D-A-x)
Buggy code:
a, b, c, d = [int(x) for x in input().split()]

if a > c:
    start = a
else:
    start = c

if b < d:
    end = b
else:
    end = d

print(end - start)


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

if a > c:
    start = a
else:
    start = c

if b < d:
    end = b
else:
    end = d

simultaneously = end - start

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

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

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

A = int(tmp.split(" ")[0])
B = int(tmp.split(" ")[1])
C = int(tmp.split(" ")[2])
D = int(tmp.split(" ")[3])

Alice = {str(x): "A" for x in range(A, B + 1)}
Bob = {str(x): "A" for x in range(C, D + 1)}

cnt = 0

for k, v in Alice.items():
  if k in Bob:
    cnt += 1
    
print(cnt - 1)



Fixed code:
tmp = (input())

A = int(tmp.split(" ")[0])
B = int(tmp.split(" ")[1])
C = int(tmp.split(" ")[2])
D = int(tmp.split(" ")[3])

Alice = {str(x): "A" for x in range(A, B + 1)}
Bob = {str(x): "A" for x in range(C, D + 1)}

cnt = 0

for k, v in Alice.items():
  if k in Bob:
    cnt += 1
    
if cnt -1 == -1:
  print(0)
else:
  print(cnt - 1)
Buggy code:
a, b, c, d = map(int, input().split())

start = a if a > c else c
end = b if b < d else d

ans = end - start

print(ans)

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

start = a if a > c else c
end = b if b < d else d

ans = 0 if b < c or d < a else end - start



print(ans)
Buggy code:
list = input().split()
a = list[0]
b = list[1]
c = list[2]
d = list[3]
result = 0
if a < b and c < d:
    if (a >= c and b <= d) or (a <= c and b >= d):
        result = min(b-a,d-c)
    elif a <= c and c <= b:
        result = b - c
    elif c <= a and a <= d:
        result =  d - a
print(result)

Fixed code:
list = input().split()
a = int(list[0])
b = int(list[1])
c = int(list[2])
d = int(list[3])
result = 0
if a < b and c < d:
    if (a >= c and b <= d) or (a <= c and b >= d):
        result = min(b-a,d-c)
    elif a <= c and c <= b:
        result = b - c
    elif c <= a and a <= d:
        result =  d - a
print(result)
Buggy 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 A <= C:
    if B<= C:
        print(0)
    else:
        if B<= D:
            print(C-B)
        else:
            print(D-C)
else:
    if A <= D:
        print(D-A)
    else:
        print(0)

Fixed 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 A <= C:
    if B<= C:
        print(0)
    else:
        if B<= D:
            print(B-C)
        else:
            print(D-C)
else:
    if A <= D:
        if B <= D:
            print(B-A)
        else:
            print(D-A)
    else:
        print(0)
Buggy 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)

Fixed code:
a,b,c,d = map(int,input().split())
if b <= d and a <= c:
	print(max(b-c,0))
elif b <= d and a > c:
	print(max(b-a,0))
elif b > d and a <= c:
	print(max(d-c,0))
else:
	print(max(d-a,0))
Buggy code:
A, B, C, D = map(int, input().split())

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

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

print(len(common) - 1)

Fixed code:
A,B,C,D = map(int,input().split())
 
alice = [i for i in range(A,B + 1)]
bob = [i for i in range(C,D + 1)]
 
common = [i for i in bob if i in alice]

if len(common) == 0:
  print(0)
else:
  print(len(common)-1)
Buggy code:
a,b,c,d = map(int,input().split())
print(max(min(b,d)-max(a,c)),0)

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

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

Fixed code:
a,b,c,d=map(int,input().split())
e=max(a,c)
f=min(b,d)
if e<f:
  print(f-e)
else:
  print(0)
Buggy code:
a,b,c,d = [int(i) for i in input().split()]
if c >= b or d >= a:
  print(0)
else:
  if a <= c and b >= d:
    print(d-c)
  elif c < a and b < d:
    print(b-a)
  elif a <= c < b <= d:
    print(b-c)
  else:
    print(d-a)

Fixed code:
a,b,c,d = [int(i) for i in input().split()]
if c >= b or d <= a:
  print(0)
else:
  if a <= c and b >= d:
    print(d-c)
  elif c < a and b < d:
    print(b-a)
  elif a <= c < b <= d:
    print(b-c)
  else:
    print(d-a)
Buggy code:
a, b, c, d = map(int, input().split())
end = min((a + b),(c + d))
start max(a,c)
r = max(0, end - start)
print(r)


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

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

r = max(0, end - start)
print(int(r))
Buggy code:
#Two switches B

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

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

print(end-start)

Fixed code:
#Two switches B

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

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

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



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

print("0")



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



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

print(mi - ma)

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



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

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

Fixed code:
A, B, C, D = map(int, input().split())
print(max(0, min(B, D) - max(A, C)))
Buggy code:
a,b,c,d = map(int, input().split())
if b<=c or d <=a:
  print(0)
  exit()
print(b-c)

Fixed code:
a,b,c,d = map(int, input().split())
if b<=c or d <=a:
  print(0)
  exit()
if a<=c and d<=b:
  print(d-c)
elif a<=c and b<=d:
  print(b-c)
elif c<=a and d<=b:
  print(d-a)
elif c<=a and b<=d:
  print(b-a)
Buggy code:
A,B,C,D = map(int,input().split())
if C<=A:
    if D>=B:
        print(B-A)
    elif A<=D:
        print(D-A)
    else:
        print(0)
elif C<=B:
    if D<=B:
        print(D-C)
    else:
        print(B-C)
    else:
        print(0)
else:
    print(0)

Fixed code:
A,B,C,D = map(int,input().split())
if B<=C or A>=D:
    print(0)
elif A<C<B<D:
    print(B-C)
elif C<A<D<B:
    print(D-A)
else:
    print(min(D-C,B-A))
Buggy code:
a,b,c,d = map(int, input().split())
if a < b:
    print(max(0, b-c))
else:
    print(max(0, a-d))

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

Fixed code:
a, b, c, d = map(int, input().split())
print(max(0, min(b, d) - max(a, c)))
Buggy code:
A, B, C, D = map(int, input().split(' '))

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


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

if B < C or A > D:
    print(0)
elif A <= C and D <= B:
    print(abs(C-D))
elif C <= A and B <= D:
    print(abs(B-A))
elif C <= A and D <= B:
    print(abs(D-A))
else:
    print(abs(B-C))
Buggy code:
a,b,c,d = map(int,input().split())
ans = 0
for i in range(101):
  if a < i < b and c < i < d:
    ans += 1
print(ans+1)
  


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

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

Fixed code:
a,b,c,d = map(int,input().split())
if b<=c or d<=a:
    print(0)
else:
    print(min(b,d)-max(a,c))
Buggy code:
A,B,C,D = [int(i) for i in input().split()]
print(min(0,min(B,D) - max(A,C))

Fixed code:
A,B,C,D = [int(i) for i in input().split()]
print(max(0,min(B,D) - max(A,C)))
Buggy code:
a,b,c,d = map(int,input().split())

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

Fixed code:
a,b,c,d=map(int,input().split())
if min(b,d)-max(a,c)>=0:
	print(min(b,d)-max(a,c))
else:
	print(0)
Buggy code:
A,B,C,D=map(int,input().split())
print(min(B,D)-max(A,C))

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

if B < D:
    end = B
else:
    end = D

print(end - start)


Fixed code:
A, B, C, D = map(int, input().split(' '))
start = 0
end = 0

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

if A < C:
    start = C
else:
    start = A

if B < D:
    end = B
else:
    end = D

print(end - start)
Buggy code:
from sys import stdin
A,B,C,D = [int(x) for x in stdin.readline().rstrip().split()]
Alice = set(range(A,B+1))
Bob   = set(range(C,D+1))
print(len(Alice & Bob))

Fixed code:
from sys import stdin
A,B,C,D = [int(x) for x in stdin.readline().rstrip().split()]
Alice = set(range(A,B))
Bob   = set(range(C,D))
print(len(Alice & Bob))
Buggy code:
a,b,c,d = map(int,input().split())
ans = 0
for i in range(0,101):
    if a<=i<=b and c<=i<=d:
        ans += 1

print(ans-1)


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

print(ans)
Buggy code:
T = [int(i) for i in input().split()]
if T[0] >= T[3] or T[2] >= T[1]:
  print(0)
elif T[0] >= T[2]:
  print(T[1] - T[2])
elif T[2] >= T[0]:
  print(T[3] - T[0])

Fixed code:
T = [int(i) for i in input().split()]
if T[0] >= T[3] or T[2] >= T[1]:
  print(0)
elif T[0] >= T[2]:
  print(min(T[3] - T[0], T[1] - T[0]))
elif T[2] >= T[0]:
  print(min(T[3] - T[2], T[1] - T[2]))
Buggy code:
A,B,C,D = map(int,input().split())

def judge(ans):
	if ans > 0:
		print(ans)
	else:
		print(0)

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

print(0)


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

def judge(ans):
	if ans > 0:
		print(ans)
	else:
		print(0)

if A < C :
	if B < D: 
		judge(B-C)
	else: 
		judge(D-C)
else:
	if B > D:
		judge(D-A)
	else:
		judge(B-A)
Buggy code:
a, b, c, d = map(int, input().split())
print(max(max(b, d) - min(a, c), 0))

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

    


Fixed code:
a, b , c, d = map(int, input().split())
if b<=c or d <= a :
    print(0)
elif c<=b:
    if c <= a and b<=d:
        print(b-a)
    elif a<= c and b<=d:
        print(b-c)
    elif a<=c and d<=b:
        print(d-c)
    elif c<=a and d<=b:
        print(d-a)
Buggy code:
A, B, C, D = map(int, input())
s = max(A, C)
e = min(B, D)
span = max(0, e - s)
print(span)

Fixed code:
A, B, C, D = map(int, input().split())
s = max(A, C)
e = min(B, D)
span = max(0, e - s)
print(span)
Buggy code:
A,B,C,D=map(int,input().split())
p=min(C,D)-max(A,B)
if p<=0:
  print(0)
else:
  print(p)

Fixed code:
A,B,C,D=map(int,input().split())
p=min(B,D)-max(A,C)
if p<=0:
  print(0)
else:
  print(p)
Buggy code:
a,b,c,d=map(int,input().split());print(min(0,min(b,d)-max(a,c)))

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

def func1(k,l):
    if k>l:
        return l
    else:
        return k

def func(x):
    if (x[2]>x[1]) or (x[0]>x[3]):
        print("Check")
        return 0
    else:
        if x[0]>x[2]:
            return (func1(x[1],x[3])-x[0])
        else:
            return (func1(x[1],x[3])-x[2])

print(func(n))


Fixed code:
n = list(map(int, input().split()))

def func1(k,l):
    if k>l:
        return l
    else:
        return k

def func(x):
    if (x[2]>x[1]) or (x[0]>x[3]):
        return 0
    else:
        if x[0]>x[2]:
            return (func1(x[1],x[3])-x[0])
        else:
            return (func1(x[1],x[3])-x[2])

print(func(n))
Buggy code:

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

Fixed code:
a,b,c,d=map(int,input().split())
if b<=c or d<=a:
    print('0')
elif b<=d:
    print(min(b-c,b-a))
else:
    print(min(d-a,d-c))
Buggy code:
A, B, C, D = list(map(lambda t: int(t), input().split(" ")))

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

Fixed code:
A, B, C, D = list(map(lambda t: int(t), input().split(" ")))
 
if B - A + D - C <= max([D - A, B - C]):
  print(0)
else:
  print(min([B, D]) - max([A, C]))
Buggy 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)

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

Fixed code:
a, b, c, d = map(int, input().split())
t = min(b,d) - max(a,c)
print(max(t, 0))
Buggy 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")

Fixed 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 > 0:
  print(b_d - a_c)
else:
  print("0")
Buggy code:
a, b, c, d = map(int, input().split())

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

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

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


Fixed 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)
Buggy code:
A, B, C, D = (int(x) for x in input().split())
ans = min(B, D) - max(A - C)
if ans < 0:
    ans = 0
print(ans)

Fixed code:
A, B, C, D = (int(x) for x in input().split())
ans = min(B, D) - max(A, C)
if ans < 0:
    ans = 0
print(ans)
Buggy code:
a,b,c,d=map(int,input().split())
print(max(b-c,d-a,0))

Fixed code:
a,b,c,d=map(int,input().split())
print(max(min(b,d)-max(a,c),0))
Buggy code:
A,B,C,D = map(int,input().split())
if C <= B or D <= A:
    print(0)
elif A <= C <= D <= B:
    print(D-C)
elif C <= A <= B <= D:
    print(B-A)
elif C <= B:
    print(B-C)
else:
    print(D-A)


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


Fixed code:
A,B,C,D = map(int,input().split())
print(max(0,min(B,D)-max(A,C)))
Buggy 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)

Fixed 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=abs(A-B)

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

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

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

Fixed code:
a, b, c, d = map(int, input().split())
if b <= c or d <= a:
    ans = 0
else:
    if b <= d and c <= a:
        ans = b - a
    if b <= d and a <= c:
        ans = b - c
    if d <= b and c <= a:
        ans = d - a
    if d <= b and a <= c:
        ans = d - c
print(ans)
Buggy code:
ABCD = list(map(int,input().split()))
if ABCD[1]<=ABCD[]2 or ABCD[3]<=ABCD[0]:
  print(0)
else:
  ABCD.sort()
  print(ABCD[2]- ABCD[1])

Fixed code:
ABCD = list(map(int,input().split()))
if ABCD[1]<=ABCD[2] or ABCD[3]<=ABCD[0]:
  print(0)
else:
  ABCD.sort()
  print(ABCD[2]- ABCD[1])
Buggy code:
a,b,c,d = map(int(input().split()))

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

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

Fixed code:
a, b, c, d = map(int, input().split())
print(max(min(b,d) - max(a,c), 0))
Buggy code:
A,B,C,D = map(int, input().split())

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

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

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

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

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

Fixed code:
A,B,C,D = map(int, input().split())
print(max(0, min(B,D) - max(A,C) ))
Buggy code:
a1,a2,b1,b2=map(int,input().split())
print(max(min(a2,b2)-max(b1,a1),0)


Fixed code:
a1,a2,b1,b2=map(int,input().split())
print(max(min(a2,b2)-max(b1,a1),0))
Buggy code:
A,B,C,D = map(int, input().split())
s = A if A > B else B
e = C if C < D else D
if e < s:
    print(0)
else:
    print(e-s)

Fixed code:
A,B,C,D = map(int, input().split())
s = A if A > C else C
e = B if B < D else D
if e < s:
    print(0)
else:
    print(e-s)
Buggy code:
a,b,c,d = map(int,input().split())
if b<c:
    print(int(0))

if b >= c:
    print(b-c)

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


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

Fixed code:
a,b,c,d=map(int,input().split())
print(max(min(d,b)-max(c,a),0))
Buggy code:
A,B,C,D=map(int, input().split())
print(max(0,B-C))

Fixed code:
A,B,C,D = map(int,input().split())
print(max(0,min(D,B)-max(C,A)))
Buggy 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)

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

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