ZhenlongDai/ACPR huggingface dataset:
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
cut = []
for _ in range(M):
    a, b = map(int, input().split())
    cut.append([a, b])

cut = sorted(cut, key=lambda x: x[0])

ans = 1
ind = 0

print(cut)

s = cut[ind][0]
e = cut[ind][1]
while ind < M:
    n_s, n_e = cut[ind]
    if n_s < e:
        e = min(e, n_e)
    else:
        s = n_s
        e = n_e
        ans += 1
    ind += 1


print(ans)


Failing test case input:
9 2
1 8
2 7
3 5
4 6
7 5

Expected output:
1


Actual output:
[[1, 8], [2, 7]]
1


Fixed submission (verdict: Accepted):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
cut = []
for _ in range(M):
    a, b = map(int, input().split())
    cut.append([a, b])

cut = sorted(cut, key=lambda x: x[0])

ans = 1
ind = 0


s = cut[ind][0]
e = cut[ind][1]
while ind < M:
    n_s, n_e = cut[ind]
    if n_s < e:
        e = min(e, n_e)
    else:
        s = n_s
        e = n_e
        ans += 1
    ind += 1


print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
islands = []
bridges = []

N, M = map(int, input().split())









for i in range(M):
    a, b = map(int, input().split())
    islands.append({'a': a, 'b': b})

islands.sort(key=lambda x: (x['a'], x['b']))


for i in islands:
    b = [j for j in bridges if j >= i['a']]
    b = [j for j in b if j < i['b']]
    if len(b) == 0:
        bridges.append(i['b'] - 1)


print(len(bridges))

Failing test case input:
5 2
-2 8
0 5

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
islands = []
bridges = []

N, M = map(int, input().split())

for i in range(M):
    a, b = map(int, input().split())
    islands.append({'a': a, 'b': b})

islands.sort(key=lambda x: x['b'])


for i in islands:
    b = [j for j in bridges if j >= i['a']]
    if len(b) == 0:
        bridges.append(i['b'] - 1)


print(len(bridges))

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(M)]
sorted(l, key = lambda l:l[1])

p_num = -1
ans = 0

for i in range(M):
	if l[i][0] > p_num:
		p_num = l[i][1] - 1
		ans += 1

print(ans)

Failing test case input:
5 10
1 2
1 3
1 4
2 5
1 3
2 4
2 5
3 5
3 5
4 5

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(M)]
l = sorted(l, key = lambda l:(l[1]))

p_num = -1
ans = 0

for i in range(M):
	if not l[i][0] <= p_num:
		p_num = l[i][1] - 1
		ans += 1

print(ans)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n , m = map(int, input().split())

ranges = [[] for _ in range(m)]
for i in range(m):
    a,b = map(int,input().split())
    ranges[i] = [a,b]
ranges = sorted(ranges, key = lambda x:x[1])
MAX = - float("inf")
ans = 0
for i in range(m):
    if MAX < ranges[i][0]:
        MAX = ranges[i][0] - 0.1
        ans += 1
print(ans)

Failing test case input:
5 2
1 3
2 8

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n , m = map(int, input().split())

ranges = [[] for _ in range(m)]
for i in range(m):
    a,b = map(int,input().split())
    ranges[i] = [a,b]
ranges = sorted(ranges, key = lambda x:x[1])
MAX = - float("inf")
ans = 0
for i in range(m):
    if MAX < ranges[i][0]:
        MAX = ranges[i][1] - 0.1
        ans += 1
print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N, M = map(int, input().split())
    ab = [[int(i) for i in input().split()] for _ in range(M)]
    ab = sorted(ab, key=lambda x: x[1] - x[0])
    d = [ab.pop(0)]
    ans = 1
    for a, b in ab:
        for aa, bb in d:
            if aa >= b or a >= bb:
                ans += 1
    print(ans)


main()


Failing test case input:
5 10
1 2
0 4
1 4
1 5
2 3
2 8
2 7
3 3
3 5
4 5

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
def main():
    N, M = map(int, input().split())
    ab = [[int(i) for i in input().split()] for _ in range(M)]
    ab = sorted(ab, key=lambda x: x[1])
    last = ab[0][1] - 1
    ans = 1
    for a, b in ab[1:]:
        if last >= a:
            continue
        ans += 1
        last = b - 1
    print(ans)


main()

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

n, m = map(int, input().split())
d = []
for i in range(m):
    a, b = map(int, input().split())
    d.append([a, b])

d.sort(key=lambda x: (x[1], x[0]))

mn = 100000000
ans = 0
for a, b in d:
    if a >= mn:
        ans += 1
        mn = b
    mn = min(mn, b)

if mn != 100000000:
    ans += 1
print(ans)

print(ans + 1)


Failing test case input:
5 1
0 5
2 7

Expected output:
1


Actual output:
1
2


Fixed submission (verdict: Accepted):

n, m = map(int, input().split())
d = []
for i in range(m):
    a, b = map(int, input().split())
    d.append([a, b])

d.sort(key=lambda x: (x[0], x[1]))

mn = 100000000
ans = 0
for a, b in d:
    if a >= mn:
        ans += 1
        mn = b
    mn = min(mn, b)

if mn != 100000000:
    ans += 1
print(ans)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
count = 0

s = [[]*2]*m
for i in range(0, m):
  s[i] = list(map(int, input().split()))

r = s[0][1]
count += 1
for i in range(1, m):
  if r <= s[i][0]:
    r = s[i][1]
    count += 1
print(count)

Failing test case input:
9 5
1 8
0 7
3 5
4 6
7 9

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
count = 0
s = [[]*2]*m
for i in range(0, m):
  s[i] = list(map(int, input().split()))
s.sort()
r = s[0][1] - 1
count += 1
for i in range(1, m):
  if s[i][1] < r + 1:
    r = s[i][1] - 1
  if s[i][0] > r:
    r = s[i][1] - 1
    count += 1
print(count)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(M)]

ab.sort(key = lambda x:x[1])
ans = 0
last = -1
for a,b in ab:
    print(a,b)
    if last <= a:
        ans += 1
        last = b
        print('hogehogehoge',last,ans)
print(ans)


Failing test case input:
5 2
-3 5
0 8

Expected output:
1


Actual output:
-3 5
0 8
hogehogehoge 8 1
1


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

ab.sort(key = lambda x:x[1])
ans = 0
last = -1
for a,b in ab:
    if last <= a:
        ans += 1
        last = b
print(ans)

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M = map(int,input().split())
L = []
for _ in range(M):
    L.append(list(map(int,input().split())))
L = sorted(L,key=lambda x:x[1])
now = -10
cnt = 0
for x in L:
    if now < x[0]:
        now = x[1]
        cnt += 1
print(cnt)


Failing test case input:
5 10
1 2
0 4
1 4
1 5
2 3
2 8
2 7
3 3
3 5
4 5

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
L = []
for _ in range(M):
    L.append(list(map(int,input().split())))
L = sorted(L,key=lambda x:x[1])
now = -10
cnt = 0
for x in L:
    if now <= x[0]:
        now = x[1]
        cnt += 1
print(cnt)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = [int(i) for i in input().split()]
e = [[int(j) for j in input().split()] for i in range(m)]
sorted(e,key= lambda x : x[1])
s=[]
for i in e:
  if s!=[] and i[0]<=s[-1]:
    pass
  else:
    s.append(i[1]-1)
    
print(len(s))


Failing test case input:
9 5
2 8
2 7
3 5
4 6
5 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n,m = [int(i) for i in input().split()]
e = [[int(j) for j in input().split()] for i in range(m)]
new_e =sorted(e,key= lambda x : x[1])
s=[]
for i in new_e:
  if s!= [] and i[0]<=s[-1]:
    pass
  else:
    s.append(i[1]-1)

print(len(s))
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
ts = [list(map(int,input().split()))[::-1] for j in range(m)]


count = 0
t = 0

for j in range(m):
  if ts[j][1]>=t:
    count+=1
    t = ts[j][0]
    
print(count)

Failing test case input:
9 5
1 8
0 7
3 5
4 9
7 9

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
ts = [list(map(int,input().split()))[::-1] for j in range(m)]

ts.sort()

count = 0
t = 0

for j in range(m):
  if ts[j][1]>=t:
    count+=1
    t = ts[j][0]
    
print(count)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
Alist = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    Alist.append(array)
Alist.sort()
q = 0
p = [Alist[0][0],Alist[0][1]]
for i in range(len(Alist)-1):
    print(p)
    if Alist[i][0] < Alist[i+1][0]:
        p[0] = Alist[i+1][0]
    if p[0] >= p[1]:
        print(q)
        q = q+1
        p = [Alist[i+1][0],Alist[i+1][1]]
    if Alist[i][1] > Alist[i+1][1]:
        p[1] = Alist[i+1][1]
print(q+1)

Failing test case input:
1 2
1 4
4 6

Expected output:
2


Actual output:
[1, 4]
0
2


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
Alist = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    Alist.append(array)
Alist.sort()
q = 0
p = [Alist[0][0],Alist[0][1]]
for i in range(len(Alist)-1):
    if p[0] < Alist[i+1][0]:
        p[0] = Alist[i+1][0]
    if p[0] >= p[1]:
        q = q+1
        p = [Alist[i+1][0],Alist[i+1][1]]
    if p[1] > Alist[i+1][1]:
        p[1] = Alist[i+1][1]
print(q+1)

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import deque
N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

ab.sort(key=lambda x :x[1])
ab=deque(ab)
num=0
while(ab):
    p=ab.popleft()
    num+=1
    e=p[1]
    q=deque()
    for i in range(len(ab)):
        if ab[i][0]<e:
            q.append(ab[i])
    ab=q
print(num)

Failing test case input:
5 2
-6 5
2 5

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import deque
N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

ab.sort(key=lambda x :x[1])
ans=deque()
for i in ab:
    if len(ans)>0:
        if i[0]<ans[-1] :
            continue
    ans.append(i[1])
print(len(ans))
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(M)]
a = list(map(lambda p: p[0], P))
sorted_b = sorted(list(map(lambda p: p[1], P)))

ret = 1
for i in set(a):
    if i >= sorted_b[0]:
        ret += 1

print(ret)


Failing test case input:
5 10
1 2
1 3
1 4
2 5
1 3
2 4
2 5
3 5
3 5
4 5

Expected output:
3


Actual output:
4


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

E = sorted(E, key=lambda x: x[1])

removed = -1
ret = 0

for e in E:
    if e[0] > removed:
        ret += 1
        removed = e[1] - 1

print(ret)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
war_list = []
divide_list = []
for i in range(M):
    war_list.append(list(map(int,input().split())))
war_list.sort(key = lambda x : x[1])

divide_list = [war_list[0][1]]
for i in range(1,M):
    if  war_list[i][0] < divide_list[-1]:
        pass
    else:
        divide_list.append(divide_list[-1])
    
print(len(divide_list))


Failing test case input:
5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 5
3 5
4 5

Expected output:
3


Actual output:
7


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
war_list = []
divide_list = []
for i in range(M):
    war_list.append(list(map(int,input().split())))
war_list.sort(key = lambda x : x[1])

divide_list = [war_list[0][1]]
for i in range(1,M):
    if  war_list[i][0] < divide_list[-1]:
        pass
    else:
        divide_list.append(war_list[i][1])
    
print(len(divide_list))

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int, input().split())
need = [list(map(int, input().split())) for i in range(m)]
need = sorted(need, key=lambda x: x[1])
print(need)

ans = 1
stock = need[0][1]
for i in range(m):
  if stock <= need[i][0]:
    ans += 1
    stock = need[i][1]
    
print(ans)

Failing test case input:
9 5
2 8
2 7
3 5
4 6
0 5

Expected output:
1


Actual output:
[[3, 5], [0, 5], [4, 6], [2, 7], [2, 8]]
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
need = [list(map(int, input().split())) for i in range(m)]
need = sorted(need, key=lambda x: x[1])

ans = 1
stock = need[0][1]
for i in range(m):
  if stock <= need[i][0]:
    ans += 1
    stock = need[i][1]
    
print(ans)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def run(n, m, ab):
    ab = sorted(ab)
    cnt = 1
    b = ab[0][1]
    for i in range(1, m):
        a = ab[i][0]
        if b < a:
            cnt += 1
        b = ab[i][1]
    return cnt


def read_line():
    n, m = list(map(int, input().split()))
    ab = []
    for i in range(m):
        a, b = list(map(int, input().split()))
        ab.append([a, b])
    return (n, m, ab)


def main():
    n, m, ab = read_line()
    print(run(n, m, ab))


if __name__ == '__main__':
    main()


Failing test case input:
1 2
1 4
4 6

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def run(n, m, ab):
    ab = sorted(ab)
    cnt = 1
    b = ab[0][1]
    c = b
    for i in range(1, m):
        a = ab[i][0]
        b = ab[i][1]
        if a < c and c <= b:
            pass
        elif c <= a:
            cnt += 1
            c = b
        else:
            c = b
    return cnt


def read_line():
    n, m = list(map(int, input().split()))
    ab = []
    for i in range(m):
        a, b = list(map(int, input().split()))
        ab.append([a, b])
    return (n, m, ab)


def main():
    n, m, ab = read_line()
    print(run(n, m, ab))


if __name__ == '__main__':
    main()

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

n, m=map(int, input().split())
hope=[]
for i in range(m):
    a, b=map(int, input().split())
    hope.append((a, b))
hope.sort(reverse=True, key=lambda x: x[0])
hope.sort(reverse=True, key=lambda x: x[1])
ans=0
for i in range(m-1):
    if i==0:
        target=hope[i][0]
    if target>hope[i+1][1]:
        ans=ans+1
        target=hope[i+1][0]
print(ans+1)


Failing test case input:
9 5
2 8
2 7
3 5
4 6
5 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):

n, m=map(int, input().split())
hope=[]
for i in range(m):
    a, b=map(int, input().split())
    hope.append((a, b))
hope.sort(reverse=True, key=lambda x: x[0])
hope.sort(reverse=True, key=lambda x: x[1])
ans=0
for i in range(m-1):
    if i==0:
        target=hope[i][0]
    if target<hope[i+1][1]:
        if target<hope[i+1][0]:
            target=hope[i+1][0]
    else:
        ans=ans+1
        target=hope[i+1][0]
print(ans+1)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n , m = map(int, input().split())

ranges = [[] for _ in range(m)]
for i in range(m):
    a,b = map(int,input().split())
    ranges[i] = [a,b]
ranges = sorted(ranges, key = lambda x:x[1])
MAX = - float("inf")
ans = 0
for i in range(m):
    if MAX < ranges[i][0]:
        MAX = ranges[i][0]
        ans += 1
print(ans)

Failing test case input:
9 5
2 5
2 7
3 5
0 12
0 5

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n , m = map(int, input().split())

ranges = [[] for _ in range(m)]
for i in range(m):
    a,b = map(int,input().split())
    ranges[i] = [a,b]
ranges = sorted(ranges, key = lambda x:x[1])
MAX = - float("inf")
ans = 0
for i in range(m):
    if MAX < ranges[i][0]:
        MAX = ranges[i][1] - 0.1
        ans += 1
print(ans)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]
print(ab)
ab.sort(key=lambda x:x[1])
print(ab)

ans = 0
endplace = 0
for ai, bi in ab:
    if endplace <= ai:
        endplace = bi
        ans += 1
print(ans)


Failing test case input:
7 2
-1 5
2 5

Expected output:
1


Actual output:
[(-1, 5), (2, 5)]
[(-1, 5), (2, 5)]
1


Fixed submission (verdict: Accepted):

n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]
ab.sort(key=lambda x:x[1])
ans = 0
endplace = 0
for ai, bi in ab:
    if endplace <= ai:
        endplace = bi
        ans += 1
print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N,M =map(int,input().split(" "))

num =[]
for i in range(M):
    l,m =map(int,input().split(" "))
    x =[m,l]
    num.append(x)
num.sort()

t = num[0][0]
ans =1
for i in range(1,M):
    k =num[i][1]
    if t<k:
        t = k
        ans +=1
print(ans)
        

Failing test case input:
5 10
1 2
0 4
1 4
1 5
2 3
2 4
2 7
3 3
3 5
4 5

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):


N,M =map(int,input().split(" "))

num =[]
for i in range(M):
    l,m =map(int,input().split(" "))
    x =[m,l]
    num.append(x)
num.sort()

t = num[0][0]
ans =1
for i in range(1,M):
    k =num[i][1]
    if t<=k:
        t = num[i][0]
        ans +=1
        
print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from operator import itemgetter
n, m = map(int, input().split())

ab = [tuple(map(int, input().split())) for i in range(m)]

ab = sorted(ab, key=itemgetter(1))

count = 0
cut = 0
for i in range(m):
    if cut < ab[i][0]:
        count += 1
        cut = ab[i][1]

print(count)

Failing test case input:
5 10
1 2
0 4
1 4
1 5
2 3
2 8
2 7
3 3
2 5
4 5

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
from operator import itemgetter
n, m = map(int, input().split())

ab = [tuple(map(int, input().split())) for i in range(m)]

ab = sorted(ab, key=itemgetter(1))

count = 0
cut = 0
for i in range(m):
    if cut <= ab[i][0]:
        count += 1
        cut = ab[i][1]

print(count)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m  = map(int, input().split())



l = 1
r = n
ans = 1
for i in range(m):
    a,b = map(int, input().split())
    
    if b < l:
        ans += 1

        r = b
    elif a > r:
        ans += 1

        l = a
    
    if a > l:
        l = a
    if b < r:
        r = b


print(ans)

Failing test case input:
5 10
1 2
0 4
1 4
1 5
2 3
2 8
2 7
3 3
2 5
4 5

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n,m  = map(int, input().split())

ans = 0
ba = [[0 for _ in range(2)] for _ in range(m)]

for i in range(m):
    a,b = map(int, input().split())
    ba[i][0] = b
    ba[i][1] = a

ba.sort()

br = 0
for b,a in ba:
    
    if not (a < br < b):
        
        br = b - 0.5
        ans += 1

print(ans)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int, input().split())
cnt = 0
end_time = 0
for _ in range(m):
  a,b = map(int, input().split())
  if end_time <= a:
    end_time = b
    cnt += 1
print(cnt)

Failing test case input:
5 10
1 2
1 3
1 4
2 5
1 3
2 4
2 5
3 5
3 5
4 5

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort(key=lambda x:x[1])
cnt = 0
end_time = 0
for a,b in ab:
  if end_time <= a:
    end_time = b
    cnt += 1
print(cnt)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]

l.sort(key=lambda x:x[1])
print(l)


c = 0

ans = 0

for a,b in l:
    if a >= c:
        c = b
        ans += 1

print(ans)

Failing test case input:
5 2
-4 5
0 5

Expected output:
1


Actual output:
[[-4, 5], [0, 5]]
1


Fixed submission (verdict: Accepted):

n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]

l.sort(key=lambda x:x[1])



c = 0

ans = 0

for a,b in l:
    if a >= c:
        c = b
        ans += 1

print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int,input().split())
m=[list(map(int, input().split()))[::-1] for _ in range(M)]
m.sort()

p=0
while m!=[]:
    tmp=max(m)[1]
    m=[l for l in m if l[0]<=tmp]
    p+=1
print(p)

Failing test case input:
9 5
2 8
2 7
3 5
4 6
7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N, M = map(int,input().split())
m=[list(map(int, input().split()))[::-1] for _ in range(M)]
m.sort()

b=[]
for i in m:
    if len([tmp for tmp in b if tmp>=i[1]])==0:
        b.append(i[0]-1)
print(len(b))

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
islands = []
bridges = []

N, M = map(int, input().split())









for i in range(M):
    a, b = map(int, input().split())
    islands.append({'a': a, 'b': b})

islands.sort(key=lambda x: (x['a'], x['b']))


for i in islands:
    b = [j for j in bridges if j >= i['a']]
    b = [j for j in b if j < i['b']]
    if len(b) == 0:
        bridges.append(i['b'] - 1)

print(bridges)


Failing test case input:
9 5
1 8
0 7
3 5
4 6
7 9

Expected output:
2


Actual output:
[6, 4, 8]


Fixed submission (verdict: Accepted):
islands = []
bridges = []

N, M = map(int, input().split())

for i in range(M):
    a, b = map(int, input().split())
    islands.append({'a': a, 'b': b})

islands.sort(key=lambda x: x['b'])


for i in islands:
    b = [j for j in bridges if j >= i['a']]
    if len(b) == 0:
        bridges.append(i['b'] - 1)


print(len(bridges))
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from operator import itemgetter

n, m = map(int, input().split())


ab = sorted([list(map(int, input().split())) for i in range(m)], key=itemgetter(1))

print(ab)
removed = -1
ans = 0

for a, b in ab:
    
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)

Failing test case input:
5 2
-7 5
2 5

Expected output:
1


Actual output:
[[-7, 5], [2, 5]]
1


Fixed submission (verdict: Accepted):
from operator import itemgetter

n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(m)], key=itemgetter(1))
removed = -1
ans = 0

for a, b in ab:
    
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())

claims = []
for i in range(M):
  claims.append(list(map(int,input().split())))
  
claims.sort()

killed = 0
last_killed = -1
for claim in claims:
  if (not( claim[0] <= last_killed and last_killed < claim[1]) ):
    last_killed = claim[1] -1
    killed += 1

print(killed)

Failing test case input:
9 2
1 8
2 7
3 5
4 6
7 5

Expected output:
1


Actual output:
2


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

claims = []
for i in range(M):
  claims.append(list(map(int,input().split())))
  
claims.sort()

killed = 0
last_killed = [-1,-1]
for claim in claims:
  if (last_killed[1] < claim[0] or last_killed[0] >= claim[1]):
    last_killed = [claim[0],claim[1] -1]
    killed += 1
  last_killed = [max(last_killed[0],claim[0]),min(last_killed[1],claim[1] -1)]
print(killed)

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m = map(int, input().split())
a = []
for i in range(m):
  x,y = map(int, input().split())
  a.append((x,y))
a.sort()
ans = 1
l,r = a[0]
for x,y in a[1:]:
  if r <= x:
    ans += 1
    r = x
    l = y

print(ans)

Failing test case input:
5 10
1 2
1 4
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

Expected output:
4


Actual output:
7


Fixed submission (verdict: Accepted):
n,m = map(int, input().split())
a = []
for i in range(m):
  x,y = map(int, input().split())
  a.append((x,y))
a.sort(key=lambda x:x[1])
ans = 1
l,r = a[0]
for x,y in a[1:]:
  if r <= x:
    ans += 1
    l = x
    r = y

print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
count = 0
s = [[]*2]*m
for i in range(0, m):
  s[i] = list(map(int, input().split()))
s.sort(key = lambda x: x[0])
r = s[0][1]
count += 1
for i in range(1, m):
  if r > s[i][0] & r > s[i][1]:
    r = s[i][1]
  if r <= s[i][0]:
    r = s[i][1]
    count += 1
print(count)

Failing test case input:
9 5
1 8
2 7
3 5
4 6
7 9

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
count = 0
s = [[]*2]*m
for i in range(0, m):
  s[i] = list(map(int, input().split()))
s.sort()
r = s[0][1] - 1
count += 1
for i in range(1, m):
  if s[i][1] < r + 1:
    r = s[i][1] - 1
  if s[i][0] > r:
    r = s[i][1] - 1
    count += 1
print(count)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin, stdout
input = lambda: stdin.readline()
write = stdout.write

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]

    AB.sort(key=lambda x: x[1])
    cuts, p = 1, AB[0][1]
    for a, b in AB:
        if a > p:
            cuts += 1
    print(cuts)

main()


Failing test case input:
1 2
1 4
4 6

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from sys import stdin, stdout
input = lambda: stdin.readline()
write = stdout.write

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]

    AB.sort(key=lambda x: x[1])
    cuts, p = 1, AB[0][1]
    for a, b in AB:
        if a >= p:
            cuts += 1
            p = b
    print(cuts)

main()

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())

claims = []
for i in range(M):
  claims.append(list(map(int,input().split())))
  
claims.sort()

killed = 0
last_killed = [-1,-1]
for claim in claims:
  if (last_killed[1] < claim[0] or last_killed[0] >= claim[1]):
    last_killed = [claim[0],claim[1] -1]
    killed += 1

print(killed)

Failing test case input:
9 5
1 8
2 7
3 5
4 6
7 5

Expected output:
2


Actual output:
1


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

claims = []
for i in range(M):
  claims.append(list(map(int,input().split())))
  
claims.sort()

killed = 0
last_killed = [-1,-1]
for claim in claims:
  if (last_killed[1] < claim[0] or last_killed[0] >= claim[1]):
    last_killed = [claim[0],claim[1] -1]
    killed += 1
  last_killed = [max(last_killed[0],claim[0]),min(last_killed[1],claim[1] -1)]
print(killed)

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m = map(int, input().split())
a = []
for i in range(m):
  x,y = map(int, input().split())
  a.append((x,y))
a.sort()
ans = 1
l,r = a[0]
for x,y in a[1:]:
  if r <= x:
    ans += 1
    r = x
    l = y
  else:
    r = max(r, y)
print(ans)

Failing test case input:
5 10
1 2
0 4
1 4
1 5
2 3
2 4
2 7
3 3
3 5
4 5

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
n,m = map(int, input().split())
a = []
for i in range(m):
  x,y = map(int, input().split())
  a.append((x,y))
a.sort(key=lambda x:x[1])
ans = 1
l,r = a[0]
for x,y in a[1:]:
  if r <= x:
    ans += 1
    l = x
    r = y

print(ans)

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m=map(int,input().split())
itv=[]
for i in range(m):
  a,b=map(int,input().split())
  start=min(a,b)
  end=max(a,b)
  itv.append([end,start])
t,ans=0,0
for e,s in itv:
  if t<s:
    t=e
    ans+=1
print(ans)

Failing test case input:
5 10
1 2
1 4
1 4
1 5
2 3
2 4
2 5
3 3
3 5
4 5

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
itv=[]
for i in range(m):
  a,b=map(int,input().split())
  start=min(a,b)
  end=max(a,b)
  itv.append([end,start])
t,ans=0,0
itv=sorted(itv)
for e,s in itv:
  if t<=s:
    t=e
    ans+=1
print(ans)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=map(int,input().split())
AB=[[0,0] for i in range(M)]
for i in range(M):
    AB[i][0],AB[i][1]=map(int,input().split())
l=AB[0][0]
r=AB[0][1]
c=0
x=0
for i in range(1,M):
    if AB[i][0]<r:
        l=AB[i][0]
        if AB[i][1]<r and x==0:
            r=AB[i][1]
            x=i
        elif AB[i][1]<r and i==x+1:
            c+=1
            l=AB[i][0]
            r=AB[i][1]
            x=0
            continue
    else:
        c+=1
        l=AB[i][0]
        r=AB[i][1]
print(c+1)





Failing test case input:
9 5
2 8
2 7
3 5
0 12
0 5

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N,M=map(int,input().split())
AB=[[0,0] for i in range(M)]
for i in range(M):
    AB[i][0],AB[i][1]=map(int,input().split())
AB.sort(key=lambda x:x[0])
l=AB[0][0]
r=AB[0][1]
c=0
for i in range(1,M):
    if AB[i][0]<r:
        l=AB[i][0]
        if AB[i][1]<r:
            r=AB[i][1]
    else:
        c+=1
        l=AB[i][0]
        r=AB[i][1]
print(c+1)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
ab = []
for i in range(M):
    ab.append(list(map(int,input().split())))
ab.sort(key = lambda ab:ab[1])
count = 0
now = 0
print(ab)
for a,b in ab:
    if a >= now:
        count += 1
        now = b
print(count)

Failing test case input:
5 2
-6 5
0 5

Expected output:
1


Actual output:
[[-6, 5], [0, 5]]
1


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
ab = []
for i in range(M):
    ab.append(list(map(int,input().split())))
ab.sort(key = lambda ab:ab[1])
count = 0
now = 0
for a,b in ab:
    if a >= now:
        count += 1
        now = b
print(count)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
x = []
for _ in range(M):
    a, b = map(int, input().split())
    x.append([a, b])

x.sort()
res = 0
right = 0
for i in range(M):
    if x[i][0] >= right:
        right = x[i][1]
        res += 1

print(res)

Failing test case input:
9 5
2 8
2 7
3 5
4 9
5 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
x = []
for _ in range(M):
    a, b = map(int, input().split())
    x.append([a, b])

x.sort(key=lambda x: x[1])
res = 0
right = 0
for i in range(M):
    if x[i][0] >= right:
        right = x[i][1]
        res += 1

print(res)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):





N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
ab.sort(key=lambda x: x[1])
print(ab)
ans = 1             
tmp = ab[0][1] - 0.1      
for i in range(1, M):
    if ab[i][0] < tmp < ab[i][1]:   
        pass
    else:                           
        ans += 1
        tmp = ab[i][1] - 0.1

print(ans)

Failing test case input:
5 10
1 2
1 6
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

Expected output:
4


Actual output:
[[1, 2], [2, 3], [1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [4, 5], [1, 6]]
4


Fixed submission (verdict: Accepted):





N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
ab.sort(key=lambda x: x[1])

ans = 1             
tmp = ab[0][1] - 0.1      
for i in range(1, M):
    if ab[i][0] < tmp < ab[i][1]:   
        pass
    else:                           
        ans += 1
        tmp = ab[i][1] - 0.1

print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
ab = []
for i in range(m):
	a,b = map(int, input().split())
	ab.append([a,b])
ab = sorted(ab, key=lambda x: x[1])
mn = ab[0][1]
c = 1
for i in ab:
	if i[0] > mn:
		c += 1
		mn = i[1]
print (c)

Failing test case input:
5 10
1 2
1 4
1 4
1 5
2 3
2 4
2 7
3 3
3 5
4 5

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
ab = []
for i in range(m):
	a,b = map(int, input().split())
	ab.append([a,b])
ab = sorted(ab, key=lambda x: x[1])
mn = ab[0][1]
c = 1
for i in ab:
	if i[0] >= mn:
		c += 1
		mn = i[1]
print (c)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
points=[]
for i in range(m):
    a,b=map(int,input().split())
    points.append([a,b])
points = sorted(points)
arrow = float('-inf')
res = 0
for l,r in points:
    if l > arrow:
        res += 1
        arrow = r
    elif r < arrow:
        arrow = r
print(res)

Failing test case input:
5 10
1 2
0 4
1 4
1 5
2 3
2 8
2 7
3 3
3 5
4 5

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
points=[]
for i in range(m):
    a,b=map(int,input().split())
    points.append([a,b-1])
points = sorted(points)
arrow = float('-inf')
res = 0

for l,r in points:
    if l > arrow:
        res += 1
        arrow = r
    elif r < arrow:
        arrow = r
print(res)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from operator import itemgetter
n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
    a_,b_=map(int,input().split())
    a.append(a_)
    b.append(b_)
ab=sorted([(a[i],b[i]) for i in range(m)],  key=itemgetter(1))  

ans=0
last=0
for i in range(m):
    if last<=ab[i][0]:
        last=ab[i][1]
        ans+=1
    else:
        last=ab[i][1]
print(ans)


Failing test case input:
9 5
1 8
2 7
3 5
4 6
7 9

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):
from operator import itemgetter
n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
    a_,b_=map(int,input().split())
    a.append(a_)
    b.append(b_)
ab=sorted([(a[i],b[i]) for i in range(m)],  key=itemgetter(1))  
removed=-1
ans=0

for i,j in ab:
    if i>removed:
        ans+=1
        removed=j-1
print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ab.sort()

l = ab[0][0]
r = ab[0][1]
ans = 0

if m == 1:
    print(1)

for i in range(1,m):
    if r<=ab[i][0]:
        ans += 1
        l = ab[i][0]
        r = ab[i][1]
    else:
        r = min(r, ab[i][1])

    if i==m-1:
        ans += 1

print(ans)

Failing test case input:
4 1
1 2
2 5

Expected output:
1


Actual output:
1
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ab.sort()

l = ab[0][0]
r = ab[0][1]
ans = 1

for i in range(1,m):
    if r<=ab[i][0]:
        ans += 1
        l = ab[i][0]
        r = ab[i][1]
    else:
        r = min(r, ab[i][1])

print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
L = list()
for i in range(m):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    L.append([a, b])
i = 0
while len(L) > 0:
    i += 1
    L = [l for l in L if l[0] > min([L[i][1] for i in range(len(L))])]
print(i)

Failing test case input:
5 2
1 2
2 8

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
L = list()
for i in range(m):
    x, y = map(int, input().split())
    if x > y:
        x, y = y, x
    L.append([x, y])
L = sorted(L, key=lambda x: x[1])
A = L[0]
i = 1
for v in L:
    if v[0] >= A[1]:
        A = v
        i += 1
print(i)

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):



from bisect import bisect_right as br
N, M = map(int, input().split())
Q = [list(map(int, input().split())) for _ in range(M)]
Q.sort(key = lambda x: x[1])
Qa = [q[0] for q in Q]
i = 0
res = 0
while i < M:
  b = Q[i][1]
  ind = br(Qa, b - 1)
  
  res += 1
  i = ind
print(res)

Failing test case input:
9 5
1 8
2 7
3 5
4 6
7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
Q = [list(map(int, input().split())) for _ in range(M)]
Q.sort(key = lambda x: (x[1], x[0]))
b = 0
res = 0
for i in range(M):
  if Q[i][0] >= b:
    b = Q[i][1]
    res += 1
print(res)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

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

l = [[int(x) for x in input().split()] for _ in range(M)]



def do(l):
    l1 = [v1 for (v1,_) in l]
    l2 = [v2 for (_,v2) in l]
    l1.sort()
    l2.sort()

    count = 1

    ma = max(l1)
    mi = min(l2)

    flag = "n"

    for i in range(len(l)):
        if l1[i] >= mi:
            if bisect.bisect_left(l2,l1[i]) != bisect.bisect_left(l2,l1[i-1]):
                count+=1
    return count




result = do(l)
print(result)

Failing test case input:
5 2
1 2
2 8

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import bisect

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

l = [[int(x) for x in input().split()] for _ in range(M)]



def do(l):

    count = 1

    l.sort()
    right = l[0][1]


    for i in range(len(l)):
        if l[i][0] >= right:
            right = l[i][1]
            count+=1
            continue
        if l[i][1] < right:
            right = l[i][1]
    return count

testl = [[x,x+1] for x in range(1)]

result = do(l)
print(result)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
a = [[]*2]*M
for i in range(M):
    a[i]=input().rstrip().split()


a=sorted(a, key=lambda x: x[1])
hasi = 0
sum = 0

for i in range(0,M):
    
    c1 = int(a[i][0])
    c2 = int(a[i][1])
    
    if hasi >= c1:
        continue
    hasi = c2-1
    sum = sum+1


print(sum)

Failing test case input:
7 1
0 2
2 5

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
a = list(list(map(int, input().split())) for x in range(M))


a=sorted(a, key=lambda x: x[1])
hasi = -1
sum = 0

for i in range(0,M):
    
    if (hasi >= a[i][0])and (hasi < a[i][1]):
        continue
    else:
        hasi = a[i][1]-1
        sum = sum+1

print(sum)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(M)]

ab.sort(key = lambda x:x[1])
ans = 0
last = -1
for a,b in ab:
    print(a,b)
    if last <= a:
        ans += 1
        last = b
print(ans)


Failing test case input:
5 2
-4 5
0 5

Expected output:
1


Actual output:
-4 5
0 5
1


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

ab.sort(key = lambda x:x[1])
ans = 0
last = -1
for a,b in ab:
    if last <= a:
        ans += 1
        last = b
print(ans)
Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=map(int,input().split())
AB=[[0,0] for i in range(M)]
for i in range(M):
    AB[i][0],AB[i][1]=map(int,input().split())
l=AB[0][0]
r=AB[0][1]
c=0
for i in range(1,M):
    if AB[i][0]<r:
        l=AB[i][0]
        if AB[i][1]<r:
            r=AB[i][1]
    else:
        c+=1
        l=AB[i][0]
        r=AB[i][1]
print(c-3)





Failing test case input:
7 2
0 5
2 5

Expected output:
1


Actual output:
-3


Fixed submission (verdict: Accepted):
N,M=map(int,input().split())
AB=[[0,0] for i in range(M)]
for i in range(M):
    AB[i][0],AB[i][1]=map(int,input().split())
AB.sort(key=lambda x:x[0])
l=AB[0][0]
r=AB[0][1]
c=0
for i in range(1,M):
    if AB[i][0]<r:
        l=AB[i][0]
        if AB[i][1]<r:
            r=AB[i][1]
    else:
        c+=1
        l=AB[i][0]
        r=AB[i][1]
print(c+1)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ab.sort()

l = ab[0][0]
r = ab[0][1]
ans = 0

for i in range(1,m):
    if r<=ab[i][0]:
        ans += 1
        l = ab[i][0]
        r = ab[i][1]
    else:
        r = min(r, ab[i][1])

    if i==m-1:
        ans += 1

print(ans)

Failing test case input:
5 1
1 5
2 5

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ab.sort()

l = ab[0][0]
r = ab[0][1]
ans = 1

for i in range(1,m):
    if r<=ab[i][0]:
        ans += 1
        l = ab[i][0]
        r = ab[i][1]
    else:
        r = min(r, ab[i][1])

print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
	n, m = list(map(int, input().split()))
	rqs = [list(map(int, input().split())) for _ in range(m)]

	rqs.sort(key = lambda x: (x[0], -x[1]))

	cnt = 0
	while len(rqs) > 1:
		min_b = min([x[1] for x in rqs[1:]])
		rqs = [x for x in rqs[1:] if x[1] > min_b]
		
		cnt += 1

	if rqs == 1:
		cnt += 1

	print(cnt)

if __name__ == '__main__':
	main()

Failing test case input:
5 2
1 2
2 6

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def main():
	n, m = list(map(int, input().split()))
	rqs = [list(map(int, input().split())) for _ in range(m)]

	rqs.sort(key = lambda x: x[1])

	b = -1
	cnt = 0
	
	for x in rqs:
		if b < x[0]:
			b = x[1] - 1
			cnt += 1

	print(cnt)

if __name__ == '__main__':
	main()
Problem: p03295
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from operator import itemgetter

n, m = map(int, input().split())


ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))

removed = -1
ans = 0
print(ab)

for a, b in ab:
    
    
    if a > removed:
        removed = b - 1
        ans += 1
        print("OK")

print(ans)

Failing test case input:
5 1
0 5
1 7

Expected output:
1


Actual output:
[(0, 5)]
OK
1


Fixed submission (verdict: Accepted):
from operator import itemgetter

n, m = map(int, input().split())


ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))

removed = -1
ans = 0

for a, b in ab:
    
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
s=[]
for i in range(m):
    a,b=map(int,input().split())
    s.append([a,b-1])
s.sort(key=lambda x:x[1])
ans=0
t=None
for i,j in s:
    if(t is None or t<i):
        t=i
        ans+=1

print(ans)

Failing test case input:
9 5
2 5
2 7
3 5
0 12
0 5

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
s=[]
for i in range(m):
    a,b=map(int,input().split())
    s.append([a,b-1])
s.sort(key=lambda x:x[1])
ans=0
t=None
for i,j in s:
    if(t is None or t<i):
        t=j
        ans+=1

print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort()
s=l[0][1]
ans=0
for i in range(1,m):
    if l[i][0]>=s:
        ans+=1
        s=l[i][1]
print(ans)

Failing test case input:
5 2
-1 1
0 5

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort()
s=l[0][1]
ans=1
for i in range(1,m):
    if l[i][0]>=s:
        ans+=1
        s=l[i][1]
    if l[i][1]<=s:
        s=l[i][1]
print(ans)

Problem: p03295
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,M=map(int,input().split())


S = [[0 for j in range(2)] for i in range(M)]

for i in range(M):
    X,L=map(int,input().split())
    S[i][0]=X
    S[i][1]=L


T=sorted(S,key=lambda x:x[1])




count=1
last=T[0][1]
print(T)
for i in range(1,M):
    if T[i][0]>=last:
        count+=1
        last=T[i][1]
print(count)



Failing test case input:
5 1
0 5
2 5

Expected output:
1


Actual output:
[[0, 5]]
1


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


S = [[0 for j in range(2)] for i in range(M)]

for i in range(M):
    X,L=map(int,input().split())
    S[i][0]=X
    S[i][1]=L


T=sorted(S,key=lambda x:x[1])




count=1
last=T[0][1]

for i in range(1,M):
    if T[i][0]>=last:
        count+=1
        last=T[i][1]
print(count)
Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

n, m=map(int, input().split())
hope=[]
for i in range(m):
    a, b=map(int, input().split())
    hope.append((a, b))
hope.sort(reverse=True, key=lambda x: x[0])
hope.sort(reverse=True, key=lambda x: x[1])
ans=0
for i in range(m-1):
    if i==0:
        target=hope[i][0]
    if target>=hope[i+1][1]:
        ans=ans+1
        target=hope[i+1][0]
print(ans+1)


Failing test case input:
9 5
1 8
2 7
3 5
4 6
7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):

n, m=map(int, input().split())
hope=[]
for i in range(m):
    a, b=map(int, input().split())
    hope.append((a, b))
hope.sort(reverse=True, key=lambda x: x[0])
hope.sort(reverse=True, key=lambda x: x[1])
ans=0
for i in range(m-1):
    if i==0:
        target=hope[i][0]
    if target<hope[i+1][1]:
        if target<hope[i+1][0]:
            target=hope[i+1][0]
    else:
        ans=ans+1
        target=hope[i+1][0]
print(ans+1)

Problem: p03295
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, M = map(int, input().split())
w = [list(map(int, input().split())) for _ in range(M)]
w.sort(key=lambda x: x[1])
f = 0
ans = 0
for i in range(M):
    if w[i][0] <= f < w[i][1]:
        continue
    f = w[i][1]
    ans += 1
print(ans)


Failing test case input:
3 2
-7 5
0 5

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
w = [list(map(int, input().split())) for _ in range(m)]
w.sort(key=lambda x: x[1])
f = -float('inf')
ans = 0
for p, q in w:
    if p >= f:
        ans += 1
        f = q
print(ans)

Problem: p03295
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(tasks):
    tasks = sorted(tasks, key=lambda x:x[1])
    cur_time = -1
    ans = 0
    for task in tasks:
        if task[0] > cur_time:
            ans += 1
            cur_time = task[1]
    return ans


n,m = map(int,input().split())

tasks = []
for i in range(m):
    a,b = map(int,input().split())
    tasks.append([a,b])

ans = solve(tasks)
print(ans)

Failing test case input:
5 2
1 2
2 8

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from operator import itemgetter


n,m = map(int,input().split())

tasks = []
for i in range(m):
    a,b = map(int,input().split())
    tasks.append([b,a])



tasks = sorted(tasks, key=lambda x: x[0])
end = 0
start = 0
ans = 0
for task in tasks:
    if task[1]<start: continue
    end = task[0]
    ans += 1
    start = end

print(ans)