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
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    S=list(input())
    T=list(input())
    d_S,d_T={},{}
    c=0
    for i,(s,t) in enumerate(zip(S,T)):
        if s in d_S:
            tmp_S=d_S[s]
        else:
            d_S[s]=c
            tmp_S=d_S[s]
        if t in d_T:
            tmp_T=d_T[t]
        else:
            d_T[t]=c
            tmp_T=d_T[t]
            c+=1
        if tmp_S!=tmp_T:
            print('No')
            exit()
    print('Yes')
        

if __name__ == '__main__':
    main()

Solution (Python):
import collections

cntS = collections.Counter(input())
cntT = collections.Counter(input())

if sorted(cntS.values()) == sorted(cntT.values()):
    print('Yes')
else:
    print('No')

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

d1 = {}
d2 = {}
ans = "Yes"
for s, t in zip(S, T):
    if s in d1:
        if d1[s] != t:
            ans = "No"
            break
    else:
        d1[s] = t
    if t in d2:
        if d2[t] != s:
            ans = "No"
            break
    else:
        d2[t] = s
print(ans)

Solution (Python):
def solve():
    S = input()
    T = input()
    
    s_counter = sorted([S.count(chr(i)) for i in range(ord('a'), ord('z') + 1)])
    t_counter = sorted([T.count(chr(i)) for i in range(ord('a'), ord('z') + 1)])
    if s_counter == t_counter:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Solution (Python):
S = list(input())
T = list(input())
R1 = [-1]*26
R2 = [-1]*26
ans = "Yes"

for i in range(len(S)):
    s = ord(S[i])
    t = ord(T[i])
    if R1[s-97] >= 0:
        if R1[s-97] != t:
            ans = "No"
            break
    else:
        R1[s-97] = t
    if R2[t-97] >= 0:
        if R2[t-97] != s:
            ans = "No"
            break
    else:
        R2[t-97] = s

print(ans)

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

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

ss = s.most_common()
tt = t.most_common()

if len(ss) != len(tt):
    print("No")
    exit()

for i in range(len(ss)):
    if ss[i][1] != tt[i][1]:
        print("No")
        exit()

print("Yes")

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

a = [0] * 26
b = [0] * 26
for i, j in zip(s, t):
    if a[ord(i) - 97] != 0 or b[ord(j) - 97] != 0:
        if a[ord(i) - 97] != j or b[ord(j) - 97] != i:
            print("No")
            exit()
    a[ord(i) - 97] = j
    b[ord(j) - 97] = i

print("Yes")

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

a = [[0 for _ in range(26)] for _ in range(26)]
b = [[0 for _ in range(26)] for _ in range(26)]
for i, j in zip(s, t):
    a[ord(i) - 97][ord(j) - 97] = 1
    b[ord(j) - 97][ord(i) - 97] = 1

for i, j in zip(a, b):
    if sum(i) >= 2 or sum(j) >= 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
from collections import defaultdict
S = input()
T = input()
d = defaultdict(set)
for s, t in zip(S, T):
    d[s].add(t)

for v in d.values():
    if len(v) != 1:
        print("No")
        exit()

chars = set()
for k, v in d.items():
    for x in v:
        if x in chars:
            print("No")
            exit()
        chars.add(x)
print("Yes")

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')
                return
        else:
            start[a] = b
            goal[b] = a
    print('Yes')


if __name__ == '__main__':
    main()

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:
            A=A.replace(s[i],'')
    else:
        if s[i] in A and t[i] in A:
            if t[i] in s:
                A=A.replace(t[i],'')
                s=s.replace(s[i],'X').replace(t[i],s[i]).replace('X',t[i])
            else:
                A=A.replace(t[i],'')
                s=s.replace(s[i],t[i])
        else:
            print('No')
            exit()
    i+=1

Solution (Python):
s=input()
t=input()
seen=set()
for i in range(len(s)):
  if s[i] not in seen:
    for j in range(i,len(t)):
      if s[i]==s[j]:
        if t[i]!=t[j]:
          print("No")
          exit(0)
      else:
        if t[i]==t[j]:
          print("No")
          exit(0)
    seen.add(s[i])
else:
  print("Yes")

Solution (Python):
from collections import Counter

S = input()
T = input()

s = list(Counter(S).values())
t = list(Counter(T).values())
s.sort()
t.sort()
if len(s) != len(t) or s != t:
    print("No")
else:
    print("Yes")

Solution (Python):
S = input()
T = input()
Sdictionary = {}
Tdictionary = {}
ans = "Yes"
for i in range(len(S)):
    if T[i] in Tdictionary:
        if Tdictionary[T[i]] == S[i]:
            continue
        else:
            ans = "No"
    else:
        Tdictionary[T[i]] = S[i]
    if S[i] in Sdictionary:
        if Sdictionary[S[i]] == T[i]:
            continue
        else:
            ans = "No"
    else:
        Sdictionary[S[i]] = T[i]


print(ans)

Solution (Python):

import sys
s=input();t=input()
start=[-1]*26
goal=[-1]*26
for i in range(len(s)):
    a=int(ord(s[i])-97)
    b=int(ord(t[i])-97)
    if start[a]!=-1 or goal[b]!=-1:
        if start[a]!=b or goal[b]!=a:
            print("No")
            sys.exit()
    else:
        start[a]=b
        goal[b]=a
print("Yes")

Solution (Python):
s=input()
t=input()
st={}
ts={}

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

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

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

Solution (Python):
from collections import Counter

s = input()
t = input()

count_s = Counter()
count_t = Counter()

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

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


s_list = sorted(list(dict(count_s).values()))
t_list = sorted(list(dict(count_t).values()))

if s_list == t_list:
    print('Yes')
else:
    print('No')

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

s_to_t = [None for _ in range(ord("z")-ord("a")+1)]
t_to_s = [None for _ in range(ord("z")-ord("a")+1)]

a = ord("a")
for s, t in zip(S, T):
    s = ord(s) - a
    t = ord(t) - a

    if s_to_t[s] is None:
        s_to_t[s] = t
    else:
        if s_to_t[s] != t:
            print("No")
            exit()
    
    if t_to_s[t] is None:
        t_to_s[t] = s
    else:
        if t_to_s[t] != s:
            print("No")
            exit()

print("Yes")

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



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

    c1 = Counter()
    c2 = Counter()

    for i in range(len(S)):
        c1[S[i] + T[i]] += 1
        c2[T[i] + S[i]] += 1

    for i in list("abcdefghijklmnopqrstuvwxyz"):
        count1 = 0
        count2 = 0
        for j in list("abcdefghijklmnopqrstuvwxyz"):
            if c1[i + j] > 0:
                count1 += 1
            if c2[i + j] > 0:
                count2 += 1
        if count1 > 1 or count2 > 1:
            print("No")
            break
    else:
        print("Yes")




if __name__ == '__main__':
    main()

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

ans = "Yes"
_dict = {}

for i in range(len(s)):
    if s[i] not in _dict:
        _dict[s[i]]=t[i]
    elif s[i] in _dict:
        if t[i] != _dict[s[i]]:
            ans="No"
            break

_dict = {}
for i in range(len(s)):
    if t[i] not in _dict:
        _dict[t[i]]=s[i]
    elif t[i] in _dict:
        if s[i] != _dict[t[i]]:
            ans="No"
            break
print(ans)

Solution (Python):
import sys
from collections import defaultdict

s, t = sys.stdin.read().split()
n = len(s)

def main():
    correspondence = defaultdict(str)
    for i in range(n):
        if not correspondence[s[i]]:
            correspondence[s[i]] = t[i]
        else:
            if correspondence[s[i]] != t[i]:
                return 'No'

    v = correspondence.values()
    return 'Yes' if len(v) == len(set(v)) else 'No'
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
S = input()
T = input()
alp = "abcdefghijklmnopqrstuvwxyz"
d = {s: None for s in alp}
e = {s: None for s in alp}
for s, t in zip(S, T):
    if d[t] is None:
        d[t] = s
    elif d[t] != s:
        print("No")
        exit()
    if e[s] is None:
        e[s] = t
    elif e[s] != t:
        print("No")
        exit()
print("Yes")

Solution (Python):

S = input()
T = input()
from collections import defaultdict

dictS = defaultdict(str)
dictT = defaultdict(str)

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


  dictS[S[i]] = T[i]
  dictT[T[i]] = S[i]

print("Yes")

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

ans = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}
res = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}
for a,b in zip(s,t):
    ans[b].append(a)
    res[a].append(b)

aa = [0 for v in ans.values() if len(set(v)) > 1]
bb = [0 for v in res.values() if len(set(v)) > 1]

if len(aa) == 0 and len(bb) == 0:
    print('Yes')
else:
    print('No')

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

ans = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}
res = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}
cnt = 0
for a,b in zip(s,t):
    ans[b].append(a)
    res[a].append(b)
    
    
    
    
    cnt += 1

aa = [0 for v in ans.values() if len(set(v)) > 1]
bb = [0 for v in res.values() if len(set(v)) > 1]

if len(aa) == 0 and len(bb) == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input().strip()
T = input().strip()
F = {}
flag = 0
for i in range(len(S)):
    a = S[i]
    b = T[i]
    if a not in F:
        F[a] = b
    if F[a] != b:
        flag = 1
        break
    for c in F:
        if c!=a and F[c]==b:
            flag = 1
            break
if flag==1:
    print("No")
else:
    print("Yes")

Solution (Python):
s=input()
t=input()
d={}
l=[]
for i in range(len(s)):
  if s[i] in d and d[s[i]]!=t[i]:
    print('No') 
    exit()
  d[s[i]]=t[i]
if len(d.values())!=len(set(d.values())):
  print('No')
  exit()
print('Yes')

Solution (Python):
from collections import defaultdict

s=input()
t=input()

n=len(s)

ss=defaultdict(list)
tt=defaultdict(list)

for i in range(n):
  ss[s[i]].append(i)
  tt[t[i]].append(i)

  
sss=[]
ttt=[]
for k,v in ss.items():
  sss.append(v)
for k,v in tt.items():
  ttt.append(v)

sss.sort()
ttt.sort()


ans="No"
if sss==ttt:
  ans="Yes"
print(ans)

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

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

from collections import Counter
cs = Counter(S)
ct = Counter(T)

anss = ['Yes','No']
ans = 0
if len(cs.keys()) != len(ct.keys()): ans = 1
else:
    As = sorted(cs.values())
    At = sorted(ct.values())
    for i in range(len(cs.keys())):
        if As[i] != At[i]:
            ans = 1
            break
print(anss[ans])

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


S, T = [sys.stdin.buffer.readline().decode().rstrip() for _ in range(2)]

def conv(s):
    cnt = 0
    num = {}
    ret = []
    for c in s:
        if c not in num:
            num[c] = cnt
            cnt += 1
        ret.append(num[c])
    return ret
ok = conv(S) == conv(T)
if ok:
    print('Yes')
else:
    print('No')

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

Solution (Python):
def main():
    S = input()
    T = input()
    d = dict()
    flg = True
    for s, t in zip(S, T):
        
        if s in d and d[s] != t:
            flg = False
            break
        d[s] = t
    
    if len(d.values()) != len(set(d.values())):
        flg = False
    print("Yes" if flg else "No")
    return


main()

Solution (Python):
def main():
    S = input()
    T = input()
    lst = [""] * (ord("z") - ord("a") + 1)
    flg = True
    for s, t in zip(S, T):
        
        if lst[ord(s) - ord("a")] and lst[ord(s) - ord("a")] != t:
            flg = False
            break
        lst[ord(s) - ord("a")] = t
    lst = [i for i in lst if i != ""]
    
    if len(lst) != len(set(lst)):
        flg = False
    print("Yes" if flg else "No")
    return


main()

Solution (Python):
from sys import stdin


def main():
    S = stdin.readline().strip()
    T = stdin.readline().strip()
    lst = [""] * (ord("z") - ord("a") + 1)
    flg = True
    for s, t in zip(S, T):
        
        if lst[ord(s) - ord("a")] and lst[ord(s) - ord("a")] != t:
            flg = False
            break
        lst[ord(s) - ord("a")] = t
    lst = [i for i in lst if i != ""]
    
    if len(lst) != len(set(lst)):
        flg = False
    print("Yes" if flg else "No")
    return


main()

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))
import sys
input = sys.stdin.readline





S=one_str()
T=one_str()

same_alpha_A = set(list(S))
same_alpha_B = set(list(T))
same_alpha_flg=False

if len(same_alpha_A) and len(same_alpha_A & same_alpha_B):
    same_alpha_flg=True

A_set={}
A_list=[]
for i in list(S):
    if i not in A_set:
        A_set[i]=len(A_set)+1
        
    A_list.append(A_set[i])

B_set={}
B_list=[]
for i in list(T):
    if i not in B_set:
        B_set[i]=len(B_set)+1
    B_list.append(B_set[i])

same_list_flg=True
for a,b in zip(A_list, B_list):
    if a!=b:
        same_list_flg=False
        break

if same_alpha_flg and same_list_flg:
    print("Yes")
else:
    print("No")

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

S = []
T = []

for i in set(s):
    S.append(s.count(i))
for j in set(t):
    T.append(t.count(j))

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

Solution (Python):



import collections

A = input()
B = input()

A_c = collections.Counter(A)
B_c = collections.Counter(B)
A_c = A_c.values()
B_c = B_c.values()

A_c = list(A_c)
B_c = list(B_c)
A_c.sort()
B_c.sort()
if A_c == B_c:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import exit

s = input().lower()
t = input().lower()
N = len(s)

d = {}
for i in range(ord('a'), ord('z')+1):
    d[chr(i)] = -1

for i in range(N):
    if d[s[i]]==-1:
        d[s[i]] = t[i]
    else:
        if t[i] == d[s[i]]:
            pass
        else:
            print('No')
            exit()


k  = []
for i in d:
    if d[i]==-1:
        pass
    else:
        if d[i] in k:
            print('No')
            exit()
        k.append(d[i])

print('Yes')

Solution (Python):
S = input()
T = input()
s_pairs = [-1] * 26
t_pairs = [-1] * 26

def convert_alphabet_to_int(s):
  return ord(s) - ord('a')


for i, s in enumerate(S):
  t = T[i]
  int_s = convert_alphabet_to_int(s)
  int_t = convert_alphabet_to_int(t)
  if s_pairs[int_s] >= 0:
    if s_pairs[int_s] != int_t:
      print('No')
      exit()
  else:
    s_pairs[int_s] = int_t
  
  if t_pairs[int_t] >= 0:
    if t_pairs[int_t] != int_s:
      print('No')
      exit()
  else:
    t_pairs[int_t] = int_s
print('Yes')

Solution (Python):
import collections
A = list(input())
B = list(input())
A_c = collections.Counter(A)
B_c = collections.Counter(B)
A_c = A_c.values()
B_c = B_c.values()
A_c = list(A_c)
B_c = list(B_c)
A_c.sort()
B_c.sort()
if A_c == B_c:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
t = input()
n = len(s)
struct1 = []
struct2 = []
dict1 = {}
dict2 = {}
k1, k2 = 0, 0
for i in range(n):
    if s[i] not in dict1:
        dict1[s[i]] = k1
        k1 += 1    
    struct1.append(dict1[s[i]])
    if t[i] not in dict2:
        dict2[t[i]] = k2
        k2 += 1
    struct2.append(dict2[t[i]])
if struct1 == struct2:
    print ("Yes")
else:
    print ("No")

Solution (Python):

s, t = input(), input()
sd, td = {}, {}
for i in range(len(s)):
    if t[i] not in td and s[i] not in sd:
        sd[s[i]] = t[i]
        td[t[i]] = s[i]
    elif t[i] in td and s[i] in sd and td[t[i]] == s[i] and sd[s[i]] == t[i]:
        continue
    else:
        print("No")
        exit()
print("Yes")

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

ds = {}
dt = {}
ls = []
lt = []

for ks,kt in zip(list(s),list(t)):
    if ks not in ds:
        ds[ks] = 1
    else:
        ds[ks] += 1
    if kt not in dt:
        dt[kt] = 1
    else:
        dt[kt] += 1

for ks in ds: ls.append(ds[ks])
for kt in dt: lt.append(dt[kt])

ls.sort()
lt.sort()

if ls == lt:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Solution (Python):
s = list(input())
t = list(input())
s_len = len(set(s))
t_len = len(set(t))
pare = []
for i,j in zip(s,t):
    pare.append(i+j)

if len(set(pare)) == s_len == t_len:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
t = input()
alfa = list('abcdefghijklmnopqrstuvwxyz')
s_count = [0 for i in range(26)]
t_count = [0 for i in range(26)]
for i in range(len(s)):
    x = alfa.index(s[i])
    y = alfa.index(t[i])
    s_count[x] += 1
    t_count[y] += 1
s_count.sort()
t_count.sort()
if s_count == t_count:
    print('Yes')
else:
    print('No')

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

alphabet_1 = [[] for _ in range(26)]
alphabet_2 = [[] for _ in range(26)]

for i in range(len(s)):
    if alphabet_1[ord(s[i])-97] == []:
        alphabet_1[ord(s[i])-97] = t[i]
    else:
        if alphabet_1[ord(s[i])-97] == t[i]:
            continue
        else:
            print('No')
            exit()

    if alphabet_2[ord(t[i])-97] == []:
        alphabet_2[ord(t[i])-97] = s[i]
    else:
        if alphabet_2[ord(t[i])-97] == s[i]:
            continue
        else:
            print('No')
            exit()

print('Yes')

Solution (Python):
s=list(input())
t=list(input())
ss=len(set(s))
tt=len(set(t))

l=[]
for i,j in zip(s,t):
    l.append(i+j)

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

Solution (Python):
import sys
import itertools
import numpy
input = sys.stdin.readline
Sa = input()
Ta = input()
S = ['0'] * len(Sa)
T = ['0'] * len(Ta)
for i in range(len(Sa)) :
    S[i] = Sa[i]
for i in range(len(Ta)) :
    T[i] = Ta[i]
ans = {}
for cs,ct in zip(S,T) :
    if cs not in ans.keys() and ct not in ans.values() :
        ans[cs] = ct
    else :
        try :
            if ans[cs] == ct :
                continue
            else :
                print("No")
                break
        except KeyError :
            print("No")
            break
else :
    print("Yes")

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

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

l = len(s)

chng = {}

for i in range(l):
    if s[i] in chng:
        if chng[s[i]]!=t[i]:
            print("No")
            exit()
    else:
        chng[s[i]] = t[i]
        
chng = {}

for i in range(l):
    if t[i] in chng:
        if chng[t[i]]!=s[i]:
            print("No")
            exit()
    else:
        chng[t[i]] = s[i]
        
    
print("Yes")

Solution (Python):
from collections import defaultdict
s=input()
t=input()
dct=defaultdict(int)
for i in range(len(s)):
  if not dct[s[i]]:
    dct[s[i]]=t[i]
  elif dct[s[i]]!=t[i]:
    print("No")
    exit()
ls=[]
for i in dct.values():
  if i in ls:
    print("No")
    exit()
  else:
    ls.append(i)
print("Yes")

Solution (Python):
S = list(input())
T = list(input())
ans = {}
for c_s, c_t in zip(S, T):
    if c_s not in ans.keys() and c_t not in ans.values():
        ans[c_s] = c_t
    else:
        try:
            if ans[c_s] == c_t:
                continue
            else:
                print("No")
                break
        except KeyError:
            print("No")
            break
else:
    print("Yes")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(S: str, T: str):
    table = {}
    for i in range(len(T)):
        if table.get(S[i]) == None:
            table[S[i]] = T[i]
        else:
            if table[S[i]] == T[i]:
                continue
            else:
                
                print(NO)
                return

    value_list = []
    for value in table.values():
        value_list.append(value)
        
    
    if len(set(value_list)) == len(table):
        print(YES)
    else:
        print(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()
sdic={}
tdic={}
for i in range(len(s)):
    if s[i] in sdic:
        if sdic[s[i]]!=t[i]:
            print("No")
            exit()
    if t[i] in tdic:
        if tdic[t[i]]!=s[i]:
            print("No")
            exit()
    sdic[s[i]]=t[i]
    tdic[t[i]]=s[i]
print("Yes")

Solution (Python):
D, E = {}, {}
A, B = [], []
S = input()
T = input()
for i in range(len(S)):
  if S[i] in D:
    D[S[i]].append(i)
  else:
    D[S[i]] = [i]
  if T[i] in E:
    E[T[i]].append(i)
  else:
    E[T[i]] = [i]
for i in D:
  A.append(D[i])
for i in E:
  B.append(E[i])
A.sort()
B.sort()
if A == B:
  print('Yes')
else:
  print('No')

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

l = len(S)
d = {chr(_): chr(_) for _ in range(97,97+26)}
for i in range(l):
    now = d[S[i]]
    change = T[i]
    for k,v in d.items():
        if now == v:
            d[k] = T[i]
        if change == v:
            d[k] = now

ans = 'Yes'
for i in range(l):
    if d[S[i]] != T[i]:
        ans = 'No'
        break

print(ans)

Solution (Python):
S = list(input())
S_dict = {}

for idx, s in enumerate(S):
    if s not in S_dict:
        S_dict[s] = [idx]
    else:
        S_dict[s].append(idx)
T = list(input())
T_dict = {}
for idx, t in enumerate(T):
    if t not in T_dict:
        T_dict[t] = [idx]
    else:
        T_dict[t].append(idx)



for s in list(S_dict.values()):
    if s in list(T_dict.values()):
        continue
    else:
        print("No")
        exit()
print("Yes")

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

SS = sorted(list(S))
TT = sorted(list(T))
SSS = []
TTT = []
numS = 0
checkS = 1
checkT = 1

for i in range(len(S)-1):
    if SS[i] != SS[i+1]:
        SSS.append(checkS)
        checkS = 1
    elif i == len(S)-2:
        SSS.append(checkS+1)
    else:
        checkS += 1

    if TT[i] != TT[i+1]:
        TTT.append(checkT)
        checkT = 1
    elif i == len(S)-2:
        TTT.append(checkT+1)
    else:
        checkT += 1
SSS.sort()
TTT.sort()
if SSS == TTT:
    print("Yes")
else:
    print("No")

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

SS = sorted(list(S))
TT = sorted(list(T))
SSS = []
TTT = []
numS = 0
numT = 0
checkS = 1
checkT = 1

for i in range(len(S)-1):
    if SS[i] != SS[i+1]:
        SSS.append(checkS)
        checkS = 1
    elif i == len(S)-2:
        SSS.append(checkS+1)
    else:
        checkS += 1

    if TT[i] != TT[i+1]:
        TTT.append(checkT)
        checkT = 1
    elif i == len(S)-2:
        TTT.append(checkT+1)
    else:
        checkT += 1
SSS.sort()
TTT.sort()
if SSS == TTT:
    print("Yes")
else:
    print("No")

Solution (Python):
import collections
s = input()
t = input()
dd = collections.defaultdict(str)
dd2 = collections.defaultdict(str)
for i in range(len(s)):
    if dd[t[i]] == '':
        dd[t[i]] = s[i]
    if dd[t[i]] != '' and dd[t[i]] != s[i]:
        print('No')
        exit()
for i in range(len(s)):
    if dd2[s[i]] == '':
        dd2[s[i]] = t[i]
    if dd2[s[i]] != '' and dd2[s[i]] != t[i]:
        print('No')
        exit()
print('Yes')

Solution (Python):
from collections import defaultdict
from collections import Counter
S = input()
T = input()
ans = "Yes"
s_dict = defaultdict(str)
t_dict = defaultdict(str)

for s,t in zip(S,T):
  if s_dict[t] != "" and s_dict[t] != s:
    ans = "No"
    break
  elif t_dict[s] != "" and t_dict[s] != t:
    ans = "No"
    break
  s_dict[t] = s
  t_dict[s] = t
print(ans)

Solution (Python):
from collections import Counter

s, t = input(), input()
sc, tc = list(Counter(s).values()), list(Counter(t).values())
sc.sort()
tc.sort()
if sc != tc:
  print('No')
  quit()
ss, tt = s[0], t[0]
for i, j in zip(s, t):
  if i == ss and j == tt:
    continue
  elif  i != ss and j != tt:
    ss, tt = i, j
  else:
    print('No')
    quit()
print('Yes')

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

s, t = readline(), readline()
sc, tc = list(Counter(s).values()), list(Counter(t).values())
sc.sort()
tc.sort()
print('Yes' if sc == tc else 'No')

Solution (Python):


import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
T = input()

C1 = sorted(Counter(S).values())
C2 = sorted(Counter(T).values())

N = len(C1)
if len(C2) != N:
    No()
    exit()
for i in range(N):
    if C1[i] != C2[i]:
        No()
        exit()
Yes()

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

adic = {}
bdic = {}

for i in range(len(S)):
  if adic.get(S[i], T[i]) != T[i] or bdic.get(T[i], S[i]) != S[i]:
    print("No")
    exit()
  adic[S[i]] = T[i]
  bdic[T[i]] = S[i]

print("Yes")

Solution (Python):
from collections import defaultdict
S = input()
T = input()
dicta = defaultdict(set)
dictb = defaultdict(set)
for i in range(len(S)):
    dicta[S[i]].add(T[i])
    dictb[T[i]].add(S[i])

flag = True
for v in dicta.values():
    if len(v) != 1:
        flag = False
for v in dictb.values():
    if len(v) != 1:
        flag = False
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline
A = list(input().rstrip())
B = list(input().rstrip())
N = len(A)
change_1 = [[0] * 26 for _ in range(26)]
change_2 = [[0] * 26 for _ in range(26)]
alpha2num = lambda c: ord(c) - ord("a")
for i, j in zip(A, B):
    change_1[alpha2num(i)][alpha2num(j)] += 1
change_1 = np.array(change_1)
for i, j in zip(B, A):
    change_2[alpha2num(i)][alpha2num(j)] += 1
change_2 = np.array(change_2)
for k in change_1:
    if np.count_nonzero(k) > 1:
        print("No")
        sys.exit()
for k in change_2:
    if np.count_nonzero(k) > 1:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
from collections import defaultdict


S = input()
T = input()
S_count = defaultdict(int)
T_count = defaultdict(int)

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

A = list(S_count.values())
B = list(T_count.values())

A.sort()
B.sort()

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

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

d = {}

c = 0
for i in range(len(s)):
  if s[i] not in d:
    d[s[i]] = c
    c += 1

d_ = {}
used = set()
for i in range(len(t)):
  if t[i] not in d_ and s[i] not in used:
    d_[t[i]] = d[s[i]]
    used.add(s[i])
  elif t[i] not in d_ and s[i] in used:
    print('No')
    exit()
  else:
    pass

for i in range(len(s)):
  if d[s[i]] != d_[t[i]]:
    print('No')
    exit()
else:
  print('Yes')

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

d = {}

c = 0
for i in range(len(s)):
  if s[i] not in d:
    d[s[i]] = c
    c += 1

d_ = {}
used = set()
for i in range(len(t)):
  if t[i] not in d_ and s[i] not in used:
    d_[t[i]] = d[s[i]]
    used.add(s[i])
  elif t[i] not in d_ and s[i] in used:
    print('No')
    exit()
  else:
    pass

for i in range(len(s)):
  if d[s[i]] != d_[t[i]]:
    print('No')
    exit()
else:
  print('Yes')

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

w = [0 for _ in range(200)]

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        
        if w[i] > 0:
            
            tmp = w[i]
            tmp2 = w[i]
            while(True):
                if w[w[i]] !=0 and w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                tmp = w[i]
                if tmp == tmp2:
                    return("No")
    return("Yes")

print(ans())