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())
""" a:1
    b:0
    c:-1
"""
nokori=k
sum_max=0
minus=0
if(a+b>=k):
    sum_max=a
else:
    minus=a+b-k
    sum_max=a+minus




print(sum_max)

Submission status: Wrong Answer

Solution code:
# S = input()
# N = int(input())
# A, B = map(int, input().split(' '))
# A = list(map(int, input().split(' ')))

A, B, C, K = map(int, input().split(' '))
result = 0

if A < K:
  result += A
  K -= A
else:
  result = A
  K -= A

if K > 0:
  if B < K:
    K -= B
  else:
    K -= B

if K > 0:
  if C < K:
    result -= C
    K -= C
  else:
    result -= K

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a <= k:
    sum += a
    k -= a
else:
    sum +=k

k -= b
    
if c <= k:
    sum -= c
    k -= c
else:
    sum -= k

print(sum)

Submission status: Wrong Answer

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

if k<=a+b:
	amount=a
	print(amount)
else:
	amount=a+(-1)*(k-a-b)
	print(amount)

Submission status: Wrong Answer

Solution code:
import sys
A,B,C,K = list(map(int,input().split()))
total = 0
output = 0

if A >= K:
  print(A)
  sys.exit()
elif A < K and A + B >= K:
  print(A)
  sys.exit()
else:
  print(A-(K-(A+B)))
  sys.exit()

Submission status: Wrong Answer

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

if (a >= k):
  print (a)
  sys.exit()
elif (a+b >= k):
  print (a)
  sys.exit()
else:
  print (a+(k-a-b)*(-1))

Submission status: Wrong Answer

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

ans = 0

if a <= k:
    ans += a
    k -= a
else:
    ans += k
    k = 0

k -= b

if k > 0:
    ans -= (b - k)

print(ans)

Submission status: Wrong Answer

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

a = min(A, K)
c = max(K - A - B, 0)

print(A * 1 + c * (-1))

Submission status: Wrong Answer

Solution code:
plus, zero, minus, number = map(int, input().split(" "))

if(plus + zero <= number):
  print(plus)
else:
  print(2 * plus + zero - number)

Submission status: Wrong Answer

Solution code:
A_1, B_0, C_minus1, K = map(int, input().split(' '))

max_total = 0

if(K <= (A_1 + B_0)):
  max_total = A_1
else:
  max_total = A_1 - (K - (A_1 + B_0))
  
print(max_total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
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:
import sys
import math
a,b,c,k=map(int,input().split())
if a<=k:
    print(k)
elif a>=k:
    print(a)
    sys.exit()
elif a+b>=k:
    print(a)
    sys.exit()
else:
    if c>k-(a+b):
        s=k-(a+b)
        print(a+(s*(-1)))
        sys.exit()
    else:
        print(a+(c*(-1)))

Submission status: Wrong Answer

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

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

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k -= b
l = k - a
a = min(a,k)
ans = a - l
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def main():
    A, B, C, K = list(map(int, input().split()))

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

weight = [1, 0, -1]

sumAns = 0

for i in range(3):
    sumAns += lNum[i] * weight[i] if lNum[i] <= lNum[3] else lNum[3] * weight[i]
    lNum[3] -= lNum[i]
    if(lNum[i] <= 0):
        break
    
print(sumAns)

Submission status: Wrong Answer

Solution code:
data = input().rstrip().split(" ")
one = int(data[0])
zero = int(data[1])
minus = int(data[2])
num = int(data[3])
answer = 0
if one + zero >= num:
    answer = one
else:
    answer = one - (num - one - zero)
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
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 >= k:
    print(a)
elif a+b >= k:
    print(a)
else:
    ab = a+b
    ans = a - k+ab
    if k >=a+b+c:
        print(a-c)
    else:
        print(ans)

Submission status: Wrong Answer

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

ans=0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

AB = A + B

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

Submission status: Wrong Answer

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

B1 = A + B
C1 = B + C


if C1 > K:
    print(max((K - B1) * (-1) + A, 0))
elif A > K:
    print(K)
else:
    print(A)

Submission status: Wrong Answer

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

if K <= A:
    print(1*A)
elif K <= A + B:
    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())

for i in range(3):
    if i == 0:
        k -= a
        if k <= 0:
            print(k)
            break

    elif i == 1:
        k -= b
        if k <= 0:
            print(a)
            break

    elif i == 2:
        if k < c:
            print(a+(-1*k))
        else:
            print(a+c)

Submission status: Wrong Answer

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

else:
    print((2*A)+B-K)
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
if k >= a:
    ans += a*1
    k = k - a
elif k < a:
    k = 0
    ans = k

if k > 0 and k >= b:
    k = k - b
elif k > 0 and k < b:
    k = 0

if k > 0 and k >= c:
    ans -= c*1
    k = k - c
elif k > 0 and k < c:
    ans = ans - 1*k
    k = 0

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
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())
sum=0
if(a>k):
  sum+=k
else:
  sum+=a
  k=k-a
  if(k==0):
    print(sum)
    exit()
  if(b>k):
    print(sum)
  else:
    k = k-b
    if(k==0):
      print(sum)
      exit()
    if(c>k):
      sum-=k
      print(sum)
    else:
      sum-=c
      print(sum)

Submission status: Wrong Answer

Solution code:
I = list(map(int,input().split()))
A = I[0]
B = I[1]
C = I[2]
K = I[3]

if A+B >= K :
    S = A
elif A+B+C > K :
    S = A - (K-A-B)
elif A+B+C == K :
    S = A-C

print(S)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A >= K:
    print(A)
    exit()
else:
    bc = K - A  # A < K なのでbc >= 1
    #assert bc >= 1
    if B >= bc:
        if A >= C:
            print(A)
            exit()
        else:
            if C >= bc:
                print(A-abs(C-bc))
                exit()
            else:
                print(A)
                exit()
    else:
        # B < bc
        cc = bc - B
        #assert cc >= 1
        print(A - cc)
        exit()

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

goukei = 0

if a == d:
    print(a)
elif d == (a+b):
    print(a)
else:
    goukei = (a - (d - a - b))
    print(goukei)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = list(map(int , input().split()))
if A[0] < A[-1]:
    a = A[0]
    b = A[-1] - A[0]
    if A[1] < b:
        a -= (b - A[1])
else:
    a = A[0]
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if k <= a:
    print(a)
elif a < k and k <= a + b:
    print(a)
elif a + b < k:
    print(a + (-1) * (k - a - b))

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
count = 0
point = 0

if D-A <= 0:
    point = A
    D -= A
    if D-B <= 0:
        D -= B
        if D-C <= 0:
            point -= C
            print(point)
        else:
            point -= D
            print(point)
    else:
        print(point)
else:
    point = D
    print(point)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def solve():
    A = int(input())
    B = int(input())
    C = int(input())
    K = int(input())
    if A >= K >= 1:
        print('{}'.format(K))
    elif A+B >= K > A:
        print('{}'.format(A))
    elif A+B+C >= K > A+B:
        result = 2*A + B - K
        print('{}'.format(result))


    return

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import sys


A, B, C, K = map(int, input().split())
ans = 0
if K >= A:
    ans += A
    K = K - A
    if K > B:
        K = K - B
        ans = ans - K
        print(ans)
        sys.exit()
    else:
        print(ans)
        sys.exit()
else:
    print(A)
    sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

s += a
k -=a
k -=b
s -= max(k , 0)
print(s)

Submission status: Wrong Answer

Solution code:
def Main(A, B, C, K):
    if K < A:
        return K
    elif A <= K <= A+B:
        return A
    else:
        if A <= C:
            return max(2*A+B-K, 0)
        else:
            return max(A+B+C-K, 0)
        
def main():
    A, B, C, K = map(int, input().split())
    print(Main(A, B, C, K))

if __name__ == '__main__':
    main()

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:
    print(A-(K-A-B))
else:
    print(A)

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)
else:
    ab = a+b
    ans = a - k+ab
    if k >a+b+c:
        print(a-c)
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int,input().split())
if A>=K:
    print(A)
elif A < 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 K - A <= 0:
  print(A * 1)
elif K - A - B <= 0:
  print(A * 1)
else:
  temp = K - A - B
  print(A * 1 + temp * -1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans=0

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b, c, k = LI()
if k < a:
    print(k)
elif a < k <= a + b:
    print(a)
else:
    print(a - (k- a - b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = [int(i) for i in input().split()]
if K <= A:
    print(K)
elif A <= K <= A+B:
    print(A)
else:
    print(A-min(C, K-A))

Submission status: Wrong Answer

Solution code:

def main():
    A, B, C, K = list(map(int, input().split()))

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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)*(-1)+a)

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)
elif (a+b+c)>=k:
    print(max(0,(a+b)-k))

Submission status: Wrong Answer

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

max = 0

if a < k:
    max = a
    k -= a
    if 0 < k:
        k -= b
        if 0 < k:
            max -= k

else:
    max = a


print(max)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int, input().split())
t=0
if a>=d:
  t+=a
  print(t)
  exit()
else:
  t+=a
  d-=a
if b>=d:
  print(t)
  exit()
else:
  d-=b
#print(t,d)
print(t-d)

Submission status: Wrong Answer

Solution code:
# S = input()
# N = int(input())
# A, B = map(int, input().split(' '))
# A = list(map(int, input().split(' ')))

A, B, C, K = map(int, input().split(' '))
result = 0

if A < K:
  result += A
  K -= A
else:
  result = A
  
if B < K:
  K -= B
else:
  K -= B

if K > 0:
  if C < K:
    result -= C
    K -= C
  else:
    result -= K

print(result)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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>=k:
  print(a)
elif a<k:
  print(a+(-1)*(k-a-b))

Submission status: Wrong Answer

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

if a>=k:
    cnt += a
else:
    k -= a
    cnt += a
    if b<=k:
        k -= b
    if c>=k:
        cnt -= k

print(cnt)

Submission status: Wrong Answer

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

if(k-a-b<0):
    print(1*a)
else :
    print(1*a - 1*(k-a-b))

Submission status: Wrong Answer

Solution code:
def main():
    abck = list(map(int, input().split()))
    count = abck[3]
    r = 0
    r += min(abck[0], count)
    count -= min(abck[0], count)
    count -= min(abck[1], count)
    count -= min(abck[2], count)
    r -= min(abck[2], count)

    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def solve(A, B, C, K):
    num = K
    ans = 0

    if K <= A:
        return 1 * A

    num -= A
    ans = 1 * A
    if num <= B:
        return ans

    num -= B

    return ans - num


A, B, C, K = map(int, input().split())
print(solve(A, B, C, K))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

number_of_A = min(A, K)
remainder = K - number_of_A

number_of_B = min(B, remainder)
remainder = remainder - B

number_of_C = remainder

total = (number_of_A * 1) + \
    (number_of_B * 0) + \
    (number_of_C * -1)

print(total)

Submission status: Wrong Answer

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

if a>=k:
    print(max(a,k))
elif a+b>=k:
    print(a)
    
else:
    x=k-a-b
    print(a-x)

Submission status: Wrong Answer

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

print(min(A, K)-min(K-A-B, C))

Submission status: Wrong Answer

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

solve()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
#coding :utf-8
A,B,C,K=map(int,input().split())
cnt=0
if K-A > 0:
  cnt=A
  if K-A-B >0:
    if K-A-B-C < 0:
      cnt=0
      print(cnt)
    else:
      cnt=A-C
      print(cnt)
  else:
    print(cnt)
else:
  print(K)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
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:
# 1,0,-1
# K枚
A, B, C, K = map(int, input().split())

ans = 0
while(K!=0):
    
    if A!=0:
        if A <= K:
            ans += A*1
            A =0
            K -= A
        else:
            ans += K*1
            A -= K
            K = 0
    elif B!=0:
        if B <= K:
            ans += B*0
            B =0
            K -= B
        else:
            ans += K*0
            B -= K
            K = 0
    elif C!=0:
        if C <= K:
            ans += C*-1
            C =0
            K -= C
        else:
            ans += K*-1
            C -= K
            K = 0

    if A==0 and B==0 and C==0:
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
a,b,c,k = map(int, sys.stdin.readline().split())
b_ = k-a
if b_ > b:
    b_ = b
    c_ = k-a-b
else:
    c_ = 0
print(a-c_)