AtCoder Beginner Contest 087 - Coins

You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan).
In how many ways can we select some of these coins so that they are X yen in total?
Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

-----Constraints-----
 - 0 \leq A, B, C \leq 50
 - A + B + C \geq 1
 - 50 \leq X \leq 20 000
 - A, B and C are integers.
 - X is a multiple of 50.

-----Input-----
Input is given from Standard Input in the following format:
A
B
C
X

-----Output-----
Print the number of ways to select coins.

-----Sample Input-----
2
2
2
100

-----Sample Output-----
2

There are two ways to satisfy the condition:
 - Select zero 500-yen coins, one 100-yen coin and zero 50-yen coins.
 - Select zero 500-yen coins, zero 100-yen coins and two 50-yen coins.

Source: atcoder | Difficulty: EASY


Solutions:
A = int(input())
B = int(input())
C = int(input())
x = int(input())
ans = 0
for a in range(A + 1):
	for b in range(B + 1):
		for c in range(C + 1):
			total = 500 * a + 100 * b + 50 * c
			if total == x:
				ans += 1
print(ans)


(a, b, c, x) = [int(input()) for i in range(4)]
count = 0
print(sum([500 * i + 100 * j + 50 * k == x for i in range(a + 1) for j in range(b + 1) for k in range(c + 1)]))


(a, b, c, x) = map(int, open(0))
print(sum((1 for i in range(a + 1) for j in range(b + 1) for k in range(c + 1) if i * 10 + j * 2 + k == x / 50)))


s = [int(input()) for _ in range(3)]
(A, B, C) = s
X = int(input())
cnt = 0
for i in range(A + 1):
	for j in range(B + 1):
		for k in range(C + 1):
			tmp = 500 * i + 100 * j + 50 * k
			if tmp == X:
				cnt += 1
print(cnt)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
max_a = min(int(x / 500), a)
max_b = min(int(x / 100), b)
max_c = min(int(x / 50), c)
cnt = 0
for i in range(max_a + 1):
	for j in range(max_b + 1):
		for k in range(max_c + 1):
			if i * 500 + j * 100 + k * 50 == x:
				cnt += 1
print(cnt)


A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
rest_X = 0
for i in range(0, A + 1):
	rest_X = X - 500 * i
	if rest_X == 0:
		cnt += 1
		break
	elif rest_X < 0:
		break
	for j in range(0, B + 1):
		rest_X = X - 500 * i
		rest_X = rest_X - 100 * j
		if rest_X == 0:
			cnt += 1
			break
		elif rest_X < 0:
			break
		if 50 * C >= rest_X:
			cnt += 1
print(cnt)


c = 0
(I, J, K, x) = [int(input()) for _ in [0] * 4]
for i in range(I + 1):
	for j in range(J + 1):
		for k in range(K + 1):
			c += i * 500 + j * 100 + k * 50 == x
print(c)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if i * 500 + j * 100 + k * 50 == x:
				cnt += 1
print(cnt)


A = int(input())
B = int(input())
C = int(input())
X = int(input())
K = 0
for a in range(A + 1):
	for b in range(B + 1):
		for c in range(C + 1):
			K += 500 * a + 100 * b + 50 * c == X
print(K)


(a, b, c, x) = [int(input()) + 1 for _ in [0] * 4]
print(sum((c > x / 50 - s * 10 - t * 2 > 0 for s in range(a) for t in range(b))))


import sys
(A, B, C, X) = map(int, sys.stdin)
ans = 0
for i in range(A + 1):
	for j in range(B + 1):
		if 0 <= X - (i * 500 + j * 100) <= C * 50:
			ans += 1
print(ans)


A = int(input())
B = int(input())
C = int(input())
X = int(input()) // 50
ans = 0
for (a, b, c) in [(a, b, c) for a in range(A + 1) for b in range(B + 1) for c in range(C + 1)]:
	if 10 * a + 2 * b + c == X:
		ans += 1
print(ans)


(A, B, C, X) = [int(input()) for _ in range(4)]
print(len([1 for a in range(A + 1) for b in range(B + 1) if 0 <= X - 500 * a - 100 * b <= C * 50]))


ans = 0
(x, y, z, p) = [int(input()) for i in range(4)]
for a in range(x + 1):
	for b in range(y + 1):
		for c in range(z + 1):
			if 500 * a + 100 * b + 50 * c == p:
				ans += 1
print(ans)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
s = 50 * c
print(len([1 for i in range(a + 1) for m in range(b + 1) if 0 <= x - 500 * i - 100 * m <= s]))


(A, B, C, X) = map(int, open(0).read().split())
ans = 0
for a in range(A + 1):
	for b in range(B + 1):
		for c in range(C + 1):
			if X == 500 * a + 100 * b + 50 * c:
				ans += 1
print(ans)


(A, B, C, X) = [int(input()) for n in range(4)]
print(sum([1 for i in range(A + 1) for j in range(B + 1) for k in range(C + 1) if i * 500 + j * 100 + k * 50 == X]))


(a, b, c, x) = [int(input()) + 1 for _ in [0] * 4]
print(len([0 for s in range(a) for t in range(b) for r in range(c) if x - 1 == (10 * s + 2 * t + r) * 50]))


A = int(input())
B = int(input())
C = int(input())
X = int(input())
m = 0
for i in range(A + 1):
	for j in range(B + 1):
		for k in range(C + 1):
			if 500 * i + 100 * j + 50 * k == X:
				m += 1
print(m)


def main():
	(a, b, c, x) = (int(input()) + 1 for _ in range(4))
	x -= 1
	ans = 0
	for i_a in range(a):
		for i_b in range(b):
			for i_c in range(c):
				if i_a * 500 + i_b * 100 + i_c * 50 == x:
					ans += 1
	print(ans)
main()


(A, B, C, X) = [int(input()) for i in range(4)]
z = 0
for a in range(A + 1):
	for b in range(B + 1):
		for c in range(C + 1):
			x = 500 * a + 100 * b + 50 * c
			if X == x:
				z += 1
print(z)


(a, b, c, X) = list((int(input()) for i in range(4)))
print([500 * x + 100 * y + 50 * z for x in range(a + 1) for y in range(b + 1) for z in range(c + 1)].count(X))


A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0, A + 1):
	a = 500 * i
	for j in range(0, B + 1):
		b = 100 * j
		for k in range(0, C + 1):
			c = 50 * k
			if a + b + c == X:
				ans += 1
print(ans)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
apple = [500 * i + 100 * j + 50 * k for i in range(a + 1) for j in range(b + 1) for k in range(c + 1)]
print(apple.count(x))


(A, B, C, X) = map(int, open(0).read().split())
count = 0
for i in range(A + 1):
	for j in range(B + 1):
		for k in range(C + 1):
			if 500 * i + 100 * j + 50 * k == X:
				count += 1
print(count)


(a, b, c, x) = list((int(input()) for i in range(4)))
ans = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if 500 * i + 100 * j + 50 * k == x:
				ans += 1
print(ans)


(a, b, c, x) = [int(input()) for i in range(4)]
print(sum((0 <= (x - 500 * A - 100 * B) // 50 <= c for A in range(a + 1) for B in range(b + 1))))


A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for n in range(A + 1):
	for m in range(B + 1):
		for l in range(C + 1):
			if X == 500 * n + 100 * m + 50 * l:
				cnt += 1
print(cnt)


(a, b, c, x) = map(int, open(0).read().split())
total = 0
for a_ in range(0, a + 1):
	for b_ in range(0, b + 1):
		y = x - a_ * 500 - b_ * 100
		if y % 50 == 0 and 0 <= y // 50 <= c:
			total += 1
print(total)


A = int(input())
B = int(input())
C = int(input())
x = int(input())
print(sum([1 for a in range(A + 1) for b in range(B + 1) for c in range(C + 1) if 500 * a + 100 * b + 50 * c == x]))


(a, b, c, x) = [int(input()) for _ in range(4)]
print([500 * q + 100 * w + 50 * e for e in range(c + 1) for w in range(b + 1) for q in range(a + 1)].count(x))


(A, B, C, X) = [int(input()) for i in range(4)]
print(sum([500 * a + 100 * b + 50 * c == X for a in range(A + 1) for b in range(B + 1) for c in range(C + 1)]))


(a, b, c, d) = map(int, open(0))
print(sum((500 * i + 100 * j + 50 * k == d for i in range(a + 1) for j in range(b + 1) for k in range(c + 1))))


(A, B, C, X) = [int(input()) for _ in [0] * 4]
ans = sum((a * 500 + b * 100 + c * 50 == X for a in range(A + 1) for b in range(B + 1) for c in range(C + 1)))
print(ans)


A = int(input())
B = int(input())
C = int(input())
x = int(input())
ans = 0
L = [500 * a + 100 * b + 50 * c for c in range(C + 1) for b in range(B + 1) for a in range(A + 1)]
print(L.count(x))


(A, B, C, X) = list(map(int, [input() for i in range(4)]))
ans = 0
for i in range(A + 1):
	for j in range(B + 1):
		for k in range(C + 1):
			if i * 500 + j * 100 + k * 50 == X:
				ans = ans + 1
print(ans)


(A, B, C, X) = [int(input()) for x in range(4)]
print([500 * a + 100 * b + 50 * c for c in range(C + 1) for b in range(B + 1) for a in range(A + 1)].count(X))


i = lambda : int(input())
(a, b, c, x) = (i(), i(), i(), i())
print(len([0 for s in range(a + 1) for t in range(b + 1) for r in range(c + 1) if x == (10 * s + 2 * t + r) * 50]))


(A, B, C, X) = map(int, open(0))
ans = 0
for i in range(0, A + 1):
	for j in range(0, B + 1):
		tmp = (X - 500 * i - 100 * j) / 50
		if tmp.is_integer() and tmp >= 0 and (tmp <= C):
			ans += 1
print(ans)


x = [int(input()) for _ in range(4)]
print(len(['' for i in range(x[0] + 1) for j in range(x[1] + 1) for k in range(x[2] + 1) if 500 * i + 100 * j + 50 * k == x[3]]))


a = int(input())
b = int(input())
c = int(input())
n = int(input())
ans = 0
for i in range(a + 1):
	for j in range(b + 1):
		for h in range(c + 1):
			if 500 * i + 100 * j + 50 * h == n:
				ans += 1
print(ans)


s = [int(input()) for i in range(4)]
A = s[0]
B = s[1]
C = s[2]
X = s[3]
res = 0
total = 0
for a in range(A + 1):
	for b in range(B + 1):
		for c in range(C + 1):
			total = 500 * a + 100 * b + 50 * c
			if total == X:
				res = res + 1
print(res)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for an in range(a + 1):
	for bn in range(b + 1):
		for cn in range(c + 1):
			if x == 500 * an + 100 * bn + 50 * cn:
				cnt += 1
print(cnt)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
	for j in range(b + 1):
		if (x - (500 * i + 100 * j)) % 50 == 0 and (x - (500 * i + 100 * j)) // 50 <= c and (500 * i + 100 * j <= x):
			ans += 1
print(ans)


A = int(input())
B = int(input())
C = int(input())
X = int(input())
L = []
for a in range(A + 1):
	for b in range(B + 1):
		for c in range(C + 1):
			if 500 * a + 100 * b + 50 * c == X:
				L.append((a, b, c))
print(len(L))


(a, b, c, x) = [int(input()) + 1 for _ in range(4)]
print(sum((10 * i + 2 * j + k == x // 50 for k in range(c) for j in range(b) for i in range(a))))


A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for a in range(A + 1):
	if X < 500 * a:
		continue
	y = X - 500 * a
	if y == 0:
		cnt += 1
		continue
	for b in range(B + 1):
		if y < b * 100:
			continue
		z = y - 100 * b
		if z == 0:
			cnt += 1
			continue
		for c in range(C + 1):
			w = z - 50 * c
			if w == 0:
				cnt += 1
				break
print(cnt)


num = [int(input()) for i in range(3)]
total = [500 * a + 100 * b + 50 * c for a in range(num[0] + 1) for b in range(num[1] + 1) for c in range(num[2] + 1)]
print(total.count(int(input())))


(a, b, c, x) = map(int, [input() for i in range(4)])
ans = [a for A in range(a + 1) for B in range(b + 1) for C in range(c + 1) if A * 500 + B * 100 + C * 50 == x]
print(len(ans))


(a, b, c, X) = [int(input()) for i in range(4)]
l = []
for x in range(a + 1):
	for y in range(b + 1):
		for z in range(c + 1):
			s = 500 * x + 100 * y + 50 * z
			l.append(s)
print(l.count(X))


(A, B, C, X) = [int(input()) for i in range(4)]
count = 0
for a in range(A + 1):
	for b in range(B + 1):
		if 0 <= X - 500 * a - 100 * b <= C * 50:
			count += 1
print(count)


a_coins = int(input())
b_coins = int(input())
c_coins = int(input())
x_num = int(input())

def money_match(a, b, c):
	money = 500 * a + 100 * b + 50 * c
	if money == x_num:
		return 1
	else:
		return 0
cnt = 0
for a in range(a_coins + 1):
	for b in range(b_coins + 1):
		for c in range(c_coins + 1):
			if money_match(a, b, c) == 1:
				cnt += 1
print(cnt)


(a, b, c, x) = [int(input()) for _ in range(4)]
print([500 * x + 100 * y + 50 * z for x in range(a + 1) for y in range(b + 1) for z in range(c + 1)].count(x))


(a, b, c, x) = map(int, [input() for i in range(4)])
cnt = 0
for aa in range(a + 1):
	for bb in range(b + 1):
		for cc in range(c + 1):
			if aa * 500 + bb * 100 + cc * 50 == x:
				cnt += 1
print(cnt)


L = [int(input()) for i in range(4)]
ans = 0
for i in range(L[0] + 1):
	for j in range(L[1] + 1):
		for k in range(L[2] + 1):
			ans += 1 if i * 500 + j * 100 + k * 50 == L[3] else 0
print(ans)


(a, b, c, x) = [int(input()) for _ in range(4)]
ans = 0
for ia in range(a + 1):
	for ib in range(b + 1):
		for ic in range(c + 1):
			if x == ia * 500 + ib * 100 + ic * 50:
				ans += 1
print(ans)


a = int(input())
b = int(input())
c = int(input())
sum_ = int(input())
count = 0
for i in range(0, a + 1):
	for j in range(0, b + 1):
		for k in range(0, c + 1):
			check = 500 * i + 100 * j + 50 * k
			if check == sum_:
				count += 1
print(count)


n = [int(input()) for i in range(4)]
print(sum((0 <= (n[3] - 500 * a - 100 * b) // 50 <= n[2] and (n[3] - 500 * a - 100 * b) % 50 == 0 for a in range(n[0] + 1) for b in range(n[1] + 1))))


a = int(input())
b = int(input())
c = int(input())
n = int(input())
d = 0
for x in range(a + 1):
	for y in range(b + 1):
		for z in range(c + 1):
			if 500 * x + 100 * y + 50 * z == n:
				d += 1
print(d)


list = [int(input()) for i in range(4)]
m = 0
for i in range(list[0] + 1):
	for j in range(list[1] + 1):
		for k in range(list[2] + 1):
			if list[3] == 50 * k + 100 * j + 500 * i:
				m += 1
print(m)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
ans = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if d == i * 500 + j * 100 + k * 50:
				ans += 1
print(ans)


(a, b, c, x) = [int(input()) for _ in range(4)]
print(len(['yes' for i in range(a + 1) for j in range(b + 1) for k in range(c + 1) if 500 * i + 100 * j + 50 * k == x]))


A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A + 1):
	X_ = X
	X_ -= 500 * i
	for j in range(B + 1):
		X__ = X_
		X__ -= 100 * j
		for k in range(C + 1):
			X___ = X__
			X___ -= 50 * k
			if X___ == 0:
				cnt += 1
print(cnt)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
print(sum([_a * 500 + _b * 100 + _c * 50 == x for _a in range(a + 1) for _b in range(b + 1) for _c in range(c + 1)]))


(A, B, C, X) = [int(input()) for i in range(4)]
print(sum((500 * x + 100 * y + 50 * z == X for x in range(A + 1) for y in range(B + 1) for z in range(C + 1))))


def solve(A, B, C, X):
	ans = 0
	for a in range(A + 1):
		for b in range(B + 1):
			for c in range(C + 1):
				total = 500 * a + 100 * b + 50 * c
				if total == X:
					ans += 1
	print(ans)

def __starting_point():
	A = int(input())
	B = int(input())
	C = int(input())
	X = int(input())
	solve(A, B, C, X)
__starting_point()


a = int(input())
b = int(input())
c = int(input())
q = int(input())
ans = 0
for i in range(a + 1):
	for k in range(b + 1):
		for p in range(c + 1):
			if 500 * i + 100 * k + 50 * p == q:
				ans += 1
print(ans)


with open(0) as f:
	(a, b, c, x) = map(int, f.read().split())
cnt = 0
from itertools import product
for (i, j, k) in product(range(a + 1), range(b + 1), range(c + 1)):
	if 500 * i + 100 * j + 50 * k == x:
		cnt += 1
print(cnt)


from itertools import product
(a, b, c, x) = (int(input()), int(input()), int(input()), int(input()))
print(sum((500 * i + 100 * j + 50 * k == x for (i, j, k) in product(range(a + 1), range(b + 1), range(c + 1)))))


(a, b, c, x) = [int(input()) for i in range(4)]
print(sum([500 * p + 100 * q + 50 * r == x for p in range(a + 1) for q in range(b + 1) for r in range(c + 1)]))


(A, B, C, X) = (int(input()) for _ in range(4))
L = [500 * x + 100 * y + 50 * z for z in range(C + 1) for y in range(B + 1) for x in range(A + 1)]
print(L.count(X))


(A, B, C, X) = [int(input()) for i in range(4)]
(n, a) = (0, 0)
while a < A + 1:
	b = 0
	while b < B + 1:
		x = a * 500 + b * 100
		b += 1
		if X < x:
			continue
		if X - x <= C * 50:
			n += 1
	a += 1
print(n)


(a, b, c, x) = map(int, [input() for i in range(4)])
res = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			res += 500 * i + 100 * j + k * 50 == x
print(res)


(a, b, c) = [int(input()) for i in range(3)]
x = int(input())
ans = [True for i in range(a + 1) for j in range(b + 1) for k in range(c + 1) if 500 * i + 100 * j + 50 * k == x]
print(sum(ans))


a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for aa in range(a + 1):
	for bb in range(b + 1):
		for cc in range(c + 1):
			if 500 * aa + 100 * bb + 50 * cc == x:
				ans += 1
print(ans)


a = int(input())
b = int(input())
c = int(input())
z = int(input())
l = [500 * i + 100 * t + 50 * w for i in range(a + 1) for t in range(b + 1) for w in range(c + 1)]
print(l.count(z))


(A, B, C, X) = [int(input()) for i in range(4)]
ways = 0
max_a = int(X / 500)
if A < max_a:
	max_a = A
for a in reversed(list(range(max_a + 1))):
	max_b = int((X - 500 * a) / 100)
	if B < max_b:
		max_b = B
	for b in reversed(list(range(max_b + 1))):
		c = int((X - 500 * a - 100 * b) / 50)
		if c > C:
			break
		ways += 1
print('%d' % ways)


(a, b, c) = map(int, [input() for _ in range(3)])
x = int(input())
print(sum((1 for i in range(a + 1) for j in range(b + 1) for k in range(c + 1) if 500 * i + 100 * j + 50 * k == x)))


(a, b, c, x) = (int(input()) for i in range(4))
print(sum([1 for q in range(a + 1) for w in range(b + 1) for e in range(c + 1) if 500 * q + 100 * w + 50 * e == x]))


[print(sum((i * 500 + j * 100 + k * 50 == sum_ for k in range(c + 1) for j in range(b + 1) for i in range(a + 1)))) for (a, b, c, sum_) in [[int(input()) for _ in range(4)]]]


(A, B, C, X) = [int(input()) for i in range(4)]
ans = 0
for a in range(A + 1):
	for b in range(B + 1):
		for c in range(C + 1):
			if 500 * a + 100 * b + 50 * c == X:
				ans += 1
				break
print(ans)


(a, b, c, x) = [int(input()) for _ in range(4)]
print(sum([(x - 500 * i - 100 * j) % 50 == 0 and 0 <= (x - 500 * i - 100 * j) // 50 <= c for i in range(a + 1) for j in range(b + 1)]))


(a, b, c, d) = [int(input()) for i in range(4)]
x = 0
for l in range(a + 1):
	for m in range(b + 1):
		for n in range(c + 1):
			if 500 * l + 100 * m + 50 * n == d:
				x += 1
print(x)


a = int(input())
b = int(input())
c = int(input())
m = int(input())
s = 0
for i in range(a + 1):
	for j in range(b + 1):
		(x, y) = divmod(m - i * 500 - j * 100, 50)
		if y == 0 and 0 <= x <= c:
			s += 1
print(s)


def t():
	return range(int(input()) + 1)
from itertools import product as p
a = 0
s = p(t(), t(), t())
x = int(input())
for (i, j, k) in s:
	if i * 500 + j * 100 + k * 50 == x:
		a += 1
print(a)


A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A + 1):
	for b in range(B + 1):
		for c in range(C + 1):
			total = 500 * a + 100 * b + 50 * c
			if total == X:
				count += 1
print(count)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
t = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if 10 * i + 2 * j + k == x / 50:
				t += 1
print(t)


from itertools import product
a = int(input())
b = int(input())
c = int(input())
x = int(input())
print(sum((A * 500 + B * 100 + C * 50 == x for (A, B, C) in product(range(a + 1), range(b + 1), range(c + 1)))))


a = int(input())
b = int(input())
c = int(input())
g = int(input())
tmp = []
for x in range(a + 1):
	for y in range(b + 1):
		for z in range(c + 1):
			tmp.append(500 * x + 100 * y + 50 * z)
ans = tmp.count(g)
print(ans)


(a, b, c, x) = map(int, [input() for i in range(4)])
ans = [a for a1 in range(a + 1) for b1 in range(b + 1) for c1 in range(c + 1) if a1 * 500 + b1 * 100 + c1 * 50 == x]
print(len(ans))


[a] = [int(i) for i in input().split()]
[b] = [int(i) for i in input().split()]
[c] = [int(i) for i in input().split()]
[x] = [int(i) for i in input().split()]
ans = 0
for ia in range(a + 1):
	for ib in range(b + 1):
		for ic in range(c + 1):
			if ia * 500 + ib * 100 + ic * 50 == x:
				ans += 1
print(ans)


(A, B, C, X) = [int(input()) for i in range(1, 5)]
print([500 * a + 100 * b + 50 * c for a in range(A + 1) for b in range(B + 1) for c in range(C + 1)].count(X))


ans = 0
(a, b, c, x) = [int(input()) + 1 for _ in range(4)]
for i in range(a):
	for j in range(b):
		for k in range(c):
			if 10 * i + 2 * j + k == x // 50:
				ans += 1
print(ans)


(a, b, c, x) = map(int, open(0).read().split())
s = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if i * 500 + j * 100 + k * 50 == x:
				s += 1
print(s)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
li = [[i, j, k] for i in range(a + 1) for j in range(b + 1) for k in range(c + 1) if 500 * i + 100 * j + 50 * k == x]
print(len(li))


import sys
input = sys.stdin.readline

def main():
	a = int(input())
	b = int(input())
	c = int(input())
	target = int(input())
	count = 0
	for i in range(a + 1):
		for j in range(b + 1):
			for k in range(c + 1):
				if 500 * i + 100 * j + 50 * k == target:
					count += 1
				else:
					continue
	print(count)

def __starting_point():
	main()
__starting_point()


(a, b, c, x) = eval('int(input())+1,' * 4)
print(sum((c > x / 50 - I // b * 10 - I % b * 2 > 0 for I in range(a * b))))


(A, B, C, x) = [int(input()) for _ in range(4)]
cnt = 0
for a in range(A + 1):
	for b in range(B + 1):
		if 0 <= (x - 500 * a - 100 * b) // 50 <= C:
			cnt += 1
print(cnt)


getints = lambda : map(int, input().split())
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			val = 500 * i + 100 * j + 50 * k
			if val == x:
				ans += 1
print(ans)


a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for a_idx in range(a + 1):
	for b_idx in range(b + 1):
		for c_idx in range(c + 1):
			total = 500 * a_idx + 100 * b_idx + 50 * c_idx
			if total == x:
				cnt += 1
print(cnt)


def answer(a: int, b: int, c: int, x: int) -> int:
	count = 0
	for i in range(0, a + 1):
		for j in range(0, b + 1):
			for k in range(0, c + 1):
				if x == i * 500 + j * 100 + k * 50:
					count += 1
	return count

def main():
	a = int(input())
	b = int(input())
	c = int(input())
	x = int(input())
	print(answer(a, b, c, x))

def __starting_point():
	main()
__starting_point()


def main():
	five_hundred = int(input())
	one_hundred = int(input())
	fifty = int(input())
	x = int(input())
	ans = 0
	for i in range(five_hundred + 1):
		for j in range(one_hundred + 1):
			for k in range(fifty + 1):
				if 500 * i + 100 * j + 50 * k == x:
					ans += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(0, A + 1):
	if 500 * a > X:
		continue
	for b in range(0, B + 1):
		if 500 * a + 100 * b > X:
			continue
		for c in range(0, C + 1):
			if 500 * a + 100 * b + 50 * c == X:
				ans += 1
print(ans)


a = list(map(int, open(0).read().split()))
res = 0
for i in range(a[0] + 1):
	for j in range(a[1] + 1):
		for k in range(a[2] + 1):
			if 500 * i + 100 * j + 50 * k == a[3]:
				res += 1
print(res)


ans = 0
(a, s, d, x) = [int(input()) for i in range(4)]
for i in range(1 + a):
	for j in range(1 + s):
		for k in range(1 + d):
			if 500 * i + j * 100 + 50 * k == x:
				ans += 1
print(ans)


import sys
(a, b, c, x) = map(int, sys.stdin.read().split())
count = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if 500 * i + 100 * j + 50 * k == x:
				count += 1
print(count)


(a, b, c, x) = [int(input()) for i in range(4)]
print([500 * X + 100 * Y + 50 * Z for X in range(a + 1) for Y in range(b + 1) for Z in range(c + 1)].count(x))


a = int(input())
b = int(input())
c = int(input())
X = int(input())
x = X / 50
count = 0
for i in range(a + 1):
	for l in range(b + 1):
		if 0 <= x - i * 10 - l * 2 <= c:
			count += 1
print(count)


(a, b, c, d) = map(int, open(0))
print(sum((500 * x + 100 * y + 50 * z == d for x in range(a + 1) for y in range(b + 1) for z in range(c + 1))))


(a, b, c, x) = [int(input()) for _ in range(4)]
s = 0
for p in range(a + 1):
	for q in range(b + 1):
		for r in range(c + 1):
			if 500 * p + 100 * q + 50 * r == x:
				s += 1
print(s)


(a, b, c, x) = [int(input()) for i in range(4)]
ans = 0
for a0 in range(a + 1):
	for b0 in range(b + 1):
		for c0 in range(c + 1):
			if a0 * 500 + b0 * 100 + c0 * 50 == x:
				ans += 1
print(ans)