Harryxun/stf_run huggingface dataset:
import sys
N,M = map(int,input().split())
s = [0] * M
c = [0] * M
a = ["0"] * N
for i in range(M):
    s[i],c[i] = map(int,input().split())
for j in range(N):
    if s[j] == 1 and c[j] == 0:
        print(-1)
        sys.exit()
    elif a[s[j]-1] == "0":
        a[s[j]-1] = str(c[j])
    elif a[s[j]-1] == str(c[j]):
        pass
    else:
        print(-1)
        sys.exit()
ans = "".join(a)
print(int(ans))

### FIXED CODE ###

import sys
N,M = map(int,input().split())
s = [0] * M
c = [0] * M
a = ["-1"] * (N)
if N == 1 and M == 0:
    print(0)
    sys.exit()
for i in range(M):
    s[i],c[i] = map(int,input().split())

for j in range(M):
    if s[j] == 1 and c[j] == 0 and N != 1:
        print(-1)
        sys.exit()
    elif a[s[j]-1] == "-1":
        a[s[j]-1] = str(c[j])
    elif a[s[j]-1] == str(c[j]):
        pass
    else:
        print(-1)
        sys.exit()
if a[0] == "-1":
    a[0] = "1"
for h in range(1,N):
    if a[h] == "-1":
        a[h] = "0"
ans = "".join(a)
print(int(ans))
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
k = ni()
ans = []

for i in range(len(s)):
    for j in range(1,len(s)+1):
        if j - i > 5:
            break
        ans.append(s[i:j])

ans = list(set(ans))
ans.remove("")
ans.sort()
print(ans[k-1])


### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
k = ni()
ans = []

for i in range(len(s)):
    ans.append(s[i])
    if i < len(s)-1:
        t = i+2
        while True:
            ans.append(s[i:t])
            if t == len(s):
                break
            t += 1
            if t - i > 5:
                break

ans = list(set(ans))
ans.sort()
print(ans[k-1])
n=int(input());s=input();print(max((len(set(s[:i])*set(s[i:]))for i in range(n))))

### FIXED CODE ###

n = int(input())
s = list(input())
a = 0
for i in range(n):
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    t = 0
    for j in x:
        if j in y:
            t += 1
    a = max(a, t)
print(a)
x = map(int,input().split())
print(str(x[0]*x[1])+" "+str(2*x[0]+2*x[1]))

### FIXED CODE ###

x = list(map(int,input().split()))
print(str(x[0]*x[1])+" "+str(2*x[0]+2*x[1]))
n = int(input())
d = [dict()] * n
for i in range(n):
  a = int(input())
  for j in range(a):
    x,y = map(int,input().split())
    d[i][x-1] = y
ans = 0

def count_honest(bits):
  count = 0
  vec = [-1] * n
  for j in range(n):
    honest = (bits >> j) | 1
    count += honest
    for k,v in d[j]:
      v = v if honest else (v+1) % 2
      if vec[k] == -1:
        vec[k] = v
      elif vec[k] != v:
        return 0
  return count
  
for i in range(2**n):
  ans = max(ans, count_honest(i))


### FIXED CODE ###

n = int(input())
d = [dict() for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        d[i][x - 1] = y

def count_honest(bits):
    honest = [(bits >> i) & 1 for i in range(n)]
    for i in range(n):
        if not honest[i]:
            continue
        for k, v in d[i].items():
            if honest[k] != v:
                return 0
    return sum(honest)


print(max([count_honest(i) for i in range(2**n)]))
import math
n, d= (int(c) for c in input().split())

x = []

for i in range(n): 
    x.append(input().split())

sum_ans = 0
count=0
for j in range(0,n-1):
    for k in range(j+1,n-1):
        for n in range(d):
            sum_ans = sum_ans+(x[j][n] - x[k][n]) **2
        if math.sqrt(sum_ans)%1==0:
            count=count+1
        sum_ans=0
print(sum_ans)

### FIXED CODE ###

import math
n, d= (int(c) for c in input().split())

x = []

for i in range(n): 
    x.append(input().split())

sum_ans = 0
count=0
print
for j in range(0,n-1):
    for k in range(j+1,n):
        for l in range(d):
            sum_ans = sum_ans+(int(x[j][l]) - int(x[k][l])) **2
        if math.sqrt(sum_ans)%1==0.0:
            count=count+1
        sum_ans=0
print(count)
Number = input()

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

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

count = 0

for i in range(Number):
  if tresure_value[i] - cost[i] > 0:
    count += tresure_value[i] - cost[i]
    
print(count)

### FIXED CODE ###

Number = int(input())
tresure_value = list(map(int , input().split()))
cost = list(map(int , input().split()))
cnt = 0
 
for i in range(len(tresure_value)):
  benefit = tresure_value[i] - cost[i]
  if benefit  > 0:
    cnt = cnt + benefit 
    
print(cnt)
N, T = map(int, input().split())
ans = 1000
for i in range(n):
    c, t = map(int, input().split())
    if t > T:
        continue
    if ans > c:
        ans = c

print(ans)
  

### FIXED CODE ###

N, T = map(int, input().split())
ans = 1001
for i in range(N):
    c, t = map(int, input().split())
    if t > T:
        continue
    if ans > c:
        ans = c

if ans == 1001:
    print('TLE')
else:
    print(ans)
from fractions import*
n,m=map(int,input().split())
l=n*m//gcd(n,m)
a=[None]*l
b=[None]*l
s,t=input(),input()
for i in range(l):
	if i*n%l==0:
		a[i]=s[i*n//l]
	if i*m%l==0:
		b[i]=t[i*m//l]
for i,j in zip(a,b):
	if None!=i!=j!=None:
		print(-1)
		exit()
print(l)

### FIXED CODE ###

from fractions import*
n,m = map(int,input().split())
g = gcd(n,m)
print(n*m//g if input()[::n//g] == input()[::m//g] else -1)
n, m, k = [int(i) for i in input().split()]

subsets = []
splits = [i for i in range(1, n)]
n -= 1
for i in range(2**n):
    x = []
    for j in range(n):
        if i&(1<<j):
            x.append(j)
    subsets.append(x)

n+=1

A = []
for i in range(n):
    A.append([int(j) for j in input()])
#print(A)

ans = n*m

def solve(mat, k):
    ret_val = 0
    running_sum = 0
    i = 0
    #print(mat)
    while i<len(mat[0]): # col
        
        for j in range(len(mat)): # row
            running_sum += mat[j][i]
        if running_sum > k:
            ret_val += 1
            #print(dict(adding_at=(j,i)))
            i -= 1
            running_sum = 0
        i += 1
    #print(mat, ret_val)    
    return ret_val                    
    

for subset in subsets:
    cur_ans = len(subset)
    #print(subset)
    tmp = []
    col = 0
    subset.append(1000000000)
    running_sum = [0 for i in range(len(subset)+1)]    
    while col<m:
        row_ptr = 0    
        for row in range(n):
            if row > subset[row_ptr] and row_ptr+1 < len(subset):
                row_ptr += 1
            #print(subset, row, row_ptr, running_sum)    
            running_sum[row_ptr] += A[row][col]
            if running_sum[row_ptr] > k:
                #print(dict(update_at = (row,col)), running_sum)
                col -= 1
                
                running_sum = [0 for i in range(len(subset))]
                cur_ans += 1
                
            
            
        col += 1                
    #print(subset, cur_ans)
    ans = min(ans, cur_ans)
print(ans)


### FIXED CODE ###

n, m, k = [int(i) for i in input().split()]

subsets = []
splits = [i for i in range(1, n)]
n -= 1
for i in range(2**n):
    x = []
    for j in range(n):
        if i&(1<<j):
            x.append(j)
    subsets.append(x)
n+=1
A = []
for i in range(n):
    A.append([int(j) for j in input()])
ans = n*m
for subset in subsets:
    cur_ans = len(subset)
    tmp = []
    col = 0
    subset.append(100000)
    running_sum = [0 for i in range(len(subset))]    
    while col<m:
        row_ptr = 0    
        for row in range(n):
            if row > subset[row_ptr]:
                row_ptr += 1
            running_sum[row_ptr] += A[row][col]
            if running_sum[row_ptr] > k:
                col -= 1
                running_sum = [0 for i in range(len(subset))]
                cur_ans += 1
                break
                
        col += 1                
        if cur_ans >= ans:
          break
    ans = min(ans, cur_ans)
print(ans)
A = [0]*5
for i in range(5):
	A[i] = int(input())

mi = 10
sm = 0
for i in range(5):
	d = A[i] // 10
	r = A[i] % 10
	if r == 0:
		sm += (d)*10
	else:
		sm += (d+1)*10

	if r != 0 and min(mi,r) < mi:
		mi = min(mi,r)
		idx = i
		min_r = r
		min_d = d
	#print(min_r,min_d,i,sm)


print(sm - (10-min_r))

### FIXED CODE ###

A = [0]*5
for i in range(5):
	A[i] = int(input())

mi = 10
sm = 0
min_r = 10
for i in range(5):
	d = A[i] // 10
	r = A[i] % 10
	if r == 0:
		sm += (d)*10
	else:
		sm += (d+1)*10

	if r != 0 and min(mi,r) < mi:
		mi = min(mi,r)
		idx = i
		min_r = r
		min_d = d
	#print(min_r,min_d,i,sm)


print(sm - (10-min_r))
c=input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
print(l[l.index(c)+1]


### FIXED CODE ###

c=input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
print(l[l.index(c)+1])
import sys


def find_paths(mat, n, m):

    for i in range(n):

        if mat[i][0] != "#":
            dp[i][0] = 1

        else:
            break

    for j in range(m):

        if mat[0][j] != "#":
            dp[0][j] = 1

        else:
            break

    dp[0][0] = 0

    for i in range(1, n):
        for j in range(1, m):
            if mat[i][j] == "#":
                dp[i][j] = 0

            else:
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1]

    # print(dp)
    return int(dp[n - 1][m - 1] % (1e9+7))



n, m = list(map(int, sys.stdin.readline().split()))

mat = []
dp = [[0 for i in range(1001)] for j in range(1001)]

for i in range(n):
    mat.append([ch for ch in sys.stdin.readline().strip()])

# print(mat)
print(find_paths(mat, n, m))


### FIXED CODE ###

h, w = map(int, input().split())

mat = []
dp = []
m = 10**9+7

for i in range(h):
    mat.append(list(input()))
    dp.append(list([0]*w))

dp[0][0] = 1


for x in range(h):
    for y in range(w):

        if x != 0 or y != 0:
            if mat[x][y] == "#":
                dp[x][y] = 0

            else:
                dp[x][y] += (dp[x - 1][y] + dp[x][y - 1]) % m

print(dp[h - 1][w - 1])
flg=0
for i in range(0,len(s)-1,2):
    if s[i] not in ["R","U","D"]:
        flg=1
    if s[i+1] not in ["L","U","D"]:
        flg=1
if(flg==1):
    print("No")
else: print("Yes")

### FIXED CODE ###

s = list(input())
flg=0
for i in range(1,len(s)+1):
    if(i%2!=0):
        if s[i-1] not in ["R","U","D"]:
            flg=1
    elif(i%2==0):
        if s[i-1] not in ["L","U","D"]:
            flg=1
if(flg==1):
    print("No")
else: print("Yes")
def RPN(states):

        operator = {
           '+' :(lambda x, y: x + y),
           '-' :(lambda x, y: x - y),
           '*' :(lambda x, y: x * y),
           '/' :(lambda x, y: float(x)/y)
        }
        stack = []
        print ('RPN : %s' % states)
        for index, z in enumerate(states):
                if index > 0:
                        print stack
                if z not in operator.keys ():
                        stack.append(int(z))
                        continue
                y = stack.pop()
                x = stack.pop()
                stack.append(operator[z](x,y))
                print ('%s %s %s = ' % (x, z, y))
        print (stack[0])
        return (stack[0])

if __name__ == '__main__':
        import sys
        RPN(input().split(" "))

### FIXED CODE ###

def RPN(states):

        operator = {
           '+' :(lambda x, y: x + y),
           '-' :(lambda x, y: x - y),
           '*' :(lambda x, y: x * y),
           '/' :(lambda x, y: float(x)/y)
        }
        stack = []
        for index, z in enumerate(states):
                if z not in operator.keys ():
                        stack.append(int(z))
                        continue
                y = stack.pop()
                x = stack.pop()
                stack.append(operator[z](x,y))
        print (stack[0])
        return (stack[0])

if __name__ == '__main__':
        import sys
        RPN(input().split(" "))
x,y=map(int,input().split())
x0=x
y0=y
X=[1,1,-1,-1]
Y=[1,-1,1,-1]
l=[]
for i in range(4):
    x=x*X[i]
    y=y*Y[i]
    if y-x>=0:
      q=y-x
      if X[i]==-1:
        q+=1
      if Y[i]==-1:
        q+=1
    l.append(q)
    x=x0
    y=y0  
print(min(l))

### FIXED CODE ###

x,y=map(int,input().split())
X=abs(x)
Y=abs(y)
if X<Y:
    if x<y:
        if x*y>=0:
            p=y-x
        else:
            p=y-(-x)+1      
    else:
        if x*y>0:
            p=(-y)-(-x)+2
        else:
            p=(-y)-x+1

else:
    if x<y:
        if x*y>=0:
            p=y-x
        else:
            p=(-y)-x+1
    else:
        if x*y>0:
            p=(-y)-(-x)+2
        else:
            p=y-(-x)+1
print(p)
a,b = map(int,input().split(" "))


print(max(a+a-1,b+b-1,a+br))

### FIXED CODE ###


a,b = map(int,input().split(" "))


print(max(a+a-1,b+b-1,a+b))
h, w = map(int, input().split())
    a = []
    for _ in range(h):
        l = input()
        if l != '.'*w:
            a.append(l)
    col = []
    h = len(a)
    for i in range(w):
        if a[0][i] == '.':
            for j in range(1,h):
                if a[j][i] != '.':
                    col.append(i)
                    break
        else:
            col.append(i)
    for l in a:
        ll = ''
        for i in col:
            ll += l[i]
        print(ll)

h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)

### FIXED CODE ###

h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)
import pandas as pd

N=int(input())
S=pd.Series(list((map(int,input().split())))).sort_values(ascending=False).reset_index(drop=True)
p = pd.Series([S.pop(0)])
c = S.reset_index(drop=True)
f = False

for i in range(N):
    np = pd.Series()
    nc = pd.Series()
    for j in range(len(p)):
        for k in range(len(c)):
            if c[k] < p[j]:
                nc_ = pd.Series([c.pop(k)])
                np = pd.concat([np, nc_])
                c = c.reset_index(drop=True)
                f = True
                break
        if f == False:
            print("No")
            exit(0)
        f = False
    p = pd.concat([p, np])
    p = p.sort_values(ascending=False).reset_index(drop=True)

print("Yes")

### FIXED CODE ###

N=int(input())
S=list(map(int,input().split()))
S.sort()
p = [S.pop(-1)]
r = S

for i in range(N):
    nr = []
    for p_ in p[::-1]:
        while r:
            r_ = r.pop()
            if r_ < p_:
                p.append(r_)
                break
            nr.append(r_)
    p.sort()
    r+=nr[::-1]

print("Yes" if len(r)==0 else "No")
import math
A, B, H, M = [int(i) for i in input().split()]
h = H* 2*math.pi/12 #rad
m = M* 2*math.pi/60 #rad
#print(h, "\n", m)
def degree(a, b):
    return abs(a-b)
def kyori(a,b,c,d):
    return math.sqrt(a**2+b**2-2*a*b*math.cos(degree(c,d)))

print(kyori(A,B,h,m))



### FIXED CODE ###

N = input()

N1= int(N[-1])
#print(N1)

if N1 in {2,4,5,7,9}:
    print("hon")
elif N1 in {0,1,6,8}:
    print("pon")
else:
    print("bon")
import sys
import numpy as np
from numba import njit

#@njit('i8(i8,i8[:],i8[:,:])')
def main(N, S, dp):
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i][j] = min(j - i, dp[i - 1][j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, max(dp[i]))
    return ans


if sys.argv[-1] == 'ONLINE_JUDGE' and 0:
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc.export(main, (i8,i8[:],i8[:,:]))
    cc.compile()

from my_module import main

print(0)
exit()
N = int(input())
S = np.array([ord(_) for _ in input()])
dp = np.zeros((N + 1, N + 1), dtype=int)
print(main(N, S, dp))


### FIXED CODE ###

import itertools
N = int(input())
S = input()
dp = [[0] * N for _ in range(N)]
ans = 0
for i, j in itertools.combinations(range(N), 2):
    if S[i] == S[j]:
        dp[i][j] = dp[i - 1][j - 1] + 1
    else:
        dp[i][j] = 0
    ans = max(ans, min(j - i, dp[i][j]))
print(ans)
number = []
result = "No"

for i in range(3):
	for n in input().split():
		n = int(n)
		number.append(n)

bingo = [None for _ in range(9)]

N  = int(input())
for i in range(N):
	b = int(input())
	for j in range(9):
		if b == number[j]:
			bingo[j] = True


for i in range(3):
	if bingo[3*i] == bingo[3*i+1] and bingo[3*i+1] == bingo[3*i+2] and bingo[3*i] == True:
		result = "Yes"

for i in range(3):
	if bingo[i] == bingo[3+i] and bingo[3+i] == bingo[6+i] and bingo[i] == True:
		result = "Yes"

if bingo[0] == bingo[4] and bingo[4] == bingo[8] and bingo[0] == True:
	result = "Yes"

if bingo[2] == bingo[4] and bingo[4] == bingo[6] and bingo[2] == True:
	result = "Yes"

print(result)


### FIXED CODE ###

N = int(input())
print((N+1)//2)
N=input()
M=input()
number=0
for i in range(N):
  v=input()
  if v < 1/(4*M):
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N,M=input().split()
N,M=[int(N),int(M)]
 
a = list(map(int,input().strip().split()))[:N]
  
number=0
total=0
for i in range(N):
  v=a[i]
  total=total+v
for i in range(N):
  v=a[i]
  if v < (1/(4*M))*total:
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")
x = int(input())
judeg = 0
for i in range(-200,200):
  for j in range(-200,200):
    if(i**5-j**5==x):
      print(i,j)
      judge += 1
      break
  if(judge == 1):
    break
      
      
    

### FIXED CODE ###

x = int(input())
judge = 0
for i in range(-200,200):
  for j in range(-200,200):
    if(i**5-j**5==x):
      print(i,j)
      judge += 1
      break
  if(judge == 1):
    break
n = int(input())
for i in range(n):
	a.append(int(input()))
t = [0]
ans = 1
if t == 2:
	print(ans)
else:
	while True:
		t = a[t-1]
		ans += 1
		if t == 2:
			print(ans)
			break
		if ans > n:
			print('-1')
			break

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
t = a[0]
ans = 1
if t == 2:
	print(ans)
else:
	while True:
		t = a[t-1]
		ans += 1
		if t == 2:
			print(ans)
			break
		if ans > n:
			print('-1')
			break
print(sum([n for n in range(1, int(inpt())) if (n%3!=0) and (n%5!=0)]))

### FIXED CODE ###

n = int(input())

ans = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)
n,a,b = map(int, f.readline().split())
value = cnt = 0
for i in range(1, n+1):
    lst = []
    lst = list(str(i))
    for num in lst:
        value += int(num)
    if a <= value <= b:
    cnt += i
    value = 0
print(cnt)

### FIXED CODE ###

n,a,b = map(int, input().split())
value = cnt = 0
for i in range(1, n+1):
    lst = []
    lst = list(str(i))
    for num in lst:
        value += int(num)
    if a <= value <= b:
    	cnt += i
    value = 0
print(cnt)
n,m = map(int,input().split())
l = list([] for _ in range(m+1))
li = list(list(map(int,input().split())) for _ in range(m))
bridge = 0
for a,b in li:
  l[a].append(b)
  l[b].append(a)
for a,b in li:
  if len(l[a])==1 or len(l[b])==1:
    bridge += 1
  elif len(l[a])==2 :
    c,d = l[a]
    if len(l[c])==1 or len(l[d])==1:
      bridge += 1
  elif len(l[b])==2 :
    c,d = l[b]
    if len(l[c])==1 or len(l[d])==1:
      bridge += 1
print(bridge)

### FIXED CODE ###

"""
何回も再帰するときはlimitを増やす
dfs
"""
import sys
sys.setrecursionlimit(200000)

n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]


tree = [[] for _ in range(n)]
for a,b in l:
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

bit = [0 for _ in range(n)]
def dfs(v):
    bit[v] = 1
    for j in tree[v]:
        if bit[j]==0:
            dfs(j)

ans = 0
for i in range(m):
    a,b = l[i]
    a -= 1
    b -= 1
    tree[a].remove(b)
    tree[b].remove(a)
    bit = [0 for _ in range(n)]
    dfs(a)
    if bit.count(1) !=n:
        ans += 1

    tree[a].append(b)
    tree[b].append(a)
print(ans)
w, h, x, y, r= map(int, raw_input().split())
if (w - r => x => r) and (h - r => y => r):
	print 'Yes'
else:
	print 'No'

### FIXED CODE ###

w, h, x, y, r= map(int, raw_input().split())
if (r <= x <= w-r) and (r <= y <= h - r):
	print 'Yes'
else:
	print 'No'
a,b,k = map(int,input().split())
s = list(range(a,b+1))
ans = [s[i] for i in range(len(s)) if i < k or i > (len(s) - k -1)]
for i in ans:
    print(i)

### FIXED CODE ###

a, b, k = map(int,input().split())
if b-a+1 >= 2*k:
    aa = [a+i for i in range(k)]
    bb = [b-i for i in range(k)]
    cc = sorted(aa+bb)
    for s in cc:
        print(s)
else:
    for s in range(a,b+1):
        print(s)
X,A,B = int(input()) for i in range(3)
print((X-A)%B)

### FIXED CODE ###

X = int(input())
A = int(input())
B = int(input())
print((X-A)%B)
a,b=map(int,input().split())
print(math.ceil((b-1)/(a-1)))


### FIXED CODE ###

import math
a,b=map(int,input().split())
c=a-1
d=b-1
print(math.ceil(d/c))
class Stack:
  def __init__(self):
    self.count = 1
    self.lst = []
  
  def push(self, element):
    if element == count:
      self.lst.append(element)
      self.count += 1
  
  def length(self):
    return len(self.lst)

n = int(input())
a = list(map(int, input().split()))
stack = Stack()
for i in a:
  stack.push(i)

b = stack.length()
if b == 0:
  print('-1')
else:
  print(n - b)

### FIXED CODE ###

class Stack:
  def __init__(self):
    self.count = 1
    self.lst = []
  
  def push(self, element):
    if element == self.count:
      self.lst.append(element)
      self.count += 1
  
  def length(self):
    return len(self.lst)

n = int(input())
a = list(map(int, input().split()))
stack = Stack()
for i in a:
  stack.push(i)

b = stack.length()
if b == 0:
  print('-1')
else:
  print(n - b)
N = int(input())
A = list(map(int,input().split()))
ave = A/N
ans = 0
sa = 10**9
for i in range(N):
    t = i+1
    x = max(A[i]-ave,ave-A[i])
    if x < sa:
        sa = x
        ans = t
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ave = sum(A)/N
ans = 0
sa = 10**9
for i in range(N):
    x = max(A[i]-ave,ave-A[i])
    if x < sa:
        sa = x
        ans = i
print(ans)
import sys
from heapq import heappush, heappop

na = lambda: map(int, sys.stdin.readline().split())

n, m = na()
ab = [list(na()) for _ in range(n)]

ans = 0
h = []
for day in range(1, m+1):
  d = 0
  for i in range(len(ab)):
    if ab[i-d][0] <= day:
      heappush(h, -ab.pop(i-d)[1])
      d += 1
  ans += -heappop(h)

print(ans)

### FIXED CODE ###

import sys
from heapq import heappush, heappop
from operator import itemgetter

na = lambda: map(int, sys.stdin.readline().split())

n, m = na()
ab = [list(na()) for _ in range(n)]
ab.sort(key=itemgetter(0))

ans = 0
p = 0
h = []
for day in range(1, m+1):
  for i in range(p, len(ab)):
    if ab[i][0] <= day:
      heappush(h, -ab[i][1])
      p += 1
    else:
      break
  if h:
    ans += -heappop(h)

print(ans)
a,b=(int(input().split()))
c=a*b
d=a+b
e=a-b
print(max(c,d,e))


### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
c=a*b
d=a+b
e=a-b
print(max(c,d,e))