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())
maxC=K-(A+B)

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

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
else:
	if maxC <=0:
		max = A 
	else:
		max = A - maxC

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
else:
	if maxC <0:
		max = A 
	else:
		max = A - maxC

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
else:
	if maxC <0 :
		max = A 
	elif maxC >= 0:
		max = A - maxC

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
else:
	if maxC <0 :
		max = A 
	else:
		max = A - maxC

print(max)

Submission status: Wrong Answer

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

if maxC < 0:
	max = A 
else:
	max = A - maxC

print(max)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
readmi = lambda: map(int, sys.stdin.readline().split())

A, B, C, K = readmi()
# result var
max_sum = 0

# check 1
max_sum = min(A, K)
K = K - max_sum

# check 0
if K > 0:
  K = K - min(B, K)

# check - 1
if K > 0:
  max_sum = max_sum - min(K, B)
# print result
print(max_sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

if b > k:
    ans += 0*k
    k = 0
else:
    ans += 0*b
    k -= b

if c > k:
    ans += 0*k
    k = 0
else:
    ans += 0*c
    k -= c


print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(k):
    if a != 0:
        ans += 1
        a += -1
        continue
    if b != 0:
        ans += 0
        b += -1
        continue
    if c != 0:
        ans += 1
        c += -1
        continue
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
def solve(A,B,C,K):
    if K <= A:
        return K
    elif A < K < A + B:
        return A
    else:
        return K - 2*A - B
print(solve(A,B,C,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:
l = [int(i) for i in input().split()]
num = [1,0,-1]
c = 0
s = 0
k = l[-1]
for i in range(3):
    
    if c + l[i] > k:
        s += num[i] *(k-c)
    else:
        s += l[i] * num[i]
        c+=l[i]

print(s)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

A = [1 for _ in range(a)]
B = [0 for _ in range(b)]
C = [-1 for _ in range(c)]

card = A + B + C
Max_sum = sum(card[:k])

print(card,Max_sum)

Submission status: Wrong Answer

Solution code:
nums = [int(e) for e in input().split()]

if nums[0]<nums[3]:
    max=nums[0]
    if nums[0]+nums[1]<nums[3]:
        max -= (nums[3]- nums[0]+nums[1])
else:
    max=nums[3]

print(max)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
in1 = input().split()
A,B,C,K = int(in1[0]),int(in1[1]),int(in1[2]),int(in1[3])
i,SUM = int(0),int(0)
while i<=K:
#for i in range(K):
    if A!=0:
        SUM+=1
        A-=1
        i+=1
    elif B!=0:
        SUM+=0
        B-=1
        i+=1
    elif C!=0:
        SUM-=1
        C-=1
        i+=1
print(SUM)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
line=input().split()
line=[int(a) for a in line]
ans=0
if line[0]>=line[3]:
  ans=1*line[0]
elif line[0]+line[1]>=line[3]:
  ans=1*line[0]
else:
  minus=line[3]-line[0]-line[1]
  ans=1*line[0]-minus
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
A, B, C, K = map(int, input().split())
c = 0
if K <= A:
    c += A
    print(c)
    sys.exit()
else:
    c += A
    K -= A
if K <= B:
    print(c)
    sys.exit()
else:
    K -= B
    c -= K
    print(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(2*A-B-K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
for c in range(C):
    for b in range(B):
        for a in range(A):
            if a + b + c == K:
                print(a-c)
                exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
# 入力をintにして変数に格納
a, b, c, k = map(int, input().split())

# KとA,Bの大きさに応じて場合分けして最大値計算
if( a+b >= k ):
    max = k

elif( a+b <= k ):
    max = a - ( k - a - b )

else:
    sys.exit(1)

# 結果を出力
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if k > 0:
  ans -= c - k

print(ans)

Submission status: Wrong Answer

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

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

if k - b > 0:
  ans -= c - k

print(ans)

Submission status: Wrong Answer

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

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

if k - b > 0:
  ans -= c - k

print(ans)

Submission status: Wrong Answer

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

S = A+B+C
result = 0

if ( K > (A+B) ):
    result = A*(1) + (K-(A+B))*(-1)
elif ( (A+B) >= K ):
    result = A*(1)

print(result)

Submission status: Wrong Answer

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

S = A+B+C
result = 0

if ( K > (A+B) ):
    result = A*(1) + (S-(A+B))*(-1)
elif ( (A+B) >= K ):
    result = A*(1)

print(result)

Submission status: Wrong Answer

Solution code:
l = list(map(int,input().split(' ')))
x_1 = l[0]
x_0 = l[1]
x_neg = l[2]
K = l[3]
if (K<=x_1):
  print(x_1)
elif (K-x_1<=x_0):
  print(x_1)
else :
  print(x_1 -(K-x_1-x_0))

Submission status: Wrong Answer

Solution code:
ABCK = input()
key = ['A', 'B', 'C', 'K']
ABCK = [int(i) for i in list(ABCK.split())]
ABCK = {k: v for k, v in zip(key, ABCK)}
sum = 0

if ABCK['A'] > ABCK['K']:
  sum = ABCK['K']
else:
  if ABCK['A'] + ABCK['B'] >= ABCK['K']:
    sum = ABCK['A']
  else:
    K = ABCK['K'] - (ABCK['A'] + ABCK['B'])
    if ABCK['A'] - K < 0:
      sum = 0
    else:
      sum = ABCK['A'] - K
print(sum)

Submission status: Wrong Answer

Solution code:
# abc167 b
a, b, c, k = [int(i) for i in input().split()]
ans = 0
if k < a:
    ans = 0
elif k < a + b:
    ans = a
else:
    ans = a - (k-(a+b))
print(ans)

Submission status: Wrong Answer

Solution code:
# abc167 b
a, b, c, k = [int(i) for i in input().split()]
ans = 0
if k < a:
    ans = 0
elif k < a + b:
    ans = a
else:
    ans = a - (k-(a+b))

Submission status: Wrong Answer

Solution code:
ABCK = input()
key = ['A', 'B', 'C', 'K']
ABCK = [int(i) for i in list(ABCK.split())]
ABCK = {k: v for k, v in zip(key, ABCK)}
sum = 0
print(ABCK)

if ABCK['A'] > ABCK['K']:
  sum = ABCK['K']
else:
  if ABCK['A'] + ABCK['B'] >= ABCK['K']:
    sum = ABCK['A']
  else:
    K = ABCK['K'] - (ABCK['A'] + ABCK['B'])
    if ABCK['A'] - K < 0:
      sum = 0
    else:
      sum = ABCK['A'] - K
print(sum)

Submission status: Wrong Answer

Solution code:
ABCK = input()
key = ['A', 'B', 'C', 'K']
ABCK = [int(i) for i in list(ABCK.split())]
ABCK = {k: v for k, v in zip(key, ABCK)}
sum = 0
print(ABCK)

if ABCK['A'] > ABCK['K']:
  sum = ABCK['K']
else:
  if ABCK['A'] + ABCK['B'] >= ABCK['K']:
    sum = ABCK['A']
  else:
    if ABCK['A'] - ABCK['C'] < 0:
      sum = 0
    else:
      sum = ABCK['A'] - ABCK['C']
print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if k<=a:
    result = k
elif k<=a+b:
    result = a
elif k<=a+b+c:
    result = a-k

print(result)

Submission status: Wrong Answer

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

if k<=a:
    result = k
elif k<=a+b:
    result = a
elif k<=a+b+c:
    result = a-c

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

elif a < k <= a+b:
    print(a)

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

if a <= k:
    print(a)

elif a < k <= a+b:
    print(a)

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
list = input().split()
if int(list[0]) > int(list[3]):
  print(int(list[3]))
elif int(list[0]) + int(list[1]) > int(list[3]):
  print(int(list[0]))
else:
  print(int(list[0]) - int(list[2])+int(list[3]))

Submission status: Wrong Answer

Solution code:
list = input().split()
if int(list[0]) > int(list[3]):
  print(int(list[3]))
elif int(list[0]) + int(list[1]) > int(list[3]):
  print(int(list[0]))
else:
  print(int(list[0]) - int(list[2]))

Submission status: Wrong Answer

Solution code:
list = input().split()
if int(list[0]) > int(list[3]):
  print(int(list[3]))
else:
  print(int(list[0]))

Submission status: Wrong Answer

Solution code:
src = list(map(lambda x : int(x), input().split(' ')))
dst = 0
k = src[3]
dst += (src[0] if src[0] <= k else k)
k -= dst
if k != 0:
  k -= (src[1] if src[1] <= k else k)
if k != 0:
  dst -= (src[1] if src[1] <= k else k)
  
print(dst)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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< K and A+B>=K:
  print(A)
elif A+B<K and A+B+C>=K:
  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())
r = min(a,k)
k = k - a
if k > 0:
    k = k - b
    if k > 0:
        r -= min(r,k)
print(r)

Submission status: Wrong Answer

Solution code:
a, b, c, k = [int(i) for i in 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 = [int(i) for i in input().split()]

ans = 0

if k == 0:
    ans = 0
elif a >= k or a + b >= k:
    ans = a
else:
    ans = a - (k - a - b)

print(ans)

Submission status: Wrong Answer

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

ans = 0

if a >= k or a + b >= k:
    ans = a
else:
    ans = a * 2 + b - k

print(ans)

Submission status: Wrong Answer

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

ans = 0

if a >= k or a + b >= k:
    ans = a
else:
    ans = 0

print(ans)

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

Submission status: Wrong Answer

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

sum = 0

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

print(sum)

Submission status: Wrong Answer

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

sum = 0

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

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def verify_sum(a,b,c,k):
    if k == a:
        print(a)
        return

    num_cards = a + b

    if k > num_cards:
        print(a - (k-num_cards))
    else:
        print(a)

verify_sum(a,b,c,k)

Submission status: Wrong Answer

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


def verify_sum(a,b,c,k):
    if k == a:
        print(a)
        return

    num_cards = a + b

    if k > num_cards:
        print(a - (min((k-a-b), c)))
    else:
        print(a)

verify_sum(a,b,c,k)

Submission status: Wrong Answer

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


def verify_sum(a,b,c,k):
    if k == a:
        print(a)
        return

    num_cards = a + b

    if k > num_cards:
        print(a - (min(k - num_cards, c)))
    else:
        print(a)

verify_sum(a,b,c,k)

Submission status: Wrong Answer

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


def verify_sum(a,b,c,k):
    if k == a:
        print(a)
        return

    num_cards = a + b

    if k > num_cards:
        print(a - (k - num_cards))
    else:
        print(a)

verify_sum(a,b,c,k)

Submission status: Wrong Answer

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


def verify_sum(a,b,c,k):
    if k == a:
        print(a)
        return

    num_cards = a + b

    if k > num_cards:
        print(c - num_cards)
    else:
        print(a)

verify_sum(a,b,c,k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

nums = []
nums.append(A)
nums.append(K - A)
nums.append(nums[1] - B)

for i in range(3):
    if nums[i] < 0:
        nums[i] = 0

print(nums[0] - nums[2])

Submission status: Wrong Answer

Solution code:
i = input()
j = i.split(" ")

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

s = 0

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

Submission status: Wrong Answer

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

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

    print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int,input().split())
sum = a+b+c; sub = abs(sum - k)
mul = (a*1)+0+((-1)*c)
print(mul+sub)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i1 = int(b[0])
i2 = int(b[1])
i3 = int(b[2])
i4 = int(b[3])

S = 0

if i1 <= i4 :
    
    S += i1 * 1 #Sの計算
    
    i4 -= i1 #カウント数の更新
    
    if i2 <= i4 :
        i4 -= i2
        # Sは変化せず
        if i3 <= i4 :
            i4 -= i3
            S -= i4
        else :
            S -= i4
    else :    
        pass
    
else : #i1 > i4
    S =i1-i4 #終了 
    pass

    
print(S)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    num = list(map(int, input().split()))

    if (num[3] == 0):
        print(0)
    else:
        print(num[0] - num[3] + num[0] + num[1])

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    num = list(map(int, input().split()))

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

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    num = list(map(int, input().split()))
    
    if (num[3] <= num[0] + num[1]):
        print(num[0])
    else:
        print(num[0] - num[3] + num[0] + num[1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

a=stdin.readline().split()
A=int(a[0]) #1
B=int(a[1]) #0
C=int(a[2]) #-1
K=int(a[3])

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

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = (int(x) for x in input().split())
if A >= K:
    ans = A
else:
    ans = A
    tmp = K - A
    if B >= tmp:
        pass
    else:
        tmp = tmp - B
        ans += tmp * (-1)
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, K = (int(x) for x in input().split())
if A >= K:
    ans = A
else:
    ans = A
    tmp = K - A
    if B >= tmp:
        pass
    else:
        tmp = tmp + B * (-1)
        ans += tmp
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
oneCard, zeroCard, miniusOneCard, getCardNum = map(int, input().split())

if oneCard >= getCardNum: print(oneCard)
elif oneCard + zeroCard >= getCardNum: print(oneCard)
else: print(oneCard - (getCardNum - oneCard - zeroCard))

Submission status: Wrong Answer

Solution code:
oneCard, zeroCard, miniusOneCard, getCardNum = map(int, input().split())

if oneCard > getCardNum: print(oneCard)
elif oneCard + zeroCard > getCardNum: print(oneCard)
else: print(oneCard - (getCardNum - oneCard - zeroCard))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


"""
print(a)
print(b)
print(c)
print(k)
"""
if a >= k:
    print(a)

elif (a + b) >= k:
    print(a + 0)

else:
    print(a - (k - a - b))

Submission status: Wrong Answer

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


"""
print(a)
print(b)
print(c)
print(k)
"""
if a >= k:
    print(a)

elif (a + b) >= k:
    print(a)

else:
    print(a - (k - a - b))

Submission status: Wrong Answer

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

    if k <= a:
        print(k)
        exit

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    if k < a or k - a < b:
        print(k)
        exit
    
    print(a - (k - a - b))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

for kk in range(k):
    if a >= k:
        print(a)
    elif a + b >= k:
        print(a)
    else:
        print(a-c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def test(a,b,c,k):
	if k<=a:
		return k
	elif k<= a+b:
		return k
	else:
		return a-(k-a-b)


a,b,c,k = list(map(int, input().split(" ")))
print(test(a,b,c,k))

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