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()
s_dic={}
t_dic={}
flag=0
for i, c in enumerate(s):
  if c in s_dic:
    if s_dic[c]!=t[i]:
      flag=1
      break
  else:
  	s_dic[c]=t[i]
for i, c in enumerate(t):
  if c in t_dic:
    if t_dic[c]!=s[i]:
      flag=1
      break
  else:
  	t_dic[c]=s[i]
if flag==1:
  print("No")
else:
  print("Yes")

Solution (Python):
import copy

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

c = {}
for i in range(len(S)):
    if S[i] in c:
        if c[S[i]] != T[i]:
            print('No')
            exit()
    elif T[i] in c.values():
        ct = copy.copy(c)
        ct[S[i]] = T[i]
        keys = [k for k, v in ct.items() if v == T[i]]
        if len(set(keys)) != 1:
            print('No')
            exit()
    else:
        c[S[i]] = T[i]
    
print('Yes')

Solution (Python):
s = input()
t = input()
while s != "":
  x = s[0]
  y = t[0]
  for i in range(len(s)):
    if (s[i] == x and t[i] != y) or (s[i] != x and t[i] == y):
      print("No")
      exit()
  s = s.replace(x,"")
  t = t.replace(y,"")
print("Yes")

Solution (Python):
s = input()
t = input()
dict_s = ["_"]*26
dict_t = ["_"]*26
alphabet = [chr(i) for i in range(97, 97 + 26)]
for i in range(len(s)):
    if dict_s[alphabet.index(s[i])] == "_":
        dict_s[alphabet.index(s[i])] = t[i]
    elif dict_s[alphabet.index(s[i])] != t[i]:
            print("No")
            exit()
    if dict_t[alphabet.index(t[i])] == "_":
        dict_t[alphabet.index(t[i])] = s[i]
    elif dict_t[alphabet.index(t[i])] != s[i]:
            print("No")
            exit()
print("Yes")

Solution (Python):





"""
RC110C
"""


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

def exchange(a,b,c):
    if a != b and a!=c:
        return(a)
    elif a == b:
        return(c)
    elif a == c:
        return(b)

ans = 'Yes'

seen = set()
for i in range(n):
    sl = s.pop()
    tl = t.pop()
    if sl == tl:
        seen.add(sl)
    elif sl != tl and not tl in seen and not sl in seen:
        s = list(map(lambda a: exchange(a,sl,tl),s))
        seen.add(tl)
    else:
        ans = 'No'
        break

print(ans)

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

Solution (Python):
import collections

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

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

slist = list(cs.values())
tlist = list(ct.values())

slist.sort()
tlist.sort()

if slist == tlist:
    print("Yes")
else:
    print("No")

Solution (Python):
def solve():
    alpha = "abcdefghijklmnopqrstuvwxyz"
    inp1, inp2 = input(), input()
    sz = dict(zip(list(alpha), [0] * 26))
    tz = dict(zip(list(alpha), [0] * 26))
    for i in range(len(inp1)):
        sz[inp1[i]] += 1
        tz[inp2[i]] += 1
        if sz[inp1[i]] != tz[inp2[i]]:
            print("No")
            return
    print("Yes")


solve()

Solution (Python):
def solve():
  from collections import Counter
  s = [i for i in sorted(Counter(input()).values())]
  t = [i for i in sorted(Counter(input()).values())]
  print(["No","Yes"][s==t])

solve()

Solution (Python):
S = input()
T = input()
f = [-1 for _ in range(130)]
g = [-1 for _ in range(130)]
ans = "Yes"
for i in range(len(S)):
  s = ord(S[i])
  t = ord(T[i])
  if f[s] == -1:
    f[s] = t
  else:
    if f[s] != t:
      ans = "No"
  if g[t] == -1:
    g[t] = s
  else:
    if g[t] != s:
      ans = "No"
print(ans)

Solution (Python):
from string import ascii_lowercase

s = input()
t = input()
dic = {}
used = {}
for c in ascii_lowercase:
    dic[c] = None
    used[c] = False

for ss, tt in zip(s, t):
    if dic[tt] is None:
        if used[ss]:
            print('No')
            exit()
        else:
            dic[tt] = ss
            used[ss] = True
    elif dic[tt] != ss:
        print('No')
        exit()
else:
    print('Yes')

Solution (Python):


import collections


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

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

slist = list(cs.values())
tlist = list(ct.values())

slist.sort()
tlist.sort()

if slist == tlist:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
T = input()
sls = {chr(_): list() for _ in range(97, 97+26)}
tls = {chr(_): list() for _ in range(97, 97+26)}
for i in range(len(S)):
    sls[S[i]].append(i)
for i in range(len(T)):
    tls[T[i]].append(i)

for i in range(97, 97+26):
    t = sls[chr(i)]
    if len(t) > 1:
        for j in range(len(t)-1):
            if T[t[j]] != T[t[j+1]]:
                print('No')
                exit(0)

for i in range(97, 97 + 26):
    t = tls[chr(i)]
    if len(t) > 1:
        for j in range(len(t) - 1):
            if S[t[j]] != S[t[j + 1]]:
                print('No')
                exit(0)

print('Yes')

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

alphabets = 'abcdefghijklmnopqrstuvwxyz'

S_list = []
T_list = []

for i in alphabets:
    Scnt = S.count(i)
    Tcnt = T.count(i)
    if Scnt > 0:
        S_list.append(Scnt)
    if Tcnt > 0:
        T_list.append(Tcnt)

if sorted(T_list) == sorted(S_list):
    print('Yes')
else:
    print('No')

Solution (Python):

s= input()
t = input()






def solve(S,T):
    s_map  = {}
    t_map = {}

    for s in S:
        if s in s_map:
            s_map[s] += 1
        else:
            s_map[s] = 1

    
    for t in T:
        if t in t_map:
            t_map[t] += 1
        else:
            t_map[t] = 1

    s_l = []
    t_l = []

    for sss in s_map:
        s_l.append(s_map[sss])
    for ttt in t_map:
        t_l.append(t_map[ttt])

    return sorted(s_l) == sorted(t_l)


    

if solve(s,t):
    print("Yes") 
else:
    print("No")

Solution (Python):
s = list(input())
t = list(input())
x = list(set(s))
y = list(set(t))
a = []
b = []

for i in range(len(set(s))):
    a.append(s.count(x[i]))
    
for j in range(len(set(t))):
    b.append(t.count(y[j]))
    
a.sort()
b.sort()

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

Solution (Python):
s = list(input())
t = list(input())
x = list(set(s))
y = list(set(t))
a = []
b = []
for i in range(len(set(s))):
  a.append(s.count(x[i]))
for j in range(len(set(t))):
  b.append(t.count(y[j]))
a.sort()
b.sort()
if a == b:
  print("Yes")
else:
  print("No")

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

S_list = []
T_list = []
alpha = "abcdefghijklmnopqrstuvwxyz"

for i in alpha:
    SS = S.count(i)
    TT = T.count(i)
    if SS > 0:
        S_list.append(SS)
    if TT > 0:
        T_list.append(TT)

if sorted(S_list) != sorted(T_list):
    print('No')
else:
    print('Yes')

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

string = ''

for i in range(len(S)):
    if S[i] not in string:
        S_ch = [j for j, x in enumerate(S) if x == S[i]]
        T_ch = [j for j, x in enumerate(T) if x == T[i]]
        string += S[i]
        if S_ch != T_ch:
            print('No')
            exit()

print('Yes')

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

S_list = []
T_list = []
alpha = "abcdefghijklmnopqrstuvwxyz"

for i in alpha:
    SS = S.count(i)
    TT = T.count(i)
    if SS > 0:
        S_list.append(SS)
    if TT > 0:
        T_list.append(TT)

if sorted(S_list) != sorted(T_list):
    print('No')
else:
    print('Yes')

Solution (Python):
s = input()
t = input()
snum = []
tnum = []
for c in range(ord('a'), ord('z') + 1):
    snum.append([i for i, x in enumerate(s) if x == chr(c)])
for c in range(ord('a'), ord('z') + 1):
    tnum.append([i for i, x in enumerate(t) if x == chr(c)])
snum.sort()
tnum.sort()
print('Yes' if snum == tnum else 'No')

Solution (Python):
S = input()
T = input()
alphabets = "abcdefghijklmnopqrstuvwxyz"

S_list=[]
T_list=[]
for c in alphabets:
    Scnt = S.count(c)
    Tcnt = T.count(c)
    if Scnt > 0:
        S_list.append(Scnt)
    if Tcnt > 0:
        T_list.append(Tcnt)

if sorted(S_list) == sorted(T_list):
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()
start = [-1]*30
goal = [-1]*30
count = 0
for i in range(0,len(s)):
    a = ord(s[i])-ord("a")
    b = ord(t[i])-ord("a")
    if start[a] != -1 or goal[b] != -1:
        if start[a] != b or goal[b] != a:
            count = 1
            break
    else:
        start[a] = b
        goal[b] = a
if count == 1:
    print("No")
elif count == 0:
    print("Yes")

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

i = 0
j = 0
ss = list()
tt = list()
slist = list()
tlist = list()

if len(S) == len(T):
   for s in S:
      if s in slist:
         ss.append(slist.index(s))
      else:
         ss.append(i)
         slist.append(s)
         i += 1

   for t in T:
      if t in tlist:
         tt.append(tlist.index(t))
      else:
         tt.append(j)
         tlist.append(t)
         j += 1

   if ss == tt:
      print("Yes")
   else:
      print("No")
else:
   print("No")

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

s = list(S)
t = list(T)

s.sort()
t.sort()

v = 0
w = 0

a = [0 for i in range(0,n)]
b = [0 for i in range(0,n)]

c = [0 for i in range(0,26)]
d = [0 for i in range(0,26)]

for i in range(0,n-1):
    if s[i] == s[i+1]:
        a[i+1] = v
    else:
        v += 1
        a[i+1] = v

for i in range(0,n-1):
    if t[i] == t[i+1]:
        b[i+1] = w
    else:
        w += 1
        b[i+1] = w

for i in range(0,26):
    c[i] = a.count(i)

for i in range(0,26):
    d[i] = b.count(i)

c.sort()
d.sort()

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

Solution (Python):
from collections import defaultdict

S = input()
T = input()

s_counter = defaultdict(int)
t_counter = defaultdict(int)

for s in S:
    s_counter[s] += 1
for t in T:
    t_counter[t] += 1

s_counter = sorted(list(s_counter.items()), key=lambda x: x[1])
t_counter = sorted(list(t_counter.items()), key=lambda x: x[1])

if len(s_counter) != len(t_counter):
    print("No")
else:
    flag = True
    for s_tup, t_tup in zip(s_counter, t_counter):
        if s_tup[1] != t_tup[1]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")

Solution (Python):
s = input()
t = input()
S = [""] * len(s)
T = [""] * len(s)
for i in range(len(s)):
    S[i] = s[i]
    T[i] = t[i]

chrset = set()
res = "Yes"
for i,s,t in zip(range(len(S)),S,T):
    if s == t:
        continue
    if (s in chrset) or (t in chrset):
        res = "No"
        break 
    for j in range(i,len(S)):
        if S[j] == s:
            S[j] = t 
        elif S[j] == t:
            S[j] = s 
    chrset.add(t)
print(res)

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

i = 0
j = 0

sdict = {}
tdict = {}

slist = []
tlist = []

for s in S:
    if s in sdict:
        slist.append(sdict[s])
    else:
        sdict[s] = i
        slist.append(i)
        i += 1


for t in T:
    if t in tdict:
        tlist.append(tdict[t])
    else:
        tdict[t] = j
        tlist.append(j)
        j += 1

if slist == tlist:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

S = input()
T = input()

counter_S = Counter(S)
counter_T = Counter(T)

if sorted(counter_S.values()) == sorted(counter_T.values()):
    print("Yes")
else:
    print("No")

Solution (Python):
def uni(t, l):
    if len(l) < 2:
        return True
    else:
        for i in range(1, len(l)):
            if t[l[0]] != t[l[i]]:
                return False
            else:
                pass
        return True

s = input()
t = input()

l = 'abcdefghijklmnopqrstuvwxyz'

flag = True

for x in l:
    tmp = []
    for i,y in enumerate(t):
        if y == x:
            tmp.append(i)


    if not uni(s, tmp):
        flag = False

for x in l:
    tmp = []
    for i,y in enumerate(s):
        if y == x:
            tmp.append(i)
    if not uni(t,tmp):
        flag = False

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

Solution (Python):
import collections as c
i=lambda:c.Counter(c.Counter(input()).values());print('YNeos'[i()!=i()::2])

Solution (Python):
from collections import Counter as C
i=lambda:C(C(input()).values());print('YNeos'[i()!=i()::2])

Solution (Python):
import sys

S = input()
T = input()

len_S = len(S)
S_Converted = S
for i in range (len(S)):
    tmp_S = S_Converted[i]
    tmp_T = T[i]
    if tmp_S == tmp_T:
        continue
    S_Converted = list(S_Converted) 
    list_indexT = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_T]
    if (not list_indexT == []) and (list_indexT[0] < i):
        print('No')
        sys.exit()
    S_Converted = ''.join(S_Converted)
    S_Converted = S_Converted.replace(tmp_S, tmp_T)
    S_Converted = list(S_Converted) 
    for li in list_indexT:
        if li == i:
            continue
        else:
            S_Converted[li] = tmp_S
    
    
S_Converted = ''.join(S_Converted)

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

Solution (Python):
a=input()
b=input()
A=a
s=set()
for i in range(len(a)):
  if b[i] not in s:
    A=A.replace(A[i],b[i].upper())
  s|={b[i]}
if A==b.upper():
  print('Yes')
else:
  print('No')

Solution (Python):
S=input()
T=input()
start=[-1]*26
goal=[-1]*26
ans='Yes'
for i in range(len(S)):
    a=ord(S[i])-ord('a')
    b=ord(T[i])-ord('a')
    if start[a]!=-1 or goal[b]!=-1:
        if start[a]!=b or goal[b]!=a:
            ans='No'
    else:
        start[a]=b;
        goal[b]=a;
print(ans)

Solution (Python):
def main():
    s=input()
    t=input()
    if len(s) != len(t):
        print('No')
    ret1 = {}
    ret2 = {}
    for i in range(len(s)):
        ret1[s[i]] = ret1.get(s[i], set())
        ret1[s[i]].add(t[i])
        ret2[t[i]] = ret2.get(t[i], set())
        ret2[t[i]].add(s[i])
    if max(len(i) for i in ret1.values()) == 1 and max(len(i) for i in ret2.values()) == 1:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):
s,t=[0]*26,[0]*26
for a,b in zip(input(),input()):
  s[ord(a)-ord('a')]+=1
  t[ord(b)-ord('a')]+=1
u,v=[],[]
for a,b in zip(s,t):
  if a!=b:
    u.append(a)
    v.append(b)
print('YNeos'[sorted(u)!=sorted(v)::2])

Solution (Python):
s,t=[0]*26,[0]*26
for a,b in zip(input(),input()):
  s[ord(a)-ord('a')]+=1
  t[ord(b)-ord('a')]+=1
u,v=[],[]
for a,b in zip(s,t):
  if a!=b:
    u.append(a)
    v.append(b)
print('YNeos'[sorted(u)!=sorted(v)::2])

Solution (Python):
from collections import Counter

S = input()
T = input()

counter_S = Counter(S)
counter_T = Counter(T)

if sorted(counter_S.values()) == sorted(counter_T.values()):
    print("Yes")
else:
    print("No")

Solution (Python):
ss = input()
tt = input()

res = "Yes"
_dict = {chr(x): [] for x in range(97, 123)}
_dict2 = {chr(x): [] for x in range(97, 123)}
for i, j in zip(ss, tt):
    _dict[i].append(j)
for i, j in zip(ss, tt):
    _dict2[j].append(i)

for array in _dict.values():
    if len(set(array)) > 1:
        res = "No"
        break
for array in _dict2.values():
    if len(set(array)) > 1:
        res = "No"
        break
print(res)

Solution (Python):
from collections import Counter
S=raw_input()
T=raw_input()

start=[ -1 for i in range(26) ]
goal=[ -1 for i in range(26) ]

L=len(S)


for i in range(L):
	a=ord(S[i])-ord("a")
	b=ord(T[i])-ord("a")

	if start[a]!=-1 or goal[b]!=-1:
		if start[a]!=b or goal[b]!=a:
			print "No"
			quit()
	else:
		start[a]=b
		goal[b]=a




print "Yes"

Solution (Python):
alp="abcdefghijklmnopqrstuvwxyz"
s=input()
t=input()
l=len(s)
a=[]
b=[]

for i in alp:
  a.append(s.count(i))
  b.append(t.count(i))

a.sort()
b.sort()

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

Solution (Python):
s = raw_input().strip()
t = raw_input().strip()

s_encode = [0]*26
t_encode = [0]*26

for i in s:
	s_encode[ord(i)-97]+=1

for i in t:
	t_encode[ord(i)-97]+=1

s_encode.sort()
t_encode.sort()
if s_encode==t_encode:
	print("Yes")
else:
	print("No")

Solution (Python):
def solv():
    s = ["" for _ in range(26)]
    t = ["" for _ in range(26)]
    for i in range(len(S)):
        if s[ord(S[i]) - ord('a')] == "":
            s[ord(S[i]) - ord('a')] = T[i]
        else:
            if s[ord(S[i]) - ord('a')] != T[i]:
                return False
        if t[ord(T[i]) - ord('a')] == "":
            t[ord(T[i]) - ord('a')] = S[i]
        else:
            if t[ord(T[i]) - ord('a')] != S[i]:
                return False
    return True


S = input()
T = input()
print("Yes" if solv() else "No")

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

d1, d2 = {}, {}
ans = 'Yes'
for s, t in zip(S, T):
    if s in d1 and d1[s] != t:
        ans = 'No'
        break
    if t in d2 and d2[t] != s:
        ans = 'No'
        break
    d1[s] = t
    d2[t] = s
print(ans)

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

flag = True
translate1 = [-1 for i in range(26)]
translate2 = [-1 for i in range(26)]
for i in range(len(S)):
    s = ord(S[i])-97
    t = ord(T[i])-97

    if translate1[s] == -1:
        translate1[s] = t
    else:
        if translate1[s] != t:
            flag = False
            break 

    if translate2[t] == -1:
        translate2[t] = s
    else:
        if translate2[t] != s:
            flag = False
            break


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

Solution (Python):
f = lambda x: ord(x)-ord('a')
S = list(map(f, list(input())))
T = list(map(f, list(input())))

def solve():
    to = [None for _ in range(26)] 
    fr = [None for _ in range(26)] 

    for s, t in zip(S, T):
        if to[s] != None and to[s] != t or fr[t] != None and fr[t] != s:
            return False
        to[s] = t
        fr[t] = s

    return True

print(["No","Yes"][solve()])

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

sorted_t = list(set(sorted(t)))

for i in sorted_t:
    check = 0
    temp = 'a'
    for j in range(len(t)):
        if t[j] == i:
            if check == 0:
                check = 1
                temp = s[j]
            elif s[j] != temp:
                print('No')
                exit()

sorted_s = list(set(sorted(s)))

for i in sorted_s:
    check = 0
    temp = 'a'
    for j in range(len(s)):
        if s[j] == i:
            if check == 0:
                check = 1
                temp = t[j]
            elif t[j] != temp:
                print('No')
                exit()

print('Yes')

Solution (Python):
S = input()
T = input()
k = {}
o = {}
res = "Yes"
for i in range(len(S)):
    if S[i] in k:
        if k[S[i]] != T[i]:
            res = "No"
            break
    else:
        k[S[i]] = T[i]
        
for i in range(len(T)):
    if T[i] in o:
        if o[T[i]] != S[i]:
            res = "No"
            break
    else:
        o[T[i]] = S[i]
    
print(res)

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):
def main():
    s, t = input(), input()

    used, dic = [0] * 512, {}
    for i in range(26):
        dic[chr(ord('a')+i)] = chr(ord('a')+i)

    for i, j in zip(s, t):
        if dic[i] == j:
            used[ord(i)] = 1
            continue

        for k, v in dic.items():
            if v == j:
                if used[ord(k)]:
                    print("No")
                    exit()
                dic[k] = i

        if used[ord(i)] and dic[i] != j:
            print("No")
            exit()

        dic[i], used[ord(i)] = j, 1

    print("Yes")


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
t = input()
ss = [s.find(i) for i in s]
tt = [t.find(i) for i in t]
if ss == tt:
    print("Yes")
else:
    print("No")

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

lens = len(S)
S = S
dic1,dic2 = {},{}

ch = 0
for i in range(lens):
    dic1[S[i]] = ''
    dic2[T[i]] = ''

for i in range(lens):
    if dic1[S[i]] == '' or dic1[S[i]] == T[i]:
        dic1[S[i]] = T[i]
    else:
        ch = 1
    if dic2[T[i]] == '' or dic2[T[i]] == S[i]:
        dic2[T[i]] = S[i]
    else:
        ch = 1

for k1 in dic1.keys():

    if dic2[dic1[k1]] != k1:
        ch = 1

if ch == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
if __name__ == '__main__':
    S = list(input())
    T = list(input())

    start = [-1 for i in range(26)]
    stop = [-1 for i in range(26)]

    fail = False
    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')

        if start[a] != -1 or stop[b] != -1:
            if start[a] != b or stop[b] != a:
                print('No')
                fail = True
                break
        else:
            start[a] = b
            stop[b] = a

    if not fail:
        print('Yes')

Solution (Python):


"""
自分の解答。これだとTLEになってしまったので、復習をします
from collections import Counter
S = str(input())
T = str(input())

for i in range(len(S)+1):
	s = str(S[i:i+1])
	t = str(T[i:i+1])
	S = S.replace(s,'A').replace(t,s).replace('A',t)

answer = 'No'

if S == T:
	answer = 'Yes'
	
print(answer)
"""

"""
対応表を作るイメージ。
azzel→appleにするのには
a a
z p
e i
l e
という変化を回せればおっけー


start = [-1]*26
goal = [-1]*26
print(start)

"""


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


from collections import defaultdict
s = defaultdict(int)
t = defaultdict(int)


for i in S:
	s[i] += 1

for j in T:
	t[j] += 1




ss = sorted(s.values())
tt = sorted(t.values())

if ss == tt:
	print('Yes')
else:
	print('No')

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

ss = collections.Counter(s)
tt = collections.Counter(t)

slist = []
tlist = []

for i in ss:
    slist.append(ss[i])
for i in tt:
    tlist.append(tt[i])

slist.sort()
tlist.sort()
check = False
if len(slist) == len(tlist):
    check = True
    for i in range(len(slist)):
        if slist[i] != tlist[i]:
            check= False
    

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

Solution (Python):
s = input()
t = input()
orz = False
for j in range(2):
  d = {}
  for i in range(len(s)):
    if s[i] in d and d[s[i]]!=t[i]:
      orz = True
      break
    d[s[i]] = t[i]
  s, t = t, s
print('No' if orz else 'Yes')

Solution (Python):
s=input()
t=input()
ans=''
a=[]
count=0
while ans=='' and count<100:
    for i,j in zip(s,t):
        if i!=j:
            if j in a:
                ans='No'
            s=s.replace(i,'.').replace(j,i).replace('.',j)
            a.append(j)
            break
    else:ans='Yes'
    count+=1
print(ans)

Solution (Python):
from collections import defaultdict as dd
f1,f2=True,True
s,t=input(),input()
ds,dt=dd(list),dd(list)

for i,c in enumerate(s):
  ds[c].append(i)
for i,c in enumerate(t):
  dt[c].append(i)

for i in ds.keys():
  if len({t[j] for j in ds[i]})!=1:f1=False
for i in dt.keys():
  if len({s[j] for j in dt[i]})!=1:f2=False

print("Yes" if f1 and f2 else "No")

Solution (Python):
from collections import Counter

S = input()
T = input()

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

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

Solution (Python):
import string

alphabet = string.ascii_lowercase

S = str(input())
T = str(input())
start = [-1 for i in range(len(alphabet))]
goal = [-1 for i in range(len(alphabet))]
tf = True

for i in range(len(S)):
    a = alphabet.index(S[i])
    b = alphabet.index(T[i])

    if (start[a] != -1 or goal[b] != -1):
        if (start[a] != b or goal[b] != a):
            tf = False
            break
    else:
        start[a] = b
        goal[b] = a

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

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

def uniq(s):
    '''Return the list obtained from s by removing repeating chars.'''
    appeared = set()
    for c in s:
        if c not in appeared:
            appeared.add(c)
            yield c

def normalized(s):
    dic = {c: i for i, c in enumerate(uniq(s))}
    return [dic[c] for c in s]

print("Yes" if normalized(S) == normalized(T) else "No")

Solution (Python):
s = input()
t = input()
flag1 = True
flag2 = True
s_dic = {}
t_dic = {}
for i, c in enumerate(s):
    if c not in s_dic.keys():
        s_dic[c] = []
    s_dic[c].append(i)
for i in s_dic.keys():
    l = []
    for ind in s_dic[i]:
        l.append(t[ind])
    if len(set(l)) != 1:
        flag1 = False

for i, c in enumerate(t):
    if c not in t_dic.keys():
        t_dic[c] = []
    t_dic[c].append(i)
for i in t_dic.keys():
    l = []
    for ind in t_dic[i]:
        l.append(s[ind])
    if len(set(l)) != 1:
        flag2 = False



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

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

s_shelv = [None for x in range(26)]
t_shelv = [None for x in range(26)]

a_z = list('abcdefghijklmnopqrstuvwxyz')


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

  if s_shelv[si] is None:
    s_shelv[si] = ti
  elif s_shelv[si] != ti:
    print('No')
    exit()

  if t_shelv[ti] is None:
    t_shelv[ti] = si
  elif t_shelv[ti] != si:
    print('No')
    exit()

print('Yes')

Solution (Python):

S = input()
T = input()

s_set = set(S)
t_set = set(T)

st_set = set(zip(S, T))

if len(s_set) == len(t_set) == len(st_set): print("Yes")
else: print("No")

Solution (Python):

S = [ord(c)-ord('a') for c in input()]
T = [ord(c)-ord('a') for c in input()]

def check():
    R = [[-1] * 26 for _ in range(2)]

    for i in range(len(S)):
        if R[0][S[i]] < 0:
            R[0][S[i]] = T[i]
        elif R[0][S[i]] != T[i]:
            return False
        
        if R[1][T[i]] < 0:
            R[1][T[i]] = S[i]
        elif R[1][T[i]] != S[i]:
            return False
    
    return True

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

Solution (Python):
S = input()
T = input()
S_dic = [0 for _ in range(26)]
T_dic = [0 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] == 0:
        S_dic[si] = ti
    elif S_dic[si] != ti:
        print("No")
        exit()

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

print("Yes")

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    t = S()
    l = len(s)
    d = collections.defaultdict(lambda: None)
    e = collections.defaultdict(lambda: None)
    for i in range(l):
        si = s[i]
        ti = t[i]
        if not d[si] is None:
            if ti != d[si]:
                return 'No'
        if not e[ti] is None:
            if si != e[ti]:
                return 'No'
        d[si] = ti
        e[ti] = si

    return 'Yes'


print(main())

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

dic_s = {}
dic_t = {}
re = 'Yes'
for i in range(len(S)):
    s = S[i]
    t = T[i]

    if s in dic_s:
        if dic_s[s] != t:
            re = 'No'
            break
    else:
        dic_s[s] = t
        
    if t in dic_t:
        if dic_t[t] != s:
            re = 'No'
            break
    else:
        dic_t[t] = s

        
print(re)

Solution (Python):
def main():
  S = [s for s in input()]
  T = [s for s in input()]
  R1 = [-1 for i in range(26)]
  R2 = [-1 for i in range(26)]
  for i in range(len(S)):
    a = ord(S[i]) % 26
    b = ord(T[i]) % 26
    if(R1[a] != -1 or R2[b] != -1):
      if(R1[a] != b or R2[b] != a):
        print("No")
        return
    else:
      R1[a]=b
      R2[b]=a
  print("Yes")
  return

main()

Solution (Python):


def main():
    s = input()
    t = input()
    abc_list = [chr(i) for i in range(ord('a'), ord('a')+26)]
    trans_dict = {}
    for abc in abc_list:
        trans_dict[abc] = ''
    for i in range(len(s)):
        if trans_dict[s[i]] == '':
            trans_dict[s[i]] = t[i]
        elif trans_dict[s[i]] != t[i]:
            print('No')
            return
    arry = [item for item in trans_dict.values() if item is not '']
    if len(arry) != len(set(arry)):
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()

Solution (Python):
S = input()
T = input()
l = len(S)
s,t = [], []
for i in "abcdefghijklmnopqrstuvwxyz":
  tmps,tmpt = [], []
  for j in range(l):
    if S[j] == i:
      tmps.append(j)
    if T[j] == i:
      tmpt.append(j)
  s.append(tmps)
  t.append(tmpt)
s.sort()
t.sort()
if s == t:
 print("Yes")
else:
 print("No")

Solution (Python):




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

Sdic = [0 for _ in range(26)]
Tdic = [0 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"]

Able = True

for i in range(len(S)):
    si = S[i]
    ti = T[i]
    if Sdic[alphabet.index(si)] == 0:
        Sdic[alphabet.index(si)] = ti
    elif Sdic[alphabet.index(si)] != ti:
        Able = False
        break
    if Tdic[alphabet.index(ti)] == 0:
        Tdic[alphabet.index(ti)] = si
    elif Tdic[alphabet.index(ti)] != si:
        Able = False
        break
        
print("Yes" if Able else "No")

Solution (Python):

import unittest


def func(s,t):
    n = len(s)
    for c in set(s):
        d = None
        for i in range(n):
            if s[i]==c:
                if d is None:
                    d = t[i]
                elif d!=t[i]:
                    return "No"
    for c in set(t):
        d = None
        for i in range(n):
            if t[i]==c:
                if d is None:
                    d = s[i]
                elif d!=s[i]:
                    return "No"
    return "Yes"

class Test(unittest.TestCase):
    def test(self):
        self.assertEqual(func("azzel", "apple"), "Yes")
        self.assertEqual(func("chokudai", "redcoder"), "No")
        self.assertEqual(func("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu"), "Yes")
        self.assertEqual(func("abc", "abc"), "Yes")

if __name__ == '__main__':
    s = input()
    t = input()
    
    print(func(s,t))