Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRI.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

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

      * Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
      * the last couple centuries. However, what people don't know is Tribonacci sequence.
      * Tribonacci sequence is defined by the recurrence:
      * tri(1) = 3
      * tri(n) = 1 + n / 2, if n is even.
      * tri(n) =  tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
      * For example:
      * tri(2) = 1 + (2 / 2) = 2
      * tri(4) = 3
      * tri(3) = tri(2) + tri(1) + tri(4)
      * = 2 + 3 + 3 = 8
      * You are given a non-negative integer number n, you have to a return a list of the
      * first n + 1 numbers of the Tribonacci sequence.
      * Examples:
      * tri(3) = [1, 3, 2, 8]
      *

      * 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 n == 0:
        return [1]
    my_tri = [1, 3]
    for i in range(2, n + 1):
        if i % 2 == 0:
            my_tri.append(i / 2 + 1)
        else:
            my_tri.append(my_tri[i - 1] + my_tri[i - 2] + (i + 3) / 2)
    return my_tri

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 3 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 4 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 6 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 7 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 8 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 9 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 20 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 0 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. TRI-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRI.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-N PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-N

       CALL "TRI" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

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

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) 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. DIGITS.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-N PIC S9(10).
           05 RESULT PIC S9(10).

      * Given a positive integer n, return the product of the odd digits.
      * Return 0 if all digits are even.
      * For example:
      * digits(1)  == 1
      * digits(4)  == 0
      * digits(235) == 15
      *

      * 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.

    product = 1
    odd_count = 0
    for digit in str(n):
        int_digit = int(digit)
        if int_digit%2 == 1:
            product= product*int_digit
            odd_count+=1
    if odd_count ==0:
        return 0
    else:
        return product

       IDENTIFICATION DIVISION.
       PROGRAM-ID. DIGITS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "DIGITS.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-N

       CALL "DIGITS" 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. DIGITS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "DIGITS.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 54 TO L-N

       CALL "DIGITS" 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. DIGITS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "DIGITS.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 120 TO L-N

       CALL "DIGITS" 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. DIGITS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "DIGITS.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5014 TO L-N

       CALL "DIGITS" 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. DIGITS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "DIGITS.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 98765 TO L-N

       CALL "DIGITS" 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. DIGITS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "DIGITS.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5576543 TO L-N

       CALL "DIGITS" 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. DIGITS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "DIGITS.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 2468 TO L-N

       CALL "DIGITS" 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. IS-NESTED.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT PIC 9.

      * '''
      * Create a function that takes a string as input which contains only square brackets.
      * The function should return True if and only if there is a valid subsequence of brackets
      * where at least one bracket in the subsequence is nested.
      *
      * is_nested('[[]]') ➞ True
      * is_nested('[]]]]]]][[[[[]') ➞ False
      * is_nested('[][]') ➞ False
      * is_nested('[]') ➞ False
      * is_nested('[[][]]') ➞ True
      * is_nested('[[]][[') ➞ True
      * '''

      * 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.

    opening_bracket_index = []
    closing_bracket_index = []
    for i in range(len(string)):
        if string[i] == '[':
            opening_bracket_index.append(i)
        else:
            closing_bracket_index.append(i)
    closing_bracket_index.reverse()
    cnt = 0
    i = 0
    l = len(closing_bracket_index)
    for idx in opening_bracket_index:
        if i < l and idx < closing_bracket_index[i]:
            cnt += 1
            i += 1
    return cnt >= 2

       IDENTIFICATION DIVISION.
       PROGRAM-ID. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[[]]' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[]]]]]]][[[[[]' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[][]' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[[[[]]]]' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[]]]]]]]]]]' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[][][[]]' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[[]' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[]]' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[[]][[' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[[][]]' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE '[[[[[[[[' TO L-STRING

       CALL "IS-NESTED" 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. IS-NESTED-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-NESTED.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-STRING PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE ']]]]]]]]' TO L-STRING

       CALL "IS-NESTED" 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. SUM-SQUARES.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

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

      * You are given a list of numbers.
      * You need to return the sum of squared numbers in the given list,
      * round each element in the list to the upper int(Ceiling) first.
      * Examples:
      * For lst = [1,2,3] the output should be 14
      * For lst = [1,4,9] the output should be 98
      * For lst = [1,3,5,7] the output should be 84
      * For lst = [1.4,4.2,0] the output should be 29
      * For lst = [-2.4,1,1] the output should be 6
      *
      *
      *

      * 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.

    import math
    squared = 0
    for i in lst:
        squared += math.ceil(i)**2
    return squared

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

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

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

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

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

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

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1.4 TO L-LST(1)
       MOVE 4.2 TO L-LST(2)
       MOVE 0 TO L-LST(3)

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

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

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

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

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

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

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE -1.4 TO L-LST(1)
       MOVE 4.6 TO L-LST(2)
       MOVE 6.3 TO L-LST(3)

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE -1.4 TO L-LST(1)
       MOVE 17.9 TO L-LST(2)
       MOVE 18.9 TO L-LST(3)
       MOVE 19.9 TO L-LST(4)

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 0 TO L-LST(1)

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE -1 TO L-LST(1)

       CALL "SUM-SQUARES" 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. SUM-SQUARES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-SQUARES.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 COMP-2.
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

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

       CALL "SUM-SQUARES" 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. IS-LAST-CHAR-LETTER.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-TXT PIC X(100).
           05 RESULT PIC 9.

      * '''
      * Create a function that returns True if the last character
      * of a given string is an alphabetical character and is not
      * a part of a word, and False otherwise.
      * Note: "word" is a group of characters separated by space.
      *
      * Examples:
      * is_last_char_letter("apple pie") ➞ False
      * is_last_char_letter("apple pi e") ➞ True
      * is_last_char_letter("apple pi e ") ➞ False
      * is_last_char_letter("") ➞ False
      * '''

      * 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.

    check = txt.split(' ')[-1]
    return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False

       IDENTIFICATION DIVISION.
       PROGRAM-ID. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "apple" TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "apple pi e" TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "eeeee" TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "A" TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "Pumpkin pie " TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "Pumpkin pie 1" TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "" TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "eeeee e " TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "apple pie" TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. IS-LAST-CHAR-LETTER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-LAST-CHAR-LETTER.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-TXT PIC X(100).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE "apple pi e " TO L-TXT

       CALL "IS-LAST-CHAR-LETTER" 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. CAN-ARRANGE.

       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).

      * Create a function which returns the largest index of an element which
      * is not greater than or equal to the element immediately preceding it. If
      * no such element exists then return -1. The given array will not contain
      * duplicate values.
      *
      * Examples:
      * can_arrange([1,2,4,3,5]) = 3
      * can_arrange([1,2,3]) = -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.

    ind=-1
    i=1
    while i<len(arr):
      if arr[i]<arr[i-1]:
        ind=i
      i+=1
    return ind

       IDENTIFICATION DIVISION.
       PROGRAM-ID. CAN-ARRANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "CAN-ARRANGE.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 4 TO L-ARR(3)
       MOVE 3 TO L-ARR(4)
       MOVE 5 TO L-ARR(5)

       CALL "CAN-ARRANGE" 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. CAN-ARRANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "CAN-ARRANGE.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 4 TO L-ARR(3)
       MOVE 5 TO L-ARR(4)

       CALL "CAN-ARRANGE" 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. CAN-ARRANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "CAN-ARRANGE.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)
       MOVE 5 TO L-ARR(4)
       MOVE 6 TO L-ARR(5)
       MOVE 7 TO L-ARR(6)
       MOVE 8 TO L-ARR(7)
       MOVE 9 TO L-ARR(8)
       MOVE 10 TO L-ARR(9)

       CALL "CAN-ARRANGE" 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. CAN-ARRANGE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "CAN-ARRANGE.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 4 TO L-ARR(1)
       MOVE 8 TO L-ARR(2)
       MOVE 5 TO L-ARR(3)
       MOVE 7 TO L-ARR(4)
       MOVE 3 TO L-ARR(5)

       CALL "CAN-ARRANGE" 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. IS-EQUAL-TO-SUM-EVEN.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-N PIC S9(10).
           05 RESULT PIC 9.

      * Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
      * Example
      * is_equal_to_sum_even(4) == False
      * is_equal_to_sum_even(6) == False
      * is_equal_to_sum_even(8) == True
      *

      * 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.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. IS-EQUAL-TO-SUM-EVEN-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-EQUAL-TO-SUM-EVEN.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-N PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 4 TO L-N

       CALL "IS-EQUAL-TO-SUM-EVEN" 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. IS-EQUAL-TO-SUM-EVEN-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-EQUAL-TO-SUM-EVEN.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-N PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 6 TO L-N

       CALL "IS-EQUAL-TO-SUM-EVEN" 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. IS-EQUAL-TO-SUM-EVEN-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-EQUAL-TO-SUM-EVEN.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-N PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 8 TO L-N

       CALL "IS-EQUAL-TO-SUM-EVEN" 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. IS-EQUAL-TO-SUM-EVEN-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-EQUAL-TO-SUM-EVEN.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-N PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 10 TO L-N

       CALL "IS-EQUAL-TO-SUM-EVEN" 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. IS-EQUAL-TO-SUM-EVEN-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-EQUAL-TO-SUM-EVEN.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-N PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 11 TO L-N

       CALL "IS-EQUAL-TO-SUM-EVEN" 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. IS-EQUAL-TO-SUM-EVEN-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-EQUAL-TO-SUM-EVEN.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-N PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 12 TO L-N

       CALL "IS-EQUAL-TO-SUM-EVEN" 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. IS-EQUAL-TO-SUM-EVEN-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-EQUAL-TO-SUM-EVEN.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-N PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 13 TO L-N

       CALL "IS-EQUAL-TO-SUM-EVEN" 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. IS-EQUAL-TO-SUM-EVEN-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "IS-EQUAL-TO-SUM-EVEN.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-N PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 16 TO L-N

       CALL "IS-EQUAL-TO-SUM-EVEN" 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. SPECIAL-FACTORIAL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-N PIC S9(10).
           05 RESULT PIC S9(10).

      * The Brazilian factorial is defined as:
      * brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
      * where n > 0
      *
      * For example:
      * >>> special_factorial(4)
      * 288
      *
      * The function will receive an integer as input and should return the special
      * factorial of this integer.
      *

      * 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.

    fact_i = 1
    special_fact = 1
    for i in range(1, n+1):
        fact_i *= i
        special_fact *= fact_i
    return special_fact

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SPECIAL-FACTORIAL-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SPECIAL-FACTORIAL.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 4 TO L-N

       CALL "SPECIAL-FACTORIAL" 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. SPECIAL-FACTORIAL-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SPECIAL-FACTORIAL.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-N

       CALL "SPECIAL-FACTORIAL" 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. SPECIAL-FACTORIAL-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SPECIAL-FACTORIAL.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 7 TO L-N

       CALL "SPECIAL-FACTORIAL" 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. SPECIAL-FACTORIAL-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SPECIAL-FACTORIAL.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-N PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-N

       CALL "SPECIAL-FACTORIAL" 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. FIX-SPACES.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-TEXT PIC X(100).
           05 RESULT PIC X(100).

      *
      * Given a string text, replace all spaces in it with underscores,
      * and if a string has more than 2 consecutive spaces,
      * then replace all consecutive spaces with -
      *
      * fix_spaces("Example") == "Example"
      * fix_spaces("Example 1") == "Example_1"
      * fix_spaces(" Example 2") == "_Example_2"
      * fix_spaces(" Example   3") == "_Example-3"
      *

      * 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.

    new_text = ""
    i = 0
    start, end = 0, 0
    while i < len(text):
        if text[i] == " ":
            end += 1
        else:
            if end - start > 2:
                new_text += "-"+text[i]
            elif end - start > 0:
                new_text += "_"*(end - start)+text[i]
            else:
                new_text += text[i]
            start, end = i+1, i+1
        i+=1
    if end - start > 2:
        new_text += "-"
    elif end - start > 0:
        new_text += "_"
    return new_text

       IDENTIFICATION DIVISION.
       PROGRAM-ID. FIX-SPACES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

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

       DATA DIVISION.

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

       WORKING-STORAGE SECTION.

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

       01 LINKED-ITEMS.
           05 L-TEXT PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE "Example" TO L-TEXT

       CALL "FIX-SPACES" 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. FIX-SPACES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

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

       DATA DIVISION.

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

       WORKING-STORAGE SECTION.

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

       01 LINKED-ITEMS.
           05 L-TEXT PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE "Mudasir Hanif " TO L-TEXT

       CALL "FIX-SPACES" 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. FIX-SPACES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

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

       DATA DIVISION.

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

       WORKING-STORAGE SECTION.

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

       01 LINKED-ITEMS.
           05 L-TEXT PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE "Yellow Yellow  Dirty  Fellow" TO L-TEXT

       CALL "FIX-SPACES" 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. FIX-SPACES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

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

       DATA DIVISION.

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

       WORKING-STORAGE SECTION.

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

       01 LINKED-ITEMS.
           05 L-TEXT PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE "Exa   mple" TO L-TEXT

       CALL "FIX-SPACES" 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. FIX-SPACES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

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

       DATA DIVISION.

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

       WORKING-STORAGE SECTION.

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

       01 LINKED-ITEMS.
           05 L-TEXT PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE "   Exa 1 2 2 mple" TO L-TEXT

       CALL "FIX-SPACES" 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
        .