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

n = int(input())
num = []
for i in range(n):
    a = int(input())
    temp = bisect.bisect_left(num, a)
    if temp == 0:
        num.append(a)
    else:
        num[temp - 1] = a
    num.sort()
print(len(num))

Fixed submission:
import bisect, collections

n = int(input())
num = collections.deque([])
for i in range(n):
    a = int(input())
    temp = bisect.bisect_left(num, a)
    if temp == 0:
        num.appendleft(a)
    else:
        num[temp - 1] = a
print(len(num))

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

n = int(input())
num = []
for i in range(n):
    a = int(input())
    temp = bisect.bisect_left(num, a)
    if temp == 0:
        num.append(a)
    else:
        num[temp - 1] = a
    num.sort()
print(len(num))

Fixed submission:
import bisect, collections

n = int(input())
num = collections.deque([])
for i in range(n):
    a = int(input())
    temp = bisect.bisect_left(num, a)
    if temp == 0:
        num.appendleft(a)
    else:
        num[temp - 1] = a
print(len(num))

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

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

color = [float("inf")]
min_color = color[0]
for i in a:
    if i <= min_color:
        color = [i] + color
        min_color = i
    else:
        insert = bisect.bisect_left(color, i)
        color[insert - 1] = i
        if insert == 1:
            min_color = color[0]
print(len(color) - 1)

Fixed submission:
import bisect, collections

n = int(input())
num = collections.deque([])
for i in range(n):
    a = int(input())
    temp = bisect.bisect_left(num, a)
    if temp == 0:
        num.appendleft(a)
    else:
        num[temp - 1] = a
print(len(num))

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

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

color = [float("inf")]
min_color = color[0]
for i in a:
    if i <= min_color:
        color = [i] + color
        min_color = i
    else:
        insert = bisect.bisect_left(color, i)
        color[insert - 1] = i
        if insert == 1:
            min_color = color[0]
print(len(color) - 1)

Fixed submission:
import bisect, collections

n = int(input())
num = collections.deque([])
for i in range(n):
    a = int(input())
    temp = bisect.bisect_left(num, a)
    if temp == 0:
        num.appendleft(a)
    else:
        num[temp - 1] = a
print(len(num))

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

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

color = [float("inf")]
min_color = color[0]
for i in a:
    if i <= min_color:
        color = [i] + color
        min_color = i
    else:
        insert = bisect.bisect_left(color, i)
        del color[insert - 1]
        bisect.insort(color, i)
        if insert == 1:
            min_color = color[0]
print(len(color) - 1)

Fixed submission:
import bisect, collections

n = int(input())
num = collections.deque([])
for i in range(n):
    a = int(input())
    temp = bisect.bisect_left(num, a)
    if temp == 0:
        num.appendleft(a)
    else:
        num[temp - 1] = a
print(len(num))