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

def solve(k, r):
    count = {}
    ans = 0
    for i, n in enumerate(r):
        target = i-n
        ans += count.get(target, 0)
        count[i+n] = count.get(i+n, 0)+1
    return ans
k = int(input())
r = list(map(int, input().split()))
print(solve(k, r))
# Judge status: Accepted
n=int(input())
import math
s=round(math.sqrt(n))+1

i=2
c1=0
c2=1
ans=0
while i<=s:
    if n%i==0:
        n//=i
        c1+=1
        if c1==c2:
            c1=0
            c2+=1
            ans+=1
    else:
        c2=1
        i+=1
        c1=0
if n>s:
    ans+=1
    
print(ans)
# Judge status: Wrong Answer
K, A, B = map(int, input().split())

if (B - A) <= 2:
    print(K)
elif K <= A:
    print(K)
else:
    M = K - A + 1
    ans = A + M // 2 * (B - A) + M % 2
    print(ans)
# Judge status: Accepted
#abc132_b.py
def is_center(A,i):
    if (A[i-1]<A[i] and A[i]<A[i+1]) or (A[i-1]>A[i] and A[i]>A[i+1]):
        return True
    return False

N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(1,N-1):
    if is_center(A,i):
        cnt+= 1
print(cnt)
# Judge status: Wrong Answer
from collections import Counter
from operator import itemgetter
N, M = map(int, input().split())
dis_list = []
my_count = Counter()
for i in range(M):
    a, b = map(int, input().split())
    my_count[a] += 1
    my_count[b] += 1
my_count = sorted(my_count.items())
for i in my_count:
    print(i[1])
# Judge status: Wrong Answer
n, k = map(int, input().split())
A = list(map(int, input().split()))
A2 = [0] * n
A3 = [n] * n
 
if k > n:
  print(*A3)
else:
  for l in range(41):
    for j in range(n):
      if A[j] == n:
         A2[j] =n
      else:
        for i in range(n):
          if A[i] >= abs(i-j):
             A2[j] += 1
    A = A2
    A2 = [0] * n
    if A == [n]*n:
      break
 
print(*A)
# Judge status: Wrong Answer
r = float(input())
re1 = 1 * 1 * 3.14
re =  r * r * 3.14

print(int(re/re1))
# Judge status: Accepted
s = input()
key = 'keyence'
n = len(s)

for i in range(n):
    for j in range(i,n):
        cmp_s = s[:i]+s[j:]
        if cmp_s == key:
            print('YES')
            exit()
print('NO')
# Judge status: Wrong Answer

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

if a == 12:
    if b >= 12:
        print(12)
    else:
        print(11)
else:
    print(min(a,b))
# Judge status: Wrong Answer
x,y,z=map(int,input().split())
n=0
while y*n+z*(n+1)<=x:
  n+=1
print(n)
# Judge status: Wrong Answer
n = int(input())
l = list(map(int, input().split()))
Sum = sum(l)

print(Sum-min(l))
# Judge status: Accepted
n = int(input())

strings = {}

for i in range(n):
    s = "".join(sorted(list(input())))
    if s in strings:
        strings[s] += 1
    else:
        strings[s] = 1

print(sum(list(map(lambda x: x*(x-1)//2, strings.values()))))
# Judge status: Accepted
LI = lambda: list(map(int, input().split()))

S = input()


def main():
    if S[-1] == "s":
        ans = S + "es"
    else:
        ans = S + "s"
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n=int(input())
s = input()
ls = len(s)
ans = 0
for i in range(1,ls):
    ans = max(ans, s[:i].count('I')-s[:i].count('D'))
print(ans)
# Judge status: Accepted
import math

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

d = 10 ** 9 + 7

fn = math.factorial(n) % d
fm = math.factorial(m) % d

if abs(n - m) >= 2:
	print(0)
elif abs(n - m) == 1:
	print((fn * fm) % d)
elif abs(n - m) == 0:
	print((2 * fn * fm) % d)
# Judge status: Accepted
import math
N, K = map(int, input().split())
P = [i -1 for i in map(int,input().split())]
lgk = int(math.log(K,2))
last = P
point = 0
for j in range(lgk+1):
    if (K >> j) & 1:
        point = last[point]
    res = []
    for i in last:
        res.append(last[i])
    last = res

print(point+1)
# Judge status: Accepted
H,W=list(map(int,input().split()))
if H==1 and W==1:
   print(1)
   exit()
if H==1 or W==1:
   print(H*W-2)
   exit()
futi=(H+W)*2-4
print(H*W-futi)
# Judge status: Wrong Answer
n = int(input())
c = input()

wi = c.find('W') + 1
ri = c.rfind('R')

if wi == -1 or ri == -1:
    print(0)
else:
    ans = 0
    while wi < ri:
        wi = c[wi:].find('W') + wi
        ri = c[:ri].rfind('R')
        ans += 1

    print(ans)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
if (b-a)%2 != 0:
    if a-1 <= n-b:
        ans = (b - a -1)//2 + 1 + a-1
    else:
        ans = (b - a - 1)//2 + 1 + n-b
else:
    ans = min((b - a) / 2, b-1, n-a)
print(ans)
# Judge status: Accepted
n = int(input())
ls = list(map(int, input().split()))

s = ls[0]
a = sum(ls) - ls[0]

ans = abs(s - a)

for i in range(1, n - 1):
	s += ls[i]
	a -= ls[i]
	sa = abs(s - a)
	if sa < ans:
		ans = sa

print(ans)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
x = [0] * (10**5+2)

for i in a:
    x[i] += 1
    x[i+1] += 1
    x[i+2] += 1 
    
print(max(a))
# Judge status: Accepted
n = int(input())
arr = list(map(int,input().split()))
ans = arr[0]
for i in range(1,n):
    ans = ans^arr[i]

brr=[]
for i in range(n):
    brr.append(ans^arr[i])
print(*(brr),sep=" ")
# Judge status: Accepted
import math
import itertools

N = int(input())
L = []
cnt = 0

for i in range(N):
    xy = list(map(int, input().split()))
    L.append(xy)

for i in itertools.permutations(L,N):
    for j in range(len(i)-1):
        cnt += math.sqrt((i[j][0] - i[j+1][0])**2 + (i[j][1] - i[j+1][1])**2)

print(cnt / math.factorial(N))
# Judge status: Accepted
S = input()
if S[0] == "A":
    if S[2:-1].count("C") == 1:
        S2 = S.replace("A","")
        S3 = S2.replace("C","")
        if S3.islower() == True:
            ac = True
        else:
            ac = False
    else:
        ac = False
else:
    ac = False
if ac == True:
    print("AC")
else:
    print("WA")
# Judge status: Accepted
N = int(input())
array = list(map(int,input().split()))
d,f = 0,array[0]
ans = [0]
for i in range(1,N):
  n = array[i]
  d = f - n
  if d >= 0:
    ans.append(d)
  else:
    ans.append(0)
  if n > f:
    f = n
print( sum(ans) )
# Judge status: Accepted
def main():
    N, T = map(int, input().split())
    l = []
    cost = 1001
    for i in range(N):
        l.append(list(map(int, input().split())))
    for i in range(N):
        if l[i][1] <= T:
            t = l[i][1]
            if l[i][0] < cost:
                cost = l[i][0]
    if cost == 1001:
        print('TLE')
    else:
        print(cost)
main()
# Judge status: Wrong Answer
i = int(input())
print(i + i*2 + i*3)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
m = 1000
ind_st = 0
ind = 1
while ind_st < n:
    if ind < n:
        if a[ind]>=a[ind-1]:
            ind+=1
            continue
    
    kb = m//a[ind_st]
    m += kb*(a[ind-1]-a[ind_st])
    ind_st = ind
    ind = ind_st+1

print(m)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
x=[0]*(n+1)

for i in a:
    x[i]+=1
s=sum([x[i]*(x[i]-1)//2 for i in range(1,n+1)])


for i in range(n):
    k=a[i]
    p=x[k]*(x[k]-1)//2
    q=(x[k]-1)*(x[k]-2)//2
    print(s-p+q)
# Judge status: Accepted
N = int(input())
A = int(input())
if N % 500 <= A:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
# n=2
# a=[4,8]
minimum=10000000
for i in range(-100,100):
    cost=0
    for j in range(n):
        cost+=(i-(a[j]))**2
        if j==n-1:
            if cost<minimum:
                minimum=cost

print(minimum)
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))
if max(l) < sum(l) - max(l):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a,b,k=map(int,input().split())

ans=[]

for i in range(a,a+k):
  if i<=b:
    ans.append(i)
  
for i in range(b-k+1,b+1):
  if i>=a and i not in ans:
    ans.append(i)
    
ans.sort()

for a in ans:
  print(a)
# Judge status: Accepted
N = int(input())
H = list(map(int,input().split()))
f = True
for i in reversed(range(1,N)):
    if H[i-1]<=H[i]:
        continue
    elif H[i-1]-H[i] == 1:
        H[i-1] -= 1
    else:
        f = False
        break

if f:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import math

def main():
    N = int(input())
    ans = 0
    for a in range(1, int(math.sqrt(N))+1):
        for b in range(a, (N // a) + 1):
            if a * b >= N:
                break
            if a != b:
                ans += 2
            else:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
h = int(input())
num = 0
t = 0
while h != 1:
    h = h//2
    num += 2**t
    t += 1
num += 2**t
print(num)
# Judge status: Wrong Answer
N = 20
x = 800 * N
y = N // 15 * 200
print(x - y)
# Judge status: Accepted
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

check = [True] * (N + 1)

count = 0
tmp = 1
while check[tmp]:
    count += 1
    check[tmp] = False
    if A[tmp - 1] == 2:
        print (count)
        exit()
    tmp = A[tmp - 1]

print (-1)
# Judge status: Accepted
n, m = map(int, input().split())

print(int(n * (n - 1) / 2 + m * (m - 1) / 2))
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for _ in range(n)]
p = max(a)

try:
    q = max(set(a) - set([p]))
except ValueError:
    q = p

for i in a:
    print(q if i == p else p)
# Judge status: Accepted
S = str(input())
T = str(input())
ans = 'No'
s = [S[i] for i in range(len(S))]
for i in range(len(S)):
    s.append(S[i])
for i in range(len(S)):
    fr = 0
    for j in range(len(S)):
        if s[i + j] != T[j]:
            fr += 1
            break
    if fr == 0:
        ans = 'Yes'
print(ans)
# Judge status: Wrong Answer
n = int(input())
l0 = 2
l1 = 1
for i in range(n-1):
  sum = l0+l1
  l0 = l1
  l1 = sum
print(sum)
# Judge status: Accepted
import math
N = int(input())
A = list(map(int,input().split()))
l = list()
ll = list()
for i in range(len(A)):
  if A[i]%4 == 0:
    l.append(A[i])
  if A[i]%2 == 0:
    ll.append(A[i])
four = len(l)
two = len(ll)-four
zero = N-two
a = math.floor(N/2)
if a <= four:
  print("Yes")
elif a-two/2 <= four:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
str = input()
list = list(str)
abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
i = 0
while abc[i] in str:
    if i < 25:
        i += 1
    else:
        break

if i > 26:
    print(abc[i])
else:
    print("None")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

kabu = 0
yen = 1000

for i in range(N-1):
  if A[i] < A[i+1]:
    buy = yen//A[i]
    kabu += buy
    yen -= buy * A[i]
  elif A[i] > A[i+1]:
    yen += kabu * A[i]
    kabu = 0

if kabu > 0:
  yen += A[-1] * kabu
  kabu = 0

print(yen)
# Judge status: Wrong Answer
n = int(input())
m = input()

if len(m) < n :
    print(m)
else:
    print(m[:n]+"...")
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))
ma = max(a)
a.remove(ma)
num = 0
ind = 0
a.sort()
for i in range(N-1):
    if a[i] < ma//2:
        ind += 1

if ind == 0:
    print(ma,a[0])
    exit()
elif ind == N-1:
    print(ma,a[-1])
    exit()

if abs(ma//2 - a[ind-1]) < abs(ma//2 - a[ind]):
    print(ma,a[ind-1])
else:
    print(ma,a[ind])
# Judge status: Accepted
import math
a,b,x=map(float,input().split())
if x>=a**2*b/2:
    ans=math.degrees(math.atan(2*b/a-2*x/a**3))
else:
    ans=math.degrees(math.atan(a*b**2/(2*x)))
print(ans)
# Judge status: Accepted
h,w,k=map(int,input().split())
ans="No"
for i in range(h+1):
  for j in range(w+1):
    if i*j+(h-i)*(w-j) == k:
      ans="Yes"
print(ans)
# Judge status: Accepted
import sys

def hantei(s,t):
  for i in range(len(s)):
    if s[i] == t[i] or s[i] == '?':
      pass
    else:
      return False
    
  return True

s = list(input())
t = list(input())

for i in reversed(range(len(s)-len(t)+1)):
  if hantei(s[i:i+len(t)], t):
    for j in range(len(t)):
      s[i+j] = t[j]
        
    print(''.join(s).replace('?', 'a'))
    sys.exit(0)
    
print("UNRESTORABLE")
# Judge status: Wrong Answer
from scipy.special import comb

S = int(input())

n = S//3
k = S%3
Q = 10**9+7
ans = 0
for i in range(n):
    #iはしきりをとった数
    m = n-i #要素数
    ans += comb(n-1,i,exact=True)*comb(m,k,exact=True)
    if k==2:
        ans += k
    ans %=Q
print(ans)
# Judge status: Accepted
N = int(input())
Ali = list(map(int,input().split()))
bli = [0]*(N+1)
M = 0

for z in range(N):
  i = N-z
  #iの倍数の箱の和%2がAliと同じか調べる
  sb = 0
  for j in range(i*2,N+1,i):
    sb += bli[j]
  if sb%2 != Ali[i-1]:
    bli[i] = 1
    M += 1
    
print(M)

cnt = 0
for i in range(N+1):
  if bli[i] == 1:
    cnt += 1
    if cnt == M:
      print(i)
    else:
      print(i,end=" ")
# Judge status: Accepted
a,b=map(int,input().split())

if a==1 or b==1:
    print(1)
else:
    print((a*b+1)//2)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
tate = 0
yoko = 0
now = 0
#print(a)
for i in a:
    if tate == 0:
        if now == i:
            tate = now
            now = 0
            continue
    else:
        if now == i:
            yoko = now
            break
    now = i

print(tate * yoko)
# Judge status: Wrong Answer
import math
N = int(input())

if math.ceil(N / 1.08) != N:
  print(':(')
else:
  print(math.ceil(N / 1.08))
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
for i in range(m):
  a[0]=a[0]/2
  t=a[0]
  for j in range(1,n):
    if a[0]<a[j]:
      a.insert(j+1,a[0])
      del a[0]
      break
import math
ans=0
for i in range(n):
  ans=ans+math.floor(a[i])
print(ans)
# Judge status: Wrong Answer
import math
n,k = map(int, input().split())

L = []
while True:
  N = int(math.floor(math.log(n)/math.log(k)))
  L.append(N)
  n = n - k**N
  if n <= 2:
    print(len(L)+1)
    exit()
# Judge status: Wrong Answer
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
X = LI()
sort_X = sorted(X)
ans1,ans2 = sort_X[(N-1)//2],sort_X[N//2]
for x in X:
    if x==ans2:
        print(ans1)
    else:
        print(ans2)
# Judge status: Accepted
N = int(input())
x = []
for _ in range(N):
    s = input()
    x.append(s)
print('AC'+ ' '+ 'x'+ ' '+str(x.count('AC')))
print('WA'+ ' '+ 'x'+ ' '+str(x.count('WA')))
print('TLE'+ ' '+ 'x'+ ' '+str(x.count('TLE')))
print('RE'+ ' '+ 'x'+ ' '+str(x.count('RE')))
# Judge status: Wrong Answer
from functools import reduce
from fractions import gcd
n=int(input())
s=list(map(int,input().split()))

if n==2:
  print(max(s))
  exit()
ma=1
for i in range(len(s)-1):
  t=s[i]
  s[i]=s[i+1]
  c=reduce(gcd,s)
  ma=max(ma,c)
  s[i]=t

print(ma)
# Judge status: Accepted
# 解説そのまま
N, Q = map(int, input().split())
S = input()
t=[0]*(N+1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
# Judge status: Wrong Answer
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_max = max(x)
y_min = min(y)
if y_min - x_max >= 0:
    print("No War")
else:
    print("War")
# Judge status: Wrong Answer
n = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
total = 0
for i in range(n):
    if B[i] >= A[i]:
        total += A[i]
        B[i] -= A[i]
        if A[i+1]- B[i] < 0:
            total += A[i+1]
        else:
            total+= B[i]
            A[i+1] -= B[i]
    else:
        total += B[i]
print(total)
# Judge status: Accepted
n,k=map(int,input().split())
print(0 if n%k==0 else 1 )
# Judge status: Wrong Answer
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
for i in ab:
    l = []
    for j in cd:
        l.append(abs((j[0] - i[0]) + (j[1] - i[1])))
    print(l.index(min(l)) + 1)
# Judge status: Accepted
n, k = map(int, input().split())
h = list(map(int, input().split()))

h_sorted = sorted(h)
# kが0だった場合のルーチン
if(k == 0):
	print(sum(h_sorted))
else:
	print(sum(h_sorted[:-k]))
# Judge status: Wrong Answer
from decimal import Decimal
from math import floor

a, b = map(float, input().split())
res = Decimal(a) * Decimal(b)
print(floor(res))
# Judge status: Accepted
a, b = map(int, input().split())
if a%3 == 0:
    print("Possible")

elif b%3 == 0:
    print("Possible")

elif (a+b)%3 == 0:
    print("Possible")

else:
    print("Impossible")
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    if 2 * n > m:
        ans = min(n, m // 2)
    else:
        c = m - 2 * n
        ans = n + c // 4

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import deque
import sys
input = sys.stdin.readline
 
k = int(input())
n = 7
ans = -1
 
for i in range(10**6): #注意
  if n % k  == 0:
    ans = i+1
    break
  else:
    n =  (n % k) *10 + 7
    
print(ans)
# Judge status: Wrong Answer
x = int(input())
if x==3 or x==5 or x==7:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
#!/usr/bin/env python3
n, a, b, c, d = map(int, input().split())
s = input()
p = "##" not in s[a:max(c, d)]
if c > d:
    p *= "..." in s[b-2:d+1]
print(p and "Yes" or "No")
# Judge status: Accepted
X = int(input())
print((X//500)*1000 + ((X%500)//5)*5)
# Judge status: Accepted
time=0
n=int(input())
todo=[]*n

for i in range(n):
  a,b=map(int, input().split())
  todo.append([b,a])

todo.sort()
d=True

for i in range(n):
  time += todo[i][1]
  if todo[i][0]<time:
    d=False
    break

if d:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a,b,c = sorted(map(int,input().split()))
print(c*10+b+a)
# Judge status: Wrong Answer
def gho(x):
  g=1
  for i in range(1,x+1):
    g*=i
  return g

q,w=map(int,input().split())
e,d=divmod((2*w-q),3)
r,f=divmod((2*q-w),3)

if d!=0 or f!=0:print(0)
else:
  print((gho(e+r)%(10**9+7)//(gho(e)*gho(r)))%(10**9+7))
# Judge status: Accepted
N = int(input())
L = list(input() for i in range(N))
M = int(input())
T = list(input() for i in range(M))

Li = []
for i in set(L):
    if i not in T:
        K = 0
    else:
        K = T.count(i)
    Li.append(L.count(i) - K)

print(max(Li) if max(Li)>0 else 0)
# Judge status: Accepted
n = int(input())
lst = []
for _ in range(n):
    lst.append(sorted(list(input())))
lst.sort()
ans = 0
count = 0
for i in range(n-1):
    if lst[i] == lst[i+1]:
        count += 1
    else:
        ans += count*(count+1)//2
        count = 0
ans += count*(count+1)//2
print(ans)
# Judge status: Accepted
input()
x=list(map(int,input().split()))
z=sorted(x)[(len(x))//2-1:]
for c in x:print(z[c<=z[0]])
# Judge status: Accepted
import itertools
import sys

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i, j in itertools.product(range(n - m + 1), range(n - m + 1)):
	if a[i][j] == b[0][0]:
		for p, q in itertools.product(range(m), range(m)):
			if a[i + p][j + q] != b[p][q]:
				if i == n - m and j == n - m:
					print('No')
				break
			elif p == m - 1 and q == m - 1:
				print('Yes')
				sys.exit()
				
	elif i == n - m and j == n - m:
		print('No')
# Judge status: Accepted
x,a,b = map(int,input().split())
print('AB'[abs(a-x)>abs(b-x)::2])
# Judge status: Wrong Answer
n=int(input())
x=(10**n)%(10**9+7)
y=(9**n)%(10**9+7)
z=(8**n)%(10**9+7)
print(z-2*y+x)
# Judge status: Accepted
li = list(map(int,input().split()))
k=int(input())

cnt=0
while li[0]>=li[1]:
  li[1]*=2
  cnt+=1

while li[1]>=li[2]:
  li[2]=2*li[2]
  cnt+=1 

if cnt<=k:
  print("Yes")
elif cnt>k:
  print("No")
# Judge status: Accepted
n, k = map(int, input().split())
p = list(map(int, input().split()))


def expectation(value):
    return 0.5 * (value + 1)


res = 0
for l in range(k):
    res += expectation(p[l])

cur = res
for l in range(k, n):
    cur += expectation(p[l]) - expectation(p[l-k])
    res = max(res, cur)
print(res)
# Judge status: Wrong Answer
N = int(input())
if N%9 == 0:
    print("yes")
else:
    print("no")
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
b = 0
bi = 0
c = 0
for i in range(n - 1):
    if a[i] == a[i + 1]:
        b = a[i]
        bi = i + 1
        break
if bi != 0:
    for i in range(bi + 1, n - 1):
        if a[i] == a[i + 1]:
            c = a[i]
            break
print(b * c)
# Judge status: Accepted
from collections import deque

N = int(input())
closings = list(input())
r_cnt = l_cnt = 0
for closing in closings:
  if closing == ')':
    if l_cnt > 0:
      l_cnt -= 1
    else:
      r_cnt += 1
  else:
    l_cnt += 1
answer = ['(' for _ in range(r_cnt)] + closings + [')' for _ in range(l_cnt)] 
print(''.join(answer))
# Judge status: Accepted
N = int(input())
print(0) if N == 1 else print(1)
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))

n4,n2=0,0
for i in range(N):
  if a[i] % 4 == 0:n4 += 1
  elif a[i] % 2 == 0:n2 += 1
    
if n4 >= N//2:print('Yes')
elif n4*2 + n2 >= N:print('Yes')
else:print('No')
# Judge status: Accepted
N, M = map(int, input().split())
mod = 10 ** 9 + 7
A = [1] * (N+1)
for i in range(M):
  A[int(input())] = 0
if N == 1:
  print(1)
else:
  p = 1
  q = 1
  for i in range(2, N+1):
    r = A[i-2] * p + A[i-1] * q
    p = q
    q = r % mod
  print(q)
# Judge status: Wrong Answer
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
al=[a[2*i] for i in range(n//2)]
bo=[a[2*i+1] for i in range(n//2)]
print(sum(al)-sum(bo))
# Judge status: Accepted
s=list(input())
diff=1000000
for i in range(len(s)-2):
  x=int(''.join(s[i:i+3]))
  diff = min(diff, abs(753-x))
  #print(x)
print(diff)
# Judge status: Wrong Answer
h, a = map(int, input().split())

if h % 2 == 0:
  	print(h // a)
else:
	print(h // a + 1)
# Judge status: Wrong Answer
N = int(input())
a = [int(s) for s in input().split()]
b = sum(a)
c = int(0)
i = int(0)
sabun = int(0)
sabun2 = int(0)
count = int(0)

for i in range(N):
  if sabun >= 0:
    b = b - a[i]
    c = c + a[i]
    sabun = b - c
    i = i + 1
    print(sabun)
  else:
    sabun2 = sabun + a[i-1] * 2
    print(sabun2)
    break

print(int( min([abs(sabun),abs(sabun2)]) ))
# Judge status: Accepted
N, M = map(int,input().split())
 
print(N*(N-1)//2 + M*(M-1)//2)
# Judge status: Wrong Answer
N=int(input())
A=int(input())

for x in range(min(A,500)):
  if (N-x)%500==0:
    print("Yes")
    break
else:
  print("No")
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))

n = A.index(1)
ans = ((n+1) // (K-1)) + ((N-n) // (K-1))
print(ans)
# Judge status: Wrong Answer
N = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i + j*j + k*k + k*j + i*k + i*j
            if v < 10050:
                ans[v] += 1

for i in range(N):
    print(ans[i])
# Judge status: Accepted
a , b = map(int,input().split())

print(a*b)
# Judge status: Accepted
s = int(input())

div, mod = divmod(s, 10 ** 9)
ans = [0, 0, 10 ** 9, 1, 0, div]
if mod != 0:
    ans[4:] = [10 ** 9 - mod, div + 1]
print(*ans)
# Judge status: Accepted
N, K = map(int, input().split())
H = list(int(input()) for _ in range(N))
H.sort()
ans = 10 ** 18
for i in range(N - K + 1):
    tmp = H[i + K - 1] - H[i]
    ans = min(ans, tmp)
print(ans)
# Judge status: Accepted
import collections
from collections import deque

n,m = list(map(int,input().split()))
li = [[] for i in range(n)]

for i in range(m):
  a,b = list(map(int,input().split()))
  li[a-1].append(b-1)
  li[b-1].append(a-1)

michi = [None for i in range(n)]
q = deque([0])
while q:
    pop = q.popleft()
    for i in li[pop]:
        if michi[i] is None:
            michi[i] = pop
            q.append(i)
print("Yes")
for i in range(1,len(michi)):
    print(michi[i]+1)
# Judge status: Accepted
a,b = map(int,input().split())
s = input()

for i in range(a):
  if s[i] == '-':
    print('No')
    exit()
if s[a] != '-':
  print('No')
  exit()
for i in range(a+1,a+b+1):
  if s[i] == '-':
    print('No')
    exit()
print('Yes')