Problem:


Score : 200 points

Problem Statement

We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.

We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Constraints

All values in input are integers.

0 \leq A, B, C

1 \leq K \leq A + B + C \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

A B C K

Output

Print the maximum possible sum of the numbers written on the cards chosen.

Sample Input 1

2 1 1 3

Sample Output 1

2

Consider picking up two cards with 1s and one card with a 0.
In this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.

Sample Input 2

1 2 3 4

Sample Output 2

0

Sample Input 3

2000000000 0 0 2000000000

Sample Output 3

2000000000



Sample input:
2 1 1 3


Sample output:
2

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())

if a >= k:
    print(a)
    exit()
if b >= k-a:
    print(a)
    exit()
if k-a-b <= 0:
    print(a)
    exit()

print(a-(k-a-b))

Submission status: Wrong Answer

Solution code:
S = list(map(int,input().split()))

if S[0] + S[1] + S[2] >= 2 * 10 ** 9:
    print('Error')
elif S[0] >= S[3]:
    print(S[3])
elif S[3] > S[0] and S[3] <= S[0] + S[1]:
    print(S[0])
elif S[3] > S[0] + S[1] and S[3] <= S[0] + S[1] + S[2]:
    print(-1 * (S[3] - S[0] - S[1]) + S[0])
else:
    print('Error')

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int,input().split())
if (A+B)>=K and A<=K:
    print(A)
elif (A+B)>=K and A>=K:
    print(K)
elif (A+B)<K:
    print(max(A-(K-A-B),0))

Submission status: Wrong Answer

Solution code:
a,b,c,k = list(map(int,input().split()))
sum1 = 0
while(k>0):
    if(k>=a and a!=0):
        k = k-a
        a = 0
        sum1+=a
    elif(k<a):
        a = a - k
        sum1 = k
    elif(k>=b and b!=0):
        b=0
        k = k-b
    elif(k<b):
        b = b - k
        sum1=k
    elif(k>=c and c!=0):
        k = k-c
        sum1 = sum1 - c
        c=0
    elif(k<c):
        c  = c-k
        sum1 = k
print(sum1)

Submission status: Wrong Answer

Solution code:
a,b,c,k =list(map(int, input().split()))

if (a>=k):
  s=a
else:
  if ((a+b)>=k):
    s=a
  else:
    s=a-(k-a-b)
  
print(s)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
S = max(A, K) - max(0, K-A-B)
print(S)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map( int, input().split() )

if k <= a:
    print( k )

elif k > a:
    if b == 0:
        nc = k - a
        print( a - nc )
    elif b != 0:
        nb = k - a
        if nb <= b:
            print( a )
        elif nb > b:
            nc = nb - c
            print( a - nc )

Submission status: Wrong Answer

Solution code:
S = list(map(int,input().split()))

if S[0] + S[1] + S[2] >= 2 * 10 ** 9:
    print('Error')
elif S[0] >= S[3]:
    print(S[3])
elif S[3] > S[0] and S[3] < S[0] + S[1]:
    print(S[0])
elif S[3] > S[0] + S[1] and S[3] <= S[0] + S[1] + S[2]:
    print(-1 * (S[3] - S[0] - S[1]) + S[0])
else:
    print('Error')

Submission status: Wrong Answer

Solution code:
a, b, c, k = map( int, input().split() )

if k <= a:
    print( a )

elif k > a:
    if b == 0:
        nc = k - a
        print( a - nc )
    elif b != 0:
        nb = k - a
        if nb <= b:
            print( a )
        elif nb > b:
            nc = nb - c
            print( a - nc )

Submission status: Wrong Answer

Solution code:
S = list(map(int,input().split()))

if S[0] + S[1] + S[2] >= 2 * 10 ** 9:
    print('Error')
elif S[0] >= S[3]:
    print(S[3])
elif S[3] > S[0] and S[3] < S[0] + S[1]:
    print(S[0])
elif S[3] > S[0] + S[1] and S[3] <= S[0] + S[1] + S[2]:
    print(-1 * (S[3] - S[0] - S[1]) + S[0])
else:
    print('Error')

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int,input().split())
if (A+B)>=K and A<=K:
    print(A)
elif (A+B)>=K and A>=K:
    print(K)
elif (A+B)<K:
    t=A-(K-A-B)
    if t<=0:
        print("0")
    else:
        print(t)

Submission status: Wrong Answer

Solution code:
a,b,c,d =list(map(int, input().split()))
if (a>=d):
  s=a
elif ((a+b)>=d):
  s=a
else:
  s=a-(d-a-b)
  
print(s)

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, k = map( int, input().split() )

    if a != 0:
        if k >= 1 and k <= a:
            print( a )
        elif k > a and k <= a+b:
            print( a )
        elif k > a+b and k <= a+b+c:
            nc = k - ( a + b )
            ans = a - nc
            print( ans  )
    elif a == 0:
        nc = k - b
        print( -nc )

main()

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
max_val = -1*C
cnt = 1
out = 0
while K > cnt:
    if A < cnt:
        break
    out += 1
    cnt += 1

while K > cnt:
    if B < cnt - A:
        break
    cnt += 1

while K > cnt:
    cnt += 1
    out -= 1

print(out)

Submission status: Wrong Answer

Solution code:
def solve():
    a, b, c, k = map(int,input().split())
    if k > a + b:
        ans = a - (k - a - b)
        print(ans)
    else:
        print(a)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, k = map( int, input().split() )

    if k >= 1 and k <= a:
        print( a )
    elif k > a and k <= a+b:
        print( a )
    elif k > a+b and k <= a+b+c:
        nc = k - ( a + b )
        ans = a - nc
        print( ans  )

main()

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
if a >= k:
	print(k)
elif a+b >=k:
	print(a)
else:
    print(a*1+(k-a+b)*(-1))

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
if a >= k:
	print(k)
elif a+b >=k:
	print(k)
else:
    print(a*1+b*0 +(k-a-b)*(-1))

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
if a >= k:
    print(a)
elif a < k and b >= k-a:
    print(a)
else:
    print(a-(k-a-b))

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
if a+b >= k:
    print(a*1+b*0)
else:
    print(a*1+b*0 +(k-a-b)*(-1))

Submission status: Wrong Answer

Solution code:
A,B,C,K=list(map(int,input().split()))
if (A+B)>=K:
    print(A)
elif A>=K:
    print(K)
else:
    t=A-(K-A-B)
    if t<=0:
        print("0")
    else:
        print(t)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
if a >= k:
    print(a)
else:
    k = k -a
    if b >= k:
        print(a)
    else:
        k = k-b
        print(a-k)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
if a >= k:
    print(a)
else:
    k = k -a
    if b >= k:
        print(a)
    else:
        k -= b
        print(a-k)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
if a >= k:
    print(a)
else:
    if b >= k-a:
        print(a)
    else:
        print(a-(k-a-b))

Submission status: Wrong Answer

Solution code:
[A, B, C, K] = list(map(int, input().split()))
if K <= A:
  print(K)
if A< K <= A + B:
  print(A)
else:
  print(2 * A - K + B)

Submission status: Wrong Answer

Solution code:
[A, B, C, K] = list(map(int, input().split()))
if K <= A:
  print(K)
if A< K <= A + B:
  print(A)
else:
  print(A - C)

Submission status: Wrong Answer

Solution code:
[A, B, C, K] = list(map(int, input().split()))
if K <= A + B:
  print(A)
else:
  print(A - C)

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int,input().split())
if (A>=K):
  print(K)
else:
  D = K-A
  if (B>=D):
    print(A)
  else:
    print(A-D)

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int,input().split())
if (A>=K):
  print(K)
else:
  D = K-A
  if (B>=D):
    print(D)
  else:
    print(A-D)

Submission status: Wrong Answer

Solution code:
A=1
B=2
C=3
K=4
maxi=2*A-K+B
print(maxi)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())

ans = 0
if k > a:
    ans = ans + a
    k = k - a
else:
    ans = ans + k
    k = 0
if k > b:
    k = k - b
else:
    k = 0
if k > c:
    ans = ans - c
else:
    ans = ans - k
print(ans)

print(ans)

Submission status: Wrong Answer

Solution code:
a=input().split()
b=[int(i) for i in a]
if b[0]==0 and b[1]>=b[3]:
    print(0)
elif b[0]>=b[3]:
    print(b[3])
elif (b[0]+b[1])>=b[3]:
    print(b[0])
else:
    print(-(b[3]-b[1]))

Submission status: Wrong Answer

Solution code:
A,B,C,K=list(map(int,input().split()))
if (A+B)>=K and A<=K:
    print(A)
elif (A+B)>=K and A>=K:
    print(K)
elif (A+B)<K:
    t=A-(K-A-B)
    if t<=0:
        print("0")
    else:
        print(t)

Submission status: Wrong Answer

Solution code:
A, B, C, K = list(map(int, input().split()))

if A + B >= K:
    print(A)
else:
    print(A - (K - A - B))

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())

a = min(A, K)
K -= a
b = min(a, K)
K -= b
c = K

print(a-c)

Submission status: Wrong Answer

Solution code:
a,b,c,k =map(int,input().split())

if a>=k or (a+b) >=k:    
    print(k)
    
else:
    print(-(k-a)+a)

Submission status: Wrong Answer

Solution code:
a,b,c,k =map(int,input().split())

if a>=k or (a+b) >=k:    
    print(a)
    
else:
    print(-(k-a)+a)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
ans=a 
ans-=(k-b-a)
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())  #数字

if A + B >= K:
    print(K)
    exit()
else:
    print(A - (1 * (K - (A + B))))

Submission status: Wrong Answer

Solution code:
a,b,c,k =map(int,input().split())

if a>=k or a+b <=k:    
    print(a)
    
else:
    print(-k+a+b)

Submission status: Wrong Answer

Solution code:
A,B,C,K=list(map(int,input().split()))
if (A+B)>=K:
    print(A)
elif (A+B)<K:
    t=A-(K-A-B)
    if t<=0:
        print("0")
    else:
        print(t)

Submission status: Wrong Answer

Solution code:
card    = list(map(int, input().split()))
answer = card[0]
card[3] -= answer

if card[3] <= 0:
    print(answer)
else:
    card[3] -= card[1]
    
    if card[3] <= 0:
        print(answer)
    else:
        answer -= card[2]
        print(answer)

Submission status: Wrong Answer

Solution code:
a,b,c,k =map(int,input().split())

z=0

if a !=0 and k >0 :
    z +=1*k
    k -=a

if b!= 0 and k>0 :
    k-=b

if k>0 and c !=0 :

    z = z -k
    
print(z)

Submission status: Wrong Answer

Solution code:

a,b,c,k =map(int,input().split())

z=0

if a !=0 and k >0 and a >= k:
    z +=1*k
    k -=a

if b!= 0 and k>0 and b >= k:
    k-=b

if k>0 and c !=0 and c >= k:

    z = z -k
    
print(z)

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int,input().split())
if A>=K:
  print(K)
elif (A+B)>=K:
  print(A)
else:
  print(A-(K-A))

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
a, b, c, k = [int(x) for x in input().split()]

d = k - a

if k <= a:
    print(a)
elif b >= d:
    print(a)
else:
    print(a + (d - b))

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())

if a >= k:
    print(a)
    exit()
else:
    if b >= k-a:
        print(a)
        exit()
    else:
        if c >= k-a-b:
            print(a-(k-a-b))
            exit()
        else:
            print(a-c)
            exit()

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())

if k <= a:
    print(k)
if a + b >= k:
    print(a)
else:
    sumcheck = k - a - b
    print(a - sumcheck)

Submission status: Wrong Answer

Solution code:
from sys import stdin
A,B,C,K=list(map(int,(stdin.readline().strip().split())))
x=K-A
if x<=0:
    print(A)
else:
    y=x-B
    if y<=0:
        print(A)
    else:
        print(A+(K-(A+B))*(-1))

Submission status: Wrong Answer

Solution code:
a=input().split()
b=[int(i) for i in a]
if b[0]==0 and b[1]>=b[3]:
    print(0)
elif b[0]>=b[3]:
    print(b[3])
elif (b[0]+b[1])>=b[3]:
    print(b[0])
else:
    print(b[0]-(b[3]-b[0]+b[1]))

Submission status: Wrong Answer

Solution code:
from sys import stdin
A,B,C,K=list(map(int,(stdin.readline().strip().split())))
x=K-A
if x<=0:
    print(A)
else:
    y=x-B
    if y<=0:
        print(A)
    else:
        print(A-(K-(A+B)))

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
cnt = k
if a >= cnt:
    print(a)
else:
    cnt = k - a
    if b >= cnt:
        print(a)
    else:
        cnt -= b
        if c >= cnt:
            print(a - cnt)
        else:
            print(a - c)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
print(min(A,K) + min(B,int(bool(K-A-B>0)))*-1)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())

if a + b >= k:
    print(a)
else:
    sumcheck = k - a - b
    print(a - sumcheck)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map( int, input().split() )

if k >= 1 and k <= a:
    print( a )
elif k > a and k <= a+b:
    print( a )
elif k > a+b and k <= a+b+c:
    nc = k - ( a + b )
    ans = a - nc
    print( ans  )

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int, input().split())

res = 0
if k < a:
     res = a
elif k < a+b:
     res = a
else:
     res = a-(k-b-a)

print(res)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
ans = 0
if k <= a+b:
  ans = a
else:
  ans = a-(k-a-b)
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
A,B,C,K=list(map(int,(stdin.readline().strip().split())))
if A+B>=K:print(A)
else:print(A+(K-(A+B)*(-1)))

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
if A > K:
    print(1 * A)
else:
    print(1 * A + -1 * (K - (A + B)))

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
count = 0
result = 0
for i in range(A):
    result = result + 1
    count = count + 1
    if count == K:
        break

if count < K:
    for j in range(A):
        count = count + 1
        if count == K:
            break

if count < K:
    for k in range(A):
        result = result - 1
        count = count + 1
        if count == K:
            break

print(result)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())

if a + b >= k:
    print(a)
else:
    sumcheck = a + b - k
    print(a - sumcheck)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
if A >= K:
    print(1 * A)
else:
    print(1 * A + -1 * (K - (A + B)))

Submission status: Wrong Answer

Solution code:
#B
A,B,C,K = map(int,input().split())

if A+B >= K:
    print(A)
else:
    print(A-(K-(A+B)))

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int,input().split())
if A + B >= K:
    print(A)
elif A + B < K:
    print((2*A) + B - K)

Submission status: Wrong Answer

Solution code:
X, Y, Z, K = map(int, input().split())
if X >= K:
    print(X)
elif X+Y >= K:
    print(X)
elif X+Y+Z >= K:
    print(X-(K-X-Y))

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
if A >= K:
    print(1 * A)
else:
    print(1 * A + -1 * (K - A - B))

Submission status: Wrong Answer

Solution code:
import math

l = list(map(int,input().split()))
a= l[0]
b= l[1]
c=l[2]
k = l[3]
s=0
while k >0:
    if a != 0 :
        s+=a
        k-=a
        a=0
    elif b!=0:
        k-=b
        b=0
    else:
        s-=k
        k=0
print(s)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
    
if(k-a<=0):
    print(1*a)
elif(k-a-b<=0):
    print(1*a - 0*b)
else :
    print(1*a+0*b-1*(k-a-b))

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())

s=-1*K*C

lc=[]
lc_=[]
for i in range(min(K,A+1)):
  for j in range(min(K-i+1,B+1)):
    lc.append([i,j,K-i-j])

#print(lc)

for i in range(len(lc)):
  if lc[i][0]<=A and lc[i][1]<=B and lc[i][2]<=C:
    # print(lc[i])
    s=max(s, lc[i][0]-lc[i][2])

print(s)

Submission status: Wrong Answer

Solution code:
#B
A,B,C,K = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())

countC = k - (a + b)
ans = (a * 1) - (countC * 1)

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
z=k-a
if z>0:
    z=z-b
print(a+z*-1)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())

if a + b >= k:
    print(a)
else:
    sumcheck = a + b - k
    print(a + sumcheck)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
s=0
sss=a+b+c
ss=a+b
for i in range(1,k+1):
    if i <= sss-b-c:
        s+=a
        break
    elif i<=a+b:
        s+=0
        break
    else:
        s=c*-1
        break

print(s)

Submission status: Wrong Answer

Solution code:
a = input().split()

pura = int(a[0])     #1
zero = int(a[1])     #0
mai  = int(a[2])     #-1
num  = int(a[3])     #枚数
total = 0
k = num-pura-zero

if pura <= num:
    total = pura
if zero <= num - pura:
    total = total
else:
    print(pura)
if k > 0:
    total = pura-(k)
print(total)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())

Cn = 0
if K - A > 0:
    if K - A == B:
        Cn == 0
    else:
        Cn = K - A - B
else:
    Cn = 0
ans = A - Cn
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
A, B, C, K = map(int, input().split())

import itertools

if K<=A:
    print(A)
elif B>K-A:
    print(A)
else:
    print(A+(-1)*(K-A-B))

Submission status: Wrong Answer

Solution code:
#B
i = input()
a = int(i.split()[0])
b = int(i.split()[1])
c = int(i.split()[2])
k = int(i.split()[3])

count = 0

if k <= a+b:
    count = a
elif a+b < k:
    count = (a)-(k-(a+b))
print(count)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
    
if(k-a-b>0):
     print(1*a+0*b-1*(k-a-b))
else :
    print(1*a+0*(k-a))

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
sum = 0

if K >= A:
	sum = sum + A
else:
	sum = sum + K
K = K - A

K = K - B

if K >= C and K >= 1:
	sum = sum - C
else:
	sum = sum - K

if sum >= 1:
	print(sum)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
A,B,C,K = input().split()
a = int(A)
b = int(B)
k = int(K)

if a >= k:
    Answer = a
    print(Answer)
else:
    if a+b >= k:
        Answer = a
        print(Answer)
    else:
        Answer = a - (k-(a+b))
        print(Answer)

Submission status: Wrong Answer

Solution code:
A,B,C,K =map(int,input().split())

if A >= K:
    print(A)
    

elif A + B >= K:
    print(A)

elif A + B < K:
    c = -1 * (K-(A+B))
    #print(c)
    #print(A)
    cc = A + c
    print(cc)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int, input().split())

res = 0
if k < a:
     res = a
elif k < a+b:
     res = a
else:
     res = a-(k-b-c)

print(res)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int, input().split())
ans=0

if A == 0:
    print(-C)
    exit()
elif C == 0:
    K = K-B
    ans = -(C-K)
    print(ans)
    exit()
elif B == 0:
    K = K-A
    C = C-K
    ans = A-C
    print(ans)
    exit()

cnt = 0

if A+B >= K:
    if A<=K:
        print(A)
        exit()
    print(K-A)
    exit()
else:
    K = K-(A+B)
    ans = A
    ans = ans-K
    print(ans)
    exit()

Submission status: Wrong Answer

Solution code:
def main():
  a, b, c, k = map(int, input().split())
  d = k-a-b
  
  if d<=0:
    print(a)
  elif d>0:
    hui = d*(-1)
    print(a+hui)
    
main()

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int, input().split())
d=0
if A>0:
    if K-A-B<0:
        d=A-(K-A)
    if K-A-B>=0:
        d=A-(K-A-B)
if A==0:
    if K-B>0:   
        d=-1*(K-B)
    else:
        d=0
print(d)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
result = 0
K = K - A
result = result + A
for i in range (K) :
    if B > 0 :
        B = B - 1
    elif C > 0 :
        result = result -1
        C = C -1
print(result)

Submission status: Wrong Answer

Solution code:
A, B, C, K = input().split()
# A=1 B=0 C=-1 K
ans = 0

for a in range(int(K)):
    if int(A) == int(K):
        ans = A
        break
    elif int(A) <= int(K):
        ans = A

    elif int(B) <= int(K):
        ans = A

    elif int(C) <= int(K):
        ans = (-1 * C)
        break
if int(A) == int(K):
    print(K)
else:
    print(int(A) + int(B) - int(C))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    def main():
        a, b, c, k = map(int, input().split())
        lis = []
        if k >= a:
            lis.append(a)
        elif k >= a+b+c:
            lis.append(-1*(c-b-a))
        print(sum(lis))
main()

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())

Cn = 0
if K - A > 0:
    if K - A == B:
        Cn == 0
    else:
        Cn = K - A - B
elif K - A == 0:
    Cn = 0
ans = A - Cn
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, k = input().split()
a, b, c, k = int(a), int(b), int(c), int(k)

while True:
    if a >= k:
        print(a)
        break
    else:
        if b >= k-a:
            print(a)
            break
        else:
            if c >= k-a-b:
                print(a-(k-a-b))
                break
            else:
                print(a-c)
                break

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
if A >= K:
    print(1 * K)
if A <= K <= A+B:
    print(1 * A + 0 * (K - A))
else:
    print(1 * A + 0 * B + (-1) * (K - A - B))

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
d,e,f = 0,0,0
for n in range(1,K):
    if n <= A:
        d = d + 1
    elif K - A <= B:
        e = e + 1
    else :
        f = f + 1

print(1*d + f* (-1))

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())

Submission status: Wrong Answer

Solution code:
i = input().split()
a = int(i[3])-int(i[0])
b = int(i[3])-int(i[0])-int(i[1])

if i[3] <= i[0]:
  print(i[3])
elif a == int(i[1]):
  print(int(i[3]) - int(i[1]))
elif a < int(i[1]):
  print(int(i[0]) - int(i[3]))
elif b == int(i[2]):
  print(int(i[0]) - int(i[2]))
else:
  print(int(i[0])*2 + int(i[1]) - int(i[3]))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    def main():
        a, b, c, k = map(int, input().split())
        lis = []
        if k >= a:
            lis.append(a)
        elif k >= a + b:
            lis.append(0*(b-a))
        elif k >= a+b+c:
            lis.append(-1*(c-b-a))
        print(sum(lis))
main()

Submission status: Wrong Answer

Solution code:
z=0
a,b,c,k = map(int,input().split())
z=k-a
print(a+z*-1)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())

if a >= k:
  ans = a
else:
  countC = k - (a + b)
  ans = (a * 1) + (countC * (-1))

print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
if A >= K:
    print(1 * K)
if K <= A+B:
    print(1 * A + 0 * (K - A))
else:
    print(1 * A + 0 * B + (-1) * (K - A - B))

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())

if a + b >= k:
    print(a)
else:
    sumcheck = c - k
    print(a - abs(sumcheck))

Submission status: Wrong Answer

Solution code:
import itertools
A, B, C, K = map(int, input().split())

import itertools

if K<=A:
    print(A)
elif B>=K-A:
    print(A)
else:
    print(A+(-1)*(K-A-B))

Submission status: Wrong Answer

Solution code:
import sys 
a,b,c,k = map(int,input().split())
max=0
if(a==k):
    print(a)
else:
    if(a<k):
        max+=a
        k=k-a
    if(b>k):
        print(max)
    else:
        k=k-b
        if(k<=0):
            print(max)
        else:
            if(c>=k):
                max-=k
                print(max)
            elif(c<k):
                max-=c
                print(max)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
cnt = k

if a >= cnt:
    print(a)
else:
    cnt = k - a
    if b >= cnt:
        print(a)
    else:
        cnt -= b
        if c >= cnt:
            print(a - cnt)
        else:
            print(a - c)

Submission status: Wrong Answer

Solution code:
i = input().split()
a = int(i[3])-int(i[0])
b = int(i[3])-int(i[0])-int(i[1])

if i[3] <= i[0]:
  print(i[3])
elif a == int(i[1]):
  print(int(i[3]) - int(i[1]))
elif a < int(i[1]):
  print(a)
elif b == int(i[2]):
  print(int(i[0]) - int(i[2]))
else:
  print(int(i[0])*2 + int(i[1]) - int(i[3]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a, b, c, k = map(int, input().split())

if a >= k:
    print(a)
else:
    if a+b >= k:
        print(a)
    else:
        if a+b+c == k:
            print(a-c)
        else:
            print(a-(k-(a+b)))

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
if k <= a:
  print(k)
elif a < k and k - a <= b:
  print(a)
elif a < k and b < k-a:
  print(a-c)
elif a == 0 and b == 0:
  print(-c)
elif a == 0 and b < k:
  print(-k+b)
else:
  print(k-c)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
if k <= a:
	print(a)
if k-a <= b and k > a:
	print(a)
if k > a + b:
	print(2*a+b-k)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=input().split()
A=int(n[0])
B=int(n[1])
C=int(n[2])
D=int(n[3])
a = np.array([1,0,-1])
b = np.array([A,D-A,D-A-B])
c = np.array([0,B,D-B])

if A>=1 and D-A-B>=0:
      print(sum(a*b))

elif  A>=1 and D-A-B<0:
      print(sum(a*b)-(-1*(D-A-B)))

elif A==0 and B==0:
      print("-1")  

elif A==0 and B>=1 and D-A-B>-0:
      print(sum(a*c))
elif  A==0 and B>=1 and D-A-B<-0:
      print(sum(a*c)-(-1*(D-A-B)))

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
if a + b >= k:
  ans = a
else:
  ans = a - (k - (a+b))
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
cnt = k

if a >= cnt:
    print(a)
else:
    cnt = k - a
    if b >= cnt:
        print(a)
    else:
        cnt -= b
        if c == 0:
            print(a)
        else:
            if c >= cnt:
                print(a - cnt)
            else:
                print(a - c)

Submission status: Wrong Answer

Solution code:
A,B,C,K =map(int,input().split())
c = 0
if A >= K:
    print(A)
    

elif A + B >= K:
    print(A)

elif A + B < K:
    c = -1 * (K-(A+B))
    #print(c)
    #print(A)
    cc = A + c
    print(cc)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
if K > A:
  print(A+B+C)
elif K <= A+B:
  print(A+B)
else:
	print(A-K+A+B)

Submission status: Wrong Answer

Solution code:
a, b, c, k = tuple([int(e) for e in input().split()])
k -= a + b
if k <= 0:
  print(a)
else:
  print(a - k)

Submission status: Wrong Answer

Solution code:
a, b, c, k = input().split()
a, b, c, k = int(a), int(b), int(c), int(k)
result = 0

while True:
    if a >= k:
        print(a)
        break
    else:
        if b >= k-a:
            print(a)
            break
        else:
            if c >= k-a-b:
                print(a-(k-a-b))
                break
            else:
                print(a-c)
                break

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
a = 1 * A
if (K - (A + B)) >= 0:
    c = -(1 * (K - (A + B)))
    print(a + c)
else:
    print(a)

Submission status: Wrong Answer

Solution code:
i = input().split()
a = int(i[3])-int(i[0])
b = int(i[3])-int(i[0])-int(i[1])

if i[3] <= i[0]:
  print(i[3])
elif a <= int(i[1]):
  print(int(i[3]) - int(i[1]))
elif b == int(i[2]):
  print(int(i[0]) - int(i[2]))
else:
  print(int(i[0])*2 + int(i[1]) - int(i[3]))

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int, input().split())
ans=0

if A == 0:
    print(-C)
    exit()
elif C == 0:
    K = K-B
    ans = -(C-K)
    print(ans)
    exit()
elif B == 0:
    K = K-A
    C = C-K
    ans = A-C
    print(ans)
    exit()

cnt = 0

if A+B >= K:
    if A<=K:
        print(A)
        exit()
    print(K-A)
    exit()
else:
    K = K-(A+B)
    ans = A
    cnt = C-K
    ans = ans-cnt
    print(ans)
    exit()

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
a = 1 * A
if (K - (A + B)) > 0:
    c = -(1 * (K - (A + B)))
    print(a + c)
else:
    print(a)

Submission status: Wrong Answer

Solution code:
A,B,C,K =map(int,input().split())
c = 0
if A >= K:
    print(A)
    

elif A + B >= K:
    print(A)

elif A + B < K:
    c = -1 * (K-(A+B))
    #print(c)
    #print(A)
    cc = int(A + c)
    print(cc)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
result = 0
if K > 0 :
    result = result + A
    K = K - A
if K > 0 :
    K = K -B
if K > 0 :
    for i in range (K):
        result = result - 1
print(result)

Submission status: Wrong Answer

Solution code:
def actual(A, B, C, K):
    score = 0

    if A >= K:
        return A
    else:
        score += A

        if B >= (K - A):
            return score
        else:
            if C >= (K - A - B):
                score -= (K - A - B)
                return score
            else:
                raise Exception()
                
A, B, C, K = [int(x) for x in input().split()]

print(actual(A, B, C, K))

Submission status: Wrong Answer

Solution code:
abck = list(map(int, input().split()))

a = abck[0]
b = abck[1]
c = abck[2]
k = abck[3]

if a + b >= k:
    print(int(1 * a))
else:
    z = (k - a - b)
    print(a - z)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())

sum = 0

if (a+b) >= k:
    sum = (k -a) * 1
    print(sum)
else:
    sum = a * 1
    sum += -1 * (k-a-b)
    print(sum)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int, input().split())

x = k - a
if x <= 0:
    print(k)
else:
    y = x - b
    if y <= 0:
        print(a)
    else: 
        print(a + ((k - b) * (-1)))

Submission status: Wrong Answer

Solution code:
card    = list(map(int, input().split()))
count  = card[3] - card[0] - card[1]
answer = card[0]

if count > 0:
    if count < card[2]:
        answer = answer + (count * -1)
        print(answer)
    else:
        answer = answer + (card[2] * -1)
        print(answer)
else:
    print(answer)

Submission status: Wrong Answer

Solution code:
A,B,C,K=(int(x) for x in input().split())

if K <= A+B:
    print(A)
else:
    print(A+(K-(A+B))*-1)

Submission status: Wrong Answer

Solution code:
x = input().split()

a = int(x[0])
b = int(x[1])
c = int(x[2])
k = int(x[3])

if(a > k): # a > k
  print(a-k)
  exit()
elif(k-a == 0):
  print(a)
  exit()
elif(k-a < b): # k > a 
  print(a)
  exit()
elif(k-a == b):
  print(a)
  exit()
elif(k-a-b < c):
  x = (k - a - b)
  print(a-x)
  exit()
elif(k-a-b == c):
  print(a-c)
elif(k-a-b > c):
  print(a-c)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
if K <= A:
  print(A+B+C)
elif K <= A+B:
  print(A+B)
else:
	print(A-K+A+B)