qyliang/CodeNanoFix huggingface dataset:
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Mon Aug  6 17:15:00 2018

@author: Yuki
"""

N = int(input())

A = list(input().split())
A = [int(i) for i in A]

def get_f_value(m, A):
    mod_list = [m%i for i in A]
    return sum(mod_list)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)

def get_lcm_from_list(A):
    lcm_list = [lcm(A[i], A[i+1]) for i in range(len(A)-1)]
    return max(lcm_list)

lcm_value = get_lcm_from_list(A)
res = []
for m in range(lcm_value):
    res.append(get_f_value(m, A))
print(max(res))


Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Mon Aug  6 17:15:00 2018

@author: Yuki
"""

N = int(input())

A = list(input().split())
A = [int(i) for i in A]
#
#def get_f_value(m, A):
#    mod_list = [m%i for i in A]
#    return sum(mod_list)
#
#def gcd(a, b):
#	while b:
#		a, b = b, a % b
#	return a
#def lcm(a, b):
#	return a * b // gcd (a, b)
#
#def get_lcm_from_list(A):
#    lcm_list = [lcm(A[i], A[i+1]) for i in range(len(A)-1)]
#    return max(lcm_list)
#
#lcm_value = get_lcm_from_list(A)
#res = []
#for m in range(lcm_value):
#    res.append(get_f_value(m, A))
#print(max(res))

print(sum(A) - N)
Buggy code:
n = int(input())
a = map(int, input().split())
print(sum(x-1 for x in s))

Fixed code:
n = int(input())
a = map(int, input().split())
print(sum(x-1 for x in a))
Buggy code:
n = input()
l = list(map,input().split())
print(sum(l)-n)

Fixed code:
n = int(input())
l = list(map(int,input().split()))
print(sum(l)-n)
Buggy code:
n=int(input())
da=list(map((int,input().split()))
ans=0
for i in da:
  ans+=i-1
print(ans)


Fixed code:
n=int(input())
da=list(map(int,input().split()))
ans=0
for i in da:
  ans+=i-1
print(ans)
Buggy code:
n = int(input())
a = (int(i) for i in input().split())
print(sum(a)-len(a))

Fixed code:
n = int(input())
a = list(int(i) for i in input().split())
print(sum(a)-len(a))
Buggy code:

N=int(input())
a = list(map(int,input().split()))

ans = 0
for aa in a:
    ans+=a-1
    
print(ans)

Fixed code:

N=int(input())
a = list(map(int,input().split()))

ans = 0
for aa in a:
    ans+=aa-1
    
print(ans)
Buggy code:
N=int(input)
print(sum(list(map(int, input().split())))-N)

Fixed code:
N=int(input())
print(sum(list(map(int, input().split())))-N)
Buggy code:
number_int = input()
list_int = list(map(int,input().split()))

print(sum(list_int)-number_int)


Fixed code:
number_int = input()
list_int = list(map(int,input().split()))

print(str(sum(list_int) - int(number_int)))
Buggy code:
i = input;i();print(sum([x-1 for x in i().split()]))

Fixed code:
i = input;i();print(sum([int(x)-1 for x in i().split()]))
Buggy code:
print(sum(i-1for i in map(int,open(0).read().split())[1:]))

Fixed code:
print(sum(i-1for i in list(map(int,open(0).read().split()))[1:]))
Buggy code:
n=int(input())
a=list(int,input().split())
print(sum(a)-n)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
print(sum(a)-n)
Buggy code:
n = int(input())
a=map(int, input().split())
print(sum(a) - len(a))

Fixed code:
n = int(input())
a=list(map(int, input().split()))
print(sum(a) - len(a))
Buggy code:
N=input()
print(sum(map(int, input().split()))-N)

Fixed code:
N=int(input())
print(sum(map(int, input().split()))-N)
Buggy code:
n = int(input())
a = list(map(int,input().split())
print(sum(a)-n)
        

         

Fixed code:
n=int(input())
a=map(int,input().split())
print(sum(a)-n)
Buggy code:
line = input()
words = line.split()
num_list = []
for word in words:
    num_list.append(int(word))
ans = 0
for num in num_list:
    ans += num-1

print(ans)

Fixed code:
line = input()
line= input()
words = line.split()
num_list = []
for word in words:
    num_list.append(int(word))
ans = 0
for num in num_list:
    ans = ans + (num-1)

print(ans)
Buggy code:
N = int(input())
a = [int(i) for i input().split()]
print(sum(a) - N)

Fixed code:
N = int(input())
a = [int(i) for i in input().split()]

print(sum(a) - N)
Buggy code:
N,M=map(int,input().split())
L=list()
for i in range(M):
  a,b=map(int,input().split())
  A=list([b,a])
  L.append(A)
L=sorted(L)
R=[L[0][1]]
for j in range(M):
  if R[-1] not in range(L[j][1],L[j][0]):
    R.append(L[j][0]-1)
print(len(R))

Fixed code:
N,M=map(int,input().split())
L=list()
for i in range(M):
  a,b=map(int,input().split())
  A=list([b,a])
  L.append(A)
L=sorted(L)
R=[L[0][0]-1]
for j in range(M):
  if R[-1] not in range(L[j][1],L[j][0]):
    R.append(L[j][0]-1)
print(len(R))
Buggy code:
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)

Fixed code:
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)
Buggy code:
a=[""]*m
b=[""]*m
for i in range(m):
    x,l=map(int,input().split())
    a[i]=x*10+5
    b[i]=l*10-5
st=sorted([(a[i],b[i]) for i in range(m)], key=itemgetter(1))
ans=0
last=0
last=-float("inf")
for i in range(m):
    if last<st[i][0]:
        ans+=1
        last=st[i][1]
print(ans)

Fixed code:
from operator import itemgetter
n,m=map(int,input().split())
a=[""]*m
b=[""]*m
for i in range(m):
    x,l=map(int,input().split())
    a[i]=x*10+5
    b[i]=l*10-5
st=sorted([(a[i],b[i]) for i in range(m)], key=itemgetter(1))
ans=0
last=0
last=-float("inf")
for i in range(m):
    if last<st[i][0]:
        ans+=1
        last=st[i][1]
print(ans)
Buggy code:
import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	n,m=MI()
	li=[LI() for _ in range(m)]

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

	now=0
	ans=0

	for a,b in li:
		if now<=a:
			now=b
			ans+=1
	print(ans)

























if __name__ == "__main__":
	main()


Fixed code:
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


#import numpy as np

def main():
	n,m=MI()
	li=[LI() for _ in range(m)]
	#print(li)
	li.sort(key=lambda x:x[1])
	#print(li)
	
	now=0
	ans=0
	
	for a,b in li:
		if now<=a:
			ans+=1
			now=b
	
	print(ans)
	
	

if __name__ == "__main__":
	main()
Buggy code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
AB = [lr() for _ in range(M)]
AB.sort(key=lambda x: [x[0], x[1]])
cur = 0
answer = 0
for a, b in AB:
    if a >= cur:
        answer += 1
        cur = b

print(answer)


Fixed code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
AB = [lr() for _ in range(M)]
AB.sort(key=lambda x: [x[0], x[1]])
cur = 0
answer = 0
for a, b in AB:
    if a >= cur:
        answer += 1
        cur = b
    if b < cur:
        cur = b

print(answer)
Buggy code:
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)


Fixed code:
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)
Buggy code:
N, M = list(map(int,input().split()))
a = []
for i in range(M):
    a.append(list(map(int,input().split())))
a = sorted(a, key=lambda x: x[1])
left = -1
ans = 0
for i in range(M):
        if left <= a[i][0]:
            left = a[i][1] - 1
            ans += 1
print(ans)

Fixed code:
N, M = list(map(int,input().split()))
a = []
for i in range(M):
    a.append(list(map(int,input().split())))
a = sorted(a, key=lambda x: x[1])
left = -1
ans = 0
for i in range(M):
    if left < a[i][0]:
      left = a[i][1] - 1
      ans += 1
print(ans)
Buggy code:
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)

Fixed code:
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)
Buggy code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,m=MI()
lis=[]
for i in range(m):
    lis.append(LI())
lis.sort(key=lambda x:x[1])
print(lis)
bri=0
count=0
for i in range(m):
    if bri<=lis[i][0]:
        bri=lis[i][1]
        count+=1
        
print(count)

Fixed code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,m=MI()
lis=[]
for i in range(m):
    lis.append(LI())
lis.sort(key=lambda x:x[1])
#print(lis)
bri=0
count=0
for i in range(m):
    if bri<=lis[i][0]:
        bri=lis[i][1]
        count+=1
        
print(count)
Buggy code:
def main():
    N, M = map(int, input().split())
    y = []
    for i in range(M):
        y.append(list(map(int, input().split())))
    youbou = sorted(y, key = lambda x:x[1])
    
    cnt = 1
    k = 0
    for i in range(1, M):
        if(youbou[i][0] >= k):
            cnt += 1
            k = youbou[i][1]
    print(cnt)
main()

Fixed code:
def main():
    N, M = map(int, input().split())
    y = []
    for i in range(M):
        y.append(list(map(int, input().split())))
    youbou = sorted(y, key = lambda x:x[1])
    
    cnt = 0
    k = 0
    for i in range(M):
        if(youbou[i][0] >= k):
            cnt += 1
            k = youbou[i][1]
    print(cnt)
main()
Buggy code:
from operator import itemgetter

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

a = []
b = []

for i in range(M):
    ao,bo = map(int,input().split())
    a.append(ao)
    b.append(bo)

ab = sorted([(a[i],b[i]) for i in range(M)], key = itemgetter(1))

ans = 0
last = 0

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

print(ans)


Fixed code:
from operator import itemgetter

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

a = []
b = []

for i in range(M):
    ao,bo = map(int,input().split())
    a.append(ao)
    b.append(bo)

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]:
        ans += 1
        last = ab[i][1]

print(ans)
Buggy code:
N, M = map(int, input().split())
s = [list(map(int, input().split())) for i in range(M)]
s.sort(key=lambda x:x[1])

count=1
mae=[0][1]
for i in range(1,N):
    if s[i][0]>=mae:
        count+=1
        mae=kukan[i][1]

print(count)

Fixed code:
N, M = map(int, input().split())
s = [list(map(int, input().split())) for i in range(M)]
s.sort(key=lambda x:x[1])

count=1
mae=s[0][1]
for i in range(1,M):
    if s[i][0]>=mae:
        count+=1
        mae=s[i][1]

print(count)
Buggy code:
n,m=map(int,input().split())

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

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

cnt=0
border=0

for item in ab:
    if item[0]>=border:
        border=item[1]
        cnt+=1

print(cnt)



Fixed code:
n,m=map(int,input().split())

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

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

cnt=0
border=0

for item in ab:
    if item[0]>=border:
        border=item[1]
        cnt+=1

print(cnt)
Buggy code:
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
l.sort(key=lambda x:x[1])
lb=0
ans=0
for a,b in l:
    if a>=lb:
        lb=b
        ans+=1
print(ans)

Fixed code:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
l.sort(key=lambda x:x[1])
lb=0
ans=0
for a,b in l:
    if a>=lb:
        lb=b
        ans+=1
print(ans)
Buggy code:
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)

Fixed code:
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)
Buggy code:
n,m=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(m)] 

ab.sort(key=lambda ab:ab[1])
ans=[ab[0]]
for i in range(1:m):
    if ans[-1][1]<=ab[i][0]:
        ans.append(ab[i])
print(len(ans))

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

ab.sort(key=lambda ab:ab[1])
ans=[ab[0]]
for i in range(1,m):
    if ans[-1][1]<=ab[i][0]:
        ans.append(ab[i])
print(len(ans))
Buggy code:
import numpy as np

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

b = np.array(b)
idx = np.argsort(b)
a=np.array(a)
a=a[idx]

n=1
r = a[0][1]
for i in range(M):
  if r <= a[i][0]:
    n+=1
    r=a[i][0]

print(n)





Fixed code:
import numpy as np

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

b = np.array(b)
idx = np.argsort(b)
a=np.array(a)
a=a[idx]

n=1
r = a[0][1]
for i in range(M):
  if r <= a[i][0]:
    n+=1
    r=a[i][1]

print(n)
Buggy code:
N, M = map(int, input().split())
#M = int(input())
ab = [list(map(int, input().split())) for _ in range(M)]

from operator import itemgetter
st = sorted(ab, key=itemgetter(1))
last = 0
ans = 0
for s, t in st:
    #print(x, l)
    if s > last:
        ans += 1
        last = t
print(ans)

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

from operator import itemgetter
st = sorted(ab, key=itemgetter(1))
last = 0
ans = 0
for s, t in st:
    #print(x, l)
    if s >= last:
        ans += 1
        last = t
print(ans)
Buggy code:
N, M = map(int, input().split())
S = []
for i in range(M):
     a, b = map(int, input().split())
    S.append([a, b])
    
from operator import itemgetter
S = sorted(S, key=itemgetter(1))
ans = 0
last = -1*float('Inf')
for si in S:
    if si[0] >= last:
        ans += 1
        last = si[1]
print(ans)

Fixed code:
N, M = map(int, input().split())
S = []
for i in range(M):
    a, b = map(int, input().split())
    S.append([a, b])
    
from operator import itemgetter
S = sorted(S, key=itemgetter(1))
ans = 0
last = -1*float('Inf')
for si in S:
    if si[0] >= last:
        ans += 1
        last = si[1]
print(ans)
Buggy code:
n,m = map(int,input().split())
ts = [list(map(int,input().split()))[::-1]]

count += 0
t = 0

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

Fixed code:
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)
Buggy code:
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)

Fixed code:
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)
Buggy code:
n,m = map(int,input().split())
ab = []
for _ in range(m):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ab = sorted(ab, key=lambda x: x[1])
print(ab)
count = 1
memo = ab[0][1]
for i in range(m):
    if i == 0:
        continue
    if memo <= ab[i][0]:
        count += 1
        memo = ab[i][1]
print(count)

Fixed code:
n,m = map(int,input().split())
ab = []
for _ in range(m):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ab = sorted(ab, key=lambda x: x[1])
#print(ab)
count = 1
memo = ab[0][1]
for i in range(m):
    if i == 0:
        continue
    if memo <= ab[i][0]:
        count += 1
        memo = ab[i][1]
print(count)
Buggy code:
N,M=map(int,input().split())
ab=[]
for m in range(M):
  [a,b]=[int(i) for i in input().split()]
  ab.append([a,b])
ab.sort(key=lambda x:x[1])
count=[]
bmin=ab[0][1]
count.append(ab[0][1]-1)
for i in range(1,M):
  if ab[i][1]==b:
    count.remove(count[0])
    count.append(ab[i][1])
  else:
    pass
for i in range(1,M):
  if ab[i][0]<=count[-1]<ab[i][1]:
    pass
  else:
    count.append(ab[i][1])
print(len(count))

Fixed code:
N,M=map(int,input().split())
ab=[]
for m in range(M):
  [a,b]=[int(i) for i in input().split()]
  ab.append([a,b])
ab.sort(key=lambda x:x[1])
count=[]
count.append(ab[0][1]-1)
for i in range(1,M):
  if ab[i][0]<=count[-1]<ab[i][1]:
    pass
  elif ab[i][0]<=count[-1] and ab[i][1]-1==count[-1]:
    count.remove(count[-1])
    count.append(ab[i][1]-1)
  else:
    count.append(ab[i][1]-1)
print(len(count))
Buggy code:
n,m = map(int,input().split())
cut = []
for _ in range(m):
  a,b = map(int,input().split())
  cut.append((a,b))
cut.sort(key = lambda x:x[1])

ex_b  = cut[0][1]
count = 0
for a,b in cut[1:]:
  if a > ex_b:
    count += 1
print(count)

Fixed code:
n,m = map(int,input().split())
cut = []
for _ in range(m):
  a,b = map(int,input().split())
  cut.append((a,b))
cut.sort(key = lambda x:x[1])

ex_b  = cut[0][1]
count = 0
for a,b in cut[1:]:
  if a >= ex_b:
    count += 1
    ex_b = b
print(count+1)
Buggy code:
n,m = map(int,input().slit())

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

cut.sort()

b_min = cut[0][1]
count = 0

for a,b in cut:
  if b_min > b:
    b_min = b
    continue
  if b_min > a:
    count += 1
    b_min = b

print(count)

Fixed code:
n,m = map(int,input().split())

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

cut.sort()

b_min = cut[0][1]
count = 0

for a,b in cut[1:]:
  if b_min > b:
    b_min = b
    continue
  if b_min <= a:
    count += 1
    b_min = b

print(count+1)
Buggy code:
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]
AB.sort(key=lambda ab: -ab[1])
count = 1
l = AB[0][1]
for a, b in AB[1:]:
    if l < a:
        l = a
    if b <= l:
        l = a
        count += 1
print(count)


Fixed code:
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]
AB.sort(key=lambda ab: -ab[1])
count = 1
l = AB[0][0]
for a, b in AB[1:]:
    if l < a:
        l = a
    if b <= l:
        l = a
        count += 1
print(count)
Buggy code:
import sys

input = sys.stdin.readline
n, m = map(int, input().split())

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

request.sort(key=lambda x: x[1])
pre = - 1
ans = 1
for a, b in request:
    if pre < a:
        ans += 1
        pre = b - 1

print(ans)


Fixed code:
import sys

input = sys.stdin.readline
n, m = map(int, input().split())

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

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

print(ans)
Buggy code:
n,m=map(int,input().split())
ab=[[0]*2 for _ in range(m)]
for i in range(m):
  a,b=map(int,input().split())
  ab[i][0],ab[i][1]=b,a
ab.sort()
cnt=0
b=0
for i in range(m):
  if b<ab[i][1]:
    cnt+=1
    b=ab[i][0]
print(cnt)

Fixed code:
n,m=map(int,input().split())
ab=[[0]*2 for _ in range(m)]
for i in range(m):
  a,b=map(int,input().split())
  ab[i][0],ab[i][1]=b,a
ab.sort()
cnt=0
chk=0
for b,a in ab:
  if chk<=a:
    cnt+=1
    chk=b
print(cnt)
Buggy code:
n, m = map(int, input().split())
p = []
for i in range(n):
  r, l = map(int, input().split())
  p.append((r, l))

p.sort()
mr = 0
c = 0
for l, r in p:
  if l >= mr:
    mr = r
    continue
  c += 1
  mr = min(mr, r)

print(c)

Fixed code:
n, m = map(int, input().split())
p = []
for i in range(m):
  r, l = map(int, input().split())
  p.append((r, l))

p.sort()
mr = 0
c = 0
for l, r in p:
  if l >= mr:
    mr = r
    c += 1
    continue
  mr = min(mr, r)

print(c)
Buggy code:
N, M = map(int, input().split())
AB = []
for i in range(M):
    a, b = list(map(int, input().split()))
    AB.append([a, b])

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

cnt = 1
s = AB[0][1]
for a, b in AB[1:]:
    if s <= a:
        cnt += 1
print(cnt)



Fixed code:
N, M = map(int, input().split())
AB = []
for i in range(M):
    a, b = list(map(int, input().split()))
    AB.append([a, b])

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

cnt = 1
s = AB[0][1]
for a, b in AB[1:]:
    if s <= a:
        cnt += 1
        s = b
print(cnt)
Buggy code:
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)

Fixed code:
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)
Buggy code:
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)

Fixed code:
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)