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

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




s_dict = Counter(s)
t_dict = Counter(t)
s_val = list(s_dict.values())
t_val = list(t_dict.values())
s_val.sort()
t_val.sort()
if s_val == t_val:
    print('Yes')
else:
    print('No')

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

dict_S={}
dict_T={}

for x, y in zip(S, T):
    if x not in dict_S:
        dict_S[x] = y
    else:
        if dict_S[x] != y:
            print("No")
            exit()

    if y not in dict_T:
        dict_T[y] = x
    else:
        if dict_T[y] != x:
            print("No")
            exit()


print("Yes")

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 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):
from collections import Counter

s = input()
t = input()

ss = sorted(Counter(s).values())
st = sorted(Counter(t).values())

print("Yes") if ss == st else print("No")

Solution (Python):
s=input()
t=input()
sset=set()
tset=set()
j=1
alp={}
ds=[0]*len(s)
for i in range(len(s)):
  if not s[i] in sset:
    alp[s[i]]=j
    ds[i]=j
    sset.add(s[i])
    j+=1
  else:
    ds[i]=alp[s[i]]
j=1
alp={}
dt=[0]*len(t)
for i in range(len(t)):
  if not t[i] in tset:
    alp[t[i]]=j
    dt[i]=j
    tset.add(t[i])
    j+=1
  else:
    dt[i]=alp[t[i]]
for i in range(len(s)):
  if ds[i]!=dt[i]:
    print('No')
    exit()
print('Yes')

Solution (Python):
"""
必要十分条件
１）Sの中の同じ文字が、Tの別の文字に対応していない
２）Tの中の同じ文字が、Sの別の文字に対応していない
"""

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):
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):
def solve():
    S=input()
    n=len(S)
    S1=[1]
    k=1
    for i in range(1,n):
        if S[i] not in S[:i]:
            k+=1
            S1.append(k)
        else:
            num=S1[S.find(S[i])]
            S1.append(num)
    return S1

S1=solve()
T1=solve()

if S1==T1:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()
sl = len(s)
ss = ""
used = [False]*26
cnt = 0
for i in range(sl):
    if used[(ord(s[i])-97)%26]:
        ss += str(used[(ord(s[i])-97)%26])
    else:
        cnt += 1
        ss += str(cnt)
        used[(ord(s[i])-97)%26] = cnt

used = [False]*26
tt = ""
cnt = 0
for i in range(sl):
    if used[(ord(t[i])-97)%26]:
        tt += str(used[(ord(t[i])-97)%26])
    else:
        cnt += 1
        tt += str(cnt)
        used[(ord(t[i])-97)%26] = cnt

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

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

def char_list(s):
    l = [0] * 26
    for x in s:
        i = ord(x) - ord("a")
        l[i] += 1
    l.sort()
    return l

l1 = char_list(s)
l2 = char_list(t)

if l1 == l2:
    print("Yes")
else:
    print("No")

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

d = defaultdict(str)



for i in range(n):
    if d[t[i]] == "":
        d[t[i]] = s[i]
    elif d[t[i]] != s[i]:
        print("No")
        exit()
d.clear()
for i in range(n):
    if d[s[i]] == "":
        d[s[i]] = t[i]
    elif d[s[i]] != t[i]:
        print("No")
        exit()

print("Yes")

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

d={}

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

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

Solution (Python):
S = input()
T = input()
S_cnt = sorted(S.count(c) for c in set(S))
T_cnt = sorted(T.count(c) for c in set(T))
print("Yes") if S_cnt == T_cnt else print("No")

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

trans_dict = {}

for i in range(len(S)):
    s = S[i]
    t = T[i]

    if s in trans_dict:
        if not trans_dict[s] == t:
            print('No')
            exit()
    else:
        trans_dict[s] = t

if len(trans_dict.values()) == len(set(trans_dict.values())):
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter
S = list(input())
T = list(input())
change = [-1]*27
ans = "Yes"
for i in range(len(S)):
    s = ord(S[i])-97
    if S[i] == T[i]:
        change[s] = s
    elif change[s] == -1:
        change[s] = ord(T[i])-97
    else:
        t = ord(T[i])-97
        if change[s] != t:
            ans = "No"
            break
change=Counter(change)
del change[-1]
for i in change.values():
    if i==1:
        continue
    else:
        ans="No"
print(ans)

Solution (Python):
def main():
    from string import ascii_lowercase
    S = input()
    T = input()

    dic1 = {a: set() for a in ascii_lowercase}
    dic2 = {a: set() for a in ascii_lowercase}
    for s, t in zip(S, T):
        dic1[s].add(t)
        dic2[t].add(s)
    if all(len(s) <= 1 for s in dic1.values()) and\
            all(len(s) <= 1 for s in dic2.values()):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
S = input().strip()
T = input().strip()
N = len(S)
C = {}
D = {}
flag = 0
for i in range(N):
    if S[i] not in C:
        C[S[i]] = T[i]
    elif C[S[i]]!=T[i]:
        flag = 1
        break
    if T[i] not in D:
        D[T[i]] = S[i]
    elif D[T[i]] != S[i]:
        flag = 1
        break
if flag==0:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
t = input()
alp =list("abcdefghijklmnopqrstuvwxyz")
sl = [0] * 26
tl = [0] * 26
for j in range(26):
        sl[j] = s.count(alp[j])
for j in range(26):
        tl[j] = t.count(alp[j])
sl.sort()
tl.sort()
if(sl == tl):
    print("Yes")
else:
    print("No")

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re












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

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
dics = defaultdict(str)
dict = defaultdict(str)
s = input()
t = input()
for i in range(len(s)):
    if dics[s[i]]:
        if dics[s[i]] == t[i]:
            pass
        else:
            print('No')
            exit()
    else:
        dics[s[i]] = t[i]
    if dict[t[i]]:
        if dict[t[i]] == s[i]:
            pass
        else:
            print('No')
            exit()
    else:
        dict[t[i]] = s[i]
print('Yes')

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

from collections import Counter
cs = Counter(s)
ct = Counter(t)

cs = list(cs.values())
ct = list(ct.values())

cs.sort()
ct.sort()

if cs == ct:
    print('Yes')
else:
    print('No')

Solution (Python):

import sys
def main(S, T):
    d = dict()
    for i in range(len(S)):
        if S[i] != T[i]:
            if T[i] not in d:
                d[T[i]] = True
                S = ''.join([T[i] if s == S[i] else S[i] if s == T[i] else s for s in S])
            else:
                return False
    if S == T:
        return True
    return False

if __name__ == '__main__':
    input = sys.stdin.readline
    S = input().rstrip()
    T = input().rstrip()
    ans = main(S, T)
    print('Yes' if ans else 'No')

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

ans = "Yes"
for x,y in zip(s.items(), t.items()):
    if x[1] != y[1]:
        ans = "No"
print(ans)

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

d = {}
for si,ti in zip(s,t):
    if not si in d:
        d[si] = ti
    else:
        if d[si] != ti:
            print('No')
            break
else:
    sset = set()
    for v in d.values():
        if v in sset:
            print('No')
            break
        sset.add(v)
    else:
        print('Yes')

Solution (Python):
import sys
s = list(input())
t = list(input())
a = [-1 for _ in range(26)]
b = [-1 for _ in range(26)]

for i in range(len(s)):
    num0, num1 = a[ord(s[i])-97], b[ord(t[i])-97]
    if num0 >= 0:
        if chr(num0+97) != t[i]:
            print('No')
            sys.exit()
    else:
        a[ord(s[i])-97] = ord(t[i])-97
        
    if num1 >= 0:
        if chr(num1+97) != s[i]:
            print('No')
            sys.exit()
    else:
        b[ord(t[i])-97] = ord(s[i])-97
            
print('Yes')

Solution (Python):
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    T = input()
    dictS =dict()
    dictT =dict()

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

        if T[i] in dictT:
            if dictT[T[i]] !=S[i]:
                print("No")
                exit()
        else:
            dictT[T[i]] =S[i]

    print("Yes")



if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


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

    c_S = Counter(S)
    c_T = Counter(T)
    count_S = list(c_S.values())
    count_T = list(c_T.values())
    count_S.sort()
    count_T.sort()
    is_same = True
    for s, t in zip(count_S, count_T):
        if s != t:
            is_same = False
            break

    ans = "Yes" if is_same else "No"
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
S=input()
T=input()
from collections import*
cs=Counter(S)
ct=Counter(T)
csv=sorted(cs.values())
ctv=sorted(ct.values())
print('YNeos'[csv!=ctv::2])

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

s_map = [[] for i in range(26)]
t_map = [[] for i in range(26)]
n = len(s)

for i in range(n):
    si = ord(s[i]) - ord("a")
    ti = ord(t[i]) - ord("a")
    
    s_map[si].append(i)
    t_map[ti].append(i)

s_map = sorted(s_map)
t_map = sorted(t_map)

if s_map == t_map:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def solve(S, T):
    d = dict()
    for s, t in zip(S, T):
        if s in d and d[s] != t:
            return False
        else:
            d[s] = t

    return True


def main():
    S = readline().strip()
    T = readline().strip()

    if solve(S, T) and solve(T, S):
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()

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

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

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

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

s_count = Counter(s)
t_count = Counter(t)


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

Solution (Python):
s=input()
t=input()
n=len(s)
f=0
a=[[] for i in range(26)]
for i in range(n):
    
    if len(a[ord(s[i])-97])==0:
        a[ord(s[i])-97].append(t[i])
    else:
        if a[ord(s[i])-97][0]!=t[i]:
            f=1
x=[a[i][0] for i in range(26) if len(a[i])==1]
if len(x)!=len(set(x)):
    f=1
print("Yes" if f==0 else "No")

Solution (Python):
import collections
S = list(input())
T = list(input())
 
cntS = collections.Counter(S)
cntT = collections.Counter(T)
 
if len(cntS) != len(cntT):
    print('No')
    exit()
else:
    valS = list(cntS.values())
    valT = list(cntT.values())

    if valS != valT:
            print('No')
            exit()
print('Yes')

Solution (Python):
s = input()
t = input()
d = []
for l in [s, t]:
    ptr = 0
    dct = dict()
    for c in l:
        if c not in dct.keys():
            dct[c] = chr(ord("A")+ptr)
            ptr += 1
    d.append([dct[c] for c in l])

print("Yes" if "".join(d[0]) == "".join(d[1]) else "No")

Solution (Python):
s=list(input())
t=list(input())
n=len(s)
a=[s.count(chr(97+i)) for i in range(26)]
b=[t.count(chr(97+i)) for i in range(26)]
if all(a[ord(s[i])-97]==b[ord(t[i])-97] for i in range(n)):
    print("Yes")
else:
    print("No")

Solution (Python):

from collections import Counter
x = lambda : sorted(Counter(input()).values())
print('YNeos'[x()!=x()::2])

Solution (Python):
s=[ord(c) for c in input()]
t=[ord(c) for c in input()]
n=len(s)
st=[(s[i],t[i]) for i in range(n)]
st=sorted(st,key=lambda x:x[0])
s=[c for c,_ in st]
t=[c for _,c in st]

for i in range(n-1):
    if (s[i]==s[i+1]) ^ (t[i]==t[i+1]):
        print('No')
        exit(0)

st=sorted(st,key=lambda x:x[1])
s=[c for c,_ in st]
t=[c for _,c in st]

for i in range(n-1):
    if (s[i]==s[i+1]) ^ (t[i]==t[i+1]):
        print('No')
        exit(0)


print('Yes')

Solution (Python):
def p(S):
    D={}
    for i in range(len(S)):
        a=S[i]
        if a in D:
            D[a].add(i)
        else:
            D[a]={i}
    return D
S=input()
T=input()

A=sorted(p(S).values())
B=sorted(p(T).values())

if A==B:
    print("Yes")
else:
    print("No")

Solution (Python):
def p(S):
    D={}
    for i in range(len(S)):
        a=S[i]
        if a in D:
            D[a].add(i)
        else:
            D[a]={i}
    return D
S=input()
T=input()

A=sorted(p(S).values())
B=sorted(p(T).values())

if A==B:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    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")


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

s = input()
t = input()

a = Counter(s)
b = Counter(t)

c = list(a.values())
d = list(b.values())

print('Yes') if c == d else print('No')

Solution (Python):
S=input()
T=input()
d=[[] for i in range(26)]
for i,c in enumerate(S):
    d[ord(c)-ord('a')].append(i)
d2=[[]for i in range(26)]
for i,c in enumerate(T):
    d2[ord(c)-ord('a')].append(i)
print(['No','Yes'][set((tuple(x) for x in d))==set((tuple(x) for x in d2))])

Solution (Python):
s=input()
t=input()
ar1=[0]*26
ar2=[0]*26
for i in s:
    ar1[ord(i)-97]+=1
for i in t:
    ar2[ord(i)-97]+=1
ar1.sort()
ar2.sort()
if ar1==ar2:
    print("Yes")
else:
    print("No")

Solution (Python):
def make_map(X):
    X = list(map(lambda x: ord(x) - ord("a"), X))
    s = [-1]*26
    res = [0]+[-1]*(len(X)-1)
    cnt = 0
    for i, x in enumerate(X):
        if s[x] == -1:
            s[x] = res[i] = cnt
            cnt += 1
        else:
            res[i] = s[x]
    return res
print("Yes" if make_map(input())==make_map(input()) else "No")

Solution (Python):
def ch(x):
    return ord(x)-ord("a")
def dch(x):
    return chr(x+ord("a"))

S = input().rstrip()
T = input().rstrip()

s0 = S[0]
cnt = 1
A1 = []
P = [-1]*26
k=0
for s in S[1:]:
    if s==s0:
        cnt += 1
    else:
        if P[ch(s0)] == -1:
            P[ch(s0)] = k
            k += 1
            A1.append((P[ch(s0)], cnt))
        else:
            A1.append((P[ch(s0)], cnt))
        cnt = 1
    s0 = s
if cnt == 1:
    if P[ch(s0)] == -1:
        P[ch(s0)] = k
        k += 1
        A1.append((P[ch(s0)], cnt))
    else:
        A1.append((P[ch(s0)], cnt))

t0 = T[0]
cnt = 1
B1 = []
P = [-1]*26
k=0
for t in T[1:]:
    if t==t0:
        cnt += 1
    else:
        if P[ch(t0)] == -1:
            P[ch(t0)] = k
            k += 1
            B1.append((P[ch(t0)], cnt))
        else:
            B1.append((P[ch(t0)], cnt))
        cnt = 1
    t0 = t
if cnt == 1:
    if P[ch(t0)] == -1:
        P[ch(t0)] = k
        k += 1
        B1.append((P[ch(t0)], cnt))
    else:
        B1.append((P[ch(t0)], cnt))

if A1==B1:
    print("Yes")
else:
    print("No")

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

d = [None]*26
flag = True
for s,t in zip(S,T):
    s = ord(s)-ord('a')
    t = ord(t)-ord('a')
    if d[s] is None:
        d[s] = t
    elif d[s] != t:
        flag = False
        break

if not flag:
    print('No')
elif len(set(v for v in d if v is not None)) != sum(int(v is not None) for v in d):
    print('No')
else:
    print('Yes')

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


sys.setrecursionlimit(10**7)


import bisect




INF = 1 << 50

def create_new_arr(DICT, SEQ):
    new_seq = ''
    next_id = 0
    for s in SEQ:
        if s not in DICT:
            DICT[s] = str(next_id)
            next_id += 1
        new_seq += DICT[s]
    return new_seq

def run():
    S, T = input(), input()
    s_dic = {}
    t_dic = {}

    new_S = create_new_arr(s_dic, S)
    new_T = create_new_arr(t_dic, T)

    if new_S == new_T:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    run()

Solution (Python):
s = input()
t = input()
n = len(s)
jisho1 = {}
jisho2 = {}


def ng():
    print("No")
    exit()


for i in range(n):
    if s[i] in jisho1:
        if jisho1[s[i]] != t[i]:
            ng()
    else:
        jisho1[s[i]] = t[i]
    if t[i] in jisho2:
        if jisho2[t[i]] != s[i]:
            ng()
    else:
        jisho2[t[i]] = s[i]
print("Yes")

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

chars = "abcdefghijklmnopqrstuvwxyz"
c2n = {chars[i]: i for i in range(26)}
RS = [-1]*26
RT = [-1]*26
N = len(S)
flag = True
for i in range(N):
    if RS[c2n[S[i]]] >= 0:
        if RS[c2n[S[i]]] != c2n[T[i]]:
            flag = False
            break
    if RT[c2n[T[i]]] >= 0:
        if RT[c2n[T[i]]] != c2n[S[i]]:
            flag = False
            break
    if RS[c2n[S[i]]] < 0:
        RS[c2n[S[i]]] = c2n[T[i]]
    if RT[c2n[T[i]]] < 0:
        RT[c2n[T[i]]] = c2n[S[i]]
    
if flag:
    print("Yes")
else:
    print("No")

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

Solution (Python):






S = input()
T = input()





mydict = {}
for i in range(len(S)):
    if S[i] in mydict:
        if T[i] != mydict[S[i]]:
            ans = "No"
            break
    else:
        mydict[S[i]] = T[i]
else:
    a = list(mydict.values())
    b = list(set(a))
    if len(b) != len(a):
        ans = "No"
    else:
        ans = "Yes"
print(ans)

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

d1 = {}

d2 = {}

for i in range(N):
    if S[i] not in d1:
        d1[S[i]] = T[i]
    else:
        if d1[S[i]] != T[i]:
            print("No")
            exit()
        else:
            pass

    if T[i] not in d2:
        d2[T[i]] = S[i]
    else:
        if d2[T[i]] != S[i]:
            print("No")
            exit()
        else:
            pass
print("Yes")

Solution (Python):
s = input()
t = input()
memo = {}
ans = 'Yes'
for i in range(len(s)):
    if s[i] in memo:
        if t[i] != memo[s[i]]:
            ans = 'No'
            break
    else:
        memo[s[i]] = t[i]
a = list(memo.values())
b = list(set(a))
if len(b) != len(a):
    ans = 'No'
print(ans)

Solution (Python):
from collections import Counter

s, t = input(), input()

dict = {}
for si, ti in zip(s, t):
    if ti not in dict:
        dict[ti] = si
    elif dict[ti] != si:
        print('No')
        break
else:
    cnt = Counter(dict.values())
    bool = all(cnt[i] <= 1 for i in cnt)
    print('Yes' if bool else 'No')

Solution (Python):
from collections import defaultdict

s = input()
t = input()

dicts = defaultdict(int)
dictt = defaultdict(int)

cs = []
ct = []

for i in range(len(s)):
    dicts[s[i]] += 1
    dictt[t[i]] += 1
    cs.append(dicts[s[i]])
    ct.append(dictt[t[i]])


if cs == ct:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections
S = input()
T = input()
if sorted(collections.Counter(S).values()) == sorted(collections.Counter(T).values()):
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
T = input()
N = len(S)
count = 0
R_1 = [-1 for i in range(26)]
R_2 = [-1 for i in range(26)]

answer = "Yes"
for i in range(N):
    r1 = ord(S[i]) - 97
    r2 = ord(T[i]) - 97
    if R_1[r1] >= 0:
        if r2 != R_1[r1]:
            answer = "No"
            break
    if R_2[r2] >= 0:
        if r1 != R_2[r2]:
            answer = "No"
            break
    if R_1[r1] < 0:
        R_1[r1] = r2
    if R_2[r2] < 0:
        R_2[r2] = r1
print(answer)

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

Solution (Python):
import numpy as np
S    = np.array(list(input()))
T    = np.array(list(input()))
N    = len(S)
SSrt = np.sort(S)
TSrt = np.sort(T)
SArg = np.argsort(S)
TArg = np.argsort(T)
SAgT = S[TArg]
TAgS = T[SArg]

SBef = ''
TBef = ''
SFlag = True
for ST in range(0,N):
    SNow = SSrt[ST]
    TNow = TAgS[ST]
    if SBef==SNow:
        if TBef!=TNow:
            SFlag = False
            break
    SBef = SNow
    TBef = TNow
        
SBef = ''
TBef = ''
TFlag = True
for TT in range(0,N):
    SNow = SAgT[TT]
    TNow = TSrt[TT]
    if TBef==TNow:
        if SBef!=SNow:
            TFlag = False
            break
    SBef = SNow
    TBef = TNow
        
if SFlag and TFlag:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
T = input()
a_idx = ord('a')
S_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
T_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
leng = len(S)
for i in range(leng):
    S_Lis[ord(S[i]) - a_idx].append(i)
    T_Lis[ord(T[i]) - a_idx].append(i)
if sorted(S_Lis.values()) == sorted(T_Lis.values()):
    print("Yes")
else:
    print("No")

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

dcs = {}
dct = {}
for i, s in enumerate(S):
    if s in dcs and dcs[s] != T[i]:
        print("No")
        exit()
    else:
        dcs[s] = T[i]
else:
    for j, t in enumerate(T):
        if t in dct and dct[t] != S[j]:
            print("No")
            exit()
        else:
            dct[t] = S[j]
    else:
        print("Yes")

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

S_count = Counter(S)
T_count = Counter(T)

d_S = defaultdict(int)
d_T = defaultdict(int)
for i in range(len(S)):
    d_S[S_count[S[i]]] += 1
    d_T[T_count[T[i]]] += 1

if (d_S == d_T):
    print('Yes')
else:
    print('No')

Solution (Python):
s1,s2=input(),input()
d1,d2={},{}
for i,j in zip(s1,s2):
  if i not in d1:
    d1[i]=1
  else:
    d1[i]+=1
  if j not in d2:
    d2[j]=1
  else:
    d2[j]+=1
d1=sorted(d1.items(),key=lambda x:x[1])
d2=sorted(d2.items(),key=lambda x:x[1])
for i,j in zip(d1,d2):
  if i[1]!=j[1]:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
if __name__ == '__main__':
	S = input()
	T = input()

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

	dic = dict()

	flg = True
	for x,y in zip(S,T):
		if x not in dic:
			dic[x] = y
		else:
			if dic[x] != y:
				flg = False
				break
	
	if flg :
		print("Yes")
	else:
		print("No")

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

n = len(s)
d = {}
d2 = {}

for i in range(n):
    if s[i] not in d:
        d[s[i]] = t[i]
    elif d[s[i]] != t[i]:
        print("No")
        exit()
    if t[i] not in d2:
        d2[t[i]] = s[i]
    elif d2[t[i]] != s[i]:
        print("No")
        exit()

print("Yes")

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

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

print('Yes')

Solution (Python):
def resolve():
    '''
    code here
    '''
    import collections
    S = [item for item in input()]
    T = [item for item in input()]

    S_cnt = collections.Counter(S)
    T_cnt = collections.Counter(T)


    if sorted(S_cnt.values()) == sorted(T_cnt.values()):
            print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    resolve()

Solution (Python):
"""
S = chokudai
T = redcoder

'redcoder' には 'e' が２つあるので一度に変える必要があるが、
Sではそれに相当する場所には 'h' と 'a' の2種類の文字があるので不可能。
こういう感じで一文字ずつ見ていけばよさそう。

10 ** 5なのでstring.count()とか使っちゃうとTLEしそう。

文字の出現回数を格納するリストを作っていって、それぞれ比較すればよさそう。
上の例だと、
    s_li = [1, 1, 1, 1, 1, 1, 1, 1]
    t_li = [2, 2, 2, 1, 1, 2, 2, 2]
になり、s_liとt_liの中身が異なるのでNG。
"""
from collections import defaultdict

S = input()
T = input()
s_li = [0] * len(S)   
t_li = [0] * len(T)   


s_cnt_dict = defaultdict(int)   
s_idx_dict = defaultdict(list)  
for i in range(len(S)):
    k = S[i]
    s_cnt_dict[k] += 1
    s_idx_dict[k].append(i)
for k in s_cnt_dict:
    for idx in s_idx_dict[k]:
        s_li[idx] = s_cnt_dict[k]


t_cnt_dict = defaultdict(int)   
t_idx_dict = defaultdict(list)  
for i in range(len(T)):
    k = T[i]
    t_cnt_dict[k] += 1
    t_idx_dict[k].append(i)
for k in t_cnt_dict:
    for idx in t_idx_dict[k]:
        t_li[idx] = t_cnt_dict[k]

print('Yes') if s_li == t_li else print('No')

Solution (Python):
S = input()
T = input()
a_idx = ord('a')
S_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
T_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
leng = len(S)
for i in range(leng):
    S_Lis[ord(S[i])-a_idx].append(i)
    T_Lis[ord(T[i])-a_idx].append(i)
for i in range(26):
    tmpS = S_Lis[i]
    if len(tmpS) == 0 or tmpS == T_Lis[i]:
        continue
    else:
        flag = True
        for j in T_Lis.values():
            if tmpS == j:
                flag = False
                break
        if flag:
            print("No")
            exit()
print("Yes")

Solution (Python):
from collections import defaultdict
s=list(input())
t=list(input())
change_st=defaultdict(int)
change_ts=defaultdict(int)
for i in range(len(s)):
    if change_st[s[i]]==0:
        change_st[s[i]]=t[i]
    else:
        if change_st[s[i]]!=t[i]:
            print("No")
            break
    if change_ts[t[i]]==0:
        change_ts[t[i]]=s[i]
    else:
        if change_ts[t[i]]!=s[i]:
            print("No")
            break
else:
    print("Yes")

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

n = len(s)
n = len(s)
a = [-1]*26
b = [-1]*26
flg = True

for i in range(n):
    snum = ord(s[i]) - 97
    tnum = ord(t[i]) - 97
    if a[snum] >= 0 and a[snum] != tnum:
        flg = False
        break
    if b[tnum] >= 0 and b[tnum] != snum:
        flg = False
        break
    if a[snum] == -1:
        a[snum] = tnum
    if b[tnum] == -1:
        b[tnum] = snum
    
print('Yes') if flg else print('No')

Solution (Python):

from collections import defaultdict

S = input()
T = input()
N = len(S)

SD = defaultdict(set)
TD = defaultdict(set)

for i in range(N):
  SD[S[i]].add(T[i])
  TD[T[i]].add(S[i])

cnt = 0

for i in SD.values():
  cnt = max(cnt, len(i))

for i in TD.values():
  cnt = max(cnt, len(i))

if cnt >= 2:
  print("No")
else:
  print("Yes")

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

S_d = dict()
T_d = dict()
for i in range(len(S)):
    S_d.setdefault(S[i], T[i])
    if S_d[S[i]] != T[i]:
        print('No')
        exit(0)
    T_d.setdefault(T[i], S[i])
    if T_d[T[i]] != S[i]:
        print('No')
        exit(0)
print('Yes')

Solution (Python):






















































def calculation(lines):
    
    
    S = lines[0]
    T = lines[1]
    ns = list()
    nt = list()
    for c in 'abcdefghijklmnopqrstuvwxyz':
        s = len(S) - len(S.replace(c, ''))
        ns.append(s)
        t = len(T) - len(T.replace(c, ''))
        nt.append(t)
    ns.sort()
    nt.sort()
    if ns == nt:
        return ['Yes']
    else:
        return ['No']



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['azzel', 'apple']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['chokudai', 'redcoder']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['abcdefghijklmnopqrstuvwxyz', 'ibyhqfrekavclxjstdwgpzmonu']
        lines_export = ['Yes']
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
s = input()
t = input()
S = sorted(map(s.count,set(s)))
T = sorted(map(t.count,set(t)))

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

Solution (Python):
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = input()
    t = input()
    for i in range(len(s)):
        if s.index(s[i]) != t.index(t[i]):
            print('No')
            return
    print('Yes')
        
        
        
            
        
    
    
if __name__ == '__main__':
    main()