peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import bisect

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

N, M = cin()
l1 = [[] for i in range(N + 1)]
l2 = []
for i in range(M):
    in1, in2 = cin()
    l1[in1].append(in2)
    l2.append([in1, in2])

for i in range(N + 1):  l1[i] = sorted(l1[i])
    
for i in range(M):
    c = l2[i]
    n = bisect.bisect_left(l1[c[0]], c[1]) + 1
    ans = str(c[0]).zfill(6) + str(n).zfill(6)
    print(ans)
# Judge status: Wrong Answer
l, r, d = map(int, input().split())
diff = r - l + 1
print(int(diff / d))
# Judge status: Accepted
n = int(input())
s = list(input())

num_eas = s.count('E')


res = []
res += [num_eas - s[0].count("E")]

for i in range(1,n):
    res += [res[i-1] + s[i-1].count("W") - s[i].count("E")]
    
print(min(res))
# Judge status: Wrong Answer
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(k*x+(n-k)*y)
# Judge status: Accepted
N = int(input())
s = input()
t = input()

l = 0
c = 0
for i in range(1, N+1):
    if s[-1 * i:] == t[:i]:
        l = len(t[:i])
        c = i

print(len(s + t[c:]))
# Judge status: Accepted
import math
N, K = map(int, input().split())
*A, = map(int, input().split())
print(math.ceil((N - 1) / (K - 1)))
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
k = int(input())
x = 0
for i in range(1,k+1):
    if 2*i*b > a:
        x += i
        break
else:
    print('No')
    quit()
if 2*(k-x)*c > 2*x*b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = []
for i in range(ls-lt+1):
    for j in range(lt):
        if s[i+j] == "?":
            continue
        if s[i+j] != t[j]:
            break
    else:
        ans.append((s[:i]+t+s[i+lt:]).replace("?","a"))
ans.sort()
if ans:
    print(ans[0])
else:
    print("UNRESTORABLE")
# Judge status: Accepted
n = list(map(int,list(input())))
num = len(n)
ans = sum(n)
ans = max(ans,9*(num-1)+n[0]-1)
print(ans)
# Judge status: Accepted
def main():
    n, *abc = map(int, open(0).read().split())
    dp = [[0, 0, 0] for _ in range(n + 1)]
    for i, (a, b, c) in enumerate(zip(abc[::3], abc[1::3], abc[2::3]), 1):
        x, y, z = dp[i - 1]
        dp[i] = [a + max(y, z), b + max(z, x), c + max(x, y)]

    ans = max(dp[-1])
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if (a<b and b<c) or (a>b and b>c):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
S = list(input())
flag = 0
for i in S:
  if flag == 0:
    if i == 'L':
      print("No")
      exit()
  else:
    if i == 'R':
      print("No")
      exit()
  flag = 1 - flag
print("Yes")
# Judge status: Accepted
from collections import Counter

S = list(input())

c = Counter(S)
flag1 = False
flag2 = False
if "S" in c and "N" in c:
    flag1 = True
elif "S" not in c and "N" not in c:
    flag1 = True

if "W" in c and "E" in c:
    flag2 = True
elif "W" not in c and "E" not in c:
    flag2 = True

if flag1 and flag2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(int,input().split()))

Change = K - 1

if (N-1)%(K-1) == 0:
  print((N-1)//(K-1))
else:
  print((N-1)//(K-1)+1)
# Judge status: Wrong Answer
X,Y=map(int,input().split())
mod=pow(10,9)+7
if (X+Y)%3!=0:
    print("0")
else:
    m=int((2*X-Y)/3)
    n=int((2*Y-X)/3)
    bunsi=1
    bunbo=1
    wa=m+n
    min=min(m,n)
    for i in range(0,min):
        bunsi=(bunsi*(wa-i))%mod
        bunbo=(bunbo*(i+1))%mod
    ans=(bunsi*pow(bunbo,mod-2,mod))%mod
    print(ans)
# Judge status: Accepted
# coding: utf-8
a,b=map(int,input().split())
ans=""

for i in range(max(a,b)):
    ans+="{}".format(min(a,b))

print(ans)
# Judge status: Accepted
n=int(input())
B=[]
for i in range(n):
  x,l=map(int,input().split())
  B.append([x-l,x+l])
B.sort(key=lambda x:x[1])
max_l=-10**18-5
ans=0
for b in B:
  if max_l <= b[0]:
    max_l = b[1]
    ans+=1
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
print(min(c, b//a))
# Judge status: Wrong Answer
a = int(input())
if a < 3200:
  print('red')
else:
  print('pink')
# Judge status: Accepted
Q, H, S, D = map(int, input().split())
N = int(input())

A = min(Q*4, H*2, S)
if N % 2 == 0:
    print(min(A*N, D*N//2))
else:
    if N == 1:
        print(A)
    else:
        print(min(A*N, D*(N//2)+A))
# Judge status: Accepted
n, k = map(int,input().split())
a = [int(i) for i in input().split()]
s = []
ord = [-1] * (n+1)
c, l = 1, 0
v = 1
while (ord[v] == -1):
    ord[v] = len(s)
    s.append(v)
    v = a[v-1]
    
c = len(s) - ord[v]
l = ord[v]
print(s[k] if (k < l) else s[l + (k - l) % c])
# Judge status: Wrong Answer
N=int(input())
A=[int(input())for i in range(N)]
ans=0
prev=A[0]

for i in range(1,N):
  x=min(A[i-1],A[i])
  ans+=x
  A[i-1]-=x
  A[i]-=x
  ans+=(A[i-1]//2)
ans+=A[N-1]//2
print(ans)
# Judge status: Wrong Answer

import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n,k=get_ints()
h=get_array()
li=[99999]*n
li[0]=0

li[1]=abs(h[1]-h[0])
for i in range(2,n):
    l=max(0,i-k)
    for j in range(l,i):




            li[i]=min(li[i],li[j]+abs(h[i]-h[j]))
##print(li)
print(li[n-1])
# Judge status: Accepted
x=int(input())
y=19

ans=0
ans+=(x//11)*2
cnt=x%11
if cnt>=7:
  ans+=2
elif cnt>=1:
  ans+=1
  
print(ans)
# Judge status: Accepted
import sys
input=sys.stdin.readline
#N = int(input())
#S = input()[:-1]
N,K = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
a = N % K
b = min(a,K-a)
print(b)
# Judge status: Wrong Answer
N, K = map(int, input().split())
cnt = [0]*100001
S = set()
for i in range(N):
  a, b = map(int, input().split())
  cnt[a-1] += b
  S.add(a)

ans = 0
for s in S:
  ans += cnt[s-1]
  if ans >= K:
    print(s)
    break
# Judge status: Accepted
N = int(input())
A = []
B = []
for i in range(N):
    AB = list(map(int, input().split()))
    A.append(AB[0])
    B.append(AB[1])
A = sorted(A)
B = sorted(B)

if N % 2 == 0:
    min1 = A[N//2-1]
    min2 = A[N//2]
    max2 = B[-N//2]
    max1 = B[-N//2-1]
    # print(min1, min2, max1, max2)
    ans = ((max2 + max1) / 2 - (min2 + min1) / 2) * 2 + 1
else:
    mini = A[N//2]
    maxi = B[-N//2]
    # print(mini, maxi)
    ans = maxi - mini + 1
print(int(ans))
# Judge status: Accepted
# B - KEYENCE String
def is_keyence_string():
	for i in range(1, len(key)):
		left = key[:i]
		right = key[i-len(key):]
		
		if S.startswith(left) and S.endswith(right):
			return True
	
	return False


S = input().strip()
key = 'keyence'

if S.startswith(key):
	print('YES')
elif S.endswith(key):
	print('YES')
elif is_keyence_string():
	print('YES')
else:
	print('NO')
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

ans = "No"
for i in range(1, 1000):
    a = A*i
    if a % B == C:
        ans = "Yes"
        break
        
print(ans)
# Judge status: Accepted
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    As = [[int(item) for item in input().split()] for _ in range(N)]

    memo = [0 for _ in range(M+1)]

    for k, *items in As:
        for item in items:
            memo[item] += 1
    res = 0
    for item in memo:
        if item == N:
            res += 1

    print(res)


if __name__ == "__main__":
    resolve()
# Judge status: Accepted
new_string = input()
new_string_lentgh = len(new_string)
print(new_string_lentgh * 'x')
# Judge status: Wrong Answer
n, m = map(int, input().split())
ab = [0] * m
for i in range(m):
    ab[i] = list(map(int, input().split()))
roads = [0] * n
for a, b in ab:
    roads[a-1] += 1
    roads[b-1] += 1
print(roads)
# Judge status: Wrong Answer
N, M = list(map(int,input().split()))
A = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    A.append([in1, in2])
A = sorted(A, key = lambda x: x[1])[::-1]
ans = 0
day = M
for i in range(N):
    if A[i][0] <= day:
        ans += A[i][1]
        day -= 1
print(ans)
# Judge status: Accepted
from collections import defaultdict

n = int(input())
data = defaultdict(int)

for i in range(n):
    a = int(input())
    data[a] += 1

ans = 0
for v in data.values():
    if v % 2 == 1:
        ans += 1

print(ans)
# Judge status: Accepted
In = str(input())
Out = str(input())
cnt = 0
for i in range(len(In)):
  if In[i] != Out[i]:
    cnt += 1
    
    
print(cnt)
# Judge status: Accepted
n = int(input())
s = [int(input()) for _ in range(n)]

ss = sum(s)
ans = ss * min(1, ss % 10)

for i in range(n):
    score = ss - s[i]

    ans = max(ans, score * min(1, score % 10))

print(ans)
# Judge status: Wrong Answer
num=list(map(int,input().split()))

x=max(num)
s=sum(num)

t=(3*x-s)
ans=t//2
if t%2!=0:
    ans+1
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

def solve(N,K,A):
    ans = -(-(N-1)//(K-1))
    return ans
print(solve(N,K,A))
# Judge status: Accepted
n = list(input())

# print(n[-1])

if int(n[-1]) == 2 or int(n[-1]) == 4 or int(n[-1]) == 5 or int(n[-1]) == 7 or int(n[-1]) == 9:
  print('hon')

elif int(n[-1]) == 0 or int(n[-1]) == 1 or int(n[-1]) == 6 or int(n[-1]) == 8:
  print('pon')

else:
  print('bon')
# Judge status: Accepted
s = input()
a = []
for i in range(len(s)-2):
  a.append(abs(753 - int(s[i:i+3])))
print(min(a))
# Judge status: Wrong Answer
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = sorted(readInts())
    dic = {}
    for a in A:
        if a in dic:
            print('No')
            break
        else:
            dic[a] = 1
if __name__ == '__main__':
  main()
# Judge status: Accepted
n=int(input())
a = list(map(int,input().split()))

junban = {}

for i in range(n):
    junban[a[i]] = i

a.sort()

for i in range(n):
    ans = junban[a[i]] + 1
    print(ans)
# Judge status: Accepted
h = int(input())
if h == 0:
  print(0)
  quit()
i = 0
while True:
  if h < 2**i:
    print(2**i - 1)
    quit()
  else:
    i += 1
# I love kemofure
# Judge status: Wrong Answer
w, a, b = map(int,input().split())
if abs(b - a- w) >= abs(a - b):
    print(abs(a-b))
elif a <= b <= a+w:
    print(0)
else:
    print(abs(b - a - w))
# Judge status: Wrong Answer


a = int(input("\n"))

if a >= 10:
    print("Number too big")

elif a < 1:
    print("Number too small")
    
else:
    print(a + (a**2) + (a**3))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().rstrip().split(" ")))
ans = 0
minnow = A[0]
for i in range(1,N):
    if(minnow > A[i]):
        ans += minnow - A[i]
    else:
        minnow = A[i]
print(ans)
# Judge status: Accepted
n = int(input())
dp = [0, 0]
for c in input():
    if c == '.':
        dp[1] += 1
    else:
        dp[1] = min(dp[1], dp[0])
        dp[0] += 1
print(min(dp))
# Judge status: Wrong Answer
N = int(input())
K = list(map(int,input().split()))
A = [0]*N
print(A)
for i in range(N):
    A[K[i]-1] += 1
r = 0
for k in range(N):
    r += 0.5*(A[k]*(A[k]-1))
An =[]
for j in range(N):
    D = A[K[j]-1]-1
    An.append(int(r-(0.5*(D+1)*(D))+(0.5*D*(D-1))))
for i in range(len(An)):
    print(An[i])
# Judge status: Accepted
X = int(input())
ans = 1
for b in range(1,101):
    for p in range(2,10):
        if X >= b**p and b**p > ans:
            ans = b**p
print(ans)
# Judge status: Accepted
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = map(int, input().split())
common_divisors = set(prime_factorize(a)) & set(prime_factorize(b)) | {1}
print(len(common_divisors))
# Judge status: Accepted
a,b=map(int,input().split())
c=1
d=0
while c<b:
    d+=1
    c=a*d-(d-1)
print(d)
# Judge status: Wrong Answer
n,m = map(int,input().split())
C = [[i, list(map(int,input().split()))] for i in range(m)]
C.sort(key=lambda x:(x[1][0],x[1][1]))
D = {}
rank=1
for i in range(m):
    name=C[i][0]
    if i>1 and C[i][1][0] != C[i-1][1][0]:
        rank = 1
    D[name] = str(C[i][1][0]).zfill(6)+str(rank).zfill(6)
    rank+=1
for i in range(m):
    print(D[i])
# Judge status: Wrong Answer
a,b,x=map(int,input().split())
if(a+b==x):
   print("Yes")
elif(a==x):
    print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n, m = map(int, input().split())
print((n*2+m)//4)
# Judge status: Accepted
N = int(input())
S = input()

ans = 0
for i in range(N):
    a = S[:i]
    b = S[i:]
    c = set(list(a)) & set(list(b))
    ans = max(ans, len(c))

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

l = []

for i in range(1, 101):
    if a % i == 0 and b % i == 0:
        l.append(i)

print(l[-k])
# Judge status: Wrong Answer
n = int(input())
aList = list(map(int, input().split()))
acount = [aList.count(i)-1 for i in aList]
sums = sum(acount)
for i in acount:
    print((sums)//2 - i for i in acount)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if (a+b)%2==0:
    print((a+b)/2)
else:
    print(int((a+b)//2+1))
# Judge status: Wrong Answer
S=list(input())
print(S)
for i,j in enumerate(S):
    if i%2==0:
        
        if j=="R"or j=="U"or j=="D":
            
            continue
        else:
            print("No")
            break
    else:
        if j=="L"or j=="U"or j=="D":
            continue
        else:
            print("No")
            break
else:
    print("Yes")
# Judge status: Accepted
# C - Build Stairs

n = int(input())
h = list(int(x) for x in input().split())

ans = 'Yes'
flg = 0 #下がった状態フラグ
for i in range(1, n):
    # 2段以上下がってる場合
    if h[i-1]-h[i]>1:
        ans = 'No'
        break
    if h[i-1]-h[i]==1:
        if flg==0:
            flg = 1
        else:
            ans = 'No'
            break
    if h[i-1]-h[i]<0:
        flg = 0

print(ans)
# Judge status: Accepted
from itertools import combinations_with_replacement

def main():
    N, M, Q = map(int, input().split())
    ABCD = [list(map(int, input().split())) for i in range(Q)]
    ans = 0

    for A in combinations_with_replacement(range(M), N):
        temp = 0
        for abcd in ABCD:
            if A[abcd[1]-1]+1 == A[abcd[0]-1]+1 + abcd[2]:
                temp += abcd[3]
        if temp > ans:
            ans = temp
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import defaultdict
dic = defaultdict(int)
N,M = map(int,input().split())
A = list(map(int,input().split()))
for x in A:
  dic[x] += 1
for i in range(M):
  a,b = map(int,input().split())
  dic[b] += a

#print(dic)
L =list(dic.keys())
L.sort(reverse = True)

cnt = 0
ans = 0
for i in range(len(L)):
  val = L[i]
  #print(cnt,val,dic[val])
  if cnt + dic[val] <= N:
    cnt += dic[val]
    ans += val*dic[val]
  else:
    ans += val*(N-cnt)
    break
print(ans)
# Judge status: Wrong Answer
n= int(input())
if n%2==0:print(n/2)
else:print((n//2 +1)/n)
# Judge status: Wrong Answer
if input() in "aiueo".split():
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
from math import ceil

n = int(input())
csfl = [tuple(map(int, input().split())) for _ in range(n-1)]

for i in range(n-1):
    c,s,f = csfl[i]
    t = s+c
    for j in range(i+1,n-1):
        c,s,f = csfl[j]
        if t <= s:
            t = s
        else:
            t = ceil(t/f)*f
        t += c
    print(t)

print(0)
# Judge status: Accepted
import heapq as hq
n,m=input().split()
hq.heapify(a:=[-int(x) for x in input().split()])
for i in range(int(m)):hq.heappush(a,-(v:=-hq.heappop(a)//2))
print(-sum(a))
# Judge status: Wrong Answer
import heapq as hp
n = int(input())
if n%2 ==0:
    m = n//2 + 1
else:
    m = (n+1) //2
a,b = [],[]
for i in (0,n):
    c = list(map(int, input().split()))
    a.append(c[0])
    b.append(c[1])
print(a,b)
la = hp.nlargest(m,a)
lb = hp.nlargest(m,b)
if n%2 == 0:
    c = la[-1] + la[-2] 
    d = lb[-1] + lb[-2] 
    print(d-c+1)
else:
    print(lb[-1]//2-la[-1]//2+1)
# Judge status: Wrong Answer
import math

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

Z = math.ceil(max(x))

if X + 1 < Y and min(y) >= Z:
  print('No War')
else:
  print('War')
# Judge status: Wrong Answer
N, M = map(int, input().split())
a = min(N, M)
b = max(N, M)

if a == 1:
    print(max(0, b - 2))
elif a == 2:
    print(0)
else:
    print((a - 2) * (b - 2))
# Judge status: Wrong Answer
n=int(input())
a=[int(x) for x in input().rstrip().split()]

odd=[]
even=[]
for i in range(n):
  if (i)%2==0:
    even.append(a[i])
  else:
    odd=[a[i]]+odd

print(*(odd+even))
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
print(b//x-(a-1)//x, 0)
# Judge status: Accepted
if __name__ == "__main__":
    n = int(input())
    a = [int(x) for x in input().split()]

    if 0 in a:
        ans = 0
    else:
        mx = 10 ** 18
        ans = 1
        for ai in a:
            ans *= ai
            if mx < ans:
                ans = -1
                break
    
    print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
ans = 0
print(A)
for i in range(N):
    for j in range(N):
        ans += A[i] * A[j]
        ans = ans % (10 ^ 9 + 7)

print(ans)
# Judge status: Accepted
c,a,b=map(int,input().split())
print(c*a//2)
# Judge status: Accepted
N = int(input())
a = [110]
a = list(map(int, input().split()))
a.sort(reverse=True)
 
Alis = 0
Bob = 0
for j in range(N):
  if j % 2 == 0:
    Alis += a[j]
  else:
    Bob += a[j]
    
print(Alis-Bob)
# Judge status: Accepted
def main():
    N, M = map(int, input().split())
    ans = [1] * M
    for _ in range(N):
        A = list(map(lambda x: int(x) - 1, input().split()))[1:]
        for a in range(M):
            if a not in A:
                ans[a] = 0
    print(sum(ans))


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = int(input())
 
if N % 500 <= A: print('Yes')
else: print('No')
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
n,m=map(int,input().split())
a=list(map(int,input().split()))
if len(a)==0:
  print(n)
else:
  a.sort()
  if n not in a:
    print(n)
  else:
    cnt=0
    for i in range(100):
      if i in a:
        continue
      elif abs(cnt-n)>abs(i-n):
        cnt=i
    print(cnt)
# Judge status: Wrong Answer
import math

n=int(input())

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

count=0
isDividable=0

for i in range(n):
  isDividable=0
  l=a[i]/2
  for j in range(n):
    if i != j and a[j] <= l and a[i] % a[j] == 0:
      isDividable=1
      break
  if isDividable==0:
    count=count+1
print(count)
# Judge status: Accepted
def main():
  k = int(input())
  #s = input()
  #s = input().split()
  #a,b = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  print((k//2)*((k+1)//2))
  
if __name__ == '__main__':
  main()
# Judge status: Wrong Answer
a, b, t = map(int, input().split())
print(b*((t+0.5)//a))
# Judge status: Accepted
M=int(input())
N=list(input().split())
check=[0]*M
for i in range(M):
    check[int(N[i])-1]+=1
num=0
for i in range(M):
    num+=check[i]*(check[i]-1)//2
for i in range(M):
    if check[int(N[i])-1]!=2:
        print(num-(check[int(N[i])-1]-1))
    else:
        print(num-1)
# Judge status: Accepted
#https://atcoder.jp/contests/abc117/tasks/abc117_b
S_list = [input() for i in range(2)]
N = map(int,S_list[0].split())    
L_list = list(map(int,S_list[1].split()))

L_max = max(L_list)
L_sum = sum(L_list) - L_max
if L_sum - L_max > 0:
    result ="Yes"
else:
    result ="No"
print(result)
# Judge status: Accepted
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
count = 0
for i in range(1,N-1):
  if (A[i+1] > A[i] and A[i] > A[i-1]) or (A[i+1] < A[i] and A[i] < A[i-1]):
    count += 1
print(count)
# Judge status: Accepted
import collections
N = int(input())
a = sorted(list(map(int,input().split())))
c = collections.Counter(a)
cnt = 0
for i in c.most_common():
   # print(i)
    if i[0]<i[1]:
      cnt=cnt+i[1]-i[0]
    if i[0]>i[1]:
      cnt=cnt+i[1]
print(cnt)
# Judge status: Accepted
x=int(input())
n=1
tgt=1
Ans=0
while tgt>0:
    tgt=(360*n)%x
    Ans=(360*n)//x
    n+=1
print(Ans)
# Judge status: Accepted
def dfs(now, mx):
    if len(now) == n:
        print(now)
    else:
        for i in range(1, mx + 2):
            mmx = max(mx, i)

            dfs(now + al[i], mmx)


n = int(input())

al = ['.', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

dfs('a', 1)
# Judge status: Accepted
x = input()
li = []
sz = 0
for i in x:
    if (i == '0') or (i == '1'):
        li.append(i)
        sz += 1
    else:
        if sz > 0:
            li.pop()
            sz -= 1

for i in li:
    print(i, end="")
# Judge status: Accepted
import math
N = int(input())
ans = 10**12
for i in range(1,10**6+1):
  j = math.ceil(N/(i+1))
  if (1+i)*j == N:
    ans = min(i+j-1,ans)
  if i == 10**6 and ans == 10**12:
    ans = N-1
    break
print(ans)
# Judge status: Accepted
# 貰うDP

n = int(input())


max_n = 110000
dp = [n] * max_n

# 初期化
dp[0] = 0

for i in range(1, n + 1):
    pow6, pow9 = 1, 1
    while pow6 <= i:
        dp[i] = min(dp[i], dp[i - pow6] + 1)
        pow6 *= 6
    while pow9 <= i:
        dp[i] = min(dp[i], dp[i - pow9] + 1)
        pow9 *= 9

print(dp[n])
# Judge status: Accepted
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

a = Counter(a)
a = {key: val for key, val in a.items() if val >= 2}
a = dict(sorted(a.items(), reverse=True))

if len(a) == 0:
    print(0)
    exit()

side1 = max(a)
a[side1] -= 2

a = {key: val for key, val in a.items() if val >= 2}
a = dict(sorted(a.items(), reverse=True))

if len(a) == 0:
    print(0)
    exit()

side2 = max(a)

print(side1 * side2)
# Judge status: Wrong Answer
A = input ()
B = input ()
C = input ()
X,Y,Z = 0,0,0
P = A
Q = X
while True:
  if len(P)==Q:
    if P==A:
      print ('A')
    elif P==B:
      print ('B')
    else:
      print ('C')
    break
  if P[Q]=='a':
    P = A
    X += 1
    Q = X
  elif P[Q]=='b':
    P = B
    Y += 1
    Q = Y
  else:
    P = C
    Z += 1
    Q = Z
# Judge status: Accepted
n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(n)]

sum = 0
mr = 0
ks = sorted(k)

for i in range(n):
    if ks[i][1] < (m-mr):
        sum += ks[i][0] * ks[i][1]
        mr += ks[i][1]

    else:
        sum += ks[i][0] * (m - mr)
        break

print(sum)
# Judge status: Wrong Answer
n,k=map(int,input().split())
h=[]
ma=10**9
for i in range(n):
  a=int(input())
  h.append(a)
h.sort()

for i in range(n-k+1):
  b=h[i:n-k+i+1]
  sa=b[-1]-b[0]
  if sa<ma:
    ma=sa
    
print(ma)
# Judge status: Accepted
def main():
    a, b, c = [int(v) for v in input().split()]

    if a + b == c or b + c == a or c + a == b:
        print("Yes")
    else:
        print("No")


main()
# Judge status: Wrong Answer
import numpy as np

N,M = map(int,input().split())
P = np.zeros(M, dtype=int)
S = np.zeros(M, dtype=int)
for i in range(M):
    p,s = map(str,input().split())
    P[i] = int(p)
    if s == 'AC':
        S[i] = 1
    
cOK = 0
cNG = 0
aP = np.argsort(P)
P = P[aP]
S = S[aP]
i = 0
while i<M:
    Q = list(S[P==P[i]])
    if 1 in Q:
        cOK += 1
        cNG += Q.index(1)
    i += len(Q)

print(cOK, cNG)