Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLUCK.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

      *
      * "Given an array representing a branch of a tree that has non-negative integer nodes
      * your task is to pluck one of the nodes and return it.
      * The plucked node should be the node with the smallest even value.
      * If multiple nodes with the same smallest even value are found return the node that has smallest index.
      *
      * The plucked node should be returned in a list, [ smalest_value, its index ],
      * If there are no even values or the given array is empty, return [].
      *
      * Example 1:
      * Input: [4,2,3]
      * Output: [2, 1]
      * Explanation: 2 has the smallest even value, and 2 has the smallest index.
      *
      * Example 2:
      * Input: [1,2,3]
      * Output: [2, 1]
      * Explanation: 2 has the smallest even value, and 2 has the smallest index.
      *
      * Example 3:
      * Input: []
      * Output: []
      *
      * Example 4:
      * Input: [5, 0, 3, 0, 4, 2]
      * Output: [0, 1]
      * Explanation: 0 is the smallest value, but  there are two zeros,
      * so we will choose the first zero, which has the smallest index.
      *
      * Constraints:
      * * 1 <= nodes.length <= 10000
      * * 0 <= node.value
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    if(len(arr) == 0): return []
    evens = list(filter(lambda x: x%2 == 0, arr))
    if(evens == []): return []
    return [min(evens), arr.index(min(evens))]

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLUCK-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PLUCK.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 4 TO L-ARR(1)
       MOVE 2 TO L-ARR(2)
       MOVE 3 TO L-ARR(3)

       CALL "PLUCK" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLUCK-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PLUCK.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-ARR(1)
       MOVE 2 TO L-ARR(2)
       MOVE 3 TO L-ARR(3)

       CALL "PLUCK" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLUCK-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PLUCK.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-ARR(1)
       MOVE 0 TO L-ARR(2)
       MOVE 3 TO L-ARR(3)
       MOVE 0 TO L-ARR(4)
       MOVE 4 TO L-ARR(5)
       MOVE 2 TO L-ARR(6)

       CALL "PLUCK" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLUCK-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PLUCK.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-ARR(1)
       MOVE 2 TO L-ARR(2)
       MOVE 3 TO L-ARR(3)
       MOVE 0 TO L-ARR(4)
       MOVE 5 TO L-ARR(5)
       MOVE 3 TO L-ARR(6)

       CALL "PLUCK" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLUCK-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PLUCK.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-ARR(1)
       MOVE 4 TO L-ARR(2)
       MOVE 8 TO L-ARR(3)
       MOVE 4  TO L-ARR(4)
       MOVE 8 TO L-ARR(5)

       CALL "PLUCK" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLUCK-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PLUCK.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 7 TO L-ARR(1)
       MOVE 6 TO L-ARR(2)
       MOVE 7 TO L-ARR(3)
       MOVE 1 TO L-ARR(4)

       CALL "PLUCK" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLUCK-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PLUCK.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 7 TO L-ARR(1)
       MOVE 9 TO L-ARR(2)
       MOVE 7 TO L-ARR(3)
       MOVE 1 TO L-ARR(4)

       CALL "PLUCK" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

      * '''
      * You are given a non-empty list of positive integers. Return the greatest integer that is greater than
      * zero, and has a frequency greater than or equal to the value of the integer itself.
      * The frequency of an integer is the number of times it appears in the list.
      * If no such a value exist, return -1.
      * Examples:
      * search([4, 1, 2, 2, 3, 1]) == 2
      * search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
      * search([5, 5, 4, 4, 4]) == -1
      * '''

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    frq = [0] * (max(lst) + 1)
    for i in lst:
        frq[i] += 1;

    ans = -1
    for i in range(1, len(frq)):
        if frq[i] >= i:
            ans = i

    return ans

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-LST(1)
       MOVE 5 TO L-LST(2)
       MOVE 5 TO L-LST(3)
       MOVE 5 TO L-LST(4)
       MOVE 1 TO L-LST(5)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 4 TO L-LST(1)
       MOVE 1 TO L-LST(2)
       MOVE 4 TO L-LST(3)
       MOVE 1 TO L-LST(4)
       MOVE 4 TO L-LST(5)
       MOVE 4 TO L-LST(6)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 3 TO L-LST(1)
       MOVE 3 TO L-LST(2)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 8 TO L-LST(1)
       MOVE 8 TO L-LST(2)
       MOVE 8 TO L-LST(3)
       MOVE 8 TO L-LST(4)
       MOVE 8 TO L-LST(5)
       MOVE 8 TO L-LST(6)
       MOVE 8 TO L-LST(7)
       MOVE 8 TO L-LST(8)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 2 TO L-LST(1)
       MOVE 3 TO L-LST(2)
       MOVE 3 TO L-LST(3)
       MOVE 2 TO L-LST(4)
       MOVE 2 TO L-LST(5)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 2 TO L-LST(1)
       MOVE 7 TO L-LST(2)
       MOVE 8 TO L-LST(3)
       MOVE 8 TO L-LST(4)
       MOVE 4 TO L-LST(5)
       MOVE 8 TO L-LST(6)
       MOVE 7 TO L-LST(7)
       MOVE 3 TO L-LST(8)
       MOVE 9 TO L-LST(9)
       MOVE 6 TO L-LST(10)
       MOVE 5 TO L-LST(11)
       MOVE 10 TO L-LST(12)
       MOVE 4 TO L-LST(13)
       MOVE 3 TO L-LST(14)
       MOVE 6 TO L-LST(15)
       MOVE 7 TO L-LST(16)
       MOVE 1 TO L-LST(17)
       MOVE 7 TO L-LST(18)
       MOVE 4 TO L-LST(19)
       MOVE 10 TO L-LST(20)
       MOVE 8 TO L-LST(21)
       MOVE 1 TO L-LST(22)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 3 TO L-LST(1)
       MOVE 2 TO L-LST(2)
       MOVE 8 TO L-LST(3)
       MOVE 2 TO L-LST(4)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 6 TO L-LST(1)
       MOVE 7 TO L-LST(2)
       MOVE 1 TO L-LST(3)
       MOVE 8 TO L-LST(4)
       MOVE 8 TO L-LST(5)
       MOVE 10 TO L-LST(6)
       MOVE 5 TO L-LST(7)
       MOVE 8 TO L-LST(8)
       MOVE 5 TO L-LST(9)
       MOVE 3 TO L-LST(10)
       MOVE 10 TO L-LST(11)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 8 TO L-LST(1)
       MOVE 8 TO L-LST(2)
       MOVE 3 TO L-LST(3)
       MOVE 6 TO L-LST(4)
       MOVE 5 TO L-LST(5)
       MOVE 6 TO L-LST(6)
       MOVE 4 TO L-LST(7)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 6 TO L-LST(1)
       MOVE 9 TO L-LST(2)
       MOVE 6 TO L-LST(3)
       MOVE 7 TO L-LST(4)
       MOVE 1 TO L-LST(5)
       MOVE 4 TO L-LST(6)
       MOVE 7 TO L-LST(7)
       MOVE 1 TO L-LST(8)
       MOVE 8 TO L-LST(9)
       MOVE 8 TO L-LST(10)
       MOVE 9 TO L-LST(11)
       MOVE 8 TO L-LST(12)
       MOVE 10 TO L-LST(13)
       MOVE 10 TO L-LST(14)
       MOVE 8 TO L-LST(15)
       MOVE 4 TO L-LST(16)
       MOVE 10 TO L-LST(17)
       MOVE 4 TO L-LST(18)
       MOVE 10 TO L-LST(19)
       MOVE 1 TO L-LST(20)
       MOVE 2 TO L-LST(21)
       MOVE 9 TO L-LST(22)
       MOVE 5 TO L-LST(23)
       MOVE 7 TO L-LST(24)
       MOVE 9 TO L-LST(25)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-LST(1)
       MOVE 9 TO L-LST(2)
       MOVE 10 TO L-LST(3)
       MOVE 1 TO L-LST(4)
       MOVE 3 TO L-LST(5)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 6 TO L-LST(1)
       MOVE 9 TO L-LST(2)
       MOVE 7 TO L-LST(3)
       MOVE 5 TO L-LST(4)
       MOVE 8 TO L-LST(5)
       MOVE 7 TO L-LST(6)
       MOVE 5 TO L-LST(7)
       MOVE 3 TO L-LST(8)
       MOVE 7 TO L-LST(9)
       MOVE 5 TO L-LST(10)
       MOVE 10 TO L-LST(11)
       MOVE 10 TO L-LST(12)
       MOVE 3 TO L-LST(13)
       MOVE 6 TO L-LST(14)
       MOVE 10 TO L-LST(15)
       MOVE 2 TO L-LST(16)
       MOVE 8 TO L-LST(17)
       MOVE 6 TO L-LST(18)
       MOVE 5 TO L-LST(19)
       MOVE 4 TO L-LST(20)
       MOVE 9 TO L-LST(21)
       MOVE 5 TO L-LST(22)
       MOVE 3 TO L-LST(23)
       MOVE 10 TO L-LST(24)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-LST(1)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 8 TO L-LST(1)
       MOVE 8 TO L-LST(2)
       MOVE 10 TO L-LST(3)
       MOVE 6 TO L-LST(4)
       MOVE 4 TO L-LST(5)
       MOVE 3 TO L-LST(6)
       MOVE 5 TO L-LST(7)
       MOVE 8 TO L-LST(8)
       MOVE 2 TO L-LST(9)
       MOVE 4 TO L-LST(10)
       MOVE 2 TO L-LST(11)
       MOVE 8 TO L-LST(12)
       MOVE 4 TO L-LST(13)
       MOVE 6 TO L-LST(14)
       MOVE 10 TO L-LST(15)
       MOVE 4 TO L-LST(16)
       MOVE 2 TO L-LST(17)
       MOVE 1 TO L-LST(18)
       MOVE 10 TO L-LST(19)
       MOVE 2 TO L-LST(20)
       MOVE 1 TO L-LST(21)
       MOVE 1 TO L-LST(22)
       MOVE 5 TO L-LST(23)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 2 TO L-LST(1)
       MOVE 10 TO L-LST(2)
       MOVE 4 TO L-LST(3)
       MOVE 8 TO L-LST(4)
       MOVE 2 TO L-LST(5)
       MOVE 10 TO L-LST(6)
       MOVE 5 TO L-LST(7)
       MOVE 1 TO L-LST(8)
       MOVE 2 TO L-LST(9)
       MOVE 9 TO L-LST(10)
       MOVE 5 TO L-LST(11)
       MOVE 5 TO L-LST(12)
       MOVE 6 TO L-LST(13)
       MOVE 3 TO L-LST(14)
       MOVE 8 TO L-LST(15)
       MOVE 6 TO L-LST(16)
       MOVE 4 TO L-LST(17)
       MOVE 10 TO L-LST(18)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-LST(1)
       MOVE 6 TO L-LST(2)
       MOVE 10 TO L-LST(3)
       MOVE 1 TO L-LST(4)
       MOVE 6 TO L-LST(5)
       MOVE 9 TO L-LST(6)
       MOVE 10 TO L-LST(7)
       MOVE 8 TO L-LST(8)
       MOVE 6 TO L-LST(9)
       MOVE 8 TO L-LST(10)
       MOVE 7 TO L-LST(11)
       MOVE 3 TO L-LST(12)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 9 TO L-LST(1)
       MOVE 2 TO L-LST(2)
       MOVE 4 TO L-LST(3)
       MOVE 1 TO L-LST(4)
       MOVE 5 TO L-LST(5)
       MOVE 1 TO L-LST(6)
       MOVE 5 TO L-LST(7)
       MOVE 2 TO L-LST(8)
       MOVE 5 TO L-LST(9)
       MOVE 7 TO L-LST(10)
       MOVE 7 TO L-LST(11)
       MOVE 7 TO L-LST(12)
       MOVE 3 TO L-LST(13)
       MOVE 10 TO L-LST(14)
       MOVE 1 TO L-LST(15)
       MOVE 5 TO L-LST(16)
       MOVE 4 TO L-LST(17)
       MOVE 2 TO L-LST(18)
       MOVE 8 TO L-LST(19)
       MOVE 4 TO L-LST(20)
       MOVE 1 TO L-LST(21)
       MOVE 9 TO L-LST(22)
       MOVE 10 TO L-LST(23)
       MOVE 7 TO L-LST(24)
       MOVE 10 TO L-LST(25)
       MOVE 2 TO L-LST(26)
       MOVE 8 TO L-LST(27)
       MOVE 10 TO L-LST(28)
       MOVE 9 TO L-LST(29)
       MOVE 4 TO L-LST(30)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 2 TO L-LST(1)
       MOVE 6 TO L-LST(2)
       MOVE 4 TO L-LST(3)
       MOVE 2 TO L-LST(4)
       MOVE 8 TO L-LST(5)
       MOVE 7 TO L-LST(6)
       MOVE 5 TO L-LST(7)
       MOVE 6 TO L-LST(8)
       MOVE 4 TO L-LST(9)
       MOVE 10 TO L-LST(10)
       MOVE 4 TO L-LST(11)
       MOVE 6 TO L-LST(12)
       MOVE 3 TO L-LST(13)
       MOVE 7 TO L-LST(14)
       MOVE 8 TO L-LST(15)
       MOVE 8 TO L-LST(16)
       MOVE 3 TO L-LST(17)
       MOVE 1 TO L-LST(18)
       MOVE 4 TO L-LST(19)
       MOVE 2 TO L-LST(20)
       MOVE 2 TO L-LST(21)
       MOVE 10 TO L-LST(22)
       MOVE 7 TO L-LST(23)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 9 TO L-LST(1)
       MOVE 8 TO L-LST(2)
       MOVE 6 TO L-LST(3)
       MOVE 10 TO L-LST(4)
       MOVE 2 TO L-LST(5)
       MOVE 6 TO L-LST(6)
       MOVE 10 TO L-LST(7)
       MOVE 2 TO L-LST(8)
       MOVE 7 TO L-LST(9)
       MOVE 8 TO L-LST(10)
       MOVE 10 TO L-LST(11)
       MOVE 3 TO L-LST(12)
       MOVE 8 TO L-LST(13)
       MOVE 2 TO L-LST(14)
       MOVE 6 TO L-LST(15)
       MOVE 2 TO L-LST(16)
       MOVE 3 TO L-LST(17)
       MOVE 1 TO L-LST(18)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-LST(1)
       MOVE 5 TO L-LST(2)
       MOVE 3 TO L-LST(3)
       MOVE 9 TO L-LST(4)
       MOVE 5 TO L-LST(5)
       MOVE 6 TO L-LST(6)
       MOVE 3 TO L-LST(7)
       MOVE 2 TO L-LST(8)
       MOVE 8 TO L-LST(9)
       MOVE 5 TO L-LST(10)
       MOVE 6 TO L-LST(11)
       MOVE 10 TO L-LST(12)
       MOVE 10 TO L-LST(13)
       MOVE 6 TO L-LST(14)
       MOVE 8 TO L-LST(15)
       MOVE 4 TO L-LST(16)
       MOVE 10 TO L-LST(17)
       MOVE 7 TO L-LST(18)
       MOVE 7 TO L-LST(19)
       MOVE 10 TO L-LST(20)
       MOVE 8 TO L-LST(21)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 10 TO L-LST(1)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 9 TO L-LST(1)
       MOVE 7 TO L-LST(2)
       MOVE 7 TO L-LST(3)
       MOVE 2 TO L-LST(4)
       MOVE 4 TO L-LST(5)
       MOVE 7 TO L-LST(6)
       MOVE 2 TO L-LST(7)
       MOVE 10 TO L-LST(8)
       MOVE 9 TO L-LST(9)
       MOVE 7 TO L-LST(10)
       MOVE 5 TO L-LST(11)
       MOVE 7 TO L-LST(12)
       MOVE 2 TO L-LST(13)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-LST(1)
       MOVE 4 TO L-LST(2)
       MOVE 10 TO L-LST(3)
       MOVE 2 TO L-LST(4)
       MOVE 1 TO L-LST(5)
       MOVE 1 TO L-LST(6)
       MOVE 10 TO L-LST(7)
       MOVE 3 TO L-LST(8)
       MOVE 6 TO L-LST(9)
       MOVE 1 TO L-LST(10)
       MOVE 8 TO L-LST(11)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 7 TO L-LST(1)
       MOVE 9 TO L-LST(2)
       MOVE 9 TO L-LST(3)
       MOVE 9 TO L-LST(4)
       MOVE 3 TO L-LST(5)
       MOVE 4 TO L-LST(6)
       MOVE 1 TO L-LST(7)
       MOVE 5 TO L-LST(8)
       MOVE 9 TO L-LST(9)
       MOVE 1 TO L-LST(10)
       MOVE 2 TO L-LST(11)
       MOVE 1 TO L-LST(12)
       MOVE 1 TO L-LST(13)
       MOVE 10 TO L-LST(14)
       MOVE 7 TO L-LST(15)
       MOVE 5 TO L-LST(16)
       MOVE 6 TO L-LST(17)
       MOVE 7 TO L-LST(18)
       MOVE 6 TO L-LST(19)
       MOVE 7 TO L-LST(20)
       MOVE 7 TO L-LST(21)
       MOVE 6 TO L-LST(22)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEARCH-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEARCH.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 3 TO L-LST(1)
       MOVE 10 TO L-LST(2)
       MOVE 10 TO L-LST(3)
       MOVE 9 TO L-LST(4)
       MOVE 2 TO L-LST(5)

       CALL "SEARCH" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRANGE-SORT-LIST.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

      * '''
      * Given list of integers, return list in strange order.
      * Strange sorting, is when you start with the minimum value,
      * then maximum of the remaining integers, then minimum and so on.
      *
      * Examples:
      * strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
      * strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
      * strange_sort_list([]) == []
      * '''

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    res, switch = [], True
    while lst:
        res.append(min(lst) if switch else max(lst))
        lst.remove(res[-1])
        switch = not switch
    return res

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRANGE-SORT-LIST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRANGE-SORT-LIST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-LST(1)
       MOVE 2 TO L-LST(2)
       MOVE 3 TO L-LST(3)
       MOVE 4 TO L-LST(4)

       CALL "STRANGE-SORT-LIST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRANGE-SORT-LIST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRANGE-SORT-LIST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-LST(1)
       MOVE 6 TO L-LST(2)
       MOVE 7 TO L-LST(3)
       MOVE 8 TO L-LST(4)
       MOVE 9 TO L-LST(5)

       CALL "STRANGE-SORT-LIST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRANGE-SORT-LIST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRANGE-SORT-LIST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-LST(1)
       MOVE 2 TO L-LST(2)
       MOVE 3 TO L-LST(3)
       MOVE 4 TO L-LST(4)
       MOVE 5 TO L-LST(5)

       CALL "STRANGE-SORT-LIST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRANGE-SORT-LIST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRANGE-SORT-LIST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-LST(1)
       MOVE 6 TO L-LST(2)
       MOVE 7 TO L-LST(3)
       MOVE 8 TO L-LST(4)
       MOVE 9 TO L-LST(5)
       MOVE 1 TO L-LST(6)

       CALL "STRANGE-SORT-LIST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRANGE-SORT-LIST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRANGE-SORT-LIST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-LST(1)
       MOVE 5 TO L-LST(2)
       MOVE 5 TO L-LST(3)
       MOVE 5 TO L-LST(4)

       CALL "STRANGE-SORT-LIST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRANGE-SORT-LIST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRANGE-SORT-LIST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-LST(1)
       MOVE 2 TO L-LST(2)
       MOVE 3 TO L-LST(3)
       MOVE 4 TO L-LST(4)
       MOVE 5 TO L-LST(5)
       MOVE 6 TO L-LST(6)
       MOVE 7 TO L-LST(7)
       MOVE 8 TO L-LST(8)

       CALL "STRANGE-SORT-LIST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRANGE-SORT-LIST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRANGE-SORT-LIST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 0 TO L-LST(1)
       MOVE 2 TO L-LST(2)
       MOVE 2 TO L-LST(3)
       MOVE 2 TO L-LST(4)
       MOVE 5 TO L-LST(5)
       MOVE 5 TO L-LST(6)
       MOVE -5 TO L-LST(7)
       MOVE -5 TO L-LST(8)

       CALL "STRANGE-SORT-LIST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRANGE-SORT-LIST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRANGE-SORT-LIST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-LST OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 111111 TO L-LST(1)

       CALL "STRANGE-SORT-LIST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

      * '''
      * Given the lengths of the three sides of a triangle. Return the area of
      * the triangle rounded to 2 decimal points if the three sides form a valid triangle.
      * Otherwise return -1
      * Three sides make a valid triangle when the sum of any two sides is greater
      * than the third side.
      * Example:
      * triangle_area(3, 4, 5) == 6.00
      * triangle_area(1, 2, 10) == -1
      * '''

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    if a + b <= c or a + c <= b or b + c <= a:
        return -1
    s = (a + b + c)/2
    area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
    area = round(area, 2)
    return area

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRIANGLE-AREA.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 3 TO L-A
       MOVE 4 TO L-B
       MOVE 5 TO L-C

       CALL "TRIANGLE-AREA" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRIANGLE-AREA.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 1 TO L-A
       MOVE 2 TO L-B
       MOVE 10 TO L-C

       CALL "TRIANGLE-AREA" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRIANGLE-AREA.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 4 TO L-A
       MOVE 8 TO L-B
       MOVE 5 TO L-C

       CALL "TRIANGLE-AREA" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRIANGLE-AREA.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 2 TO L-A
       MOVE 2 TO L-B
       MOVE 2 TO L-C

       CALL "TRIANGLE-AREA" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRIANGLE-AREA.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 1 TO L-A
       MOVE 2 TO L-B
       MOVE 3 TO L-C

       CALL "TRIANGLE-AREA" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRIANGLE-AREA.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 10 TO L-A
       MOVE 5 TO L-B
       MOVE 7 TO L-C

       CALL "TRIANGLE-AREA" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRIANGLE-AREA.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 2 TO L-A
       MOVE 6 TO L-B
       MOVE 3 TO L-C

       CALL "TRIANGLE-AREA" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRIANGLE-AREA.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 1 TO L-A
       MOVE 1 TO L-B
       MOVE 1 TO L-C

       CALL "TRIANGLE-AREA" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE-AREA-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRIANGLE-AREA.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 L-C PIC S9(10).
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 2 TO L-A
       MOVE 2 TO L-B
       MOVE 10 TO L-C

       CALL "TRIANGLE-AREA" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. WILL-IT-FLY.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-Q OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-W PIC S9(10).
           05 RESULT PIC 9.

      * '''
      * Write a function that returns True if the object q will fly, and False otherwise.
      * The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.
      *
      * Example:
      * will_it_fly([1, 2], 5) ➞ False
      * # 1+2 is less than the maximum possible weight, but it's unbalanced.
      *
      * will_it_fly([3, 2, 3], 1) ➞ False
      * # it's balanced, but 3+2+3 is more than the maximum possible weight.
      *
      * will_it_fly([3, 2, 3], 9) ➞ True
      * # 3+2+3 is less than the maximum possible weight, and it's balanced.
      *
      * will_it_fly([3], 5) ➞ True
      * # 3 is less than the maximum possible weight, and it's balanced.
      * '''

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    if sum(q) > w:
        return False

    i, j = 0, len(q)-1
    while i<j:
        if q[i] != q[j]:
            return False
        i+=1
        j-=1
    return True

       IDENTIFICATION DIVISION.
       PROGRAM-ID. WILL-IT-FLY-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "WILL-IT-FLY.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-Q OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-W PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 3 TO L-Q(1)
       MOVE 2 TO L-Q(2)
       MOVE 3 TO L-Q(3)
       MOVE 9 TO L-W

       CALL "WILL-IT-FLY" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. WILL-IT-FLY-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "WILL-IT-FLY.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-Q OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-W PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1 TO L-Q(1)
       MOVE 2 TO L-Q(2)
       MOVE 5 TO L-W

       CALL "WILL-IT-FLY" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. WILL-IT-FLY-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "WILL-IT-FLY.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-Q OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-W PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 3 TO L-Q(1)
       MOVE 5 TO L-W

       CALL "WILL-IT-FLY" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. WILL-IT-FLY-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "WILL-IT-FLY.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-Q OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-W PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 3 TO L-Q(1)
       MOVE 2 TO L-Q(2)
       MOVE 3 TO L-Q(3)
       MOVE 1 TO L-W

       CALL "WILL-IT-FLY" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. WILL-IT-FLY-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "WILL-IT-FLY.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-Q OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-W PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1 TO L-Q(1)
       MOVE 2 TO L-Q(2)
       MOVE 3 TO L-Q(3)
       MOVE 6 TO L-W

       CALL "WILL-IT-FLY" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. WILL-IT-FLY-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "WILL-IT-FLY.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-Q OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-W PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 5 TO L-Q(1)
       MOVE 5 TO L-W

       CALL "WILL-IT-FLY" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SMALLEST-CHANGE.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

      *
      * Given an array arr of integers, find the minimum number of elements that
      * need to be changed to make the array palindromic. A palindromic array is an array that
      * is read the same backwards and forwards. In one change, you can change one element to any other element.
      *
      * For example:
      * smallest_change([1,2,3,5,4,7,9,6]) == 4
      * smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
      * smallest_change([1, 2, 3, 2, 1]) == 0
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    ans = 0
    for i in range(len(arr) // 2):
        if arr[i] != arr[len(arr) - i - 1]:
            ans += 1
    return ans

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SMALLEST-CHANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SMALLEST-CHANGE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-ARR(1)
       MOVE 2 TO L-ARR(2)
       MOVE 3 TO L-ARR(3)
       MOVE 5 TO L-ARR(4)
       MOVE 4 TO L-ARR(5)
       MOVE 7 TO L-ARR(6)
       MOVE 9 TO L-ARR(7)
       MOVE 6 TO L-ARR(8)

       CALL "SMALLEST-CHANGE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SMALLEST-CHANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SMALLEST-CHANGE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-ARR(1)
       MOVE 2 TO L-ARR(2)
       MOVE 3 TO L-ARR(3)
       MOVE 4 TO L-ARR(4)
       MOVE 3 TO L-ARR(5)
       MOVE 2 TO L-ARR(6)
       MOVE 2 TO L-ARR(7)

       CALL "SMALLEST-CHANGE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SMALLEST-CHANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SMALLEST-CHANGE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-ARR(1)
       MOVE 4 TO L-ARR(2)
       MOVE 2 TO L-ARR(3)

       CALL "SMALLEST-CHANGE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SMALLEST-CHANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SMALLEST-CHANGE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-ARR(1)
       MOVE 4 TO L-ARR(2)
       MOVE 4 TO L-ARR(3)
       MOVE 2 TO L-ARR(4)

       CALL "SMALLEST-CHANGE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SMALLEST-CHANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SMALLEST-CHANGE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-ARR(1)
       MOVE 2 TO L-ARR(2)
       MOVE 3 TO L-ARR(3)
       MOVE 2 TO L-ARR(4)
       MOVE 1 TO L-ARR(5)

       CALL "SMALLEST-CHANGE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SMALLEST-CHANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SMALLEST-CHANGE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 3 TO L-ARR(1)
       MOVE 1 TO L-ARR(2)
       MOVE 1 TO L-ARR(3)
       MOVE 3 TO L-ARR(4)

       CALL "SMALLEST-CHANGE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SMALLEST-CHANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SMALLEST-CHANGE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-ARR(1)

       CALL "SMALLEST-CHANGE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SMALLEST-CHANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SMALLEST-CHANGE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-ARR OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 0 TO L-ARR(1)
       MOVE 1 TO L-ARR(2)

       CALL "SMALLEST-CHANGE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .