Buggy python submission (verdict: Time Limit Exceeded):
def p_e():
    N = int(input())
    # A = [int(input()) for _ in range(N)]
    ans = [-1]

    for _ in range(N):
        a = int(input())
        is_set = False
        for i, l in enumerate(ans):
            if l < a:
                ans[i] = a
                is_set = True
                break

        if not is_set:
            ans.append(a)

    print(len(ans))


if __name__ == '__main__':
    p_e()


Fixed submission:
from bisect import *


def p_e():
    N = int(input())
    # A = [int(input()) for _ in range(N)]
    ans = [-1] * N

    for _ in range(N):
        a = int(input())
        ans[bisect(ans, a - 1) - 1] = a

    print(N - bisect(ans, -1))


if __name__ == '__main__':
    p_e()

Buggy python submission (verdict: Time Limit Exceeded):
def p_e():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = [-1]

    for a in A:
        is_set = False
        for i, l in enumerate(ans):
            if l < a:
                ans[i] = a
                is_set = True
                break

        if not is_set:
            ans.append(a)

    print(len(ans))


if __name__ == '__main__':
    p_e()


Fixed submission:
from bisect import *


def p_e():
    N = int(input())
    # A = [int(input()) for _ in range(N)]
    ans = [-1] * N

    for _ in range(N):
        a = int(input())
        ans[bisect(ans, a - 1) - 1] = a

    print(N - bisect(ans, -1))


if __name__ == '__main__':
    p_e()

Buggy python submission (verdict: Time Limit Exceeded):

def p_e():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = [[-1]]

    for a in A:
        is_set = False
        for l in ans:
            if l[-1] < a:
                l.append(a)
                is_set = True
                break

        if not is_set:
            ans.append([a])
            
    print(len(ans))


if __name__ == '__main__':
    p_e()

Fixed submission:
from bisect import *


def p_e():
    N = int(input())
    # A = [int(input()) for _ in range(N)]
    ans = [-1] * N

    for _ in range(N):
        a = int(input())
        ans[bisect(ans, a - 1) - 1] = a

    print(N - bisect(ans, -1))


if __name__ == '__main__':
    p_e()

Buggy python submission (verdict: Time Limit Exceeded):

def p_e():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = [[-1]]

    for a in A:
        is_set = False
        for l in ans:
            if l[-1] < a:
                l.append(a)
                is_set = True
                break

        if not is_set:
            ans.append([a])
            
    print(len(ans))


if __name__ == '__main__':
    p_e()

Fixed submission:
from bisect import *


def p_e():
    N = int(input())
    # A = [int(input()) for _ in range(N)]
    ans = [-1] * N

    for _ in range(N):
        a = int(input())
        ans[bisect(ans, a - 1) - 1] = a

    print(N - bisect(ans, -1))


if __name__ == '__main__':
    p_e()

Buggy python submission (verdict: Time Limit Exceeded):
def p_e():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = 0

    while A:
        ans += 1
        stv = -1
        start = A.index(min(A))
        while start < len(A):
            if A[start] > stv:
                stv = A.pop(start)
            else:
                start += 1

    print(ans)


if __name__ == '__main__':
    p_e()


Fixed submission:
from bisect import *


def p_e():
    N = int(input())
    # A = [int(input()) for _ in range(N)]
    ans = [-1] * N

    for _ in range(N):
        a = int(input())
        ans[bisect(ans, a - 1) - 1] = a

    print(N - bisect(ans, -1))


if __name__ == '__main__':
    p_e()