Problem:
 Score : 200 points    Problem Statement 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 1 2
2
2
100      Sample Output 1 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.        Sample Input 2 5
1
0
150      Sample Output 2 0  Note that the total must be exactly X yen.       Sample Input 3 30
40
50
6000      Sample Output 3 213

Solution (Python):

import sys

def main():
	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):
				if (a * 500) + (b * 100) + (c * 50) == X:
					ans += 1
	print(ans)
		
if __name__ == "__main__":
	main()

Solution (Python):


import itertools
import collections
import bisect

def main():
    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):
            rest = X - 500 * a - 100 * b
            if 0 <= rest <= 50 * C:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

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

Solution (Python):
a,b,c,d=[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(d))

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for ai in range(a+1):
	for bi in range(b+1):
		for ci in range(c+1):
			if x == ai*500 + bi* 100 + ci*50:
				count+=1
				
print(count)

Solution (Python):

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 500*i+100*j+50*k == x:
                cnt += 1
print(cnt)

Solution (Python):
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(k*50+j*100+i*500 == X):
        cnt += 1
print(cnt)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = 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) == x:
                count += 1

print(count)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
pattern = 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:
                pattern += 1
print(pattern)

Solution (Python):
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):
      if 500*i + 100*j + 50*k == x:
        ans += 1

print(ans)

Solution (Python):
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):
            if 500*i+100*j+50*k == x:
                ans += 1

print(ans)

Solution (Python):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
a=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:
        a+=1
print(a)

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    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):
                if 500 * i + 100 * j + 50 * k == X:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

if(X >= 500):
 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)

else:
 for j in range(B+1):
    for k in range(C+1):
      if((100*j+50*k)==X):
        count += 1   
 print(count)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
num = 0



for i in range(a+1):
    if 500 * i == x:
        num = num + 1
        break
    
    elif 500 * i > x:
        break
    
    else:
        for j in range(b+1):
            if 500 * i + 100 * j == x:
                num = num + 1
                break

            elif 500 * i + 100 * j > x:
                break

            else:
                for k in range(c+1):
                    if 500 * i + 100 * j + 50 * k == x:
                        num = num + 1
                        break

                    elif 500 * i + 100 * j + 50 * k > x:
                        break

print(num)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

res = 0
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:
                res += 1
print(res)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res = 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 += 1
print(res)

Solution (Python):
count = 0

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

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

Solution (Python):
def main():
    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):
                if 500*a + 100*b + 50*c == X:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
ans = 0
A,B,C,X = (int(input()) for i in range(4))
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)

Solution (Python):
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):
      ch = i*500 + j*100 + k*50
      if ch == X:
        cnt += 1
print(cnt)

Solution (Python):

A = int(input())
B = int(input())
C = int(input())
X = int(input()) // 50
ans = 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:
                ans += 1
print(ans)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
num = 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:
                num += 1
                break
print(num)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 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 :
                cnt += 1

print(cnt)

Solution (Python):
from sys import stdin
a = int(stdin.readline().rstrip())
b = int(stdin.readline().rstrip())
c = int(stdin.readline().rstrip())
x = int(stdin.readline().rstrip())
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 += 1

print(ans)

Solution (Python):
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):
      if X == 500*i+100*j+50*k:
        ans+=1
print(ans)

Solution (Python):
c500=int(input())
c100=int(input())
c50=int(input())
x=int(input())
a=0
for i in range(c500+1):
    for j in range(c100+1):
        for k in range(c50+1):
            amount=k*50+j*100+i*500
            if amount==x:
                a+=1
print(a)

Solution (Python):
count_500 = int(input())
count_100 = int(input())
count_50 = int(input())
target = int(input())

count=0
for i in range(count_500+1):
  for j in range(count_100+1):
    for k in range(count_50+1):
      if target==500*i+100*j+50*k:
        count+=1
print(count)

Solution (Python):
count_500 = int(input())
count_100 = int(input())
count_50 = int(input())
target = int(input())

count = 0
for i in range(count_500+1):
    for j in range(count_100+1):
        for k in range(count_50+1):
            if target == 500 * i + 100 * j + 50 * k:
                count += 1
print(count)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ret = 0
for i in range(a+1):
    for j in range(b+1):
        if (x - i*500 - j*100)//50 in range(c+1):
            ret += 1
print(ret)

Solution (Python):
coin_500=int(input())
coin_100=int(input())
coin_50=int(input())
x=int(input())
ans=0
for i in range(coin_500+1):
    for j in range(coin_100+1):
        for k in range(coin_50+1):
            if i*500+j*100+50*k==x:
                ans+=1
print(ans)

Solution (Python):
a, b, c, x = 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 += 1
print(ans)

Solution (Python):
a,b,c,x=[int(input()) for i in range(4)]
cnt=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:
                cnt+=1
print(cnt)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
maxa = min([a,x//500])
maxb = min([b,x//100])
maxc = min([c,x//50])
count = 0
for i in range(maxa + 1):
    for j in range(maxb + 1):
        for k in range(maxc + 1):
            if 10*i + 2*j + k == x/50:
                count += 1
print(count)

Solution (Python):
a = int(input()) + 1
b = int(input()) + 1
c = int(input()) + 1
total = int(input())
pattern_num = 0
for i in range(0, a):
    for j in range(0, b):
        for k in range(0, c):
            if i*500+j*100+k*50 == total:
                pattern_num += 1
print (pattern_num)

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

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

out_sum = 0
cnt = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            out_sum = i * 500 + j * 100 + k * 50
            if out_sum == X : cnt += 1
                
                
print(cnt)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
total = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            money = i*500 + j*100 + k*50
            if money == x:
                total = total + 1

print(total)

Solution (Python):

"""
Created on Wed Feb 27 16:15:21 2019

@author: yuta
"""

def coin(a,b,c,x):
    count = 0
    for i in range(a + 1):
        for j in range(b + 1):
            for k in range(c + 1):
                d = 500 * i + 100 * j + 50 * k
                if d == x:
                    count += 1
    print(count)

a = int(input())
b = int(input())
c = int(input())
x = int(input())

coin(a,b,c,x)

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

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

n = 0
for fiveHundred in range(a+1):
    for hundred in range(b+1):
        for fifty in range(c+1):
            if x == 500*fiveHundred + 100*hundred + 50*fifty:
                n +=1

print(n)

Solution (Python):
A, B, C, X = [int(input()) for _ 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)

Solution (Python):
a, b, c, x = [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 += 1
print(ans)

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

Solution (Python):
A = input()
B = input()
C = input()
X = input()

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
print ans

Solution (Python):
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):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

Solution (Python):
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):
             if 500*i + 100*j + 50*k == x:
                    ans +=1
print(ans)

Solution (Python):
a=int(input())
b=int(input())
c=int(input())
x=int(input())
s=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:
                 s+=1
print(s)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
a = list(map(lambda x: x * 500, range(A + 1)))
b = list(map(lambda x: x * 100, range(B + 1)))
c = list(map(lambda x: x * 50, range(C + 1)))

counter = 0

for i in a:
    for p in b:
        for o in c:
            if (i + p + o) == X:
                counter += 1

print(counter)

Solution (Python):
a, b, c, x = [int(input()) for _ 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)

Solution (Python):
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 500*i+100*j+50*k==x:
        t+=1
print(t)

Solution (Python):
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):
            if 500*i+100*j+50*k==X:
                ans+=1
print(ans)

Solution (Python):
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 500*i+100*j+50*k==x:
                cnt+=1
print(cnt)

Solution (Python):
a=int(input())
b=int(input())
c=int(input())

x=int(input())


def only_hun_fif(b,c,m):
    count=0
    for i in range(b+1):
        if m-(i*100)<=50*c and m-(i*100)>=0:
            count+=1

            
    return count
        
count=0

for i in range(a+1):
    if x-i*500<0:
        break
    else:
        count+=only_hun_fif(b,c,x-i*500)
    
print(count)

Solution (Python):
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):
        if 0 <= (x-i*500-j*100)//50 <= c:
            cnt += 1
print(cnt)

Solution (Python):
c = [500,100,50]
a = []
for i in range(3):
    a.append(int(input()))
x = int(input())

def dfs(d,y):
    if d == 3:
        if y == x:
            return 1
        return 0

    ret = 0
    for i in range(a[d]+1):
        ret += dfs(d+1, y+c[d]*i)
    return ret

print(dfs(0,0))

Solution (Python):
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):
        x = X - (a*500+b*100)
        if x < 0:
            break
        if (x % 50 == 0) and (x / 50 <= C):
            count += 1
print(count)

Solution (Python):
a, b, c, x = [int(d[0]) for d in [input().split() for _ in range(4)]]
cnt = 0
for o in range(a+1):
    for p in range(b+1):
        for q in range(c+1):
            if o * 500 + p * 100 + q * 50 == x:
                cnt += 1
print(cnt)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
k = 0

if X % 50:
    print(k)
else:
    maxA = min(X // 500, A)
    for i in range(maxA + 1):
        d = X - 500 * i
        maxB = min(d // 100, B)
        for j in range(maxB + 1):
            dd = d - 100 * j
            if dd // 50 <= C:
                k += 1
    print(k)

Solution (Python):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for amai in range(A+1):
  for bmai in range(B+1):
    for cmai in range(C+1):
      if (amai*500+bmai*100+cmai*50==X):
        count=count+1
print(count)

Solution (Python):
import itertools
la = [500 * i for i in range(int(input())+1)]
lb = [100 * i for i in range(int(input())+1)]
lc = [50 * i for i in range(int(input())+1)]
d = int(input())
r = list(itertools.product(la, lb, lc))
ans = 0

for s in r:
  if sum(s) == d:
    ans += 1
print(ans)

Solution (Python):
a,b,c,x=[int(input())+1for _ in[0]*4];print(sum(c>x/50-I//b*10-I%b*2>0for I in range(a*b)))

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

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

Solution (Python):
R=range;a,b,c,x=[int(input())+1for _ in[0]*4];print(sum(x-1==(10*s+2*t+r)*50for s in R(a)for t in R(b)for r in R(c)))

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

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

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

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

Solution (Python):
a,b,c,x=[int(input())for _ in[0]*4];print(len([0for 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]))

Solution (Python):
i=lambda:int(input());a,b,c,x=i(),i(),i(),i();print(len([0for 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]))

Solution (Python):
A=int(input())
B=int(input())
C=int(input())
X=int(input())

l=[]
count=0

for i in range(A+1):
	for j in range(B+1):
		for k in range(C+1):
			if X==(500*i+100*j+50*k):
				count+=1

print(count)
"""
for i in range(A):
	if(X>=500*i):
		Y=X-500*i
		print(Y)
		a+=1
	for j in range(B):
		if(Y>=100*j):
			Z=Y-100*j
			print(Z)
			b+=1
"""

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 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:
        cnt += 1
print(cnt)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = 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 == x:
                count += 1 
print(count)

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

Solution (Python):
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 ):
            if 500*i + 100*j + 50*k == X:
                ans += 1

print( ans )

Solution (Python):
A=[int(input()) for _ in range(3)]
N=int(input())
ans=0

for i in range(A[0]+1):
  for j in range(A[1]+1):
    for k in range(A[2]+1):
      if N==(500*i+100*j+50*k):
        ans+=1
        
print(ans)

Solution (Python):
count_500 = int(input())
count_100 = int(input())
count_50 = int(input())
target = int(input())

ways = 0
for i in range(1+count_500):
    for j in range(1+count_100):
        for k in range(1+count_50):
            if target == 500*i+100*j+50*k:
                ways +=1
print(ways)

Solution (Python):
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):
            if(500*i+100*j+50*k == x):
                ans+=1
print(ans)

Solution (Python):
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):
            if 500*i+100*j+50*k==x:
                ans += 1
print(ans)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

num = 0
for i in range(0,A+1):
    for ii in range(0,B+1):
        for iii in range(0,C+1):
            t = i*500 + ii*100 + iii*50
            if t ==X:
                num+=1
print(num)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count=0
for i in range(a+1):
    for j in range(b+1):
        rest = x- (i*500 + j*100)
        
        if 0<=rest and rest//50 <=c:
            count+=1

print(count)

Solution (Python):
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(500*i + 100*j + 50*k == X):
        cnt += 1
print(cnt)

Solution (Python):
a,b,c,x=int(input()),int(input()),int(input()),int(input())
cnt=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:
        cnt+=1
print(cnt)

Solution (Python):
a, b, c, x = int(raw_input()), int(raw_input()), int(raw_input()), int(raw_input())
def calc(a, b, c, x, m) :
    if not x : 
        return 1

    result = 0
    if m >= 500 and x >= 500 and a :
        result += calc(a - 1, b, c, x - 500, 500)
    if m >= 100 and x >= 100 and b :
        result += calc(a, b - 1, c, x - 100, 100)
    if x >= 50 and c:
        result += calc(a, b, c - 1, x - 50, 50)
    
    return result


print calc(a, b, c, x, x)

Solution (Python):
nums = [input() for i in range(3)]
A,B,C = map(int,nums)
x = 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 == x:
        count +=1
print(count)

Solution (Python):
int_a = int(input())
int_b = int(input())
int_c = int(input())
int_x = int(input())

int_pattern = 0

for a in range(int_a + 1):
    for b in range(int_b + 1):
        for c in range(int_c + 1):
            if 500 * a + 100 * b + 50 * c == int_x:
                int_pattern = int_pattern + 1

print(int_pattern)

Solution (Python):
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):
            if (X == 500 * i + 100 * j + 50 * k):
                ans += 1

print(ans)

Solution (Python):
""" AtCoder """

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):
            if i * 500 + j * 100 + k *50 == X:
                ans += 1

print(ans)

Solution (Python):
a_500 = int(input().split()[0])
b_100 = int(input().split()[0])
c_50 = int(input().split()[0])
x = int(input().split()[0])

all_coins = []
count = 0

for a_n in range(a_500+1):
    for b_n in range(b_100+1):
        for c_n in range(c_50+1):
            total = 500*a_n + 100*b_n + 50*c_n
            if total == x:
                count += 1

print(count)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 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:
                cnt+=1
print(cnt)

Solution (Python):
import sys
input = sys.stdin.readline

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):
        if 500 * a + 100 * b <= X <= 500 * a + 100 * b + 50 * C:
            count += 1

print(count)

Solution (Python):
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("Three")
    else:print("Four")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())














a = ip()+1
b = ip()+1
c = ip()+1
x = ip()
sum = 0
for i in range(a):
    for l in  range(b):
        for m in range(c):
            if 500*i+100*l+50*m == x:sum+=1
print(sum)

Solution (Python):
a,b,c,x = [int(input()) for i in range(4)]
d = 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): 
                d += 1
print(d)

Solution (Python):
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):
            if 500 * a + 100 * b + 50 * c == X:
                count += 1

print(count)

Solution (Python):
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):
            if 500 * a + 100 * b + 50 * c == X:
                count += 1

print(count)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = 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 == X:
                count += 1


print(count)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

flg = 0
count = 0
for i in range(A+1):
    if 500 * i > X:
        break
    for j in range(B+1):
        if 500 * i + 100 * j > X:
            break
        for k in range(C+1):
            _sum = 500 * i + 100 * j + 50 * k
            if _sum > X:
                break
            if _sum == X:
                count += 1
print(count)

Solution (Python):
A=int(input())
B=int(input())
C=int(input())
X=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==X:
                count+=1
print(count)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

X //= 50
ans = 0
for a in range(A+1):
    for b in range(B+1):
        if 0 <= X - 10*a - 2*b <= C:
            ans += 1
print(ans)

Solution (Python):
a=int(input())
b=int(input())
c=int(input())
X = int(input())
fifty = [x for x in range (0,X+1,500)][:a+1]
hundred = [x for x in range (0,X+1,100)][:b+1]
five_hundred = [x for x in range (0,X+1,50)][:c+1]
pattern = [x+y+z for x in fifty for y in hundred for z in five_hundred]
print(len(list(filter(lambda x:x==X,pattern))))

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            num = 500*i + 100*j + 50*k
            if num == X:
                count = count + 1

print(count)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

comb = []
count = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
                comb.append([i, j, k])
for i in range(len(comb)):
    if x == 500*comb[i][0] + 100*comb[i][1] + 50*comb[i][2]:
        count += 1

print(count)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

comb = []
count = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
                comb.append([i, j, k])
for i in range(len(comb)):
    if (x == 500*comb[i][0] + 100*comb[i][1] + 50*comb[i][2]) and \
        (a >= comb[i][0]) and (b >= comb[i][1]) and (c >= comb[i][2]):
        count += 1

print(count)

Solution (Python):

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 = cnt + 1
                
print(cnt)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

res = 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 == 0:
                res += 1

print(res)

Solution (Python):
a=int(input())
b=int(input())
c=int(input())
x=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==x):
                count+=1
print(count)

Solution (Python):
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):
            if 500*i+100*j+50*k == X:
                ans += 1

print(ans)

Solution (Python):


a = int(input())
b = int(input())
c = int(input())

x = int(input())


pettern = 0
for i in range(0, a + 1):
    temp_x = x - (i * 500)

    if temp_x == 0:
        pettern += 1

    if temp_x <= 0:
        break

    
    for j in range(0, b + 1):
        temp_x2 = temp_x - (j * 100)

        if temp_x2 == 0:
            pettern += 1

        if temp_x2 <= 0:
            break

        
        for k in range(0, c + 1):
            temp_x3 = temp_x2 - (k * 50)

            if temp_x3 == 0:
                pettern += 1

            if temp_x3 <= 0:
                break

print(pettern)

Solution (Python):
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):
      sum = 500*i + 100*j + 50*k
      if sum==x:
        ans+=1
print(ans)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i_a in range(a + 1):
  for j_b in range(b + 1):
    for k_c in range(c + 1):
      sum = 500 * i_a + 100 * j_b + 50 * k_c
      if sum == x:
        ans += 1

print(ans)