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


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    L = [A[0]]
    for a in A[1:]:
        if a <= L[-1]:
            L.append(a)
        else:
            i = bisect(L, a)
            L[i] = a
    print(len(L))

    

if __name__ == "__main__":
    main()


Fixed submission:
from bisect import bisect


def main():
    N = int(input())
    A = [-int(input()) for _ in range(N)]
    L = [A[0]]
    for a in A[1:]:
        if a >= L[-1]:
            L.append(a)
        else:
            L[bisect(L, a)] = a
    print(len(L))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import math




def search3(S):
    harf = int(len(A)/3)
    for i, a in enumerate(A[harf:]):
        if a < S:
            A[i] = S
            return 
    return

def search2(S):
    harf = int(len(A)/2)
    for i, a in enumerate(A[harf:]):
        if a < S:
            A[i] = S
            return 
    return

def search(S):
    for i, a in enumerate(A):
        if a < S:
            A[i] = S
            return 
    return



def main():
    N = int(input())
    A[0] = int(input())
    m = A[0]
    harf = 0
    for _ in range(N-1):
        S = int(input())
        if S <= m:
            A.append(S)
        elif S <= th:
            search3(S)
        elif S <= harf:
            search2(S)
        else:
            search(S)
        m = A[-1]
        harf = A[int(len(A)/2)]
        th = A[int(len(A)/3)]
    print(len(A))

    

if __name__ == "__main__":
    A = [0]
    main()


Fixed submission:
from bisect import bisect


def main():
    N = int(input())
    A = [-int(input()) for _ in range(N)]
    L = [A[0]]
    for a in A[1:]:
        if a >= L[-1]:
            L.append(a)
        else:
            L[bisect(L, a)] = a
    print(len(L))


if __name__ == "__main__":
    main()

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



def search2(S):
    harf = int(len(A)/2)
    for i, a in enumerate(A[harf:]):
        if a < S:
            A[i] = S
            return 
    return

def search(S):

    for i, a in enumerate(A):
        if a < S:
            A[i] = S
            return 
    return



def main():
    N = int(input())
    A[0] = int(input())
    m = A[0]
    harf = 0
    for _ in range(N-1):
        S = int(input())
        if S <= m:
            A.append(S)
        if S <= m:
            search2(S)
        else:
            search(S)
        m = A[-1]
        harf = A[int(len(A)/2)]
    print(len(A))

    

if __name__ == "__main__":
    A = [0]
    main()


Fixed submission:
from bisect import bisect


def main():
    N = int(input())
    A = [-int(input()) for _ in range(N)]
    L = [A[0]]
    for a in A[1:]:
        if a >= L[-1]:
            L.append(a)
        else:
            L[bisect(L, a)] = a
    print(len(L))


if __name__ == "__main__":
    main()

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

def search(S):

    for i, a in enumerate(A):
        if a < S:
            A[i] = S
            return 
    return



def main():
    N = int(input())
    A[0] = int(input())
    m = A[0]
    for _ in range(N-1):
        S = int(input())
        if S <= m:
            A.append(S)
        else:
            search(S)
        m = A[-1]
    print(len(A))

    

if __name__ == "__main__":
    A = [0]
    main()


Fixed submission:
from bisect import bisect


def main():
    N = int(input())
    A = [-int(input()) for _ in range(N)]
    L = [A[0]]
    for a in A[1:]:
        if a >= L[-1]:
            L.append(a)
        else:
            L[bisect(L, a)] = a
    print(len(L))


if __name__ == "__main__":
    main()

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

def search(S):

    for i, a in enumerate(A):
        if a < S:
            A[i] = S
            return 
    A.append(S)
    return



def main():
    N = int(input())
    A[0] = int(input())
    le = 1
    m = A[0]
    m_i = 1
    for _ in range(N-1):
        S = int(input())
        search(S)
    print(len(A))

    

if __name__ == "__main__":
    A = [0]
    main()


Fixed submission:
from bisect import bisect


def main():
    N = int(input())
    A = [-int(input()) for _ in range(N)]
    L = [A[0]]
    for a in A[1:]:
        if a >= L[-1]:
            L.append(a)
        else:
            L[bisect(L, a)] = a
    print(len(L))


if __name__ == "__main__":
    main()

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

def search(A, S):

    for i, a in enumerate(A):
        if a < S:
            A[i] = S
            return A
    A.append(S)
    return A



def main():
    N = int(input())
    A = [int(input())]
    le = 1
    for _ in range(N-1):
        S = int(input())
        A = search(A, S)
    print(len(A))

    

if __name__ == "__main__":
    main()


Fixed submission:
from bisect import bisect


def main():
    N = int(input())
    A = [-int(input()) for _ in range(N)]
    L = [A[0]]
    for a in A[1:]:
        if a >= L[-1]:
            L.append(a)
        else:
            L[bisect(L, a)] = a
    print(len(L))


if __name__ == "__main__":
    main()