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
from operator import itemgetter

s = input()
t = input()

pairs = set(zip(s, t))
sc = Counter(map(itemgetter(0), pairs))
tc = Counter(map(itemgetter(1), pairs))

if any(count >= 2 for count in sc.values()) or \
        any(count >= 2 for count in tc.values()):
    print("No")
else:
    print("Yes")

Solution (Python):
S = list(input())
T = list(input())
S.sort()
T.sort()
SKind = []
TKind = []
cnt = 1
for i in range(1,len(S)):
    if i == len(S)-1:
        if S[i]==S[i-1]:
            cnt += 1
            SKind.append(cnt)
        else:
            SKind.append(cnt)
            SKind.append(1)
    elif S[i]==S[i-1]:
        cnt+=1
    elif S[i]!=S[i-1]:
        SKind.append(cnt)
        cnt = 1
cnt = 1        
for i in range(1,len(T)):
    if i == len(T)-1:
        if T[i]==T[i-1]:
            cnt += 1
            TKind.append(cnt)
        else:
            TKind.append(cnt)
            TKind.append(1)
    elif T[i]==T[i-1]:
        cnt+=1
    elif T[i]!=T[i-1]:
        TKind.append(cnt)
        cnt = 1
SKind.sort()
TKind.sort()
if SKind == TKind:
    print("Yes")
else: print("No")

Solution (Python):
from collections import defaultdict
if __name__ == '__main__':
    S = str(input())
    T = str(input())
    
    count = defaultdict(str)
    count2 = defaultdict(str)
    flag = True
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if count[t] != '':
            if count[t] != s:
                flag = False
        else:
            if count2[s] != '':
                if count2[s] != t:
                    flag = False
            else:
                count[t] = s
                count2[s] = t
    if flag:
        print('Yes')
    else:
        print('No')

Solution (Python):
from collections import Counter

S,T = Counter([s for s in input()]), Counter([s for s in input()])
print('Yes' if Counter(S.values()) ==  Counter(T.values()) else 'No')

Solution (Python):
S = list(input())
T = list(input())
conv = {}
flag = 1
for s, t in zip(S, T):
    if s in conv and conv[s] != t:
        flag = 0
        break
    conv[s] = t
end = conv.values()
if len(end) != len(set(end)):
    flag = 0
print('Yes' if flag else 'No')

Solution (Python):
S=input()
T=input()
convert = {}
flag=1
for s,t in zip(S,T):
  if s in convert and convert[s]!=t:
    flag=0
    break
  convert[s] = t
after = convert.values()
if len(after)!= len(set(after)):
  flag = 0

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

Solution (Python):
from sys import exit
S = input()
T = input()
start = [-1] * 26
goal = [-1] * 26
for i in range(len(S)):
  a = ord(S[i]) - ord('a')
  b = ord(T[i]) - ord('a')

  if start[a] != -1 or goal[b] != -1:
    if start[a] != b or goal[b] != a:
      print('No')
      exit()
  else:
    start[a] = b
    goal[b] = a
print('Yes')

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

    f = True
    dep = {}

    for sc,tc in zip(s,t):
        if (dep.get(tc) is not None or sc in dep.values()) and sc != dep.get(tc):
            print("No")
            f = False
            break
        else:
            dep[tc] = sc

    if f:
        print("Yes")

if __name__ == "__main__":
    string_transformation()

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

d = {}
for i in range(len(S)):
  d[S[i]] = T[i]

t = []
for i in range(len(S)):
  t.append(d[S[i]])

if ''.join(t) != T or len(d.values()) != len(set(d.values())):
  print('No')
else:
  print('Yes')

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

S = input().replace('\n', '')
T = input().replace('\n', '')

alphabet = 'abcdefghijklmnopqrstuvwxyz'
len_alphabet = len(alphabet)
dict_alphabet = {chara: i for i, chara in enumerate(alphabet)}


def calc_state(target_string):
    state_idx = [[] for _ in range(len_alphabet)]
    state_count = [0 for _ in range(len_alphabet)]

    for i, chara in enumerate(target_string):
        alphabet_idx = dict_alphabet[chara]
        state_idx[alphabet_idx].append(i)
        state_count[alphabet_idx] += 1

    return state_idx, state_count


state_idx_s, state_count_s = calc_state(S)
state_idx_t, state_count_t = calc_state(T)


if sorted(state_count_s) != sorted(state_count_t):
    print('No')
    exit()



last_s = None
last_t = None
for s, t in zip(S, T):
    if last_s == s and last_t != t:
        print('No')
        exit()
    last_s, last_t = s, t

print('Yes')

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

mps = dict()
mpt = dict()
ans = "Yes"
for i in range(len(s)):
  if s[i] in mps.keys():
    if t[i] != mps[s[i]]:
      ans = "No"
  elif t[i] in mpt.keys():
    if s[i] != mpt[t[i]]:
      ans = "No"
  else:
    mps[s[i]] = t[i]
    mpt[t[i]] = s[i]

print(ans)

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

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

S = input().replace('\n', '')
T = input().replace('\n', '')

alphabet = 'abcdefghijklmnopqrstuvwxyz'
len_alphabet = len(alphabet)
dict_alphabet = {chara: i for i, chara in enumerate(alphabet)}


def calc_state(target_string):
    state_idx = [[] for _ in range(len_alphabet)]
    state_count = [0 for _ in range(len_alphabet)]

    for i, chara in enumerate(target_string):
        alphabet_idx = dict_alphabet[chara]
        state_idx[alphabet_idx].append(i)
        state_count[alphabet_idx] += 1

    return state_idx, state_count


state_idx_s, state_count_s = calc_state(S)
state_idx_t, state_count_t = calc_state(T)


if sorted(state_count_s) != sorted(state_count_t):
    print('No')
    exit()
else:
    print('Yes')

Solution (Python):
S = input()
T = input()
al = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

setS = []
cnt = 0
for i in range(len(S)):
  if S[i] not in setS:
    S = S.replace(S[i],al[cnt])
    cnt += 1
    setS.append(S[i])

setT = []
cnt = 0
for i in range(len(T)):
  if T[i] not in setT:
    T = T.replace(T[i],al[cnt])
    cnt += 1
    setT.append(T[i])

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

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

dict_st = {}
dict_ts = {}

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

    if y not in dict_ts:
        dict_ts[y]=x
    else:
        if dict_ts[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):
import collections
s = input()
t = input()
s = collections.Counter(s)
t = collections.Counter(t)
if sorted(s.values()) == sorted(t.values()):
  print("Yes")
else:
  print("No")

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

Solution (Python):
s = input()
t = input()
a = {}
b=set()
for i, j in zip(s, t):
    if i in a:
        if a[i] != j:
            print("No")
            exit()
    else:
        if j in b:
            print("No")
            exit()
        b.add(j)
        a[i]=j
print("Yes")

Solution (Python):
from collections import Counter


S = input()
T = input()
ans = -1
countS = Counter(S)
countT = Counter(T)
for i in range(len(S)):
    s = countS[S[i]]
    t = countT[T[i]]
    if s != t:
        ans = 1
        break
    else:
        ans = 0
print('YNeos'[ans::2])

Solution (Python):
S = input()
T = input()
dict1 = {}
dict2 = {}

for s,t in zip(S,T):
    if s in dict1:
        if dict1[s] == t:
            pass
        else:
            print('No')
            exit()
    else:
        dict1[s] = t
    if t in dict2:
        if dict2[t] == s:
            pass
        else:
            print('No')
            exit()
    else:
        dict2[t] = s
print('Yes')

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

def strshape(s):
    d = {}
    ret = []
    idx = 0
    for ch in s:
        if ch not in d:
            d[ch] = idx
            idx += 1
        ret.append(d[ch])
    return ret

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

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

def str2num(s):
    d = {}
    ret = []
    idx = 0
    for ch in s:
        if ch not in d:
            d[ch] = idx
            idx += 1
        ret.append(d[ch])
    return ret

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

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

S = input().split()
S = list(S[0])
T = input().split()
T = list(T[0])
S.sort()
T.sort()
s = []
t = []
i=0
while i < len(S):
    j = i
    count=0
    while j < len(S):
        if S[i] == S[j]:
            count += 1
            j+=1
        else:
            s.append(count)
            break
    i = j
if count!=0:
    s.append(count)
i=0
while i < len(T):
    j = i
    count=0
    while j < len(T):
        if T[i] == T[j]:
            count += 1
            j+=1
        else:
            t.append(count)
            break
    i = j
if count!=0:
    t.append(count)
s.sort()
t.sort()

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

Solution (Python):
import collections

s = input().strip()
t = input().strip()

counter0 = collections.Counter()
counter1 = collections.Counter()

for c in s:
    counter0[c] += 1
for c in t:
    counter1[c] += 1
values0 = sorted(counter0.values())
values1 = sorted(counter1.values())

ok = True
for x0, y0 in zip(values0, values1):
    if x0 != y0:
        ok = False
        break
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
S = list(map(str, input()))
T = list(map(str, input()))

dic, dic_2 = dict(), dict()

def dictionary_append(dictionary, lst):
	id = 0
	for s in lst:
		if not s in dictionary:
			dictionary[s] = []	
		dictionary[s].append(id)
		id += 1

dictionary_append(dic, S)
dictionary_append(dic_2, T)
	
s_prime	= list(dic.values())
t_prime = list(dic_2.values())
s_prime.sort()
t_prime.sort()


no_flg = 0
for s, t in zip(s_prime, t_prime):
	if not s == t:
		print("No")
		no_flg = 1
		break
if not no_flg:
	print("Yes")

Solution (Python):
import string
import sys
S = input()
T = input()
sLst = [0] * 26
tLst = [0] * 26

for i in range(26):
    sLst[i] = S.count(string.ascii_lowercase[i])
    tLst[i] = T.count(string.ascii_lowercase[i])
sLst.sort(reverse=True)
tLst.sort(reverse=True)

for i in range(26):
    if sLst[i] != tLst[i]:
        print('No')
        sys.exit()

print('Yes')

Solution (Python):
s = input()
t = input()
Ps = [[] for i in range(26)]
Pt = [[] for i in range(26)]
for i in range(len(s)):
    Ps[ord(s[i])-97] += [i]
for i in range(len(t)):
    Pt[ord(t[i])-97] += [i]
Ps.sort()
Pt.sort()
if Ps == Pt:
    print('Yes')
else:
    print('No')

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

al = list('abcdefghijklmnopqrstuvwxyz')

ss = {}
ts = {}
for char in s:
    if not char in ss.keys():
        ss[char] = 1
    else:
        ss[char] += 1

for char in t:
    if not char in ts.keys():
        ts[char] = 1
    else:
        ts[char] += 1

if sorted(list(ss.values())) == sorted(list(ts.values())):
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter as C
s=C(input()).most_common()
t=C(input()).most_common()
print("Yes" if [s[i][1] for i in range(len(s))]==[t[i][1] for i in range(len(t))] else "No")

Solution (Python):
def main():
    import sys
    S = input()
    T = input()
    a = {}
    b = {}
    flag = 0
    for i in range(len(S)):
        if not S[i] in a:
            a[S[i]] = T[i]
        if a[S[i]] != T[i]:
            flag = 1
        if not T[i] in b:
            b[T[i]] = S[i]
        if b[T[i]] != S[i]:
            flag = 1
    if flag == 0:
        print("Yes")
    else:
        print("No")
    
main()

Solution (Python):
S = input()
T = input()
def par(m):
  if UF[m] == m:
    return m
  r = par(UF[m])
  UF[m] = r
  return r
UF = list(range(len(S)))
for i in range(len(S)):
  c = S[i]
  j = S.find(c, i+1)
  if not(j < 0):
    UF[j] = i
UFS = UF
UF = list(range(len(T)))
for i in range(len(T)):
  c = T[i]
  j = T.find(c, i+1)
  if not(j < 0):
    UF[j] = i
UFT = UF
if UFS == UFT:
  print("Yes")
else:
  print("No")

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

ss = set(s)
ts = set(t)

sc = [0]*len(s)
tc = [0]*len(t)

for i in ts:
  c = 1
  for j in range(len(t)):
    if t[j] == i:
      tc[j] += c
      c += 1
    
for i in ss:
  c = 1
  for j in range(len(s)):
    if s[j] == i:
      sc[j] += c
      c += 1
      
for i in range(len(t)):
  if sc[i] != tc[i]:     
    print('No')
    exit()
else:
  print('Yes')

Solution (Python):
dicS={'a':0,'b':0,'c':0,'d':0,'e':0,
     'f':0,'g':0,'h':0,'i':0,'j':0,
     'k':0,'l':0,'m':0,'n':0,'o':0,
     'p':0,'q':0,'r':0,'s':0,'t':0,
     'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}
dicT={'a':0,'b':0,'c':0,'d':0,'e':0,
     'f':0,'g':0,'h':0,'i':0,'j':0,
     'k':0,'l':0,'m':0,'n':0,'o':0,
     'p':0,'q':0,'r':0,'s':0,'t':0,
     'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}
S=input()
for i in range(len(S)):
  dicS[S[i]]+=1
T=input()
for i in range(len(T)):
  dicT[T[i]]+=1
lsS=list(dicS.values())
lsT=list(dicT.values())
lsS.sort()
lsT.sort()
if lsS==lsT:
  print("Yes")
else:
  print("No")

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

S = list(input())
T = list(input())
ret = 'Yes'
t = {}
for i in range(len(S)):
    if S[i] in t:
        if t[S[i]] == T[i]:
            continue
        else:
            ret = 'No'
    if ret == 'No':
        break
    t[S[i]] = T[i]

if ret == 'No':
    print(ret)
elif len(t) == len(set(t.values())):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
s = input()
t = input()
yetlist = {}
yetlist2 = {}
for i in range(len(s)):
    if s[i] in yetlist:
        if t[i] != yetlist[s[i]]:
            print("No")
            sys.exit()
    else:
        yetlist[s[i]] = t[i]
    if t[i] in yetlist2:
        if s[i] != yetlist2[t[i]]:
            print("No")
            sys.exit()
    else:
        yetlist2[t[i]] = s[i]   
            
print("Yes")

Solution (Python):
from collections import Counter

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

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

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

def main():
    S = input().strip()
    T = input().strip()
    a = [set() for i in range(26)]
    for i,c1 in enumerate(S):
        s = a[ord(c1)-ord("a")]
        s |= set(T[i])
        if len(s) >= 2:
            print("No")
            return
    a = [set() for i in range(26)]
    for i,c1 in enumerate(T):
        s = a[ord(c1)-ord("a")]
        s |= set(S[i])
        if len(s) >= 2:
            print("No")
            return
        
    print("Yes")

if __name__ == '__main__':
    main()

Solution (Python):
import collections

S = input()
T = input()

s_counter = collections.Counter(S)
t_counter = collections.Counter(T)

if sorted(s_counter.values()) == sorted(t_counter.values()):
    print('Yes')
else:
    print('No')

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

    d={}

    for i in range(len(s)):
        si=s[i]
        ti=t[i]
        if not si in d:
            d[si]=ti
        else:
            if d[si]==ti:
                continue
            else:
                return "No"
            
    vals=d.values()
    if len(vals)==len(set(vals)):
        return "Yes"
    else:
        return "No"
print(check())

Solution (Python):
import sys
import math
from fractions import gcd

from collections import Counter



def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""


 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())


 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

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

sc = Counter(S)
tc = Counter(T)

s = [x for x in sc.values()]
t = [x for x in tc.values()]

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

Solution (Python):
from collections import Counter

S = input()
T = input()

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

Solution (Python):
S = input()
T = input()
S_dict={}
T_dict={}
for i in range(len(S)):
    if S[i] not in S_dict:
        S_dict[S[i]] = 1
    else:
        S_dict[S[i]] += 1
    if T[i] not in T_dict:
        T_dict[T[i]] = 1
    else:
        T_dict[T[i]] += 1
S_list=list(S_dict.values())
T_list=list(T_dict.values())
S_list.sort()
T_list.sort()
result='Yes'
for (x,y) in zip(S_list,T_list):
    if int(x)!=int(y):
        result='No'
print(result)

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

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

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

s = input()
t = input()
ans = "Yes"
d1 = {}
d2 = {}
for i in range(len(s)):
    if s[i] in d1:
        if d1[s[i]] != t[i]:
            ans = "No"
            break
    else:
        d1[s[i]] = t[i]
    if t[i] in d2:
        if d2[t[i]] != s[i]:
            ans = "No"
            break
    else:
        d2[t[i]] = s[i]
print(ans)

Solution (Python):
import sys
from collections import Counter
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

S = input()
T = input()

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

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

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

    ok = True
    dic = {}
    dic2 = {}
    for i in range(len(s)):
        if t[i] in dic:
            if dic[t[i]] != s[i]:
                ok = False
                break
        else:
            dic[t[i]] = s[i]
        if s[i] in dic2:
            if dic2[s[i]] != t[i]:
                ok = False
                break
        else:
            dic2[s[i]] = t[i]
    if ok:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
s, t = list(input()), list(input())
if len(s) != len(t):
    print('No')
    exit(0)
s_cset = set(s)
t_cset = set(t)
if len(s_cset) != len(t_cset):
    print('No')
    exit(0)
s_count = set([])
t_count = set([])
for char in s_cset:
    disto = set([])
    for i, item in enumerate(s):
        if char == item:
            disto.add(i)
    s_count.add(frozenset(disto))
for char in t_cset:
    disto = set([])
    for i, item in enumerate(t):
        if char == item:
            disto.add(i)
    t_count.add(frozenset(disto))
if s_count != t_count:
    print('No')
    exit(0)
print('Yes')

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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

t = {}
for i in range(len(S)):
    if S[i] in t:
        if t[S[i]] == T[i]:
            continue
        else:
            print('No')
            exit()

    t[S[i]] = T[i]

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

Solution (Python):
import itertools
import collections

S = input().split()[0]
T = input().split()[0]
st_set_list = []

for s, t in zip(S, T):
    st_set_list.append(''.join([s, t]))


st_set_list = list(set(st_set_list))

s_list = [s for s, t in st_set_list]
t_list = [t for s, t in st_set_list]
s_c = collections.Counter(s_list)
t_c = collections.Counter(t_list)
ans = 'Yes' if s_c.most_common()[0][1] == 1 and t_c.most_common()[0][1] == 1 else 'No'
print(ans)

Solution (Python):
import sys

S = input()
T = input()
m1 = dict()
m2 = dict()
for s, t in zip(S, T):
    if s in m1 and m1[s] != t:
        print('No')
        sys.exit()
    if t in m2 and m2[t] != s:
        print('No')
        sys.exit()

    m1[s] = t
    m2[t] = s

print('Yes')

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

pairs_s = {}
pairs_t = {}

for i in range(n):
  if s[i] in pairs_s.keys():
    if pairs_s[s[i]] != t[i]:
      print('No')
      break
  else:
    pairs_s[s[i]] = t[i]
      
  if t[i] in pairs_t.keys():
    if pairs_t[t[i]] != s[i]:
      print('No')
      break
  else:
    pairs_t[t[i]] = s[i]
      
else:
  print('Yes')

Solution (Python):
import sys
S = input()
T = input()
used = set()
siz = len(S)

def swap_str(strin, str1, str2, tmp='34343434'):
  return strin.replace(str1,tmp).replace(str2, str1).replace(tmp, str2)

for i in range(siz):
  if S[i] == T[i]:
    continue
  if T[i] in used or S[i] in used:
    print('No')
    sys.exit()
  S = swap_str(S, S[i], T[i])
  used.add(T[i])
print('Yes')

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

Ds = dd(int)
Dt = dd(int)
Cs = dd(int)
Ct = dd(int)

for i in range(len(S)):
  Ds[S[i]] += 1
  Dt[T[i]] += 1  
  
for v in Ds.values():
  Cs[v] += 1
for v in Dt.values():
  Ct[v] += 1
if Cs == Ct:
  print ("Yes")
else:
  print ("No")

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

Solution (Python):
import collections

s = input()
t = input()
S = collections.Counter(s)
T = collections.Counter(t)

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

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



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

a = defaultdict()

for i in range(len(S)):
    if S[i] in a.keys():
        if a[S[i]]==T[i]:
            continue
        else:
            print('No')
            exit()
    else:
        if T[i] in a.values():
            print('No')
            exit()
        else:
            a[S[i]] = T[i]
                      
print('Yes')

Solution (Python):
def resolve():
    S=input()
    T=input()
    a,b={},{}
    for s,t in zip(S,T):
        if a.setdefault(s,t)!=t :
            print('No')
            return()
        if b.setdefault(t,s)!=s :
            print('No')
            return()
    print('Yes')
resolve()

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

    start = [-1] * 26
    goal = [-1] * 26

    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')

        if start[a] != -1 or goal[b] != -1:
            if start[a] != b or goal[b] != a:
                print('No')
                exit()
        
        start[a] = b
        goal[b] = a
    
    print('Yes')

main()

Solution (Python):
s = input()
t = input()
a = {} ; b = {}
for c, d in zip(s, t) :
    if a.setdefault(c, d) != d : print("No") ; break
    if b.setdefault(d, c) != c : print("No") ; break
else : print("Yes")

Solution (Python):
S=input()
T=input()
dic={}
change=[]
ans="No"
for s,t in zip(S,T):
  if s not in dic:
    dic.setdefault(s,t)
    s=dic[s]
    change.append(s)
  else:
    s=dic[s]
    change.append(s)
after=dic.values()
if len(after)==len(set(after)) and "".join(change)==T:
  ans="Yes"
print(ans)

Solution (Python):
def check_signature():
    s = input()
    t = input()
    dict_s = {}
    dict_t = {}
    for s_, t_ in zip(s, t):
        if s_ not in dict_s:
            dict_s[s_] = t_
        if t_ not in dict_t:
            dict_t[t_] = s_
        if dict_s[s_] != t_ or dict_t[t_] != s_:
            return False
    else:
        return True

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

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

def check_signature(str_1, str_2):
    dict_s = {}
    dict_t = {}
    for s_, t_ in zip(s, t):
        if s_ not in dict_s:
            dict_s[s_] = t_
        if t_ not in dict_t:
            dict_t[t_] = s_
        if dict_s[s_] != t_ or dict_t[t_] != s_:
            return False
    else:
        return True

print('Yes' if check_signature(s, t) else 'No')

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

def make_signature(str_):
    dict_ = {}
    sign = []
    cnt = 0
    for s_ in str_:
        if s_ not in dict_:
            dict_[s_] = cnt
            cnt += 1
        sign.append(dict_[s_])
        
    return sign

print('Yes' if make_signature(s) == make_signature(t) else 'No')

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

def make_signature(str_):
    dict_ = {}
    sign = []
    cnt = 0
    for s_ in str_:
        if s_ in dict_:
            sign.append(dict_[s_])
        else:
            sign.append(cnt)
            dict_[s_] = cnt
            cnt += 1

    return sign

print('Yes' if make_signature(s) == make_signature(t) else 'No')

Solution (Python):
s=input()
t=input()
n=len(t)
ss=[0]*26
tt=[0]*26
for i in range(n):
	x=ord(s[i])-ord("a")
	y=ord(t[i])-ord("a")
	ss[x]+=1
	tt[y]+=1
ss.sort()
tt.sort()
if ss==tt:
	print("Yes")
else:
	print("No")

Solution (Python):
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque


args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][0]) for _ in range(ps[0][1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def main():
    S, T = input(str, str)
    swap_st, swap_ts = {}, {}
    for s, t in zip(S, T):
        if not s in swap_st:
            swap_st[s] = t
        else:
            if swap_st[s] != t:
                print("No")
                break
        if not t in swap_ts:
            swap_ts[t] = s
        else:
            if swap_ts[t] != s:
                print("No")
                break
    else:
        print("Yes")

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

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

N = len(S)

RSi = [-1] * 26
RTi = [-1] * 26

a = ord("a")
flg = True
for i in range(N):
    Si = ord(S[i]) - a
    Ti = ord(T[i]) - a
    if RSi[Si] >= 0 and RSi[Si] != Ti:
        flg = False
    elif RSi[Si] < 0:
        RSi[Si] = Ti
    if RTi[Ti] >= 0 and RTi[Ti] != Si:
        flg = False
    elif RTi[Ti] < 0:
        RTi[Ti] = Si
    if not flg:
        break

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

Solution (Python):

S = input()
T = input()

start = [-1]*26
goal = [-1]*26

for i in range(len(S)):
  a = ord(S[i]) - ord("a")
  b = ord(T[i]) - ord("a")
  
  if start[a] != -1 or goal[b] != -1:
    if start[a] != b or goal[b] != a:
      print("No")
      break
  else:
    start[a] = b
    goal[b] = a
else:
  print("Yes")

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

SS = [s for s in S]
SS_set = list(set(SS))
CS = []
for c in SS_set:
  C_idx_in_S = [i for i, x in enumerate(SS) if x==c]
  if len(C_idx_in_S) > 1:
    CS.append(C_idx_in_S)

TT = [t for t in T]
TT_set = list(set(TT))
CT = []
for c in TT_set:
  C_idx_in_T = [i for i, x in enumerate(TT) if x==c]
  if len(C_idx_in_T) > 1:
    CT.append(C_idx_in_T)

if len(CS) == len(CT):
  for i in CS:
    if i in CT:
      continue
    else:
      print("No")
      break
  else:
    print("Yes")
else:
  print("No")

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

s = input()
t = input()
f = defaultdict(lambda : None)
for i in range(len(s)):
    si,ti = s[i],t[i]
    if f[si] != None:
        if f[si] != ti:
            print("No")
            quit()
    else:
        f[si] = ti
f = defaultdict(lambda : None)
for i in range(len(s)):
    si,ti = s[i],t[i]
    if f[ti] != None:
        if f[ti] != si:
            print("No")
            quit()
    else:
        f[ti] = si

print("Yes")

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

Solution (Python):
S=str(input())
T=str(input())
s=list(S)
t=list(T)
s.sort()
t.sort()
import collections
ss=collections.Counter(s)
tt=collections.Counter(t)
ans=0
a=[]
b=[]
for i in range(len(set(s))):
    a.append(ss.most_common()[i][1])
for i in range(len(set(t))):
    b.append(tt.most_common()[i][1])
if a==b:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections as C
import sys
s = input()
t = input()

if len(set(s)) != len(set(t)):
    print("No")
    sys.exit()

ans = [0] * len(s)
stock = C.Counter([])
for i in range(len(s)):
    if s[i] not in stock.keys():
        stock[s[i]] = t[i]
    ans[i] = stock[s[i]]

ss = "".join(ans)

print("Yes") if ss == t and len(list(stock.keys())) == len(list(stock.values())) else print("No")

Solution (Python):


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

c1={}
c2={}
for ss,tt in zip(s,t):
    if c1.get(ss) is None:
        c1[ss]=tt
    if c2.get(tt) is None:
        c2[tt]=ss
    if c1[ss]==tt and c2[tt]==ss:continue
    else:
        print('No')
        exit()

print('Yes')

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