peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def main():
    n = int(input())
    As = list(map(int, input().split()))
    ans = float("inf")

    for i in range(-100, 101):
        ans_temp = 0
        for j in range(n):
            ans_temp += (As[j] + i)**2
        ans = min(ans, ans_temp)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
# Judge status: Accepted
X = int(input())

ans = (X // 500) * 1000
ans += ( ((X % 500) // 5) * 5 )

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

ans = ''
for i in range(max(0,X-K)+1,X+K):
  ans += str(i) + ' '

print(ans)
# Judge status: Wrong Answer
n = int(input())
l = list(map(int, input().split()))
c = 0
i = 1
while i < n:
  j = i + 1
  while j < n:
    k = j + 1
    while k < n:
      if l[i] != l[j] and l[j] != l[k] and l[k] != l[i] and abs(l[j]-l[k]) < l[i] < l[j] + l[k]:
        c += 1
      k += 1
    j += 1
  i += 1
print(c)
# Judge status: Accepted
import collections


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


sorted_A = list(reversed(sorted(A)))

maxiuam = sorted_A[0]
is_there_tow_maximum = A.count(maxiuam) >= 2

second = None
for Ai in sorted_A:
    if Ai < maxiuam:
        second = Ai
        break

answer = []
for Ai in A:
    if is_there_tow_maximum:
        answer.append(maxiuam)
    elif Ai == maxiuam:
        answer.append(second)
    else:
        answer.append(maxiuam)
answer = "\n".join(map(str, answer))

print(answer)
# Judge status: Accepted
#ABC104_B
S = input()

ans = "AC"

if S[0] != 'A' or S[2:-1].count('C') != 1 or S[-1] == 'C' or S[1] == 'C':
  ans = "WA"
for i in range(1, len(S)):
  if S[i].isupper() and S[i] != 'C':
    ans = "WA"
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort()
res = 1
for i in range(n):
	res *= a[i]
	if res > 1e18:
		print(-1)
		exit(0)
print(res)
# Judge status: Accepted
n,k = list(map(int, input().split()))
x = list(map(int, input().split()))

# 連続するK地点を選ぶ
cost = 10**18
for i in range(0, n-k+1):
    left = x[i]
    right = x[i+k-1]
    if left < 0 and right < 0:
        cost = min(cost , abs(left))
    elif left > 0 and right > 0:
        cost = min(cost, abs(right))
    else:
        cost = min(cost, min(2 * abs(right) + abs(left), 2 * abs(left) + abs(right)))

print(cost)
# Judge status: Wrong Answer
n = int(input())
p = []

for i in range(n):
    p.append(int(input()))

ans = 0
for i in range(i<<n):
    li = []
    for j in range(n):
        if (i>>j)&1:
            li.append(p[j])
    tmp = sum(li)
    if tmp%10==0:
        tmp = 0
    ans = max(ans, tmp)
print(ans)
# Judge status: Accepted
N=int(input())

ans=1

while(ans*2<=N):
  ans*=2
print(ans)
# Judge status: Accepted
k,n = map(int,input().split())
a = list(map(int,input().split()))
res = k+a[0]-a[n-1]
for i in range(1,n):
    res = max(res,a[i]-a[i-1])
print(k-res)
# Judge status: Accepted
from functools import lru_cache
@lru_cache()
def gcd(x,y):
    r = x%y
    if r == 0:
        return y
    return gcd(y,r)

K = int(input())
Sum = 0

for i in range(1,K+1):
    Sum += i
    for j in range(i+1,K+1):
        Sum += 6*gcd(i,j)
        for k in range(j+1,K+1):
            Sum += 6*gcd(gcd(i,j),k)
print(Sum)
# Judge status: Accepted
S=input()
A=[]
for i in range(len(S)-2):
    A.append(abs(753-int(S[i:i+3:1])))
print(min(A))
# Judge status: Wrong Answer
from collections import defaultdict
d = defaultdict(int)

n=int(input())
for _ in range(n):
  d[input()]+=1

n=int(input())
for _ in range(n):
  d[input()]-=1
  
print(d[max(d)])
# Judge status: Accepted
f=input().split(" ")
a,b,m=[int(f[i]) for i in range(3)]
coup=[]
As=[]
Bs=[]
f=input().split(" ")
for each in f:
    As.append(int(each))

f=input().split(" ")
for each in f:
    Bs.append(int(each))

for i in range(m):
    f=input().split(" ")
    vac=[]
    for each in f:
        vac.append(int(each))
    coup.append(vac)
        
price=min(As)+min(Bs)
for each in coup:
    price_c=As[each[0]-1]+Bs[each[1]-1]-each[2]
    if price_c<price:
        price=price_c
print(price)
# Judge status: Wrong Answer
n, k = map(int, input().split())
arr = list(map(int, input().split()))

inf = float('inf')
min_cost = inf
for amount in range(n, 100000):
    for e in arr:
        if str(e) in str(amount):
            break
        min_cost = min(min_cost, amount)

print(min_cost)
# Judge status: Wrong Answer
n,m = map(int,input().split())
stair = []
for i in range(m):
    stair.append(int(input()))

ans = [0]*(n+1)
ans[0] = 1
ans[1] = 1
for i in range(n+1):
    if i in stair:
        ans[i] = 0
    else:
        if i ==0:
            continue
        else:
            ans[i] = ans[i-2] + ans[i-1]
print(ans[n]%(10**9+7))
# Judge status: Wrong Answer
import math
n=int(input())
n=180-n
ans=math.ceil(360/(180-n))
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
from1 = set()
fromn = set()
a =[]
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        fromn.add(b)
    if b == n:
        from1.add(a)
if len(from1 & fromn)>0 :
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Judge status: Accepted
n = int(input())
L = len(str(n))

def sumdigit(i):
    return sum(map(int, list(str(i))))

print(max([sumdigit(n - (n%(10**i) + 1)) for i in range(1, L)] + [sumdigit(n)]))
# Judge status: Accepted
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
z = [list(map(int, input().split())) for i in range(M)]

price = min(a) + min(b)

for e in z:
    tmp_price = a[e[0]-1] + b[e[1]-1] - e[2]

    if(price > tmp_price):
        price = tmp_price

print(price)
# Judge status: Accepted
from itertools import groupby

s = list(input())
f = 0
ans = 0
for k,v in groupby(s):
  d = len(list(v))
  left = d if k==">" else 0
  right = d if k=="<" else 0
  if f>left:
    ans += d*(d+1)//2 - left
  else:
    ans += -1*f + d*(d+1)//2  
  f = right 
print(ans)
# Judge status: Wrong Answer
a, b, k = map(int, input().split())

if a>=k:
  print(a-k,b)
elif a<k and b>=k:
  print(0,b-(k-a))
else:
  print(0,0)
# Judge status: Accepted
a,b=[int(x) for x in input().split()]

if (a+b)%2==0:
  print((a+b)//2)
else:
  print("IMPOSSIBLE")
# Judge status: Accepted
def main():
  n, x, *ls = map(int, open(0).read().split())
  d=0
  cou=1
  for l in ls:
    d += l
    if d <= x:
      cou+=1
    else:
      return(cou)
  return n+1
if __name__ == '__main__':
  print(main())
# Judge status: Wrong Answer
n,k=map(int,input().split())

ans=0
for i in range(1,n+1):
  num=i
  p=1/3
  while num<=k:
    num=num*2
    p=p*(1/2)
  ans+=p
  
print(ans)
# Judge status: Accepted
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    H, W, N = [ii(), ii(), ii()]
    print(math.ceil(N/max(H, W)))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if A[i]==i+1:
    ans=ans+1
    b=A[i+1]
    A[i+1]=A[i]
    A[i]=b
print(ans)
# Judge status: Accepted
# coding: utf-8
X,Y=map(int,input().split())

if X%Y==0:
    print(-1)
else:
    print(X)
# Judge status: Wrong Answer
n = str(input())

if n[0]=='9' or n[1]=='9':
  print('YES')
else:
  print('NO')
# Judge status: Accepted
import heapq
N,M = map(int,input().split())
AB = [[] for i in range(M+1)]
for i in range(N):
    a,b = list(map(int,input().split()))
    if a <= M:
        AB[a].append(-b)
work = 0
AB2 = []
heapq.heapify(AB2)
for i in range(1,M+1):
    for j in AB[i]:
        heapq.heappush(AB2,j)
    if len(AB2) > 0:
        b = heapq.heappop(AB2)
        work += -b
print(work)
# Judge status: Accepted
n = int(input())
arr = [int(input()) for _ in range(n)]
ls = sorted(arr)
for i in arr:
    if i == ls[-1]:
        print(ls[-2])
    else:
        print(ls[-1])
# Judge status: Accepted
n = int(input())
c = 0
for i in range(1,n):
      if (i%2==1):
            c+=1
print("{0:.10f}".format(1-(c/n)))
# Judge status: Accepted
n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
print(sum(a[n:3*n:2]))
# Judge status: Accepted
N=int(input())

if N<=999:
  print('ABC')
else:
  print('ABD')
# Judge status: Accepted
def resolve():
	n = int(input())
	c = []
	for _ in range(n):
		c.append(list(map(int, input().split())))
	dp = [[0, 0, 0] for _ in range(n)]
	dp[0] = c[0]
	for i in range(n-1):
		for j in range(3):
			for k in range(3):
				if j == k:
					continue
				else:
					dp[i+1][j] = max(dp[i+1][j], dp[i][k] + c[i+1][j])
	print(max(dp[-1]))
resolve()
# Judge status: Accepted
n = int(input())
a = 1
ans = 0
if a >= n:
    ans = 1
else:
    for i in range(2,n+1):
        a += i
        if a >= n:
            ans = i
            break
for k in range(1,ans+1):
    if a - n != k:
        print(k)
    else:
        continue
# Judge status: Accepted
A1, A2, A3 = map(int, input().split())

if A1 + A2 + A3 >= 22:
    print('bust')
else:
    print('win')
# Judge status: Accepted
import numpy as np
A, B, H, M = map(int,input().split())
time = 60*H + M #経過時間(分)

rad_h = 2*np.pi-(np.pi/360)*time
rad_m = 2*np.pi-(np.pi/30)*M

A_x = A*np.cos(rad_h)
A_y = A*np.sin(rad_h)
B_x = B*np.cos(rad_m)
B_y = B*np.sin(rad_m)

v = np.array([A_x-B_x,A_y-B_y])

l = np.linalg.norm(v)
  
print(l)
# Judge status: Accepted
N = int(input())
S = input()
MAX = 0
for T in range(0,N+1):
    X = S[:T]
    Y = S[T:]
    Com = len(set(X)&set(Y))
    if Com>MAX:
        MAX = Com
print(MAX)
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()

total_AB, total_B = 0, 0
for c in S:
    if c=='a':
        if total_AB < A+B:
            print('Yes')
            total_AB += 1
        else:
            print('No')
    elif c=='b':
        if total_AB < A+B and total_B < B:
            print('Yes')
            total_AB += 1
            total_B += 1
        else:
            print('No')
    else:
        print('No')
# Judge status: Wrong Answer
n,m = map(int,input().split())
drink = {}
for _ in range(n):
    a,b = map(int,input().split())
    drink[a] = b
d = sorted(drink.items(), key=lambda x:x[0])

ans = 0
x = 0

for t in d:
    if x+t[1] < m:
        ans += t[0]*t[1]
        x += t[1]
    else:
        ans += (m-x)*t[0]
        break

print (ans)
# Judge status: Accepted
N=int(input())
ans=[]
count=[]
n=0
for i in range(1,N+1):
    n+=i
    count.append(n)
num=0
for i in range(N):
    if count[i]>N:
        num=i
        break
if N==1:
    print(1)
    exit()
sa=count[num]-N
#print(sa)
for i in range(1,num+2):
    if sa==i:
        continue
    ans.append(i)
for i in range(len(ans)):
    print(ans[i])
# Judge status: Wrong Answer
import math

def colon():
    input_value = [int(i) for i in input('Enter values: ').split()]
    hour_hand = input_value[0]
    minute_hand = input_value[1]

    hour = input_value[2]
    minute = input_value[3]

    degree = (((hour * 60 + minute) * 360)/720) - ((minute * 360)/60)
    cos = math.cos(math.radians(degree))

    answer = math.sqrt((hour_hand ** 2) + (minute_hand ** 2) - (2 * hour_hand * minute_hand * cos))
    print(answer)

colon()
# Judge status: Accepted
K = int(input())
 
num = 0
cnt = 0
ans = -1
 
for i in range(K):
    num = num*10 +7
    cnt += 1
    if num%K != 0:
        num = num%K
    else:
        ans = cnt
        break
    
print(ans)
# Judge status: Wrong Answer
a, b = (int(i) for i in input().split())
if a <= 8 and b <= 8:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
input()
L = list(set(list(map(int, input().split()))))
l = len(L)

count = 0
for i in range(l):
    for j in range(i+1, l):
        for k in range(j+1, l):
            if L[i] < L[j] + L[k]:
                if L[j] < L[i] + L[k]:
                    if L[k] < L[i] + L[j]:
                        count += 1

print(count)
# Judge status: Accepted
[A, B, C] = [int(i) for i in input().split()]
K = int(input())


def cal():
    global A, B, C, K
    count = 0
    while A >= B:
        B *= 2
        count += 1
        if K < count:
            return "No"
    while B >= C:
        C *= 2
        count += 1
        if K < count:
            return "No"
    return "Yes"


print(cal())
# Judge status: Accepted
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

from itertools import combinations_with_replacement

ans=0
for a in combinations_with_replacement(range(1, m+1,), n):
    d=0
    for i in range(q):
        if a[abcd[i][1]-1]-a[abcd[i][0]-1]==abcd[i][2]:
            d+=abcd[i][3]
    ans=max(ans,d)
print(ans)
# Judge status: Accepted
c1 = input()
c2 = input()
print('YES' if c1[::-1] == c2 else 'NO')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
res = 0
p = 1
for i in range(n):
    if a[i] == p:
        p += 1
    else:
        res += 1
if res == n:
    print(-1)
else:
    print(res)
# Judge status: Wrong Answer
def main():
    a, b, x = map(int, input().split())
    if a+b < x or a > x:
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7

s = sum(A)
ans = 0
for i, a in enumerate(A):
    s -= a
    ans = (ans + s * a) % mod

print(ans)
# Judge status: Accepted
import sys

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


def main():
    s = input()
    t = input()

    sl = list(s)
    sl.sort()
    st = list(t)
    st.sort(reverse=True)

    if sl < st:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import deque
S = deque(input())
Q = int(input())
d = 0 # d=0:right, d=1:left
for i in range(Q):
  I = list(input().split())
  if I[0] == "1":
    d ^= 1
  else:
    if d + int(I[1]) == 2:
      S.append(I[2])
    else:
      S.appendleft(I[2])
if d == 1:
  S.reverse()
for s in S:
  print(s, end="")
print()
# Judge status: Accepted
S = input()
T = input()

if(S==T[0:len(S)]):
  print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N, C, K = list(map(int, input().split(" ")))
T = []
for i in range(N):
  T.append(int(input()))

bus = []
departure=0

for passenger in T:
  if bus == []:
    bus.append(passenger)
    
  elif passenger <= bus[0]+K and len(bus)<(C-1):
    bus.append(passenger)
    
  else:
    bus.clear()
    departure+=1
    
print(departure + 1)
# Judge status: Accepted
from collections import deque

n = int(input())
A = list(map(int, input().split()))
deq = deque([])

for i in range(1, n+1):
    if i % 2 == 1:
        deq.append(A[i-1])
    else:
        deq.appendleft(A[i-1])

if n % 2 == 0:
    print(*deq)
else:
    print(*reversed(list(deq)))
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = input()
if any(s[i]==s[i+1]=="#" for i in range(a-1, c-2)) or any(s[i]==s[i+1]=="#" for i in range(b-1, d-2)):
    print("No")
elif c<d:
    print("Yes")
else:
    if any(s[i-1]==s[i]==s[i+1]=="." for i in range(b-1, d)):
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import math
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if N == K:
    print(1)
else:
    print(math.ceil((N-1)/(K-1)))
# Judge status: Accepted
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

X, Y = map(int, input().split())

val = X
cnt = 0
while val <= Y:
    val *= 2
    cnt += 1
print(cnt)
# Judge status: Wrong Answer
n=list(map(int,input().split()))
print(n.count(1))
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Mon May  4 20:56:08 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
A = list(map(int,input().split()))
A1 = np.array(A)

m = np.min(A)
pre = m
while len(A1) > 1:
    pre = m
    A1 %= m
    A1 = A1[A1 != 0]
    A1 = np.append(A1, m)
    m = np.min(A1)
print(pre)
# Judge status: Wrong Answer
n = int(input())
List = [int(input()) for i in range(n)]
print(List)

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
print(lcm_list(List))
# Judge status: Accepted
N, A, B = map(int, input().split())
res = 0
for i in range(1, N+1):
    s = str(i)
    if A <= sum(int(t) for t in s) <= B:
        res += i
print(res)
# Judge status: Wrong Answer
N=int(input())
*A,=map(int,input().split())
A.sort()

ans=A[0]
count=[0]*N
i=0
while i<N:
    count[i]=A[i]%ans
    i+=1

for c in count:
    if c>0:
        ans=min(ans,c)

for a in A:
    if a%ans>0:
        ans=min(ans,a%ans)

for a in A:
    if a%ans>0:
        ans=min(ans,a%ans)

for a in A:
    if a%ans>0:
        ans=min(ans,a%ans)

for a in A:
    if a%ans>0:
        ans=min(ans,a%ans)

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

result = 3

if a == b and b == c:
  result = 1
elif a != b and b != c:
  result = 3
else:
  result = 2
  
print(result)
# Judge status: Wrong Answer
n = int(input())
ns = list(map(int, input().split()))
if n == 0:
    if ns[0] == 1:
        print(1)
    else:
        print(-1)
    exit()
li = 1
ans = 0
max_leafs = [1]
for i in ns:
    li = (li - i) * 2
    max_leafs.append(li)
max_leafs.pop()
points = ns.pop()
ans += points
for i in range(len(ns)-1, -1, -1):
    a = ns[i]
    points = min(points + a, max_leafs[i])
    ans += points
if max_leafs[-1] <= 0:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
n, p = map(int, input().split())
A = list(map(int, input().split()))
U = n*100
dp = [0]*(U+1)
dp[0] = 1
for a in A:
    for j in reversed(range(U+1)):
        if 0 <= j-a:
            dp[j] += dp[j-a]
print(sum(dp[p::2]))
# Judge status: Wrong Answer
S = str(input())
if S[0]==S[1] and S[1]==S[2]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n , m = map(int, input().split())
if n == 1 and m == 1:
  print(1)
elif n == 1 or m == 1:
  print(max(n, m) - 2)
else:
  print((n - 2) * (m - 2))
# Judge status: Accepted

url = "https://atcoder.jp//contests/abc130/tasks/abc130_b"

def main():
    n,x = list(map(int, input().split()))
    lis = list(map(int, input().split()))
    lis.insert(0, 0)
    count = 0
    pos = 0
    for l in lis:
        pos += l
        count += 1
        if pos > x:
            print(count-1)
            exit()
    print(count)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline

x, n = list(map(int, input().split()))
p = list(map(int, input().split()))


l = x
h = x

while True:
    if l not in p:
        break
    else:
        l -= 1

while True:
    if h not in p:
        break
    else:
        h += 1

if (x - l) <= (h - x):
    print(l)
else:
    print(h)
# Judge status: Accepted
# 

from sys import stdin
input = lambda: stdin.readline().rstrip()


X = list(map(int, input().split()))
for i in range(5):
    if (X[i] == 0):
        print(i+1)
# Judge status: Wrong Answer
input()
a=max(list(map(int,input().split())))
b=min(list(map(int,input().split())))
print("War" if a>b else "No War")
# Judge status: Accepted
n, d = map(int, input().split())

xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for i, j in zip(x, y):
    if i*i + j*j <= d*d:
        count += 1

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

sum = B[0] + B[-1]

for i in range(N-2):
    sum += min(B[i], B[i+1])

print(sum)
# Judge status: Accepted
s = input()
s = sorted([s[0], s[1], s[2]])
s = ''.join(s)

if s=='abc':
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if (w - v) >= 0:
         print("NO")
         exit()
else:
         if (abs(a - b) + (v - w - 1))//(v - w) <= t:
                  print("YES")
         else:
                  print("NO")
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

ans = 1
up = dn = False
pre = A[0]
for a in A[1:]:
    if pre < a:
        up = True
    elif pre > a:
        dn = True
    if up and dn:
        ans += 1
        up = dn = False
    pre = a

print(ans)
# Judge status: Accepted
S = input()

T = input()
counter = 0
l = len(S)
for i in range(l):
    if not S[i]==T[i]:
        counter += 1

print(counter)
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for a in range(0, A + 1):
    if X < 500 * a:
        break
    for b in range(0, B + 1):
        if X < 500 * a + 100 * b:
            break
        c = (X - 500 * a - 100 * b) / 50
        if c <= C:
            ans += 1
        b += 1
    a += 1
    
print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
h=[int(input())for _ in range(n)]
h.sort()
ls=[]

for i in range(n-k+1):
  ls.append(abs(h[i]-h[i+k-1]))
  
print(min(ls))
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
Red = sorted(list(map(int, input().split())), reverse=True)
Grn = sorted(list(map(int, input().split())), reverse=True)
Wht = sorted(list(map(int, input().split())), reverse=True)

Mix = Red[:X] + Grn[:Y] + Wht
Mix = sorted(Mix, reverse=True)
ans = sum(Mix[:X+Y])
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

count=[0]*8
cnt = 0
for i in a:
    if i >=3200:
        cnt +=1
    else:
        count[i//400]+=1
cnt2= 0
for i in count:
    if i>0:
        cnt2+=1
if cnt2 == 0:
    print(1, cnt)
else:
    print(cnt2, cnt2+cnt)
# Judge status: Wrong Answer
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
s1 = sum(A1)
s2 = sum(A2[:-1])
result = A2[-1]
for j in range(N):
    result += A1[j]
    s1 -= A1[j]
    if s1 <= s2:
        result += s2
        break
    s2 -= A2[j]
print(result)
# Judge status: Accepted
n,m=map(int,input().split())
d={k:0 for k in range(1,n+1)}
for _ in range(m):
    a,b=map(int,input().split())
    d[a]+=1
    d[b]+=1
for v in d.values():
    print(v)
# Judge status: Wrong Answer
import fractions
def myAnswer(N:int,A:list) -> int:
   A.sort()
   return fractions.gcd(A[0],A[1])

def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()
# Judge status: Accepted
N = int(input())

flag =0

for i in range(1,10):
    for j in range(1,10):
        if j*i == N:
            flag +=1

print('Yes' if flag >0 else 'No')
# Judge status: Wrong Answer
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M,X = LI()
CA = np.array([LI() for _ in range(N)])
ans = float('INF')
for i in range(2**N):
    bit = np.array([[i>>j&1 for j in range(N)]]).T
    temp = np.sum(CA*bit,axis=0).tolist()
    temp2 = []
    temp2.append(temp)
    for money,*x in temp2:
        for y in x:
            if y<10:
                break
        else:
            ans = min(ans,money)
print(ans if ans !=float('INF') else -1)
# Judge status: Accepted
s = input()

tmp = s[0]
ans = 0
x = ""
for i in range(1,len(s)):
    if tmp == x+s[i]:
        x = s[i]
    else:
        tmp = x+s[i]
        x = ""
        ans += 1
print(ans+1)
# Judge status: Accepted
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
max_a = max(a for a, _ in ab)
dp = [10 ** 18 for _ in range(h + max_a)]
dp[0] = 0
for i in range(1, h + max_a):
    dp[i] = min(dp[i-a] + b for a, b in ab)
print(min(dp[h:]))