Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

c = [0 for _ in range(N)]
cnt = 0
for i, (l, r) in enumerate(LR):
    for j in range(l - 1, r):
        c[j] += i + 1
    cnt += i + 1

s = [1 if k == cnt else 0 for k in c]

print(sum(s))


Fixed submission:
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

N, M = input().split()

N = int(N)
M = int(M)

cnt = 0

NM = np.zeros([N])
B = np.zeros([N])

for i in range(M):
    A = input().split()
    B[int(A[0])-1:int(A[1])] = 1
    NM += B
    B = np.zeros([N])


print(np.sum(NM==M))


Fixed submission:
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

N, M = input().split()

N = int(N)
M = int(M)

cnt = 0

NM = np.zeros([N])
B = np.zeros([N])

for i in range(M):
    A = input().split()
    B[int(A[0])-1:int(A[1])] = 1
    NM += B
    B = np.zeros([N])


print(np.sum(NM==M))


Fixed submission:
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

N, M = input().split()

N = int(N)
M = int(M)

cnt = 0

NM = np.zeros([M,N])

for i in range(M):
    A = input().split()
    NM[i,int(A[0])-1:int(A[1])] = 1.0

s = np.sum(NM,axis=0)

print(np.sum(s==M))

Fixed submission:
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

N, M = input().split()

N = int(N)
M = int(M)

cnt = 0

NM = np.zeros([M,N])

for i in range(M):
    A = input().split()
    NM[i,int(A[0])-1:int(A[1])] = 1.0

print(NM)

s = np.sum(NM,axis=0)
print(s)

print(np.sum(s==M))

Fixed submission:
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

N, M = input().split()

N = int(N)
M = int(M)

cnt = 0

NM = np.zeros([M,N])

for i in range(M):
    A = input().split()
    NM[i,int(A[0]):int(A[1])] = 1.0

s = np.sum(NM,axis=0)

print(np.sum(s==M))

Fixed submission:
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

N, M = input().split()

N = int(N)
M = int(M)

A = np.zeros([2,M])

cnt = 0

for i in range(M):
    A[:,i] = input().split()

A = np.array(A,dtype=np.int64)


NM = np.zeros([M,N])

for i in range(M):
    NM[i,A[0,i]-1:A[1,i]] = 1.0


s = np.sum(NM,axis=0)

print(np.sum(s==M))

Fixed submission:
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

N, M = input().split()

N = int(N)
M = int(M)

A = np.zeros([2,M])

cnt = 0

for i in range(M):
    A[:,i] = input().split()

for i in range(1,N+1):
    for j in range(M):
        if A[0,j] <= i and i <= A[1,j]:
            continue
        else:
            cnt += 1
            break

print(N - cnt)

Fixed submission:
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)