ZhenlongDai/ACPR huggingface dataset:
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())

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

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K=map(int,input().split())
count=0
if K<=A or K<=A+B:
  print(A)
else:
  m=K-A-B
  print(A-m)  

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
A,B,C,K=map(int,input().split())
count=0
if K<=A:
  print(K)
elif K<=A+B:
  print(A)
else:
  m=K-A-B
  print(A-m)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
list1 = list(map(int, input().split()))
if list1[3] <= list1[0]:
    print(list1[0])
else:
    a = list1[3] - list1[0]
    if a <= list1[1]:
        print(list1[0])
    else:
        b = a - list1[1]
        c = (-1)*b
        print(c)

Failing test case input:
1 2 18 4

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
list1 = list(map(int, input().split()))
if list1[3] <= list1[0]:
    print(list1[3])
else:
    a = list1[3] - list1[0]
    if a <= list1[1]:
        print(list1[0])
    else:
        b = a - list1[1]
        c = (-1)*b + list1[0]
        print(c)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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()

Failing test case input:
-1 2 5 6

Expected output:
-6


Actual output:

Fixed submission (verdict: Accepted):
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)

print(main())

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())
ans=min(a,k)
k-=min(a,k)
k-=min(b,k)
ans+=min(c,k)
print(ans)
    

Failing test case input:
0 2 5 4

Expected output:
-2


Actual output:
2


Fixed submission (verdict: Accepted):
a,b,c,k=map(int,input().split())
ans=min(a,k)
k-=min(a,k)
k-=min(b,k)
ans-=min(c,k)
print(ans)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())
if k>(a+b):
    print(a-1*(k-(a+b)))
elif k<=(a+b):
    print(a)
else:
    print(k)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k=map(int,input().split())
if k>(a+b):
    print(a-1*(k-(a+b)))
elif a<k and k<=(a+b):
    print(a)
else:
    print(k)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,d=map(int,input().split())
if a>=d:
    print(d)
elif a+b>=d:
    print(a)
else:
    print(a-(d-a-b))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int,input().split())

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

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
a, b, c, k = map(int,input().split())

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())

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

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
l = list(map(int,input().split()))
a = l[0]
b = l[1]
c = l[2]
k = l[3]
if (c-k-a-b) >0:
  print(a-1*(c-k-a-b))
else:
  print(a)

Failing test case input:
0 1 8 0

Expected output:
0


Actual output:
-7


Fixed submission (verdict: Accepted):
l = list(map(int,input().split()))
a = l[0]
b = l[1]
c = l[2]
k = l[3]
if (k-a-b) >0:
  print(a-1*(k-a-b))
else:
  print(min(a,k))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    a,b,c,k = map(int,input().split())
    if a>=k:
        print(a)
    else:
        k = k-a
        if b>=k:
            print(a)
        else:
            k = k-b
            print(a-k)


if __name__ == "__main__":
    main()


Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    a,b,c,k = map(int,input().split())
    if a>=k:
        print(k)
    else:
        k = k-a
        if b>=k:
            print(a)
        else:
            k = k-b
            print(a-k)


if __name__ == "__main__":
    main()
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K= map(int, input().split())
if A >= K:
    print(K)
elif A+B >= K:
    print(A)
else:
    print(K-(K-A-B))

Failing test case input:
1 3 10 9

Expected output:
-4


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K= map(int, input().split())
if A >= K:
    print(K)
elif A+B >= K:
    print(A)
else:
    print(A-(K-A-B))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = list(map(int, input().split()))
if a + b > k:
  print(a)
else:
  print(2 * a + b - k)

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k = list(map(int, input().split()))
if a > k:
  print(k)
elif a + b >= k:
  print(a)
else:
  print(2 * a + b - k)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

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


result_score = 0
for score, i in [(1, A), (0, B), (-1, C)]:
        if K <= 0:
               continue 
        
        if K >= i:
            result_score =- score * i
            K -= i
        else:
            result_score =- score * K
            K = 0

print(result_score)

Failing test case input:
0 6 8 8

Expected output:
-2


Actual output:
2


Fixed submission (verdict: Accepted):

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


result_score = 0
for score, i in [(1, A), (0, B), (-1, C)]:
        if K <= 0:
               continue

        if K >= i:
            result_score += score * i
            K -= i
        else:
            result_score += score * K
            K = 0

print(result_score)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K=map(int,input().split())
if A>=K:
    print(K)
    exit()
elif A+B>=K:
    print(A)
    exit()
else:
    print(A+(K-A-B))
    exit()

Failing test case input:
1 3 10 9

Expected output:
-4


Actual output:
6


Fixed submission (verdict: Accepted):
A,B,C,K=map(int,input().split())
if A>=K:
    print(K)
    exit()
elif A+B>=K:
    print(A)
    exit()
else:
    print(A-(K-A-B))
    exit()

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())
if k == 0:
    print(0)
elif a >= k:
        print(a)
elif a+b >= k:
        print(a)
else:
    ab = a+b
    ans = a - k+ab
    if k >=a+b+c:
        print(a-c)
    else:
        print(ans)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())
aa=a
if k == 0:
    print(0)
elif a > k:
    print(k)
elif a+b >= k:
    print(a)
else:
    ab = a+b
    ans = aa-(k-ab)
    print(ans)

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
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))

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

if(k<=a):
  print(k)
elif(a<k<=(a+b)):
  print(a)
elif(a+b<k<=(a+b+c)):
  print(a-(k-a-b))
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())


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

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
2
4


Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())


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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int, input().split())
ans = 0

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

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

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




Failing test case input:
1 2 9 3

Expected output:
1


Actual output:
1
-1


Fixed submission (verdict: Accepted):
a,b,c,k = map(int, input().split())
ans = 0

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

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

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())

s = 0

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

Failing test case input:
-1 3 5 6

Expected output:
-5


Actual output:
-1


Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())

s = 0

s += min(a,k)
k -=a
if k<0:
  print(s)
  exit()
k -=b
if k<0:
  print(s)
  exit()
s -= min(c,k)
print(s)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K=[int(i) for i in input().split()]
P=A
if A+B<K:
    P-=(K-A+B)
print(P)

Failing test case input:
0 3 8 5

Expected output:
-2


Actual output:
-8


Fixed submission (verdict: Accepted):
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)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split()) 

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


Failing test case input:
0 6 8 6

Expected output:
0


Actual output:
6


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split()) 

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)


Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
a,b,c,k=map(int, input().split())

if a>=k:
  print(k)
  exit()
if a+b>=k:
  print(a)
  exit
else:
  print(a-(k-a-b))
Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
a,b,c,k = list(map(int,input().split()))

count=0
if a<k:
    if b<k-a:
        count=a-(k-a-b)
    else:
        count=a
else:
    count=a

print(count)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k = list(map(int,input().split()))

count=0
if a<k:
    if b<k-a:
        count=a-(k-a-b)
    else:
        count=a
else:
    if a==k:
        count=a
    else:
        count=k

print(count)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

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

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int,input().split())

if K < A:
    print(K)
if A <= K < A + B:
    print(A)
if A + B <= K < A + B + C:
    print(2*A + B - K)
    

Failing test case input:
2000000000 0 0 2000000000

Expected output:
2000000000

Actual output:

Fixed submission (verdict: Accepted):
A, B, C, K = map(int,input().split())

if K < A:
    print(K)
if A <= K < A + B:
    print(A)
if A + B <= K <= A + B + C:
    print(2*A + B - K)

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())

total=0
total+=a

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

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
2


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

total=0
total+=a

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())
if A >= K:
    print(1 * A)
else:
    print(1 * A + -1 * (K - (A + B)))

Failing test case input:
-1 6 2 1

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())
if A >= K:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(A - (K - A - B))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())
sub = A+B-K
if sub>=0:
  print(A)
else:
  print(A+B-C)

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())
sub = A+B-K
if A>=K:
  print(K)
elif sub>=0:
  print(A)
else:
  print(A+sub)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
input = sys.stdin.readline





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

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

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline





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

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = list(map(int, input().split()))
Sum = 0
if S[0] > S[3]:
  Sum = S[3]
if S[0] + S[1] >= S[3]:
  Sum = S[0]
else:
  Sum = S[0]*2 - S[3] + S[1]
print(Sum)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
S = list(map(int, input().split()))
Sum = 0
if S[0] >= S[3]:
  Sum = S[3]
elif S[0] + S[1] >= S[3]:
  Sum = S[0]
else:
  Sum = S[0]*2 - S[3] + S[1]
print(Sum)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

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

Failing test case input:
0 6 1 1

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):

ABCK = input().split(' ')
A = int(ABCK[0]) ; B = int(ABCK[1]) ; C = int(ABCK[2])
K = int(ABCK[3])
if K <= A:
    print(K)
elif K <= (A + B):
    print(A)
else:
    print(A - (K - A - B))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


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


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

    return


if __name__ == '__main__':
    main()


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


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


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

    return


if __name__ == '__main__':
    main()

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
A,B,C,K = list(map(int,input().split()))
ans = 0

if K - A >= 0:
    ans += A * 1
else:
    ans += 0

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


Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
0


Fixed submission (verdict: Accepted):
A,B,C,K = list(map(int,input().split()))
ans = 0

if A > K:
    ans += K * 1
else:
    ans += A * 1

if K - A - B >= 0:
    ans += (K - A - B) * (-1)
else:
    ans += 0
    
print(ans)
Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())


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

    

Failing test case input:
-1 3 5 5

Expected output:
-4


Actual output:
1


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())


if k - a <= 0:
    print(k)
elif k - a > 0 and k - a - b <= 0:
    print(a)
else:
    s = k - a - b
    print(a - s)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())
if A >= K:
  print(A*K)
elif A+B >= K and A < K:
  print(A)
elif A+B < K:
  print(A - (K-A-B))

Failing test case input:
2 3 14 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())
if A >= K:
  print(K)
elif A+B >= K and A < K:
  print(A)
elif A+B < K:
  print(A - (K-A-B))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = list(map(int, input().split()))
if k <= (a + b):
	s = k * 1
else:
	s = (k * 1) + ((k-(a+b)) * (-1))
print(s) 

Failing test case input:
-1 6 3 1

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
a, b, c, k = list(map(int, input().split()))
if k <= a:
	s = k * 1
elif k <= (a+b):
	s = a * 1
else:
	s = (a * 1) + ((k-(a+b)) * (-1))
print(s)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())
ans=a
if k-a==0:
    print(ans)
    exit()
if k-a-b==0:
    print(ans)
    exit()
if k-a-b-c<0:
    ans=ans+(k-a-b)*(-1)
    print(ans)
else:
    ans=ans+c*(-1)
    print(ans)

Failing test case input:
2 6 8 3

Expected output:
2


Actual output:
7


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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
read = input().split()
print(read)
x = int(read[3]) - int(read[0]) - int(read[1])
if x <= 0:
    print(int(read[0]))
else:
    print(int(read[0]) - x)

Failing test case input:
0 6 8 8

Expected output:
-2


Actual output:
['0', '6', '8', '8']
-2


Fixed submission (verdict: Accepted):
read = input().split()
x = int(read[3]) - int(read[0]) - int(read[1])
if int(read[3]) < int(read[0]):
    print(int(read[3]))
elif x <= 0:
    print(int(read[0]))
else:
    print(int(read[0]) - x)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())
total=0
if a < k:
    total += a
    k -= a
else:
    print(a)
    exit()
if b < k:
    k -= b
else:
    print(a)
    exit()
print(total-k)

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())

total = 0

if k <= a:
    print(k)
    exit()
else:
    if k <= a+b:
        print(a)
        exit()
    else:
        print(a-(k-(a+b)))
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))
    

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map( int, input().split() )

if k <= a:
    print( a )

elif k > a:
    if b == 0:
        nc = k - a
        print( a - nc )
    elif b != 0:
        nb = k - a
        if nb <= b:
            print( a )
        elif nb > b:
            nc = nb - c
            print( a - nc )


Failing test case input:
1 2 10 4

Expected output:
0


Actual output:
8


Fixed submission (verdict: Accepted):
a, b, c, k = map( int, input().split() )

if k <= a:
    print( k )

elif k > a:
    if b == 0:
        nc = k - a
        print( a - nc )
    elif b != 0:
        nb = k - a
        if nb <= b:
            print( a )
        elif nb > b:
            nc = nb - b
            print( a - nc )

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k= map(int,input().split())
ans=0
if a<=k:
    ans = a
    k=k-a
if b<=k:
    k=k-b
if k>0:
    ans = ans-k
print(ans)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
a,b,c,k= map(int,input().split())
ans=a
if k<a:
    ans = k
if a+b<k:
    ans = ans-k+a+b

print(ans)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K = map(int, input().split())

if K <= A+B:
    ans = A
else:
    ans = 2*A+B-K

print(ans)

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
A,B,C,K = map(int, input().split())

if K <= A:
    ans = K
elif A+B >= K:
    ans = A
else:
    ans = 2*A+B-K

print(ans)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int, input().split())
if a > k:
  print(k)
else:
  k -= a + b
if k <= 0:
  print(a)
else:
  print(a-k)

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
2
2


Fixed submission (verdict: Accepted):
a,b,c,k = map(int, input().split())
if a >= k:
  print(k)
else:
  k -= a + b
  if k <= 0:
    print(a)
  else:
    print(a-k)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K=map(int,input().split())
maxC=K-(A+B)

if A > K:
	max=A
else:
	if maxC <0 :
		max = A 
	elif maxC >= 0:
		max = A - maxC

print(max)

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
A,B,C,K=map(int,input().split())
cntC=K-(A+B)

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

print(max)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K=map(int,input().split())

M=K-(A+B)

if 0>=M:
    print(A)
else:
    print(A-M)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A,B,C,K=map(int,input().split())

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K = map(int,input().split())
m=0

if K<=A:
  m=A
else:
  if K-A <=B:
    m=A
  else:
    if K-A-B <=C:
      m = 2*A-K+B

print(m)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A,B,C,K = map(int,input().split())
m=0

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)))

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A,B,C,K = map(int,input().split(" "))
if K<=A:
    print(K)
elif K<=A+B:
    print(A)
else:
    print(A - (K-(A+B)))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
[A,B,C,K]=map(int,input().split())
if A+B>=K:
    print(A)
else:
    print(2*A+B-K)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
[A,B,C,K]=map(int,input().split())
if A>=K:
    print(K)
elif A+B>=K:
    print(A)
else:
    print(2*A+B-K)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys

A, B, C, K = map(int, sys.stdin.readline().split())
res = 0
res += min(A, K)
K -= A
if K > 0:
  K -= B
if K > 0:
  res -= min(B, K)
print(res)

Failing test case input:
-4 3 8 5

Expected output:
-10


Actual output:
-7


Fixed submission (verdict: Accepted):
import sys
 
A, B, C, K = map(int, sys.stdin.readline().split())
res = 0
res += min(A, K)
K -= A
if K > 0:
  K -= B
if K > 0:
  res -= min(C, K)
print(res)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,d = map(int,input().split())
sum = 0
d = d-a
sum = a
if d>0:
  d = d-b
  if d>0:
    sum += -d
print(sum)

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
a,b,c,d = map(int,input().split())
x = min(a,d)
d = d-x
sumi = x
if d>0:
  d = d-b
  if d>0:
    sumi += -d
print(sumi)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a = input()
 
A, B, C, K = map(int, a.split())
 
if A >= K:
  print(K)
elif A + B >= K > A:
  print(A)
else:
  print(- B - C +K)

Failing test case input:
0 3 8 8

Expected output:
-5


Actual output:
-3


Fixed submission (verdict: Accepted):
a = input()
 
A, B, C, K = map(int, a.split())
 
if A >= K:
  print(K)
elif A + B >= K > A:
  print(A)
else:
  print(2 * A + B - K)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())

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

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


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

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

Failing test case input:
1 2 8 3

Expected output:
1


Actual output:
1 2 8 3
1


Fixed submission (verdict: Accepted):
A,B,C,K = map(int,input().split())
ANS = 0

ANS += min([A,K])
K -= A
K -= B

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())
print(a+b if a+b>=k else a-(k-a-b))

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
7


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())
print(min(a, k, a*2+b-k))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())

ans = 0

ans = a*1
k -= a
if k > 0:
    k -= b
    if k > 0:
        for _ in range(c):
            if k == 0:
                break
            ans += (1)
            k -= 1
print(ans)

Failing test case input:
-3 3 8 5

Expected output:
-8


Actual output:
2


Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())

ans = 0

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = list(map(int, input().split()))

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


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K = list(map(int, input().split()))

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K = map(int, input().split())
if A+B<K<=A+B+C:
  ans = A-(K-B-A)
else:
  ans = A
print(ans)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A,B,C,K = map(int, input().split())
if A+B<K<=A+B+C:
  ans = A-(K-B-A)
elif A<K<=A+B:
  ans = A
else:
  ans = K
print(ans)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K= map(int,input().split())


A_C = min(A,K)
K -= A
B_C = min(B,K)
K -= B
C_C = min(C,K)

print(A_C-C_C)

Failing test case input:
1 3 1 3

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
A,B,C,K= map(int,input().split())


A_C = min(A,K)
K -= A_C
B_C = min(B,K)
K -= B_C
C_C = min(C,K)

print(A_C-C_C)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    a,b,c,k=L()
    if a+b>=k:
        print(a)
    else:
        tmp=k-(a+b)
        print(a-tmp)
    
if __name__ == '__main__':
    main()

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    a,b,c,k=L()
    if k<a:
        print(k)
    elif a+b>=k:
        print(a)
    else:
        tmp=k-(a+b)
        print(a-tmp)
    
if __name__ == '__main__':
    main()

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,d=[int(x) for x in input().split()]
count=a
sum=a
if count==d:
    print(a)
else:
    count=count+b
    if count<d:
        if d-count<=c:
          print(sum+((d-count)*-1))
        else:
            print(sum+(c*-1))
    else:
        print(sum)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = [int(i) for i in input().split()]

sum = 0

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

print(sum)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = [int(i) for i in input().split()]

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K = map(int,input().split())
if A + B + C == K:
    print(A*1 + C*(-1))
elif (K >= A + B) and (K < A + B + C)  :
    print(A*1 + (-1)*(K-A-B))
elif (K >= A) and (K>A+B):
    print(K)
elif (K<A):
    print(K)

Failing test case input:
1 14 2 1

Expected output:
1


Actual output:

Fixed submission (verdict: Accepted):
A,B,C,K = map(int,input().split())
if A + B + C == K:
    print(A - C)
elif (K >= A + B) and (K < A + B + C)  :
    print(A - K + A + B)
elif (K >=A and K < A + B):
    print(A)
else:
    print(K)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):





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
else:
  K -= B

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

print(result)


Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):





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

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

if K > 0:
  if B < K:
    K -= B
  else:
    K -= B

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

print(result)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())
if A + B >= K:
  print(A)
elif A >= K:
  print(K)
else:
  d = K - A - B
  print(A-d)

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A=list(map(int,input().split()))
ans = 0
if A[0] >= A[3]:
    ans = A[0]
else:
    A[3] = A[3]-A[0]
    ans = A[0]
    A[3] = A[3] -A[1]
    if A[3] > 0:
        ans = ans - A[3]
print(ans)

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
A=list(map(int,input().split()))
ans = 0
if A[0] >= A[3]:
    ans = A[3]
else:
    A[3] = A[3]-A[0]
    ans = A[0]
    A[3] = A[3] -A[1]
    if A[3] > 0:
        ans = ans - A[3]
print(ans)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys

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

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

k = k - b
if k <= 0:
    print(total)
    sys.exit()

print(total - k)


Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
import sys

a, b, c, k = map(int, input().split())
if a >= k:
    print(k)
    sys.exit()

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

k = k - b
if k <= 0:
    print(total)
    sys.exit()

print(total - k)

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())

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

print(ans)


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())

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

print(ans)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a = list(map(int, input().split()))
n = a[0]
m = a[1]
l = a[2]
k = a[3]

if 0 < k <= n:
    print(k)

elif n < k <= n + m:
    print(n)

elif n+m <= k < n+m+l:
    print(n -1*(k - (n+m)))

elif n+m+l < k :
    print(n - l)
else:
    print(0)

Failing test case input:
-1 2 5 6

Expected output:
-6


Actual output:
0


Fixed submission (verdict: Accepted):
a = list(map(int, input().split()))
n = a[0]
m = a[1]
l = a[2]
k = a[3]

if 0 < k <= n:
    print(k)

elif n < k <= n + m:
    print(n)

elif n+m <= k < n+m+l:
    print(n -1*(k -n -m))

elif n+m+l <= k:
    print(n - l)
else:
    print(0)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K = map(int,input().split())
if A + B >= K:
	print(max(K,A))
else:
	print(A-(K-(A+B)))

Failing test case input:
1 7 3 6

Expected output:
1


Actual output:
6


Fixed submission (verdict: Accepted):
A,B,C,K = map(int,input().split())
if A + B >= K:
	print(min(K,A))
else:
	print(A-(K-(A+B)))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
a, b, c, k = map(int, input().split())

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

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

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
a, b, c, k = map(int, input().split())

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

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

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

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

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):

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

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=[int(x) for x in input().split()]
count=0
if a>=k:
  count+=a
  print(count)
else:
  count+=a
  k-=a
  if b>=k:
    print(count)
  else:
    k-=b
    count-=k
    print(count)
  

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k=[int(x) for x in input().split()]
count=0
if a>=k:
  count+=k
  print(count)
else:
  count+=a
  k-=a
  if b>=k:
    print(count)
  else:
    k-=b
    count-=k
    print(count)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())
if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a-(k-a-b))
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)))

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
A, B, C, K = list(map(int, input().split()))

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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()


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
  a, b, c, k = map(int, input().split())
  if a >= k:
    print(k)
  elif a + b >= k:
    print(a)
  elif a+b<k:
    print(2*a+b-k)

if __name__ == '__main__':
  main()

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())
if k<a:
  print(k)
elif a+b<k:
  print(a)
else:
  print(a-(k-(a+b)))

Failing test case input:
-1 6 5 6

Expected output:
-2


Actual output:
-1


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

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())
ans = 0
card_left = k
ans += a
card_left -= a

card_left -= b
if(card_left >= 0):ans -= card_left

print(ans)

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())
ans = 0

card_left = k
ans += min(a, k)
card_left -= a

if(card_left >= 0):card_left -= b
if(card_left >= 0):ans -= card_left

print(ans)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a , b, c, k = map(int, input().split())
if(k<=a+b):
    print(a)
else:
    print(a-(k-(a+b)))

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
a , b, c, k = map(int, input().split())
if(k<=a+b):
    print(min(a,k))
else:
    print(a-(k-(a+b)))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a , b, c, k = map(int,input().split())
if 0 < k <= a + b:
    print(a)
elif a + b < k <= a + b + c:
    print(a-(k-a-b))


Failing test case input:
0 3 8 0

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
a , b, c, k = map(int,input().split())
if 0 < k < a:
    print(k)
if a <= k <= a + b:
    print(a)
elif a + b < k <= a + b + c:
    print(a-(k-a-b))
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = [int(i) for i in input().split(" ")]
N = [A, B, C]
for i in range(len(N)):
    K -= N[i]
    if K == 0:
        if i == 0:
            N[i+1] = 0
            N[i+2] = 0
        elif i == 1:
            N[i+1] = 0
        break
    elif K < 0:
        if i == 0:
            N[i+1] = 0
            N[i+2] = 0
        elif i == 1:
            N[i+1] = 0
        N[i-1] += K
        break
print(1 * N[0] -1 * N[2])

Failing test case input:
0 2 8 3

Expected output:
-1


Actual output:
-8


Fixed submission (verdict: Accepted):
A, B, C, K = [int(i) for i in input().split(" ")]
N = [A, B, C]
for i in range(len(N)):
    K -= N[i]
    if K == 0:
        if i == 0:
            N[i+1] = 0
            N[i+2] = 0
        elif i == 1:
            N[i+1] = 0
        break
    elif K < 0:
        if i == 0:
            N[i+1] = 0
            N[i+2] = 0
        elif i == 1:
            N[i+1] = 0
        N[i] += K
        break
print(1 * N[0] -1 * N[2])

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())

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

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):

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

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

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b,c,k = LI()
if a + b >= k:
    print(min(a,k))
else:
    print(a - (k - a - b))
Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
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)

Failing test case input:
2 3 10 9

Expected output:
-2


Actual output:
-14


Fixed submission (verdict: Accepted):
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-now)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())

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


Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

ans = a

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K = map(int,input().split())

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

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A,B,C,K = map(int,input().split())

if K <= A:
    value = K
else:
    value = A + B*0
cnt = A + B

if cnt >= K:
    print(value)
else:
    value -= K - cnt
    print(value)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())  

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

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())  

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

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())

import sys

ans = 0
if a != 0 and a >= k:
    
    print(a)
    sys.exit()
elif a != 0:
    ans += a
    k -= a

if b != 0 and b >= k:
    print(ans)
    sys.exit()
elif b != 0:
    k -= b

ans += k * -1
print(ans)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

import sys

ans = 0
if a != 0 and a >= k:
    
    print(k)
    sys.exit()
elif a != 0:
    ans += a
    k -= a

if b != 0 and b >= k:
    print(ans)
    sys.exit()
elif b != 0:
    k -= b

ans += k * -1
print(ans)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int,input().split())
if K <= (A + B):
  print(A)
else:
  print(2*A + B - K)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K = map(int,input().split())
if K <= A:
  print(K)
elif K <= (A +B):
  print(A)
else:
  print(2*A + B - K)