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

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [-1] * N
    ans = 0
    for _ in range(N):
        n = int(input())
        for i, a in enumerate(A):
            if n > a:
                A[i] = n
                ans = max(ans, i)
                break

    return ans + 1


if __name__ == '__main__':
    print(main())


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

def main():
    input = sys.stdin.readline
    N = int(input())
    a = int(input())
    q = deque()
    q.append(a)
    ans = 1
    for _ in range(N-1):
        n = int(input())
        if n <= q[0]:
            q.appendleft(n)
            ans += 1
            continue

        if n > q[-1]:
            q[-1] = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = q[0]

    return ans


if __name__ == '__main__':
    print(main())

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

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [-1] * N
    ans = 0
    for _ in range(N):
        n = int(input())
        for i, a in enumerate(A):
            if n > a:
                A[i] = n
                ans = max(ans, i)
                break

    return ans + 1


if __name__ == '__main__':
    print(main())


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

def main():
    input = sys.stdin.readline
    N = int(input())
    a = int(input())
    q = deque()
    q.append(a)
    ans = 1
    for _ in range(N-1):
        n = int(input())
        if n <= q[0]:
            q.appendleft(n)
            ans += 1
            continue

        if n > q[-1]:
            q[-1] = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = q[0]

    return ans


if __name__ == '__main__':
    print(main())

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

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [-1] * N
    ans = 0
    for _ in range(N):
        n = int(input())
        for i, a in enumerate(A):
            if n > a:
                A[i] = n
                ans = max(ans, i)
                break

    return ans + 1


if __name__ == '__main__':
    print(main())


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

def main():
    input = sys.stdin.readline
    N = int(input())
    a = int(input())
    q = deque()
    q.append(a)
    ans = 1
    for _ in range(N-1):
        n = int(input())
        if n <= q[0]:
            q.appendleft(n)
            ans += 1
            continue

        if n > q[-1]:
            q[-1] = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = q[0]

    return ans


if __name__ == '__main__':
    print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N = int(input())
    q = deque()
    min_ = 10**9 + 1
    max_ = 0
    cnt = 0
    for _ in range(N):
        n = int(input())
        if n <= min_:
            q.appendleft(n)
            min_ = n
            cnt += 1
            continue

        if n > max_:
            _ = q.pop()
            q.append(n)
            max_ = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = min(q)

    return cnt


if __name__ == '__main__':
    print(main())


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

def main():
    input = sys.stdin.readline
    N = int(input())
    a = int(input())
    q = deque()
    q.append(a)
    ans = 1
    for _ in range(N-1):
        n = int(input())
        if n <= q[0]:
            q.appendleft(n)
            ans += 1
            continue

        if n > q[-1]:
            q[-1] = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = q[0]

    return ans


if __name__ == '__main__':
    print(main())

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

def main():
    input = sys.stdin.readline
    N = int(input())
    A = []
    cnt = 0
    for _ in range(N):
        n = int(input())
        check = True
        for i, a in enumerate(A):
            if n > a:
                A[i] = n
                check = False
                break

        if check:
            A.append(n)
            cnt += 1

    return cnt


if __name__ == '__main__':
    print(main())


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

def main():
    input = sys.stdin.readline
    N = int(input())
    a = int(input())
    q = deque()
    q.append(a)
    ans = 1
    for _ in range(N-1):
        n = int(input())
        if n <= q[0]:
            q.appendleft(n)
            ans += 1
            continue

        if n > q[-1]:
            q[-1] = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = q[0]

    return ans


if __name__ == '__main__':
    print(main())