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



Sample input:
azzel
apple


Sample output:
Yes

Submission status: Accepted

Solution code:
s = input()
t = input()
S = [""] * len(s)
T = [""] * len(s)
for i in range(len(s)):
    S[i] = s[i]
    T[i] = t[i]

chrset = set()
res = "Yes"
for i,s,t in zip(range(len(S)),S,T):
    if s == t:
        continue
    if (s in chrset) or (t in chrset):
        res = "No"
        break 
    for j in range(i,len(S)):
        if S[j] == s:
            S[j] = t 
        elif S[j] == t:
            S[j] = s 
    chrset.add(t)
print(res)

Submission status: Accepted

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

i = 0
j = 0

sdict = {}
tdict = {}

slist = []
tlist = []

for s in S:
    if s in sdict:
        slist.append(sdict[s])
    else:
        sdict[s] = i
        slist.append(i)
        i += 1


for t in T:
    if t in tdict:
        tlist.append(tdict[t])
    else:
        tdict[t] = j
        tlist.append(j)
        j += 1

if slist == tlist:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

counter_S = Counter(S)
counter_T = Counter(T)

if sorted(counter_S.values()) == sorted(counter_T.values()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def uni(t, l):
    if len(l) < 2:
        return True
    else:
        for i in range(1, len(l)):
            if t[l[0]] != t[l[i]]:
                return False
            else:
                pass
        return True

s = input()
t = input()

l = 'abcdefghijklmnopqrstuvwxyz'

flag = True

for x in l:
    tmp = []
    for i,y in enumerate(t):
        if y == x:
            tmp.append(i)
#    print(x)
#    print(tmp)
    if not uni(s, tmp):
        flag = False

for x in l:
    tmp = []
    for i,y in enumerate(s):
        if y == x:
            tmp.append(i)
    if not uni(t,tmp):
        flag = False

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

Submission status: Accepted

Solution code:
import collections as c
i=lambda:c.Counter(c.Counter(input()).values());print('YNeos'[i()!=i()::2])

Submission status: Accepted

Solution code:
from collections import Counter as C
i=lambda:C(C(input()).values());print('YNeos'[i()!=i()::2])

Submission status: Accepted

Solution code:
import sys

S = input()
T = input()

len_S = len(S)
S_Converted = S
for i in range (len(S)):
    tmp_S = S_Converted[i]
    tmp_T = T[i]
    if tmp_S == tmp_T:
        continue
    S_Converted = list(S_Converted) 
    list_indexT = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_T]
    if (not list_indexT == []) and (list_indexT[0] < i):
        print('No')
        sys.exit()
    S_Converted = ''.join(S_Converted)
    S_Converted = S_Converted.replace(tmp_S, tmp_T)
    S_Converted = list(S_Converted) 
    for li in list_indexT:
        if li == i:
            continue
        else:
            S_Converted[li] = tmp_S
    #print(''.join(S_Converted))
    
S_Converted = ''.join(S_Converted)

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

Submission status: Accepted

Solution code:
a=input()
b=input()
A=a
s=set()
for i in range(len(a)):
  if b[i] not in s:
    A=A.replace(A[i],b[i].upper())
  s|={b[i]}
if A==b.upper():
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S=input()
T=input()
start=[-1]*26
goal=[-1]*26
ans='Yes'
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:
            ans='No'
    else:
        start[a]=b;
        goal[b]=a;
print(ans)

Submission status: Accepted

Solution code:
def main():
    s=input()
    t=input()
    if len(s) != len(t):
        print('No')
    ret1 = {}
    ret2 = {}
    for i in range(len(s)):
        ret1[s[i]] = ret1.get(s[i], set())
        ret1[s[i]].add(t[i])
        ret2[t[i]] = ret2.get(t[i], set())
        ret2[t[i]].add(s[i])
    if max(len(i) for i in ret1.values()) == 1 and max(len(i) for i in ret2.values()) == 1:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s,t=[0]*26,[0]*26
for a,b in zip(input(),input()):
  s[ord(a)-ord('a')]+=1
  t[ord(b)-ord('a')]+=1
u,v=[],[]
for a,b in zip(s,t):
  if a!=b:
    u.append(a)
    v.append(b)
print('YNeos'[sorted(u)!=sorted(v)::2])

Submission status: Accepted

Solution code:
ss = input()
tt = input()

res = "Yes"
_dict = {chr(x): [] for x in range(97, 123)}
_dict2 = {chr(x): [] for x in range(97, 123)}
for i, j in zip(ss, tt):
    _dict[i].append(j)
for i, j in zip(ss, tt):
    _dict2[j].append(i)

for array in _dict.values():
    if len(set(array)) > 1:
        res = "No"
        break
for array in _dict2.values():
    if len(set(array)) > 1:
        res = "No"
        break
print(res)

Submission status: Accepted

Solution code:
from collections import Counter
S=raw_input()
T=raw_input()

start=[ -1 for i in range(26) ]
goal=[ -1 for i in range(26) ]

L=len(S)


for i in range(L):
	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"
			quit()
	else:
		start[a]=b
		goal[b]=a

#print "start::: ",start
#print "goal::: ",goal

print "Yes"

Submission status: Accepted

Solution code:
alp="abcdefghijklmnopqrstuvwxyz"
s=input()
t=input()
l=len(s)
a=[]
b=[]

for i in alp:
  a.append(s.count(i))
  b.append(t.count(i))

a.sort()
b.sort()

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

Submission status: Accepted

Solution code:
s = raw_input().strip()
t = raw_input().strip()

s_encode = [0]*26
t_encode = [0]*26

for i in s:
	s_encode[ord(i)-97]+=1

for i in t:
	t_encode[ord(i)-97]+=1

s_encode.sort()
t_encode.sort()
if s_encode==t_encode:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
def solv():
    s = ["" for _ in range(26)]
    t = ["" for _ in range(26)]
    for i in range(len(S)):
        if s[ord(S[i]) - ord('a')] == "":
            s[ord(S[i]) - ord('a')] = T[i]
        else:
            if s[ord(S[i]) - ord('a')] != T[i]:
                return False
        if t[ord(T[i]) - ord('a')] == "":
            t[ord(T[i]) - ord('a')] = S[i]
        else:
            if t[ord(T[i]) - ord('a')] != S[i]:
                return False
    return True


S = input()
T = input()
print("Yes" if solv() else "No")

Submission status: Accepted

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

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

Submission status: Accepted

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

flag = True
translate1 = [-1 for i in range(26)]
translate2 = [-1 for i in range(26)]
for i in range(len(S)):
    s = ord(S[i])-97
    t = ord(T[i])-97

    if translate1[s] == -1:
        translate1[s] = t
    else:
        if translate1[s] != t:
            flag = False
            break 

    if translate2[t] == -1:
        translate2[t] = s
    else:
        if translate2[t] != s:
            flag = False
            break


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

Submission status: Accepted

Solution code:
f = lambda x: ord(x)-ord('a')
S = list(map(f, list(input())))
T = list(map(f, list(input())))

def solve():
    to = [None for _ in range(26)] 
    fr = [None for _ in range(26)] 

    for s, t in zip(S, T):
        if to[s] != None and to[s] != t or fr[t] != None and fr[t] != s:
            return False
        to[s] = t
        fr[t] = s

    return True

print(["No","Yes"][solve()])

Submission status: Accepted

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

sorted_t = list(set(sorted(t)))

for i in sorted_t:
    check = 0
    temp = 'a'
    for j in range(len(t)):
        if t[j] == i:
            if check == 0:
                check = 1
                temp = s[j]
            elif s[j] != temp:
                print('No')
                exit()

sorted_s = list(set(sorted(s)))

for i in sorted_s:
    check = 0
    temp = 'a'
    for j in range(len(s)):
        if s[j] == i:
            if check == 0:
                check = 1
                temp = t[j]
            elif t[j] != temp:
                print('No')
                exit()

print('Yes')

Submission status: Accepted

Solution code:
S = input()
T = input()
k = {}
o = {}
res = "Yes"
for i in range(len(S)):
    if S[i] in k:
        if k[S[i]] != T[i]:
            res = "No"
            break
    else:
        k[S[i]] = T[i]
        
for i in range(len(T)):
    if T[i] in o:
        if o[T[i]] != S[i]:
            res = "No"
            break
    else:
        o[T[i]] = S[i]
    
print(res)

Submission status: Accepted

Solution code:
def main():
    s, t = input(), input()

    used, dic = [0] * 512, {}
    for i in range(26):
        dic[chr(ord('a')+i)] = chr(ord('a')+i)

    for i, j in zip(s, t):
        if dic[i] == j:
            used[ord(i)] = 1
            continue

        for k, v in dic.items():
            if v == j:
                if used[ord(k)]:
                    print("No")
                    exit()
                dic[k] = i

        if used[ord(i)] and dic[i] != j:
            print("No")
            exit()

        dic[i], used[ord(i)] = j, 1

    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

lens = len(S)
S = S
dic1,dic2 = {},{}

ch = 0
for i in range(lens):
    dic1[S[i]] = ''
    dic2[T[i]] = ''

for i in range(lens):
    if dic1[S[i]] == '' or dic1[S[i]] == T[i]:
        dic1[S[i]] = T[i]
    else:
        ch = 1
    if dic2[T[i]] == '' or dic2[T[i]] == S[i]:
        dic2[T[i]] = S[i]
    else:
        ch = 1

for k1 in dic1.keys():
#    print(k1, '->', dic2[dic1[k1]])
    if dic2[dic1[k1]] != k1:
        ch = 1

if ch == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    S = list(input())
    T = list(input())

    start = [-1 for i in range(26)]
    stop = [-1 for i in range(26)]

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

        if start[a] != -1 or stop[b] != -1:
            if start[a] != b or stop[b] != a:
                print('No')
                fail = True
                break
        else:
            start[a] = b
            stop[b] = a

    if not fail:
        print('Yes')

Submission status: Accepted

Solution code:
#coding:utf-8

"""
自分の解答。これだとTLEになってしまったので、復習をします
from collections import Counter
S = str(input())
T = str(input())

for i in range(len(S)+1):
	s = str(S[i:i+1])
	t = str(T[i:i+1])
	S = S.replace(s,'A').replace(t,s).replace('A',t)

answer = 'No'

if S == T:
	answer = 'Yes'
	
print(answer)
"""

"""
対応表を作るイメージ。
azzel→appleにするのには
a a
z p
e i
l e
という変化を回せればおっけー

#初期値-1で、要素26コの対応表をつくる
start = [-1]*26
goal = [-1]*26
print(start)

"""


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

#辞書型を使ってみる。defaultdictは便利らしい。どこがかはちょっとよく分からなかった。
from collections import defaultdict
s = defaultdict(int)
t = defaultdict(int)


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

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

#辞書型をソートできるsoted()を使う。
#values()で辞書型のkey valueのvalueだけを取り出している。

ss = sorted(s.values())
tt = sorted(t.values())

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

Submission status: Accepted

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

ss = collections.Counter(s)
tt = collections.Counter(t)

slist = []
tlist = []

for i in ss:
    slist.append(ss[i])
for i in tt:
    tlist.append(tt[i])

slist.sort()
tlist.sort()
check = False
if len(slist) == len(tlist):
    check = True
    for i in range(len(slist)):
        if slist[i] != tlist[i]:
            check= False
    

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

Submission status: Accepted

Solution code:
s = input()
t = input()
orz = False
for j in range(2):
  d = {}
  for i in range(len(s)):
    if s[i] in d and d[s[i]]!=t[i]:
      orz = True
      break
    d[s[i]] = t[i]
  s, t = t, s
print('No' if orz else 'Yes')

Submission status: Accepted

Solution code:
s=input()
t=input()
ans=''
a=[]
count=0
while ans=='' and count<100:
    for i,j in zip(s,t):
        if i!=j:
            if j in a:
                ans='No'
            s=s.replace(i,'.').replace(j,i).replace('.',j)
            a.append(j)
            break
    else:ans='Yes'
    count+=1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
f1,f2=True,True
s,t=input(),input()
ds,dt=dd(list),dd(list)

for i,c in enumerate(s):
  ds[c].append(i)
for i,c in enumerate(t):
  dt[c].append(i)

for i in ds.keys():
  if len({t[j] for j in ds[i]})!=1:f1=False
for i in dt.keys():
  if len({s[j] for j in dt[i]})!=1:f2=False

print("Yes" if f1 and f2 else "No")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

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

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

Submission status: Accepted

Solution code:
import string

alphabet = string.ascii_lowercase

S = str(input())
T = str(input())
start = [-1 for i in range(len(alphabet))]
goal = [-1 for i in range(len(alphabet))]
tf = True

for i in range(len(S)):
    a = alphabet.index(S[i])
    b = alphabet.index(T[i])

    if (start[a] != -1 or goal[b] != -1):
        if (start[a] != b or goal[b] != a):
            tf = False
            break
    else:
        start[a] = b
        goal[b] = a

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

Submission status: Accepted

Solution code:
S = input()
T = input()
assert len(S) == len(T)

def uniq(s):
    '''Return the list obtained from s by removing repeating chars.'''
    appeared = set()
    for c in s:
        if c not in appeared:
            appeared.add(c)
            yield c

def normalized(s):
    dic = {c: i for i, c in enumerate(uniq(s))}
    return [dic[c] for c in s]

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

Submission status: Accepted

Solution code:
s = input()
t = input()
flag1 = True
flag2 = True
s_dic = {}
t_dic = {}
for i, c in enumerate(s):
    if c not in s_dic.keys():
        s_dic[c] = []
    s_dic[c].append(i)
for i in s_dic.keys():
    l = []
    for ind in s_dic[i]:
        l.append(t[ind])
    if len(set(l)) != 1:
        flag1 = False

for i, c in enumerate(t):
    if c not in t_dic.keys():
        t_dic[c] = []
    t_dic[c].append(i)
for i in t_dic.keys():
    l = []
    for ind in t_dic[i]:
        l.append(s[ind])
    if len(set(l)) != 1:
        flag2 = False



if flag1 and flag2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

s_shelv = [None for x in range(26)]
t_shelv = [None for x in range(26)]

a_z = list('abcdefghijklmnopqrstuvwxyz')


for i in range(len(S)):
  s = S[i]
  t = T[i]
  si = a_z.index(s)
  ti = a_z.index(t)

  if s_shelv[si] is None:
    s_shelv[si] = ti
  elif s_shelv[si] != ti:
    print('No')
    exit()

  if t_shelv[ti] is None:
    t_shelv[ti] = si
  elif t_shelv[ti] != si:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
# encoding: utf-8
S = input()
T = input()

s_set = set(S)
t_set = set(T)

st_set = set(zip(S, T))

if len(s_set) == len(t_set) == len(st_set): print("Yes")
else: print("No")

Submission status: Accepted

Solution code:

S = [ord(c)-ord('a') for c in input()]
T = [ord(c)-ord('a') for c in input()]

def check():
    R = [[-1] * 26 for _ in range(2)]

    for i in range(len(S)):
        if R[0][S[i]] < 0:
            R[0][S[i]] = T[i]
        elif R[0][S[i]] != T[i]:
            return False
        
        if R[1][T[i]] < 0:
            R[1][T[i]] = S[i]
        elif R[1][T[i]] != S[i]:
            return False
    
    return True

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

Submission status: Accepted

Solution code:
S = input()
T = input()
S_dic = [0 for _ in range(26)]
T_dic = [0 for _ in range(26)]

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(len(S)):
    s = S[i]
    t = T[i]
    si = alphabet.index(s)
    ti = alphabet.index(t)

    if S_dic[si] == 0:
        S_dic[si] = ti
    elif S_dic[si] != ti:
        print("No")
        exit()

    if T_dic[ti] == 0:
        T_dic[ti] = si
    elif T_dic[ti] != si:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    t = S()
    l = len(s)
    d = collections.defaultdict(lambda: None)
    e = collections.defaultdict(lambda: None)
    for i in range(l):
        si = s[i]
        ti = t[i]
        if not d[si] is None:
            if ti != d[si]:
                return 'No'
        if not e[ti] is None:
            if si != e[ti]:
                return 'No'
        d[si] = ti
        e[ti] = si

    return 'Yes'


print(main())

Submission status: Accepted

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

dic_s = {}
dic_t = {}
re = 'Yes'
for i in range(len(S)):
    s = S[i]
    t = T[i]
#    print(s,t)
    if s in dic_s:
        if dic_s[s] != t:
            re = 'No'
            break
    else:
        dic_s[s] = t
        
    if t in dic_t:
        if dic_t[t] != s:
            re = 'No'
            break
    else:
        dic_t[t] = s
#    print(dic_s, dic_t)
        
print(re)

Submission status: Accepted

Solution code:
def main():
  S = [s for s in input()]
  T = [s for s in input()]
  R1 = [-1 for i in range(26)]
  R2 = [-1 for i in range(26)]
  for i in range(len(S)):
    a = ord(S[i]) % 26
    b = ord(T[i]) % 26
    if(R1[a] != -1 or R2[b] != -1):
      if(R1[a] != b or R2[b] != a):
        print("No")
        return
    else:
      R1[a]=b
      R2[b]=a
  print("Yes")
  return

main()

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

def main():
    s = input()
    t = input()
    abc_list = [chr(i) for i in range(ord('a'), ord('a')+26)]
    trans_dict = {}
    for abc in abc_list:
        trans_dict[abc] = ''
    for i in range(len(s)):
        if trans_dict[s[i]] == '':
            trans_dict[s[i]] = t[i]
        elif trans_dict[s[i]] != t[i]:
            print('No')
            return
    arry = [item for item in trans_dict.values() if item is not '']
    if len(arry) != len(set(arry)):
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
T = input()
l = len(S)
s,t = [], []
for i in "abcdefghijklmnopqrstuvwxyz":
  tmps,tmpt = [], []
  for j in range(l):
    if S[j] == i:
      tmps.append(j)
    if T[j] == i:
      tmpt.append(j)
  s.append(tmps)
  t.append(tmpt)
s.sort()
t.sort()
if s == t:
 print("Yes")
else:
 print("No")

Submission status: Accepted

Solution code:
# coding:utf-8

# 解答みながらの復習

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

Sdic = [0 for _ in range(26)]
Tdic = [0 for _ in range(26)]

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

Able = True

for i in range(len(S)):
    si = S[i]
    ti = T[i]
    if Sdic[alphabet.index(si)] == 0:
        Sdic[alphabet.index(si)] = ti
    elif Sdic[alphabet.index(si)] != ti:
        Able = False
        break
    if Tdic[alphabet.index(ti)] == 0:
        Tdic[alphabet.index(ti)] = si
    elif Tdic[alphabet.index(ti)] != si:
        Able = False
        break
        
print("Yes" if Able else "No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import unittest


def func(s,t):
    n = len(s)
    for c in set(s):
        d = None
        for i in range(n):
            if s[i]==c:
                if d is None:
                    d = t[i]
                elif d!=t[i]:
                    return "No"
    for c in set(t):
        d = None
        for i in range(n):
            if t[i]==c:
                if d is None:
                    d = s[i]
                elif d!=s[i]:
                    return "No"
    return "Yes"

class Test(unittest.TestCase):
    def test(self):
        self.assertEqual(func("azzel", "apple"), "Yes")
        self.assertEqual(func("chokudai", "redcoder"), "No")
        self.assertEqual(func("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu"), "Yes")
        self.assertEqual(func("abc", "abc"), "Yes")

if __name__ == '__main__':
    s = input()
    t = input()
    # unittest.main()
    print(func(s,t))

Submission status: Accepted

Solution code:
S = input()
T = input()
R = [0 for _ in range(26)]
Rrev = [0 for _ in range(26)]
AB = ["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"]

Able = True
for i in range(len(S)):
    if R[AB.index(S[i])] == 0:
        R[AB.index(S[i])] = T[i]
    elif R[AB.index(S[i])] != T[i]:
        Able = False
        break
    if Rrev[AB.index(T[i])] == 0:
        Rrev[AB.index(T[i])] = S[i]
    elif Rrev[AB.index(T[i])] != S[i]:
        Able = False
        break

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

Submission status: Accepted

Solution code:
s, t = input(), input()

print("Yes" if [t.find(t_i) for t_i in t] == [s.find(s_i) for s_i in s] else "No")

Submission status: Accepted

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

X = {}
Y = {}

for i in range(len(S)):
  if not S[i] in X:
    X[S[i]] = T[i]
  elif X[S[i]] == T[i]:
    pass
  else:
    print("No")
    exit(0)

  if not T[i] in Y:
    Y[T[i]] = S[i]
  elif Y[T[i]] == S[i]:
    pass
  else:
    print("No")
    exit(0)

print("Yes")

Submission status: Accepted

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

start = [-1 for i in range(26)]
goal = [-1 for i in range(26)]

for i in range(len(s)):
    a = ord(s[i]) - ord('a')
    b = ord(t[i]) - ord('a')
    
    if start[a] != -1 or goal[b] != -1:
        if start[a] != b or goal[b] != a:
            print("No")
            exit()
    else:
        start[a] = b
        goal[b] = a

print("Yes")

Submission status: Accepted

Solution code:
S = input()
T = input()
for i in range(len(S)):
    if S.find(S[i]) != T.find(T[i]):
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
S = input()
T = input()
sid = {}
tid = {}
ss = []
tt = []
sn = 0
tn = 0
for i in range(len(S)):
    if not S[i] in sid:
        sid[S[i]] = sn
        sn += 1
    ss += [sid[S[i]]]
    if not T[i] in tid:
        tid[T[i]] = tn
        tn += 1
    tt += [tid[T[i]]]
if ss == tt:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def main():
    s, t = input(), input()

    s_dic, t_dic = {}, {}
    for i, j in zip(s, t):
        if i in s_dic and s_dic[i] != j:
            print("No")
            exit()

        if j in t_dic and t_dic[j] != i:
            print("No")
            exit()

        s_dic[i], t_dic[j] = j, i

    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
T = input()
U = "abcdefghijklmnopqrstuvwxyz"
s =[0 for i in range(26)]
t =[0 for i in range(26)]
for k in range(26):
    s[k] += S.count(U[k])
    t[k] += T.count(U[k])
print("Yes" if sorted(s)==sorted(t) else "No")

Submission status: Accepted

Solution code:
import sys
from collections import Counter
one=list(input())
#print(one)
two=list(input())
z={}
result=[]
for num,i in enumerate(one):
    if i not in z:
        z[i]=[num]
    else:
        z[i].append(num)
p={}
for num,i in enumerate(two):
    if i not in p:
        p[i]=[num]
    else:
        p[i].append(num)

#print(p)
#print(z)

w=[]
for k,v in z.items():
    if len(v)>1:
        w.append(v)
o=[]
for k,v in p.items():
    if len(v)>1:
        o.append(v)
#print(w)
#print(o)
"""
for i in w:
    if i not in o:
        print("No")
        sys.exit()
for i in o:
    if i not in w:
        print("No")
        sys.exit()
print("Yes")"""
"""


for k,v in z.items():
    if len(v)>1:
        temp=0
        for k1, v1 in p.items():
            if p[k1]==z[k]:
                temp=1
"""



w.sort()
o.sort()
print("Yes") if w==o else print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()
enco = {}
enco2 = {}
for i in range(len(s)):
  if t[i] not in enco:
    enco[t[i]] = s[i]
  else:
    if enco[t[i]] != s[i]:
      print("No")
      exit()
  if s[i] not in enco2:
    enco2[s[i]] = t[i]
  else:
    if enco2[s[i]] != t[i]:
      print("No")
      exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
from collections import Counter
one=list(input())
#print(one)
two=list(input())
z={}
result=[]
for num,i in enumerate(one):
    if i not in z:
        z[i]=[num]
    else:
        z[i].append(num)
p={}
for num,i in enumerate(two):
    if i not in p:
        p[i]=[num]
    else:
        p[i].append(num)

#print(p)
#print(z)

w=[]
for k,v in z.items():
    if len(v)>1:
        w.append(v)
o=[]
for k,v in p.items():
    if len(v)>1:
        o.append(v)
#print(w)
#print(o)
for i in w:
    if i not in o:
        print("No")
        sys.exit()
for i in o:
    if i not in w:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
t = input()

ds = Counter(list(s))
ts = Counter(list(t))

print('Yes') if(sorted(ds.values()) == sorted(ts.values())) else print('No')

Submission status: Accepted

Solution code:
S=input()
T=input()
X=0
for i in range(len(S)):
    s=S[i]
    if ord(s)>96:
        X+=1
        S=S.replace(s,chr(X+47))
Y=0
for i in range(len(T)):
    t=T[i]
    if ord(t)>96:
        Y+=1
        T=T.replace(t,chr(Y+47))
print('Yes'if S==T else'No')

Submission status: Accepted

Solution code:
a=input()
b=input()

while (1):
    if a=='':
        break
    a=a.replace(a[0],'')
    b=b.replace(b[0],'')    

    if len(a)!=len(b):
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

S = input()
T = input()

# 1対1の変換表(dict)
start = {}
goal = {}

for i in range(len(S)):
    s = S[i]
    t = T[i]
    # 変換表の該当箇所がまだ空いてるかどうか
    if s in start or t in goal:
        # 埋まっている場合、今回の組み合わせと一致しているかどうか
        if start.get(s) != t or goal.get(t) != s:
            print('No')
            exit()
    # 空いていれば変換表を埋める
    else:
        start[s] = t
        goal[t] = s

print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

S = input()
T = input()

# 1対1の変換表
start = {}
goal = {}

for i in range(len(S)):
    s = S[i]
    t = T[i]
    # 変換表(変換前S)の該当箇所がまだ空いてるかどうか
    if s in start:
        # 埋まっている場合、今回の組み合わせと一致しているかどうか
        if start[s] != t:
            print('No')
            exit()
    # 空いていれば変換表を埋める
    else:
        start[s] = t
    # 変換後Tも同じようにやる
    if t in goal:
        if goal[t] != s:
            print('No')
            exit()
    else:
        goal[t] = s

print('Yes')

Submission status: Accepted

Solution code:
def main():
    data0 = input()
    data1 = input()

    flag = True
    data_tmp = data0
    count = 0
    len_data = len(data0)
    while True:
        if data0 == "":
            break

        data0 = data0.replace(data0[0], "")
        data1 = data1.replace(data1[0], "")

        if len(data0) != len(data1):
            print('No')
            exit()

    print('Yes')

if __name__ == "__main__":
    main()

Submission status: Accepted

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

def normalize(s):
    pos = {}
    for i, c in enumerate(s):
        if not c in pos:
            pos[c] = i
        yield pos[c]

if all(x == y for x, y in zip(normalize(S), normalize(T))):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
T = input()
ans ='Yes'
d = {}
d2 = {}
for s, t in zip(S, T):

    if d.get(s) is not None:
        if d[s] != t:
            ans = 'No'
            break
    else:
        d[s] = t

    if d2.get(t) is not None:
        if d2[t] != s:
            ans = 'No'
            break
    else:
        d2[t] = s

print(ans)

Submission status: Accepted

Solution code:
#速い解答みてるとこんなロジックで通ってるんだがいいのか？
#つまりbbcc → bcbc でもOKということなんだが。それがokなら全部OKでは。

sS = input().rstrip()
sT = input().rstrip()

aS = [0] * 26
aT = [0] * 26
sABC = "abcdefghijklmnopqrstuvwxyz"
for i in range(26):
    aS[i]=sS.count(sABC[i])
    aT[i]=sT.count(sABC[i])
aS.sort()
aT.sort()
if aS == aT:
    print ("Yes")
else:
    print ("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

S = input()
T = input()

# 1対1の対応表
start = [-1] * 26
goal = [-1] * 26

for i in range(len(S)):
    # アルファベットを0～25の数値に変換
    a = ord(S[i]) - ord('a')
    b = ord(T[i]) - ord('a')
    # 対応表の該当箇所がまだ空いてるかどうか
    if start[a] != -1 or goal[b] != -1:
        # 埋まっている場合、今回の組み合わせと一致しているかどうか
        if start[a] != b or goal[b] != a:
            print('No')
            exit()
    # 空いていれば対応表を埋める
    else:
        start[a] = b
        goal[b] = a

print('Yes')

Submission status: Accepted

Solution code:
sS = input().rstrip()
sT = input().rstrip()

aS = [0] * 26
aT = [0] * 26
sABC = "abcdefghijklmnopqrstuvwxyz"
for i in range(26):
    aS[i]=sS.count(sABC[i])
    aT[i]=sT.count(sABC[i])
aS.sort()
aT.sort()
if aS == aT:
    print ("Yes")
else:
    print ("No")

Submission status: Accepted

Solution code:
S = input()
T = input()
ST = {}
TS = {}
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s in ST:
        if ST[s] != t:
            print("No")
            break
    else:
        ST[s] = t
    if t in TS:
        if TS[t] != s:
            print("No")
            break
    else:
        TS[t] = s
else:
    print("Yes")