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

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
n = 0
for i in range(k):
  if a != 0:
    n += 1
    a -= 1
  elif b != 0:
    b -= 0
  else:
    n -= 1
    
print(n)

Submission status: Wrong Answer

Solution code:
#B
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))




##A
#S = input()
#T = input()

Submission status: Wrong Answer

Solution code:
#B
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))




##A
#S = input()
#T = input()

Submission status: Wrong Answer

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

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




##A
#S = input()
#T = input()

Submission status: Wrong Answer

Solution code:
#B
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))




##A
#S = input()
#T = input()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a+b >= k:
  result = a
else:
  result = a-c

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if k >= a :
  k = k-a
  if k >= b :
    k = k-b
    if k<= c :
      c = k
  else:
    b = k
else:
  a = k
  b = 0
  c = 0

print(a-c)

Submission status: Wrong Answer

Solution code:
A, B, C, K = (int(x) for x in 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(a+c-k)

Submission status: Wrong Answer

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

summation = 1 * a
k = k - a - b

if k > 0:
    summation = summation + (-1 * k)
    print(summation)
else:
    print(summation)

Submission status: Wrong Answer

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

summation = 1 * a
k = k - a

summation = summation + (0 * k)
k = k - b

if k > 0:
    summation = summation + (-1 * k)
    print(summation)
else:
    print(summation)

Submission status: Wrong Answer

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

summation = 1 * a
k = k - a

while k > 0 and k - b >= 0:
    summation += 0
    k -= 1

if k >= 0:
    summation = summation + (-1 * k)
print(summation)

Submission status: Wrong Answer

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

if In[3]-In[0] <= 0:
  print(In[0])
elif In[3] - (In[0]+In[1]) <= 0:
  print(In[0])
else:
  print(In[0]-(In[3]-In[0]-In[1]))

Submission status: Wrong Answer

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

if In[3]-In[0] <= 0:
  print(In[0])
elif In[3] - (In[0]+In[1]) <= 0:
  print(In[0])
else:
  print(In[0]+In[1]-In[2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input()

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

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

Submission status: Wrong Answer

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

if K > 0:
    K -= B

if K > 0:
    s -= K

print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K > 0:
    K -= B

if K > 0:
    s -= K

print(s)

Submission status: Wrong Answer

Solution code:
a, b, c, k= 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())

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())
result = 0
t = min(a,k)
result += 1
k -= 1
t = min(b,k)
k -= 0
t = min(c,k)
result -= 1
print(result)

Submission status: Wrong Answer

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

A,B,C,K = MI()

def result(K):
   if K <= 0:
    print(sum)
    exit()

sum = 0
sum += K

K -= A

result(K)

K -= B
result(K)

sum -= K

result(K)

Submission status: Wrong Answer

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

A,B,C,K = MI()

def result(K):
   if K <= 0:
    print(sum)
    exit()

sum = 0
K -= A
sum += A

result(K)

K -= B
result(K)

sum -= K

print(sum)

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 * 2 - k - b)

Submission status: Wrong Answer

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

A,B,C,K = MI()

def result(K):
   if K <= 0:
    print(sum)
    exit()

sum = 0
K -= A
sum += A

result(K)

K -= B
result(K)

for i in range(C):
    sum -= 1
    K -= 1
    result(K)

result(K)

Submission status: Wrong Answer

Solution code:
read = input().split()
x = int(read[3]) - int(read[0]) - int(read[1])
if x <= 0:
    print(int(read[0]))
else:
    print(int(read[0]) - x)

Submission status: Wrong Answer

Solution code:
read = input().split()
print(read)
x = int(read[3]) - int(read[0]) - int(read[1])
if x <= 0:
    print(int(read[0]))
else:
    print(int(read[0]) - x)

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

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

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(float, 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(float, 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+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:
  ans = a
elif a < k and a + b >= k:
  ans = a
elif a + b < k and a + b + c >= k:
  ans = a - (k - a - b)
else:
  ans = a - c
  
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, K = input().strip().split()
A, B, C, K = [int(A), int(B), int(C), int(K)]
summary = A
minus = K - A - B
if minus > 0:
  summary = summary - minus
print(str(summary))

Submission status: Wrong Answer

Solution code:
A, B, C, K = input().strip().split()
A, B, C, K = [int(A), int(B), int(C), int(K)]
summary = A
minus = K - A - B
if minus > 0:
  answer = summary - minus
else:
  answer = summary
print(str(answer))

Submission status: Wrong Answer

Solution code:
A, B, C, K = input().strip().split()
A, B, C, K = [int(A), int(B), int(C), int(K)]
summary = A
minus = K - A - B
answer = summary + minus
print(str(answer))

Submission status: Wrong Answer

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

if n[0] >= n[3]:
    print(n[3])
elif n[0]+n[1] >= n[3]:
    print(n[3])
else:
    print(n[0] - (n[3]-(n[0]+n[1])))

Submission status: Wrong Answer

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

if n[0] >= n[3]:
    print(n[0])
elif n[0]+n[1] >= n[3]:
    print(n[0])
else:
    print(n[0] - (n[3]-(n[0]+n[1])))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(test)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=1
b=0
c=-1
A,B,C,K=input().split()
A=int(A)
B=int(B)
C=int(C)
K=int(K)
item=K
if A<=item:
    A=A*a
    K=K-A
elif K<=0:
    c=0
if B<=item:
    A=A
    K=K-B
elif K<=0:
    c=0
if C<=item:
    A=A+K*c


    
print(A)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest


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

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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 1 1 3"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1 2 3 4"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2000000000 0 0 2000000000"""
        output = """2000000000"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest


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

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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 1 1 3"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1 2 3 4"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2000000000 0 0 2000000000"""
        output = """2000000000"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

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

if(a >= k):
    print(a, end="")
else:
    k -= a
    if(b >= k):
        print(a, end="")
    else:
        k -= b
        print(a-k, end="")

Submission status: Wrong Answer

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

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

    if A >= K:
        print(A)
        return

    total = A
    K -= A

    if B >= K:
        print(total)
        return

    K -= B

    total += -K

    print(total)


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = 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())
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(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-C)

Submission status: Wrong Answer

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

s = 0

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

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

Submission status: Wrong Answer

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



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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

score = 0


if K <= A+B:
    score = min(A,K)
else:
    score = max(A - (K - (A+B)), 0)


print(score)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = input().split()
# print(A, B, C, K) #+1:A枚 0:B枚 -1:C枚 K=picknum

A, B, C, K = int(A), int(B), int(C), int(K)
Ascore = A * 1
Bscore = (K-B) * 0
Cscore = (K-A-B) * (-1)
Tscore = Ascore + Bscore + Cscore

print(Tscore)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A >= K:
    print(A)
elif (A + B) >= K:
    print(A)
else:
    for i in range(K):
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            continue
        elif B == (i + 1 - A):
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)

Submission status: Wrong Answer

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

if A >= K:
    print(A)
elif (A + B) >= K:
    print(A)
else:
    for i in range(K):
        print(i)
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            continue
        elif B == (i + 1 - A):
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)

Submission status: Wrong Answer

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

if A <= K:
    print(K)
elif (A + B) <= K:
    print(K)
else:
    for i in range(K):
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            result += 0
            continue
        elif B == (i + 1 - A):
            result += 0
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)

Submission status: Wrong Answer

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

if A >= K:
    print(K)
elif (A + B) >= K:
    print(K)
else:
    for i in range(K):
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            result += 0
            continue
        elif B == (i + 1 - A):
            result += 0
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)

Submission status: Wrong Answer

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

if A >= K:
    print(K)
else:
    for i in range(K):
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            result += 0
            continue
        elif B == (i + 1 - A):
            result += 0
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break

print(result)

Submission status: Wrong Answer

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

if A > K:
    print(K)
    exit

for i in range(K):
    if A > (i + 1):
        result += 1
        continue
    elif A == (i + 1):
        result += 1
        continue

    if B > (i + 1 - A):
        result += 0
        continue
    elif B == (i + 1 - A):
        result += 0
        continue

    if C > (i + 1 - A - B):
        result -= 1
        continue
    elif C == (i + 1 - A - B):
        result -= 1
        break
    else:
        break

print(result)

Submission status: Wrong Answer

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

for i in range(K):
    if A > (i + 1):
        result += 1
        continue
    elif A == (i + 1):
        result += 1
        continue
    else:
        break

    if B > (i + 1 - A):
        result += 0
        continue
    elif B == (i + 1 - A):
        result += 0
        continue
    else:
        break

    if C > (i + 1 - A - B):
        result -= 1
        continue
    elif C == (i + 1 - A - B):
        result -= 1
        break
    else:
        break

print(result)

Submission status: Wrong Answer

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

for i in range(K):
    if A > (i + 1):
        result += 1
    elif A == (i + 1):
        result += 1
        continue
    else:
        break

    if B > (i + 1 - A):
        result += 0
    elif B == (i + 1 - A):
        result += 0
        continue
    else:
        break

    if C > (i + 1 - A - B):
        result -= 1
    elif C == (i + 1 - A - B):
        result -= 1
        break
    else:
        break

print(result)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k -= a
k -= b

print(a - k)

Submission status: Wrong Answer

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

if 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())
ans = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N=input("")
l_str=N.split()
l=[int(s) for s in l_str]

#l[0]が1,l[1]が0,l[2]が-1,l[3]がkの枚数
max;


if l[0]>=l[3] or l[0]+l[1]>=l[3]:
    max=1*l[0]
else:
    max=1*l[0]-1*(l[3]-(l[0]+l[1]))

print(max)

Submission status: Wrong Answer

Solution code:
N=input("")
l_str=N.split()
l=[int(s) for s in l_str]

#l[0]が1,l[1]が0,l[2]が-1,l[3]がkの枚数
max;


if l[0]>=l[3] or l[0]+l[1]>=l[3]:
    max=1*l[0]
else:
    max=1*l[0]-1*(l[3]-(l[0]+l[1]))

print(str(max))

Submission status: Wrong Answer

Solution code:
def main():
    A, B, _, K = map(int, input().split())
    print(A - max([0, K - A - B]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
one,zero,ng_one,card = map(int, input().split())

if card <= one+zero:
    print(one)
else:
    print(one - (card - one - zero))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max = 0

if(K >= A):
    max += A
    K -= A
else:
    max += K

K -= B

max -= K

print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a > 0 :
  ans -= a
  
print(ans)

Submission status: Wrong Answer

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

if A >= K or A+B >= K:
	max=A
else:
		max = A - (cntC)

print(max)

Submission status: Wrong Answer

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

if A >= K or A+B >= K:
	max=A
else:
		max = A - cntC

print(max)

Submission status: Wrong Answer

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

if A >= K:
	max=A
else:
	if cntC <= 0:
		max = A 
	else:
		max = A - cntC

print(max)

Submission status: Wrong Answer

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

if A >= K:
	max=A
elif A ==0 and B >= K:
	max = 0
elif A==0 and B==0:
	max=-maxC
else:
	if maxC <=0:
		max = A 
	else:
		max = A - maxC

print(max)