peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
X = [0, 0, 0]
for a in A:
  if a % 2 == 1:
    X[0] += 1
  elif a % 4 == 2:
    X[1] += 1
  else:
    X[2] += 1
if X[1] == 0:
  if X[2] >= X[0] - 1:
    print("Yes")
  else:
    print("No")
else:
  if X[2] >= X[0]:
    print("Yes")
  else:
    print("No")
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
d = -1*a + b
if(d <= 0):
    print("delicious")
elif(abs(d) <= x+1):
    print("safe")
else:
    print("dangerous")
# Judge status: Accepted
a, b, c = map(int, input().split())
if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    chk = [a, b, c]
    chk.sort()
    print(chk[0] * chk[1])
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

t = [0] * (max(a) + 1)
for v in a:
    t[v] += 1

ans = 0
for i in range(1, max(a) - 1):
    ans = max(ans, t[i] + t[i+1] + t[i+2])

print(ans)
# Judge status: Accepted
#!/usr/bin/env python3


def main():
    N = int(input())
    aList = list(map(lambda x: int(x), input().split()))

    aliceValue = 0
    bobValue = 0
    isAliceTurn = True
    while len(aList) > 0:
        maxValue = max(aList)
        aList.remove(maxValue)
        if isAliceTurn:
            aliceValue += maxValue
        else:
            bobValue += maxValue

        isAliceTurn = not isAliceTurn

    print(aliceValue - bobValue)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
NM=list(map(int,input().split()))
N=NM[0]
M=NM[1]
N_list=list(map(int,input().split()))
 
total=sum(N_list)
 
total=total/4
 
counter=0
for number in N_list:
  if number>=total/4:
    counter+=1
    
if counter>=M:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n = int(input())
card = list(map(int,input().split()))

card.sort()

for i in range(n//2):
            ans = card[2*i]-card[2*i+1]
if n%2==1:
            ans += card[-1]

print(ans)
# Judge status: Wrong Answer
s = input()
t = input()
ans = len(t)

for i in range(len(s)):
  if (i + len(t)>= len(s)): break
  dif = 0
  for j in range(len(t)):
    if (s[i + j] != t[j]):
      dif += 1
  ans = min(ans, dif)
print(ans)
# Judge status: Wrong Answer
import random

s = input()
start = random.randint(0,len(s)-2)

nickname = s[start:start+3]
print(nickname)
# Judge status: Wrong Answer
X = input()

if X[0] == 1:
	X2 = [9]*(len(X) - 1)
elif X.count("9") == len(X):
	X2 = X
else:
	tmp = int(X[0])-1
	X2 = [str(tmp)] + ["9"]*(len(X)-1)


print(sum(list(map(int, X2))))
# Judge status: Accepted

#1,入力をちゃんと受け取る
# ex:「2 5] →a=2,b=5 みたいにする
a, b = map(int, input().split())
#print(a)
#print(b)

#2,目的通りの計算
# ex:二つの整数AとBの掛け算をする
answer = a * b

#計算の結果を出力する
print(answer)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()

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

ans = []

flg = 0
for i in range(N):
    if flg == 0:
        K = list(map(int, input().split()))
        K = K[1:]
        ans += K
        flg = 1
    else:
        K = list(map(int, input().split()))
        K = K[1:]
        
        ans = set(ans)&set(K)

print(len(ans))
# Judge status: Accepted
n = input()
if int(n[0]*len(n)) >= int(n):
    print(n[0]*len(n))
else:
    print(str(int(n[0])+1)*len(n))
# Judge status: Accepted
b, c = map(str, input().split())
d = b+c
for n in range(int(d)):
    if n == 0:
        continue
    if ((int(d)/n) == n):
        print('Yes')
        break
    if (n+1) == int(d):
        print('No')
# Judge status: Accepted
N,K=map(int,input().split())
a=N%K
b=K/2
 
if a<=b:
    print(a)
else:
    print(K-a)
# Judge status: Accepted
N = int(input())
A_i = list(map(int, input().split()))

result = [None] * N

for i in range(N):
    result[A_i[i]-1] = i+1

print(' '.join(map(str, result)))
# Judge status: Accepted
s = input()
t = input()
ans = len(t)
for i in range(len(s) - len(t) + 1):
    ss = s[i:i + len(t)]
    # print(ss)
    cnt = 0
    for i,e in enumerate(ss):
        if e != t[i]:
            cnt += 1
    # print(cnt)
    ans = min(ans,cnt)

print(ans)
# Judge status: Accepted

import sys
import fractions

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

sx, sy, tx, ty = lr()

ans = ""
ans += "R" * (tx - sx)
ans += "U" * (ty - sy)
ans += "L" * (tx - sx)
ans += "D" * (ty - sy)
ans += "D"
ans += "R" * (tx - sx + 1)
ans += "U" * (ty - sy + 1)
ans += "L"
ans += "U"
ans += "L" * (tx - sx + 1)
ans += "D" * (ty - sy + 1)
ans += "R"

print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
A = list(map(lambda x:-int(x),input().split()))
import heapq
heapq.heapify(A)
for i in range(m):
    a = heapq.heappop(A)
    heapq.heappush(A,-(-a//2))
print(-sum(A))
# Judge status: Accepted
n,k=map(int,input().split())
l=list(map(int,input().split()))

for i in range(k,n):
  if l[i] > l[i-k]:
    print('Yes')
  else:
    print('No')
# Judge status: Wrong Answer
N=input()
A = list(map(int, input().split()))
A_set = set(A)

if len(A)==len(A_set):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for an in range(a + 1):
  for bn in range(b + 1):
    for cn in range(c + 1):
      total = an * 500 + bn * 100 + cn * 50
      if total == x:
        ans += 1
print(ans)
# Judge status: Accepted
import math
import sys
import collections
import bisect


def main():
    a, b, c, k = map(int, input().split())
    print((-1) ** k * (a - b))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N,M = map(int,input().split())
Ls = []
Lp = []
for i in range(N):
    a,b = map(int,input().split())
    Ls.append([a,b])
for m in range(M):
    c,d = map(int,input().split())
    Lp.append([c,d])
dis =[]
for i in range(N):
    for m in range(M):
        dis.append(abs(Ls[i][0]-Lp[m][0])+abs(Ls[i][1]-Lp[m][1]))
    print(dis.index(min(dis))+1)
# Judge status: Wrong Answer
A, B, X = map(int, input().split())
if (A - X) * (A - X) < (B - X) * (B - X) : print('A')
else : print('B')
# Judge status: Wrong Answer
a = input()
b = input()
c = input()

turn = "a"

while not(a == "" or b == "" or c == ""):
    if turn == "a":
        turn = a[0]
        a = a[1:]
    if turn == "b":
        turn = b[0]
        b = b[1:]
    if turn == "c":
        turn = c[0]
        c = c[1:]

turn = turn.upper()
print(turn)
# Judge status: Accepted
n = int(input())
b = [int(x) for x in input().split()]
ans = [0 for x in range(n)]

ans[n-1] = b[n-2]
ans[0] = b[0]
for i in range(1,n-1) :
  j = n - 1 - i
  ans[j] = min(b[j],b[j-1])
  
print(sum(ans))
# Judge status: Wrong Answer
N=int(input())
X=list(map(int,input().split()))

print(sum([(xi-(sum(X)+N-1)//N)**2 for xi in X]))
# Judge status: Wrong Answer
S = input()
T = input()

for i in range(len(T), 0, -1):
    for j in range(len(T)-i+1):
        subst = T[j:i+j]
#        print(subst)
        if S.find(subst, j)>=0:
            print (len(T)-i)
            exit(0)
# Judge status: Accepted
N = list(input())
if "7" in N:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b = map(int, input().split())

if a*500 >= b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s = input()

x = 0
for i in range(0,3):
    if s[i] == s[i+1]:
        x = x + 1
if x >= 1:
    print("Bad")
else:
    print("Good")
# Judge status: Wrong Answer
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()


def main():
    n = input()
    d = defaultdict(int)
    for c in n: d[int(c)] += 1
    flag = False
    for key in d:
        if d[key] >= 3: flag = True
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n = int(input())

A = [0]*(n+1)

ans = 0
for i in range(n):
    a = int(input())
    ans += a//2
    A[i] = a%2
    
for i in range(n):
    if A[i] and A[i+1]:
        ans += 1
        A[i+1] -= 1
        
print(ans)
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())

max = max(H, W)

if N % max == 0:
  print(N // max)
else:
  print(N // max + 1)
# Judge status: Wrong Answer
s = str(input())
s.replace('2017', '2018')
print(s)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print('Yes' if a <= c <= b else 'No')
# Judge status: Wrong Answer
D=input()
D=int(D)

if D==25:
  print("Christmas")
if D==24:
  print("Christmas Eve")
if D==23:
  print("Christmas Eve Eve")
if D==23:
  print("Christmas Eve Eve Eve")
# Judge status: Wrong Answer
n = int(input())
if n==1:
    print('a')

i = 0
buf = 0
while 26**i+buf<=n:
    buf += 26**i
    i += 1
ans = ''
for j in range(i):
    ans += chr(ord('a')+(n//(26**j)-1)%26)
    n -= 26**j
print(ans[::-1])
# Judge status: Wrong Answer
n, m = map(int, input().split())

c = 2*n
m -= c;
m = (m//4)+n
print(m)
# Judge status: Wrong Answer
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
k = set(A)
r = set(range(1, N + 1))

for key in r - k:
    c[key] = 0

for v in c.values():
    print(v)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
  if p[i-1] < p[i] and p[i] < p[i+1]: ans += 1
  if p[i-1] > p[i] and p[i] > p[i+1]: ans += 1
print(ans)
# Judge status: Accepted
n, m = map(int,input().split())
print(abs((n-2)*(m-2)))
# Judge status: Accepted
def read_input(trans=int):
    return list(map(trans, input().split()))


N, K = read_input()
A = read_input()
K = min(K, 41)

for _ in range(K):
    B = [0]*N
    for i in range(N):
        start = max(i-A[i], 0)
        end = min(i+A[i], N-1)

        B[start] += 1
        if end+1 < N:
            B[end+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    A = B.copy()


print(" ".join(map(str, A)))
# Judge status: Accepted
a, b, c, d = map(int, input().split())

ans = max(a*c, a*d, b*c, b*d)
print(ans)
# Judge status: Accepted
import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]

S = deque(map(int, list(input())))
num = 0
dict = {}
dict[0] = 1
ans = 0

for i in range(len(S)):
    num += S.pop() * pow(10,i,2019)
    cand = num % 2019
    if cand in dict.keys():
        dict[cand] += 1
    else:
        dict[cand] = 1

for key in dict.keys():
    ans += dict[key] * (dict[key] - 1) // 2
print(ans)
# Judge status: Wrong Answer
A, B = map(int, input().split())

ans = B
if 6 <= A <= 12:
    ans = B / 2
elif A <= 5:
    ans = 0
print(ans)
# Judge status: Accepted
N = int(input())
if N % 2 == 0:
  print(N//2)
else:
  print((N//2)+1)
# Judge status: Accepted
n, m = map(int, input(). split())
b = set()
i = 1
while i * i <= m:
    if m % i == 0:
        b.add(i)
        b.add(m // i)
    i += 1
ans = 1
for i in b:
    if i * n <= m:
        ans = max(ans, i)
print(ans)
# Judge status: Accepted
a,b,c,d=[i[::-1] for i in ['dream','dreamer','erase','eraser']]
s,j=input()[::-1],True
while j:
  j=False
  for i in [a,b,c,d]:
    if s.startswith(i): s=s[len(i):];j=True
print('YNEOS'[len(s)>0::2])
# Judge status: Accepted
a,b,c = map(int, input().split())

x = b//a
print(x if x<c else c)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
B = []
Ans = [1]
for a1, a2 in zip(A, A[1:]):
    B.append(a1 ^ a2)
B.append(A[0] ^ A[-1])

for b in B:
    Ans.append(Ans[-1] ^ b)

for a in Ans[:-2]:
    print(a, end=' ')
print(Ans[-2])
# Judge status: Accepted
X, K, D = map(int, input().split())
X = abs(X)

if X // D > K:
    ans = X - D * K
else:
    if (K - X // D) % 2 == 0:
        ans = X % D
    else:
        ans = abs(X % D - D)

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

# 最小の答えは1、ここに足していく
ans = 1

# 増加と減少切り替わったタイミングで組の数を増やす
flags = [False, False]

for i in range(N - 1):
    da = a[i + 1] - a[i]
    if da > 0:
        flags[0] = True
    elif da < 0:
        flags[1] = True

    if flags[0] == True and flags[1] == True:
        ans += 1
        # 初期化
        flags = [False, False]

print(ans)
# Judge status: Accepted
x = int(input())
li = [0]*100105
li[0] = 1
for i in range(x):
    if li[i] == 1:
        for j in range(6):
            li[i+j+100] = 1
print(li[x])
# Judge status: Wrong Answer
N = int(input())

s = ''
for i in reversed(range(27)):
    if 26 ** i > N:
        continue
    M = N // (26 ** i)
    s += chr(M + 96)
    N -= M * (26 ** i)

print(s)
# Judge status: Accepted
h=int(input())
w=int(input())
n=int(input())
p=max(h,w)
print(n//p+(n%p!=0))
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline

def main():
    K,A,B = map(int,input().split())
    if A+2 >= B:
        print(K+1)
    else:
        if K<=A:
            print(K+1)
        else:
            rest = K-(A-1)
            print(A+(B-A)*(rest//2)+rest%2)
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
n, x, y = map(int,input().split())
list_length = [0 for i in range(n)]
length = 0

for i in range(1, n+1):
    for j in range(i+1, n+1):
        length = min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))
        list_length[length] += 1

for i in range(1, len(list_length)):
    print(list_length[i])
# Judge status: Wrong Answer
n,m = map(int,input().split())
s,c = [],[]
for i in range(n):
    a = list(map(int,input().split()))
    s.append(a)
for i in range(m):
    a = list(map(int,input().split()))
    c.append(a)


for i in range(n):
    tmp = 10**8
    ans = 0
    for j in range(m):
        b = (abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1]))
        if tmp > b:
            tmp = b
            ans = j+1
    print(ans)
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[7]:


N,M = map(int, input().split())
lr = []
l_max = 1
r_min = N
for _ in range(M):
    lr.append(list(map(int, input().split())))
    l_max = max(l_max, lr[-1][0])
    r_min = min(r_min, lr[-1][1])

print(max(0, r_min - l_max +1))


# In[ ]:
# Judge status: Accepted
n = int(input())
if n % 2 == 0:
    print(0.5)
else:
    print((n+1)/2/n)
# Judge status: Wrong Answer
S = list(input())
K = int(input())

if S.count('1') == len(S):
    print(1)
for s in S:
    if s != '1':
        print(s)
        exit(0)
# Judge status: Wrong Answer
n = int(input())
w = [input() for _ in range(n)]
result = 'Yes'

for i in range(1,n-1):
    en = len(w[i-1]) - 1
    if w[i][0] != w[i-1][en]:
        result = 'No'

nw = set(w)

if len(nw) != n:
    result = 'No'
print(result)
# Judge status: Accepted
N = int(input())
*A, = map(int, input().split())

dp1 = [A[0]]
dp2 = [-A[0]]
for i in range(1, N-1):
    dp1.append(max(dp1[i-1] + A[i], dp2[i-1] - A[i]))
    dp2.append(max(dp1[i-1] - A[i], dp2[i-1] + A[i]))
dp1.append(dp1[-1] + A[N-1])
dp2.append(dp2[-1] - A[N-1])


print(max(dp1[-1], dp2[-1]))
# Judge status: Wrong Answer
line = input()

if line == '5 5 7' or line == '7 5 5':
  print('Yes')
  
else:
  print('NO')
# Judge status: Wrong Answer
from collections import Counter
input()
rates = Counter(map(lambda a: int(a) // 400, input().split()))
over3199 = rates[8]
colors = len(rates) - bool(over3199)
print(max(1, colors), colors + over3199)
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(k * x + (n - k) * y if n > k else n * x)
# Judge status: Wrong Answer
n = sorted(list(str(input())),reverse=True)

print(int(''.join([n[0],n[0],n[0]])))
# Judge status: Accepted
N,K=map(int, input().split())
A=list(map(int, input().split()))

from collections import Counter

AL=Counter(A)
AL= sorted(AL.items(), key=lambda x:x[1])
n=len(set(A))-K

sum=0
for i in range(n):
  sum+=AL[i][1]
print(sum)
# Judge status: Wrong Answer
r = int(input('> '))
r = r*r
print(r)
# Judge status: Accepted
import sys
input=sys.stdin.readline
n=int(input())

a=[None]*n
b=[None]*n
c=[None]*n
for i in range(n):
    a[i],b[i],c[i]=map(int,input().split())

dpa=[a[0]]+[None]*(n-1)
dpb=[b[0]]+[None]*(n-1)
dpc=[c[0]]+[None]*(n-1)

for i in range(1,n):
    dpa[i]=a[i]+max(dpb[i-1],dpc[i-1])
    dpb[i]=b[i]+max(dpa[i-1],dpc[i-1])
    dpc[i]=c[i]+max(dpa[i-1],dpb[i-1])

print(max(dpa[-1],dpb[-1],dpc[-1]))
# Judge status: Accepted
input = int(input())
count = 0
for i in range(1, input + 1, 2):
    num = 0
    for j in range(2, i):
        if i % j == 0:
            num += 1
    if num == 6:
        count += 1
print(count)
# Judge status: Accepted
n = int(input())
s = input()

ans = 0
x = 0
for i in s:
  if i=="I":
    x +=1
  else:
    x -=1
  ans = max(ans,x)
print(ans)
# Judge status: Accepted
n, k, q = map(int,input().split())
a =  []
for i in range(q):
  a.append(int(input()))
p = [k for i in range(n)]
for i in range(q):
  p[a[i]-1] += 1
for i in range(n):
  if p[i] -q <= 0:
    print('No')
  else:
    print('Yes')
# Judge status: Wrong Answer
n, m = map(int, input().split())

if n == 1 and m == 1: ans = 1
elif n == 1 and m != 1: ans = m-2
else: ans = (n-2) * (m-2)
print(ans)
# Judge status: Wrong Answer
#ABC048.A
s = input('')
print('AtCoder'+s[0]+'Contest')
# Judge status: Wrong Answer
N=int(input())
count=0
ans =0
for j in range(N+1):
    count =0
    for i in range(1,N+1):
        if j %2 ==0:
            continue
        if j % i ==0:
            count +=1

        else:
            continue
        if count == 8 and i ==N:
            ans += 1
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
a = [0]*n
AC,WA=0,0
for i in range(m):
    x,y = input().split()
    x = int(x)
    if a[x-1]!=-1 and y=="WA":
        a[x-1]+=1
    if a[x-1]!=-1 and y=="AC":
        WA+=a[x-1]
        AC+=1
        a[x-1]=-1
print(AC,WA)
# Judge status: Wrong Answer
N, M = map(int, input().split())
ab = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 or b == N:
        ab.append([int(a), int(b)])

flag = False
for i in range(len(ab)):
    for k in range(len(ab)-i):
        if len(set(ab[i])&set(ab[k]))==1:
            print('POSSIBLE')
            flag = True
            break
    if flag:
        break
else:
    print('IMPOSSIBLE')
# Judge status: Wrong Answer
s=input()
n=len(s)
ans=0
for i,j in zip(s[:n//2-1],s[n:n//2-1:-1]):
  if i!=j:
    ans+=1
print(ans)
# Judge status: Wrong Answer
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
S = l()
S.sort()
ans1 = 0
ans2 = sum(S)
sa = 1000000000

for i in range(1,N):
    sa = min(sa,abs(sum(S[:i])-sum(S[i:])))

print(sa)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    p = list(map(int, input().split()))

    ans = 0
    for i in range(N - 1):
        if p[i] == i + 1:
            ans += 1
            p[i], p[i + 1] = p[i + 1], p[i]
    if p[-1] == N:
        ans += 1

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
from collections import Counter
n = int(input())
list_A = list(map(int, input().split()))
list_C = Counter(list_A)
list_D = sorted(list_C.items(), key=lambda x:x[0],reverse=True)
q = []
for i in range(len(list_D)):
    if len(q) == 2:
        break
    l = list_D[i]
    if l[1] > 1:
        q.append(l[0])
        if len(q) == 1 and l[1] > 3:
            q.append(l[0])
if len(q) == 2:
    print(q[0]*q[1])
else:
    print(0)
# Judge status: Accepted


def main():
    n,m = map(int,input().split())
    
    lm = 1
    rm = n
    for i in range(m):
        l,r = map(int,input().split())
        lm = max(lm,l)
        rm = min(rm,r)
    
    print(max(0,rm-lm+1))

if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())

array = sorted(list(map(int, input().split())))

print(array[N//2]-array[N//2-1])
# Judge status: Accepted
n = int(input())

n_list = [0]*50000
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            if x+y+z >= 150:
                break
            index = x*x + y*y + z*z + x*y + y*z + z*x
            n_list[index] = n_list[index]+1

for i in range(1,n+1):
    print(n_list[i])
# Judge status: Accepted
n = int(input())
ans = 0
m = 0
for i in range(n):
    a = int(input())
    ans += (m+a)//2
    m = max(0,a-m)%2
print(ans)
# Judge status: Wrong Answer
a = (int)(input())
mons = list(map(int, input().split(" ")))
yuu = list(map(int, input().split(" ")))
count = 0
for i in range(a):
  print(count)
  if yuu[i] >= mons[i]:
    yuu[i] -= mons[i]
    count += mons[i]
    if yuu[i] >= mons[i + 1]:
      yuu[i] -= mons[i + 1]
      count += mons[i + 1]
    else:
      mons[i + 1] -= yuu[i]
      count += yuu[i]
  else:
    mons[i] -= yuu[i]
    count += yuu[i]
print(count)
# Judge status: Accepted
import sys
import os


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

    S = sys.stdin.buffer.readline().decode().rstrip()
    print('Heisei' if S <= '2019/04/30' else 'TBD')


if __name__ == '__main__':
    main()
# Judge status: Accepted
def resolve():
	n, a = [int(input()) for _ in range(2)]
	if n % 500 > a:
		print('No')
	else:
		print('Yes')
resolve()
# Judge status: Wrong Answer
x,y,z = map(int,input().split())
a = x-y
b = a//(y+z)
print(b+1)
# Judge status: Wrong Answer
x,n = map(int, input().split())
valid = [1] *101
p = list(map(int, input().split()))
for i in range(n):
	valid[p[i]] = 0

for j in range(x):
	print(x,j,x-j,x+j)
	if((x-j) >= 1):
		if(valid[x-j] == 1):
			print(x-j)
			break
	elif((x+j) <= 100):
		if(valid[x+j] == 1):
			print(x+j)
			break
# Judge status: Accepted
n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()

def slv():
    cnt = 0
    for i in range(n):
        cnt += ab[i][1]
        if cnt >= k:
            return print(ab[i][0])

slv()
# Judge status: Accepted
import collections
a=int(input())
b=list(map(int,input().split()))

c=collections.Counter(b)

n,m=zip(*c.most_common())
n,m=list(n),list(m)
result=0
for i in range(len(m)):
    result+=(m[i]*(m[i]-1))//2

for i in b:
    print(result-c[i]+1)
# Judge status: Wrong Answer
x=input()
if x.isupper()==True:
    print("A")
else:
    print("a")
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def main():
    x, a, b = map(int, input().split())
    if abs(x - a) < abs(x - b):
        print("A")
    else:
        print("B")
    
    


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
ans = 'APPROVED'

for a in map(int, input().split()):
    if a % 2 == 0 and a % 3 != 0 and a % 5 != 0:
        ans = 'DENIED'

print(ans)
# Judge status: Accepted
def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]

    dp = [[0] * 3 for _ in range(n)]
    dp[0] = a[0]

    for i in range(n - 1):
        dp[i + 1][0] = a[i + 1][0] + max(dp[i][1], dp[i][2])
        dp[i + 1][1] = a[i + 1][1] + max(dp[i][2], dp[i][0])
        dp[i + 1][2] = a[i + 1][2] + max(dp[i][0], dp[i][1])
    print(max(dp[-1]))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b=map(int,input().split())
ans=a*b
for i in (2,max(a,b)):
    if a%i==0 and b%i==0:
        ans=ans/i
print(ans)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A=sorted(A)
B=sorted(B)
x=sum(B)-sum(A)
cnt=0
for i in range(N):
  if B[i]<A[i]:
    cnt+=(A[i]-B[i])
  else:
    cnt+=(B[i]-A[i]+1)//2
if x<cnt:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
s = input()
if s[-1] == "s":
    print(s + "es")
else:
    print(s + "s")
# Judge status: Wrong Answer
x = int(input())

for a in range(-100, 101):
    for b in range(-100, 101):
        if a**5 - b**5 == x:
            print(a, b)
            break
    else:
        continue
    break
else:
    print(-1)
# Judge status: Accepted
a,b,c = map(int,input().split())

print(min(c,b//a))
# Judge status: Wrong Answer
D, N = map(int, input().split())

ans = N * 100 ** D
print(ans)