IDENTIFICATION DIVISION.
PROGRAM-ID. A-GoodInteger.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP.
   03 N   PIC 9 OCCURS 4.
 
PROCEDURE DIVISION.
  ACCEPT INP.

  IF ((N(1) + N(2) + N(3)) / 3 = N(1)) OR
     ((N(2) + N(3) + N(4)) / 3 = N(2))
    DISPLAY 'Yes'
  ELSE
    DISPLAY 'No'
  END-IF. 

  STOP RUN.
