ZhenlongDai/ACPR huggingface dataset:
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
n = int(input())
a_ls = []
for i in range(n):
    a_ls.append(-int(input()))
L_ls = [a_ls[0]]
for a in a_ls[1:]:
    if L_ls[-1] <= a:
        L_ls.append(a)
    else:
        L_ls[bisect.bisect_left(L_ls, a)] = a
print(len(L_ls))

Failing test case input:
5
4
1
4
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
a_ls = []
for i in range(n):
    a_ls.append(-int(input()))
L_ls = [a_ls[0]]
for a in a_ls[1:]:
    if L_ls[-1] <= a:
        L_ls.append(a)
    else:
        L_ls[bisect.bisect_right(L_ls, a)] = a
print(len(L_ls))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
n=int(input())
h=[]
for i in range(n):
  a=int(input())
  if len(h)==0:
    h.append(-1*a)
  elif (-1)*a>=h[-1]:
    h.append(-1*a)
  else:
    index=bisect.bisect_left(h,-1*a)
    h[index]=a
print(len(h))

Failing test case input:
5
12
1
4
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
n=int(input())
h=[]
for i in range(n):
  a=int(input())
  if len(h)==0:
    h.append(-1*a)
  elif (-1)*a>=h[-1]:
    h.append(-1*a)
  else:
    index=bisect.bisect_right(h,-1*a)
    h[index]=-1*a
print(len(h))

Problem: p02973
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import bisect
N = int(input())
A = [int(input()) for i in range(N)]


S = []
for i in range(N):
    posi = bisect.bisect_right(S,A[i])
    if posi == 0:
        S.insert(0,A[i])
    else:
        S[posi-1] = A[i]

print(len(S))

Failing test case input:
5
4
1
4
17
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
A = [int(input()) for i in range(N)]


S = []
for i in range(N):
    posi = bisect.bisect_left(S,A[i])
    if posi == 0:
        S.insert(0,A[i])
    else:
        S[posi-1] = A[i]

print(len(S))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
A=[int(input()) for i in range(N)]

import bisect
from collections import deque
D=deque([A[0]])

for a in A[1:]:
    if a<=D[0]:
        D.appendleft(a)
        
    x = bisect.bisect_right(D,a)
    D[x-1]=a

    

print(len(D))

Failing test case input:
5
4
1
4
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N=int(input())
A=[int(input()) for i in range(N)]



import bisect
from collections import deque
D=deque([A[0]])

for a in A[1:]:
    if a<=D[0]:
        D.appendleft(a)

    else:
        x = bisect.bisect_right(D,a-1)
        D[x-1]=a

    

print(len(D))
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from bisect import bisect_left
n=int(input())
A=[int(input()) for _ in range(n)][::-1]

DP=[A[0]]
for i in range(1,n):
    num=A[i]
    if DP[-1]<=num:
        DP.append(num)
    else:
        index=bisect_left(DP,num)
        DP[index]=num
print(len(DP))

Failing test case input:
5
0
0
0
5
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_right
n=int(input())
A=[int(input()) for _ in range(n)][::-1]

DP=[A[0]]
for i in range(1,n):
    num=A[i]
    if DP[-1]<=num:
        DP.append(num)
    else:
        index=bisect_right(DP,num)
        DP[index]=num
print(len(DP))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

a = int(input())
maxVal = [a]

ans = 1
for _ in range(N-1) :
    a = int(input())
    i = 0
    for i in range(len(maxVal)) :
        if a <= maxVal[i] :
            maxVal.append(a)
            ans += 1
            break
    else :
        maxVal[i] = max(maxVal[i] , a)


print(ans)

Failing test case input:
5
0
0
1
2
1

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
A = []

a = int(input())

val = [-a]
length = 1

for _ in range(N - 1) :
    a = int(input())
    a *= -1
    i = 0

    index = bisect.bisect_right(val, a)
    if index >= length :
        val.append(a)
        length += 1
    else :
        val[index] = a

print(length)

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
A = [int(input()) for _ in range(N)]
tmp = [A[0]]
ans = 0
for i in range(1, N):
    index = bisect.bisect_left(tmp, A[i])
    print(A[i], index)
    if index == 0:
        tmp.append(A[i])
        tmp.sort()
    else:
        tmp[index-1] = A[i]

print(len(tmp))


Failing test case input:
5
0
0
-1
0
0

Expected output:
4


Actual output:
0 0
-1 0
0 1
0 0
4


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
A = [-int(input()) for _ in range(N)]
tmp = [A[0]]
for i in A[1:N]:
    index = bisect.bisect(tmp, i)
    if index == len(tmp):
        tmp.append(i)
    else:
        tmp[index] = i

print(len(tmp))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS = [arr[0]]
for i in range(1,n):
  if arr[i] >= LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_left(LIS, arr[i])] = arr[i]
print(len(LIS))

Failing test case input:
5
0
0
0
5
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):

import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS=[arr[0]]
for i in range(1,n):
  if arr[i]>=LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_right(LIS,arr[i])]=arr[i]
print(len(LIS))
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]

b = [a[-1]]
for i in range(n - 2, -1, -1):
    if b[-1] <= a[i]:
        b.append(a[i])
    else:
        b[bisect.bisect_left(b, a[i])] = a[i]

print(len(b))

Failing test case input:
4
0
0
1
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]

b = [a[-1]]
for i in range(n - 2, -1, -1):
    if b[-1] <= a[i]:
        b.append(a[i])
    else:
        b[bisect.bisect_right(b, a[i])] = a[i]

print(len(b))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
from collections import deque
n = int(input())
l = deque([])
l.append(int(input()))
for i in range(n-1):
    a = int(input())
    if l[0] >= a:
        l.appendleft(a)
    else:
        l[bisect.bisect_right(l,a)-1] = a
print(len(l))


Failing test case input:
4
0
-1
0
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
from collections import deque
n = int(input())
l = deque([])
l.append(int(input()))
for i in range(n-1):
    a = int(input())
    if l[0] >= a:
        l.appendleft(a)
    else:
        l[bisect.bisect_left(l,a)-1] = a
print(len(l))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect_left as bl

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

def lis(X: list):
    L = [-X[0]]
    for x in X[1:]:
        if L[-1] <= -x:
            L.append(-x)
        else:
            L[bl(L, -x)] = -x
    return len(L)

print(lis(A))

Failing test case input:
5
0
-1
2
2
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect as bl

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

def lds(X: list):
    L = [-X[0]]
    for x in X[1:]:
        if L[-1] <= -x:
            L.append(-x)
        else:
            L[bl(L, -x)] = -x
    return len(L)

print(lds(A))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


from collections import deque
from bisect import bisect_right, bisect_left
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    d = deque()
    for a in A:
        t = bisect_right(d, a)
        if t == 0:
            d.append(a)
            continue
        if d[t-1] == a:
            t = bisect_left(d, a)
        if t == 0:
            d.append(a)
        else:
            d[t-1] = a
    print(len(d))
if __name__ == '__main__':
    main()


Failing test case input:
5
0
0
-1
7
0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):


from collections import deque
from bisect import bisect_right, bisect_left
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    d = deque()
    for a in A:
        t = bisect_right(d, a)
        if t == 0:
            d.appendleft(a)
            continue
        if d[t-1] == a:
            t = bisect_left(d, a)
        if t == 0:
            d.appendleft(a)
        else:
            d[t-1] = a
    print(len(d))
if __name__ == '__main__':
    main()

Problem: p02973
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from bisect import bisect_right
N = int(input())
A = [int(input()) for i in range(N)]
X = [A[0]]

for i in range(1, N):
    if X[0] >= A[i]:
        X.insert(0, A[i])
    else:
        idx = bisect_right(X, A[i])
        X[idx-1] = A[i]

print(len(X))


Failing test case input:
5
0
-1
0
3
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_left
N = int(input())
A = [int(input()) for i in range(N)]
X = [A[0]]

for i in range(1, N):
    if X[0] >= A[i]:
        X.insert(0, A[i])
    else:
        idx = bisect_left(X, A[i])
        X[idx-1] = A[i]

print(len(X))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from bisect import bisect_left

N = int(input())
A = [int(input()) for _ in range(N)]
A.reverse()

L = [A[0]]
for a in A[1:]:
    if a >= L[-1]:
        L.append(a)
    else:
        L[bisect_left(L, a)] = a

print(len(L))


Failing test case input:
5
7
1
1
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_right

N = int(input())
A = [int(input()) for _ in range(N)]
A.reverse()

L = [A[0]]
for a in A[1:]:
    if a >= L[-1]:
        L.append(a)
    else:
        L[bisect_right(L, a)] = a

print(len(L))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

N = int(input())
L = []
L.append(int(input()))
c = 1

for i in range(N - 1):
	A = -int(input())
	x = bisect.bisect_right(L, A)
	if x == c:
		L.append(A)
		c += 1
	else:
		L[x] = A

print(c)

Failing test case input:
4
1
0
0
0

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
L = []
L.append(-int(input()))
c = 1

for i in range(N - 1):
	A = -int(input())
	x = bisect.bisect_right(L, A)
	if x == c:
		L.append(A)
		c += 1
	else:
		L[x] = A

print(c)
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque
import bisect
n = int(input())
q = deque()

for _ in range(n):
    a = int(input())
    if len(q) == 0:
        q.appendleft(a)
    elif a <= q[0]:
        q.appendleft(a)
    else:
        i = bisect.bisect_right(q, a) - 1
        q[i] = a
print(len(q))

Failing test case input:
5
4
1
4
5
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import deque
import bisect
n = int(input())
q = deque()

for _ in range(n):
    a = int(input())
    if len(q) == 0:
        q.appendleft(a)
    elif a <= q[0]:
        q.appendleft(a)
    else:
        i = bisect.bisect_right(q, a-1) - 1
        q[i] = a
print(len(q))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

n = int(input())
a = sorted([int(input()) for i in range(n)])
LIS = [a[0]]
for i in range(len(a)):
    if a[i] >= LIS[-1]:
        LIS.append(a[i])
    else:
        LIS[bisect.bisect_left(LIS, a[i])] = a[i]
print(len(LIS)-1)

Failing test case input:
5
16
-1
1
2
2

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
import bisect

n = int(input())
a = [int(input()) for i in range(n)][::-1]
LIS = [a[0]]
for i in a[1:]:
    if i >= LIS[-1]:
        LIS.append(i)
    else:
        LIS[bisect.bisect_right(LIS, i)] = i
print(len(LIS))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
words = lambda t : list(map(t, input().split()))
n = int(input())
a = []
for i in range(n):
    x = int(input())
    a.append((x,i))

a.sort()

ans = 1
min_i = a[0][1]

for i in range(1,n):
    if a[i][0] == a[i-1][0]:
        ans+= 1
    elif a[i][1] < min_i:
        ans+= 1
    min_i = min(min_i, a[i][1])

print(ans)


Failing test case input:
5
12
1
4
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

words = lambda t : list(map(t, input().split()))
n = int(input())
a = []
for i in range(n):
    a.append(-1 * int(input()))

b = []
b.append(a[0])

for i in range(1,n):
    x = a[i]
    x_ind = bisect.bisect_right(b,x)
    
    if x_ind >= len(b):
        b.append(x)
    else:
        b[x_ind] = x

print(len(b))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a_ls = []
for i in range(n):
    a_ls.append(int(input()))
L_ls = [a_ls[0]]
for a in a_ls[1:]:
    if L_ls[-1] >= a:
        L_ls.append(a)
print(len(L_ls))

Failing test case input:
5
10
-1
6
13
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
a_ls = []
for i in range(n):
    a_ls.append(-int(input()))
L_ls = [a_ls[0]]
for a in a_ls[1:]:
    if L_ls[-1] <= a:
        L_ls.append(a)
    else:
        L_ls[bisect.bisect_right(L_ls, a)] = a
print(len(L_ls))
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import bisect as bs

n = int(input())
alist = [0]*n
for i in range(n):
    alist[i] = int(input())

col = []
min_ = 1000000000

for a in alist:
    if a <= min_:
        col.insert(0, a)
    else:
        index = bs.bisect(col, a) - 1
        col[index] = a
    min_ = min(col)

print(len(col))



Failing test case input:
5
0
0
1
1
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect as bs
import collections

n = int(input())
alist = [0]*n
for i in range(n):
    alist[i] = int(input())

col = collections.deque()
min_ = 10000000000

for a in alist:
    if a <= min_:
        col.appendleft(a)
    else:
        index = bs.bisect_left(col, a) - 1
        col[index] = a
    min_ = col[0]

print(len(col))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]

LDS = deque()
LDS.append(A[0])

for i in range(1,N):
    if LDS[0] >= A[i]:
        LDS.appendleft(A[i])
    else:
        LDS[bisect.bisect(LDS,A[i])-1] = A[i]

print(len(LDS))


Failing test case input:
5
4
1
4
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]

LDS = deque()
LDS.append(A[0])

for i in range(1,N):
    if LDS[0] >= A[i]:
        LDS.appendleft(A[i])
    else:
        LDS[bisect.bisect_left(LDS,A[i])-1] = A[i]

print(len(LDS))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from collections import deque
from bisect import bisect_right

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

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

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

    return ans


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


Failing test case input:
5
4
1
4
17
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
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())
Problem: p02973
Buggy submission (Python (3.8.2), verdict: Wrong Answer):



from bisect import insort_left, bisect_right

N = int(input())
A = []
for _ in range(N):
    x = int(input())
    idx = bisect_right(A, x)
    if idx == 0:
        A = [x] + A
    else:
        if A[idx-1]==x:
            insort_left(A, x)
        A[idx-1] = x

print(len(A))


Failing test case input:
4
0
0
-1
0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):



from bisect import bisect_left

N = int(input())
A = []
for _ in range(N):
    x = int(input())
    idx = bisect_left(A, x)
    if idx == 0:
        A.insert(idx, x)
    elif A[idx-1] == x:
        A.insert(idx, x)
    else:
        A[idx-1] = x

print(len(A))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
from collections import deque
N = int(input())
A = [int(input()) for i in [0]*N]


ls = deque([A[0]])
for a in A[1:]:
	ind = bisect.bisect(ls,a)
	if ind == 0:
		ls.appendleft(a)
	else:
		ls[ind-1] = a

print(len(ls))






Failing test case input:
4
0
-1
0
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
from collections import deque
N = int(input())
A = [int(input()) for i in [0]*N]


ls = deque([A[0]])
for a in A[1:]:
	ind = bisect.bisect_left(ls,a)
	if ind == 0:
		ls.appendleft(a)
	else:
		ls[ind-1] = a

print(len(ls))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):




import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    al = [int(input()) for _ in range(n)]

    lsbs = deque()
    for a in al:
        pos = bisect.bisect_left(lsbs, a)
        if pos == 0:
            lsbs.appendleft(a)
        else:
            lsbs[min(pos, len(lsbs)-1)] = a
    print(len(lsbs))


if __name__ == '__main__':
    main()


Failing test case input:
5
3
-1
1
2
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):




import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    al = [int(input()) for _ in range(n)]

    lsbs = deque()
    for a in al:
        pos = bisect.bisect_left(lsbs, a)
        if pos == 0:
            lsbs.appendleft(a)
        else:
            if pos == len(lsbs):
                lsbs[-1] = a
            else:
                lsbs[pos-1] = a
        
    print(len(lsbs))


if __name__ == '__main__':
    main()
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
def main():

    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    B = [A[-1]]
    for i in range(N-2, -1, -1):
        if B[-1] <= A[i]:
            B.append(A[i])
        else:
            j = bisect.bisect_left(B, A[i])
            B[j] = A[i]
    return len(B)

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

Failing test case input:
4
0
0
1
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
def main():

    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    B = [A[-1]]
    for i in range(N-2, -1, -1):
        if B[-1] <= A[i]:
            B.append(A[i])
        else:
            j = bisect.bisect_right(B, A[i])
            B[j] = A[i]
    return len(B)

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

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
update_list=[11 for _ in range(n+1)]
for old_element in range(n):
    update_position=bisect(update_list,-a[old_element])
    update_list[update_position]=-a[old_element]

counter=0
for sign in update_list:
    if sign<0:
        counter+=1
print(counter)

Failing test case input:
5
0
0
0
3
0

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
from bisect import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
update_list=[11 for _ in range(n+1)]
for old_element in range(n):
    update_position=bisect(update_list,-a[old_element])
    update_list[update_position]=-a[old_element]

ans=0
while update_list[ans] <= 0:
	ans += 1
print(ans)

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from bisect import bisect_left
n=int(input())
A=[-int(input()) for _ in range(n)]

DP=[A[0]]
for i in range(1,n):
    num=A[i]
    if DP[-1]<=num:
        DP.append(num)
    else:
        index=bisect_left(DP,num)
        DP[index]=num
print(len(DP))

Failing test case input:
5
0
-1
2
2
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_right
n=int(input())
A=[int(input()) for _ in range(n)][::-1]

DP=[A[0]]
for i in range(1,n):
    num=A[i]
    if DP[-1]<=num:
        DP.append(num)
    else:
        index=bisect_right(DP,num)
        DP[index]=num
print(len(DP))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
aa=list(map(int,sys.stdin.read().split()))
aa=aa[1:aa[0]+1]
n=len(aa)
import bisect
bb=[]
for i in range(n):
    if not bb:
        bb.append(aa[-i-1])
    else:
        if bb[-1] <= aa[-i-1]:
            bb.append(aa[-i-1])
        else:
            j = bisect.bisect_left(bb,aa[-i-1])
            bb[j] = aa[-i-1]
print(len(bb))

Failing test case input:
4
0
0
1
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
aa=list(map(int,sys.stdin.read().split()))
aa=aa[1:aa[0]+1]
n=len(aa)
import bisect
bb=[]
for i in range(n):
    if not bb:
        bb.append(aa[-i-1])
    else:
        if bb[-1] <= aa[-i-1]:
            bb.append(aa[-i-1])
        else:
            j = bisect.bisect_right(bb,aa[-i-1])
            bb[j] = aa[-i-1]
print(len(bb))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect as bl

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

def lds(X: list):
    L = [-X[0]]
    for x in X[1:]:
        if L[-1] <= -x:
            L.append(-x)
        else:
            L[bl(L, -x)] = -x
    return L

print(lds(A))

Failing test case input:
5
1
0
0
5
1

Expected output:
3


Actual output:
[-5, -1, 0]


Fixed submission (verdict: Accepted):
from bisect import bisect as bl

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

def lds(X: list):
    L = [-X[0]]
    for x in X[1:]:
        if L[-1] <= -x:
            L.append(-x)
        else:
            L[bl(L, -x)] = -x
    return len(L)

print(lds(A))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
ans = int(0)

N = I()
color = []
a = I()
maxcolor =[]
maxcolor.append(a)
lena = 1
for i in range(N-1):
    minmaxcolor = a
    a = I()
    if a<=minmaxcolor:
        maxcolor.insert(0,a)

        lena += 1
    else:
        acandi = bisect.bisect_left(maxcolor, a)
        maxcolor[acandi-1] = a
        


ans = len(maxcolor)
print(ans)

Failing test case input:
5
0
-1
1
4
0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
from collections import deque
import bisect
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
ans = int(0)

N = I()
color = []
a = I()
maxcolor =deque()
maxcolor.append(a)
lena = 1
for i in range(N-1):
    minmaxcolor = maxcolor[0]
    a = I()
    if a<=minmaxcolor:
        maxcolor.appendleft(a)

        lena += 1
    else:
        acandi = bisect.bisect_left(maxcolor, a)
        maxcolor[acandi-1] = a
        


ans = len(maxcolor)
print(ans)
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N=int(input())
ls=[int(input()) for _ in range(N)]
color=[ls[-1]]
ans=1
for i in range(N-1):
  a=ls[-2-i]
  k=bisect.bisect_left(color,a)
  if k==ans:
    color.append(a)
    ans+=1
  else:
    color[k]=a
print(ans)

Failing test case input:
4
1
0
0
0

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
N=int(input())
ls=[int(input()) for _ in range(N)]
color=[ls[-1]]
ans=1
for i in range(N-1):
  a=ls[-2-i]
  k=bisect.bisect_right(color,a)
  if k==ans:
    color.append(a)
    ans+=1
  else:
    color[k]=a
print(ans)

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
aa=list(map(int,sys.stdin.read().split()))
aa=aa[1:]
n=len(aa)
import bisect
bb=[]
for i in range(n):
    if not bb:
        bb.append(aa[i])
    else:
        if bb[0] >= aa[i]:
            bb = [aa[i]] + bb
        else:
            j = bisect.bisect_right(bb,aa[i])
            bb[j-1] = aa[i]
print(len(bb))

Failing test case input:
4
0
-1
0
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
aa=list(map(int,sys.stdin.read().split()))
aa=aa[1:aa[0]+1]
n=len(aa)
import bisect
bb=[]
for i in range(n):
    if not bb:
        bb.append(aa[-i-1])
    else:
        if bb[-1] <= aa[-i-1]:
            bb.append(aa[-i-1])
        else:
            j = bisect.bisect_right(bb,aa[-i-1])
            bb[j] = aa[-i-1]
print(len(bb))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)
a.reverse()
counter = 0
mxm = 0
for i in range(n):
    if mxm <= a[i]:
        counter += 1
        mxm = a[i]
print(counter)

Failing test case input:
5
4
1
4
17
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)
a.reverse()
b = [a[0]]
counter = 1
for i in range(1,n):
    if a[i] >= b[-1]:
        counter += 1
        b.append(a[i])
    else:
        ind = bisect.bisect_right(b,a[i])
        b[ind] = a[i]
print(counter)

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
As = [int(input()) for _ in range(N)]
from bisect import bisect_left
from collections import deque

def LIS(L):
    dp = deque([L[0]])
    length = len(L)
    for i in range(1, length):
        a = L[i]
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_left(dp, a)] = a
    return dp

print(len(LIS(As[::-1])))

Failing test case input:
5
0
0
1
4
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
As = [int(input()) for _ in range(N)]
from bisect import bisect_right
from collections import deque

def LIS(L):
    dp = deque([L[0]])
    length = len(L)
    for i in range(1, length):
        a = L[i]
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_right(dp, a)] = a
    return dp

print(len(LIS(As[::-1])))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
def input(): return sys.stdin.readline().rstrip()
import bisect
def make_LIS(L):
    LIS=[L[0]]
    for i in range(1,len(L)):
        if L[i]>=LIS[-1]:
            LIS.append(L[i])
        else:
            LIS[bisect.bisect_left(LIS,L[i])]=L[i]
    return len(LIS)
def main():
    n=int(input())
    A=[int(input())for _ in range(n)]
    print(make_LIS(A[::-1]))

if __name__=='__main__':
    main()

Failing test case input:
5
0
0
1
2
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
def input(): return sys.stdin.readline().rstrip()
import bisect
def make_LIS(L):
    LIS=[L[0]]
    for i in range(1,len(L)):
        if L[i]>=LIS[-1]:
            LIS.append(L[i])
        else:
            LIS[bisect.bisect_right(LIS,L[i])]=L[i]
    return len(LIS)
def main():
    n=int(input())
    A=[int(input())for _ in range(n)]
    print(make_LIS(A[::-1]))

if __name__=='__main__':
    main()

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import*
N,*A=map(int,open(0))
L=[A[0]]
for x in A[1:]:
	i=bisect_left(L,x)
	if i==0:L+=x,
	else:L[i-1]=x
print(len(L))

Failing test case input:
4
1
0
-1
0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
from collections import*
from bisect import*
N,*A=map(int,open(0))
q=deque([A[0]])
for x in A[1:]:
	i=bisect_left(q,x)
	if i==0:q.appendleft(x)
	else:q[i-1]=x
print(len(q))
Problem: p02973
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

def main():
    N = I()
    D = [float('inf')]*N
    res = [0]*N
    for i in range(N):
        num = I()
        index = bisect_left(D, num)
        D[index] = num
        res[index]+=1
    print(max(res))




if __name__ == "__main__":
    main()

Failing test case input:
5
16
-1
1
2
2

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

def main():
    N = I()
    D = [float('inf')]*N
    for i in range(N):
        num = -I()
        index = bisect_right(D, num)
        D[index] = num

    res = 0
    for i in D:
        if i != float('inf'):
            res+=1
        else:
            break
    print(res)




if __name__ == "__main__":
    main()

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from bisect import bisect_left
N = int(input())
A = list(int(input()) for _ in range(N))
INF = 10 ** 9 + 1

dp = [INF]
for i, a in enumerate(A):
    if -a >= dp[-1]:
        dp.append(-a)
    else:
        j = bisect_left(dp, -a)
        dp[j] = -a

print(len(dp))


Failing test case input:
5
4
1
4
5
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_right
N = int(input())
A = list(int(input()) for _ in range(N))
INF = 10 ** 9 + 1

dp = [INF]
for a in A:
    if -a >= dp[-1]:
        dp.append(-a)
    else:
        j = bisect_right(dp, -a)
        dp[j] = -a

print(len(dp))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r:
        ans+=1
    elif l == 0:
        lis.appendleft(a)
    else:
        lis[l-1] = a
print(len(lis)+ans)

Failing test case input:
5
0
-1
0
3
1

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r :
        if l > 0:
            lis[l-1]=a
        elif r ==  len(lis):
            lis.append(a)
        else:
            lis.appendleft(a)
    elif l == 0:
        lis.appendleft(a)
    else:
        lis[r-1] = a
print(len(lis))

Problem: p02973
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from bisect import bisect_left
n = int(input())
a = [int(input())*-1 for i in range(n)]

LIS = [a[0]]
for v in a[1:]:

    if LIS[-1] <= v:
        LIS.append(v)
    else:
        LIS[bisect_left(LIS, v)] = v
 
print(len(LIS))

Failing test case input:
5
0
-1
0
3
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
seq = [int(input()) for _ in range(N)]
from collections import deque
import bisect
LIS = deque([seq[0]])
for i in range(1,len(seq)):
    if seq[i] <= LIS[0]:
        LIS.appendleft(seq[i])
    else:
        LIS[bisect.bisect_left(LIS, seq[i])-1] = seq[i]

print(len(LIS))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
A = [int(input()) for i in [0]*N]


ls = [A[0]]
for a in A[1:]:
	ind = bisect.bisect(ls,a)
	if ind == 0:
		ls.insert(0,a)
	else:
		ls[ind-1] = a

print(len(ls))






Failing test case input:
5
0
0
0
8
0

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
from collections import deque
N = int(input())
A = [int(input()) for i in [0]*N]


ls = deque([A[0]])
for a in A[1:]:
	ind = bisect.bisect_left(ls,a)
	if ind == 0:
		ls.appendleft(a)
	else:
		ls[ind-1] = a

print(len(ls))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import bisect
N = int(input())
A = [int(input()) for i in range(N)]

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

Failing test case input:
4
-1
0
-1
0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):

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))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpln(n)
res = 0
m = 0
for i,j in enumerate(a):
    if i == 0:
        m = j
        res += 1
        continue
    if j <= m:
        res += 1
        m = j
print(res)

        

Failing test case input:
5
12
1
4
9
6

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpln(n)
q = deque([])

for i,j in enumerate(a):
  if i == 0:
    q.append(j)
    continue
  c = bisect.bisect_left(q,j)
  if c == 0:
    q.appendleft(j)
  else:
    q[c-1] = j
    
print(len(q))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def lis(A: "Array[int]") -> int:
    from bisect import bisect_left

    
    dp = [A[0]]
    for i in A[1:]:
        if i >= dp[-1]:
            dp.append(i)
        else:
            dp[bisect_left(dp, i)] = i
    return len(dp)


def main():
    N, *A = map(int, open(0))
    ans = lis(A[::-1])
    print(ans)


if __name__ == "__main__":
    main()

Failing test case input:
5
0
0
0
3
0

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):

def lis(A: "Array[int]") -> int:
    from bisect import bisect_right

    
    dp = [A[0]]
    for i in A[1:]:
        if i >= dp[-1]:
            dp.append(i)
        else:
            dp[bisect_right(dp, i)] = i
    return len(dp)


def main():
    N, *A = map(int, open(0))
    ans = lis(A[::-1])  
    print(ans)


if __name__ == "__main__":
    main()

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

maxims = [A[0]]
ans = 1
minim = A[0]
for a in A[1:]:
    if a > minim:
        midx = bisect.bisect_left(maxims,a)-1
        m = maxims[midx]
        if m == minim:
            minim = a
        maxims[midx] = a

    else:
        maxims.insert(0,a)
        ans += 1
        minim = a
print(ans)
    
    
    

Failing test case input:
5
2
2
4
5
3

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect
import sys
input = sys.stdin.readline

N = int(input())
A = [-1*int(input()) for _ in range(N)]

maxims = [A[0]]
ans = 1
for a in A[1:]:
    if maxims[-1] > a:
        idx = bisect.bisect(maxims,a)
        maxims[idx] = a
    else:
        maxims.append(a)
        ans += 1
    
print(ans)

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r:
        lis.append(a)
        lis = deque(sorted(list(lis)))
    elif l == 0:
        lis.appendleft(a)
    else:
        lis[r-1] = a
print(len(lis))

Failing test case input:
4
0
-1
0
0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r :
        if l > 0:
            lis[l-1]=a
        elif r ==  len(lis):
            lis.append(a)
        else:
            lis.appendleft(a)
    elif l == 0:
        lis.appendleft(a)
    else:
        lis[r-1] = a
print(len(lis))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():

    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    count = 0
    min_v = float('inf')
    for i in range(N):
        if A[i] <= min_v:
            count += 1
            min_v = A[i]
    return count


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

Failing test case input:
5
16
-1
1
2
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
def main():

    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    B = [A[-1]]
    for i in range(N-2, -1, -1):
        if B[-1] <= A[i]:
            B.append(A[i])
        else:
            j = bisect.bisect_right(B, A[i])
            B[j] = A[i]
    return len(B)

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

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from bisect import bisect_left, insort_left
n = int(input())
a = []
b = []
cnt = 0
for i in range(n):
  t = int(input())
  a.append(t)
for i in range(n-1, -1, -1):
  
  t = bisect_left(b, a[i])
  if len(b)-1<t or b[t]==a[i]:
    insort_left(b, a[i])
  else:
    b[t] = a[i]
  
print(len(b))

Failing test case input:
4
-1
0
-1
0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import sys
from bisect import bisect_right, insort

def I(): return int(sys.stdin.readline())

def main():
  n = I()
  a = [I() for i in range(n)]
  b = []

  for i in range(n-1, -1, -1):
    t = bisect_right(b, a[i])
    if len(b)-1<t or b[t]==a[i]:
      insort(b, a[i])
    else:
      b[t] = a[i]
  print(len(b))

if __name__ == '__main__':
  main()

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

n = int(input())
nums = [int(input()) for _ in range(n)]

colors = []
for num in nums:
	idx = bisect.bisect_left(colors, num)
	if idx == 0:
		colors.insert(0, num)
	else:
		idx_r = bisect.bisect_right(colors, num) - 1
		colors[idx_r] = num

print(len(colors))



Failing test case input:
4
0
-1
0
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

n = int(input())
nums = [-int(input()) for _ in range(n)]

colors = []
max_val = -1 * (10 ** 10)
for num in nums:
	if num >= max_val:
		colors.append(num)
		max_val = num
	else:
		idx_r = bisect.bisect_right(colors, num)
		colors[idx_r] = num
		max_val = min(colors[-1], max_val)

print(len(colors))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

N = int(input())
LIS = [-1 * int(input())]
for _ in range(N-1):
    A = -1 * int(input())
    if A >= LIS[-1]:
        LIS.append(A)
    else:
        LIS[bisect.bisect_left(LIS, A)] = A

print(len(LIS))

Failing test case input:
5
0
0
1
1
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
LIS = [-1 * int(input())]
for _ in range(N-1):
    A = -1 * int(input())
    if A >= LIS[-1]:
        LIS.append(A)
    else:
        LIS[bisect.bisect_right(LIS, A)] = A

print(len(LIS))
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from heapq import heappop,heappush 
n=int(input())
a=[int(input()) for _ in range(n)]
num=[-a[0]]
count=1
lst=[a[0]]
for i in range(1,n):
    b=-num[0]
    if a[i]>b:
        heappush(num,-a[i])
    else:
        c=heappop(lst)
        if a[i]>c:
            heappush(lst,a[i])
        else:
            heappush(lst,c)
            heappush(lst,a[i])
            count+=1
print(count)

Failing test case input:
5
0
1
1
2
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):

inf=float("inf")
from heapq import heappop,heappush 
n=int(input())
a=[int(input()) for _ in range(n)]
dp=[-1]*(n)
dp[0]=a[0]
for i in range(1,n):
    m=0
    M=n-1
    while M-m>1:
        if dp[(M+m)
            M=(M+m)
        else:
            m=(M+m)
    if dp[m]>=a[i]:
        dp[M]=a[i]
    else:
        dp[m]=a[i]
count=0
for i in range(n):
    if dp[i]!=-1:
        count+=1
    else:
        break
print(count)

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpln(n)[::-1]
res = 0
x = []
heapify(x)
for i,j in enumerate(a):
    if i == 0:
        heappush(x,-j)
        res += 1
        continue
    m = -heappop(x)
    if j > m:
        res += 1
        heappush(x,-j)
        heappush(x,-m)
    else:
        heappush(x,-j)
    
print(res)


Failing test case input:
5
0
0
1
2
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpln(n)
q = deque([])

for i,j in enumerate(a):
  if i == 0:
    q.append(j)
    continue
  c = bisect.bisect_left(q,j)
  if c == 0:
    q.appendleft(j)
  else:
    q[c-1] = j
    
print(len(q))
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdin, setrecursionlimit
from collections import defaultdict


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    min = float('inf')
    dic = defaultdict(int)
    for ai in a:
        dic[ai] += 1
        if ai <= min:
            ans += 1
            min = ai
        elif dic[ai] > ans:
            ans += 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Failing test case input:
5
12
-1
7
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from sys import stdin, setrecursionlimit
from collections import deque
from bisect import bisect_left


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = deque()
    for ai in a:
        idx = bisect_left(ans, ai)
        if idx == 0:
            ans.appendleft(ai)
        else:
            ans[idx - 1] = ai

    print(len(ans))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
a = [int(input()) for _ in range(n)]

s = deque([a[0]])

from bisect import bisect_right

for i in a[1:]:
    if i <= s[0]:
        s.appendleft(i)
    else:
        s[bisect_right(s, i) - 1] = i


print(len(s))


Failing test case input:
5
0
-1
0
3
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
a = [int(input()) for _ in range(n)]

s = deque([a[0]])

from bisect import bisect_left

for i in a[1:]:
    if i <= s[0]:
        s.appendleft(i)
    else:
        s[bisect_left(s, i) - 1] = i


print(len(s))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdin, setrecursionlimit
from collections import defaultdict


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    dic = defaultdict(int)
    for ai in a:
        for i in range(n):
            if dic[i] < ai:
                dic[i] = ai
                break

    print(len(dic))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Failing test case input:
5
10
-1
1
13
2

Expected output:
2


Actual output:
5


Fixed submission (verdict: Accepted):
from sys import stdin, setrecursionlimit
from collections import deque
from bisect import bisect_left


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = deque()
    for ai in a:
        idx = bisect_left(ans, ai)
        if idx == 0:
            ans.appendleft(ai)
        else:
            ans[idx - 1] = ai

    print(len(ans))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()