Buggy python submission (verdict: Time Limit Exceeded):
#E問題
from bisect import bisect_left

N = int(input())
A = [int(input()) for i in range(N)]
B = [0]
for i in range(N):
    if i == 0:
        B[0]=A[i]
    else:
        if B[0] >= A[i]:
            B.insert(0,A[i])
        else:
            index = bisect_left(B,A[i])-1
            B[index] = A[i]
b=len(B)
print(b)

Fixed submission:
#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))

Buggy python submission (verdict: Time Limit Exceeded):
#E問題
from bisect import bisect_left

N = int(input())
A = [int(input()) for i in range(N)]
B = [0]
for i in range(N):
    if i == 0:
        B[0]=A[i]
    else:
        if B[0] >= A[i]:
            B.insert(0,A[i])
        else:
            index = bisect_left(B,A[i])-1
            B[index] = A[i]
b=len(B)
print(b)

Fixed submission:
#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))

Buggy python submission (verdict: Time Limit Exceeded):
#E問題
import bisect

N = int(input())
A = [int(input()) for i in range(N)]
B = [0]
for i in range(N):
    if i == 0:
        B[0]=A[i]
    else:
        if B[0] >= A[i]:
            B.insert(0,A[i])
        else:
            index = bisect.bisect_left(B,A[i])-1
            B[index] = A[i]
b=len(B)
print(b)

Fixed submission:
#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))

Buggy python submission (verdict: Time Limit Exceeded):
#E問題
import bisect

N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
    if i == 0:
        B.append(A[i])
    else:
        if B[0] >= A[i]:
            B.insert(0,A[i])
        else:
            index = bisect.bisect_left(B,A[i])-1
            B[index] = A[i]
b=len(B)
print(b)

Fixed submission:
#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))

Buggy python submission (verdict: Time Limit Exceeded):
#E問題
import bisect

N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
    if len(B) == 0:
        B.append(A[i])
    else:
        if B[0] >= A[i]:
            B.insert(0,A[i])
        else:
            index = bisect.bisect_left(B,A[i])-1
            B[index] = A[i]
print(len(B))

Fixed submission:
#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))

Buggy python submission (verdict: Time Limit Exceeded):
#E問題
import bisect

N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
    if len(B) == 0:
        B.append(A[i])
    else:
        if B[0] >= A[i]:
            B.insert(0,A[i])
        else:
            index = bisect.bisect_left(B,A[i])-1
            B[index] = A[i]
print(len(B))

Fixed submission:
#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))

Buggy python submission (verdict: Time Limit Exceeded):
#E問題
import bisect

N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
    if len(B) == 0:
        B.append(A[i])
    else:
        if B[0] >= A[i]:
            B.append(A[i])
        else:
            index = bisect.bisect_left(B,A[i])-1
            B[index] = A[i]
    B.sort()
print(len(B))

Fixed submission:
#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))

Buggy python submission (verdict: Time Limit Exceeded):
#E問題
N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
    if len(B) == 0:
        B.append(A[i])
    else:
        if B[0] >= A[i]:
            B.append(A[i])
        else:
            for j in range(len(B)):
                if B[j] >= A[i]:
                    B[j-1] = A[i]
                    break
    B.sort()
print(len(B))

Fixed submission:
#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))