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

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


def check(i, l, r):
    if i == m:
        return max(r - l + 1, 0)
    l_, r_ = map(int, input().split())
    nl = max(l, l_)
    nr = min(r, r_)
    i += 1
    return check(i, nl, nr)


print(check(1, l, r))

Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))

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

li = []
for _ in range(m):
    li.append(list(map(int, input().split())))


def check(i, l, r):
    if i == m:
        try:
            return r - l + 1
        except:
            return 0

    l_, r_ = li[i]
    nl = max(l, l_)
    nr = min(r, r_)
    return check(i + 1, nl, nr)


l, r = li[0]
print(check(1, l, r))


Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))

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

li = []
for _ in range(m):
    li.append(list(map(int, input().split())))


def check(i, l, r):
    if r - l + 1 == 0:
        return 0
    if i == m:
        return r - l + 1
    l_, r_ = li[i]
    nl = max(l, l_)
    nr = min(r, r_)
    return check(i + 1, nl, nr)


l, r = li[0]
print(check(1, l, r))


Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))

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

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


def check(i, l, r):
    if r - l + 1 == 0:
        return 0
    if i == m:
        return r - l + 1
    l_, r_ = map(int, input().split())
    nl = max(l, l_)
    nr = min(r, r_)
    return check(i + 1, nl, nr)


print(check(1, l, r))


Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))

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

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


def check(i, l, r):
    if i == m:
        return r - l + 1
    l_, r_ = map(int, input().split())
    nl = max(l, l_)
    nr = min(r, r_)
    i += 1
    return check(i, nl, nr)


print(check(1, l, r))


Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))

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

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


def check(i, l, r):
    if i == m:
        print(r - l + 1)
        exit(0)
    l_, r_ = map(int, input().split())
    nl = max(l, l_)
    nr = min(r, r_)
    i += 1
    check(i, nl, nr)


check(1, l, r)


Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))

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

# 1個目を受け取る
l, r = map(int, input().split())


def check(i, l, r):
    if i == m:
        print(r - l + 1)
        exit()
    l_, r_ = map(int, input().split())
    nl = max(l, l_)
    nr = min(r, r_)
    i += 1
    check(i, nl, nr)


check(1, l, r)




Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))

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

l = [nu for nu in range(1, n + 1)]

for i in range(m):
    L, R = map(int, input().split())
    card = [nu for nu in range(L, R + 1)]
    l = list(set(l) & set(card))

print(len(l))



Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))

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

l = [0] * (n + 1)
s = 0

for i in range(m):
    L, R = map(int, input().split())
    for j in range(L, R+1):
        l[j] += 1

for k in range(n + 1):
    if l[k] == m:
        s += 1

print(s)


Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))

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

l = [0] * (n + 1)
s = 0

for i in range(m):
    L, R = map(int, input().split())
    for j in range(L, R+1):
        l[j] += 1

for k in range(n + 1):
    if l[k] == m:
        s += 1
print(s)


Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))