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:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c,k=mii()


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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d=[int(x) for x in input().split()]
count=a
sum=a
if count==d:
    print(a)
else:
    count=count+b
    if count<d:
        print(sum+((d-count)*-1))
    else:
        print(sum)

Submission status: Wrong Answer

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

ans = 0

zan = K - A

if zan > 0:
    zan = zan - B

if zan > 0:
    print(A - zan)
else:
    print(A)

Submission status: Wrong Answer

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



resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

count = 0

if K >= A:
    count += A
    K -= A
else:
    count = A
    K = 0

if K != 0:
    if K>=B:
        K -= B
    else:
        K= 0
if K != 0:
    count -= K

print(count)

Submission status: Wrong Answer

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

ans = 0
if A + B >= K:
    ans = K - B
else:
    K -= A + B
    ans = A - K

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if(K<=A):
  point=A
  print(point)
  sys.exit()
else:
  point+=A
  K-=A

if(K<=B):
  print(point)
  sys.exit()
else:
  K-=B
  point-=K
  print(point)

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


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

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

    print(ans)


if __name__ == '__main__':
    main()

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

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=map(int,input().split())
if A+B>=K:
    print(1*A)
else:
    print(1*A-1*(K-A-B))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max = 0

if a <= k:
    max = a
    k -= a
    if b <= k:
        k -= b
        if 0 < k:
            max -= k

else:
    max = a


print(max)

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

print(ans)

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    a,b,c,k = map(int,input().strip().split())
    # print( a-max(0,k-a-b)  )
    if k>a+b:
        print(2*a+b-k)
    else:
        print(a)


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

Submission status: Wrong Answer

Solution code:
import sys

a,b,c,k=list(map(int,input().split()))
sum=0
if(a>=k):
    print(a)
    sys.exit()
else:
    sum=a
if(b>=k-a):
    print(a)
    sys.exit()
else:
    sum=sum-(k-a-b)
    print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

weight = [1, 0, -1]

sumAns = 0

for i in range(3):
    sumAns += lNum[i] * weight[i] if lNum[i] <= lNum[3] else lNum[3] * weight[i]
    lNum[3] -= lNum[i]
    
print(sumAns)

Submission status: Wrong Answer

Solution code:
lis=list(map(int,input().split()))
A=lis[0]
B=lis[1]
C=lis[2]
K=lis[3]
ans=0
if(A>=K):
    ans=A
elif(A+B>=K):
    ans=A
else:
    c=K-(A+B)
    ans=A-c
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
ans += A * 1
K -= A
if K <= 0:
    print(ans)
    exit()

ans += min(K, B) * 0
K -= B
if K <= 0:
    print(ans)
    exit()

ans += K * -1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
end = False
if a < k:
    sum+=a
    k-=a
else:
    sum=a
    end=True

if end==False and b < k:
    k-=b
else:
    end=True

if end==False:
    sum-=k
     
print(sum)

Submission status: Wrong Answer

Solution code:
import sys

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

cnt=0


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

if k<=(a+b):
  print(a)
  sys.exit()


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

Submission status: Wrong Answer

Solution code:
string=input("")
li=string.split()
a=eval(li[0])
b=eval(li[1])
c=eval(li[2])
k=eval(li[3])
if(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())

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

Submission status: Wrong Answer

Solution code:
A, B, C, k = map(int, input().split())
r = A
_k = k - A - B

if _k > 0:
    r -= _k

print(r)

Submission status: Wrong Answer

Solution code:
def ABC_167_B():
    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))


if __name__ == '__main__':

    ABC_167_B()

Submission status: Wrong Answer

Solution code:

ABCK = input().split()

A= int(ABCK[0].strip())
B= int(ABCK[1].strip())
C= int(ABCK[2].strip())
K= int(ABCK[3].strip())


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

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

if b < k:
    k -= b
elif k <= b:
    print(ans)
    exit()

ans += -1*k
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, K: int):
    ans = 0
    if K >= A:
        ans += A
    if K >= A + B:
        ans += min(K - (A + B), C) * -1
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if K >= A:
    a = A
else:
    print(K)
    exit()

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

print(a+c)

Submission status: Wrong Answer

Solution code:


import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

"""
# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = map(int,readline().rstrip().split()) # １行に複数の数値
A = list(map(int,readline().rstrip().split()))  # １行に複数の数値（リスト受け取り）
lis = [readline().rstrip().split() for _ in range(n)] # １行に複数の数値(m個)かつ、n行続く場合（出力は二次元リスト：[['1', '2'], ['4', '5']]）

# 一行に文字列が一個 * n行
s_lis=[readline().rstrip().decode() for _ in range(n)] # .decodeはバイト列から文字列へ変換
# 一行に文字列が一個 * n行で文字列をアルファベット順に変換
s_lis=["".join(sorted(readline().rstrip().decode())) for _ in range(n)]
# 一行に文字列が複数個 * n行
s_lis=[readline().rstrip().split().decode() for _ in range(n)] # .decodeはバイト列から文字列へ変換

# 一行に数値が一個 * n行
s_lis=[int(readline().rstrip()) for _ in range(n)] 
# 一行に数値が複数個 * n行
s_lis=[int(readline().rstrip().split()) for _ in range(n)]

# dとAの行が交互に並んでいる場合
s = sys.stdin.readlines()
n, k=map(int, s[0].split())
d=[]
A=[]
for i in s[1:2*k:2]:
    d.append(int(i))
for i in s[2:2*k+1:2]:
    A.append(list(map(int, i.split())))
"""

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

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:
if __name__ == "__main__":
    
    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:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

ans = 0
if K <= A:
    print(K)
    quit()
K -= A
ans = A
if K <= B:
    print(ans)
    quit()
K -= B
ans -= C - K - 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
A,B,C,K = LI()
ans = A
if A+B<=K:
    ans -= K-(A+B)
print(ans)

Submission status: Wrong Answer

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

print(counter)

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:
# -*- coding: utf-8 -*-
import numpy as np

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

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

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

Submission status: Wrong Answer

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

ans = 0

while a > 0:
    if k < 1:
      break
    #if a < 1:
    #  break

    ans += 1
    k -= 1
    a -= 1
    

while b > 0:
    if k < 1:
      break
    #if b < 1:
    #  break
    
    b -= 1
    k -= 1
    

while c > 0:
    if k < 1:
      break
    #if b < 1:
    #  break
    
    ans -= 1
    k -= k
    
print(ans)

Submission status: Wrong Answer

Solution code:
all = input()
A = int(all.split(' ')[0])
B = int(all.split(' ')[1])
K = int(all.split(' ')[3])
print(A*2+B-K)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

A,B,C,K=(int(x) for x in input().rstrip('\n').split())
res = A
if A<K:
  K-=A
  if B<K:
    K -= B
    res -= K
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
cnt = 0
ans += A
cnt += A
if cnt >= K:
    ans = K
    print(ans)
    sys.exit()
cnt += B
if cnt >= K:
    print(ans)
    sys.exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

s=K
ans = 0

s-=A
ans+=A

if (s>0):
    s-=B
    if (s>0):
       ans -= s

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0

if K - A >= 0:
    ans += A
    K -= A

K -= B

if K > 0:
    if K-C >= 0:
        ans -= C
    else:
        ans -= K

print(ans)

Submission status: Wrong Answer

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

X = K - A
Y = K - A - B
Z = 0

if X >= 0:
    Z += A
    if Y > 0:
        Z -= Y

print(Z)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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



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

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

Submission status: Wrong Answer

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

if 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())
a_=min(a,k)
sum_=k-a
res=a_*1
b_=min(sum_,b)
sum_-=b
res+=b_*0
c_=min(sum_,c)
res+=(-1)*c_
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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 - c
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

count = 0

if K >= A:
    count += A
    K -= A
else:
    count = A
    K = 0
    print(count)

if K != 0:
    if K>=B:
        K -= B
    else:
        K= 0
if K != 0:
    count -= K

print(count)

Submission status: Wrong Answer

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:


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

ANS += min([A,K])
K -= A
if K<1:
    print(ANS)
    exit()
K -= B
if K<1:
    print(ANS)
    exit()
ANS -= min([C,K])
print(ANS)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')

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(k)
else:
    print(2*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:
  print(A + B - C)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

# -*- coding: utf-8 -*-

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

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = [int(x) for x in input().split()]
print(min(K, A) - min(K - A - B, C))

Submission status: Wrong Answer

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

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)