Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
 
c = []
for i in range(N):
    n = int(input())
    index = bisect.bisect_left(c,n)
    #print(index,c)
    if index == 0:
        c.insert(0,n)
    else:
        c[index-1] = n
    #print(c)
 
print(len(c)) 

Fixed submission:
import bisect
N = int(input())

def bisect_right_reverse(a, x, lo=0, hi=None):
    """Return the index where to insert item x in list a, assuming a is sorted.
    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(x) will
    insert just after the rightmost x already there.
    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """

    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x > a[mid]: hi = mid
        else: lo = mid+1
    return hi


c = []
for i in range(N):
    n = int(input())
    index = bisect_right_reverse(c,n)
    #print(index)
    if index == len(c):
        c.append(n)
    else:
        c[index] = n
    #print(c)

print(len(c))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
 
c = []
for i in range(N):
    n = int(input())
    index = bisect.bisect_left(c,n)
    #print(index,c)
    if index == 0:
        c.insert(0,n)
    else:
        c[index-1] = n
    #print(c)
 
print(len(c)) 

Fixed submission:
import bisect
N = int(input())

def bisect_right_reverse(a, x, lo=0, hi=None):
    """Return the index where to insert item x in list a, assuming a is sorted.
    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(x) will
    insert just after the rightmost x already there.
    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """

    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x > a[mid]: hi = mid
        else: lo = mid+1
    return hi


c = []
for i in range(N):
    n = int(input())
    index = bisect_right_reverse(c,n)
    #print(index)
    if index == len(c):
        c.append(n)
    else:
        c[index] = n
    #print(c)

print(len(c))

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

c = []
for i in range(N):
    n = int(input())
    index = bisect.bisect_left(c,n)
    if index == 0:
        c.append(n)
    else:
        c[index-1] = n
    c.sort()
    #print(c)

print(len(c))      

Fixed submission:
import bisect
N = int(input())

def bisect_right_reverse(a, x, lo=0, hi=None):
    """Return the index where to insert item x in list a, assuming a is sorted.
    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(x) will
    insert just after the rightmost x already there.
    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """

    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x > a[mid]: hi = mid
        else: lo = mid+1
    return hi


c = []
for i in range(N):
    n = int(input())
    index = bisect_right_reverse(c,n)
    #print(index)
    if index == len(c):
        c.append(n)
    else:
        c[index] = n
    #print(c)

print(len(c))