Buggy python submission (verdict: Time Limit Exceeded):
"""import bisect
lst=[i for i in range(100)]
lst.reverse()
print(bisect.bisect_left(lst,1))
exit()
"""
N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=[]
lstm=0
for i in range(N):
    if A[i]==C[-1]:

        if not lst:
            C.pop()
            count+=1
            continue
    flag=1
    for l in range(len(lst)):
        if lst[l]<A[i]:
            lst[l]=A[i]
            flag=0
            break
    if flag:
        lst.append(A[i])
        count+=1
    #print(count,i,lst)
print(count)


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=[]
lstm=0
for i in range(N):
    flag=1
    for l in range(len(lst)):
        if lst[l]<A[i]:
            lst[l]=A[i]
            flag=0
            break
    if flag:
        lst.append(A[i])
        count+=1
    #print(count,i,lst)
print(count)


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N=int(input())
A=np.array([int(input()) for i in range(N)],dtype=np.int32)
B=[0 for i in range(N)]
C=sorted(A)
count=0
for i in range(N):

    if B[i]:
        continue

    else:
        temp=A[i]
        for m in range(i,N):
            if not B[m]:
                if A[m]==C[-1]:
                    B[m]=1
                    C.pop()
                    break
                else:
                    if temp<A[m]:
                        temp=A[m]
                        B[m]=1
        count+=1
    #print(i,count,B)
print(count)


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N=int(input())
A=np.array([int(input()) for i in range(N)],dtype=np.int32)
B=[0 for i in range(N)]
C=sorted(A)
count=0
for i in range(N):

    if B[i]:
        continue

    else:
        temp=A[i]
        for m in range(i,N):
            if not B[m]:
                if A[m]==C[-1]:
                    B[m]=1
                    C.pop()
                    break
                else:
                    if temp<A[m]:
                        temp=A[m]
                        B[m]=1
        count+=1
    #print(i,count,B)
print(count)


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
for i in range(N):

    if B[i]:
        continue

    else:
        temp=A[i]
        for m in range(i,N):
            if not B[m]:
                if A[m]==C[-1]:
                    B[m]=1
                    C.pop()
                    break
                else:
                    if temp<A[m]:
                        temp=A[m]
                        B[m]=1
        count+=1
    #print(i,count,B)
print(count)


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

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

N=int(input())
A=[int(input()) for i in range(N)]
lst=[A[-1]]
nowN=max(A)+1
i=len(A)-2
while i>=0:
    #print(lst)
    if max(lst)>A[i]:
        maxvalue=0
        maxvaluei=100000
        for n in range(len(lst)):
            if lst[n]>A[i] and lst[n]>maxvalue:
                maxvalue=lst[n]
                maxvaluei=n
        lst[maxvaluei]=A[i]
                #break
    else:
        lst.append(A[i])

    i-=1
print(len(lst))


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

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

N=int(input())
A=[int(input()) for i in range(N)]
lst=[[A[-1]]]
nowN=max(A)+1
i=len(A)-2
while i>=0:
    #print(lst)
    lst2=[n[-1] for n in lst]
    if max(lst2)>A[i]:
        maxvalue=0
        maxvaluei=100000
        for n in range(len(lst2)):
            if lst2[n]>A[i] and lst2[n]>maxvalue:
                maxvalue=lst2[n]
                maxvaluei=n
        lst[maxvaluei].append(A[i])
                #break
    else:
        lst.append([A[i]])

    i-=1
print(len(lst))


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

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

N=int(input())
A=[int(input()) for i in range(N)]
count=0
while A:

    nowN=A[-1]
    A.pop()
    count+=1
    i=len(A)-1
    while i>=0:
        if A[i]<nowN:
            nowN=A[i]
            A.pop(i)
        i-=1


    #print(count,A)
print(count)


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

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

N=int(input())
A=[int(input()) for i in range(N)]
lst=[]
nowN=max(A)+1
i=0
while i<N:
    if nowN>=A[i]:
        nowN=A[i]
        lst.append([A[i]])
    else:
        lst2=[n[-1] for n in lst]
        if min(lst2)<A[i]:
            for n in range(len(lst2)):
                if lst2[n]<A[i]:
                    lst[n].append(A[i])
                    break
        else:
            lst.append([A[i]])
    i+=1
print(len(lst))


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

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

N=int(input())
A=[int(input()) for i in range(N)]
lst=[]
nowN=max(A)+1
i=0
while i<N:
    if nowN>=A[i]:
        nowN=A[i]
        lst.append([A[i]])
    else:
        lst2=[n[-1] for n in lst]
        if min(lst2)<A[i]
            for n in range(len(lst2)):
                if lst2[n]<A[i]:
                    lst[n].append(A[i])
                    break
        else:
            lst.append([A[i]])
    i+=1
print(len(lst))


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):

N=int(input())
A=[int(input()) for i in range(N)]
lst=[]
nowN=max(A)+1
i=0
while i<N:
    if nowN>=A[i]:
        nowN=A[i]
        lst.append([A[i]])
    else:
        flag=0
        for n in range(len(lst)):
            if lst[n][-1]<A[i]:
                lst[n].append(A[i])
                flag=1
                break
        if not flag:
            lst.append([A[i]])
    i+=1
print(len(lst))


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
lst=[]
nowN=max(A)+1
i=0
while i<N:
    if nowN>=A[i]:
        nowN=A[i]
        lst.append([A[i]])
    else:
        lst2=[n[-1] for n in lst]
        flag=0
        for n in range(len(lst2)):
            if lst2[n]<A[i]:
                lst[n].append(A[i])
                flag=1
                break
        if not flag:
            lst.append([A[i]])
    i+=1
print(len(lst))


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
count=0
nowN=0
while A:
    #print(A)
    nowN=0
    m=1
    deleteFlag=0
    maxA=max(A)
    while m<len(A):
        #print(A[nowN],A[m])
        if A[m]==maxA and A[nowN]<A[m]:
            #print(A[nowN],A[m],"MAX")
            A.pop(m)
            A.pop(nowN)
            deleteFlag=1
            break
        if A[nowN]<A[m]:
            #print( A[nowN],A[m],"hutuu")
            A.pop(nowN)
            nowN=m-1
            deleteFlag=1
        else:
            m+=1
    count+=1
    if not deleteFlag:A.pop(0)

print(count)


Fixed submission:
import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

print(count)