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

banned_list = []
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))
banned_list = sorted(banned_list,key=lambda x:x[1])
#status = [1 for _ in range(N-1)]
status = set()
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if len([one for one in status if (one >= a-1 and one < b-1)]) == 0:
        status  |= {b-2}
        counter += 1
print(counter)


Fixed submission:
N, M = map(int,input().split())

banned_list = []
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))
banned_list = sorted(banned_list,key=lambda x:x[1])
#status = [1 for _ in range(N-1)]
status = set()
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if len([one for one in status if (one >= a-1 and one < b-1)]) == 0:
        status  |= {b-2}
        counter += 1
print(counter)

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

banned_list = []
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))

banned_list = sorted(banned_list,key=lambda x:x[1])
status = [1 for _ in range(N-1)]
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if not 0 in status[a-1:b-1]:
        counter += 1
        status[b-2] = 0
print(counter)

Fixed submission:
N, M = map(int,input().split())

banned_list = []
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))
banned_list = sorted(banned_list,key=lambda x:x[1])
#status = [1 for _ in range(N-1)]
status = set()
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if len([one for one in status if (one >= a-1 and one < b-1)]) == 0:
        status  |= {b-2}
        counter += 1
print(counter)

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

banned_list = []*M
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))

banned_list = sorted(banned_list,key=lambda x:x[1])
status = [1 for _ in range(N-1)]
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if sum(status[a-1:b-1]) ==  b-a:
        counter += 1
        status[b-2] = 0
print(counter)

Fixed submission:
N, M = map(int,input().split())

banned_list = []
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))
banned_list = sorted(banned_list,key=lambda x:x[1])
#status = [1 for _ in range(N-1)]
status = set()
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if len([one for one in status if (one >= a-1 and one < b-1)]) == 0:
        status  |= {b-2}
        counter += 1
print(counter)

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

banned_list = []*M
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))

banned_list = sorted(banned_list,key=lambda x:x[1])
status = [True for _ in range(N-1)]
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if sum(status[a-1:b-1]) ==  b-a:
        counter += 1
        status[b-2] = False
print(counter)

Fixed submission:
N, M = map(int,input().split())

banned_list = []
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))
banned_list = sorted(banned_list,key=lambda x:x[1])
#status = [1 for _ in range(N-1)]
status = set()
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if len([one for one in status if (one >= a-1 and one < b-1)]) == 0:
        status  |= {b-2}
        counter += 1
print(counter)

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

banned_list = []*M
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))

banned_list = sorted(banned_list,key=lambda x:x[1])
status = [True for _ in range(N-1)]
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if sum(status[a-1:b-1]) ==  b-a:
        counter += 1
        status[b-2] = False
print(counter)

Fixed submission:
N, M = map(int,input().split())

banned_list = []
for i in range(M):
    banned_list.append(tuple(map(int,input().split())))
banned_list = sorted(banned_list,key=lambda x:x[1])
#status = [1 for _ in range(N-1)]
status = set()
counter = 0
for i in range(M):
    a = banned_list[i][0]
    b = banned_list[i][1]
    if len([one for one in status if (one >= a-1 and one < b-1)]) == 0:
        status  |= {b-2}
        counter += 1
print(counter)