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
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    t=input()
    s_lis=[[] for _ in range(32)]
    t_lis=[[] for _ in range(32)]
    for i,ss in enumerate(s):
        s_lis[ord(ss)-ord('a')].append(i)
    for i,tt in enumerate(t):
        t_lis[ord(tt)-ord('a')].append(i)
    ss_lis=[sl for sl in s_lis if len(sl)>0]
    tt_lis=[tl for tl in t_lis if len(tl)>0] 
    ss_lis.sort()
    tt_lis.sort()
    if all([True if x==y else False for x,y in zip(ss_lis,tt_lis)]):
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    t=input()
    s_lis=[[] for _ in range(32)]
    t_lis=[[] for _ in range(32)]
    for i,ss in enumerate(s):
        s_lis[ord(ss)-ord('a')].append(i)
    for i,tt in enumerate(t):
        t_lis[ord(tt)-ord('a')].append(i)
    ss_lis=[sl for sl in s_lis if len(sl)>0]
    tt_lis=[tl for tl in t_lis if len(tl)>0] 
    ss_lis.sort()
    tt_lis.sort()
    if all([True if x==y else False for x,y in zip(ss_lis,tt_lis)]):
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    main()

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

    st = dict()
    ts = dict()
    cond = True
    for sc, tc in zip(s, t):
        if st.get(sc, None) is None:
            st[sc] = tc
        if st[sc] != tc:
            cond = False
            break
        if ts.get(tc, None) is None:
            ts[tc] = sc
        if ts[tc] != sc:
            cond = False
            break

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


if __name__ == '__main__':
    main()

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

S_char_count = [[c, n] for c, n in collections.Counter(S).items()]
T_char_count = [[c, n] for c, n in collections.Counter(T).items()]
S_char_count.sort(key=lambda S_char_count: S_char_count[1])
T_char_count.sort(key=lambda T_char_count: T_char_count[1])

ans = 'Yes'
if len(S_char_count) == len(T_char_count):
  for i in range(len(S_char_count)):
    if S_char_count[i][1] != T_char_count[i][1]:
      ans = 'No'
      break
else:
  ans = 'No'

print(ans)

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

s_c = sorted(Counter(s).values())
t_c = sorted(Counter(t).values())

if s_c==t_c:print('Yes')
else:print('No')

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

s = input()
t = input()
c1 = collections.Counter(s)
c2 = collections.Counter(t)
value1 = []
value2 = []
for value in c1.values():
    value1.append(value)
for value in c2.values():
    value2.append(value)
value1.sort(),value2.sort()
if value1 == value2:
    print("Yes")
else:
    print("No")

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

memo_s = {"a":-1,"b":-1,"c":-1,"d":-1,"e":-1,"f":-1,"g":-1,"h":-1,"i":-1,"j":-1,"k":-1,"l":-1,"m":-1,"n":-1,"o":-1,"p":-1,"q":-1,"r":-1,"s":-1,"t":-1,"u":-1,"v":-1,"w":-1,"x":-1,"y":-1,"z":-1}
memo_t = {"a":-1,"b":-1,"c":-1,"d":-1,"e":-1,"f":-1,"g":-1,"h":-1,"i":-1,"j":-1,"k":-1,"l":-1,"m":-1,"n":-1,"o":-1,"p":-1,"q":-1,"r":-1,"s":-1,"t":-1,"u":-1,"v":-1,"w":-1,"x":-1,"y":-1,"z":-1}

for i in range(N):
    if memo_s[S[i]] == -1 and memo_t[T[i]] == -1:
        memo_s[S[i]] = T[i]
        memo_t[T[i]] = S[i]
    else:
        if memo_s[S[i]] != T[i] or memo_t[T[i]] != S[i]:
            print("No")
            quit()

print("Yes")

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

R1 = [-1] * 26
R2 = [-1] * 26

l = len(S)
ord_a = ord("a")

for i in range(l):
    s = ord(S[i]) - ord_a
    t = ord(T[i]) - ord_a
    if R1[s] < 0:
        R1[s] = t
    else:
        if R1[s] != t:
            print("No")
            exit()
    if R2[t] < 0:
        R2[t] = s
    else:
        if R2[t] != s:
            print("No")
            exit()

print("Yes")

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

start = {chr(i):-1 for i in range(97,97+26)}
goal = {chr(i):-1 for i in range(97,97+26)}
ans = 'Yes'
for i in range(N):
    s = S[i]
    t = T[i]
    if start[s] != -1 and start[s] != t:
        ans = 'No'
    if goal[t] != -1 and goal[t] != s:
        ans = 'No'
    start[s] = t
    goal[t] = s

print(ans)

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

start = [-1 for i in range(26)]
goal = [-1 for i in range(26)]
a = ord('a')
ans = 'Yes'
for i in range(N):
    s = ord(S[i])-a
    t = ord(T[i])-a
    if start[s] != -1 and start[s] != t:
        ans = 'No'
    if goal[t] != -1 and goal[t] != s:
        ans = 'No'
    start[s] = t
    goal[t] = s

print(ans)

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

start = [-1 for i in range(26)]
goal = [-1 for i in range(26)]
a = ord('a')
ans = 'Yes'
for i in range(N):
    s = ord(S[i])-a
    t = ord(T[i])-a
    if start[s] != -1 or goal[t] != -1:
        if start[s] != t or goal[t] != s:
            ans = 'No'
    start[s] = t
    goal[t] = s


print(ans)

Solution (Python):
S = input()
T = input()
N = len(S)
 
d = {chr(i):chr(i) for i in range(97,97+26)}
 
ans = 'Yes'
for i in range(N):
    now_si = d[S[i]]
    for k,v in d.items():
        if v == now_si:
            d[k] = T[i]
        elif v == T[i]:
            d[k] = now_si
 
for i in range(N):
    if d[S[i]] != T[i]:
        ans = 'No'
        break
 
 
print(ans)

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

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

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

S = input()
T = input()

if S==T:
    print("Yes")
    exit()

ls1 = ["?"]*26
ls2 = ["?"]*26
for i in range(len(S)):
    s = S[i]
    t = T[i]
    no1 = ord(s) - 97
    no2 = ord(t) - 97
    if ls1[no1]=="?":
        ls1[no1] = t
    else:
        if ls1[no1]==t:
            pass
        else:
            print("No")
            exit()
    if ls2[no2]=="?":
        ls2[no2] = s
    else:
        if ls2[no2]==s:
            pass
        else:
            print("No")
            exit()

print("Yes")
exit()

Solution (Python):
from collections import defaultdict
S = input()
T = input()
s_map = defaultdict(str)
t_map = defaultdict(str)
ans = 'Yes'
for s, t in zip(S, T):
    if len(s_map[s]) > 0:
        if s_map[s] != t:
            ans = 'No'
    if len(t_map[t]) > 0:
        if t_map[t] != s:
            ans = 'No'
    s_map[s] = t
    t_map[t] = s

print(ans)

Solution (Python):


s = input()
t = input()
 
before = [-1] * 26
after = [-1] * 26
 
for i, j in zip(s, t):
    si = ord(i) - ord('a')
    ti = ord(j) - ord('a')
 
    if before[si] != -1 or after[ti] != -1:
        if before[si] != ti or after[ti] != si:
            print("No")
            exit()
 
    before[si] = ti
    after[ti] = si
print("Yes")

Solution (Python):
A = {chr(i):0 for i in range(97,123)}
S = input().strip()
T = input().strip()
N = len(S)
G = {}
for i in range(N):
    a = S[i]
    if a not in G:
        G[a]=[]
    b = T[i]
    if b not in G[a]:
        G[a].append(b)
flag = 0
cnt = 0
for a in G:
    cnt += 1
    if len(G[a])>1:
        flag = 1
        break
    if len(G[a])==0 and cnt==26:
        break
    b = G[a][0]
    if a!=b:
        cnt += 1
    if A[b]==0:
        A[b] += 1
    else:
        flag = 1
        break
if flag==1:
    print("No")
else:
    print("Yes")

Solution (Python):
from collections import Counter

s=input()
t=input()

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

print('Yes' if sorted(cs.values())==sorted(ct.values()) else 'No')

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    dict1 = {}
    dict2 = {}
    for s, t in zip(S, T):
        if dict1.get(t) is not None and dict1[t] != s:
            print("No")
            exit()

        if dict2.get(s) is not None and dict2[s] != t:
            print("No")
            exit()

        dict1[t] = s
        dict2[s] = t

    print("Yes")


if __name__ == '__main__':
    resolve()

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

d = {chr(i):chr(i) for i in range(97,97+26)}

ans = 'Yes'
for i in range(N):
    now_si = d[S[i]]
    for k,v in d.items():
        if v == now_si:
            d[k] = T[i]
        elif v == T[i]:
            d[k] = now_si

for i in range(N):
    if d[S[i]] != T[i]:
        ans = 'No'


print(ans)

Solution (Python):
s = list(input())
t = list(input())
s_set = list(set(s))
t_set = list(set(t))

for j in range(len(s_set)):
    tmp = []
    for k in range(len(s)):
        if s_set[j] == s[k]:
            tmp.append(t[k])
    if len(set(tmp)) > 1:
        print('No')
        exit()

for p in range(len(t_set)):
    tmp = []
    for q in range(len(t)):
        if t_set[p] == t[q]:
            tmp.append(s[q])
    if len(set(tmp)) > 1:
        print('No')
        exit()

print('Yes')

Solution (Python):
S=list(input())
T=list(input())
N=len(S)
D1={}
D2={}
count=0
for i in range(N):
    s=S[i]
    t=T[i]
    if s not in D1:
        D1[s]=count
        S[i]=count
    else:
        S[i]=D1[s]
    if t not in D2:
        D2[t]=count
        T[i]=count
        count+=1
    else:
        T[i]=D2[t]

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
t = list(input())
ss = [s,t]
n = len(s)
res = [[],[]]
for i in range(2):
    d = defaultdict(int)
    cnt = 1
    for j,x in enumerate(ss[i]):
        if d[x] == 0:
            d[x] = cnt
            cnt += 1
        res[i].append(d[x])
print('Yes' if res[0] == res[1] else 'No')

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    dict = {}
    for s, t in zip(S, T):
        if dict.get(t) is not None and dict[t] != s:
            print("No")
            exit()
        else:
            dict[t] = s

    if len(set(dict.values())) == len(dict):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()

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

def check():
    n = len(S)
    dic1,dic2 = {},{}
    for i in range(n):
        if T[i] not in dic1:
            dic1[T[i]] = S[i]
        elif dic1[T[i]] != S[i]:
            return 'No'
        if S[i] not in dic2:
            dic2[S[i]] = T[i]
        elif dic2[S[i]] != T[i]:
            return 'No'
    return 'Yes'
print(check())

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7



alphasm=[chr(i) for i in range(97, 97+26)]
s=input().rstrip()
t=input().rstrip()
u=Counter(list(s))
v=Counter(list(t))
a,b=[],[]
for i in alphasm:
    a.append(u[i])
    b.append(v[i])
a.sort()
b.sort()
if a==b:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    S=readline().strip()
    T=readline().strip()

    d=dict()
    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")
                break
    else:
        li=list(d.items())
        d2=dict()
        for cs in li:
            c1=cs[0]
            c2=cs[1]
            if c2 not in d2:
                d2[c2]=c1
            else:
                if d2[c2]!=c1:
                    print("No")
                    break
        else:
            print("Yes")
if __name__=="__main__":
    main()

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

slist = []
scount = []
tlist = []
tcount = []

for i in range(n):
  if not s[i] in slist:
    slist.append(s[i])
    scount.append(1)
  else:
    for j in range(len(slist)):
      if slist[j] == s[i]:
        scount[j] += 1
   
  if not t[i] in tlist:
    tlist.append(t[i])
    tcount.append(1)
  else:
    for j in range(len(tlist)):
      if tlist[j] == t[i]:
        tcount[j] += 1
        
print("Yes") if scount == tcount else print("No")

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

Solution (Python):
from collections import Counter
s = Counter(input())
t = Counter(input())
s_n = sorted([x for x in s.values()])
t_n = sorted([x for x in t.values()])
print("Yes" if s_n==t_n else "No")

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import Counter

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

SC = Counter(S)
TC = Counter(T)

lstS = []
for s in SC:
    lstS.append(SC[s])

lstT = []
for t in TC:
    lstT.append(TC[t])

lstS.sort()
lstT.sort()

if lstS == lstT:
    print ('Yes')
else:
    print ('No')

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

def isOk():
    sToT = {}
    tToS = {}
    for s, t in zip(S, T):
        if not s in sToT:
            sToT[s] = t
        elif sToT[s] != t:
            return False
        if not t in tToS:
            tToS[t] = s
        elif tToS[t] != s:
            return False
    return True

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

Solution (Python):
s = input()
t = input()
cnt1 = [0]*26
cnt2= [0]*26
for x in s:
    cnt1[ord(x) - ord('a')] += 1
for x in t:
    cnt2[ord(x) - ord('a')] += 1
cnt1.sort()
cnt2.sort()
ok = True
for i in range(26):
    if cnt1[i] != cnt2[i]:
        ok = False
        break
if ok:print('Yes')
else:print('No')

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

s_alph_index = {}
for i in range(len(s)):
    if s[i] not in s_alph_index:
        s_alph_index[s[i]] = [i,]
    else:
        s_alph_index[s[i]].append(i)
t_alph_index = {}
for i in range(len(t)):
    if t[i] not in t_alph_index:
        t_alph_index[t[i]] = [i,]
    else:
        t_alph_index[t[i]].append(i)

for key, vals in s_alph_index.items():
    cur = t[vals[0]]
    for index in vals:
        if t[index] != cur:
            print('No')
            exit()

for key, vals in t_alph_index.items():
    cur = s[vals[0]]
    for index in vals:
        if s[index] != cur:
            print('No')
            exit()

print('Yes')

Solution (Python):
s = list(input())
t = list(input())
s_set = list(set(s))
t_set = list(set(t))
l = len(s)
l_s_set = len(s_set)
l_t_set = len(t_set)

x = [[] for _ in range(l)]
for i in range(l):
    x[i].append(s[i])
    x[i].append(t[i])

for j in range(l_s_set):
    tmp = []
    for k in range(l):
        if s_set[j] == x[k][0]:
            tmp.append(x[k][1])
    if len(set(tmp)) > 1:
        print('No')
        exit()

for p in range(l_t_set):
    tmp = []
    for q in range(l):
        if t_set[p] == x[q][1]:
            tmp.append(x[q][0])
    if len(set(tmp)) > 1:
        print('No')
        exit()

print('Yes')

Solution (Python):

import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
T = sr()
cnt_S = Counter(S)
cnt_T = Counter(T)
num_S = sorted(list(cnt_S.values()))
num_T = sorted(list(cnt_T.values()))

bl = num_S == num_T
print('Yes' if bl else 'No')

Solution (Python):
S = input()
T = input()
d = {}

for s, t in zip(S, T):
  if s in d:
    
    if d[s] != t:
      print("No")
      exit()
  else:
    d[s] = t


if len(d) != len(set(d.values())):
  print("No")
else:
  print("Yes")

Solution (Python):
s = input()
t = input()
li_s = list(s)
li_t = list(t)
ma = {}
ma_2 = {}
for i,j in zip(li_s,li_t):
    if j not in ma:
        ma[j] = i
    elif ma[j] != i:
        print('No')
        exit()

    if i not in ma_2:
        ma_2[i] = j
    elif ma_2[i] != j:
        print('No')
        exit()
print('Yes')

Solution (Python):
s = list(input())
t = list(input())
n = len(s)
sp = []
tp = []
for i in range(n):
    if not s[i] in sp:
        sp.append(s[i])
    x = sp.index(s[i])
    if not t[i] in tp:
        tp.append(t[i])
    y = tp.index(t[i])
    
    if x != y:
        print("No")
        exit()
print("Yes")

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


s=input().rstrip()
t=input().rstrip()
u=Counter(s)
v=Counter(t)
for i in range(len(s)):
    if u[s[i]]!=v[t[i]]:
        print("No")
        
        sys.exit()
print("Yes")

Solution (Python):
from collections import Counter
s = Counter(input())
t = Counter(input())
sc = sorted([x for x in s.values()])
tc = sorted([x for x in t.values()])
print("Yes" if sc==tc else "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):
import sys
s = input()
t = input()
v = {}
for i, c in enumerate(s):
  if s[i] not in v:
    v[s[i]] = t[i]
  elif v[s[i]] != t[i]:
    print('No')
    sys.exit()
  else:
    v[s[i]] = t[i]
st = set()
for x in v.values():
  if x in st:
    print('No')
    sys.exit()
  else:
    st.add(x)
print('Yes')

Solution (Python):


S = input()
T = input()

s_t = {}
t_s = {}

for s, t in zip(S, T):
    if s not in s_t:
        s_t[s] = t
    else:
        if s_t[s] != t:
            print("No") 
            exit()
            
    if t not in t_s:
        t_s[t] = s
    else:
        if t_s[t] != s:
            print("No") 
            exit()
print("Yes")

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):
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    S = collections.Counter(iss())
    T = collections.Counter(iss())

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


if __name__ == '__main__':
    main()

Solution (Python):
s=input()
t=input()
d={}
for i in range(len(s)):
    if s[i] in d.keys():
        if d[s[i]]!=t[i]:
            print("No")
            exit()
    else:
        if t[i] in d.values():
            print("No")
            exit()
        else:
            d[s[i]]=t[i]

print("Yes")

Solution (Python):
def cn(s):
    return ord(s)-ord("a")
s  = input()
t  = input()
alp = "abcdefghijklmnopqrstuvwxyz"
arr = [-1]*26
arrt = [-1]*26
f =True
for i in range(len(s)):
    if arr[cn(s[i])] ==-1:
        arr[cn(s[i])] = cn(t[i])
    elif arr[cn(s[i])] != cn(t[i]):
        f=False
        break
for i in range(len(s)):
    if arrt[cn(t[i])] ==-1:
        arrt[cn(t[i])] = cn(s[i])
    elif arrt[cn(t[i])] != cn(s[i]):
        f=False
        break

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

Solution (Python):
s=input()
t=input()
dicST={}
dicTS={}

for i,j in zip(s,t):
  if (dicTS.get(j,0) != 0 and dicTS[j] != i) or \
    (dicST.get(i,0) != 0 and dicST[i] != j):
    print("No")
    break
  else:
    dicTS[j] = i
    dicST[i] = j
else:
  print("Yes")

Solution (Python):
from collections import defaultdict

S = input()
T = input()

S_dict, T_dict = defaultdict(list), defaultdict(list)
for i, s in enumerate(S):
    S_dict[s].append(i)
for i, t in enumerate(T):
    T_dict[t].append(i)

S_set, T_set = set(), set()
for s in S_dict.values():
    S_set.add(tuple(s))
for t in T_dict.values():
    T_set.add(tuple(t))

print('Yes' if S_set == T_set else 'No')

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

n = len(s)

from collections import defaultdict
ds = defaultdict(list)
dt = defaultdict(list)

for i in range(n):
    if s[i] in ds.keys():
        if ds[s[i]] != t[i]:
            print('No')
            exit()
    else:
        ds[s[i]] = t[i]

for i in range(n):
    if t[i] in dt.keys():
        if dt[t[i]] != s[i]:
            print('No')
            exit()
    else:
        dt[t[i]] = s[i]

print('Yes')

Solution (Python):
S = input()
T = input()
d = {}

for s, t in zip(S, T):
  if s in d:
    
    if d[s] != t:
      print("No")
      exit()
  else:
    d[s] = t


if len(d) != len(set(d.values())):
  print("No")
else:
  print("Yes")

Solution (Python):
S = input()
T = input()
d = {}

for s, t in zip(S, T):
  if s in d:
    if d[s] != t:
      print("No")
      exit()
  else:
    d[s] = t

if len(d) != len(set(d.values())):
  print("No")
else:
  print("Yes")

Solution (Python):
import sys
S=input()
T=input()
start=[-1 for i in range(26)]
goal=[-1 for i in range(26)]
alp=[i for i in "abcdefghijklmnopqrstuvwxyz"]
for i in range(len(S)):
  ind_s=alp.index(S[i])
  ind_t=alp.index(T[i])

  if start[ind_s]!=-1 or goal[ind_t]!=-1:
    if start[ind_s]!=ind_t or goal[ind_t]!=ind_s:
      print("No")
      sys.exit()
  else:
    start[ind_s]=ind_t
    goal[ind_t]=ind_s
print("Yes")

Solution (Python):
import sys

S = input()
T = input()

d_T = {}
d_S = {}

for i in range(len(S)):
    if T[i] in d_T and d_T[T[i]]!=S[i]:
        print("No")
        sys.exit()
    d_T[T[i]] = S[i]

for i in range(len(T)):
    if S[i] in d_S and d_S[S[i]]!=T[i]:
        print("No")
        sys.exit()
    d_S[S[i]] = T[i]


print("Yes")

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

dcts = {}
dctt = {}
jdg = True

for i, s in enumerate(S):
    if s in dcts.keys():
        if dcts[s]!=T[i]:
            jdg = False
            break
    else: dcts[s] = T[i]
    if T[i] in dctt.keys():
        if dctt[T[i]]!=s:
            jdg = False
            break
    else: dctt[T[i]] = s
print('Yes' if jdg else 'No')

Solution (Python):

from collections import defaultdict
import sys


YES = "Yes"  
NO = "No"  


def solve(S: str, T: str):
    d1 = defaultdict(set)
    for i, si in enumerate(S):
        d1[si].add(i)
    d2 = defaultdict(set)
    for i, ti in enumerate(T):
        d2[ti].add(i)
    print(
        YES if
        set(frozenset(s) for s in d1.values()) ==
        set(frozenset(s) for s in d2.values())
        else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    T = next(tokens)  
    solve(S, T)


if __name__ == '__main__':
    main()

Solution (Python):


sl=list(input())
tl=list(input())


sdic={}
tdic={}
flag=True
for i in range(len(sl)):
    s=sl[i]
    t=tl[i]
    if sdic.get(s,-1)==-1:
        sdic[s]=t
    else:
        if sdic[s]!=t:
            flag=False
            break
    if tdic.get(t,-1)==-1:
        tdic[t]=s
    else:
        if tdic[t]!=s:
            flag=False
            break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')


def solve():
    S = list(input())
    T = list(input())

    ds = {}
    dt = {}
    ids = ''
    idt = ''
    cids = 0
    cidt = 0
    for i in range(len(S)):
        
        s = S[i]
        if s in ds:     
            idss = ds[s]
            ids = ids + str(idss)
        else:           
            cids += 1
            ds[s] = cids
            ids = ids + str(cids)

        
        t = T[i]
        if t in dt:
            idst = dt[t]
            idt = idt + str(idst)
        else:
            cidt += 1
            dt[t] = cidt
            idt = idt + str(cidt)

        if ids != idt:
            print('No')
            return

    print('Yes')



if __name__ == '__main__':
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    S = list(input())
    T = list(input())

    ds = {}
    dt = {}
    ids = ''
    idt = ''
    cids = 0
    cidt = 0
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if s in ds:
            idss = ds[s]
            ids = ids + str(idss)
        else:
            cids += 1
            ds[s] = cids
            ids = ids + str(cids)

        if t in dt:
            idst = dt[t]
            idt = idt + str(idst)
        else:
            cidt += 1
            dt[t] = cidt
            idt = idt + str(cidt)

    print('Yes' if ids == idt else 'No')



if __name__ == '__main__':
    solve()

Solution (Python):
s=input()
t=input()
ns,nt=0,0
anss,anst=s,t
sl,tl=[],[]
for i in range(len(s)):
    if s[i] in sl:
        pass
    else:
        ns+=1
        sl.append(s[i])
        anss=anss.replace(s[i],str(ns))
    if t[i] in tl:
        pass
    else:
        nt+=1
        tl.append(t[i])
        anst=anst.replace(t[i],str(nt))
print('Yes' if anss==anst else 'No')

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

a="abcdefghijklmnopqrstuvwxyz"
rs=dict()
rt=dict()
for i in range(26):
    rs[a[i]]=-1
    rt[a[i]]=-1

yn="Yes"
for i in range(len(s)):
    if rs[s[i]]==-1:
        rs[s[i]]=t[i]
    else:
        if rs[s[i]]!=t[i]:
            yn="No"
            break
    if rt[t[i]]==-1:
        rt[t[i]]=s[i]
    else:
        if rt[t[i]]!=s[i]:
            yn="No"
            break       
print(yn)

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

a=list("abcdefghijklmnopqrstuvwxyz")

rs=dict()
rt=dict()
for i in range(26):
    rs[a[i]]=-1
    rt[a[i]]=-1

yn="Yes"
for i in range(len(s)):
    if rs[s[i]]==-1:
        rs[s[i]]=t[i]
    else:
        if rs[s[i]]!=t[i]:
            yn="No"
            break
    if rt[t[i]]==-1:
        rt[t[i]]=s[i]
    else:
        if rt[t[i]]!=s[i]:
            yn="No"
            break
        
print(yn)

Solution (Python):

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

a=list("abcdefghijklmnopqrstuvwxyz")

rs=dict()
rt=dict()
for i in range(26):
    rs[a[i]]=-1
    rt[a[i]]=-1

yn=""
for i in range(len(s)):
    if rs[s[i]]==-1:
        rs[s[i]]=t[i]
    else:
        if rs[s[i]]!=t[i]:
            yn="No"
            break
    if rt[t[i]]==-1:
        rt[t[i]]=s[i]
    else:
        if rt[t[i]]!=s[i]:
            yn="No"
            break
        
if yn=="No":
    print("No")
else:
    print("Yes")

Solution (Python):
s1 = input()
s2 = input()
dict_s1 = {}
dict_s2 = {}
for i in range(len(s1)):
    if s1[i] not in dict_s1:
        dict_s1[s1[i]] = s2[i]
    else:
        if dict_s1[s1[i]] != s2[i]:
            print('No')
            quit()
    if s2[i] not in dict_s2:
        dict_s2[s2[i]] = s1[i]
    else:
        if dict_s2[s2[i]] != s1[i]:
            print('No')
            quit()
print('Yes')

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

st = defaultdict(lambda :0)
for x, y in zip(s,t):
    if (st[(y, 1)] != 0 and st[(y, 1)] != x) or (st[(x, 0)] != 0 and st[(x, 0)] != y):
        
        print('No')
        exit()
    st[(y, 1)] = x
    st[(x, 0)] = y

print('Yes')