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

N = int(input())

A = [int(input()) for _ in range(N)]

colors = []

for i in range(N):
    target = bisect.bisect_left(colors, A[i])

    if target == 0:
        colors.insert(0, A[i])
    else:
        colors[target-1] = A[i]

print(len(colors))


Fixed submission:
import bisect

N = int(input())

A = [int(input()) for _ in range(N)]

colors = []

for i in range(N-1, -1, -1):
    target = bisect.bisect_right(colors, A[i])

    if target == len(colors):
        colors.append(A[i])
    else:
        colors[target] = A[i]

print(len(colors))

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

A = []

for _ in range(N):
    A.append(int(input()))

color_base = []

for i, a in enumerate(A):
    for j, color in enumerate(color_base):
        if a > color :
            color_base[j] = a
            break
    else :
        color_base.append(a)

print(len(color_base))


Fixed submission:
import bisect

N = int(input())

A = [int(input()) for _ in range(N)]

colors = []

for i in range(N-1, -1, -1):
    target = bisect.bisect_right(colors, A[i])

    if target == len(colors):
        colors.append(A[i])
    else:
        colors[target] = A[i]

print(len(colors))

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

A = []

for _ in range(N):
    A.append(int(input()))

color_num = 0

while A != []:
    base = A[0]
    A.pop(0)

    looking = 0

    while looking < len(A):
        if base < A[looking] :
            base = A[looking]
            A.pop(looking)
        else:
            looking += 1

    color_num += 1

print(color_num)


Fixed submission:
import bisect

N = int(input())

A = [int(input()) for _ in range(N)]

colors = []

for i in range(N-1, -1, -1):
    target = bisect.bisect_right(colors, A[i])

    if target == len(colors):
        colors.append(A[i])
    else:
        colors[target] = A[i]

print(len(colors))

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

A = []

for _ in range(N):
    A.append(int(input()))

colored = [False] * N
goal = [True] * N

color_num = 0

while colored != goal:
    start = colored.index(False)
    base = A[start]
    colored[start] = True

    for i in range(start+1, N):
        if colored[i] == False:
            if base < A[i] :
                colored[i] = True
                base = A[i]

    color_num += 1

print(color_num)


Fixed submission:
import bisect

N = int(input())

A = [int(input()) for _ in range(N)]

colors = []

for i in range(N-1, -1, -1):
    target = bisect.bisect_right(colors, A[i])

    if target == len(colors):
        colors.append(A[i])
    else:
        colors[target] = A[i]

print(len(colors))

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

A = []

for i in range(N):
    A.append(int(input()))

color = 1

def hantei(start):
    global color
    current = start - 1

    while current >= 0:
        if A[current] >= A[start]:
            color += 1
            hantei(current)
            return
        else:
            current -= 1
            start -= 1

hantei(N-1)

print(color)


Fixed submission:
import bisect

N = int(input())

A = [int(input()) for _ in range(N)]

colors = []

for i in range(N-1, -1, -1):
    target = bisect.bisect_right(colors, A[i])

    if target == len(colors):
        colors.append(A[i])
    else:
        colors[target] = A[i]

print(len(colors))