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):
def examA():
    A = LI()
    A.sort()
    ans = A[2]*10+A[1]+A[0]
    print(ans)
    return

def examB():
    N, M, x, y = LI()
    X = LI()
    Y = LI()
    X.sort(); Y.sort()
    if max(X[-1],x)<min(Y[0],y):
        print("No War")
    else:
        print("War")
    return

def examC():
    S = SI()
    T = SI()
    N = len(S)
    Ds = defaultdict(str)
    Dt = defaultdict(str)
    for i in range(N):
        s = S[i]; t = T[i]
        if Ds[s]!="" and Ds[s]!=t:
            print("No")
            return
        Ds[s] = t
        if Dt[t] != "" and Dt[t] != s:
            print("No")
            return
        Dt[s] = s
    print("Yes")
    return

def examD():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()



def examA():
    A = LI()
    A.sort()
    ans = A[2]*10+A[1]+A[0]
    print(ans)
    return

def examB():
    N, M, x, y = LI()
    X = LI()
    Y = LI()
    X.sort(); Y.sort()
    if max(X[-1],x)<min(Y[0],y):
        print("No War")
    else:
        print("War")
    return

def examC():
    S = SI()
    T = SI()
    N = len(S)
    Ds = defaultdict(str)
    Dt = defaultdict(str)
    for i in range(N):
        s = S[i]; t = T[i]
        if Ds[s]!="" and Ds[s]!=t:
            print("No")
            return
        Ds[s] = t
        if Dt[t] != "" and Dt[t] != s:
            print("No")
            return
        Dt[t] = s
    print("Yes")
    return

def examD():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()



Verdicts: Wrong Answer

Accepted