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 math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 



 




 


 





 


 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    S = input()
    T = input()
    S = S[:-1]
    T = T[:-1]
    
    S_dict = {}
    T_dict = {}
    for i in range(len(S)):
        if S[i] in S_dict:
            S_dict[S[i]] += 1
        else:
            S_dict[S[i]] = 1
            
        if T[i] in T_dict:
            T_dict[T[i]] += 1
        else:
            T_dict[T[i]] = 1
            
    S_list = []
    T_list = []
    for k,v in S_dict.items():
        S_list.append(v)
    for k,v in T_dict.items():
        T_list.append(v)
        
    S_list.sort()
    T_list.sort()
    
    if S_list == T_list:
        print("Yes")
    else:
        print("No")
    
    
        
    
if __name__ == "__main__":
	main()

Solution (Python):

s = list(map(lambda x:ord(x)-97,input()))
t = list(map(lambda x:ord(x)-97,input()))

ret = "Yes"
transform_mapping = [[0] * 26 for _ in range(26)]

for si,ti in zip(s,t):
    transform_mapping[si][ti] = 1
for i in transform_mapping:
    if sum(i) >= 2:
        ret = "No"
for i in zip(*transform_mapping):
    if sum(i) >= 2:
        ret = "No"
print(ret)

Solution (Python):
def list_count(my_list):
    dic={} 
    for num in my_list:
        if num in dic: 
            dic[num]+=1 
        else: 
            dic[num]=1 
    return dic
s=input()
t=input()
n=len(s)
dic={}
for i in range(n):
    if s[i] in dic and dic[s[i]]!=t[i]:
        print("No")
        exit()
    else:
        dic[s[i]]=t[i]
dic2={}
for i in range(n):
    if t[i] in dic2 and dic2[t[i]]!=s[i]:
        print("No")
        exit()
    else:
        dic2[t[i]]=s[i]
print("Yes")

Solution (Python):
from collections import Counter

S = input()
T = input()

a = sorted([i for i in Counter(S).values()])
b = sorted([i for i in Counter(T).values()])

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

Solution (Python):
S=input();T=input()
for cap in range(ord("a"),ord("z")+1):
  c=chr(cap)
  list_s=[]
  for i in range(len(S)):
    if S[i]==c:
      list_s.append(i)
  
  list_t=[]
  if list_s != []:
    c=T[list_s[0]]  
    for i in range(len(T)):
      if T[i]==c:
        list_t.append(i)
        
  if list_s!=list_t:
    print("No");exit()
    
print("Yes")

Solution (Python):
import sys
from collections import Counter
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

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

cs = Counter(S).most_common()
ct = Counter(T).most_common()

N = len(cs)

vs, cs = zip(*cs)
vt, ct = zip(*ct)



for i,j in zip(cs, ct):
	if cs != ct:
		print('No')
		sys.exit()
print('Yes')

Solution (Python):
S = input()
T = input()
AL=[chr(ord('A') + i) for i in range(26)]
al=[chr(ord('a') + i) for i in range(26)]

def cnvS(St):
  import re
  cnt = 0
  while (cnt < 26):
    fnd=re.search('[a-z]', St)
    if fnd:
      St = St.replace(fnd.group(),AL[cnt])
      cnt +=1
    else:
      break
  return St

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

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

pre_dict = {}
post_dict = {}
ans = True
for i in range(len(s_l)):
    if s_l[i] in pre_dict.keys():
        if t_l[i] not in pre_dict[s_l[i]]:
            ans = False
    else:
        pre_dict[s_l[i]] = [t_l[i]]
    
    if t_l[i] in post_dict.keys():
        if s_l[i] not in post_dict[t_l[i]]:
            ans = False
    else:
        post_dict[t_l[i]] = [s_l[i]]

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

Solution (Python):
import sys
s=input()
t=input()
n=len(s)
d=dict()
d2=dict()
for i in range(n):
    if t[i] in d.keys():
        if d[t[i]] != s[i]:
            print("No")
            sys.exit()
    else:
        d[t[i]] = s[i]
    
    if s[i] in d2.keys():
        if d2[s[i]] != t[i]:
            print("No")
            sys.exit()
    else:
        d2[s[i]] = t[i]
else:
    print("Yes")

Solution (Python):
S = input()
T = input()
ans = "Yes"
start = [-1]*26
goal = [-1]*26
for i in range(len(S)):
    s,t = ord(S[i])-97,ord(T[i])-97
    if start[s]!=-1 or goal[t]!=-1:
        if start[s]!=t or goal[t]!=s:
            ans = "No"
    else:
        start[s] = t
        goal[t] = s
print(ans)

Solution (Python):
S = input()
T = input()
ans = "Yes"
start = [-1]*27
goal = [-1]*27
for i in range(len(S)):
    s,t = ord(S[i])-96,ord(T[i])-96
    if start[s]!=-1 or goal[t]!=-1:
        if start[s]!=t or goal[t]!=s:
            ans = "No"
    else:
        start[s] = t
        goal[t] = s
print(ans)

Solution (Python):
S = input()
T = input()
D = dict()
f = True
for s, t in zip(S, T):
  if s not in D:
    if t not in D.values():
    	D[s] = t
    else:
      f = False
      break
  elif D[s] != t:
    f = False
    break
print('Yes' if f else 'No')

Solution (Python):
s=list(input())
t=list(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")

Solution (Python):
from collections import Counter

s = input()
t = input()

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

if len(sc) != len(tc):
    print("No")
    exit()

S,T = [],[]
for s,t in zip(sc.values(),tc.values()):
    S.append(s)
    T.append(t)

S.sort()
T.sort()

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

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

def checking(check_dict, key, val, yes_ans):
    if key in check_dict:
        if check_dict[key] == val:
            pass
        else:
            print('No')
            yes_ans = False
            return yes_ans
    else:
        check_dict[key] = val
    return yes_ans


t_dict = {}
s_dict = {}
yes_ans = True

for t_val, s_val in zip(t, s):
    yes_ans = checking(t_dict, t_val, s_val, yes_ans)
    if yes_ans == False:
        break
    yes_ans = checking(s_dict, s_val, t_val, yes_ans)
    if yes_ans == False:
        break

if yes_ans:
    print('Yes')

Solution (Python):
S=str(input())
T=str(input())
x=[]
y=[]
dic={}

for i in range(len(S)):
    x.append(S[i])
    y.append(T[i])
    
for s,t in zip(x,y):
    if s in dic:
        if dic[s]!=t:
            print("No")
            exit()
    else:
        dic[s]=t

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

Solution (Python):
S=input()
T=input()
S2=[0]*len(S)
T2=[0]*len(T)
SD={}
TD={}

c=0
for i in range(len(S)):
    if(SD.get(S[i],None)==None):
        c+=1
        SD[S[i]]=c
        S2[i]=c
    else:
        S2[i]=SD.get(S[i],None)
c=0
for i in range(len(T)):
    if(TD.get(T[i],None)==None):
        c+=1
        TD[T[i]]=c
        T2[i]=c
    else:
        T2[i]=TD.get(T[i],None)
if(S2==T2):
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
t=input()
l=len(s)
c=[chr(i) for i in range(97,97+26)]
for i in range(26):
    f=0
    for j in range(l):
        if c[i]==s[j]:
            if f==0:
                k=t[j]
                f+=1
            elif f==1 and t[j]!=k:
                f+=1
                print("No")
                break
    if f==2:
        break
else:
    for i in range(26):
        f=0
        for j in range(l):
            if c[i]==t[j]:
                if f==0:
                    k=s[j]
                    f+=1
                elif f==1 and s[j]!=k:
                    f+=1
                    print("No")
                    break
        if f==2:
            break
    else:
        print("Yes")

Solution (Python):
S = list(input())
T = list(input())
dic = {}
ans='Yes'
for s,t in zip(S,T):
  if not s in dic:
    if t in dic.values():
      ans = 'No'
      break
    else:
      dic[s]=t
    
  else:
    if dic[s]!=t:
      ans = 'No'
      break
      
print(ans)

Solution (Python):
a=input()
b=input()
c={}
state=True
for i in range(len(a)):
  if b[i] not in c and a[i] not in c.values():
    c[b[i]]=a[i]
  if b[i] in c:
    if c[b[i]]!=a[i]:
      state=False
  else:
    state=False
if state:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys
input = sys.stdin.readline
s = list(input())
del s[-1]
t = list(input())
del t[-1]


table_s = [-1]*26
table_t = [-1]*26

for i in range(len(s)):
    if table_s[ord(s[i])-ord("a")] == -1:
        table_s[ord(s[i])-ord("a")] = ord(t[i])-ord("a")
        table_t[ord(t[i])-ord("a")] = ord(s[i])-ord("a")
    else:
        if table_s[ord(s[i])-ord("a")] != ord(t[i])-ord("a"):
            print("No")
            exit()

table_s = [-1]*26
table_t = [-1]*26

for i in range(len(t)):
    if table_t[ord(t[i])-ord("a")] == -1:
        table_t[ord(t[i])-ord("a")] = ord(s[i])-ord("a")
        table_s[ord(s[i])-ord("a")] = ord(t[i])-ord("a")
    else:
        if table_t[ord(t[i])-ord("a")] != ord(s[i])-ord("a"):
            print("No")
            exit()


print("Yes")

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

from collections import Counter as c
s = c(S)
t = c(T)

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

Solution (Python):

import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

s=input()
t=input()
ds=collections.defaultdict(set)
dt=collections.defaultdict(set)

for i in range(len(s)):
    ds[s[i]].add(t[i])
    dt[t[i]].add(s[i])

for si in ds.values():
    if len(si)>=2:
        print("No")
        exit()

for ti in dt.values():
    if len(ti)>=2:
        print("No")
        exit()

print("Yes")

Solution (Python):
s = input()
t = input()
sWords = {}
tWords = {}
for si, ti in zip(s,t):
    sWords[si] = sWords.get(si, 0) + 1
    tWords[ti] = tWords.get(ti, 0) + 1
print(["No", "Yes"][sorted(list(sWords.values())) == sorted(list(tWords.values()))])

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

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

temp = 0

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

    if (b in start or a in goal):
        if (start[a] != b or goal[b] != a):
            temp = 1
            break
    else:
        start[a] = b
        goal[b] = a

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

Solution (Python):
d={}
w1=input()
w2=input()
num=len(w1)
b=True
for i in list("qwertyuiopasdfghjklzxcvbnm"):
  d[i]=""
for i in range(num):
  if d[w1[i]]=="":
    d[w1[i]]=w2[i]
  elif d[w1[i]]==w2[i]:
    pass
  elif d[w1[i]]!=w2[i]:
    b=False
    break
if not b:
  print("No")
else:
  l=[]
  for i in d:
    if d[i] in l:
      b=False
      break
    else:
      if d[i]!="":
        l.append(d[i])
  if b:
    print("Yes")
  else:
    print("No")

Solution (Python):
S = list(input())
T = list(input())
now = 0
idxS_dict = {}
idxT_dict = {}
for i in range(26):
    idxS_dict[chr(ord('a') + i)] = []
    idxT_dict[chr(ord('a') + i)] = []
for i in range(len(S)):
    idxS_dict[S[i]].append(i)
    idxT_dict[T[i]].append(i)

S_vals = idxS_dict.values()
T_vals = idxT_dict.values()

for val in S_vals:
    if not val in T_vals:
        print('No')
        exit()
print('Yes')

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

dicS = defaultdict(int)
dicT = defaultdict(int)
for s, t in zip(S, T):
    dicS[s] += 1
    dicT[t] += 1
    if dicS[s] != dicT[t]:
        print('No')
        exit()
print('Yes')

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

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

ascii_lower = list(string.ascii_lowercase)
s_list = [-1 for _ in range(26)]
t_list = s_list[:]


for s, t in zip(S, T):
  s_index = ascii_lower.index(s)
  t_index = ascii_lower.index(t)
  
  if s_list[s_index] != -1 or t_list[t_index] != -1:
    if s_list[s_index] != t_index or t_list[t_index] != s_index:
      print('No')
      break
  s_list[s_index] = t_index
  t_list[t_index] = s_index
else:
  print('Yes')

Solution (Python):
S = list(input())
T = list(input())
slis = [None]*26
tlis = [None]*26
for s,t in zip(S,T):
    sn = ord(s) - 97
    tn = ord(t) - 97
    if slis[sn] == None and tlis[tn] == None:
        slis[sn] = tn
        tlis[tn] = sn
    else:
        if slis[sn] == tn and tlis[tn] == sn:
            continue
        else:
            print("No")
            exit()
print("Yes")

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

S = input().strip()
T = input().strip()
dic = {}

for s, t in zip(S, T):
    if s not in dic:
        dic[s] = t
    elif dic[s] != t:
        print('No')
        exit()

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

Solution (Python):
s=list(input())
t=list(input())
al=lambda x:ord(x)-ord("a")+1 
moji=[0]*27 
moji_num=0 
l=len(s)
ans="Yes"
for i in range(l): 
    if s[i]==t[i]:
        index=al(s[i])
        if moji[index]==0:
            moji[index]=1
            moji_num+=1
        if moji_num==26:
            break
            
want=[[] for i in range(27)] 
wanted=[[] for i in range(27)] 
for i in range(l):
    s_str=s[i] 
    t_str=t[i]
    if s_str!=t_str:
        index1=al(s_str)
        index2=al(t_str)
        if moji[index1]==1 or moji[index2]==1: 
            ans="No"
            
            break
        if len(want[index1])!=0: 
            if want[index1][0]!=t_str:
                ans="No"
                
                break
        want[index1].append(t_str)
        if len(wanted[index2])!=0: 
            if wanted[index2][0]!=s_str:
                ans="No"
                
                break
        wanted[index2].append(s_str)
print(ans)

Solution (Python):
S = input()
T = input()
d = {}
for s,t in zip(S,T):
    if s in d:
        if d[s] != t:
            print('No')
            exit()
    else:
        d[s] = t

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

Solution (Python):
S = input()
T = input()
s_dict = {}
for s in S:
    if s in s_dict:
        s_dict[s] += 1
    else:
        s_dict[s] = 1
t_dict = {}
for t in T:
    if t in t_dict:
        t_dict[t] += 1
    else:
        t_dict[t] = 1

ss = list(s_dict.values())
ss.sort()

tt = list(t_dict.values())
tt.sort()


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

Solution (Python):
s = str(input())
t = str(input())
slist = []*len(s)
scnt = 0
tlist = []*len(t)
tcnt = 0
ans='Yes'
i=0
while i < len(s):
    inds = s.index(s[i])
    indt = t.index(t[i])
    if inds < i:
        slist.append(slist[inds])
    else:
        slist.append(scnt)
        scnt+=1
    if indt < i:
        tlist.append(tlist[indt])
    else:
        tlist.append(tcnt)
        tcnt+=1
    if slist[i]!=tlist[i]:
        ans='No'
        break
    i+=1
print(ans)

Solution (Python):
S = input()
T = input()
dict_st = {}
dict_ts = {}
N = len(S)
for i in range(N):
    if S[i] not in dict_st:
        dict_st[S[i]] = T[i]
    else:
        if dict_st[S[i]] != T[i]:
            print("No")
            exit()
for i in range(N):
    if T[i] not in dict_ts:
        dict_ts[T[i]] = S[i]
    else:
        if dict_ts[T[i]] != S[i]:
            print("No")
            exit()
print("Yes")

Solution (Python):
s = input()
t = input()
dict_st = {}
dict_ts = {}
for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y
    else:
        if dict_st[x] != y:
            print("No")
            break
    if y not in dict_ts:
        dict_ts[y] = x
    else:
        if dict_ts[y] != x:
            print("No")
            break
else:
    print("Yes")

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

Solution (Python):
s=input()
t=input()
import sys
from collections import defaultdict
dic1=defaultdict(lambda:'A')
dic2=defaultdict(lambda:'B')
ans=1
for i in range(len(s)):
  if s[i] in dic1 or t[i] in dic2:
    if dic1[s[i]]==t[i] and  dic2[t[i]]==s[i]:
      pass
    else:
      print('No')
      quit()
  else:
    dic1[s[i]]=t[i]
    dic2[t[i]]=s[i]
print('Yes')

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

replace_to =[]
flag = False
for i in range(len(S)):
    if S[i] != T[i]:
        if S[i] in replace_to or T[i] in replace_to:
            flag = True
            break
        else:
            S = S.replace(T[i], '0').replace(S[i], T[i]).replace('0', S[i])
            replace_to.append(S[i])

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

Solution (Python):
import numpy as np


def solve(s, t):
    u = np.array([0]*26)
    v = np.array([0]*26)

    for si in s:
        u[ord(si)-97] += 1
    for ti in t:
        v[ord(ti)-97] += 1
    u.sort()
    v.sort()
    for i in range(26):
        if u[i] - v[i] != 0:
            return False

    return True


if __name__ == '__main__':
    s = input()
    t = input()
    ans = 'Yes' if solve(s, t)else 'No'
    print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    s = list(input())
    t = list(input())
    n = len(s)
    s_dict = defaultdict(int)
    t_dict = defaultdict(int)
    for i in range(n):
        s_dict[s[i]] += 1
        t_dict[t[i]] += 1

    
    

    if sorted(list(s_dict.values()))== sorted(list(t_dict.values())):
        print('Yes')
    else:
        print('No')
        

if  __name__=='__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
T = input()

dic = defaultdict(int)
dic2 = defaultdict(int)

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

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

for i, j in zip(sorted(dic.values()), sorted(dic2.values())):
	if i != j:
		print("No")
		break
else:
	print("Yes")

Solution (Python):

S = input()
T = input()

import collections
trans_dicts1 = collections.defaultdict(set)
trans_dicts2 = collections.defaultdict(set)
for s, t in zip(S, T):
    
    trans_dicts1[s].add(t)
    trans_dicts2[t].add(s)

n1 = max(map(len, trans_dicts1.values()))
n2 = max(map(len, trans_dicts2.values()))

if n1 == 1 and n2 == 1:
    print('Yes')
else:
    print('No')

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

slist=[]
tlist=[]


for i in range(26):
  c=chr(i+ord("a"))
  temp1=s.count(c)
  temp2=t.count(c)
  slist.append(temp1)
  tlist.append(temp2)


sbetsu=[]
tbetsu=[]

for i in s:
  sbetsu.append(slist[ord(i)-97])
for i in t:
  tbetsu.append(tlist[ord(i)-97])



if sbetsu==tbetsu:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import defaultdict
s = input()
t = input()
ds = defaultdict(list)
dt = defaultdict(list)
for i in range(len(s)):
  ds[s[i]].append(i)
  dt[t[i]].append(i)
dss = set()
dts = set()
for i in ds.values():
  dss.add(tuple(i))
for i in dt.values():
  dts.add(tuple(i))
print('YNeos'[dss!=dts::2])

Solution (Python):
from collections import Counter as c
print('Yes' if sorted(c(input()).values())==sorted(c(input()).values()) else 'No')

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

S=readline().rstrip().decode("utf-8")
T=readline().rstrip().decode("utf-8")

S2T=[[0 for i in range(26)] for j in range(26)]
T2S=[[0 for i in range(26)] for j in range(26)]

for i in range(len(S)):
  s,t=ord(S[i])-97,ord(T[i])-97
  S2T[s][t]+=1
  T2S[t][s]+=1


for i in range(26):
  cnt=0
  for j in range(26):
    if S2T[i][j]>0:
      cnt+=1
      if cnt>1:
        print("No")
        exit()
  cnt=0
  for j in range(26):
    if T2S[i][j]>0:
      cnt+=1
      if cnt>1:
        print("No")
        exit()
print("Yes")

Solution (Python):
def main():
    S = input()
    T = input()
    from collections import defaultdict
    st_dic = defaultdict(set)
    ts_dic = defaultdict(set)
    for s, t in zip(S, T):
        st_dic[s].add(t)
        ts_dic[t].add(s)
        if len(st_dic[s]) > 1 or len(ts_dic[t]) > 1:
            return print("No")
    print("Yes")


if __name__ == '__main__':
    main()

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

con = 0

ans = "Yes"

for i in range(0,len(S)):
  for j in range(0,i):
    if T[i] == T[j]:
      if S[i] != S[j]:
        ans = "No"
        break
      break
    if S[i] == S[j]:
      if T[i] != T[j]:
        ans = "No"
        break
      break


print(ans)

Solution (Python):
s=input()
t=input()
n=len(s)
A='abcdefghijklmnopqrstuvwxyz'
i=0
while A:
	if s==t:
		print('Yes')
		exit()
	if i==n:
		print('No')
		exit()
	if s[i]!=t[i]:
		if s[i] in A and t[i] in A:
			s=s.replace(s[i],'X').replace(t[i],s[i]).replace('X',t[i])
			A=A.replace(s[i],'').replace(t[i],'')
	i+=1
print('No')

Solution (Python):
import collections
s=input()
t=input()
cnt1=1
cnt2=1
lst1=[]
lst2=[]
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    cnt1+=1
  else:
    lst1.append(cnt1)
for j in range(len(t)-1):
  if t[j]==t[j+1]:
    cnt2+=1
  else:
    lst2.append(cnt2)
S=collections.Counter(s)
T=collections.Counter(t)
S_=list(S.values())
T_=list(T.values())
S_.sort()
T_.sort()
if S_==T_ and lst1==lst2:
  print('Yes')
else:
  print('No')

Solution (Python):
def solve():
    s = input()
    t = input()
    d = dict()
    for sc, tc in zip(s, t):
        if d.get(sc, None) is None:
            d[sc] = tc
        else:
            if d[sc] != tc:
                return False

    d = {value: key for key, value in d.items()}
    for sc, tc in zip(s, t):
        if d.get(tc, None) is None:
            d[tc] = sc
        else:
            if d[tc] != sc:
                return False
    return True


if __name__ == '__main__':
    print('Yes' if solve() else 'No')

Solution (Python):

import sys










def main():
    S, T = sys.stdin.read().split()

    convert = dict()
    
    flag = True
    for s, t in zip(S, T):
        if s in convert and convert[s] != t:
            flag = False
            break
        convert[s] = t

    
    
    after = convert.values()
    if len(after) != len(set(after)):
        flag = False
    

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

if __name__ == "__main__":
    main()

Solution (Python):
s = input()
t = input()
sdic = {}
tdic = {}
S = [0] * len(s)
T = [0] * len(t)
for i, char in enumerate(s):
  if char not in sdic.keys():
    sdic[char] = len(sdic.keys())
  S[i] = sdic[char]
for i, char in enumerate(t):
  if char not in tdic.keys():
    tdic[char] = len(tdic.keys())
  T[i] = tdic[char]
if S == T:
  print("Yes")
else:
  print("No")

Solution (Python):
from sys import stdin
import fractions

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()

li = []
for i in range(len(s)):
    li.append((s[i],t[i]))
li.sort()

for i in range(len(li)-1):
    if li[i][0] == li[i+1][0]:
        if li[i][1] != li[i+1][1]:
            print("No")
            exit()

li.sort(key=lambda x:(x[1]))

for i in range(len(li)-1):
    if li[i][0] != li[i+1][0]:
        if li[i][1] == li[i+1][1]:
            print("No")
            exit()

print("Yes")

Solution (Python):
S = list(input())
T = list(input())
ma = dict()
yes = True
for i in range(len(S)):
    if S[i] not in ma:
        ma[S[i]] = T[i]
    else:
        if ma[S[i]] != T[i]:
            yes = False
            break
ma.clear()
for i in range(len(S)):
    if T[i] not in ma:
        ma[T[i]] = S[i]
    else:
        if ma[T[i]] != S[i]:
            yes = False
            break
            
if yes:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict

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:
            print("No")
            exit()
    if ddt[t]==0:
        ddt[t]=s
    else:
        if ddt[t]!=s:
            print("No")
            exit()
print("Yes")

Solution (Python):
S = input()
T = input()
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
j = 0

for i in range(len(S)):
    if S[i].islower() and T[i].islower():
        S = S.replace(S[i], alphabet[j])
        T = T.replace(T[i], alphabet[j])
        j += 1
    elif S[i].isupper() and T[i].isupper():
        pass
    else:
        break

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

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

for i in range(len(abc)):
	a = 0
	for j in range(len(s)):
		if abc[i] == s[j]:
			if a == 0:
				st = t[j]
				a = 1
			else:
				if t[j] != st:
					print("No")
					exit(0)
	a = 0
	for j in range(len(t)):
		if abc[i] == t[j]:
			if a == 0:
				st = s[j]
				a = 1
			else:
				if s[j] != st:
					print("No")
					exit(0)
print("Yes")

Solution (Python):
import string

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

S_l = [[] for _ in range(26)]
T_l = [[] for _ in range(26)]
alpha = string.ascii_lowercase

for n in range(len(S)):
    for m in range(26):
        if S[n] == alpha[m]:
            S_l[m].append(n)

for n in range(len(T)):
    for m in range(26):
        if T[n] == alpha[m]:
            T_l[m].append(n)

for i in range(25, -1, -1):
    if S_l[i] == T_l[i] and S_l[i] !=0:
        del S_l[i]
        del T_l[i]

S_l = sorted(S_l)
T_l = sorted(T_l)

if S_l == T_l:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter as C
s,t = input(),input()
print('No') if C(C(s).values()) != C(C(t).values()) else print('Yes')

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

x = {}
for s in S:
    if s in x:
        x[s] += 1
    else:
        x[s] = 1

y = {}
for t in T:
    if t in y:
        y[t] += 1
    else:
        y[t] = 1

x2 = list(x.values())
x2.sort()
y2 = list(y.values())
y2.sort()


if len(x2) != len(y2):
    print("No")
else:
    for i in range(len(x2)):
        if x2[i] != y2[i]:
            print("No")
            break
    else:
        print("Yes")

Solution (Python):
s, t = input(), input()
ls, lt = [ [s[0], {0}] ], [ [t[0], {0}] ]

for i in range(len(s)-1):
  if s[i] != s[i+1]:
    b = True
    for j in range(len(ls)):
      if s[i+1] in ls[j][0]:
        ls[j][1].add(i+1)
        b = False
    if b:
      ls.append( [s[i+1], {i+1}] )
      
for i in range(len(t)-1):
  if t[i] != t[i+1]:
    b = True
    for j in range(len(lt)):
      if t[i+1] in lt[j][0]:
        lt[j][1].add(i+1)
        b = False
    if b:
      lt.append( [t[i+1], {i+1}] )

if len(ls) != len(lt):
  print("No")
else:
  for i in range(len(ls)):
    if ls[i][1] != lt[i][1]:
      print("No")
      exit()
  print("Yes")

Solution (Python):
from collections import defaultdict

S = input()
T = input()

dic_S = defaultdict(int)
dic_T = defaultdict(int)

for s, t in zip(S, T):
    dic_S[s] += 1
    dic_T[t] += 1

S_count = list(dic_S.values())
T_count = list(dic_T.values())

S_count.sort()
T_count.sort()

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

Solution (Python):
S, T = input(), input()
cnt1, cnt2 = [0] * 30, [0] * 30
for s in S:
    cnt1[ord(s)-97] += 1
for t in T:
    cnt2[ord(t)-97] += 1
if all(c1==c2 for c1, c2 in zip(sorted(cnt1), sorted(cnt2))):
    print('Yes')
else:
    print('No')

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

r="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

j=0
for i in range(len(s)):
  if s[i].islower():
    s = s.replace(s[i],r[j])
    j += 1

j=0
for i in range(len(t)):
  if t[i].islower():
    t = t.replace(t[i],r[j])
    j += 1

print('Yes' if s==t else '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]] = t[i]
        
    elif s_dict[s[i]] != t[i]:
        print('No')
        exit()

    if t[i] not in t_dict:
        t_dict[t[i]] = s[i]
    elif t_dict[t[i]] != s[i]:
        print('No')
        exit()


print('Yes')

Solution (Python):
S = input()
T = input()
 
convert = dict()
 
answer = 'Yes'

for s, t in zip(S, T):
    
    if s in convert and convert[s] != t:
        answer = 'No'
        break
    
    else:
        convert[s] = t
 
after = convert.values()


if len(after) != len(set(after)):
    answer = 'No'
 
print(answer)

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

ans = "Yes"
 
for i in range(0,len(S)):
  for j in range(0,i):
    if S[j] == S[i]:
      if T[i] != T[j]:
        ans = "No"
        break
      break
    if T[j] == T[i]:
      if S[j] != S[i]:
        ans = "No"
        break
      break
print(ans)

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

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

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

s_dict = {}
for i in range(len(S)):
    if not S[i] in s_dict:
        s_dict[S[i]] = T[i]

    elif s_dict[S[i]] != T[i]:
        print('No')
        exit()

t_dict = {}
for i in range(len(T)):
    if not T[i] in t_dict:
        t_dict[T[i]] = S[i]

    elif t_dict[T[i]] != S[i]:
        print('No')
        exit()

print('Yes')

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

Solution (Python):
def main():
    s=input()
    t=input()
    n=len(s)
    zumi=[]
    for i in range(n):
        ss= s[i]
        st= t[i]
        if ss != st:
            if st in zumi or ss in zumi:
                return "No"
            zumi.append(st)
            s=s.translate(str.maketrans({ss:st,st:ss}))
    return "Yes"

print(main())