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 bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()

table = {}
ok = True
for i, t in enumerate(T):
    if t not in table:
        table[t] = S[i]
    if table[t] != S[i]:
        ok = False
if ok and len(set(table.values())) == len(table):
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
T = input()
flag = True
traslateT = [0] * 26
traslateS = [0] * 26
use = [False] * 26
for i in range(len(S)):
    si = ord(S[i]) - ord('a')
    ti = ord(T[i]) - ord('a')
    if(traslateS[si] != 0 and traslateS[si] != ti):
        flag = False
    if(traslateT[ti] != 0 and traslateT[ti] != si):
        flag = False
    traslateS[si] = ti
    traslateT[ti] = si

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

Solution (Python):



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

if len(set(s)) != len(set(t)):
    print('No')
    quit()

dif = {}
for x,y in zip(s,t):
    if x not in dif:
        dif[x] = y
    elif dif[x] != y:
        print('No')
        quit()
print('Yes')

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

d = {}
d2 = {}

for i in range(len(S)):
    if S[i] not in d: d.update({S[i]: T[i]})
    elif d[S[i]]==T[i]: pass
    else:
        print('No')
        exit()

    if T[i] not in d2: d2.update({T[i]: S[i]})
    elif d2[T[i]]==S[i]: pass
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
from collections import Counter

s = input()
t = input()
s_chr_list = []
s_chr_num = 0
s_num_list = []
for i in range(len(s)):
    if s[i] in s_chr_list:
        s_same_chr = s_chr_list.index(s[i])
        s_num_list.append(s_same_chr)
    else:
        s_chr_list.append(s[i])
        s_chr_num += 1
        s_num_list.append(s_chr_num)
t_chr_list = []  
t_chr_num = 0
t_num_list = []        
for i in range(len(t)):
    if t[i] in t_chr_list:
        t_same_chr = t_chr_list.index(t[i])
        t_num_list.append(t_same_chr)
    else:
        t_chr_list.append(t[i])
        t_chr_num += 1
        t_num_list.append(t_chr_num)
if t_num_list == s_num_list:
    print("Yes")
else:
    print("No")

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

def main():
	s = input().strip()
	t = input().strip()
	l = [-1] * 26
	k = [-1] * 26
	a = ord('a')
	for i in range(len(s)):
		if l[ord(s[i]) - a] != -1 or k[ord(t[i]) - a] != -1:
			if l[ord(s[i]) - a] != t[i] or k[ord(t[i]) - a] != s[i]:
				print('No')
				return
		l[ord(s[i]) - a] = t[i]
		k[ord(t[i]) - a] = s[i]
	print('Yes')


if __name__ == '__main__':
	main()

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

s2t = dict()
t2s = dict()

flg = True
for i, (ss, tt) in enumerate(zip(s, t)):
    a = s2t.get(ss, None)
    if a is None:
        s2t[ss] = tt
    else:
        if a != tt:
            flg = False
            break

    b = t2s.get(tt, None)
    if b is None:
        t2s[tt] = ss
    else:
        if b != ss:
            flg = False
            break
print('Yes' if flg else 'No')

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())


S = input()
T = input()

stlist = [[sc, tc] for sc, tc in zip(S, T)]


from operator import itemgetter


stlist = sorted(stlist, key=itemgetter(0))


prevsc = 'Z'
prevtc = 'Z' 
for sc, tc in stlist:
  if prevsc == sc and prevtc != tc:
    print('No')
    exit()
  else:
    prevsc = sc
    prevtc = tc



stlist = sorted(stlist, key=itemgetter(1))


prevsc = 'Z' 
prevtc = 'Z'
for sc, tc in stlist:
  if prevtc == tc and prevsc != sc:
    print('No')
    exit()
  else:
    prevsc = sc
    prevtc = tc

print('Yes')

Solution (Python):
s,t=input(),input()
rs=[""for _ in range(26)]
rt=[""for _ in range(26)]
def a(n):return [chr(ord('a')+i)for i in range(26)].index(n)
for i in range(len(s)):
  ss,tt=a(s[i]),a(t[i])
  if rs[ss]=="":rs[ss]=t[i]
  elif rs[ss]!=t[i]:print("No");exit()
  if rt[tt]=="":rt[tt]=s[i]
  elif rt[tt]!=s[i]:print("No");exit()
print("Yes")

Solution (Python):

s = input()
t = input()

s_list = [ 0 for i in range(26) ]
t_list = [ 0 for i in range(26) ]
for i in range(len(s)):
    s_list[ord(s[i])-97] += 1
    t_list[ord(t[i])-97] += 1

s_list = sorted(s_list)
t_list = sorted(t_list)

if s_list == t_list:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
t=input()
ds={}
dt={}
for i in range(len(s)):
  ts=s[i]
  tt=t[i]
  if ts not in ds:
    ds[ts]=tt
    rs=tt
  else:
    rs=ds[ts]
  if tt not in dt:
    dt[tt]=ts
    rt=ts
  else:
    rt=dt[tt]
  if rs==tt and rt==ts:
    continue
  else:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
S = input()
T = input()
 
if len(set(S)) != len(set(T)):
    print("No")
    exit()
 
D = {}
for s, t in zip(S, T):
    if s not in D:
        D[s] = t
    elif D[s] != t:
        print("No")
        exit()
 
print("Yes")

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

if len(set(S)) != len(set(T)):
    print("No")
    exit()

D = {}
for s, t in zip(S, T):
    if s not in D:
        D[s] = t
    elif D[s] != t:
        print("No")
        exit()

print("Yes")

Solution (Python):

S = input()
T = input()
StoT = [-1] * 26  
TfromS = [-1]*26
ans = 1

for i in range(len(S)):
    num_s = ord(S[i]) - 97
    num_t = ord(T[i])-97
    if StoT[num_s] == -1:
        StoT[num_s] = num_t
    else:
        if StoT[num_s] != num_t:
            ans = 0
            break

    if TfromS[num_t] == -1:
        TfromS[num_t] = num_s
    else:
        if TfromS[num_t] != num_s:
            ans = 0
            break

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

Solution (Python):
from collections import defaultdict

d1 = defaultdict(lambda: 'AA')
d2 = defaultdict(lambda: 'AA')

S = input()
T = input()

flag = True
for i in range(len(S)):
    if d2[T[i]] != 'AA':
        if d2[T[i]] != S[i]:
            flag = False
            break
    if d1[S[i]] != 'AA':
        if d1[S[i]] != T[i]:
            flag = False
            break
    d1[S[i]] = T[i]
    d2[T[i]] = S[i]

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

Solution (Python):
from collections import defaultdict

d1=defaultdict(lambda:'AA')
d2=defaultdict(lambda:'AA')
S=input()
T=input()
flag =True
for i in range(len(S)):
	if d1[S[i]]!='AA':
		if d1[S[i]] != T[i]:
			flag = False
			break
	if d2[T[i]]!='AA':
		if d2[T[i]]!=S[i]:
			flag =False
			break
	d1[S[i]]=T[i]
	d2[T[i]]=S[i]
if flag:
	print('Yes')
else:
	print('No')

Solution (Python):
s = input()
t = input()
mapping_s = {}
mapping_t = {}
count_s = 0
count_t = 0
code_s = []
code_t = []
for cs, ct in zip(s, t):
    if cs not in mapping_s:
        mapping_s[cs] = count_s
        count_s += 1
    if ct not in mapping_t:
        mapping_t[ct] = count_t
        count_t += 1
    code_s.append(mapping_s[cs])
    code_t.append(mapping_t[ct])
if code_s == code_t:
    print("Yes")
else:
    print("No")

Solution (Python):


S = input()
T = input()

StoT = {}
TtoS = {}

for s, t in zip(S, T):
    if s in StoT.keys():
        if StoT[s] != t:
            print('No')
            exit()
    elif t in TtoS.keys():
        if TtoS[t] != s:
            print('No')
            exit()
    else:
        StoT[s] = t
        TtoS[t] = s
        
print('Yes')

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

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

Solution (Python):
def shurui(s):
	m=set(s)
	ans=[]
	for i in m:
		ans.append(s.count(i))
	return sorted(ans)

def resolve():
	s=input()
	t=input()
	if shurui(s)==shurui(t):
		print('Yes')
	else:
		print('No')
resolve()

Solution (Python):

def main():
    s, t = [input().rstrip() for _ in range(2)]
    d1, d2 = {}, {}
    for i, j in zip(s, t):
        if i not in d1:
            d1[i] = j
        if j not in d2:
            d2[j] = i
        if d1[i] != j or d2[j] != i:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    s, t = [input().rstrip() for _ in range(2)]
    d = {}
    for i, j in zip(s, t):
        if i not in d:
            d[i] = j
        else:
            if d[i] != j:
                print("No")
                break
    else:
        print("Yes" if len(set(s)) == len(set(t)) else "No")


if __name__ == "__main__":
    main()

Solution (Python):
s = str(input())
t = str(input())
alp_s = [0]*26
alp_t = [0]*26
for i in range(len(s)):
    a = ord(s[i])-ord("a")
    b = ord(t[i])-ord("a")
    alp_s[a]+=1
    alp_t[b]+=1
alp_s.sort()
alp_t.sort()
for i in range(26):
    if alp_s[i]!=alp_t[i]:
        print("No")
        exit()
print("Yes")

Solution (Python):
s=list(input())
t=list(input())
ls = [[] for _ in range(2)]
for i in range(len(s)):
    if s[i]==t[i]:
        if s[i] in ls[0]:
            index=ls[0].index(s[i])
            if t[i] == ls[1][index]:
                pass
            else:
                print("No")
                exit()

        else:
            if t[i] in ls[1]:
                print("No")
                exit()
            else:
                ls[0].append(s[i])
                ls[1].append(t[i])
    else:
        if s[i] in ls[0]:
            index = ls[0].index(s[i])
            if t[i] == ls[1][index]:
                pass
            else:
                print("No")
                exit()
        else:
            if t[i] in ls[1]:
                print("No")
                exit()
            else:
                ls[0].append(s[i])
                ls[1].append(t[i])
print("Yes")

Solution (Python):
import string
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

S=input()
T=input()

mp1={s: 0 for s in string.ascii_lowercase}
mp2={s: 0 for s in string.ascii_lowercase}
for i in range(len(S)):
    mp1[S[i]] += 1
    mp2[T[i]] += 1

li1 = list(mp1.values())
li2 = list(mp2.values())
li1.sort()
li2.sort()

print('Yes' if li1 == li2 else 'No')

Solution (Python):
s = input()
t = input()
lis = []
lit = []
anss = ""
anst = ""
n = len(s)
for i in range(n):
  if s[i] in lis:
    anss += str(lis.index(s[i]))
  else:
    lis.append(s[i])
    anss += str(lis.index(s[i]))
for i in range(n):
  if t[i] in lit:
    anst += str(lit.index(t[i]))
  else:
    lit.append(t[i])
    anst += str(lit.index(t[i]))
if anss == anst:
  print("Yes")
else:
  print("No")

Solution (Python):
S=input()
T=input()
a=[None]*26
b=[None]*26
k=1
for i in range(26):
    for j in range(len(S)):
        if S[j]==chr(97+i):
            if a[i]==None:
                a[i]=T[j]
            else:
                if T[j]!=a[i]:
                    k=0
                    break
for i in range(26):
    for j in range(len(S)):
        if T[j]==chr(97+i):
            if b[i]==None:
                b[i]=S[j]
            else:
                if S[j]!=b[i]:
                    k=0
                    break
if k==1:print("Yes")
else:print("No")

Solution (Python):
import sys
from collections import defaultdict
s = input()
t = input()
d1 = defaultdict(set)
d2 = defaultdict(set)

for i in range(len(s)):
    d1[t[i]].add(s[i])
    d2[s[i]].add(t[i])
    if len(d1[t[i]])>1 or len(d2[s[i]])>1:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
from collections import defaultdict
s = input()
t = input()
d1 = defaultdict(set)
d2 = defaultdict(set)
for i in range(len(s)):
  d1[t[i]].add(s[i])
  d2[s[i]].add(t[i])
  if len(d1[t[i]])>1 or len(d2[s[i]])>1:
    print("No")
    exit()
print("Yes")

Solution (Python):
S=input()
T=input()
a=[None]*26
b=[None]*26
k=1
for i in range(26):
    for j in range(len(S)):
        if S[j]==chr(97+i):
            if a[i]==None:
                a[i]=T[j]
            else:
                if T[j]!=a[i]:
                    k=0
                    break
for i in range(26):
    for j in range(len(S)):
        if T[j]==chr(97+i):
            if b[i]==None:
                b[i]=S[j]
            else:
                if S[j]!=b[i]:
                    k=0
                    break
if k==1:print("Yes")
else:print("No")

Solution (Python):
from collections import defaultdict

S = input()
T = input()

dict = defaultdict()

for i in range(len(S)):
    if S[i] in dict:
        if dict[S[i]] != T[i]:
            print("No")
            exit()
    else:
        dict[S[i]] = T[i]

dict2 = {v:k for k, v in dict.items()}
for i in range(len(T)):
    if dict2[T[i]] != S[i]:
        print("No")
        exit()
print("Yes")

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

lst_s = []
lst_t = []
for i in range(len(s)):
    if lst_s.count(s[i])==0:
        lst_s.append(s[i])
    if lst_t.count(t[i])==0:
        lst_t.append(t[i])
    if lst_s.index(s[i]) != lst_t.index(t[i]):
        print("No")
        exit()
print("Yes")

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

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

r1 = {}
r2 = {}

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

for i in range(len(s)):
    c = t[i]
    if c not in r2:
        r2[c] = s[i]
    else:
        if r2[c] != s[i]:
            print("No")
            exit()
print("Yes")

Solution (Python):
S = input()
T = input()
s_dict = {}
t_dict = {}
duplicate_flag = 0
for s,t in zip(S,T):
    if not s in s_dict:
        s_dict[s] = t
        if not t in t_dict:
            t_dict[t] = s
        else:
            print("No")
            exit()
    elif s_dict[s] != t:
        print("No")
        exit()
else:
    print("Yes")

Solution (Python):
import collections as c
s=c.Counter(input())
t=c.Counter(input())
if sorted(s.values())==sorted(t.values()):
  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):
S = input()
T = input()

if S == T:
    print('Yes')
    exit()
if len(S) != len(T):
    print('No')
    exit()

freqs = {}
freqt = {}

def calc_freq(S, freq):
    for s in S:
        if s not in freq:
            freq[s] = 1
        else:
            freq[s] += 1

calc_freq(S, freqs)
calc_freq(T, freqt)


anss = [freqs[x] for x in freqs]
anst = [freqt[x] for x in freqt]
anss.sort()
anst.sort()



if anss == anst:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections

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

c_s = collections.Counter(s)
s_values, s_counts = zip(*c_s.most_common())

c_t = collections.Counter(t)
t_values, t_counts = zip(*c_t.most_common())

if s_counts == t_counts:
    print('Yes')
else:
    print('No')

Solution (Python):

first_word = input()
second_word = input()


answer = "No"
answer_dict = {}
answer_dict2 = {}

def check_dict(dic, val_word, check_word):
  answer_bool = True
  for i in range(len(val_word)):
    if (val_word[i] in dic.keys()):
      if (dic[val_word[i]] != check_word[i]):
        answer_bool = False
        break
    else:
      dic[val_word[i]] = check_word[i]

  return answer_bool

check_1 = check_dict(answer_dict, first_word, second_word)
check_2 = check_dict(answer_dict2, second_word, first_word)
if (check_1 and check_2):
  answer = "Yes"


print(answer)

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():

  
  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']

  l2=[list() for i in range(26)]
  l3=[list() for i in range(26)]

  s=S()
  t=S()

  for i in range(len(s)):
    if len(l2[l.index(s[i])])>0:
      if l2[l.index(s[i])][0]!=t[i]:
        return 'No'
    else:
      l2[l.index(s[i])].append(t[i])
    if len(l3[l.index(t[i])])>0:
      if l3[l.index(t[i])][0]!=s[i]:
        return 'No'
    else:
      l3[l.index(t[i])].append(s[i])

  return 'Yes'

print(main())

Solution (Python):
S = input()
T = input()
TS = list(zip(T, S))

TS_set = set()
for t,s in TS:
  TS_set.add((t,s))

S_set = set()
for x in TS_set:
  S_set.add(x[1])

T_set = set()
for x in TS_set:
  T_set.add(x[0])

print("Yes" if S == T or len(TS_set) == len(S_set) == len(T_set) else "No")

Solution (Python):
def resolve():
    S = input()
    T = input()
    smap = {}
    tmap = {}
    for i in range(len(S)):
        if S[i] in smap: 
            if smap[S[i]] != T[i]:
                print("No")
                return
        else:
            smap[S[i]] = T[i]
        
        if T[i] in tmap: 
            if tmap[T[i]] != S[i]:
                print("No")
                return
        else:
            tmap[T[i]] = S[i]

    print("Yes")
    return


if '__main__' == __name__:
    resolve()

Solution (Python):

S = input()
T = input()

S_dic={}
T_dic={}

for i in range(len(S)):

    if S[i] in S_dic:
        S_dic[S[i]].append(i)
    else:
        S_dic[S[i]] = [i]

for i in range(len(T)):

    if T[i] in T_dic:
        T_dic[T[i]].append(i)
    else:
        T_dic[T[i]] = [i]





T_dicR = {}

for i in T_dic:
    T_dicR[ str(T_dic[i]) ] = 1

ans = True

for i in S_dic:

    if str(S_dic[i]) not in T_dicR:
        ans = False
        break



if ans:
    print ("Yes")

else:
    print ("No")

Solution (Python):
from collections import Counter
print("NYoe s"[sorted(list(Counter(input()).values()))==sorted(list(Counter(input()).values()))::2])

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

N = len(S)
A = []
B = []
X = {}
Y = {}
x = 0
y = 0

for n in range(N):
    if S[n] not in X:
        X[S[n]] = x
        A.append(x)
        x += 1
    if T[n] not in Y:
        Y[T[n]] = y
        B.append(y)
        y += 1
    if S[n] in X:
        A.append(X[S[n]])
    if T[n] in Y:
        B.append(Y[T[n]])
        
if A == B:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
T = input()
S_dict = dict()
T_dict = dict()
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s not in S_dict:
        S_dict[s] = []
    if t not in T_dict:
        T_dict[t] = []
    S_dict[s].append(i)
    T_dict[t].append(i)
S_Value = []
T_Value = []
for s in S_dict.values():
    S_Value.append(s)
for t in T_dict.values():
    T_Value.append(t)
S_Value.sort()
T_Value.sort()
if S_Value == T_Value:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
T = input()
 
def num_counter(s):
    form = []
    idx = 0
    visited = {}
    
    for ss in s:
        if ss not in visited:
            visited[ss] = idx
            idx += 1
        form.append(visited[ss])
    
    return form
    
S_form = num_counter(S)
T_form = num_counter(T)

if S_form == T_form:
    print('Yes')
else:
    print('No')

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

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y
    else:
        if dict_st[x] != y:
            print("No")
            break

    if y not in dict_ts:
        dict_ts[y] = x
    else:
        if dict_ts[y] != x:
            print("No")
            break
else:
    print("Yes")

Solution (Python):
from collections import defaultdict
sdic,tdic=defaultdict(int),defaultdict(int)
s=input()
t=input()

def count(str,dic):
    for i in str:
        dic[i]+=1
    dic=sorted(dic.items(),key=lambda x:x[1])
    lst=[]
    for i in range(len(dic)):
        lst.append(dic[i][1])
    return lst
  
slist=count(s,sdic); tlist=count(t,tdic)
if slist==tlist:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter
s,t=input(),input()
Sc,Tc=Counter(s),Counter(t)

if sorted(Sc.values()) == sorted(Tc.values()):
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter

s = input().rstrip()
t = input().rstrip()

cs = Counter(s)
ct = Counter(t)
s_v = sorted(cs.values())
c_v = sorted(ct.values())

if len(s_v) != len(c_v):
    print('No')
else:
    for i1, i2 in zip(s_v, c_v):
        if i1 != i2:
            print('No')
            break
    else:
        print('Yes')

Solution (Python):


from collections import Counter
S = list(input())
T = list(input())
Tdup = sorted([e for e in set(T) if T.count(e) > 1], key=T.index)
Sdup = sorted([e for e in set(S) if S.count(e) > 1], key=S.index)
if len(T) == len(set(T)) and len(S) == len(set(S)):
    print("Yes")
elif len(S) != len(set(S)) and len(T) != len(set(T)) and len(Sdup) == len(Tdup):
    counter = 0
    while counter < len(Tdup):
        Tdupid = [i for i, x in enumerate(T) if x == Tdup[counter]]
        Sdupid = [i for i, x in enumerate(S) if x == Sdup[counter]]
        if Tdupid != Sdupid:
            print("No")
            break
        else:
            counter += 1
    else:
        print("Yes")
else:
    print("No")

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  t=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']

  l1=['']*26
  l2=['']*26

  for i in range(len(s)):
    if l1[l.index(s[i])]!='':
      if l1[l.index(s[i])]!=t[i]:
        return 'No'
    else:
      l1[l.index(s[i])]=t[i]

  for i in range(len(s)):
    if l2[l.index(t[i])]!='':
      if l2[l.index(t[i])]!=s[i]:
        return 'No'
    else:
      l2[l.index(t[i])]=s[i]

  return 'Yes'

print(main())

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

n=len(s)
az=list('abcdefghijklmnopqrstuvwxyz')
ls=[set() for i in range(26)]
ls2=[set() for i in range(26)]
ans='Yes'
di=dict()
for i in range(n):
    ls[az.index(t[i])].add(s[i])
    ls2[az.index(s[i])].add(t[i])
for i in range(26):
    if len(ls[i])>1:
        ans='No'
    if len(ls2[i])>1:
        ans='No'
print(ans)

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

Solution (Python):



import sys

input = sys.stdin.readline

def main():
    S = input().strip()
    T = input().strip()
    m = {}
    for i in range(len(T)):
        if T[i] in m:
            if m[T[i]] != S[i]:
                print("No")
                return
        m[T[i]] = S[i]

    T2 = T[:]
    for i in range(len(S)):
        if S[i] == T2[i]:
            continue
        from_c = T2[i]
        to_c = S[i]
        T2 = T2.translate(str.maketrans({from_c: to_c, to_c: from_c}))

    if S != T2:
        print("No")
    else:
        print("Yes")

main()

Solution (Python):
from bisect import bisect, bisect_left
from collections import Counter, defaultdict
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor, mul

import sys


def inpl(): return list(map(int, input().split()))
S = input()
T = input()
P = defaultdict(set)

for i in range(len(S)):
    P[S[i]].add(T[i])
    

for v in P.values():
    if len(v) >= 2:
        print("No")
        break
else:
    if Counter(Counter(S).values()) == Counter(Counter(T).values()):
        print("Yes")
    else:
        print("No")

Solution (Python):
S = input()
T = input()
alph = [chr(i) for i in range(97, 97+26)]
flag = True
for a in alph:
    S_pos = [i for i in range(len(S)) if S[i] == a]
    T_pos = [i for i in range(len(T)) if T[i] == a]
    if len(S_pos) > 1:
        for i in S_pos:
            if T[i] != T[S_pos[0]]:
                flag = False
                break
    if len(T_pos) > 1:
        for i in T_pos:
            if S[i] != S[T_pos[0]]:
                flag = False
                break
    if not flag:
        break

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

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

_d = {}
for i, t in enumerate(T):
  if S[i] == _d.setdefault(t, S[i]):
    continue
  else:
    print('No')
    break
else:
  if len(set([k for k,v in _d.items()]))==len(set([v for k,v in _d.items()])):
  	print('Yes')
  else:
    print('No')

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

dict_1 = {}
dict_2 = {}

for i in range(len(S)):
    if dict_1.setdefault(S[i],T[i]) != T[i]:
        print("No")
        sys.exit()
    if dict_2.setdefault(T[i],S[i]) != S[i]:
        print("No")  
        sys.exit()  
print("Yes")

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

dict_1 = {}
dict_2 = {}

for i in range(len(S)):
    if dict_1.setdefault(S[i],T[i]) != T[i]:
        print("No")
        sys.exit()
    if dict_2.setdefault(T[i],S[i]) != S[i]:
        print("No")  
        sys.exit()  
print("Yes")

Solution (Python):
from collections import Counter

s = input()
t = input()

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
  if x not in dict_st:
    dict_st[x] = y
  else:
    if dict_st[x] != y:
      print("No")
      break
  if y not in dict_ts:
    dict_ts[y] = x
  else:
    if dict_ts[y] != x:
      print("No")
      break
else:
  print("Yes")

Solution (Python):
from collections import Counter

s = Counter(list(input()))
t = Counter(list(input()))
s = list(s.values())
t = list(t.values())
print("Yes" if sorted(s)==sorted(t) else "No")

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

memo_S = {}
memo_T = {}
answer = 'Yes'
for i in range(len(S)):
    if S[i] not in memo_S:
        memo_S[S[i]] = T[i]
    elif memo_S[S[i]] != T[i]:
        answer = 'No'
        break
    if T[i] not in memo_T:
        memo_T[T[i]] = S[i]
    elif memo_T[T[i]] != S[i]:
        answer = 'No'
        break
print(answer)

Solution (Python):
from collections import Counter

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

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

convert = dict()

bl = True
for s,t in zip(S,T):
  if s in convert and convert[s] != t:
    bl = False
    break
  convert[s] = t


after = convert.values()
if len(after) != len(set(after)):
  bl = False

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

Solution (Python):
from collections import Counter

s = input()
t = input()

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y
    else:
        if dict_st[x] != y:
            print("No")
            break
    
    if y not in dict_ts:
        dict_ts[y] = x
    else:
        if dict_ts[y] != x:
            print("No")
            break
else:
    print("Yes")

Solution (Python):
from collections import Counter

s = input()
t = input()

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

for x, y in zip(c1, c2):
    if x[1] != y[1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
S,T = input(),input()
str = "abcdefghijklmnopqrstuvwxyz"
dic,dic2 = [[] for _ in str],[[] for _ in str]
for i in range(len(S)):
    dic[str.index(S[i])].append(i)
for i in range(len(T)):
    dic2[str.index(T[i])].append(i)
dic.sort()
dic2.sort()
print("Yes" if dic == dic2 else "No")

Solution (Python):
s = str(input())
t = str(input())
d = dict()
f = dict()
for i in range(0,len(s)):
    if s[i] in d:
        if d[s[i]] != t[i]:
            print("No")
            break 
    else:
        d[s[i]] = t[i]
    if t[i] in f:
        if f[t[i]] != s[i]:
            print("No")
            break
    else:
        f[t[i]] = s[i]
else:
    print("Yes")

Solution (Python):
def pare_exist(ST_pare_lst, Si, Ti):
    if (Si, Ti) in ST_pare_lst:
        return True
    else:
        for Sj, Tj in ST_pare_lst:
            if (Sj == Si and Tj != Ti) or (Sj != Si and Tj == Ti):
                return False
        
        ST_pare_lst.append((Si, Ti))
        return None

def exchanging(S, T):
    ST_pare_lst = []
    length = len(S)

    for i in range(length):
        judge = pare_exist(ST_pare_lst, S[i], T[i])
        if judge is None:
            pass
        elif judge == True:
            pass
        else:   
            return False
    return True

def same_chr_contain(S, T):
    S_chr_lst = []
    T_chr_lst = []
    for i in range(len(S)):
        if not S[i] in S_chr_lst:
            S_chr_lst.append(S[i])
        if not T[i] in T_chr_lst:
            T_chr_lst.append(T[i])

    if len(S_chr_lst) == len(T_chr_lst):
        return True
    else:
        return False

S = input()
T = input()

ST_pare_lst = []
length = len(S)

if not same_chr_contain(S, T):
    print("No")
elif exchanging(S, T):
    print("Yes")
else:
    print("No")

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

S1=collections.Counter(S).most_common()
T1=collections.Counter(T).most_common()
if len(S1)!=len(T1):print('No');exit()
elif all(S1[i][1]==T1[i][1] for i in range(len(S1))):print('Yes')
else:print('No')

Solution (Python):
s=input()
t=input()
ss=list(set(s))
st=list(set(t))
s_cnt=[0]*len(ss)
t_cnt=[0]*len(st)
ans='No'
for i in range(len(ss)):
    s_cnt[i]=s.count(ss[i])
for i in range(len(st)):
    t_cnt[i]=t.count(st[i])
s_cnt.sort()
t_cnt.sort()
if  s_cnt==t_cnt:
    ans='Yes'
print(ans)

Solution (Python):
s = input()
t = input()
sn=[0 for i in range(26)]
tn=[0 for i in range(26)]
for i in range(len(s)):
    sn[ord(s[i])-ord('a')]+=1
    tn[ord(t[i])-ord('a')]+=1
print('Yes' if sorted(sn) == sorted(tn) else 'No')