peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i], B[i] = map(int, input().split())

def f(n):
  AB = list(zip(A, B))
  AB.sort()
  return AB[n]

if N%2==0:
  a1, b1 = f(N//2-1)
  a2, b2 = f(N//2)
  print((b1+b2)-(a1+a2)+1)
else:
  a, b = f(N//2)
  print(b-a+1)
# Judge status: Accepted
K, X = map(int, input().split())
list = [X]
for i in range(1,K):
    list.append(X+i)
    list.append(X-i)
print(*sorted(list))
# Judge status: Accepted
print(2 * 3.141592653589793 * int(input()))
# Judge status: Wrong Answer
n = input()
l = map(int,raw_input().split())
mxs = 10**9


for i in range(max(l)):
    sm = 0
    for j in l:
        sm += (j-i)**2
    if sm<mxs:
        mxs = sm
print mxs
# Judge status: Wrong Answer
x = input("")
if "x".islower():
    print("a")
else:
        print("A")
# Judge status: Wrong Answer
import itertools
N, M, X = map(int, input().split())
a = [list(map(int, input().split())) for i in range(N)]
li = []
for i in range(N+1):
    for j in itertools.combinations(range(N), i):
        sm = [0] * (M+1)
        for k in j:
            for l in range(M+1):
                sm[l] += a[k][l]
        if all(y >= X for y in sm[1:M+1]):
            li.append(sm[0])
if li == []:
    print(-1)
else:
    print(min(li))
print(li)
# Judge status: Accepted
K, A, B = list(map(int, input().split()))
if A >= B - 1 or A + 1 > K:
    res = K + 1
else:
    K -= A + 1
    t = int(K / 2)
    res = (t + 1) * B - t * A + K % 2
print(res)
# Judge status: Accepted
N = int(input())
L = [int(a) for a in input().split()]
maxL = max(L)
excep = sum(L)-maxL
if maxL<excep:
    print('Yes')

else:
    print('No')
# Judge status: Accepted
import sys

A,B,C,D=list(map(int,input().split()))

while (A>0 or C>0):
    C-=B

    if C <= 0:
        ans='Yes'
        break;

    A-=D

    if A <= 0:
        ans='No'
        break;

print(ans)
# Judge status: Accepted
n = int(input())
s = input()

count = 0
for i in range(n):
    if(s[i] == "R"):
        count += 1

count2 = 0
for i in range(count):
    if(s[i] == "W"):
        count2 += 1

print(count2)
# Judge status: Accepted
q,h,result,d = map(int,input().split())
n = int(input())
result = min(q*4, h*2,result)
print(min(result*n, n//2*d + (n%2)*result))
# Judge status: Wrong Answer
N = int(input())
l = list(map(int,input().split()))
l_ans = [[] for _ in range(100)]

for i in range(100):
    sum = 0

    for j in range(N):
        sum = sum + (i+1-l[j])**2

    l_ans[i] = sum

print(min(l_ans))
# Judge status: Accepted
n=int(input())
i=0
while not 2**i<=n<2**(i+1):
    i+=1
print(2**i)
# Judge status: Accepted
import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
memo = [0] * n
for i in range(q):
    a = int(input())
    memo[a - 1] += 1
for i in range(n):
    if k - (q - memo[i]) > 0:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
N = int(input())
print((N-1)//2+1)
# Judge status: Accepted
def main():
    n = int(input())
    total = 0
    for i in range(1,n+1):
        if i % 3 == 0 and i % 5 == 0:
            pass
            #print("FizzBuzz")
        elif i%3 == 0:
            pass
            #print("Fizz")
        elif i%5 == 0:
            pass
            #print()
        else:
            total += i
    print(total)



if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N,M=map(int,input().split())
X=sorted(set(list(map(int,input().split()))))
Y=[]
for i in range(M-1):
    y=X[i+1]-X[i]
    Y.append(y)
print(sum(sorted(Y)[:-(N-1)]))
# Judge status: Accepted
def main():
  string = input()
  flg=0
  while len(string)!=0:
    if(string.count(string[0])%2==0):
      string=string.replace(string[0],'')
    else:
      flg=1
      break
  if flg==0:
    print('Yes')
  else:
    print('No')  
main()
# Judge status: Wrong Answer

def main():
  N = input()
  N_sum = 0
  
  if N == str(0):
    print("No")
    exit()
  
  for i in N:
    N_sum += int(i)
    
  if N_sum // 9 == 0:
    print("Yes")
  else:
    print("No")
  
if __name__ == "__main__":
  main()
# Judge status: Accepted
S = input()
l = len(S)
count = 0
for i in range(l//2):
    if S[i] != S[-1-i]:
        count += 1
print(count)
# Judge status: Accepted
a, b, c, d = map(int, input().split())

max_min = max(a, c)
min_max = min(b, d)

if min_max - max_min > 0:
  print(min_max - max_min)
else:
  print(0)
# Judge status: Accepted
a, b, k = map(int, input().split())

cnt = 0
for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        break

print(i)
# Judge status: Accepted
a=list(map(int,input().split()))
if a[1]>=a[0]:
    print('unsafe')
else:
    print('safe')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
B=[]
for i,ai in enumerate(a,start=1):
  B.append(ai-i)
c=sorted(B)
b=c[len(c)//2]

ans=0
for i in B:
  ans+=abs(i-b)
print(ans)
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
S = input()
for i in range(A-1,max(C,D)-1):
    if S[i] == '#' and S[i+1] == '#':
        print('No')
        exit()
if D < C:
    for i in range(B-2,N-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()
        if i+1 == D-1:
            break
    print('No')
    exit()
else:
    print('Yes')
    exit()
# Judge status: Accepted
import math
X = int(input())
res = 1
for i in range(2, int(math.sqrt(X)) + 1):
    j = 2
    while i ** j <= X:
        j += 1
    res = max(res, i ** (j - 1))
print(res)
# Judge status: Accepted
import sys
from fractions import gcd
input = sys.stdin.readline

def lcm(x, y):
    return (x * y) // gcd(x, y)
def main():
    n = int(sys.stdin.readline())
    a = list(map(int,input().split()))
    
    l = a[0]
    for i in range(n):
        l = lcm(l, a[i])
    sum = 0
    for i in range(n):
        sum += l // a[i]
    print(sum % 1000000007)
main()
# Judge status: Wrong Answer
n, x = map(int, input().split())
x_s = list(map(int, input().split()))

x_s.append(x)
x_s.sort()
sub = []
for i in range(n):
    sub.append(x_s[i+1]-x_s[i])

print(min(sub))
# Judge status: Wrong Answer
import sys
r,g,b = map(int,input().split())
k = int(input())
#青＞緑＞赤
count = 0
if g*(2**k)>r:
    while g<r:
        g*=2
        count += 1
else:
    print("No")
    sys.exit(0)

if b*(2**(k-count))>g and k<=count:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N,M = map(int,input().split())

if (N == 1 and M == 1):
    print(1)
    exit()
elif N == 1:
    if M == 2:
        print(1)
    else:
        print(M-2)
elif M == 1:
    if N == 2:
        print(1)
    else:
        print(N-2)
else:
    print((N-2)*(M-2))
# Judge status: Accepted
n = int(input())
h = list(map(int,input().split()))
check = True
for i in range(1,n):
    if h[i] >= h[i-1]:
        continue
    elif h[i] + 1 == h[i-1]:
        h[i] += 1
    else:
        check = False
        break
print("Yes" if check else "No")
# Judge status: Accepted
S = input()
N = len(S)

dp = [0 for _ in range(N)]

dp[0] = 1
dp[1] = 2 if S[0] != S[1] else 1

for i in range(2, N):
    if S[i] != S[i - 1]:
        dp[i] += dp[i - 1] + 1
    else:
        dp[i] += dp[i - 3] + 2

print(dp[-1])
# Judge status: Wrong Answer
n,k = map(int,input().split())
dk = [1,k,float("inf")]
ans = 0

while k > 2:
    k /= 2
    dk.append(int(-(-k//1)))
    
dk = sorted(dk)[::-1]
    
for i in range(len(dk)-1):
    num = min(dk[i],n) - dk[i+1] + 1*(min(dk[i],n)==dk[i+1])
    
    if num < 1:
        num = 0
        
    ans += num/n * (0.5**i)
    
print(ans)
# Judge status: Accepted
s=list(input())
l=list(chr(i)for i in range(97,123))
for i in l:
    if i not in s:
        print(i)
        exit()
print('None')
# Judge status: Wrong Answer
s = input()
a = s.count("a")
b = s.count("b")
c = s.count("c")
k = (a > 0) + (b > 0) + (c > 0)
if k == 1:
  print("NO")
  exit()
if k == 2:
  if len(s) == 2:
    print("YES")
  else:
    print("NO")
  exit()
minabc = sorted([a, b, c])[0]
a = max(0, a - minabc)
b = max(0, b - minabc)
c = max(0, c - minabc)
# print(a, b, c, k)
if a <= 1 and b <= 1 and c <= 1:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
import fractions
from functools import reduce

mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
a = list(map(int, input().split()))
a_ = []
for i in range(n):
    a_.append(pow(a[i], mod - 2, mod))

num_lcm = lcm(*a) % mod
ans = 0
for i in range(n):
    ans = (ans + num_lcm * a_[i]) % mod

print(ans)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())
if abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N,M = map(int, input().split()) 
A = list(map(int, input().split()))
S =sum(A)

if N-S >=0:
    print(N-S)
else: print("-1")
# Judge status: Accepted
n = int(input().strip())
a = list(map(int, input().split()))
b = [(a[i] - (i + 1)) for i in range(n)]
b.sort()
mid = 0
if n == 1:
    mid = b[0]
elif n % 2 == 1:
    mid = b[(n - 1) // 2]
else:
    mid = (b[(n - 1) // 2] + b[(n - 1) // 2 + 1]) // 2
ans = 0
for i in range(n):
    ans += abs(b[i] - mid)
print(ans)
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

k = sum(b) - sum(a)
m = [(max(a[i], b[i])+(a[i]<b[i] and (b[i]-a[i])%2==1)) for i in range(n)]
if k>=0 and sum(a)+2*k>=sum(m) and sum(b)+k>=sum(m):
    ans = "Yes"
else:
    ans = "No"
print(ans)
# Judge status: Wrong Answer
data=list(map(int,input().split()))
if data[0]/data[1]<=data[2]:
    print('yes')
else:
    print('No')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ans = [1] * n
check = [False] * n
check[0] = True
for i in range(m):
  x, y = map(int, input().split())
  if check[x - 1]:
    ans[y - 1] += 1
    ans[x - 1] -= 1
    check[y - 1] = True
  if ans[x - 1] == 0:
    check[x - 1] = False
print(check.count(True))
# Judge status: Accepted
N = int(input())
T = [0]*N

for i in range(1, N+1):
    for j in range(i-1, N, i):
        T[j]+=1

res = 0
for i in range(i):
    k = i+1
    res += k*T[i]

print(res)
# Judge status: Accepted
s = input()
K = int(input())

ans = []
for ch in s:
    v = ord("a") + 26 - ord(ch)
    if ch != "a" and v <= K:
        K -= v
        ans.append("a")
    else:
        ans.append(ch)

if K > 0:
    ans[-1] = chr(ord(ans[-1]) + K % 26)
print("".join(ans))
# Judge status: Accepted
n = int(input())
init = [int(s) for s in input().split()]

a = {}
init_sum = sum(init)

for i in init:
    if i not in a:
        a[i] = 1
    else:
        a[i] += 1

q = int(input())

ans = init_sum
for _ in range(q):
    (b, c) = [int(s) for s in input().split()]

    if b not in a:
        a[b] = 0

    ans -= (b * a[b])

    if c not in a:
        a[c] = a[b]
    else:
        a[c] += a[b]

    ans += (c * a[b])

    a[b] = 0

    print(ans)
# Judge status: Accepted
rating = int(input())
print(10 - rating // 200)
# Judge status: Accepted
import fractions
from functools import reduce

N,M = map(int,input().split())
A = list(set((map(lambda x : int(x) // 2,input().split()))))

def lcm(a,b):
  return (a * b) // fractions.gcd(a, b)
def gcd_list(numbers):
  return reduce(fractions.gcd, numbers)
def lcm_list(numbers):
  return reduce(lcm, numbers, 1)

LCM = lcm_list(A)
ans = (M // LCM + 1) // 2

for a in A[1:]:
  if (LCM // a) % 2 == 0:
    ans = 0
    break
    
print(ans)
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))
xor = 0
for a in A:
    xor ^= a
for a in A:
    for i in range(20):
        if xor >> i & 1:
            a ^= 1 << i
    print(a, "", end="")
# Judge status: Accepted
D=int(input())
if D==25:
  print('Christmas')
elif D==24:
  print('Christmas Eve')
elif D==23:
  print('Christmas Eve Eve')
else: 
  print('Christmas Eve Eve Eve')
# Judge status: Wrong Answer
a,b,c,d=map(int,raw_input().split())
if c-a < d or a-c<d:
  print "Yes"
elif a-b <d or b-a<d and b-c <d or c-b <d:
  print "Yes"
else:
  print "No"
# Judge status: Wrong Answer
import math
N = int(input())

power = math.factorial(N)
result = power % (pow(10, 9) + 7)
print(result)
# Judge status: Wrong Answer
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b_list = [int(input()) for _ in range(n)]

card = [[0] * 3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b_list:
            card[i][j] = 1

for i in range(3):
    if card[i][:] == [1,1,1] or card[:][i] == [1,1,1]:
        print('Yes')
        exit()
if sum([card[0][0], card[1][1], card[2][2]]) == 3 or sum([card[0][2], card[1][1], card[2][0]]) == 3:
    print('Yes')
    exit()
print('No')
# Judge status: Accepted
A, B = map(int, input().split())

for i in range(100):
    if 1 + (A-1) * i >= B: break
print(i)
# Judge status: Accepted
import math
a,b,c,d=map(int,input().split())
ans=""
for i in range (c-a):
    ans+="R"
for i in range (d-b):
    ans+="U"
for i in range (c-a):
    ans+="L"
for i in range (d-b):
    ans+="D"
ans+="D"
for i in range (c-a+1):
    ans+="R"
for i in range (d-b+1):
    ans+="U"
ans+="LU"
for i in range (c-a+1):
    ans+="L"
for i in range (d-b+1):
    ans+="D"
ans+="R"
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = [list(input())[: -1] for _ in range(N)]
b = [list(input())[: -1] for _ in range(M)]
for i in range(N - M + 1):
  for j in range(N - M + 1):
    for y in range(M):
      for x in range(M):
        if a[i + y][j + x] != b[y][x]: break
      else: continue
      break
    else:
      print("Yes")
      exit(0)
print("No")
# Judge status: Wrong Answer
d = int(input())
if d == 25:
    print('Christmas')
elif d == 24:
    print('Christmas Eve')
elif d == 23:
    print('Chritsmas Eve Eve')
elif d == 22:
    print('Christmas Eve Eve Eve')
# Judge status: Accepted
week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "GOMI"]
d = {v: i for i, v in enumerate(week[::-1])}
print(d[input()])
# Judge status: Accepted
s=int(input())
a=[]
a.append(s)
k=0
while True:
    if a[k]%2==0:a.append(a[k]//2)
    else:a.append(3*a[k]+1)
    k+=1
    for i in range(k):
        if a[i]==a[k]:
            print(k+1)
            exit()
# Judge status: Wrong Answer
S = input()
T = input()
res = []

ok = -1
for i in range(len(S) - len(T) + 1):
    if S[i] == T[0] or S[i] == "?":
        for j in range(len(T)):
            if S[i + j] not in ("?", T[j]):
                break
        else:
            s = S[:i] + T + S[i + len(T):]
            res.append(s.replace("?", "a"))

if res:
    print(*res)
else:
    print("UNRESTORABLE")
# Judge status: Accepted
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input().rstrip())
a=[int(i) for i in input().split()]
cumxor1=[0]
cumxor2=[0]
ans=[]
for i in a:cumxor1.append(cumxor1[-1]^i)
for i in reversed(a):cumxor2.append(cumxor2[-1]^i)
cumxor2=list(reversed(cumxor2))
for i in range(n):
    ans.append(cumxor1[i]^cumxor2[i+1])
print(*ans)
# Judge status: Wrong Answer
D=int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last_day = [0]*26

def calc_sum(day,t,sum):
  sum += s[day-1][t-1]
  last_day[t-1]=day
  for j in range(len(c)):
    sum -= c[j]*(day-last_day[j])
  return sum

score = 0
for i in range(D):
  t = 1
  max = 0
  for j in range(26):
    if(max > calc_sum(i,j,score)):
      score = max
      t = j
  print(t)
# Judge status: Accepted
N = int(input())
S = {}
c = 0
for _ in range(N):
	s = input()
	if s not in S:
		S[s] = 1
	else:
		S[s] += 1
	c = max(c, S[s])
ans = []
for k, v in S.items():
	if v == c:
		ans.append(k)
ans.sort()
for a in ans:
	print(a)
# Judge status: Accepted
n, m, x, y = map(int, input().split())
x = list(map(int, input().split())) + [x]
y = list(map(int, input().split())) + [y]

if max(x)<min(y):
    print('No War')
else:
    print('War')
# Judge status: Wrong Answer

A, B = map(int, input().split())

A_, B_ = A, B
common = 1
n_max = int(min(A,B)**0.5) + 1
for n in range(2, n_max):
    while True:
        if (A_ % n == 0) and (B_ % n == 0):
            common *= n
            A_ = A_ // n
            B_ = B_ // n
        else:
            break
print(common* A_ * B_)
# Judge status: Wrong Answer
from math import log2
X,Y = [int(i) for i in input().split()]
print(int(log2(Y) - log2(X))+1)
# Judge status: Accepted
l,r=map(int,input().split())
if r-l>=2019: print(0)
else:
    ans=2018
    mod_l=l%2019
    mod_r=r%2019
    for i in range(min(mod_l,mod_r),max(mod_l,mod_r)+1):
        for j in range(i+1,max(mod_l,mod_r)+1):
            mod=(i*j)%2019
            if mod<ans: ans=mod
    print(ans)
# Judge status: Accepted
N = int(input())
A = [int(input()) for _ in range(N)]
pushed = [False] * N
pushed[0] = True
button = 0
count = 0
while True:
    count += 1
    button = A[button] - 1
    if button == 1:
        print(count)
        exit()
    if pushed[button]:
        print(-1)
        exit()
    pushed[button] = True
# Judge status: Wrong Answer
n=int(input())
List = [input() for i in range(n)]
set(List)
print(len(List))
# Judge status: Wrong Answer
n = int(input())
aa =list(map(int, input().split()))

list1 =[0] * n
list1[0] = 1

if n >1:
  list1[1] = 1

for i in range(2,n):
  if list1[i-2] == list1[i-1]:
    if (aa[i] - aa[i-1]) * (aa[i-1] -aa[i-2]) < 0:
      list1[i] = list1[i-1] + 1
    else:
      list1[i] = list1[i-1]
  else:
    list1[i] = list1[i-1]
    
print(list1[n-1])
# Judge status: Accepted
s=input()
n=len(s)
ans=0
for i in range(n//2):
  if s[i]!=s[n-1-i]:
    ans+=1
print(ans)
# Judge status: Accepted
s = input()
if "AB" in s or "BA" in s:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
arr=list(map(int,input().split()))
ma=0
ans=0
for i in range(1,n):
    if arr[i]<arr[i-1]:

        ans+=arr[i-1]-arr[i]
        arr[i] = arr[i - 1]
print(ans)
# Judge status: Accepted
n = eval(input().replace(" ","*"))
print("Odd" if n%2 else "Even")
# Judge status: Accepted
a,b=map(int,input().split());print(['Yay!',':('][a>8 or b>8])
# Judge status: Accepted
import sys , math

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

X = A[0]
for i in range(1,N):
    X = X ^ A[i]

ans = [ X ^ A[i] for i in range(N) ]
print( *ans )
# Judge status: Wrong Answer
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
i = A.index(1)
print(math.ceil(i/(K-1))+math.ceil((N-1-i)/(K-1)))
# Judge status: Accepted
X=int(input())
a=X//500
b=(X%500)//5
print(a*1000+b*5)
# Judge status: Wrong Answer
A, B = map(int, input().split())
if A%B == 0:
  print((A + B)//2)
else:
  print('IMPOSSIBLE')
# Judge status: Accepted
import math 
A,B,H,M = map(int, input().split())

hour = H*0.5*60
mini = M*5.5
d = abs(hour-mini)
ans = A**2 + B**2 - 2 * A * B * math.cos(math.radians(d))
print(math.sqrt(ans))
# Judge status: Wrong Answer
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
for i in range(n-k):
    if t[k+i] == t[i]:
        t[k+i] == 0
x = t.count("r")*p+ t.count("s")*r+ t.count("p")*s
print(x)
# Judge status: Wrong Answer
N, K = map(int,input().split())
P = list(map(int,input().split()))
P_sorted = sorted(P)
print(P_sorted)
ans = 0
for i in range(K):
    ans += P_sorted[i]
print(ans)
# Judge status: Accepted
import os, sys, re, math

N = int(input())
d = [int(n) for n in input().split()]

d = sorted(d)
m1 = d[N // 2 - 1]
m2 = d[N // 2]
print(m2 - m1)
# Judge status: Wrong Answer
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.buffer.readline())
    S = sys.stdin.buffer.readline().decode()

    ret = []
    for s in S:
        n = ord(s) + N
        if n > 90:
            ret.append(chr(n - 26))
        else:
            ret.append(chr(n))

    print("".join(ret), end="")


if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c,d=map(int,input().split())
if abs(a-c)<=d:
  print("Yes")
elif abs(a-b)<=d and abs(b-c)<=d:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a,b,c = map(int,input().split())
print('Yes' if c >= a and c <= b else 'No')
# Judge status: Accepted
def solve(x, n, p):
    S = set(p)
    for d in range(n+1):
        for y in [x-d, x+d]:
            if not y in S:
                return y

x, n = map(int, input().split())
p = list(map(int, input().split()))
print(solve(x, n, p))
# Judge status: Accepted
n,m = list(map(int,input().split()))
x = n//2
y = n//2+1

temp_used = [0] * (n+1)

for i in range(m):
    print("{x} {y}".format(x=x,y=y))
    temp_used[y-x]+=1
    temp_used[n+x-y]+=1
    x-=1
    y+=1
    if temp_used[y-x]==1 or temp_used[n+x-y]==1 or y-x==n/2:
        y+=1

print("")
# Judge status: Wrong Answer
k = int(input())
ans = 0

def lunlun(ans):
    a = True
    c = len(str(ans))
    for i in range(c-1):
        r1 = ans % 10
        ans = int(ans/10)
        r2 = ans % 10
        if abs(r1-r2) > 1:
            a = False
    return a

while k > 0:
    ans += 1
    if lunlun(ans):
        k -= 1
# Judge status: Wrong Answer
import sys
S = input()


for i in range(len(S)):
    print((S[:i]))
    for j in range(i,len(S)):
        
        if "keyence" == (S[:i]) + (S[j:]):
            print("YES")
            sys.exit()

print("NO")
# Judge status: Accepted
from collections import deque

s = input()
a = deque()
for i in s:
  a.append(i)
q = int(input())
rev = 0
for i in range(q):
  s = input()
  if s[0] == '1':
    rev ^= 1
  else:
    b = (int(s[2]) - 1) ^ rev
    if b:
      a.append(s[4])
    else:
      a.appendleft(s[4])
if rev:
  a.reverse()
for i in a:
  print(i, end="")
# Judge status: Wrong Answer
L,R,d=map(int,input().split())
if R%d!=0:
    print(int(R/d)-int(L/d))
else:
    print(int(R/d)-int(L/d)+1)
# Judge status: Accepted
n,k = map(int,input().split())
p = list(map(int,input().split()))

ans = sum(p[:k])/2 + k/2
s = ans

for i in range(n-k):
    s = s - p[i]/2 + p[i+k]/2
    ans = max(ans,s)
print(ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
P = list(map(int, input().split()))

P.sort()

sum(P[0:k])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

cnt1 = 0
for i in range(8):
  v1 = i * 400
  v2 = (i + 1) * 400 - 1
  for j in range(N):
    if v1 <= A[j] and A[j] <= v2:
      cnt1 += 1
      break

cnt2 = 0
for i in range(N):
  if A[i] >= 3200:
    cnt2 += 1

if cnt1 == 0:
  print(1, cnt2)
else:
  print(cnt1, cnt1 + cnt2)
# Judge status: Wrong Answer
N = int(input()) 
num = N // 11
res = 0
k = 0
k = res * 11
if N % 11 == 0:
  res = num * 2
else:
  res = num * 2 + 1
  k += 5
  if k < N:
    res = num * 2 + 1
    k += 6
print(res)
# Judge status: Wrong Answer
a=input()
n=['SUN','MON','TUE','WED','THU','FRI','SAT']
if a!='SAT':
  print(7-n.index(a))
else:
  print(7)
# Judge status: Wrong Answer
def main():
    A, B, T = map(int, input().split())
    print(((T+0.5)//A) * B)

    return 0


if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    pair = [0, 0]
    dic = defaultdict(int)

    for a in A:
        if dic[a]:
            pair.append(a)
            dic[a] = 0
        else:
            dic[a] = 1

    pair.sort()
    print(pair[-1] * pair[-2])


if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
    S = input()
    T = input()

    ans = 10**4
    for i in range(len(S)-len(T) + 1):
        count = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                count += 1

        if ans > count :
            ans = count 

    if ans == 10**4:
        print(len(T))
    else:
        print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    if a[i] == ans:
        ans += 1
print(n-ans+1 if ans != 1 else -1)