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

s = 0

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

print(s)

Submission status: Wrong Answer

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

if A > K:
    print(A)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=input().split(' ')

for i in range(len(n)):
  n[i]=int(n[i])

k=n[3]
sum=0
if k > n[0]:
  sum+=n[0]
  k-=n[0]
k-=n[1]
if 0 < k:
  sum-=k
print(sum)

Submission status: Wrong Answer

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

ans = a
k = k - a

if k > 0:
    k = k - b

ans = ans - k

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt=0
left=k

#A
if a > k:
    left=0
    cnt=a
else:
    left-=a
    cnt+=a

if left>0:
    left-=b

if left>0:
    if left > c:
        cnt-=c
    else:
        cnt-=left
    
print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

b += a
c += b

ans = 0

if 0 <= k and k <= a:
    ans += k
elif k <= b:
    ans += a
else:
    ans = a-(k-(c-b))


print(ans)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if k <= a:
    print(k)
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 = [int(i) for i in input().split()]
if k<=a+b:
  print(a)
else:
  print(a-(k-a-b))

Submission status: Wrong Answer

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

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

ret = 0
if k >= a:
    ret += a
    ret += max(k-a, 0) * 0
    ret += max(k-a-b, 0) * (-1)
else:
    ret = a-k

print(ret)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def main():
    a, b, c, k = [int(x) for x in stdin.readline().rstrip().split()]
    if a + b >= k:
        print(a)
    else:
        nokori = k - (a + b)
        print(a - nokori)

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

resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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


def mysum(A, B, C, K):
  if K <= A:
    return(A)
  
  if K <= A+B:
    return(A)
  
  return(A+ -1*(A+B+C-K))
 
print(mysum(A, B, 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-((a+b)-k)*-1)

Submission status: Wrong Answer

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

ans = 0

ans = A
K = K - A

if K > 0:
  K = K - B

if K > 0:
  ans = ans - K

print(ans)

Submission status: Wrong Answer

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    A, B, C, K = mulinputs()
    # 出力
    if K <= A+B:
        print(A)
        exit()
    K -= (A+B)
    print(A-K)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
  a,b,c,k = map(int,input().split())
  
  if k <= a:
    return a
  
  result = a
  k -= a
  
  if k <= b:
    return result
  
  k -= b
  
  return result - k

print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin


def get_result(data):
    A, B, C, K = data
    if (A + B) > K:
        return A
    else:
        return A - (K-(A+B))


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)

Submission status: Wrong Answer

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

A = int(s[0])
B = int(s[1])
C = int(s[2])
K = int(s[3])

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

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


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

Submission status: Wrong Answer

Solution code:

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

print(a-min(k-a-b,c))

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

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, k = [int(i) for i in input().split(" ", 4)]
    s = 0
    if k < a:
        print(k)
        return
    elif k < a+b:
        print(a)
        return
    else:
        print(a - c)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fileinput

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

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

s += a
kk = k - a

if b >= kk:
    print(s)
    exit()

kkk = kk - b

s -= kkk
print(s)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

if K<=A:
    ans = A
else:
    N = K-A
    if N <= B:
        ans = A
    else:
        NN = N - B
        ans = A - NN
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=input().split(' ')

for i in range(len(n)):
  n[i]=int(n[i])

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = list(map(int, input().split(" ")))
sumv = 0
sumv += A
sumv -= (K - A - B)
print(sumv)

Submission status: Wrong Answer

Solution code:
import sys
a, b, c, d = map(int, sys.stdin.readline().split())
if a+b < d:
  print(a-(d-a-b))
else:
  print(a)

Submission status: Wrong Answer

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

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

ans -= max(0, min(c, k))
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print (ans)

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

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

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt = 0

K = K - A
cnt += A

if K > 0:
    K = K - B
if K > 0:
    cnt -= K
        
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18
#list(map(int, stdin.readline().rstrip().split()))
a,b,c,k = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    A, B, C, K = MAP()
    ans = 0
    p = 1
    for i in [A, B, C]:
        ans += p * min(i, K)
        K -= i
        p -= 1

    print(ans)


if __name__ == '__main__':
    main()

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, C, K = LI()

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

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

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

for i in range(k):
    ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def main():
    a, b, c, k = map(int, input().split())
    if k <= a:
        print(a)
    elif k <= a + b:
        print(a)
    else:
        print(a * 2 + b - k)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,c,k=map(int, input().split())
    l=[]
    if k<=a:
        print(k)
    elif a<k<=a+b:
        print(a)
    else:
        print(max(0,a-(k-a+b)))
resolve()

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

an = a if a <= k else a-k
ans = an
k = k - an
if k > 0:
  bn = b if b <= k else b-k
  k = k - bn
if k > 0:
  cn = c if c <= k else k
  ans = ans - cn
print(ans)

Submission status: Wrong Answer

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

c1 = A+B
c2 = A+B+C

if K>c1 and K<c2:
    num = A - (K-A-B)
else:
    num = A

print(num)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

print(a - max(0, (k - a - b)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

A = k-a 
B = A-b 
C = B-c 
print(A-C)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    a = kwargs["a"]
    b = kwargs["b"]
    c = kwargs["c"]
    k = kwargs["k"]

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

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["a"], kwargs["b"], kwargs["c"], kwargs["k"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

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

ans = min(A, K)
K -= A
if K <= 0:
    print(ans)
    sys.exit()

K -= B
if K <= 0:
    print(ans)
    sys.exit()

ans -= min(A, K)

print(ans)