peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()


def main():
    g1 = [1,3,5,7,8,10,12]
    g2 = [4,6,9,11]
    g3 = [2]
    d = {}
    for x in g1: d[x] = 1
    for x in g2: d[x] = 2
    for x in g3: d[x] = 3
    x, y = map(int, input().split())
    if d[x] == d[y]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=[list(map(int,input().split())) for a in range(n)]
c=[list(map(int,input().split())) for b in range(m)]
dist=0
minnum=0
for indi,i in enumerate(a):
    dist=0
    min=10*16
    minnum=0
    for indj,j in enumerate(c):
        dist+=abs(i[0]-j[0])
        dist+=abs(i[1]-j[1])
        if min>dist:
            min=dist
            minnum=indj
        dist=0 
    print(minnum+1)
# Judge status: Wrong Answer
D = int(input())
print("Christmas", "Eve"*(25-D))
# Judge status: Wrong Answer
n = int(input())
a = []
for i in range(2):
    a.append(list(map(int, input().split(" "))))
print(a)

ans_l = []
for i in range(n):
    ans = 0
    f = False
    for j in range(n):
        if j == 0:
            ans += a[0][0]
        elif f:
            ans += a[1][j]
        else:
            ans += a[0][j]

        if i == j:
            ans += a[1][j]
            f = True

    ans_l.append(ans)
print(max(ans_l))
# Judge status: Accepted
n, a, b = map(int, input().split())
ans = n // (a + b) * a + min(n % (a + b), a)
print(ans)
# Judge status: Wrong Answer
import numpy as np   
n,m = [int(i)for i in input().split()]

l = [[int(i)-1 for i in input().split()] for _ in range(m)]

line = np.array([1 for _ in range(n)])
is_red = np.zeros(n,dtype = np.int32)
is_red[0] = 1

for x,y in l:
    line[x] -= 1 if line[x] > 0 else 0
    line[y] += 1
    is_red[y] = 1 if is_red[x] == 1 else is_red[y]
    

ans = np.count_nonzero(is_red[line > 0])

print(ans)
# Judge status: Wrong Answer
x = int(input())
#h, w = list(map(int, input().split()))
#((n+1)*n)//2 >= x
# (n+1)*n = 2*x
n = 1
a = ((n+1)*n)//2
while a < x:
    a = ((n+1)*n)//2
    n += 1
print(n)
# Judge status: Wrong Answer
import collections

n=int(input())	
s=input()

c = collections.Counter(s)

ans_count = c['R'] * c['G'] * c['B']

for i in range(1, (n-1)//2):
    for j in range(n):
        if j+(2*i) >= n:
            break

        if s[j] != s[j+i] and s[j+i] != s[j+(2*i)] and s[j] != s[j+(2*i)]:
            ans_count -= 1


print(ans_count)
# Judge status: Accepted

def main():
    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')


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n,k=map(int,input().split())
A=list(map(int,input().split()))
high=max(A)
low=0
while high-low>1:
    cnt=0
    now=(low+high)//2
    for a in A:
        cnt+=max((a-1)//now,0)
        if cnt>k:
            break
    if cnt>k:
        low=now
    else:
        high=now
    print(cnt,low,high)
print(high)
# Judge status: Accepted
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
B = reduce(lambda x,y: x^y, A)
print(" ".join(map(str, [A[i]^B for i in range(N)])))
# Judge status: Accepted
import collections

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

CA = collections.Counter(A)

max1 = 0
max2 = 0
for item in CA.items():
    if item[1] >= 2 and item[0] > max1:
        if item[1] >= 4:
            max1 = item[0]
            max2 = item[0]
        else:
            max2 = max1
            max1 = item[0]
    elif item[1] >= 2 and item[0] > max2:
        max2 = item[0]
print(max1*max2)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

def f(x):
    return sum((a+x-1)//x - 1 for a in A)

l = 0
r = 10**9+1 
while r - l > 1:
    mid = (l + r) // 2
    if f(mid) <= K:
        r = mid
    else:
        l = mid
print(r)
# Judge status: Wrong Answer
a = list(map(int,input().split()))
if a[0] == 0 or a[1] == 0:
    print("Zero")
elif a[0] == abs(a[0]) and a[1] == abs(a[1]):
    print("Positive")
elif a[0] != abs(a[0]) and a[1] != abs(a[1]):
    print("Negative")
# Judge status: Accepted
n, x, y = list(map(int, input().split()))

ans = [0] * n
for i in range(1, n):
    for j in range(i + 1, n + 1):
        ans[min(j - i, abs(i - x) + abs(j - y) + 1)] += 1
print('\n'.join(map(str, ans[1:])))
# Judge status: Accepted
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))

kion=[]
for i in range(len(h)):
    kion.append(t-h[i]*0.006)
#print(kion)
j=0
x=10000000000000000000000
for i in range(len(kion)):
    if abs(a-kion[i])<x:
        j=i+1
        x=abs(a-kion[i])
print(j)
# Judge status: Accepted
import sys


def solve(inp):
    r = int(inp.readline())

    return r * r


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
s = [input() for i in range(n)]
for k in ['AC', 'WA', 'TLE', 'RE']:
    print(k, 'x', s.count(k))
# Judge status: Wrong Answer
N = input()

cnt = 1

for i in range(len(N)-1):

    if N[i] == N[i+1]:
        cnt += 1

    else:
        cnt = 0

    if cnt == 3:
        print("Yes")
        exit()


print("No")
# Judge status: Accepted
# とっかかりを掴むために、全探索で実験してみる
n = int(input())
A = list(map(int, input().split()))
boxes = [None]*(n+1)
for i in range(n, 0, -1):
    coef = 1
    tmp = 0
    while i*(coef+1) <= n:
        coef += 1
        tmp += boxes[i*coef]
    boxes[i] = A[i-1] ^ (tmp % 2)

ans = []
for idx, v in enumerate(boxes):
    if v == 1:
        ans.append(idx)

print(len(ans))
if len(ans) > 0:
    print(*ans)
# Judge status: Accepted
def main():
    no = int(input())
    maths = map(int,input().split())
    
    count = 0
    for index,math in enumerate(maths):
        if index % 2==0 and math %2==1:
            count+=1
    print(count)


if __name__ == "__main__":
    main()
# Judge status: Accepted
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
T=[]
result=-(D*(D+1)//2)*sum(C)
last=[0 for i in range(26)]

#初期解の算出
for i in range(D):
    change=[S[i][j]+(i-last[j]+1)*(D-last[j])*C[j] for j in range(26)]
    score=max(change)
    t=change.index(score)
    T.append(t+1)
    print(t+1)
    last[t]=i+1
    result+=score
# Judge status: Wrong Answer
A, B, C, X = [int(input()) for i in range(4)]
print(sum(500*a + 100*b + 50*c == X for a in range(A+1) for b in range(B+2) for c in range(C+1)))
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

s = (A - C) // B

for i in range(s, 101):
    if (B * i + C) % A == 0:
        print('Yes')
        break
    if i == 100:
        print('No')
# Judge status: Wrong Answer
N, A, B = map(int,input().split())
S = input()

a_counter = 0
b_counter = 0

while S != "":
  s = S[0]
  if s == "a" and a_counter + b_counter <=A+B:
    a_counter += 1
    print("Yes")
  elif s == "b" and b_counter <= B and a_counter + b_counter <=A+B:
    b_counter += 1
    print("Yes")
  else:
    print("No")
  
  S = S[1:]
# Judge status: Wrong Answer
N=int(input())
#A,B,C>0 C=N-A*B
count=0
for A in range(1,N):
    for B in range(1,N):
        print(A,B,N-A*B)
        if N-(A*B)>0:
            count+=1
print(count)
# Judge status: Accepted
N = input()
A = map(int, input().split())
current = 0
ans = 0
for a in A:
  ans += current - min(current, a)
  current = max(current, a)
print(ans)
# Judge status: Accepted
N,M=map(int,input().split())
wa=[0]*N
pen=[0]*N
ac=[0]*N
for x in range(M):
  P,S=input().split()
  if S=="WA" and ac[int(P)-1]==0:
    wa[int(P)-1] += 1
  elif S=="AC" and ac[int(P)-1]==0:
    ac[int(P)-1] += 1
    pen[int(P)-1] = wa[int(P)-1]
print(f"{sum(ac)} {sum(pen)}")
# Judge status: Accepted
a,b = map(int, input().split())
print(a-1 if a>b else a)
# Judge status: Accepted
x,y=map(int,input().split())
for l in [[1,3,5,7,8,10,12],[4,6,9,11],[2]]:
    if x in l and y in l:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
def main():
    a, b, c, d = list(map(int, input().split()))
    return max(a * c, b * d, a * d, b * c)


# print('Yes' if main() else 'No')
print(main())
# Judge status: Accepted
n,m = map(int,input().split(" "))
ar = [[0,1] for i in range(n)]
ar[0] = [1,1]
r = 0
for i in range(m):
    a,b = map(int,input().split(" "))
    a -= 1
    b -= 1
    if ar[a][0] == 1 and ar[a][1] >= 1:
        ar[b][0] = 1
    ar[b][1] += 1
    ar[a][1] -= 1
    if ar[a][1] == 0:
        ar[a][0] = 0
count = 0
for r in ar:
    if r[0] == 1:
        count += 1
print(count)
# Judge status: Wrong Answer
import collections
dq = collections.deque()
s = input()
dq.append(s)
is_reveresed = False
q = int(input())
for i in range(q):
    query = input()
    if query[0] == '1':
        is_reveresed = not is_reveresed
    else:
        f = query[2]
        c = query[4]
        if (f == '1') ^ is_reveresed:
            dq.appendleft(c)
        else:
            dq.append(c)
if is_reveresed:
    dq.reverse()
print(''.join(dq))
# Judge status: Accepted
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in ab:
    best = float('inf')
    result = -1
    for i in range(M):
        c, d = cd[i]
        t = abs(a - c) + abs(b - d)
        if t < best:
            result = i + 1
            best = t
    print(result)
# Judge status: Accepted
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

kabu, yen = 0, 1000

for x, y in zip(A, A[1:] + [0]):
    # 円にもどす
    kabu, yen = 0, yen + x * kabu
    if x < y:
        # 買う
        kabu, yen = divmod(yen, x)

print(yen)
# Judge status: Wrong Answer
a, b = map(int, input().split())
s = input()

if s[a] != "-":
  print("No")
elif not s[:a].isdigit():
  print("No")
elif not s[b:].isdigit():
  print("No")
else:
  print("Yes")
# Judge status: Accepted
import collections 
n=input()
a=tuple(map(int,input().split()))
c=collections.Counter(a)
b=sorted(list(set(a)))[::-1]
ans,count=0,0
for i in b:
  if c[i]>3 and ans==0:
    print(i**2)
    exit()
  if c[i]>1:
    ans=ans*i if ans>0 else i
    count+=1
    if count==2:
      print(ans)
      exit()
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
if A>= 13:
    print(B)
elif 6 <= A <= 12:
    print(B//2)
else:
    print(0)
# Judge status: Accepted
import collections
n,k,q = map(int, input().split())
temp = [k-q for _ in range(n)]
for _ in range(q):
  a = int(input())
  temp[a-1] += 1
for i in temp:
  print('Yes' if i > 0 else 'No')
# Judge status: Accepted
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

x = I()

if(x >= 400 and x < 600):
    result = 8
elif(x < 800):
    result = 7
elif(x < 1000):
    result = 6
elif(x < 1200):
    result = 5
elif(x < 1400):
    result = 4
elif(x < 1600):
    result = 3
elif(x < 1800):
    result = 2
else:
    result = 1

print(result)
# Judge status: Accepted
X = int(input())
if(X >= 2100):
    print(1)
else:
    ct = X // 100
    r = X % 100
    if(r <= ct * 5):
        print(1)
    else: 
        print(0)
# Judge status: Accepted
from sys import stdin
rs = stdin.readline
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    n = ri()
    A = ril()
    h = 0
    ans = 0
    for a in A:
        dh = max(h-a, 0)
        h = a + dh
        ans += dh
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
N, A, B = map(int, input().split())

times = math.floor(N / (A+B))

amari = N - times * (A + B)
if amari > A:
  amari_a = A
else:
  amari_a = amari 

print(times * A + amari_a)
# Judge status: Accepted
S = input()
N = len(S)
ans = 0
for i in range(N):
  for j in range(i, N):
    if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
      ans = max(ans, j - i + 1)
print(ans)
# Judge status: Accepted
x = int(input())

c500 = x // 500
x %= 500
c005 = x // 5

print(c500 * 1000 + c005 * 5)
# Judge status: Accepted
N=int(input())
ans=''
while N:
  ans=str(N%2)+ans
  N=-(N//2)
print(ans if ans else 0)
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n <= k:
    price = x * n
else:
    price = x * k + (y * (n - k))

print(price)
# Judge status: Accepted
N,X,T = map(int, input().split())
t = 0
while(N>0):
  t += 1
  N -= X

print(T*t)
# Judge status: Accepted
import itertools
n = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
cnt = 0
a = -1
b = -1
for per in itertools.permutations(range(1,n+1)):
  cnt += 1
  if list(per) == P:
    a = cnt
  if list(per) == Q:
    b = cnt

print(abs(a-b))
# Judge status: Accepted
n = int(raw_input())


c = 2 * (n / 11)
h = {0:0}
for i in range(1, 6+1):
	h[i] = 1
for i in range(7, 12):
	h[i] = 2
if n in h:
	print h[n]
else:
	print h[n % 11] + c
# Judge status: Accepted
import math

N = int(input())

X = math.ceil(N / 1.08)
print(X if math.floor(X*1.08)==N else ":(")
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
t=(tmax+tmin)/2
import math
ans=tmax
if k==0:
  print(tmax)
else:
  while True:
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=min(math.ceil(t),math.ceil(ans))
      tmax=t
      t=(tmin+t)/2
    else:
      tmin=t
      t=(t+tmax)/2
    if tmax-tmin<0.01:
      break
  print(ans)
# Judge status: Accepted
n,l=map(int,input().split())
lst=[]
for _ in range(n):
    lst.append(input())
lst.sort()
print("".join(lst))
# Judge status: Accepted
N=input()
nums=[int(N[0]), int(N[0])-1]
for i in range(1, len(N)):
  nums=[nums[0]+int(N[i]), max(nums[1]+9, nums[0]+int(N[i])-1)] if N[i]!='0' else [nums[0]+int(N[i]), nums[1]+9]
print(max(nums))
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))
ans = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            maxint = max(L[i],  L[j],  L[k])
            sumint = L[i] + L[j] + L[k]
            if sumint > 2 * maxint:
                if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] :
                    ans += 1

print(ans)
# Judge status: Accepted
n,m,x,y=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
c=0
max_x=max(s)
min_y=min(t)

for i in range(x+1,y+1):
    if i>max_x and i<=min_y:
        c+=1
if c>0:
    print('No War')
else:
    print('War')
# Judge status: Accepted

n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

print((n-1)//min(a,b,c,d,e)+1+4)
# Judge status: Wrong Answer
a = input()

if a.count('5') == 2:
    if a.count('7') == 1:
        print('yes')
    else:
        print('no')
else:
    print('no')
# Judge status: Accepted
import math
k = int(input())
ans = 0
for q in range(1,k+1):
    for r in range(1,k+1):
        x = math.gcd(q,r)
        for s in range(1,k+1):
            ans += math.gcd(x,s)

print(ans)
# Judge status: Accepted
x, a, b = map(int, input().split())

if a-b>=0:
  print('delicious')
elif a-b<0 and x +(a-b)>=0:
  print('safe')
else:
  print('dangerous')
# Judge status: Accepted
n = input()
if n.isupper():
  print("A")
else:
  print("a")
# Judge status: Accepted
n = list(input())
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import sys

to_pay = None
number_of_yen = None

lines = []
while True:
  try:
    line = input()
  except EOFError:
    break
    
  if line:
    lines.append(line)
  else:
    break
number_of_yen = int(lines.pop())
to_pay = int(lines.pop())

if (to_pay % 500) < number_of_yen:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
import sys

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


def main():
    A, B, C = map(int, readline().split())

    if A < C < B:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
x = list(map(int, input().split()))
for i in range(len(x)):
  if x[i] == 0:
    print(i+1)
    break
# Judge status: Accepted
N = int(input())
S = list(map(int,input().split()))

sp = [400,800,1200,1600,2000,2400,2800,3200]
rank = ["gray","brown","green","cyan","blue","yellow","orange","red","highest"]
cnt = [0]*len(rank)

import bisect as b

for score in S:
  cnt[b.bisect(sp,score)] += 1
  
mid = sum([1 for n in cnt[:-1] if n > 0])
t = cnt[-1]
max_amt = mid + t
min_amt = mid
if t > 0:
  min_amt = max(mid,1)
print(min_amt,max_amt)
#print(cnt)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
ans=0
f=[1]*(N+1)
las=A[N]
g=[las]*(N+1)
flag=1
for i in range(0,N):
    f[i+1]=2*(f[i]-A[i])
for i in range(N,0,-1):
    g[i-1]=g[i]+A[i-1]
#print(f,g)
for i in range(N+1):
    if min(f[i],g[i])<=0:
        flag=0
        break
    ans=ans+min(f[i],g[i])
if g[N]>f[N]:
    flag=0
if flag==0:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
S = int(input())
a = S // 3
MOD = 10**9 + 7

#nCr求める
def inv(a):
  return pow(a,MOD-2,MOD)

fact=[0,1]
for i in range(2,S+1):
  fact.append((fact[-1]*i)%MOD)

def choose(n,r):
  if r==0 or r==n:
    return 1
  else:
    return fact[n]*inv(fact[r])*inv(fact[n-r])%MOD

ans = 0
for i in range(1,a+1):
    b = S - i*3
    ans += choose(b+i-1, b)
    ans %= MOD
else:
    print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
ans = n - sum(map(int, input().split()))

print(-1) if ans < 0 else print(ans)
# Judge status: Accepted
import numpy as np
import itertools

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

all_df = np.zeros((1,M+1))
for n in range(N):
  A = [int(i) for i in input().split()]
  all_df = np.vstack([all_df, np.array(A).reshape(1,-1)])
all_df = all_df[1:]

cost = N * (10**6)
for pattern in itertools.product([0,1], repeat=N):
  result = all_df[np.array(pattern).astype(bool)].sum(axis=0)

  if (X > result[1:]).sum() > 0:
    pass
  else:
    if result[0] < cost:
      cost = result[0]

if cost == N * (10**6):
  print(-1)
else:
  print(int(cost))
# Judge status: Accepted
import math
N = int(input())
ans = 1
for i in range(N):
  a = int(input())
  ans = ans*a//math.gcd(ans,a)
print(ans)
# Judge status: Accepted
s=input()
c0=0
c1=0

for i in range(len(s)):
  if (s[i]=="0"):
    c0+=1
  else:
    c1+=1
print(2*min(c0,c1))
# Judge status: Wrong Answer
import sys


def handler():
    n, m = [int(i) for i in input().strip().split()]
    a = [int(i) for i in input().strip().split()]
    for i in range(m, n):
        if a[i] <= a[i - m]:
            sys.stdout.write('NO\n')
        else:
            sys.stdout.write('YES\n')


def main():
    while True:
        try:
            handler()
        except ValueError:
            continue
        except EOFError:
            break


if __name__ == '__main__':
    main()
# Judge status: Accepted
a = int(input())
b = list(map(int, input().split()))
d = 0
c = 1000

while d+1 < a:
   if b[d+1] > b[d]:
       c = c - (b[d] * (c//b[d])) + ((c//b[d]) * (b[d+1]))
   else: pass
   d += 1

print(c)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h1, m1, h2, m2, k = map(int,input().split())
    print(h2*60+m2-h1*60-m1-k)

if __name__=='__main__':
    main()
# Judge status: Accepted
import itertools

n=int(input())
l=[]
for i in range(n):
    x=[int(j) for j in input().rstrip().split()]
    l.append(x)


cnt=0
ans=0
num=[i for i in range(n)]
for i in itertools.permutations(num,n):
    cnt+=1
    for j in range(n-1):
        ans+=((l[i[j]][0]-l[i[j+1]][0])**2+(l[i[j]][1]-l[i[j+1]][1])**2)**0.5
print(ans/cnt)
# Judge status: Accepted
import sys
from io import StringIO
import unittest

def resolve():
    N = int(input())
    P = list(map(int, input().split()))
    m = P[0];
    cnt = 0;
    for p in P:
        if(p <= m) :
            m = p
            cnt = cnt + 1

    print(cnt)
resolve()
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 2)
for i in range(n, 0, -1):
    b[i - 1] = b[i] + a[i]
t = 1 - a[0]
ans = 1
for i in range(n):
    m = min(t * 2, b[i])
    if m < a[i + 1]:
        print(-1)
        exit(0)
    ans += m
    t = m - a[i + 1]
print(ans)
# Judge status: Accepted
s = input()
ans = 0
for f, b in zip(s, s[::-1]):
    if f!=b: ans+=1
print(ans//2)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
m=int(round(sum(a)/n,0))
ans=0
for i in a:
  ans+=(i-m)**2
print(ans)
# Judge status: Wrong Answer
A,B = map(int,input().split())

if (A + B) // 3 >= 1:
    print('Possible')
else:
    print('Impossible')
# Judge status: Accepted
import sys, bisect

N = int(input())
L = list(map(int, sys.stdin.readline().rsplit()))
L.sort()

res = 0
for i in reversed(range(1, N)):
    for j in reversed(range(i)):
        l = bisect.bisect_left(L, L[i] + L[j])
        # r = bisect.bisect_right(L, abs(L[i] - L[j]))
        
        res += l - 1 - i
        
print(res)
# Judge status: Accepted
y,m,d = map(int,input().split('/'))
if y < 2019:
    print('Heisei')
elif m < 5:
    print('Heisei')
else:
    print('TBD')
# Judge status: Accepted
import collections
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
q = collections.deque()
q.append(0)
dist = [-1]*N
dist[0] = 0
while len(q) != 0:
    v = q.popleft()
    for w in graph[v]:
        if dist[w] > -1:
            continue
        dist[w] = v + 1
        q.append(w)
print('Yes')
for i in range(1,N):
    print(dist[i])
# Judge status: Accepted
def atc_136a(input_v: str) -> int:
    ABC = input_v.split(" ")
    A = int(ABC[0])
    B = int(ABC[1])
    C = int(ABC[2])

    D = C - (A - B)

    if D < 0:
        return 0
    else:
        return D

abc = input()
print(atc_136a(abc))
# Judge status: Accepted
s=input()
n="Good"
for i in range(3):
  if s[i]==s[i+1]:
    n="Bad"
  
print(n)
# Judge status: Accepted
def resolve():
    A, B, N = map(int, input().split())
    if B <= N+1:
        print(A*(B-1)//B)
    else:
        print(A*N//B)
resolve()
# Judge status: Wrong Answer
N,M=map(int,input().split())
A=list(map(int,input().split()))
Total=sum(A)

n=0
def jugde_A(n):
    i=0
    for i in range(len(A)):
        if A[i]<(Total/4*M):
            n+=1
    return n
if jugde_A(n)>=M:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = input()

flag = 1
c_count = 0
ans = 'AC'
if S[0] != 'A':
  ans = 'WA'
for i in range(1,len(S)):
  if (i == 1 or i == len(S)-1) and S[i].islower() == False:
    ans = 'WA'
  elif 2 <= i <= len(S)-2:
      if S[i] == 'C':
        c_count += 1
if c_count != 1:
  ans = 'WA'
print(ans)
# Judge status: Accepted
import sys
#input = sys.stdin.buffer.readline

def main():
    s = str(input())
    N = len(s)
    pl = [0 for _ in range(N+1)]
    ml = [0 for _ in range(N+1)]
    for i in range(N):
        if s[i] == "<":
            pl[i+1] = pl[i]+1
        if s[-i-1] == ">":
            ml[-i-2] = ml[-i-1]+1

    ans = 0
    for i in range(N+1):
        ans += max(pl[i],ml[i])
    
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
ans = list(input())

for i in range(n - 1):
    s = list(input())
    tmp = []
    for i in range(len(s)):
        if s[i] in ans:
            tmp.append(s[i])
            ans.remove(s[i])
    ans = tmp
    
ans.sort()
print(''.join(ans))
# Judge status: Wrong Answer
import sys
import io
import math
def readlines():
    for line in io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8'):
        yield line.strip('\n')

lines = readlines()

n = int( next(lines))
print(math.pi *n)
# Judge status: Wrong Answer
N = int(input())
M = list(map(int, input().split()))

S1 = 0
S2 = sum(M)
a = S2

for i in range(N-1):
    S1 += M[i]
    S2 -= M[i]
    if a <= abs(S1 - S2):
        print(a)
        quit()
    else:
        a = abs(S1 - S2)
    print(a)
# Judge status: Accepted
s = int(input())
x2 = 10**9
y1 = -(-s//x2)
y2 = 1
x1 = x2*y1-s
print(0,0,x1,x2,y1,y2)