AtCoder Beginner Contest 149 - Greedy Takahashi

Takahashi has A cookies, and Aoki has B cookies.
Takahashi will do the following action K times:
 - If Takahashi has one or more cookies, eat one of his cookies.
 - Otherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.
 - If they both have no cookies, do nothing.
In the end, how many cookies will Takahashi and Aoki have, respectively?

-----Constraints-----
 - 0 \leq A \leq 10^{12}
 - 0 \leq B \leq 10^{12}
 - 0 \leq K \leq 10^{12}
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
A B K

-----Output-----
Print the numbers of Takahashi's and Aoki's cookies after K actions.

-----Sample Input-----
2 3 3

-----Sample Output-----
0 2

Takahashi will do the following:
 - He has two cookies, so he eats one of them.
 - Now he has one cookie left, and he eats it.
 - Now he has no cookies left, but Aoki has three, so Takahashi eats one of them.
Thus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.

Source: atcoder | Difficulty: EASY


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


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


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


(A, B, K) = map(int, input().split())
t = max(0, A - K)
a = max(0, A + B - K - t)
print(t, a)


(A, B, K) = map(int, input().split())
a = max(A - K, 0)
K -= A - a
b = max(B - K, 0)
print(a, b)


(a, b, k) = map(int, input().split())
if a >= k:
	print(a - k, b)
else:
	print(0, max(b - (k - a), 0))


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


a = input()
a = a.split()
k = int(a[2])
b = int(a[1])
a = int(a[0])
d = b
c = a - k
if c < 0:
	c = 0
if c == 0:
	d = b - k + a
if d < 0:
	d = 0
print(c, d)


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


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


(a, b, n) = map(int, input().split())
print(max(a - n, 0), max(b - max(n - a, 0), 0))


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


(a, b, k) = map(int, input().split())
ta = a - min(a, k)
k -= a - ta
b -= min(b, k)
print(ta, b)


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


(t, a, k) = map(int, input().split())
T = max(t - k, 0)
k -= t - T
A = max(a - k, 0)
print(T, A)


(A, B, K) = map(int, input().split())
k = max(K - A, 0)
print(max(A - K, 0), max(B - k, 0))


(a, b, k) = map(int, input().split())
remain = a - k
takahashi = remain
aoki = b
if remain < 0:
	takahashi = 0
	aoki = b + remain
print(str(takahashi) + ' ' + str(aoki if aoki > 0 else 0))


(A, B, K) = map(int, input().split())
if A >= K:
	print(A - K, B)
else:
	print(0, max(B + A - K, 0))


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


import math
from collections import Counter
from itertools import product
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(map(int, input().split()))
(a, b, k) = mi()
if a <= k:
	print(0, max(0, b - (k - a)))
else:
	print(a - k, b)


(A, B, K) = map(int, input().split())
C = max(0, A + B - K)
B2 = min(C, B)
A2 = C - B2
print(A2, B2)


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


(a, b, k) = map(int, input().split())
d = min(a, k)
a -= d
k -= d
d = min(b, k)
b -= d
k -= d
print(a, b)


(a, b, k) = map(int, input().split())
if a >= k:
	a -= k
	print(a, b)
	return
else:
	k -= a
	a = 0
if b >= k:
	b -= k
	print(a, b)
	return
else:
	b = 0
print(a, b)


(A, B, K) = map(int, input().split())
ret_A = A
ret_B = B
if A + B <= K:
	ret_A = 0
	ret_B = 0
elif A <= K <= A + B:
	ret_A = 0
	ret_B = B - (K - A)
else:
	ret_A = A - K
	ret_B = B
print(ret_A, ret_B, sep=' ')


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


(a, b, k) = map(int, input().split())
takahashi_list = [0, a - k]
aoki_list = [0, b + min(takahashi_list)]
print(max(takahashi_list), max(aoki_list))


(n, m, k) = map(int, input().split())
if n >= k:
	print(n - k, m)
else:
	if m - (k - n) < 0:
		m = 0
	else:
		m -= k - n
	print(0, m)


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


(t, a, c) = map(int, input().split())
t1 = t - c
a1 = a + min(0, t - c)
print(max(0, t1), max(0, a1))


from typing import List

def answer(a: int, b: int, k: int) -> List[int]:
	if k <= a:
		a -= k
	elif k <= a + b:
		b -= k - a
		a = 0
	else:
		a = 0
		b = 0
	return [a, b]

def main():
	(a, b, k) = map(int, input().split())
	(a, b) = answer(a, b, k)
	print(a, b)

def __starting_point():
	main()
__starting_point()


(A, B, K) = map(int, input().split())
a = min(A, K)
b = min(B, K - a)
print(A - a, B - b)


(A, B, C) = map(int, input().split())
if A < C:
	B = B - (C - A)
	A = 0
else:
	A = A - C
print(A, max(B, 0))


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


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


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


(A, B, K) = map(int, input().split())
if A - K <= 0:
	K2 = K - A
	A_ans = 0
	if B - K2 <= 0:
		B_ans = 0
	else:
		B_ans = B - K2
else:
	A_ans = A - K
	B_ans = B
print(A_ans, B_ans)


(a, b, k) = (int(n) for n in input().split())
if k < a:
	print(a - k, b)
elif a <= k <= a + b:
	print('0', b - (k - a))
else:
	print('0', '0')


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
if a >= c:
	print(a - c, b)
if a < c <= a + b:
	print(0, a + b - c)
if c > a + b:
	print(0, 0)


(A, B, K) = [int(n) for n in input().split()]
if 0 <= K < A:
	(A, B) = (A - K, B)
elif A <= K < A + B:
	(A, B) = (0, A + B - K)
elif A + B <= K:
	(A, B) = (0, 0)
print(A, B)


(a, b, k) = list(map(int, input().split()))
rem_a = max(a - k, 0)
k = max(k - a, 0)
rem_b = max(b - k, 0)
print(str(rem_a) + ' ' + str(rem_b))


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


def slove():
	(A, B, K) = map(int, input().split())
	if A > K:
		print(A - K, B)
	else:
		print(0, max(0, -K + (A + B)))

def __starting_point():
	slove()
__starting_point()


(a, b, k) = map(int, input().split())
eat1 = min(a, k)
k -= eat1
eat2 = min(b, k)
print(a - eat1, b - eat2)


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


(a, b, k) = (int(i) for i in input().split())
e = min(a, k)
a -= e
k -= e
b -= min(b, k)
print(a, b)


(a, b, k) = (int(x) for x in input().split())
c = a
if a + b <= k:
	a = 0
	b = 0
elif a <= k:
	a = 0
	b = b + c - k
elif a > k:
	a = a - k
c = str(a) + ' ' + str(b)
print(c)


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


(a, b, k) = map(int, input().split())
t = a - min(a, k)
k -= min(a, k)
q = b - min(k, b)
print(t, q)


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


(t, a, k) = map(int, input().split())
t = t - k
if t < 0:
	a += t
	t = 0
if a < 0:
	a = 0
print(t, a)


def solve(A: int, B: int, K: int):
	if A >= K:
		return f'{A - K} {B}'
	elif A + B >= K:
		return f'0 {A + B - K}'
	else:
		return '0 0'

def main():
	(A, B, K) = list(map(int, input().split()))
	answer = solve(A, B, K)
	print(answer)

def __starting_point():
	main()
__starting_point()


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


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


(A, B, K) = map(int, input().split())
x = min(A, K)
y = min(B, K - x)
print(A - x, B - y)


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


(a, b, k) = map(int, input().split())
a = a - k
if a < 0:
	b += a
	a = 0
	if b < 0:
		b = 0
print(str(a) + ' ' + str(b))


(A, B, K) = list(map(int, input().split()))
k = min(A, K)
print(A - k, max(0, B - (K - k)))


(A, B, K) = map(int, input().split())
if A >= K:
	ans_a = A - K
	ans_b = B
elif A < K and A + B >= K:
	K = K - A
	ans_a = 0
	ans_b = B - K
else:
	ans_a = 0
	ans_b = 0
print(str(ans_a) + ' ' + str(ans_b))


(a, b, k) = map(int, input().split())
li = [0, 0]
li[0] = max(a - k, 0)
li[1] = max(min(b - (k - a), b), 0)
print(*li)


(A, B, K) = map(int, input().split())
print(max(0, A - K), max(0, B - abs(max(0, K - A))))


import numpy as np
(A, B, K) = map(int, input().split())
if K > A:
	a = 0
	B = max(B - (K - A), 0)
else:
	a = A - K
print(a, B)


[A, B, K] = list(map(int, input().split()))
X = max(0, A - K)
Y = max(0, min(B, B - (K - A)))
print(X, Y)


(A, B, K) = map(int, input().split())
print(A - min(A, K), B - min(B, K - min(A, K)))


(a, b, k) = map(int, input().split())
y = min(a, k)
z = min(b, k - y)
print(a - y, b - z)


(a, b, k) = map(int, input().split())
t = min(a, k)
a -= t
k -= t
u = min(b, k)
b -= u
print(a, b)


(A, B, K) = map(int, input().split())
print(max(0, A - K), end=' ')
K = max(0, K - A)
print(max(0, B - K))


(a, b, k) = map(int, input().split())
ra = max(a - k, 0)
if k > a:
	b = max(b - (k - a), 0)
print(ra, b)


(a, b, k) = map(int, input().split())
takahashi = [0, a - k]
aoki = [0, b + min(takahashi)]
print('{takahashi} {aoki}'.format(takahashi=max(takahashi), aoki=max(aoki)))


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


(a, b, k) = map(int, input().split())
x = min(a, k)
a -= x
k -= x
y = min(b, k)
b -= y
print(a, b)


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


(A, B, K) = map(int, input().split())
T = max(0, A - K)
print(T, max(0, B - K + A - T))


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


(a, b, k) = map(int, input().split())
aa = max(a - k, 0)
rest = max(k - a, 0)
bb = max(b - rest, 0)
print(f'{aa} {bb}')


(a, b, c) = map(int, input().split())
rem = min(a, c)
a -= rem
c -= rem
rem = min(b, c)
b -= rem
print(a, b)


(a, b, k) = map(int, input().split())
t = min(a, k)
s = min(b, k - t)
print(a - t, b - s)


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


(A, B, K) = map(int, input().split())
rA = max(0, A - K)
rB = max(0, B - (K - (A - rA)))
print(rA, rB)


(A, B, K) = map(int, input().split())
temp = A
if K >= A:
	K = K - A
	A = 0
else:
	A = A - K
	K = 0
if B >= K:
	B = B - K
else:
	B = 0
print('{} {}'.format(A, B))


(a, b, k) = [int(x) for x in input().split()]
if a > k:
	print(a - k, b)
else:
	print(0, max(0, a + b - k))


(a, b, k) = map(int, input().split())
taka = a - k
if taka < 0:
	aoki = b - abs(taka)
	taka = 0
	if aoki < 0:
		aoki = 0
else:
	aoki = b
print(taka, aoki)


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


(a, b, k) = map(int, input().split())
print(' '.join(map(str, [max(0, a - k), max(0, b - max(0, k - a))])))


(T, A, K) = map(int, input().split())
S = T
T -= min(T, K)
K = K - (S - T)
A -= min(A, K)
print(T, A)


import sys
(a, b, k) = map(int, input().split())
if a >= k:
	print(a - k, b)
	return
if b >= k - a:
	print(0, b - (k - a))
	return
print(0, 0)


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

def sum():
	nonlocal A, B, K
	if A >= K:
		return (A - K, B)
	else:
		a = K - A
		A = 0
		if B >= a:
			return (A, B - a)
		else:
			return (A, 0)
print(*sum())


(A, B, K) = map(int, input().split())
(A, rem) = (max(A - K, 0), max(K - A, 0))
B = max(B - rem, 0)
print(A, B)


(A, b, k) = map(int, input().split())
a = A - min(A, k)
k -= min(A, k)
b -= min(b, k)
print(a, b)