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

N, M = list(map(int, input().split()))
path = [[] for _ in range(N + 1)]
for _ in range(M):
  A, B = list(map(int, input().split()))
  path[A].append(B)
  path[B].append(A)

#print(N, M, path)

hq = [(0, 0, 1)]

mark = [None] * (N + 1)

while hq:
  cost, prev, node = heapq.heappop(hq)
  #print(cost, prev, node)
  if not mark[node]:
    mark[node] = prev
    for nxt in path[node]:
      heapq.heappush(hq, (cost + 1, node, nxt))

if all(mark[2:]):
  print('Yes')
  for m in mark[2:]:
    print(m)
else:
  print('No')
# Judge status: Wrong Answer
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

arr = [0] * 1000
for i in p:
    arr[i] = 1

ans1 = 0
for i in range(x, 0, -1):
    if arr[i] == 0:
        ans1 = i
        break

#print(arr)

ans2 = 0
for i in range(x, 102):
    if arr[i] == 0:
        ans2 = i
        break

if ans1 == 0:
    print(ans2)
else:
    if abs(ans1-x) <= abs(x-ans2):
        print(ans1)
    else:
        print(ans2)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
ans = (0, 0)
AL = 0
for i in A:
  if i == MA:
    continue
  if i < int(MA / 2) - 1:
    continue
  r = math.factorial(MA) // (math.factorial(MA-i) * math.factorial(i))
  if AL < r:
    AL = r
    ans = (MA, i)
    
print(ans[0], ans[1])
# Judge status: Accepted
s = list(input())

n = len(s)
hst = ["#"]
sk = ""

for i in range(n):
    sk += s[i]
    if hst[-1] != sk:
        hst.append(sk)
        sk = ""

print(len(hst)-1)
# Judge status: Accepted
a, b, c, = map(int,input().split())
print("YES" if b * 2 - (a + c) == 0 else "NO")
# Judge status: Accepted
n=int(input())
s=input()
print("Yes" if n%2==0 and s[:n//2]==s[n//2:] else "No")
# Judge status: Accepted
s=input()
if s=="MON":
  print("6")
elif s=="TUE":
  print("5")
elif s=="WED":
  print("4")
elif s=="THU":
  print("3")
elif s=="FRI":
  print("2")
elif s=="SAT":
  print("1")
else:
  print("7")
# Judge status: Accepted
def abc_of_ABC(s):

    return "Yes" if s.count("a") == 1 and s.count("b") == 1 else "No"

def main():
    s = str(input())
    print(abc_of_ABC(s))

if __name__ == '__main__':
    main()
# Judge status: Accepted
from math import gcd

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

def lcm(a,b):
  return a*b//gcd(a,b)

lcm_a = 1
 
for i in A:
    lcm_a = lcm(lcm_a,i)
 
ans = 0
for i in A:
    ans += lcm_a//i

print(ans%(10**9+7))
# Judge status: Wrong Answer
s=input()
ans=1000
for i in range(len(s)-3):
  ans=min(ans,abs(int(s[i:i+3])-753))
print(ans)
# Judge status: Accepted
n = int(input())
w = list(map(int, input().split()))
a = sum(w) // 2
c = 0
t = []
for i in range(n):
    t.append(abs(sum(w[i:]) - sum(w[:i])))
print(min(t))
# Judge status: Wrong Answer
import sys
from collections import defaultdict
from collections import deque

n, m = map(int, input().split())

graph = defaultdict(list)

for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    graph[a].append(b)
    graph[b].append(a)

q = deque([1])
cnt = 0

while q and cnt <= 2:
    cnt += 1
    node = q.popleft()
    after = graph[node]

    for a in after:
        if a == n:
            print("POSSIBLE")
            sys.exit()
        q.append(a)

print("IMPOSSIBLE")
# Judge status: Wrong Answer
s = list(map(lambda x: ord(x) - ord('a'), list(input())))

ans = ["-1", "-1"]
# print(s)
if len(s) == 2:
    if set(s) == 1:
        print(1, 2)
        exit()
    else:
        print(" ".join(ans))
        exit()

for i in range(len(s) - 2):
    # print(len(set(s[i:i+3])))
    if len(set(s[i:i+3])) <= 2:
        # print(s[i:i+3])
        ans = [str(i+1), str(i+3)]
        break

print(" ".join(ans))
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
res = 0
for i in range(1,2*N,2):
    res += a[i]
print(res)
# Judge status: Accepted
n, m = map(int, input().split())
if n*m==1:
    print(1)
elif n==1:
    print(m-2)
elif m==1:
    print(n-2)
else:
    print((n-2)*(m-2))
# Judge status: Wrong Answer
import sys
import os

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # input()
    N,M=map(int, input().split())
    cen=int(N/2)
    ans=[]
    for i in range(M):
        ans.append([cen-i,cen+1+i])
    [print(str(i[0])+" "+str(i[1])) for i in ans]

if __name__ == '__main__':
    main()
# Judge status: Accepted
s=input()
t=input()
c=0
for i in range(len(s)):
  if s[i]!=t[i]:
    c+=1
print(c)
# Judge status: Accepted
n = int(input())
n0 = 2
n1 = 1

if n == 1:
    print(1)
else:
    for _ in range(1, n):
        n2 = n0+n1
        n0, n1 = n1, n2
    print(n2)
# Judge status: Accepted
import math
l = list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l[0] -= 1
la = l[0] - l[0] // l[2] - l[0] // l[3] + l[0] // lcm(l[2], l[3])
lb = l[1] - l[1] // l[2] - l[1] // l[3] + l[1] // lcm(l[2], l[3])
print(lb - la)
# Judge status: Wrong Answer
r,k = map(int,input().split())
b = input().split()
s = set(b)
n = [b.count(i) for i in s]
n.sort()
ans = 0
for i in range(len(s)-k):
    ans += n[i]
    print(n[i])
print(ans)
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[21]:


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


# In[22]:


A_s = sorted(enumerate(A), key=lambda x: x[1], reverse=False)
# print(A_s)
odr = [str(idx+1) for idx,x in A_s]
print(" ".join(odr))


# In[ ]:
# Judge status: Wrong Answer
N, R = list(map(int,input().split(" ")))

if N < 10:
  print(R-100*(10-N))
else:
  print(R)
# Judge status: Accepted
n=int(input())
i = list(map(int, input().split())) 

m=sum(i)

ans=0
for k in range(n):
    ans+=(i[k]*(m-i[k]))
ans=ans//2
ans=ans%(10**9+7)
print(ans)
# Judge status: Accepted
import math

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

def cal(lis,x):
    an = 0
    for i in range(len(lis)):
        an += (math.ceil(lis[i] / x) - 1)
        
    return an

left = 0
right = 10**9

for i in range(100):
    m = (left + right) / 2
    
    b = cal(a,m)
    
    if b > k:
        left = m
    else:
        right = m
        
print(math.ceil(m))
# Judge status: Accepted
n,m = map(int,input().split())
l = [0 for _ in range(m)]
r = [0 for _ in range(m)]
for i in range(m):
    l[i],r[i] = map(int,input().split())
s = [0 for _ in range(n+1)]
for i in range(m):
    s[l[i]-1] += 1
    s[r[i]] -= 1
h = [0]
for i in range(n):
    h.append(s[i]+h[i])
ans = 0
for i in range(n+1):
    if(h[i] == m):
        ans += 1
print(ans)
# Judge status: Accepted
S = list(input())
K = int(input())
for i in S:
    if i != "1":
        break
i = S.index(i)
if K <= i:
    print(1)
else:
    print(S[i])
# Judge status: Wrong Answer
n=int(input())

for i in range(n+2):
    if 2**i<=n:
        print(2**i)
# Judge status: Wrong Answer
s = list(input())
t = list(input())
f = False
l = len(s)
p = ["" for _ in range(l)]
for i in range(l):
	if s == p: 
		print("as")
		f = True
		break
	for j in range(l):
		p[(j+i)%l] = t[j]
if f: print("Yes")
else: print("No")
# Judge status: Wrong Answer
import sys
from io import StringIO
import unittest
import math

def resolve():
    s,c= map(int,input().split())

    if s>=c/2:
        print(str(math.floor(c/2)))
    else:
        zanc = c - (s * 2)
        print(str(s + math.floor(zanc/4)))
# Judge status: Wrong Answer
L=int(input())
if L%3==0:
    print((L//3)**3)
elif L%3==1:
    print((L//3)*(L//3)*(L//3+1))
else:
    print((L//3)*(L//3+1)*(L//3+1))
# Judge status: Accepted
l, r = map(int, input().split())

MOD = 2019
r = min(r, l + MOD - 1)

res = MOD - 1
for i in range(l, r):
    for j in range(i + 1, r + 1):
        res = min(res, (i % MOD) * (j % MOD) % MOD)
print(res)
# Judge status: Wrong Answer
def main():
    S = input()
    if int(S[:2]) > 12 and 12 >= int(S[2:]) > 0:
        print("YYMM")
    elif 0 < int(S[2:]) <= 12 and 12 < int(S[:2]):
        print("MMYY")
    elif 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("NA")


if __name__ == '__main__':
    main()
# Judge status: Accepted
#E re
H, N = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
DP = [float('inf')] * (H+1)
DP[0] = 0

for i in range(N):
    for j in range(H):
        nj = min(j+A[i], H)
        DP[nj] = min(DP[nj], DP[j]+B[i])

print(int(DP[H]))
# Judge status: Accepted
S = input()
a = b = c = 0
for s in S:
  if s == 'S':
    a += 1
  else:
    if a == 0:
      b += 1
    else:
      a -= 1
print(a+b)
# Judge status: Wrong Answer
w,a,b = map(int,input().split())
aw = a+w
bw =b+w
print(min(abs(a-b),abs(b-aw),abs(bw-a)))
# Judge status: Wrong Answer
from itertools import accumulate


def main():
    section_num = int(input())
    length = list(map(int, input().split()))
    accumulate_length = list(accumulate(length))
    answer = float("inf")
    for i in range(1, section_num):
        answer = min(answer, abs(accumulate_length[-1] - 2 * accumulate_length[i]))
    print(answer)


if __name__ == '__main__':
    main()
# Judge status: Accepted
def resolve():
    N = int(input())
    N += 1

    ans = 0
    for i, n in enumerate(range(len(str(N)))):
        if i == 0:
            continue
        ans += int(9)
    ans += int(str(N)[0])-1
    print(ans)
    return


resolve()
# Judge status: Wrong Answer
W, H, N  = map(int,input().split()) 
l = 0; r = W; u = H; d = 0 

for i in range(N):
    x, y, a = map(int,input().split()) 
    if a == 1:
        l = max(l,x) 
    elif a == 2:
        r = min(r,x) 
    elif a == 3:
        d = max(d,y) 
    else:
        u = min(u,y) 

print(max(0,(r-l)*(u-d)))
# Judge status: Accepted
n, a, b = map(int, input().split())
cnt = 0
for i in range(1, n+1):
    s = list(str(i))
    t = 0
    for j in range(len(s)):
        t += int(s[j])
    if a<=t and t<=b:
        cnt += i
print(cnt)
# Judge status: Accepted
n = int(input())
arr = [list(map(int, input().split())) for _ in range(n-1)]
for i in range(n):
    t = 0  # 初期条件
    for j in range(i, n-1):
        ci, si, fi = arr[j]  # 各駅の条件を代入
        if t <= si:  # まだ始発が出発していないとき
            t = si
        else:  # すでに出発している時
            t = ((t + fi - 1)//fi) * fi
        t += ci  # 電車に乗っている時間
    print(t)
# Judge status: Wrong Answer
S = set(input())
for i in range(97, 122):
    if chr(i) not in S:
        print(chr(i))
        exit()
print('None')
# Judge status: Accepted
sx,sy,tx,ty = map(int,input().split())
x = (tx-sx)
y = (ty-sy)

order = "L"

order += "U"*(y+1)
order += "R"*(x+1)
order += "D"

order += "R"
order += "D"*(y+1)
order += "L"*(x+1)
order += "U"

order += "U"*y
order += "R"*x
order += "D"*y
order += "L"*x
print(order)
# Judge status: Accepted
import queue

N, M = map(int, input().split())

rooms = [[] for _ in range(N + 1)]
parents = [-1] * (N + 1)
for m in range(M):
    A, B = map(int, input().split())
    rooms[A].append(B)
    rooms[B].append(A)

q = queue.Queue()
q.put((1, 0))
while(not q.empty()):
    x, p = q.get()
    if parents[x] != -1:
        continue
    parents[x] = p
    for connection in rooms[x]:
        if parents[connection] == -1:
            q.put((connection, x))
print('Yes')
for p in parents[2:]:
    print(p)
# Judge status: Accepted
n,m = map(int,input().split())
if 2*n >= m:
  print(m//2)
else:
  print(n+(m-2*n)//4)
# Judge status: Wrong Answer
N = int(input())
A = [0] * 5
for i in range(5): A[i] = int(input())
ans = 5
print(ans + N // min(A))
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(n//7+1):
    if (n-i*7)%4 == 0:
        ans = 1
        break
print(["No","Yes"][ans])
# Judge status: Accepted
x,y = map(int, input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C =[2]
if x in A and y in A or x in B and y in B or x in C and y in C:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
x = int(input())

x_sur = x % 100

if x_sur > 15:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
n, l = map(int, input().split())                                                               
moji_array = list(map(str, input().split()))
 
moji_array.sort()
 
result = ''.join(moji_array)
print(result)
# Judge status: Accepted
# coding: utf-8
# Your code here!
import math
N = int(input())

print(math.ceil(N / 2))
# Judge status: Wrong Answer
import sys
readline = sys.stdin.readline

n,m = map(int,readline().split())

l=1
r=n
for i in range(m):
  print(l,r)
  r -= 1
# Judge status: Accepted
s=input()
s=s[::-1]

for i in range(100000):
    if s[:5] == 'maerd':
        s = s[5:]
    if s[:5] == 'esare':
        s = s[5:]
    if s[:6] == 'resare':
        s = s[6:]
    if s[:7] == 'remaerd':
        s = s[7:]

if len(s)==0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
import itertools

n = int(input())
lst = [int(elem) for elem in range(1, n+1)]
p = list(itertools.permutations(lst))

ps = [int(elem) for elem in input().split()]
qs = [int(elem) for elem in input().split()]

print(abs(p.index(tuple(ps)) - p.index(tuple(qs))))
# Judge status: Accepted
N = int(input())
nums = list(map(int, input().split()))
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
L[0] = nums[0]
for i in range(N-1):
  L[i+1] = L[i] + nums[i+1]
  R[N-i-2] = R[N-i-1] + nums[N-i-1]
ans = 10**20
for i in range(N):
  ans = min(ans, abs(R[i]-L[i]))
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = input()
mx = -1
for i in range(1,n-1):
    x = set(s[0:i])
    y = set(s[i:])
    mx = max(mx,len(x & y))
print(mx)
# Judge status: Wrong Answer
N = int(input())
if (N < 105):
    print(0)
if (105 <= N < 135):
    print(1)
if (135 <= N < 189):
    print(2)
else:
    print(3)
# Judge status: Wrong Answer
#!/usr/bin/env python3
n = int(input())
cnt = [0] * (1 + n)
for a in range(1, 32):
    for b in range(1, 32):
        for c in range(1, 32):
            k = a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a
            if k > n:
                continue
            cnt[k] += 1
for i in range(1, n + 1):
    print(cnt[i])
# Judge status: Accepted

n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = a[0]
for i in range(n-1):
    ans = (ans + a[i+1])/2
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())

print(max(2*a-1,a+b,2*b-1))
# Judge status: Accepted
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
n, m  = map(int, input().split())
divs = make_divisors(m)
divs.sort()
ans = 0
for d in divs:
    if m // d >= n:
        ans = d
print(ans)
# Judge status: Wrong Answer
import itertools
n = int(input())
a = list(itertools.accumulate(list(map(int, input().split()))))
ans = 1000000000
sum_a = a[-1]
for i in range(n):
  ans = min(ans,abs(sum_a - 2 * a[i]))
print(ans)
# Judge status: Wrong Answer
s = input()
rs = reversed(s)

acc = sum([c == rc for c, rc in zip(s, rs)])

print(acc // 2)
# Judge status: Wrong Answer
s = str(input())
nikname = s[2:5]
print(nikname)
# Judge status: Accepted
s = input()
cnt0 = s.count('0')
cnt1 = s.count('1')
print(min(cnt0, cnt1) * 2)
# Judge status: Wrong Answer
h = int(input())
print(2 ** (h - 1) - 1)
# Judge status: Wrong Answer
#!/usr/bin/env python3
"""
RWとなってなければおｋ
WRはだめ
"""


def main():
    import sys

    input = sys.stdin.readline

    N = int(input())
    c = input()

    white, red = 0, c.count('R')
    ans = N
    for i in range(N):
        if c[i] == 'W':
            white += 1
        else:
            red -= 1
        res = max(white, red)
        ans = min(ans, res)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
elif 0<=x<=99 and 1<=y<12:
  print('YYMM')
else:
  print('NA')
# Judge status: Wrong Answer
x=int(input())
for i in range(240):
  for j in range(240):
    if (120-i)**5-(120-j)**5==x:
      print(i,j)
      exit()
# Judge status: Accepted
X = list(input())

cnt = 0
s = 0
for i in range(len(X)):
    if X[i] == "S":
        s += 1
    else:
        if s:
            cnt += 2
            s -= 1
print(len(X)-cnt)
# Judge status: Wrong Answer
a,b,c,d = (map(int,input().split()))
while True:
    a = a-d
    if a<=0:
        print ('No')
        break
    c = c-d
    if c<=0:
        print ('Yes')
        break
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

def main():

    N = int(input())
    S = input()

    listS = list(S)
    num = 0
    listNum = []

    for i in listS:
        if i == 'I':
            num += 1
            listNum.append(num)

        elif i == 'D':
            num += -1
            listNum.append(num)

    ans = max(listNum)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b,k=map(int,input().split())
print(max(0,a-k),max(0,b-max(0,k-a)))
# Judge status: Accepted
a,b,k = map(int,input().split())
i = 1
cand = []
while i<101:
  if a%i == 0 and b%i==0:
    cand.append(i)
  i += 1
  
print(cand[-k])
# Judge status: Wrong Answer
a = int(input())
b = int(input())
print(i for i in range(1,4) if i != a and i != b)
# Judge status: Accepted
S = int(input())
ans = [0]*2001
mod = 10**9+7

for i in range(0,76):
  if i <= 2:
    ans[i] = 0
  elif i <= 5:
    ans[i] = 1



for m in range(6,S+1):
  ans[m] = ans[m-1] + ans[m-3]

print(ans[S]%mod)
# Judge status: Accepted
X, K, D = list(map(int, input().split()))

if abs(X) > K*D:
    print(abs(X) - K*D)
else:
    X = abs(X)
    K -= X//D
    X = X%D
    if K%2 == 0:
        print(X)
    else:
        print(abs(X-D))
# Judge status: Wrong Answer
S = input()
Q=int(input())
Query=[S]
flag = True
for i in range(Q):
  x=input().split()
  if len(x)==1:
    flag = not flag
  else:
    if flag:
      if x[1]=="1":
        Query=[x[2]]+Query
      else:
        Query.append(x[2])
    else:
      if x[1]=="1":
        Query.append(x[2])
      else:
        Query=[x[2]]+Query
if flag==False:
  Query.reverse()

print("".join(Query))
# Judge status: Accepted
S = input()
D = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
print(7 - D.index(S))
# Judge status: Accepted
#!/usr/bin/env python3
def main():
    K, N = map(int, input().split())
    A = [int(x) for x in input().split()]

    max_length = A[0] + K - A[-1]
    for i in range(1, len(A)):
        max_length = max(max_length, A[i] - A[i - 1])
    print(K - max_length)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())

if N & 1 == 0:
	sum = 0
	N //= 10
	while N != 0:
		sum += N
		N //= 5
	print(sum)
else:
	print(0)
# Judge status: Accepted
a,b=map(int,input().split())
import math
x=min(math.floor(a/0.08),math.floor(b/0.1))
y=max(math.floor((a+1)/0.08),math.floor((b+1)/0.1))
for i in range(x,y):
    if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
        print(i)
        exit()
print(-1)
# Judge status: Accepted
val = {1, 2, 3}
val.remove(int(input()))
val.remove(int(input()))
print(list(val)[0])
# Judge status: Accepted
a=list(map(int,input().split()))
k=int(input())
a.sort()
for i in range(k):
    a[-1]*=2
print(sum(a))
# Judge status: Accepted
from collections import defaultdict

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

max1, max2 = 0, 0

for a in A:
    d[a] += 1
    if d[a] == 2:
        if a > max1:
            max2 = max1
            max1 = a
        elif a > max2:
            max2 = a

if d[max1] >= 4:
    ans = max1 * max1
else:
    ans = max1 * max2
print(ans)
# Judge status: Wrong Answer
import itertools

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    l = list(itertools.accumulate(A))
    
    if A[0] == 1 and len(A) == 1:
        return 1
    
    ans = 0
    for i in range(M, N):
        ans = max(ans, l[i] - l[i-M])
    
    ans = (ans+1) / 2
    
    return ans

print(solve())
# Judge status: Accepted
import itertools
n,m,q = map(int,input().split())
mx = 0
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
  ai,bi,ci,di = map(int,input().split())
  a[i] = ai-1
  b[i] = bi-1
  c[i] = ci
  d[i] = di
mx = 0
l = [i for i in range(m)]
for v in itertools.combinations_with_replacement(l, n):
  s = 0
  for i in range(q):
    if v[b[i]] - v[a[i]] == c[i]:
      s += d[i]
  if s > mx:
    mx = s
print(mx)
# Judge status: Wrong Answer
n = int(input())
ps = list(map(int, input().split()))
ans = 0

for i in range(1, len(ps)-1):
    if ps[i] == min(ps[i-1], ps[i], ps[i+1]):
        ans += 1
print(ans)
# Judge status: Accepted
import collections

n=int(input())
a=list(map(int,input().split()))
c = collections.Counter(a)

rkey=list(set(a))
list.sort(rkey, reverse=True)
rvalue=[c[i] for i in rkey]

for i in range(len(rvalue)):
  if rvalue[i]>=4:
    print(rkey[i]**2)
    exit()
  elif rvalue[i]>=2:
    width=rkey[i]
    rvalue.pop(i)
    rkey.pop(i)
    break
else:
  print("0")
  exit()
for i in range(len(rvalue)):
  if rvalue[i]>=2:
    height=rkey[i]
    break
else:
  print("0")
  exit()
print(width*height)
# Judge status: Wrong Answer
a=int(input())
if a % 500 == 0:
  print(a * 2)
else:
  print(round(a,-2) * 2 + int((a % 500) / 5) * 5)
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(1, N-1):
  if P[i-1] < P[i] < P[i+1]:
    ans += 1
  elif P[i+1] < P[i] < P[i-1]:
    ans += 1
print(ans)
# Judge status: Wrong Answer
A, B, C, D = map(int, input().split())
if A<C and B<D:
    print(B-C)
elif B<=C:
    print(0)
elif A<C and D<B:
    print(D-B)
# Judge status: Wrong Answer
x,y=map(int,input().split())
if abs(x) == abs(y):
    print(1)
elif x>=0 and y >=0:
    print(abs(x-y))
elif x<=0 and y<=0 and x<y:
    print(y-x)
else:
    print(abs(x-y)+2)
# Judge status: Accepted
x=int(input())
print('Yes' if x>=30 else 'No')
# Judge status: Accepted
X, Y = map(int, input().split())
k = 1
if X % Y == 0:
    print(-1)
    exit()
while 1:
    if (k * X) % Y == 0:
        k += 1
    else:
        ans = k * X
        break
print(ans)
# Judge status: Accepted
n = int(input())
friendliness = [int(s) for s in input().split()]

friendliness.sort(reverse=True)
print(friendliness[0] + 2 * sum(friendliness[1:n//2]) + (n%2) * friendliness[n//2])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
S = sorted(A, reverse=True)
w, h = 0, 0

cnt = 0
tmp = S[0]
for i in range(N):
  if S[i] == tmp:
    cnt += 1
    if cnt == 2:
      if w == 0:
        w = tmp
        cnt = 0
      else:
        h = tmp
        break
  else:
    cnt = 1
    tmp = S[i]
        
ans = w * h
print(ans)
# Judge status: Wrong Answer
s=input()
t=input()
sl=len(list(s))
tl=len(list(t))
for i in range(sl-tl+1):
    c=0
    for j in range(tl):
        if s[i+j]==t[j] or s[i+j]=='?':c+=1
        else:break
    if c==tl:
        print((s[:i]+t+s[i+tl:]).replace("?", "a"))
        exit()
print('UNRESTORABLE')
# Judge status: Accepted
from sys import stdin
x = int(stdin.readline().rstrip())

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
def lcm(a, b):
  return a * b // gcd(a, b)

ans = int(lcm(x, 360) / x)
print(ans)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
ans = 0
x = a*c
y = a*d
z = b*c
w = b*d
print(max(x,y,z,w))
# Judge status: Accepted
import math
s=int(input())
def sosuuukana(x):
    y=int(math.sqrt(x))
    f=0
    for i in range(2,y+1):
        if x%i==0:
            f=f+1
            break
    return f
while sosuuukana(s)>0:
    s=s+1
else:
    print(s)
# Judge status: Accepted
N,M = map(int,input().split())
cnt = 0

m = int(M/2)

if N >= m:
    cnt = m
elif m > N:
    cnt = N
    M -= 2*N
    cnt += int(M/4)

print(cnt)
# Judge status: Wrong Answer
n, m, x, y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

c = max(a)+1
d = min(b)
e = 0

if c > d:
    print("War")
else:
    for i in range(c,d+1):
        if x < i and i <= y:
            print("No War")
            print(i)
            e = 1
            break
    if e == 0:
        print("War")
# Judge status: Wrong Answer
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

peo = 1
bus = 1
out = T[0] + k

for t in T:
    if t <= out and peo < c:
        peo += 1
    else:
        out = t + k
        peo = 1
        bus += 1

print(bus)