Buggy python submission (verdict: Time Limit Exceeded):
import bisect
 
 
N = int(input())
 
lis = []
 
A1 = int(input())
 
 
lis.append(A1)
 
 
for i in range(N-1):
 
    A = int(input())
 
    flag = True
    ins = bisect.bisect_left(lis,A)
 
    if ins == 0:
        lis.insert(0,A)
 
    if lis[ins-1] < A:
        lis[ins-1] = A
 
"""
    for l in lis:
 
 
 
        if l < A:
            l = A
            flag = False
            lis.sort()
            maxi = max(maxi , i)
            break
 
    if flag:
        lis.append(A)
"""
 
#print (lis)
print (len(lis))


Fixed submission:
import bisect

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

A.reverse()

seq = [float("-inf")]

for i in A:

    ind = bisect.bisect_right(seq,i)

    if ind == len(seq):
        seq.append(i)
    else:
        seq[ind] = i

print (len(seq)-1)

Buggy python submission (verdict: Runtime Error):
import bisect
 
 
N = int(input())
 
lis = []
 
A1 = int(input())
 
 
lis.append(A1)
 
 
for i in range(N-1):
 
    A = int(input())
 
    flag = True
    ins = bisect.bisect_left(lis,A)
 
    if ins == 0:
        B = [A] + lis
        lis = B.copy()
 
    if lis[ins-1] < A:
        lis[ins-1] = A
 
"""
    for l in lis:
 
 
 
        if l < A:
            l = A
            flag = False
            lis.sort()
            maxi = max(maxi , i)
            break
 
    if flag:
        lis.append(A)
"""
 
#print (lis)
print (len(lis))


Fixed submission:
import bisect

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

A.reverse()

seq = [float("-inf")]

for i in A:

    ind = bisect.bisect_right(seq,i)

    if ind == len(seq):
        seq.append(i)
    else:
        seq[ind] = i

print (len(seq)-1)

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


N = int(input())

lis = []

A1 = int(input())


lis.append(A1)


for i in range(N-1):

    A = int(input())

    flag = True
    ins = bisect.bisect_left(lis,A)

    if ins == 0:
        B = [A] + lis
        lis = B.copy()

    if lis[ins-1] < A:
        lis[ins-1] = A

"""
    for l in lis:

 

        if l < A:
            l = A
            flag = False
            lis.sort()
            maxi = max(maxi , i)
            break

    if flag:
        lis.append(A)
"""

#print (lis)
print (len(lis))


Fixed submission:
import bisect

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

A.reverse()

seq = [float("-inf")]

for i in A:

    ind = bisect.bisect_right(seq,i)

    if ind == len(seq):
        seq.append(i)
    else:
        seq[ind] = i

print (len(seq)-1)

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


N = int(input())

lis = []

A1 = int(input())


lis.append(A1)


for i in range(N-1):

    A = int(input())

    flag = True
    ins = bisect.bisect_left(lis,A)

    if ins == 0:
        B = [A] + lis
        lis = B.copy()

    if lis[ins-1] < A:
        lis[ins-1] = A

"""
    for l in lis:

 

        if l < A:
            l = A
            flag = False
            lis.sort()
            maxi = max(maxi , i)
            break

    if flag:
        lis.append(A)
"""

#print (lis)
print (len(lis))


Fixed submission:
import bisect

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

A.reverse()

seq = [float("-inf")]

for i in A:

    ind = bisect.bisect_right(seq,i)

    if ind == len(seq):
        seq.append(i)
    else:
        seq[ind] = i

print (len(seq)-1)

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


N = int(input())

lis = []

A1 = int(input())


lis.append(A1)


for i in range(N-1):

    A = int(input())

    flag = True
    ins = bisect.bisect_left(lis,A)

    if ins == 0:
        B = [A] + lis
        lis = B.copy()

    if lis[ins-1] < A:
        lis[ins-1] = A

"""
    for l in lis:

 

        if l < A:
            l = A
            flag = False
            lis.sort()
            maxi = max(maxi , i)
            break

    if flag:
        lis.append(A)
"""

#print (lis)
print (len(lis))


Fixed submission:
import bisect

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

A.reverse()

seq = [float("-inf")]

for i in A:

    ind = bisect.bisect_right(seq,i)

    if ind == len(seq):
        seq.append(i)
    else:
        seq[ind] = i

print (len(seq)-1)

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


N = int(input())

lis = []

A1 = int(input())


lis.append(A1)


for i in range(N-1):

    A = int(input())

    flag = True
    ins = bisect.bisect_left(lis,A)

    if ins == 0:
        lis.insert(0,A)

    if lis[ins-1] < A:
        lis[ins-1] = A

"""
    for l in lis:

 

        if l < A:
            l = A
            flag = False
            lis.sort()
            maxi = max(maxi , i)
            break

    if flag:
        lis.append(A)
"""

#print (lis)
print (len(lis))


Fixed submission:
import bisect

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

A.reverse()

seq = [float("-inf")]

for i in A:

    ind = bisect.bisect_right(seq,i)

    if ind == len(seq):
        seq.append(i)
    else:
        seq[ind] = i

print (len(seq)-1)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())

lis = []

A1 = int(input())

lis.append([A1])


for i in range(N-1):

    A = int(input())

    flag = True

    for l in lis:

        if l[-1] < A:
            l.append(A)
            flag = False
            break

    if flag:
        lis.append([A])

#print (lis)
print (len(lis))


Fixed submission:
import bisect

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

A.reverse()

seq = [float("-inf")]

for i in A:

    ind = bisect.bisect_right(seq,i)

    if ind == len(seq):
        seq.append(i)
    else:
        seq[ind] = i

print (len(seq)-1)