Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = [a.pop(0)]
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.insert(0,ai)
print(len(color))

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

from collections import deque
import bisect
color = deque([a.pop(0)])
color_count =0 
for i, ai in enumerate(a): 
    index = bisect.bisect_left(color, ai)
    print(index-1, ai, color)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

Buggy python submission (verdict: Runtime Error):

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

import bisect

color = []
color.append(a.pop(0))
color_count =0 
for i, ai in enumerate(a): 
    index = bisect.bisect_left(color, ai)
    print(index-1, ai, color)
    if index > 0:
        color[index -1] = ai
    else:
        color.insert(0, ai)
print(len(color), color)

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

color = []
color.append(a.pop(0))
clen = 1
for ai in a:
    for i, c in enumerate(color): 
        if ai > c:
            color[i] = ai
            #color = quick_sort(color)
            break
        else:
            if i+1 == clen:
                color.append(ai)
                clen += 1
                break
print(clen)

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

Buggy python submission (verdict: Time Limit Exceeded):
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele > ref:
            left.append(ele)
        elif ele < ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

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

color = []
color.append(a.pop(0))
clen = 1
for ai in a:
    for i, c in enumerate(color): 
        if ai > c:
            color[i] = ai
            color = quick_sort(color)
            break
        else:
            if i+1 == clen:
                color.append(ai)
                clen += 1
                break
print(clen)

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

color = []
color.append(a.pop(0))
for ai in a:
    #color.sort(reverse=True)
    clen = len(color)
    for i, c in enumerate(color): 
        if ai > c:
            color[i] = ai
            break
        else:
            if i+1 == clen:
                color.append(ai)
                break
print(len(color))

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

color = []
color.append(a.pop(0))
for ai in a:
    color.sort(reverse=True)
    clen = len(color)
    for i, c in enumerate(color): 
        if ai > c:
            color[i] = ai
            break
        else:
            if i+1 == clen:
                color.append(ai)
                break
print(len(color))

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))