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:
def getls():
    return [ipt for ipt in input().split()]
def getlsi():
    return [int(ipt) for ipt in input().split()]

[a,b,c,k] = getlsi()
#ls = [1]*a + [0] * b+ [-1] * c
#print(sum(ls[:k]))
#print(ls)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

score = 0

if K >= A:
  score += A
  K -= A
else:
  score += K
  if K <= 0:
    print(score)
    exit()
  
if K >= B:
  K -= B
if K <= 0:
  print(score)
  exit()

if K >= C:
  score -= C
else:
  score -= K
if K <= 0:
  print(score)
  exit()

print(score)

Submission status: Wrong Answer

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

score = 0

if K >= A:
  score += A
  K -= A
else:
  score += K

if K >= B:
  K -= B

if K >= C:
  score -= C
else:
  score -= K 

print(score)

Submission status: Wrong Answer

Solution code:
def a():
    s = input()
    t = input()
    if s == t[0:-1]:
        print('Yes')
    else:
        print('No')



def b():
    a, b, c, k = map(int, input().split())
    xa = min(k, a)
    k1 = k - xa
    xb = min(k1, b)
    k2 = k1 - xb
    print(xa - k2)
    

    print(sum)

# def c():

# def d():


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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count=0
if a<k:
    if b<k-a:
        count=a-(k-a-b)
    else:
        count=a
else:
    count=a

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

if k >= b:
    k -= b
else:
    print(ans)

if k >= c:
    ans -= c
    print(ans)
else:
    ans -= k
    print(ans)

Submission status: Wrong Answer

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

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

if a + b >= k:
	print(a)
	sys.exit()
else:
	sum = a - (k - a - b)
	print(sum)

Submission status: Wrong Answer

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

if a + b >= k:
	print(a)
	sys.exit()
else:
	sum = a - (k - a - b)
	print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

xa = min(A,K)
K1 = K -xa
if K1 == 0:
  print(K)
else:
	xb = min(B,K1)
	K2 = K1 -xb
	if K2 == 0:
  		print(K)
	else:
   		print(A-K2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0

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

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

ans += min(c,k) + -1
k -= min(c,k)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

max_value = 0

for _ in range(A):
  if K <= 0:
    print(max_value)
    break
  else:
    K -= 1
    max_value+=1
    
for  _ in range(B):
  if K <= 0:
      print(max_value)
      break
  else:
    K-=1

for _ in range(C):
  if K <= 0:
    print(max_value)
    break
  else:
    K -= 1
    max_value-=1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,K = list(map(int,input().split()))
"""
for n in range(1):
    n = list(map(int,input().split()))
    L.append(n)
"""

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l = list(map(int, input().split()))
p = 0
if(l[0] + l[1] >= l[3]):
    p = l[0]
else:
    p = l[0] - (l[3] - l[0] - l[1])

print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

class abc_167:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        T=input()
        if S==T[:len(S)]:print("Yes")
        else:print("No")
    
    def B(self):
        ABCK=list(map(int,input().split()))
        sum_num=0
        
        if ABCK[3]<=ABCK[0]+ABCK[1]:sum_num=ABCK[3]
        else:sum_num=ABCK[0]-(ABCK[3]-ABCK[0]-ABCK[1])
        
        print(sum_num)
            
    def C(self):
        pass
            
    def D(self):
        
        NK=list(map(int,input().split()))
        A=list(map(int,input().split()))
        stack=[]
        A_memo=[0]*(NK[0]+1)
        flag=False
        
        
        count=0
        stack.append(A[count])
        count+=1
        A_memo[1]=count
        
        max_data = NK[0]+1 if NK[0]<=NK[1] else NK[1]
        
        while(count<max_data):
            data=stack.pop()
            stack.append(A[data-1])
            count+=1
            
            if A_memo[A[data-1]]==0:
                A_memo[A[data-1]]=count
            else:
                loop_val=A[data-1]
                flag=True
                break
            
        #a=count-A[loop_val]
        #b=NK[1]-A[loop_val]
        #print(count-A[loop_val])
        #print(NK[1]-A[loop_val])
        #print((b%a)+A[loop_val]-1)
        ans_stack=[]
        ans_stack.append(A[0])
            
        if flag==True:
            ans=((NK[1]-A[loop_val])%(count-A[loop_val]))+(A[loop_val]-1)
            for i in range(ans):
                ans_data=ans_stack.pop()
                ans_stack.append(A[ans_data-1])
            end=ans_stack.pop()
            print(end)
        else:
            ans=count
            for i in range(ans):
                ans_data=ans_stack.pop()
                ans_stack.append(A[ans_data-1])
            end=ans_stack.pop()
            print(end)
            
            
           
            
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_167()
    obj.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 = list(map(int, input().split()))
b = [1, 0, -1]
c = 0
s = 0
for i in range(a[3]):
  if a[s] == 0:
    s += 1
  a[s] -= 1
  c += b[s]
  if a[s] == 0:
    s += 1

print(c)

Submission status: Wrong Answer

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

res = 0

K = K - A
for b in range(B+1):
    c = K - b
    if c >= 0:
        total = A*1 + b*0 + c*-1
        if res < total:
            res = total
print(res)

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    inp = input()
    data = inp.split(" ")
    data = [int(i) for i in data]
    a = data[0]
    b = data[1]
    c = data[2]
    k = data[3]

    if a > k:
        print(a)
        return

    r = k - a
    score = a

    if b > r:
        print(score)
        return

    r = r - b

    if c > r:
        score -= r
    else:
        score -= c

    print(score)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

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


main()

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

Submission status: Wrong Answer

Solution code:
import itertools
import math
import fractions
import functools

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:
def main():
    a,b,c,k = (int(x) for x in input().split())
    if a >= k: print(a)
    else: print(a - (k-(a+b)))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n = min(a, k)
m = n-((k-a)-b)

print(m)

Submission status: Wrong Answer

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

n = min(a, k)
m = n-(k-(a+b))

print(m)

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:
# input
A, B, C, K = map(int, input().split())

# check
result_score = 0
for score, i in [(1, A), (0, B), (-1, C)]:
        if K <= 0:
               continue 
        
        if K >= i:
            result_score =- score * i
            K -= i
        else:
            result_score =- score * K
            K = 0

print(result_score)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# check
result_score = 0
while K > 0:
        for score, i in [(1, A), (0, B), (-1, C)]:
                while K > 0 or i > 0:
                        result_score += score
                        i -= 1
                        K -= 1

print(result_score)

Submission status: Wrong Answer

Solution code:
a,b,c,k = [int(i) for i 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=(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+b>=k:
  ans=a
else:
  ans=a-(k-(a+b))
print(ans)

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

Submission status: Wrong Answer

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

print(a+a+b-k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

A, B, C, K = map(int, sys.stdin.readline().split())
res = 0
res += min(A, K)
K -= A
if K > 0:
  K -= B
if K > 0:
  res -= min(B, K)
print(res)

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

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())
print(min(A,K)-(0 if K-(A+B)>1 else 1*(K-(A+B))))

Submission status: Wrong Answer

Solution code:
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #ここにコード
    #input
    A, B, C, K = map(int, input().split())

    #output
    #できるだけAを多く取りたい。
    # K <= A
        #point = A
    # A < K <= A+B
        #point = A
    # A+B < K
        #Cの枚数はK - (A+B)
        #point = A - K + (A+B) = 2*A + B - K
    if K <= A+B:
        print(A)
    else:
        print(2*A + B - K)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

else:
    maxvalue = A
    K -= A
    if K <= B:
        print(maxvalue)
    else:
        K -= B
        if K == 0:
            print(maxvalue)
        else:
            print(maxvalue-K)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())  # a 1 b 0 c -1

if K <= A:
    print(K)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

sum = 0

if a[0] >= a[3]:
    sum += -1 * a[3]
else:
    sum += -1 * a[0]

a[3] -= a[0]
a[3] -= a[1]

if a[3] > 0:
    if a[2] > a[3]:
        sum += -1 * a[3]
    else:
        sum += -1 * a[2]

print(sum)

Submission status: Wrong Answer

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

sum = 0

if a[0] >= a[3]:
    sum += -1 * a[3]
else:
    sum += -1 * a[0]

a[3] -= a[0]
a[3] -= a[1]

if a[2] >= a[3]:
    sum += -1 * a[3]
else:
    sum += -1 * a[2]

print(sum)

Submission status: Wrong Answer

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

sum = 0

sum += 1 * a[0]
a[3] -= a[0]
a[3] -= a[1]

if a[2] >= a[3]:
    sum += -1 * a[3]
else:
    sum += -1 * a[2]

print(sum)

Submission status: Wrong Answer

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

sum = 0

sum += 1 * a[0]
a[3] -= a[0]
a[3] -= a[1]

if a[2] >= a[3]:
    sum += -1 * a[0]

print(sum)

Submission status: Wrong Answer

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

sum = 0

sum += 1 * a[0]
a[3] -= a[0]
a[3] -= a[1]

if a[2] < a[3]:
    sum -= 1 * a[0]

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#B
ABCK = input().split(' ')
A = int(ABCK[0]) ; B = int(ABCK[1]) ; C = int(ABCK[2])
K = int(ABCK[3])
if K <= (A + B):
    print(A)
else:
    print(A - (K - A - B))

Submission status: Wrong Answer

Solution code:
#B
ABCK = input().split(' ')
A = int(ABCK[0]) ; B = int(ABCK[1]) ; C = int(ABCK[2])
K = int(ABCK[3])
if K <= (A + B):
    print(K)
else:
    print(A - (K - A - B))

Submission status: Wrong Answer

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

# B - Easy Linear Programming
a, b, c, k = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
#B
ABCK = input().split(' ')
A = int(ABCK[0]) ; B = int(ABCK[1]) ; C = int(ABCK[2])
K = int(ABCK[3])
if K <= (A + B):
    print(K)
else:
    print(A + C * (K - A))

Submission status: Wrong Answer

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

# B - Easy Linear Programming
a, b, c, k = map(int, input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

 
a,b,c,k = map(int,input().split())
z=k-min(k,a)
z=k-min(k,b)
print(a-z)

Submission status: Wrong Answer

Solution code:

 
a,b,c,k = map(int,input().split())
z=k-min(k,a)
if z>0:
    z=k-min(k,b)
print(a-z)

Submission status: Wrong Answer

Solution code:

a,b,c,k = map(int,input().split())
z=k-min(k,a)
if z>0:
    z=z-b
print(a+b*0+z*-1)

Submission status: Wrong Answer

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

x1=int(b[0]) #1
x2=int(b[1]) #0
x3=int(b[2]) #-1
x4=int(b[3]) #k

if x4 <= x1+x2:
	print(x1)

elif x4 <= x1:
	print(x4)

else:
	print(x1-(x4-x1-x2))

Submission status: Wrong Answer

Solution code:
x = [x for x in map(int,input().split())]
A = x[0] # A = 1,B = 0,C = -1 ,k
B = x[1]
C = x[2]
K = x[3]
sum = 0
L = K - A - B
sum += A
sum -= L
print(sum)

Submission status: Wrong Answer

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

x1=int(b[0]) #1
x2=int(b[1]) #0
x3=int(b[2]) #-1
x4=int(b[3]) #k

if x4 <= x1+x2:
	print(x1)

else:
	print(x1-(x4-x1-x2))

Submission status: Wrong Answer

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

x1=int(b[0]) #1
x2=int(b[1]) #0
x3=int(b[2]) #-1
x4=int(b[3]) #k

if x4 <= x1+x2:
	print(x1)

else:
	print(x1-(x3-x1-x2))

Submission status: Wrong Answer

Solution code:

#a,b=(int(x) for x in input().split()) #数値の時




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

if(k<=a):
  print(a*k)
else:
  sum=a
  t=k-a
  if(t<=b):
    print(sum)
    
  else:
    t-=b
    
    
    print(sum-t)

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

Submission status: Wrong Answer

Solution code:
# B - Easy Linear Programming
def main():
    A, B, C, K = map(int, input().split())
    if A + B > K:
        print(A)
    else:
        print(A - (K - A - B))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

#a,b=(int(x) for x in input().split()) #数値の時




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

if(k<=a):
  print(a*k)
else:
  sum=a
  t=k-a
  if(t<=b):
    print(sum)
  else:
    
    
    t2=t-c
    print(sum-c)

Submission status: Wrong Answer

Solution code:
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li():
    return list(map(int, sys.stdin.readline().split()))


def num():
    return map(int, sys.stdin.readline().split())


def nu():
    return int(input())


def find_gcd(x, y):
    while (y):
        x, y = y, x % y
    return x


def lcm(x, y):
    gg = find_gcd(x, y)
    return (x * y // gg)


mm = 1000000007

def solve():
    t = 1
    for tt in range(t):
        a,b,c,d=num()
        if(a+b>=d):
            print(a)
        else:
            z=d-a-b
            print(a-z)

                 


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:

#a,b=(int(x) for x in input().split()) #数値の時




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

if(k<=a):
  print(a*k)
else:
  sum=k
  t=k-a
  if(t<=b):
    print(sum)
  else:
    
    
    t2=t-c
    print(sum-t2)

Submission status: Wrong Answer

Solution code:
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li():
    return list(map(int, sys.stdin.readline().split()))


def num():
    return map(int, sys.stdin.readline().split())


def nu():
    return int(input())


def find_gcd(x, y):
    while (y):
        x, y = y, x % y
    return x


def lcm(x, y):
    gg = find_gcd(x, y)
    return (x * y // gg)


mm = 1000000007

def solve():
    t = 1
    for tt in range(t):
        a,b,c,d=num()
        if(a+b>=d):
            print(d)
        else:
            z=d-a-b
            print(a-z)

                 


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:

#a,b=(int(x) for x in input().split()) #数値の時




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

if(k<=a):
  print(a*k)
else:
  sum=a*k
  t=k-a
  if(t<=b):
    print(sum)
  else:
    
    t2=t-c
    print(sum-c*t2)

Submission status: Wrong Answer

Solution code:
# B - Easy Linear Programming
def main():
    A, B, C, K = map(int, input().split())
    if A + B >= K:
        print(A)
    else:
        print(A - (K - A - B))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if(k<=a):
  print(a*k)
else:
  sum=a*k
  t=k-a
  if(t<=b):
    print(sum+b*t)
  else:
    sum+=b*t
    t2=t-c
    print(sum+c*t2)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

K -= A
xa = min(K,A)
K -= B
xb = min(K,B)
ans = xa - K
print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

ans = 0

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

Submission status: Wrong Answer

Solution code:
a=input().split()
b=[int(i) for i in a]
if (b[0]+b[1])>=b[3]:
    print(b[0])
else:
    print(b[0]-b[2])

Submission status: Wrong Answer

Solution code:
def a():
    s = input()
    t = input()
    if s == t[0:-1]:
        print('Yes')
    else:
        print('No')


def b():
    a, b, c, k = map(int, input().split())
    sum = 0
    k -= a
    if k < 0:
        sum = k
    else:
        sum = a
    print(sum)
    k -= b
    if k >= 1:
        sum -= k
    print(sum)

# def c():

# def d():


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

Submission status: Wrong Answer

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

#標準入力で受け取り配列に入れる
num_line = input().split()

#配列から変数を取り出す
num_one = int(num_line[0])
num_zero = int(num_line[1])
num_mini = int(num_line[2])
num_amount = int(num_line[3])

#num_oneから順に取っていく
if num_one >= num_amount:
    print(num_amount)
elif num_one + num_zero >= num_amount:
    print(num_amount)
else:
    #マイナスの数を計算して保存
    minus_count = num_amount - (num_one + num_zero)
    print(num_one - minus_count)

Submission status: Wrong Answer

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


one = a[0]
zero = a[1]
mone = a[2]
num = a[3]

ans = 0
if one >= num:
    print(num)
else:
    ans += one
    num -= one
    if zero >= num:
        print(ans)
    else:
        num -= zero
        print(num)
        print(one - num)

Submission status: Wrong Answer

Solution code:
def main(a, b, c, k):
    total = 0
    counts = 0
    while counts == k:
        counts += 1
        if a > 0:
            total += 1
            a -= 1
        elif b > 0:
            b -= 1
        else:
            total -= 1
            c -= 1
    return total


if __name__ == '__main__':
    a, b, c, k = tuple(map(int, input().split(' ')))
    print(main(a, b, c, k))

Submission status: Wrong Answer

Solution code:
ipt = "3 1 1 3"
a = list(map(int,input().split()))

one = a[0]
zero = a[1]
mone = a[2]
num = a[3]

ans = 0
if one >= num:
    print(num)
else:
    ans += one
    num -= one
    if zero >= num:
        print(ans)
    else:
        num -= zero
        print(one - mone*num)

Submission status: Wrong Answer

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

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

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

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