peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

i = 0
m = 100
M = -100

s = 0
while i < n:
    s += a[i]
    i+=1

s1 = s//n
s2 = s1 + 1

i = 0
x1 = 0
x2 = 0
while i < n:
    x1 += (s1-a[i])**2
    x2 += (s2-a[i])**2
    i+=1

if x1<x2:
    ans = x1
else:
    ans = x2
print(ans)
# Judge status: Accepted
n = int(input())

A = [-1] + [int(x) - 1 for x in input().split(" ")]

resses = [0] * n

for i in range(1, n):
    resses[A[i]] += 1

for res in resses:
    print(res)
# Judge status: Accepted
n,h = map(int,input().split())
a = []
b = []

for i in range(n):
    a_,b_ = map(int,input().split())
    a.append(a_)
    b.append(b_)
b.sort(reverse = True)
max_a = max(a)
ans =0

for i in range(n):
    ans +=1
    if max_a > b[i]:
        ans -=1
        break
    h -= b[i]
    if h <= 0:
        break
    
if h > 0: 
    d,f = divmod(h,max_a)
    ans += d
    if f != 0:
        ans +=1
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n

def cnt_rem(ans, x):
    i = 2
    ret = 0
    while (x + 1) * i <= n:
        ret += ans[(x + 1) * i - 1]
        i += 1
    
    return ret

for i in range(n - 1, -1, -1):
    cnt = cnt_rem(ans, i)
    if cnt != a[i]:
        ans[i] += 1

print(sum(ans))
for i in range(n):
    if ans[i] == 1:
        print(i + 1, end = " ")
# Judge status: Accepted
def main():
    a,b,h = (int(input()) for _ in range(3))
    print((a+b)*h//2)

if __name__ == '__main__':
    main()
# Judge status: Accepted
List = sorted([int(i) for i in input().split(" ")],reverse=True)
K = int(input())
List[0] = List[0]*(2**K)
print(sum(List))
# Judge status: Accepted
# -*- coding: utf-8 -*-
s = set(list(input()))
if len(s) == 1:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
n=int(input())
if n<1000:
  print("ABC")
else:
  print("ABD")
# Judge status: Wrong Answer
s = input()
n = len(s)
top = s[:n//2]
under = s[n//2+1:n]

if s == s[::-1]:
  if top == top[::-1]:
    if under == under[::-1]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
# Judge status: Wrong Answer
n,k=map(int,input().split())
a = list(map(int,input().split()))

zenki = a[k-1]
#print(zenki)

for i in range(k-1):
  zenki *= a[k-2-i]
  #print(zenki)

count = k

while count < n:
  konki = (zenki / a[count-k] * a[count])
  #print(konki)
  if konki > zenki :print("YES")
  else:print("NO")
  zenki = konki
  count += 1
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(1,n):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)
# Judge status: Accepted
N= int(input())

flaga=0
flagw=0
flagt=0
flagr=0


for _ in range(N):
    K = str(input())

    if(K=='AC'):
        flaga+=1

    if(K=='WA'):
        flagw+=1

    if(K=='TLE'):
        flagt+=1

    if(K=='RE'):
        flagr+=1

print("AC x "+str(flaga))
print("WA x "+str(flagw))
print("TLE x "+str(flagt))
print("RE x "+str(flagr))
# Judge status: Accepted
R = lambda: map(int, input().split())
n, k = R()
print(sum(sorted(R())[:k]))
# Judge status: Wrong Answer
n = int(input())
a =list(map(int,input().split()))
d = [0]*(n+1)
answer = 0
for i in range(n):
  d[a[i]]+=1
for j in range(n):
  answer+= int((d[j]*(d[j]-1))/2)
for k in range(n):
  print(answer+1-(d[a[k]]))
# Judge status: Wrong Answer
x = int(input())
if x == 1:
    print(1.0000000000)
elif x % 2 == 0:
    print(0.5000000000)
else:
    print(0.6000000000)
# Judge status: Wrong Answer
s = list(input())
t = input()
ans = "No"
for i in range(len(s)):
    s.append(s.pop(0))
    print(s)
    if "".join(s)==t:
        ans = "Yes"
print(ans)
# Judge status: Wrong Answer
from collections import Counter
s = sorted(list(Counter(list(input())).values()))[::-1]
if len(s)<=2:
  print("NO")
  exit()
a = s[0]
for i in s:
  if a==i or a==i+1:
    continue
  else:
    print('NO')
else:
  print("YES")
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))
    a4 = 0; a2 = 0
    for a in A:
        if a%2 == 0:
            a2 += 1
        if a%4 == 0:
            a4 += 1
    a2 -= a4

    if N//2 <= a4:
        print('Yes')
    else:
        if N - 2*a4 <= a2:
            print('Yes')
        else:
            print('No')

if __name__ == "__main__":
    main()
# Judge status: Accepted
n =int(input())
w = []

for i in range(n):
    w.append(input())

for i in range(n - 1):
    for j in range(i + 1, n):
        if w[i] == w[j]:
            print("No")
            exit()

for i in range(n - 1):
    if w[i][-1] != w[i + 1][0]:
        print("No")
        exit()

print("Yes")
# Judge status: Accepted
H = int(input())
ans = 0
enemy = 1
while H>1:
    ans += enemy
    enemy *= 2
    H //= 2
ans += enemy
print(ans)
# Judge status: Wrong Answer
n = int(input())
*A, = map(int, input().split())
DP = [[0 for j in range(n+1)] for i in range(n+1)]
for l in range(1, n+1):
    for i in range(n-l+1):
        j = i+l
        DP[i][j] = max(A[i]-DP[i+1][j], A[j-1]-DP[i][j-1])
print(DP[0][n])
# Judge status: Accepted
a,b = map(int, input().split())
print(int((a*(a-1))/2  + (b*(b-1))/2))
# Judge status: Accepted
n=int(input())

if n==0:
  print(0)
  exit()

ans=''
while n!=0:
  q=n%(-2)
  if q<0:
    q+=2

  ans+=str(q)

  n-=q
  n//=(-2)

print(ans[::-1])
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
from collections import Counter



def main():
    N = int(input())
    S = input().strip()

    c = Counter(S)

    ans = float("inf")

    w_c = 0
    for i in range(N):
        tmp = c['E']
        tmp += w_c
        ans = min(ans, tmp)
        if S[i] == 'W':
            w_c += 1
        else:
            c['E'] -= 1

    print(ans)





if __name__ == '__main__':
    main()
# Judge status: Accepted
S=input()
if len(S)%2==0:
    S_mae=S[:len(S)//2]
    S_ushiro=S[len(S)//2:]
else:
    S_mae=S[:len(S)//2+1]
    S_ushiro=S[len(S)//2:]
ans=0
for i in range(len(S_mae)):
    if S_mae[-i-1]!=S_ushiro[i]:
        ans += 1
print(ans)
# Judge status: Wrong Answer
S = input()
while len(S)>0:
    if S[-7:] == "deamer":
        S = S[:-7]
    elif S[-6:] == "eraser":
        S = S[:-6]
    elif S[-5:] == "dream":
        S = S[:-5]
    elif S[-5:] == "erase":
        S = S[:-5]
    else:
        break
print("NO" if len(S)>0 else "YES")
# Judge status: Wrong Answer
x=int(input())
ans=2*(x//11)+((x%11)//6)+(x%11)%6
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = [int(i) for i in input().split()]

from collections import Counter

Acnt = Counter(A)

ans = [-1] * 2
for key,cnt in Acnt.items():
    if cnt >= 2:
        tmp = min(ans)
        if key > tmp:
            ans[ans.index(tmp)] = key

if -1 in ans:
    print(0)
else:
    print(ans[0] * ans[1])
# Judge status: Accepted
N, K = [int(x) for x in input().split(' ')]
p = [int(x) for x in input().split(' ')]

p = sorted(p)

print(sum(p[:K]))
# Judge status: Accepted
N = int(input())

ans = []
for i in range(1,int(N**0.5)+1):
  if N%i == 0:
    j = int(N/i)
    ans.append(i+j)
print(min(ans)-2)
# Judge status: Wrong Answer
n,q = map(int,input().split())
s=input()
a=[0]*n
for i in range(n-1):
    a[i+1]=a[i]+(1 if s[i:i+2]=="AC" else 0)
print(a)

for i in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])
# Judge status: Wrong Answer
from collections import Counter

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

d = Counter(a)
l = []
flag = False
for k,v in list(sorted(d.items()))[::-1]:
  if v >= 4:
    l.append(k)
    l.append(k)
  elif v >= 2:
    l.append(k)
  if len(l) == 2:
    flag = True
    break

    
if flag:
  ans = l[0]*l[1]
else:
  ans = 0


print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
*A, = map(int, input().split())

l, r = 10**19, 1
while abs(r-l) > 1:
    m = (l+r)//2
    k = 0
    for a in A:
        if a > m:
            k += a//m
    if k <= K:
        l = m
    else:
        r = m

print(l)
# Judge status: Wrong Answer
x,y=map(int, input().split())


crain = (4 * x - y) / 2
if crain.is_integer() and crain > 0:
    crain = int(crain)
    print('Yes')
elif x == 1 and y ==4:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,m=map(int,input().split())
cu=[0]*200001
for i in range(m):
    x,y=map(int,input().split())
    cu[x]=y
f=cu[cu[1]]
print('POSSIBLE' if f==n else 'IMPOSSIBLE')
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(int, input().split()))

line = sum(A) // (4 * M)
ans = [i for i in A if i > line]
print("Yes") if len(ans) >= M else print("No")
# Judge status: Accepted
N, K = [int(x) for x in input().split()]
A_lst = [int(x) for x in input().split()]
dict = {}
for i in A_lst:
    if not i in dict:
        dict[i] = 1
    else:
        dict[i] += 1

lst = []
for i in dict.keys():
    lst.append(dict[i])
lst.sort()
k = len(lst)
cnt = 0
i = 0

while k > K:
    k -= 1
    cnt += lst[i]
    i += 1

print(cnt)
# Judge status: Accepted
import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
ans = 0
cnt = 1
mn = T[0]
for i in range(1,N):
    if cnt == C or mn+K < T[i]:
        ans += 1
        cnt = 1
        mn = T[i]
    else:
        cnt += 1
if cnt > 0:
    ans += 1
print(ans)
# Judge status: Accepted
import statistics
N = int(input())
A = list(map(int, input().split()))

for i, a in enumerate(A):
    A[i] = a - (i+1)

tmp = int(statistics.median(A))

ans = 0
for i, a in enumerate(A):
    ans += abs(a - tmp)

print(ans)
# Judge status: Accepted
def main():
    n = int(input())
    print((n - 1) * n // 2)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s = list(input())

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))
# Judge status: Accepted
N, T = map(int, input().split())
INF = 10**9
res = INF
for _ in range(N):
    c, t = map(int, input().split())
    if t <= T and c < res:
        res = c
print(res if res != INF else 'TLE')
# Judge status: Accepted
value = input().split()
rows = int(value[0])
colmuns = int(value[1])

#valid
if colmuns == 1:
  rows = 1
elif rows == 1:
  colmuns = 1

OddColNum = colmuns // 2 
EvenColNum = OddColNum
if (colmuns % 2) != 0:
  OddColNum = OddColNum + 1
if (colmuns == 1):
  OddColNum = 1

OddRowCount = 0
EvenRowCount = rows // 2
if (rows % 2) == 0:
  OddRowCount = rows // 2
else:
  OddRowCount = (rows // 2) + 1
if (rows == 1):
  OddRowCount = 1

counts = OddRowCount * OddColNum + EvenColNum * EvenRowCount
print(counts)
# Judge status: Wrong Answer
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, W = map(int, input().split())
    dp = [[0] * (N + 1) for _ in range(W + 1)]
    for i in range(1, N + 1):
        w, v = map(int, input().split())
        for j in range(w,W + 1):
            dp[j][i] = max(dp[j][i - 1], dp[j - w][i-1] + v)

    print(dp[W][N])


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * n
for i in a:
  c[i - 1] += 1
print(sum(c[k:]))
# Judge status: Wrong Answer
from itertools import accumulate

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


As = list(accumulate(A))
Bs = list(accumulate(B))

ans = 0
if Bs[M-1] <= K:
    ans = max(ans, M)
idx = M-1
for i in range(N):    
    while idx != -1 and As[i] + Bs[idx] > K:
        idx -= 1
    num = i + idx + 2
    if As[i] > K:  
        num = 0
    ans = max(ans, num)

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

ans = 1
for i in range(2, x+1):
  n = 2
  while i ** n < x:
    ans = i ** n
    n += 1
print(ans)
# Judge status: Wrong Answer
s = input()
opl = ['+', '-']

flag = [0,0,0]
for i in range(0, 0b111+1):
    for j in range(3):
        #print(i)
        flag[j] = (i>>(j+1) & 1)
        ans = s[0] + opl[flag[0]] + s[1] + opl[flag[1]] + s[2] + opl[flag[2]] + s[3]
        if(eval(ans) == 7):
            print(ans + '=7')
            break
    else:
        continue
    break
# Judge status: Accepted
s=input()
count=0
for i in range(len(s)//2):
    if s[i]==s[len(s)-1-i]:
        count+=1
print(len(s)//2-count)
# Judge status: Accepted
s = input()
bit_pre = 0
bit_post = 0
if 1 <= int(s[:2]) and int(s[:2]) <= 12:
    bit_pre = 1
if 1 <= int(s[2:]) and int(s[2:]) <= 12:
    bit_post = 1
if bit_pre and bit_post:
    print("AMBIGUOUS")
elif bit_pre:
    print("MMYY")
elif bit_post:
    print("YYMM")
else:
    print("NA")
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)

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

if (a-b)%2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')
# Judge status: Accepted
A,B=map(int,input().split())

print(A*B)
# Judge status: Accepted
s = input()
t = input()
n = len(s)
m = len(t)

ans = 0
for i in range(n):
    if n < i+m:
        continue
    x = s[i:i+m]
    cnt = 0
    for a, b in zip(x, t):
        if a == b:
            cnt += 1
    if ans < cnt:
        ans = cnt
print(m-ans)
# Judge status: Wrong Answer
def resolve():
    N, M = list(map(int, input().split()))
    totalc = N*2 + M
    print(totalc // 4)

if '__main__' == __name__:
    resolve()
# Judge status: Accepted
s = int(input())

xl = int(s ** 0.5) + 1
if (xl - 1) * (xl - 1) >= s:
  xl -= 1
  yl = xl
elif (xl - 1) * xl >= s:
  yl = xl - 1
else:
  yl = xl

diff = xl * yl - s
print(*[0, 0, xl, diff, 1, yl])
# Judge status: Accepted
A, B, C, D = map(int, input().split())

import fractions

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


def f(x, c, d):
    cd = lcm(c, d)
    
    divisible = x//c + x//d - x//cd
    
    return x - divisible

print(f(B, C, D) - f(A-1, C, D))
# Judge status: Wrong Answer
sq_nums = {i * i for i in range(1, 101)}
N, D = map(int, input().split())
coords = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i, N):
        if sum((y - z) ** 2 for y, z in zip(coords[i], coords[j])) in sq_nums:
            ans += 1
print(ans)
# Judge status: Accepted
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
r=[a[-1]]
l=[a[0]]
for i in range(1,n-1):
    l.append(gcd(l[i-1],a[i]))
    r.append(gcd(r[i-1],a[-1-i]))
ans=r[-1]    
for i in range(n-2):
    ans=max(ans,gcd(l[i],r[-2-i]))
ans=max(ans,l[-1])
print(ans)
# Judge status: Wrong Answer
N = int(input())
X = list(map(int, input().split()))

Max = max(X)
p_min = 10000
for i in range(1, Max+1):
    p = 0
    for j in range(len(X)):
        p += (X[j] - i)**2
    if  p < p_min:
        p_min = p
    else:
        p_min = p_min
print(p_min)
# Judge status: Accepted
from re import match

if match("^A[a-z]+C[a-z]+$", input()):
    print('AC')
else:
    print('WA')
# Judge status: Wrong Answer
N , M = (map(int , input().split()))
A = list(map(int , input().split()))
A.append(N)
a_lis = []
for i in range(len(A)-1):
    a_lis.append(A[i+1]-A[i])
print(N - max(a_lis))
# Judge status: Wrong Answer
N = int(input())
ppair = [[0,0]]*N
for i in range(N):
    ppair[i] = list(map(int,input().split()))

ppair.sort()
ans = 0
pf = False
for i in range(N-1):
    if (pf):
        pf = False
        continue
    else:
        if (sum(ppair[i]) > ppair[i+1][0] - ppair[i+1][1]):
            ans += 1
            pf = True

print(N-ans)
# Judge status: Accepted
N = int(input())
ans = 0

for n in range(N+1):
  if n%2==1:
    Y = 0
    for m in range(1,N+1):
      if n%m==0:
        Y+=1
    if Y==8:
      ans+=1
    
print(ans)
# Judge status: Accepted
def prime_factors(n):
    res = set()
    while n % 2 == 0:
        res.add(2)
        n //= 2
    i = 3
    while i * i <= n:
        if n % i == 0:
            res.add(i)
            n //= i
        else:
            i += 2
    if n != 1:
        res.add(n)
    return res

a, b = map(int, input().split())
a = prime_factors(a)
b = prime_factors(b)
print(len(a & b) + 1)
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int,input().split()))
    pre = A[0]
    for i in A:
        if pre > i:
            print("No")
            return
        elif pre < i:
            pre = i -1
    print("Yes")        
if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
import collections

n=int(input()) 
c = []
m = int(math.sqrt(n))

for x in range(1,m+1):
    for y in range(1,m+1):
        for z in range(1,m+1):
            tmp = x*x + y*y + z*z + x*y + y*z + z*x
            c.append(tmp)

cc = collections.Counter(c)
#print(cc)

for i in range(1,n+1):
    if i in cc:
        print(cc[i])
    else:
        print(0)
# Judge status: Accepted
from collections import deque
from bisect import bisect_left
N=int(input())
li=[]
ans=0
for i in range(N):
    a=-int(input())
    b=bisect_left(li,a+1)
    if b==len(li):
        li.append(a)
        ans+=1
    else:
        li[b]=a
print(ans)
# Judge status: Accepted
def f(M,A):
  c=0
  s=sum(A)
  for a in A:
    if a>=s/4/M:c+=1
    if c>=M:return("Yes")
  return("No")
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
s=sum(A)
print(f(M,A))
# Judge status: Wrong Answer
import numpy as np
S = input()
count = True
for i in np.arange(0, len(S), 2):
    if S[i] == "L":
        count = False
        
for i in np.arange(1, len(S), 2):
    if S[i] == "R":
        count += False

if count:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
K = int(input())
cnt = 0
i = 1
while cnt < K:
  s = str(i)
  if len(s) == 1:
    cnt += 1
  else:
    flg = True
    for j in range(1, len(s)):
      if abs(int(s[j]) - int(s[j-1])) > 1:
        flg = False
        break
    if flg:
      cnt += 1
    i += 1
print(i-1)
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))

arr.sort()
length = len(arr)

ans = 0
for x in range(length):
    for y in range(x + 1, length):
        for z in range(y + 1, length):
            if arr[x] != arr[y] and arr[y] != arr[z] and arr[z] != arr[x]:
                if arr[x] + arr[y] > arr[z]:
                    ans += 1

print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
s=input()
x=1

for i in range(n-1):
  if s[i]!=s[i+1]:
    x+=1
    
print(min(n-1,n-x+2*k))
# Judge status: Wrong Answer
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
def lcm(x, y):
    return (x * y) // gcd(x, y)
n=int(input())
ans=1
tmp1=int(input())
for i in range(n-1):
    tmp2=int(input())
    ans=lcm(tmp1,tmp2)
    tmp1=ans
print(ans)
# Judge status: Wrong Answer
import sys
n=int(input())
h=list(map(int,input().split()))
h[0]-=1
for i in range(1,n-1):
    if h[i-1]<=h[i]<=h[i+1]:
        pass
    else:
        h[i]-=1
        if h[i-1]<=h[i]<=h[i+1]:
            pass
        else:
            print("No")
            sys.exit()
print("Yes")
# Judge status: Accepted
N = int(input())
pi = 360
while True:
  if pi % N == 0:
    print(pi//N)
    exit()
  else:
    pi+=360
# Judge status: Wrong Answer
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    ans = 0
    for v in c.values():
        ans += v*(v-1)//2
    for k in range(N):
        if 2 <= c[A[k]]:
            print(ans - (c[A[k]] - 1))
        else:
            print(0)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N,K = map(int,input().split())
A = list(map(int,input().split()))
ind = A.index(1)
n = ind//(K-1)
if ind%(K-1):
    n += 1
m = (N-1-ind)//(K-1)
if (N-1-ind)%(K-1):
    m += 1
print(n+m)
# Judge status: Accepted
def main():
    S = input()
    S1 = S[:len(S)//2]
    S2 = S[len(S)//2:][::-1]
    num_hug = 0
    for s1, s2 in zip(S1, S2):
        if s1 != s2:
            num_hug += 1
    print(num_hug)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import itertools
moji = str(input())
A,B,C,D = int(moji[0]),int(moji[1]),int(moji[2]),int(moji[3])

Bn = [B,B*-1]
Cn = [C,C*-1]
Dn = [D,D*-1]
flg = 0
for i,j,k in itertools.product(Bn, Cn,Dn):
    X = A + i + j + k
    if X == 7:
        break
    
print(str(A) + (str(i),"+"+str(i))[i >= 0]+ (str(j),"+"+str(j))[j >= 0]+ (str(k),"+"+str(k))[k >= 0]+"=7")
# Judge status: Wrong Answer
N,Y=map(int,input().split())

for x in range(N+1):
    for y in range(N+1):
        if 10000*x+5000*y+1000*(N-x-y)==Y:
            print(x,y,N-x-y) 
            exit()
        else:
            print(-1,-1,-1)
# Judge status: Accepted
N, M = map(int, input().split())

lstL = list()
lstR = list()

for i in range(0, M):
    L, R = map(int, input().split())
    lstL.append(L)
    lstR.append(R)

minVal = max(lstL)
maxVal = min(lstR)

res = (maxVal - minVal + 1) if minVal <= maxVal else 0

print(res)
# Judge status: Wrong Answer
a=input()
op=list("+-")
flag = False
for i in op:
    for j in op:
        for k in op:
            s = a[0]+i+a[1]+j+a[2]+k+a[3]
            flag = True
            if eval(s) == 7:
                break
        if flag:
            break
    if flag:
        break
print(s+"=7")
# Judge status: Accepted
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
if N>=M:
  ans=0
else:
  D=X[M-1]-X[0]
  xm=[]
  for i in range(M-1):
    xm.append(X[i+1]-X[i])
  xm.sort()
  ans=sum(xm[:M-N])
print(ans)
# Judge status: Wrong Answer
def GCD(x,y):
  if y == 0:
    return 1
  return GCD(y, x%y)

print(GCD(1,5))
# Judge status: Accepted
n = int(input())
if n%2 == 1:
    print((n+1)//2)
else:
    print(n//2)
# Judge status: Wrong Answer
A, B = map(int, input().split())

A_k, B_k = A, B
AB_max = max(A, B)
yakusu = {1}
for i in range(2, int(AB_max**0.5+1)):
    while A_k % i == 0 and B_k % i == 0:
        A_k = A_k // i
        B_k = B_k // i
        yakusu.add(i)


print(len(yakusu))
# Judge status: Wrong Answer
N, K = list(map(int, input().split()))
people = [False for i in range(0, N)]

for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))

    for a in A:
        people[a-1] = True

print(len(list(filter(lambda x : x, people))))
# Judge status: Accepted
def main():
    r = int(input())
    print(r**2)

if __name__ == "__main__":
    main()
# Judge status: Accepted
n=int(input())
x=[int(i) for i in input().split()]
ans=10**9
for i in range(1,101):
    res=0
    for j in x:
        res+=(j-i)**2
    ans=min(ans,res)
print(ans)
# Judge status: Wrong Answer
import math
n = int(input())
res = 0
for i in range(1,n):
  for j in range(1,n):
    for k in range(1,n):
      res += math.gcd(math.gcd(i,j),k)
print(res)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())
if b < c or d < a:
    print(0)
elif a <= c and d <= b:
    print(d-c)
elif c <= a and b <= d:
    print(a-b)
elif a <= c and b <= d:
    print(b-c)
elif c <= a and d <= b:
    print(d-a)
# Judge status: Wrong Answer
n = int(input())
H = list(map(int, input().split()))
DP = [10 ** 5] * n
DP[0] = 0
for i in range(1, n):
    DP[i] = min(DP[i], DP[i - 1] + abs(H[i] - H[i - 1]))
    if i > 1:
        DP[i] = min(DP[i], DP[i - 2] + abs(H[i] - H[i - 2]))

print(DP[-1])
# Judge status: Accepted
N = int(input())
TEN = 1
NINE = 1
EIGHT = 1
a = 10
b = 9
c = 8

mod = 10 ** 9 + 7

for i in range(64):
    if N % 2:
        TEN *= a
        TEN %= mod
        NINE *= b
        NINE %= mod
        EIGHT *= c
        EIGHT %= mod
    N //= 2
    a *= a
    a %= mod
    b *= b
    b %= mod
    c *= c
    c %= mod

print((TEN - 2 * NINE + EIGHT + mod * 2)%mod)
# Judge status: Accepted
x, y = map(int, input().split())
diff = abs(abs(x)-abs(y))
 
if abs(x) < abs(y):
  if x < 0:
    diff += 1
  if y < 0:
    diff += 1
else:
  if x > 0:
    diff += 1
  if y > 0:
    diff += 1
print(diff)
# Judge status: Accepted
a,b,c=map(int,input().split())

k=int(input())

cnt=0
while a>=b:
    b*=2
    cnt+=1

while b>=c:
    c*=2
    cnt+=1

if cnt<=k:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A,B,H,M=(int(x) for x in input().split())

import math

time = H*60 + M
dist = (5.5 * time)%360
if 0 < dist < 180:
   dist = 360 - dist

ans = math.sqrt(A*A + B*B  - 2*A*B*math.cos(math.radians(dist)))

print(ans)
# Judge status: Accepted

from bisect import bisect_right

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

INF = 10 ** 9 + 7
dp = [INF] * (N + 1)
for i in range(N):
    dp[bisect_right(dp, -X[i])] = -X[i]

print(sum(v < INF for v in dp))