def merge(left,right): sl=[] l=0 r=0 while l1: mid=(u+d)//2 if ul[mid]<=lis[i][0]: d=mid else: u=mid if d+1==len(ul): ul.append(lis[i][1]) li[i]=d+1 ul[d+1]=min(ul[d+1],lis[i][1]) #print(ul) #print(li) print(n-max(li))