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):
S=input()
T=input()

r1=[set() for _ in range(26)]
r2=[set() for _ in range(26)]
for s,t in zip(S,T):
  r1[ord(t)-ord('a')].add(s)
  r2[ord(s)-ord('a')].add(t)
  
flag=True
for ind,outd in zip(r1,r2):
  n_in=len(ind)
  n_out=len(outd)
  if n_in>=2 or n_out>=2:
    flag=False
    break
print('Yes') if flag else print('No')

Solution (Python):
from collections import defaultdict

S = input()
T = input()

first_appear_s = dict()
first_appear_t = dict()

for i in range(len(S)) :
    s = S[i]
    t = T[i]
    if not s in first_appear_s :
        first_appear_s[s] = i
    if not t in first_appear_t :
        first_appear_t[t] = i
        
    if first_appear_s[s] != first_appear_t[t] :
        print('No')
        break
else :
    print('Yes')

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()
T = si()
 
dict_S = {}
dict_T = {}
 
for i in range(len(S)):
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    else:
        dict_S[S[i]] = T[i]
        
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    else:
        dict_T[T[i]] = S[i]
        
print("Yes")

Solution (Python):
def main():
  S = str(input())
  s = list(S)
  T = str(input())
  t = list(T)
  alpha2num = lambda c: ord(c) - ord('a')
  r = [-1]*26
  r_ = [-1]*26
  ans = "Yes"
  for i in range(len(s)):
    if r[alpha2num(s[i])] >= 0:
      if r[alpha2num(s[i])] == alpha2num(t[i]):
        continue
      else:
        ans = "No"
        break
    else:
      r[alpha2num(s[i])] = alpha2num(t[i])
    if r_[alpha2num(t[i])] >= 0:
      if r_[alpha2num(t[i])] == alpha2num(s[i]):
        continue
      else:
        ans = "No"
        break
    else:
      r_[alpha2num(t[i])] = alpha2num(s[i])
  print(ans)

if __name__ == "__main__":
  main()

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

dict_S = {}
dict_T = {}

for i in range(len(S)):
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    else:
        dict_S[S[i]] = T[i]
        
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    else:
        dict_T[T[i]] = S[i]
        
print("Yes")

Solution (Python):
w1 = input()
w2 = input()

s1 = list(w1)
s2 = list(w2)
s1.sort()
s2.sort()

c1 = 0
t1 = ""
a1 = []
for i1 in range(len(s1)):
    if s1[i1] != t1:
        a1.append(c1)
        t1 = s1[i1]
        c1 = 1
        if i1 == len(s1) - 1:
            a1.append(c1)
    else:
        c1 += 1
        if i1 == len(s1) - 1:
            a1.append(c1)

c1 = 0
t1 = ""
a2 = []
for i2 in range(len(s2)):
    if s2[i2] != t1:
        a2.append(c1)
        t1 = s2[i2]
        c1 = 1
        if i2 == len(s2) - 1:
            a2.append(c1)
    else:
        c1 += 1
        if i2 == len(s2) - 1:
            a2.append(c1)

a1.sort()
a2.sort()

if a1 == a2:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
s=sorted(Counter(input()).values())
t=sorted(Counter(input()).values())
print('Yes' if s==t else 'No')

Solution (Python):
S = input()
T = input()
SD = dict()
TD = dict()

valid = True
for s, t in zip(S, T):
    if s not in SD.keys():
        SD[s] = t
    else:
        if SD[s] != t:
            valid = False
            break
    if t not in TD.keys():
        TD[t] = s
    else:
        if TD[t] != s:
            valid = False
            break

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

Solution (Python):
from collections import defaultdict
s = input()
t = input()
n = len(s)
sd = defaultdict(lambda: -1)
td = defaultdict(lambda: -1)
u, v = [0] * len(s), [0] * len(t)

for i in range(n):
    sc = s[i]
    if sd[sc] != -1:
        u[i] = sd[sc]
    else: 
        u[i] = i
        sd[sc] = i
    
    tc = t[i]
    if td[tc] != -1:
        v[i] = td[tc]
    else: 
        v[i] = i
        td[tc] = i
    
    if u[i] != v[i]:
        print("No")
        break
else: print("Yes")

Solution (Python):
S = input()
T = input()
d = dict()
d2 = dict()
check1 = dict()
check2 = dict()
for i in "abcdefghijklmnopqrstuvwxyz":
    check1[i] = False
    check2[i] = False
for i in range(len(S)):
    if check2[T[i]]:
        if d2[T[i]] != S[i]:print("No");exit()
    if not check1[S[i]]:
        check1[S[i]] = True
        d[S[i]] = T[i]
        check2[T[i]] = True
        d2[T[i]] = S[i]
    else:
        if d[S[i]] != T[i]:print("No");exit()
print("Yes")

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

dicS={};dicT={}

f=True

for i in range(len(S)):
    c=S[i];d=T[i]
    
    if c in dicS and d!=dicS[c]:
        f=False
        break
    elif c not in dicS:
        dicS[c]=d
    
    if d in dicT and c!=dicT[d]:
        f=False
        break
    elif d not in dicT:
        dicT[d]=c 

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

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

convert = dict()

answer = 'Yes'
for s, t in zip(S, T):
    if s in convert and convert[s] != t:
        answer = 'No'
        break
    else:
        convert[s] = t

after = convert.values()
if len(after) != len(set(after)):
    answer = 'No'

print(answer)

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

answer = 'Yes'
for s in sorted(map(chr,range(97,123))):
    if S.count(s) >= 2:
        l1 = [i for i, x in enumerate(S) if x == s]
        for x in l1:
            if T[x] != T[l1[0]]:
                answer = 'No'
    if T.count(s) >= 2:
        l2 = [i for i, x in enumerate(T) if x == s]
        for x in l2:
            if S[x] != S[l2[0]]:
                answer = 'No'
print(answer)

Solution (Python):
from collections import Counter
def main():
    s = sorted(Counter(input()).values())
    t = sorted(Counter(input()).values())
    print('Yes' if t == s else 'No')
if __name__ == "__main__":
    main()

Solution (Python):

flag1=True
flag2=True

for i in range(2):
    if i==0:
        a=input()
    else:
        b=input()

n=len(a)
uselist=[0]*n
for i in range(n):
        uselist[i]=(a[i],b[i])

  
sets=set(uselist)
dicti={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}
dicti2={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}

for i in sets:
        dicti[i[0]]+=1
        dicti2[i[1]]+=1
for i in dicti.values():
    if i>=2:
        flag1=False
        
        
for i in dicti2.values():
    if i>=2:
        flag2=False
        

if flag1 and flag2:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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 MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



s = S()
t = S()
s_dict = defaultdict(int)
t_dict = defaultdict(int)
for i in range(len(s)):
    if s_dict[s[i]] and s_dict[s[i]] != t[i]:
        print('No')
        break
    else:
        s_dict[s[i]] = t[i]
    if t_dict[t[i]] and t_dict[t[i]] != s[i]:
        print('No')
        break
    else:
        t_dict[t[i]] = s[i]
else:
    print('Yes')

Solution (Python):
s=input()
t=input()
n=len(s)
word="abcdefghijklmnopqrstuvwxyz"
data_s=[[] for i in range(26)]
data_t=[[] for i in range(26)]
for i in range(26):
    a=word[i]
    for j in range(n):
        if s[j]==a:
            data_s[i].append(j)
        if t[j]==a:
            data_t[i].append(j)
data_s.sort()
data_t.sort()
if data_s==data_t:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict
s = input()
t = input()
S = defaultdict(list)
T = defaultdict(list)
trans = defaultdict(int)
for i in range(len(t)):
  c = t[i]
  m = s[i]
  if T[c]==[]:
    T[c] = i
  if S[m]==[]:
    S[m] = i
  if T[c]!= S[m]:
    print('No')
    break
else:
  print('Yes')

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

    r = [[-1] * 26 for _ in range(2)]

    bl = True
    for se, te in zip(s, t):
        si = ord(se) - ord("a")
        ti = ord(te) - ord("a")

        if r[0][si] < 0:
            r[0][si] = ti
        else:
            if r[0][si] != ti:
                bl = False
                break

        if r[1][ti] < 0:
            r[1][ti] = si
        else:
            if r[1][ti] != si:
                bl = False
                break

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


if __name__ == "__main__":
    main()

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

    ind = [set() for _ in range(26)]
    outd = [set() for _ in range(26)]

    for se, te in zip(s, t):
        si = ord(se) - ord("a")
        ti = ord(te) - ord("a")
        outd[si].add(te)
        ind[ti].add(se)

    bl = True
    for e_ind, e_outd in zip(ind, outd):
        l_ind = len(e_ind)
        l_outd = len(e_outd)
        if l_ind >= 2 or l_outd >= 2:
            bl = False
            break

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


if __name__ == "__main__":
    main()

Solution (Python):


S=list(input())
T=list(input())

dict1={}
dict2={}

for i in range(len(S)):
    if S[i] in dict1:
        if dict1[S[i]]==T[i]:
            pass
        else:
            print("No")
            exit()
    else:
        dict1[S[i]]=T[i]
    
    if T[i] in dict2:
        if dict2[T[i]]==S[i]:
            pass
        else:
            print("No")
            exit()
    else:
        dict2[T[i]]=S[i]
        
print("Yes")

Solution (Python):
import collections

S=input()
T=input()

def SameGroup(word):
    CW=collections.Counter(word)
    CWval,CWcou=zip(*CW.most_common())
    Count=[]
    for i in range(len(CWval)):
        if CWcou[i]==1:
            break
        else:
            Count.append([])
            for j in range(len(word)):
                if word[j]==CWval[i]:
                    Count[-1].append(j)
    return(Count)

print('YNeos'[SameGroup(S)!=SameGroup(T)::2])

Solution (Python):
S = input()
T = input()
from collections import defaultdict
ds = defaultdict(int)
dt = defaultdict(int)
for i in range(len(S)):
    ds[S[i]] += 1
    dt[T[i]] += 1
ds = list(ds.values())
dt = list(dt.values())
ds.sort()
dt.sort()
for e1,e2 in zip(ds,dt):
    if e1 != e2:
        print('No')
        exit()
print('Yes')

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    s = collections.Counter(str(input().rstrip('\n'))).most_common()
    t = collections.Counter(str(input().rstrip('\n'))).most_common()
    if len(s) != len(t):
        print("No")
    else:
        for i in range(len(s)):
            if s[i][1] != t[i][1]:
                print("No")
                exit()
        print("Yes")


if __name__ == '__main__':
    slove()

Solution (Python):
s = input()
t = input()
import collections
import sys
c_s = collections.Counter(s)
c_t = collections.Counter(t)
l_s = c_s.most_common()
l_t = c_t.most_common()
for i in range(len(l_s)):
    if l_t[i][1] != l_s[i][1]:
        print("No")
        sys.exit()
print("Yes")

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

Solution (Python):
def count1(s):
    L = len(s)
    abc=[]
    s0 = s[0]
    abc.append(s[0])
    ans1 = ""
    ans2=""
    cnt = 1
    cnt2=0
    a0=0
    for i in range(1, L):
        if s0 == s[i]:
            cnt += 1
        else:
            ans1 = ans1 + str(cnt)
            ans2=ans2+str(a0)
            cnt = 1
            s0=s[i]
            if s[i] in abc:
                a0=abc.index(s[i])
            else:
                abc.append(s[i])
                cnt2+=1
                a0=cnt2

    ans1 = ans1 + str(cnt)
    ans2 = ans2 + str(a0)

    return ans1,ans2


S = input()
T = input()

if len(S)==1:
    print("Yes")
    exit()

Sx,Sy = count1(S)
Tx,Ty = count1(T)

if Sx == Tx and Sy==Ty:
    print("Yes")
else:
    print("No")

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

S_list=list(set(list(S)))
T_list=list(set(list(T )))
print("Yes" if sorted([S.count(i) for i in S_list])==sorted([T.count(i) for i in T_list]) else "No")

Solution (Python):

s=input()
t=input()
n=len(s)
dic={}
se=set()
ans='Yes'
for i in range(n):
    if s[i] not in dic:
        dic[s[i]]=t[i]
        if t[i] in se:
            ans='No'
        se.add(t[i])
    else:
        if dic[s[i]]!=t[i]:
            ans='No'
print(ans)

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

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

N = len(S)
Slist = {}
Tlist = {}
for i in range(N):
    if S[i] in Slist:
        Slist[S[i]] += 1
    else:
        Slist[S[i]] = 1
    if T[i] in Tlist:
        Tlist[T[i]] += 1
    else:
        Tlist[T[i]] = 1

M = len(Slist)
L = len(Tlist)
if M == L:
    skey = []
    tkey = []
    svalue = []
    tvalue = []
    for k, v in Slist.items():
        skey.append(k)
        svalue.append(v)
    skey.sort()
    svalue.sort()
    
    for k, v in Tlist.items():
        tkey.append(k)
        tvalue.append(v)
    tkey.sort()
    tvalue.sort()
    
    if svalue == tvalue:
        print('Yes')
    else:
        print('No')
        
else:
    print('No')

Solution (Python):

from collections import Counter as cs

S = input()
T = input()

cS = cs(S)
cT = cs(T)

lS = [0] * 26
lT = [0] * 26

az = "abcdefghijklmnopqrstuvwxyz"

for i in range(26):
    lS[i] = cS[az[i]]
    lT[i] = cT[az[i]]

lS.sort()
lT.sort()

if lS==lT:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
T = input()
cnt = 0
for i in range(len(S)):
  if cnt > 30:
    break
  if S[i] != T[i]:
    X = S[i]
    S = S.replace(S[i],"X")
    if T[i] in S:
      S = S.replace(T[i],X)
    S = S.replace("X",T[i])
    cnt += 1
print("Yes" if S == T else "No")

Solution (Python):
from collections import defaultdict
class CountUp:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

S = input()
T = input()
N = len(S)
Sdic = defaultdict(CountUp())
Tdic = defaultdict(CountUp())
for i in range(N):
    s = Sdic[S[i]]
    t = Tdic[T[i]]
    if s != t:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
s=list(input())
t=list(input())
u=list(int(-1) for i in range(26))
ans=[]

for i in range(len(s)):
    if u[ord(s[i])-97]==-1:
        u[ord(s[i])-97]=ord(t[i])-97
        
    else:
        if u[ord(s[i])-97]!=ord(t[i])-97:
            print('No')
            exit()
  
for i in range(len(u)):
    if u[i]!=-1:
        ans.append(u[i])

if len(set(ans))<len(ans):      
    print('No')
else:
    print('Yes')

Solution (Python):
from collections import Counter as ct

s = input()
t = input()

c_s = ct(s)
c_t = ct(t)

n_s = []
n_t = []

for w in set(s):
    n_s.append(c_s[w])

for w in set(t):
    n_t.append(c_t[w])

b = sorted(n_s) == sorted(n_t)

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

Solution (Python):
s = input()
t = input()
s_list = [-1]*26  
t_list = [-1]*26  

ans = "Yes"
for i in range(len(s)):
    s_num = ord(s[i]) - 97
    t_num = ord(t[i]) - 97
    if s_list[s_num] < 0:
        s_list[s_num] = t_num
    else:
        if s_list[s_num] != t_num:
            ans = "No"
            break
    if t_list[t_num] < 0:
        t_list[t_num] = s_num
    else:
        if t_list[t_num] != s_num:
            ans = "No"
            break
print(ans)

Solution (Python):
s, t = input(), input()
ans = "Yes"
dct = {i:set() for i in t}
for i in range(len(s)): dct[t[i]].add(s[i])
for i in dct.items():
    if len(i[1])>1:ans="No"
dct = {i:set() for i in s}
for i in range(len(s)): dct[s[i]].add(t[i])
for i in dct.items():
    if len(i[1])>1:ans="No"
print(ans)

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

a={}
b={}

for i in range(len(S)):
  if S[i] in a:
    a[S[i]].append(i)
  else:
    a[S[i]]=[i]
  if T[i] in b:
    b[T[i]].append(i)
  else:
    b[T[i]]=[i]

if sorted(a.values())==sorted(b.values()):
  print("Yes")
else:
  print("No")

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

s_set = list(set(s))
t_set = list(set(t))

s_count = [0] * len(s_set)
t_count = [0] * len(t_set)

for i in range(0,len(s_set)) :
    s_count[i] = s.count(s_set[i])

for j in range(0,len(t_set)) :
    t_count[j] = t.count(t_set[j])

s_count.sort()
t_count.sort()

if s_count == t_count :
    print('Yes')
else :
    print('No')

Solution (Python):
s=list(input())
t=list(input())
sal=[]
ska=[]
tal=[]
tka=[]
n=len(s)
for i in range(n):
    if s[i] in sal:
        ska[sal.index(s[i])].append(i)
    else:
        sal.append(s[i])
        ska.append([i])
    if t[i] in tal:
        tka[tal.index(t[i])].append(i)
    else:
        tal.append(t[i])
        tka.append([i])
ska.sort()
tka.sort()
if ska==tka:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections, re, itertools, copy

S = input()
T = input()


def same_letter_index_set(A, cA):
    output = []
    for s in cA.keys():
        match_index_list = [m.span() for m in re.finditer(s, A)]
        output.append(list(itertools.chain.from_iterable([m.span() for m in re.finditer(s, A)])))
    return output


def same_multi_list(A_input,B_input):
    A = copy.deepcopy(A_input)
    B = copy.deepcopy(B_input)
    for i in A:
        try:
            B.remove(i)
        except:
            return False
    if len(B) == 0:
        return True
    else:
        return False


cS = collections.Counter(S)
cT = collections.Counter(T)
print("Yes" if same_multi_list(same_letter_index_set(S, cS), same_letter_index_set(T, cT)) else "No")

Solution (Python):
import collections, re, itertools, copy

S = input()
T = input()


def same_letter_index_set(A, cA):
    output = []
    for s in cA.keys():
        match_index_list = [m.span() for m in re.finditer(s, A)]
        output.append(list(itertools.chain.from_iterable([m.span() for m in re.finditer(s, A)])))
    return output


def same_multi_list(A_input,B_input):
    A = copy.deepcopy(A_input)
    B = copy.deepcopy(B_input)
    for i in A:
        try:
            B.remove(i)
        except:
            return False
    if len(B) == 0:
        return True
    else:
        return False


cS = collections.Counter(S)
cT = collections.Counter(T)
print("Yes" if same_multi_list(same_letter_index_set(S, cS), same_letter_index_set(T, cT)) else "No")

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

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

Solution (Python):
import collections
s=sorted(collections.Counter(input()).values())
t=sorted(collections.Counter(input()).values())
print("Yes" if s==t else "No")

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

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y
    else:
        if dict_st[x] != y:
            print("No")
            break

    if y not in dict_ts:
        dict_ts[y] = x
    else:
        if dict_ts[y] != x:
            print("No")
            break
else:
    print("Yes")

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

dic={}
ans='Yes'
for i in range(n):
    if t[i] not in dic:
        dic[t[i]]=s[i]
    
    else:
        if dic[t[i]]==s[i]:
            continue
        else :
            ans='No'
            break
    
if len(dic)!=len(set(dic.values())):
    ans='No'
print(ans)

Solution (Python):

import sys 
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
 
s = ns()
t = ns()

s_cnt = []
t_cnt = []

for alp in "abcdefghijklmnopqrstuvwxyz":
  s_cnt.append(s.count(alp))
  t_cnt.append(t.count(alp))

s_cnt.sort()
t_cnt.sort()

if s_cnt == t_cnt:
  print("Yes")
else:
  print("No")

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

dict_S_to_T = {}
dict_T_to_S = {}

for s, t in zip(S, T):
    if s not in dict_S_to_T.keys():
        dict_S_to_T[s] = t
    else:
        if dict_S_to_T[s] != t:
            print('No')
            exit()
    if t not in dict_T_to_S.keys():
        dict_T_to_S[t] = s
    else:
        if dict_T_to_S[t] != s:
            print('No')
            exit()

print('Yes')

Solution (Python):
from collections import Counter

S = str(input())
T = str(input())

s_counter = Counter(S)
t_counter = Counter(T)




dict_S_to_T = {}
dict_T_to_S = {}

for s, t in zip(S, T):
    if s not in dict_S_to_T.keys():
        dict_S_to_T[s] = t
    else:
        if dict_S_to_T[s] != t:
            print('No')
            exit()
    if t not in dict_T_to_S.keys():
        dict_T_to_S[t] = s
    else:
        if dict_T_to_S[t] != s:
            print('No')
            exit()

print('Yes')

Solution (Python):
import collections
S=input()
T=input()
tableS=collections.defaultdict(list)
tableT=collections.defaultdict(list)

for i in range(len(S)):
  tableS[S[i]].append(i)
  tableT[T[i]].append(i)
listS=tableS.values()
listT=tableT.values()

for x in listS:
  flag=False
  for y in listT:
    if x in y or x in listT:
      flag=True
      break
  if not flag:
    print("No")
    exit(0)
print("Yes")

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

dic = {}
for i in range(len(S)):
  s = S[i]
  t = T[i]
  if s in dic.keys():
    if dic[s] != t:
      print('No')
      exit()
  else:
    if t in dic.values():
      print('No')
      exit()
    else:
      dic[s] = t
print('Yes')

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

s_count = []
t_count = []
for i in "abcdefghijklmnopqrstuvwxyz":
    s_count.append(s.count(i))
    t_count.append(t.count(i))
print("Yes" if sorted(s_count) == sorted(t_count) else "No")

Solution (Python):
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce



def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList



def getInputStr():
    inputNum = str(input())
    return inputNum

s = getInputStr()
t = getInputStr()


listS = []
listS = list(s)
listT = []
listT = list(t)

lim = len(listS)

onedic = {}
twodic = {}

flg = True

for i in range(lim):
    keyone = listS[i]
    keytwo = listT[i]

    if keyone not in onedic:
        onedic[keyone] = keytwo
    else:
        if onedic[keyone] != keytwo:
            flg = False
            break

    if keytwo not in twodic:
        twodic[keytwo] = keyone
    else:
        if twodic[keytwo] != keyone:
            flg = False
            break

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

Solution (Python):
S = input()
T = input()
N = len(S)
C_S = dict()
C_T = dict()
count_s = 0
count_t = 0
s_list = []
t_list = []
for i in range(N):
    if S[i] in C_S:
        C_S[S[i]] += 1
    else:
        C_S[S[i]] = 1
        count_s += 1
for i in range(N):
    if T[i] in C_T:
        C_T[T[i]] += 1
    else:
        C_T[T[i]] = 1
        count_t += 1
check = True
for skey in C_S.keys():
    s_list.append(C_S[skey])
for tkey in C_T.keys():
    t_list.append(C_T[tkey])
s_list.sort()
t_list.sort()

if count_s == count_t:
    for i in range(len(s_list)):
        if s_list[i] != t_list[i]:
            check = False
else:
    check = False

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

Solution (Python):
import os, sys, re, math

S = input()
T = input()

table = {}
flg = True
for i in range(len(S)):
	if S[i] in table.keys():
		if T[i] != table[S[i]]:
			flg = False
	else:
		if T[i] in table.values():
			flg = False
		else:
			table[S[i]] = T[i]
	if not flg:
		break

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

Solution (Python):
s = input()
t = input()
num_s ={}
num_t ={}
for i in range(len(s)):
    si = s[i]
    ti = t[i]
    if si in num_s:
        num_s[si] +=1
    else:
        num_s[si] =1
    if ti in num_t:
        num_t[ti] +=1
    else:
        num_t[ti] =1

values_s = list(num_s.values())
values_t = list(num_t.values())
values_s.sort()
values_t.sort()
if values_s==values_t:
    print('Yes')
else:
    print('No')

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

dic={}
for i in range(len(s)):
    if s[i] not in dic:
        dic.setdefault(s[i],t[i])
    else:
        if t[i]!=dic[s[i]]:
            print("No")
            exit()

dic={}
for i in range(len(t)):
    if t[i] not in dic:
        dic.setdefault(t[i],s[i])
    else:
        if s[i]!=dic[t[i]]:
            print("No")
            exit()
            
print("Yes")

Solution (Python):
from collections import Counter

S = Counter(list(input()))
T = Counter(list(input()))

flag = False
for s, t in zip(S.most_common(), T.most_common()):
    if s[1] != t[1]:
        flag = True
print('No' if flag else 'Yes')

Solution (Python):
S = raw_input()
T = raw_input()
d = dict()
d2 = dict()
ret = True
for s, t in zip(S, T):
    if s in d and d[s] != t:
        ret = False
        break
    if t in d2 and d2[t] != s:
        ret = False
        break
    d[s] = t
    d2[t] = s
        
print 'Yes' if ret else 'No'

Solution (Python):
aaa = input()
bbb = input()
d = {}
d_rev = {}
ans = 'Yes'
for a, b in zip(aaa, bbb):
  if (a in d and d.get(a) != b) or (b in d_rev and d_rev.get(b) != a):
    ans = 'No'
  d[a] = b
  d_rev[b] = a
print(ans)

Solution (Python):
import os, sys, re, math

S = input()
T = input()

sCount = [0] * 26
tCount = [0] * 26

for s in S:
    sCount[ord(s) - ord('a')] += 1
for t in T:
    tCount[ord(t) - ord('a')] += 1

sCount.sort()
tCount.sort()

print ('Yes' if sCount == tCount else 'No')

Solution (Python):
s = input()
t = input()
print("Yes" if len(set(s)) == len(set(t)) == len(set(zip(s, t))) else "No")

Solution (Python):
s = input()
t = input()
dct = dict()
 
bool =True
for a,b in zip(s,t):
    if a in dct and dct[a]!=b:
        bool =False
        break
    dct[a]=b



if len(dct.values())!=len(set(dct.values())):
    bool =False
print('Yes' if bool else 'No')

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

bool =True
for a,b in zip(s,t):
    if a in dct and dct[a]!=b:
        bool =False
        break
    dct[a]=b



a =dct.values()
if len(a)!=len(set(a)):
    bool =False
print('Yes' if bool else 'No')

Solution (Python):
S,T = input(),input()
 
convert = dict()
 
bl = True
for s,t in zip(S,T):
  if s in convert and convert[s] != t:
    bl = False
    break
  convert[s] = t
 

after = convert.values()
if len(after) != len(set(after)):
  bl = False
 
print('Yes' if bl else 'No')

Solution (Python):
def test():
    s = input()
    t = input()
    dict1,dict2 = {},{}
    for i,j in zip(s,t):
        if i in dict1:
            if dict1[i] != j:
                print("No")
                return
        else:
            dict1[i] = j
        if j in dict2:
            if dict2[j] != i:
                print("No")
                return
        else:
            dict2[j] = i
    print("Yes")


if __name__ == "__main__":
    test()

Solution (Python):

import collections
S = str(input())
T = str(input())

S1 = sorted(collections.Counter(S).values())
T1 = sorted(collections.Counter(T).values())

if S1 == T1:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter

s = input()
t = input()

S = sorted(Counter(s).values())
T = sorted(Counter(t).values())

if S==T:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys 
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()

s = ns()
t = ns()
s_cnt = []
t_cnt = []
for alp in "abcdefghijklmnopqrstuvwxyz":
  s_cnt.append(s.count(alp))
  t_cnt.append(t.count(alp))
s_cnt.sort()
t_cnt.sort()
if s_cnt == t_cnt:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import Counter as cnt
fnc = lambda: cnt(cnt(input()).values())
print("Yes" if fnc() == fnc() else "No")

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from collections import Counter
    s=Counter(input()).most_common()
    t=Counter(input()).most_common()
    n=len(s)
    print("Yes" if all(s[i][1]==t[i][1] for i in range(n)) else "No")
resolve()

Solution (Python):
S=input()
T=input()
N=len(S)
def char2num(a):
  temp='abcdefghijklmnopqrstuvwxyz'
  i=0
  while temp[i]!=a:
    i+=1
  return i

s2t=[-1]*26
t2s=[-1]*26
for i in range(N):
  snum=char2num(S[i])
  tnum=char2num(T[i])
  if s2t[snum]>=0 or t2s[tnum]>=0:
    if s2t[snum]!=tnum or t2s[tnum]!=snum:
      print('No')
      exit()
  else:
    s2t[snum]=tnum
    t2s[tnum]=snum
    
print('Yes')

Solution (Python):
from  collections import Counter

S = input()
T = input()

s_counter = Counter(S)
t_counter = Counter(T)

if sorted(s_counter.values()) == sorted(t_counter.values()):
    print('Yes')
else:
    print('No')

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

sd = dict()
td = dict()
ans = True
for s, t in zip(S, T):
    if s not in sd:
        sd[s] = t
    else:
        if sd[s] != t:
            ans = False
            break

    if t not in td:
        td[t] = s
    else:
        if td[t] != s:
            ans = False
            break

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