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


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    array = []
    for A in As:
        idx = bisect.bisect_left(array, A)
        if idx == 0:
            array = [A] + array
        else:
            array[idx - 1] = A
    print(len(array))


if __name__ == "__main__":
    main()


Fixed submission:
import bisect
from collections import deque
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    dq = deque([])
    for A in As:
        idx = bisect.bisect_left(dq, A)
        if idx == 0:
            dq.appendleft(A)
        else:
            dq[idx - 1] = A
    print(len(dq))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from sys import stdin


def increment_left(li, As):
    while True:
        if As[li] < As[li + 1]:
            li += 1
            continue
        break
    return li


def decrement_right(ri, As):
    while True:
        if As[ri] > As[ri - 1]:
            ri -= 1
            continue
        break
    return ri


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    result = 0
    li = 0
    ri = N - 1
    while True:
        li = increment_left(li, As)
        ri = decrement_right(ri, As)
        if ri <= li:
            result += 1
            break
        if As[li] < As[ri]:
            result += 1
        else:
            result += 2
        li += 1
        ri -= 1
        if ri == li:
            result += 1
            break
        elif ri < li:
            break
    print(result)


if __name__ == "__main__":
    main()


Fixed submission:
import bisect
from collections import deque
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    dq = deque([])
    for A in As:
        idx = bisect.bisect_left(dq, A)
        if idx == 0:
            dq.appendleft(A)
        else:
            dq[idx - 1] = A
    print(len(dq))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from sys import stdin


def increment_left(li, As):
    while True:
        if As[li] < As[li + 1]:
            li += 1
            continue
        break
    return li


def decrement_right(ri, As):
    while True:
        if As[ri] > As[ri - 1]:
            ri -= 1
            continue
        break
    return ri


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    result = 0
    li = 0
    ri = N - 1
    while True:
        li = increment_left(li, As)
        ri = decrement_right(ri, As)
        if ri <= li:
            result += 1
            break
        if As[li] < As[ri]:
            result += 1
        else:
            result += 2
        li += 1
        ri -= 1
        if ri <= li:
            break
    print(result)


if __name__ == "__main__":
    main()


Fixed submission:
import bisect
from collections import deque
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    dq = deque([])
    for A in As:
        idx = bisect.bisect_left(dq, A)
        if idx == 0:
            dq.appendleft(A)
        else:
            dq[idx - 1] = A
    print(len(dq))


if __name__ == "__main__":
    main()