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

if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    N = K - A - B
    print(A - N)

Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)

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

if K > A:
    N = K - A
    all_number = 1*A
    print(all_number)

    if N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    else:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)

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

if K > A:
    N = K - A //2
    all_number = 1*A //3

    if N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    else:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)


Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)

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

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N <= B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)


Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)

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

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        if N >= C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)

Buggy python submission (verdict: Runtime Error):
if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        if N >= C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)

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

all_number = 0

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        all_number = all_number - 1*N
        print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)