Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m = map(int,input().split())

li = np.array([i for i in range(1,n+1)])
for i in range(m):
  l,r = map(int,input().split())
  li = li[l <= li]
  li = li[li <= r]
  if len(li)==0:
    break
else:
  print(len(li))
  exit()
print(0)


Fixed submission:
n,m = map(int,input().split())

lans = 1
rans = n
for i in range(m):
  l,r = map(int,input().split())
  lans = max(lans,l)
  rans = min(rans,r)
if lans <= rans:
  print(len(list(range(lans,rans+1))))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())

li = np.array([i for i in range(1,n+1)])
for i in range(m):
  l,r = map(int,input().split())
  li = li[l <= li]
  li = li[li <= r]
  if len(li)==0:
    break
else:
  print(len(li))
  exit()
print(0)

Fixed submission:
n,m = map(int,input().split())

lans = 1
rans = n
for i in range(m):
  l,r = map(int,input().split())
  lans = max(lans,l)
  rans = min(rans,r)
if lans <= rans:
  print(len(list(range(lans,rans+1))))
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

li = list(range(1,n+1))
for i in range(m):
  l,r = map(int,input().split())
  if li[len(li)-1] < l or r < li[0]:
    break
  li = list(range(max(min(li),l),min(max(li),r)+1))
else:
  print(len(li))
  exit()
print(0)

Fixed submission:
n,m = map(int,input().split())

lans = 1
rans = n
for i in range(m):
  l,r = map(int,input().split())
  lans = max(lans,l)
  rans = min(rans,r)
if lans <= rans:
  print(len(list(range(lans,rans+1))))
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

li = list(range(1,n+1))
for i in range(m):
  l,r = map(int,input().split())
  if li[len(li)-1] < l or r < li[0]:
    break
  li = list(range(max(li[0],l),min(li[len(li)-1],r)+1))
else:
  print(len(li))
  exit()
print(0)

Fixed submission:
n,m = map(int,input().split())

lans = 1
rans = n
for i in range(m):
  l,r = map(int,input().split())
  lans = max(lans,l)
  rans = min(rans,r)
if lans <= rans:
  print(len(list(range(lans,rans+1))))
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
li = [0]*m
for i in range(m):
  li[i] = list(map(int,input().split()))

ans = 0
for i in range(1,n+1):
  for j in range(m):
    if i < li[j][0] or li[j][1]< i:
      break
  else:
    ans += 1
print(ans)

Fixed submission:
n,m = map(int,input().split())

lans = 1
rans = n
for i in range(m):
  l,r = map(int,input().split())
  lans = max(lans,l)
  rans = min(rans,r)
if lans <= rans:
  print(len(list(range(lans,rans+1))))
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
li = [0]*m
for i in range(m):
  li[i] = list(map(int,input().split()))

ans = 0
for i in range(1,n+1):
  cnt = 0
  for j in range(m):
    if li[j][0] <= i <= li[j][1]:
      cnt += 1
      continue
    else:
      break
  if cnt == m:
    ans += 1
print(ans)

Fixed submission:
n,m = map(int,input().split())

lans = 1
rans = n
for i in range(m):
  l,r = map(int,input().split())
  lans = max(lans,l)
  rans = min(rans,r)
if lans <= rans:
  print(len(list(range(lans,rans+1))))
else:
  print(0)