peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
alphabet = 'abcdefghijklmnopqrstuvwxyz'
s = input()
K = int(input())
ans = ''
for i in range(len(s) - 1):
    s_i = alphabet.index(s[i])
    if s_i == 0:        
        continue
    elif 26 - s_i < K:
        K -= 26 - s_i
        s_i = 0
    ans += alphabet[s_i]
s_i = (alphabet.index(s[-1]) + K) % 26
ans += alphabet[s_i]
print(ans)
# Judge status: Accepted
n = int(input())
a = int(input())
if n%500 > a:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
S = input( '今日の天気は？' )

if S == 'Sunny':
    answer = 'Cloudy'
elif S == 'Cloudy':
    answer = 'Rainy'
elif S == 'Rainy':
    answer = 'Sunny'
else:
    answer = '入力間違い【Sunny】【Cloudy】【Rainy】を入力'

print('明日の天気は',answer)
# Judge status: Accepted
N, M = map(int, input().split())
MIN = 0
MAX = 110000
        
for i in range(M):
    L, R = map(int, input().split())
    MIN = max(MIN, L)
    MAX = min(MAX, R)
    #print(MIN, MAX)

ans = MAX-MIN+1 if MAX >= MIN else 0
print(ans)
# Judge status: Wrong Answer
def solve():
    X = int(input())
    p = X / 100
    q = X % 100
    if 0 <= q <= 5 * p:
        print(1)
    else:
        print(0)

if __name__ == "__main__":
    solve()
# Judge status: Accepted
A, B = map(int, input().split())
print(A * B if A <= 9 and B <= 9 else -1)
# Judge status: Wrong Answer
a = int(input())
print(int((a)*(a-1)/2))
# Judge status: Accepted
n = int(input())

res = 100000
for i6 in range(0, n+1, 6):
    c6, c9 = 0, 0
    i9 = n - i6
    while (i6 > 0):
        c6 = c6 + (i6%6)
        i6 = i6 // 6
    while (i9 > 0):
        c9 = c9 + (i9%9)
        i9 = i9 // 9

    if c6 + c9 < res:
        res = c6 + c9

print(res)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**5)
def GCM(a, b):
  a, b = max(a,b), min(a, b)
  r = a % b
  if r == 0:
    return b
  else:
    return GCM(b, r)

def LCD(a, b):
  g = GCM(a, b)
  return (a//g)*b

N, M = map(int, input().split())
A = list(map(int, input().split()))
X = A[0]//2
for a in A[1:]:
  b = a//2
  newX = LCD(X, a//2)
  if (newX // b)%2 == 0:
    print(0)
    sys.exit(0)
  else:
    X = newX
X_2 = X*2
print(M//X-M//X_2)
# Judge status: Wrong Answer
l=[int(input()) for i in range(5)]
mod=sorted([10-n%10 for n in l])
c=mod.count(10)
print(sum(l)+sum(mod)-mod[4-c]-10*c)
# Judge status: Accepted
n = int(input())

res = 0
for a in range(1, n):
    max_b = int((n-1)/a)
    res += max_b

print(res)
# Judge status: Accepted
N, L = map(int, input().split())
S = [str(input()) for i in range(N)]

S = sorted(S)


print(''.join(S))
# Judge status: Wrong Answer
n, m = list(map(int, input().split()))
ss = []
cs = []
for i in range(m):
    s, c = list(map(int, input().split()))
    ss.append(s)
    cs.append(str(c))

ans = ["_"] * n

for s, c in zip(ss, cs):
    # print(f"ans={ans}: s={s}, c={c}")
    if ans[s-1] == "_" or ans[s-1] == c:
        ans[s-1] = c
    else:
        print("-1")
        exit()

if ans[0] == "0":
    print("-1")
    exit()

if ans[0] == "_":
    ans[0] = "1"

print("".join(ans).replace("_", "0"))
# Judge status: Accepted
n = int(input())
if n<=999: print('ABC')
else: print('ABD')
# Judge status: Accepted
n, p = map(int, input().split())
a = list(map(int, input().split()))

count = 0
for i in a:
    if i%2 == 0:
        count += 1
if count == n:
    if p == 1:
        print(0)
    else:
        print(2**n)
else:
    print(2**(n-1))
# Judge status: Accepted
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n = I()
    a = LI()
    bemax = a[0]
    ans = 0
    for i in a[1:]:
        if i > bemax:
            bemax = i
        elif i < bemax:
            ans += bemax - i
    print(ans)
main()
# Judge status: Accepted
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N<=K:
  print(N*X)
else:
  print((K*X)+(N-K)*Y)
# Judge status: Accepted
al = [list(map(int, input().split())) for i in range(3)]
al = sum(al, [])
n = int(input())
bl = [int(input()) for i in range(n)]
check = [0 for i in range(9)]

for b in bl:
    if b in al:
        check[al.index(b)] = 1

if [1,1,1] in [check[:3], check[3:6], check[6:], check[0:7:3], check[1:8:3], check[2:9:3], check[0:9:4], check[2:8:2]]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
print(["Impossible", "Possible"][eval(input().replace(" ","*"))%3==0])
# Judge status: Wrong Answer
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.buffer.readline().rstrip())
    V = list(map(int, sys.stdin.buffer.readline().split()))
    V.sort(reverse=True)

    ret = 0
    for n in range(N-1):
        ret = (V[n] + V[n+1]) / 2

    print(ret)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
a,b,c=map(int, input().split())
if (a+b)>c:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a,b,n = map(int, input().split())
# ans = []
if(b-1<=n):
    i = b-1
else:
    i = n
# for i in range(0, n):
ans = (a*i)//b - a*(i//b)
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
if n == 1 or m == 1:
    if n == m == 1:
        ans = 1
    else:
        ans = max(n - 2, m - 2)
else:
    ans = (n - 2) * (m - 2)
print(ans)
# Judge status: Accepted
N,K=map(int,input().split(' '))
ans = 0
while N > 0:
    ans += 1
    N -=K
    if N > 0:
        N+=1
print(ans)
# Judge status: Wrong Answer
s1 = input()
s2 = input()
 
for i in range(len(s1)):
  count = len(s1)
  if s1[i] == s2[i]:
    count -= 1
    
print(count)
# Judge status: Accepted
A,B,C = map(int,input().split())
if A % 2 == 1 and B % 2 == 1 and C % 2 == 1:
    print(min(A*B,B*C,C*A))
else:
    print(0)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
INF = 10**9

dp0 = [0]
dp1 = [-INF-1]

for i, x in enumerate(A):
  dp0.append( max(dp0[i] + x, dp1[i] - x) )
  dp1.append( max(dp0[i] - x, dp1[i] + x) )

print(dp0[-1])
# Judge status: Accepted
N,M = map(int, input().split())
A = list(map(int, input().split()))
print(max(N-sum(A),-1))
# Judge status: Accepted
N, M = map(int, input().split())
AB = [0] * N
for i in range(N):
    AB[i] = list(map(int, input().split()))
AB.sort(key=lambda AB: AB[0])

cnt = 0
ans = 0
for i in range(N):
    cnt += AB[i][1]
    ans += AB[i][0] * AB[i][1]
    if cnt > M:
        ans -= (cnt - M) * AB[i][0]
        break
print(ans)
# Judge status: Wrong Answer
a, b, c, k = map(int, input().split())

flag = True
for i in range(10**18):
    if k == 0:
        break
    if a == b and b == c:
        break
    A = a
    B = b
    C = c
    a = B + C
    b = A + C
    c = A + B
    if i == k - 1:
        break
    if a > 10**19:
        flag = False
        break
if flag:
    print(a - b)
else:
    print('Unfair')
# Judge status: Wrong Answer
N, K, Q = map(int,input().split())
a = []
for i in range(Q):
    A = int(input())
    a.append(A)
if K > Q:
    for i in range(N):
        print('Yes')
for i in range(1,N + 1):
    if Q - K + 1 <= a.count(i):
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
def default():
    t=int(input())
    print(min(360//t,306//(180-t)))
if(__name__=="__main__"):
    default()
# Judge status: Accepted
N, K = map(int, input().split())
X = list(map(int, input().split()))
ret = 10 ** 9
for i in range(N-K+1):
    width = X[i+K-1] - X[i]
    mi = min(abs(X[i+K-1]), abs(X[i]))
    ret = min(ret, width+mi)

print(ret)
# Judge status: Wrong Answer
def main():
    S = input()

    if S[0] == 'A':
        if S[2]=='C' or S[3]=='C':
            S = S[1]+S[4:]
            if S.islower():
                print('AC')
                return
    print('WA')

if __name__ == '__main__':
    main()
# Judge status: Accepted
N=int(input())
result=0
for i in range(0,N+1):
    if i%2 != 0:
        result+=1
    else: 
        result+=0
print(float(result/N))
# Judge status: Accepted
s=input()
ans=""
for i in range(3):
    ans+=s[i]
print(ans)
# Judge status: Accepted
list=[]
for i in range(1,10):
  for j in range(1,10):
    list.append(i*j)

if int(input()) in list:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import collections

N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q)]
c = collections.Counter(A)

if (K - Q) > 0:
    for _ in range(N):
        print('Yes')
else:
    l = []
    for i,v in dict(c).items():
        if v >(Q - K):
            l.append(i-1)
    for j in range(N):
        if j in l:
            print('Yes')
            l.pop()
        else:
            print('No')
# Judge status: Accepted
from collections import deque

n = int(input())
A = list(map(int,input().split()))
que = deque()

for i in range(n):
    if i % 2 == 0:
        que.appendleft(A[i])
    else:
        que.append(A[i])
else:
    if n % 2 == 0:
        que.reverse()
    print(*que)
# Judge status: Wrong Answer
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(k * x + (n - k) * y)
# Judge status: Accepted
N = int(input())
S = input().strip()

ans = ""

l = 0
r = 0

for i in range(N):
    if S[i] == "(":
        l += 1
        ans += "("
    else:
        r += 1
        if l >= r:
            ans += ")"
        else:
            ans = "(" + ans + ")"
            l += 1

while l < r:
    ans = "(" + ans
    l += 1
while l > r:
    ans += ")"
    r += 1

print(ans)
# Judge status: Wrong Answer
A,B,C,D = map(int,input().rstrip().split(" "))
print(min(B,D) - max(A,C))
# Judge status: Accepted
import sys
import bisect

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
INF = 10 ** 10
dp = [INF] * N
# マイナスの値にしてLongest Increasing Sequence
for _ in range(N):
    a = 10 ** 9 - ir()
    i = bisect.bisect_right(dp, a)
    dp[i] = a

index = bisect.bisect_left(dp, INF)
print(index)
# 04
# Judge status: Accepted
s = input()
if len(s) == len(set(s)):
    print("yes")
else:
    print("no")
# Judge status: Wrong Answer
X = int(input())

if X >=1800 and X <1999:
    print(1)
elif X >=1600 and X <=1799:
    print(2)
elif X >=1400 and X<=1599:
    print(3)
elif X >=1200 and X<=1399:
    print(4)
elif X >= 1000 and X <=1099:
    print(5)
elif X >= 800 and X <= 999:
    print(6)
elif X >= 600 and X <= 799:
    print(7)
elif X >= 400 and X <= 599:
    print(8)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

nmax = max(a)
target = nmax/2

cur = a[0] if a[0] != nmax else a[1]
curdiff = abs(cur-target)

for i in range(n):
    if a[i] == nmax:
        continue

    diff = abs(a[i]-target)

    if diff < curdiff:
        curdiff = diff
        cur = a[i]

print(nmax, cur)
# Judge status: Accepted
s=list(input())
flag=True
for i in range(1,len(s)+1):
    v=s[i-1]
    if i%2==0:
        if v=="L" or v=="U" or v=="D":
            pass
        else:
            flag=False
            break
    else:
        if v=="R" or v=="U" or v=="D":
            pass
        else:
            flag=False
            break
if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
c=100000
ans=0
for i in range(N):
  if c>abs(T-H[i]*0.006-A):
    c=abs(T-H[i]*0.006-A)
    ans=i+1
print(ans)
# Judge status: Accepted
#C
N = int(input())

inf = float("inf")
MIN = inf

for i in range(1,10**6+1):
    if N%i == 0:
        MIN = min(MIN,(i-1) + (N//i - 1))

print(MIN)
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
print(A*B/2)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  A = []
  for i in range(N):
    s, p = input().split()
    p = int(p)
    A.append((s, -p, i+1))
  A.sort()
  for s, p, i in A:
    print(i)
  
if __name__ == '__main__':
  main()
# Judge status: Accepted
N,M,K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
B = list(map(int,input().split(" ")))

time_A = [0]*(N+1)
time_B = [0]*(M+1)

for i in range(N):
    time_A[i+1] = time_A[i] + A[i]
for j in range(M):
    time_B[j+1] = time_B[j] + B[j]

ans = 0
l = M

for k in range(N+1):
    if time_A[k] > K:
        break
    while time_A[k] + time_B[l] > K:
        l -= 1
    ans = max(ans,k+l)

print(ans)
# Judge status: Accepted
c = [[int(i) for i in input().split()] for j in range(3)]
f = True
a, b = c[0][0] - c[0][1], c[0][1] - c[0][2]
for i in range(1, 3):
    if not(c[i][0] - c[i][1] == a and c[i][1] - c[i][2] == b):
        f = False
a, b = c[0][0] - c[1][0], c[1][0] - c[2][0]
for i in range(1, 3):
    if not(c[0][i] - c[1][i] == a and c[1][i] - c[2][i] == b):
        f = False
print("Yes" if f else "No")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

ans = [0] * n

for i in a:
    ans[i - 1] += 1

for j in ans:
    print(j)
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n,m = iim()
cand = []
check = []
for i in range(m):
    a,b = iim()
    if a == 1:
        cand.append(b)
    if b == n:
        check.append(a)

cand = set(cand)
flag=False
for i in check:
    if i in cand:
        flag = True

print('POSSIBLE' if flag else 'IMPOSSIBLE')
# Judge status: Accepted
N, R = map(int, input().split())

print(R + 100 * max(0, 10 - N))
# Judge status: Accepted
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

def main():
    N = int(input())
    ans = 0
    for n in range(1, N + 1):
        k = N // n
        ans += n * k * (k + 1) // 2
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
A, B, C, D = map(int, input().split())
t = min(B, D) - max(A, C)
print(t if t > 0 else 0)
# Judge status: Wrong Answer
S = input()
C = [S.count('a'), S.count('b'), S.count('c')]
if len(set(list(S))) == 3 and max(C) - min(C) < 2:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
n=int(input())
k=map(int,input().split())
p=sorted(k)
print(p[-1]-p[0])
# Judge status: Wrong Answer
x = list(input())
box = []

for i in range(len(x)):
    if x[i] == "S": box.append(x[i])
    else:
        if len(box) == 0 or box[-1] == "S":
            box.append(x[i])
        else: box.pop(-1)
print(len(box))
# Judge status: Accepted
a, b = map(int, input().split())
if (a+b)%2 == 0:
     print((a+b)//2)
else:
     print('IMPOSSIBLE')
# Judge status: Accepted
n,m,x = (int(x) for x in input().split())

la=[]
for i in range(n):
  la.append(list(map(int, input().split())))

y = 0
for i in range(2 ** n):
  lb = [0]*(m+1)
  for j in range(n):
    if ((i >> j) & 1):
      lb = [x + y for (x, y) in zip(lb, la[j][:])] 
  frg=1
  for h in range(m):
    if lb[h+1]<x:
      frg=0
  if frg==1:
    if lb[0] <= y or y==0:
      y=lb[0]
  del lb[:]
print(y if y>0 else -1)
# Judge status: Accepted
S, W = [int(_) for _ in input().split()]
if W >= S:
    print('unsafe')
else:
    print('safe')
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
dp =[]

for i in range(n):
  if i == 0:
    dp.append(0)
  elif i == 1:
    dp.append(abs(h[1]-h[0]))
  else:
    dp.append(min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]))    

print('{}'.format(dp[n-1]))
# Judge status: Wrong Answer
n=int(input())
dp=[100000]*n
h=list(map(int,input().split()))
dp[0]=0
for i in range(n):
   for j in range(i+1,i+3):
       if j<n:
           dp[j]=min(dp[j],abs(h[i]-h[j])+dp[i])
print(dp[n-1])
# Judge status: Accepted
s = input()
list_s = list(set(s))
ans = ''
if len(set(s)) == 4:
    ans = 'Yes'
elif len(list_s) == 2 and list_s.count('E') == list_s.count('W'):
    ans = 'Yes'
elif len(list_s) == 2 and list_s.count('N') == list_s.count('S'):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)
# Judge status: Wrong Answer
from scipy.special import comb
import copy

MOD = 10**+7
s = int(input())
cnt = 0
ans = 1

if s <= 2:
    print(0)
else :
    s = s-3
    while s >= 3:
        s -= 3
        cnt += 1
        if s > 0:
            ans += comb(s+cnt, cnt, exact=True)%MOD
        else :
            ans += 1
    print(ans)
# Judge status: Wrong Answer
S = int(len(input()))

cnt = "*"
length = 0
a = "*"

while S != length:
    cnt = cnt + a
    length = len(cnt)

print(cnt)
# Judge status: Wrong Answer
import sys

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


ans = 0
for a in A:
    ans += abs(a)

c = 0
m = A[0]
for a in A:
    if a < 0:
        c += 1
    elif a == 0:
        print(ans)
        sys.exit()

    if abs(a) < m:
        m = abs(a)

if c % 2 == 0:
    print(ans)
else:
    print(ans - 2 * m)
# Judge status: Wrong Answer
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

cnt=0
for i in range(n):
    for j in range(i+1,n):
        sum=0
        for k in range(d):
            sum += (x[i][k]-x[j][k])**2
            route = sum**0.5
            if route.is_integer:
              cnt += 1

print(cnt)
# Judge status: Accepted
A = sorted(list(map(int,input().split())))
print(A[0]*A[1]*(A[2]-(A[2]//2)*2))
# Judge status: Wrong Answer
k = int(input())
seven = 7
count = 0

while True:
    if k % 2 == 0:
        count = -1
        break

    elif seven % k == 0:
        count += 1
        break
    else:
        count += 1
        seven = (seven * 10 + 7) % k

print(count)
# Judge status: Accepted
import heapq

N, M = map(int, input().split())
A = [-x for x in map(int, input().split())]

heapq.heapify(A)
for i in range(M):
    tmp = -heapq.heappop(A)
    tmp = tmp // 2
    heapq.heappush(A, -tmp)
    # print(A)
print(-sum(A))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
lis = [0]*n
for i in range(n-1):
    if a[i] > a[i+1]:
        lis[i] = -1
b = a[::-1]
for i in range(n-1):
    if b[i] > b[i+1]:
        lis[i] = 1
lis[-1] = -1
m = 1000
k = 0
for i in range(n):
    if lis[i] == 1:
        k += m//a[i]
        m = m%a[i]
    elif lis[i] == -1:
        m += k*a[i]
        k = 0

print(m)
# Judge status: Accepted
[N, K] = [int(i) for i in input().split()]
point_list = [int(i) for i in input().split()]

for i in range(N):
    if i >= K:
        if point_list[i-K] < point_list[i]:
            print("Yes")
        else:
            print("No")
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 16:16:15 2020

@author: shinba
"""
import sys

s = list(input())

if s[0] != "A":
    print("WA")
    sys.exit()
else:
    s = s[1:]

t = s[1:len(s)-1]

if t.count("C") != 1:
    print("WA")
    sys.exit()
else:
    t.remove("C")

t.append(s[-1])

if "".join(t) == "".join(t).lower():
    print("AC")
else:
    print("WA")
# Judge status: Wrong Answer
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
if(N == 1): print(x[0])
ans = abs(X - x[0])
for i in range(1, len(x)):
    ans = gcd(abs(x[i] - x[i - 1]), ans)
print(ans)
# Judge status: Wrong Answer
s = input()
t = input()

t = t.rstrip(t[len(t)-1])

if(s == t):
    print("yes")
else:
    print("no")
# Judge status: Accepted
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())

    A=[int(input()) for i in range(N)]
    num=0
    cnt=0

    for i in range(N):
        if A[num]==2:
            print(cnt+1)
            break
        num=A[num]-1
        cnt+=1

        if i==N-1:
            print(-1)

resolve()
# Judge status: Accepted
s=input().split(' ')
print(len(set(s)))
# Judge status: Accepted
N = int(input())
A = [0] + [int(input()) for _ in range(N)]

light = 1
goal = 2
for i in range(1, 10**6):
    light = A[light]
    if goal == light:
        print(i)
        exit()
print(-1)
# Judge status: Accepted
N=int(input())
c=(N+10)//11
print(2*c-((N+10)%11<6))
# Judge status: Accepted
s = input()

if s=="ABC":
    print("ARC")
else:
    print("ABC")
# Judge status: Wrong Answer

A, B, C, D = [int(x) for x in input().split()]

if A + B >= C + D:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
S=input()
T=input()

for i in range(100):
  if S[-1-i:-1:-1]+S[0:100-i] ==T:
    print("Yes")
    break
else:
  print("No")
# Judge status: Accepted
d,n=map(int, input().split())
if n==100:n=101
s=(100**d)*n
print(s)
# Judge status: Wrong Answer
a, b = map(int, input().split())
print(2*max(a, b)-1)
# Judge status: Accepted
n=int(input())
x=list(map(int, input().split()))
a=min(x);b=max(x)+1
ans=[]
for i in range(a,b):
    res=0
    for j in range(n):
        res+= (i-x[j])**2
    ans+=[res]
print(min(ans))
# Judge status: Wrong Answer

x=list(map(int,input().split("/")))


if x[0]<2019:
    print("HEISEI")
elif x[0]==2019 and x[1]<=4:
    print("HEISEI")
    
elif x[1]>4 and x[0]==2019:
    print("TBD")   
else:
    print("TBD")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = [0]*8
leng = 0

for i in range(N):
    now = A[i]//400
    if now < 8:
        ans[now] = 1
    else:
        leng += 1

mi = sum(ans) if sum(ans) > 0 else 1
print(mi, sum(ans) + leng)
# 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:
    node = q.popleft()
    after = graph[node]

    for a in after:
        if a == n:
            print("POSSIBLE")
            sys.exit()
        q.append(a)
    cnt += 1
print("IMPOSSIBLE")
# Judge status: Wrong Answer
n = int(input())
a = [int(x) for x in input().split()]

place = []
isfail = False
if 1 not in a:
    isfail = True
if n == 1 and a[0] == 1:
    place.append(1)
elif n == 1 and a[0] != 1:
    isfail = True

for x in range(1, n):
    try:
        if x in a:
            place.append(a.index(x))
            a = a[a.index(x):]
        else:
            break
    except:
        isfail = True
        break

if isfail:
    print("-1")
else:
    print(n - len(place))
# Judge status: Accepted
N = int(input())

y = N // 15
x = N * 800

if y >= 1:
    print( x - (y * 200))
else:
    print(x)
# Judge status: Wrong Answer
n= int(input())
if n%2==0:print(n/2)
elif n==1:print(1)
else:print((n//2 +1)/n)
# Judge status: Accepted
L,R=list(map(int, input().split()))
M=2019
if R-L==1:
  print(((R%M)*(L%M))%M)
  exit()
if L//M!=R//M:
  print(0)
  exit()
L=L%M
R=R%M
ans=M
for i in range(L,R+1):
  for j in range(i+1,R+1):
    ans=min(ans,(i*j)%M)
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    ans="Possible"
else:
    ans="Impossible"
print(ans)
# Judge status: Accepted
D,T,S = map(int,input().split())

if D <= T * S:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = sorted(input())
t = sorted(input(), reverse=True)
alf = 'abcdefghijklmnopqrstuvwxyz'
r = 'No'
if len(s)<len(t) and s==t[len(s):]:
    r = 'Yes'

for i in range(min(len(s),len(t))):
    si = alf.index(s[i])
    ti = alf.index(t[i])
    if si < ti:
        r = 'Yes'
        break
    elif si == ti:
        continue
    else:
        break
print(r)
# Judge status: Accepted
import sys
input = sys.stdin.readline
x,y=map(int,input().split())
ans=1
for i in range(y-x):
    x*=2
    if x>y:
        break
    ans+=1
print(ans)
# Judge status: Accepted
n=int(input())
l=[int(input())for _ in range(n)]
l.sort()
ans=sum(l)
if ans%10!=0:
    print(ans)
    exit()
for s in l:
    if (ans-s)%10!=0:
        print(ans-s)
        exit()
print(0)
# Judge status: Accepted
S=[input() for i in range(3)]

flag=1
i=0

while flag==1:
  t=S[i][0]
  if t=='a':
    ni=0
  elif t=='b':
    ni=1
  elif t=='c':
    ni=2
    
  S[i]=S[i][1:]
  #print(i,S[i])
  if S[ni]=='':
    print('A' if ni==0 else 'B' if ni==1 else 'C')
    flag=0
  else:
    i=ni