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=input()
t=input()

s_t=[-1]*26
t_s=[-1]*26

for i in range(len(s)):
    num_s=ord(s[i])-97
    num_t=ord(t[i])-97
    
    if s_t[num_s]==-1 and t_s[num_t]==-1:
        s_t[num_s]=num_t
        t_s[num_t]=num_s
    elif s_t[num_s]!=num_t or t_s[num_t]!=num_s:
        print("No")
        exit()
    
print("Yes")

Solution (Python):
s1 = input()
s2 = input()
dic = {}
for i in range(len(s1)):
    if not s1[i] in dic:
        dic[s1[i]] = s2[i]
    else:
        if dic[s1[i]] != s2[i]:
            print('No')
            quit()

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

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

def checker(s,t):
    alphabets = [None] * 26
    for i,j in zip(s,t):
        order_number = ord(i) - ord("a")
        if alphabets[order_number] == None:
            alphabets[order_number] = j
        else:
            if alphabets[order_number] != j:
                return False
    return True

if checker(s,t) and checker(t,s):
    print("Yes")
else:
    print("No")

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

convert = dict()

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


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

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

Solution (Python):
s=list(input())
t=list(input())
S=sorted(map(s.count,set(s)))
T=sorted(map(t.count,set(t)))
print("Yes" if S==T else "No")

Solution (Python):


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

    d = {}
    for i in range(len(s)):
        if t[i] in d and d[t[i]] != s[i]:
            print('No')
            return
        elif t[i] not in d:
            d[t[i]] = s[i]
    d = {}
    for i in range(len(s)):
        if s[i] in d and d[s[i]] != t[i]:
            print('No')
            return
        elif s[i] not in d:
            d[s[i]] = t[i]
    print('Yes')


if __name__ == "__main__":
    main()

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








ALPHABETS = 'abcdefghijklmnopqrstuvwxyz'
answer = 'Yes'
for alphabet in ALPHABETS:
    i = S.find(alphabet)
    if i == -1: continue

    replaced_S = S.replace(S[i], '')
    replaced_T = T.replace(T[i], '')
    
    if len(replaced_S) != len(replaced_T):
        answer = 'No'
        break
print(answer)

Solution (Python):
import string


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

ans = "Yes"
tableT = []
for i in range(26):
  tableT.append("0")


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


tableS = []
for i in range(26):
  tableS.append("0")



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

print(ans)

Solution (Python):
d,d_=dict(),dict()
s,t=input(),input()
l=len(s)
for i in range(l):
    if s[i] not in d:
        d[s[i]]=[i]
    else:
        d[s[i]].append(i)
for i in range(l):
    if t[i] not in d_:
        d_[t[i]]=[i]
    else:
        d_[t[i]].append(i)
x=[sorted(i[1]) for i in list(d.items())]
y=[sorted(i[1]) for i in list(d_.items())]
x.sort()
y.sort()
print("Yes" if x==y else "No")

Solution (Python):
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    S = list(iss())
    T = list(iss())
    StoT = {}
    TtoS = {}
    for n in range(ord('a'), ord('z') + 1):
        StoT[chr(n)] = 0
        TtoS[chr(n)] = 0

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    A = list(iss())
    B = list(iss())
    atob = {}
    btoa = {}
    for n in range(ord('a'), ord('z') + 1):
        atob[chr(n)] = 0
        btoa[chr(n)] = 0

    for ab in zip(A, B):
        a, b = ab
        if atob[a] == 0 and btoa[b] == 0:
            atob[a] = b
            btoa[b] = a
        elif atob[a] != b or btoa[b] != a:
            print('No')
            exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()

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

from collections import defaultdict
ds=defaultdict(list)
dt=defaultdict(list)

for i in range(len(s)):
    if t[i] not in ds[s[i]]:
        ds[s[i]].append(t[i])
    if s[i] not in dt[t[i]]:
        dt[t[i]].append(s[i])

for k in ds.keys():
    if len(ds[k])>1:
        print('No')
        exit()
for k in dt.keys():
    if len(dt[k])>1:
        print('No')
        exit()
print('Yes')

Solution (Python):
import collections
S = input()
T = input()
scounter = collections.Counter(S)
tcounter = collections.Counter(T)
scounter_v = dict(scounter).values()
tcounter_v = dict(tcounter).values()
sdist = sorted([i for i in scounter_v])
tdist = sorted([i for i in tcounter_v])
if sdist == tdist:
  print("Yes")
else:
  print("No")

Solution (Python):
def f():
  i = input()
  return sorted(i.count(j) for j in set(i))
print("YNeos"[f()!=f()::2])

Solution (Python):
from collections import*
c = Counter
f = lambda: c(c(input()).values())
print("YNeos"[f()!=f()::2])

Solution (Python):
from collections import defaultdict
s = input()
t = input()
sd = defaultdict(set)
td = defaultdict(set)
for i in range(len(s)):
    sd[s[i]].add(t[i])
    td[t[i]].add(s[i])
if [1 for i in sd.values() if len(i)!=1] or [1 for i in td.values() if len(i)!=1]:
    print('No')
else:
    print('Yes')

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

a = [[] for i in range(26)]
for i in range(len(s)):
    a[ord(s[i])-97].append(i)

b = [[] for i in range(26)]
for i in range(len(t)):
    b[ord(t[i])-97].append(i)

a.sort()
b.sort()

for i in range(26):
    if (a[i]!=b[i]):
        print("No")
        exit()
print("Yes")

Solution (Python):
import sys

S=input()
T=input()
n=len(S)
D={}
C=[]
for i in range(n):
    if not S[i] in D:
        if T[i] in C:
            print("No")
            sys.exit()
        D[S[i]]=T[i]
        C.append(T[i])
    else:
        if D[S[i]]!=T[i]:
            print("No")
            sys.exit()
print("Yes")

Solution (Python):
import sys
import math  
import bisect  
import queue  


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    S = input()
    T = input()

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

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

    if len(cnt_S) != len(cnt_T):
        print("No")
    else:
        cnt_S = [v for v in cnt_S.values()]
        cnt_T = [v for v in cnt_T.values()]
        cnt_S.sort()
        cnt_T.sort()
        ans = True
        for s, t in zip(cnt_S, cnt_T):
            if s != t:
                ans = False
                break
        if ans:
            print("Yes")
        else:
            print("No")

Solution (Python):

















mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    S = input()
    T = input()
    dic_s = {}
    dic_t = {}
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if s in dic_t:
            if dic_t[s] != t:
                print('No')
                exit()
        if t in dic_s:
            if dic_s[t] != s:
                print('No')
                exit()
        dic_t[s] = t
        dic_s[t] = s
    print('Yes')
if __name__ == '__main__':
  main()

Solution (Python):
s = input()
t = input()
scnt = {}
tcnt = {}
sres = []
tres = []
for x in s:
    if x not in scnt:scnt[x] = 1
    else:scnt[x] +=1
for x in t:
    if x not in tcnt:tcnt[x] = 1
    else:tcnt[x] +=1
for k in scnt:
    sres.append(scnt[k])
for k in tcnt:
    tres.append(tcnt[k])
sres.sort()
tres.sort()
n = max(len(sres),len(tres))
ok = True
for i in range(n):
    if sres[i] != tres[i]:
        ok = False
        break
if ok:print('Yes')
else:print('No')

Solution (Python):
str1 = input()
str2 = input()

dict1 = dict()
ans = "Yes"

for i in range(len(str1)):
    if(str1[i] in dict1.keys()):
        if(dict1[str1[i]] != str2[i]):
            ans = "No"
    else:
        if(str2[i] in dict1.values()):
            ans = "No"
        dict1[str1[i]] = str2[i]

print(ans)

Solution (Python):
s = list(input())
t = list(input())
ls, lt = len(s), len(t)
ss = [0] * ls
alph1 = [-1] * 130
alph2 = [-1] * 130
for i in range(ls):
    c = 1
    m, n = ord(s[i]), ord(t[i])
    if alph1[m] == -1:
        alph1[m] = ord(t[i])
    else:
        if not alph1[m] == ord(t[i]):
            c = 0
    if alph2[n] == -1:
        alph2[n] = ord(s[i])
    else:
        if not alph2[n] == ord(s[i]):
            c = 0
    if c == 0:
        break
print("Yes" if c == 1 else "No")

Solution (Python):
from collections import Counter
 
def check():
    S = sorted(Counter(input()).values())
    T = sorted(Counter(input()).values())
    
    for s,t in zip(S,T):
        if s !=t: 
            return 'No'
    return 'Yes'
  
print(check())

Solution (Python):
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline 
sys.setrecursionlimit(500000)

S = input()
T = input()
N = len(S)
ds = {}
dt = {}
ss = 0
tt = 0
SS = []
TT = []
for i in range(N):
    if S[i] in ds:
        SS.append(ds[S[i]])
    else:
        ds[S[i]] = ss
        SS.append(ss)
        ss += 1
    if T[i] in dt:
        TT.append(dt[T[i]])
    else:
        dt[T[i]] = tt
        TT.append(tt)
        tt += 1
flag = True
for i in range(N):
    if SS[i]==TT[i]:
        continue
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
def isOK(s,t):
  m = [None] * 26
  for i,j in zip(s,t):
    num = ord(i) - ord("a")
    if m[num] == None:
      m[num] = j
    else:
      if m[num] != j:
        return False
  return True

s = input()
t = input()
if isOK(s,t) and isOK(t,s):
  print("Yes")
else:
  print("No")

Solution (Python):
s = input()
t = input()
replace_s = {chr(i): '' for i in range(ord('a'), ord('z')+1)}
replace_t = {chr(i): '' for i in range(ord('a'), ord('z')+1)}
ans = 'Yes'
for i, j in zip(s, t):
    if replace_s[i] and replace_s[i] != j or replace_t[j] and replace_t[j] != i:
        ans = 'No'
        break
    if not replace_s[i]:
        replace_s[i] = j
    if not replace_t[i]:
        replace_t[j] = i
print(ans)

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

    spair = {}
    tpair = {}

    for s, t in zip(S, T):
        if s not in spair:
            spair[s] = t
        else:
            if spair[s] != t:
                print("No")
                exit()
        if t not in tpair:
            tpair[t] = s
        else:
            if tpair[t] != s:
                print("No")
                exit()

    print("Yes")


if __name__ == "__main__":
    solve()

Solution (Python):
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()


S, T = input(), input()

m = {}
ok = True
for s, t in zip(S, T):
    if s in m and m[s] != t:
        ok = False
        break
    m[s] = t
print('Yes' if ok and len(m.values()) == len(set(m.values())) else 'No')

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

def main():
    S = input()
    T = input()
    pair1 = {}
    pair2 = {}
    for i in range(len(S)):
        if S[i] not in pair1.keys():
            pair1[S[i]] = T[i]
        else:
            if pair1[S[i]] != T[i]:
                print('No')
                return
        if T[i] not in pair2.keys():
            pair2[T[i]] = S[i]
        else:
            if pair2[T[i]] != S[i]:
                print('No')
                return
        
    print('Yes')


if __name__ == '__main__':
    main()

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

def main():
    S = input()
    T = input()
    pair = {}
    pair2 = {}
    for i in range(len(S)):
        if S[i] not in pair.keys():
            pair[S[i]] = T[i]
        else:
            if pair[S[i]] != T[i]:
                print('No')
                return
        if T[i] not in pair2.keys():
            pair2[T[i]] = S[i]
        else:
            if pair2[T[i]] != S[i]:
                print('No')
                return
        
    
    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
ch = list("abcdefghijklmnopqrstuvwxyz")

s = list(input())
t = list(input())
import numpy as np

s = np.array(s)
t = np.array(t)

flag = True
for i in ch:
  t_temp = (t[s == i])
  s_temp = (s[t == i])
  if len(set(t_temp)) > 1 or len(set(s_temp)) > 1:
    flag = False
    
if flag:print("Yes")
else:print("No")

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

s = sorted(Counter(list(readline().rstrip().decode())).values())
t = sorted(Counter(list(readline().rstrip().decode())).values())
if s == t:
    print('Yes')
else:
    print('No')

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


def check(S,T):
    dic1 = {}
    dic2 = {}
    for s,t in zip(S,T):
        if s not in dic1:
            dic1[s] = t
            
        elif dic1[s] != t:
            return False
    for k in dic1.keys():
        if list(dic1.values()).count(k) > 1:
            return False
        
        
        
        
        
        
        
        
        
        
        
        
        
    return True
            

if check(S,T):
    print('Yes')
else:
    print('No')

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

dic = {}
dic2 = {}
for i in range(len(s)):
  tmp = dic.get(s[i],-1)
  tmp2 = dic2.get(t[i],-1)
  if tmp != -1 and tmp != t[i]:
    print('No')
    sys.exit(0)
    
  if tmp2 != -1 and tmp2 != s[i]:
    print('No')
    sys.exit(0)
    
  if tmp == -1:
    dic[s[i]] = t[i]
    
  if tmp2 == -1:
    dic2[t[i]] = s[i]

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) and (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()

combination = []
for i, j in zip(S,T):
    combination.append([i,j])

set_S = []
set_T = []

for i,j in list(map(list, set(map(tuple, combination)))):
    set_S.append(i)
    set_T.append(j)

if len(set_S) == len(set(set_S))and len(set_T) == len(set(set_T)):
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

def check():
    S = sorted(Counter(input()).values())
    T = sorted(Counter(input()).values())
    
    for s,t in zip(S,T):
        if s !=t:
            return 'No'
    return 'Yes'
  
print(check())

Solution (Python):



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


s_map = {}
t_map = {}
is_ok = True


for i in range(len(S)):
    s = S[i]
    t = T[i]
    if not s in s_map:
        s_map[s] = set([t])
    else:
        s_map[s].add(t)

    if not t in t_map:
        t_map[t] = set([s])
    else:
        t_map[t].add(s)



for s in s_map:
    if len(s_map[s])>1:
        is_ok = False

for t in t_map:
    if len(t_map[t])>1:
        is_ok = False


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

Solution (Python):
import sys
from string import ascii_lowercase

o = dict(zip(ascii_lowercase, range(26)))

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

def main():
    g1 = [set() for _ in range(26)]
    g2 = [set() for _ in range(26)]
    for i in range(len(s)):
        a = o[s[i]]; b = o[t[i]]
        g1[a].add(b); g2[b].add(a)

    for i in range(26):
        if len(g1[i]) >= 2 or len(g2[i]) >= 2:
            print('No')
            return
    print('Yes')

if __name__ ==  '__main__':
    main()

Solution (Python):
import sys

def o(c): return ord(c) - ord('a')

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

def main():
    g1 = [set() for _ in range(26)]
    g2 = [set() for _ in range(26)]
    for i in range(len(s)):
        a = o(s[i]); b = o(t[i])
        g1[a].add(b); g2[b].add(a)

    for i in range(26):
        if len(g1[i]) >= 2 or len(g2[i]) >= 2:
            print('No')
            return
    print('Yes')

if __name__ ==  '__main__':
    main()

Solution (Python):





mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    
    
    S = input()
    T = input()
    ok = True
    dic_s = {}
    dic_t = {}
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if s in dic_s.keys():
            if dic_s[s] != t:
                ok = False
        if t in dic_t.keys():
            if dic_t[t] != s:
                ok = False
        dic_s[s] = t
        dic_t[t] = s
        
    if ok:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
  main()

Solution (Python):


def solve():

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


if __name__ == "__main__":
    solve()

Solution (Python):
from collections import defaultdict
d1 = defaultdict(list)
d2 = defaultdict(list)
S = input()
T = input()
N = len(S)
for i in range(N):
    d1[S[i]].append(i)
for i in range(N):
    d2[T[i]].append(i)
val1 = d1.values()
val2 = d2.values()
val1 = list(val1)
val2 = list(val2)
val1.sort()
val2.sort()
if val1 == val2:
    print('Yes')
else:
    print('No')

Solution (Python):
import string
import collections
S = input()
T = input()
s_cnt =collections.Counter(list(S))
n_cnt = collections.Counter(list(T))


for i in range(len(s_cnt)):
  if(s_cnt.most_common()[i][1] != n_cnt.most_common()[i][1]):
    print("No")
    exit()
print("Yes")

Solution (Python):
s = str(input())
t = str(input())
ls = [[0] for i in range(26)]
lt = [[0] for i in range(26)]
for i in range(len(s)):
    ls[ord(s[i])-97].append(i)
    lt[ord(t[i])-97].append(i)
for i in ls:
    for j in lt:
        if i==j:
            break
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
s=list(input())
t=list(input())
c=[chr(i) for i in range(97, 97+26)]
l=[[] for i in range(26)]
l2=[[] for i in range(26)]
for i in range(len(s)):
  l[c.index(s[i])].append(t[i])
  l2[c.index(t[i])].append(s[i])
for i in range(26):
  if len(set(l[i]))>1 or len(set(l2[i]))>1:
    print('No')
    exit()
print('Yes')

Solution (Python):
"""
嘘解法です.通るかな?
コーナーケース:
in:
    abab
    aabb
Out:
    Yes
    (本当はNo)
"""
s = str(input())
t = str(input())
ls = [0]*26
lt = [0]*26
for i in range(len(s)):
    ls[ord(s[i])-97] += 1
    lt[ord(t[i])-97] += 1
ls.sort()
lt.sort()
if lt == ls:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
t=input()
dict_s = {}
dict_t = {}
ans = 0

for i in range(len(s)):
    s1 = s[i]
    if s1 in dict_s.keys():
        dict_s[s1] += 1
    else:
        dict_s[s1] = 1

for i in range(len(t)):
    t1 = t[i]
    if t1 in dict_t.keys():
        dict_t[t1] += 1
    else:
        dict_t[t1] = 1

for i in range(len(s)):
    if dict_s[s[i]] != dict_t[t[i]]:
        ans = 1
        break

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

Solution (Python):
s = list(input())
t = list(input())
tr = []
a_ar =[chr(ord('a') + i) for i in range(26)]
a_edge = []
for i in range(26):
    a_edge.append(set())
for i in range(len(s)):
    a_edge[a_ar.index(s[i])].add(a_ar.index(t[i]))

ans = []
for i in range(26):
    if len(a_edge[i]) >= 2:
        print("No")
        exit()
    elif len(a_edge[i]) != 0:
        l = list(a_edge[i])
        ans.append(l[0])
p = len(ans)
q = len(set(ans))
if p == q:
    print("Yes")
else:
    print("No")

Solution (Python):
s = str(input())
t = str(input())
ls = [[0] for i in range(26)]
lt = [[0] for i in range(26)]

for i in range(len(s)):
    ls[ord(s[i])-97].append(i)
    lt[ord(t[i])-97].append(i)


for i in ls:
    f = 0
    for j in lt:
        if i==j:
            f = 1
            break
    if f == 0:
        print("No")
        exit()
print("Yes")

Solution (Python):
def c_string_transformation():
    from collections import defaultdict
    S,T = input(),input()
    dict_s_to_t = defaultdict(set)
    dict_t_to_s = defaultdict(set)
    for c1, c2 in zip(S, T):
        dict_s_to_t[c1].add(c2)
        dict_t_to_s[c2].add(c1)
    
    
    
    
    for v in list(dict_s_to_t.values()) + list(dict_t_to_s.values()):
        if len(v) != 1:
            return 'No'
    return 'Yes'

print(c_string_transformation())

Solution (Python):
import sys
s=list(input())
t=list(input())
c=[chr(i) for i in range(97, 97+26)]
l=[[] for i in range(26)]
l2=[[] for i in range(26)]
for i in range(len(s)):
  l[c.index(s[i])].append(t[i])
  l2[c.index(t[i])].append(s[i])
for i in range(26):
  l[i]=list(set(l[i]))
  l2[i]=list(set(l2[i]))
for i in range(26):
  if len(l[i])>=2:
    print('No')
    sys.exit()
  if len(l2[i])>=2:
    print('No')
    sys.exit()
print('Yes')

Solution (Python):


s, t = input(), input()
sd, td = {}, {}
for sv in s:
    if sv in sd:
        sd[sv] += 1
    else:
        sd[sv] = 1
for tv in t:
    if tv in td:
        td[tv] += 1
    else:
        td[tv] = 1
sort_sk, sort_tk = sorted(sd.values()), sorted(td.values())
print("Yes" if sort_sk == sort_tk else "No")

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

Solution (Python):
s=input()
t=input()
sr=[-1]*26
tr=[-1]*26
ans="Yes"
for S,T in zip(s,t):
    if sr[ord(S)-97]>=0:
        if sr[ord(S)-97]!=ord(T):
            ans="No"
    if tr[ord(T)-97]>=0:
        if tr[ord(T)-97]!=ord(S):
            ans="No"
    if sr[ord(S)-97]<0:
        sr[ord(S)-97]=ord(T)
    if tr[ord(T)-97]<0:
        tr[ord(T)-97]=ord(S)
print(ans)

Solution (Python):


from string import ascii_lowercase
s, t = input(), input()
alphabets = ascii_lowercase
sd, td = {}, {}
for sv in s:
    if sv in sd:
        sd[sv] += 1
    else:
        sd[sv] = 1
for tv in t:
    if tv in td:
        td[tv] += 1
    else:
        td[tv] = 1
sort_sk = sorted(sd.values())
sort_tk = sorted(td.values())
print("Yes" if sort_sk == sort_tk else "No")

Solution (Python):
from collections import defaultdict

s = input()
t = input()

def fprint(x):
    d = defaultdict(list)
    for i, c in enumerate(x):
        d[c].append(i)
    return sorted(d.values())

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

Solution (Python):
S, T = input().strip(), input().strip()
ds, dt = {}, {}

for s, t in zip(S, T):
    if s not in ds or ds[s] == t:
        ds[s] = t
    else:
        print('No')
        exit()
    if t not in dt or dt[t] == s:
        dt[t] = s
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
from collections import defaultdict
S, T = map(lambda x: x.strip(), open(0).read().split())

ds, dt = defaultdict(str), defaultdict(str)
ans = 'Yes'
for s, t in zip(S, T):
    if not ds[s] or ds[s] == t:
        ds[s] = t
    else:
        ans = 'No'
        break
    if not dt[t] or dt[t] == s:
        dt[t] = s
    else:
        ans = 'No'
        break
print(ans)

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

ds = {}
dt = {}
ans = 'Yes'
for s, t in zip(S, T):
    if s not in ds or ds[s] == t:
        ds[s] = t
    else:
        ans = 'No'
        break
    if t not in dt or dt[t] == s:
        dt[t] = s
    else:
        ans = 'No'
        break
print(ans)

Solution (Python):
a = input()
b = input()
relsa = {}
relsb = {}
possible = True
for i in range(len(a)):
  if a[i] not in relsa:
    relsa[a[i]] = b[i]
  else:
    if relsa[a[i]] != b[i]:
      possible = False
  if b[i] not in relsb:
    relsb[b[i]] = a[i]
  else:
    if relsb[b[i]] != a[i]:
      possible = False
      
if possible:
  print("Yes")
else:
  print("No")

Solution (Python):
S=input()
T=input()
Rs=[-1]*26
Rt=[-1]*26
for i in range(len(S)):
  a=ord(S[i])-ord("a")
  b=ord(T[i])-ord("a")
  if Rs[a]==-1:
    Rs[a]=b
  elif Rs[a]!=b:
    print("No")
    exit()
  if Rt[b]==-1:
    Rt[b]=a
  elif Rt[b]!=a:
    print("No")
    exit()
print("Yes")

Solution (Python):
s=input()
t=input()
S=sorted(map(s.count,set(s)))
T=sorted(map(t.count,set(t)))
print("Yes" if S==T else "No")

Solution (Python):
s1 = input()
s2 = input()
set1 = set()
li = []
for i in range(len(s1)):
    set1.add((s1[i],s2[i]))
set1 = list(set1)
while set1:
    a = set1.pop()
    
    for i in range(len(set1)):
        if (a[0] != set1[i][0] and a[1] == set1[i][1]) or (a[0] == set1[i][0] and a[1] != set1[i][1]):
            print("No")
            exit()
print("Yes")

Solution (Python):
s = input()
t = input()
x = len(s)
dic = {}
already = set()
for i in range(x):
    if not s[i] in dic.keys():
        if t[i] in already:
            print("No")
            exit()
        dic[s[i]] = t[i]
        already.add(t[i])
    else:
        if dic[s[i]] != t[i]:
            print("No")
            exit()
print("Yes")

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

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

alpha2num = lambda c: ord(c) - ord('a')

flag = 1

for i in range(len(S)):
  si = alpha2num(S[i])
  ti = alpha2num(T[i])
  
  
  if(R[si] < 0):
    R[si] = ti
    
  if(R2[ti] < 0):
    R2[ti] = si
    
  if(R[si] >= 0):
    if(R[si] != ti):
      flag = 0
      print('No')
      break
      
  if(R2[ti] >= 0):
    if(R2[ti] != si):
      flag = 0
      print('No')
      break
    
if(flag == 1):
  print('Yes')

Solution (Python):
s=input()
t=input()
sd={}
td={}
for i in s:
  if i in sd.keys():
    sd[i]+=1
  else:
    sd[i]=1
for i in t:
  if i in td.keys():
    td[i]+=1
  else:
    td[i]=1
if sorted(sd.values()) == sorted(td.values()):
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline

S = input().strip()
T = input().strip()

dic_s = Counter([i for i in S])
dic_t = Counter([i for i in T])

arr_s = sorted([i for i in dic_s.values()])
arr_t = sorted([i for i in dic_t.values()])

if arr_s == arr_t:
    print('Yes')
else:
    print('No')

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

Solution (Python):
S = input()
T = input()
ListS = []
ListT = []
Alphabet = ["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"]
for i in range(26):
    ListS.append(S.count(Alphabet[i]))
    ListT.append(T.count(Alphabet[i]))
ListS.sort()
ListT.sort()
print("Yes" if ListS == ListT else "No")

Solution (Python):
from collections import Counter
s = Counter(input())
a = [i for i in s.values()]
t = Counter(input())
b = [i for i in t.values()]
if sorted(a)==sorted(b):
  print('Yes')
else:
  print("No")

Solution (Python):
import collections
s=list(input())
t=list(input())
svalues, scounts = zip(*collections.Counter(s).most_common())
tvalues, tcounts = zip(*collections.Counter(t).most_common())
if scounts==tcounts:print('Yes')
else:print('No')

Solution (Python):
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
t = ins()
h = {}
g = {}
for i in range(len(s)):
    if s[i] not in h:
        if t[i] not in g:
            h[s[i]] = t[i]
            g[t[i]] = s[i]
        else:
            print('No')
            exit()
    elif h[s[i]] != t[i]:
        print('No')
        exit()
print('Yes')

Solution (Python):
s = input()
t = input()
c1 = {}
c2 = {}
for i,j in zip(s,t):
    if i in c1:
      if c1[i] != j:
        a = "No"
        break
    else:
      c1[i] = j
    if j in c2:
      if c2[j] != i:
        a = "No"
        break
    else:
      c2[j] = i
else:
  a = "Yes"
print(a)

Solution (Python):
s1 = input()
s2 = input()
N = len(s1)
s1l = []
s2l = []
ans = True
f = False
for i in range(N):
  f = True
  for s in range(len(s1l)):
    if s1[i] == s1l[s]:
      if s2[i] != s2l[s]:
        ans = False
      f = False
      break
    elif s2[i] == s2l[s]:
      ans = False
  if f:
    s1l.append(s1[i])
    s2l.append(s2[i])
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import Counter

def can_match(s, t):
  fs = Counter(S)
  ft = Counter(T)
  
  if len(s) != len(t):
    return False
  
  for cs, ct in zip(s, t):
    
    if fs[cs] != ft[ct]:
      return False

  return True


S = input()
T = input()

if can_match(S, T):
  print('Yes')
else:
  print('No')