peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def judge(A,B,n,m):
    C = []
    for i in range(n-m+1):
        for j in range(n-m+1):
            C = [A[i+k][j:m+j] for k in range(m)]
            if B == C:
                return True
    return False

def main():
    N,M = map(int,input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]

    if judge(A,B,N,M):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a, b = map(int, input().split())

n = a
ans = 1

while n < b:
    n += a - 1
    ans += 1
    
print(ans)
# Judge status: Accepted
n,m,k = map(int, input().split())
ans = "No"
for i in range(n+1):
    for j in range(m+1):
        l = i*(m-j) + (n-i)*j
        if k==l:
            ans ="Yes"
        else:
            continue
print(ans)
# Judge status: Wrong Answer
N =int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for i in range(N):
  if AB[-1][0]%AB[-1][1]==0:
    push = 0
  else:
    push = (AB[-1][1] - (AB[-1][0]%AB[-1][1]))
  ans += push
  for j in range(len(AB)):
    AB[j][0] += push
  print(i,ans,push,AB)
  AB.pop()
print(ans)
# Judge status: Accepted

S = input()

if set(S) == set("abc"):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
ABC = list(map(int, input().split()))

ABC.sort()
for i in ABC:
    if i % 2 == 0:
        print(0)
        break
else:
    print(ABC[0] * ABC[1])
# Judge status: Accepted
n = int(input())
print((n*(n-1))//2)
# Judge status: Accepted
from heapq import heapify, heappop, heappush
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    a[i] *= -1
heapify(a)
#print(a)
for i in range(m):
    maxa = heappop(a)
    heappush(a, math.ceil(maxa/2))
#print(a)
print(-(sum(a)))
# Judge status: Accepted
N = int(input())

if N%2!=0:
  print(0)
else:
  cnt = 0
  n = N//2
  k = 5
  while(n//k != 0):
    cnt += n//k
    k*=5
  print(cnt)
# Judge status: Accepted
N = int(input())
sumN = sum(int(digit) for digit in str(N))
if sumN%9 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x, a, b = map(int, input().split())
if abs(x - a) > abs(x - b):
    print("B")
else:
    print("A")
# Judge status: Accepted
import sys, math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N, K = map(int,input().split())
    D = set(input().split())
    for ans in range(N,1000000):
        f = 0
        for e in str(ans):
            if e in D:
                f = 1
                break
        if f == 0:
            print(ans)
            exit(0)
if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
    a,b,c,d = map(int, input().split())
    print(max([a*c, a*d, b*c, b*d]))


if __name__ == '__main__':
    main()
# Judge status: Accepted
O=input("")
E=input("")
s=[]
lo=len(O)
le=len(E)
if(lo<le):
    p=lo
else:
    p=le
for i in range(p):
    s.append(O[i])
    s.append(E[i])

if(lo==le):
    print(''.join(s))
elif(lo<le):
    s.append(E[le-1])
    print(''.join(s))
else:
    s.append(O[lo-1])
    print(''.join(s))
# Judge status: Accepted
n=int(input())
if n==7 or n==5 or n==3:

    print("YES")
else:
    print("NO")
# Judge status: Accepted
n = int(input())

ans=10**9+7
for i in range(1,n):
    tmp=list(str(i)) + list(str(n-i))
    tmp=[int(i) for i in tmp]
    ans=min(ans, sum(tmp))

print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
py = [list(map(int, input().split())) for i in range(m)]
py = [[py[i][0], py[i][1], i] for i in range(m)]
py = sorted(py)
p_list = [1 for _ in range(n+1)]
result = []
for i in range(m):
    result.append([py[i][2], py[i][0], p_list[py[i][0]]])
    p_list[py[i][0]] += 1
result = sorted(result)
for a, b, c in result:
    print("{:06}{:06}".format(b, c))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=[i**2 for i in a]
#sum_=sum(b)-2*p*sum(a)+n*p**2
c=sum(a)
def tai(p):
    return n*p**2-2*p*c
d=[]
for i in range(min(a)-2,max(a)+2):
    d.append(tai(i+1))
print(min(d)+sum(b))
# Judge status: Accepted
s,_,*q=open(0)
a=['','']
p=1
for q in q:
  p^=q[0]<'2'
  a[(q<'2 2')^p]+=q[-2]*(q[0]>'1')
print(a[p^1][::-1]+s[:-1][::p or-1]+a[p])
# Judge status: Accepted
MOD = 998244353
N = int(input())
D = list(map(int, input().split()))
if D[0] != 0:
    print(0)
    exit()
D_2 = [0]*(max(D)+1)
for i in D:
    D_2[i] += 1
if D_2[0] != 1:
    print(0)
    exit()
ans = 1
for i in range(1,max(D)+1):
    ans *= D_2[i-1]**D_2[i]
    ans %= MOD
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = int(input())
j = n % 500
if (j <= a):
  print("YES")
else:
  print("NO")
# Judge status: Accepted
#b
n,l=map(int, input().split())
result = 0
if l > 0:
    for i in range(n-1):
        result += i+l+1
elif l + n > 0:
    for i in range(n):
        result += i+l
else:
    for i in range(n-1):
        result += i+l
print(result)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
ans = 0
for i in range(1,n+1):
  ans += a[i*2]
print(ans)
# Judge status: Accepted
s = input()

alphabets = 'abcdefghijklmnopqrstuvwxyz'

for i in range(len(alphabets)):
   if not alphabets[i] in s:
      print(alphabets[i])
      exit()

print('None')
# Judge status: Accepted
A,B,C = map(int,input().split())

if A + B >= C:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
if N==M:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import math
l = input().split()
N = int(l[0])
l = input().split()
A = [0] * 13
for i in l:
    index = int(i) // 400
    if index < 8:
        A[index] = 1
    else:
        A[index] += 1
x = sum(A[:8])
y = sum(A[8:])

print(max(1, x), x + y)
# Judge status: Wrong Answer
k = int(input())
if k%2==0:
  print((k//2)*2)
else:
  print(((k+1)//2)*((k-1)//2))
# Judge status: Accepted
import math
N=int(input())

ans=0
for i in range(1,N):
    ans+=(N-1)//i
print(ans)
# Judge status: Accepted
#C - Energy Drink Collector
N,M = map(int,input().split())
A_B = [tuple(map(int,input().split())) for _ in range(N)]

A_B = sorted(A_B, key = lambda x:x[1],reverse = True)
A_B = sorted(A_B, key = lambda x:x[0], reverse = False)

pay = 0
drink = M
for A, B in A_B:
    if drink <= B:
        pay += A*drink
        break
    else:
        pay += A*B
        drink -= B
print(pay)
# Judge status: Accepted
import math

a, b, n = map(int, input().split())
if (b == n):
    x = n-1
elif (b < n):
    x = b-1
elif (b > n):
    x = n

print(math.floor((a * x) / b) - (a * math.floor(x / b)))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

odd_cnt = 0
multi_4 = 0
for i in range(n):
    if a[i] % 4 == 0:
        multi_4 += 1
    elif a[i] % 2 == 1:
        odd_cnt += 1

if multi_4 + odd_cnt == n:
    print("Yes" if multi_4 >= odd_cnt - 1 else "No")
else:
    print("Yes" if multi_4 >= odd_cnt else "No")
# Judge status: Accepted
a = input()
A = int(a[0])
B = int(a[2])
C = int(a[4])

if(A==5 and B==7 and C==5):
    print('YES')
elif(A==7 and B==5 and C==5):
    print('YES')
elif(A==5 and B==5 and C==7):
    print('YES')
else:
    print('NO')
# Judge status: Accepted
lst = []
n, l = map(int, input().split())

for _ in range(n):
    lst.append(input())

res = ""
for i in range(n):
    res += min(lst)
    lst.remove(min(lst))

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

flag = False
n = len(s)
for i in range(n):
    for j in range(i,n):
        if 'keyence' == s[:i] +s[j:]:
            flag = True

if flag:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
def actual(A, B, K):
    nums = [str(x) for x in range(A, B + 1)]

    satisfied_nums = sorted(set(nums[:K] + nums[-K:]))

    return '\n'.join(satisfied_nums)

A, B, K = map(int, input().split())
print(actual(A, B, K))
# Judge status: Accepted
n, m = map(int, input().split())
for i in range(1, m+1):
    a, b = i, n-i+1
    if not n % 2 and b-a <= n//2: print(a, b-1)
    else: print(a, b)
# Judge status: Wrong Answer
N, K = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(xs[-1])
ruiseki = []

prev = xs[0]
for i in range(N-K+1):
    ruiseki.append(abs(min(xs[i:i+K]) - max(xs[i:i+K])) + abs(min(xs[i:i+K])))
print(min(ruiseki))
# Judge status: Accepted
h, n  = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

dp = [10**10] * (h+1)
dp[0] = 0

for i in range(1,h+1):
    for j in range(n):
        if(i >= ab[j][0]):
            dp[i] = min(dp[i], dp[ i - ab[j][0]]+ ab[j][1])
        else:
            dp[i] = min(dp[i], dp[0] + ab[j][1])

print(dp[h])
# Judge status: Wrong Answer
#https://atcoder.jp/contests/abc066/tasks/arc077_a
N = int(input())
N_List = list(map(str,input().split()))
if N % 2 == 0:
    ans = ''.join(reversed(N_List[1::2])) + ''.join(N_List[::2])
else:
    ans = ''.join(reversed(N_List[::2])) + ''.join(N_List[1::2])

print(ans)
# Judge status: Accepted
s = input()
li = []

for i in s:
    if i=="1":
        li.append(1)

ans = 2*min(len(li), len(s)-len(li))
print(ans)
# Judge status: Accepted
x,y=map(int,input().split())
i=x
l=False
if x==y or x%y==0:
    print(-1)
else:
    while 1<=i and i<=x*y:
        if i%x==0 and i%y!=0:
            print(i)
            l=True
            break
        else:
            i+=x
# Judge status: Accepted
n, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(0, n-1):
    if A[i] + A[i+1] > x:
        diff = A[i] + A[i+1] - x
        ans += diff
        A[i+1] = max(0, A[i+1]-diff)

print(ans)
# Judge status: Accepted
s, t = input().split()
a, b = map(int, input().split())
u = input()

if u == s:
    a -= 1

if u == t:
    b -= 1

print('%d %d' % (a, b))
# Judge status: Accepted
N = int(input())
li = []
for _ in range(N):
    li.append(int(input()))

li.sort()
if sum(li) % 10 != 0:
    print(sum(li))
else:
    for i in range(N):
        if li[i] % 10 != 0:
            print(sum(li) - li[i])
            exit()

    print(0)
# Judge status: Accepted
import sys

n = int(input())
ab = [list(map(int, i.split())) for i in sys.stdin.readlines()]
ab.sort(key=lambda x:x[1])
ans = 0
for a, b in ab:
    ans += a
    if ans > b:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
n = int(input())
s = input()
result = []
for i in range(1, n):
    a = set(list(s[:i]))
    b = set(list(s[i:]))
    result.append(len(a & b))
print(max(result))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
b[0] = 0
for i in range(1, n):
    if a[i-1] + b[i-1] > a[i]:
        b[i] = a[i-1] + b[i-1] - a[i]
    else:
        b[i] = 0
c = 0
for i in range(1, n):
    c = c + b[i]
print(c)
# Judge status: Accepted
s = str(input())
if s == 'AAA':
    print('No')
if s == 'BBB':
    print('No')
if s != 'AAA' and s != 'BBB':
    print('Yes')
# Judge status: Accepted
s = input()
if s[-1] == 's':
    s = s + 'es'
else:
    s = s + 's'
print(s)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 10 21:06:29 2020

@author: over-
"""




K,X=map(int,input().split())
if 500*K >= X:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
t = 0
S = 0
for Ai in A:
    S=S+Ai

for Ai in A:
    if Ai >= S/(4*M):
        t = t+1

if t >= M:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))
D.sort()
print(D[N//2] - D[N//2-1])
# Judge status: Wrong Answer
mod=10**9+7
l,a,b=map(int,input().split())
def C(n,k,m):
  for i in range(1,k):
    n*=(n-i)%m
    k*=(k-i)%m
  return n*pow(k,m-2,m)

ans=pow(2,l,mod)
ca=C(l,a,mod)
print(ca)
cb=C(l,b,mod)
print(cb)
print((ans-ca-cb)%mod)
# Judge status: Wrong Answer
N = int(input())
csf = [list(map(int, input().split())) for i in range(N - 1)]

for i in range(N):
    ans = 0
    for j in range(i, N - 1):
        c, s, f = csf[j]
        if ans <= s:
            ans += s - ans + c
        else:
            while ans < s:
                s += f
            ans += c
    print(ans)
# Judge status: Accepted
triangulo = input()
lados = triangulo.split()
AB = lados[0]
BC = lados[1]
area = (int(AB) * int(BC))/2
print("%.0f" % area)
# Judge status: Wrong Answer
N = int(input())
S = input()

if N % 2 == 0:
    if S[:N//2] == S[N//2:]:
        print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
def main():

    k = int(input())
    a = [0] * (10 ** 6 + 1)
    a[0] = 7 % k
    for i in range(1, k + 1):
        a[i] = (a[i - 1] * 10 + 7) % k
        if a[i] == 0:
            print(i + 1)
            exit()
    print(-1)

if __name__ == '__main__':
    main()
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())
ans = ""


ans += "U"*(ty - sy)
ans += "R"*(tx - sx)
ans += "D"*(ty - sy)
ans += "L"*(tx - sx + 1)
ans += "U"*(ty - sy + 1)
ans += "R"*(tx - sx + 1)
ans += "DR"
ans += "D"*(ty - sy + 1)
ans += "L"*(tx - sx + 1)
ans += "U"

print(ans)
# Judge status: Accepted
x = int(input())
ans  = 1
for b in range(1,32):
    for p in range(2,10):
        c = b**p
        if x >= c > ans:
            ans = c
print(ans)
# Judge status: Accepted
N = int(input())
p = list(map(int, input().split()))
P = sorted(p)

count = 0
for i in range(N):
    if p[i] != P[i]:
        count += 1
if count == 0 or count == 2:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
from collections import Counter

def check():
    S = sorted(Counter(input()).values())
    T = sorted(Counter(input()).values())
    
    for s,t in zip(S,T):
        if s !=t:
            return 'No'
    return 'Yes'
  
print(check())
# Judge status: Accepted
def f(x1, y1, x2, y2):
    return abs(x1*y2 - x2*y1)

def main():
    S = int(input())
    d = pow(10, 9)
    X1, Y1 = 0, 0
    X2, Y2 = d, 1
    X3 = (d - S%d)%d
    Y3 = (S + X3) // d
    print(X1, Y1, X2, Y2, X3, Y3)
    #print(f(X2, Y2, X3, Y3))

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = int(input())
S = {}
ans = N

for i in range(N):
    s = input()
    if s not in S:
        S[i] = s
print(len(S))
# Judge status: Accepted
import math
n, d = map(int, input().split())
x = []
cnt = 0
for i in range(n):
    l = list(map(int, input().split()))
    x.append(l)
for i in range(n-1):
    for j in range(i+1, n):
        di = 0
        for k in range(d):
            di += (x[i][k] - x[j][k]) ** 2
        if math.sqrt(di).is_integer():
            cnt += 1
print(cnt)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))

l = sum(a)
halfp = 0
for i in range(n):
    if sum(a[:i+1])>= l/2:
        halfp = i
        break

print(int((sum(a[:halfp+1])-l/2)*2))
# Judge status: Accepted
def getDigits(n):
  digits = []
  while n > 0:
    digits.append(n % 10)
    n //= 10
  return digits

def firstValidNumber(n, digits):
  while True:
    isValid = True
    currentDigits = getDigits(n)
    for digit in currentDigits:
      if digit in digits:
        isValid = False
        break
    if isValid:
      return n
    n += 1
  return n

n, k = map(int, input().split())
digits = list(map(int, input().split()))
print(firstValidNumber(n, digits))
# Judge status: Accepted
s=input()
ans=0
for i in range(len(s)//2):
    if s[i]!=s[-(i+1)]:
        ans+=1
print(ans)
# Judge status: Accepted
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  A = input()[:-1]

  E = [0]
  for a in A:
    if a == 'E':
      E.append(E[-1]+1)
    else:
      E.append(E[-1])

  min_ = float('inf')
  for i in range(N):
    min_ = min(min_, (i-E[i])+(E[N]-E[i+1]))
  print(min_)


if(__name__ == '__main__'):
  main()
# Judge status: Wrong Answer
n=int(input())
print((10**n-9**n*2+8**n)%10**9+7)
# Judge status: Accepted
N=int(input())
S=input()

x=0
ans=0
for i in range(N):
  if S[i]=='I':
    x+=1
    ans=max(ans,x)
  else:
    x -= 1
    
print(ans)
# Judge status: Accepted
a, b, x = map(int, input().split())
print(b // x - (a - 1) // x)
# Judge status: Wrong Answer
s = input()
t = 0
u = 0
if "N" in s and "S" in s:
    t = 1
if "E" in s and "W" in s:
    u = 1
if u == t == 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

a,b,c=mp()
print((a*b)//2)
# Judge status: Wrong Answer
#!/usr/bin/env python3

def main():
    *N, = map(str, open(0).read().split())
    S = N[2:]
    L = int(N[1])
    N = int(N[0])

    for i in range(0, L):
        S = sorted(S, key=lambda x: x[i])
    print(''.join(S))


main()
# Judge status: Accepted
n,m,k = [int(x) for x in input().split()]

ans = "No"
for i in range(n+1):
    for j in range(m+1):
        if i * (m-j) + j * (n-i) == k:
            ans = "Yes"
            break

print(ans)
# Judge status: Accepted
w, h, x, y = map(int, input().split())
if x == w / 2 and y == h / 2:
    print(w * h / 2, 1)
else:
    print(w * h / 2, 0)
# Judge status: Accepted
a, b = map(int, input().split())
print(len([i for i in map(str, range(a, b+1)) if i == i[::-1]]))
# Judge status: Accepted
import bisect
n = int(input())
ans = [-1*int(input())]
for i in range(n-1):
  a=int(input())
  a=-1*a
  if ans[-1]<=a:
    ans.append(a)
  else:
    b = bisect.bisect_right(ans,a)
    ans[b]=a
print(len(ans))
# Judge status: Wrong Answer
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  x=x-a[i]
  if x<0:
    x=x+a[i]
  else:
    ans+=1
a.sort(reverse=True,key=int)
ansr=0
for i in range(n-1):
  x=x-a[i]
  if x<0:
    x=x+a[i]
  else:
    ansr+=1
print(max(ans,ansr))
# Judge status: Accepted
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
H = sorted(h)
# print(H)
minH = 10 ** 9
for x in range(N - K + 1):
    sumh = H[x + K - 1] - H[x]
    # print("sumh", sumh)
    if minH > sumh:
        minH = sumh
print(minH)
# Judge status: Wrong Answer
s = list(map(int, input().split()))
ss = sorted(s)
ssr = sorted(s, reverse=True)

if s==ss or s==ssr:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
N = int(input())
T, A = input().split(' ')
T = int(T)
A = int(A)
H = input().split(' ')
H = [int(H[i]) for i in range(N)]
check = 10**9
for i in range(N):
  C = A - (T - H[i] * 0.006)
  if abs(C)<check:
    check = abs(C)
    point = i + 1
print(point)
# Judge status: Accepted
import sys

n = int(input())
s = input()
 
if n%2 == 1:
  print("No")
  sys.exit()
 
slise = (n/2)
a = s[:int(slise)]
b = s[int(slise):]
 
if a==b:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
s,w = map(int,input().split())
if s>w/2 :
  print('safe')
else:
  print('unsafe')
# Judge status: Accepted
n, m = map(int, input().split())
a = [0]*(n+1)

for i in range(m):
        l, r = map(int, input().split())
        a[l-1] += 1
        a[r] -= 1
for i in range(n): a[i+1] += a[i]

print(a.count(m))
# Judge status: Accepted
print(eval('+'.join(sorted(input()))+'*10'))
# Judge status: Accepted
import math
a,b = map(int,input().split())
print(a*b//math.gcd(a,b))
# Judge status: Accepted
#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))


n = input_one_number()
asnyan = input_multiple_number_as_list()

asnyan.sort()

b = 0
flg = True
for a in asnyan:
    if b == a:
        flg = False
    b = a

if flg:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n = int(input())
ps = list(map(int, input().split()))
ans = 0

for i in range(1,n-1):
    if sorted(ps[i-1:i+2]).index(ps[i]) == 1:
        ans += 1

print(ans)
# Judge status: Accepted
from collections import Counter

S = input()
C = Counter(S)

if len(C) == 3:
    c = min(C.values())
else:
    c = 0

for cc in C.values():
    if not (cc == c or cc == c + 1):
        print("NO")
        exit()

print("YES")
# Judge status: Accepted
n = int(input())
num = [int(i) for i in input().split()]

cont=0
ans=1

for j in num:
    if j == 0: cont+=1

if cont > 0: print(0)
else:
    for i in num:
        ans=ans*i
        if ans>1e18:
            ans=-1
            break
    print(ans)
# Judge status: Accepted
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
p = l()
count = 0
i = 0

while i < N:
    if p[i] == i+1:
        count += 1
        i += 1
    i += 1

print(count)
# Judge status: Wrong Answer
n,m = map(int,input().split())
h = input().split(" ")
hlist = [int(n) for n in h]
alist = [int(n) for n in h]
for i in range(m):
  b = input().split(" ")
  blist = [int(n) for n in b]
  if hlist[blist[0]-1]>hlist[blist[1]-1] and hlist[blist[1]-1] in alist:
      alist.remove(hlist[blist[1]-1])
  if hlist[blist[1]-1]>hlist[blist[0]-1] and hlist[blist[0]-1] in alist:
      alist.remove(hlist[blist[0]-1])
kotae = len(alist)
print(kotae)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

ans = 0
yen = 1000;kabu = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        kabu += yen // a[i]
        yen %= a[i]
    else:
        yen += a[i]*kabu
        kabu = 0
yen += a[-1]*kabu
print(yen)
# Judge status: Wrong Answer
import heapq
n,m=map(int,input().split())
t=[[0] for _ in range(m)]
for i in range(n):
    a,b=map(int,input().split())
    if a>m:
        continue
    t[a-1].append(b)
h=[]
for i in range(m):
    t[i].sort(reverse=True)
    for j in range(min(len(t[i]),m-i)):
            h.append(-t[i][j])
print(h)
heapq.heapify(h)
ans=0
for i in range(m):
    ans+=-heapq.heappop(h)
print(ans)
# Judge status: Wrong Answer
N = input()
h = int(N[0])
t = int(N[1])
o = int(N[2])

if h == t and t == o:
    print(N)
else:
    h += 1
    print(h*111)
# Judge status: Wrong Answer
x,y=map(int,input().split())
n=y//x
ct=0
while n>1:
  ct+=1
  n//=2
print(ct)
# Judge status: Accepted
n, m = map(int, input().split())

def calc_divisors(n):
    res = []
    i = 1
    while i * i <= n:
        if n % i == 0:
            res.append(i)
            res.append(n // i)
        i += 1
    res = list(set(res))
    return res

divisors = calc_divisors(m)
divisors.sort(reverse=True)

for divisor in divisors:
    if m >= n * divisor:
        print(divisor)
        break
# Judge status: Accepted
N=int(input())
print((N+1)//2)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
cnt = 0
if not 1 in a:
    print(-1)
else:
    tmp = 1
    for i in range(N):
        if a[i] == tmp:
            tmp += 1
        else:
            cnt += 1
    print(cnt)
# Judge status: Accepted
s, c = map(int,input().split())

cnt = 0
if 2*s <= c:
    cnt += s
    c -= 2*s
else:
    cnt += c // 2
    c = 0

cnt += c//4
print(cnt)
# Judge status: Accepted
import decimal
a,b,c,d=map(int,input().split())
n=int(input())
l=[a*4,b*2,c,d/2]
p=min(l)
q=min(l[:3])
print(int(decimal.Decimal(n)*decimal.Decimal(min(l))) if n%2==0 or p==q else int(decimal.Decimal(n-1)*decimal.Decimal(d/2)+q))
# Judge status: Accepted
s=input()
q=int(input())
f=0
l,r='',''
for i in range(q):
    a=list(input().split())
    if a[0]=='1':
        f+=1
    else:
        if (int(a[1])-1)^(f%2)==0:
            l+=a[2]
        else:
            r+=a[2]
if f%2==1:
    print(r[::-1]+s[::-1]+l)
else:
    print(l[::-1]+s+r)
# Judge status: Accepted
def resolve():
    a = list(map(int, input().split()))
    a = sorted(a)
    x = a[0]
    y = a[1]
    z = a[2]
    ans = z-y
    if (z-(ans+x)) % 2 == 0:
        ans += (z-(ans+x)) // 2
        print(ans)
    else:
        ans += (z - (ans + x)) // 2
        print(ans+2)
resolve()
# Judge status: Wrong Answer
from collections import Counter

n = int(input())
A = sorted(map(int, input().split()))
c = Counter(A)
flag = [False] * n
for i in range(n):
    if c[A[i]] > 1:
        flag[i] = True
    if flag[i] == False:
        for j in range(i+1, n):
            if A[j] % A[i] == 0:
                flag[j] = True
print(flag.count(False))