peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
S = input()

lans = list()
for i in range(1, N):
    sa = S[:i]
    sb = S[i:]
    l = list()
    cnt = 0
    for j in range(i):
        if S[j] in sb and S[j] not in l:
            l.append(S[j])
            cnt += 1
    lans.append(cnt)

print(max(lans))
# Judge status: Wrong Answer
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

res = [0]*N
hands = ["r", "s", "p"]

for i in range(N):
    res[i] = hands[hands.index(T[i])-1]

for i in range(N):
    if i >= K and res[i-K] == res[i]:
        res[i] = 0

score = R*res.count("r") + S*res.count("s") + P*res.count("p")
print(res)
print(R*res.count("r"), S*res.count("s"), P*res.count("p"))
print(score)
# Judge status: Accepted
a = list(map(int,input().split()))

result =[]
result.append(a[0] * a[2])
result.append(a[0] * a[3])
result.append(a[1] * a[2])
result.append(a[1] * a[3])
print(max(result))
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
S = '.' + input()


def solve():
    if '##' in S[A:C + 1] or '##' in S[B:D + 1]:
        return 'No'

    if C > D:
        if '...' not in S[B - 1:D + 2]:
            return 'No'

    return 'Yes'


print(solve())
# Judge status: Accepted
N, K = map(int, input().split())
sunuke = set([x for x in range(1,N+1)])
for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    sunuke.difference_update(A)
    
print(len(sunuke))
# Judge status: Accepted
A, B = [int(_) for _ in input().split()]
if A == B:
  print('Draw')
else:
  if A == 1:
    print('Alice')
  elif B == 1:
    print('Bob')
  elif A > B:
    print('Alice')
  elif B > A:
    print('Bob')
# Judge status: Accepted
N, K = map(int, input().split())
PS = list(map(int, input().split()))
PS.sort()
print(sum(PS[:K]))
# Judge status: Accepted

N,M = map(int,input().split())
H = list(map(int,input().split()))
ans = [0]*N


visited = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    visited[a-1] = 1
    visited[b-1] = 1
    if H[a-1]<H[b-1]:
        ans[a-1] = -1
    elif H[b-1]<H[a-1]:
        ans[b-1] = -1
    else:
        ans[a-1] = -1
        ans[b-1] = -1
        

ans = [i for i in range(N) if ans[i]==0]
print(len(ans))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

if len(A) == 1:
    print(A[0])
    exit(0)

B_left = []
B_right = []
for i, a in enumerate(A):
    if i % 2 == 0:
        B_right.append(a)
    else:
        B_left.append(a)

if len(A) % 2 == 0:
    B = B_left[::-1] + B_right
else:
    B = B_right[::-1] + B_left
print(*B)
# Judge status: Accepted
n,a,b = map(int,input().split())

if a == b:
  ans = 0
elif abs(a-b)%2 == 0:
  ans = abs(a-b)//2
elif abs(a-b)%2 == 1:
  if a > b:
    if (a-1) > (n-b):
      ans = (n-a) + (a-b-1)//2 + 1
    else:
      ans = (b-1) + (a-b-1)//2 + 1
  if b > a:
    if (b-1) > (n-a):
      ans = (n-b) + (b-a-1)//2 + 1
    else:
      ans = (a-1) + (b-a-1)//2 + 1
      
print(ans)
# Judge status: Accepted
def main():
	n,m = map(int,input().split())
	ans = 1
	while n >= m:
		n = (n-n%m) // m
		ans += 1
	print(ans)

if __name__ == '__main__':
	main()
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a%b==0:
    print(0)
else:
    print(a//b-a%b)
# Judge status: Accepted
a,b,c = map(int,input().split())

count=0
while a%2==0 and b%2==0 and c%2==0:
    if (b/2+c/2)==(a/2+c/2)==(a/2+b/2):
        count=-1
        break
    a,b,c = b/2+c/2,a/2+c/2,a/2+b/2
    count+=1
print(count)
# Judge status: Accepted
a=int(input())
b=input()
b=list(b)
c=[0]*26
ans=0
t=0
for i in range(a):
	c[ord(b[i])-97]=c[ord(b[i])-97]+1

for j in range(26):
	t=c[j]
	for k in range(j+1,26):
		t=t*(c[k]+1)
	ans=ans+t
print(ans%(10**9+7))
# Judge status: Accepted
X = int(input())

while True:
    
    flag = 0
    
    for i in range(2, X): #2からX-1までのループ
        if X % i == 0: #対象はXという数
            flag = 1
            break
    if flag == 1:
        X += 1
        continue
    break
    
print(X)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
d4=len([i for i in A if i%4==0])
d2=len([i for i in A if i%2==0 and i%4!=0])

N=N-(d4*2+1)
if N==1 and d2>=2:
    N=0
elif N>=2 and N-d2<=0:
    N=0

print("Yes" if N<=0 else "No")
# Judge status: Wrong Answer
if __name__ == '__main__':
    b, c = map(int, input().split())
    a = int(str(b)+str(c))

    for i in range(1,101):
        if a % (i*i) == 0:
            print("Yes")
            break
        elif a <  i* i:
            print("No")
            break
# Judge status: Wrong Answer
a = int(input())
b = input()
print(b[:a]+'...')
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if(a==b or b==c or c==a and not (a==b and b==c)):print("Yes")
else:print("No")
# Judge status: Wrong Answer
S = str(input())
T = str(input())
ans = 1000
for i in range(len(S) - len(T)):
    c = 0
    for j in range(len(T)):
        if S[i] != T[j]:
            c += 1
        i += 1
    ans = min(ans, c)
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
cake = [0]*16
for i in range(A):
  try:
    cake[i*2] = 1
  except:
    print(':(')
    exit()
for i in range(B):
  try:
    cake[(i*2)+1] = 1
  except:
    print(':(')
    exit()
print('Yay!')
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = []
d = []
for i in range(k):
    d.append(int(input()))
    a.extend(list(map(int, input().split())))

n_set = {i for i in range(1, n)}

a_set = set(a)

difference = n_set - a_set

print(len(difference))
# Judge status: Accepted
l=list(map(int,input().split()))
a=max(l)*3-sum(l)+1
print(a//2 if a%2 else a//2+1)
# Judge status: Accepted
def I(): return int(input())
print((I()+I())*I()//2)
# Judge status: Wrong Answer
n, k = map(int, input().split())
data = list(map(int, input().split()))

max = max(data)
sum = sum(data)

print(sum - max)
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[2]:


N = int(input())


# In[12]:


def lucas(n):
    mylist = [2,1]
    for i in range(2,n+1):
        mylist.append(mylist[i-1]+mylist[i-2])
    return mylist[n]


# In[14]:


print(lucas(N))


# In[ ]:
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
if a>k:a=a-k
if a<=k:
  b=b+(a-k)
  a=0
elif a==0 and b==0:
  a=0
  b=0
print(a,b)
# Judge status: Accepted
N,M=map(int,input().split())
S=[]
G=[]
for i in range(M):
	x,y=map(int,input().split())
	if x==1:
		S.append(y)
	if y==N:
		G.append(x)
if S==[] or G==[]:
	print("IMPOSSIBLE")
	exit()
S=set(S)
G=set(G)
T=len(S)+len(G)
k=len(G)
S=list(S)
G=list(G)
for i in range(k):
	S.append(G[i])
U=len(set(S))
if T!=U:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")
# Judge status: Accepted
import math

N, M = map(int, input().split())
P = [tuple(map(int, input().split())) for i in range(N)]

ans = 0

for i in range(N):
    d = math.sqrt(P[i][0]**2 + P[i][1]**2)
    if d <= M:
        ans += 1

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

x1 = 25*A//2
x2 = 25*(A+1)//2
x3 = 10*B
x4 = 10*(B+1)

if x1 <= x3 and x3 < x2:
  print(x3)
elif x3 <= x1 and x1 < x4:
  print(x1)
else:
  print(-1)
# Judge status: Accepted
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    if N == 2:
        print(A[1], A[0])
        return
    idx = bisect_left(A, A[-1] // 2)
    a = A[idx]
    if idx > 0 and (A[idx] - A[-1] / 2) > (A[-1] // 2 - A[idx - 1]):
        a = A[idx - 1]
    print(A[-1], a)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
print('ABC' if n<1000 else 'ABD')
# Judge status: Accepted
x, y = map(int, input().split())
i = 1
if x % y == 0:
    print(-1)
else:
    print(x * y - x)
# Judge status: Accepted
n, m = map(int, input().split())
l = [1 for i in range(n+1)]
b = [False for i in range(n+1)]
l[1] = 1
b[1] = True
for i in range(m):
    x, y = map(int, input().split())
    if b[x] == True:
        if l[x] == 1:
            b[x] = False
        b[y] = True
    l[x] -= 1
    l[y] += 1
cnt = 0
for i in range(1, n+1):
    if b[i] == True:
        cnt += 1
print(cnt)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
color = [0] * 8
cnt = 0
for i in a:
  if i < 400:
    color[0] = 1
  elif i < 800:
    color[1] = 1
  elif i < 1200:
    color[2] = 1
  elif i < 1600:
    color[3] = 1
  elif i < 2000:
    color[4] = 1
  elif i < 2400:
    color[5] = 1
  elif i < 2800:
    color[6] = 1
  elif i < 3200:
    color[7] = 1
  else:
    cnt += 1
if color.count(1) == 0:
  print(1, cnt)
else:
  print(color.count(1), color.count(1) + cnt)
# Judge status: Wrong Answer
import numpy as np

N, W = map(int, input().split())
wv = np.array([[int(i) for i in input().split()] for j in range(N)])

max_v = 10**3*(N+1)
dp = np.full([N+1,max_v], np.inf)
dp[0,0] = 0
 
for i in range(N):
    # 遷移元なし
    dp[i+1,:wv[i,1]] = dp[i,:wv[i,1]]
    # 遷移元あり
    dp[i+1,wv[i,1]:] = np.minimum(dp[i,wv[i,1]:], dp[i,:max_v-wv[i,1]]+wv[i,0])

print(np.max(np.where(dp <= W)))
# Judge status: Accepted
n=int(input())
d=dict()
a=["AC","WA","TLE","RE"]
for x in a:
	d[x]=0
for _ in range(n):
	d[input()]+=1
for x in a:
	print(x + " x " + str(d[x]))
# Judge status: Accepted
a,b=map(int,input().split())
if a==b:
    print("Draw")
elif a==1:
    print("Alice")
elif b==1:
    print("Bob")
elif a>b:
    print("Alice")
else:
    print("Bob")
# Judge status: Accepted
S = input()
left = int(S[:2])
right = int(S[2:])
year_flag = [0, 0]

if left > 12 or left == 0:
    year_flag[0] += 1
if right > 12 or right == 0:
    year_flag[1] += 1

if sum(year_flag) == 2:
    print('NA')
elif sum(year_flag) == 0:
    print('AMBIGUOUS')
elif year_flag[0] == 1:
    print('YYMM')
else:
    print('MMYY')
# Judge status: Accepted
s = input()
l = []
for i in range(len(s)-2):
    a = abs(753 - int(s[i:i+3]))
    l.append(a)
print(min(l))
# Judge status: Accepted
n=int(input())

s="No"
for i in range(26):
  for j in range(15):
    if 4*i+7*j==n:
      s="Yes"
print(s)
# Judge status: Accepted
a, b, c = map(int, input().split())
d = 0
for i in range(1,c+1):
  if i*a <=b:
    d += 1
    continue
  else:
    break
print(d)
# Judge status: Wrong Answer
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = 1
flag = 0
for i in range(N):
    gcd = fractions.gcd(A[i]//2, lcm_half)
    lcm_half = (lcm_half * (A[i]) // 2) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    ans = 1+M//(lcm_half*2)

print(ans)
# Judge status: Accepted
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

L = int(read())
print(L**3 / 27)
# Judge status: Accepted
x = list(map(int, input().split()))
print(max(x[0]*x[2], x[0]*x[3], x[1]*x[2], x[1]*x[3]))
# Judge status: Wrong Answer
N,X=map(int,input().split())
ai=list(map(int,input().split()))
ai.sort()
sum_of_the_candy=0
ans=0
if sum(ai)==X:
	ans=N
elif sum(ai)<X:
	ans=N-1
else:
	for i in range(N):
		sum_of_the_candy=sum_of_the_candy+ai[i]
		if sum_of_the_candy < X:
			ans = ans +1
		else:
			break
print(ans)
# Judge status: Accepted
inp=[int(x) for x in input().split()]
print(inp[2],inp[0],inp[1])
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
if B*C <= A:
  r = C
else:
  r = A // B

print(r)
# Judge status: Accepted
n,a,b=map(int,input().split())
if a==0:
  print("0")
  exit()
tmp1 = n // (a+b)
tmp2 = n-(tmp1*(a+b))
if tmp2 >= a:
  print((tmp1*a)+a)
else:
  print((tmp1*a)+tmp2)
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())

a_max = X // 500
b_max = X // 100
c_max = X // 50

a_range = A
if A > a_max:
  a_range = a_max
b_range = B
if B > b_max:
  b_range = b_max
c_range = C
if C > c_max:
  c_range = c_max

count = 0

for i in range(c_range+1):
  for j in range(b_range+1):
    for k in range(a_range+1):
      if k * 500 + j * 100 + i * 50 == X:
        count += 1

print(count)
# Judge status: Accepted
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
s=input()
n=len(s)
res=900
for i in range(n-2):
    if abs(753-int(s[i:i+3]))<res:
        res=abs(753-int(s[i:i+3]))
print(res)
# Judge status: Wrong Answer
N = int(input())
B = [0] + list(map(int,input().split()))
A = [0,B[1]]
for i in range(2,N):
    A.append(B[i-1])
    if A[i] > B[i]:
        A[i] = B[i]
A.append(B[N-1])
print(B[1:])
print(A[1:])
print(sum(A))
# Judge status: Accepted
N = int(input())
string = input()
r2w = string.count("R")
w2r = 0
ans_list = [max(r2w, w2r)]
for c in string:
    if c == "W":
        w2r += 1
    else:
        r2w -= 1
    ans_list.append(max(r2w, w2r))
print(min(ans_list))
# Judge status: Accepted
a, b = map(int, input().split())
if a <= 0 <= b:
    print("Zero")
elif 1 <= a or (b-(a-1))%2 == 0:
    print("Positive")
else:
    print("Negative")
# Judge status: Wrong Answer
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

A_ = A + V * T
B_ = B + W * T

if A == B:
  print('YES')
elif A > B:
  print('NO')
elif A < B and A_ >= B_:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
from fractions import gcd
a,b=map(int,input().split())
l=a*b//(gcd(a,b))
print(l)
# Judge status: Accepted
h, w = [int(x) for x in input().split()]
if h == 1 or w == 1:
    res = 1
else:
    if w%2 == 0:
        res = h * w // 2
    else:
        res = h * (w//2) + (h + 2 - 1)//2
print(res)
# Judge status: Accepted
n, m = map(int, input().split())

if n == 1:
    if m == 1:
        print(1)
    else:
        print(m-2)

elif m == 1:
    print(n-2)

else:
    print((n-2) * (m-2))
# Judge status: Accepted
import math
R = int(input())

print(2*R*math.pi)
# Judge status: Accepted
import math
a,b,x=map(int,input().split())

if x/(a**2)>=b:
    print(0)
elif x/(a**2)>=b*0.5:
    print(90-math.degrees(math.atan((a*0.5)/(b-x/a**2))))
else:
    print(math.degrees(math.atan(b/(2*x/(a*b)))))
# Judge status: Accepted
S = input()
Q = int(input())
cond = 1
pre = ''
epi = ''
for i in range(Q):
	q = list(map(str, input().split()))
	if q[0] == "1":
		cond *= -1
	else:
		if q[1] == "1":
			if cond == 1:
				pre += q[2]
			else:
				epi += q[2]
		else:
			if cond == 1:
				epi += q[2]
			else:
				pre += q[2]

if cond == 1:
	print(pre[::-1]+S+epi)
else:
	print(epi[::-1]+S[::-1]+pre)
# Judge status: Accepted
from math import gcd

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

L = [0] * N
R = [0] * N
L[0] = A[0]
R[N-1] = A[N-1]
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

ans = -1
for i in range(N):
    if i == 0:
        ans = max(ans, R[1])
    elif i == N-1:
        ans = max(ans, L[N-2])
    else:
        ans = max(ans, gcd(L[i-1], R[i+1]))

print(ans)
# Judge status: Wrong Answer
a, b =	input().split()
a = int(a)
b = b.replace(".", "")
b = int(b)
print(a * b // 100)
# Judge status: Wrong Answer
import numpy as np

def multi_input():
    return map(int, input().split())

l = np.array(list(multi_input()))
l = np.abs(l - max(l))
l.sort()

ans = 0
if (l[2] - l[1]) % 2 == 0:
    ans += l[1] + (l[2] - l[1]) // 2
else:
    ans += (l[2] - l[1]) // 2 + (l[2] - l[1])
print(ans)
# Judge status: Accepted
a,b=map(int, input().split()) #a1 a2 a3
print(a*b)
# Judge status: Wrong Answer
A,B=input().split()
if (int(A)>int(B) and A!="13") or (int(A)<int(B) and B=="13"):
  print('Alice')
elif A==B:
  print("Draw")
else:
  print("Bob")
# Judge status: Wrong Answer
x, y = map(int, input().split())


def group(v):
    if v in [1, 3, 5, 7, 8, 10, 12]:
        return 1
    else:
        return 2


if group(x) == group(y):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import itertools
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
nn = [i+1 for i in range(n)]
mm = list(itertools.permutations(nn))
print(max((mm.index(q)) - (mm.index(p)) , (mm.index(p)) - mm.index(q)))
# Judge status: Accepted
s = input()

res = 1000
for i in range(len(s)-2):
    res = min(res, abs(753-int(s[i:i+3])))
print(res)
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())

if a > 2*c and b > 2*c:
    ans = 2*c*max(x, y)
elif a < c and  b < c:
    ans = a*x + b*y
else:
    ans = float('inf')
    for i in range(min(x, y)+1):
        p = 2*c*i + (x-i)*a + (y-i)*b #; print(i, p)
        ans = min(p, ans)
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
sum=0
for i in range(N-1):
    if A[i+1]>A[i]:
        sum+=A[i+1]-A[i]
print(sum)
# Judge status: Wrong Answer
# C
import math
n = int(input())
a = list(map(int, input().split()))
ave = math.ceil(sum(a)/n)

ans = 0
for i in range(n):
    ans += (a[i] - ave)**2
    
print(ans)
# Judge status: Accepted
n, d = map(int, input().split())

d = d*2 + 1

ans = n//d

if n%d == 0:
    print(ans)
else:
    print(ans + 1)
# Judge status: Accepted
n = int(input())

s = []
for i in range(1, n):
    j = n - i
    if i + j == n:
        a = sum(map(int, str(i)))
        b = sum(map(int, str(j)))
        s.append(a + b)
print(min(s))
# Judge status: Accepted
N, M = map(int,input().split())
s = [list(map(int,input().split())) for k in range(N)]
p = [list(map(int,input().split())) for k in range(M)]
ans = []
for e in s:
    temp = float("inf")
    u = 0
    for k in range(M):
        if temp > abs(e[0]-p[k][0]) + abs(e[1]-p[k][1]):
            temp = abs(e[0]-p[k][0]) + abs(e[1]-p[k][1])
            u = k+1
    ans.append(u)
print(*ans,sep="\n")
# Judge status: Wrong Answer
n=int(input())
a=4
b=7
for i in range(26):
	for j in range(15):
		if a*i+b*j==n:
			print('Yes')
		else:
			print('No')
# Judge status: Wrong Answer
import fractions
import sys

N, X = map(int, input().split())
li = list(map(int, input().split()))

if len(li) == 1:
  print(li[0] - X)
  sys.exit()
  
li.append(X)
li.sort(reverse=True)

ans = li[0] - li[1]

for index, i in enumerate(li):
  if index == 0:
    continue

  if index == len(li) - 1:
    break

  ans = fractions.gcd(ans, i - li[index+1])

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

flg=0
if "N" in s:
    flg+=1
if "S" in s:
    flg-=1
if "W" in s:
    flg+=10
if "E" in s:
    flg-=10

if flg==0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
mem=[[0] * 10 for _ in range(10)]

for i in range(1, N+1):
    s = str(i)
    mem[int(s[0])][int(s[-1])] += 1 
    
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += mem[i][j] * mem[j][i]
print(ans)
# Judge status: Accepted
N = int(input())
s = input()
t = input()
ans = 2*N
for i in range(N):
  if s[-(i+1):] == t[:i+1]:
    ans = 2*N-(i+1)
print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
s=input()
if s[k-1]=='A':
  x='a'
elif s[k-1]=='B':
  x='b'
elif s[k-1]=='C':
  x='c'
print(s[:k-1]+x+s[k:])
# Judge status: Accepted
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)

count_use = 0
while count_use < m:
    max_a = heapq.heappop(a)
    max_a = -1*((-1*max_a)//2)
    #print(max_a)
    heapq.heappush(a, max_a)
    count_use += 1

print((-1)*sum(a))
# Judge status: Accepted
li = list(input())
ans = ""
for i in li:
  if i == "0":
    ans = ans + "0"
  elif i == "1":
    ans = ans + "1"
  elif i == "B":
    ans = ans[:len(ans)-1]
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
if a*c<=b:
    print(c)
else:
    print(b//a)
# Judge status: Accepted
s = input()
ans = 0
pre = ""
now = ""
for ss in s:
    now += ss
    if pre != now:
        ans += 1
        pre = now
        now = ""
print(ans)
# Judge status: Accepted
n=input()

if n[-1]=="2" or n[-1]=="4" or n[-1]=="5" or n[-1]=="7" or n[-1]=="9":
    print('hon')
elif n[-1]=="3":
    print('bon')
else:
    print('pon')
# Judge status: Accepted
S=input()

n,w,s,e='N' in S,'W' in S,'S' in S,'E' in S

cand1=not n^s
cand2=not w^e

ans="Yes" if cand1 and cand2 else "No"
print(ans)
# Judge status: Accepted
A, B, C = map(int,input().split())

if (A * B * C) % 2 == 0:
  ans = 0
else:
  ans = min(A*B,B*C,C*A)
print(ans)
# Judge status: Wrong Answer
n,x,t = map(int, input().split())

ans = n / x
ans = round(ans)
ans = ans * t
if ans == 0:
    ans = t
if n == 0:
    ans = 0
print(ans)
# Judge status: Wrong Answer
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
saishou=A.index(1)
if saishou==0:
    answer=math.ceil((N-1)/(K-1))
    print(answer)
else:
    print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(K-1)))
# Judge status: Accepted
from sys import stdin

A = list(map(int,stdin.readline().split()))

if A[1]-2*A[0]<0:
    print('No')
else:
    if (A[1]-2*A[0])%2==0:
        if (A[1]-2*A[0])/2>A[0]:
            print('No')
        else:
            print('Yes')
    else:
        print('No')
# Judge status: Accepted
#code
n=int(input())
s=input()
t=input()
ans=2*n
for i in range(0,len(s)):
    if(s[i:]==t[:n-i]): ans=min(ans,i+n-i+i)
    
    
print(ans)
# Judge status: Accepted
def resolve():
    import sys
    n,x=map(int, input().split())
    l=list(map(int, input().split()))
    l.sort()
    cnt=0
    for i in range(n):
        if l[i]<=x:
            x-=l[i]
            cnt+=1
        else:
            break
    if cnt==n and x>0:
        cnt-=1
    print(cnt)
resolve()
# Judge status: Accepted
s=list(input().split())
a,b=map(int,input().split())
print(a,b-1) if s.index(input())==1 else print(a-1,b)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split(" ")))
s = 0
for i in range(0,N):
  s += a[i]

s = s*s

for i in range(0,N):
  s -= a[i]*a[i]

while s >= 2*(10**9 +7):
  s = s % (10**9 +7)
if s >= 10**9 + 7:
  s = s % (10**9)
s = s/2
 
print(int(s))
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    c=SI()
    if c in "aiueo":print("vowel")
    else:print("consonant")

main()
# Judge status: Wrong Answer
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()

from scipy.misc import comb
def combi(n):
    if n<=1:
        return 0
    if n==2:
        return 1
    return comb(n,2)

c=[a.count(i) for i in range(1,n+1)]
d=[combi(m) for m in c]
s=sum(d)

for i in range(n):
    print(s-d[a[i]-1]+combi(c[a[i]-1]-1))
# Judge status: Wrong Answer
import math
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
ans=5
x=[a,b,c,d,e]
s=0
if n>a:
    s=math.ceil(n/a)
for i in range(4):
    if x[i]>x[i+1]:
        t=x[i]//x[i+1]
        if x[i]%x[i+1]!=0:
            t+=1
        s=max(s,t)
print(ans+s)
# Judge status: Accepted
N = int(input())
r = [list(map(int, input().split())) for _ in range(N)]
a = []
for i in r:
    a.append((i[0]+i[1],i[0]-i[1]))
a.sort()
ans = 0
cur = a[0][1]
for i in a:
    if i[1] < cur:
        continue
    ans += 1
    cur = i[0]
print(ans)
# Judge status: Accepted
def main():
	N = int(input())
	A = list(map(int, input().split()))

	is_increasing = True
	is_first = True
	ans = 1

	for i in range(1, N):
		if is_first == True:
			if A[i - 1] < A[i]:
				is_increasing = True
				is_first = False
			elif A[i - 1] > A[i]:
				is_increasing = False
				is_first = False
		else:
			if is_increasing == True and A[i - 1] > A[i]:
				ans += 1
				is_first = True
			elif is_increasing == False and A[i - 1] < A[i]:
				ans += 1
				is_first = True

	print(ans)



 
if __name__ == "__main__":
  	main()