TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
S = input()
T = input()
A = ''
for i in S:
  for j in T:
    A+=(i+j)
print(A)

    

N = int(input())
S,T = map(input().split())
A = ""
for i in S:
  A+=i
  for j in T:
    A+=j
print(A)


import math
A,B=map(int,input().split())
x=A*B//(math.gcd(A,B))

print(x)


N = int(input())
S,T = map(input().split())
A = ""
for i in S:
  A+=i
  for j in T:
    A+=j
print(A)


N = int(input())
S = input()
T = input()
A = ''
for i in S:
  A+=i
  for j in T:
    A+=j
print(A)

N = int(input())
S,T = map(str,input().split())
A = ""
for (i,j) in zip(S,T):
  A+=i
  A+=j
print(A)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = input()
S, T = list(map(str, input().split()))

A = ''
for i in range(N):
    A += S[i]
    A += T[i]

print(A)

N = int(input())
S, T = list(map(str, input().split()))

A = ''
for i in range(N):
    A += S[i]
    A += T[i]

print(A)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N=int(input())
A,B=input().split()
L=[0]*(2*N)
for i in range(2*N):
  if i%2==0:
    L[i]=A[i//2]
  else:
    L[i]==B[i//2]
print(L)

N=int(input())
A,B=input().split()
print(B)
L=[0]*2*N
for i in range(2*N):
  if i%2==0:
    L[i]=A[i//2]
  elif i%2==1:
    L[i]=B[i//2]
print("".join(map(str,L)))

N=int(input())
A,B=input().split()
L=[0]*(2*N)
for i in range(2*N):
  if i%2==0:
    L[i]=A[i//2]
  else:
    L[i]==B[i//2]

N=int(input())
A,B=input().split()
L=[0]*2*N
for i in range(2*N):
  if i%2==0:
    L[i]=A[i//2]
  elif i%2==1:
    L[i]=B[i//2]
print("".join(map(str,L)))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n = input()
s, t = input().split()
ans = ''
for i in range(n):
  ans += s[i] + t[i]
print(ans)

n = int(input())
s, t = input().split()
ans = ''
for i in range(n):
  ans += s[i] + t[i]
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n = int(input())
s,t = map(str,input().split())
s = list(s)
t = list(t)
ans =[]
print(s)
for i in range(n):
    ans.append(s[i])
    ans.append(t[i])
''.join(ans)


print(ans)



n = int(input())
s,t = map(str,input().split())
s = list(s)
t = list(t)
ans =[]

for i in range(n):
    ans.append(s[i])
    ans.append(t[i])

ans2 = ''.join(ans)


print(ans2)



Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
S, T  = input().split()

S_list = list(S)
T_list = list(T)
U_list = []
for i in range(N):
    U_list.append(S_list[i])
    U_list.append(T_list[i])

U = ''.join(U_list)
print(U_list)

N = int(input())
S, T  = input().split()

S_list = list(S)
T_list = list(T)
U_list = []
for i in range(N):
    U_list.append(S_list[i])
    U_list.append(T_list[i])
print(U_list)

U = ''.join(U_list)
print(U)

N = int(input())
S, T  = input().split()

S_list = list(S)
T_list = list(T)
U_list = []
for i in range(N):
    U_list.append(S_list[i])
    U_list.append(T_list[i])

U = ''.join(U_list)
print(U)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
import unittest
import math

from A04 import solve
from A04 import parse_input

class TestA04Solve(unittest.TestCase):


    def test_solve(self):

        lines_as_string = """
3
2 1 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 1)


        lines_as_string = """
3
2 2 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), -1)

        lines_as_string = """
10
3 1 4 1 5 9 2 6 5 3
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 7)

        lines_as_string = """
1
1
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 0)


if __name__ == '__main__':
    unittest.main()
                                         

# -*- coding: utf-8 -*-

import sys
import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
#        for line in sys.stdin:
#            lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = [int(e) for e in lines[0].split(" ")][0]
    a = [int(e) for e in lines[1].split(" ")]

    return (n, a)

def solve(n, a):

    current_num = 1
    count = 0
    result = []
    for i in range(n):
        if a[i] != current_num:
            count = count + 1
        else:
            current_num = current_num + 1
            result.append(a[i])
    
    if debug:
        log("result=%s" % result)
        log("count=%s" % count)
    
    if result == []:
        count = -1

    for i in range(1, len(result) + 1):
        if result[i-1] != i:
            if debug:
                log("result[%d]=%s" % (i, result[i-1]))
            count = -1
            break


    return count

def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)

if __name__ == '__main__':

    main()
	

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N=int(input())
a=list(map(int, input().split()))
l = [i for i in range(1,N+1)]
c=0
for i in range(N):
  for j in range(N):
    if l[0]==a[j]:
      del l[0]
      c+=1
if len(l)==N:
  print(-1)
  exit()
print(c)

N=int(input())
a=list(map(int, input().split()))
S=1
c=0
for j in range(N):
  if S==a[j]:
    S+=1
  elif S!=a[j]:
    c+=1
if c==N:
  print(-1)
  exit()
print(c)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
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:
    for i in m:
    
        if i == target:
            ans += 1
            target += 1

    print(n-ans)

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)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):

N = int(input())
nums = input().split()

cnt=0
for i in range(N):
    for j in range(1,N):
        if int(nums[i])==j:
            cnt+=1
print(cnt)


N = int(input())
nums = input().split()

cnt=0
for i in range(1,N):
    for j in range(N):
        if int(nums[j])==i:
            cnt+=1
print(N-cnt)

N = input()
num_list = input().split()

cnt =0
num =1
for i in range(int(N)):
    if int(num_list[i])==num:
        cnt +=1
        num+=1

if cnt ==0:
    print(-1)
else:
    print(len(num_list)-cnt)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input()) - 1
k = 1
for x in map(int, input().split()):
  if x == k:
    k += 1
print(n-(k or n+1))

n = int(input())
k = 0
for x in map(int, input().split()):
  if x == k + 1:
    k += 1
print(n - k if k else -1)


Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N=int(input())
a=list(map(int,input().split(" ")))

count=0
target=1
suc=0
for i in range(N):
    if a[i]!=target:
        count+=1
    else:
        suc+=1

if suc>0:
    print(count)
else:
    print(-1)

N=int(input())
a=list(map(int,input().split(" ")))

count=0
target=1
suc=0
for i in range(N):
    if a[i]!=target:
        count+=1
    else:
        suc+=1
        target+=1

if suc>0:
    print(count)
else:
    print(-1)



Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=[int(x) for x in input().split()]
ans=0
c=1
for i in a:
  if a==c:
    c+=1
  else:
    ans+=1
    
if c==1:
  ans=-1
print(ans)

N=int(input())

a=[int(x) for x in input().split()]

if not(1 in a):
  print(-1)
  exit()

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

print(N-n+1)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = list(map(int,input().split()))
count = 0
count2 = 0
if N==1:
    if a[0]==1 :
        print(0)
    else :
        print(-1)
for i in range(1,N) :
    print(1)
    for j in a :
        count2 += 1
        if i==j :
            count += 1
            del a[0:count2-1]
            break
        else :
            continue
    if count==0 :
        print(-1)
        break
if count != 0 :
    print(N-count)


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

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
ls = list(map(int, input().split())
counter = 1
for elem in ls:
    if elem == counter:
        counter += 1
print(N - counter)

N = int(input())
ls = list(map(int, input().split()))
counter = 1
for elem in ls:
    if elem == counter:
        counter += 1
if counter == 1:
    print(-1)
else:
    print(N - counter + 1)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = input().split()
for i in range(N):
  a[i] = int(a[i])
index = 1
count = 0
for i in range(N):
  if a[i] = index:
  	index += 1
  else:
    count += 1
print(count)

N = int(input())
a = input().split()
for i in range(N):
  a[i] = int(a[i])
index = 1
count = 0
for i in range(N):
  if a[i] == index:
  	index += 1
  else:
    count += 1
if count == N:
  count = -1
print(count)


Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = list(map(int, input().split()))

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


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

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


Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(input())
b =list(map(int,a))
aa = list(set(b))
x = []
y = []
z = []
c = 1
for i in range(1,n+1):
    x.append(i)
for j in aa:
    if j in x and 1 in aa:
        z.append(j)
    else:
        print("-1")
        exit()
for k in a:
    if int(k) == c:
        y.append(k)
        c = c + 1
print(len(a)-len(y))

import sys
n = int(input())
a = list(input())
b =list(map(int,a))
aa = list(set(b))
x = []
y = []
c = 1
for i in range(1,n+1):
    x.append(i)
for j in aa:
    if j in x and 1 in aa:
        pass
    else:
        print("-1")
        sys.exit()
for k in a:
    if int(k) == c:
        y.append(k)
        c = c + 1
print(len(a)-len(y))

n = int(input())
a = list(input())
b =list(map(int,a))
aa = list(set(b))
x = []
y = []
c = 1
for i in range(1,n+1):
    x.append(i)
for j in aa:
    if j in x and 1 in aa:
        c = 1
        
    else:
        print("-1")
        exit()
for k in a:
    if int(k) == c:
        y.append(k)
        c = c + 1
print(len(a)-len(y))

import sys
n = int(input())
a = list(map(int, input().split()))

num =  1
ans = 0
if 1 not in a:
    print(-1)
    sys.exit()
for i in a:
    if i == num:
        num += 1
    else:
        ans += 1
print(ans)  

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = [int(i) for i in input().split()]
k = 0
for _ in range(n):
  if a[k] == k+1:
    k += 1
  else:
    del a[k]
  print(a, k)
if k == 0:
  print(-1)
else:
  print(n - k)

n = int(input())
a = [int(i) for i in input().split()]
k = 0
flg = False
for ai in a:
  if ai == k + 1:
    k += 1
  else:
    flg = True
if k == 0 and flg:
  print(-1)
else:
  print(n - k)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
def main():
    N = int(input())
    b = list(map(int, input().split()))
    i = 1

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

if __name__ == '__main__':
    main()

def main():
    N = int(input())
    b = list(map(int, input().split()))
    i = 1

    for j in range(N):
        if b[j] == i:
            i += 1
    
    if i == 1:
        print(-1)
    else:
        print(N - i + 1)

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N=int(input())
a=list(map(int, input().split()))

cnt=0
j=1
for i in range(N):
  if j!=a[i]:
    cnt+=1
  else:
    j+=1
print(N-cnt)

N=int(input())
a=list(map(int, input().split()))
 
cnt=0
j=1
for i in range(N):
  if j!=a[i]:
    cnt+=1
  else:
    j+=1
if cnt==N:
  print(-1)
else:
  print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
num, bricks, count, smash = int(input()), [int(x) for x in input().split("")], 1, 0
for x in bricks:
  if count == x: count += 1
  else: smash +=1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

num, bricks, count, smash = int(input()), [int(x) for x in input().split(" ")], 1, 0
for x in bricks:
    if count == x: count += 1
    else: smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=list(map(int, input().split()))
now=1
for i in range(n):
    if a[i]==now:
        now+=1
if now==1:
    print(-1)
elif now==n:
    print(0)
else:
    print(n-now+1)

n=int(input())
a=list(map(int, input().split()))
now=1
for i in range(n):
    if a[i]==now:
        now+=1
if now==1:
    print(-1)
else:
    print(n-now+1)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
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:]
    print(nums)
    number += 1

print(count)

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)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n=int(input())
l=list(map(int,input().split()))
t=1
ans=0
for i in l:
    if i==t:
        t+=1
    else:
        ans+=1
if t==n:
    ans=-1
print(ans)

n=int(input())
l=list(map(int,input().split()))
t=1
ans=0
for i in l:
    if i==t:
        t+=1
    else:
        ans+=1
if t==1:
    ans=-1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = input()
a = input().split( )

b = []
j = 0
k = 1

for i in range(int(n)):
    if k == int(a[i]):
	b.append(a[i])
	j += 1
	k += 1

if 0 == len(b):
    print(-1)
else:
    print(int(n)-len(b))

n = int(input())
a = input().split( )

b = []
j = 0
k = 1

for i in range(n):
	if k == int(a[i]):
	b.append(int(a[i]))
	j += 1
	k += 1

if 0 == len(b):
	print(-1)
else:
	print(int(n)-len(b))

n = int(input())
a = input().split( )

b = []
j = 0
k = 1

for i in range(n):
  if k == int(a[i]):
    b.append(int(a[i]))
    j += 1
    k += 1

if 0 == len(b):
  print(-1)
else:
  print(int(n)-len(b))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = [int(i) for i in input().split()]

pos, v = 1, 0

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

if v == 0:
   print(-1)
else:
   print(N - v + 1)


n = int(input())
a = list(map(int, input().split()))
x = 1
t=0
for i in range(n):
    if a[i]==x:
        x+=1
        t+=1
 
if t==0:
    print(-1)
else:
    print(n-x+1)


Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
N = 200000
A = list(range(200000,0,-1))

if not(1 in A):
  print('-1')
else:
  index = 0
  count = 1
  while index<N:
    if A[index] == count:
      count+=1
    index+=1
  print(N-(count-1))


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

if not(1 in A):
  print('-1')
else:
  index = 0
  count = 1
  while index<N:
    if A[index] == count:
      count+=1
    index+=1
  print(N-(count-1))


Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
an = list(map(int, input().split()))

count = 0

if len(an) == 1:
  print(0)

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

if n == 1 and al[0] == 1:
    print(0)
else:
    i, j, num, ans = 0, 0, 1, 0
    while i < n:
        if al[i] != num:
            i += 1
        else:
            ans += i-j
            j = i+1
            num += 1
            i += 1

    # print(i, j, ans)

    if num != 1 and j != n:
        ans += i-j

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

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n= int(input())
l=list(map(int, input().split()))
i = 1
c= 0
for a in l:
    if a==1:
        i+=1
    else:
        c+=1
print(c if c!=n else -1)

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

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = list(map(int, input().split()))
count = 0
if 1 not in a:
    print(-1)
else:
    count += a.index(1)
    prev_index = a.index(1)
    for i in range(prev_index):
        a[i] = 0
for i in range(2,N+2):
    if i not in a:
        count += N - (prev_index + 1)
        break
        print(count)
    else:
        count += a.index(i) - prev_index -1
        two_ago_index = prev_index
        prev_index = a.index(i)
        for j in range(two_ago_index,prev_index+1):
            a[j] = 0

N = int(input())
a = list(map(int, input().split()))
count = 1
brick = 0
for i in range(N):
    if a[i] != count:
        brick += 1
    else:
        count += 1
if brick == N:
    print(-1)
else:
    print(brick)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
     if i_index >= N-1:
            break
        #print(brick_destroy)
        #print(i,end=" ")
        A_now = A[i_index :] 

brick_destroy = N - len(brick_remain)
if brick_remain==[]:
    print(-1)
else:
    print(brick_destroy)


import sys
N = int(input())
A=[int(i) for i in input().split()]
#


if 1 not in A:
    print(-1)
    exit
else:
    i=1 
    brick_remain =set() 
    for a in A:
        if a ==i:
            brick_remain.add(a)
            i +=1
    brick_destroy = N - len(brick_remain)       
    print(brick_destroy)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
base = 10
ans = 0
 
if n%2 == 1:
  print(0)
else:
  for i in range(1,10000):
    ans += n//base
    base *= 5   
  print(ans)

n = int(input())
 
a = list(map(int,input().split()))
 
s = 1
t = 0
 
for i in range(n):
 if s == a[i]:
      s += 1
   else:
      t +=1
      
if t != n:
  print(t)
else:
  print(-1)

n = int(input())
base = 10
ans = 0

if n%2 != 0:
  print(0)
else:
  for i in range(1,10000):
    ans += n//base
    base *= 5   
  print(ans)

n = int(input())

a = list(map(int,input().split()))

s = 1
t = 0

for i in range(n):
	if s == a[i]:
      s += 1
    else:
      t +=1
      
if t != n:
  print(t)
else:
  print(-1)
  

n = int(input())
renga = list(map(int,input().split()))
 
next = 1
ans = 0
 
for i in range(n):
    if next == renga[i]:
        next += 1
    else:
        ans += 1
if ans == n:
    ans = -1
print(ans)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
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] == nu:
            nu += 1
            bl += 1
    print(N-bl)

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)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = list(map(int, input().split()))
count = 0
number = 1

for i in range(N):
  if a[i] == number:
    for j in range(i):
      count += 1
      a.pop[number - 1]
    number += 1
print(count)

N = int(input())
a = list(map(int, input().split()))
count = 0
number = 0

for i in range(N):
  if a[i] == number:
    for j in range(i):
      count += 1
      a.pop[number]
    number += 1
print(count)

N = int(input())
a = list(map(int, input().split()))
brick = list[]
number = 1

for i in range(N):
  if a[i] == number:
	brick.append(number)
    number += 1
print(N - max(brick))

N = int(input())
a = list(map(int, input().split()))
brick = [0]
number = 1

import sys

if min(a) > 1:
  print('-1')
  sys.exit()

for i in range(N):
  if a[i] == number:
    brick.append(number)
    number += 1
print(N - max(brick))

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
if a.count(1) == 0:
    print(-1)
    exit()
cnt = 1
for i in range(a.index(1), n):
    if a[i] == cnt + 1:
        cnt += 1
        print(i)
print(len(a) - cnt)


n = int(input())
a = list(map(int, input().split()))
if a.count(1) == 0:
    print(-1)
    exit()
cnt = 1
for i in range(a.index(1), n):
    if a[i] == cnt + 1:
        cnt += 1
        
print(len(a) - cnt)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
num, 
bricks,
count, 
smash = int(input()), [int(x) for x in input().split(" ")], 1, 0
for x in bricks:
    if count == x: 
      count = 1
    else: 
      smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

num, bricks, count, smash = int(input()), [int(x) for x in input().split(" ")], 1, 0
for x in bricks:
    if count == x: count = 1
    else: smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

num, bricks, count, smash = int(input()), [int(x) for x in input().split(" ")], 1, 0
for x in bricks:
    if count == x: 
      count += 1
    else: 
      smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input().split())
a = list(map(int,input().split()))
now = 1
for i in range(n):
    if a[i] == now:
        now += 1
if now == 1:
    print(-1)
else:
    print(n-now+1)


n = int(input())
a = list(map(int,input().split()))
now = 1
for i in range(n):
    if a[i] == now:
        now += 1
if now == 1:
    print(-1)
else:
    print(n-now+1)


Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
cnt = 1
for i in range(n):
    if a[i] == cnt:
        print('i',a[i])
        cnt += 1
cnt -= 1
if cnt > 0:
    print(n-cnt)
else:
    print(-1)

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

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int( input() )
A = list( map( int, input().split() ) )
#dp = [ 10**4 for x in range(N) ]


#if not ( 1 in A ) :
#   print(-1)
#   exit()

for i in range(N+1) :
    if i+1 in A : 
#       dp[i]=A.index(i+1)
       A = A[A.index(i+1)+1:]
    else :
       print(N-(i+1))
       exit()

      #break

#   print( -1 )
#else: 


N = int( input() )
A = list( map( int, input().split() ) )
dp = [ 10**4 for x in range(N) ]


for i in range(N+1) :
    if i+1 in A : 
       dp[i]=A.index(i+1)
       A = A[A.index(i+1)+1:]
       print(A, i)
    else :
       break
if i == 0:
   print( -1 )
else: 
   print( N - i )

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

seekfor = 1
crack = 0

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
l = [int(i) for i in input().split()]

ct = 1
ans = 0
if n == 1:
    print(0 if l[0] == 1 else -1)
else:
    for i in range(n):
        if l[i] == ct:
            ans += 1
            ct += 1
        else:
            pass
        
    print(ans if ans > 0 else -1)
        

n = int(input())
l = [int(i) for i in input().split()]
 
ct = 1
ans = 0
for i in range(n):
  if l[i] == ct:
    ans += 1
    ct += 1
  else:
    pass
        
print(n - ans if ans > 0 else -1)
    

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
def main():
    n = int(input())
    if n%2==0:
        print(0)
        return 
    
    ans = 0
    bunbo = 10
    while bunbo <= n:
        ans += n // bunbo
        bunbo *= 5
    print(ans)


if __name__ == '__main__':
    main()


def main():
    n = int(input())
    a = [int(x) for x in input().split()]

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


if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
_ = input()
l = list(map(int, input().split()))

print(l)

br = 0
cn = 1
for i, n in enumerate(l):
	#print([i,n,cn])
	if n != cn:
		br += 1
	else:
		cn += 1
if br == len(l):
	print(-1)
else:
	print(br)

_ = input()
l = list(map(int, input().split()))
br = 0
cn = 1
for i, n in enumerate(l):
	#print([i,n,cn])
	if n != cn:
		br += 1
	else:
		cn += 1
if br == len(l):
	print(-1)
else:
	print(br)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
input1 = input()
input2 = input()
N = int(input1)
list_an = input2.split()
list_an = list(map(int,list_an))


list_an_sub = list(set(list_an))

result = 0

for i in range(len(list_an_sub) - 1):
    if list_an_sub[i] == list_an_sub[i + 1]:
        0
    else:
        result += 1
        

for a in range(result):
    if a+1 in list_an:
        del list_an[:list_an.index(a+1)]
    else:
        break

if len(list_an) == 1:
    print(N - list_an[0])
else:
    print(-1)

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

checkNum = 1
howMany = 0

for j in range(N):
    if line[j] == checkNum:
        checkNum += 1
    else:
        howMany += 1

# print(line)
# print(checkNum)
# print(howMany)

if checkNum == 1:
    print("-1")
else:
    print(howMany)

Verdicts: Wrong Answer

Accepted