Problem:
 Score : 300 points    Problem Statement 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.      Constraints  1 \leq |S| \leq 2 \times 10^5  |S| = |T|  S and T consists of lowercase English letters.         Input Input is given from Standard Input in the following format:  S  T       Output If S and T can be made equal, print Yes ; otherwise, print No .        Sample Input 1 azzel
apple      Sample Output 1 Yes  azzel can be changed to apple , as follows:   Choose e as c_1 and l as c_2 . azzel becomes azzle .  Choose z as c_1 and p as c_2 . azzle becomes apple .        Sample Input 2 chokudai
redcoder      Sample Output 2 No  No sequences of operation can change chokudai to redcoder .       Sample Input 3 abcdefghijklmnopqrstuvwxyz
ibyhqfrekavclxjstdwgpzmonu      Sample Output 3 Yes

Solution (Python):
import sys
from collections import Counter


def main():
    s = input()
    t = input()
    s_count = [0]*26
    t_count = [0]*26
    for i in range(ord("a"), ord("z")+1):
        s_count[i-97] = s.count(chr(i))
        t_count[i-97] = t.count(chr(i))
    s_count.sort()
    t_count.sort()
    if s_count == t_count:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    S = input().rstrip()
    T = input().rstrip()
    L = [[S[i],T[i]] for i in range(len(S))]
    L.sort(key = lambda x: x[0])
    D = defaultdict(int)
    D2 = defaultdict(int)
    for a, b in L:
        if (D[a] == 0 or D[a] == b) and (D2[b] == 0 or D2[b] == a):
            D[a]=b
            D2[b]=a
        else:
            print("No")
            exit()
    print("Yes")
    
    
if __name__ == "__main__":
    main()

Solution (Python):
S = input()
T = input()
s_let = [0]*26
t_let = [0]*26
ans = "Yes"

for i in range(len(S)):
  s_let[ord(S[i])-ord("a")] += 1
for j in range(len(T)):
  t_let[ord(T[j])-ord("a")] += 1

s_let.sort()
t_let.sort()

for k in range(26):
  if s_let[k] != t_let[k]:
    ans = "No"

print(ans)

Solution (Python):
import collections

A = input()
B = input()

A_c = collections.Counter(A)
B_c = collections.Counter(B)
A_c = A_c.values()
B_c = B_c.values()

A_c = list(A_c)
B_c = list(B_c)
A_c.sort()
B_c.sort()
if A_c == B_c:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
t = input()
x = []
y = []
for i in range(len(s)):
    if s[i] not in x:
        x.append(s[i])
    if t[i] not in y:
        y.append(t[i])
for i in range(len(x)):
    s = s.replace(x[i], str(i))
for i in range(len(y)):
    t = t.replace(y[i], str(i))
if s == t:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

def main():
    S = input()
    T = input()
    cnt_S = []
    cnt_T = []
    for i, j in Counter(S).items():
        cnt_S.append(j)
    for i, j in Counter(T).items():
        cnt_T.append(j)

    cnt_S.sort()
    cnt_T.sort()
    if cnt_T == cnt_S:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Solution (Python):








def solve(S, T):
    N = len(S)
    S_check = [0] * N
    T_check = [0] * N
    for i in range(N):
        if S_check[i] == 0:
            S_check[i] = 1
            for j in range(i + 1, N):
                if S[i] == S[j]:
                    S_check[j] = 1
                    if T[i] != T[j]:
                        print('No')
                        return
        if T_check[i] == 0:
            T_check[i] = 1
            for j in range(i + 1, N):
                if T[i] == T[j]:
                    T_check[j] = 1
                    if S[i] != S[j]:
                        print('No')
                        return
    print('Yes')


if __name__ == '__main__':
    S = input()
    T = input()
    solve(S, T)

Solution (Python):








def solve(S, T):
    alp = 'abcdefghijklmnopqrstuvwxyz'
    N = len(S)
    S_same = [[] for _ in range(N)]
    S_alphabet = {s: [] for s in alp}
    T_same = [[] for _ in range(N)]
    T_alphabet = {s: [] for s in alp}
    for i in range(N):
        S_alphabet[S[i]].append(i)
        T_alphabet[T[i]].append(i)
    for s in alp:
        stmp = S_alphabet[s]
        ttmp = T_alphabet[s]
        if len(stmp) > 0:
            S_same[stmp[0]] = stmp.copy()
        if len(ttmp) > 0:
            T_same[ttmp[0]] = ttmp.copy()
    for i in range(N):
        if len(S_same[i]) > 1:
            for ss in S_same[i][1:]:
                if T[S_same[i][0]] != T[ss]:
                    print('No')
                    return
        if len(T_same[i]) > 1:
            for tt in T_same[i][1:]:
                if S[T_same[i][0]] != S[tt]:
                    print('No')
                    return
    print('Yes')


if __name__ == '__main__':
    S = input()
    T = input()
    solve(S, T)

Solution (Python):
s=list(input())
t=list(input())

n=len(s)
ch=0
ch1=0
ans=0

d={}
d1={}

st=1
st1=1

s_new=[]
t_new=[]

for i in range(n):
  if s[i] not in d:
    d[s[i]]=st
    st+=1
    
for g in range(n):
  if t[g] not in d1:
    d1[t[g]]=st1
    st1+=1
    
for h in range(n):
  s_new.append(d[s[h]])
  t_new.append(d1[t[h]])
  
if s_new==t_new:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  


alphabet = [chr(i+97) for i in range(26)]
dS,dT = {},{}
for s in alphabet:
    dS[s] = []
    dT[s] = []

S,T = LS2(),LS2()
N = len(S)
for i in range(N):
    dS[S[i]].append(i)
    dT[T[i]].append(i)

count_S,count_T = [0]*N,[0]*N  
for i in range(N):
    count_S[i] = len(dS[S[i]])
    count_T[i] = len(dT[T[i]])

print('Yes' if count_S == count_T else 'No')

Solution (Python):
S=input()
T=input()
N=len(S)
d=dict()
for i in range(N):
    if S[i] not in d.keys():
        if T[i] in d.values():
            print("No")
            break
        d[S[i]]=T[i]
    else:
        if d[S[i]]!=T[i]:
            print("No")
            break
else:
    print("Yes")

Solution (Python):
S = input()
T = input()
sdic = {}
tdic = {}
flag = True
for s, t in zip(S, T):
  if s not in sdic:
    sdic[s] = t
  if t not in tdic:
    tdic[t] = s
  if sdic[s] != t or tdic[t] != s:
    flag = False
    break
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():


    s = S()
    t = S()
    
    dic1 = collections.defaultdict(str)
    dic2 = collections.defaultdict(str)
    
    for i in range(len(s)):
        if dic1[t[i]] == "":
            dic1[t[i]] = s[i]
        else:
            if dic1[t[i]] != s[i]:
                print("No")
                exit(0)

        if dic2[s[i]] == "":
            dic2[s[i]] = t[i]
        else:
            if dic2[s[i]] != t[i]:
                print("No")
                exit(0)
        
    print("Yes")

main()

Solution (Python):
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    S = SI()
    T = SI()
    
    
    ord_S = [0 for _ in range(26)]
    ord_T = [0 for _ in range(26)]
    
    for n in range(len(S)):
        ord_S[ord(S[n])-97] += 1
        ord_T[ord(T[n])-97] += 1
    
    
    s_ord_S = sorted(ord_S)
    s_ord_T = sorted(ord_T)
    
    for p in range(26):
        if s_ord_S[p] != s_ord_T[p]:
            print("No")
            sys.exit()
    print("Yes")
        

if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input():
  return sys.stdin.readline().rstrip()

S=input()
T=input()

ok=True
a,b={},{}
for i in range(len(S)):
  s=S[i]
  t=T[i]
  if s in a:
    if a[s]!=t:
      ok=False
  if t in b:
    if b[t]!=s:
      ok=False
  a[s]=t
  b[t]=s

print("Yes" if ok else "No")

Solution (Python):
S=input()
T=input()

ok=True
a,b={},{}
for i in range(len(S)):
  s=S[i]
  t=T[i]
  if s in a:
    if a[s]!=t:
      ok=False
  if t in b:
    if b[t]!=s:
      ok=False
  a[s]=t
  b[t]=s

print("Yes" if ok else "No")

Solution (Python):
import sys

input = sys.stdin.readline

S = input()
S = S.replace('\n','')
s_list = list(S)

T = input()
T = T.replace('\n','')
t_list = list(T)

alpha_dict = {}
t_diff_count = [0 for i in range(27)]
s_diff_count = [0 for i in range(27)]

for i,c in enumerate(range(ord('a'),ord('z')+1)):
    alpha_dict[chr(c)] = i 

for i,s in enumerate(s_list):
    
    number = alpha_dict[s_list[i]]
    s_diff_count[number] += 1
    number = alpha_dict[t_list[i]]
    t_diff_count[number] += 1

for i,s in enumerate(s_list):
    number = alpha_dict[s_list[i]]
    s_count = s_diff_count[number] 
    number = alpha_dict[t_list[i]]
    t_count = t_diff_count[number]
    if not s_count == t_count:
        if t_count >= 2:
            print("No")
            exit(0)
        if s_count >= 2:
            print("No")
            exit(0)
print("Yes")

Solution (Python):
import collections
a = list(input())
b = list(input())
A = collections.Counter(a)
B = collections.Counter(b)
Alist = list(A.values())
Blist = list(B.values())
Asort = sorted(Alist)
Bsort = sorted(Blist)
if Asort == Bsort:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()
T = input()
U = [[i,j] for i,j in zip(S,T)]
U.sort()
s = U[0][0]
t = U[0][1]
for i,j in U:
    if  i != s:
        s = i
        t = j
    elif j != t:
        print("No")
        exit()
U.sort(key=lambda x:x[1])
s = U[0][0]
t = U[0][1]
for i,j in U:
    if j != t:
        s = i
        t = j
    elif i != s:
        print("No")
        exit()
print("Yes")

Solution (Python):
import math
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    S = input().strip()
    T = input().strip()
    s_t = {}
    t_s = {}
    for s, t in zip(S, T):
        if s not in s_t and t not in t_s:
            s_t[s] = t
            t_s[t] = s
        elif s in s_t and t in t_s:
            if not (s_t[s] == t and t_s[t] == s):
                return 'No'
        else:
            return 'No'
    return 'Yes'



if __name__ == '__main__':
    print(solve())

Solution (Python):
S = input()
T = input()
length = len(S)
keep_S = [[] for i in range(26)]  
keep_T = [[] for i in range(26)]  

for i in range(length):

    num_S = ord(T[i]) - ord('a')
    num_T = ord(S[i]) - ord('a')

    if S[i] in keep_S[num_S]:
        continue
    else:
        keep_S[num_S].append(S[i])

    if T[i] in keep_T[num_T]:
        continue
    else:
        keep_T[num_T].append(T[i])


for i in range(26):
    if (len(keep_T[i]) > 1) | (len(keep_S[i]) > 1):
        print('No')
        exit()
print('Yes')

Solution (Python):
S = input()
T = input()

chk1 = [[] for _ in range(26)]
chk2 = [[] for _ in range(26)]
for i in range(len(S)):
    s1 = ord(S[i]) - 97
    s2 = ord(T[i]) - 97
    if len(chk1[s1]) == 0:
        chk1[s1].append(T[i])
    else:
        if chk1[s1][0] == T[i]:
            pass
        else:
            print('No')
            exit()
    if len(chk2[s2]) == 0:
        chk2[s2].append(S[i])
    else:
        if chk2[s2][0] == S[i]:
            pass
        else:
            print('No')
            exit()    
print('Yes')

Solution (Python):
S = input()
T = input()
N = len(S)
SD = {}
TD = {}
SN = [0]*N
TN = [0]*N
count = 1
for i in range(N):
  s = S[i]
  if s not in SD:
    SD[s] = count
    count+=1
  SN[i] = SD[s]
count = 1
for i in range(N):
  t = T[i]
  if t not in TD:
    TD[t] = count
    count+=1
  TN[i] = TD[t]
ans = "Yes"
for i in range(N):
  if SN[i]!=TN[i]:
    ans = "No"
    break
print(ans)

Solution (Python):

import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

S = input()
T = input()

sd = defaultdict(lambda: ".")
td = defaultdict(lambda: ".")

for s, t in zip(S, T):
    if sd[s] != "." and sd[s] != t:
        print("No")
        exit()
    if td[t] != "." and td[t] != s:
        print("No")
        exit()
    sd[s] = t
    td[t] = s
print("Yes")

Solution (Python):
S=input()
T=input()
alp=[chr(i) for i in range(97, 97+26)]
words_T=[[] for _ in range(len(alp))]
words_S=[[] for _ in range(len(alp))]
num=0
for al in alp:
    for n in range(len(T)):
        if T[n]==al:
            words_T[num].append(n)
    num+=1
num=0
for al in alp:
    for n in range(len(T)):
        if S[n]==al:
            words_S[num].append(n)
    num+=1
flag=0
for word in words_T:
    if len(word)<=1:
        continue
    wo=S[word[0]]
    for w in word:
        if wo==S[w]:
            continue
        else:
            flag=1
            break
for word in words_S:
    if len(word)<=1:
        continue
    wo=T[word[0]]
    for w in word:
        if wo==T[w]:
            continue
        else:
            flag=1
            break
if flag==0:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()

l_s = [[] for _ in range(26)]

for i, x in enumerate(s):
    l_s[ord(x) - 97].append(i)

l_t = [[] for _ in range(26)]
for i, x in enumerate(t):
    l_t[ord(x) - 97].append(i)

for l in l_s:
    if len(l) > 0:
        if l_t[ord(t[l[0]]) - 97] != l:
            print('No')
            exit()

print('Yes')

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    s = input()
    t = input()
    import string

    l = string.ascii_lowercase

    for i in l:
        trial = set()
        for k,j in enumerate(s):
            if i == j:
                trial.add(t[k])
                if len(trial) > 1:
                    print("No")
                    exit()
        trial = set()
        for k,j in enumerate(t):
            if i == j:
                trial.add(s[k])
                if len(trial) > 1:
                    print("No")
                    exit()

    print("Yes")



if __name__=="__main__":
    main()

Solution (Python):
s=input()
t=input()

t1=0
l1={}
sl=[]
for i in s:
  if i in l1:
    sl.append(l1[i])
  else:
    l1[i]=t1
    sl.append(t1)
    t1+=1

t2=0
l2={}
tl=[]
for i in t:
  if i in l2:
    tl.append(l2[i])
  else:
    l2[i]=t2
    tl.append(t2)
    t2+=1
print("Yes" if sl==tl else "No")

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

S,T=input(),input()
C=[-1]*26
D=set(list(range(26)))
ans=True
for i in range(len(S)):
    s,t=ston(S[i]),ston(T[i])
    if C[s]!=t:
        if C[s]!=-1 or t not in D:
            ans=False
            break
        D.remove(t)
        C[s]=t
judge(ans)

Solution (Python):
def main():
    dic1 = {}
    dic2 = {}
    S = list(input().rstrip())
    T = list(input().rstrip())
    for s, t in zip(S, T):
        if s not in dic1:
            dic1[s] = t
        elif dic1[s] != t:
            print('No')
            exit()
        if t not in dic2:
            dic2[t] = s
        elif dic2[t] != s:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
import sys

from collections import Counter


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = input()
    T = input()
    S_cnt = Counter(S).most_common()
    T_cnt = Counter(T).most_common()
    if len(S_cnt) != len(T_cnt):
        print("No")
        return
    for i in range(len(S_cnt)):
        if S_cnt[i][1] == T_cnt[i][1]:
            continue
        else:
            print("No")
            return
    print("Yes")
    return


if __name__ == "__main__":
    main()

Solution (Python):
s = list(input())
t = list(input())
n = len(s)

s_par = [i for i in range(n + 1)]
t_par = [i for i in range(n + 1)]

def operation(x, par):
    for i in range(n):
        for j in range(i):
            if x[i] == x[j]:
                par[i] = par[j]
                break
    return par

if operation(s, s_par) == operation(t, t_par):
    print('Yes')
else:
    print('No')

Solution (Python):
s = list(input())
t = list(input())
n = len(s)

s_par = [i for i in range(n + 1)]
t_par = [i for i in range(n + 1)]

for i in range(n):
    for j in range(i):
        if s[i] == s[j]:
            s_par[i] = s_par[j]
            break
            
for i in range(n):
    for j in range(i):
        if t[i] == t[j]:
            t_par[i] = t_par[j]
            break
            
if s_par == t_par:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()
n = len(s)
x = []
y = []

for i in range(n):
    if s[i] not in x:
        x.append(s[i])
    if t[i] not in y:
        y.append(t[i])

for i in range(len(x)):
    s = s.replace(x[i], str(i))
for i in range(len(y)):
    t = t.replace(y[i], str(i))
print('Yes' if s == t else 'No')

Solution (Python):
s = list(input())
t = list(input())

s = list(map(ord, s))
t = list(map(ord, t))
s_to_t = [-1] * 200
t_to_s = [-1] * 200

for i in range(len(s)):
    if s_to_t[s[i]] == -1:
        s_to_t[s[i]] = t[i]
    else:
        if s_to_t[s[i]] != t[i]:
            print("No")
            break
    if t_to_s[t[i]] == -1:
        t_to_s[t[i]] = s[i]
    else:
        if t_to_s[t[i]] != s[i]:
            print("No")
            break
else:
    print("Yes")

Solution (Python):

from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)





def LI(): return list(map(int, sys.stdin.buffer.readline().split()))




def I(): return int(sys.stdin.buffer.readline())





def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()




def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')







def IR(n): return [I() for i in range(n)]







def LIR(n): return [LI() for i in range(n)]







def SR(n): return [S() for i in range(n)]







def LSR(n): return [LS() for i in range(n)]







def SRL(n): return [list(S()) for i in range(n)]


def main():
    s = S()
    t = S()
    s_c = Counter(s)
    s_t = Counter(t)
    if sorted(s_c.values()) == sorted(s_t.values()):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
s = input()
t = input()
x = []
y = []
for i in range(len(s)):
    if s[i] not in x:
        x.append(s[i])
    if t[i] not in y:
        y.append(t[i])
for i in range(len(x)):
    s = s.replace(x[i], str(i))
for i in range(len(y)):
    t = t.replace(y[i], str(i))
if s == t:
    print("Yes")
else:
    print("No")

Solution (Python):
import collections
S = list(input())
T = list(input())
counterS = collections.Counter(S)
counterT = collections.Counter(T)
Scou = list(counterS.values())
Tcou = list(counterT.values())
Scou.sort()
Tcou.sort()
if Scou == Tcou:
    print('Yes')
else:
    print('No')

Solution (Python):
s=list(input())
t=list(input())
n=len(s)
def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for i in range(n):
        ans[s[i]].append(i)
    return ans


def get_index2alpha(s):
    ans={}
    for i in range(n):
        ans[i]=s[i]
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0

s_set=set(s)


for i in range(n):
    s_alpha=s_index[i]
    t_alpha = t_index[i]
    if s_alpha in s_set:
        s_set.remove(s_alpha)
        if not s_count[s_alpha]==t_count[t_alpha]:
            ans+=1

if ans==0:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
T = input()
ans = 'Yes'
dic1,dic2 = {},{}

for i,j in zip(S,T):
    if i in dic1:
        if dic1[i] != j:
            ans = 'No'
    else:
        dic1[i] = j
        
    if j in dic2:
        if dic2[j] != i:
            ans = 'No'
    else:
        dic2[j] = i



print(ans)

Solution (Python):
S=input()
T=input()

D1={}
D2={}

ans=1
for s,t in zip(S,T):
    x=D1.get(t, '')
    if x=='':
        D1[t]=s
    else:
        if x!=s:
            ans=0
            break
            
    x=D2.get(s, '')
    if x=='':
        D2[s]=t
    else:
        if x!=t:
            ans=0
            break

print('Yes' if ans else 'No')

Solution (Python):
from collections import Counter
s = [i for i in str(input())]
t = [h for h in str(input())]
s1 = Counter(s).most_common()
t1 = Counter(t).most_common()
if len(s1) != len(t1):
    print('No')
else:
    z = 'Yes'
    for j in range(len(s1)):
        if s1[j][1] != t1[j][1]:
            z = 'No'
            break
    print(z)

Solution (Python):
s = input()
t = input()

def f(x):
    dic = {}
    for c in x:
        if c in dic:
            dic[c] += 1
        else:
            dic[c] = 1
    return dic

d1 = f(s)
d2 = f(t)
l1 = [i for i in d1.values()]
l2 = [i for i in d2.values()]
l1.sort()
l2.sort()

if l1 == l2:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter

s = list(input())
t = list(input())

sc = Counter(s).values()
tc = Counter(t).values()

sl = Counter(sc)
tl = Counter(tc)

if sl == tl:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()
cs = []
ct = []
for i in range(97,97+26):
  cs.append(s.count(chr(i)))
  ct.append(t.count(chr(i)))
if sorted(cs) == sorted(ct):
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    S = SI()
    T = SI()
    D = defaultdict(str)
    for s, t in zip(S, T):
        if D[s] == "":
            D[s] = t
        if D[s] != t:
            print("No")
            exit()
    if len(set(D.keys())) != len(set(D.values())):
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Solution (Python):

from collections import defaultdict

S = input()
T = input()

ctr_s = defaultdict(list)
ctr_t = defaultdict(list)
for i in range(len(S)):
    ctr_s[S[i]].append(i)
    ctr_t[T[i]].append(i)

ok = True
for key in ctr_s:
    char = T[ctr_s[key][0]]
    ok &= len(ctr_s[key]) == len(ctr_t[char])
    ok &= all(u == v for u, v in zip(ctr_s[key], ctr_t[char]))

if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
t=input()

n=len(s)

slis=[]

for i in range(n):
  if s[i] not in slis:
    slis.append(s[i])

tlis=[]

for i in range(n):
  if t[i] not in tlis:
    tlis.append(t[i])

snum=[]

for i in range(n):
  for j in range(len(slis)):
    if s[i]==slis[j]:
      snum.append(j)
      break

tnum=[]
for i in range(n):
  for j in range(len(tlis)):
    if t[i]==tlis[j]:
      tnum.append(j)


c=0
for i in range(n):
  if snum[i]!=tnum[i]:
    c+=1

if c==0:
  print("Yes")
else:
  print("No")

Solution (Python):







s, t = list(input()), list(input())
sd, td = {}, {}
for sv in s:
    if sv not in sd:
        sd[sv] = 1
    else:
        sd[sv] += 1
for tv in t:
    if tv not in td:
        td[tv] = 1
    else:
        td[tv] += 1
ss, ts = sorted(sd.values()), sorted(td.values())
if ss == ts:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
t = input()

sc = {}
tc = {}

for i in range(len(s)):
    if s[i] in sc:
        sc[s[i]].append(i)
    else:
        sc[s[i]] = [i]

    if t[i] in tc:
        tc[t[i]].append(i)
    else:
        tc[t[i]] = [i]

sc = list(sc.values())
tc = list(tc.values())

print("Yes" if sc == tc else "No")

Solution (Python):
S = input()
T = input()

s = [[] for i in range(26)]
t = [[] for i in range(26)]

for i in range(len(S)):
    s[ord(S[i])-97].append(i)
    t[ord(T[i])-97].append(i)

s = sorted(s)
t = sorted(t)
if s == t:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import *
s=input()
r=input()
c=Counter(sorted(s))
C=Counter(sorted(r))
if(sorted(c.values())==sorted(C.values())):
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
s = input()
t = input()

s_count = Counter(s)
t_count = Counter(t)
if sorted(s_count.values()) == sorted(t_count.values()): print("Yes")
else: print("No")

Solution (Python):
s = input()
t = input()

sl = list(s)
tl = list(t)

from collections import Counter
sc = Counter(sl)
tc = Counter(tl)

sp =[]
tp =[]

alp = "abcdefghijklmnopqrstuvwxyz"

for i in alp:
    sp.append(sc[i])
    tp.append(tc[i])

sps =sorted(sp)
tps = sorted(tp)

for i,j in zip (sps,tps):
    if i ==j:
        pass
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
s=list(input())
t=list(input())

import sys
dic_s={}
dic_t={}

for i in range(len(s)):
  a=dic_s.get(s[i],t[i])
  b=dic_t.get(t[i],s[i])
  if a!=t[i] or b!=s[i]:
    print("No")
    sys.exit()
  dic_s[s[i]]=t[i]
  dic_t[t[i]]=s[i]
print("Yes")

Solution (Python):
S = input()
T = input()

alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

S_counter = []
T_counter = []
for i in alph:
    S_counter.append(S.count(i))
    T_counter.append(T.count(i))

S_counter.sort()
T_counter.sort()

if S_counter == T_counter:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()

d = {}
use = set()
for si,ti in zip(s,t):
    if(si in d):
        if(ti != d[si]):
            print('No')
            exit()
    else:
        if(ti in use):
            print('No')
            exit()
        d[si] = ti
        use.add(ti)

print('Yes')

Solution (Python):
from collections import defaultdict

S = input()
T = input()

dictS = defaultdict(int)
dictT = defaultdict(int)
dictS[S[0]] = dictT[T[0]] = 1
n = 2

for i in range(1, len(S)):
    if dictS[S[i]] == dictT[T[i]]:
        if dictS[S[i]] == 0:
            dictS[S[i]] = dictT[T[i]] = n
            n += 1
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
import collections 
s = input()
t = input()
sc = sorted(collections.Counter(s).values())
tc = sorted(collections.Counter(t).values())


for i in range(len(sc)):
  if sc[i] != tc[i]:
    print("No")
    exit()
print("Yes")

Solution (Python):
from collections import Counter

S=list(input())
T=list(input())
a=Counter(S).most_common()
b=Counter(T).most_common()
for i in range(len(a)):
  if a[i][1]!=b[i][1]:
    print('No')
    exit()
else:
  print('Yes')

Solution (Python):
import sys






from collections import Counter, deque, defaultdict


MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    s = read_str()
    t = read_str()

    s_lis = sorted(Counter(s).values())
    t_lis = sorted(Counter(t).values())
    
    if s_lis == t_lis:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    Main()