Buggy python submission (verdict: Time Limit Exceeded):
import sys
from bisect import bisect_right, insort_left
N = int(sys.stdin.readline())
a_list = [int(sys.stdin.readline()) for _ in range(N)]


que = []

ans = 0
min_num = float("inf")
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        min_num = a
        ans += 1
    else:
        # idx = bisect_right(que, a-1)
        if a <= min_num:
        # if idx == 0:
            insort_left(que, a)
            ans += 1
            min_num = a
        else:
            idx = bisect_right(que, a-1)
            que[idx-1] = a
            if idx -1 == 0:
                min_num = a
    #print(que, min_num)
print(ans)


Fixed submission:
import sys
from bisect import bisect_right, insort_left
from collections import deque
N = int(sys.stdin.readline())
a_list = [int(sys.stdin.readline()) for _ in range(N)]


que = []
que = deque(que)

ans = 0
min_num = float("inf")
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        min_num = a
        ans += 1
    else:
        idx = bisect_right(que, a-1)

        if idx == 0:
            que.appendleft(a)
            ans += 1
            min_num = a
        else:
            idx = bisect_right(que, a-1)
            que[idx-1] = a
            if idx -1 == 0:
                min_num = a
    #print(que, min_num)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from bisect import bisect_right, insort_left
N = int(sys.stdin.readline())
a_list = [int(sys.stdin.readline()) for _ in range(N)]


que = []

ans = 0
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        ans += 1
    else:
        idx = bisect_right(que, a-1)
        if idx == 0:
            insort_left(que, a)
            ans += 1
        else:
            que[idx-1] = a

print(ans)


Fixed submission:
import sys
from bisect import bisect_right, insort_left
from collections import deque
N = int(sys.stdin.readline())
a_list = [int(sys.stdin.readline()) for _ in range(N)]


que = []
que = deque(que)

ans = 0
min_num = float("inf")
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        min_num = a
        ans += 1
    else:
        idx = bisect_right(que, a-1)

        if idx == 0:
            que.appendleft(a)
            ans += 1
            min_num = a
        else:
            idx = bisect_right(que, a-1)
            que[idx-1] = a
            if idx -1 == 0:
                min_num = a
    #print(que, min_num)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a_list = [int(input()) for _ in range(N)]

from bisect import *

que = []

ans = 0
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        ans += 1
    else:
        idx = bisect_right(que, a-1)
        if idx == 0:
            insort_left(que, a)
            ans += 1
        else:
            # b = que[idx-1]
            #if a != b:
            que[idx-1] = a
            #idx2 = bisect_right(que, a-1)

print(ans)


Fixed submission:
import sys
from bisect import bisect_right, insort_left
from collections import deque
N = int(sys.stdin.readline())
a_list = [int(sys.stdin.readline()) for _ in range(N)]


que = []
que = deque(que)

ans = 0
min_num = float("inf")
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        min_num = a
        ans += 1
    else:
        idx = bisect_right(que, a-1)

        if idx == 0:
            que.appendleft(a)
            ans += 1
            min_num = a
        else:
            idx = bisect_right(que, a-1)
            que[idx-1] = a
            if idx -1 == 0:
                min_num = a
    #print(que, min_num)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a_list = [int(input()) for _ in range(N)]

from bisect import *

que = []

ans = 0
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        ans += 1
    else:
        idx = bisect_right(que, a-1)
        if idx == 0:
            insort_left(que, a)
            ans += 1
        else:
            # b = que[idx-1]
            #if a != b:
            que[idx-1] = a
            #idx2 = bisect_right(que, a-1)

print(ans)


Fixed submission:
import sys
from bisect import bisect_right, insort_left
from collections import deque
N = int(sys.stdin.readline())
a_list = [int(sys.stdin.readline()) for _ in range(N)]


que = []
que = deque(que)

ans = 0
min_num = float("inf")
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        min_num = a
        ans += 1
    else:
        idx = bisect_right(que, a-1)

        if idx == 0:
            que.appendleft(a)
            ans += 1
            min_num = a
        else:
            idx = bisect_right(que, a-1)
            que[idx-1] = a
            if idx -1 == 0:
                min_num = a
    #print(que, min_num)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a_list = [int(input()) for _ in range(N)]

from heapq import *
from bisect import *

que = []

ans = 0
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        ans += 1
    else:
        idx = bisect_right(que, a-1)
        if idx == 0:
            insort_left(que, a)
            ans += 1
        else:
            b = que[idx-1]
            #if a != b:
            que[idx-1] = a
            #idx2 = bisect_right(que, a-1)

    # print(que, ans)
print(ans)


Fixed submission:
import sys
from bisect import bisect_right, insort_left
from collections import deque
N = int(sys.stdin.readline())
a_list = [int(sys.stdin.readline()) for _ in range(N)]


que = []
que = deque(que)

ans = 0
min_num = float("inf")
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        min_num = a
        ans += 1
    else:
        idx = bisect_right(que, a-1)

        if idx == 0:
            que.appendleft(a)
            ans += 1
            min_num = a
        else:
            idx = bisect_right(que, a-1)
            que[idx-1] = a
            if idx -1 == 0:
                min_num = a
    #print(que, min_num)
print(ans)