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

R = {chr(i) : -1 for i in range(97, 97 + 26)}
Rd = {chr(i) : -1 for i in range(97, 97 + 26)}

def check(i):
  ret = True
  if R[S[i]] >= 0 and R[S[i]] != ord(T[i]):
    ret = False
  if Rd[T[i]] >= 0 and Rd[T[i]] != ord(S[i]):
    ret = False
  if R[S[i]] < 0:
    R[S[i]] = ord(T[i])
  if Rd[T[i]] < 0:
    Rd[T[i]] = ord(S[i])
  return ret

ans = "Yes"
for i in range(len(S)):
  if not check(i):
    ans = "No"
    break
print(ans)

Solution (Python):
s=input()
t=input()
l=[]
m=[]
for i in range(len(s)):
    l.append(s[i])
    m.append(t[i])
l.sort()
m.sort()
li=[1]
mi=[1]
i=1
while i<len(s):
    if l[i]==l[i-1]:
        li[-1]+=1
    else:
        li.append(1)
    if m[i]==m[i-1]:
        mi[-1]+=1
    else:
        mi.append(1)
    i+=1
li.sort()
mi.sort()
print("Yes" if li==mi else "No")

Solution (Python):
def solve(string):
    s, t = string.split()

    c_s = sorted([s.count(_c) for _c in set(s)])
    c_t = sorted([t.count(_c) for _c in set(t)])

    if c_s == c_t:
        return "Yes"
    else:
        return "No"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
def check(S, T):
    n = len(S)
    m = {}
    d = {}
    for i in range(n):
        s = S[i]
        t = T[i]
        if t not in d:
            d[t] = s
        if d[t] != s:
            return False
        if s not in m:
            m[s] = t
        if m[s] != t:
            return False
    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().rstrip()
T = input().rstrip()

dic_s = {}
dic_t = {}

for i in range(len(S)):
    if not S[i] in dic_s.keys():
        dic_s[S[i]] = T[i]
    if not T[i] in dic_t.keys():
        dic_t[T[i]] = S[i]
    if dic_s[S[i]] != T[i] or dic_t[T[i]] != S[i]:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
S=input()
T=input()
al=[chr(ord('a')+i) for i in range(26)]
sameS=[]
sameT=[]

for k in al:
    indexes=[i for i, x in enumerate(S) if x==k]
    sameS.append(indexes)

for k in al:
    indexes=[i for i, x in enumerate(T) if x==k]
    sameT.append(indexes)

if all([x in sameS for x in sameT]) and all([x in sameT for x in sameS]):
    print('Yes')
else:
    print('No')

Solution (Python):
S=input()
T=input()
al=[chr(ord('a')+i) for i in range(26)]
sameS=[]
sameT=[]
 
for k in al:
    indexes=[i for i, x in enumerate(S) if x==k]
    sameS.append(indexes)
 
for k in al:
    indexes=[i for i, x in enumerate(T) if x==k]
    sameT.append(indexes)
 
if all([x in sameS for x in sameT]) and all([x in sameT for x in sameS]):
    print('Yes')
else:
    print('No')

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

def f():
  dicS, dicT = {}, {}
  for i in range(len(S)):
    if dicS.get(S[i], '') == '':
      dicS[S[i]] = T[i]
    else:
      if dicS[S[i]] != T[i]:
        return 'No'
    if dicT.get(T[i], '') == '':
      dicT[T[i]] = S[i]
    else:
      if dicT[T[i]] != S[i]:
        return 'No'
  return 'Yes'
print(f())

Solution (Python):
s = input()
t = input()
f = ""
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = t[i]
    f += d[s[i]]
if f == t and len(d.values()) == len(set(d.values())):
    print("Yes")
else:
    print("No")

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

start = [-1] * 26
goal = [-1] * 26
flag = True
length = len(s)
dict = { chr(97 + i):i for i in range(26) }
for i in range(0, length):
	a = dict[s[i]]
	b = dict[t[i]]

	if start[a] != -1 or goal[b] != -1:
		if start[a] != b or goal[b] != a:
			flag = False
			break
	else:
		start[a] = b;
		goal[b] = a;
if flag:
	print("Yes")
else:
	print("No")

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

count_s = dict(zip([chr(i) for i in range(97, 97+26)], [0]*26))
count_t = dict(zip([chr(i) for i in range(97, 97+26)], [0]*26))
for ss, tt in zip(s, t):
    count_s[ss] += 1
    count_t[tt] += 1
v_s = sorted(count_s.values())
v_t = sorted(count_t.values())

ans = 'Yes' if v_s == v_t else 'No'
print(ans)

Solution (Python):
from collections import Counter as C
s=list(input())
t=list(input())
print('YNeos'[C(C(s).values())!=C(C(t).values())::2])

Solution (Python):
s = list(input())
t = list(input())
n = len(s)
sl = [0] * n
tl = [0] * n
sd = {}
td = {}
for i in range(n):
    c = s[i]
    if c not in sd:
        sd[c] = i
        sl[i] = i
    else:
        sl[i] = sd[c]
for i in range(n):
    c = t[i]
    if c not in td:
        td[c] = i
        tl[i] = i
    else:
        tl[i] = td[c]
if sl == tl:
    print('Yes')
else:
    print('No')

Solution (Python):
s,t = input(),input()
def g(s,t):
    for j in range(len(s)):
        if len(s) == len(t):
            S = [i for i in s if i != s[0]]
            T = [i for i in t if i != t[0]]
            s = S
            t = T
        else:
            return 'No'
    return 'Yes'
print(g(s,t))

Solution (Python):



















from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

s = input()
t = input()

s_dic = dict()
t_dic = dict()

flag = True
for i in range(len(s)):
    s_i = s[i]
    t_i = t[i]
    if s_i not in s_dic:
        s_dic[s_i] = t_i
    else:
        if s_dic[s_i] != t_i:
            flag = False
    if t_i not in t_dic:
        t_dic[t_i] = s_i
    else:
        if t_dic[t_i] != s_i:
            flag = False

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

Solution (Python):
s = input()
t = input()
s_list = []
t_list = []

for i in range(26):
    s_list.append(s.count(chr(97+i)))
    t_list.append(t.count(chr(97+i)))

s_list.sort()
t_list.sort()
true = 0
for i in range(26):
    if s_list[i] != t_list[i]:
        print('No')
        break
    else:
        true += 1
if true == 26:
    print('Yes')

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

Solution (Python):
S, T = input(), input()
cnt1, cnt2, r1, r2 =[], [], [], []
for c in S:
    if not c in r1:
        cnt1.append(S.count(c))
        r1.append(c)
for c in T:
    if not c in r2:
        cnt2.append(T.count(c))
        r2.append(c)


if cnt1 == cnt2:
    print('Yes')
else:
    print('No')

Solution (Python):
S, T = input(), input()
cnt1, cnt2, r1, r2 =[], [], [], []
for c in S:
    if not c in r1:
        cnt1.append(S.count(c))
        r1.append(c)
for c in T:
    if not c in r2:
        cnt2.append(T.count(c))
        r2.append(c)
cnt1.sort()
cnt2.sort()
if cnt1 == cnt2:
    print('Yes')
else:
    print('No')

Solution (Python):
S, T = input(), input()
cnt1, cnt2, r1, r2 =[], [], [], []
for c in S:
    if not c in r1:
        cnt1.append(S.count(c))
        r1.append(c)
for c in T:
    if not c in r2:
        cnt2.append(T.count(c))
        r2.append(c)
cnt1.sort()
cnt2.sort()
if cnt1 == cnt2:
    print('Yes')
else:
    print('No')

Solution (Python):
dict={
  'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25,
}
l1=['']*26
l2=['']*26
s1=input()
s2=input()
f=0
for i in range(len(s1)):
  a=s1[i]
  b=s2[i]
  ind=dict[a]
  if l1[ind]=='':
    l1[ind]=b
  else:
    if l1[ind]!=b:
      f=1
      break
  ind=dict[b]
  if l2[ind]=='':
    l2[ind]=a
  else:
    if l2[ind]!=a:
      f=1
      break
if f==1:
  print('No')
else:
  print('Yes')

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

sc = ["" for i in range(0, 26)]
tc = ["" for i in range(0, 26)]
scf = False
tcf = False
for i in range(0, len(s)):
    sci = sc[ord(s[i]) - ord('a')]
    if sci != "" and t[i] != sci:
        print("No")
        scf = True
        break
    else:
        sc[ord(s[i]) - ord('a')] = t[i]

if not scf:
    for i in range(0, len(t)):
        tci = tc[ord(t[i]) - ord('a')]
        if tci != "" and s[i] != tci:
            print("No")
            tcf = True
            break
        else:
            tc[ord(t[i]) - ord('a')] = s[i]
    if not tcf:
        print("Yes")

Solution (Python):
str1 = input()
str2 = input()

n = len(str1)
d1 = dict()
d2 = dict()
for i in range(26):
    d1[chr(97+i)] = ''
    d2[chr(97+i)] = ''
res = "Yes"
for i in range(n):
    if d1[str1[i]] != '' and d1[str1[i]]!=str2[i]:
        res = "No"
        break
    if d2[str2[i]] != '' and d2[str2[i]]!=str1[i]:
        res = "No"
        break
    if d1[str1[i]] == '':
        d1[str1[i]] = str2[i]
    if d2[str2[i]] == '':
        d2[str2[i]] = str1[i]
print(res)

Solution (Python):
import collections as cl
s=input()
t=input()
s_count=cl.Counter(s)
t_count=cl.Counter(t)
a=sorted(s_count.values())
b=sorted(t_count.values())
if a==b:
    print('Yes')
else:
    print('No')

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

st = {}
tset = set()
out = 'Yes'
for _s, _t in zip(s, t):
  if _s in st:
    if st[_s] != _t:
      out = 'No'
      break
  elif _t in tset:
    out = 'No'
    break
  else:
    st[_s] = _t
    tset.add(_t)
print(out)

Solution (Python):


S = input()
T = input()


def to_dict(s):
    dic = {}
    for c in list(s):
        if c in dic:
            dic[c] += 1
        else:
            dic[c] = 1

    return sorted(list(dic.values()))


sl = to_dict(S)
tl = to_dict(T)

if to_dict(S) == to_dict(T):
    print("Yes")
else:
    print("No")

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

def judge(s1, s2):
    d = {}
    for i,c in enumerate(s1):
        if c not in d:
            d[c] = [i]
        else:
            d[c].append(i)
    for v in d.values():
        a = v[0]
        for b in v:
            if s2[a]!=s2[b]:
                return 0
            a = b
    return 1

if judge(S,T)*judge(T,S) == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
s=(input())
t=(input())
a=[chr(ord("a")+i)for i in range(26)]
b=[chr(ord("a")+i)for i in range(26)]
for i in range(0,len(s)):
    p=ord(s[i])-ord("a")
    q=ord(t[i])-ord("a")
    if len(a[p])==1:
        a[p]=t[i]+"1"
    else:
        if a[p]!=t[i]+"1":
            print("No")
            break
    if len(b[q])==1:
        b[q]=s[i]+"1"
    else:
        if b[q]!=s[i]+"1":
            print("No")
            break
else:
    print("Yes")

Solution (Python):
A = list(input())
B = list(input())
dicB = {}
dicA = {}
for i in range(len(A)):
    dicB.setdefault(B[i], A[i])
    dicA.setdefault(A[i], B[i])
    if dicB.get(B[i]) != A[i] or dicA.get(A[i]) != B[i]:
        print("No")
        exit()
print("Yes")

Solution (Python):
from collections import defaultdict
str_s = input()
str_t = input()


def check_pattern(str):
    checkdict = defaultdict(int)
    pattern = list()
    for w in str:
        if w not in checkdict:
            checkdict[w] = len(checkdict) + 1

        pattern.append(checkdict[w])
    return pattern


if check_pattern(str_s) == check_pattern(str_t):
    print("Yes")
else:
    print("No")

Solution (Python):
import collections as col

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

c1 = col.Counter(s)
c2 = col.Counter(t)

cv1 = sorted(c1.values())
cv2 = sorted(c2.values())

if cv1 == cv2:
    print('Yes')
else:
    print('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):
s = str(input())
t = str(input())

import collections
s_count = collections.Counter(s)
t_count = collections.Counter(t)

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

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

for i in s:
    if i not in letter_list:
        letter_list.append(i)
        id_list.append(len(set(id_list)) + 1)
    else:
        id_list.append(letter_list.index(i) + 1)
        
        
letter_list = list()
id_list2 = list()

for i in t:
    if i not in letter_list:
        letter_list.append(i)
        id_list2.append(len(set(id_list2)) + 1)
    else:
        id_list2.append(letter_list.index(i) + 1)
        
if id_list == id_list2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
T = input()
st = {}
ts = {}
for s, t in zip(S, T):
    if s in st and st[s] != t:
        print("No")
        exit()
    if t in ts and ts[t] != s:
        print("No")
        exit()
    st[s] = t
    ts[t] = s
print("Yes")

Solution (Python):
s, t = input(), input()
f = [-1] * 27
can = True
count = 0
for i in range(len(s)):
    if f[ord(s[i])-ord("a")] == -1:
        f[ord(s[i])-ord("a")] = ord(t[i]) - ord("a")
        count += 1
    elif f[ord(s[i])-ord("a")] == ord(t[i]) - ord("a"):
        continue
    else:
        can = False
        break
if len(set(f)) != count+1:
    can = False
if can:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter as C
print(["No", "Yes"][C(C(input()).values()) == C(C(input()).values())])

Solution (Python):
s=input()
t=input()
 
listA=[s.count(chr(i)) for i in range(ord('a'),ord('z')+1)]
listB=[t.count(chr(i)) for i in range(ord('a'),ord('z')+1)]

listA.sort()
listB.sort()

print('Yes' if listA==listB else 'No')

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


listA=[s.count(chr(i)) for i in range(97,122+1)]
listB=[t.count(chr(i)) for i in range(97,122+1)]



listA.sort()
listB.sort()



print('Yes' if listA==listB else 'No')

Solution (Python):
import sys
 
def main():
  input = sys.stdin.readline
  S = str(input().strip())
  T = str(input().strip())
  
  C1, C2 = [], []
  ans = 'Yes'
  S2T = dict()
  T2S = dict()
  for c1, c2 in zip(S, T):
    if (c1 in S2T) and (c2 in T2S):
      if not((S2T[c1] == c2) and (T2S[c2] == c1)):
        ans = 'No'
        break
    elif (c1 not in S2T) and (c2 not in T2S):
      S2T[c1] = c2
      T2S[c2] = c1
    else:
      ans = 'No'
      break
  print(ans)
 
 
if __name__ == '__main__':
  main()

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  S = str(input().strip())
  T = str(input().strip())
  
  C1, C2 = [], []
  ans = 'Yes'
  S2T = dict()
  T2S = dict()
  for c1, c2 in zip(S, T):
    if (c1 in S2T) and (c2 in T2S):
      if (S2T[c1] == c2) and (T2S[c2] == c1):
        continue
      else:
        ans = 'No'
        break
    elif (c1 in S2T):
      if S2T[c1] == c2:
        T2S[c2] = c1
        continue
      else:
        ans = 'No'
        break
    elif (c2 in T2S):
      if T2S[c2] == c1:
        S2T[c1] == c2
        continue
      else:
        ans = 'No'
        break
    else:
      S2T[c1] = c2
      T2S[c2] = c1
  print(ans)


if __name__ == '__main__':
  main()

Solution (Python):

S=input()
T=input()

d={}

for i in range(len(S)):
    if S[i] not in d:
        d[S[i]]=T[i] 
    else:
      
        if d[S[i]]!=T[i]:
            print('No')
            exit()
d={}
for i in range(len(T)):
    if T[i] not in d:
        d[T[i]]=S[i]
    else:
        if d[T[i]]!=S[i]:
            print('No')
            exit()
print('Yes')

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

def combocount(st):
    res = []
    count = 0
    tmp = {}
    for c in st:
        
        if c in tmp:
            res.append(tmp[c])
        
        else:
            tmp[c] = count
            res.append(count)
            count += 1
    return res


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

Solution (Python):
S = input()
T = input()
s, t = [], []
for alp in "abcdefghijklmnopqrstuvwxyz":
  s.append(S.count(alp))
  t.append(T.count(alp))
if(sorted(s) == sorted(t)):
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()
T = input()
    
dt = {}
ds = {}
for s, t in zip(S,T):
    if not t in dt:
        dt[t] = s
    else:
        if dt[t] != s:
            print('No')
            quit()

    if not s in ds:
        ds[s] = t
    else:
        if ds[s] != t:
            print('No')
            quit()
print('Yes')

Solution (Python):
def char_range(c1, c2):
    """
    Generates the characters from `c1` to `c2`, inclusive.
    Taken from: https://stackoverflow.com/questions/7001144/range-over-character-in-python
    """
    for c in range(ord(c1), ord(c2)+1):
        yield chr(c)

class Solver(object):
    def __init__(self):
        self.s = input()
        self.t = input()

    def solve(self):
        self.s_to_t = {}
        self.t_to_s = {}
        for c in char_range('a', 'z'):
            self.s_to_t[c] = None
            self.t_to_s[c] = None
        
        for i in range(len(self.s)):
            cs = self.s[i]
            ct = self.t[i]
            if self.s_to_t[cs] is None:
                self.s_to_t[cs] = ct
            if self.t_to_s[ct] is None:
                self.t_to_s[ct] = cs
            if self.s_to_t[cs] != ct:
                print("No")
                return
            if self.t_to_s[ct] != cs:
                print("No")
                return
        print("Yes")


if __name__ == "__main__":
    s = Solver()
    s.solve()

Solution (Python):
a = input()
b = input()
k = []
l = []
np=0
nq=0
for i in range(0,len(a)):
    if a[i] not in k:
        k.append(a[i])
        np+=1
    if b[i] not in l:
        l.append(b[i])
        nq+=1
    if i != 0:
        if not (k.index(a[i])==l.index(b[i]) and ((a[i-1]==a[i] and b[i-1] == b[i]) or ( a[i-1] != a[i] and b[i-1]!= b[i]))):
            np*=0
if np == nq:
    print("Yes")
else:
    print("No")

Solution (Python):
S=input()
T=input()
d={}
for i in range(len(S)):
    if S[i] not in d:
        d[S[i]]=T[i]
    else:
        if d[S[i]]!=T[i]:
            print('No')
            exit()
d={}
for i in range(len(T)):
    if T[i] not in d:
        d[T[i]]=S[i]
    else:
        if d[T[i]]!=S[i]:
            print('No')
            exit()
print('Yes')

Solution (Python):
def judge(S,T):
    d={}
    length=len(S)
    for i in range(length):
        if S[i] not in d:
            d[S[i]]=T[i]
        else:
            if d[S[i]]!=T[i]:
                return "No"
    d={}          
    for i in range(length):
        if T[i] not in d:
            d[T[i]]=S[i]
        else:
            if d[T[i]]!=S[i]:
                return "No"
    return "Yes"
  
print(judge(input(),input()))

Solution (Python):
s = input()
t = input()
sl = []
tl = []
for c in "abcdefghijklmnopqrstuvwxyz":
    sl.append(s.count(c))
    tl.append(t.count(c))
if sorted(sl)==sorted(tl):
    print("Yes")
else:
    print("No")

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

from collections import defaultdict

td = defaultdict(set)
sd = defaultdict(set)
for i in range(len(s)):
        td[t[i]].add(s[i])
        sd[s[i]].add(t[i])

for tv, sv in zip(td.values(), sd.values()):
    if (len(tv) > 1) or (len(sv) > 1):
        print("No")
        break
else:
    print('Yes')

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

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

sv = []
tv = []
for v in cs.values():
    sv.append(v)
for v in ct.values():
    tv.append(v)
    
sv.sort()
tv.sort()
if len(sv) == len(tv):
    for i in range(len(sv)):
        if sv[i] != tv[i]:
            print('No')
            exit()
    else:
        print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()
tra = {}
f = True
for i in range(len(s)):
    if s[i] in tra.keys():
        if tra[s[i]] != t[i]:
            f = False
            break
    else:
        if t[i] in tra.values():
            f = False
            break
        else:
            tra[s[i]] = t[i]
print("Yes" if f == True else "No")

Solution (Python):
import sys

s = input()
t = input()




for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        s_tmp = s
        s = s.translate(s.maketrans({s[i]:t[i], t[i]:s[i]}))
        if s_tmp[:i] != s[:i]:
            print("No")
            sys.exit()
        else:
            pass


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

Solution (Python):

S = input()
T = input()
n = len(T)
from collections import defaultdict

diff = {}
diff2 = {}
same = set()
for i in range(n):
    if S[i] != T[i]:
        diff[S[i]] = T[i]
        diff2[T[i]] = S[i]
    else:
        same.add(S[i])

for i in range(n):
    if S[i] in diff and diff[S[i]] != T[i]:
        print("No")
        exit(0)
    elif T[i] in diff2 and diff2[T[i]] != S[i]: 
        print("No")
        exit(0)


print("Yes")
exit(0)

Solution (Python):

S = input()
T = input()
n = len(T)
from collections import defaultdict

diff_s_to_t = {}
diff_t_to_s = {}
same = set()

for i in range(n):
    if S[i] == T[i]:
        same.add(S[i])

for i in range(n):
    if S[i] != T[i] and not S[i] in diff_s_to_t:
        diff_s_to_t[S[i]] = T[i]
        diff_t_to_s[T[i]] = S[i] 

for i in range(n):
    if S[i] != T[i] and  S[i] in diff_s_to_t:
        if diff_s_to_t[S[i]] != T[i]: 
            print("No")
            exit(0)


for i in range(n):
    if S[i]==T[i] and S[i] in diff_t_to_s: 
        print("No")
        exit(0)

S,T = T,S
diff_s_to_t = {}
diff_t_to_s = {}
same = set()
for i in range(n):
    if S[i] == T[i]:
        same.add(S[i])

for i in range(n):
    if S[i] != T[i] and not S[i] in diff_s_to_t:
        diff_s_to_t[S[i]] = T[i]
        diff_t_to_s[T[i]] = S[i] 

for i in range(n):
    if S[i] != T[i] and  S[i] in diff_s_to_t:
        if diff_s_to_t[S[i]] != T[i]: 
            print("No")
            exit(0)


for i in range(n):
    if S[i]==T[i] and S[i] in diff_t_to_s: 
        print("No")
        exit(0)


print("Yes")
exit(0)

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):
S = input()
T = input()
s, t = [], []
for alp in "abcdefghijklmnopqrstuvwxyz":
  s.append(S.count(alp))
  t.append(T.count(alp))
if(sorted(s) == sorted(t)):
  print("Yes")
else:
  print("No")

Solution (Python):
def func():
    pass


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

    s_s = set(s)
    t_s = set(t)

    s_c = list()
    t_c = list()

    for si in s_s:
        s_c.append(s.count(si))

    for ti in t_s:
        t_c.append(t.count(ti))

    
    
    if sorted(s_c) == sorted(t_c):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
t = input()
counts = []
countt = []
alphabetlist = ["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 alphabetlist:
    counts.append(s.count(i))
    countt.append(t.count(i))
if sorted(counts) == sorted(countt):
    print("Yes")
else:
    print("No")

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

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

S.sort()
T.sort()
Sdata = []
Tdata = []

counter = 0
p = S[0]
for i in S:
    if i == p:
        counter += 1
    else:
        Sdata.append(counter)
        counter = 1
        p = i
Sdata.append(counter)

counter = 0
p = T[0]
for i in T:
    if i == p:
        counter += 1
    else:
        Tdata.append(counter)
        counter = 1
        p = i
Tdata.append(counter)

Sdata.sort()
Tdata.sort()

if Sdata == Tdata:
    print 'Yes'
else:
    print 'No'

Solution (Python):
S = input()
T = input()
s = []
t = []
for alp in "abcdefghijklmnopqrstuvwxyz":
  s.append(S.count(alp))
  t.append(T.count(alp))
if(sorted(s) == sorted(t)):
  print("Yes")
else:
  print("No")

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

mapping = {}
for i in range(len(s)):
    if s[i] in mapping:
        if mapping[s[i]] == t[i]:
            continue
        else:
            print('No')
            break
    elif t[i] in mapping.values():
        print('No')
        break
    else:
        mapping[s[i]] = t[i]
else:
    print('Yes')

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

d = {}
flag = True
for i in range(len(s)):
    if s[i] in d.keys():
        if t[i] == d[s[i]]:
            continue
        else:
            flag=False
            break
    elif t[i] in d.values():
        if d.get(s[i]) == t[i]:
            continue
        else:
            flag=False
            break
    else:
        d[s[i]] = t[i]

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

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

s2t = {}
t2s = {}
ans = 'Yes'
for si, ti in zip(s, t):
    if si not in s2t:
        s2t[si] = ti
    elif s2t[si] != ti:
        ans = 'No'
        break
    if ti not in t2s:
        t2s[ti] = si
    elif t2s[ti] != si:
        ans = 'No'
        break

print(ans)

Solution (Python):
S = list(input())
T = list(input())
L = []
M = []
al = list('abcdefghijklmnopqrstuvwxyz')

for i in range(len(al)):
    l = []
    for j in range(len(S)):
        if al[i] == S[j]:
            l.append(j)
        else:
            pass
    L.append(l)
i = 0
for i in range(len(al)):
    l = []
    for j in range(len(T)):
        if al[i] == T[j]:
            l.append(j)
        else:
            pass
    M.append(l)
if sorted(L)==sorted(M):
    print("Yes")
else:
    print("No")

Solution (Python):
S = list(input())
T = list(input())
L = []
M = []
al = list('abcdefghijklmnopqrstuvwxyz')

for i in range(len(al)):
    l = []
    for j in range(len(S)):
        if al[i] == S[j]:
            l.append(j)
        else:
            pass
    L.append(l)
i = 0
for i in range(len(al)):
    l = []
    for j in range(len(T)):
        if al[i] == T[j]:
            l.append(j)
        else:
            pass
    M.append(l)
if sorted(L)==sorted(M):
    print("Yes")
else:
    print("No")

Solution (Python):
import collections
S = input()
L = []
M = []
c = collections.Counter(S)
for x in c.items():
    L.append(x[1])
T = input()
c = collections.Counter(T)
for x in c.items():
    M.append(x[1])
if sorted(M) == sorted(L):
    print("Yes")
else:
    print("No")

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

R={}
R_={}

for a in zip(S,T):
  if a[0] not in R:
    R[a[0]]=a[1]
  else:
    if R[a[0]]!=a[1]:
      print('No')
      break
      
  if a[1] not in R_:
    R_[a[1]]=a[0]
  else:
    if R_[a[1]]!=a[0]:
      print('No')
      break
      
else:
  print('Yes')

Solution (Python):
S=input()
T=input()
l=len(S)
Rs=[0]*26
Rt=[0]*26
for i in range(l):
    Rs[ord(S[i])-ord('a')]+=1
    Rt[ord(T[i])-ord('a')]+=1
Rs.sort()
Rt.sort()
if Rs==Rt:
    print('Yes')
else:
    print('No')

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


def check(A, B):
    alphabets = "abcdefghijklmnopqrstuvwxyz"
    d = {c: None for c in alphabets}
    for i in range(len(A)):
        if d[A[i]] is None:
            d[A[i]] = B[i]
        elif d[A[i]] != B[i]:
            return False
    return True


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

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


def check(A, B):
    alphabets = "abcdefghijklmnopqrstuvwxyz"
    d = {c: None for c in alphabets}
    for i in range(len(A)):
        if d[A[i]] is None:
            d[A[i]] = B[i]
        elif d[A[i]] != B[i]:
            return False
    return True


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

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

command = [S, T]
spel = [[], []]
counter = [[], []]

for i in range(2):
    for j in range(len(S)):
        if command[i][j] in spel[i]:
            counter[i][spel[i].index(command[i][j])].append(j)

        else:
            spel[i].append(command[i][j])
            counter[i].append([j])

print('Yes' if counter[0] == counter[1] else 'No')

Solution (Python):

def db(x): 
    global debug
    if debug: print(x)
debug = False
def swap(fromStr, toStr, nth):
    db((fromStr,toStr,nth))
    fromChar = fromStr[nth]
    toChar = toStr[nth]
    toStr = toStr.replace(fromChar,'
    db(toStr)
    toStr = toStr.replace(toChar,fromChar)
    db(toStr)
    toStr =  toStr.replace('
    db(toStr)
    return toStr
S = input()
T = input()
db((S,T))
used = []
for i in range(len(S)):
    if S[i] in used: 
        continue
    else:
        used.append(S[i])
        if S[i]==T[i]: continue
        T = swap(S, T, i)
if S==T: print('Yes')
else: print('No')
db((S,T,used))

Solution (Python):
S = sorted(input())
T = sorted(input())
S_list = []
T_list = []
for alp in "abcdefghijklmnopqrstuvwxyz":
  S_list.append(S.count(alp))
  T_list.append(T.count(alp))
if(sorted(S_list) != sorted(T_list)):
  print('No')
else:
  print('Yes')

Solution (Python):
a = int('a', 36)
S = list(input())
T = list(input())

s_index = [[] for i in range(28)]
t_index = [[] for i in range(28)]

for i in range(len(S)):
  s_index[int(S[i], 36) - a].append(i)
  t_index[int(T[i], 36) - a].append(i)

s_index = sorted(s_index)
t_index = sorted(t_index)

if s_index == t_index:
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()
T = input()
N = len(S)
num_swap = 0
for i in range(N):
    if num_swap > 24:
        print('No')
        break
    if S[i] != T[i]:
        s, t = S[i], T[i]
        S = S.replace(s, '0').replace(t, s).replace('0', t)
        num_swap += 1
else:
    if S == T:
        print('Yes')
    else:
        print('No')

Solution (Python):
S = input()
T = input()
N = len(S)
num_swap = 0
for i in range(N):
    if num_swap > 24:
        print('No')
        break
    if S[i] != T[i]:
        s, t = S[i], T[i]
        S = S.replace(s, '0')
        S = S.replace(t, s)
        S = S.replace('0', t)
        num_swap += 1
else:
    if S == T:
        print('Yes')
    else:
        print('No')

Solution (Python):
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    s = input()
    t = input()
    l_s = list(s)
    l_t = list(t)
    str_key = {}
    str_key_t = {}
    for i,moji in enumerate(s):
        if not moji in str_key:
            str_key[moji] = t[i]
        l_s[i] = str_key[moji]
    for i,moji in enumerate(t):
        if not moji in str_key_t:
            str_key_t[moji] = s[i]
        l_t[i] = str_key_t[moji]
    if "".join(l_s) == t and "".join(l_t) == s:
        print('Yes')
    else:
        print('No')

Solution (Python):


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

    ct = [-1] * 26
    dt = [-1] * 26

    oa = ord('a')
    f = True
    for i in range(len(S)):
        c1 = S[i]
        c2 = T[i]
        j1 = ord(c1) - oa
        j2 = ord(c2) - oa
        if ct[j1] == -1:
            if dt[j2] == -1:
                ct[j1] = j2
                dt[j2] = j1
            else:
                f = False
                break
        elif ct[j1] != j2:
            f = False
            break


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


if __name__ == '__main__':
    main()