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):
from collections import Counter
s=Counter(input()).most_common()
t=Counter(input()).most_common()
ans="Yes"
for i in range(min(len(s),len(t))):
  if s[i][1]!=t[i][1]:
    ans="No"
print(ans)

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

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

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter

from fractions  import gcd

import bisect
s=input()
t=input()
n=len(s)
x={}
y={}
for i in range(n):
    if s[i] not in x:
        x[s[i]]=set([i])
    else:
        x[s[i]].add(i)
    if t[i] not in y:
        y[t[i]]=set([i])
    else:
        y[t[i]].add(i)
a=set()
b=set()
for i in x.values():
  if i not in y.values():
    print("No")
    break
else:
  print("Yes")

Solution (Python):

from collections import defaultdict
import sys

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


S_conversion =defaultdict(str)
T_conversion =defaultdict(str)
ans ="Yes"
if S ==T:
    ans ="Yes"
else:
    for i in range(len(S)):
        if S_conversion[S[i]] =="" and T_conversion[T[i]] =="":
            S_conversion[S[i]] =T[i] 
            T_conversion[T[i]] =S[i]
        elif S_conversion[S[i]] ==T[i]:
            continue
        elif T_conversion[T[i]] ==S[i]:
            continue
        else:
            ans ="No"
            
            break
print(ans)

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi



import string

from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    
    s = input()
    t = input()
    n = len(s)
    d = defaultdict(set)
    for i in range(n-1):
        if t[i] != t[i+1] and s[i] == s[i+1]:
            print("No")
            return
        d[t[i]].add(s[i])
    d[t[-1]].add(s[-1])

    for c in d:
        if len(d[c]) > 1:
            print("No")
            return
            
    print("Yes")
        

t = 1

for case in range(1,t+1):
    ans = solve()


"""
a b a
d c d
a b a
"""

Solution (Python):
from string import ascii_lowercase
import sys
input=sys.stdin.readline
s=input().rstrip()
t=input().rstrip()
for alp in ascii_lowercase:
    switch=0
    for i in range(len(s)):
        if switch==0:
            if s[i]==alp:
                rem=t[i]
                switch=1
        else:
            if s[i]==alp:
                if t[i]!=rem:
                    print("No")
                    exit()
for alp in ascii_lowercase:
    switch=0
    for i in range(len(s)):
        if switch==0:
            if t[i]==alp:
                rem=s[i]
                switch=1
        else:
            if t[i]==alp:
                if s[i]!=rem:
                    print("No")
                    exit()
print("Yes")

Solution (Python):
ss,tt = open(0).read().split()

from collections import defaultdict

d = defaultdict(str)
e = defaultdict(str)
ans = 'Yes'
for s,t in zip(ss,tt):
    if not d[s]:
        d[s] = t
    elif d[s] != t:
        ans = 'No'
        break
    if not e[t]:
        e[t] = s
    elif e[t] != s:
        ans = 'No'
        break

print(ans)

Solution (Python):
from collections import defaultdict

S = input()
T = input()

s_dic = defaultdict(list)
t_dic = defaultdict(list)


for i, ch in enumerate(S):
    s_dic[ch].append(i)

for i, ch in enumerate(T):
    t_dic[ch].append(i)

lis_s = list(s_dic.values())
lis_t = list(t_dic.values())

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

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



S = input()
T = input()

x = defaultdict(list)
y = defaultdict(list)

for i, t in enumerate(T):
    x[t].append(S[i])

for i, s in enumerate(S):
    y[s].append(T[i])

ok = True
for k, v in x.items():
    a = v[0]
    for c in v:
        if c != a:
            ok = False
            break

for k, v in y.items():
    a = v[0]
    for c in v:
        if c != a:
            ok = False
            break

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

Solution (Python):
S1 = input()
S2 = input()

ss1 = {}
ss2 = {}
N = len(S1)
for i in range(N):
    if S1[i] not in ss1.keys():
        ss1[S1[i]] = S2[i]
    elif ss1[S1[i]] != S2[i]:
        print('No')
        exit(0)
    if S2[i] not in ss2.keys():
        ss2[S2[i]] = S1[i]
    elif ss2[S2[i]] != S1[i]:
        print('No')
        exit(0)

print('Yes')

Solution (Python):

"""
@author: H_Hoshigi
"""
def check_two_str(A, B):
    AtoB_dict = {}
    answer = True
    for i in range(len(A)):
        try:
            AtoB_dict[A[i]]
        except KeyError:
            AtoB_dict[A[i]] = B[i]
        else:
            if AtoB_dict[A[i]] != B[i]:
                answer = False
                break
    return answer

def main():
    S = input()
    T = input()
    if check_two_str(S, T) and check_two_str(T, S):
        print("Yes")
    else:
        print("No")
    return

if __name__ == "__main__":
    main()

Solution (Python):
import sys
S = input()
T = input()
tmp1 = [set() for i in range(26)]
tmp2 = [set() for i in range(26)]
alpha2num = lambda c: ord(c) - ord('a')
for i in range(len(S)):
    tmp1[alpha2num(S[i])].add(T[i])
    tmp2[alpha2num(T[i])].add(S[i])
for i in range(26):
    if len(tmp1[i]) > 1 or len(tmp2[i]) > 1:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):








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

from collections import defaultdict
s_dic = defaultdict(set)
t_dic = defaultdict(set)
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if len(s_dic[s]) > 0 and t not in s_dic[s]:
        print('No')
        exit()
    if len(t_dic[t]) > 0 and s not in t_dic[t]:
        print('No')
        exit()
    s_dic[s].add(t)
    t_dic[t].add(s)

print('Yes')

Solution (Python):
from collections import defaultdict
 
S = list(input())
T = list(input())
ds = defaultdict(int)
dt = defaultdict(int)
cnt_s = []
cnt_t = []
for s, t in zip(S, T):
    ds[s] += 1
    dt[t] += 1
    cnt_s.append(ds[s])
    cnt_t.append(dt[t])
print('Yes' if cnt_s == cnt_t else "No")

Solution (Python):
from collections import Counter
s = input()
t = input()
csm = Counter(s).most_common()
ctm = Counter(t).most_common()
if len(csm)!=len(ctm):
    print('No')
else:
    for i in range(len(csm)):
        if csm[i][1]!=ctm[i][1]:
            print('No')
            break
        if i==len(csm)-1:
            print('Yes')

Solution (Python):
def get_char_set(word):
    char_index = {}
    for i, c in enumerate(word):
        if c not in char_index.keys():
            char_index[c] = []
        char_index[c].append(i)
    char_set = set()
    for char_index_list in char_index.values():
        char_set.add(tuple(char_index_list))
    return char_set

s = input()
t = input()

s_char_set = get_char_set(s)
t_char_set = get_char_set(t)
if s_char_set == t_char_set:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict

S = list(input())
T = list(input())
ds = defaultdict(int)
dt = defaultdict(int)
cnt_s = []
cnt_t = []
for s, t in zip(S, T):
    ds[s] += 1
    dt[t] += 1
    cnt_s.append(ds[s])
    cnt_t.append(dt[t])
print('Yes' if cnt_s == cnt_t else "No")

Solution (Python):
from collections import Counter

sc=Counter(input())
tc=Counter(input())

for s,t in zip(sorted(sc.values()),sorted(tc.values())):
    if s!=t:
      print("No")
      break
else:
    print("Yes")

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

sc=Counter(s)
tc=Counter(t)
if len(sc)!=len(tc):
  print("No")
else:
  for s1,t1 in zip(sorted(sc.items(),key=lambda i: i[1]),sorted(tc.items(),key=lambda i: i[1])):
    if s1[1]!=t1[1]:
      print("No")
      break
  else:
    print("Yes")

Solution (Python):
from string import ascii_lowercase
s = input()
t = input()

begin = {c:None for c in ascii_lowercase}
end = {c:None for c in ascii_lowercase}

for idx in range(len(s)):
    sc = s[idx]
    tc = t[idx]
    if begin[sc] is not None and begin[sc] != tc:
        print('No')
        exit()
    if end[tc] is not None and end[tc] != sc:
        print('No')
        exit()
    begin[sc] = tc
    end[tc] = sc

print('Yes')

Solution (Python):
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
t = input()
a = [0]*26
b = [0]*26

for i in range(len(s)):
    x = ord(s[i])-ord('a')
    y = ord(t[i])-ord('a')
    a[x] += 1
    b[y] += 1

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

Solution (Python):
S = input()
T = input()
stot = dict()
ttos = dict()
for s, t in zip(S, T):
    stot.setdefault(s, set())
    stot[s].add(t)
    ttos.setdefault(t, set())
    ttos[t].add(s)

ans = 'Yes'
for k, l in stot.items():
    if len(l) > 1:
        ans = 'No'
        break

for k, l in ttos.items():
    if len(l) > 1:
        ans = 'No'
        break
print(ans)

Solution (Python):
S = input()
T = input()
stot = dict()
sset = set()
tset = set()
for s, t in zip(S, T):
    if s in sset:
        dt = stot[s]
        if t != dt:
            print('No')
            break
    else:
        if not t in tset:
            stot[s] = t
            sset.add(s)
            tset.add(t)
        else:
            print('No')
            break
else:
    print('Yes')

Solution (Python):
S = input()
T = input()
length = len(S)
flg = 1
dic = {}
for i in range(length):
    data = S[i]
    if S[i] not in dic:  dic[S[i]] = T[i]
    else:
        if dic[S[i]] != T[i]:  flg = 0

dic = {}
for i in range(length):
    data = T[i]
    if T[i] not in dic:  
        dic[T[i]] = S[i]
    else:
        if dic[T[i]] != S[i]:  flg = 0
                
if flg:  print("Yes")
else:  print("No")

Solution (Python):
from collections import Counter

s = input()
t = input()

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

Solution (Python):


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

dict_ = {}
for i in range(len(s)):
    if s[i] in dict_:
        dict_[s[i]].append(i)
    else:
        dict_[s[i]] = [i]
for key, value in dict_.items():
    a = set([])
    for i in value:
        a.add(t[i])
    
    if len(set(a)) != 1:
        print("No")
        exit()

s, t = t, s
dict_ = {}
for i in range(len(s)):
    if s[i] in dict_:
        dict_[s[i]].append(i)
    else:
        dict_[s[i]] = [i]
for key, value in dict_.items():
    a = set([])
    for i in value:
        a.add(t[i])
    
    if len(set(a)) != 1:
        print("No")
        exit()
print("Yes")

Solution (Python):
s,t = raw_input(), raw_input()
def f(s,t):
	cc = {}
	cr = {}
	for u,v in zip(s,t):
		if u in cc:
			if cc[u] != v: return False
		if v in cr:
			if cr[v] != u: return False
		
		cc[u] = v
		cr[v] = u
	return True
print 'Yes' if f(s,t) else 'No'

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

s_t = {}
s = set()
t = set()
for i in range(len(S)):
    if S[i] not in s:
        if T[i] not in t:
            s.add(S[i])
            t.add(T[i])
            s_t[S[i]] = T[i]
        else:
            print("No")
            exit()
    else:
        if s_t[S[i]] != T[i]:
            print("No")
            exit()

print("Yes")

Solution (Python):
S = list(input())
T = list(input())
N = len(S)
dicS={}
dicT={}
for i in range(97,123,1):
    dicS[chr(i)] = []
    dicT[chr(i)] = []

for i in range(0,N,1):
    dicS[S[i]].append(i)
    dicT[T[i]].append(i)

for a2z in dicS:
    if len(dicS[a2z])>0:
        tmp = T[dicS[a2z][0]]
        for i in range(0,len(dicS[a2z]),1):
            if T[dicS[a2z][i]]!=tmp:
                print("No")
                exit()
    if len(dicT[a2z])>0:
        tmp = S[dicT[a2z][0]]
        for i in range(0,len(dicT[a2z]),1):
            if tmp != S[dicT[a2z][i]]:
                print("No")
                exit()

print("Yes")

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

exchange = [-1] * 26
alpha2num = lambda c: ord(c) - ord('a')


for i in range(len(S)):
    now_num = alpha2num(S[i])
    
    if exchange[now_num] == -1:
      exchange[now_num] = alpha2num(T[i])
    elif exchange[now_num] == alpha2num(T[i]):
      
      continue
    else:
      print("No")
      quit()
  
  
exchange = sorted(exchange)
for i in range(1, 26):
  if exchange[i] == exchange[i - 1]:
    if exchange[i] != -1:
      print("No")
      quit()
  
print("Yes")

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

from collections import Counter
Counter_S=Counter(S)
Counter_T=Counter(T)
S_num=list(Counter_S.values())
T_num=list(Counter_T.values())

S_num.sort()
T_num.sort()

if S_num==T_num:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict

s = input()
t = input()

in_deg = defaultdict(set)
out_deg = defaultdict(set)

for es, et in zip(s, t):
    out_deg[es].add(et)
    in_deg[et].add(es)

in_deg_mx = max(map(len, in_deg.values()))
out_deg_mx = max(map(len, out_deg.values()))

if in_deg_mx <= 1 and out_deg_mx <= 1:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Solution (Python):
s=input()
t=input()
n=len(s)
d={}
for i in range(n):
    ss=s[i]
    tt=t[i]
    if ss in d and (ss,tt) not in d.items():
        print("No")
        exit()
    if tt in d.values() and (ss,tt) not in d.items():
        print("No")
        exit()
    if ss not in d:
        d[ss]=tt    
print("Yes")

Solution (Python):
import sys
import collections
input = sys.stdin.readline

s = input().rstrip()
t = input().rstrip()

scl = sorted(list(collections.Counter(s).values()))
tcl = sorted(list(collections.Counter(t).values()))

if scl == tcl:
    print('Yes')

else:
    print('No')

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

a = ord('a')
alf = []
for i in range(26):
     alf.append(chr(a))
     a += 1

SN = [[] for i in range(26)]
TN = [[] for i in range(26)]
for i in range(N):
    for j in range(26):
        if alf[j] == S[i]:
            SN[j].append(i)
        if alf[j] == T[i]:
            TN[j].append(i)
SN.sort()
TN.sort()
print('Yes' if SN == TN else 'No')

Solution (Python):
from collections import Counter

s = input().rstrip()
t = input().rstrip()

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

Solution (Python):
from collections import*
s,t=Counter(input()),Counter(input())
print("YNeos"[sorted(s.values())!=sorted(t.values())::2])

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

l = len(S)
S_lst = [None] * l
T_lst = [None] * l
S_dic = {}
T_dic = {}

s_cnt = 0
for i, s in enumerate(S):
    if s in S_dic:
        n = S_dic[s]
        S_lst[i] = n
    else:
        S_lst[i] = s_cnt
        S_dic[s] = s_cnt
        s_cnt += 1


t_cnt = 0
for i, t in enumerate(T):
    if t in T_dic:
        n = T_dic[t]
        T_lst[i] = n
    else:
        T_lst[i] = t_cnt
        T_dic[t] = t_cnt
        t_cnt += 1


if s_cnt != t_cnt:
    print('No')
    exit()

for i in range(l):
    if S_lst[i] != T_lst[i]:
        print('No')
        exit()

print('Yes')

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

d = {}

for i in range(len(S)):
    
    if S[i] not in d:
        if T[i] in d.values():
            print('No')
            break
        else:
            d[S[i]] = T[i]
    else:
        if d[S[i]] != T[i]:
            print('No')
            break
    
else:
    print('Yes')

Solution (Python):

def solve():
    l = len(S)
    R  = [-1]*26
    R1 = [-1]*26
    is_ok = True
    for i in range(l):
        S_num = ord(S[i]) - ord("a")
        T_num = ord(T[i]) - ord("a")
        if R[S_num] == -1:
            R[S_num] = T_num
        else:
            if R[S_num] != T_num:
                is_ok = False
                break
        if R1[T_num] == -1:
            R1[T_num] = S_num
        else:
            if R1[T_num] != S_num:
                is_ok = False
                break
        
    if is_ok:
        print("Yes")
    else:
        print("No")


if __name__=="__main__":
    S = input()
    T = input()


    solve()

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

d = {}
ans = True
for i, v in enumerate(s):
    if v not in d:
        if t[i] in d.values():
            ans = False
            break
        else:
            d[v] = t[i]
    else:
        if d[v] != t[i]:
            ans = False
            break
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()
    T = SS()

    l = len(S)
    R0 = [-1] * 26
    R1 = [-1] * 26

    is_ok = True
    for i in range(l):
        S_num = ord(S[i]) - ord('a')
        T_num = ord(T[i]) - ord('a')
        
        if R0[S_num] == -1:
            R0[S_num] = T_num
        else:
            if R0[S_num] != T_num:
                is_ok = False 
                break
        if R1[T_num] == -1:
            R1[T_num] = S_num
        else:
            if R1[T_num] != S_num:
                is_ok = False 
                break

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

if __name__ == '__main__':
    resolve()

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()
    T = SS()

    l = len(S)

    S_i = [[] for _ in range(26)]
    T_i = [[] for _ in range(26)]
    for i in range(l):
        S_i[ord(S[i]) - ord('a')].append(i)
        T_i[ord(T[i]) - ord('a')].append(i)

    S_set = set()
    T_set = set()
    for i in range(26):
        if S_i[i]: S_set.add(tuple(S_i[i]))
        if T_i[i]: T_set.add(tuple(T_i[i]))

    if S_set == T_set:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Solution (Python):
s = input()
t = input()
l = len(s)
cs = [0]*26
ct = [0]*26
for i in range(l):
    cs[ord(s[i])-ord('a')] += 1
    ct[ord(t[i])-ord('a')] += 1
cs.sort()
ct.sort()
if cs==ct:
    print('Yes')
else:
    print('No')

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

alp='abcdefghijklmnopqrstuvwxyz'
d={}
for i in range(len(alp)):
    d[alp[i]]=i

t_arr=[[] for _ in range(26)]
s_arr=[[] for _ in range(26)]

for j in range(len(s)):
    a=s[j]
    b=t[j]
    if a in t_arr[d[b]]:
        continue
    else:
        t_arr[d[b]].append(a)

for j in range(len(s)):
    a=s[j]
    b=t[j]
    if b in s_arr[d[a]]:
        continue
    else:
        s_arr[d[a]].append(b)


ans='Yes'
for k in range(26):
    if len(t_arr[k])>=2:
        ans='No'
        break
    if len(s_arr[k])>=2:
        ans='No'
        break

print(ans)

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
ans=0
S=input()
T=input()
for i in range(len(S)):
 if d[S[i]]==0 or d[S[i]]==T[i]:
  d[S[i]]=T[i]
 else:
  ans+=1
  break
d = defaultdict(int)
for i in range(len(S)):
 if d[T[i]]==0 or d[T[i]]==S[i]:
  d[T[i]]=S[i]
 else:
  ans+=1
  break
if ans>0:
 print("No")
else:
 print("Yes")

Solution (Python):
from sys import exit

s = input()
t = input()

l = len(s)
d_s = dict()
d_t = dict()
for i in range(l):
    if s[i] in d_s:
        if d_s[s[i]] != t[i]:
            print('No')
            exit()
    else:
        d_s[s[i]] = t[i]
    
    if t[i] in d_t:
        if d_t[t[i]] != s[i]:
            print('No')
            exit()
    else:
        d_t[t[i]] = s[i]

print('Yes')

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

from collections import Counter

S_sorted = sorted(Counter(S).values(), reverse = True)
T_sorted = sorted(Counter(T).values(), reverse = True)

if S_sorted == T_sorted:
    print("Yes")
else:
    print("No")

Solution (Python):
d,d_=dict(),dict()
s,t=input(),input()
l=len(s)
for i in range(l):
    if s[i] not in d:
        d[s[i]]=[i]
    else:
        d[s[i]].append(i)
for i in range(l):
    if t[i] not in d_:
        d_[t[i]]=[i]
    else:
        d_[t[i]].append(i)
x=[sorted(i[1]) for i in list(d.items())]
y=[sorted(i[1]) for i in list(d_.items())]
x.sort()
y.sort()
print("Yes" if x==y else "No")

Solution (Python):
dic = {}
dic1 = {}
s=input()
t=input()
ans = "Yes"
for i in range(len(s)):
  try:
    if dic[s[i]]!=t[i]:
      ans = "No"
  except:
    dic[s[i]] = t[i]
  try:
    if dic1[t[i]]!=s[i]:
      ans = "No"
  except:
    dic1[t[i]] = s[i]
print(ans)

Solution (Python):


from collections import defaultdict

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    S = input()
    T = input()

    s1 = {}
    t1 = {}

    for i, (s, t) in enumerate(zip(S, T)):
        if s in s1 and t in t1:
            if s1[s] != t1[t]:
                print('No')
                return
        elif s not in s1 and t not in t1:
            s1[s] = i
            t1[t] = i
        else:
            print('No')
            return
    
    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
def solve():
    s = input()
    t = input()
    s_cnt = Counter(s)
    t_cnt = Counter(t)
    if all(sv == tv for sv, tv in zip(sorted(s_cnt.values()), sorted(t_cnt.values()))):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Solution (Python):
s = input()
t = input()
S = sorted(map(s.count,set(s)))
T = sorted(map(t.count,set(t)))
print("Yes" if S == T else "No")

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

dic1 = {}
dic2 = {}

for i in range(len(T)):
    tmp1 = T[i]
    tmp2 = S[i]
    if tmp1 not in dic1:
        dic1[tmp1] = tmp2
    else:
        if dic1[tmp1] != tmp2:
            print('No')
            exit()

    if tmp2 not in dic2:
        dic2[tmp2] = tmp1
    else:
        if dic2[tmp2] != tmp1:
            print('No')
            exit()

print('Yes')

Solution (Python):
s=input()
t=input()
S=sorted(map(s.count,set(s)))
T=sorted(map(t.count,set(t)))
print("Yes" if S==T else "No")

Solution (Python):
S = input()
T = input()
s = {d:[] for d in set(S)}
t = {d:[] for d in set(T)}

for i, (j,k) in enumerate(zip(S,T)):
    s[j] += [i]
    t[k] += [i]
a = sorted(s.values())
b = sorted(t.values())

print('Yes' if a==b else "No")

Solution (Python):
S = input()
T = input()
n = len(S)
chars1 = []
chars2 = []
pos1 = {}
pos2 = {}
for i in range(n):
    c1 = S[i]
    c2 = T[i]
    if c1 in pos1:
        chars1[pos1[c1]].append(i)
    else:
        pos1[c1] = len(chars1)
        chars1.append([i])

    if c2 in pos2:
        chars2[pos2[c2]].append(i)
    else:
        pos2[c2] = len(chars2)
        chars2.append([i])
print('Yes' if chars1 == chars2 else 'No')

Solution (Python):
import collections

S = input()
T = input()

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

if s == t:
    print('Yes')
else:
    print('No')

Solution (Python):

"""
Created on Tue Jun 23 13:06:09 2020

@author: NEC-PCuser
"""
import string

S = input()
T = input()

dic = dict.fromkeys(string.ascii_lowercase, 0)
dic2 = dict.fromkeys(string.ascii_lowercase, 0)

for i in range(len(S)):
    dic[S[i]] += 1
    dic2[T[i]] += 1

li = []
li2 = []
for v in dic.values():
    li.append(v)
for v in dic2.values():
    li2.append(v)
li.sort()
li2.sort()

for i in range(len(li)):
    if li[i] != li2[i]:
        print("No")
        break
else:
    print("Yes")

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

t2s = {}
s2t = {}

for s, t in zip(S, T):
    if s2t.get(s, t) != t:
        print('No')
        break
    if t2s.get(t, s) != s:
        print('No')
        break
    s2t[s] = t
    t2s[t] = s
else:
    print('Yes')

Solution (Python):
from collections import defaultdict

s=input()
t=input()
lis=defaultdict(lambda:"A")
lis2=defaultdict(lambda:"A")
for i,val in enumerate(s):
    if lis[val]=="A":
        lis[val]=t[i]
    else:
        if lis[val]!=t[i]:
            print("No")
            exit()
for i,val in enumerate(t):
    if lis2[val]=="A":
        lis2[val]=s[i]
    else:
        if lis2[val]!=s[i]:
            print("No")
            exit()
print("Yes")

Solution (Python):
from collections import Counter

S = input()
T = input()

st = {}
ts = {}

for s, t in zip(S, T):
  if s not in st:
    st[s] = t
  else:
    if st[s] != t:
      print('No')
      break
  if t not in ts:
    ts[t] = s
  else:
    if ts[t] != s:
      print('No')
      break
else:
  print('Yes')

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(S: str, T: str):
    from collections import defaultdict
    d1 = defaultdict(set)
    d2 = defaultdict(set)
    for s, t in zip(S, T):
        d1[t].add(s)
        d2[s].add(t)
    return YES if max(map(len, d1.values())) < 2 and max(map(len, d2.values())) < 2 else NO


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    T = next(tokens)  
    print(solve(S, T))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
from collections import Counter

S = input()
T = input()

alps_counter_s = Counter(S).most_common()
alps_counter_t = Counter(T).most_common()

for s, t in zip(alps_counter_s, alps_counter_t):
    if s[1] != t[1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
s=input()
t=input()
ds=dict()
dt=dict()
ss=''
st=''
for i in s:
    if i not in ds:
        ds[i]=str(len(ds))+' '
    ss+=ds[i]
for i in t:
    if i not in dt:
        dt[i]=str(len(dt))+' '
    st+=dt[i]

print('Yes' if ss==st else 'No')

Solution (Python):
from collections import*
f=lambda:sorted(Counter(input()).values())
print("YNeos"[f()!=f()::2])

Solution (Python):
from collections import Counter
 
s = Counter(input())
t = Counter(input())
 
sv = sorted(s.values())
tv = sorted(t.values())
 

if sv == tv:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

print('Yes' if sorted(list(Counter(input()).values())) == 
       sorted(list(Counter(input()).values())) else 'No')

Solution (Python):


S = input()
T = input()


dS = {}
dT = {}
for i in range(len(S)):
    dS.setdefault(T[i], S[i])
    if dS[T[i]] != S[i]:
        print("No")
        exit()
    dT.setdefault(S[i], T[i])
    if dT[S[i]] != T[i]:
        print("No")
        exit()
        


print("Yes")

Solution (Python):
S=input()
T=input()
U=list(S)
V=list(T)
dp=[0]*26
bp=[0]*26
for i in range(len(S)):
  dp[ord(U[i])-97]+=1
  bp[ord(V[i])-97]+=1
dp.sort()
bp.sort()
ans='Yes'
for i in range(len(dp)):
  if dp[i]!=bp[i]:
    ans='No'
    break
print(ans)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = list(s())
T = list(s())
N = len(S)
s = [[] for _ in range(26)]
t = [[] for _ in range(26)]
for i in range(N):
    s[ord(S[i])-97].append(i)
    t[ord(T[i])-97].append(i)
for i in range(26):
    s[i].sort()
    t[i].sort()
for i in range(26):
    if s[i] not in t:
        print('No')
        exit()
print('Yes')

Solution (Python):
from collections import Counter

s = Counter(input())
t = Counter(input())

sv = sorted(s.values())
tv = sorted(t.values())

if sv == tv:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

s = Counter(input())
t = Counter(input())

sv = sorted(s.values())
tv = sorted(t.values())

if sv == tv:
    print("Yes")
    exit()

print("No")

Solution (Python):
from collections import Counter

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

cs = Counter(s)
ct = Counter(t)

csv = sorted(cs.values())
ctv = sorted(ct.values())

if csv == ctv:
    print("Yes")
    exit()

print("No")

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

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

Solution (Python):
a = {}
b = {}
i = 0
for c, d in zip(input(), input()):
    if c not in a and d not in b:
        a[c] = b[d] = i
        i += 1
    elif c in a and d in b:
        if a[c] != b[d]:
            print('No')
            break
    else:
        print('No')
        break
else:
    print('Yes')

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

ans='Yes'

sabc=[]
tabc=[]
number=0

for i in range(len(s)):
  try:
    tempa=sabc.index(s[i])+1
    try:
      tempb=tabc.index(t[i])+1
      if tempa!=tempb:
        ans='No'
        break
    except ValueError:
      ans='No'
      break
  except ValueError:
    try:
      tempb=tabc.index(t[i])+1
      ans='No'
      break
    except ValueError:
      sabc.append(s[i])
      sabc.append(number)
      tabc.append(t[i])
      tabc.append(number)
print(ans)