Problem: We have N ID cards, and there are M gates.  We can pass the i-th gate if we have one of the following ID cards: the L_i- th, (L_i+1)-th, ..., and R_i-th ID cards.  How many of the ID cards allow us to pass all the gates alone?

Submission attempts (in order):
# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


N, M = lr()
l_list = []
r_list = []
for i in range(M):
    l, r = lr()
    l_list.append(l)
    r_list.append(r)

maxL = 0
minR = 100000000
for i in range(M):
    if maxL == 0:
        maxL = l_list[i]
        minR = r_list[i]
        continue
    max(maxL, l_list[i])
    min(minR, r_list[i])
ans = max(minR - maxL + 1, 0)


# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


N, M = lr()
l_list = []
r_list = []
for i in range(M):
    l, r = lr()
    l_list.append(l)
    r_list.append(r)

maxL = 0
minL = 0
for i in range(M):
    if maxL == 0:
        maxL = l_list[i]
        minR = r_list[i]
        continue
    max(maxL, l_list[i])
    min(minR, r_list[i])
ans = max(maxL - minR + 1, 0)


# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


N, M = lr()
l_list = []
r_list = []
for i in range(M):
    l, r = lr()
    l_list.append(l)
    r_list.append(r)

maxL = 0
minR = 100000000
for i in range(M):
    if maxL == 0:
        maxL = l_list[i]
        minR = r_list[i]
        continue
    max(maxL, l_list[i])
    min(minR, r_list[i])
ans = max(maxL - minR + 1, 0)


# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


N, M = lr()
l_list = []
r_list = []
for i in range(M):
    l, r = lr()
    l_list.append(l)
    r_list.append(r)

maxL = 0
minR = 100000000
for i in range(M):
    if maxL == 0:
        maxL = l_list[i]
        minR = r_list[i]
        continue
    maxL = max(maxL, l_list[i])
    minR = min(minR, r_list[i])
ans = max(minR - maxL + 1, 0)


# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


N, M = lr()
l_list = []
r_list = []
for i in range(M):
    l, r = lr()
    l_list.append(l)
    r_list.append(r)

for i in range(M):
    if i == 0:
        maxL = l_list[i]
        minR = r_list[i]
        continue
    maxL = max(maxL, l_list[i])
    minR = min(minR, r_list[i])
ans = max(minR - maxL + 1, 0)


# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


N, M = lr()
l_list = []
r_list = []
for i in range(M):
    l, r = lr()
    l_list.append(l)
    r_list.append(r)

for i in range(M):
    if i == 0:
        maxL = l_list[i]
        minR = r_list[i]
        continue
    maxL = max(maxL, l_list[i])
    minR = min(minR, r_list[i])
ans = max(minR - maxL + 1, 0)
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted