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



Sample input:
2
2
2
100


Sample output:
2

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A, B, C, X = map(int,input().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)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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))==0:
                count+=1

print(count)

Submission status: Runtime Error

Solution code:
x500 = int(input())
x100 = int(input())
x50 = int(input())
xxx = int(input())

i = 0
j = 0
k = 0


def judge(sum, xxx):
    sum = 500 * i + 100 * j + 50 * k
    return sum == xxx and sum <= 2000


count = 0
for i in range(x500):
    if judge(i, j, k):
        count += 1
    for j in range(x100):
        if judge(i, j, k):
            count += 1
        for k in range(x50):
            if judge(i, j, k):
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
x500 = int(input())
x100 = int(input())
x50 = int(input())
xxx = int(input())

i = 0
j = 0
k = 0

count = 0
for i in range(x500):
    if total(i, j, k) == xxx:
        count += 1
    for j in range(x100):
        if total(i, j, k) == xxx:
            count += 1
        for k in range(x50):
            if total(i, j, k) == xxx:
                count += 1
print(count)


def total(i, j, k):
    return 500 * i + 100 * j + 50 * k

Submission status: Runtime Error

Solution code:
x500 = int(input())
x100 = int(input())
x50 = int(input())
xxx = int(input())

i = 0
j = 0
k = 0

count = 0
for i in range(x500):
    if total(i, j, k) == xxx:
        count += 1
    for j in range(x100):
        if total(i, j, k) == xxx:
            count += 1
        for k in range(x50):
            if total(i, j, k) == xxx:
                count += 1
print(count)


def total(i, j, k):
    return 500 * i + 100 * j + 50 * k

Submission status: Runtime Error

Solution code:
x500 = int(input())
x100 = int(input())
x50 = int(input())
xxx = int(input())

i = 0
j = 0
k = 0

count = 0
for i in x500:
    if total(i, j, k) == xxx:
        count += 1
    for j in x100:
        if total(i, j, k) == xxx:
            count += 1
        for k in x50:
            if total(i, j, k) == xxx:
                count += 1
print(count)


def total(i, j, k):
    return 500 * i + 100 * j + 50 * k

Submission status: Runtime Error

Solution code:
x500 = int(input())
x100 = int(input())
x50 = int(input())
xxx = int(input())

n500 = 0
n100 = 0
n50 = 0

count = 0
for i in x500:
    if total(i, j, k) == xxx:
        count += 1
    for j in x100:
        if total(i, j, k) == xxx:
            count += 1
        for k in x50:
            if total(i, j, k) == xxx:
                count += 1
print(count)


def total(i, j, k):
    return 500 * i + 100 * j + 50 * k

Submission status: Runtime Error

Solution code:
A=[]
for _ in range(3):
    A.append(int(input()))
a=A[0]
b=A[1]
c=A[2]
x=int(input())
count=0
for p in range(a):
    for q in range(b):
        for r in range(c):
            if 500*p+100*q+50*r==x:
                count=count+1
			else:
				count=count
print(count)

Submission status: Runtime Error

Solution code:
You went shopping to buy cakes and donuts with 
X
 yen (the currency of Japan).

First, you bought one cake for 
A
 yen at a cake shop. Then, you bought as many donuts as possible for 
B
 yen each, at a donut shop.

How much do you have left after shopping?

Constraints
1
≤
A
,
B
≤
1
 
000
A
+
B
≤
X
≤
10
 
000
X
, 
A
 and 
B
 are integers.

Submission status: Runtime Error

Solution code:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        A: usize,
        B: usize,
        C: usize,
        X: usize
    }

    let mut ans = 0;

    for a in 0..A+1 {
        for b in 0..B+1 {
            let cnt = (0..C+1).filter(|&c| 500*a + 100*b + 50*c == X).count();
            ans += cnt;
        }
    }

    println!("{}", ans);
}

Submission status: Runtime Error

Solution code:
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):
            amount = 500 * ai + 100 * bi + 50 * ci
            if amount == x:
                ans += 1
 // Input
print(ans)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
 result= 0
 
for xx in range(a+1):
    A = 500*xx
    for y in range(b+1) :
        B = 100*y
        for z in range(c+1):
            C = 50*z
            if x == A+B+C:
                result += 1
            else:
                continue
 
 
print(result)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
 result= 0
 
for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            amount = 500 * ai + 100 * bi + 50 * ci
            if amount == x:
                result += 1
 
print(result)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
result = 0             //initialized to zero
 
for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            amount = 500 * ai + 100 * bi + 50 * ci        //formula
            if amount == x:
                result += 1
 
print(result)        //output

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
ans = 0
 
for xx in range(a+1):
    A = 500*xx
    for y in range(b+1):
        B = 100*y
        for z in range(c+1):
            C = 50*z
            if x == A+B+C:
                ans += 01
            else:
                continue
 
 
print(ans)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
ans = 00
 for xx in range(a+1):
    A = 500*xx
    for y in range(b+1):
        B = 100*y
        for z in range(c+1):
            C = 50*z
            if x == A+B+C:
                ans += 1
            else:
                continue
 
print(ans)

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0

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

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
C=int(input())
x=int(input())
s=0
for i in range(A+1):
  if x<=0: break
  else:
    for t in range(B+1):
    if x<=0: break
    elif 50*C>=x:
      s+=1
      x-=100
    else: x-=100
  x-=500
print(s)

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
C=int(input())
x=int(input())
s=0
for i in range(A+1):
  if x==0: break
  else:
    for t in range(B+1):
    if x==0: break
    elif 50*C>=x:
      s+=1
      x-=100
    else: x-=100
  x-=500
print(s)

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
C=int(input())
x=int(input())
s=0
for i in range(A+1):
  if x=0: break
  else:
    for t in range(B+1):
    if x=0: break
    elif 50*C>=x:
      s+=1
      x-=100
    else: x-=100
  x-=500
print(s)

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
C=int(input())
x=int(input())
s=0
for i in range(A+1):
  if x=0: break
  else:
    for t in range(B+1):
    if x=0: break
    else 50*C>=x:
      s+=1
      x-=100
  x-=500
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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)))

Submission status: Runtime Error

Solution code:
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 + j * 100 + k * 50 == X:
                count += 1

print(count) 2

Submission status: Runtime Error

Solution code:
fh, oh, ft, su = int(input().split().rstrip())
int

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,c,x = map(int,input().split())
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)

Submission status: Runtime Error

Solution code:
a,b,c,x = map(int,input().split())
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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
a,b,c,x = map(int,input().split())
count = 0

for a in range(a+1):
    for b in range(b+1):
        for c in range(c+1):
            count += 1

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a=input()
b=input()
c=input()
x=input()
total = 0
cnt = 0

for i in a+1:
  for i in b+1:
    for i in c+1:
      total = 500*a+100*b+50*c
      if total=x:
        cnt +=1
        
        
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = input()
b = input()
c = input()
x = input()


counter = 0
for aa in range(0,int(a)+1):
    for bb in range(0,int(b)+1):
        for cc in range(0, int(c)+1):
            sumx = 500 * aa + 100 * bb + 50 * cc
            if int(x) == sumx and int(x) % 50 == 0 and 50 <= int(x) <= 20000:
                counter += 1
                print(f'{aa},{bb},{cc}')
print(counter)

Submission status: Runtime Error

Solution code:
a = input()
b = input()
c = input()
x = input()


counter = 0
for aa in range(0,int(a)+1):
    for bb in range(0,int(b)+1):
        for cc in range(0, int(c)+1):
            sumx = 500 * aa + 100 * bb + 50 * cc
            if x == sumx:
                counter += 1
                print(f'{aa},{bb},{cc}')
print(counter)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A, B, C, X = [int(input()) for i in range(4)]

print(sum(500*a + 100*b + 50*c == X) for a in A for b in B for c in C)

Submission status: Runtime Error

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

cnt = 0

for h in range(0,c):
  for i in range(0,b):
    for j in range(0,a):
      if (x == (500 * j + 100 * i + 50 * h))
      	cnt = cnt +1

  print(cnt)

Submission status: Runtime Error

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

cnt = 0

for h in range(0,c):
  for i in range(0,b):
    for j in range(0,a):
      if (x == (500 * a + 100 * b + 50 * c))
      	cnt = cnt +1

  print(cnt)

Submission status: Runtime Error

Solution code:
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())
 
counter = 0
for i in range(numof500 + 1):
  for j in range(numof100 + 1):
  	for k in range(numof50 + 1):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1
 
print(counter)

Submission status: Runtime Error

Solution code:
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())

counter = 0
for i in range(numof500):
  for j in range(numof100):
  	for k in range(numof50):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1

print(counter)

Submission status: Runtime Error

Solution code:
a, b, c, x = map(int, [input().split() 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 500*i+100*j+50*k == x:
                count+=1
print(count)

Submission status: Runtime Error

Solution code:
total=0
count=0

for l in range(A+1):
    for m in range(B+1):
        for n in range(C+1):
            total=500*l + 100*m + 50*n
            print(total)
            if(total==X): count += 1
                
print(count)

Submission status: Runtime Error

Solution code:
l = [int(input()) for i in range(4)]
count = 0
for num1 in range(l[1]):
  for num2 in range(l[2]):
    for num3 in range(l[3]):
      if l[4] == num1*500+num2*100+num3*50:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
A, B, C, X = [list(map(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)))

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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):
        nc = (500 * i + 100 * j) // 50
        if nc < 0 || c < nc:
            continue
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
if A>50 or B>50 or C>50 or X<50 or X>20000 or X % 50 != 0:
    print('error')
else:
    x = X // 50
    #print(x)
    y = 0
    xA = x // 10
    xB = (x - xA * 10) //2
    xC = x - xA * 10 - xB * 2
    #print(str(xA)+', '+str(xB)+', '+str(xC))
    if xA <= A:
        while xA >= 0: #and xB <= B:
            #print(str(xA)+', '+str(xB)+', '+str(xC))
            if xB <= B:
                yB = xB
                yC = xC
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
            else:
                yB = B
                yC = x - xA * 10 - yB * 2
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
                
 
    else:
        xA = A
        xB = (x - xA * 10)//2
        if xB <= B:
            y = 0
            while xA >= 0: #and xB <= B:
                print(str(xA)+', '+str(xB)+', '+str(xC))
                if xB <= B:
                    yB = xB
                    yC = xC
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
                else:
                    yB = B
                    yC = x - xA * 10 - xB * 2
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
        else:
            xB = B
            xC = (x - xA * 10 - xB * 2)
            y = 0
            while xA >= 0 and xB <= B:
                #print(str(xA)+', '+str(xB)+', '+str(xC))
                yB = xB
                yC = x - xA * 10 - yB * 2
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
                    
print(y)    
#例題4
A = int(input())
B = int(input())
C = int(input())
X = int(input())
if A>50 or B>50 or C>50 or X<50 or X>20000 or X % 50 != 0:
    print('error')
else:
    x = X // 50
    #print(x)
    y = 0
    xA = x // 10
    xB = (x - xA * 10) //2
    xC = x - xA * 10 - xB * 2
    #print(str(xA)+', '+str(xB)+', '+str(xC))
    if xA <= A:
        while xA >= 0: #and xB <= B:
            #print(str(xA)+', '+str(xB)+', '+str(xC))
            if xB <= B:
                yB = xB
                yC = xC
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
            else:
                yB = B
                yC = x - xA * 10 - yB * 2
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
                

    else:
        xA = A
        xB = (x - xA * 10)//2
        if xB <= B:
            y = 0
            while xA >= 0: #and xB <= B:
                print(str(xA)+', '+str(xB)+', '+str(xC))
                if xB <= B:
                    yB = xB
                    yC = xC
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
                else:
                    yB = B
                    yC = x - xA * 10 - xB * 2
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
        else:
            xB = B
            xC = (x - xA * 10 - xB * 2)
            y = 0
            while xA >= 0 and xB <= B:
                #print(str(xA)+', '+str(xB)+', '+str(xC))
                yB = xB
                yC = x - xA * 10 - yB * 2
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
                    
print(y)

Submission status: Runtime Error

Solution code:
#例題4
A = int(input())
B = int(input())
C = int(input())
X = int(input())

if A>50 or B>50 or C>50 or X<50 or X>20000 or X % 50 != 0:
    pass
else:
    x = X // 50
    #print(x)
    y = 0
    xA = x // 10
    xB = (x - xA * 10) //2
    xC = x - xA * 10 - xB * 2
    #print(str(xA)+', '+str(xB)+', '+str(xC))
    if xA <= A:
        while xA >= 0: #and xB <= B:
            #print(str(xA)+', '+str(xB)+', '+str(xC))
            if xB <= B:
                yB = xB
                yC = xC
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
            else:
                yB = B
                yC = x - xA * 10 - yB * 2
                if yC <= C:
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
                

    else:
        xA = A
        xB = (x - xA * 10)//2
        if xB <= B:
            y = 0
            while xA >= 0: #and xB <= B:
                #print(str(xA)+', '+str(xB)+', '+str(xC))
                if xB <= B:
                    yB = xB
                    yC = xC
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
                else:
                    yB = B
                    yC = x - xA * 10 - yB * 2
                    if yC <= C:
                        while yB >= 0 and yC <= C:
                            #print(str(yB)+', '+str(yC))
                            yB = yB - 1
                            yC = yC + 2
                            y = y + 1
                        xA = xA -1
                        xB = xB + 5
        else:
            xB = B
            xC = (x - xA * 10 - yB * 2)
            y = 0
            while xA >= 0 and xB <= B:
                #print(str(xA)+', '+str(xB)+', '+str(xC))
                yB = xB
                yC = x - xA * 10 - yB * 2
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
                    
print(y)

Submission status: Runtime Error

Solution code:
#例題4
A = int(input())
B = int(input())
C = int(input())
X = int(input())
if A>50 or B>50 or C>50 or X<50 or X>20000 or X % 50 != 0:
    pass
else:
    x = X // 50
    #print(x)
    y = 0
    xA = x // 10
    xB = (x - xA * 10) //2
    xC = x - xA * 10 - xB * 2
    #print(str(xA)+', '+str(xB)+', '+str(xC))
    if xA <= A:
        while xA >= 0: #and xB <= B:
            #print(str(xA)+', '+str(xB)+', '+str(xC))
            if xB <= B:
                yB = xB
                yC = xC
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
            else:
                yB = B
                yC = x - xA * 10 - yB * 2
                if yC <= C:
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
                
 
    else:
        xA = A
        xB = (x - xA * 10)//2
        if xB <= B:
            y = 0
            while xA >= 0: #and xB <= B:
                print(str(xA)+', '+str(xB)+', '+str(xC))
                if xB <= B:
                    yB = xB
                    yC = xC
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
                else:
                    yB = B
                    yC = x - xA * 10 - xB * 2
                    if yC <= C:
                        while yB >= 0 and yC <= C:
                            #print(str(yB)+', '+str(yC))
                            yB = yB - 1
                            yC = yC + 2
                            y = y + 1
                        xA = xA -1
                        xB = xB + 5
        else:
            xB = B
            xC = (x - xA * 10 - yB * 2)
            y = 0
            while xA >= 0 and xB <= B:
                #print(str(xA)+', '+str(xB)+', '+str(xC))
                yB = xB
                yC = x - xA * 10 - yB * 2
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
                    
print(y)    
#例題4
A = int(input())
B = int(input())
C = int(input())
X = int(input())
if A>50 or B>50 or C>50 or X<50 or X>20000 or X % 50 != 0:
    pass
else:
    x = X // 50
    #print(x)
    y = 0
    xA = x // 10
    xB = (x - xA * 10) //2
    xC = x - xA * 10 - xB * 2
    #print(str(xA)+', '+str(xB)+', '+str(xC))
    if xA <= A:
        while xA >= 0: #and xB <= B:
            #print(str(xA)+', '+str(xB)+', '+str(xC))
            if xB <= B:
                yB = xB
                yC = xC
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
            else:
                yB = B
                yC = x - xA * 10 - yB * 2
                if yC <= C:
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
                

    else:
        xA = A
        xB = (x - xA * 10)//2
        if xB <= B:
            y = 0
            while xA >= 0: #and xB <= B:
                print(str(xA)+', '+str(xB)+', '+str(xC))
                if xB <= B:
                    yB = xB
                    yC = xC
                    while yB >= 0 and yC <= C:
                        #print(str(yB)+', '+str(yC))
                        yB = yB - 1
                        yC = yC + 2
                        y = y + 1
                    xA = xA -1
                    xB = xB + 5
                else:
                    yB = B
                    yC = x - xA * 10 - yB * 2
                    if yC <= C:
                        while yB >= 0 and yC <= C:
                            #print(str(yB)+', '+str(yC))
                            yB = yB - 1
                            yC = yC + 2
                            y = y + 1
                        xA = xA -1
                        xB = xB + 5
        else:
            xB = B
            xC = (x - xA * 10 - yB * 2)
            y = 0
            while xA >= 0 and xB <= B:
                #print(str(xA)+', '+str(xB)+', '+str(xC))
                yB = xB
                yC = x - xA * 10 - yB * 2
                while yB >= 0 and yC <= C:
                    #print(str(yB)+', '+str(yC))
                    yB = yB - 1
                    yC = yC + 2
                    y = y + 1
                xA = xA -1
                xB = xB + 5
                    
print(y)