Skip to content
TheChatArchiveThe Chat Archive
DeepSeekDeepseek v3.2· deepseekHugging Face Frontier Reasoning Traces

Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action…

  1. User

    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.

    Examples

    Input

    2 3 3

    Output

    0 2

    Input

    500000000000 500000000000 1000000000000

    Output

    0 0

  2. DeepSeek Assistant

    We are asked to solve a problem: Takahashi and Aoki have A and B cookies. Takahashi does an action K times:

    • If Takahashi has >=1 cookie, he eats one of his cookies.
    • Else if Aoki has >=1 cookie, he eats one of Aoki's cookies.
    • Else (both have 0) do nothing.

    So essentially: Takahashi reduces his own cookies first, until he runs out, then starts reducing Aoki's cookies. After K actions (or until both are zero? Actually if both become zero earlier, then subsequent actions do nothing because both have 0, so they remain 0). So final numbers: Let eatenFromT = min(A, K). After that, remaining Takahashi cookies: A' = A - eatenFromT. Remaining actions after eating from Takahashi: K' = K - eatenFromT. Then eatenFromA = min(B, K'). Aoki's remaining: B' = B - eatenFromA. If K' > B then Aoki becomes 0, but there might be extra actions after both zero? But according to the process: after both zero, do nothing, so nothing changes. So final A = max(0, A - K)?? Actually careful: If A >= K, then A' = A - K, B' = B. If A < K, then A' = 0, K' = K - A, and B' = max(0, B - K'). So B' = max(0, B - (K - A)). So final answer: (max(0, A - K), max(0, B - (K - A))) but with the note that B - (K - A) could be negative, so take max with 0.

    So the solution: if A >= K: print(A - K, B) else: print(0, max(0, B - (K - A)))

    But constraints up to 1e12, so 64-bit integers. We need to handle Python ints (unlimited). So straightforward.

    Edge cases: A=0, B=0, K>0: final (0,0). Works. A=0, B=5, K=3: Since Takahashi has 0, he will eat Aoki's cookies: after 3 actions, B' = 2, A'=0. Our formula: A >= K? 0 >=3 false, so A'=0, K' = K - A = 3, B' = max(0, B - K') = 2. OK.

    A=5, B=0, K=10: A >= K? 5>=10 false, so A'=0, K'=10-5=5, B'=max(0,0-5)=0. final (0,0). Correct: after eating his 5, then tries to eat Aoki but none, so nothing for remaining actions.

    Thus implement.

    We should read input as three integers A, B, K.

    Output: print A' and B'.

    Will do.

    But let's double-check: Problem statement says "Takahashi will do the following action K times:" and the action: "If Takahashi has one or more cookies, eat one of his cookies." So it's always Takahashi who eats. Yes.

    Hence code.

    But also note that if A and B both 0, and K>0, after first action both are 0 and doing nothing. So final (0,0). Correct.

    Thus solution.

    But sometimes there is trick: The order of actions: he always reduces his own first. So simple.

    Now I'm thinking about whether there is any nuance: "Eat one of his cookies" meaning his own. So yes.

    Thus I'll code.

    But check example: Input 2 3 3 => A=2 < K=3? Actually 2<3, so A'=0, K'=1, B'=max(0,3-1)=2. So output 0 2 matches.

    Second example: 5e11 5e11 1e12: A=5e11, K=1e12, A < K so A'=0, K'=1e12 - 5e11 = 5e11, B'=max(0,5e11-5e11)=0 => (0,0). matches.

    All good.

    Now I'll produce final answer in code: read A, B, K; compute if A>=K: print(A-K, B) else: print(0, max(0, B-(K-A))).

    But note: we need to ensure that B - (K - A) may be negative, use max.

    I will write in Python.

    I'll also consider using direct formula: a_remaining = max(0, A-K) b_remaining = max(0, B - max(0, K-A))? Actually B gets reduced only if K > A, by the amount K-A. So b_remaining = max(0, B - (K - A) if K>A else 0). So we can compute: if K > A: b_remaining = max(0, B - (K - A)) else: b_remaining = B And a_remaining = max(0, A - K). So we can compute directly.

    Either way.

    I'll use the straightforward conditional.

    Complexity O(1).

    Thus final answer. ```python

    def solve() -> None: import sys A, B, K = map(int, sys.stdin.readline().split())

    if A >= K:
        # Takahashi only eats from his own cookies
        print(A - K, B)
    else:
        # Takahashi eats all his cookies, then from Aoki's
        remaining_actions = K - A
        b_remaining = max(0, B - remaining_actions)
        print(0, b_remaining)
    

    if name == "main": solve()