peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
def serveal_monter(input):
  H, A = input.split(" ")
  H = int(H)
  A = int(A)
  if H % A > 0:
    return (H // A) + 1
  return H // A
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
count = 0
for i in range(n-1, -1, -1):
    c = sum([ans[j] for j in range(i, n, i+1)])%2
    if c != a[i]:
        count+=1
        ans[i] = 1
print(count)
ans = [i+1 for i in range(n) if ans[i]==1]
if count > 0:
    print(' '.join(map(str, ans)))
# Judge status: Accepted
x,y=map(int,input().split())
s=y-2*x
t=4*x-y
if (s>0 and t>=0 or s>=0 and t>0) and s%2==0 and t%2==0:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n, k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
ans = sum(h[k:])
print(ans)
# Judge status: Wrong Answer
n=int(input())
if n%2==1:
    print(0)
    exit(0)

k=n//2

from math import floor

ans=0
deno=5
while deno<=k:
    ans+=floor(k/deno)
    deno*=5

print(ans)
# Judge status: Accepted
n = int(input())
for i in range(1,10):
    for j in range(1,10):
        if(i*j==n):
            print("Yes")
            exit()
print("No")
# Judge status: Accepted
from collections import  defaultdict


N = int(input())

d = defaultdict(int)
for i in range(1, N+1):
    s = str(i)
    d[(s[0], s[-1])] += 1


ans = 0
for i in range(1,N+1):
    s = str(i)
    ans += d[(s[-1], s[0])]


print(ans)
# Judge status: Wrong Answer
p,q,r=map(int,input().split())
if p+q<q+r and p+q<p+r:
    print(p+q)
if p+r<p+q and p+r<q+r:
    print(p+r)
if q+r<p+r and q+r<p+q:
    print(q+r)
if p+q==q+r and p+q<p+r:
    print(p+q)
if p+r==q+r and p+r<p+q:
    print(p+r)
if p==q==r:
    print(p+q)
if r+p==q+r and r+p<p+q:
    print(r+p)
# Judge status: Accepted
def make_divisors(n):
    a,b =[],[]
    i = 1
    while i*i<=n:
        if n%i == 0:
            a.append(i)
            if i != n//i:
                b.append(n//i)
        i+= 1
    return a+b[::-1]

n = int(input())
c = 0
for i in range(1,n+1):
    if len(make_divisors(i))== 8 and i%2==1:
        c+=1
print(c)
# Judge status: Accepted
import numpy as np
import itertools as it

n = int(input())
city = [np.array(list(map(int,input().split()))) for i in range(n)]

dist = [[[] for i in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        v = city[i] - city[j]
        dist[i][j] = np.linalg.norm(v, ord=2)

ps = it.permutations([i for i in range(n)])
anss = []
for p in ps:
    ans = 0
    for i in range(n-1):
        ans += dist[p[i]][p[i+1]]
    anss.append(ans)

print(np.average(anss))
# Judge status: Accepted
import math

n = int(input())
if n == 1:
    print(0)
    exit(0)
max = int(math.sqrt(n) + 0.1)
ans = 0
for i in range(2, max):
    count = 0
    while n % i == 0:
        count += 1
        n = n // i
    if count > 0:
        for j in range(1, 64):
            if count >= j:
                ans += 1
            else:
                break
            count -= j
    if n == 1:
        print(ans)
        exit(0)
print(ans + 1)
# Judge status: Accepted
N = int(input())
if N % 2:
    print(0)
    quit()
total = 0
N //= 2
while N:
    N //= 5
    total += N
print(total)
# Judge status: Wrong Answer
S=input()
n=len(S)
if S[n-1]=='s':
    print(S[:-1]+'es')
else:
    print(S+'s')
# Judge status: Accepted
o=input()
e=input()
print("".join([o[i]+e[i] for i in range(len(o)-1)]),end="")
print(o[-1],end="")
if len(o) == len(e):
  print(e[-1])
# Judge status: Accepted
H, A = map(int, input().split())

if H % A == 0:
    print(H//A)
else:
    print(H//A + 1)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a <= 0 <= b:
  print("Zero")
elif 0 < a:
  print("Positive")
else:
  if (b - a + 1) % 2 == 0:
    print("Negative")
  else:
    print("Positive")
# Judge status: Accepted
n, k = map(int, input().strip().split())
L = list(map(int, input().strip().split()))
L = [v - 1 for v in L]
 
seen = set()
intersec = 0
route=[]
while intersec not in seen:
    seen.add(intersec)
    route.append(intersec)
    intersec = L[intersec]

intersecInd = route.index(intersec)

if k<=intersecInd:
    ans=route[k]
else:
    loopSize = len(route) - intersecInd
    ans = route[(k - intersecInd) % (loopSize) + intersecInd]
 
print(ans + 1)
# Judge status: Accepted
a,b=map(int, input().split())
print(a+b//2)
# Judge status: Accepted
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
L = inputlist()
L.sort()
s=sum(L)
s -=L[-1]
if L[-1] < s:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = str(input())
ans = 753
for i in range(2,len(S)):
  ans = min(ans,abs(753 - int(S[i-2]+S[i-1]+S[i])))

print(ans)
# Judge status: Accepted
x=input()
x=list(x)
x.sort()
if x[0]=='a' and x[1]=='b' and x[2]=='c':
	print('Yes')
else:
	print('No')
# Judge status: Accepted
n=int(input())
a=list(map(lambda x:int(x),input().split()))
cnt=0
cnt2=0
for i in a:
    if i%4==0:
        cnt+=1
    if i%4!=0 and i%2==0:
        cnt2+=1
if (2*cnt+cnt2>=n and cnt2>0) or (cnt2==0 and 2*cnt+1>=n):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import numpy as np
 
mod = 10 ** 9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
 
ans = 0
for n in range(len(bin(max(A)))):   # 最大桁数は、最も大きい数値の2進数の桁数
    num_1 = np.count_nonzero((A >> n)&1)   # 1の数をカウント
    num_0 = N - num_1                      # 0の数をカウント
    mul = num_1 * num_0   # 0 XOR 1の回数
    ans += ((2 ** n)*mul) % mod
ans %= mod
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
n, h = map(int, input().split())
a, b = [0]*n, [0]*n
for i in range(n):
    a[i], b[i] = map(int, input().split())
a_max = max(a)
b_thr = []
for i in b:
    if i > a_max:
        b_thr.append(i)
b_thr.sort(reverse=True)
ans = 0
for i in b_thr:
    if h > 0:
        h -= i
        ans += 1
    else:
        print(ans)
        exit()
if h % a_max == 0:
    ans += h // a_max
else:
    ans += h // a_max + 1
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
if 2 * N >= M:
    print(M // 2)
else:
    c_cnt = M + N * 2
    print(c_cnt // 4)
# Judge status: Accepted
import sys
import math
import bisect

def main():
    A = list(map(int, input().split()))
    A.sort()
    for _ in range(int(input())):
        A[-1] <<= 1
    print(sum(A))

if __name__ == "__main__":
    main()
# Judge status: Accepted
n = input()
n = n[::-1]
n += '0'
cnt = 0
dp = [[float('inf')] * 2 for _ in range(len(n) + 1)]
dp[0][0] = 0
dp[0][1] = 1
for i in range(len(n)):
    a = int(n[i])
    dp[i + 1][0] = min(dp[i][0] + a, dp[i][1] + 10 - a)
    dp[i + 1][1] = min(dp[i][0] + a + 1, dp[i][1] + 10 - (a + 1))
print(min(dp[len(n)][0], dp[len(n)][1]))
# Judge status: Accepted
N,*X=map(int,open(0).read().split())
M=sorted(X)[N//2-1:N//2+1]
for x in X:
    print(M[x<M[1]])
# Judge status: Wrong Answer
import sys
def main():
    x, y = map(int, input().split())
    
    for i in range(0, x+1):
        for j in range(0, x-i+1):
            res = i * 2 + j * 4
            if y == res and res > 0:
                print('Yes')
                sys.exit()
                
    print('No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
A, B, C = map(int, input().split())
def f(x, y, z):
    if x % 2 == 0:
        return 0
    else:
        return y * z
print(min(f(A, B, C), f(B, C, A), f(C, A, B)))
# Judge status: Accepted
N = int(input())
for i in range(30):
    for j in range(20):
        if(N == i*4+j*7):
            print("Yes")
            exit()
print("No")
# Judge status: Accepted
N,M = map(int,input().split())
A = [0 for _ in range(N+1)]
B = [1 for _ in range(N+1)]
A[1] = 1
B[0] = 0
for _ in range(M):
    x,y = map(int,input().split())
    if A[x]==1:
        A[y]=1
    B[y] += 1
    B[x] -= 1
    if B[x]==0:
        A[x] = 0
print(sum(A))
# Judge status: Wrong Answer
N = int(input())
#Mi=i%(i+1) (1<=i<N),
#   i%1     (i=N)

ans = N*(N-1)/2

print(int(ans))
# Judge status: Accepted
N=int(input())
s=input()
t=input()
overlap=N
for i in range(N):
    if s[i:]==t[:N-i]:
        overlap=i
        break
print(N+overlap)
# Judge status: Accepted
s = input()
count = 0
mx = 0
for i in s:
    if i=="A" or i=="C" or i=="G" or i=="T":
        count += 1
        mx = max(count,mx)
    else:
        count = 0
print(mx)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
k = int(input())
while k > 0:
    if c < b:
        c*=2
    elif b < a:
        b*=2
    else:
        a*=2
    k-=1
print("Yes" if c>b>a else "No")
# Judge status: Wrong Answer
h, a = map(int, input().split())

for i in range(2 * 10**6):
  continue
# Judge status: Accepted
n = int(input())
s = []
for i in range(n):
    s.append(input())

set_s = sorted(set(s[0]))
nn = int(len(set_s))
ans = [[] for i in range(nn)]
for i in range(nn):
    for j in s:
        ans[i].append(j.count(set_s[i]))

ans_2 = []
c = 0
for i in ans:
    i = min(i)
    for j in range(i):
        ans_2.append(set_s[c])
    c += 1

for j in ans_2:
    print(j,end="")
# Judge status: Wrong Answer
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re


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()

    num = 0

    for i in range(1, N+1):
        y = N//i
        num += (y*(y+1)*i)/2

    print(num)


if __name__ == '__main__':
    main()
# Judge status: Accepted
abcd = list(map(int, input()))
op = {'0':'+', '1':'-'}
for i in range(8):
    result = abcd[0]
    code = str(abcd[0])
    pointer = 1
    for k in bin(i)[2:].zfill(3):
        if op[k] == '+':
            code += '+'
            result += abcd[pointer]
        else:
            code += '-'
            result -= abcd[pointer]
        code += str(abcd[pointer])
        pointer += 1
    if result == 7:
        code += "=7"
        break
print(code)
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
    if(p[i-1]<p[i] and p[i]<p[i+1]):
        cnt += 1
    elif(p[i-1]>p[i] and p[i]>p[i+1]):
        cnt += 1
print(cnt)
# Judge status: Accepted
n = int(input())

if n%2==1:
    print(0)
else:
    # 2の倍数には不足しないので、5の倍数を数える
    cnt=0
    n //= 2
    while n:
        n //= 5
        cnt += n
    print(cnt)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
print("Yes") if n-(b//2)-3*c<1 else print("No")
# Judge status: Accepted
n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
for i in range(m):
  x,y=map(int,input().split())
  if x==1:
    a[y]=1
  if y==n:
    b[x]=1
ans=0
for i in range(n+1):
  ans+=a[i]*b[i]
if ans==0:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')
# Judge status: Accepted
n,m,x=(int(i) for i in input().split())
a=[]
c=[]
for i in range(n):
  a.append(list(map(int,input().split())))
  c.append(a[i][0])
  del a[i][0]
  
INF=1001001001
ans=INF

for s in range(1<<n):
  cost=0
  d=[0]*m
  for i in range(n):
    if(s>>i&1):
      cost+=c[i]
      for j in range(m):
        d[j]+=a[i][j]
  ok=True
  for j in range(m):
    if(d[j]<x):
      ok=False
  if ok:
    ans=min(ans,cost)
if ans==INF:
  print(-1)
else:
  print(ans)
# Judge status: Accepted
s = input()
t = input()
cnt = 0
for si, ti in zip(s,t):
    if si != ti:
        cnt += 1
print(cnt)
# Judge status: Accepted
def main():
    n, k = map(int, input().split())
    s = list("*" + input() + "*")
    count = 0
    for i in range(1, n + 1):
        if (s[i] == s[i - 1] == "L") or (s[i] == s[i + 1] == "R"):
            count += 1
    print(min(count + 2 * k, n - 1))


if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b = map(int,input().split())
if a > b:
    print(2*a-1)
elif a == b:
    print(2*a)
else:
    print(2*b-1)
# Judge status: Wrong Answer
s = input()
a = 0
for i in range(3):
    if s[i] == 'R':
        a += 1
    else:
        a = 0
print(a)
# Judge status: Accepted
x,y = map(int,input().split())

res = []

for i in range(-(x-1)+y, x+y):
    res.append(i)

print(' '.join(map(str,res)))
# Judge status: Accepted
s = int(input())

ans, num = [0, 0, 10 ** 9, 1], 10 ** 9
cnt = s % num
if cnt == 0:
    ans += [0, s // num]
elif cnt != 0:
    ans += [num - cnt, s // num + 1]
print(*ans)
# Judge status: Wrong Answer
n = int(input())
d = list(map(int,input().split()))
c = 0
k = 0
while True:
  if(k == max(d)):
    break
  ab = 0
  ar = 0
  for i in range(0,n):
    if(d[i] >= k):
      ar = ar + 1
    else:
      ab = ab + 1
  if(ab == ar):
    c = c + 1
  k = k + 1
print(c)
# Judge status: Wrong Answer
N = int(input())
left = 0
right = 3200
while right - left > 1:
    mid = (left + right) // 2
    if mid * (mid + 1) // 2 < N:
        left = mid
    else:
        right = mid
ans = {i for i in range(1, right + 1)}
ans -= {right * (right - 1) // 2 - N + right}
print('\n'.join(map(str, ans)))
# Judge status: Accepted
n = int(input())
a = [0]+list(map(int, input().split()))
boxi=[0]*(n+1)
box=[]
for i in range(n,0,-1):
  t=0
  for j in range(2,n//i+1):
    if boxi[j*i] == 1:
      t+=1
  if t%2 != a[i]:
    box.append(i)
    boxi[i]=1
else:
  print(len(box))
  box=[str(i) for i in box]
  print(" ".join(box))
#print(-1)
# Judge status: Wrong Answer
n = int(input())
s = list(input())
cnt = 0
ans_list = [0]
e_cnt = int()

for i in range(1,n):
    if s[i-1] == "E":
        cnt -= 1
    if s[i-1] == 'W':
        cnt += 1
    ans_list.append(cnt)

if s[n-1] == 'E':
    e_cnt = (ans_list[n-1] - 1 - n) //(-2)
else:
    e_cnt = (ans_list[n-1] - n) //(-2)

print(min(ans_list) + e_cnt)
# Judge status: Wrong Answer
x = int(input())
min_dt = 1001001001
min_i = 0
for i in range(1, int(x**0.5)):
    dt = abs(x - (i+1)*i//2)
    if dt<min_dt:
        min_dt = dt
        min_i = i
    if min_dt == 0:
        print(i)
        break
else:
    print(min_i+min_dt)
# Judge status: Wrong Answer
def main():
    N = int(input())
    H = [int(i) for i in input().split()]
    for i in range(N-1)[::-1]:
        if H[i] > H[i+1]:
            H[i] -= 1
            if H[i] > H[i+1]:
                return print("NO")
    print("YES")


if __name__ == '__main__':
    main()
# Judge status: Accepted
s=input()
count=0
for i in s:
    count+=1

print("x"*count)
# Judge status: Accepted
N = int(input())
N -= 1
print((N*(N+1))//2)
# Judge status: Accepted
a, b, c = [int(x) for x in input().split()]

for i in range(1, b + 1):
    if a * i % b == c:
        print('YES')
        break
else:
    print('NO')

# 余りはループする。Modを回答するのだって同じだ。
# Judge status: Wrong Answer

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

kumikazu = s.count('R')*s.count('B')*s.count('G')

for i in range(n-2):
    for j in range(n-1):
        k = 2*j-i
        if k > n-1:
            break
        if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):
            kumikazu -= 1

print(kumikazu)
# Judge status: Accepted
x,y=map(int,input().split())
g1=[1,3,5,7,8,10,12]
g2=[4,6,9,11]
g3=[2]
if x in g1 and y in g1 or x in g2 and y in g2 or x in g3 and y in g3:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N=int(input())
C=list(map(int,input().split()))
ans=[0]*N
for i in range(1,N+1):
  ans.insert(C[i-1],str(i))
for _ in range(N):
  ans.remove(0)
ans=' '.join([str(n) for n in ans])
print(ans)
# Judge status: Accepted
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

d = {}
for each in s:
  d[each] = d.get(each, 0) + 1
for each in t:
  d[each] = d.get(each, 0) - 1

print(max(0, max(d.values())))
# Judge status: Accepted
a, s, c = map(str, input().split())
print(a[0] + s[0] + c[0])
# Judge status: Accepted
import math
h = int(input())
c = 0
num = 1
while True:
    if h == 1:
        c += num
        print(c)
        break
    else:
        c += num
        h = math.floor(h/2)
        num = num*2
        # print(num)
        # print(num)
# Judge status: Accepted
a, b = map(int, input().split())

if a <= b:
    a += 1

print(a-1)
# Judge status: Wrong Answer
import itertools
N,K=map(int,input().split())
D=[int(x) for x in input().split()]
T=[]
answer=10000
for i in range(10):
  if not i in D:
    T+=[i]
for x in itertools.product(T,repeat=5):
    p=x[-1]+x[-2]*10+x[-3]*100+x[-4]*1000+x[-5]*10000
    if p>=N:
      answer=min(p,answer)
print(answer)
# Judge status: Accepted
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
ans = 0
for i in c:
	if c[i] > i:
		ans += c[i] - i
	elif c[i] < i:
		ans += c[i]
print (ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

d = [1] * (N+1)
d[0] -= A[0]
for i in range(N):
    d[i+1] = d[i] * 2 - A[i+1]

if d[-1] < 0:
    print(-1)
    exit()
else:
    d[-1] = A[-1]
for i in range(N, 0, -1):
    x = d[i]
    x += A[i-1]
    d[i-1] = min(x, d[i-1]+A[i-1])
print(sum(d))
# Judge status: Wrong Answer
n = int(input())
print(int((n-1)*n*0.5) )
# Judge status: Wrong Answer
S = input()
T = input()

if 1 <= len(S) <= 10 and len(T) == len(S) + 1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import math
import collections

def LI():
  return [int(s) for s in input().split()]

A,B = LI()

prime_factor = []

for i in range(2,int(math.sqrt(A))+1):
  while A%i == 0:
    prime_factor.append(i)
    A/=i

if A > 1:
  prime_factor.append(A)

prime_factor.append(1)
c1 = set(prime_factor)

prime_factor = []

for i in range(2,int(math.sqrt(B))+1):
  while B%i == 0:
    prime_factor.append(i)
    B/=i
    
if B > 1:
  prime_factor.append(B)

prime_factor.append(1)
c2 = set(prime_factor)

N = len(c1 & c2)

print(N)
# Judge status: Accepted
N = int(input())
A = input().split()
L = A[1::2]
R = A[0::2]
if N%2==0:
    print(' '.join(L[::-1]+R))
else:
    print(' '.join(R[::-1]+L))
# Judge status: Accepted
a, b = map(int, input().split())
if a <= 0 and b >= 0:
    print("Zero")
elif b <= 0 and b >= 0:
    print("Zero")
elif a == 0 or b == 0:
    print("Zero")
elif a > 0 and a > 0:
    print("Positive")
elif a < 0 and b < 0:
    c = abs( b - a + 1)
    if c %2 == 1:
        print("Negative")
    else:
        print("Positive")
# Judge status: Wrong Answer
A, B, C = map(int,(input().split()))
K = int(input())

for kkk in range(0, K-1):
    if B < A:
        B *= 2
    elif C < B:
        C *= 2

if A < B and B < C:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A,B,C = map(int, open(0).read().split())
if A <= C <= B:
    print("Yes")
elif A >= C >= B:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
y = list(map(lambda x:abs((t-(x*0.006)) - a), h))
print(y.index(min(y))+1)
# Judge status: Accepted
n = int(input())
c = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, n+1):
  si = str(i)
  a = int(si[0])
  b = int(si[-1])
  c[a][b] += 1

res = 0
for i in range(10):
  for j in range(10):
    res += c[i][j] * c[j][i]
print(res)
# Judge status: Accepted
N = int(input())
v = list(map(int, input().split()))

v.sort()
ans = v[0]
for i in range(1, N):
  ans = (ans + v[i]) / 2

print(ans)
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())

p = list(map(int, input().split()))
p.sort(reverse = True)
p = p[:X]

q = list(map(int, input().split()))
q.sort(reverse = True)
q = q[:Y]

r = list(map(int, input().split()))
r.sort(reverse = True)
r = r[:(X+Y)]

s = p+q+r
s.sort(reverse = True)
print(sum(s[:(X+Y)]))
# Judge status: Wrong Answer
a,b = map(int,input().split())
if a == 1:
  a = 14
elif b == 1:
  b = 14
elif a == 1 and b == 1:
  a = 14
  b = 14
  
if a>b:
  print("Alice")
elif b>a:
  print("Bob")
else:
  print("Draw")
# Judge status: Accepted
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
a=10**9
z_max=-1*a
z_min=a
w_max=-1*a
w_min=a
for x,y in l: #点のx座標とy座標の和の最大値と最小値の差か座標の差の最大値と最小値の差が答え
  z_max=max(z_max,x+y)
  z_min=min(z_min,x+y)
  w_max=max(w_max,x-y)
  w_min=min(w_min,x-y)
print(max(z_max-z_min,w_max-w_min))
# Judge status: Accepted
N, M = map(int,input().split())
cnt = 0
#cが余る（Sが使い切れる）とき
if 2*N <= M:
  cnt += N
  M -= 2*N
  cnt += M//4
  print(cnt)
#cが足りない（Sが余る）とき
else:
  print(M//2)
# Judge status: Accepted
n = int(input())
H = list(map(int, input().split()))

memo = [0 for _ in range(n)]
memo[1] = abs(H[1] - H[0])
for i in range(2, n):
  memo[i] = min(memo[i-1] + abs(H[i] - H[i-1]), memo[i-2] + abs(H[i] - H[i-2]))
print(memo[-1])
# Judge status: Accepted
# Problem B - Guidebook

# input
N = int(input())
restaurant = {}
for i in range(N):
    s, p = input().split()
    p = int(p)
    if s in restaurant:
        restaurant[s].append((i+1, p))
    else:
        restaurant[s] = [(i+1, p)]

# dict sort
restaurant = sorted(restaurant.items(), key= lambda x:x[0])

# price sort
for r in restaurant:
    tmp = r[1]
    result = sorted(tmp, key= lambda x:x[1], reverse=True)
    for i in result:
        print(i[0])
# Judge status: Accepted
import math

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

x = math.log(n, k)
x = math.floor(x)

print(x+1)
# Judge status: Accepted
n = int(input())

if n%1000:
    bills = n//1000 + 1
else:
    bills = n//1000

ans = bills * 1000 - n
print(ans)
# Judge status: Accepted
def LI():return list(map(int,input().split()))

n,m=LI()
h=LI()
edge=[[] for _ in range(n)]
for i in range(m):
    a,b=LI()
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)
    
ans=0
for i in range(n):
    if all([h[i]-h[v]>0 for v in edge[i]]):
        # print(i)
        ans+=1

print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
S = set()
for i in range(100):
	count = len(S)
	S.add(a * i % b)
	if len(S) == count:
		break
print("YES" if c in S else "NO")
# Judge status: Wrong Answer
N, A, B = list(map(int, input().split()))
S = input()
passed_num = 0
passed_foreigners_num = 0
for i in S:
    if passed_num < A + B:
        if i == 'a':
            print('yes')
            passed_num += 1 
        elif i == 'b' and passed_foreigners_num < B:
            print(i)
            print('yes')
            passed_num += 1 
            passed_foreigners_num += 1
        else:
            print('No')
    else:
        print('No')
# Judge status: Wrong Answer
n = int(input())
x = [list(map(int, input().split())) for i in range (n)]

grid = [list([0,0]) for i in range(n)]

for i in range(n):
    grid[i][0] = x[i][0] - x[i][1]
    grid[i][1] = x[i][0] + x[i][1]

new_grid = sorted(grid)
cnt = 0
for i in range(n-1):
    if i + 1 >= len(new_grid):
        break;
    if new_grid[i][1] > new_grid[i+1][0]:
        cnt += 1
        del new_grid[i]

ans = n - cnt

print(ans)
# Judge status: Accepted
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

res = 0

t_0 = T[0]
c = C

for t in T:
    if c == 0 or t - t_0 > K:
        res += 1
        t_0 = t
        c = C - 1
    else:
        c -= 1
else:
    if c != C:
        res += 1

print(res)
# Judge status: Accepted
import math
n=int(input())
print(800*n-200*math.floor(n/15))
# Judge status: Wrong Answer
n=int(input())
ans=""
i=0
while n!=0 :
    if n%2==0:
        ans+="0"

    else:
        ans+="1"
        if i%2==0:
            n-=1
        else:
            n+=1
    n=n//2
    i+=1
    #print(n,ans)

print(ans[::-1])
# Judge status: Accepted
n, q = map(int, input().split())
s = input()
cnt_AC = [0] * n
cnt = 0

for i in range(n - 1):
    if s[i] == "A" and s[i + 1] == "C":
        cnt += 1
    cnt_AC[i + 1] = cnt

for i in range(q):
    l, r = map(int, input().split())
    print(cnt_AC[r - 1] - cnt_AC[l - 1])
# Judge status: Wrong Answer
N = int(input())
a_list = list(map(int, input().split()))
fours = []
twos = []
others = []

for a in a_list:
    if a % 4 == 0:
        fours.append(a)
    elif a % 2 == 0:
        twos.append(a)
    else:
        others.append(a)
if len(fours) - len(others) == -1 and len(twos) > 0:
    print('No')
    exit()

if len(fours) - len(others) < 0 :
    print('No')
    exit()

if len(fours) == 0 and len(twos) < 2:
    print('No')
    exit()

print("Yes")