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()


if len(set(list(s))) != len(set(list(t))):
    print("No")
    exit()


d = dict()
for si, ti in zip(s, t):
    if si not in d:
        d[si] = ti
    else:
        if d[si] != ti:
            print("No")
            exit()
print("Yes")

Solution (Python):
s = input()
t = input()
s_memo = {}
t_memo = {}

for i in range(len(s)):
    c1 = s[i]
    c2 = t[i]
    if (c1 in s_memo and s_memo[c1] != c2) or \
            (c2 in t_memo and t_memo[c2] != c1):
        print("No")
        exit()
    s_memo[c1] = c2
    t_memo[c2] = c1

print("Yes")

Solution (Python):
from collections import Counter
S = Counter(input()).most_common()
T = Counter(input()).most_common()

ans = 'Yes'
if len(S) != len(T):
    ans = 'No'
else:
    for i in range(len(S)):
        if S[i][1] != T[i][1]:
            ans = 'No'
            break
            
print(ans)

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

def to_num_list(s):
    word_dic = {}
    word_number = []
    idx = 0
    for i in s:
        if i not in word_dic:
            word_dic[i] = idx
            idx += 1
        word_number.append(word_dic[i])
    return word_number

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

Solution (Python):


ABC = "abcdefghijklmnopqrstuvwxyz"
assert len(ABC) == 26

def main():
    s = input()
    t = input()
    ss = sets_of_indices(s)
    tt = sets_of_indices(t)
    print("Yes" if ss == tt else "No")

def sets_of_indices(s):
    di = {c: [] for c in ABC}
    for i, c in enumerate(s):
        di[c].append(i)
    res = {tuple(di[c]) for c in ABC}
    return res

main()

Solution (Python):
s=input()
t=input()
s_set={}
t_set={}
s_dash=[]
t_dash=[]
for i in range(len(s)):
    if s[i] not in s_set.keys():
        s_set.update({s[i]:i})
    s_dash.append(s_set[s[i]])
    if t[i] not in t_set.keys():
        t_set.update({t[i]:i})
    t_dash.append(t_set[t[i]])

if s_dash==t_dash:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    s = list(input())
    t = list(input())
    n = len(s)
    memo1 = {}
    memo2 = {}

    for i in range(n):
        c1 = s[i]
        c2 = t[i]
        if (c1 in memo1 and memo1[c1] != c2) or \
                (c2 in memo2 and memo2[c2] != c1):
            print('No')
            exit()
        memo1[c1] = c2
        memo2[c2] = c1

    print('Yes')


main()

Solution (Python):
def main():
    s = list(input())
    t = list(input())
    n = len(s)
    memo1 = {}
    memo2 = {}

    for i in range(n):
        c1 = s[i]
        c2 = t[i]
        if c1 in memo1:
            if memo1[c1] != c2:
                print('No')
                exit()
        else:
            memo1[c1] = c2
        if c2 in memo2:
            if memo2[c2] != c1:
                print('No')
                exit()
        else:
            memo2[c2] = c1

    print('Yes')


main()

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

s_memo = {}
t_memo = {}

for i in range(len(s)):
  if t[i] not in t_memo:
    t_memo[t[i]] = s[i]
  else:
    if t_memo[t[i]] != s[i]:
      print("No")
      exit()
      break
  
  if s[i] not in s_memo:
    s_memo[s[i]] = t[i]
  else:
    if s_memo[s[i]] != t[i]:
      print("No")
      exit()
      break

print("Yes")

Solution (Python):
S = input()
T = input()
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

k=0
for i in range(len(S)):
    if S[i].islower():
        S = S.replace(S[i],A[k])
        k=k+1


k=0
for i in range(len(T)):
    if T[i].islower():
        T = T.replace(T[i],A[k])
        k=k+1

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

Solution (Python):
def d(s,t):
    s1=list(set([i for i in s]))
    t1=list(set([i for i in t]))
    ans='No'
    st=set(zip(s,t))
    if len(st)-len(s1)==0 and len(st)-len(t1)==0:
        ans='Yes'
    return ans
print(d(input(),input()))

Solution (Python):
def main(s,t):
    n = len(s)
    for i in range(n):
        if t[i]!=s[i]:
            rep =s[i]
            s=s.replace(rep,"A")
            s=s.replace(t[i],rep)
            s=s.replace("A",t[i])
            if t[:i] !=s [:i]:
                return "No"
    if s == t:
        return "Yes"
    else:
        return "No"
s=input()
t=input()
print(main(s,t))

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

sd = {S[0]: 0}
td = {T[0]: 0}

def len_match():
    for i in range(1, len(S)):
        if (S[i-1] == S[i] and T[i-1] == T[i]) or (S[i] != S[i-1] and T[i] != T[i-1]):
            slast = sd.get(S[i], -1)
            tlast = td.get(T[i], -1)
            if slast != tlast:
                return False
            sd[S[i]] = i
            td[T[i]] = i
        else:
            return False
    return True

def ans():
    result = len_match()
    return 'Yes' if result else 'No'

print(ans())

Solution (Python):
def check(str1,str2):
    al = [[] for i in range(26)]
    
    for i in range(len(str1)):
        index = ord(str1[i]) - 97
        al[index].append(i)
    
    for l in al:
        note = [str2[i] for i in l]
        if len(list(set(note))) > 1:
            global ans 
            ans = "No"
            break

S = input(); T = input()
ans = "Yes"
check(S,T); check(T,S)
print(ans)

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

d1 = {}
d2 = {}

flag = 1

for s,t in zip(S,T):
    if not s in d1:
        d1[s] = t
    elif d1[s] != t:
        print('No')
        flag = 0
        break
    if not t in d2:
        d2[t] = s
    elif d2[t] != s:
        print('No')
        flag = 0
        break

if flag:
    print('Yes')

Solution (Python):
abc=list("abcdefghijklmnopqrstuvwxyz")
S=input()
T=input()

c1=[[] for i in abc]
c2=[[] for i in abc]
for i in range(0,len(S)):
    c1[ord(S[i])-ord("a")].append(i)

for i in range(0,len(T)):
    c2[ord(T[i])-ord("a")].append(i)

ans="Yes"
for i in c1:
    if(i not in c2):
        ans="No"
        break
    
print(ans)

Solution (Python):
from collections import defaultdict
S = input()
T = input()

flag = True
ds = defaultdict(chr)
dt = defaultdict(chr)
for i in range(len(S)):
    if S[i] in ds.keys():
        if ds[S[i]] != T[i]:
            flag = False
    else:
        ds[S[i]] = T[i]

    if T[i] in dt.keys():
        if dt[T[i]] != S[i]:
            flag = False
    else:
        dt[T[i]] = S[i]

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

Solution (Python):
s=list(input())
t=list(input())
S=sorted(map(s.count,set(s)))
T=sorted(map(t.count,set(t)))
print("Yes" if S==T else "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

S = sorted(Counter(input()).values())
T = sorted(Counter(input()).values())
if S == T:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

S = sorted(Counter(input()).values())
T = sorted(Counter(input()).values())

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

Solution (Python):
S = input()
T = input()
for x in set(T):
    S = S.replace(S[T.index(x)],'A').replace(x,S[T.index(x)]).replace('A',x)
if S == T:
    print('Yes')
else:
    print('No')

Solution (Python):


S = list(input())
T = list(input())
s = {}
for i in range(len(S)):
    if not(S[i] in s):
        s[S[i]] = i
        S[i] = i
    else:
        S[i] = s[S[i]]
s = {}
for i in range(len(T)):
    if not(T[i] in s):
        s[T[i]] = i
        T[i] = i
    else:
        T[i] = s[T[i]]
print("Yes" if T == S  else "No")

Solution (Python):
s = list(input())
t = list(input())
A = []
B = []
count=0
for i, j in zip(s, t):
    if(s.index(i) != t.index(j)):
        print("No")
        count+=1
        break
if(count==0):
    print("Yes")

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

f_S = {}
f_T = {}


for i in range(len(S)):
    if S[i] not in f_S:
        f_S[S[i]] = T[i]
    elif f_S[S[i]] != T[i]:
        print('No')
        exit()
      
for i in range(len(T)):
    if T[i] not in f_T:
        f_T[T[i]] = S[i]
    elif f_T[T[i]] != S[i]:
        print('No')
        exit()
      
print('Yes')

Solution (Python):



def check(S, T, c):
    ids = tuple((i for i in range(len(T)) if T[i] == c))
    if len(ids) < 2:
        return True
    cs = set((S[i] for i in ids))
    if len(cs) != 1:
        return False
    return True


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

    for ci in range(ord("a"), ord("z") + 1):
        c = chr(ci)
        if check(S, T, c) and check(T, S, c):
            continue
        return False
    return True


if __name__ == "__main__":
    print(["No", "Yes"][main()])

Solution (Python):
from collections import defaultdict

S = input()
T = input()

s_dic = defaultdict(lambda: -1)
t_dic = defaultdict(lambda: -1)

can_replace = True
for i in range(len(S)):
    s_char = S[i]
    t_char = T[i]

    if s_dic[s_char] != -1 or t_dic[t_char] != -1:
        if s_dic[s_char] != t_char and t_dic[t_char] != s_char:
            can_replace = False
            break
    else:
        s_dic[s_char] = t_char
        t_dic[t_char] = s_char

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

Solution (Python):
s = input()
t = input()
s_l = {}
t_l = {}
for i in range(len(s)):
    if s[i] in s_l:
        s_l[s[i]]+=1
    else:
        s_l[s[i]]=1
    if t[i] in t_l:
        t_l[t[i]]+=1
    else:
        t_l[t[i]]=1

s_arr = []
t_arr = []
for i in s_l.values():
    s_arr.append(i)
for i in t_l.values():
    t_arr.append(i)
s_arr = sorted(s_arr)
t_arr = sorted(t_arr)
flag = False
for i in range(len(s_arr)):
    if s_arr[i] != t_arr[i]:
        flag = True
        break
if flag:
    print('No')
else:
    print('Yes')

Solution (Python):
from collections import Counter

S = input()
T = input()

lenS = len(Counter(S))
lenT = len(Counter(T))
flag = 0

if lenS == lenT:
    for i in range(lenS):
        if Counter(S).most_common()[i][1] == Counter(T).most_common()[i][1]:
            continue
        else:
            flag = 1
            break
else:
    flag = 1
    
if flag == 0:
    print('Yes')
else:
    print('No')

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

dic_S = {}
dic_T = {}

for i in range(len(S)):
	if S[i] in dic_S.keys():
		if dic_S[S[i]] == T[i]: continue
		else:
			print('No')
			break
	if T[i] in dic_T.keys():
		if dic_T[T[i]] == S[i]: continue
		else:
			print('No')
			break
	else:
		dic_S[S[i]] = T[i]
		dic_T[T[i]] = S[i]
else:
	print('Yes')

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

dic = {}
flag=True

for i in range(len(S)):
    v = S[i]
    w = T[i]
    key=''

    if v not in dic.keys() and w not in dic.values():
        dic[v]=w
    elif w in dic.values():
        for k in dic.keys():
            if dic[k]==w:
                key=k
        if v!=key:
            flag=False
    else:
        flag=False


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

Solution (Python):
from collections import Counter

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

Scount = Counter(S).values()
Tcount = Counter(T).values()



if sorted(Scount) == sorted(Tcount):
    ans = 'Yes' 
else:
    ans = 'No'

print(ans)

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

cntS = [0 for _ in range(26)]
cntT = [0 for _ in range(26)]
Alph = list("abcdefghijklmnopqrstuvwxyz")

for i in range(26):
    for j in S:
        if j == Alph[i]:
            cntS[i] += 1

for i in range(26):
    for j in T:
        if j == Alph[i]:
            cntT[i] += 1
cntS.sort()
cntT.sort()



if cntS == cntT:
    print("Yes")
else:
    print("No")

Solution (Python):
import string
s = input()
t = input()
n = len(s)
trans = {c:['', ''] for c in string.ascii_lowercase}

for i in range(n):
    if trans[s[i]][1] == '':
        trans[s[i]][1] = t[i]
        if trans[t[i]][0] != '' and trans[t[i]][0] != s[i]:
            print('No')
            exit()
        trans[t[i]][0] = s[i]
    if trans[s[i]][1] != t[i] or trans[t[i]][0] != s[i]:
        print('No')
        exit()
print('Yes')

Solution (Python):
from collections import defaultdict
S = input()
T = input()
def solve(S, T):
    fanin = defaultdict(set)
    fanout = defaultdict(set)
    for s, t in zip(S, T):
        fanin[t].add(s)
        fanout[s].add(t)
    for x in fanin.values():
        if len(x) > 1:
            return False
    for x in fanout.values():
        if len(x) > 1:
            return False
    return True
print(['No', 'Yes'][solve(S, T)])

Solution (Python):
from collections import Counter

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

cs = sorted(Counter(S).values())
ct = sorted(Counter(T).values())

if cs == ct:
    print('Yes')
else:
    print('No')

Solution (Python):
S = list(input())
T = list(input())
 
Sn = [ord(i)-ord("a") for i in S]
Tn = [ord(i)-ord("a") for i in T]
sub1 = [-1]*26
sub2 = [-1]*26
 
for i in range(len(S)):
    if sub1[Sn[i]] == -1 or sub2[Tn[i]] == -1:
        if sub1[Sn[i]] == -1:
            sub1[Sn[i]] = Tn[i]
        if sub2[Tn[i]] == -1:
            sub2[Tn[i]] = Sn[i]
    if sub1[Sn[i]] != Tn[i] or sub2[Tn[i]] != Sn[i]:
            print("No")
            break
else:
    print("Yes")

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

Solution (Python):
from collections import Counter


def main():
    s = input()
    t = input()
    vs_s = Counter(Counter(s).values())
    vs_t = Counter(Counter(t).values())
    if vs_s == vs_t:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
S = str(input())
T = str(input())
s_list = [[] for i in range(26)]
t_list = [[] for i in range(26)]

for i in range(len(S)):
    s_list[ord(S[i])-97].append(i)
for i in range(len(T)):
    t_list[ord(T[i])-97].append(i)
ok = True
for s in s_list:
    if s != []:
        if s in t_list:
            continue
        else:
            ok = False
            break

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

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

flag = 0
dic1 = {}
dic2 = {}

for i in range(len(S)):
    if dic1.get(S[i]) == None:
        dic1[S[i]] = T[i]
    elif dic1[S[i]] != T[i]:
        print("No")
        exit()
    
    if dic2.get(T[i]) == None:
        dic2[T[i]] = S[i]
    elif dic2[T[i]] != S[i]:
        print("No")
        exit()

print("Yes")

Solution (Python):
S = list(input())
T = list(input())
d = {}
e = {}
flag = 1

for i in range(len(S)):
    if S[i] not in d:
        d[S[i]] = T[i]
    else:
        if d[S[i]] != T[i]:
            flag = 0
            break

for i in range(len(S)):
    if T[i] not in e:
        e[T[i]] = S[i]
    else:
        if e[T[i]] != S[i]:
            flag = 0
            break



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

Solution (Python):
S = input()
T = input()
 
dicS = {}
dicT = {}

alphabet = "abcdefghijklmnopqrstuvwxyz"

for _a in alphabet:
    dicS[_a] = []
    dicT[_a] = []

for i,_s_ in enumerate(S):
    dicS[_s_].append(i)
   
for i,_t_ in enumerate(T):
    dicT[_t_].append(i)

for _s in dicS:
    dicS[_s] = tuple(dicS[_s])

for _t in dicT:
    dicT[_t] = tuple(dicT[_t])

flg = True
for t in dicS.values():
    if not t in dicT.values():
        flg = False
        
if flg:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()
d1 = {}
d2 = {}

for i in range(len(s)):
  if s[i] not in d1:
    d1[s[i]] = t[i]
  elif d1[s[i]] != t[i]:
    print("No")
    break
  if t[i] not in d2:
    d2[t[i]] = s[i]
  elif d2[t[i]] != s[i]:
    print("No")
    break
  
else:
  print("Yes")

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


def main():
    StoT = {}
    TtoS = {}

    for i in range(len(S)):

        if S[i] in StoT:
            if StoT[S[i]] != T[i]:
                print("No")
                return

        else:
            StoT[S[i]] = T[i]

            if T[i] in TtoS:
                if TtoS[T[i]] != S[i]:
                    print("No")
                    return
            else:
                TtoS[T[i]] = S[i]

    print("Yes")


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
t = input()
dic1 = {}
dic2 = {}
for i in range(len(s)):
    if dic1.get(s[i]) == None:
        dic1[s[i]] = t[i]
    elif dic1[s[i]] != t[i]:
        print("No")
        exit()
    if dic2.get(t[i]) == None:
        dic2[t[i]] = s[i]
    elif dic2[t[i]] != s[i]:
        print("No")
        exit()
print("Yes")

Solution (Python):
from collections import Counter

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

s_s = sorted(s.values())
t_s = sorted(t.values())

if s_s == t_s:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections

S = input()
T = input()

s = collections.Counter(S)
t = collections.Counter(T)

scounts = list(s.values())
tcounts = list(t.values())

scounts.sort()
tcounts.sort()

if scounts == tcounts:
    print("Yes")
else:
    print("No")

Solution (Python):
S = list(input())
T = list(input())
dic = {}

for s,t in zip(S,T):
    if s in dic:
        if dic[s] != t:
            print("No")
            exit(0)   
    else:
        dic[s] = t

if len(set(dic.values())) != len(dic):
    print("No")
else:
    print("Yes")

Solution (Python):





from collections import Counter
 
S = list(input())
T = list(input())
 
cs = sorted(Counter(S).values())
ct = sorted(Counter(T).values())
 
if cs == ct:
    print('Yes')
else:
    print('No')

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

dic = {}
dic_rev = {}


def solve():
    for s, t in zip(S, T):
        if t in dic.keys():
            if s != dic[t]:
                print('No')
                return
        else:
            dic[t] = s
    for s, t in zip(S, T):
        if s in dic_rev.keys():
            if t != dic_rev[s]:
                print('No')
                return
        else:
            dic_rev[s] = t
    print('Yes')
    return


solve()

Solution (Python):
from collections import Counter

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

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

for i in range(len(S)):
    if S[i][1] == T[i][1]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):

s = input()
t = input()
n = len(s)

ds = {}
dt = {}
for i in range(n):
    if s[i] not in ds:
        ds[s[i]] = t[i]
    elif ds[s[i]]!=t[i]:
        print("No")
        exit()
    if t[i] not in dt:
        dt[t[i]] = s[i]
    elif dt[t[i]]!=s[i]:
        print("No")
        exit()
print("Yes")

Solution (Python):
from collections import Counter

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

cs = sorted(Counter(S).values())
ct = sorted(Counter(T).values())

if cs == ct:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter

s=input()
t=input()
if len(Counter(t))==len(Counter(s)) and len(s)==len(t):
  ls1=sorted([Counter(t)[x] for i,x in enumerate(Counter(t))])
  ls2=sorted([Counter(s)[x] for i,x in enumerate(Counter(s))])
  for i in range(len(ls1)):
    if ls1[i]!= ls2[i]:
      print('No')
      exit()
  print('Yes')
else:
  print("No")

Solution (Python):


if __name__ == "__main__":
    s = input()
    t = input()
    map_s = {}
    map_t = {}
    for i in range(len(s)):
        if s[i] not in map_s:
            map_s[s[i]] = t[i]
        else:
            if map_s[s[i]] != t[i]:
                print("No")
                i = 0
                break
        if t[i] not in map_t:
            map_t[t[i]] = s[i]
        else:
            if map_t[t[i]] != s[i]:
                print("No")
                i = 0
                break
    if i == len(s) - 1:
        print("Yes")

Solution (Python):
from collections import Counter

S = sorted(list(Counter(input()).values()))
T = sorted(list(Counter(input()).values()))

for i, v in enumerate(S):
    if v == T[i]:
        continue
    else:
        print('No')
        break
else:
    print(('Yes'))

Solution (Python):
def ctonum(c):
	alp = "qwertyuiopasdfghjklzxcvbnm"
	for i in range(len(alp)):
		if c == alp[i]:
			return i

countS=[0 for i in range(100)]
countT=[0 for i in range(100)]

S=input()
T=input()

for i in range(len(S)):
	countS[ctonum(S[i])]+=1
	countT[ctonum(T[i])]+=1
	
countS.sort()
countT.sort()

if countS==countT:
	print("Yes")
else:
	print("No")

Solution (Python):
S = input()
T = input()
S_dic = {}
T_dic = {}

for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s in S_dic:
        S_dic[s] += 1
    else:
        S_dic[s] = 1

    if t in T_dic:
        T_dic[t] +=1

    else:
        T_dic[t] = 1

S_dic = sorted(S_dic.items(), key= lambda x:x[1])
T_dic = sorted(T_dic.items(), key=lambda x:x[1])
f = True
if len(S_dic) >= len(T_dic):
    length = len(T_dic)
else:
    length = len(S_dic)
for i in range(length):
    s = S_dic[i][1]
    t = T_dic[i][1]
    if s != t:
        f = False

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

Solution (Python):
S = input()
T = input()
S_dic = [-1 for _ in range(26)]
T_dic = [-1 for _ in range(26)]

alphabet = ["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"]

for i in range(len(S)):
    s = S[i]
    t = T[i]
    si = alphabet.index(s)
    ti = alphabet.index(t)

    if S_dic[si] == -1:
        S_dic[si] = ti
    elif S_dic[si] != ti:
        print("No")
        exit()

    if T_dic[ti] == -1:
        T_dic[ti] = si
    elif T_dic[ti] != si:
        print("No")
        exit()

print("Yes")

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

letters = 'abcdefghijklmnopqrstuvwxyz'
res = "Yes"
for st in letters:
    temp = ""
    for i in range(len(S)):
        if S[i] == st:
            if temp and T[i] != temp:
                res = "No"
                break
            else:
                temp = T[i]
    if res == "No":
        break

for st in letters:
    temp = ""
    for i in range(len(T)):
        if T[i] == st:
            if temp and S[i] != temp:
                res = "No"
                break
            else:
                temp = S[i]
    if res == "No":
        break

print(res)

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

sd = {}
td = {}

for k in range(ord('a'),ord('z')+1):   
    sd[chr(k)] = 0
    td[chr(k)] = 0

for i in range(len(s)) :
    if s[i] in sd :
        sd[s[i]] = sd[s[i]] + 1

    if t[i] in td :
        td[t[i]] = td[t[i]] + 1
""" 
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in sd :
        print(str(sd[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print()
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in td :
        print(str(td[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print() """

ta = []
sa = []
for k in range(ord('a'),ord('z')+1):
    if td[chr(k)] != sd[chr(k)] : 
        if td[chr(k)] > 0 :
            ta.append(td[chr(k)])
        if sd[chr(k)] > 0 :    
            sa.append(sd[chr(k)])



ta.sort()
sa.sort()

if ta == sa :
    print("Yes")
else :
    print("No")

Solution (Python):
import collections
S = sorted(list(collections.Counter(input()).values()))
T = sorted(list(collections.Counter(input()).values()))
for i,s in enumerate(S):
    if s == T[i]:
        continue
    print('No')
    break
else:
    print('Yes')

Solution (Python):
from collections import defaultdict
import string


S = input()
T = input()

td = defaultdict(set)
for i, s in enumerate(T):
    td[s].add(i)

for c in td.keys():
    index = td[c]
    s = set()
    for i in index:
        s.add(S[i])
    if len(s) != 1:
        print("No")
        exit()

sd = defaultdict(set)
for i, s in enumerate(S):
    sd[s].add(i)

for c in sd.keys():
    index = sd[c]
    s = set()
    for i in index:
        s.add(T[i])
    if len(s) != 1:
        print("No")
        exit()
print("Yes")

Solution (Python):
def main():
    s = input()
    t = input()
    chk_dir = {}
    for i in range(len(s)):
        if not(s[i] in chk_dir.keys()):
            if (t[i] in chk_dir.values()):
                return print("No")
            else:
                chk_dir[s[i]] = t[i]
        elif chk_dir[s[i]] != t[i]:
            return print("No")

    print("Yes")

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    s = input()
    t = input()
    chk_dir = {}
    for i in range(len(s)):
        if not(s[i] in chk_dir.keys()):
            if (t[i] in chk_dir.values()):
                print("No")
                return
            else:
                chk_dir[s[i]] = t[i]
        elif chk_dir[s[i]] != t[i]:
            print("No")
            return

    print("Yes")
    return

if __name__ == "__main__":
    main()

Solution (Python):
import sys

S=input()
T=input()

DICT=dict()
L=len(S)

for i in range(L):
    if DICT.get(S[i])!=None and DICT.get(S[i])!=T[i]:
        print("No")
        sys.exit()
    else:
        DICT[S[i]]=T[i]


INVDICT=dict()

for d in DICT:
    if INVDICT.get(DICT[d])!=None and INVDICT.get(DICT[d])!=d:
        print("No")
        sys.exit()
    else:
        INVDICT[DICT[d]]=d

else:
    print("Yes")

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

list1 = [-1 for i in range(26)]
list2 = [-1 for i in range(26)]

for i in range(len(s)):
    a = ord(s[i]) - ord("a")
    b = ord(t[i]) - ord("a")
    
    if list1[a] != -1 or list2[b] != -1:
        if list1[a] != b or list2[b] != a:
            print("No")
            exit()
    else:
        list1[a] = b
        list2[b] = a

print("Yes")

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

d = {}
for a,b in zip(S,T):
    if a in d:
        if d[a] == b:
            continue
        else:
            print('No')
            exit()
    else:
        d[a] = b
l = len(set(d.values()))

print('Yes' if len(d) == l else 'No')

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

stot = dict()
ttos = dict()

s = lc()
t = lc()

ans = True

for si,ti in zip(s,t):
    if not si in stot.keys():
        stot.update({si: ti})
    elif stot[si] != ti:
        ans = False
        break
        
    if not ti in ttos.keys():
        ttos.update({ti: si})
    elif ttos[ti] != si:
        ans = False
        break
    
print('Yes') if ans else print('No')

Solution (Python):
def check(S, T):
    tbl = {}
    inv = {}
    for i in range(len(S)):
        if S[i] in tbl and tbl[S[i]] != T[i]:
            return False
        if T[i] in inv and inv[T[i]] != S[i]:
            return False
        tbl[S[i]] = T[i]
        inv[T[i]] = S[i]
    return True


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


if __name__ == "__main__":
    main()

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

arrayS = []
arrayT = []
for i in range(len(S)):
    if S[i] in arrayS:
        if arrayT[arrayS.index(S[i])] != T[i]:
            result = False
            break
    elif T[i] in arrayT:
        result = False
        break
    else:
        arrayS.append(S[i])
        arrayT.append(T[i])

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

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

ds = {}
dt = {}
for letter in s:
    ds.setdefault(letter,0)
    ds[letter]+=1

for letter in t:
    dt.setdefault(letter,0)
    dt[letter]+=1

if sorted(ds.values()) == sorted(dt.values()):
    print("Yes")
else:
    print("No")

Solution (Python):
str1= list(raw_input())
str2 = list(raw_input())
from collections import Counter

resstr2 = Counter(str2)
resstr1 = Counter(str1)


res1 = Counter(resstr1.values())
res2 =  Counter(resstr2.values())
result = "Yes"
for k , i in res1.iteritems():
    if res2[k] != i:
        result = "No"
        break
print result

Solution (Python):


s = raw_input()
t = raw_input()
dd1 = {}
dd2 = {}
flag = True
for i in xrange(len(s)):
    c1, c2 = s[i], t[i]
    if dd1.get(c1, c2) != c2:
        flag = False
        break
    if dd2.get(c2, c1) != c1:
        flag = False
        break
    dd1[c1] = c2
    dd2[c2] = c1
print 'Yes' if flag else 'No'

Solution (Python):
s=raw_input()
t=raw_input()
if [s.find(i) for i in s] == [t.find(j) for j in t]:
 print 'Yes'
else:
 print 'No'

Solution (Python):
import numpy as np

s=input()
t=input()
s_cnt=np.zeros(26)
s_letterPlace=[[] for _ in range(26)]
for i,si in enumerate(s):
    num=ord(si)-ord('a')
    s_cnt[num]+=1
    s_letterPlace[num].append(i)

s_multiLetter=[]
for cnt,place in zip(s_cnt,s_letterPlace):
    if cnt>1:
        s_multiLetter.append(place)

t_cnt=np.zeros(26)
t_letterPlace=[[] for _ in range(26)]
for i,ti in enumerate(t):
    num=ord(ti)-ord('a')
    t_cnt[num]+=1
    t_letterPlace[num].append(i)

t_multiLetter=[]
for cnt,place in zip(t_cnt,t_letterPlace):
    if cnt>1:
        t_multiLetter.append(place)



flag=1
if len(s_multiLetter)!=len(t_multiLetter):
    flag=0
elif len(s_multiLetter)==0 & len(t_multiLetter)==0:
    flag=1
elif len(s_multiLetter)*len(t_multiLetter)==0:
    flag=0
else:
    for s_place in s_multiLetter:
        if(flag==1):
            for t_place in t_multiLetter:
                if(s_place==t_place):
                    flag=1
                    break
                else:
                    flag=0

print('Yes' if flag==1 else 'No')

Solution (Python):
S=input()
T=input()
s=list(S)
t=list(T)
ss=[]
tt=[]
for i in range(97,123):
    a=s.count(chr(i))
    ss.append(a)
    b=t.count(chr(i))
    tt.append(b)
ss.sort()
tt.sort()
if ss==tt:
    print("Yes")
else:
    print("No")

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

S = input()
T = input()


N = len(S)


def f(STR1, STR2):
    d = {}
    isOK = True
    for i in range(N):
        s = STR1[i]
        t = STR2[i]

        if d.get(s) == None:
            d[s] = t
        elif d.get(s) == t:
            pass
        else:
            return False
    return True


if f(S,T) and f(T,S):
    print("Yes")
else:
    print("No")

Solution (Python):
def m():
    s = input()
    t = input()
    a = {chr(i): "" for i in range(97, 97 + 26)}
    b = {chr(i): "" for i in range(97, 97 + 26)}
    n = len(s)
    for i in range(n):
        if a[s[i]] == "":
            a[s[i]] = t[i]
        else:
            if a[s[i]] != t[i]:
                return 'No'
        if b[t[i]] == "":
            b[t[i]] = s[i]
        else:
            if b[t[i]] != s[i]:
                return 'No'
    return 'Yes'
print(m())