Problem:


Score : 200 points

Problem Statement

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

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

Constraints

All values in input are integers.

0 \leq A, B, C

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

Input

Input is given from Standard Input in the following format:

A B C K

Output

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

Sample Input 1

2 1 1 3

Sample Output 1

2

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

Sample Input 2

1 2 3 4

Sample Output 2

0

Sample Input 3

2000000000 0 0 2000000000

Sample Output 3

2000000000



Sample input:
2 1 1 3


Sample output:
2

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;

  int ans;

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

  cout << ans << endl;

  return 0;
}

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    A, B, C, K = map(int,read().split())
    t = [1]*A+[0]*B+[-1]*C
    print(sum(t[:K]))
    #a, b, c = map(int,read().split())
    #l = [int(read()) for _ in range(5)]
    

 
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    A, B, C, K = map(int,read().split())
    t = [1]*A+[0]*B+[-1]*C
    print(sum(t[:K]))
    #a, b, c = map(int,read().split())
    #l = [int(read()) for _ in range(5)]
    

 
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
lst = []

for i in range(K):
    input() # this input is not useful, so it's not going to be a variable
    lst.extend(input().split()) # use 'extend', not 'append'

lst_to_dict = {}
for a in lst:
    lst_to_dict[a] = lst_to_dict.get(a, 0)
print(N-len(lst_to_dict))

Submission status: Runtime Error

Solution code:
# 4つの入力
a = input()

# スペースで区切り処理
inputs = a.split(' ')

# A,B,C,Kに代入
A = int(inputs[0])
B = int(inputs[1])
C = int(inputs[2])
K = int(inputs[3])

# 最終的結果の数字
final = int(0)

# 残りの変数
left = int(0)

# パターン1-1
# K（取る枚数）がA(１のカード)より多い時、A（1のカード）枚取り、
# left(残りの取る枚数)に代入する
if K >= A:
        left = K - A
        final = final + A
        # print(f'1-1,残り枚数 {left}')
        # print(f'1-1,結果数 {i}')

# パターン2-1
# left(残り枚数)がB(０のカード)より多い時B(０のカード)枚取る
# leftに残りの枚数を代入する
        if left >= B:
            left = left - B
            # print(f'2-1残り枚数 {left}')
            # print(f'2-1結果数 {i}')

#パターン3-1
#left(残り枚数)が0より多い時C(-1のカード)をleft(残り枚数)枚取る
            if left > 0:
                final = final - left
                # print(f'3-1結果数{i}')
                print(final)


#パターン3-2
#C(-1)のカードをleft(残り枚数)枚とる（終了）
            else :
                    #left = left - left
                    # print(f'3-2結果数{i}')
                    print(final)
#パターン2-2
# B(0のカード)がleft(残り枚数)より多い時B(0のカード)をleft(残り枚数)枚取る（終了）
        elif B > left:
            # print(f'2-2結果数{i}')
            print(final)

# パターン1-2
# A(１のカード)がK(取る枚数)より多い時K枚取る（終了）
elif A > K:
    i = i+A
    # print(f'1-2結果数{i}')
    print(final)

Submission status: Runtime Error

Solution code:
A,B,C,K=map(int, input().split(' '))
A_array, B_array, C_array, cards = [1] * A, [0] * B, [-1] * C, []
cards.extend(A_array)
cards.extend(B_array)
cards.extend(C_array)
total = 0
for _ in range(K):
    tmp = max(cards)
    total += tmp
    cards.remove(tmp)

print(total)

Submission status: Runtime Error

Solution code:
a,b,c,d = input().split()
if int(d) < int(a):
    print(int(d))
elif int(d) < int(a) + int(b):
    print(int(a) + (int(d) - int(a))* 0)
else:
    res = int(a) - (int(d)-(int(a)+ int(b)))
    print(res)
~

Submission status: Runtime Error

Solution code:
l = list(map(int,input().split()))
res = 0
k = l[3]
r = -1 
for i in range (3) :
  
  if res + a[i] <= k :
    res += a[i]
  else: 
    r = i
    break
d = res - k
if r != 2:
  print(res)
else :
  print(res -d)

Submission status: Runtime Error

Solution code:
a, b, c, x = map(int, input().split())
alist = [1]
blist = [0]
clist = [-1]
list = alist*a + blist*b + clist*c
print(sum(list[:x]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

max_num = 0

while k>0:
if a>0:
  max_num += a
  k -= a
  if k>0:
    k -= b
    if c>k:
      max_num = 0
    else:
      max_num -= c
      k -= c
print(max_num)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0

while(k > 0):
  {
    if (a > 0)
      a-=1
      ans+=1
      k-=1
    elif (a == 0 & b > 0){
      b-=1
      k-=1
    }
    else (a == 0 & b == 0 & c > 0) {
      c-=1
      ans-=1
      k-=1
    }
  }
print(ans)

Submission status: Runtime Error

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

ans = 0

while(k > 0):
  {
    if (a > 0)
      a-=1
      ans+=1
      k-=1
    if (a == 0 & b > 0){
      b-=1
      k-=1
    }
    if (a == 0 & b == 0 & c > 0) {
      c-=1
      ans-=1
      k-=1
    }
  }
print(ans)

Submission status: Runtime Error

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

ans = 0

while(k > 0):
  {
    if (a != 0)
      a-=1
      ans+=1
      k-=1
    if (a == 0 & b > 0){
      b-=1
      k-=1
    }
    if (a == 0 & b == 0 & c > 0) {
      c-=1
      ans-=1
      k-=1
    }
  }
print(ans)

Submission status: Runtime Error

Solution code:
 = 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)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
if k <= a:
    print(k)
elif k <= a +b:
    print(a)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
K = int(input())

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

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K > A:
    N = K - A
    all_number = 1*A
    print(all_number)

    if N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    else:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K > A:
    N = K - A //2
    all_number = 1*A //3

    if N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    else:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N <= B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        if N >= C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Submission status: Runtime Error

Solution code:
if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        if N >= C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
K = int(input())

all_number = 0

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        all_number = all_number - 1*N
        print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Submission status: Runtime Error

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

a = [1] * A
b = [0] * B
c = [-1] * C

X = a + b + c
print(sum(X[:K]))

Submission status: Runtime Error

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

a = [1] * A
b = [0] * B
c = [-1] * C
X = a + b + c
print(sum(X[:K]))

Submission status: Runtime Error

Solution code:
#入力させる
A = int(input())
B = int(input())
C = int(input())
K = int(input())
#the number of A,B,C for given K
if K-A<0: #K<Aであれば、1をＫ枚選ぶ。
    NA = K
    NB = 0
    NC = 0
else: #K≧Aであれば、1をA枚選び、残りのK-A枚は0 or -1 を選ぶ。
    NA = A
    if (K-A)-B<0: #K-A<Bであれば、K-A枚全て0を選べる
        NB = K-A
        NC = 0
    else: #K-A≧Bであれば、0をB枚選び、残りのK-A-B枚は0 or -1 を選ぶ。
        NB = B
        NC = K-A-B

#最大値を求める
sum = NA *1 + NB *0 + NC *(-1)

#出力
print(sum)

Submission status: Runtime Error

Solution code:
A, B, C, K = input().strip().split()
A, B, C, K = [int(A), int(B), int(C), int(K)]
summary = A
if A > K:
  summary = K
else:
  minus = K - A - B
if minus > 0:
  summary = summary - minus
print(str(summary))

Submission status: Runtime Error

Solution code:
A, B, C, K = input().strip().split()
A, B, C, K = [int(A), int(B), int(C), int(K)]
summary = A
if A > K:
  minus = K - A - B
if minus > 0:
  summary = summary - minus
print(str(summary))

Submission status: Runtime Error

Solution code:
A, B, C, K = input().strip().split()
A, B, C, K = [int(A), int(B), int(C), int(K)]
summary = A
minus = K - A - B
if minus > 0:
  answer = summary - minus
print(str(answer))

Submission status: Runtime Error

Solution code:
A, B, C, K = input().strip().split()
A, B, C, K = [int(A), int(B), int(C), int(K)]
summary = A
minus = K - A - B
if minus > 0:
  answer = summary + minus
print(str(answer))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k <= a) cout << k << endl;
  else if(k <= a + b) cout << a << endl;
  else cout << a - (k - a - b) << endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
S=input()
T=input()


if len(S)+1==len(T):
    for i in range(len(S)): #回数の時は絶対range()
        if S[i]==T[i]:
            a='ok'
            continue
        else:
            a='no'
            break
else:
    print('no')

if a=='ok':
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

if K<=A:
  print(str(K))
elif k<=A+B:
  print(str(A))
else:
  print(str(A-(C-(k-(A+B))))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
K = int(input())

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

Submission status: Runtime Error

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

ans = 0
while a > 0:
  a - 1
  k - 1
  ans += 1
  if k = 0:
    brake
  if a = 0:
    brake
while b > 0:
  b - 1
  k - 1
  ans += 0
  if k = 0:
    brake
  if b = 0:
    brake
while c > 0:
  c - 1
  k - 1
  ans -= 1
  if k = 0:
    brake
  if c = 0:
    brake

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

val_a = [1] * a
val_b = [0] * b
val_c = [-1] * c

val_a.extend(val_b)
val_a.extend(val_c)
print(val_a)

print(sum(val_a[:k]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A=input() B=input() C=input() K=input()
if (K<=A):
  print(K)
elif (A<K<=A+B):
  print(A)
else:
  print(2A+B-K)

Submission status: Runtime Error

Solution code:
A=input() B=input() C=input() K=input()
if (K<=A):
  print(K)
elif (A<K<=A+B):
  print(A)
else:
  print(2A+B-k)

Submission status: Runtime Error

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

if K >= A:
    Anum = A
    N = K - A
else:
    Anum = K

if N >= B:
    Bnum = B
    N = N - B
else:
    Bnum = N

Cnum = N

Total = Anum * 1 + Bnum * 0 + Cnum * (-1)

print(Total)

Submission status: Runtime Error

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

A = [1]*A
B = [0]*B
C = [-1]*C

all_data = A+B+C

print(sum(all_data[:K]))

Submission status: Runtime Error

Solution code:
import random

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

A = [1]*A
B = [0]*B
C = [-1]*C

all_data = A+B+C

print(sum(all_data[:K]))

Submission status: Runtime Error

Solution code:
import random

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

A = [1]*A
B = [0]*B
C = [-1]*C

all_data = A+B+C

ans = random.sample(all_data, K)

print(sum(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

if A >= K:
    print(A)
elif (A + B) >= K:
    print(A)
else:
    for i in range(K):
        print(i)
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            continue
        elif B == (i + 1 - A):
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)

Submission status: Runtime Error

Solution code:
def main():
    A, B, C, K = map(int, input().split())
    li = [1] * A
    li += ([0] * B)
    li += ([-1] * C)
    print(sum(li[:K]))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    A, B, C, K = map(int, input().split())
    li = ([1] * A) + ([0] * B) + ([-1] * C)
    print(sum(li[:K]))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
one = int(input())
zero = int(input())
ng_one = int(input())
card = int(input())

card_list = []
for i in range(one):
    card_list.append(1)
for i in range(zero):
    card_list.append(0)
for i in range(ng_one):
    card_list.append(-1)

print(sum(card_list[:card]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# input
A = input()
B = input()
C = input()
K = input()

# parse int
A = int(A)
B = int(B)
C = int(C)
K = int(K)

# result var
max_sum = 0

# check 1
max_sum = min(A, K)
K = K - max_sum

# check 0
if K > 0:
  K = K - min(B, K)

# check - 1
if K > 0:
  max_sum = max_sum - min(K, B)
# print result
print(max_sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
2000000000 0 0 200000000

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,C,K = map(int,input().split())
for a in range(A):
    if a == K:
        print(a)
        exit()
for b in range(B):
    if a+b == K:
        print(a)
        exit()
for c in range(C):
    if a+b+c == K:
        print(a-c)
        exit()

Submission status: Runtime Error

Solution code:
a, b, c, k = map(int, input().split())
s = 0
for in range(k):
  if a > 0:
    s += 1
    a -= 1
  elif b > 0:
    b += 0
  else:
    s += -1
print(s)

Submission status: Runtime Error

Solution code:
'''
if the value of k is less than or equal to a => print out k*1

but if value of k is more than the value of a -> use as many of the b cards as available

If the value of k is still more, use the c cards

'''

def easy(a,b,c,k):
    print(k*1)

def hard(a,b,c,k):
    total= 0
    sum = 0

    while total <k:
        if a>0:
            sum+=1
            total+=1
            a = a-1

        elif b>0 and a<=0:
            sum = sum + 0
            total+=1
            b = b-1

        elif a<=0 and b<=0 and c>0:
            sum = sum - 1
            total += 1
            c = c-1


    print(sum)


userInput = input()
userInput = userInput.replace(" ", "")

a,b,c,k = [int(e) for e in userInput]

a = int(a)
b = int(b)
c = int(c)
k = int(k)

if k<=a:
    easy(a,b,c,k)

if k>=a:
    hard(a,b,c,k)

Submission status: Runtime Error

Solution code:
'''
if the value of k is less than or equal to a => print out k*1

but if value of k is more than the value of a -> use as many of the b cards as available

If the value of k is still more, use the c cards

'''

def easy(a,b,c,k):
    print(k*1)

def hard(a,b,c,k):
    total= 0
    sum = 0

    while total <k:
        if a>0:
            sum+=1
            total+=1
            a = a-1

        elif b>0 and a<=0:
            sum = sum + 0
            total+=1
            b = b-1

        elif a<=0 and b<=0 and c>0:
            sum = sum - 1
            total += 1
            c = c-1


    print(sum)


userInput = input()
userInput.strip()
a,b,c,k = userInput.strip(" ")
a = int(a)
b = int(b)
c = int(c)
k = int(k)

if k<=a:
    easy(a,b,c,k)

if k>=a:
    hard(a,b,c,k)

Submission status: Runtime Error

Solution code:
def easy(a,b,c,k):
    print(k*1)

def hard(a,b,c,k):
    total= 0
    sum = 0

    while total <k:
        if a>0:
            sum+=1
            total+=1
            a = a-1

        elif b>0 and a<=0:
            sum = sum + 0
            total+=1
            b = b-1

        elif a<=0 and b<=0 and c>0:
            sum = sum - 1
            total += 1
            c = c-1


    print(sum)



a = int(input())
b = int(input())
c = int(input())
k = int(input())

if k<=a:
    easy(a,b,c,k)

if k>=a:
    hard(a,b,c,k)

Submission status: Runtime Error

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

S = A+B+C
result = 0

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

print(result)

Submission status: Runtime Error

Solution code:
inputs = list(map(lambda x: int(x), input().split()))
counter = ([1] * inputs[0]) + [0] * inputs[1] + [-1] * inputs[2]

if len(counter) < inputs[3]:
    inputs[3] = len(counter)
    
from functools import reduce

print(reduce(lambda x, y: x + y, counter[0:inputs[3]]))

Submission status: Runtime Error

Solution code:
inputs = list(map(lambda x: int(x), input().split()))
counter = [1] * inputs[0] + [0] * inputs[1] + [-1] * inputs[2]

from functools import reduce

print(reduce(lambda x, y: x + y, counter[0:inputs[3]]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a, b, c, k = int(input())
if a > k:
	print(sum(([1] * a)[:k]))
else:
	print(sum([1] * a))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,C,K=map(int,input().split())
X=[1]*A
Y=[0]*B
Z=[-1]*C
ANS=X+Y+Z
cnt=0
for i in range(K):
    cnt+=ANS[i]
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,C,K = map(int, input().split())
card_list = [1]*A + [0]*B + [-1]*C
 
print(sum(card_list[0:K]))

Submission status: Runtime Error

Solution code:
A,B,C,K = map(int, input().split())
card_list = (([1]*A).extend([0]*B)).extend([-1]*C)
 
print(sum(card_list[0:K]))

Submission status: Runtime Error

Solution code:
A,B,C,K = map(int, input().split())
card_list = (([1]*A).extend([0]*B)).append([-1]*C)

print(sum(card_list[0:K]))

Submission status: Runtime Error

Solution code:
A, B, C, K = (int(x) for x in input().split())
tmp = [1] * A + [0] * B + [-1] * C
ans = 0
ans = sum(tmp[0:K])
print(ans)

Submission status: Runtime Error

Solution code:
A, B, C, K = (int(x) for x in input().split())
tmp = [1] * A + [0] * B + [-1] * C
ans = 0
for k in range(K):
    ans += tmp[k]
print(ans)

Submission status: Runtime Error

Solution code:
if oneCard >= getCardNum: print(oneCard)
elif oneCard + zeroCard >= getCardNum: print(oneCard)
else: print(oneCard - (getCardNum - oneCard - zeroCard))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

"""
print(a)
print(b)
print(c)
print(k)
"""
if a >= k:
    print(a)

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

else:
    print(a-c)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    A = input()
    B = input()
    C = input()
    K = input()

    a = int(A)
    b = int(B)
    c = int(C)
    k = int(K)

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

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    A = input()
    B = input()
    C = input()
    K = input()

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

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    A = input()
    B = input()
    C = input()
    K = input()

    if A > K:
        print(K)
    elif A+B >k:
        print(A)
    else:
        print(2*A-K-B)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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