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):

'''
S、あるいはTに含まれる文字Xを一つとってきたときに、
Xが配置されている場所群が、SとTとで同じであればYes、そうでなければNoと出力すればよい。
'''

S = input()
T = input()

S_dict = {}
for i,s in enumerate(S):
    if s not in S_dict:
        S_dict[s] = i

T_dict = {}
for i,t in enumerate(T):
    if t not in T_dict:
        T_dict[t] = i

for s, t in zip(S, T):
    if S_dict[s] == T_dict[t]:
        pass
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
def gnum(str):
  return ord(str) - 97

S = input()
T = input()

R = [-1] * 26
RR = [-1] * 26

c = 0

for i in range(len(S)):
  if R[gnum(S[i])] < 0:
    R[gnum(S[i])] = gnum(T[i])
  else:
    if R[gnum(S[i])] != gnum(T[i]):
      c = 1

  if RR[gnum(T[i])] < 0:
    RR[gnum(T[i])] = gnum(S[i])
  else:
    if RR[gnum(T[i])] != gnum(S[i]):
      c = 1

if c == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
import string
S = input()
T = input()
L = len(S)

s_hash = {}
t_hash = {}
for i in string.ascii_lowercase:
  s_hash[i] = -1
  t_hash[i] = -1

s = []
t = []
for i in range(L):
  if s_hash[S[i]] == -1:
    s_hash[S[i]] = i
  if t_hash[T[i]] == -1:
    t_hash[T[i]] = i
  s.append(s_hash[S[i]])
  t.append(t_hash[T[i]])



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

Solution (Python):
import collections


S = input()
T = input()
cnt_S = collections.Counter(S)
cnt_T = collections.Counter(T)
S_values, S_counts = zip(*cnt_S.most_common())
T_values, T_counts = zip(*cnt_T.most_common())
if S_counts == T_counts:
    print('Yes')
else:
    print('No')

Solution (Python):



S = input()
T = input()

st = {}
ts = {}

yes = "Yes"
no = "No"

ans = yes
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s not in st and t not in ts:
        st[s] = t
        ts[t] = s
    elif s in st:
        if st[s] != t:
            ans = no
            break
    else:
        ans = no
        break
print(ans)

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

v1_to_v2 = {}
v2_to_v1 = {}

dep = ord("z") - ord("a")

def get_end(v, start, depth=0):
    result = to.get(v)
    if result == start:
        return True
    if depth > dep:
        return False
    if result is None:
        return True
    return get_end(result, start, depth + 1)


visited = [True] * n

changes = set()
for v1, v2 in zip(s, t):
    if v1_to_v2.get(v1) is not None and v1_to_v2[v1] != v2:
        print("No")
        exit()
    if v2_to_v1.get(v2) is not None and v2_to_v1[v2] != v1:
        print("No")
        exit()

    
    

    v1_to_v2[v1] = v2
    v2_to_v1[v2] = v1
    
    
    
    
    
print("Yes")

Solution (Python):
s=input()
t=input()
def convert(S):
  lis=[]
  dic=dict()
  con=""
  for i in range(len(S)):
    if S[i] in lis:
      con+=str(dic[S[i]])
    else:
      lis.append(S[i])
      con+=str(len(lis))
      dic[S[i]]=len(lis)
  return con
print("Yes" if convert(s)==convert(t) else "No")

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




sset = list(set(s))
tset = list(set(t))




s_getindex = []
t_getindex = []

for j in range(len(sset)):
    s_getindex.append([i for i, x in enumerate(s) if x == sset[j]])

for jj in range(len(tset)):
    t_getindex.append([ii for ii, y in enumerate(t) if y == tset[jj]])




check_s = []
check_t = []
ans = 0

for k in range(len(sset)):
    if len(s_getindex[k]) != 1:
        for m in s_getindex[k]:
            check_s.append(t[m])


        if len(set(check_s)) != 1:
            ans = ans + 1

        check_s.clear()

for kk in range(len(tset)):
    if len(t_getindex[kk]) != 1:
        for mm in t_getindex[kk]:
            check_t.append(s[mm])
        if len(set(check_t)) != 1:
            ans = ans + 1

        check_t.clear()



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

Solution (Python):
from collections import*
e=defaultdict(list)
d=defaultdict(list)
for k,v in enumerate(input()):
    e[v].append(k)
for k,v in enumerate(input()):
    d[v].append(k)
if set(map(tuple,e.values()))==set(map(tuple,d.values())):
    print("Yes")
else:
    print("No")

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

s_read_chars = []
t_read_chars = []

encoded_S = ""
encoded_T = ""

for s, t in zip(S, T):
    if s not in s_read_chars:
        i = len(s_read_chars)
        s_read_chars.append(s)
    else:
        i = s_read_chars.index(s)
    encoded_S += str(i)
        
    if t not in t_read_chars:
        j = len(t_read_chars)
        t_read_chars.append(t)
    else:
        j = t_read_chars.index(t)
    encoded_T += str(j)

if encoded_S == encoded_T:
    print("Yes")
else:
    print("No")

Solution (Python):

from collections import defaultdict

def main():
    a = list(input())
    b = list(input())
    move_dic = defaultdict(str)

    flg = 1
    for i in range(len(a)):
        char_a = a[i]
        char_b = b[i]

        if char_a in move_dic:
            if move_dic[char_a] != char_b:
                flg = 0
                break
        else:
            move_dic[char_a] = char_b
    if len(list(move_dic.values())) != len(set(list(move_dic.values()))):
        flg = 0
    if flg:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(S: str, T: str):
    n = len(S)
    m_in = {}
    m_out = {}
    for i in range(n):
        if (S[i] in m_in and m_in[S[i]] != T[i]) or (T[i] in m_out and m_out[T[i]] != S[i]):
            ret = NO
            print(ret)
            return
        else:
            m_in[S[i]] = T[i]
            m_out[T[i]] = S[i]
    print(YES)
    return


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

if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
from fractions import gcd

from math import sqrt
from math import ceil
from itertools import permutations
from heapq import *
from collections import defaultdict
from copy import deepcopy

from bisect import bisect_left as bl

S=input()
T=input()
N=len(S)
dic1=defaultdict(int)
for i in range(N):
    s=S[i]
    t=T[i]
    if s in dic1.keys():
        if t!=dic1[s]:
            print("No")
            quit()
    else:
        dic1[s]=t
dic2=defaultdict(int)
for i in range(N):
    s=S[i]
    t=T[i]
    if t in dic2.keys():
        if s!=dic2[t]:
            print("No")
            quit()
    else:
        dic2[t]=s
print("Yes")

Solution (Python):
import sys
T=input()
S=input()
Ts=set(T)
Ss=set(S)
for v in Ts:
  ind=[i for i, x in enumerate(T) if x == v]
  for i in range(len(ind)):
    if i==0:
      continue
    if not S[ind[i-1]]==S[ind[i]]:
      print("No")
      sys.exit()
for v in Ss:
  ind=[i for i, x in enumerate(S) if x == v]
  for i in range(len(ind)):
    if i==0:
      continue
    if not T[ind[i-1]]==T[ind[i]]:
      print("No")
      sys.exit()
print("Yes")

Solution (Python):
from collections import Counter
S = input()
T = input()
S = Counter(S)
T = Counter(T)
S = sorted(list(S.values()))
T = sorted(list(T.values()))

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

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

dict1 = {}
for s in S:
  if(s in dict1): dict1[s] += 1
  else: dict1[s] = 1   
dict2 = {}
for t in T:
  if(t in dict2): dict2[t] += 1
  else: dict2[t] = 1

list1,list2 = [],[]
for k, v in sorted(dict1.items(), key=lambda x: x[1]):
  list1.append(v)
for k, v in sorted(dict2.items(), key=lambda x: x[1]):
  list2.append(v)


if(list1 == list2):
 print('Yes')
else:
 print('No')

Solution (Python):
s=input()
n=input()
d=dict()
dd=dict()
ans="Yes"
for i in range(len(s)):
  if s[i] not in d:
    d[s[i]]=n[i]
  elif d[s[i]]!=n[i]:
    ans="No"
  if n[i] not in dd:
    dd[n[i]]=s[i]
  elif dd[n[i]]!=s[i]:
    ans="No"
print(ans)

Solution (Python):
import collections


if __name__ == '__main__':
    s = input()
    t = input()

    s_freq_values = list(collections.Counter(s).values())
    s_freq_values.sort()

    t_freq_values = list(collections.Counter(t).values())
    t_freq_values.sort()

    if t_freq_values == s_freq_values:
        print('Yes')
    else:
        print('No')

Solution (Python):
S = input()
T = input()
slist,tlist = {},{}
S2,T2 = [],[]
scount,tcount = 0,0

for i in range(len(S)):
  if S[i] not in slist.keys():
    slist[S[i]] = scount
    scount += 1
  S2.append(slist[S[i]]) 

  if T[i] not in tlist.keys():
    tlist[T[i]] = tcount
    tcount += 1
  T2.append(tlist[T[i]]) 

if S2 == T2:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()
T = input()
list1 = {}
list2 = {}

flag = True
for i in range(len(S)):
    if S[i] in list1.keys():
        if list1[S[i]] != T[i]:
            flag = False
    if T[i] in list2.keys():
        if list2[T[i]] != S[i]:
            flag = False
    list1[S[i]] = T[i]
    list2[T[i]] = S[i]

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

Solution (Python):
import collections as col
s = list(input())
t = list(input())
s_1 = col.Counter(s)
t_1 = col.Counter(t)
s_2 = sorted(s_1.values())
t_2 = sorted(t_1.values())
if s_2 == t_2:
    print("Yes")
else:
    print("No")

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

d_s2t = dict()
d_t2s = dict()

flg = True
for ss, tt in zip(s, t):
    if d_s2t.get(ss) is None:
        d_s2t[ss] = tt
    else:
        if not d_s2t[ss] == tt:
            flg = False
            break

    if d_t2s.get(tt) is None:
        d_t2s[tt] = ss
    else:
        if not d_t2s[tt] == ss:
            flg = False
            break

if flg:
    if len(set(d_s2t.keys())) != len(set(d_s2t.values())):
        flg = False
    if len(set(d_t2s.keys())) != len(set(d_t2s.values())):
        flg = False

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

Solution (Python):
from string import ascii_lowercase

s = input()
t = input()

d_s2t = dict()
d_t2s = dict()

flg = True
for ss, tt in zip(s, t):
    if d_s2t.get(ss) is None:
        d_s2t[ss] = tt
    else:
        if not d_s2t[ss] == tt:
            flg = False
            break

    if d_t2s.get(tt) is None:
        d_t2s[tt] = ss
    else:
        if not d_t2s[tt] == ss:
            flg = False
            break

if flg:
    if len(set(d_s2t.keys())) != len(set(d_s2t.values())):
        flg = False
    if len(set(d_t2s.keys())) != len(set(d_t2s.values())):
        flg = False

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

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

dic1 = {}
dic2 = {}
f = True
for i,j in zip(s,t):
    if i in dic1:
        if dic1[i] != j:
            f = False
    else:
        dic1[i] = j
    if j in dic2:
        if dic2[j] != i:
            f = False
    else:
        dic2[j] = i
if f:
    print("Yes")
else:
    print("No")

Solution (Python):


def calc(S, T):
    
    ans = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            ans += 1
    return ans


def solve():
    s = input()
    S = [moji for moji in s]
    T = input()

    
    
    diff = calc(S, T)
    if diff == 0:
        print("Yes")
        return

    pre_diff = diff

    while True:
        
        for i in range(len(S)):
            if S[i] != T[i]:
                c1 = S[i]
                c2 = T[i]
                break
        
        
        for i in range(len(S)):
            if S[i] == c1:
                S[i] = c2
            elif S[i] == c2:
                S[i] = c1
        
        
        diff = calc(S, T)
        if diff == 0:
            print("Yes")
            return
        elif diff < pre_diff:
            pre_diff = diff
            continue
        else:
            print("No")
            return


if __name__ == "__main__":
    solve()

Solution (Python):


def calc(S, T):
    
    ans = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            ans += 1
    return ans


def solve():
    s = input()
    S = [moji for moji in s]
    T = input()

    
    
    diff = calc(S, T)
    if diff == 0:
        print("Yes")
        return
    pre_diff = diff

    while True:
        
        for i in range(len(S)):
            if S[i] != T[i]:
                c1 = S[i]
                c2 = T[i]
                break
        
        
        for i in range(len(S)):
            if S[i] == c1:
                S[i] = c2
            elif S[i] == c2:
                S[i] = c1
        
        
        diff = calc(S, T)
        if diff == 0:
            break
        elif diff < pre_diff:
            pre_diff = diff
            continue
        else:
            print("No")
            return
    print("Yes")





if __name__ == "__main__":
    solve()

Solution (Python):
s = input()
t = input()
dic1 = {}
dic2 = {}
f = True
for i, j in zip(s, t):
    if i in dic1:
        if dic1[i] != j:
            f = False
            break
    dic1[i] = j
    if j in dic2:
        if dic2[j] != i:
            f = False
            break
    dic2[j] = i
if f:
    print('Yes')
else:
    print('No')

Solution (Python):

import sys
import collections

YES = "Yes"  
NO = "No"  


def solve(S: str, T: str):
    wcS = collections.defaultdict(int)
    wcT = collections.defaultdict(int)
    for c in S:
        wcS[c] += 1
    for c in T:
        wcT[c] += 1
    cS = collections.defaultdict(int)
    cT = collections.defaultdict(int)
    for key in wcS:
        cS[wcS[key]] += 1
    for key in wcT:
        cT[wcT[key]] += 1
    representable = True
    if len(cT.keys()) > len(cS.keys()):
        temp = cT
        cT = cS
        cS = temp
    for key in cS:
        if cT[key] != cS[key]:
            representable = False
    print(YES if representable else NO)
    return



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


if __name__ == '__main__':
    main()

Solution (Python):
S = input()
T = input()
check = {'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'}
alll = ['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']
alfa = {'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'}
count_s = set()
count_t = set()
nums = 0
numt = 0
for s in range(len(S)):
    if count_s == alfa:
        break
    if S[s] in check:
        continue
    count_s.add(S[s])
    S = S.replace(S[s],str(alll[nums]))
    nums += 1
for t in range(len(T)):
    if count_t == alfa:
        break
    if T[t] in check:
        continue
    count_t.add(T[t])
    T = T.replace(T[t],str(alll[numt]))
    numt += 1
if S == T:
    print('Yes')
else:print('No')

Solution (Python):
S = input()
T = input()
dic1 = {}
dic2 = {}
flag = True
for i , j in zip(S, T):
    if i in dic1:
        if dic1[i] != j:
            flag = False
            break
    dic1[i] = j
    if j in dic2:
        if dic2[j] != i:
            flag = False
            break
    dic2[j] = i
if flag:
    print('Yes')
else:
    print('No')

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

def replacer():
	m = {}
	i = ord("A")

	def replace(c):
		nonlocal i
		if c not in m:
			m[c] = chr(i)
			i += 1
		return m[c]

	return replace

rs="".join(map(replacer(), S))
rt="".join(map(replacer(), T))

print("Yes" if rs == rt else "No")

Solution (Python):
s = input()
t = input()
a = "abcdefghijklmnopqrstuvwxyz"

flag = 0
i = 0 
while i < len(s):
	if s[i] != t[i]:
		if t[i] in a:
			c = s[i]
			s = s.replace(c, "1")
			s = s.replace(t[i], c)
			s = s.replace("1", t[i])
			a = a.replace(t[i], "1")
		else:
			break
	i += 1
if s == t:
	print("Yes")
else:
	print("No")

Solution (Python):
S = [i for i in input()]
T = [i for i in input()]

judge_s, judge_t = {}, {}

idx = 0
ct = 0
for i in S:
    if judge_s.get(i):
        S[idx] = judge_s[i]
    else:
        S[idx] = ct
        judge_s[i] = ct
        ct += 1
    idx += 1

idx = 0
ct = 0
for i in T:
    if judge_t.get(i):
        T[idx] = judge_t[i]
    else:
        T[idx] = ct
        judge_t[i] = ct
        ct += 1
    idx += 1

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

Solution (Python):
S = input()
T = input()
F = 1
DD = [0 for i in range(1001)]
NUM = [0 for i in range(1001)]
grid = [i for i in range(ord('a'),ord('z')+1)]
for i in range(len(S)):
    if (not DD[ord(S[i])] == ord(T[i])) and (not DD[ord(S[i])] == 0):
        F = 0
    if DD[ord(S[i])] == 0:
        NUM[ord(T[i])] = NUM[ord(T[i])] + 1
    DD[ord(S[i])] = ord(T[i])
for i in NUM:
    if i >= 2:
        F = 0
print("Yes" if F == 1 else "No")

Solution (Python):
S = list(str(input()))
T = list(str(input()))
moji = "abcdefghijklmnopqrstuvwxyz"
tmp_1 = []
tmp_2 = []
for i in range(26):
  count = S.count(moji[i])
  tmp_1.append(count)
for i in range(26):
  count = T.count(moji[i])
  tmp_2.append(count)
tmp_1.sort()
tmp_2.sort()
if tmp_1 == tmp_2:
  print("Yes")
else:
  print("No")

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

ds = dict()
dt = dict()
for i in range(len(S)):
    s, t = S[i], T[i]
    if s in ds:
        if ds[s] != t:
            print('No')
            exit()
    else:
        ds[s] = t

    if t in dt:
        if dt[t] != s:
            print('No')
            exit()
    else:
        dt[t] = s

print('Yes')

Solution (Python):
s = input()
t = input()
 
s_c = []
t_c = []
for c in 'abcdefghijklmnopqrstuvwxyz':
    s_c.append(s.count(c))
    t_c.append(t.count(c))
s_c.sort()
t_c.sort()
if s_c == t_c:
  print('Yes')
else:
  print('No')

Solution (Python):
prj = {}
prj_inv = {}
s = input()
t = input()
for i, j in zip(s, t):
    if i not in prj and j not in prj_inv:
        prj[i] = j
        prj_inv[j] = i
    elif i in prj and j in prj_inv:
        if prj[i] == j:
            continue
        else:
            print('No')
            break
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
def check(s, t):
    from collections import Counter
    sc = Counter(s)
    tc = Counter(t)
    return sorted(sc.values()) == sorted(tc.values())

print(['No','Yes'][check(input(),input())])

Solution (Python):
s=input()
t=input()
def C(a, b):
    d={}
    for i in range(len(a)):
        if a[i] in d:
            if d[a[i]]!=b[i]:
                return False
        else:
            d[a[i]]=b[i]
    return True
if C(s, t)and C(t, s):
    print('Yes')
else:
    print('No')

Solution (Python):
s=input()
t=input()
dic1={}
for i in range(len(s)):
    if s[i] in dic1:
        if dic1[s[i]]!=t[i]:
            print("No")
            exit()
    else:
        dic1[s[i]]=t[i]
dic2={}
for k in range(len(t)):
    if t[k] in dic2:
        if dic2[t[k]]!=s[k]:
            print("No")
            exit()
    else:
        dic2[t[k]]=s[k]
print("Yes")

Solution (Python):
import collections

S = input()
T = input()

sc = sorted(list(collections.Counter(S).values()))
tc = sorted(list(collections.Counter(T).values()))

if sc == tc:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict

from math import sqrt

S=input()
T=input()
ds=defaultdict(str)
dt=defaultdict(str)
for s,t in zip(S,T):
    if not(s in ds.keys()):
        ds[s]=t
        continue
    elif ds[s]==t:
        continue
    else:
        print("No")
        quit()
for s,t in zip(S,T):
    if not(t in dt.keys()):
        dt[t]=s
        continue
    elif dt[t]==s:
        continue
    else:
        print("No")
        quit()
print("Yes")

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

S_charmap={ chr(i):-1 for i in range (97,97+26)}
T_charmap={ chr(i):-1 for i in range (97,97+26)}
S_kinds=0
T_kinds=0

ans='Yes'
for i in range(N):
	if S_charmap[S[i]] == -1:
		S_kinds += 1
		S_charmap[S[i]] = S_kinds
	if T_charmap[T[i]] == -1:
		T_kinds += 1
		T_charmap[T[i]] = T_kinds
	if S_charmap[S[i]] == T_charmap[T[i]]:
		continue
	else:
		ans='No'
		break
print(ans)

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

dic={}
for i in range(len(s)):
    if not s[i] in dic and t[i] in dic.values():
        print("No")
        sys.exit()
    dic.setdefault(s[i],t[i])
    if dic[s[i]]!=t[i]:
        print("No")
        sys.exit()


print("Yes")

Solution (Python):
import collections

s = input()
t = input()
c1 = collections.Counter(s)
c2 = collections.Counter(t)
s_values = sorted(list(c1.values()))
t_values = sorted(list(c2.values()))

if len(s) == len(t):
  if len(list(set(s))) == len(list(set(t))):
    if s_values == t_values:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Solution (Python):
from collections import defaultdict
S = input()
T = input()
s = defaultdict(int)
t = defaultdict(int)
for c in S:
    s[c] += 1
for c in T:
    t[c] += 1
sv = sorted(s.values())
tv = sorted(t.values())
if sv == tv:
    print('Yes')
else:
    print('No')

Solution (Python):
S=input()
T=input()
Skey=sorted(set(S),key=S.index)
Tkey=sorted(set(T),key=T.index)

for index,i in enumerate(Skey):
  S=S.replace(i,str(index))
for index,i in enumerate(Tkey):
  T=T.replace(i,str(index))

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

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

Skey = sorted(set(S),key=S.index)
Tkey = sorted(set(T),key=T.index)

for idx,i in enumerate(Skey):
  S = S.replace(i,str(idx))
for idx,i in enumerate(Tkey):
  T = T.replace(i,str(idx))

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

Solution (Python):


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

s.sort()
t.sort()

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

s = array_count(s)
t = array_count(t)

def get_item_1 (arr):
    newarr = []
    for i in range(len(arr)):
        newarr.append(arr[i][1])
    return newarr

s = get_item_1(s)
t = get_item_1(t)

s.sort()
t.sort()

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

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

def hoge(text):
    assign = {}
    result = []
    for c in text:
        if c not in assign:
            assign[c] = len(assign)
        result.append(assign[c])
    return result

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

Solution (Python):
def main():
    Sdict = {}
    Tdict = {}
    S = list(input())
    T = list(input())
    for i in S:
        if i in Sdict.keys():
            Sdict[i] += 1
        else:
            Sdict[i] = 1
    for i in T:
        if i in Tdict.keys():
            Tdict[i] += 1
        else:
            Tdict[i] = 1
    if sorted(list(Sdict.values())) == sorted(list(Tdict.values())):
        print("Yes")
    else:
        print("No")

main()

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

s_c = []
t_c = []
for c in 'abcdefghijklmnopqrstuvwxyz':
    s_c.append(s.count(c))
    t_c.append(t.count(c))
s_c.sort()
t_c.sort()
if s_c == t_c:
  print('Yes')
else:
  print('No')

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

s_counter = []
t_counter = []
for c in 'abcdefghijklmnopqrstuvwxyz':
    s_counter.append(s.count(c))
    t_counter.append(t.count(c))

s_counter.sort()
t_counter.sort()

ans = 'Yes' if s_counter == t_counter else 'No'
print(ans)

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

sl = [0]*26
tl = [0]*26

for temp in S:
    tn = ord(temp) - ord("a")
    sl[tn] += 1

for temp in T:
    tn = ord(temp) - ord("a")
    tl[tn] += 1

sl.sort()
tl.sort()

ans = "Yes"
for n in range(26):
    if sl[n] == tl[n]:
        continue
    else:
        ans = "No"
        break

print(ans)

Solution (Python):
import collections
S = list(input())
T = list(input())
S_c = sorted(collections.Counter(S).items(),key=lambda x:x[1])
T_c = sorted(collections.Counter(T).items(),key=lambda x:x[1])

if len(S_c) == len(T_c):
  for i in range(len(S_c)):
    if S_c[i][1] != T_c[i][1]:
      print('No')
      exit()
  else:
    print('Yes')
      
else:
  print('No')

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

StoT = {}
TtoS = {}

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

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

Skey = sorted(set(S),key=S.index)
Tkey = sorted(set(T),key=T.index)

for idx,i in enumerate(Skey):
  S = S.replace(i,str(idx))
for idx,i in enumerate(Tkey):
  T = T.replace(i,str(idx))

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

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

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

Solution (Python):
S = [c for c in input()]
T = [c for c in input()]

def main():
    z = zip(S, T)
    s = set(z)
    unpacked = list(zip(*s))
    
    ans = [len(set(t)) == len(t) for t in unpacked]
    print('Yes' if all(ans) else 'No')

if __name__ == '__main__':
    main()

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

sc = Counter(s)
tc = Counter(t)

if sorted(sc.values()) == sorted(tc.values()):
  print("Yes")
else:
  print("No")

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

def fix(T,S):
    l = [[] for _ in range(26)]
    for k, c in enumerate([chr(ord("a") + i) for i in range(26)]):
        for i,t in enumerate(T):
            if t == c:
                l[k].append(i)

    for a in l:
        if len(a) <= 1:
            continue
        prop = S[a[0]]
        for i in a:
            if prop != S[i]:
                print("No")
                exit()

fix(T,S)
fix(S,T)

print("Yes")

Solution (Python):
from collections import Counter as C
print(["No", "Yes"][C(C(input()).values()) == C(C(input()).values())])

Solution (Python):
import sys
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  
def LF(): return [float(x) for x in sys.stdin.readline().split()]  
def LS(): return sys.stdin.readline().split()  
def MI(): return map(int, sys.stdin.readline().split())  
def II(): return int(sys.stdin.readline())  
def IS(): return input()  
def P(x): return print(x)
def C(x): return Counter(x)


S = C(IS())
T = C(IS())
sv = sorted([v for v in S.values()])
tv = sorted([v for v in T.values()])
P('Yes') if sv == tv else P('No')

Solution (Python):
from collections import Counter

S = input()
T = input()

s = list(Counter(S).values())
t = list(Counter(T).values())
s.sort(reverse=True)
t.sort(reverse=True)

for i,j in zip(s,t):
    if i != j:
        print('No')
        break
else:
    print('Yes')

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

f = lambda c,l:[i for i,x in enumerate(l) if c == x]

sc = []
ts = []
for s,t in zip(S,T):
	if not s in sc:
		sc.append(s)
		sind = f(s,S)
		tind = f(t,T)
		if sind != tind:
			print("No")
			exit()
print("Yes")

Solution (Python):
'''
考え方

なんらかの文字列IDを降って、指定した位置の文字の文字列IDが完全一致していること。
（アルファベットが何か、は関係ないので考慮しなくても良い）

なので、同一アルファベットがどの位置にあるか、というのが一致していればOK。

辞書型の変数を持つ。キーは「Sの文字列ID」、値は「その文字列IDが出現する位置」
'''


S = input()
T = input()
len_S = len(S)
len_T = len(T)

dict_s = {}
dict_t = {}
alphabets = 'abcdefghijklmnopqrstuvwxyz'


for alphabet in alphabets:
  cnt = S.count(alphabet)
  if cnt == 0:
    continue
  else:
    dict_s[alphabet] = [i for i, x in enumerate(S) if x == alphabet]



for alphabet in alphabets:
  cnt = T.count(alphabet)
  if cnt == 0:
    continue
  else:
    dict_t[alphabet] = [i for i, x in enumerate(T) if x == alphabet]



dict_used = {}
cnt = 0
for key_src, value_src in dict_s.items():
  for key_trg, value_trg in dict_t.items():
    if value_src == value_trg and key_src not in dict_used:
      dict_used[key_src] = 1
      cnt += 1
      break


if len(dict_s) == cnt:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    S = input()
    sa = [-1]*len(S)
    T = input()
    ta = [-1]*len(T)
    dict_s = {}
    dict_t = {}
    for index, c in enumerate(S):
        if not (c in dict_s.keys()):
            dict_s[c] = len(dict_s.keys())
        sa[index] = dict_s[c]
    for index, c in enumerate(T):
        if not (c in dict_t.keys()):
            dict_t[c] = len(dict_t.keys())
        ta[index] = dict_t[c]
    for i in range(len(sa)):
        if sa[i] != ta[i]:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main()

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')



S, T = "", ""


def set_inputs():
    global S, T
    S = get_str()
    T = get_str()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    mapper = dict()
    inverser = dict()
    for s, t in zip(S, T):
        m = mapper.get(s, None)
        if m and m != t:
            print("No")
            return
        mapper[s] = t
        i = inverser.get(t, None)
        if i and i != s:
            print("No")
            return
        inverser[t] = s
    print("Yes")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


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


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Solution (Python):
s=list(input())
t=list(input())
set_s=sorted(set(s),key=s.index)
set_t=sorted(set(t),key=t.index)
s_dic={}
t_dic={}
k=0
for i in set_s:
    s_dic[i]=k
    k+=1
k=0
for i in set_t:
    t_dic[i]=k
    k+=1
flg=0
for a,b in zip(s,t):
    if s_dic[a]!=t_dic[b]:
        flg=1
if flg==0:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict
import sys

S = input()
T = input()
dic1 = defaultdict(str)
dic2 = defaultdict(str)

for x, y in zip(S, T):
    if not x in dic1:
        dic1[x] = y
    if not y in dic2:
        dic2[y] = x
    if x in dic1:
        if dic1[x] != y:
            print('No')
            sys.exit()
    if y in dic2:
        if dic2[y] != x:
            print('No')
            sys.exit()

print('Yes')