Problem:


Score : 200 points

Problem Statement

We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.

We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Constraints

All values in input are integers.

0 \leq A, B, C

1 \leq K \leq A + B + C \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

A B C K

Output

Print the maximum possible sum of the numbers written on the cards chosen.

Sample Input 1

2 1 1 3

Sample Output 1

2

Consider picking up two cards with 1s and one card with a 0.
In this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.

Sample Input 2

1 2 3 4

Sample Output 2

0

Sample Input 3

2000000000 0 0 2000000000

Sample Output 3

2000000000



Sample input:
2 1 1 3


Sample output:
2

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,k = inpl()
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 >= K:
    print(K)
    exit(0)
elif A != 0:
    K = K - A
    total = A

if B >= K:
    print(total)
    exit(0)
elif B != 0:
    K = K - B
    print(total-K)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = map(int, input().split())
#print(a, b, c, k)
ans = 0
if a > k:
    ans += k
    print(ans)
    exit()
if a <= k:
    ans += a
    if (k-(a+b)) >= c:
        ans += c*(-1)
        print(ans)
        exit()
    if (k-(a+b)) < c:
        ans += (k-(a+b))*(-1)
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = map(int, input().split())
#print(a, b, c, k)
ans = 0
if a > k:
    ans += k
    print(ans)
    exit()
if a <= k:
    ans += a
    if (k-(a+b)) > c:
        ans += c*(-1)
        print(ans)
        exit()
    if (k-(a+b)) <= c:
        ans += (k-(a+b))*(-1)
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = map(int, input().split())
#print(a, b, c, k)
ans = 0
if a <= k:
    ans += a
if a > k:
    ans += k
    print(ans)
    exit()
if (k-(a+b)) > c:
    ans += c*(-1)
    print(ans)
    exit()
if (k-(a+b)) <= c:
    ans += (k-(a+b))*(-1)
    print(ans)
    exit()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = map(int, input().split())
#print(a, b, c, k)
ans = 0
if a <= k:
    ans += a
ans += (k-(a+b))*(-1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D = map(int, input().split())
    total = 0
    X = 0
    while X == 0:
        D = D - A
        if D == 0:
            print(A)
            return
        elif D < 0:
            print(A - D)
            return
        else:
            total = A
        D = D - B
        if D <= 0:
            print(total)
            return 
        D = D - C
        if D == 0:
            print(total - C)
            return
        elif D < 0:
            print(total - C + (-1 * D))
            return
    
main()

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D = map(int, input().split())
    total = 0
    minus = 0
    X = 0
    while X == 0:
        D = D - A
        if D < 0:
            minus = D
            print(A - D)
            return
        else:
            total = A
        D = D - B
        if D < 0:
            print(total)
            return 
        D = D - C
        if D <= 0:
            minus = D
            print(total - C + (minus*-1))
            return
        else:
            print(total - D)
    
main()

Submission status: Wrong Answer

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

ans=0

if a>= k:
  print(k)

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

Submission status: Wrong Answer

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

ans=0

if a>= k:
  print(k)

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

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)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

nokori = k - a

if nokori <= 0:
    print(k + nokori)
    sys.exit()

nokori = nokori - b

if nokori <= 0:
    print(a)
    sys.exit()

print(a - nokori)

Submission status: Wrong Answer

Solution code:
import sys

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

nokori_a = k - a

if nokori_a <= 0:
    print(k + nokori_a)
    sys.exit()

nokori_b = nokori_a - b

if nokori_b <= 0:
    print(a)
    sys.exit()

nokori_c = nokori_b - c

if nokori_b <= 0:
    print(a - (nokori_b + nokori_c))
    sys.exit()

print(0)

Submission status: Wrong Answer

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

 
A_num = A
B_num = 0
C_num = 0
if A<K:
  A_num = K
elif K-A-B>0:
  B_num = B
  C_num = K-A-B
else:
  B_num = K-A

  

print(A_num*1+B_num*0+C_num*(-1))

Submission status: Wrong Answer

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

 
A_num = A
B_num = 0
C_num = 0
if K-A-B>0:
  B_num = B
  C_num = K-A-B
else:
  B_num = K-A

  

print(A_num*1+B_num*0+C_num*(-1))

Submission status: Wrong Answer

Solution code:
A,B,C,K=[int(i) for i in input().split()]
if K<A:
    P=K
else:
    P=A
    if A+B<K:
        P-=(K-A+B)
print(P)

Submission status: Wrong Answer

Solution code:
A,B,C,K=[int(i) for i in input().split()]
P=A
if A+B<K:
    P-=(K-A+B)
print(P)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def calc(a,b,c,k):
    if k<=a+b:
        return k
    else:
        return a-(k-a-b)
print(calc(a,b,c,k))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def calc(a,b,c,k):
    if k<=a+b:
        return a
    for i in range(1,c):
        if k==a+b+i:
            return a-i
print(calc(a,b,c,k))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K - A - B > 0:
    print(1 * A - (K - A - B) * 1)

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

Submission status: Wrong Answer

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

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

elif K - A >= 0 and K - A - B < 0:
    print((1 * A))

elif K - A >= 0:
    print(1 * K)

Submission status: Wrong Answer

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

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

elif K - A <= 0:
    print((1 * A))


elif K - A >= 0:
    print(1 * K)

Submission status: Wrong Answer

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

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

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

else:
    print((1 * A) - (1 * C))

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if k <= a + b:
    print(a)
else:
    print(f'{2*a + b - k}')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#
from collections import Counter

k = list(map(int,input().split()))
pick = k[3]
maxi = 0
while pick>0:
        maxi = max(maxi,maxi+k[0]*(1))
        pick = pick-k[0]
        maxi = max(maxi,maxi+k[1]*(0))
        pick = pick-k[1]
        maxi = max(maxi,maxi+k[2]*(-1))
        pick = pick-k[2]


print(maxi)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#
from collections import Counter

k = list(map(int,input().split()))
pick = k[3]
maxi = 0
for i in range(len(k)):
    if(i<pick):
        maxi = max(maxi,maxi+1)
        pick = pick-1
    elif k[1]<(pick-k[i]):
        maxi = max(maxi,maxi+0)
        pick=pick-1
    elif k[2]<(pick-k[i]):
        maxi = max(maxi,maxi-0)
        pick = pick-1


print(maxi)

Submission status: Wrong Answer

Solution code:
#
from collections import Counter

k = list(map(int,input().split()))
pick = k[3]
maxi = 0
for i in range(len(k)):
    if(i<k[0]-1):
        maxi = max(maxi,maxi+1)
        pick = pick-1
    elif k[1]<(pick-k[i]):
        maxi = max(maxi,maxi+0)
        pick=pick-1
    elif k[2]<(pick-k[i]):
        maxi = max(maxi,maxi-0)
        pick = pick-1


print(maxi+1)

Submission status: Wrong Answer

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

#K枚の優先順位を選ぶ
#＋１の枚数分だけ選択、KからAを引く、総和のリストにA枚分の+1を追加
# K<Aのとき、K枚分だけリストにAを追加、KからKを引く
#0の枚数分だけ選択、KからBを引く、総和のリストにB枚分の0を追加

#・・・総和のリストないの総和を計算する
sum_num = []
card_num = [1,0,-1]
for i,card in enumerate(a[0:2]):
  if card > a[3]:
    sum_num.append(a[3] * card_num[i])
    a[3] -= a[3]
  else:
    sum_num.append(card * card_num[i])
    a[3] -= card
print(sum(sum_num))

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

Solution code:
# B

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
# B

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

ans = 0

if K <= A:
  ans = K
elif K <= A+B:
  ans = A
elif K <= A+B+C:
  ans = A+B-C

print(ans)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
if a[3] < a[0]:
  print(a[3])
elif a[3] < a[0] + a[1]:
  print(a[0])
elif a[3] < a[0] + a[1] + a[2]:
  print(a[0] - (a[2] - a[0] - a[1]))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
if a[3] < a[0]:
  print(a[3])
elif a[3] < a[0] + a[1]:
  print(a[0])
elif a[3] < a[0] + a[1] + a[2]:
  print(a[0] - (a[3] - a[0] - a[1]))

Submission status: Wrong Answer

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

k = k - b

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

ans -= k
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( A - (K-B-A) )

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A >= K:
  print(A)

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

Submission status: Wrong Answer

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

K -= A
if K <= 0 or K <= B:
    print(A)
else:
    print(max(0, K - C))

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

else:
    print((1 * a) + (-1 * (k - a)))

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def main():
    A, B, C, K = map(int, input().split())
    print(2*A+B-K)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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 = [int(i)  for i in input().split()]

if k-a>0:
  if k-a-b>0:
      ans=2*a+b-k
  else:
    ans=a
else:
  ans=a

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

else:
    K = 0
    ans += K

print(ans)

Submission status: Wrong Answer

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

if K <= A:
    print(K)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def Easy_Linear_Programming():
    cards_reguration = input()
    cards = cards_reguration.split()
    A = int(cards[0])
    B = int(cards[1])
    C = int(cards[2])
    K = int(cards[3])
    
    point = 0
    
    if A >0:
        point = A
        K -= A
        if K <= 0:
            print(point)
            return
        
    if B > 0 and K > 0:
        K -= B
        if K <= 0:
            print(point)
            return
        
    if C >= 0 and K > 0:
        point -= K
        print(point)
        return
            
    
Easy_Linear_Programming()

Submission status: Wrong Answer

Solution code:
def Easy_Linear_Programming():
    cards_reguration = input()
    cards = cards_reguration.split()
    A = int(cards[0])
    B = int(cards[1])
    C = int(cards[2])
    K = int(cards[3])
    
    point = 0
    
    if A >0:
        point = A
        K -= A
        if K <= 0:
            print(point)
            return
        
    if B > 0 and K > 0:
        K -= B
        if K <= 0:
            print(point)
            return
        
    if C >= 0 and K > 0:
        point -= K
        if K == 0:
            print(point)
            return
            
    
Easy_Linear_Programming()

Submission status: Wrong Answer

Solution code:
def Easy_Linear_Programming():
    cards_reguration = input()
    cards = cards_reguration.split()
    A = int(cards[0])
    B = int(cards[1])
    C = int(cards[2])
    K = int(cards[3])
    
    point = 0
    
    if A >0:
        while A > 0:
            point += 1
            A -= 1
            K -= 1
        if K == 0:
            print(point)
            return
        
    if B > 0 and A ==0:
        while B > 0:
            B -= 1
            K -= 1
        if K == 0:
            print(point)
            return
        
    if B == 0 and A == 0:
        while C > 0:
            point -= 1
            C -= 1
            K -= 1
        if K == 0:
            print(point)
            return
            
    
Easy_Linear_Programming()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

if a == 0 and c == 0:
  print(0)
  exit()
r = 0

if a >= k:
  print(k)
  exit()
if a != 0 and a < k:
  r += a
  k -= a
if b >= k:
  print(r)
  exit()
if b != 0 and b < k:
  k -= b
  r -= k
  print(r)

Submission status: Wrong Answer

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

print(a,b,c,k)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

if c >= k:
    print(p - k)
    exit(0)
else:
    p = p - c

print(p)

Submission status: Wrong Answer

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

sum = 0

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

Submission status: Wrong Answer

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

sum = 0

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

Submission status: Wrong Answer

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

sum = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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