Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans=Ans+[a]
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))


Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())

a_list=[]
for i in range(n):
  a_list.append(int(input()))

ans_head=[a_list[-1]]

for i in range(n-2,-1,-1):
  a=a_list[i]
  if a>ans_head[-1]:
    ans_head.append(a)
  else:
    insert_index = bisect.bisect_right(ans_head,a)
    ans_head[insert_index]=a

  #print(ans_head)
print(len(ans_head))


Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())

a_list=[]
for i in range(n):
  a_list.append(int(input()))

ans_head=[a_list[-1]]

for i in range(n-2,0,-1):
  a=a_list[i]
  if a>ans_head[-1]:
    ans_head.append(a)
  else:
    insert_index = bisect.bisect_right(ans_head,a)
    ans_head[insert_index]=a

  #print(ans_head)
print(len(ans_head))


Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())

a_list=[]
for i in range(n):
  a_list.append(int(input()))

ans_head=[99999]

for i in range(n-1,0,-1):
  a=a_list[i]
  if a>ans_head[-1]:
    ans_head.append(a)
  else:
    insert_index = bisect.bisect_right(ans_head,a)
    ans_head[insert_index]=a

  #print(ans_head)
print(len(ans_head))


Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
ans_head=[-1]

a_list=[]
for i in range(n):
  a_list.append(int(input()))

for i in range(n):
  a=a_list[i]
  if ans_head[0]>=a:
    ans_head=[a].append(ans_head)
  else:
    insert_index = bisect.bisect_left(ans_head,a)
    ans_head[insert_index-1]=a

  #print(ans_head)
print(len(ans_head))


Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
ans_head=[-1]

a_list=[]
for i in range(n):
  a_list.append(int(input()))

for i in range(n):
  a=a_list[i]
  if ans_head[0]>=a:
    ans_head=[a]+ans_head
  else:
    insert_index = bisect.bisect_left(ans_head,a)
    ans_head[insert_index-1]=a

  #print(ans_head)
print(len(ans_head))


Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
ans_head=[-1]
for i in range(n):
  a=int(input())
  if ans_head[0]>=a:
    ans_head=[a]+ans_head
  else:
    insert_index = bisect.bisect_left(ans_head,a)
    ans_head[insert_index-1]=a

  #print(ans_head)
print(len(ans_head))


Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
ans_head=[-1]
for i in range(n):
  a=int(input())
  if ans_head[0]>=a:
    ans_head=[a]+ans_head
  else:
    insert_index = bisect.bisect_left(ans_head,a)
    ans_head[insert_index-1]=a

  #print(ans_head)
print(len(ans_head))


Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
ans_head=[-1]
for i in range(n):
  a=int(input())
  if min(ans_head)>=a:
    ans_head=[a]+ans_head
  else:
    insert_index = bisect.bisect_left(ans_head,a)
    ans_head[insert_index-1]=a

  #print(ans_head)
print(len(ans_head))


Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
ans_head=[-1]
for i in range(n):
  a=int(input())
  if min(ans_head)>=a:
    ans_head=[a]+ans_head
  else:
    insert_index = bisect.bisect_left(ans_head,a)
    ans_head[insert_index-1]=a

  #print(ans_head)
print(len(ans_head))

Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
ans_head=[-1]
for i in range(n):
  a=int(input())
  if min(ans_head)>=a:
    ans_head.append(a)
  else:
    insert_index = bisect.bisect_left(ans_head,a)
    ans_head[insert_index-1]=a

  ans_head.sort()
  #print(ans_head)
print(len(ans_head))

Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list=[]
ans_head=[-1]
for i in range(n):
  a=int(input())
  for j in range(len(ans_head)):
    if ans_head[j]<a:
      ans_head[j]=a
      break
    else:
      if j==len(ans_head)-1:
        ans_head.append(a)
print(len(ans_head))

Fixed submission:
import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))