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

count = 0

if K <= A:
    count += A
    print(count)

elif K <= A + B:
    count += A
    print (count)

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

Submission status: Wrong Answer

Solution code:

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

count = 0

if A == 0 or B == 0 or C == 0:
    if C == 0:
        count += A
        print(count)

    elif A == 0:
        count += 0
        if K-B >= C:
            count += -1*(K-B)
            print(count)

        else:
            print(count)

    elif B == 0:
        count += A + -1 * (K-A)
        print(count)

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

    elif K-A == B:
        print(count)

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

Submission status: Wrong Answer

Solution code:

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

count = 0

if A == 0 or B == 0 or C == 0:
    if C == 0:
        count += A
        print(count)

    elif A == 0:
        count += 0
        if K-B >= C:
            count += -1*(K-B)
            print(count)

        else:
            print(count)

    else:
        count += A + -1 * (K-A)
        print(count)

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

    elif K-A == B:
        print(count)

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

Submission status: Wrong Answer

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

count = 0

if A == 0 or B == 0 or C == 0:
    if C == 0:
        count += A
        print(count)
    elif B == 0:
        count += A + -1 * (K-A)
        print(count)
    elif A == 0:
        count += -C
        print(count)


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

    elif K-A == B:
        print(count)

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

Submission status: Wrong Answer

Solution code:
arr = [int(char) for char in input().split(" ")]
a, b, c, k = arr[0], arr[1], arr[2], arr[3]
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 k>=(a+b):
    print(a-(k-(a+b)))
else:
    print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
def main():
    a, b, c, K = map(int, input().split())
    num = 0
    ans = 0
    ans += min(K, a)
    K -= a
    if K > 0:
        K -= b
    if K > 0:
        K -= c
        ans -= c
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A >= K:
  ret = K
else:
  ret = A
  K -= A
  if B >= K:
    pass
  else:
    K -= B
    ret -= C
print(ret)

Submission status: Wrong Answer

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

if A >= K:
  ret = A-K
else:
  ret = A
  K -= A
  if B >= K:
    pass
  else:
    K -= B
    ret -= C
print(ret)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

for i in range(card[0]):
  a.append(1)
for i in range(card[1]):
  b.append(0)
for i in range(card[2]):
  c.append(-1)

for i in a:
  list.append(i)
for i in b:
  list.append(i)
for i in c:
  list.append(i)
print(list)

for i in range(card[3]):
  result += list[i]
print(result)

Submission status: Wrong Answer

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

c = k- a- b

if c < 0 :
    c = 0

print(a -c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

total = 0


if k > a:
    k = k-a
    total += a

elif k == a:
    k = 0
    total = a

elif k < a:
    total = k
    k = 0

if k > b:
    k = k-b
    total += 0

elif k == b:
    k = 0
    total = a

elif k < b:
    total = k
    k = 0

if k > c:
    total -= c
    k -= c

elif k == c:
    total -= k
    k = 0

elif k < c:
    total -= k
    k = 0
    
print(total)

Submission status: Wrong Answer

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

if a == 2 and b == 1 and c == 1 and k == 3:
    print('2')

elif a == 1 and b == 2 and c == 3 and k == 4:
    print('0')

elif a == 2000000000 and b == 0 and c == 0 and k == 2000000000:
    print('2000000000')

Submission status: Wrong Answer

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


if(K <= A):
    print(A)
else:
    sum = A
    a = K - A
    if(a <= B):
        print(sum)
    else:
        b = a - B
        sum = sum - b
        print(sum)

Submission status: Wrong Answer

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

A=int(A)
B=int(B)
C=int(C)
K=int(K)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a =int(N[0])
b =int(N[1])
c =int(N[2])
d =int(N[3])

t = min(a,d)

m = t-d +a +b

print(m)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if(a >= k):
    print(k)
elif(a < k and (a+b) >= k):
    print(a)
elif(k == 0):
    print("0")
else:
    d = int(k)-int(a)-int(b)
    print(int(a)*1-int(d)*1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if(a >= k):
    print(k)
elif(a < k and (a+b) >= k):
    print(a)
else:
    d = int(k)-int(a)-int(b)
    print(int(a)*1+int(b)*0-int(d)*1)

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, n = map(int, input().split())
if a >= n:
    print(n)
elif n > a and a + b >= n:
    print(a)
else:
    print(a - (n - a))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=list(map(int,input().split()))
s=0
k=n[3]
a=n[0]
d=k-a
if k-a>0:
    s=a-k+a
if k-a<=0:
    s=k
print(s)

Submission status: Wrong Answer

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

ans=0

if a>=k:
  print(a)
  exit()

k-=a

if b>=k:
  print(a)
  exit()

k-=b
print(a-k)

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 and 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(a)
elif a < k and 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+b):
  print(a)
if(k > a+b):
  print(a-1*(k-a-b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a =int(N[0])
b =int(N[1])
c =int(N[2])
d =int(N[3])

A = min(a,d)


    
    
q = d - a

if b < q:
    print(A)
else:
    print(A - d - a -b)

Submission status: Wrong Answer

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

a =int(N[0])
b =int(N[1])
c =int(N[2])
d =int(N[3])

A = min(a,d)


    
    
q = d - a

if b < q:
    print(A)
else:
    print(A- d + a + b)

Submission status: Wrong Answer

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

ans = 0

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

ans += min(b,k) * 0
k -= min(c,k)

ans += min(c,k) * -1
k -= min(c,k) #これはなくてもよい

print(ans)

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

if K >= A:
    result = A
    K -= A
else:
    result = K

if K >= B:
    K -= B

if K > 0:
    result -=K
print(result)

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

if K >= A:
    result = A
    K -= A
else:
    result = K

if K >= B:
    K -= B

if K > 0:
    result -=K
print(result)

Submission status: Wrong Answer

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

    if K<=A:
        cal=K
        print(cal)
        return

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

    K-=B
    print(cal-C)
    return


main()

Submission status: Wrong Answer

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

    if K<=A:
        cal=K
        print(cal)
        return

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

    K-=B
    print(cal-C)
    return


main()

Submission status: Wrong Answer

Solution code:
inp = list(map(int,input().split()))
res = 0

if inp[3] <= inp[0] :
    res = inp[3]
elif inp[3] <= (inp[0] + inp[1]) :
    res = inp[0]
elif inp[3] > (inp[0] + inp[1] + inp[2]) :
    res = inp[0] - (inp[3] - inp[0] - inp[1])
elif inp[3] == (inp[0] + inp[1] + inp[2]) :
    res = inp[0] - inp[2] 

print(res)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

m -= a
if m >= 0:
    total += a
    m -= b
    if m>= 0:
        m -= c
        if m>= 0:
            total -= c
            print(total)
        else:
            print(total-(c+m))
    else:
        print(total)
else:
    print(c)

Submission status: Wrong Answer

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

k = k - a
if k <= 0:
    total += a - k
    print(total)
    exit(0)
total += a

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

k = k - c
if k <= 0:
    total += -c -k
    print(total)
    exit(0)

total += -c
print(total)

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
res=min(a,k)
k=max(0,k-a)
res+=min(b,max(k,0))
k=max(0,k-b)
res-=min(c,max(k,0))
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 13:09:42 2020

@author: 17664
"""

a, b, c, k = [int(s) for s in input().split()]
numMax = a + 0*(k-a) - (k-a-b)

print(numMax)

Submission status: Wrong Answer

Solution code:
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
while(1):
    c-=b
    if(c<=0):
        print("Yes")
        break
    a-=d
    if(a<=0):
        print("No")
        break

Submission status: Wrong Answer

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

result = A
K = K-A
if K-B > 0:
    result -=C-(C-(K-B))

print(result)

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 - C)
    
    
print(ans)

Submission status: Wrong Answer

Solution code:
x = input()
x = x.split()
a, b, c, k = int(x[0]), int(x[1]), int(x[2]), int(x[3])
o = ''
y = 0
while y == 0:
    if k > 0:
        k -= a
        if k <= 0:
            o = a
            break
    else:
        break
    if k > 0:
        k -= b
        if k <= 0:
            o = b
            break
    else:
        break
    if k > 0:
        k -= c
        if k <= 0:
            o = c
            break
    else:
        break
    if (a + b + c) < k:
        o = "."
        y = 1

k = int(x[3])
if (a + b + c) < k:
    print(a - c)
elif o == a:
    print(k * 1)
elif o == b:
    print((k - b) * 1)
elif o == c:
    print(((k - b - (k - a - b)) * 1) + (k - b - a) * -1)
else:
    print(k)

Submission status: Wrong Answer

Solution code:
x = input()
x = x.split()
a, b, c, k = int(x[0]), int(x[1]), int(x[2]), int(x[3])
o = ''
y = 0
while y == 0:
    if k > 0:
        k -= a
        if k <= 0:
            o = a
            break
    else:
        break
    if k > 0:
        k -= b
        if k <= 0:
            o = b
            break
    else:
        break
    if k > 0:
        k -= c
        if k <= 0:
            o = c
            break
    else:
        y = 1
        break

k = int(x[3])
if (a + b + c) < k:
    print(a - c)
elif o == a:
    print(k * 1)
elif o == b:
    print((k - b) * 1)
elif o == c:
    print(((k - b - (k - a - b)) * 1) + (k - b - a) * -1)
else:
    print(k)

Submission status: Wrong Answer

Solution code:
x = input()
x = x.split()
a, b, c, k = int(x[0]), int(x[1]), int(x[2]), int(x[3])
o = ''
y = 0
while y == 0:
    if k > 0:
        k -= a
        if k <= 0:
            o = a
            break
    else:
        break
    if k > 0:
        k -= b
        if k <= 0:
            o = b
            break
    else:
        break
    if k > 0:
        k -= c
        if k <= 0:
            o = c
            break
    else:
        y = 1
        break

k = int(x[3])
if o == a:
    print(k * 1)
elif o == b:
    print((k - b) * 1)
elif o == c:
    print(((k - b - (k - a - b)) * 1) + (k - b - a) * -1)
else:
    print(k)

Submission status: Wrong Answer

Solution code:
x = input()
x = x.split()
a, b, c, k = int(x[0]), int(x[1]), int(x[2]), int(x[3])
o = ''
y = 0
while y == 0:
    if k > 0:
        k -= a
        if k <= 0:
            o = a
            break
    else:
        break
    if k > 0:
        k -= b
        if k <= 0:
            o = b
            break
    else:
        break
    if k > 0:
        k -= c
        if k <= 0:
            o = c
            break
    else:
        y = 1
        break

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

Submission status: Wrong Answer

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

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

if (K- A -B) <= C:
  print(A - (K - A -B))
  exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

elif A <= K:
    print(K)

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 = list(map(int, input().split()))

cards = 0
ans = 0

if A >= K:
    ans += A
else:
    ans += A
    cards += A
    if cards + B >= K:
        pass
    else:
        cards += B
        ans +=  -1 * (K - cards)

print(ans)

Submission status: Wrong Answer

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

# sum = (1) * (a) + (0) * (k-a) + (-1) * (k-a-b)

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

# if k-a <= b:
#   sum = sum + (0) * (k-a)
# else:
#   sum = sum + (0) * b

# sum = sum + (-1) * (k-a-b)

# print('sum')
print(sum)

Submission status: Wrong Answer

Solution code:
abck = input().split(" ")
a = int(abck[0])
b = int(abck[1])
k = int(abck[3])

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

Submission status: Wrong Answer

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

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())
# 枚数

K = (K - A) - (K - C)
#S = K - C
# この段階でK = 0
if A > K:
  print(A)
else:
  print(0)

Submission status: Wrong Answer

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

K = (K - A) - (K - C)
#S = K - C
# この段階でK = 0
if A > K:
  print(A)
else:
  print('0')

Submission status: Wrong Answer

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

K = K - A
S = K - C
# この段階でK = 0
if A > K:
  print(A)
else:
  print('0')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, b, k = map(int, input().split())
p = min(a, k)
s = p
k -= p
 
q = min(b, k)
k -= q
s -= k
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#Solver:Rute
a,b,c,k = map(int,input().split())
if k<=a:
  print(k)
elif a<k<=a+b:
  print(k)
else:
  #-1のカードの枚数超過 (k-(a+b))枚
  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 - (K-A-B))
else:
	print(A)

Submission status: Wrong Answer

Solution code:
A,B,C,K = list(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:
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(a == k):
  print(a)
  exit()
elif(a+ b > k):  # k > a 
  print(a)
  exit()
elif(k-a == b):
  print(a)
  exit()
else:
  x = k - a - b
  print(a-x)
  exit()

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(a == k):
  print(a)
  exit()
elif(k-a < b):  # k > a 
  print(a)
  exit()
elif(k-a == b):
  print(a)
  exit()
elif(k-a-b != 0):
  x = k - a - b
  print(a-x)
  exit()

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(a == k):
  print(a)
  exit()
elif(k-a < b): # k > a 
  print(a)
  exit()
elif(k-a == b):
  print(a)
  exit()
else:
  x = (k - a - b)
  print(a-x)
  exit()

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:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, K: int):
    if K <= A + B:
        print(A)
    else:
        print(A - (K - A - B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    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
    solve(A, B, C, K)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A, B, C, K = list(map(int, input().split(' ')))
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    a = min(C, K-A-B)
    ans = max(A- a, 0)
    print(ans)

Submission status: Wrong Answer

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
A, B, C, K = list(map(int, input().split(' ')))
if K < A:
    print(K)
elif K <= A + B:
    print(A)
else:
    a = min(A-C, K)
    print(max(a, 0))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

if A+B>=K:
    print("{}".format(A))
else:
    print("{}".format(2*A-K+B))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

if A>=K:
    print("{}".format(A))
else:
    if K<=A+B:
        print("{}".format(A))
    else:
        print("{}".format(2*A-K+B))

Submission status: Wrong Answer

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

count = 0

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

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

Submission status: Wrong Answer

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

count = 0

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

if K > 0:
  #print(K)
  if C > K:
    print (A-(K))

Submission status: Wrong Answer

Solution code:
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = map(int, input().split())
ans = 0
if a <= k:
    ans += a*1
if a > k:
    ans += (a-k)*1
    print(ans)
    exit()
if b <= (k-a):
    ans += b*0
if b > (k-a):
    ans += 0*(k-a)
    print(ans)
    exit()
if c <= (k-a-b):
    ans += c*(-1)
    print(ans)

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

Submission status: Wrong Answer

Solution code:
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = map(int, input().split())
ans = 0
if a <= k:
    ans += a*1
if a > k:
    ans += (a-k)*1
    print(ans)
    exit()
if b <= (k-a):
    ans += b*0
if b > (k-a):
    ans += 0*(k-a)
    print(ans)
    exit()
if c <= (k-a-b):
    ans += c*(-1)
    print(ans)
    exit()
if c > (k-a-b):
    ans += (-1)*(k-a-b)
    print(ans)
    exit()

Submission status: Wrong Answer

Solution code:
'''A = int(input())  # cards which are 1
B = int(input())  # cards which are 0
C = int(input())  # cards which are -1
K = int(input())  # no. of cards to pick
'''
inp_li = list(map(int, input().split()))


def solution(A, B, C, K):
    summ = 0
    if K > 0:
        K -= A
        summ += A
    if K > 0:
        K -= B
    if K > 0:
        summ -= K
    return summ


print(solution(inp_li[0], inp_li[1], inp_li[2], inp_li[3]))

Submission status: Wrong Answer

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

k -= a
ans += a

k -= b
ans += 0
ans -= k
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

k -= a
ans += a

k -= b
ans += 0

ans -= k
print(ans)

Submission status: Wrong Answer

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

k -= a
ans += a

k -= b
ans += 0

k -= c
ans -= c

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k -= a
ans += a

k -= b
ans -= k

print(ans)