Problem:
Almost Identical Programs

The programming contest named
Concours de Programmation Comtemporaine Interuniversitaire (CPCI)
has a judging system similar to that of ICPC;
contestants have to submit correct outputs for two different inputs
to be accepted as a correct solution.

Each of the submissions should include the program that generated
the output. A pair of submissions is judged to be a correct
solution when, in addition to the correctness of the outputs, they
include an identical program.

Many contestants, however, do not stop including a different version
of their programs in their second submissions, after modifying a
single string literal in their programs representing
the input file name, attempting to process different input.

The organizers of CPCI are exploring the possibility of showing a
special error message for such close submissions,
indicating contestants what's wrong with such submissions.

Your task is to detect such close submissions.

Input

The input consists of at most 100 datasets, each in the following format.

s1
s2

Each of s1 and s2 is
a string written in a line, with the length between 1 and 200, inclusive.
They are the first and the second submitted programs respectively.

A program consists of lowercase letters (a, b, ..., z), uppercase letters (A, B, ..., Z),
digits (0, 1, ..., 9), double quotes ("), and semicolons (;).
When double quotes occur in a program, there are always even number of them.

The end of the input is indicated by a line containing one '.' (period).

Output

For each dataset, print the judge result in a line.

If the given two programs are identical, print IDENTICAL.
If two programs differ with only one corresponding string literal, print CLOSE.
Otherwise, print DIFFERENT.

A string literal is a possibly empty sequence of characters between an
odd-numbered occurrence of a double quote and the next occurrence of
a double quote.

Sample Input

print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.

Output for the Sample Input

IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT

Solution in JAVA (judge verdict: Accepted)

import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static String IDENTICAL = "IDENTICAL";
    public static String CLOSE = "CLOSE";
    public static String DIFFERENT = "DIFFERENT";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int i = 0;
        String c1 = "";
        String c2 = "";
        while (true) {
            String line = sc.nextLine();
            if (line.equals(".")) {
                return;
            }

            if (i % 2 == 0) {
                c1 = line;
            } else {
                c2 = line;
                System.out.println(process(c1, c2));
            }
            i++;
        }

    }


    public static String process(String c1, String c2) {
        if (c1.equals(c2)) {
            return IDENTICAL;
        }
        String regex = "\\\"(.*?)\\\"";

        String removeCommand1 = c1.replaceAll(regex, "");
        String removeCommand2 = c2.replaceAll(regex, "");
        if(!removeCommand1.equals(removeCommand2)) {
            return DIFFERENT;
        } else {
            String [] arrC1 = c1.split(regex);
            String [] arrC2 = c2.split(regex);

            for (int i = 0; i < arrC1.length && i < arrC2.length; i++) {
                if(!arrC1[i].equals(arrC2[i])){
                    return DIFFERENT;
                }
            }
        }

        Pattern p = Pattern.compile(regex);
        Matcher m1 = p.matcher(c1);
        Matcher m2 = p.matcher(c2);
        ArrayList<String> arrCommand1 = new ArrayList<>();
        while(m1.find()) {
            arrCommand1.add(m1.group(1));
        }

        ArrayList<String> arrCommand2 = new ArrayList<>();
        while(m2.find()) {
            arrCommand2.add(m2.group(1));
        }

        int countCommandDiff = 0;
        if(arrCommand2.size() != arrCommand1.size()){
            return DIFFERENT;
        }
        for (int i = 0; i < arrCommand1.size() && i < arrCommand2.size(); i++) {
            if(!arrCommand1.get(i).equals(arrCommand2.get(i))) {
                countCommandDiff ++;
            }
        }

        if(countCommandDiff < 2) {
            return CLOSE;
        }

        return DIFFERENT;
    }
}