TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
a,b,c,k = input().split(None, 4)
A = int(a)
B = int(b)
C = int(c)
K = int(k)
X = K - A - B
if K <= A:
    print(K)
elif A < K <= A + B:
    print(A)
else A + B < K:
    print(A - X)

a,b,c,k = input().split(None, 4)
A = int(a)
B = int(b)
C = int(c)
K = int(k)
X = K - A - B
if K <= A:
    print(K)
elif A < K <= A + B:
    print(A)
else:
    print(A - X)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)))

a,b,c,k = map(int,input().split())
xa = min(a,k)
k -= xa
xb = min(b,k)
k -= xb
xc = k
ans = xa -xc
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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()

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, k = list(map(int, input().split()))

ans = 0

if k > a:
  if k > b:
    for i in range(a):
      ans += 1
      k = k - 1
    for i in range(b):
      ans += 0
      k = k - 1
    for i in range(k):
      ans += -1
      print(ans)
  elif k <= b:
      for i in range(k):
        ans += 0
      print(ans)
elif k <= a:
  for i in range(k):
    ans += 1
  print(ans)
      
    



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

ans = 0

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



Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import os
import random
import re
import sys

def solution(a,b,c,k):
    max=0
    while(k>0):
        while(a>0 and k>0):
            max+=1
            a-=1
            k-=1
        if(k<=0):
            return max
            break
        while(b>0 and k>0):
            b-=1
            k-=1
        if(k<=0):
            return max
            break
        while(c>0 and k>0):
            max-=1
            c-=1
            k-=1
        return max
            
                
if __name__ == '__main__':
    fptr = sys.stdout
    a=int(input())
    b=int(input())
    c=int(input())
    k=int(input())
    result = solution(a,b,c,k)

    fptr.write(str(result) + '\n')


fptr.close()


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




Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = int(input().split())
if K<=A:
    print(K)
elif A<K<=A+B:
    print(A)
else:
    print(A-(K-A-B))

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
# coding: utf-8
# Your code here!


num_line = input().split()


num_one = int(num_line[0])
num_zero = int(num_line[1])
num_mini = int(num_line[2])
num_amount = int(num_line[3])


if num_one >= num_amount:
    print(num_amount)
elif num_one + num_zero >= num_amount:
    print(num_amount)
else:
    
    minus_count = num_amount - (num_one + num_zero)
    print(num_one - minus_count)

# coding: utf-8
# Your code here!


num_line = input().split()


num_one = int(num_line[0])
num_zero = int(num_line[1])
num_mini = int(num_line[2])
num_amount = int(num_line[3])


if num_one >= num_amount:
    print(num_amount)
elif num_one + num_zero >= num_amount:
    print(num_one)
else:
    
    minus_count = num_amount - (num_one + num_zero)
    print(num_one - minus_count)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = input().split()

if s[3] == "0" :
    print(0)
    
elif ( int(s[0]) >= int(s[3]) ) or ((int(s[3]) - int(s[0]) <= int(s[1]))) :
    print(s[3])
elif int(s[3]) - int(s[0]) > int(s[1]) :
    print(int(s[0])- (int(s[3])-int(s[0])-int(s[1])))

s = input().split()

if s[3] == "0" :
    print(0)
    
elif ( int(s[0]) >= int(s[3]) ) :
    print(s[3])

elif ((int(s[3]) - int(s[0]) <= int(s[1]))):
    print(s[0])
elif int(s[3]) - int(s[0]) > int(s[1]) :
    print(int(s[0])- (int(s[3])-int(s[0])-int(s[1])))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k = map(int,input().split())
d = k - a
k -= a
e = k - b
k -= b
f = k - c
n = 0 
if d == 0:
  print(a)
elif e == 0 and e < 0:
  print(a)
elif f == 0:
  print(a + c)
elif k < a:
  print(k)
else:
  print(a - e)

  


a,b,c,k = map(int,input().split())
s = k
d = k - a
k -= a
e = k - b
k -= b
f = k - c
n = 0 
if d == 0:
  print(a)
elif s < a:
  print(s)
elif e == 0 or e < 0:
  print(a)
elif f == 0 :
  print(a - c)
else:
  print(a - e)

  


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()
          
n = 1
for i in range(N):
    n *= A[i]
    if n > 10**18:
        print(-1)
        exit()

print(n)


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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, k = map(int, input().split())

ans = 0

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

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

ans = 0

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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A,B,C,K =map(int,input().split())

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A = int(input())
B = int(input())
C = int(input())
K = int(input())
remain_A = K-A
if remain_A<=0:
    print(K)
else:
    remain_B = remain_A - B
    if remain_B <= 0:
        print(A)
    else:
        ans = (A*1) + (B*0) + (remain_B * (-1))
        print(ans)

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

A,B,C,K=(int(x) for x in input().split())
remain_A = K-A
if remain_A<=0:
    print(K)
else:
    remain_B = remain_A - B
    if remain_B <= 0:
        print(A)
    else:
        ans = (A*1) + (B*0) + (remain_B * (-1))
        print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
A,B,C,K=map(int,input().split())
for i in range(C):
    for j in range(B):
        for k in range(A):
            if i+j+k==K:
                print(-1*i+k)
                exit()

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
if __name__ == "__main__":
    a = int(input())
    b = int(input())
    c = int(input())
    k = int(input())

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


if __name__ == "__main__":
    A = int(input())
    B = int(input())
    C = int(input())
    K = int(input())
    
    if (K <= A + B):
        print(A)
    else:
        print(A - K + A + B)


if __name__ == "__main__":
    num = list(map(int, input().split()))

    if (num[3] == 0):
        print(0)
    elif (num[0] == 0 and num[1] == 0 and num[2] == 0):
        print(0)
    elif (num[3] <= num[0]):
        print(num[3])
    else:
        print(num[0] - num[3] + num[0] + num[1])


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, k = map(int, input().split())

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


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

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k = [int(i) for i in input().split()]
if k<=a:
  print(k)
else if k<=a+b and k>a:
  print(a)
else:
  print(a-(k-a-b))
      

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

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
line = input().split(" ")
a, b, c, k = line[0], line[1], line[2], line[3]

if a >= k:
  print(k)
  return 

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

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

import sys
line = list(map(lambda x: int(x), input().split(" ")))
a, b, c, k = line[0], line[1], line[2], line[3]
 
if a >= k:
  print(k)
  sys.exit(0)
 
tmp = k - a
if b >= tmp:
  print(a)
  sys.exit(0)
 
print(a - (k - a -b))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,d = map(int,input().split())

ans = 0

if d == 0:
    ans = 0
elif a >= d:
    ans = d
elif (a + b) >= d:
    ans = d
elif (a + b - c) <= 0:
    ans = 0
else:
    ans = a - c

print(ans)

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

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

if ans >= 0:
    ans = 0
print(ans)

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = map(int, input().split())

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


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

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

print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = map(int, input().split())
if K <= A+B:
    print(K)
else:
    print(A - (K-A-B))

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
i = input().split()

a = i[0]
b = i[1]
c = i[2]
d = i[3]

if int(d) <= int(a):
  print(int(d))
  elif int(d) - int(a) <= int(b):
    print(int(a))
else:
  print(int(a) - (int(d) - int(a) -int(b)))

i = input().split()
a = int(i[3])-int(i[0])
b = int(i[3])-int(i[0])-int(i[1])

if i[3] <= i[0]:
  print(i[3])
elif a <= int(i[1]):
  print(a)
elif b == int(i[2]):
  print(int(i[0]) - int(i[2]))
else:
  print(int(i[0])*2 + int(i[1]) - int(i[3]))

i = input().split()

a = i[0]
b = i[1]
c = i[2]
d = i[3]

if int(d) <= int(a):
  print(int(d))
elif int(d) - int(a) <= int(b):
    print(int(a))
else:
  print(int(a) - (int(d) - int(a) -int(b)))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, k = map(int, input().split())

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


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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n = list(map(int,input().split()))

sum = 0
num = 0
nm = [1,0,-1]
c = n[3]
cu =0


for i in n:
    print(sum)
    if c == 0:
        break
    if i > c:
        sum+= nm[num]*c
        break
    if i <= c:
        sum += nm[num] * i
        c-=i
        num+=1




print(sum)


n = list(map(int,input().split()))

sum = 0
num = 0
nm = [1,0,-1]
c = n[3]
cu =0


for i in n:
    if c == 0:
        break
    if i > c:
        sum+= nm[num]*c
        break
    if i <= c:
        sum += nm[num] * i
        c-=i
        num+=1




print(sum)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = map(int,input().split())

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

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)
    

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)
    

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, d = map(int, input().split())
if a >= k:
    print(1 * k)
else:
    if b >= (k - a):
        print(1 * a + k * 0)
    else:
        if c >= (k - a - b):
            print(1 * a + 0 * b + (-1) * k)
        else:
            print(-1)


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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k = map(int,input().split())


if a>=k:
    Result=k
elif a+b>=k:
    Result=a
else:
    Result=2a-k+b

print(Result)

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

if a>=k:
    Result=k
elif a+b>=k>a:
    Result=a
else:
    Result=2a-k+b

print(Result)

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


if a>=k:
    Result=k
elif a+b>=k>a:
    Result=a
else:
    Result=2*a-k+b

print(Result)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k = (int(x) for x in input().split())
answer = 0
answer += min(a,k)
k = k - min(a,k)
k = k - min(b-k)
answer -= min(c,k)
print(answer)

a,b,c,k = (int(x) for x in input().split())
answer = 0
answer += min(a,k)
k = k - min(a,k)
k = k - min(b,k)
answer -= min(c,k)
print(answer)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, k = map(int, input().split())

ans = 0

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

ans += min(b, k) * 0
k -= min(b,k)

ans += min(c,k) + -1
k -= min(c,k)

print(ans)

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

ans = 0

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

ans += min(b, k) * 0
k -= min(b,k)

ans += min(c,k) * -1
k -= min(c,k)

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = list(map(int,input().split()))

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

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

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, k = [int(i) for i in input().split()]

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

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

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
total = 0
if K < A:
    print(A)
else:
    total += A
    K = K - A
    if K < B:
        print(total)
    else:
        K = K - B
        if K < C:
            total -= K
            print(total)
        else:
            total -= C
            print(total)

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

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a,b,c,k = I2()
    l = k-a-b
    print(l)
    if k <= a:print(k)
    elif a+b >= k:print(a)
    elif l <= c:print(a-l)

import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a,b,c,k = I2()
    l = k-a-b
    #print(l)
    if k <= a:print(k)
    elif a+b >= k:print(a)
    elif l <= c:print(a-l)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
i = list(map(int,input().split()))

if i[0] <= i[3]:
	saidai=1*i[0]
elif:
	saidai=1*i[3]
else:
if i[2] >= (i[3]-i[0]-i[1]):
	saidai=saidai-1*(i[3]-i[0]-i[1])

print (saidai)
	

i = list(map(int,input().split()))

if i [0] >= i[3]:
	saidai=1*i[3]
else:
	saidai=1*i[0]-1*(i[3]-i[0]-i[1])
print (saidai)
	

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = map(int, input().split())
score = 0

if K - (A + B) > 0:
    
    score = A - (K - (A + B))
else:
    
    score = max(K, A)

print(score)

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

if K - (A + B) > 0:
    
    score = A - (K - (A + B))
else:
    
    score = min(K, A)

print(score)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
#python 3.7.1

a=int(input())

b=int(input())

c=int(input())

d=int(input())

cnt=0

while(d!=0):

  

  if(a!=0 and d>0):

    d-=1

    a=a-1

    

    cnt=cnt+1

    

  elif b!=0 and d>0:

    d-=1

    b=b-1

    

    

  elif c!=0 and d>0:

    d-=1

    c=c-1

    

    cnt=cnt-1

    

print(cnt)

  

#python 3.7.1

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

k=d

if(a-k>0):

  print(k)

else:

  k=d-a

  if(b-k>0):

    print(a)

    

  else:

    k=d-a-b

    print(a-k)

    

    

    

  

  



Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = [int(x) for x in input().strip().split()]
k = K
res = 0
if A > K:
	print(K)
else:
	k -= A
	res += A
    if b > k:
        print(res)
    else:
        k -= b
        if k > 0:
            res -= k * -1
            print(res)
  

a, b, c, k = [int(x) for x in input().split()]
res = 0
i = 0
t = [a, b, c]
j = [1, 0, -1]
while k > 0:
  m = min(k, t[i])
  k -= m
  res += j[i] * m
  i += 1
print(res)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, k = map(int, input().split())
     
if a >= k:
  print(k)
elif:
  a+b >= k
  print(a)
else:
  k -= a+b
  print(a-1*k)

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
X = list(map(int,input().split()))
A = X[0]
B = X[1]
C = X[2]
K = X[3]
score=[1,0,-1]
max_score = 0
nums = []

if (K>=A):
  max_score += 1*A
if (K-A<=B):
  max_score += 2*B
if (K-A-B>0):
  max_score += (-1)*(K-A-B)
print(max_score)
  

X = list(map(int,input().split()))
A = X[0]
B = X[1]
C = X[2]
K = X[3]
score=[1,0,-1]
max_score = 0
nums = []

if (K>=A):
  max_score += 1*A
if (K>=A+B):
  max_score += 0*B
if (K-A-B>0):
  max_score += (-1)*(K-A-B)

if(A>K):
  max_score += 1*K
  
print(max_score)
  

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a = int(input())
b,c = map(int, input().split())
k = int(input())
n = 0

for _ in range(k):
  if a > 0:
    n += 1
  elif b > 0:
    n += 0
  elif c > 0:
    n -= 1
    
print(n)

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

for _ in range(k):
  if a > 0:
    n += 1
  elif b > 0:
    n += 0
  else:
    n -= 1
    
print(n)


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

for _ in range(k):
  if a > 0:
    n += 1
  elif b > 0:
    n += 0
  elif c > 0:
    n -= 1
    
print(n)


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

for s in range(k):
  if a > 0:
    n += 1
  elif b > 0:
    n += 0
  else:
    n -= 1
    
print(n)


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


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = map(int, input().split())

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



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

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k = list(map(input(),split()))
if a+b >= k:
  print(min(a,k))
else:
  print(a-(k-a-b))

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k=map(int,input().split())
printmin((a-max(k-a-b,0)),k)

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

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
Copy
a,b,c,k = map(int,input().split())
 
ans = 0
 
if k <= a:
  ans = a
  print(ans)
elif a< k <= a+b:
  ans = a
  print(ans)
else:
  ans = a-(K-a-b)
  if ans < 0:
    ans = 0
  print(ans)

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = list(map(int, input()))

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

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

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)
  


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)
  


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A,B,C,K = map(int,input().split())

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li():
    return list(map(int, sys.stdin.readline().split()))


def num():
    return map(int, sys.stdin.readline().split())


def nu():
    return int(input())


def find_gcd(x, y):
    while (y):
        x, y = y, x % y
    return x


def lcm(x, y):
    gg = find_gcd(x, y)
    return (x * y // gg)


mm = 1000000007

def solve():
    t = 1
    for tt in range(t):
        a,b,c,d=num()
        if(a+b>=d):
            print(d)
        else:
            z=d-a-b
            print(a-z)

                 


if __name__ == "__main__":
    solve()


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li():
    return list(map(int, sys.stdin.readline().split()))


def num():
    return map(int, sys.stdin.readline().split())


def nu():
    return int(input())


def find_gcd(x, y):
    while (y):
        x, y = y, x % y
    return x


def lcm(x, y):
    gg = find_gcd(x, y)
    return (x * y // gg)


mm = 1000000007

def solve():
    t = 1
    for tt in range(t):
        a,b,c,d=num()
        if(a+b>=d):
            print(min(a,d))
        else:
            z=d-a-b
            print(a-z)

                 


if __name__ == "__main__":
    solve()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k = list(map(int, input().split(" ")))

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

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

d = k-a
if d == 0:
  print(a)
elif d < 0:
  print(k)
elif d > 0:
  if b >= d:
    print(a)
  else:
    i = d-b
    print(a-i)
  

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k=map(int,input().split())
if k < a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(2a+b-k)

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)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k-map(inat,input().split())
ans=0
ans+=min(k,a)
k-=min(k,a)
k-=min(k,b)
ans-=min(k,c)
print(ans)

a,b,c,k=map(int,input().split())
ans=0
ans+=min(k,a)
k-=min(k,a)
k-=min(k,b)
ans-=min(k,c)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, k = map(int, input().split())
    
if(k-a-b<=0):
    print(max(1*a+0*(k-a)))
else :
    print(max(1*a+0*b-1*(k-a-b)))

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
A , B , C , K = map(int,input().split())

s = 0

mn = min(A, K)
s += mn 
K -= mn
print(K)

mn = min(B, K)
K -= mn
print(K)

mn = min(C, K)
s -=mn
K -= mn
print(K)

print(s)

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

s = 0

mn = min(A, K)
s += mn 
K -= mn

mn = min(B, K)
K -= mn

mn = min(C, K)
s -=mn
K -= mn

print(s)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a, b, c, d = map(int, input().split())

s = 0
s += min(a, d)
if min(a, d) == d:
  print(s)
elif min(a+b, d) == d
  print(a)
else:
  d -= a + b
  print(a-min(c, d))

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

s = 0
s += min(a, d)
if min(a, d) == d:
  print(s)
elif min(a+b, d) == d:
  print(a)
else:
  d -= a + b
  print(a-min(c, d))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
if a>=k:
    print(k)
elif a<k<=a+b:
    print(a)
else:
    print(a-(k-a-b))

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
if a.isdigit()==True and b.isdigit()==True and c.isdigit()==True and k.isdigit()==True:
    a = int(a)
    b = int(b)
    c = int(c)
    k = int(k)
    if a>=0 and b>=0 and c>=0:
        if k>=1 and k<=(a+b+c) and (a+b+c)<=2*(10**9):
            if k < a:
                print(k)
            elif k >= a and k <= (a+b):
                print(a)
            else:
                print(a - (k - b - a))

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

if a.isdigit()==True and b.isdigit()==True and c.isdigit()==True and k.isdigit()==True:
    a = int(a)
    b = int(b)
    c = int(c)
    k = int(k)
    if k>=1 and k<=(a+b+c) and (a+b+c)<=2*(10**9):
        if k <= a:
            print(k)
        elif k > a and k <= (a+b):
            print(a)
        else:
            print(a - (k - b - a))

if a.isdigit()==True and b.isdigit()==True and c.isdigit()==True and k.isdigit()==True:
    a = int(a)
    b = int(b)
    c = int(c)
    k = int(k)
    if a>=0 and b>=0 and c>=0 and k>=1 and k<=(a+b+c) and (a+b+c)<=2*(10**9):
        if k < a:
            print(k)
        elif k >= a and k <= (a+b):
            print(a)
        else:
            print(a - (k - b - a))

if a.isdigit()==True and b.isdigit()==True and c.isdigit()==True and k.isdigit()==True:
    a = int(a)
    b = int(b)
    c = int(c)
    k = int(k)
    if a>=0 and b>=0 and c>=0 and k>=1 and k<=(a+b+c) and (a+b+c)<=2*(10**9):
        if k < a:
            print(k)
        elif k >= a and k <= (a+b):
            print(a)
        else:
            print(a - (k - b - a))

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

result = 0
t = min(a, k)
result += t
k -= t
t = min(b, k)
k -= t
t = min(c, k)
result -= t
print(result)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
#ABC167B
a,b,c,d,k = map(int,input().split())
print(min(a,k)-max(k-a-b,0))

#ABC167B
a,b,c,k = map(int,input().split())
print(min(a,k)-max(k-a-b,0))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k = map(int,input().split())

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

choice2(a,b,c,k)

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

xa = min(a,k)
k1 = k-xa
xb = min(b,k1)
k2 = k1-xb
xc = k2

print(xa-xc)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k=map(int,input().split())
if k<=a+c:
    print(k)
elif k>a+c:
    print(a+c)

def do():
    a,b,c,k=map(int,input().split())
    if a>=k:
        return k
    elif a+b>=k:
        return a
    elif k>a+b:
        v=min(k-a-b,c)
        return a-v
print(do())


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):


#b b <B
#c K-a-b <C 
if K < A:
    ans=K
elif K-A <= B and K>=A:
    ans=A
else :
    ans=A-(K-A-B)
print(ans)

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


#b b <B
#c K-a-b <C 
if K < A:
    ans=K
elif K-A <= B and K>=A:
    ans=A
else :
    ans=A-(K-A-B)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b,c,k=map(int,input().split())
if k<=a+b:
    print(k)
else:
    print(2*a+b-k)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A,B,C,D = map(int,input().split())
count = 0
point = 0

if D-A <= 0:
    point = A
    D -= A
    if D-B <= 0:
        D -= B
        if D-C <= 0:
            point -= C
            print(point)
        else:
            point -= D
            print(point)
    else:
        print(point)
else:
    point = D
    print(point)

A,B,C,D = map(int,input().split())
count = 0
point = 0

if D-A >= 0:
    point = A
    D -= A
    if D-B >= 0:
        D -= B
        if D-C >= 0:
            point -= C
            print(point)
        else:
            point -= D
            print(point)
    else:
        print(point)
else:
    point = D
    print(point)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = map(int, input().split())

A = max(A, K)
B = max(K - A, B)
C = max(K - A - B, C)
assert A + B + C >= K
print(A - C)A, B, C, K = map(int, input().split())

A = min(A, K)
B = min(K - A, B)
C = min(K - A - B, C)
assert A + B + C >= K
#print(A, B, C)
print(A - C)

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

A = min(A, K)
B = min(K - A, B)
C = min(K - A - B, C)
assert A + B + C >= K
#print(A, B, C)
print(A - C)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
A, B, C, K = map(int,input().split())

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

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

Verdicts: Wrong Answer

Accepted