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 = tuple(int(c) for c in input().split(' '))

if A >= K:
    print(A)
    exit()
else:
    bc = K - A  # A < K なのでbc >= 1
    #assert bc >= 1
    if B >= bc:
        if A >= C:
            print(A)
            exit()
        else:
            print(A-abs(bc-C))
    else:
        # B < bc
        cc = bc - B
        #assert cc >= 1
        print(A - cc)
        exit()

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

Submission status: Wrong Answer

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

a=min(K,A)
ans+=1*a
K-=a

b=min(K,B)
ans+=0*b
K-=B

c=min(K,C)
ans+=-1*c
K-=c

print ans

Submission status: Wrong Answer

Solution code:
a,b,c,k=list(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<=a+b+c):
  ans=a-c
elif(a+b+c<k):
  ans=a-c
print(ans)

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 0 < k:
        k -= b
        if 0 < k:
            max -= min(c, k)

else:
    max = a


print(max)

Submission status: Wrong Answer

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

ans = 0

if d > a:
    ans += a
else:
    ans += d

if d-a-b > c:
    ans -= c
else:
    ans -= d-a-b

print(ans)

Submission status: Wrong Answer

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

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

ans = a

if a + b < k:
    ans -= (k - (a + b))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if K == 0:
    print(ans)
    exit()

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

if K == 0:
    print(ans)
    exit()


if K >= C:
    ans += -1 * C
else:
    print(ans - 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)

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

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = [int(e) for e in input().split()]
if(N[3] - N[0] > 0):
    N[3] -= N[0]
    if(N[3] - N[1] > 0):
        N[3] -= N[1]
        ans = N[0] - N[3]
    else:
        ans = N[0]
else:
    ans = N[0]
print(ans)

Submission status: Wrong Answer

Solution code:
abckList = list(map(int, input().strip().split()))
a = abckList[0]
b = abckList[1]
c = abckList[2]
k = abckList[3]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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



resolve()

Submission status: Wrong Answer

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

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 * 2 + B - K)

Submission status: Wrong Answer

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

total = 0

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

if K <= C:
    total -= K
else:
    total -= C
print(total)

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

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:
from sys import stdin
A,B,C,K=list(map(int,(stdin.readline().strip().split())))
if A+B>=K:print(A)
else:print(A-(K-(A+B)))

Submission status: Wrong Answer

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

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

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 input_int_list():
    return [int(thing) for thing in input().split(" ")]

def int_input():
    return int(input())


def print_ans(string):
    print(string)
    exit()

def yes():
    print("Yes")
    exit()

def no():
    print("No")
    exit()

A,B,C,K=input_int_list()

if K<=A:
    print_ans(A)
else:
    if K<=A+B:
        print_ans(A)
    else:
        print_ans(2*A-K+B)

Submission status: Wrong Answer

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

if k>=b:
    k = k-b
else:
    k = 0

print(num-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(max(A + B - C, -1 * K))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
# 1 0 -1 Num
result = 0
if K <= A:
	print(A)
else:
	result = A
	c = K-A
	if c <= B:
		print(result)
	else:
		print(result-(c-B))

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

d=A
if K-A-B>0:
    d=d-(K-A-B)
print(d)

Submission status: Wrong Answer

Solution code:
# S = input()
# N = int(input())
# A, B = map(int, input().split(' '))
# A = list(map(int, input().split(' ')))

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

if A < K:
  result += A
  K -= A
else:
  result = A
  
if B < K:
  K -= B

if C < K:
  result -= C
  K -= C
else:
  result -= K

print(result)

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

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


one = a
zero = k -a 
min = k -a -b

ans = 1*one-1*min
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    a, b, c, k = map(int, input().split())
    ans = 0
    if k < a:
        ans = k
    elif a < k <=  a + b:
        ans = a
    else:
        ans = a- (k - a-b)
    print(ans)

if __name__ == "__main__":
    main() #endline===============================================

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, k=(int(x) for x in input().split())
sum = 0
sum = sum + a
k = k - a
k = k - b
sum = sum + (-1) * k
print(sum)

Submission status: Wrong Answer

Solution code:
import itertools
import math

def solve():
  a, b, c, k = map(int, input().split())
  hoge = [[a,1], [b,0], [c,-1]]
  hoge.sort(reverse = True)
  if hoge[0][0] >= k:
    print(hoge[0][1]*k)
  elif (hoge[1][0]+hoge[0][0]) >= k:
    print(hoge[0][1]*hoge[0][0])
  else:
    print(hoge[0][1]*hoge[0][0]+(k-hoge[1][0]-hoge[0][0])*hoge[2][1])
  return 0

 
if __name__ == "__main__":
  solve()

Submission status: Wrong Answer

Solution code:
import sys, re
import math
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

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

a,b,c,k = MAP()

sum = 0

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

sum -= min(max(0, k), c)

print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation



'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  # [1, 0, 3]

'''

def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''


########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

def main():

    w=1
    j=0
    k=0
    #n=int(input())
    a,b,c,k=map(int, input().split(" "))
    if a+b>=k:
        print(a)
        sys.exit()
    elif a<k:
        print(k)
        sys.exit()
    print(2*a-k+b)
    #r=int(input())
    #dp= [[0]*3 for i in range(5)]#列　行
    #dp用の0の入ったやつ
    #dp= [[0]*(w+1) for i in range(n+1)]#0からwまでのw+1回計算するから
    #print(dp)＃初期条件が入る分計算回数+1列分必要(この場合は判断すべきものの数)
    DP = np.zeros(w+1, dtype=int)#これでも一次元リストが作れる
    exdp=np.zeros((3,4)) # ３×４の２次元配列を生成。2次元ならこう
    #dtypeは指定しないとfloatになる
    #for i in range(n):#ちょっとした入力に便利
    #    a, b = map(int, input().split())
        #dp[i][0] += [a]
        #これだとintとlistをつなぐことになって不適
    #    dp[i] += [a]
    #    dp[i] += [b]
        #これはうまくいく
        #やり方はいろいろあるということ
    #print(dp)


    "1行1つの整数を入力を取得し、整数と取得する"
    #nl=list(map(int, input().split(" ")))#数字の時
    #print(number_list)
    "12 21 332 とか入力する時に使う"
    "1行に複数の整数の入力を取得し、整数として扱う"
    #brray=[list(map(int, input().split(" ")))for i in range(N)
    #print(brray)


    #s=input()
    #a=[int(i) for i in s]#int取るとstrでも行ける
    #print(a)
    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]#内包表記に慣れろ
    #print(pin_l)

    ls = ["a", "b", "c", "d", "e"]


    #print(ls[2:5])
    #スライスでの取得

    #print(ls[:-3])
    #一番左端から右から3番目より左まで取得

    #print(ls[:4:2])
    #スライスで1個飛ばしで取得
    #ないときは左端スタート
    #始点のインデックス番号 : 終点のインデックス番号 : スキップする数+1
    #print(ls[::2])
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
A, B, C, K = (int(i) for i in input().split())  
ans = 0

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

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[2] - ABCK[3]
    print(ABCK[0] - s)

Submission status: Wrong Answer

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

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
abc = []
for i in range(a):
    abc.append(1)
for j in range(b):
    abc.append(0)
for k in range(c):
    abc.append(-1)

print(sum(abc[0:k]))

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

Submission status: Wrong Answer

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

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

res=0

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

print(res)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans=0
tot=0

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

Submission status: Wrong Answer

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

ans = 0

if a > k:
  print(k)
  exit()

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

Submission status: Wrong Answer

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_rpw_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    a, b, c, k = i_map()

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

    k -= a

    k -= b

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

    print(a-k)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if A < K and K > 0:
    ans += A
    K -= A
elif A >= K and K > 0:
    ans += K
    K = 0

if B < K and K > 0:
    K -= B
elif A >= K and K > 0:
    K = 0

if C < K and K > 0:
    ans -= C
    K -= C
elif A >= K and K > 0:
    K = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if b < k:
    k-=b
else:
    print(maxim)
    exit()

print(maxim-k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
    cnt-=left
        
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
arr = input().split(" ")

a = int(arr[0])
b = int(arr[1])
c = int(arr[2])
d = int(arr[3])

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

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

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

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
ans=0
if a<k:
  ans+=a
  k-=a
else:
  ans+=a
  k=0
if b>k and k>0:
  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())
a = A
b = K - A
c = K - B - A
p = [0 if x < 0 else x for x in [a, b, c]]
ans = 0
for i in range(3):
    if i == 0:
        ans += p[0]
    elif i == 2:
        ans -= p[2]
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:
    rest = k - (a + b)
    print(a - rest)

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

Submission status: Wrong Answer

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

if k <= a:
    point += a
elif k > a and (k - a) <= b:
    point += a
elif k > a and (k - a) > b:
    point = a + (-1) * (k - a - b)

print(point)