Problem:


Score : 200 points

Problem Statement

We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.

We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Constraints

All values in input are integers.

0 \leq A, B, C

1 \leq K \leq A + B + C \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

A B C K

Output

Print the maximum possible sum of the numbers written on the cards chosen.

Sample Input 1

2 1 1 3

Sample Output 1

2

Consider picking up two cards with 1s and one card with a 0.
In this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.

Sample Input 2

1 2 3 4

Sample Output 2

0

Sample Input 3

2000000000 0 0 2000000000

Sample Output 3

2000000000



Sample input:
2 1 1 3


Sample output:
2

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans-K)

Submission status: Wrong Answer

Solution code:
a,b,c,k=[int(x) for x in input().split()]
count=0
if a>=k:
  count+=a
  print(count)
else:
  count+=a
  k-=a
  if b>=k:
    print(count)
  else:
    k-=b
    count-=k
    print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if i[3]<=i[0]+i[1]:
    print(i[3])
else:
    ans=i[0]-i[3]+i[0]+i[1]
    print(ans)

Submission status: Wrong Answer

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

if i[3]<=i[0]+i[1]:
    print(i[0])
else:
    ans=i[0]-i[3]+i[0]+i[1]
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
A, B, C, K = map(int,readline().split())
count = 0

if A >= K:
	print(K)
	sys.exit()

while(K>0):
	if A != 0:
		count += A
		K -= A
		A = 0
	elif B != 0:
		K -= B
		B = 0
	else:
		count -= K
		K = 0
			
print(0 if count<= 0 else count)

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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
A, B, C, K = map(int,readline().split())
count = 0
if A >= K:
	print(K)
	sys.exit()

while(K>0):
	if A >= 1:
		count += A
		K -= A
		A = 0
		continue
	elif B > A:
		K -= B
		B = 0
		continue
	else:
		count -= K
		K = 0	
print(0 if count<= 0 else count)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
A, B, C, K = map(int,readline().split())
count = 0
if A >= K:
	print(K)
	sys.exit()

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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
A, B, C, K = map(int,readline().split())
count = 0
if A >= K:
	print(K)
	sys.exit()

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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
A, B, C, K = map(int,readline().split())
count = 0
if A >= K:
	print(K)
	sys.exit()
else:
	while(K>0):
		if A >= 1:
			count += A
			K -= A
			A = 0
		elif B > A:
			K -= B
			B = 0
		else:
			count -= C
			K -= C		
print(0 if count<= 0 else count)

Submission status: Wrong Answer

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

ans = 0
if a >= k:
    print(a)
elif a + b >= k:
    print(a)
else:
    for _ in range(k):
        if a > 0:
            ans += 1
            a -= 1
        elif b > 0:
            b -= 1
        elif c > 0:
            ans -= 1
            c -= 1
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
for _ in range(k):
    if b == 0 and c == 0:
        ans += a
        break
    elif a == 0 and c == 0:
        break
    elif b == 0 and a == 0:
        ans -= c
        break

    if a > 0:
        a -= 1
        ans += 1
    elif b > 0:
        b -= 1
    elif c > 0:
        c -= 1
        ans -= 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def actual(a, b, c, k):
    if a + b >= k:
        return a

    return a - (k - a - b)



print(actual(a, b, c, k))

Submission status: Wrong Answer

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


def actual(a, b, c, k):
    if a >= k:
        return a
    else:
        k -= a

    if b >= k:
        return a
    else:
        k -= b

    return a - k

  
print(actual(a, b, c, k))

Submission status: Wrong Answer

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

print(a-(1*(k-a-b)))

Submission status: Wrong Answer

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

if K - (A + B) > 0:
    # C を取る
    score = A - (K - (A + B))
else:
    # C を取らない
    score = max(K, A)

print(score)

Submission status: Wrong Answer

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

if K - (A + B) > 0:
    # C を取る
    score = A - (K - (A + B))
else:
    # C を取らない
    score = A

print(score)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
step1 = K-A
step2 = step1 - B
step3 = step2 - C
if step1 <= 0:
    print(K)
elif step2 <= 0:
    print(K)
else:
    print(A-step2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag_A=False
flag_B=False
flag_C=False

if K<=A:
  flag_A=True
elif A<K and K<=A+B:
  flag_B=True
elif A+B<K and K<=A+B+C:
  flag_C=True
  
if flag_A==True or flag_B==True:
  print(A)
elif flag_C==True:
  print(A-(K-A-B))

Submission status: Wrong Answer

Solution code:
a,b,c,d= map(int,input().split())
e = min(a,d)
d = -e
f = min(b,d)
d = -f
g = d
ans = e-g
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d= map(int,input().split())
if a+b >=d or  (b==0 and c == 0) :
    print(a)
    exit()
while d>0 :
  d = d-1
  if a != 0:
   a = a-1
  elif a == 0:
    b = b-1
  elif b == 0 :
    c = c-1
print(d)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    num = A
    for i in range(K-A-B):
        num -= 1
    print(num)
    

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

main()

Submission status: Wrong Answer

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

maxi = a

if a + b < num:
  maxi = a -  (num - (a + b))
  
print(maxi)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, k = map(int, input().split())
    res = 0
    if k-a >= 0:
        res += a
    if k-a-b >= 0:
        res += 0
    if k-a-b > 0:
        res += (k-a-b)*-1
    print(res)
                
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
# 4つの入力
a = input()

# スペースで区切り処理
inputs = a.split(' ')

# A,B,C,Kに代入
A = int(inputs[0])
B = int(inputs[1])
C = int(inputs[2])
K = int(inputs[3])

# 最終的結果の数字
i = int(0)

# 残りの変数
left = int(0)

# パターン1-1
# K（取る枚数）がA(１のカード)より多い時、A（1のカード）枚取り、
# left(残りの取る枚数)に代入する
if K >= A:
        left = K - A
        i = i + A
        # print(f'1-1,残り枚数 {left}')
        # print(f'1-1,結果数 {i}')

# パターン2-1
# left(残り枚数)がB(０のカード)より多い時B(０のカード)枚取る
# leftに残りの枚数を代入する
        if left >= B:
            left = left - B
            # print(f'2-1残り枚数 {left}')
            # print(f'2-1結果数 {i}')

#パターン3-1
#left(残り枚数)より多い時C(-1のカード)をleft(残り枚数)枚取る
            if left > 0:
                i = i - left
                # print(f'3-1結果数{i}')
                print(i)


#パターン3-2
#C(-1)のカードをleft(残り枚数)枚とる（終了）
            else :
                    left = left - left
                    # print(f'3-2結果数{i}')
                    print(left)
#パターン2-2
# B(0のカード)がleft(残り枚数)より多い時B(0のカード)をleft(残り枚数)枚取る（終了）
        elif B > left:
            # print(f'2-2結果数{i}')
            print(i)

# パターン1-2
# A(１のカード)がK(取る枚数)より多い時K枚取る（終了）
elif A > K:
    i = i+A
    # print(f'1-2結果数{i}')
    print(i)

Submission status: Wrong Answer

Solution code:
# 4つの入力
a = input()

# スペースで区切り処理
inputs = a.split(' ')

# A,B,C,Kに代入
A = int(inputs[0])
B = int(inputs[1])
C = int(inputs[2])
K = int(inputs[3])

# 最終的結果の数字
i = int(0)

# 残りの変数
left = int(0)

# パターン1-1
# K（取る枚数）がA(１のカード)より多い時、A（1のカード）枚取り、
# left(残りの取る枚数)に代入する
if K >= A:
        left = K - A
        i = i + A
        # print(f'1-1,残り枚数 {left}')
        # print(f'1-1,結果数 {i}')

# パターン2-1
# left(残り枚数)がB(０のカード)より多い時B(０のカード)枚取る
# leftに残りの枚数を代入する
        if left >= B:
            left = left - B
            # print(f'2-1残り枚数 {left}')
            # print(f'2-1結果数 {i}')

#パターン3-1
#left(残り枚数)より多い時C(-1のカード)をleft(残り枚数)枚取る
            if left > 0:
                for a in range(left):
                 i-=1
                # print(f'3-1結果数{i}')
                print(i)


#パターン3-2
#C(-1)のカードをleft(残り枚数)枚とる（終了）
            else :
                    left = left - left
                    # print(f'3-2結果数{i}')
                    print(left)
#パターン2-2
# B(0のカード)がleft(残り枚数)より多い時B(0のカード)をleft(残り枚数)枚取る（終了）
        elif B > left:
            # print(f'2-2結果数{i}')
            print(i)

# パターン1-2
# A(１のカード)がK(取る枚数)より多い時K枚取る（終了）
elif A > K:
    i = i+A
    # print(f'1-2結果数{i}')
    print(i)

Submission status: Wrong Answer

Solution code:
# 4つの入力
a = input()

# スペースで区切り処理
inputs = a.split(' ')

# A,B,C,Kに代入
A = int(inputs[0])
B = int(inputs[1])
C = int(inputs[2])
K = int(inputs[3])

# 最終的結果の数字
i = int(0)

# 残りの変数
left = int(0)

# パターン1-1
# K（取る枚数）がA(１のカード)より多い時、A（1のカード）枚取り、
# left(残りの取る枚数)に代入する
if K >= A:
        left = K - A
        i = i + A
        # print(f'1-1,残り枚数 {left}')
        # print(f'1-1,結果数 {i}')

# パターン2-1
# left(残り枚数)がB(０のカード)より多い時B(０のカード)枚取る
# leftに残りの枚数を代入する
        if left >= B:
            left = left - B
            #print(f'2-1残り枚数 {left}')
            #print(f'2-1結果数 {i}')

#パターン3-1
#C（-1のカード）がleft(残り枚数)より多い時C(-1のカード)をleft(残り枚数)枚取る
            if left >= 0:
                for a in range(left):
                 i-=1
                # print(f'3-1結果数{i}')
                print(i)


#パターン3-2
#C(-1カード)がleft(残り枚数)より多い時C(-1)のカードをleft(残り枚数)枚とる（終了）
            else :
                    left = left - left
                    # print(f'3-2結果数{i}')
                    print(left)
#パターン2-2
# B(0のカード)がleft(残り枚数)より多い時B(0のカード)をleft(残り枚数)枚取る（終了）
        elif B > left:
            # print(f'2-2結果数{i}')
            print(i)

# パターン1-2
# A(１のカード)がK(取る枚数)より多い時K枚取る（終了）
elif A > K:
    i = i+A
    # print(f'1-2結果数{i}')
    print(i)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


A_C = min(A,K)
K -= A
B_C = min(B,K)
K -= B
C_C = min(C,K)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def calc(K,d,p):
    sum = 0
    if(K > d):
        sum = p * d
    else:
        sum = p * K
    
    return sum,d


def resolve():
    data = [int(i) for i in input().split()]
    sum = 0
    K = data[3]
    for i in range(3):
        add,count= calc(K,data[i],1 - i)
        sum += add
        K -= count
        if(K == 0):
            break    
    print(sum) 
resolve()

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

Submission status: Wrong Answer

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

if k >= a:
    print(k)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min(A, K) + min(0, (A + B) - K )

Submission status: Wrong Answer

Solution code:
def main():

    A, B, C, K = map(int, input().split())
    if K <= A:
        return A
    elif K <= A+B:
        return A
    else:
        return A - (K-A-B)
        

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
#ABC168-B

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans=0

while a>0 and k>0:
    ans+=1
    a-=1
    k-=1
    if k==0:
        print(ans)
while b>0 and k>0:
    b-=1
    k-=1
    if k==0:
        print(ans)
if k>0:
    ans=ans-c
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
if k > a and k-a > b:
    ans = a + (k - a - b) * -1
elif k >= a:
    ans = a
else:
    ans = a-k

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(A - max(0, K - A - B))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
l = list(map(int,input().split()))
res = 0
k = l[3]
r = -1 
for i in range (3) :
  
  if res + l[i] <= k :
    res += l[i]
  else: 
    r = i
    break
d = res - k
if r != 2:
  print(res)
else :
  print(res -d)

Submission status: Wrong Answer

Solution code:
# 4つの入力
a = input()

# スペースで区切り処理
inputs = a.split(' ')

# A,B,C,Kに代入
A = int(inputs[0])
B = int(inputs[1])
C = int(inputs[2])
K = int(inputs[3])

# 最終的結果の数字
i = int(0)

# 残りの変数
left = int(0)

# パターン1-1
# K（取る枚数）がA(１のカード)より多い時、A（1のカード）枚取り、
# left(残りの取る枚数)に代入する
if K >= A:
        left = K - A
        i = i + A
        # print(f'1-1,残り枚数 {left}')
        # print(f'1-1,結果数 {i}')

# パターン2-1
# left(残り枚数)がB(０のカード)より多い時B(０のカード)枚取る
# leftに残りの枚数を代入する
        if left >= B:
            left = left - B
            # print(f'2-1残り枚数 {left}')
            # print(f'2-1結果数 {i}')

#パターン3-1
#C（-1のカード）がleft(残り枚数)より多い時C(-1のカード)をleft(残り枚数)枚取る
            if left >= C:
                i = i + -C
                # print(f'3-1結果数{i}')
                print(i)

#パターン3-2
#C(-1カード)がleft(残り枚数)より多い時C(-1)のカードをleft(残り枚数)枚とる（終了）
            elif C > left:
                    i = i - left
                    # print(f'3-2結果数{i}')
                    print(i)
#パターン2-2
# B(0のカード)がleft(残り枚数)より多い時B(0のカード)をleft(残り枚数)枚取る（終了）
        elif B > left:
            # print(f'2-2結果数{i}')
            print(i)

# パターン1-2
# A(１のカード)がK(取る枚数)より多い時K枚取る（終了）
elif A > K:
    i = i+A
    # print(f'1-2結果数{i}')
    print(i)

Submission status: Wrong Answer

Solution code:
inputList = list(map(int, input().split()))
if inputList[3] <= inputList[0] + inputList[1]:
  print(inputList[0])
else:
  print(inputList[0]-(inputList[3]-inputList[0]-inputList[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:
    print(2*a - k - 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(2*a - k - b)

Submission status: Wrong Answer

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

#a=10, b=10, c=10, mai=30
if mai <= a:
  print(mai)
else:
  mai -= a
  if mai <= b:
    print(mai)
  else:
    mai -= b
    ans = a - mai
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed May 27 14:43:56 2020

@author: 17664
"""

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

total = 0
while k:
    if a:
        total += a
        k -= a
        a = 0
    elif b:
        k -= b
        b = 0
    else:
        total -= k
        k = 0
    
print(total)

Submission status: Wrong Answer

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

print(A+B-max(0, K-A-B))

Submission status: Wrong Answer

Solution code:
a,b,c,k = (int(x) for x in input().split())
if a >= k:
    print(a)
elif a + b >= k:
    print(a)
else:
    print(a - (k - (a + b)))
    pass

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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