Buggy python submission (verdict: Runtime Error):
N=int(input())
from collections import deque
d = deque([int(input())]) 
def insert_search(List,a,l,r):
  if r==l:
    List[l-1]=a
    return List
  m=(l+r)//2
  if List[m]<a:
    return insert_search(List,a,m+1,r)
  elif List[m]!=a:
    return insert_search(List,a,l,m-1)
  else:
    while List[m]==a:
      m-=1
    List[m]=a
    return List
for i in range(N-1):
  a=int(input())
  if a>d[-1]:
    d[-1]=a
  elif d[0]>=a:
    d.appendleft(a)
  else:
    d=insert_search(d,a,0,len(d)-1)
print(len(d))

Fixed submission:
N=int(input())
from collections import deque
d = deque([int(input())]) 
import bisect

for i in range(N-1):
  a=int(input())
  if a>d[-1]:
    d[-1]=a
  elif d[0]>=a:
    d.appendleft(a)
  else:
    i=bisect.bisect_left(d,a)
    d[i-1]=a
print(len(d))

Buggy python submission (verdict: Runtime Error):
N=int(input())
X=[int(input())]

def insert_search(List,a,l,r):
  if r==l:
    List[l-1]=a
    return List
  m=(l+r)//2
  if List[m]<a:
    return insert_search(List,a,m+1,r)
  elif List[m]!=a:
    return insert_search(List,a,l,m-1)
  else:
    while List[m]==a:
      m-=1
    List[m]=a
    return List
for i in range(N-1):
  a=int(input())
  if a>X[-1]:
    X[-1]=a
  elif X[0]>=a:
    X.insert(0,a)
  else:
    X=insert_search(X,a,0,len(X)-1)
print(len(X))

Fixed submission:
N=int(input())
from collections import deque
d = deque([int(input())]) 
import bisect

for i in range(N-1):
  a=int(input())
  if a>d[-1]:
    d[-1]=a
  elif d[0]>=a:
    d.appendleft(a)
  else:
    i=bisect.bisect_left(d,a)
    d[i-1]=a
print(len(d))

Buggy python submission (verdict: Runtime Error):
N=int(input())
X=[int(input())]

def insert_search(List,a,l,r):
  if r==l:
    List[l-1]=a
    return List
  m=(l+r)//2
  if List[m]<a:
    return insert_search(List,a,m+1,r)
  elif Lisr[m]!=a:
    return insert_search(List,a,l,m-1)
  else:
    while List[m]==a:
      m-=1
    List[m]=a
    return List
for i in range(N-1):
  a=int(input())
  if a>X[-1]:
    X[-1]=a
  elif X[0]>=a:
    X.insert(0,a)
  else:
    X=insert_search(X,a,0,len(X)-1)
print(len(X))

Fixed submission:
N=int(input())
from collections import deque
d = deque([int(input())]) 
import bisect

for i in range(N-1):
  a=int(input())
  if a>d[-1]:
    d[-1]=a
  elif d[0]>=a:
    d.appendleft(a)
  else:
    i=bisect.bisect_left(d,a)
    d[i-1]=a
print(len(d))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=[int(input())]

def insert_search(List,a,l,r):
  if r==l:
    List[l-1]=a
    return List
  m=(l+r)//2
  if List[m]<a:
    return insert_search(List,a,m+1,r)
  else:
    return insert_search(List,a,l,m)
for i in range(N-1):
  a=int(input())
  if a>X[-1]:
    X[-1]=a
  elif X[0]>=a:
    X.insert(0,a)
  else:
    X=insert_search(X,a,0,len(X)-1)
print(len(X))

Fixed submission:
N=int(input())
from collections import deque
d = deque([int(input())]) 
import bisect

for i in range(N-1):
  a=int(input())
  if a>d[-1]:
    d[-1]=a
  elif d[0]>=a:
    d.appendleft(a)
  else:
    i=bisect.bisect_left(d,a)
    d[i-1]=a
print(len(d))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=[int(input())]
for i in range(N-1):
  a=int(input())
  if a>X[-1]:
    X[-1]=a
  elif X[0]>=a:
    X.insert(0,a)
  else:
    for j,x in enumerate(X):
      if x>=a:
        X[j-1]=a
        break
print(len(X))

Fixed submission:
N=int(input())
from collections import deque
d = deque([int(input())]) 
import bisect

for i in range(N-1):
  a=int(input())
  if a>d[-1]:
    d[-1]=a
  elif d[0]>=a:
    d.appendleft(a)
  else:
    i=bisect.bisect_left(d,a)
    d[i-1]=a
print(len(d))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=[int(input())]
for i in range(N-1):
  a=int(input())
  if a>max(X):
    X[-1]=a
  elif min(X)>=a:
    X.insert(0,a)
  else:
    for j,x in enumerate(X):
      if x>=a:
        X[j-1]=a
        break
print(len(X))

Fixed submission:
N=int(input())
from collections import deque
d = deque([int(input())]) 
import bisect

for i in range(N-1):
  a=int(input())
  if a>d[-1]:
    d[-1]=a
  elif d[0]>=a:
    d.appendleft(a)
  else:
    i=bisect.bisect_left(d,a)
    d[i-1]=a
print(len(d))