IDENTIFICATION DIVISION.
PROGRAM-ID. 149B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP PIC X(100).
01 A   PIC 9(13).
01 B   PIC 9(13).
01 K   PIC 9(13).
01 W-A PIC Z(12)9.
01 W-B PIC Z(12)9.

PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO A B K.
*>
  PERFORM UNTIL K <= 0
    EVALUATE TRUE
      WHEN A > K
        COMPUTE A = A - K
        MOVE 0  TO K
      WHEN A > 0 
        COMPUTE K = K - A
        MOVE 0  TO A
      WHEN B > 0 AND B > K
        COMPUTE B = B - K
        MOVE 0  TO K
      WHEN B > 0    
        COMPUTE K = K - B
        MOVE 0  TO B
      WHEN OTHER
        MOVE 0  TO K
    END-EVALUATE
  END-PERFORM.
*>
  MOVE A TO W-A
  MOVE B TO W-B
  DISPLAY FUNCTION TRIM(W-A) ' ' FUNCTION TRIM(W-B).
*>
  STOP RUN.
