Problem: You are given strings S and T consisting of lowercase English letters.  You can perform the following operation on S any number of times:  Operation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.  Determine if S and T can be made equal by performing the operation zero or more times.

Submission attempts (in order):
S = input()
T = input()
flag = True
flag2 = False
l = ''
for i in range(len(S)):
    if S[i] != T[i]:
        if flag2 and S[i] in S[:i-1]:
            print(S[i])
            print(T[i])
            print(S)
            print(T)
            flag = False
            break
        s = S[i]
        for j in range(i,len(S)):
            if S[j] == s:
                S = S[:j]+T[i]+S[j+1:]
            elif S[j] == T[i]:
                S = S[:j]+s+S[j+1:]
    if not flag2:
        flag2 = True
if flag:
    print('YES')
else:
    print('NO')

S = input()
T = input()

flag = True
translate = [-1 for i in range(26)]

for i in range(len(S)):
    s = ord(S[i])-97
    if translate[s] == -1:
        translate[s] = ord(T[i])
    else:
        if ord(T[i]) != translate[s]:
            flag = False
            break


if flag:
    print('YES')
else:
    print('NO')


S = input()
T = input()
flag = True
flag2 = False
l = ''
for i in range(len(S)):
    if S[i] != T[i]:
        if flag2 and (S[i] in S[:i-1] or T[i] in S[:i-1]):
            flag = False
            break
        s = S[i]
        for j in range(i,len(S)):
            if S[j] == s:
                S = S[:j]+T[i]+S[j+1:]
            elif S[j] == T[i]:
                S = S[:j]+s+S[j+1:]
#        print(S)
    if not flag2:
        flag2 = True
if flag:
    print('YES')
else:
    print('NO')



S = input()
T = input()

flag = True
translate1 = [-1 for i in range(26)]
translate2 = [-1 for i in range(26)]
for i in range(len(S)):
    s = ord(S[i])-97
    t = ord(T[i])-97

    if translate1[s] == -1:
        translate1[s] = t
    else:
        if translate1[s] != t:
            flag = False
            break 

    if translate2[t] == -1:
        translate2[t] = s
    else:
        if translate2[t] != s:
            flag = False
            break


if flag:
    print('YES')
else:
    print('NO')

S = input()
T = input()
flag = True
flag2 = False
l = ''
for i in range(len(S)):
    if S[i] != T[i]:
        if flag2 and S[i] in S[:i-1]:
            print(S[i])
            print(T[i])
            print(S)
            print(T)
            flag = False
            break
        s = S[i]
        for j in range(i,len(S)):
            if S[j] == s:
                S = S[:j]+T[i]+S[j+1:]
            elif S[j] == T[i]:
                S = S[:j]+s+S[j+1:]
        flag2 = True
if flag:
    print('YES')
else:
    print('NO')

S = input()
T = input()
flag = True
flag2 = False
l = ''
for i in range(len(S)):
    if S[i] != T[i]:
        if flag2 and (S[i] in S[:i-1] or T[i] in T[:i-1]):
            flag = False
            break
        s = S[i]
        for j in range(i,len(S)):
            if S[j] == s:
                S = S[:j]+T[i]+S[j+1:]
            elif S[j] == T[i]:
                S = S[:j]+s+S[j+1:]
    if not flag2:
        flag2 = True
if flag:
    print('YES')
else:
    print('NO')

S = input()
T = input()

flag = True
translate1 = [-1 for i in range(26)]
translate2 = [-1 for i in range(26)]
for i in range(len(S)):
    s = ord(S[i])-97
    t = ord(T[i])-97

    if translate1[s] == -1:
        translate1[s] = t
    else:
        if translate1[s] != t:
            flag = False
            break 

    if translate2[t] == -1:
        translate2[t] = s
    else:
        if translate2[t] != s:
            flag = False
            break


if flag:
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted