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

Solution (Python):
import sys
import numpy as np

s1 = sys.stdin.readline().strip()
s2 = sys.stdin.readline().strip()

pos_dct = {}
pos_dct_1 = {}
for i, c in enumerate(s2):
    if c not in pos_dct:
        pos_dct[c] = [i]
    else:
        pos_dct[c].append(i)
for i, c in enumerate(s1):
    if c not in pos_dct_1:
        pos_dct_1[c] = [i]
    else:
        pos_dct_1[c].append(i)

        
s1 = np.array(list(s1))
s2 = np.array(list(s2))
for key in pos_dct:
    tmp = s1[pos_dct[key]][0]
    judge = len(list(filter(lambda x: x != tmp, s1[pos_dct[key]])))
    if judge != 0:
        print("No")
        sys.exit()
        
for key in pos_dct_1:
    tmp = s2[pos_dct_1[key]][0]
    judge = len(list(filter(lambda x: x != tmp, s2[pos_dct_1[key]])))
    if judge != 0:
        print("No")
        sys.exit()

print("Yes")

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

patterns = set([(a,b) for a, b in zip(s, t)])

alphabets = [[False, False] for i in range(26)]
flag = False

for pattern in patterns:
  if alphabets[ord(pattern[0]) - ord('a')][0] == True:
    break
  else:
    alphabets[ord(pattern[0]) - ord('a')][0] = True
    
  if alphabets[ord(pattern[1]) - ord('a')][1] == True:
    break
  else:
    alphabets[ord(pattern[1]) - ord('a')][1] = True
else:
  flag = True
  
if flag == True:
  print('Yes')
else:
  print('No')

Solution (Python):

"""
Created on Sun Sep 23 18:34:34 2018
ABC110C
@author: maezawa
"""

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

a = [[] for _ in range(26)]
b = [[] for _ in range(26)]


for i, c in enumerate(s):
    j = ord(c) - 97
    a[j].append(i)

for i, c in enumerate(t):
    j = ord(c) - 97
    b[j].append(i)
    
a.sort()
b.sort()

if a==b:
    print('Yes')
else:
    print('No')

Solution (Python):
S=input()
T=input()
sc={}
tc={}
for i in S:
    sc[i]=sc.get(i,0)+1
for i in T:
    tc[i]=tc.get(i,0)+1
x=list(sc.values())
x.sort()
y=list(tc.values())
y.sort()
if x==y:
    print('Yes')
else:
    print('No')

Solution (Python):
S = list(input())
T = list(input())
S2, T2 = [], []
St, Tt = [], []
for i in range(26):
    s = chr(ord('a') + i)
    St.append(S.count(s))
    Tt.append(T.count(s))
for i in range(len(S)):
    S2.append(St[ord(S[i]) - ord('a')])
    T2.append(Tt[ord(T[i]) - ord('a')])
if S2 != T2:
    print('No')
else:
    print('Yes')

Solution (Python):
import collections

s=list(input())
t=list(input())
s = collections.Counter(s)
t = collections.Counter(t)
sc=s.most_common()
tc=t.most_common()
ans = True
for i in range(min(len(sc), len(tc))):
    if sc[i][1] != tc[i][1]:
        ans = False

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

Solution (Python):
from collections import Counter

s = Counter(input())
t = Counter(input())

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

Solution (Python):
def solve():
    s = input()
    t = input()
    d0 = {}
    d1 = {}
    if len(s) != len(t):
        print('No')
        return
    for i in range(len(s)):
        if s[i] in d0:
            if t[i] != d0[s[i]]:
                print('No')
                return
        elif t[i] in d1:
            if s[i] != d1[t[i]]:
                print('No')
                return
        else:
            d0[s[i]] = t[i]
            d1[t[i]] = s[i]
    print('Yes')


solve()

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

def count_string(strInput):
    tmp = {}
    for s in strInput:
        if s in tmp:
            tmp[s] += 1
        else:
            tmp[s] = 1
    
    re = [tmp[a] for a in tmp]
    re = sorted(re)
    return re

S_count = count_string(S)
T_count = count_string(T)

if S_count == T_count:
    print('Yes')
else:
    print('No')

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

alpha = "abcdefghijklmnopqrstuvwxyz" 

d = {}
for i in alpha:
    d[i] = None

for i in range(len(T)):
    if(d[T[i]] == None):
        if((S[i] in d.values()) == True):
            print("No")
            exit()
        d[T[i]] = S[i]
    elif(d[T[i]] != S[i]):
        print("No")
        exit()

print("Yes")

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

lists = []
listt = []
lists.append(s.count("a"))
lists.append(s.count("b"))
lists.append(s.count("c"))
lists.append(s.count("d"))
lists.append(s.count("e"))
lists.append(s.count("f"))
lists.append(s.count("g"))
lists.append(s.count("h"))
lists.append(s.count("i"))
lists.append(s.count("j"))
lists.append(s.count("k"))
lists.append(s.count("l"))
lists.append(s.count("m"))
lists.append(s.count("n"))
lists.append(s.count("o"))
lists.append(s.count("p"))
lists.append(s.count("q"))
lists.append(s.count("r"))
lists.append(s.count("s"))
lists.append(s.count("t"))
lists.append(s.count("u"))
lists.append(s.count("v"))
lists.append(s.count("w"))
lists.append(s.count("x"))
lists.append(s.count("y"))
lists.append(s.count("z"))
listt.append(t.count("a"))
listt.append(t.count("b"))
listt.append(t.count("c"))
listt.append(t.count("d"))
listt.append(t.count("e"))
listt.append(t.count("f"))
listt.append(t.count("g"))
listt.append(t.count("h"))
listt.append(t.count("i"))
listt.append(t.count("j"))
listt.append(t.count("k"))
listt.append(t.count("l"))
listt.append(t.count("m"))
listt.append(t.count("n"))
listt.append(t.count("o"))
listt.append(t.count("p"))
listt.append(t.count("q"))
listt.append(t.count("r"))
listt.append(t.count("s"))
listt.append(t.count("t"))
listt.append(t.count("u"))
listt.append(t.count("v"))
listt.append(t.count("w"))
listt.append(t.count("x"))
listt.append(t.count("y"))
listt.append(t.count("z"))

for i in range(26):
    if max(lists) == max(listt):
        lists.remove(max(lists))
        listt.remove(max(listt))
    else:
        flag = False
        break

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

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

d_S = [[] for _ in range(26)]
d_T = [[] for _ in range(26)]

for i in range(len(S)):
    d_S[ord(S[i])-97].append(i)
    d_T[ord(T[i])-97].append(i)

for i in range(26):
    tmp = ""
    for j in d_S[i]:
        if tmp == "":
            tmp = T[j]
        else:
            if tmp != T[j]:
                print("No")
                break
    else:
        continue
    break
else:
    for i in range(26):
        tmp = ""
        for j in d_T[i]:
            if tmp == "":
                tmp = S[j]
            else:
                if tmp != S[j]:
                    print("No")
                    break
        else:
            continue
        break
    else:
        print("Yes")

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

S_list = []
pre_c = S[0]
c_num = {}
for i, c in enumerate(S[1:]):
    if c != pre_c:
        if c not in c_num:
            c_num[c] = i
        S_list.append((i, c_num[c]))
        pre_c = c

T_list = []
pre_c = T[0]
c_num = {}
for i, c in enumerate(T[1:]):
    if c != pre_c:
        if c not in c_num:
            c_num[c] = i
        T_list.append((i, c_num[c]))
        pre_c = c

if S_list == T_list:
    print("Yes")
else:
    print("No")

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

dic = {}
dic2 = {}

for i in range(len(s)):
    sc = s[i]
    tc = t[i]
    if sc not in dic:
        dic[sc] = tc
    elif dic[sc] != tc:
        print('No')
        exit()
for i in range(len(s)):
    sc = t[i]
    tc = s[i]
    if sc not in dic2:
        dic2[sc] = tc
    elif dic2[sc] != tc:
        print('No')
        exit()

print('Yes')

Solution (Python):
s1 = input()
s2 = input()
if len(s1) != len(s2):
    print("No")
else:
    D1 = {}
    D2 = {}
    flag = True
    for x, y in zip(s1, s2):
        if x not in D1:
            D1[x] = y
        else:
            flag = (flag and (D1[x] == y))
        if y not in D2:
            D2[y] = x
        else:
            flag = (flag and (D2[y] == x))
        if not flag:
            break
    if flag:
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import defaultdict

S = input()
T = input()

A = {}
B = {}

isok = True
for i in range(len(S)):
    if S[i] in A:
        if T[i] != A[S[i]]:
            isok = False
            break
    else:
        A[S[i]] = T[i]
    if T[i] in B:
        if S[i] != B[T[i]]:
            isok = False
            break
    else:
        B[T[i]] = S[i]
        
if isok:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
T = input()
flag = True
sdict = {}
tdict = {}
for si, ti in zip(S, T):
    if si not in sdict:
        sdict[si] = len(sdict)
    if ti not in tdict:
        tdict[ti] = len(tdict)
    if sdict[si] == tdict[ti]:
        continue
    flag = False
    break

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

Solution (Python):
S=input()
T=input()
N=len(S)
L=[chr(i+97) for i in range(26)]
D=dict()
for i in range(26):
    D[L[i]]=i
A=[[] for i in range(26)]
B=[[] for i in range(26)]
for i in range(N):
    A[D[S[i]]].append(i)
    B[D[T[i]]].append(i)
X=[-1 for i in range(26)]
Y=[-1 for i in range(26)]
for i in range(26):
    for c in A[i]:
        if X[i]==-1:
            X[i]=D[T[c]]
        else:
            if X[i]!=D[T[c]]:
                print("No")
                exit()
    for c in B[i]:
        if Y[i]==-1:
            Y[i]=D[S[c]]
        else:
            if Y[i]!=D[S[c]]:
                print("No")
                exit()
print("Yes")

Solution (Python):
from collections import Counter

S = input()
T = input()


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

S_number = sorted(S_count.values())
T_number = sorted(T_count.values())

flag = True

if len(S_number) != len(T_number):
    flag = False
else:
    for i in range(len(S_number)):
        if S_number[i] != T_number[i]:
            flag = False
        
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
s = list(input())
t = list(input())
n = len(s)
end = 0
alp = list("abcdefghijklmnopqrstuvwxyz")
for i in range(26):
    k = ""
    kk = ""
    for j in range(n):
        if t[j] == alp[i]:
            if k == "" or s[j] == k:
                k = s[j]
            else:
                end = 1
                break
        if s[j] == alp[i]:
            if kk == "" or t[j] == kk:
                kk = t[j]
            else:
                end = 1
                break
if end == 1:
    print("No")
else:
    print("Yes")

Solution (Python):
S = input()
T = input()
k = {}
o = {}
res = "Yes"
for i in range(len(S)):
    if S[i] in k:
        if k[S[i]] != T[i]:
            res = "No"
            break
    else:
        k[S[i]] = T[i]
        
for i in range(len(T)):
    if T[i] in o:
        if o[T[i]] != S[i]:
            res = "No"
            break
    else:
        o[T[i]] = S[i]
    
print(res)

Solution (Python):
S = input()
T = input()
c2pos=dict()
s_c2pos = dict()

for ix, c in enumerate(S):
    if s_c2pos.get(c) == None:
        s_c2pos[c] = [ix]
    else:
        s_c2pos[c].append(ix)

for ix, c in enumerate(T):
    if c2pos.get(c) == None:
        c2pos[c] = [ix]
    else:
        c2pos[c].append(ix)

res = "Yes"

for k, v in c2pos.items():
    if len(v) < 1:
        continue

    if len(set([S[_v] for _v in v])) != 1:
        res = "No"

    if s_c2pos[S[v[0]]] != v:
        res = "No"
    
print(res)

Solution (Python):



def main():
    s = str(input())
    t = str(input())

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

    ds = dict()
    dt = dict()
    for i in range(len(s)):
        if s[i] in ds.keys() and ds[s[i]] != t[i]:
            print('No')
            return
        if t[i] in dt.keys() and dt[t[i]] != s[i]:
            print('No')
            return

        ds[s[i]] = t[i]
        dt[t[i]] = s[i]

    print('Yes')


if __name__ == '__main__':
    main()

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

Alpha= [[0 for i in range(1)] for j in range(26)]
Beta= [[0 for i in range(1)] for j in range(26)]

for i in range(len(S)):
  Alpha[ord(S[i])-97].append(T[i])
  Beta[ord(T[i])-97].append(S[i])

for i in range(26):
  Alpha[i]=list(set(Alpha[i]))
  Beta[i]=list(set(Beta[i]))
  if len(Alpha[i])>=3 or len(Beta[i])>=3:
    print('No')
    exit()
print('Yes')

Solution (Python):


import math
import sys
import itertools
import numpy as np



s = list(input())
t = list(input())
dame = 0
d = []
for i in ["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"]:
    if i in s:
        j=t[s.index(i)]
        if j in d:
            dame = 1

            break
        d.append(j)

        for x in [p for p, x in enumerate(s) if x == i]:
            if j != t[x]:
                dame = 1

                break

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

Solution (Python):
S = input()
T = input()
S_map = {}
T_map = {}
l = len(S)
S_cnt = 0
T_cnt = 0
for i in range(l):
	s,t = S[i], T[i]
	if s in S_map:
		s_id = S_map[s]
	else:
		s_id = S_cnt
		S_map[s] = S_cnt
		S_cnt += 1
	if t in T_map:
		t_id = T_map[t]
	else:
		t_id = T_cnt
		T_map[t] = T_cnt
		T_cnt += 1
	if s_id != t_id:
		print("No")
		exit()
print("Yes")

Solution (Python):
from collections import Counter
s=input()
t=input()
s1=Counter(s)
t1=Counter(t)
ans='Yes'
if len(s1)!=len(t1):ans='No'
else:
    for i,j in zip(s1.most_common(),t1.most_common()):
        if i[1]!=j[1]:ans='No'
print(ans)

Solution (Python):

S = input()
T = input()

Smap = {}
Tmap = {}

for c in S:
    if c in Smap:
        Smap[c] += 1
    else:
        Smap[c] = 1

Sval = list(Smap.values())
Sval.sort()

for c in T:
    if c in Tmap:
        Tmap[c] += 1
    else:
        Tmap[c] = 1

Tval = list(Tmap.values())
Tval.sort()



if Sval == Tval:
    print('Yes')
else:
    print('No')

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

ds={}
dt={}
cnts=0
cntt=0
for si,ti in zip(s,t):
    if si not in ds:
        ds[si]=cnts
        cnts+=1
    sn=ds[si]
    if ti not in dt:
        dt[ti]=cntt
        cntt+=1
    tn=dt[ti]
    if sn!=tn:
        print('No')
        break
else:
    print('Yes')

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

from collections import defaultdict
s = defaultdict(int)
t = defaultdict(int)

for i in S:
    s[i] += 1

for j in T:
    t[j] += 1

ss = sorted(s.values())
tt = sorted(t.values())



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

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

ma = {c : [] for c in s}
mb = {c : [] for c in t}
for i in range(len(s)):
    ma[s[i]].append(i)
    mb[t[i]].append(i)

a = [item for item in ma.values()]
b = [item for item in mb.values()]
a.sort()
b.sort()
if(a==b):
    print('Yes')
else:
    print('No')

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

cnt = 0
clist = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
for i in range(len(S)):
    if S[i].islower():
        S = S.replace(S[i], clist[cnt])
        cnt += 1

cnt = 0
for i in range(len(T)):
    if T[i].islower():
        T = T.replace(T[i], clist[cnt])
        cnt += 1

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

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


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


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S, T):
    sc = Counter(S)
    tc = Counter(T)

    for i in range(len(S)):
        if sc[S[i]] != tc[T[i]]:
            return 'No'

    return 'Yes'


def main():
    S = read_str()
    T = read_str()
    print(slv(S, T))


if __name__ == '__main__':
    main()

Solution (Python):
Ss = input()
Ts = input()

Ass = [[0] * 26 for _ in range(26)]

ordA = ord('a')
for S, T in zip(Ss, Ts):
    ordS = ord(S) - ordA
    ordT = ord(T) - ordA
    Ass[ordS][ordT] = 1

if max(map(sum, Ass)) > 1:
    print('No')
elif max(map(sum, list(zip(*Ass)))) > 1:
    print('No')
else:
    print('Yes')

Solution (Python):
S=input()
T=input()
X=0
for i in range(len(S)):
    s=S[i]
    if ord(s)>96:
        X+=1
        S=S.replace(s,chr(X+47))
Y=0
for i in range(len(T)):
    t=T[i]
    if ord(t)>96:
        Y+=1
        T=T.replace(t,chr(Y+47))
print('Yes'if S==T else'No')

Solution (Python):


INF = float('inf')


def inpl(): return list(map(int, input().split()))


S = input()
T = input()

A = []
B = []
tmp = []
tmp2 = []

cnt = 0
for s in S:
    if s in tmp:
        A.append(tmp.index(s))
    else:
        tmp.append(s)
        A.append(cnt)
        cnt += 1


cnt = 0
for t in T:
    if t in tmp2:
        B.append(tmp2.index(t))
    else:
        tmp2.append(t)
        B.append(cnt)
        cnt += 1

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

Solution (Python):
from collections import Counter

if __name__ == '__main__':
    s = input()
    t = input()
    sc = tuple(sorted(Counter(s).values()))
    tc = tuple(sorted(Counter(t).values()))
    print('Yes' if sc == tc else 'No')

Solution (Python):

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

def str2num(words):
    used = []
    nums = []
    for i in range(len(words)):
        if words[i] in used:
            nums.append(used.index(words[i]))
        else:
            used.append(words[i])
            nums.append(used.index(words[i]))
    return nums


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

Solution (Python):
s = input()
t = input()
x,y,f = [-1]*26,[-1]*26,1
for i in range(len(s)):
	if x[ord(s[i])-97]!=y[ord(t[i])-97]: f=0
	else: x[ord(s[i])-97],y[ord(t[i])-97] = i,i
if f: print("Yes")
else: print("No")

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

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

S = input().rstrip()
T = input().rstrip()
n = len(S)
s = []
t = []

for i in range(n):
	if S[i] in s:
		if t[s.index(S[i])] != T[i]:
			print("No")
			exit()
	else:
		s.append(S[i])
		t.append(T[i])

for i in range(n):
	if T[i] in t:
		if s[t.index(T[i])] != S[i]:
			print("No")
			exit()
	else:
		s.append(S[i])
		t.append(T[i])


print("Yes")

Solution (Python):
S = [str(i) for i in input()]
T = [str(i) for i in input()]
ans = "Yes"

for j in range(len(S)):
    if S[j] == 0:
        continue

    IDXs = [i for i, x in enumerate(S) if x == S[j]]
    IDXt = [i for i, x in enumerate(T) if x == T[j]]

    if IDXs != IDXt:
        ans = "No"
        break

    for k in range(len(IDXs)):
        S[IDXs[k]] = 0
        T[IDXs[k]] = 0

print(ans)

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

ans = 'Yes'
s_pairs = {}
t_pairs = {}
for i in range(len(s)):
    if s[i] in s_pairs:
        if s_pairs[s[i]] != t[i]:
            ans = 'No'
            break
    elif t[i] in t_pairs:
        if t_pairs[t[i]] != s[i]:
            ans = 'No'
            break
    else:
        s_pairs[s[i]] = t[i]
        t_pairs[t[i]] = s[i]

print(ans)

Solution (Python):
import collections

S=input()
T=input()

S_list=[i for i in S]
T_list=[i for i in T]

S_dict=collections.Counter(S_list)
T_dict=collections.Counter(T_list)

S_count=sorted([v for k,v in S_dict.items()])
T_count=sorted([v for k,v in T_dict.items()])

if S_count==T_count:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter
s = list(input())
t = list(input())
s_count = Counter(s).most_common()
t_count = Counter(t).most_common()
for i in range(len(set(s))):
    if s_count[i][1] != t_count[i][1]:
        print("No")
        exit()
print("Yes")

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

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

dds = defaultdict(int)
ddt = defaultdict(int)
for i in range(L):
  s = S[i]
  t = T[i]
  if dds[s] == 0:
    dds[s] = t
  else:
    if dds[s] == t:
      continue
    else:
      print("No")
      sys.exit()
      
  if ddt[t] == 0:
    ddt[t] = s
  else:
    if ddt[t] == s:
      continue
    else:
      print("No")
      sys.exit()
      
print("Yes")

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


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

    SD = collections.defaultdict(lambda: [])
    TD = collections.defaultdict(lambda: [])

    for i, s in enumerate(S):
        SD[s].append(i)

    for i, t in enumerate(T):
        TD[t].append(i)

    for L in SD.values():
        
        if len(L) == 1:
            continue

        piv = T[L[0]]

        for i in L[1:]:
            if piv != T[i]:
                print("No")
                return
    
    for L in TD.values():

        if len(L) == 1:
            continue

        piv = S[L[0]]

        for i in L[1:]:
            if piv != S[i]:
                print("No")
                return

            

    print("Yes")




main()

Solution (Python):
a = input()
b = input()

def tonum(x):
    tmp = []
    ans = []
    for i in x:
        if i in tmp:
            ans.append(tmp.index(i))
        else:
            tmp.append(i)
            ans.append(len(tmp)-1)
            
    return(ans)

a = tonum(a)
b = tonum(b)

if(a==b):
    print("Yes")
else:
    print("No")

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

answer = 'Yes'

for c in 'abcdefghijklmnopqrstuvwxyz':
    found = ' '
    for i, s in enumerate(S):
        if s == c:
            if found == ' ':
                found = T[i]
            elif found == T[i]:
                found = T[i]
            else:
                answer = 'No'

    found = ' '
    for i, t in enumerate(T):
        if t == c:
            if found == ' ':
                found = S[i]
            elif found == S[i]:
                found = S[i]
            else:
                answer = 'No'


print(answer)

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

scount = []
tcount = []

for x in [chr(i) for i in range(97,97+26)]:
    scount.append(s.count(x))
    tcount.append(t.count(x))

if sorted(scount) == sorted(tcount):
    print("Yes")
else:
    print("No")

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

def normalized(S):
    dic = {}  
    last = -1
    T = []
    for s in S:
        if s not in dic:
            last += 1
            dic[s] = last
        T.append(dic[s])
    return T

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

Solution (Python):
s = input()
t = input()
ds = {}
dt = {}

for i in range(len(s)):
    if(s[i] in ds):
        ds[s[i]] += 1
    else:
        ds[s[i]] = 1

for i in range(len(t)):
    if(t[i] in dt):
        dt[t[i]] += 1
    else:
        dt[t[i]] = 1

s_ = sorted(list(ds.values()))
t_ = sorted(list(dt.values()))
if(s_ != t_):
    print("No")
else:
    print("Yes")

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

for s, t in zip(S, T):
    D[s].add(t)

used = set()
for x in D.values():
    if len(x) > 1:
        print("No")
        break

    if list(x)[0] in used:
        print("No")
        break

    used.add(list(x)[0])

else:
    print("Yes")

Solution (Python):
from pprint import pprint
s=input()
t=input()
d={}
for c in 'abcdefghijklmnopqrstuvwxyz':
  d[c]=set()
for c1, c2 in zip(s,t):
  d[c1].add(c2)
te = set()
for key in d.keys():
  if len(d[key]) >= 2:
    print("No")
    break
  if len(d[key]) == 1:
    val = list(d[key])[0]
    if val in te:
      print("No")
      break
    te.add(val)
else:
  print("Yes")

Solution (Python):
s = input()
t = input()
alf = []
for i in range(97,123):
    alf.append(chr(i))
slist = []
tlist = []
for i in alf:
    slist.append(s.count(i))
    tlist.append(t.count(i))
slist.sort()
tlist.sort()
ans = "Yes"
for i in range(len(slist)):
    if slist[i] != tlist[i]:
        ans = "No"
print(ans)

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

s_d = {}
t_d = {}

ans = 'Yes'

for i in range(len(s)):
    a = s[i]
    b = t[i]
    if a in s_d.keys() and b in t_d.keys():
        if s_d[a] != t_d[b]:
            ans = 'No'
            break

    elif a in s_d.keys() and b not in t_d.keys():
        ans = 'No'
        break

    elif a not in s_d.keys() and b in t_d.keys():
        ans = 'No'
        break

    else:
        s_d[a] = i
        t_d[b] = i

print(ans)

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

def f():
    st = {}
    ts = {}
    for s,t in zip(S, T):
        if s in st:
            if st[s] != t:
                return "No"
        else:
            if t in ts:
                if ts[t] != s:
                    return "No"
            else:
                ts[t] = s
                st[s] = t
    return "Yes"
print(f())

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


def judge():
    
    Sletters=list("abcdefghijklmnopqrstuvwxyz")
    Tletters=[0]*26

    for i in range(len(S)):
        if Tletters[Sletters.index(S[i])]!=0 and Tletters[Sletters.index(S[i])]!=T[i]:
            return "No"
        else: Tletters[Sletters.index(S[i])]=T[i]
    
    
    Tletters=list("abcdefghijklmnopqrstuvwxyz")
    Sletters=[0]*26
    
    for i in range(len(T)):
        if Sletters[Tletters.index(T[i])]!=0 and Sletters[Tletters.index(T[i])]!=S[i]:
            return "No"
        else: Sletters[Tletters.index(T[i])]=S[i]
        
    return "Yes"
    
print(judge())

Solution (Python):
S = input()
T = input()
L = len(S)
dicS = {}
dicT = {}
ans = "Yes"
for i in range(L):
    if S[i] not in dicS:
        dicS[S[i]] = T[i]
    else:
        if T[i] != dicS[S[i]]:
            ans ="No"
    if T[i] not in dicT:
        dicT[T[i]] = S[i]
    else:
        if S[i] != dicT[T[i]]:
            ans = "No"
print(ans)

Solution (Python):
S = input()
T = input()
sidx = [S.find(S[i]) for i in range(len(S))]
tidx = [T.find(T[i]) for i in range(len(T))]
if sidx == tidx:
    print('Yes')
else:
    print('No')

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

changes = dict()
values = set()
answer = True

for a, b in zip(s, t):
    if a in changes:
        answer &= changes[a] == b
    else:
        if b in values:
            answer = False
        else:
            changes[a] = b
            values.add(b)

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

Solution (Python):
S = list(input())
T = list(input())
A = list(set(S))
B = list(set(T))
X = []
Y = []
flag = 0
for i in range(len(A)) :
    x = S.count(A[i])
    X.append(x)
for j in range(len(B)) :
    y = T.count(B[j])
    Y.append(y)
X.sort()
Y.sort()
if len(X) == len(Y) :
    for k in range(len(X)) :
        if X[k] != Y[k] :
            flag += 1
            break
else :
    flag += 1
if flag == 0 :
    print("Yes")
else :
    print("No")

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


chars = "abcdefghijklmnopqrstuvwxyz"

sp = {}
tp = {}

result = True

for i in range(len(S)):
    sc = S[i]
    sx = i
    tc = T[i]
    tx = i
    if not sc in sp:
        sp[sc] = i
    else:
        sx = sp[sc]
    if not tc in tp:
        tp[tc] = i
    else:
        tx = tp[tc]
    if sx != tx:
        result = False
        break

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

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

snum = [0 for i in range(26)]
ssnum = [0 for i in range(26)]

for i in range(len(s)):
  snum[ord(s[i])-97] +=1
  ssnum[ord(ss[i])-97] +=1
snum.sort()
ssnum.sort()
for i in range(26):
  if snum[i]!=ssnum[i]:
    print("No")
    break
else:
  print("Yes")

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

X=[]
Y=[]

a = [c  for c in "abcdefghijklmnopqrstuvwxyz"]

for i in a:
    X.append(len(S) - len(S.replace(i, "")))
    Y.append(len(T) - len(T.replace(i, "")))
    
X.sort()
Y.sort()

ret = "Yes"
for i in range(26):
    if X[i] != Y[i]:
        ret = "No"
    
print (ret)