Problem:
 Score : 300 points    Problem Statement You are given strings S and T consisting of lowercase English letters.  You can perform the following operation on S any number of times:  Operation: Choose two distinct lowercase English letters c_1 and c_2 , then replace every occurrence of c_1 with c_2 , and every occurrence of c_2 with c_1 .  Determine if S and T can be made equal by performing the operation zero or more times.      Constraints  1 \leq |S| \leq 2 \times 10^5  |S| = |T|  S and T consists of lowercase English letters.         Input Input is given from Standard Input in the following format:  S  T       Output If S and T can be made equal, print Yes ; otherwise, print No .        Sample Input 1 azzel
apple      Sample Output 1 Yes  azzel can be changed to apple , as follows:   Choose e as c_1 and l as c_2 . azzel becomes azzle .  Choose z as c_1 and p as c_2 . azzle becomes apple .        Sample Input 2 chokudai
redcoder      Sample Output 2 No  No sequences of operation can change chokudai to redcoder .       Sample Input 3 abcdefghijklmnopqrstuvwxyz
ibyhqfrekavclxjstdwgpzmonu      Sample Output 3 Yes

Solution (Python):
from fractions import gcd
from collections import defaultdict as dd
from collections import Counter as C
a = input()
b = input()
a = sorted(a)
b = sorted(b)
a = C(a)
b = C(b)
p,q = [],[]
for k in dict(a):
    p.append(a[k])
for k in dict(b):
    q.append(b[k])
p = sorted(p)
q = sorted(q)
if p==q:
    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):
def main():
    s = input()
    t = input()

    dt = dict()
    ds = dict()
    for i in range(len(s)):
        if t[i] not in dt:
            dt[t[i]] = s[i]
        else:
            if dt[t[i]] != s[i]:
                print("No")
                return

        if s[i] not in ds:
            ds[s[i]] = t[i]
        else:
            if ds[s[i]] != t[i]:
                print("No")
                return

    print("Yes")

if __name__ == "__main__":
    main()

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

out_str = "Yes"

indexes_s_all = []
indexes_t_all = []
for i in range(26) :
	c = chr(ord('a') + i)
	indexes_s = [n for n, x in enumerate(list(S)) if x == c]
	indexes_t = [n for n, x in enumerate(list(T)) if x == c]
	indexes_s_all.append(indexes_s)
	indexes_t_all.append(indexes_t)

indexes_s_all.sort()
indexes_t_all.sort()
if (indexes_s_all == indexes_t_all) :
	print("Yes")
else :
	print("No")

Solution (Python):
S = raw_input()
T = raw_input()
N = len(S)
ks = {}
kt = {}
xs = 0
xt = 0
ys = []
yt = []
for i in range(N):
  if S[i] not in ks:
    ks[S[i]] = xs
    xs += 1
  ys.append(ks[S[i]])
  if T[i] not in kt:
    kt[T[i]] = xt
    xt += 1
  yt.append(kt[T[i]])
print "Yes" if ys==yt else "No"

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

dict_s = {}
for i in range(len(s)):
    if s[i] not in dict_s:
        dict_s[s[i]] = t[i]
    else:
        if dict_s[s[i]] != t[i]:
            print('No')
            exit()
        else:
            continue

dict_t = {}
for i in range(len(t)):
    if t[i] not in dict_t:
        dict_t[t[i]] = s[i]
    else:
        if dict_t[t[i]] != s[i]:
            print('No')
            exit()
        else:
            continue

print('Yes')

Solution (Python):
def listToString(_list, split=""):
    maped_list = map(str, _list)  
    mojiretu = split.join(maped_list)
    return mojiretu


def stringToList(_string, split=" "):
    str_list = []
    temp = ''
    for x in _string:
        if x == split:  
            str_list.append(temp)
            temp = ''
        else:
            temp += x
    if temp != '':  
        str_list.append(temp)
    return str_list


def asciiToindex(alphabet):
    return ord(alphabet) - ord("a")


s = input()
t = input()

alpha = [i for i in range(asciiToindex("z") + 1)]
visited = [0 for i in range(asciiToindex("z") + 1)]

for i in range(len(s)):
    if alpha[asciiToindex(s[i])] != asciiToindex(t[i]):
        if visited[alpha[asciiToindex(s[i])]] == 1 or\
                        visited[asciiToindex(t[i])] == 1:
            print("No")
            exit()
        else:
            
            tmp = alpha[asciiToindex(s[i])]
            for j in range(len(alpha)):
                if alpha[j] == tmp:
                    alpha[j] = asciiToindex(t[i])
                elif alpha[j] == asciiToindex(t[i]):
                    alpha[j] = tmp
    visited[asciiToindex(t[i])] = 1
    
    
    
print("Yes")

Solution (Python):
from collections import Counter

S = input()
T = input()

s_count = Counter(S)
t_count = Counter(T)

flag = True
for i in range(len(S)):
    if t_count.get(T[i]) != s_count.get(S[i]):
        flag = False
        break
print('Yes' if flag else 'No')

Solution (Python):
import sys
Ga={}
Gb={}
A=list(input())
B=list(input())
for i in range(len(A)):
  if A[i] in Ga and Ga[A[i]] != B[i]:
    print("No")
    sys.exit()
  else:
    Ga[A[i]] = B[i]
for i in range(len(B)):
  if B[i] in Gb and Gb[B[i]] != A[i]:
    print("No")
    sys.exit()
  else:
    Gb[B[i]] = A[i]
print("Yes")

Solution (Python):
Ga={}
Gb={}
A=list(input())
B=list(input())
flag = True
for i in range(len(A)):
  if A[i] in Ga and Ga[A[i]] != B[i]:
    flag = False
    break
  else:
    Ga[A[i]] = B[i]
for i in range(len(B)):
  if B[i] in Gb and Gb[B[i]] != A[i]:
    flag = False
    break
  else:
    Gb[B[i]] = A[i]
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
s=input()
t=input()
a,b={},{}
cnt=1

for i in range(len(s)):
    if s[i] not in a and t[i] not in b:
        a[s[i]]=cnt
        b[t[i]]=cnt
        cnt+=1
    elif s[i] in a and t[i] in b and (a[s[i]]==b[t[i]]):
        pass
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
s=input()
t=input()
a,b={},{}
cnt=1
for i in s:
    if i not in a:
        a[i]=cnt
        cnt+=1
cnt=1
for i in t:
    if i not in b:
        b[i]=cnt
        cnt+=1

for i in range(len(s)):
    if a[s[i]]!=b[t[i]]:
        print("No")
        exit()
print("Yes")

Solution (Python):
import collections

s=input()
t=input()

ans=True
sa=collections.Counter(s)
ta=collections.Counter(t)
for i in range(len(s)):
    if(ta.get(t[i])!=sa.get(s[i])):
        ans=False
        break
if(ans):
    print('Yes')
else:
    print('No')

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

s_c=collections.Counter(s)
s_t=collections.Counter(t)
for i in range(len(s_c)):
    if s_c.get(s[i]) != s_t.get(t[i]):
        print("No")
        exit()
print("Yes")

Solution (Python):
import sys
from collections import defaultdict

S = input()
T = input()
L = len(S)

dcts = defaultdict(int)
dctt = defaultdict(int)
for i in range(L):
    s = S[i]
    t = T[i]
    if dcts[s] == 0:
        dcts[s] = t
    else:
        if dcts[s] != t:
            print('No')
            sys.exit()
    if dctt[t] == 0:
        dctt[t] = s
    else:
        if dctt[t] != s:
            print('No')
            sys.exit()
print('Yes')

Solution (Python):
import numpy as np

S = input()
T = input()

F = -np.ones(26,dtype=np.int)
G = -np.ones(26,dtype=np.int)
for i in range(len(S)):
    s = ord(S[i])-ord('a')
    t = ord(T[i])-ord('a')
    if F[s] < 0:
        F[s] = t
    elif F[s] != t:
        print('No')
        exit()

    if G[t] < 0:
        G[t] = s
    elif G[t] != s:
        print('No')
        exit()

print('Yes')

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


S = fin()[:-1]
T = fin()[:-1]

correspondence = dict()
for char_s, char_t in zip(S, T):
    if char_s not in correspondence:
        correspondence[char_s] = char_t
    else:
        if char_t != correspondence[char_s]:
            print("No")
            exit(0)
if len(set(correspondence.values())) < len(correspondence):
    print("No")
else:
    print("Yes")

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

dictS={}
dictT={}

passed = True
for i in range((len(S))):
  s = S[i]
  t = T[i]
  if( not s in dictS.keys() ):
    dictS[s]=len(dictS)
  if( not t in dictT.keys() ):
    dictT[t]=len(dictT)

  if(dictS[s] != dictT[t]):
    print("No")
    passed=False
    break
    
if(passed):
  print("Yes")

Solution (Python):
S=input();T=input()
for i in range(2):
    d={}
    S,T = T,S
    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()

print("Yes")

Solution (Python):
def solve(S, T):
    sm = {}
    tm = {}
    for s, t in zip(S, T):
        if s in sm and sm[s] != t:
            return "No"
        sm[s] = t

        if t in tm and tm[t] != s:
            return "No"
        tm[t] = s

    return "Yes"


if __name__ == "__main__":
    S = input()
    T = input()
    print(solve(S, T))

Solution (Python):
s = input()
t = input()
n = len(s)
a = ord("a")
s_al = list()
t_al = list()
for i in range(a, 123):
    s_al.append(s.count(chr(i)))
    t_al.append(t.count(chr(i)))
s_al.sort()
t_al.sort()
if s_al == t_al:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)



def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    st = dict()
    ts = dict()
    for s, t in zip(S, T):
        if s in st and st[s] != t:
            print(No)
            return
        st[s] = t
        if t in ts and ts[t] != s:
            print(No)
            return
        ts[t] = s

    print(Yes)


if __name__ == '__main__':
    main()

Solution (Python):
A = input()
B = input()

dica = {}
dicb = {}
for i, a in enumerate(list(A)):
    b = B[i]
    ai = dica.get(a, -1)
    bi = dicb.get(b, -1)
    if ai != bi:
        print('No')
        exit()
    dica[a] = i
    dicb[b] = i
print('Yes')

Solution (Python):



S = input().rstrip()
T = input().rstrip()
sm = {}

for i in range(len(S)):
    if S[i] in sm:
        sm[S[i]] = sm[S[i]] + 1
    else:
        sm[S[i]] = 1

st = {}
for i in range(len(T)):
    if T[i] in st:
        st[T[i]] = st[T[i]] + 1
    else:
        st[T[i]] = 1

sl = list(sm.values())
tl = list(st.values())
sl.sort()
tl.sort()

print('Yes' if sl == tl else 'No')

Solution (Python):
from collections import defaultdict
S,T = input(),input()
ss,ts = defaultdict(int),defaultdict(int)
for i in range(len(S)):
    ss[S[i]] += 1
    ts[T[i]] += 1
s = sorted(ss.items(),key=lambda x:x[1])
t = sorted(ts.items(),key=lambda x:x[1])
OK = True
for i in range(min(len(s),len(t))):
    if s[i][1]!=t[i][1]:
        OK = False
print('Yes' if OK else 'No')

Solution (Python):
S=input()
T=input()
kaesk=[i for i in range(97,97+26)]
ans=1

for i in range(len(S)):
    tmp=kaesk[ord(S[i])-97]
    no=0
    for j in range(26):
        if kaesk[j]==ord(T[i]):
            no=j
    kaesk[ord(S[i])-97]=ord(T[i])
    kaesk[no]=tmp


for i in range(len(S)):
    if kaesk[ord(S[i])-97]!=ord(T[i]):
        ans=0
        break
if ans==1:
    print("Yes")
else:
    print("No")

Solution (Python):
A=input()
B=input()
a=[0 for s in range(len(A))]
b=[0 for t in range(len(A))]

count=1
count2=1
for i in range(len(A)):
    j=i
    if a[i] == 0:
        while A.find(A[i],j) != -1:
            a[A.find(A[i],j)]=count
            j=A.find(A[i],j)+1
        count+=1
    j=i
    if b[i] == 0:
        while B.find(B[i],j) != -1:
            b[B.find(B[i],j)]=count2
            j=B.find(B[i],j)+1
        count2+=1
        
if a == b:
    print("Yes")
else:
    print("No")

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

mydict={}
for i in range(len(S)):
    if( S[i] in mydict):
        if(mydict[S[i]] != T[i]):
            print("No")
            sys.exit(0)
    else:
        mydict[S[i]]=T[i]

mydict={}
for i in range(len(T)):
    if( T[i] in mydict):
        if(mydict[T[i]] != S[i]):
            print("No")
            sys.exit(0)
    else:
        mydict[T[i]]=S[i]
print("Yes")

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


def trans_to_num(arr):
    letter_used = []
    num_arr = []
    for i in range(len(arr)):
        if arr[i] not in letter_used:
            letter_used.append(arr[i])
        num_arr.append(letter_used.index(arr[i]))
    return num_arr

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

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


def trans_to_num(arr):
    letter_used = []
    num_arr = []
    for i in range(len(arr)):
        if arr[i] not in letter_used:
            letter_used.append(arr[i])
        num_arr.append(letter_used.index(arr[i]))
    return num_arr

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

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

counta={}
countb={}

for i in s:
    if i in counta:
        counta[i] += 1
    else:
        counta[i] = 1

for y in t:
    if y in countb:
        countb[y] += 1
    else:
        countb[y] = 1

if sorted(counta.values())  == sorted(countb.values()):
    print('Yes')
else:
    print('No')

Solution (Python):
S=input().strip()
T=input().strip()
fl=True
dicu={}
dicl={}
for i in range(len(S)):
    if S[i] in dicu:
        if dicu[S[i]] != T[i]:
            fl=False
            break
    else:
        dicu[S[i]]=T[i]
    if T[i] in dicl:
        if dicl[T[i]] != S[i]:
            fl=False
            break
    else:
        dicl[T[i]]=S[i]
if fl:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
j = [str(x) for x in list(str(s))]
t = input()
k = [str(x) for x in list(str(t))]

ar = []

for i in range(len(j)):
    if j[i] != k[i]:
        if j[i] in ar:
            break
        """if j[i] not in ar:
            ar.append(j[i])"""
        com = j[i]
        j[i] = k[i]
        if j[i] not in ar:
            ar.append(j[i])
        for h in range(len(j)):
            if j[h] == com:
                j[h] = k[i]
            elif j[h] == k[i] and h != i:
                j[h] = com
        for g in range(i + 1):
            if j[g] != k[g]:
                break
        else:  
            continue  
        break  

if j == k:
    print("Yes")
else:
    print("No")

Solution (Python):
def solution(s, t):
    cs = [0 for i in xrange(26)]
    for c in s:
        cs[ord(c) - ord('a')] += 1
    ps = { }
    for k in cs:
        if k > 0:
            if k not in ps:
                ps[k] = 1
            else:
                ps[k] += 1
    ct = [0 for i in xrange(26)]
    for c in t:
        ct[ord(c) - ord('a')] += 1
    for k in ct:
        if k > 0:
            if k not in ps:
                return False
            if ps[k] == 0:
                return False
            ps[k] -= 1
    return True

def main():
    s = raw_input().strip()
    t = raw_input().strip()
    if solution(s, t):
        print 'Yes'
    else:
        print 'No'

if __name__ == '__main__':
    main()

Solution (Python):
S = input()
T = input()
dic = {}
flag = False
N = len(S)
for i in range(N):
    if S[i] in dic.keys():
        if T[i] != dic[S[i]]:
            flag = True
            break
    else:
        dic[S[i]] = T[i]

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

Solution (Python):
s = input()
t = input()
check = {}
ans = 0
for i in range(len(s)):
    if s[i] in check.keys():
        if t[i] != check[s[i]]:
            ans = 1
            break
    else:
        check[s[i]] = t[i]
if ans == 1 or len(check.values()) != len(set(check.values())):
    print('No')
else:
    print('Yes')

Solution (Python):
s1 = input()
s2 = input()

s = set(zip(s1, s2))
lst = list(s)
if len(set([x[0] for x in lst])) != len(set([x[1] for x in lst])):
    print("No")
    exit(0)

ret = ""
for x in s1:
    appended = False
    for y in s:
        if y[0] == x:
            ret += y[1]
            appended = True
            break
    if not appended:
        ret += x
if s2 == ret:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
t = input()
ans = "Yes"
l = []
for i in range(len(s)):
    if s[i] in l:
        if s[i] != t[i]:
            ans = "No"
            break
    else:
        if t[i] in l:
            ans = "No"
            break
        if s[i] == t[i]:
            l.append(s[i])
        else:
            c1 = s[i]
            c2 = t[i]
            s = s.replace(c1, 'A')
            s = s.replace(c2, 'B')
            s = s.replace('A', c2)
            s = s.replace('B', c1)
            l.append(c2)
print(ans)

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

    s_dict = {}
    t_dict = {}

    for ch_s, ch_t in zip(S, T):
        if ch_t in t_dict.keys():
            if t_dict[ch_t] != ch_s:
                print("No")
                return
        else:
            t_dict[ch_t] = ch_s

        if ch_s in s_dict.keys():
            if s_dict[ch_s] != ch_t:
                print("No")
                return
        else:
            s_dict[ch_s] = ch_t
        
        

    print('Yes')
    return


main()

Solution (Python):


from collections import Counter
from operator import itemgetter


def solve(seq1, seq2):
    if len(seq1) != len(seq2):
        return "No"
    letters1 = sorted(Counter(seq1).most_common(), key=itemgetter(1, 0), reverse=True)
    letters2 = sorted(Counter(seq2).most_common(), key=itemgetter(1, 0), reverse=True)
    for i in range(len(letters1)):
        if letters1[i][1] != letters2[i][1]:
            return "No"
    return "Yes"


if __name__ == "__main__":
    seq1 = input("")
    seq2 = input("")
    print(solve(seq1, seq2))

Solution (Python):
def solve(s, t):
    D1, D2 = {}, {}
    for i in range(len(s)):
        k = s[i]
        v = t[i]
        D1.setdefault(k, set()).add(v)
        D2.setdefault(v, set()).add(k)
        if (len(D1[k]) > 1) or (len(D2[v]) > 1):
            return "No"
    return "Yes"

assert solve("azzel", "apple") == "Yes"
assert solve("chokudai", "redcoder") == "No"
assert solve("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu") == "Yes"
s = raw_input()
t = raw_input()
print solve(s, t)

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

count_s = []
count_t = []

iterator = 'abcdefghijklmnopqrstuvwxyz'
for a in iterator:
    count_s.append(S.count(a))
    count_t.append(T.count(a))

count_s.sort()
count_t.sort()

if count_s == count_t:
    print('Yes')
else:
    print('No')

Solution (Python):
lis = list(input())
lit = list(input())

counts = {}
countt = {}

for i in lis:
    if i not in counts.keys():
        counts[i] = 0
    counts[i] += 1

for i in lit:
    if i not in countt.keys():
        countt[i] = 0
    countt[i] += 1


counts = sorted(counts.items(),key = lambda x: x[1])
countt = sorted(countt.items(),key = lambda x: x[1])

flag = "Yes"
count = 0

for i in range(len(counts)):
    if counts[i][1] != countt[i][1]:
        flag = "No"
        break
    count += 1

print(flag)

Solution (Python):
S = input()
T = input()
l = len(S)
right = True
dic = {}
for i in range(l):
    if T[i] not in dic:
        dic[T[i]] = set()
    dic[T[i]].add(S[i])
for key, st in dic.items():
    if len(st) > 1:
        right = False
dic = {}
for i in range(l):
    if S[i] not in dic:
        dic[S[i]] = set()
    dic[S[i]].add(T[i])
for key, st in dic.items():
    if len(st) > 1:
        right = False
print("Yes" if right else "No")

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

aS = [ord(_) - ord('a') for _ in S]
aT = [ord(_) - ord('a') for _ in T]

aS2 = [[] for _ in range(26)]
aT2 = [[] for _ in range(26)]

for i in range(0, len(aS)):
    aS2[aS[i]].append(i)
    aT2[aT[i]].append(i)

if sorted(aS2) == sorted(aT2):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
from collections import deque

S = input()
T = input()
q = deque()
while len(S):
    indexes = [i for i, v in enumerate(S) if v == S[0]]
    q.append(indexes)
    S = S.replace(S[0], "")
while len(T):
    indexes = [i for i, v in enumerate(T) if v == T[0]]
    if q.popleft() != indexes:
        print("No")
        sys.exit()
    T = T.replace(T[0], "")
print("Yes")

Solution (Python):
s=input().rstrip()
t=input().rstrip()
def func(s,t):
  ds, dt = {}, {}
  for i,j in zip(s,t):
    if i not in ds:
      ds[i] = j
    elif ds[i]!=j:
      return "No"
    if j not in dt:
      dt[j] = i
    elif dt[j]!=i:
      return"No"
  return "Yes"
print(func(s,t))

Solution (Python):
s=list(input())
t=list(input())
start=[-1]*26
goal=[-1]*26
for i in range(len(s)):
    a=ord(s[i])-97
    b=ord(t[i])-97
    if start[a]!=-1 or goal[b]!=-1:
        if start[a]!=b or goal[b]!=a:
            print("No")
            exit()
    start[a]=b
    goal[b]=a

print("Yes")

Solution (Python):
L = [chr(i) for i in range(97,97+26)]
S = list(input())
T = list(input())

LS = []
LT = []

for i in range(26):
	LS.append(S.count(L[i]))
	LT.append(T.count(L[i]))

LS = sorted(LS)
LT = sorted(LT)

if LS == LT:
	print("Yes")
else:
	print("No")

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

Rs = {}
Rt = {}
for i in range(len(S)):
    if S[i] in Rs.keys():
        if Rs[S[i]] != T[i]:
             print("No")
             exit()
    else:
        Rs[S[i]] = T[i]

    if T[i] in Rt.keys():
        if Rt[T[i]] != S[i]:
            print("No")
            exit()
    else:
        Rt[T[i]] = S[i]
print("Yes")

Solution (Python):
s = list(input())
t = list(input())
Rs = {}
Rt = {}
for i in range(len(s)):
    if s[i] in Rs:
        if Rs[s[i]] != t[i]:
            print('No')
            exit()
    else:
        Rs[s[i]] = t[i]
    if t[i] in Rt:
        if Rt[t[i]] != s[i]:
            print('No')
            exit()
    else:
        Rt[t[i]] = s[i]
print('Yes')

Solution (Python):
import sys


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

    ss = []

    for ch in range(ord('a'), ord('z') + 1):
        ids = []

        for i in range(n):
            if chr(ch) == s[i]:
                ids.append(i)

        if ids:
            ss.append(ids)

    tt = []

    for ch in range(ord('a'), ord('z') + 1):
        ids = []

        for i in range(n):
            if chr(ch) == t[i]:
                ids.append(i)

        if ids:
            tt.append(ids)

    ss.sort()
    tt.sort()

    
    

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


if __name__ == '__main__':
    main()

Solution (Python):
S=input()
T=input()
a=list(S.count(chr(ord('a') + i)) for i in range(26))
b=list(T.count(chr(ord('a') + i))for i in range(26))
a.sort()
b.sort()
if a==b:
    print('Yes')
else:
    print('No')

Solution (Python):
a = list(input())
b = list(input())
dica = {}
dicb = {}
la = []
lb = []
ite = 0
for ia in a:
  if ia in dica:
    la.append(dica[ia])
  else:
    dica[ia] = ite
    la.append(ite)
    ite+= 1

ite = 0
for ib in b:
  if ib in dicb:
    lb.append(dicb[ib])
  else:
    dicb[ib] = ite
    lb.append(ite)
    ite+= 1
if la == lb:
  print("Yes")
else:
  print("No")

Solution (Python):
"""
import string
al = string.ascii_lowercase

ord('A') =65
chr(65) ='A'
"""


def c2i(c): return ord(c) - ord('a')


s = input()
t = input()

chrList = [-1 for _ in range(26)]

flg = True
for i in range(len(s)):
    idx_s = c2i(s[i])
    idx_t = c2i(t[i])

    if chrList[idx_s] == -1:
        chrList[idx_s] = idx_t
    else:
        if chrList[idx_s] != idx_t:
            flg = False
            break



chk = [False for _ in range(26)]
for i in range(26):
    if chrList[i] == -1:
        pass
    elif not chk[chrList[i]]:
        chk[chrList[i]] = True
    else:
        flg = False
        break

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

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

ds = {}
dt = {}
for i in range(len(S)):
    if S[i] not in ds:
        ds[S[i]] = []
    if T[i] not in dt:
        dt[T[i]] = []
    ds[S[i]].append(i)
    dt[T[i]].append(i)

ans = 'Yes'
ds = ds.values()
dt = dt.values()
for x in ds:
    if x not in dt:
        ans = 'No'
        break

print(ans)

Solution (Python):
from collections import Counter
import numpy as np

s = input()
t = input()

l = list(set([(s[i], t[i]) for i in range(len(s))]))

l1 = []
l2 = []

for i in l:
    l1.append(i[0])
    l2.append(i[1])

c1 = Counter(l1)
_, counts1 = zip(*c1.most_common())
k1 = np.where(np.array(counts1)>1)[0]

c2 = Counter(l2)
_, counts2 = zip(*c2.most_common())
k2 = np.where(np.array(counts2)>1)[0]

if len(k1) >= 1 or len(k2) >= 1:
    print('No')
else:
    print('Yes')

Solution (Python):
s=input()
t=input()
l=len(s)
sl=[]
tl=[]
slist=[0]*26
tlist=[0]*26
flag=0
sabc=''
tabc=''
for i in range(l):
    sb=not s[i] in sabc
    tb=not t[i] in tabc
    if sb:
        sabc+=s[i]
    else:
        slist[sabc.find(s[i])]+=1
    if tb:
        tabc+=t[i]
    else:
        tlist[tabc.find(t[i])]+=1
    
    if slist!=tlist:
        flag=1
        break
if flag==1:
    print('No')
else:
    print('Yes')

Solution (Python):
s = input()
t = input()
trans_in = [-1] * 26 
trans_out = [-1] * 26
for i in range(len(s)):
    a = ord(s[i]) - ord("a")
    b = ord(t[i]) - ord("a")
    
    
    if trans_in[a] != -1 or trans_out[b] != -1:
        if trans_in[a] != b or trans_out[b] != a:
            print("No")
            exit()
    trans_in[a] = b
    trans_out[b] = a
print("Yes")

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

d1 = dict()
d2 = dict()

ret = "Yes"

for s, t in zip(S, T):
    
    tmp1 = d1.get(s, None)
    tmp2 = d2.get(t, None)
    if (tmp1 == None or tmp1 == t) and (tmp2 == None or tmp2 == s):
        d1[s] = t
        d2[t] = s
    else:
        ret = "No"

print(ret)

Solution (Python):
s = list(input())
t = list(input())
pair = []
li =[]
ans = "Yes"

for i in range(len(s)):
    if [s[i],t[i]] in li:
        pass
    else:
        li.append([s[i],t[i]])

def check2(pair,i,li):
    for j in range(len(pair)):
        if (li[i][0]==pair[j][0] and li[i][1]!=pair[j][1])or(li[i][0]!=pair[j][0] and li[i][1]==pair[j][1]):
            return False
    return True

for i in range(len(li)):
    if check2(pair,i,li):
        pair.append([li[i][0],li[i][1]])
    else:
        ans = "No"
        break

print(ans)

Solution (Python):
S=input()
T=input()
string="abcdefghijklmnopqrstuvwxyz"
s=[0 for i in range(26)]
t=[0 for i in range(26)]
for i in range(26):
    s[i]+=S.count(string[i])
    t[i]+=T.count(string[i])
print("Yes" if sorted(s)==sorted(t) else "No")

Solution (Python):

from sys import stdin

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
st = ""

for i in range(len(s)):
    st += s[i] + t[i]

st_sprit = [st[i: i+2] for i in range(0, len(st), 2)]

s_unique = list(set(s))
t_unique = list(set(t))
st_sprit_unique = list(set(st_sprit))

if min(len(s_unique),len(t_unique)) == len(st_sprit_unique):
    print("Yes")
else:
    print("No")

Solution (Python):
import collections
S=input()
T=input()
a1=collections.Counter(S)
a2=collections.Counter(T)
x=''
for i in range(len(S)):
    if a1[S[i]]!=a2[T[i]]:
        x='No'
if x=='':
    print('Yes')
else:
    print(x)

Solution (Python):
from collections import defaultdict

def a(s):
    dic = defaultdict(list)
    for i, ch in enumerate(s):
        dic[ch].append(i)
    return sorted(list(dic.values()))

s = input()
t = input()
print('Yes' if a(s) == a(t) else 'No')

Solution (Python):
import sys
S=input()
T=input()
N=len(S)
a=ord('a')
R=[-1]*26
Q=[-1]*26
for i in range(N):
    s=ord(S[i])-a
    t=ord(T[i])-a
    if R[s]!=-1:
        if Q[t]!=R[s]:
            print('No')
            sys.exit()
    if Q[t]!=-1:
        if R[s]!=Q[t]:
            print('No')
            sys.exit()  
    if R[s]==-1:
        R[s]=i
    if Q[t]==-1:
        Q[t]=i
print('Yes')

Solution (Python):
import sys
S=input()
T=input()
N=len(S)
L=['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']
Ss=[]
Ts=[]
for x in L:
    A=set()
    B=set()
    for i in range(N):
        if S[i]==x:
            A.add(i)
        if T[i]==x:
            B.add(i)
    Ss.append(A)
    Ts.append(B)
for A in Ss:
    flag=True
    for B in Ts:
        if A==B:
            flag=False
    if flag:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):
from collections import defaultdict

def p(X):
    d = defaultdict(list)    
    for i, c in enumerate(X):
        d[c].append(i)
    return sorted(list(d.values()))

S = input()
T = input()

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

Solution (Python):
S = input()
T = input()
l = len(S)
flag = "Yes"
Rs = [-1]*130
Rt = [-1]*130

for i in range(l):
    s = ord(S[i])
    t = ord(T[i])
    if Rs[s] < 0:
        Rs[s] = t
    if Rt[t] < 0:
        Rt[t] = s
    if Rs[s] > 0:
        if Rs[s] != t:
            flag = "No"
    if Rt[t] > 0:
        if Rt[t] != s:
            flag = "No"

print(flag)

Solution (Python):
word1 = input()
word2 = input()

def cnt_element(x):
    dict = {}
    for i in x:
        if i not in dict:
            dict[i] = 1
        else:
            dict[i] += 1
    return  sorted([x for x in dict.values()],reverse=True)

if cnt_element(word1) == cnt_element(word2):
    print('Yes')
else:
    print('No')

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

used = []
res  = []

for i in range(len(S)):
    if S[i] not in used:
        used.append(S[i])
    res.append(used.index(S[i]))



used = []
ret = []

for i in range(len(T)):
    if T[i] not in used:
        used.append(T[i])
    ret.append(used.index(T[i]))

if res == ret:
    print('Yes')
else:
    print('No')

Solution (Python):
s = list(input())
t = list(input())
abc = [chr(i) for i in range(97, 97+26)]
def index(list, char):
    return tuple(i for i, c in enumerate(list) if c == char)
s_ = [index(s, _) for _ in abc]
t_ = [index(t, _) for _ in abc]
print('Yes' if set(s_) == set(t_) else 'No')

Solution (Python):
s = input()
t = input()
sal = [0 for i in range(26)]
tal = [0 for i in range(26)]
s2, t2 = [], []
for i in range(26):
    sal[i] = s.count(chr(ord('a') + i))
    tal[i] = t.count(chr(ord('a') + i))
for i in range(len(s)):
    s2.append(sal[ord(s[i]) - ord('a')])
    t2.append(tal[ord(t[i]) - ord('a')])
if s2 != t2:
    print('No')
else:
    print('Yes')

Solution (Python):
import sys

input = sys.stdin.readline
s = input()
t = input()
s_dic = {}
t_dic = {}
flag = 0
for i in range(len(s)):
    if s[i] in s_dic:
        s_num = s_dic[s[i]]
    else:
        s_num = i
        s_dic[s[i]] = i
    if t[i] in t_dic:
        t_num = t_dic[t[i]]
    else:
        t_num = i
        t_dic[t[i]] = i
    if s_num != t_num:
        flag = 1
        break
if flag == 1:
    print('No')
else:
    print('Yes')

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

used = []
res  = []

for i in range(len(S)):
    if S[i] not in used:
        used.append(S[i])
    res.append(used.index(S[i]))



used = []
ret = []

for i in range(len(T)):
    if T[i] not in used:
        used.append(T[i])
    ret.append(used.index(T[i]))

if res == ret:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()
flag = True
d1,d2 = dict(),dict()
for i in range(len(s)):
    if s[i] in d1:
        if d1[s[i]] != t[i]:
            flag = False
    else:
        d1[s[i]] = t[i]
        
for i in range(len(s)):
    if t[i] in d2:
        if d2[t[i]] != s[i]:
            flag = False
    else:
        d2[t[i]] = s[i]

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