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 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())

import sys

ans = 0
if a != 0 and a >= k:
    # a = 1
    print(a)
    sys.exit()
elif a != 0:
    ans += a
    k -= a

if b != 0 and b >= k:
    print(ans)
    sys.exit()
elif b != 0:
    k -= b

ans += k * -1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max_num = 0
for a_i in range(a+1):
    for b_i in range(b+1):
        c_i = k-(a_i+b_i)
        total = a_i*1 + b_i*0 + c_i*-1
        if total > max_num and k == a_i+b_i+c_i:
            max_num = total

print(max_num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
IN = [i for i in map(int,input().split())]
K = IN[3]
A = min(IN[0],K)
B = 0 if A == K else K -A
C = 0 if A+B == K else K -A- B
print(A*1+B*0+C*-1)

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:
    print(a-(k-a-b))

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

def main():
    a,b,c,k = map(int, input().split())
    if a >= k:
        print(a)
    else: # aより多い
        k -= a
        if b >= k:
            print(a)
        else:
            k -= b
            print(a-k)


if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

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

else:
    c = K - A - B
    print(A-c)

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-b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
if 1 <= 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())
if 1 <= k <= a+b:
  print(a)
elif a+b+1 <= k <= a+b+c:
  print(2*a+b-k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, k = list(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 = list(map(int, input().split()))
if k <= a or k <= a + b:
    print(a)
else:
    print(a - (k - a - b))

Submission status: Wrong Answer

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

ans = 0

ans += min(a,k)
k -= min(a,k)
ans += min(b,k)
k -= min(b,k)
ans += min(c,k)
k -= min(c,k)

print(ans)

Submission status: Wrong Answer

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

if a == k:
    print(a)

ans = 0
for i in range(k):
    ans+=1
    a-=1
    k-=1
    if a==0:
        break
if k >= 1:
    for i in range(k):
        b-=1
        k-=1
        if b==0:
            break
if k >= 1:
    for i in range(k):
        ans+=-1
        c-=1
        if c==0:
            break

print(ans)

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:
    print(a - (k -(a+b)))

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 k <= a:
  print(a)
elif 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:
  print(a)
elif k <= a+b:
  print(a)
else:
  print(2*a-k+b)

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:
  print(2*a-k+b)

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:
  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+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 k<a:
  print(k)
elif a+b<k:
  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 + b:
  print(a)
else:
  print(a - (k - (a + b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


def solve(A: int, B: int, C: int, K: int):
    return A - max(K-A-B, 0)


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(A, B, C, K))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


def solve(A: int, B: int, C: int, K: int):
    return A - (K-A-B)


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(A, B, C, K))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = a
nokori = k - a
if (nokori == 0):
    print(ans)
    exit()

nokori = nokori  - b
if (nokori == 0):
    print(ans)
    exit()

ans = ans - nokori
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
A,B,C,K=map(int, sys.stdin.readline().split())
ans=0
a_cards=min(K,A)
K-=a_cards
ans+=a_cards*1

b_cards=min(K,B)
K-=b_cards
ans+=b_cards*0

c_cards=min(K,B)
K-=c_cards
ans+=c_cards*-1

print ans

Submission status: Wrong Answer

Solution code:
a,b,c,d=[int(i) for i in input().split()]
s=0
if(s<d):
    s=a
if(s<d):
    s=s+(b*0)
    e=a+b
    if(e<d):
        f=d-e
        s=s-f
print(s)

Submission status: Wrong Answer

Solution code:
import sys

ans=0
A, B, C, K = (int(x) for x in input().split())

if A>K:
  print(K)
  sys.exit(0)
else:
  K-=A
  ans+=A
  
if B>K:
  print(K)
  sys.exit(0)
else:K-=B

if C>K:
  print(ans-K)
  sys.exit()
else:
  ans-=C
  print(ans)

Submission status: Wrong Answer

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

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

print(s)

Submission status: Wrong Answer

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

sum=0
sum += a
sum -= (k-a-b) if k >= a+b else 0

print(sum)

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
if b<=k:
  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 >= 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())
if A >= K or 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)
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)
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)
elif a + b <= k:
  print(a)
else:
  print(k - b)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

count = 0
if a < k:
    count += a
    if a+b < k:
        count -= k-a-b
else:
    count = a

print(count)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

#print('k = :{0}, ans = :{1}'.format(k, ans))
if k - b >= 0:
  k = k - b
#print('k = :{0}, ans = :{1}'.format(k, ans))
  
if k > 0:
  ans -= k
#print('k = :{0}, ans = :{1}'.format(k, ans))

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())
ans=int()
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())
x = 0
if k == a:
    print(a)
elif k <= a + b:
    x = a
    k = k - a
    if b > k:
        print(a)
    else:
        k = k - b
        print(a)
elif k <= a + b + c:
    x = a
    k = k - a - b
    x = x - k * 1
    print(x)

Submission status: Wrong Answer

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

if k <= (a+b):
  print(int(a))
else:
  n = k - (a+b)
  print(int(a-n))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a >= k:
    print(a)

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

Submission status: Wrong Answer

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

if a >= k:
    print(a)

else:
    l = a
    k -= a
    
    while (b != 0) & (k != 0):
        b -= 1
        k -= 1

    while (c != 0) & (k != 0):
        l -= 1
        c -= 1
        k -= 1

    print(l)

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:
	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:
	print(a-(k-(a+b)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def main():
  a ,b ,c ,k = list(map(int,input().split()))
  if k > a:
    ans = a*1
    k-= a
  else:
    ans = (k)*1
    k = 0
#  print('a',k,ans)
  k-= b
#  print('b',k,ans)
  if k > c and k>0:
    ans += (c)*-1
  else:
    ans += (k)*-1
    
  print(ans)   
 
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
if(k<=a):
    print(a)
elif(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==0 and b==0):
    print(k-c)
if(a==0):
    if(k<=b):
        print(b)
    else:
        print(b-(k-b))
if(b==0):
    if(k<=a):
        print(a)
    else:
        print(a-(k-a))
if(a!=0 and b!=0):
    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==0):
    if(k<=b):
        print(b)
    else:
        print(b-(k-b))
if(b==0):
    if(k<=a):
        print(a)
    else:
        print(a-(k-a))
if(a==0 and b==0):
    print(k-c)
if(a!=0 and b!=0):
    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())
t=0
if(a!=0):
    t=t+a
if(b!=0):
    t=t
if(k>a-b):
    t=t-(k-a-b)
print(t)

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 and 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:
    print(a - (k - a - b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

ans = 0

if K <= (A + B):
  print(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 >= k:
    print(a)
elif a < k:
    k -= a
    if b >= k:
        print(a)
    elif b < k:
        k -= b
        print(a - k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if(y>0):
  print(a*1+y*(-1))
  
else:
  print(a*1)

Submission status: Wrong Answer

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

print(a*1+y*(-1))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if(X[0]<X[3] and X[3]-(X[0] + X[1])>0):
  print(X[0]*1+((X[3]-X[0] - X[1])*(-1)))
elif(X[0]<X[3] and X[3]-X[0]>0 and X[3]-(X[0] + X[1])==0):
  print(X[0]*1)
else:
  print(X[0]*1)

Submission status: Wrong Answer

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

if(X[0]<X[3] and X[3]-(X[0] + X[1])>0):
  print(X[0]*1+((X[3]-X[0] - X[1])*(-1)))
else:
  print(X[0]*1)

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

X = 1 * A + 0 * Y + (-1) * Z
print(X)

Submission status: Wrong Answer

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

X = A + 0 * Y + (-1) * Z
print(X)

Submission status: Wrong Answer

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

if(A >= K):
    print(A)
    exit()
K = K - A
if(B >= K):
    print(A)
    exit()
K = K - B
print(A-K)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
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 K <= A:
    print(K)

elif 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:
    print(K)

elif K <= B:
    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 + b:
	print(k)
else:
	print(a - (k - (a + b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,k = input().split()
a,b,c,k = int(a),int(b),int(c),int(k)
amount = a
k-=a
while k>0 and b>0:
    b-=1
    k-=1
while k>0 and c>0:
    amount+=-1
    c-=1
    k-=1
print(amount)

Submission status: Wrong Answer

Solution code:
a , b ,c , k = input().split()
a,b,c,k = int(a) , int(b) , int(c) , int(k)
count=a
k -= a
while b>0 and k>0:
    k-=1
    b-=1
while c>0 and k>0:
    count+=-1
    k-=1
    c-=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

a,b,c,k = Mi()
ans = a
k -= a
if k > b:
  ans -= k-b
  
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

sum = 0
sum += A * 1
if(A + B < K):
  sum += C * (-1)

print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

sum = 0
sum += A * 1
if(A + B < K):
  sum += (K - A - B) * (-1)

print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def maximum():
    A,B,C,K = map(int,input().split())
    num = 0
    max = 0
    if A <= K:
        max = A
        num = K - A
        if B <= num:
            num = num - B
            max -= num
            print(max)
            return
        else:
            print(max)
            return
    else:
        print(max)
        return
maximum()

Submission status: Wrong Answer

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

    if A >= K:
        print(A)
        return
    if A + B >= K:
        print(A)
        return

    print(A-(K - A - B))

    return


resolve()

Submission status: Wrong Answer

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

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

    return


resolve()

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())
ret = min( A, K )
if A < K:
  ret -= min( 0, K - A - B )
print( ret )

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

if ans >= 0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

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

if ans >= 0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

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

if ans >= 0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

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

if ans >= 0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 + b))

Submission status: Wrong Answer

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

if k - a <= 0:
  print(k)
elif k - a + b <= 0:
  print(a)
else:
  k -= (a + b)
  for i in range(1, c+1):
    if k - i == 0:
      print(a-i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
s = 0
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 = 0
if  a + b >= k:
    s = a
elif b > k:
    s = 0
else:
    s = a - (c - b) 
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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)
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  a + b >= k:  
  print(a)
elif a > k:
  print(k)
else:
  print(2*a - k + b)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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 < 0):
    if(A + B - K < 0):
        print(A - C * (K - A - B))
    else:
        print(A)
else:
    print(K)