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

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

Submission status: Wrong Answer

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

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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    # import math
    # import random
    input = stdin.readline


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  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))
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 mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))

a,b,c,k = mp()
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=list(map(int,input().split()))
now = K
a = min(A,now)
now -= a
if now < 0:
    now = 0
b = min(B,now)
now -= b
if now < 0:
    now = 0
c = now
print(a-c*now)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# @author 

import sys

class BEasyLinearProgramming:
    def solve(self, tc=0):
        a, b, c, k = [int(_) for _ in input().split()]
        print(a - max(0, min(k - a - b, c)))


solver = BEasyLinearProgramming()
input = sys.stdin.readline

solver.solve()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = 0
if K >= A:
  x += A

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

a1 = min(k, a)
k = max(0, k-a)
b1 = min(k, b)
k = max(0, k-b)
c1 = min(k, b)

print(a1 + (c1 * -1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(max(ans, 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# process
ans = 0
if A+B>=K:
    ans = A
else:
    ans = A-(K-A-B)

# output
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
#read=sys.stdin.buffer.read
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
sys.setrecursionlimit(10**6)

def main():
    A, B, C, K = map(int, readline().split())
    if A + B >= K:
        print(A)
    else:
        tmp = K - A - B
        print(A-tmp)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x = [int(x) for x in input().split()]

a = x[0]
b = x[1]
c = x[2]
X = x[3]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a >= k:
  print(int(a))
elif a + b >= 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 >= K:
    print(A)
elif A+B >=K:
    print(K)
elif A+B+C >=K:
    nc = K - A - B
    print(A - nc)
else:
    print(A-C)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)


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


def resolve():

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

resolve()

Submission status: Wrong Answer

Solution code:
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
from collections import deque
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def main():
    a,b,c,k = ints()
    if k<=a:
        print(k)
    elif k<=b:
        print(a)
    elif k<=c:
        print(a+b-k)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b, c, k = [int(i) for i in input().split()]
if a + b <= k:
    print(a - (k - a - b))
else:
    print(max(a, k))

Submission status: Wrong Answer

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



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

print(r)

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

ans = 0

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
    if k==0:
        print(ans);exit()
if k>=b:
    k-=b
    if k==0:
        print(ans);exit()
print(ans-k)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
ans = min(a,k)*1+min(b,k-a)*0+min(c,k-a-b)*(-1)
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:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a, b, c, k = MII()
    if a >= k:
        print(a)
    elif a+b >= k:
        print(a)
    else:
        d = k-(a+b)
        print(a-d)

if __name__ == '__main__':
    main()

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

Submission status: Wrong Answer

Solution code:
a, b, c, k = list(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())
if A+B >= K:
  print(A)
else:
  print(A-(K-A-B))

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D = map(int, input().split())
    ans = 0
    D -= A
    if D <= 0:
        print(A)
        exit()
    D -= B
    
    if D <= 0:
        print(A)
    else:
        print(D - A)
    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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= 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:
import sys
a, b, c, d = map(int, sys.stdin.readline().split())
if a < d:
  if a+b < d:
    print(a-(d-a-b))
  else:
    print(a)
else:
  print(a)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    A, B, C, K = [int(x) for x in input().strip().split()]
    if K <= A + B:
        print(min(K, A))
    else:
        print(A - (B - (K - A - B)))
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
a, b, c, k = map(int, input().split())
if (a + b) > k:
    print(a)
else:
    print((a + b) - min(k, c))

Submission status: Wrong Answer

Solution code:
#!python3.8
# -*- coding: utf-8 -*-
# abc167/abc167_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    A, B, C, K = i2nn()
    if K <= A + B:
        print(A)
    else:
        print(2 * A - K + B)
    return

main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
A,B,C,K = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
ans += min(K,A)
ans -= (K-A-B)
print(ans)

Submission status: Wrong Answer

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

x=k-a-b
y=a-x
print(y)

Submission status: Wrong Answer

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

minus = K - (A+B)
print(A-minus)

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

Submission status: Wrong Answer

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


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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b,c,K = IL()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:



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

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

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int,input().split())
ans=0
ans=A
K-=A
def chk(k):
    if k>0:
        return True
    else:
        return False

if not chk(K):
    print(ans)
    exit()

K-=B
if not chk(K):
    print(ans)
    exit()

ans=ans-K
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, K = list(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(a)
elif a < k <= a + b:
    print(a)
else:
    print(a - (k - a - b))

Submission status: Wrong Answer

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



if __name__ == "__main__":
    main()

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

Submission status: Wrong Answer

Solution code:
a, b, c, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
#n = int(input())
# n, m = list(map(int, input().split()))
if a+b >= k:
    print(a)
else:
    print(a-(k-(a+b)))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	A, B, C, K = getlist()
	if A + B >= K:
		print(A)
	else:
		print(2 * A + B - K)
	




if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys


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


sys.setrecursionlimit(20000000)


def main():
    A, B, C, K = map(int, input().split())
    answer = 0
    if K >= A:
        answer += A
        K -= A
        if K >= B:
            K -= B
            if K > 0:
                answer -= K
    else:
        answer += A
    print(answer)


if __name__ == "__main__":
    main()

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:
#!/usr/bin/env python3


def main() -> None:
    A, B, C, K = rmi()
    sum_ = 0
    if A > K:
        sum_ += A
        K -= A
    else:
        sum_ += K
        K = 0
    if B > K:
        K -= B
    if 0 < K:
        sum -= K
    w(sum_)


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def MS(): return map(str,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

a,b,c,k = MI()

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

Submission status: Wrong Answer

Solution code:
x = sum(list(map(int, input().split(" "))))
print(x)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#N = int(input())
#J,K = map(int,input().split())
#A = list(map(int(input().split())))
#A = [list(map(int(input().split()))) for _ in range(N)]
#for i in range():

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

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

Submission status: Wrong Answer

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

if k <= a:
    print(a)
else:
    minus = max(0, k - a - b)
    print(a - minus)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

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

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b,c,k = myinput()

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,c,k=map(int,readline().split())
    if a>=k:
        print(a)
    elif a+b>=k:
        print(a)
    else:
        n=k-a-b
        print(a-n)
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(a - (k - (a + b)))

Submission status: Wrong Answer

Solution code:
A,B,C,K=list(map(int,input().split()))
now = K
a = min(A,now)
now -= a
b = min(B,now)
now -= b
c = now
print(a-c*now)

Submission status: Wrong Answer

Solution code:
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

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

    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	a, b, c, k = map(int, sys.stdin.readline().split())
	ans = 0
	if k <= a:
		print(a)
	elif k <= a + b:
		print(a)
	elif k <= a + b + c:
		print(a+(k-a-b)*-1)


main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    A, B, C, K = [int(x) for x in input().strip().split()]
    if K <= A + B:
        print(A)
    else:
        print(A - (B - (K - A - B)))
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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