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):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
T = input()

s = [[] for _ in range(26)]
t = [[] for _ in range(26)]

l = len(S)

for i in range(l):
    s[ord(S[i]) - ord('a')].append(i)
    t[ord(T[i]) - ord('a')].append(i)


def ok():
    ch = [False] * 26
    for i in range(l):
        if not ch[ord(S[i]) - ord('a')]:
            ch[ord(S[i]) - ord('a')] = True
            ls = s[ord(S[i]) - ord('a')]
            lt = t[ord(T[i]) - ord('a')]
            if ls != lt:
                return False
    return True

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

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

n=len(s)
s_d={}
t_d={}
s_n=[]
t_n=[]
s_cnt=1
t_cnt=1

for s_i, t_i in zip(s,t):

    if s_i in s_d:
        s_n.append(s_d[s_i])
    else:
        s_d[s_i]=s_cnt
        s_cnt+=1
        s_n.append(s_d[s_i])

    if t_i in t_d:
        t_n.append(t_d[t_i])
    else:
        t_d[t_i]=t_cnt
        t_cnt+=1
        t_n.append(t_d[t_i])

print('Yes' if s_n==t_n else 'No')

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

go = []
back = []
g = []
b = []
def has_duplicates(seq):
    return len(seq) != len(set(seq))


for i in range(len(s)):
  go.append(s[i]+t[i])
  back.append(t[i]+s[i])

go_l = set(go)
back_l = set(back)
go = list(go_l)
back = list(back_l)




for i in range(len(go)):
  g.append(go[i][0])
  b.append(back[i][0])
  


  
ansg = has_duplicates(g)
ansb = has_duplicates(b)

if ansg == True or ansb == True:
  print("No")
else:
  print("Yes")

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    s = list(input()[:-1])
    t = list(input()[:-1])
    N = len(s)
    S = {}
    T = {}
    t_si = 0
    t_ti = 0
    n_s = []
    n_t = []
    for si, ti in zip(s, t):
        if not si in S:
            S[si] = t_si
            n_s.append(t_si)
            t_si += 1
        else:
            n_s.append(S[si])
        if not ti in T:
            T[ti] = t_ti
            n_t.append(t_ti)
            t_ti += 1
        else:
            n_t.append(T[ti])

    for si, ti in zip(n_s, n_t):
        if si != ti:
            print('No')
            exit()
    print('Yes')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):
s = input()
z = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
s_alpha = [[] for _ in range(26)]
z_alpha = [[] for _ in range(26)]
for num, i in enumerate(s):
    pos = alpha.index(i)
    s_alpha[pos].append(num)
for num, i in enumerate(z):
    pos = alpha.index(i)
    z_alpha[pos].append(num)
s_alpha.sort()
z_alpha.sort()
if s_alpha == z_alpha:
    print("Yes")
else:
    print("No")

Solution (Python):
def String_kind(S):
    S_kind,S_kind_num,count = set(),{},0
    OP = []
    for i in range(len(S)):
        if S[i] not in S_kind:
            S_kind.add(S[i])
            S_kind_num[S[i]] = count
            count += 1
        OP.append(S_kind_num[S[i]])

    return OP

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

    S_kind,T_kind = String_kind(S),String_kind(T)
    if S_kind == T_kind:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Solution (Python):
def main():

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

    d = dict()
    d_inv = dict()
    for i in range(len(S)):
        if S[i] not in d:
            if T[i] in d_inv:
                return "No"
            else:
                d[S[i]] = T[i]
                d_inv[T[i]] = S[i]
        else:
            if d[S[i]] != T[i]:
                return "No"
    return "Yes"
        
if __name__ == '__main__':
    print(main())

Solution (Python):
from collections import Counter

S=input()
T=input()
A=dict(Counter(list(S)))
B=dict(Counter(list(T)))

ans="Yes"
for m in A:
  for n in B:
    if A[m]==B[n]:
      del B[n]
      break
  else:
    ans="No"
    break
print(ans)

Solution (Python):
from collections import defaultdict

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

ms = defaultdict(str)
mt = defaultdict(str)
for i in range(n):
    if ms[s[i]] == '':
        ms[s[i]] = t[i]
    if mt[t[i]] == '':
        mt[t[i]] = s[i]
    if ms[s[i]] != t[i] or mt[t[i]] != s[i]:
        print("No")
        exit()

print("Yes")

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

a = [0 for i in range(26)]
n = len(s)
dict = {}
for i in range(n):
	x = ord(t[i]) - ord("a")
	if s[i] not in dict:
		dict[s[i]] = t[i]
		a[x] += 1
	else:
		if dict[s[i]] != t[i]:
			print ("No")
			exit()

for i in range(26):
	if a[i] >= 2:
		print ("No")
		exit()
print ("Yes")

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

my_d = dict()

for i, ch in enumerate(s):
    if ch not in my_d:
        if t[i] in my_d.values():
            print('No')
            exit()
        else:
            my_d[ch] = t[i]
    else:
        if my_d[ch] != t[i]:
            print('No')
            exit()

print('Yes')

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

dict_S = {}
dict_T = {}

for i in range(N):
    
    
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    dict_S[S[i]] = T[i]
    dict_T[T[i]] = S[i]
print("Yes")

Solution (Python):
s=str(input())
t=str(input())
temp=["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"]
s=list(s)
t=list(t)
temps=[0]*len(temp)
tempt=[0]*len(temp)
for i in range(0,len(temp)):
  temps[i]=s.count(temp[i])
  tempt[i]=t.count(temp[i])
temps.sort()
tempt.sort()
if temps==tempt:
  print("Yes")
else:
  print("No")

Solution (Python):
s = input()
t = input()
st_dict = {}
flag = True
for i in range(len(s)):
    if s[i] not in st_dict:
        if t[i] in st_dict.values():
            flag = False
            break
        else:
            st_dict[s[i]] = t[i]
            
    else:
        if st_dict[s[i]] != t[i]:
            flag = False
if flag:
    print('Yes')
    
else:
    print('No')

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

my_d = dict()

for i, ch in enumerate(s):
    if ch not in my_d:
        if t[i] in my_d.values():
            print('No')
            exit()
        else:
            my_d[ch] = t[i]
    else:
        if my_d[ch] != t[i]:
            print('No')
            exit()

print('Yes')

Solution (Python):
import sys

S = input()
T = input()

changes = {}
changes_reverse = {}
for i in range(len(T)):
    
    if S[i] != T[i]:
        if S[i] in changes:
            if changes[S[i]] != T[i]:
                print('No')
                sys.exit(0)
        if T[i] in changes_reverse:
            if changes_reverse[T[i]] != S[i]:
                print('No')
                sys.exit(0)

        changes[S[i]] = T[i]
        changes_reverse[T[i]] = S[i]
    else:
        changes[S[i]] = T[i]
        changes_reverse[T[i]] = S[i]
        

print('Yes')

Solution (Python):
S = input()
T = input()
dic1={}
dic2={}
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s!=t:
        if (s not in dic1) and (t not in dic2):
            dic1[s]=t
            dic2[t]=s
        elif (s in dic1) and (t in dic2):
            if dic1[s]!=t:
                print('No')
                break
            else:
                continue
        else:
            print('No')
            break
    else:
        dic1[s]=t
        dic2[t]=s
else:
    print('Yes')

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

S = input()
T = input()

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














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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


s = S()
t = S()
l = len(s)
S_Alphabet = [-1]*26
T_Alphabet = [-1]*26

for i in range(l):
    si = ord(s[i])-97
    ti = ord(t[i])-97
    if S_Alphabet[si] == -1:
        S_Alphabet[si] = ti
    else:
        if S_Alphabet[si] == ti:
            continue
        else:
            print("No")
            exit()
    if T_Alphabet[ti] == -1:
        T_Alphabet[ti] = si
    else:
        if T_Alphabet[ti] == si:
            continue
        else:
            print("No")
            exit()
else:
    print("Yes")

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

flg=True

def dic(DIC,str):
    for num in range(len(str)):
        if str[num] not in DIC:
            DIC[str[num]]=[num]
        else:
            DIC[str[num]].append(num)
    return DIC

D_S={}
D_T={}

D_S=dic(D_S,S)
D_T=dic(D_T,T)

if len(D_S)==len(D_T):
    for lst in D_S.values():
        if lst not in D_T.values():
            flg=False
else:
    flg=False

if flg==True:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
t = input()
ds = dict()
dt = dict()
ni = 1
for i in range(len(s)):
    si = s[i]
    ti = t[i]
    if not si in ds:
        ds[si] = ni
        if ti in dt:
            print("No")
            exit()
        else:
            dt[ti] = ni
            ni += 1
    elif (not ti in dt) or (not ds[si] == dt[ti]):
        print("No")
        exit()

print("Yes")

Solution (Python):
from collections import defaultdict
s = input()
t = input()
n = len(s)
changed_s = defaultdict(list)
changed_t = defaultdict(list)
flag = True
used = []
for i in range(n):
    if s[i] != t[i]:
        changed_s[s[i]].append(t[i])
        changed_t[t[i]].append(s[i])
    else:
        used.append(s[i])




for key, lis in changed_s.items():
    if len(set(lis)) == 1 and key in used:
        flag = False
    elif len(set(lis)) != 1:
        flag = False
for key, lis in changed_t.items():
    if len(set(lis)) == 1 and key in used:
        flag = False
    elif len(set(lis)) != 1:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
first = str(input())
second = str(input())
"""
def cycleis(start, dici, seen):
    curr = start
    
    while seen[curr] != 1:
        
        seen[curr] = 1
        curr = dici[curr]
        if curr not in seen:
            return True

    if curr == start:
        return True
    else:
        return False
"""
good = True
dici = {}
dici2 = {}
seen = {}

for i in range(0,len(first)):
    if first[i] in dici:
        if second[i] != dici[first[i]]:
            print("No",end='')
            good = False
            
            break
    else:
        dici[first[i]] = second[i]

    if second[i] in dici2:
        if first[i] != dici2[second[i]]:
            print("No", end='')
            good = False
            break
    else:
        dici2[second[i]] = first[i]

    
    



"""
for i in dici.keys():
    if cycleis(i, dici, seen) == False:
        print("No", end='')
        good = False
        break"""
"""
for i in dici.keys():
    if dici[i] in dici:
        if dici[dici[i]] != i:
            print("A hiba: {} -> {}-ba megy itt meg {}-be kene".format(i, dici[i], dici[dici[i]]))
            good = False
            print("No", end='')
            break
"""
if good:
    print("Yes",end='')

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

direct_graph1 = {}
direct_graph2 = {}
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
for i in list(ascii_lowercase):
    direct_graph1[i] = None
    direct_graph2[i] = None

flg = 0
for s,t in zip(S,T):
    if direct_graph1[s] == None or direct_graph1[s] == t:
        direct_graph1[s] = t
    else:
        flg =1
    
    if direct_graph2[t] == None or direct_graph2[t] == s:
        direct_graph2[t] = s
    else:
        flg = 1

    if flg == 1:
        print('No')
        exit()

print('Yes')

Solution (Python):
s=input()
t=input()
s1={}
t1={}
for i in range(len(s)):
    if s[i] in s1 and t[i] in t1:
        if s1[s[i]]!=t1[t[i]]:
            print("No")
            break
    elif s[i] not in s1 and t[i] not in t1:
        s1[s[i]]=i
        t1[t[i]]=i
    else:
        print("No")
        break
else:
    print("Yes")

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

def s2i(z):
    ret = []
    nz = defaultdict(int)
    for i in range(len(z)):
        if z[i] in nz:
            ret.append(nz[z[i]])
        else:
            x = len(nz) + 1
            ret.append(x)
            nz[z[i]] = x
    return ret

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

Solution (Python):
s=input()
t=input()
d=dict()
flag=True
ds=set()
for i in range(len(s)):

  if not(t[i] in d):
    if s[i] in ds:
      flag=False
      break
    d[t[i]]=s[i]
    ds.add(s[i])
  else:
    if d[t[i]]!=s[i]:
      flag=False
      break
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    S = input()
    T = input()
    d = dict()
    for s, t in zip(S, T):
        if s not in d.keys():
            if t in d.values():
                print('No')
                return
            d[s] = t
        else:
            if d[s] != t:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
S, T = input(), input()
d = dict()
count = 0
S_list = []
for c in S:
    try:
        n = d[c]
    except:
        d[c] = n = count
        count += 1
    S_list.append(n)
d = dict()
count = 0
for m, c in zip(S_list, T):
    try:
        n = d[c]
    except:
        d[c] = n = count
        count += 1
    if n != m:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True




def warshall_floyd(d, n):
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d



def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)






def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



s = input()
t = input()
n = len(s)
yes = True
x = [-1 for i in range(26)]
y = [-1 for i in range(26)]
for i in range(n):
    a = ord(s[i]) - 97
    b = ord(t[i]) - 97
    if x[a] != -1 or y[b] != -1:
        if x[a] != b or y[b] != a:
            yes = False
            break
    x[a] = b
    y[b] = a
if yes:
    print("Yes")
else:
    print("No")

Solution (Python):




import math
import sys
import bisect
import heapq 

inf = 10**15
mod = 10**9+7
s = list(input())
t = list(input())
dict = {}
dict_t = {}
s_judge = [True for i in range(26)] 
t_judge = [True for i in range(26)] 
aint = ord('a')
flag = True
for i,c in enumerate(s):
    tmp = t[i]
    sint = ord(c)-aint
    tint = ord(tmp)-aint
    if s_judge[sint]:
        dict[sint] = tint
        s_judge[sint] = False
    else:
        if dict[sint] != tint:
            flag = False
            break
    if t_judge[tint]:
        dict_t[tint] = sint
        t_judge[tint] = False
    else:
        if dict_t[tint] != sint:
            flag = False
            break
if flag:
    print('Yes')
else:
    print('No')

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

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


def get_patten(l):
    pattern = []
    d = dict()
    i = ord('a')
    for c in l:
        if c not in d:
            d[c] = chr(i)
            i += 1
        pattern.append(d[c])
    return pattern


ps = get_patten(s)
pt = get_patten(t)

if ps == pt:
    print('Yes')
else:
    print('No')

Solution (Python):
from sys import exit

s=input()
t=input()
alp=[0]*26
for i in range(len(s)):
	if alp[ord(s[i])-97]==0:
		alp[ord(s[i])-97]=t[i]
	else:
		if alp[ord(s[i])-97]!=t[i]:
			print("No")
			exit()
			
alp=[0]*26
for i in range(len(t)):
	if alp[ord(t[i])-97]==0:
		alp[ord(t[i])-97]=s[i]
	else:
		if alp[ord(t[i])-97]!=s[i]:
			print("No")
			exit()

print("Yes")

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


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

    sl = dict()
    tl = dict()
    for s, t in zip(S, T):
        if s not in sl:
            sl[s] = t
        else:
            if sl[s] != t:
                print('No')
                break

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


if __name__ == "__main__":
    main()

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

Solution (Python):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def rle(l):
    hoge = list(set(l))
    huga = []
    for i in hoge:
        huga.append(l.count(i))
    huga.sort()
    return huga

def solve():
    s = list(input())
    t = list(input())
    if rle(s) == rle(t):
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):

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

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    s = input()
    t = input()
    s_first_appeared = dict()
    s_replaced = [i for i in range(len(s))]
    for i, char in enumerate(s):
        if char not in s_first_appeared:
            s_first_appeared[char] = i
        else:
            s_replaced[i] = s_first_appeared[char]
    t_first_appeared = dict()
    t_replaced = [i for i in range(len(t))]
    for i, char in enumerate(t):
        if char not in t_first_appeared:
            t_first_appeared[char] = i
        else:
            t_replaced[i] = t_first_appeared[char]
    print('Yes') if s_replaced == t_replaced else print('No')





if __name__ == "__main__":
    main()

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

Ms = defaultdict(int)
Mt = defaultdict(int)

for i in range(len(S)):
    Ms[S[i]] += 1
    Mt[T[i]] += 1

ans = "Yes"

A = list(Ms.values())
A.sort()
B = list(Mt.values())
B.sort()

for i in range(len(A)):
    if A[i] != B[i]:
        ans = "No"
        break

print(ans)

Solution (Python):
S = input().rstrip()
T = input().rstrip()
from collections import defaultdict
s2t = defaultdict(int)
t2s = defaultdict(int)
for s,t in zip(S,T):
    if (s2t[s] != 0 and s2t[s] != t) or (t2s[t] != 0 and t2s[t] != s):
        print('No')
        exit()
    s2t[s] = t
    t2s[t] = s
print('Yes')

Solution (Python):
import sys

readline = sys.stdin.readline

def myindex(l, s):
    if s in l:
        return l.index(s)
    else:
        return len(l)

def main():
    S = list(readline()[:-1])
    T = list(readline()[:-1])
    tmpS = []; tmpT = []
    cntS = 0; cntT = 0
    flag = True
    for i in range(len(S)):
        cntS = myindex(tmpS, S[i])
        cntT = myindex(tmpT, T[i])
        tmpS.append(S[i])
        tmpT.append(T[i])
        if cntS != cntT:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res

from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
import string


def check(t, sidx):
    for idx in sidx.values():
        if idx:
            tmp = set()
            for i in idx:
                tmp.add(t[i])
            if len(tmp) > 1:
                return False
    return True

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

    sidx = {a: [] for a in string.ascii_lowercase}
    tidx = {a: [] for a in string.ascii_lowercase}
    for i, si in enumerate(s): sidx[si].append(i)
    for i, ti in enumerate(t): tidx[ti].append(i)

    if check(s,tidx) and check(t,sidx):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res

from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
import string


def main():
    s = IS()
    t = IS()
    tidx = {a: [] for a in string.ascii_lowercase}
    sidx = {a: [] for a in string.ascii_lowercase}
    for i, ti in enumerate(t):
        tidx[ti].append(i)
    for i, si in enumerate(s):
        sidx[si].append(i)
    for k, idx in tidx.items():
        tmp = set()
        for i in idx:
            tmp.add(s[i])
        if len(tmp) > 1:
            print('No')
            return None
    for k, idx in sidx.items():
        tmp = set()
        for i in idx:
            tmp.add(t[i])
        if len(tmp) > 1:
            print('No')
            return None
    print('Yes')

if __name__ == '__main__':
    main()

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

used = [False]*26
d = defaultdict(str)

flg = True
for i in range(len(S)):
    if S[i] in d:
        if d[S[i]] != T[i]:
            flg = False

    else:
        d[S[i]] = T[i]
        if used[ord(T[i])-ord('a')] is True:
            flg = False
        used[ord(T[i])-ord('a')] = True

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

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

keep=[0]*26
moji=["0"]*26
res=1

for i in range(0,len(s)):
  moji_s=s[i]
  moji_t=t[i]
  s_num=ord(moji_s)-97
  t_num=ord(moji_t)-97
  if keep[s_num]==0:
    keep[s_num]=1
    moji[s_num]=moji_t
  else:
    if moji[s_num]!=moji_t:
      res=0
      break
  kepkep=moji[s_num]
  moji[s_num]="0"
  if moji_t in moji:
    res=0
    break
  moji[s_num]=kepkep

if res==1:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys

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

jisho_s = {}
jisho_t = {}
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s in jisho_s and jisho_s[s] != t:
        print("No")
        sys.exit()
    if t in jisho_t and jisho_t[t] != s:
        print("No")
        sys.exit()
    if s not in jisho_s:
        jisho_s[s] = t
    if t not in jisho_t:
        jisho_t[t] = s

print("Yes")