Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = []
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())

	for j in range(L, R + 1):
		pass_ids.append(j)

print(int(len([x for x in pass_ids if pass_ids.count(x) == M]) / M))

Fixed submission:
# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [x for x in range(N)]

L_max, R_min = 0, N
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())
	
	if L_max < L:
		L_max = L
	if R_min > R:
		R_min = R


if L_max < R_min + 1:
	print(len(list(range(L_max, R_min + 1))))
else:
	print("0")

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [True] * N
l, r = 0, N
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())

	for j in range(l, L):
		pass_ids[j] = False
	for j in range(R + 1, r):
		pass_ids[j] = False

	if l > L:
		l = L
	if r < R:
		r = R

print(pass_ids.count(True))

Fixed submission:
# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [x for x in range(N)]

L_max, R_min = 0, N
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())
	
	if L_max < L:
		L_max = L
	if R_min > R:
		R_min = R


if L_max < R_min + 1:
	print(len(list(range(L_max, R_min + 1))))
else:
	print("0")

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

N, M = (int(x) for x in input().split())

#pass_ids = [x for x in range(N)]
#for i in range(M):
#	L, R = (int(x) - 1 for x in input().split())
#	pass_ids = [x for x in pass_ids if L <= x <= R]
#
#print(len(pass_ids))

non_pass_ids = set()
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())
	for x in range(0, L):
		non_pass_ids.add(x)
	for x in range(R + 1, N):
		non_pass_ids.add(x)

print(N - len(non_pass_ids))

Fixed submission:
# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [x for x in range(N)]

L_max, R_min = 0, N
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())
	
	if L_max < L:
		L_max = L
	if R_min > R:
		R_min = R


if L_max < R_min + 1:
	print(len(list(range(L_max, R_min + 1))))
else:
	print("0")

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [x for x in range(N)]
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())
	pass_ids = [x for x in pass_ids if L <= x <= R]

print(len(pass_ids))

Fixed submission:
# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [x for x in range(N)]

L_max, R_min = 0, N
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())
	
	if L_max < L:
		L_max = L
	if R_min > R:
		R_min = R


if L_max < R_min + 1:
	print(len(list(range(L_max, R_min + 1))))
else:
	print("0")

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [True] * N
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())
	for j in range(L):
		pass_ids[j] = False
	for j in range(R + 1, N):
		pass_ids[j] = False

print(pass_ids.count(True))

Fixed submission:
# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [x for x in range(N)]

L_max, R_min = 0, N
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())
	
	if L_max < L:
		L_max = L
	if R_min > R:
		R_min = R


if L_max < R_min + 1:
	print(len(list(range(L_max, R_min + 1))))
else:
	print("0")