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



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
.


Sample output:
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT

Submission status: Accepted

Solution code:
ans=[]
while 1:
    s1=input().split('"')
    if s1==["."]: break
    s2=input().split('"')
    if len(s1)!=len(s2):
        ans.append("DIFFERENT")
        continue
    else:
        cnt=0
        flag=0
        for i in range(len(s1)):
            if s1[i]!=s2[i]:
                if i%2==0:
                    ans.append("DIFFERENT")
                    flag=1
                    break
                else:
                    cnt+=1
            else: pass
        if flag==1:
            continue
        else: pass
        if cnt==0:
            ans.append("IDENTICAL")
        elif cnt==1:
            ans.append("CLOSE")
        else: 
            ans.append("DIFFERENT")

for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
s1=[]
s2=[]
O=[]
while 1:
    A=input().split('"')
    if A==["."]:
        break
    i=0
    cnt=0
    B=input().split('"')
    l1=len(A)
    l2=len(B)
    if l1==l2:   
        while i<l1 and i<l2:
            if A[i]!=B[i]:
                cnt+=1
                if i%2==0:
                    cnt+=2
            i+=1
        if cnt==0:
            O.append("IDENTICAL")
        elif cnt==1:
            O.append("CLOSE")
        else:
            O.append("DIFFERENT")
    else:
        O.append("DIFFERENT")
for i in range(len(O)):
    print(O[i])

Submission status: Accepted

Solution code:
while 1:

    s1 = input().split('"')
    if s1 == ['.']:  # 強制終了
        break

    s2 = input().split('"')
    if len(s1) != len(s2):  # 長さが違う場合
        print("DIFFERENT")
        continue

    cnt = 0
    for i in range(len(s1)):
        if s1[i] != s2[i]:
            cnt += 1
            if i%2==0:
                cnt += 2
        else:
            i+=1

    if cnt == 0:
        print("IDENTICAL")  # 完全一致
    elif cnt == 1:
        print("CLOSE")  # 一つ違い
    else:
        print("DIFFERENT")  # それ以外

Submission status: Accepted

Solution code:
st = []
while(1):
    a1 = input()
    if a1 =='.':
        break
    a2 = input()
    b1 = a1.split('"')
    b2 = a2.split('"')
    cnt = 0
    if len(b1)==len(b2):
        for i in range(0,len(b1)):
            if i%2==0:
                if b1[i]!=b2[i]:
                    cnt+=10000
                    break
            if i%2!=0:
                if b1[i]!=b2[i]:
                    cnt+=1
    else:
        cnt+=10000
    
    if cnt>1:
        st.append("DIFFERENT")
    if cnt==1:
        st.append("CLOSE")
    if cnt==0:
        st.append("IDENTICAL")

for i in range(len(st)):
    print(st[i])

Submission status: Accepted

Solution code:
while 1:
    s1=input().split('"')
    if s1[0]==".":
        break
    s2=input().split('"')
     
    cnt1=0
    cnt2=0
    flag=0
     
    if len(s1)!=len(s2):
        print("DIFFERENT")
    else:
        i=0
        while i<len(s1):
            if s1[i]==s2[i]:
                cnt1+=1
            elif i%2==0:
                print("DIFFERENT")
                flag=1
                break
            else:
                cnt2+=1
                if cnt2>1:
                    print("DIFFERENT")
                    break
            i+=1
                 
        if flag==0 and cnt2==1:
            print("CLOSE")
        if cnt1==len(s1):
            print("IDENTICAL")

Submission status: Accepted

Solution code:
while 1:
    list1=input().split('"')
    if list1[0]==".":
        break
    list2=input().split('"')
     
    cnt1=0
    cnt2=0
    flag=0
     
    if len(list1)!=len(list2):
        print("DIFFERENT")
    else:
        i=0
        while i<len(list1):
            if list1[i]==list2[i]:
                cnt1+=1
            elif i%2==0:
                print("DIFFERENT")
                flag=1
                break
            else:
                cnt2+=1
                if cnt2>1:
                    print("DIFFERENT")
                    break
            i+=1
                 
        if flag==0 and cnt2==1:
            print("CLOSE")
        if cnt1==len(list1):
            print("IDENTICAL")

Submission status: Accepted

Solution code:
while 1:
    list1=input().split('"')
    if list1[0]==".":
        break
    list2=input().split('"')
     
    cnt1=0
    cnt2=0
    flag=0
     
    if len(list1)!=len(list2):
        print("DIFFERENT")
    else:
        i=0
        while i<len(list1):
            if list1[i]==list2[i]:
                cnt1+=1
            elif i%2==0:	#「""の間で」の意味
                print("DIFFERENT")
                flag=1
                break
            else:
                cnt2+=1
                if cnt2>1:
                    print("DIFFERENT")
                    break
            i+=1
                 
        if flag==0 and cnt2==1:
            print("CLOSE")
        if cnt1==len(list1):
            print("IDENTICAL")

Submission status: Accepted

Solution code:
while True:
    list1=input().split('"')
    if list1[0]==".":
        break
    list2=input().split('"')
     
    cnt1=0
    cnt2=0
    flag=0
     
    if len(list1)!=len(list2):
        print("DIFFERENT")
    else:
        i=0
        while i<len(list1):
            if list1[i]==list2[i]:
                cnt1+=1
            elif i%2==0:	#[ " ~~~~~ " ]in ""
                print("DIFFERENT")
                flag=1
                break
            else:
                cnt2+=1
                if cnt2>1:
                    print("DIFFERENT")
                    break
            i+=1
                 
        if flag==0 and cnt2==1:
            print("CLOSE")
        if cnt1==len(list1):
            print("IDENTICAL")

Submission status: Accepted

Solution code:
while(1):
    a = input()
    if(a == '.'):
        break
    b = input()
    n = len(a)
    m = len(b)
    l = 0;
    flag = 0
    idx_dif = 0
    error_cou = 0

    while(1):
        if(l >= n-1 or l+idx_dif >= m-1):
            flag = 2

        if(flag == 0):
            for i in range(l,n):
                if(a[i] == '\"'):
                    if(i+idx_dif < m and a[l:i+1] == b[l+idx_dif:i+idx_dif+1]):
                        l = i+1
                        flag = 1
                    else:
                        flag = 2
                    break

                elif(i == n-1):
                    if(a[l:i] != b[l+idx_dif:m-1]):
                        flag = 2
                    else:
                        l = n-1
                    break
                if(flag != 0):
                    break

        elif(flag == 1):
            for i in range(l,n):
                if(a[i] == '\"'):
                    for j in range(l+idx_dif,m):
                        if(b[j] == '\"'):
                            if(a[l:i+1] != b[l+idx_dif:j+1]):
                                error_cou += 1
                            idx_dif = j-i
                            l = i+1
                            flag = 0
                            break
                        if(j == m-1):
                            flag = 2
                            break

                if(flag != 1):
                    break

        if(flag == 2 or l >= n-1 or l+idx_dif >= m-1):
            break

    if(error_cou >= 2 or flag == 2):
        print("DIFFERENT")
    elif(error_cou == 1):
        print("CLOSE")
    elif(error_cou == 0):
        print("IDENTICAL")

Submission status: Accepted

Solution code:
while(1):
    a = input()
    if(a == '.'):
        break
    b = input()
    n = len(a)
    m = len(b)
    l = 0
    flag = 0
    idx_dif = 0
    error_cou = 0

    while(1):
        if(flag == 0):
            for i in range(l,n):
                if(a[i] == '\"'):
                    if(i+idx_dif < m and a[l:i+1] == b[l+idx_dif:i+idx_dif+1]):
                        l = i+1
                        flag = 1
                    else:
                        flag = 2
                    break

                elif(i == n-1):
                    if(a[l:i] != b[l+idx_dif:m-1]):
                        flag = 2
                    else:
                        l = n-1

        elif(flag == 1):
            for i in range(l,n):
                if(a[i] == '\"'):
                    for j in range(l+idx_dif,m):
                        if(b[j] == '\"'):
                            if(a[l:i+1] != b[l+idx_dif:j+1]):
                                error_cou += 1
                            idx_dif = j-i
                            l = i+1
                            flag = 0
                            break
                        if(j == m-1):
                            flag = 2
                            break
                if(flag != 1):
                    break

        if(flag == 2 or l >= n-1 or l+idx_dif >= m-1):
            break

    if(error_cou >= 2 or flag == 2):
        print("DIFFERENT")
    elif(error_cou == 1):
        print("CLOSE")
    elif(error_cou == 0):
        print("IDENTICAL")

Submission status: Accepted

Solution code:
while(1):
    a = input()
    if(a == '.'):
        break
    b = input()
    n = len(a)
    m = len(b)
    l = 0
    flag = 0
    idx_dif = 0
    error_cou = 0
 
    while(1):
        if(flag == 0):
            for i in range(l,n):
                if(a[i] == '\"'):
                    if(i+idx_dif < m and a[l:i+1] == b[l+idx_dif:i+idx_dif+1]):
                        l = i+1
                        flag = 1
                    else:
                        flag = 2
                    break
 
                elif(i == n-1):
                    if(a[l:i] != b[l+idx_dif:m-1]):
                        flag = 2
                    else:
                        l = n-1
 
        elif(flag == 1):
            for i in range(l,n):
                if(a[i] == '\"'):
                    for j in range(l+idx_dif,m):
                        if(b[j] == '\"'):
                            if(a[l:i+1] != b[l+idx_dif:j+1]):
                                error_cou += 1
                            idx_dif = j-i
                            l = i+1
                            flag = 0
                            break
                        if(j == m-1):
                            flag = 2
                            break
                if(flag != 1):
                    break
 
        if(flag == 2 or l >= n-1 or l+idx_dif >= m-1):
            break
 
    if(error_cou >= 2 or flag == 2):
        print("DIFFERENT")
    elif(error_cou == 1):
        print("CLOSE")
    elif(error_cou == 0):
        print("IDENTICAL")

Submission status: Accepted

Solution code:
A=[]
while True:	
	a=input().split('"')
	if a[0]==".":
		break
	b=input().split('"')
	
	cnt=0

	if len(a)!=len(b):
		A.append(-1)
	else:
		for i in range(len(a)):
			if(a[i]==b[i]):
				pass
			else:
				if i%2==1:
					cnt+=1
				else:
					cnt+=2
		if cnt>=2:
			A.append(-1)
		if cnt==1:
			A.append(0)
		if cnt==0:
			A.append(1)

A.reverse()
#print(A)
for i in range(len(A)):
	tmp=A.pop()
	if tmp==-1:
		print("DIFFERENT")
	elif tmp==0:
		print("CLOSE")
	else:
		print("IDENTICAL")

Submission status: Accepted

Solution code:
ans=[]

while 1:
	s1=input().split('"')
	if s1[0]==".":
		break

	s2=input().split('"')
	
	if len(s1)!=len(s2):
		ans.append("DIFFERENT")
		continue
	else:
	
		cnt=0
		flag=0
		
		for i in range(len(s1)):
		
			if s1[i]!=s2[i]:
			
				if i==0:
					flag=1
					break
					
				elif i%2==0:
					flag=1
					break
				else:
					cnt+=1
			
		if flag==1 or cnt>1:
			ans.append("DIFFERENT")
		elif cnt==1:
			ans.append("CLOSE")
		else:
			ans.append("IDENTICAL")

for a in ans:
	print(a)

Submission status: Accepted

Solution code:
s=[]
while True:
    l1=input()
    if l1==".":
        break
    l2=input()
 
    sp1=l1.split('"')
    sp2=l2.split('"')
     
    m=0
    if len(sp1)==len(sp2):
        for i in range(len(sp1)):
            if i%2==1 and sp1[i]!=sp2[i]:
                m+=1
            elif i%2!=1 and sp1[i]!=sp2[i]:
                m+=2
 
 
    if sp1==sp2:
        s+=["IDENTICAL"]
    elif m==1:
        s+=["CLOSE"]
    else:
        s+=["DIFFERENT"]
 
for x in s:
    print(x)

Submission status: Accepted

Solution code:
#16D8101014F 久留米 竜之介 Python3
#a=[]
while(True):
	i=0
	tmp=0
	a=input().split('"') 
	aL=len(a)
	if a[0] ==".":
		break
	b=input().split('"')
	bL=len(b)
		
	if aL != bL:
		print("DIFFERENT")
	else:
		while(True):
			if a[i] != b[i]:
				print("DIFFERENT")
				break
			elif i > aL-2:
				if tmp==1:
					print("CLOSE")
					break
				else:
					print("IDENTICAL")
					break
			elif a[i+1] != b[i+1]:
				if tmp==1:
					print("DIFFERENT")
					break
				else: tmp=1
			i +=2

Submission status: Accepted

Solution code:
while True:
    s1 = input()
    if s1 == '.':
        break
    s2 = input()

    if s1 == s2:
        print("IDENTICAL")
        continue

    s2 = s2.split('"')
    s1 = s1.split('"')
    # print(s1)
    # print(s2)
    count = 0
    isTmp = False
    if s1[0] == '"' and s2[0] == '"':
        isTmp = True

    hoge = True
    for i in range(len(s1)):
        if len(s1) != len(s2):
            print("DIFFERENT")
            hoge = False
            break
        if count > 1:
            print("DIFFERENT")
            hoge = False
            break

        if not isTmp:
            if i % 2 == 0:
                if s1[i] != s2[i]:
                    print("DIFFERENT");
                    hoge = False
                    break
            if i % 2 == 1:
                if s1[i] != s2[i]:
                    count += 1
        else:
            if i+1 % 2 == 0:
                if s1[i] != s2[i]:
                    print("DIFFERENT");
                    hoge = False
                    break
            if i+1 % 2 == 1:
                if s1[i] != s2[i]:
                    count += 1

    if count == 1 and hoge:
        print("CLOSE")

Submission status: Accepted

Solution code:
# coding: utf-8

"""

"""

while True:
    s1 = raw_input()

    if s1 == '.':
        break

    s2 = raw_input()

    if s1 == s2:
        print "IDENTICAL"

    elif s1.count('"') != s2.count('"'):
        print "DIFFERENT"

    else:
        s1 = s1.split('"')
        s2 = s2.split('"')
        
        cnt = 0

        for i in range(len(s1)):
            if i % 2 == 1: 
                if s1[i] != s2[i]:
                    cnt += 1
            else:
                if s1[i] != s2[i]:
                    cnt += 2
                    break

        print "CLOSE" if cnt == 1 else "DIFFERENT"

Submission status: Accepted

Solution code:
while True:
    s1 = raw_input()
 
    if s1 == '.':
        break
 
    s2 = raw_input()

    s1 = s1.split('"')
    s2 = s2.split('"')

    if s1 == s2:
        print "IDENTICAL"
 
    elif len(s1) != len(s2):
        print "DIFFERENT"

    else:
        cnt = 0
        for i in range(len(s1)):
            if s1[i] != s2[i] and i % 2 == 1:
                cnt += 1
            elif s1[i] != s2[i]:
                cnt += 2

        print "CLOSE" if cnt == 1 else "DIFFERENT"

Submission status: Accepted

Solution code:
def vals(arr):
    even = True
    res = [[], []]
    tmp = []
    for e in arr:
        if e == "\"":
            even = not even
            res[even].append(tmp)
            tmp = []
            continue
        tmp.append(e)
    even = not even
    res[even].append(tmp)
    return res


while True:
    str1 = input()
    if str1 == ".":
        break
    a = vals(str1)
    b = vals(input())
    res = 0
    if len(a[0]) != len(b[0]) or len(a[1]) != len(b[1]) :
        res = 2
    else:
        for (x, y) in zip(a[0], b[0]):
            if x != y:
                res = 2
                break
    if res == 0:
        for (a, b) in zip(a[1], b[1]):
            if a != b:
                res += 1
                if res == 2:
                    break
    if res == 0:
        print("IDENTICAL")
    elif res == 1:
        print("CLOSE")
    else:
        print("DIFFERENT")

Submission status: Accepted

Solution code:
def check(s1,s2):
    l1 = s1.split('"')
    l2 = s2.split('"')
    if len(l1) != len(l2):
        return "DIFFERENT"
    close = 0
    for i in range(len(l1)):
        if l1[i] != l2[i]:
            if i % 2 == 0: return "DIFFERENT"
            else : close += 1
    if close == 1: return "CLOSE"
    if close == 0: return "IDENTICAL"
    return "DIFFERENT"

if __name__ == '__main__':
    while True:
        s1 = input()
        if s1 == ".": break
        s2 = input()
        print(check(s1,s2))

Submission status: Accepted

Solution code:
def check(str1,str2):
    if not(len(str1)==len(str2)):
        return False 
    for i in range(len(str1)):
        if not(str1[i]==str2[i]):
            return False
    return True


def solve(s1,s2):
    #print(len(s1),len(s2))
    if not(len(s1) == len(s2)):
        print("DIFFERENT")
        return
    flag = True
    for i in range(len(s1)):
        if not(check(s1[i],s2[i])):
            if i%2==1:
                if flag:
                    flag = False
                else:
                    print("DIFFERENT")
                    return
            else:
                print("DIFFERENT")
                return
    if flag:
        print("IDENTICAL")
    else:
        print("CLOSE")
        
    return


while True:
    s1=input().split('"')
    if s1[0] == '.':
        break
    s2 = input().split('"')
    solve(s1,s2)

Submission status: Accepted

Solution code:
def solve(s, t):
    s = s.split('"')
    t = t.split('"')

    if s == t:
        return "IDENTICAL"

    if len(s) == len(t):
        cnt = 0
        for i in range(len(s)):
            if s[i] != t[i] and i % 2 == 1:
                cnt += 1
            elif s[i] != t[i]:
                cnt += 2
        if cnt == 1:
            return 'CLOSE'

    return 'DIFFERENT'

while True:
    s1 = raw_input()

    if s1 == '.': break

    s2 = raw_input()

    print solve(s1, s2)

Submission status: Accepted

Solution code:
s1 = input().split('"')
while s1[0]!='.':
  miss = 0
  ans = "IDENTICAL"
  s2 = input().split('"')
  if len(s1) != len(s2):
    ans="DIFFERENT"
  else :
    for i in range(len(s1)):
      if i % 2 == 0 and s1[i] != s2[i]:
        ans="DIFFERENT"
        break
      if i % 2 == 1 and s1[i] != s2[i]:
        if ans == "CLOSE":
          ans="DIFFERENT"
          break
        else:
          ans = "CLOSE"
  print(ans)
  s1=input().split('"')

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

while True:
    s1 = input()
    if s1 == '.':
        break
    s2 = input()
    a = s1.strip().split('\"')
    b = s2.strip().split('\"')

    if len(a) != len(b):
        print("DIFFERENT")
    elif a[0::2] != b[0::2]:
        print("DIFFERENT")
    else:
        c = a[1::2]
        d = b[1::2]
        cnt = 0
        for i in range(len(c)):
            if c[i] != d[i]:
                cnt += 1
        if cnt == 0:
            print("IDENTICAL")
        elif cnt == 1:
            print("CLOSE")
        else:
            print("DIFFERENT")

Submission status: Accepted

Solution code:
#2行の文字列を受け取る
while True:
    str1 = input()
    if str1 == ".":
        break

    str2 = input()
#完全一致か判定する→「完全一致なら：ＸＸＸｘとだす」
    if str1 == str2:
        print("IDENTICAL")
        continue

#完全一致じゃない場合は→""でsplitする→頭が"ならば、奇数番目、頭が"じゃなければ、偶数番目にかこまれているやつはくる
        
    str1 = str1.split("\"")
    str2 = str2.split("\"")
    if not len(str1)==len(str2):
        print("DIFFERENT")
        continue
    
#""で囲まれていない場所が違っていたら、そもそもdiffrentをだす
    flg = 0
    for i in range(0,len(str1),2):
        if not str1[i] == str2[i]:
            flg = 1
            print("DIFFERENT")
            break
    if flg == 1:
        continue
    

#""で囲まれている場所を確認し、相違が1つだけならXXXXXを、2つ以上あればdiffrentをだす
    count = 0
    for i in range(1,len(str1),2):
        if not str1[i] == str2[i]: count +=1
        if count >= 2:
            break
    if count == 1:
        print("CLOSE")
    else:
        print("DIFFERENT")

Submission status: Accepted

Solution code:
while 1:
    s = input()
    if s=='.':
        break
    s=list(s.split('"'))
    t=list(input().split('"'))
    if s==t:
        print("IDENTICAL")
    elif len(s)!=len(t):
        print("DIFFERENT")
        continue
    else:
        flag = 0
        for i in range(0,len(s),2):
            if s[i] != t[i]:
                print("DIFFERENT")
                flag = 1
                break
        if flag == 1:
            continue
        for i in range(1,len(s),2):
            if s[i] != t[i]:
                flag+=1
                if flag == 2:
                    print("DIFFERENT")
                    break
        if flag == 1:
            print("CLOSE")

Submission status: Accepted

Solution code:
while True:
    s1 = input()
    if s1 == ".":
        break
    s2 = input()

    w1 = s1.split('"')
    w2 = s2.split('"')

    if len(w1) != len(w2):
        result = "DIFFERENT"
    else:
        n = len(w1)
        result = "IDENTICAL"
        for i in range(n):
            if i % 2 == 0:
                if w1[i] != w2[i]:
                    result = "DIFFERENT"
                    break
            else:
                if w1[i] != w2[i]:
                    if result == "IDENTICAL":
                        result = "CLOSE"
                    else:
                        result = "DIFFERENT"
                        break

    print(result)

Submission status: Accepted

Solution code:
while True:
    s1 = input().split('"')
    if s1[0] == '.':
        exit()
    s2 = input().split('"')
    if len(s1) != len(s2):
        print('DIFFERENT')
        continue
    ans = 1
    for i in range(len(s1)):
        if i % 2 == 0:
            if s1[i] != s2[i]:
                ans = -1
        else:
            if s1[i] != s2[i]:
                ans -= 1
    if ans == 1:
        print('IDENTICAL')
    elif ans == 0:
        print('CLOSE')
    else:
        print('DIFFERENT')

Submission status: Accepted

Solution code:
while(True):
    s1 = input()
    if (s1 == '.'):
        break
    s2 = input()

    ans = None
    if s1 == s2:
        ans = 'IDENTICAL'

    if ans is None:
        s1 = s1.split('"')
        s2 = s2.split('"')
        if len(s1) == len(s2):
            miss = 0
            for p1, p2 in zip(s1[0::2], s2[0::2]):
                if p1 != p2:
                    miss = 2
            for p1, p2 in zip(s1[1::2], s2[1::2]):
                if p1 != p2:
                    miss += 1
            if miss <= 1:
                ans = 'CLOSE'

    if ans is None:
        ans = 'DIFFERENT'

    print(ans)

Submission status: Accepted

Solution code:
while True:
    A = list(input().split("\""))
    if A[0] == ".":
        break
    
    B = list(input().split("\""))

    wrong = 0
    ans = ""

    for i in range(min(len(A),len(B))):
        if i%2 == 1:
            if A[i] != B[i]:
                wrong += 1
        else:
            if A[i] != B[i]:
                wrong = 2
    if wrong == 0:
        ans = "IDENTICAL"
    elif wrong == 1:
        ans = "CLOSE"
    else:
        ans = "DIFFERENT"   
    if len(A) != len(B):
        ans = "DIFFERENT"
    print(ans)

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2,gcd
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    ans=[]
    while 1:
        s1 = input()
        if s1 == '.':
            break
        else:
            s2 = input().split('"')
            s1=s1.split('"')

            ct=0
            flag=0

            if len(s1)!=len(s2):
                flag=2
            else:
                for i in range(len(s1)):
                    if i%2==0 :
                        if s1[i]!=s2[i]:
                            flag=2
                            break
                    else:
                        if s1[i]!=s2[i]:
                            if ct==0:
                                flag=1
                                ct+=1
                            else:
                                flag=2


            if flag==0:
                ans.append('IDENTICAL')
            elif flag==1:
                ans.append('CLOSE')
            else:
                ans.append('DIFFERENT')

    for x in ans:
        print(x)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import re
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))

ans = []
while 1:
	s1 = input()
	if s1 == ".":
		break
	s2 = input()

	if s1 == s2:
		ans.append("IDENTICAL")
	else:
		if s1.count('"') != s2.count('"'):
			ans.append("DIFFERENT")

		else:
			s1 = s1.split('"')
			s2 = s2.split('"')
			cnt = 0
			for i in range(min(len(s1), len(s2))):
				if i % 2 == 0 and s1[i] != s2[i]:
					ans.append("DIFFERENT")
					break
				elif i % 2 == 1 and s1[i] != s2[i]:
					cnt += 1
					if cnt >= 2:
						ans.append("DIFFERENT")
						break
			else:
				ans.append("CLOSE")
for i in ans:
	print(i)

Submission status: Accepted

Solution code:
def parse(str):
    strs = []
    s = ""
    code = ""
    isStr = False
    for c in str:
        if c == "\"":
            if isStr:
                strs.append(s)
                s = ""
            else:
                code = code + c
            isStr = not isStr
        elif isStr:
            s = s + c
        else:
            code = code + c
    return [strs, code]

def is_close(l1, l2):
    strs1 = parse(l1)
    strs2 = parse(l2)   
    if strs1[1] != strs2[1]:
        return False
    strs1 = strs1[0]
    strs2 = strs2[0]
    reach = False
    for i in range(min(len(strs1), len(strs2))):
        if strs1[i] != strs2[i]:
            if reach:
                return False
            else:
                reach = not reach
    if len(strs1) != len(strs2):
        return False
    else:
        return reach

while True:
    l1 = input()
    if l1 == '.':
        break
    l2 = input()
    if l1 == l2:
        print("IDENTICAL")
    elif is_close(l1, l2):
        print("CLOSE")
    else:
        print("DIFFERENT")

Submission status: Accepted

Solution code:
def make(s1):
    i = 0
    l1 = []
    while i < len(s1):
        if s1[i] == '"':
            for k in range(i + 1, len(s1)):
                if s1[k] == '"':
                    l1.append((s1[i + 1:k], 1))
                    i = k + 1
                    break
        elif s1[i] == ";":
            for k in range(i, len(s1)):
                if s1[k] == ';':
                    l1.append((s1[i + 1:k],0))
                    i = k + 1
                    break
                if s1[k] == '"':
                    l1.append((s1[i + 1:k], 0))
                    i = k 
                    break
            else:
                l1.append((s1[i + 1:], 0))
                i = k + 1
        else:
            for k in range(i, len(s1)):
                if s1[k] == ';':
                    l1.append((s1[i:k], 0))
                    i = k + 1
                    break
                if s1[k] == '"':
                    l1.append((s1[i:k], 0))
                    i = k
                    break
            else:
                l1.append((s1[i:], 0))
                i = k + 1
    return l1

def main():
    s1 = input()
    s2 = input()
    l1 = make(s1)
    l2 = make(s2)
    if len(l1) != len(l2):
        print("DIFFERENT")
        return
    f = 0
    for i in range(len(l1)):
        if l1[i] != l2[i]:
            if l1[i][1] == 0:
                f += 1
            f += 1
    if f == 0:
        print("IDENTICAL")
    elif f == 1:
        print("CLOSE")
    else:
        print("DIFFERENT")



for i in range(100):
    main()

Submission status: Accepted

Solution code:
def main(s):
	if s == ".":
		return False
	ss = input()
	diffc = 0
	sl = s.split("\"")
	ssl = ss.split("\"")
	if len(sl) != len(ssl):
		print("DIFFERENT")
		return True
	for i in range(len(sl)):
		if i % 2 == 0:
			if sl[i] != ssl[i]:
				print("DIFFERENT")
				return True
		else:
			if sl[i] != ssl[i]:
				diffc += 1
	if diffc == 0:
		print("IDENTICAL")
	elif diffc == 1:
		print("CLOSE")
	else:
		print("DIFFERENT")
	return True


while main(input()):
	pass