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

input=sys.stdin.readline

def f(n):
    r = []
    for _ in range(n):
        a = int(input())
        if not r:
            r.append(a)
            continue
        i = bisect_left(r, a)
        if i:
            r[i-1]=a
        else:
            r = [a] + r
    print(len(r))

n = int(input())
f(n)


Fixed submission:
import sys
from bisect import *

input=sys.stdin.readline

def f(n):
    mi=-1
    r = [inf]*n
    for _ in range(n):
        a = -int(input())
        i = bisect_right(r, a)
        r[i]=a
        if i>mi:
            mi=i
    print(mi+1)

n = int(input())
inf=10**10
f(n)

Buggy python submission (verdict: Runtime Error):
from bisect import *

def f(n):
    r = []
    for _ in range(n):
        a = int(input())
        if not r:
            r.append(a)
            continue
        i = bisect_left(r, a)
        if i:
            r[i]=a
        else:
            r = [a] + r
    print(len(r))

n = int(input())
f(n)


Fixed submission:
import sys
from bisect import *

input=sys.stdin.readline

def f(n):
    mi=-1
    r = [inf]*n
    for _ in range(n):
        a = -int(input())
        i = bisect_right(r, a)
        r[i]=a
        if i>mi:
            mi=i
    print(mi+1)

n = int(input())
inf=10**10
f(n)

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

def f(n):
    r = []
    for _ in range(n):
        a = int(input())
        if not r:
            r.append(a)
            continue
        i = bisect_left(r, a)
        if i:
            r.insert(i, a)
            del r[i - 1]
        else:
            r = [a] + r
    print(len(r))

n = int(input())
f(n)


Fixed submission:
import sys
from bisect import *

input=sys.stdin.readline

def f(n):
    mi=-1
    r = [inf]*n
    for _ in range(n):
        a = -int(input())
        i = bisect_right(r, a)
        r[i]=a
        if i>mi:
            mi=i
    print(mi+1)

n = int(input())
inf=10**10
f(n)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for _ in range(n)]
cnt=0
ans=0
used=[False]*n
while cnt<n:
    ans+=1
    mx = -1
    for i in range(n):
        if used[i]:continue
        if a[i]>mx:
            used[i]=True
            mx=a[i]
            cnt+=1
print(ans)

Fixed submission:
import sys
from bisect import *

input=sys.stdin.readline

def f(n):
    mi=-1
    r = [inf]*n
    for _ in range(n):
        a = -int(input())
        i = bisect_right(r, a)
        r[i]=a
        if i>mi:
            mi=i
    print(mi+1)

n = int(input())
inf=10**10
f(n)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import *
n=int(input())
r=[]
for _ in range(n):
    a=int(input())
    if not r:
        r.append(a)
        continue
    i=bisect_left(r,a)
    if i:
        r.insert(i,a)
        del r[i-1]
    else:
        r=[a]+r
print(len(r))

Fixed submission:
import sys
from bisect import *

input=sys.stdin.readline

def f(n):
    mi=-1
    r = [inf]*n
    for _ in range(n):
        a = -int(input())
        i = bisect_right(r, a)
        r[i]=a
        if i>mi:
            mi=i
    print(mi+1)

n = int(input())
inf=10**10
f(n)