Problem: p03037
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int, input().split())
gate_l = [[int(x) for x in input().split()] for _ in range(M)]

min_card = max(l[0] for l in gate_l)
max_card = min(l[1] for l in gate_l)

print(max_card - min_card +1)

Failing test case input:
10 3
0 2
4 9
9 14

Expected output:
0


Actual output:
-6


Fixed submission (verdict: Accepted):
N,M = map(int, input().split())
gate_l = [[int(x) for x in input().split()] for _ in range(M)]

min_card = max(l[0] for l in gate_l)
max_card = min(l[1] for l in gate_l)

if max_card >= min_card:
    print(max_card - min_card +1)
    
else:
    print(0)

Problem: p03037
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
l = []
r = []
for i in range(m):
  A, B = list(map(int,input().split()))
  l.append(A)
  r.append(B)

min = 0
max = n
for i in range(m):
  if min < l[i]:
    min = l[i]
  if max > r[i]:
    max = r[i]

print(max - min + 1)

Failing test case input:
8 3
1 7
14 7
2 11

Expected output:
0


Actual output:
-6


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
l = []
r = []
for i in range(m):
  A, B = list(map(int,input().split()))
  l.append(A)
  r.append(B)

min = 0
max = n
for i in range(m):
  if min < l[i]:
    min = l[i]
  if max > r[i]:
    max = r[i]

if max - min + 1 > 0:
  print(max - min + 1)
else:
  print(0)

Problem: p03037
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())

gate = []

l, r = map(int, input().split())


for i in range(M-1):
    tmpl, tmpr = map(int, input().split())
    if l < tmpl:
        l = tmpl
    if tmpr < r:
        r = tmpr

print(r - l + 1)


Failing test case input:
10 3
3 6
11 7
1 9

Expected output:
0


Actual output:
-4


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())

gate = []

l, r = map(int, input().split())


for i in range(M-1):
    tmpl, tmpr = map(int, input().split())
    if l < tmpl:
        l = tmpl
    if tmpr < r:
        r = tmpr


if r - l < 0:
    print(0)
else:
    print(r - l + 1)

Problem: p03037
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M = map(int,input().split())
A = []
B = []
for _ in range(M):
    L,R = map(int,input().split())
    A.append(L)
    B.append(R)
print(min(B)-max(A)+1)

Failing test case input:
14 3
3 2
4 7
8 14

Expected output:
0


Actual output:
-5


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
A = []
B = []
for _ in range(M):
    L,R = map(int,input().split())
    A.append(L)
    B.append(R)
ans = min(B)-max(A)+1
if ans >= 0:
    print(ans)
else:
    print(0)

Problem: p03037
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
L,R = [],[]
for _ in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

print(min(R)-max(L)+1)

Failing test case input:
14 3
3 2
4 7
9 14

Expected output:
0


Actual output:
-6


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
L,R = [],[]
for _ in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

res = min(R)-max(L)+1
if res > 0:
    print(res)
else:
    print(0)