Buggy python submission (verdict: Runtime Error):
import functools

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

if min(A, B, C, X) == X:
	print(0)

@functools.lru_cache
def num_patterns(A, B, C, X):
    if X == 0:
      	return 1

    if min(A, B, C, X) == X:
        return 0
    branch_A = num_patterns(A - 1, B    , C    , X - 500) if A > 0 else 0
    branch_B = num_patterns(A    , B - 1, C    , X - 100) if B > 0 else 0
    branch_C = num_patterns(A    , B    , C - 1, X - 50 ) if C > 0 else 0
    return branch_A + branch_B + branch_C

print(num_patterns(A, B, C, X))

Fixed submission:
import functools

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

if min(A, B, C, X) == X:
	print(0)

@functools.lru_cache(1000)
def num_patterns(A, B, C, X):
    if X == 0:
      	return 1

    if min(A, B, C, X) == X:
        return 0

    if A > 0:
        return sum(
            num_patterns(0, B, C, X - 500 * nA) if X >= 500 * nA else 0
            for nA in range(0, A + 1)
        )
    if B > 0:
        return sum(
            num_patterns(0, 0, C, X - 100 * nB) if X >= 100 * nB else 0
            for nB in range(0, B + 1)
        )
    if C > 0 and X % 50 == 0 and X / 50 <= C:
        return 1
    else:
        return 0

print(num_patterns(A, B, C, X))

Buggy python submission (verdict: Time Limit Exceeded):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

if min(A, B, C, X) == X:
	print(0)

def num_patterns(A, B, C, X):
    if X == 0:
      	return 1

    if min(A, B, C, X) == X:
        return 0
    branch_A = num_patterns(A - 1, B    , C    , X - 500) if A > 0 else 0
    branch_B = num_patterns(A    , B - 1, C    , X - 100) if B > 0 else 0
    branch_C = num_patterns(A    , B    , C - 1, X - 50 ) if C > 0 else 0
    return branch_A + branch_B + branch_C

print(num_patterns(A, B, C, X))

Fixed submission:
import functools

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

if min(A, B, C, X) == X:
	print(0)

@functools.lru_cache(1000)
def num_patterns(A, B, C, X):
    if X == 0:
      	return 1

    if min(A, B, C, X) == X:
        return 0

    if A > 0:
        return sum(
            num_patterns(0, B, C, X - 500 * nA) if X >= 500 * nA else 0
            for nA in range(0, A + 1)
        )
    if B > 0:
        return sum(
            num_patterns(0, 0, C, X - 100 * nB) if X >= 100 * nB else 0
            for nB in range(0, B + 1)
        )
    if C > 0 and X % 50 == 0 and X / 50 <= C:
        return 1
    else:
        return 0

print(num_patterns(A, B, C, X))

Buggy python submission (verdict: Runtime Error):
A = int(input)
B = int(input)
C = int(input)
X = int(input)

if min(A, B, C, X) == X:
	print(0)

def num_patterns(A, B, C, X):
    if X == 0:
      	return 1
	if min(A, B, C, X) == X:
    	return 0
    branch_A = num_patterns(A - 1, B    , C    , X - 500) if A > 0 else 0
    branch_B = num_patterns(A    , B - 1, C    , X - 100) if B > 0 else 0
    branch_C = num_patterns(A    , B    , C - 1, X - 50) if C > 0 else 0
    return branch_A + branch_B + branch_C

print(num_patterns(A, B, C, X))

Fixed submission:
import functools

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

if min(A, B, C, X) == X:
	print(0)

@functools.lru_cache(1000)
def num_patterns(A, B, C, X):
    if X == 0:
      	return 1

    if min(A, B, C, X) == X:
        return 0

    if A > 0:
        return sum(
            num_patterns(0, B, C, X - 500 * nA) if X >= 500 * nA else 0
            for nA in range(0, A + 1)
        )
    if B > 0:
        return sum(
            num_patterns(0, 0, C, X - 100 * nB) if X >= 100 * nB else 0
            for nB in range(0, B + 1)
        )
    if C > 0 and X % 50 == 0 and X / 50 <= C:
        return 1
    else:
        return 0

print(num_patterns(A, B, C, X))