peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
# abc159 c
L = int(input())
ans = 0
for H in range(L):
    for W in range(L-H):
        ans = max(H * W * (L-H-W), ans)
print(ans)
# Judge status: Accepted
N = input()

def rest_nine(x):
  for i in range(1, len(x)):
    if int(x[i]) != 9:
      return False
  return True

if rest_nine(N):
  print(int(N[0])+(len(N)-1)*9)
else:
  print(int(N[0])-1+(len(N)-1)*9)
# Judge status: Accepted
if __name__ == '__main__':
  N, K = map(int, input().split())
  D = list(input())
  
  x = N
  while True:
    if all(y not in D for y in list(str(x))):
      if x >= N:
        print(x)
        break
    x += 1
# Judge status: Accepted
# B - Box and Ball
N,M = map(int,input().split())
move = [list(map(int,input().split())) for _ in range(M)]
box = [[1,0] for _ in range(N+1)]
box[1][1] = 1
for x,y in move:
    box[x][0] -= 1
    box[y][0] += 1
    if box[x][1]==1:
        box[y][1] = 1
        if box[x][0]==0:
            box[x][1] = 0
print(sum(b[1] for b in box))
# Judge status: Accepted
import sys

input = sys.stdin.readline

def main():
    X, Y = map(int, input().split())
    if X%Y == 0:
        print(-1)
    else:
        print(X)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N,M,K=map(int,input().split())
flag=0
for i in range(N+1):
    for j in range(M+1):
        if (N-i)*j+(M-j)*i==K:
            flag=1
            break
if flag==1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def r(i):
    indr = s.find('<', i)
    return indr - i if indr != -1 else n - i - 1
def l(i):
    indl = s.rfind('>', 0, i)
    return i - indl -1 if indl != -1 else i 

s = input()
n = len(s) + 1
print(sum([max(r(i), l(i)) for i in range(n)]))
# Judge status: Accepted
from math import sqrt

N, M = map(int, input().split())
sqrtm = int(sqrt(M) + 1)
D = set()
for i in range(1, sqrtm):
    if M % i == 0:
        D.add(i)
        D.add(M // i)
D = sorted(list(D))
ans = 0
for d in D:
    if d * N <= M:
        ans = d
print(ans)
# Judge status: Accepted
N=input()
print("Yes" if N[0]==N[1]==N[2] or N[1]==N[2]==N[3] else "No")
# Judge status: Wrong Answer
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
q = tmp[0]

for i in range(4):
    l[i].append(tmp[i])
#print(l)
for i in range(4):
    l[i].append(l[i][1]*4/(l[i][0]*4))
#print(l)

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = int(input())
for i in range(4):
    tmp = n//l[i][0]
    if tmp >= 1:
        ans += tmp * l[i][1]
        n -= tmp*l[i][0]

print(int(ans))
# Judge status: Accepted
li = list(map(int,input().split()))
K = int(input())
li.sort(reverse = True )
li[0]=li[0]*2**K
ans = sum(li)
print(ans)
# Judge status: Wrong Answer
n = int(input())
L = list(map(int, input().split()))
A = sorted(set(L), reverse=True)
flag = 0
for a in A:
    if L.count(a) >= 4:
        if flag == 0:
            print(a * 2)
            break
        else:
            print(l * a)
            break
    elif L.count(a) >= 2:
        if flag == 0:
            l = a
            flag = 1
        else:
            print(l * a)
            break
else:
    print(0)
# Judge status: Wrong Answer
n,m = map(int,input().split())
mod = 10 ** 9 + 7
if abs(n - m) > 1:
  print(0)
if n == m:
  ans = 2
  for i in range(1,n+1):
    ans *= i*i
    ans %= mod
  print(ans)
else:
  ans = 1
  for i in range(1,min(n,m) + 1):
    ans *= i*i
    ans %= mod
  ans *= max(n,m)
  ans %= mod
  print(ans)
# Judge status: Accepted
n = int(input())
for i in range(1,1000):
  if n * i % 360 == 0:
    print(i)
    exit()
# Judge status: Wrong Answer
s = input()
print(s[2], end="")
print(s[1], end="")
print(s[0])
# Judge status: Accepted
import numpy as np
import sys

input = sys.stdin.readline

A,B,M = map(int,input().split())

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

res = np.min(a) + np.min(b)

for i in range(M):
    x,y,c = map(int,input().split())
    x-=1
    y-=1
    res = min(res,(a[x]+b[y]-c))

print(res)
# Judge status: Accepted
class Main:

    s1, s2= map(int,input().split());

    if s1 <= s2:
        print("unsafe");
    else:
        print("safe");
# Judge status: Accepted
import collections
N = int(input())
a = list(map(int, input().split()))
a = collections.Counter(a)
a_key = list(a.keys())
a_value = list(a.values())
cnt = 0
for i in range(len(a)):
    x = int(a_value[i])-int(a_key[i])
    if  x >= 0:
        cnt += x
    else:
        cnt += a_value[i]
print(cnt)
# Judge status: Wrong Answer
n,m=map(int,input().split())

if n==1 and m==1:
  print("0")
if n==1 and not m==1:
  print(m*(m-1)/2)
if m==1 and not n==1:
  print(n*(n-1)/2)
if not m==1 and not n==1:
    print(n*(n-1)/2+m*(m-1)/2)
# Judge status: Accepted
from collections import deque
s = deque(input())
q = int(input())

flag = 0
for _ in range(q):
  query = list(map(str, input().split()))
  if query[0] == "1": flag = 1 - flag
  else:
    if query[1] == "1":
      if flag == 0: s.appendleft(query[2])
      else: s.append(query[2])
    else:
      if flag == 0: s.append(query[2])
      else: s.appendleft(query[2])

if flag == 1: s.reverse()
print(*s, sep="")
# Judge status: Accepted
def resolve():
    import math
    N, M = list(map(int, input().split()))
    modfactor = 10**9+7
    if abs(N-M) >= 2:
        print(0)
        return
    NM = math.factorial(N) * math.factorial(M)
    print(NM%modfactor if N != M else (NM*2)%modfactor)

if '__main__' == __name__:
    resolve()
# Judge status: Wrong Answer
# join 20/03/28
def ruiwa(n):
  c=0
  ans=[]
  for i in range(n):
    c+=i
    ans.append(c)
  return ans

n,x,y=map(int,input().split())
dp=[j for i in range(n)for j in range(1,n)]
r=ruiwa(n)
for i in range(1,n):
  for j in range(i+1,n+1):
    if j<x:continue
    p=(n-1)*i-(n-j)-r[x]
    dp[p]=min(dp[p],x-i-~abs(j-y))
for i in range(n):
  print(dp.count(i))
# Judge status: Wrong Answer
n,m = map(int, input().split())
print(n,m)

ArA = [0]*n
ArB = [0]*n

for i in range(n):
	a,b = map(int, input().split())
	ArA[i] = a
	ArB[i] = b
	print(a,b)
#Sort
for j in range(n):
	mind = ArA[j]
	ind=j
	for i in range(j,n):
		if ArA[i] <= mind:
			ind=i
			mind=ArA[i]
	tmp = ArA[ind]
	ArA[ind]=ArA[j]
	ArA[j]=tmp
	tmp = ArB[ind]
	ArB[ind]=ArB[j]
	ArB[j]=tmp
		
    
print(ArA, ArB)
# Judge status: Accepted
n = int(input())
temp = 0
ans = 0
for i in range(n):
    a = int(input())
    if a != 0:
        q, r = divmod(a+temp, 2)
        ans += q
        temp = r
    else:
        temp = 0
print(ans)
# Judge status: Accepted
c = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
c.extend(c2)
c.extend(c3)
for a1 in range(c[0]+1):
  b1 = c[0]-a1
  b2 = c[1]-a1
  b3 = c[2]-a1
  a2 = c[3]-b1
  a3 = c[6]-b1
  ab = [a1,a2,a3,b1,b2,b3]
  for i in ab:
    if i < 0:
      break
  if (c[4]==a2+b2) & (c[5]==a2+b3) & (c[7]==a3+b2) & (c[8]==a3+b3):
    print("Yes")
    break
else:
  print("No")
# Judge status: Wrong Answer
def biserch(n,List):
    left = 0
    right = len(List)
    while left < right:
        mid = (left+right)//2
        if n < List[mid]:
            right = mid
        else:
            left = mid + 1
    
    return left
    
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        key = L[i] + L[j]
        anchor = biserch(key,L)
        
        ans += max(anchor - (j+1),0)

print(ans)
# Judge status: Wrong Answer
H, N = map(int, input().split())
A, B = [], []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

dp = [1e7]*(H+max(A)+1)
dp[0] = 0
for h in range(0,H):
  for n in range(N):
    dp[h+A[n]] = min(dp[h+A[n]], dp[h]+B[n])
print(min(dp[H:]))
# Judge status: Wrong Answer
n = int(input())
L = [input().split() for _ in range(n)]
d = {}
for s, p in L:
    if s not in d.keys():
        d[s] = [int(p)]
    else:
        d[s].append(int(p))
for i, v in enumerate(L, start=1):
    v.append(i)
for i in sorted(d):
    for j in sorted(d[i], reverse=True):
        print(d[i][d[i].index(j)])
        for k in range(n):
            if L[k][1] == d[i][d[i].index(j)]:
                print(L[k][2])
# Judge status: Accepted
n=int(input())
for i in range(n):
    n=n+i
print(n)
# Judge status: Wrong Answer
n,k=map(int, input().split())
ds=list(map(str, input().split()))
while True:
  for i in ds:
    if i in str(n):
      n+=1
      continue
  break
print(str(n))
# Judge status: Wrong Answer
n, d = map(int, input().split())
count = 0
for i in range(n):
    x, y = map(int, input().split())
    if (x ** 2 + y ** 2) ** 0.5 < d:
        count += 1
print(count)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
check1 = 0
check2 = 0
for i in range(N):
    if A[i]%2 == 0:
        check1+=1
for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3 == 0 or A[i]%5 == 0 :
            check2+=1
        else:
            check2+=0
    else:
        check2+=0
if check1 == check2:
    print("APPROVED")
elif check1 != check2:
    print("DENIED")
# Judge status: Accepted
# -*- coding: utf-8 -*-
from math import sqrt
x = int(input())

def prime(n):
    for i in range(2,int(sqrt(n))+1):
        if n%i==0:
            return False
    return True

for i in range(x,10**6):
    if prime(i):
        print(i)
        exit()
# Judge status: Accepted
n,k = map(int, input().split())
s = input()
 
t = s[:k-1]+s[k-1].lower()+s[k:]
print(t)
# Judge status: Accepted
n = int(input())
a = [0] * 10**5
for x in range(1, 101):
	for y in range(1, 101):
		for z in range(1, 101):
			a[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
for i in range(1, n + 1):
	print(a[i])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = set(A)
if len(A)==len(B):
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
import fractions
a=l[0]
for i in range(1,n):
   l[i]%=mod
   a=(a*l[i]//(fractions.gcd(a,l[i])))
print(a)
list=[(a//l[i]) for i in range(n)]
print(list)
print(sum(list)%mod)
# Judge status: Accepted
s = input()
if s == 'Sunny':
	print('Cloudy')
elif s == 'Cloudy':
	print('Rainy')
else:
	print('Sunny')
# Judge status: Wrong Answer
S = input()
if "a" and "b" and "c" in S:
    print( "Yes" )
else:
    print( "No" )
# Judge status: Wrong Answer
import math

X = int(input())
Money = 100

cnt = 0
while (Money <= X):
    if (X <= 103):
        Money = Money + Money * 0.01
        cnt = cnt + 1

    else:
        Money = Money + math.floor(Money * 0.01)
        cnt = cnt + 1

print(cnt)
# Judge status: Accepted
n = int(input())

ans = 0
D = {}
for i in range(n):
      s = "".join(sorted(input()))
      if s in D.keys():
            ans += D[s]
            D[s] += 1
      else:
            D[s] = 1
print(ans)
# Judge status: Wrong Answer
K = int(input())

if K % 2 == 0:
  print(-1)
  exit()

k = 7
cnt = 1
for i in range(10 ** 7):
  if k % K == 0:
    break
  k = (k * 10 + 7) % K
  cnt += 1
else:
  print(-1)

print(cnt)
# Judge status: Accepted
D = int(input())

for d in range(D):
    print(d % 26 + 1)
# Judge status: Wrong Answer
import math
N=int(input())
x=[]
min=10000000000000000
ans=0
sqN=math.ceil(math.sqrt(N))
for i in range(1,sqN+1):
  if N%i==0:
    j=int(N/i)
    a=[i,j]
    x.append(a)
for i,j in x:
  if i+j<=min:
    ans=i+j-2
    min=i+j
print(ans)
print(x)
# Judge status: Accepted
from queue import Queue
N, M = [int(i) for i in input().split()]
al = [[] for _ in range(N + 1)]
for _ in range(M):
    A, B = [int(i) for i in input().split()]
    al[A].append(B)
    al[B].append(A)
q = Queue()
q.put(1)
seen = [False] * (N + 1)
seen[1] = True
while not q.empty():
    v = q.get()
    for nv in al[v]:
        if not seen[nv]:
            q.put(nv)
            seen[nv] = v
print("Yes")
for i in seen[2:]:
    print(i)
# Judge status: Wrong Answer
import collections
a=collections.deque(list(input()))
b=collections.deque(list(input()))
c=collections.deque(list(input()))
next_=a.popleft()
while a and b and c:
    if next_=='a':next_=a.popleft()
    if next_=='b':next_=b.popleft()
    if next_=='c':next_=c.popleft()
print(str(next_).upper())
# Judge status: Accepted
def getWinPoint(c):
    if(c == "r"):
        return P
    elif(c == "p"):
        return S
    elif(c == "s"):
        return R
    else:
        return 0
    return 0

N, K = list(map(int, input().strip().split()))
R, S, P = list(map(int, input().strip().split()))
T = input()

ans = 0
hands = ""
for n in range(N):
    if(K <= n and T[n] == hands[n-K]):
        hands += "_"
        continue    
    ans += getWinPoint(T[n])
    hands += T[n]
print(ans)
# Judge status: Wrong Answer
s = input()

cnt = 0

for i in range(len(s)-2):
    if s[i] == s[i+1]:
        s = s[:i+1] + "0" + s[i+2:]
        cnt += 1
if s[-3] != "0" and s[-2] == s[-1]:
    cnt += 1

print(len(s) - cnt)
# Judge status: Wrong Answer
N = input()
hon = [2,4,5,7,9]
pon = [0,1,6,8]

if int(N[-1]) in hon:
    print('hon')
elif int(N[-1]) in pon:
    print(pon)
else:
    print('bon')
# Judge status: Wrong Answer
from collections import deque

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

graph=[[] for i in range(n)]

roomSign=[0]*n

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

D=deque([0])

while D:
    v=D.popleft()
    for i in graph[v]:
        if roomSign[i] == 0:
          roomSign[i]=v
          D.append(i)

print("Yes")

for i in range(1,n):
    print(roomSign[i]+1)
# Judge status: Accepted
a, b, c = map(int, input().split())
l = [a, b, c]
k = int(input())
print(sum(l) + max(l) * (2 ** k - 1))
# Judge status: Accepted
import math
X=int(input())

N=int(math.ceil(X/105))
dekiruka=0
while N <= X/100:
    if X-100*N <= 5*N:
        dekiruka=1
        break
    N=N+1

if dekiruka==1:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
print(round(sum(list(map(int, input().split())))/2))
# Judge status: Accepted
A,B,C=map(int,input().split())
count=0
if A%2==0 and A==B and A==C:
  print("-1")
  exit()
while True:
  if A%2==1 or B%2==1 or C%2==1:
    break
  a,b,c=A/2,B/2,C/2
  A,B,C=b+c,a+c,a+b
  count+=1
print(count)
# Judge status: Accepted
a, b, c, d = map(int, input().split())

if abs(c-a) <= d or abs(b-a) <= d and abs(c-b) <= d:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
w, h, x, y = map(int, input().split())


if x in [0, w] or y in [0, h]:
    print(w * h/2, 0)
else:
    if x * 2 == w and y * 2 == h:
        print(w * h / 2, 1)
    else:
        print(w * h/2, 0)
# Judge status: Wrong Answer
N = input()
raw_input1 = input()

l = raw_input1.split()
l_num = [int(x) for x in l]

flag = 0
flag1 = 0

for a in l_num:
    if a % 2 ==0:
        if a % 3 == 0 or a % 5 == 0:
            flag = 0
        else:
            flag = 1
    if flag != 0:
        break

if flag == 0:
    print('APPROVAL')
else:
    print('DENIED')
# Judge status: Accepted
n, k = map(int,input().split())
h =[int(input()) for i in range(n)]
h.sort()
ans = 1000000000000

for i in range(len(h)-k+1):
    if h[i+k-1] - h[i] < ans:
        ans = h[i+k-1] - h[i]
        if ans == 0:
            break

print(ans)
# Judge status: Wrong Answer
import math
N = int(input())
A = list(map(int, input().split()))
count = []
for i in A:
    if i%4 == 0:
        count.append("4")
    elif i%2 == 0:
        count.append("2")
    else:
        count.append("1")
B1 = count.count("4")
B2 = count.count("1") + math.ceil(count.count("2")/2)
print("Yes" if B1+1 >= B2 else "No")
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
hands = {"r": P, "s": R, "p": S}
K_list = [""]*K

for i in range(N):
    K_list[i % K] += T[i]

for k in range(K):
    K_list[k] = K_list[k].replace("rr", "r")
    K_list[k] = K_list[k].replace("ss", "s")
    K_list[k] = K_list[k].replace("pp", "p")

ans = 0
for k_list in K_list:
    for s in k_list:
        ans += hands[s]

print(ans)
# Judge status: Wrong Answer
N = int(input())

count = 0
flag = 0

for i in range(N):
  N,M = map(int, input().split())
  if N == M:
    count += 1
  else:
    count = 0
  if count >= 3:
    flag = 1
   
if flag == 1:
  print("yes")
else:
  print("no")
# Judge status: Wrong Answer
a = input().split()
a.sort()
print("".join(a))
# Judge status: Wrong Answer
A, B, C, D = map(int, input().split(" "))
Takahashi = {
  "attack": A,
  "HP": B
}

Aoki = {
  "attack": C,
  "HP": D
}
# print("resolve", A, B, C, D)
winner = True
while True:
  Aoki["HP"] = Aoki["HP"] - Takahashi["attack"]
  if (Aoki["HP"] <= 0):
    winner = True
    break

  Takahashi["HP"] = Takahashi["HP"] - Aoki["attack"]
  if (Takahashi["HP"] <= 0):
    winner = False
    break

print("Yes" if winner else "No")
# Judge status: Wrong Answer
#100
N, M = map(int,input().split())
if N == M:
    print("AC")
else:
    print("WA")
# Judge status: Accepted
#A
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

ant = [a,b,c,d,e]
flg = True
for i in range(5):
    for j in range(5):
        if i != j:
            #print(dist)
            dist = abs(ant[i]-ant[j])
            if dist > k:
                flg = False
                break
if flg:
    print('Yay!')
else:
    print(':(')
# Judge status: Wrong Answer
N = input()
TA = input().split()
T = int(TA[0])
A = int(TA[1])

first = True
place = 0
minTmep = 0

H = list(map(int, input().split()))
for i in range(0,len(H)):
    compare = abs(A - T - H[i] * 0.006)
    if first == True:
        place = i
        minTmep = compare
        first = False
    
    if minTmep > compare:
        place = i
        minTmep = compare

print(place + 1)
# Judge status: Accepted
S= str(input())
T= str(input())
#N,M,X = map(int,input().split())
#N = int(input())
#A = list(map(int,input().split()))

if T[:-1]==S:
    print('Yes')

else:
    print('No')
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
if (b-a<=d)&(c-b<=d):
    print("Yes")
elif (c-a<=d):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
if a <= x <= a + b:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
x = int(input())
if x%11 == 0:
    print(x//11*2)
elif x%11 >= 7:
    print(x//11*2+2)
else:
    print(x//11*2+1)
# Judge status: Accepted
n = int(input())
D = sorted(list(map(int, input().split())))
print(D[int(n / 2)] - D[int(n/ 2 - 1)])
# Judge status: Accepted
from collections import defaultdict
N = int(input())
d = defaultdict(int)
for _ in range(N):
    d[tuple(sorted(input()))] += 1
ans = 0
for i in d.values():
    ans += i*(i-1)//2
print(ans)
# Judge status: Wrong Answer
a = input()
if a == 'Sunny':
  print('Cloudy')
if a == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')
# Judge status: Accepted
A, B, M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(M)]

nouse = min(a) + min(b)
ans = []
ans.append(nouse)
for x in X:
    re, de, c = x
    ans.append(a[re-1] + b[de-1] - c)

print(min(ans))
# Judge status: Accepted
n, m = map(int, input().split())
a, b = [0]*m, [0]*m
for i in range(m):
    a[i], b[i] = map(int, input().split())
for j in range(1,n+1):
    print(a.count(j)+b.count(j))
# Judge status: Wrong Answer
N = int(input())
H = [int(i) for i in input().split()]
#  N = 5
#  H = [1, 2, 1, 1, 3]
#  N = 4
#  H = [1, 3, 2, 1]
#  N = 5
#  H = [1, 2, 3, 4, 5]
#  N = 1
#  H = [1000000000]
ret = True
prev = H[0]
peek = 0
for i in range(1, N - 1):
    peek = H[i + 1]
    h = H[i]
    if h - peek == 1:
        h -= 1
    # print(prev, H[i], h, peek)
    if h < prev:
        ret = False
        break
    prev = h
print("Yes" if ret else "No")
# Judge status: Accepted
a,b,x = map(int,input().split())
print(int(b//x)-int((a-1)//x))
# Judge status: Accepted
N=int(input())
binaly=[int(s) for s in input().split()]

boxes=[0 for _ in range(N)]
ans=set()

for i in range(N-1,-1,-1):
  if sum(boxes[i::i+1])%2!=binaly[i]:
    boxes[i]=1
    ans.add(i+1)
print(len(ans))
print(*ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) + [0]

ans = min(A[0], B[0])
rest = B[0] - ans
  
for i in range(N):
  #rest+B[i+1]でとA[i+1]をどれだけ倒せるか？
  curr = min(A[i+1], rest + B[i+1])
  rest = min(0, B[i+1] - curr)
  ans += curr
print(ans)
# Judge status: Wrong Answer
N = int(input())
a = []
cnt = 0
for i in range(N):
    b = int(input())
    if not b in a:
        a.append(b)
    else:
        cnt+=1
print(len(a)-cnt)
# Judge status: Accepted
s = input()
print(max([j for j, y in enumerate(s) if y == 'Z']) - min([i for i, x in enumerate(s) if x == 'A']) + 1)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

X=1000
Y=0

for k in range(N-1):
    if Y:
        X+=Y*A[k]
        Y=0
        
    if A[k]<A[k+1]:
        Y=X//A[k]
        X-=A[k]*Y

X+=A[-1]*Y
print(X)
# Judge status: Wrong Answer
a,b = map(int,input().split())
    
result = a+b
if result % 3==0 and a >=3 or b >= 3:
    print("Possible")

else:
    print("Impossible")
# Judge status: Wrong Answer
#input
N = int(input())
P = list(map(int, input().split()))

#output
answer = 1

for i in range(N-1):
    if P[i] > P[i+1]:
        answer += 1
print(answer)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

S = set(A)

if len(A) == len(S):
    print ('YES')
else:
    print ('NO')
# Judge status: Accepted
n = int(input())
ans = 0

for i in range(1, n+1, 2):
    cnt = 0
    for j in range(1, n+1):
        if(i % j == 0):
            cnt += 1
    if(cnt == 8):
        ans += 1

print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
li1 = [0 for _ in range(n)]
li2 = [0 for _ in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if a==0:
        li1[b] = 1
    elif b==n-1:
        li2[a] = 1

ans = False
for i in range(1,n-1):
    if li1[i] and li2[i]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
n, d = map(int, input().split())
ans = 0
for i in range(n):
    x, y = map(int, input().split())
    dis = (x**2+y**2)**0.5
    if dis <= d:
        ans += 1
print(ans)
# Judge status: Accepted
a,b,c,d=map(int,input().split())
if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N, K = map(int, input().split())
a = list(map(int, input().split()))
print(a[0])
b = []

for k in range(K):
    b = [0 for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if i - a[i]<= j and j <= i+a[i]:
                b[j] += 1
    for i in range(N):
        a[i] = b[i]
print(a)
# Judge status: Wrong Answer
lis = list(map(int,input().split()))
x = 0
for i in lis:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            x += 1
if x == 0:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Wrong Answer
def find(lst):
  d={}
  for i in lst:
    d.setdefault(i,0)
    d[i]+=1
  ans=0
  d1={}
  for i in d.keys():
    if d[i]==1:
      ans+=1
    else:
      d1.setdefault(d[i],0)
      d1[d[i]]+=1
  if len(list(d1.keys()))>0:
    for i in d1.keys():
      ans+=pow(i,d1[i])

  return ans

n=int(input())
lst=list(map(int,input().split()))
print(find(lst))
# Judge status: Accepted
X = int(input())
Y = X%100
Z = X//100
if Y > 5*Z:
  print(0)
else:
  print(1)
# Judge status: Accepted

import itertools
import sys
import math

sys.setrecursionlimit(10**9)

def comb(n, r):
    mod = 10**9 + 7
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * pow(i+1, mod-2, mod) % mod
    return res

def main():
    N, a, b = map(int,input().split())

    # print(comb(10**5,5000,10**9+7))
    nCa = comb(N,a)
    nCb = comb(N,b)

    _, ans = divmod(2**N-1 - nCa - nCb,10**9+7)
    print(ans)

if __name__ == "__main__":
  main()
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
h = list(map(float, input().split()))

dt = 1000
ans = 0
for i in range(len(h)):
    tmp = float(t) - 0.006 * h[i]
    if dt > abs( a - tmp ):
        dt = abs( a - tmp )
        ans = i + 1

print(ans)