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):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
counter=0

for a in range(A+1):
    a_total=a*500
    for b in range(B+1):
        b_total=b*100
        for c in range(C+1):
            c_total=c*50
            total_amount=(a_total+b_total+c_total)
            if X==total_amount:
                counter=counter+1
print(counter)

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):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B, C, X = map(int, read().decode("utf-8").split())

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

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())
list = []
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            list.append(500*a + 100*b + 50*c)
print(list.count(X))

Solution (Python):
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    l = []
    cnt = 0

    for i in range(C+1):
        for j in range(B+1):
            for k in range(A+1):
                if 50*i + 100*j + 500*k == X:
                    if not [i, j, k] in l:
                        cnt += 1
    print(cnt)
main()

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

Solution (Python):
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()

def main():
    A=int(input())
    B=int(input())
    C=int(input())
    X=int(input())
    arr=np.add.outer(np.arange(0,100*B+1,100).T,np.arange(0,500*A+1,500))
    arr= X-arr
    print(arr[(arr>=0) & (arr<=50*C)].size)

if __name__ == '__main__':
    main()

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

Solution (Python):
A,B,C,X = (int(input()) for X in range(0,4))
Count = 0
for TA in range(0,A+1):
    for TB in range(0,B+1):
        for TC in range(0,C+1):
            if 500*TA+100*TB+50*TC==X:
                Count += 1
print(Count)

Solution (Python):
in_a = input()
in_b = input()
in_c = input()
in_x = input()

A = int(in_a)
B = int(in_b)
C = int(in_c)
X = int(in_x)

count = 0
for i in range(A+1):
    for j in range(B+1):
        k = ( X - 500*i - 100*j ) / 50
        
        if k < 0:
            break;
        elif k.is_integer() and k <= C:
            count +=1
            

print(count)

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

count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            sum_kozeni = i * 500 + j * 100 + k * 50  
            if sum_kozeni == total:
                count += 1
            elif sum_kozeni > total:
                break
print(count)

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

count=0

for k_a in range(A+1):
    for k_b in range(B+1):
        for k_c in range(C+1):
            if 500*k_a+100*k_b+50*k_c == X:
                count=count+1
print(count)

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 = 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())
p=0
for a in range(0,A+1):  
    for b in range(0,B+1):
        for c in range(0,C+1):
            sum=500*a+100*b+50*c
            if X==sum:
                p=p+1

print(p)

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

res = 0
for i in range(a+1):
    rem = x
    rem -= 500 * i
    tempA = rem
    if rem == 0:
        res += 1
        continue
    for j in range(b+1):
        rem = tempA
        rem -= 100 * j
        tempB = rem
        if rem == 0:
            res += 1
            continue
        for k in range(c+1):
            rem = tempB
            rem -= 50 * k
            if rem == 0:
                res += 1
                break

print(res)

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):
m500 = int(input())
m100 = int(input())
m50 = int(input())
X = int(input())

count = 0

for i in range(m500+1):
    for j in range(m100+1):
        for k in range(m50+1):
            if X == i*500+j*100+k*50:
                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, b, c, x = map(int,[input() for i in range(4)])

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

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

Solution (Python):
inputlist = [input() for i in range(4)]

n = 0

A,B,C= inputlist[0],inputlist[1],inputlist[2]

for i in range(int(A)+1):

    X = inputlist[3] 

    X = int(X) - i*500

    for j in range(int(B)+1):

        X = X - j*100

        for k in range(int(C)+1):
            
            X = X -k*50

            if X == 0:
                n += 1
            X= X + k*50

        X = X + j*100

    X = X + i*500

print(n)

Solution (Python):
A,B,C,X = [int(input()) for i in range(4)]
X_original = X
n = 0

for i in range(int(A)+1):
    X = X_original
    X500 = X - i*500
    for j in range(int(B)+1):
        X100 = X500 - j*100
        for k in range(int(C)+1):
            X50 = X100-k*50
            if X50== 0:
                n += 1

print(n)

Solution (Python):

L = int(input())  
M = int(input())  
S = int(input())  
N = int(input())
count = 0


def sum(l=0, m=0, s=0):
    return 500 * l + 100 * m + 50 * s


for l in range(L + 1):
    if N == sum(l):
        count += 1
        break
    else:
        for m in range(M + 1):
            if N == sum(l, m):
                count += 1
                break
            else:
                for s in range(S + 1):
                    if N == sum(l, m, s):
                        count += 1
                        break
print(count)

Solution (Python):
*coins, X = [int(input()) for _ in range(4)]

price = [500, 100, 50]
payable = []

for a in range(coins[0]+1):
    for b in range(coins[1]+1):
        for c in range(coins[2]+1):
            payable.append(a*price[0] + b*price[1] + c*price[2])
            
print(payable.count(X))

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

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 = count + 1

print (count)

Solution (Python):
na = int(input())
nb = int(input())
nc = int(input())
xx = int(input())
counter = 0
for aa in range(na+1):
    for bb in range(nb+1):
        residue = xx-500*aa-100*bb
        if residue >= 0 and residue / 50 <= nc:
            counter += 1
print(counter)

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

Solution (Python):
def solve():
    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__":
    solve()

Solution (Python):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for ai in range(A+1):
    for bi in range(B+1):
        for ci in range(C+1):
            temp=ai*500+bi*100+ci*50
            if temp==X:
                ans+=1
print(ans)

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
pos = {}
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            v = a*500 + b*100 + c*50
            pos.setdefault(v,0)
            pos[v] += 1
            if v > X:
                break
print(pos.setdefault(X,0))

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

a = min(x//500, a)+1
b = min(x//100, b)+1
c = min(x//50, c)

cnt = 0

for i in range(a):
  for j in range(b):
    now = x-500*i-100*j
    if now>=0 and now//50 <= c:
      cnt +=1

print(cnt)

Solution (Python):


A_init = 500
B_init = 100
C_init = 50

A_n = int(input())
B_n = int(input())
C_n = int(input())

X = int(input())

cnt = 0
for a in range(A_n+1):
    if A_init * a <= X:
        for b in range(B_n+1):
            if (A_init * a + B_init * b) <= X:
                K = X - (A_init * a + B_init * b)
                if K % 50 == 0 and K / C_init <= C_n:
                    cnt += 1
            else:
                break
    else:
        break

print(cnt)

Solution (Python):


A_init = 500
B_init = 100
C_init = 50

A_n = int(input())
B_n = int(input())
C_n = int(input())

X = int(input())

cnt = 0
for a in range(A_n+1):
    if A_init * a <= X:
        for b in range(B_n+1):
            if (A_init * a + B_init * b) <= X:
                for c in range(C_n+1):
                    if (A_init * a + B_init * b + C_init * c) == X: cnt += 1
            else:
                break
    else:
        break

print(cnt)

Solution (Python):
import numpy as np

A_init = 500
B_init = 100
C_init = 50

A_n = int(input())
B_n = int(input())
C_n = int(input())

X = int(input())

cnt = 0
for a in range(A_n+1):
    if A_init * a <= X:
        for b in range(B_n+1):
            if (A_init * a + B_init * b) <= X:
                for c in range(C_n+1):
                    if (A_init * a + B_init * b + C_init * c) == X: cnt += 1
            else:
                break
    else:
        break

print(cnt)

Solution (Python):
import numpy as np

A_init = 500
B_init = 100
C_init = 50

A_n = int(input())
B_n = int(input())
C_n = int(input())

X = int(input())

cnt = 0
for a in range(A_n+1):
    for b in range(B_n+1):
        for c in range(C_n+1):
            if (A_init * a + B_init * b + C_init * c) == X: cnt += 1

print(cnt)

Solution (Python):
List = []
for i in range (3):
  List.append(int(input()))
X=int(input())
res = 0
c = 0
for i in range(List[0]+1):
  for j in range(List[1]+1):
    c = int(X/50) - 10 * i - 2 * j
    if 0<= c <= List[2]:
      res+=1
print(res)

Solution (Python):
def main(n500, n100, n50, price):
    count = 0
    for i in range(n500 + 1):
        if i * 500 <= price:
            for j in range(n100 + 1):
                if i * 500 + j * 100 <= price:
                    for k in range(n50 + 1):
                        p = i * 500 + j * 100 + k * 50
                        if p == price:
                            count += 1
    print(count)


if __name__ == "__main__":
    n500 = int(input())
    n100 = int(input())
    n50 = int(input())
    price = int(input())
    main(n500, n100, n50, price)

Solution (Python):
def main(n500, n100, n50, price):
    count = 0
    for i in range(n500 + 1):
        for j in range(n100 + 1):
            for k in range(n50 + 1):
                p = i * 500 + j * 100 + k * 50
                if p == price:
                    count += 1
    print(count)


if __name__ == "__main__":
    n500 = int(input())
    n100 = int(input())
    n50 = int(input())
    price = int(input())
    main(n500, n100, n50, price)

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

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

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

Solution (Python):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
n = X // 500 + 1
count = 0
for i in range(n):
  if i <= A:
    m = (X-500*i)//100+1
    for j in range(m):
      if j <= B and (X-500*i - 100*j) % 50 == 0 and ((X-500*i - 100*j) / 50) <= C:
        if not (i==0 and j ==0 and ((X-500*i - 100*j) / 50)==0): 
          count += 1

print(count)

Solution (Python):

A,B,C,X = map(int, [input()for i in range(4)])
counter = 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:
               counter += 1

print(counter)

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

combination = []
for A in range(a+1):
  for B in range(b+1):
    for C in range(c+1):
      total = A*500 + B*100 + C*50
      combination.append(total)

count = combination.count(x)
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):
e = input()
f = input()
g = input()
h = input()

a = int(e)
b = int(f)
c = int(g)
x = int(h)

answer = 0

arrays = []
for i in range(125001):
    arrays.append(0)

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            arrays[500 * i + 100 * j + 50 * k] += 1

answer = arrays[x]
print(answer)

Solution (Python):
import math

a, b, c, x = [int(input()) for _ in range(4)]

ans = 0
a_min = max(0, math.ceil((x - 100 * b - 50 * c) / 500))
a_max = min(a, math.floor(x / 500))
for ai in range(a_min, a_max + 1):
    b_min = max(0, math.ceil((x - 500 * ai - 50 * c) / 100))
    b_max = min(b, math.floor((x - 500 * ai) / 100))
    ans += b_max - b_min + 1
print(ans)

Solution (Python):
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)]))

Solution (Python):
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)]))

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):
five_h = int(input())
one_h = int(input())
f_m = int(input())
s = int(input())

count = 0

for i in range(0, five_h + 1):
    a = 500 * i
    b = 0
    for j in range(0, one_h + 1):
        b = 100 * j
        d = 0
        c = a + b
        for k in range(0, f_m + 1):
            d = 50 * k
            e = c + d
            if e == s:
                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 i*500 + j*100 + k*50 == X:
                ans += 1

print(ans, flush=True)

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

print(count)

Solution (Python):
a_500 = int(input())
b_100 = int(input())
c_50 = int(input())
kadai = int(input())
sum_coin = 0
count = 0
sum_list = []

for n in range(a_500 + 1):
    for m in range(b_100 + 1):
        for l in range(c_50 + 1):
            sum_list.append((500*n) + (100*m) + (50*l))
print(sum_list.count(kadai))

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, B, C, X = map(int, open(0).read().split())
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)]))

Solution (Python):


A, B, C, X = map(int, open(0).read().split())
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)]))

Solution (Python):
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)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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=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())
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):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(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):
            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())

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

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

Solution (Python):
def resolve():
  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)
  return

if __name__ == "__main__":
  resolve()

Solution (Python):
import sys
from collections import defaultdict, deque, Counter
import math


from bisect import bisect_left, bisect_right
import heapq




input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():
    a =getN()
    b=getN()
    c=getN()
    x=getN()
    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)


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    
    solve()

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

Solution (Python):
c500 = int(input())
c100 = int(input())
c50 = int(input())
x = int(input())
count = 0
 
for c500_n in range(c500+1):
  for c100_n in range(c100+1):
    for c50_n in range(c50+1):
      if c500_n*500 + c100_n*100 + c50_n*50 == x:
        count += 1
 
print(count)

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

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):
            price = i * 500 + j * 100 + k * 50
            if price == 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
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
mod = 1000000007
inf = float("INF")
def I(): return int(input().rstrip())
def IR(n): return [I() for _ in range(n)]
def LI(): return list(map(int, input().rstrip().split()))
def LIR(n): return [LI() for _ in range(n)]
def LI_(): return list(map(lambda x: int(x) - 1, input().rstrip().split()))
def LIR_(n): return [LI_() for _ in range(n)]
def F(): return float(input().rstrip())
def FR(n): return [F() for _ in range(n)]
def LF(): return list(map(float, input().rstrip().split()))
def LFR(n): return [LI() for _ in range(n)]
def S(): return input().rstrip()
def SR(n): return [S() for _ in range(n)]
def LS(): return list(sys.stdin.readline().rstrip().split())
def LSR(n): return [LS() for _ in range(n)]


a, b, c, x = IR(4)
res = 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:
                res += 1
print(res)

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

Solution (Python):
ABC = [int(input()) for _ in range(3)]
X = int(input())

A,B,C = ABC[0],ABC[1],ABC[2]

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

Solution (Python):
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
print(ans)

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

count = 0
for ia in range(0, a + 1):
    for ib in range(0, b + 1):
        for ic in range(0, c + 1):
            if 500 * ia + 100 * ib + 50 * ic == 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):
coin_500 = int(input()) + 1
coin_100 = int(input()) + 1
coin_50 = int(input()) + 1
total = int(input())

cnt = 0

for i in range(coin_500):
    for j in range(coin_100):
        for k in range(coin_50):
            if 500 * i + 100 * j + 50 * k == total:
                cnt +=1
                
print(cnt)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
x = 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) :
            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 a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a * 10 + b * 2 + c == X // 50:
                cnt += 1
print(cnt)

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

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

print(num)

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

Solution (Python):
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)

Solution (Python):


A = int(input()) 
B = int(input()) 
C = int(input()) 
X = int(input()) 

ans = 0
tmp_x = 0

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

print(ans)

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


if __name__ == "__main__":
    resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    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)

if __name__ == "__main__":
    main()

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