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

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

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(A: int, B: int, C: int, K: int):
    if K <= A:
        print(K)
    elif K <= A+B:
        print(A)
    else:
        print(A - (K-A-B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = min(A, K)
z = max(0, min(C, K - A - B))

print(x - z)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

n1 = min(A, K)
ans = n1
K -= n1

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

n3 = min(C, K)
ans -= n3

print(ans)

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	a,b,c,k = l
	if(k <= a):
		return k
	elif(k <= a+b):
		return a
	else:
		return a-(k-a-b)
	

l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
ans += max(min(a, k), 0)
k -= a
k -= b
ans -= max(min(c, k), 0)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

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

Submission status: Accepted

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

res = 0
res += min(A, K)
K -= min(A, K)

if K != 0:
    K -= min(B, K)

if K != 0:
    res -= min(C, K)

print(res)

Submission status: Accepted

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

Submission status: Accepted

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


t = min(A, K)
K = K - min(A, K)
K = K - min(B, K)
t = t - min(C, K)

print(t)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    a,b,c,k = map(int , input().split())
    s = 0
    s += min(a , k)
    k -= min(k , a)

    k -= min(k , b)

    s -= min(k , c)
    print(s)
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0

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

bb = min(b, k)
k -= bb

cc = min(c, k)
ans -= cc

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(A: int, B: int, C: int, K: int):
    if K <= A:
        print(K)
    elif K <= A+B:
        print(A)
    else:
        print(A-(K-(A+B)))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    a, b, c, k = map(int, input().split())
    answer = min(a, k)
    k -= min(a, k)
    if k > 0:
        k -= min(b, k)
    if k > 0:
        answer -= min(k, c)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    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))
resolve()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    a,b,c,k=MI()
    p=min(a,k)
    m=max(k-(a+b),0)
    print(p-m)

main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B,C,K = inputIL()

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

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


a, b, c, k = list(map(int, sys.stdin.buffer.readline().split()))

ans = 0
cnt = min(a, k)
a -= cnt
k -= cnt
ans += cnt
cnt = min(b, k)
b -= cnt
k -= cnt
cnt = min(c, k)
c -= cnt
k -= cnt
ans -= cnt
print(ans)

Submission status: Accepted

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

    return a - c

print(main())

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


def main():
    A, B, C, K = inpl()
    if K <= A:
        print(K)
    elif K <= A + B:
        print(A)
    else:
        print(A - (K - A - B))
    return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
A = int(input('A = '))
B = int(input('B = '))
C = int(input('C = '))
K = int(input('Selected number = '))
#----------以上入力----------
if A+B >= K:
    print(A)
else:
    print(A-(K-A-B))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A, B, C, K = map(int, input().split())
# 1:A枚, 0:B枚, -1:C枚, K枚を選ぶ
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())
# 1:A枚, 0:B枚, -1:C枚, K枚を選ぶ
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)

Submission status: Runtime Error

Solution code:
a,b,c,k = map(int,input().split())
m = min(k,a)
if m == k :
    n = 0
    l = 0
n = min(k-a,b)
if n == k=a :
    l = 0
l = min(k-a-b,c)
print(1*m+0*n+(-1)*l)

Submission status: Runtime Error

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

a = K - A #Aのカードを引いた後のB,Cの数
b = K - A - B #Bのカードで水増しした後のCの数

if A = 0:
    print((-1)*b)
elif A > 0:
    if b >= 0:
        print(A - b)
    elif b < 0:
        print(A)

Submission status: Runtime Error

Solution code:
a,b,c,k = map(int,input().split())
ans = 0
cun = 0
for i in range(a):
    if cun <= k:
        cun += 1
        ans += 1
    else:
        break
for i in range(b):
    if cun <= k:
        cun += 1
    else:
        break
for i in renge(c):
    if cun <= k:
        cun += 1
        ans -= 1
pritn(ans)

Submission status: Runtime Error

Solution code:
a,b,c,k = map(int,input().split())
ans = 0
cun = 0
for i in range(a):
    if cun <= K:
        cun += 1
        ans += 1
    else:
        break
for i in range(b):
    if cun <= K:
        cun += 1
    else:
        break
for i in renge(c):
    if cun <= k:
        cun += 1
        ans -= 1
pritn(ans)

Submission status: Runtime Error

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

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:
A, B, C, K = map(int, input().split())
lst = [1] * A + [0] * B + [-1] * C
print(sum(sorted(lst)[-K:]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

l = [1]*A + [0]*B + [-1]*C
ans = sum(l[:K])

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
r=input().split()
A=int(r[0])
B=int(r[1])
C=int(r[2])
K=int(r[3])
d_a=[1]*A
d_b=[0]*B
d_c=[-1]*C
d=d_a+d_b+d_c
if K>A+B+C:
    print(A-B)
else:
    ans=0
    for i in range(K):
        ans+=d[i]
    print(ans)

Submission status: Runtime Error

Solution code:
r=input().split()
A=int(r[0])
B=int(r[1])
C=int(r[2])
K=int(r[3])
d_a=[1]*A
d_b=[0]*B
d_c=[-1]*C
d=d_a+d_b+d_c
ans=0
for i in range(K):
    ans+=d[i]
print(ans)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

a, b, c, k = Is()
nums = sorted([1] * a + [0] * b + [-1] * c, reverse=True)
print(np.sum(nums[:k]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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:
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-map(inat,input().split())
ans=0
ans+=min(k,a)
k-=min(k,a)
k-=min(k,b)
ans-=min(k,c)
print(ans)

Submission status: Runtime Error

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

num_list = [1] * a + [0] * b + [-1] * c

count = sum(num_list[:k])
print(count)

Submission status: Runtime Error

Solution code:
a, b, c, k = map(int, input().split())
l = [1]*a
l.extend([0]*b)
l.extend([-1]*c)
print(sum(l[:k]))

Submission status: Runtime Error

Solution code:
a, b, c, k = map(int, input().split())
l = [1]*a + [0]*b + [-1]*c
print(sum(l[:k]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a, b, c, k = [int(i) i in input().split(" ")]
print(min(a, k) - max(0, k-a-b))

Submission status: Runtime Error

Solution code:
a, b, c, k = [int(i) in input().split(" ")]
print(min(a, k) - max(0, k-a-b))

Submission status: Runtime Error

Solution code:
if a >= k:
	print(a)
elif 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())
all_list=[1]*a+[0]*b+[-1]*c
#print(all_list)
print(sum(all_list[:k]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

if(S==T[0:len(S)]):
  print(Yes)
 else:
    print(No)

Submission status: Runtime Error

Solution code:
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
 
a,b,c,k = Mi()
if k <= a:
  ans = k
  exit(0)
ans = a
k -= a
if k > b:
  ans -= k-b
  
print(ans)

Submission status: Runtime Error

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

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

print( sum(l[:K]) )

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
k = int(input())
s = 0
if 0 < a and 0 < k:
    s += a
    k -= a
elif 0 < b and 0 < k:
    k -= b
elif 0 < c and 0 < k:
    s -= c
    k -= c
print(s)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
k = int(input())
s = 0
while(0 < a and 0 < k):
    s += 1
    k -= 1
    a -= 1
while(0 < b and 0 < k):
    k -= 1
    b -= 1
while(0 < c and 0 < k):
    s -= 1
    k -= 1
    c -= 1
print(s)

Submission status: Runtime Error

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

if  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(k < a):
    pritn(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())

lst_1 = [1] * a
lst_2 = [0] * b
lst_3 = [-1] * c
lst_1.extend(lst_2)
lst_1.extend(lst_3)

ans = sum(lst_1[0:k])
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
a,b,c,k = map(int,input().split())
l = [1]*a + [0]*b + [-1]*c
print(sum(l[:k]))

Submission status: Runtime Error

Solution code:
a,b,c,k = map(int,input().split())
l = [1]*a + [0]*b + [-1]*c
print(sum(l[:k])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if a>=k:
  print(a)
  break()
else:
  if k-a<b:
    print(a)
  else:
    c=k-a-b
    print(a-c)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
ans = False
a, b, c, k = map(int, input().split()
ans += min(k, a)
k -= min(k, a)
k -= min(k, b)
ans -= min(k, c)
print(ans)

Submission status: Runtime Error

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

ans=0

if a>= k:
  print(k)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()
t = input()
a = len(s)

if len(s) > 10 or len(s) < 1:
  print('no')
else:
  if t[0:a] != s:
    print('no')
  else:
    if len(t) == len(s) + 1:
      print('yes')

Submission status: Runtime Error

Solution code:
def main():
  s = input()
  t = input()
  a = len(s)

  if len(s) > 10 or len(s) < 1:
    print('no')
  else:
    if t[0:a] != s:
      print('no')
    else:
      if len(t) == len(s) + 1:
        print('yes')

main()

Submission status: Runtime Error

Solution code:
a, b, c, k = map(int, input().split())
l = [1] * a + [0] * b + [-1] * c
print(sum(l[:k]))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
if K < A:
  print(A)
elif A <= K and B >= (K-A):
  print(A)
else:
  print(A - (K-A-B))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

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

ans = []

a_list = list(range(a + 1))
b_list = list(range(b + 1))

for l in a_list:
    for m in b_list:
        ans.append(l - (k - l - m))

print(max(ans))

Submission status: Runtime Error

Solution code:
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    a,b,c,k = IL()
    l = [1]*a+[0]*b+[-1]*c
    print(sum(l[:k]))
    return

if __name__=='__main__':
    Main()

Submission status: Runtime Error

Solution code:
sum_num = []
card_num = [1,0,-1]
for i,card in enumerate(a[0:3]):
  if card > a[3]:
    sum_num.append(a[3] * card_num[i])
    a[3] -= a[3]
  else:
    sum_num.append(card * card_num[i])
    a[3] -= card
print(sum(sum_num))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

s = [1] * a + [0] * b + [-1] * c
print(sum(s[:k]))