ZhenlongDai/ACPR huggingface dataset:
Problem: p02606
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
L,R,d = map(int, input().strip().split())
x=math.ceil(L/d)
y=math.floor(R/d)
print(y-x)

Failing test case input:
9 62 1

Expected output:
54


Actual output:
53


Fixed submission (verdict: Accepted):
import math
L,R,d = map(int, input().strip().split())
x=math.ceil(L/d)
y=math.floor(R/d)
print(y-x+1)

Problem: p02606
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

L, R, d = input_int()

mins = L
maxs = R

print(maxs-mins)

Failing test case input:
11 76 2

Expected output:
33


Actual output:
65


Fixed submission (verdict: Accepted):
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

L, R, d = input_int()

count=0
for i in range(L,R+1):
    if i%d==0:
        count+=1

print(count)

Problem: p02606
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
l, r, d = map(int,input().split())
ans = l 
print(ans)

Failing test case input:
2 98 4

Expected output:
24


Actual output:
2


Fixed submission (verdict: Accepted):
l, r, d = map(int,input().split())
print(r

Problem: p02606
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
input = input()
print(input)
L, R, d = [int(n) for n in input.split()]
count = 0
for n in range(L, R+1):
    if n % d == 0:
        count += 1

print(count)

Failing test case input:
1 116 1

Expected output:
116


Actual output:
1 116 1
116


Fixed submission (verdict: Accepted):
input = input()
L, R, d = [int(n) for n in input.split()]
count = 0
for n in range(L, R+1):
    if n % d == 0:
        count += 1

print(count)
Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    H, W = map(int, input().split())
    if H + W == 0:
        break
    for i in range(H):
        print("*" * W)

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

Expected output:
####

######
######
######
######
######




Actual output:
****
******
******
******
******
******


Fixed submission (verdict: Accepted):
while True:
    H, W = map(int, input().split())
    if H + W == 0:
        break
    for i in range(H):
        print("
    print()

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
while True:
 h,w=map(int,input().split())
 if h==0:break
 for _ in range(h):
  print("".join(['*']*w))
 print('')

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

Expected output:


######






Actual output:


******






Fixed submission (verdict: Accepted):
while True:
 h,w=map(int,input().split())
 if h==0:break
 for _ in range(h):
  print("".join(['
 print('')

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
first = True
while(True):
    H, W = map(int, input().split())
    if(H == W == 0):
        break
    if(first == False):
        print()
    first = False
    for i in range(H):
        print("*" * W)

Failing test case input:
6 6
5 4
2 3
0 0

Expected output:
######
######
######
######
######
######

####
####
####
####
####

###
###



Actual output:
******
******
******
******
******
******

****
****
****
****
****

***
***


Fixed submission (verdict: Accepted):
while(True):
    H, W = map(int, input().split())
    if(H == W == 0):
        break
    first = False
    for i in range(H):
        print("
    print()

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
array = []
while True:
    n = input()
    if n == "0 0":
        break
    array.append(n.split())
for i in range(len(array)):
    for i2 in range(int(array[i][0])):
        for i3 in range(int(array[i][1])):
            if i3 == int(array[i][1])-1:
                print("???")
            else:
                print("???",end="")
    if i != len(array)-1:
        print("")

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

Expected output:
####
####
####
####
####
####

#########
#########
#########
#########
#########
#########




Actual output:
????????????
????????????
????????????
????????????
????????????
????????????

???????????????????????????
???????????????????????????
???????????????????????????
???????????????????????????
???????????????????????????
???????????????????????????



Fixed submission (verdict: Accepted):
array = []
while True:
    n = input()
    if n == "0 0":
        break
    array.append(n.split())
for i in range(len(array)):
    for i2 in range(int(array[i][0])):
        for i3 in range(int(array[i][1])):
            if i3 == int(array[i][1])-1:
                print("
            else:
                print("
    print("")
Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                bar += "*"
            if i < H - 1: print(bar)
            else: print(bar + '\n')

if __name__ == "__main__":
    main()


Failing test case input:
10 6
5 6
2 1
0 0

Expected output:
######
######
######
######
######
######
######
######
######
######

######
######
######
######
######

#
#



Actual output:
******
******
******
******
******
******
******
******
******
******

******
******
******
******
******

*
*



Fixed submission (verdict: Accepted):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
 
def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                bar += "
            if i < H - 1: print(bar)
            else: print(bar + '\n')
 
if __name__ == "__main__":
    main()

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                bar += "*"
            print(bar)

if __name__ == "__main__":
    main()


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

Expected output:
####
####
####
####
####
####
####
####
####
####

######
######
######
######
######




Actual output:
****
****
****
****
****
****
****
****
****
****
******
******
******
******
******


Fixed submission (verdict: Accepted):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
 
def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                bar += "
            if i < H - 1: print(bar)
            else: print(bar + '\n')
 
if __name__ == "__main__":
    main()
Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for i in range(W):
                bar += "*"
            print(bar)

if __name__ == "__main__":
    main()



Failing test case input:
3 4
15 6
2 4
0 0

Expected output:
####
####
####

######
######
######
######
######
######
######
######
######
######
######
######
######
######
######

####
####



Actual output:
****
****
****
******
******
******
******
******
******
******
******
******
******
******
******
******
******
******
****
****


Fixed submission (verdict: Accepted):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
 
def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                bar += "
            if i < H - 1: print(bar)
            else: print(bar + '\n')
 
if __name__ == "__main__":
    main()

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
while True:
 h,w=map(int,input().split())
 if h==0:break
 for _ in range(h):
  print("".join(['*']*w))
 print()

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

Expected output:
##
##

######
######
######
######
######

#
#
#



Actual output:
**
**

******
******
******
******
******

*
*
*



Fixed submission (verdict: Accepted):
while True:
 h,w=map(int,input().split())
 if h==0:break
 for _ in range(h):
  print("".join(['
 print('')

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    H, W = map(int, input().split())
    if H + W == 0:
        break
    for i in range(H):
        print("*" * W)
    print()

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

Expected output:







######
######




Actual output:







******
******



Fixed submission (verdict: Accepted):
while True:
    H, W = map(int, input().split())
    if H + W == 0:
        break
    for i in range(H):
        print("
    print()

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
while True:
  ( H, W) = [ int(i) for i in input().split() ]
  if H == W == 0: break
  
  print()

Failing test case input:
3 4
9 6
2 1
0 0

Expected output:
####
####
####

######
######
######
######
######
######
######
######
######

#
#



Actual output:

Fixed submission (verdict: Accepted):
while True:
  ( H, W) = [ int(i) for i in input().split() ]
  if H == W == 0: break
  for h in range(H): print( '
  print()
Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    H, W =[int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            print('w', end='')
        
        print()

    print()

Failing test case input:
6 4
5 4
2 3
0 0

Expected output:
####
####
####
####
####
####

####
####
####
####
####

###
###



Actual output:
wwww
wwww
wwww
wwww
wwww
wwww

wwww
wwww
wwww
wwww
wwww

www
www



Fixed submission (verdict: Accepted):
while True:
    H, W =[int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            print('
        
        print()

    print()

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for i in range(W):
                bar += "*"
            print(bar)
        print('\n')

if __name__ == "__main__":
    main()


Failing test case input:
4 4
5 6
2 0
0 0

Expected output:
####
####
####
####

######
######
######
######
######






Actual output:
****
****
****
****


******
******
******
******
******








Fixed submission (verdict: Accepted):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
 
def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                bar += "
            if i < H - 1: print(bar)
            else: print(bar + '\n')
 
if __name__ == "__main__":
    main()

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    i = list(map(int, input().split()))
    if i[0] == 0 and i[1] == 0:
        break
    else:
        for j in range(i[0]):
            for k in range(i[1]):
                print("＃", end='')
            print("\n", end='')


Failing test case input:
4 4
5 6
2 1
0 0

Expected output:
####
####
####
####

######
######
######
######
######

#
#



Actual output:
＃＃＃＃
＃＃＃＃
＃＃＃＃
＃＃＃＃
＃＃＃＃＃＃
＃＃＃＃＃＃
＃＃＃＃＃＃
＃＃＃＃＃＃
＃＃＃＃＃＃
＃
＃


Fixed submission (verdict: Accepted):
while True:
    i = list(map(int, input().split()))
    if i[0] == 0 and i[1] == 0:
        break
    else:
        for j in range(i[0]):
            for k in range(i[1]):
                print("
            print("\n", end='')
        print("\n", end='')
Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
import sys

while True:
    
    ins = input().split()
    h = int(ins[0])
    w = int(ins[1])

    if h == 0 and w == 0:
        break
        
    for i in range(h):
        for j in range(w-1):
            sys.stdout.write("*")
        print("*")

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

Expected output:
####
####
####
####
####







##
##



Actual output:
****
****
****
****
****
*
*
*
*
*
**
**


Fixed submission (verdict: Accepted):
import sys

while True:
    
    ins = input().split()
    h = int(ins[0])
    w = int(ins[1])

    if h == 0 and w == 0:
        break
        
    for i in range(h):
        for j in range(w-1):
            sys.stdout.write("
        print("
        
    print("")

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for i in range(W):
                bar += "*"
            print(bar + '\n')
        print('\n\n')        

if __name__ == "__main__":
    main()


Failing test case input:
3 4
5 6
2 2
0 0

Expected output:
####
####
####

######
######
######
######
######

##
##

Actual output:
****

****

****




******

******

******

******

******




**

**






Fixed submission (verdict: Accepted):
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
 
def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                bar += "
            if i < H - 1: print(bar)
            else: print(bar + '\n')
 
if __name__ == "__main__":
    main()

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
while True:
  ( H, W) = [ int(i) for i in input().split() ]
  if H == W == 0: break
  

Failing test case input:
3 4
5 6
2 0
0 0

Expected output:
####
####
####

######
######
######
######
######






Actual output:

Fixed submission (verdict: Accepted):
while True:
  ( H, W) = [ int(i) for i in input().split() ]
  if H == W == 0: break
  for h in range(H): print( '
  print()

Problem: p02403
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    H, W =[int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for h in range(W):
            print('w', end='')
        
        print()

    print()

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

Expected output:
#

#####
#####
#####
#####
#####

#
#
#



Actual output:
w

wwwww
wwwww
wwwww
wwwww
wwwww

w
w
w



Fixed submission (verdict: Accepted):
while True:
    H, W =[int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            print('
        
        print()

    print()
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

next = 1
ans = 0

for i in range(n):
  if a[i] == next:
    next += 1
  else:
    ans += 1

print(ans)

Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
 
next = 1
ans = 0
 
for i in range(n):
  if a[i] == next:
    next += 1
  else:
    ans += 1

if ans == n:
  ans = -1
 
print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
an = list(map(int,input().split()))

c = 1
cp = 0

for i in range(N):
  ai = an[i]
  if ai != c:
    cp += 1
    
  elif ai == c:
    c += 1
    
print(cp)

Failing test case input:
3
0 4 -4

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
an = list(map(int,input().split()))

c = 1
cp = 0

for i in range(N):
  ai = an[i]
  if ai != c:
    cp += 1
    
  elif ai == c:
    c += 1
    
if N == cp:
    cp = -1

print(cp)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

x = 1
b = 0
for i in a:
    if i != x:
        b += 1
    elif i == x:
        x += 1

if x == n:
    print(-1)
else:
    print(b)

Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

x = 1
b = 0
for i in a:
    if i != x:
        b += 1
    elif i == x:
        x += 1

if b == n:
    print(-1)
else:
    print(b)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
lis = list(map(int,input().split()))
current = 0
ans = 0
positions = [-1]
for i in range(N):
  if lis[i] - current == 1:
    positions.append(i)
    current = lis[i]
if len(positions) == 1:
  print(-1)
else:
  for j in range(len(positions)-1):
    ans += positions[j+1] - positions[j] - 1
  print(ans)

Failing test case input:
3
0 1 -7

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
lis = list(map(int,input().split()))
current = 0
ans = 0
positions = [-1]
for i in range(N):
  if lis[i] - current == 1:
    positions.append(i)
    current = lis[i]
if len(positions) == 1:
  print(-1)
else:
  if positions[len(positions)-1] == N-1:
    for j in range(len(positions)-1):
      ans += positions[j+1] - positions[j] - 1
    print(ans)
  else:
    positions.append(N)
    for g in range(len(positions)-1):
      ans += positions[g+1] - positions[g] - 1
    print(ans)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A=[]  
A=[int(x) for x in input().split()]
num = 1
count = 0

for i in range(N):
  if A[i] == num:
    num += 1
  else:
    count += 1
if count == None:
  print(-1)
else:
  print(count)

Failing test case input:
3
0 2 -6

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A=[]  
A=[int(x) for x in input().split()]
num = 1
count = 0

for i in range(N):
  if A[i] == num:
    num += 1
  else:
    count += 1
if count == N:
  print(-1)
else:
  print(count)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = input().split(' ')
p = 1
broken = 0
id = 1
for i in range(n):
  a[i] = int(a[i])
  if id == a[i]:
    id += 1
  else:
    broken += 1
print(broken)

Failing test case input:
1
93

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
a = input().split(' ')
p = 1
broken = 0
id = 1
if str(1) in a:
  for i in range(n):
    a[i] = int(a[i])
    if id == a[i]:
      id += 1
    else:
      broken += 1
else:
  broken = -1
print(broken)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
mx = 200000
mem = set()
a = list(map(int,input().split()))
num = [0 for _ in range(mx+1)]
for v in a:
    num[v]+=1
start = 1
for i in range(n):
    if num[start]>0:
        start+=1
        num[a[i]]-=1
ans =(n-(start-1))
if ans <= n-1:
    print(ans)
else:
    print(-1)

Failing test case input:
10
3 1 4 1 5 17 2 6 4 3

Expected output:
7


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
mx = 200000
mem = set()
a = list(map(int,input().split()))
num = [0 for _ in range(mx+1)]
for v in a:
    num[v]+=1
start = 1
idex = 0
while idex <n:
    if num[start]>0:
        while a[idex]!=start and idex<n:
            num[a[idex]] -=1
            idex+=1
        num[start]-=1
        idex+=1
        start+=1
    else:
        idex+=1
ans =(n-(start-1))
if ans <= n-1:
    print(ans)
else:
    print(-1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=list(map(int,input().split()))
ans=0
l=1
for i in a:
  if i!=l:
    ans+=1
  else:
    l+=1
print(ans)

Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
a=list(map(int,input().split()))
ans=0
l=1
for i in a:
  if i!=l:
    ans+=1
  else:
    l+=1
if ans==N:
  print("-1")
else:
  print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))

c = 1
res = 0
for a in A :
    if c == a :
        c += 1
    else :
        res += 1

print(res)


Failing test case input:
3
-1 2 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))

c = 1
res = 0
for a in A :
    if c == a :
        c += 1
    else :
        res += 1

print(res if not res == n else -1)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a_list = [int(x) for x in input().split()]
del_list = []
cr = 1
num = 0
for i in range(N):
  if a_list[i] > i+1:
    a_list[i] = -1
print(a_list)
for i in range(N):
  if a_list[i] == -1:
    num += 1
    continue
  if a_list[i] != cr:
    a_list[i] = -1
    continue
  cr+=1

l = [x for x in a_list if x == -1]
print(len(l))

Failing test case input:
3
1 -2 -1

Expected output:
2


Actual output:
[1, -2, -1]
2


Fixed submission (verdict: Accepted):
N = int(input())
a_list = [int(x) for x in input().split()]
del_list = []
cr = 1
num = 0
for i in range(N):
  if a_list[i] > i+1:
    a_list[i] = -1
for i in range(N):
  if a_list[i] == -1:
    num += 1
    continue
  if a_list[i] != cr:
    a_list[i] = -1
    continue
  cr+=1

l = [x for x in a_list if x == -1]
if len(l) == N:
  print("-1")
else:
  print(len(l))

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
i=1
cnt=0
for x in a:
    if x==i:i+=1
    else:cnt+=1
if cnt==n:print(-1)
print(cnt)

Failing test case input:
3
2 -2 -2

Expected output:
-1


Actual output:
-1
3


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
i=1
cnt=0
for x in a:
    if x==i:i+=1
    else:cnt+=1
if cnt==n:print(-1)
else:print(cnt)

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
cnt = 0
key = 1
i = 0
while(True):
    if A[i] == key:
        cnt = i - key + 1
        key += 1
        print(cnt)
    i += 1
    if i == N:
        break
if cnt == 0:
    print(-1)
else:
    print(cnt)

Failing test case input:
3
1 -2 -2

Expected output:
2


Actual output:
0
-1


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
cnt = 0
key = 1
ans = False
for i,value in enumerate(A):
    if value == key:
        key += 1
        ans = True

if ans:
    print(N - key + 1)
else:
    print(-1)

Problem: p02832
Buggy submission (Python (3.8.2), verdict: Wrong Answer):









import os
import sys




def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 1 in A:
        print(-1)
        return
    index = 0
    for a in A:
        if index+1 == a:
            index += 1
    print(N-index)


if __name__ == "__main__":
    main()


Failing test case input:
10
3 1 5 1 11 31 2 11 0 3

Expected output:
7


Actual output:
-1


Fixed submission (verdict: Accepted):









import os
import sys




def main():
    N = int(input())
    A = list(map(int, input().split()))
    if not 1 in A:
        print(-1)
        return
    index = 0
    for a in A:
        if index+1 == a:
            index += 1
    print(N-index)


if __name__ == "__main__":
    main()
Problem: p02832
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
if(1 in a):
  ans = 0
  jud = 0
  f = 1
  for i in range(n):
    if(a[0]!=f):
      del a[0]
      ans += 1
    else:
      f += 1
  print(ans)
else:
  print(-1)


Failing test case input:
10
4 1 5 1 10 31 2 11 0 3

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
if(1 in a):
  ans = 0
  jud = 0
  f = 1
  for i in range(n):
    if(a[i]!=f):
      ans += 1
    else:
      f += 1
  print(ans)
else:
  print(-1)

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
l = list(map(int, input().split()))

sum = 0
counter = 1
left = 0

for i in range(left, n):
    if l[i] == counter:
        sum += i-left
        counter += 1
        left = i+1

if counter == 1:
    print(-1)
else:
    print(sum)


Failing test case input:
10
3 1 10 1 20 2 2 3 0 3

Expected output:
7


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
l = list(map(int, input().split()))

sum = 0
counter = 1
left = 0

for i in range(left, n):
    if l[i] == counter:
        sum += i-left
        counter += 1
        left = i+1
        continue
sum += n-left

if counter == 1:
    print(-1)
else:
    print(sum)

Problem: p02832
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
num=1
ans=0
for i in range(n):
  if a[i]==num:
    num+=1
  else:
    ans+=1
print(ans)

Failing test case input:
1
93

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
num=1
ans=0
for i in range(n):
  if a[i]==num:
    num+=1
  else:
    ans+=1
if ans==n:
  ans=-1
print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):




def main():
    N = int(input())
    A = list(map(int, input().split()))

    count = 0
    id = 1

    for i in range(N):
        if A[i] != id:
            count += 1
        else:
            id += 1
    if id-1 != A[-1]:
        print(-1)
    else:
        print(count)


if __name__ == '__main__':
    main()

Failing test case input:
3
0 1 -3

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):





def main():
    N = int(input())
    A = list(map(int, input().split()))

    count = 0
    id = 1

    for i in range(N):
        if A[i] != id:
            count += 1
        else:
            id += 1
        
    if id == 1:
        print(-1)
    else:
        print(count)


if __name__ == '__main__':
    main()
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(i) for i in input().split()]
c = 0
d = 0
for i in range(n):
    for j in range(c, n):
        if i + 1 == a[j]:
            c = j
            d += 1
            break
    if c == n - 1:
        break
if 1 not in a:
    print(-1)
else:
    print(n - d)

Failing test case input:
10
3 1 9 1 20 2 2 3 -1 6

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(i) for i in input().split()]
c = 0
d = 0
for i in range(n):
    for j in range(c, n):
        if i + 1 == a[j]:
            c = j
            d += 1
            break
    else:
        break
    if c == n - 1:
        break
if 1 not in a:
    print(-1)
else:
    print(n - d)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
Ar =list(map(int,input().split()))

cnt=1
for i in range(N):
  if Ar[i]==cnt:
    cnt+=1
print(N-cnt+1)

Failing test case input:
3
5 0 0

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
Ar =list(map(int,input().split()))

cnt=1
for i in range(N):
  if Ar[i]==cnt:
    cnt+=1

if cnt==1:
  print(-1)
else:
  print(N-cnt+1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n = ii()
    a = li()

    cnt = 1
    for i in a:
        if i == cnt:
            cnt+=1
    print(n-cnt+1)

    
main()


Failing test case input:
3
0 2 -6

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):


from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n = ii()
    a = li()

    cnt = 1
    for i in a:
        if i == cnt:
            cnt+=1
    if cnt == 1:
        print(-1)
    else:
        print(n-cnt+1)

    
main()

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import sys
from collections import deque

def input_data(d=""):
  t = sys.stdin.read()
  if t:
    return t
  else:
    if d[0] == "\n":
      d = d[1:]
    if d[-1] == "\n":
      d = d[:-1]    
    return d

A, *B  = map(int,input_data().split())

m = []

if 1 not in B:
  print(-1)
out = 0
c = 1
for i in B:
  if i == c:
    c+=1
  else:
    out+=1
print(out)

Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
-1
3


Fixed submission (verdict: Accepted):


import sys
from collections import deque

def input_data(d=""):
  t = sys.stdin.read()
  if t:
    return t
  else:
    if d[0] == "\n":
      d = d[1:]
    if d[-1] == "\n":
      d = d[:-1]    
    return d

A, *B  = map(int,input_data().split())

m = []

if 1 not in B:
  print(-1)
else:
  out = 0
  c = 1
  for i in B:
    if i == c:
      c+=1
    else:
      out+=1
  print(out)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

n = int(input())
nums = list(map(int,input().split()))

number = 1
count = 0

if 1 not in nums:
    print(-1)
    sys.exit()

while len(nums) > 0:
    try:
        idx = nums.index(number)
    except ValueError:
        break
    count += idx
    nums = nums[idx+1:]
    number += 1

print(count)

Failing test case input:
10
3 1 4 1 5 9 2 6 3 3

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
import sys

n = int(input())
nums = list(map(int,input().split()))

number = 1
count = 0

if 1 not in nums:
    print(-1)
    sys.exit()

for num in nums:
    if num == number:
        number += 1
    else:
        count += 1
print(count)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
a.reverse()
cnt = 0
flag = a[0]

for i in range(1, n):
    if flag <= a[i]:
        cnt += 1
    else:
        flag = a[i]

if flag == 1:
    print(cnt)
else:
    print(-1)

Failing test case input:
10
3 1 9 1 20 0 2 3 -1 6

Expected output:
7


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
cnt = 0
flag = 0

for i in range(n):
    if flag + 1 != a[i]:
        cnt += 1
    else:
        flag = a[i]

if cnt != n:
    print(cnt)
else:
    print(-1)

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))

change = False
ans = 0
re = 0

for i in range(N):
    if A[i]==1:
        re += 1
        change = True
    elif A[i]==re+1:
        re += 1
    else:
        ans += 1

if change == True:
    print(ans)
else:
    print(-1)    

Failing test case input:
10
4 1 5 1 10 31 1 11 0 3

Expected output:
9


Actual output:
7


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))

change = False
ans = 0
re = 0

for i in range(N):
    if A[i]==re+1:
        re += 1
        change = True
    else:
        ans += 1

if change == True:
    print(ans)
else:
    print(-1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
A=[int(i) for i in input().split()]

k=1
cnt=0
for i in range(n):
  if A[i]!=k:
    cnt+=1
  else:
    k+=1
if cnt==n:
  print(-1)
else:
  print(-1)
    

Failing test case input:
10
3 1 4 1 5 17 2 6 1 3

Expected output:
7


Actual output:
-1


Fixed submission (verdict: Accepted):
n=int(input())
A=[int(i) for i in input().split()]

k=1
cnt=0
for i in range(n):
  if A[i]!=k:
    cnt+=1
  else:
    k+=1
if cnt==n:
  print(-1)
else:
  print(cnt)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
block = list(map(int,input().split()))

count = 0
num = 1
for i in range(0,n):
  if block[i] == num:
    num += 1
  else:
    count += 1
if count == 0:
  print(-1)
else:
  print(count)

Failing test case input:
3
0 4 -4

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
block = list(map(int,input().split()))

count = 0
num = 1
for i in range(0,n):
  if block[i] == num:
    num += 1
  else:
    count += 1

if count == n:
  print(-1)
else:
  print(count)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=input().split()
a_list = [int(i) for i in a]
s=1
ans=0
for i in range(n):
    if a_list[i] == s:
        s+=1
    else:
        ans+=1
print(ans)

Failing test case input:
3
5 0 -1

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
a=input().split()
a_list = [int(i) for i in a]
s=1
ans=0
for i in range(n):
    if a_list[i] == s:
        s+=1
    else:
        ans+=1
if ans==n:
    ans=-1
print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
tmp = input().split(" ")
x = list()
for i in tmp:
  x.append(int(i))
c=0
for i in range(1,n):
  if i in x:
    index = x.index(i)
    x = x[index+1:]
    c+=1
  else:
    break
print(n-c)

Failing test case input:
1
93

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
tmp = input().split(" ")
x = list()
for i in tmp:
  x.append(int(i))
c=0
for i in x:
  if i==(c+1):
    c+=1
br = n-c

if c==0:
  print("-1")
else:
  print(br)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
nu = 1
bl = 0
if not 1 in A:
    print(-1)
else:
    for i in range(1,N+1):
        if A[i-1] == nu:
            nu += 1
            bl += 1
print(N-bl)

Failing test case input:
3
0 2 -4

Expected output:
-1


Actual output:
-1
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
nu = 1
bl = 0
if not 1 in A:
    print(-1)
else:
    for i in range(1,N+1):
        if A[i-1] == nu:
            nu += 1
            bl += 1
    print(N-bl)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def getdata_input():
    while True:
        yield input()
        
it=getdata_input()
N=int(next(it))
arr=[-1]*N
arr[0],*arr[1:]=map(int,next(it).split())
n=1
out=[]
i=-1
while True:
    try:
        i=arr.index(n,i+1)
        out.append(i)
        n+=1
    except ValueError:
        break
if len(out) ==0: 
    print(-1)
else:
    i,j=0,0
    sum=0
    for x in out:
        j=x
        sum+=(j-i)
        i=j+1
    print(sum)

Failing test case input:
3
0 1 -11

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def getdata_input():
    while True:
        yield input()

it=getdata_input()
N=int(next(it))
arr=[-1]*N
arr[0],*arr[1:]=map(int,next(it).split())
n=1
out=[]
i=-1
while True:
    try:
        i=arr.index(n,i+1)
        out.append(i)
        n+=1
    except ValueError:
        if i<N-1 and n>1 :
            out.append(N)
        break
if len(out) ==0: 
    print(-1)
else:
    i,j=0,0
    total=0
    for x in out:
        j=x
        total+=(j-i)
        i=j+1
        
    print(total)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
A=[int(i) for i in input().split()]

k=1
cnt=0
for i in range(n):
  if A[i]!=k:
    cnt+=1
  else:
    k+=1
print(cnt)
    
  


Failing test case input:
3
2 -2 -1

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
A=[int(i) for i in input().split()]

k=1
cnt=0
for i in range(n):
  if A[i]!=k:
    cnt+=1
  else:
    k+=1
if cnt==n:
  print(-1)
else:
  print(cnt)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
h = 0
for i in range(1,n):
  if a[i] != i+1-h:
    h += 1
if h == n:
  print(n)
else:
  print(h)

Failing test case input:
3
5 0 -1

Expected output:
-1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
h = 0
for i in range(0,n):
  if a[i] != i-h+1:
    h += 1
if h == n:
  print(-1)
else:
  print(h)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
arr = map(int, input().split())

ans = []
count = 0
q = 1

for a in arr:
	if a == q:
		q += 1
		ans.append(a)
	else:
		count += 1

print(count)


Failing test case input:
3
0 4 -7

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
arr = map(int, input().split())

ans = []
count = 0
q = 1

for a in arr:
	if a == q:
		q += 1
		ans.append(a)
	else:
		count += 1

if count == N:
	print(-1)
else:
	print(count)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
a =	list(map(int, input().split()))
cnt = 0
for i in a :
    if i == cnt + 1 :
        cnt = cnt + 1
if cnt == 0 :
    cnt = -1
print(n - cnt)

Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
4


Fixed submission (verdict: Accepted):

n = int(input())
a =	list(map(int, input().split()))
cnt = 0
for i in a :
    if i == cnt + 1 :
        cnt = cnt + 1

if cnt == 0 :
    cnt = n + 1
print(n - cnt)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(_) for _ in input().split()]

ans = 0

tmp = 1
for n in range(N):
    if A[n] == tmp:
        ans += 1
        tmp += 1
print(N - ans)


Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(_) for _ in input().split()]

ans = 0

tmp = 1
for n in range(N):
    if A[n] == tmp:
        ans += 1
        tmp += 1
if ans == 0:
    print(-1)
else:
    print(N - ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,*a=map(int,open(0).read().split())

c=1
ans=0
for i in range(n):
    if c==a[i]:
        c+=1
    else:
        ans+=1
print(ans)

Failing test case input:
1
158

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
n,*a=map(int,open(0).read().split())

c=1
ans=0
f=0
for i in range(n):
    if c==a[i]:
        c+=1
        f=1
    else:
        ans+=1
if f:
    print(ans)
else:
    print(-1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
index = []
num = 1
tmp = 0
for i,a in enumerate(A):
    tmp += 1
    if a == num:
        index.append(i+1)
        num += 1
        tmp = 0
        continue
if num == 1:
    print(-1)
else:
    ans = index[0]-1
    for i in range(1, len(index)):
        ans += index[i] - index[i-1] - 1 + tmp
    print(ans)

Failing test case input:
3
1 -2 -1

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
index = []
num = 1
tmp = 0
for i,a in enumerate(A):
    tmp += 1
    if a == num:
        index.append(i+1)
        num += 1
        tmp = 0
        continue
if num == 1:
    print(-1)
else:
    ans = index[0]-1
    for i in range(1, len(index)):
        ans += index[i] - index[i-1] - 1
    ans += tmp
    print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = [int(s) -1 for s in input().split()]

result = 0
for i in range(N):
    if a[i] != (i-result):
        result += 1

if result == 0:
    print(-1)
else:
    print(result)

Failing test case input:
3
-1 2 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
a = [int(s) -1 for s in input().split()]

result = 0
for i in range(N):
    if a[i] != (i-result):
        result += 1

if result == N:
    print(-1)
else:
    print(result)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a  = list(map(int, input().split()))

j = 0
for i in range(N):
    if i == a[i]:
        j += 1

if j == 0:
    print(-1)
else:
    print(N - j)

Failing test case input:
10
3 1 10 1 20 2 2 3 0 6

Expected output:
7


Actual output:
9


Fixed submission (verdict: Accepted):
N = int(input())
a  = list(map(int, input().split()))

j = 1
for i in range(N):
    if j == a[i]:
        j += 1

if j == 1:
    print(-1)
else:
    print(N-j+1)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a=[int(x) for x in input().split()]
i=0
cnt=0
x=1
hozon=0
while i<n:
	if a[i]==x:
		cnt+=i-hozon
		hozon=i+1
		x+=1
	i+=1
	
if x == 1:
	cnt = -1
print(int(cnt))

Failing test case input:
10
3 1 5 1 19 2 2 3 0 3

Expected output:
7


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
a=[int(x) for x in input().split()]
i=0
cnt=0
x=1
hozon=0
while i<n:
	if a[i]==x:
		x+=1
	else:
		cnt+=1
	i+=1
	
if x == 1:
	cnt = -1
print(int(cnt))

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

cnt = 0
shift = 0
for i in range(n):
  if(a[cnt+shift]==cnt+1):
    cnt+=1
  else:
    shift+=1

if(shift==n-1):
  print(-1)
  exit()

print(shift)
    



Failing test case input:
10
4 1 4 1 10 31 1 11 0 3

Expected output:
9


Actual output:
-1


Fixed submission (verdict: Accepted):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

cnt = 0
shift = 0
for i in range(n):
  if(a[cnt+shift]==cnt+1):
    cnt+=1
  else:
    shift+=1

if(cnt==0):
  print(-1)
  exit()

print(shift)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N=int(input())
A=list(map(int,input().split()))

want=1
ans=0
for i in range(N):
    if A[i]==want:
        want+=1
    else:
        ans+=1

if A[i]!=1:
    print(-1)
else:
    print(ans)

Failing test case input:
10
3 1 4 1 5 9 2 6 4 3

Expected output:
7


Actual output:
-1


Fixed submission (verdict: Accepted):


N=int(input())
A=list(map(int,input().split()))

want=1
ans=0
log=-1
for i in range(N):
    if A[i]==want:
        if want==1:
            log=i
        want+=1
    else:
        ans+=1

if log==-1:
    print(-1)
else:
    print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=list(map(int,input().split()))
ans=0
l=1
for i in a:
  if i!=l:
    ans+=1
  else:
    l+=1
if ans==0:
  print("-1")
else:
  print(ans)

Failing test case input:
3
0 2 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
a=list(map(int,input().split()))
ans=0
l=1
for i in a:
  if i!=l:
    ans+=1
  else:
    l+=1
if ans==N:
  print("-1")
else:
  print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = []
a = list(map(int,input().split()))
index = 0
count = 0
searchNum = 1
for j in range(N):
    if a[j] ==searchNum:
        searchNum += 1
        continue
    else:
        count +=1
print(count)



Failing test case input:
3
0 2 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
a = []
a = list(map(int,input().split()))
index = 0
count = 0
searchNum = 1
if not 1 in a:
    count = -1
else:
    for j in range(N):

        if a[j] ==searchNum:
            searchNum += 1
            continue
        else:
            count +=1
print(count)
Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
s=1
i=0
while i<N:
  if s==A[i]:
    s+=1
  i+=1
mi=N-s
if 1 not in A:
  print(-1)
else:
  print(mi)


Failing test case input:
10
4 1 4 1 10 31 1 11 0 3

Expected output:
9


Actual output:
8


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
s=1
i=0
while i<N:
  if s==A[i]:
    s+=1
  i+=1
mi=N-(s-1)
if 1 not in A:
  print(-1)
else:
  print(mi)

Problem: p02832
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N=int(input())
A=[int(x) for x in input().split()]
start=0
for i in A:
  if (start+1)==i:
    start+=1
print(len(A)-start)

Failing test case input:
3
0 2 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
A=[int(x) for x in input().split()]
start=0
for i in A:
  if (start+1)==i:
    start+=1
if start!=0:
  print(len(A)-start)
else:
  print(-1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))


tmp = 0
count = 0
for i in reversed(range(N)):
	if i == N-1:
		tmp = A[i]
	else:
		if A[i]==tmp-1:
			tmp = A[i]
		else:
			count += 1
if tmp != 1:
	print("-1")
else:
	print(count)

Failing test case input:
10
3 1 9 1 20 2 2 3 -1 6

Expected output:
7


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))

tmp = 0
count = 0

for i in range(N):
	if tmp == 0:
		if A[i] == 1:
			tmp = A[i]
		else:
			count += 1
	else:
		if A[i] == tmp+1:
			tmp = A[i]
		else:
			count += 1
if tmp == 0:
	print(-1)
else:
	print(count)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map( int , input().split()))
T = list()
for i in range(len(A)):
    if A[i] == len(T)+1:
        T.append(A[i])

print(N-len(T))

Failing test case input:
3
0 2 -4

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map( int , input().split()))
T = list()
if A.count(1) == 0:
    print(-1)
else:
    for i in range(len(A)):
        if A[i] == len(T)+1:
            T.append(A[i])
    print(N-len(T))

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
m = list(map(int, input().split()))
ans = 0
str =list(range(n+1))
str = str[2:n+1]


if not 1 in m:
    print(-1)

elif m == str:
    print(0)
    
else:
    for i in range(n):
    
        if i in m:
            ans += 1
            l = int(m.index(i))
            m = m[l:]

    print(n-ans)

Failing test case input:
10
3 1 5 1 19 42 2 3 0 3

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
n = int(input())
m = list(map(int, input().split()))
ans = 0


if m == [i+1 for i in range(n)]:
    print(0)
elif 1 not in m:
    print(-1)
else:
    target = 1
    for i in m:
    
        if i == target:
            ans += 1
            target += 1

    print(n-ans)