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()
n=len(s)
x=[['',''] for _ in range(n)]
for i in range(n):
  x[i]=[s[i],t[i]]
x.sort(key=lambda x: x[0])

ss,tt='S','T'
for i in range(n):
  s=x[i][0]
  t=x[i][1]
  if ss==s and tt!=t:
    print("No")
    exit()
  ss=s
  tt=t
ss,tt='S','T'
x.sort(key=lambda x: x[1])
for i in range(n):
  s=x[i][0]
  t=x[i][1]
  if ss!=s and tt==t:
    print("No")
    exit()
  ss=s
  tt=t




print("Yes")
"""
print(x)  
s,t='',''
for i in range(n):
  s+=x[i][0]
  t+=x[i][1]

print(s)
print(t)
"""

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
t = input()
# 10日前にACした問題を解く
# 文字列s,tが与えられ、s内にある異なる文字a,bをひっくり返すことでtにできるか判定
# s,tの文字が全単射であるかどうか判定する
# s,t内に出てくる文字全ての位置をリストで保管して、それが一致しているかを判定すれば良い
s_idx = []
t_idx = []
s_visit = []
t_visit = []
for i in range(len(s)):# 全ての位置を探索する
  if s[i] not in s_visit:#初出のやつならその文字を記録する
    s_idx.append([i])
    s_visit.append(s[i])
  else:# 既出ならそれが出てきた時の位置に場所を追加する
    pos = s_visit.index(s[i])
    s_idx[pos].append(i)
for i in range(len(t)):# 全ての位置を探索する
  if t[i] not in t_visit:#初出のやつならその文字を記録する
    t_idx.append([i])
    t_visit.append(t[i])
  else:# 既出ならそれが出てきた時の位置に場所を追加する
    pos = t_visit.index(t[i])
    t_idx[pos].append(i)
#print(s_idx,t_idx,s_visit,t_visit)
if s_idx == t_idx:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import Counter
S=input()
T=input()
SS=Counter(S)
TT=Counter(T)
if sorted(SS.values())==sorted(TT.values()):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from collections import Counter

s = Counter([s for s in input()])
t = Counter([t for t in input()])

check = sum([1 for item in zip(s.most_common(),t.most_common()) if item[0][1]!=item[1][1]])

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

Submission status: Accepted

Solution code:
from collections import Counter
s=[i for i in input()]
t=[i for i in input()]
S=Counter(s)
T=Counter(t)
#辞書形式で返ってくるが、欲しいのはvalues、値

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

Submission status: Accepted

Solution code:
def chr_num(word):
    return ord(word) - 97


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

    start = [-1] * 26
    goal = [-1] * 26
    for i in range(len(s)):
        a = chr_num(s[i])
        b = chr_num(t[i])

        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:
from collections import Counter

s = input()
t = input()

s_cnt = Counter(s).most_common()
t_cnt = Counter(t).most_common()

for i in range(min(len(s_cnt), len(t_cnt))):
    if s_cnt[i][1] != t_cnt[i][1]:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
S=input()
T=input()
dict1={}
a=0
for i in range(len(S)):
  if S[i] in dict1:
    if dict1[S[i]]!=T[i]:
      a=1
  else:
    dict1[S[i]]=T[i]
dict2={}
for i in range(len(T)):
  if T[i] in dict2:
    if dict2[T[i]]!=S[i]:
      a=1
  else:
    dict2[T[i]]=S[i]
if a==0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    cnt = 0
    
    S_dict = {}
    T_dict = {}
    
    for i in range(len(S)):
        if(S[i] not in S_dict):
            S_dict[S[i]] = T[i]
        elif(S_dict[S[i]] != T[i]):
            print("No")
            break
        
        if(T[i] not in T_dict):
            T_dict[T[i]] = S[i]
        elif(T_dict[T[i]] != S[i]):
            print("No")
            break
    else:
        print("Yes")
main()

Submission status: Accepted

Solution code:
# import bisect
from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

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

    sc=Counter(S)
    tc=Counter(T)

    sl,tl=[],[]
    for i in sc.values():
        sl.append(i)

    for i in tc.values():
        tl.append(i)

    if sorted(sl)==sorted(tl):
        print('Yes')
    else:
        print('No')





resolve()

Submission status: Accepted

Solution code:
s = input()
t = input()
TABLE = {a: "" for a in map(chr, range(97, 123))}

for x, y in zip(s, t):
    if TABLE[x] == "":
        if y not in TABLE.values():
            TABLE[x] = y

    if TABLE[x] != y:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
from collections import Counter
s=[i for i in input()]
t=[i for i in input()]
S=Counter(s)
T=Counter(t)
#print(S)辞書形式で返ってくるが、欲しいのはvalues、値
#print(T)
if sorted(S.values())==sorted(T.values()):
    #print(sorted(S.values()),sorted(T.values()))
    print("Yes")
else:print("No")

Submission status: Accepted

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

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

    else:
        d[i] = j

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

    else:
        d2[j] = i

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s_s = input()
s_t = input()

#S->Tの変換ができるか確認するディクショナリー
check_ST_dic = {} 
check_TS_dic = {}

for i in range(len(s_s)):
    s = s_s[i]
    t = s_t[i]
    if s not in check_ST_dic:
        check_ST_dic[s] = t
    elif check_ST_dic[s] != t:
        print('No')
        break

    if t not in check_TS_dic:
        check_TS_dic[t] = s
    elif check_TS_dic[t] != s:
        print('No')
        break

else:
    print('Yes') #breakで抜けなかった時のみ実行

Submission status: Accepted

Solution code:
from collections import defaultdict
s = defaultdict(list)
t = defaultdict(list)
S = list(input())
T = list(input())
for i in range(len(S)):
    if T[i] not in s[S[i]]:
        s[S[i]].append(T[i])
        if len(s[S[i]]) >= 2:
            print("No")
            break
    if S[i] not in t[T[i]]:
        t[T[i]].append(S[i])
        if len(t[T[i]]) >= 2:
            print("No")
            break
    if i == len(S) - 1:
        print("Yes")

Submission status: Accepted

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

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

check_ST_dic={}
check_TS_dic={}

for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s not in check_ST_dic:
        check_ST_dic[s] = t
    elif check_ST_dic[s] != t:
        print("No")
        break

    if t not in check_TS_dic:
        check_TS_dic[t] = s
    elif check_TS_dic[t] != s:
        print("No")
        break
    
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(t)
a = [0] * 26
b = [0] * 26
c = []
d = []
fl = "Yes"

for i in range(n):
    ts = ord(s[i]) - 97
    tt = ord(t[i]) - 97
    
    if a[ts] == 0:
        a[ts] = max(a) + 1
    if b[tt] == 0:
        b[tt] = max(b) + 1
        
    if a[ts] != b[tt]:
        fl = "No"
        
print(fl)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

    dict_st = {}
    dict_ts = {}

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

        if t not in dict_ts:
            dict_ts[t] = s
        else:
            if dict_ts[t] != s:
                print("No")
                break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

def normalized(S):
    m_set = list()
    for moji in S:
        if moji not in m_set:
            m_set.append(moji)
    m_dic = {m : i for i, m in enumerate(m_set)}
    ad_list = [m_dic[moji] for moji in S]

    return ad_list

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

Submission status: Accepted

Solution code:
def norm_s(S):
    num = 97
    al_dict = {}
    new = ''
    for i, moji in enumerate(S):
        if moji not in al_dict:
            al_dict[moji] = i
            new += chr(num)
            num += 1
        else:
            new += new[al_dict[moji]]
    
    return new

S = input()
T = input()

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

Submission status: Accepted

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

#ad_list = [[] for i in range(26)]
#ad_list2 = [[] for i in range(26)]
num = 97
al_dict = {}
al_dict2 = {}
new = ''
new2 = ''
for i, moji in enumerate(S):
    if moji not in al_dict:
        al_dict[moji] = i
        new += chr(num)
        num += 1
    else:
        new += new[al_dict[moji]]

num = 97

for i, moji in enumerate(T):
    if moji not in al_dict2:
        al_dict2[moji] = i
        new2 += chr(num)
        num += 1
    else:
        new2 += new2[al_dict2[moji]]

if new==new2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def ad_list_gen(S):
    l = len(S)
    ad_list = [[] for i in range(l)]
    al_dict = {}

    for i, moji in enumerate(S):
        if moji not in al_dict:
            al_dict[moji] = i
        else:
            ad_list[al_dict[moji]].append(i)
    
    return ad_list

S = input()
T = input()

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

Submission status: Accepted

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

l = len(S)

ad_list = [[] for i in range(l)]
ad_list2 = [[] for i in range(l)]

al_dict = {}
al_dict2 = {}

for i, moji in enumerate(S):
    if moji not in al_dict:
        al_dict[moji] = i
    else:
        ad_list[al_dict[moji]].append(i)

for i, moji in enumerate(T):
    if moji not in al_dict2:
        al_dict2[moji] = i
    else:
        ad_list2[al_dict2[moji]].append(i)

if ad_list==ad_list2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#String Transformation
import string

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

    dict_s = dict()
    dict_t = dict()
    for c in string.ascii_lowercase:
        dict_s[c] = []
        dict_t[c] = []

    for i, _s in enumerate(s):
        dict_s[_s].append(i)
    for i, _t in enumerate(t):
        dict_t[_t].append(i)
    
    is_ans = True
    for _dict_s in dict_s.values():
        if _dict_s not in dict_t.values():
            is_ans = False
            break

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
alp = 'abcdefghijklmnopqrstuvwxyz'

def f(s):
  new_s = ''
  i = 0
  is_used = [-1]*26
  for si in s:
    idx = ord(si) - 97
    if is_used[idx] < 0:
      is_used[idx] = i
      new_s += alp[i]
      i += 1
    else:
      new_s += alp[is_used[idx]]
  return new_s


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

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    start = [-1 for _ in range(26)]
    goal  = [-1 for _ in range(26)]
    
    for i in range(len(S)):
        fr = ord(S[i]) - ord('a')
        to = ord(T[i]) - ord('a')
        
        if (start[fr] != -1) or (goal[to] != -1):
            if (start[fr] != to) or (goal[to] != fr):
                print('No')
                return
        else:
            start[fr] = to
            goal[to]  = fr

    print('Yes')
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

map_s = [-1] * 26
map_t = [-1] * 26
for cs, ct in zip(s, t):
    if map_s[ord(cs)-97] < 0:
        map_s[ord(cs)-97] = ord(ct)
    else:
        if map_s[ord(cs)-97] != ord(ct):
            print('No')
            break
    if map_t[ord(ct)-97] < 0:
        map_t[ord(ct)-97] = ord(cs)
    else:
        if map_t[ord(ct)-97] != ord(cs):
            print('No')
            break
else:
    print('Yes')

Submission status: Accepted

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

ds = {}
dt = {}

ret = True
for i in range(len(s)):
  cs = s[i]
  ct = t[i]
  ccs = ds.get(cs, 0)
  cct = dt.get(ct, 0)
  if ccs == 0:
      ds[cs] = ct
  elif ccs == ct:
      pass
  else:
      ret = False
      break
  
  if cct == 0:
      dt[ct] = cs
  elif cct == cs:
      pass
  else:
      ret = False
      break

if ret == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
t = input()
s_idx = [[] for _ in range(26)]
t_idx = [[] for _ in range(26)]
for i in range(len(s)):
    s_idx[ord(s[i])-97].append(i)
visit = []
for i in range(26):
    cnt = 0
    for j in s_idx[i]:
        if cnt == 0 and t[j] in visit:
            print("No")
            exit()
        if cnt == 0:
            visit.append(t[j])
            cnt += 1
        else:
            if t[j] != visit[-1]:
                print("No")
                exit()
print("Yes")

Submission status: Accepted

Solution code:
#ABC110C
from collections import Counter
s=[i for i in input()]
t=[i for i in input()]
S=Counter(s)
T=Counter(t)
if sorted(S.values())==sorted(T.values()):
    print("Yes")
else:print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter

s = [i for i in input()]
t = [i for i in input()]

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
T = input()
d1 = defaultdict(int)
d2 = defaultdict(int)
for i in range(len(S)):
    d1[S[i]] += 1
    d2[T[i]] += 1
tmp_1 = list(d1.values())
tmp_2 = list(d2.values())
tmp_1.sort()
tmp_2.sort()
if tmp_1==tmp_2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

s2 = []
t2 = []

sdic = {}
tdic = {}

cnt = 0
for c in s:
    if c in sdic:
        s2.append(sdic[c])
    else:
        s2.append(cnt)
        sdic[c] = cnt
        cnt += 1

cnt = 0
for c in t:
    if c in tdic:
        t2.append(tdic[c])
    else:
        t2.append(cnt)
        tdic[c] = cnt
        cnt += 1

print("Yes" if s2 == t2 else "No")

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    S = input()
    T = input()
    s = sorted(Counter(S).values())
    t = sorted(Counter(T).values())
    return 'Yes' if s == t else 'No'

print(main())

Submission status: Accepted

Solution code:
s = input()
t = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'
dic_s = {}
dic_t = {}
for i in alpha:
    dic_s[i] = 0
    dic_t[i] = 0
for i, j in zip(s, t):
    dic_s[i] += 1
    dic_t[j] += 1
val_s = sorted(dic_s.values())
val_t = sorted(dic_t.values())
ans = 'Yes'
for i, j in zip(val_s, val_t):
    if i != j:
        ans = 'No'
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
N = len(S)
L = [[0]*2 for i in range(N)]

for i in range(N):
    L[i][0] = S[i]
    L[i][1] = T[i]

L.sort()

#print(L)

now = L[0][1]
for i in range(1,N):
    if L[i][0] == L[i-1][0]:
        if L[i][1] != now:
            print("No")
            break
    else:
        now = L[i][1]
else:
    for i in range(N):
        L[i][0] = T[i]
        L[i][1] = S[i]

    L.sort()

    #print(L)

    now = L[0][1]
    for i in range(1,N):
        if L[i][0] == L[i-1][0]:
            if L[i][1] != now:
                print("No")
                break
        else:
            now = L[i][1]
    else:
        print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict
def main():
    d1 = defaultdict(int)
    d2 = defaultdict(int)
    for s in input():
        d1[s] += 1
    for t in input():
        d2[t] += 1
    S = sorted(d1.values())
    T = sorted(d2.values())
    if S == T:
        print('Yes')
    else:
        print('No')
    #初期状態で異なる二文字を同一の文字に置換することはできないので、
    #変形可能な場合、Sに含まれる同一の文字の個数とTに含まれる同一の文字の個数は一致する。
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import Counter
S = input()
T = input()
s = Counter(S)
t = Counter(T)
if len(s) != len(t):
    print('No')
else:
    flag = True
    d = defaultdict(int)
    for i in range(len(S)):
        if d[S[i]] == 0:
            d[S[i]] = T[i]
        else:
            if d[S[i]] != T[i]:
                flag = False
    if flag:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
match = [0] * 26
for i in range(len(s)):
    if match[ord(s[i])-97] == 0:
        match[ord(s[i])-97] = t[i]
    if match[ord(s[i])-97] != t[i]:
        print('No')
        break
else:
    for i in match:
        if i != 0 and match.count(i) != 1:
            print('No')
            break
    else: print('Yes')

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
n = len(s)
atoz = [chr(i) for i in range(97, 97+26)]
rs = [-1]*26
rt = [-1]*26
for i in range(n):
  if rs[atoz.index(s[i])] != -1 or rt[atoz.index(t[i])] != -1:
    if rs[atoz.index(s[i])] != t[i] or rt[atoz.index(t[i])] != s[i]:
      print("No")
      break
  else:
    rs[atoz.index(s[i])] = t[i]
    rt[atoz.index(t[i])] = s[i]
else:
  print("Yes")

Submission status: Accepted

Solution code:

def submit():
    s = input().strip()
    t = input().strip()

    # 変換ペアを作成した際に
    # 変換先/変換元が重複していなければOK
    check_s = {}
    check_t = {}
    for se, te in zip(s, t):
        if se in check_s.keys() and check_s[se] != te:
            print("No")
            return
        else:
            check_s[se] = te
        
        if te in check_t.keys() and check_t[te] != se:
            print("No")
            return
        else:
            check_t[te] = se
        
    print("Yes")


if __name__ == "__main__":
    submit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
alp = "abcdefghijklmnopqrstuvwxyz"
for i in range(0,min(len(S),len(alp)*2)):
  if S[i] != T[i]:
    S = S.translate(str.maketrans({S[i]:T[i], T[i]:S[i]}))
  else:
    pass
  if S == T:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
s=list(input())
t=list(input())
for al in ["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"]:
    num=[nu for nu,chra in enumerate(s) if chra==al]
    if len(set([t[i] for i in num])) >=2:
        print("No")
        exit()
for al in ["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"]:
    num=[nu for nu,chra in enumerate(t) if chra==al]
    if len(set([s[i] for i in num])) >=2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
def index(L,x):
    return [i for i, l in enumerate(L) if l == x]
def check(S, T):
    now = 'a'
    for i in range(26):
        ind = index(S, now)
        if ind:
            x = ind[0]
            t = T[x]
            for i in ind:
                if  t != T[i]:
                    print('No')
                    exit()
        now = chr(ord(now)+1)
def main():
    S = input()
    T = input()
    check(S,T)
    check(T,S)
    print('Yes')
main()

Submission status: Accepted

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

r1 = [-1] * 26
r2 = [-1] * 26

for i in range(len(s)):
    ss = ord(s[i]) - 97
    tt = ord(t[i]) - 97
    if r1[ss] >= 0:
        if r1[ss] != tt:
            print("No")
            exit()
    if r2[tt] >= 0:
        if r2[tt] != ss:
            print("No")
            exit()
    if r1[ss] < 0:
        r1[ss] = tt
    if r2[tt] < 0:
        r2[tt] = ss

print("Yes")

Submission status: Accepted

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

    ds, dt = {}, {}
    for cs, ct in zip(s, t):
        if (ds.get(cs) is not None and ds.get(cs) != ct) \
                or (dt.get(ct) is not None and dt.get(ct) != cs):
            print('No')
            exit()

        ds[cs] = ct
        dt[ct] = cs

    print('Yes')

if __name__ == "__main__":
    main()

Submission status: Accepted

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

tran = [i for i in range(97,123)]

for i in range(len(S)) :
    Si = ord(S[i])-97
    Ti = ord(T[i])-97
    if tran[Si] == Ti :
        continue
    elif tran[Si] > 90 :
        tran[Si] = Ti
    else :
        print("No")
        exit()

if len(set(tran)) == len(tran) :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict

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

Sm=defaultdict(str)
Tm=defaultdict(str)

for s,t in zip(S,T):
    if (Sm[s] and Sm[s]!=t) or (Tm[t] and Tm[t]!=s): print('No'); exit()
    else: Sm[s]=t; Tm[t]=s
print('Yes')

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()

def main():
    S = list(input())
    T = list(input())

    memo = defaultdict(lambda: defaultdict(str))

    for s, t in zip(S, T):
        for key, (a, b) in {'s': (s, t), 't': (t, s)}.items():
            if memo[key][a] and memo[key][a] != b:
                print('No')
                exit()
            else:
                memo[key][a] = b
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()

def main():
    S = list(input())
    T = list(input())

    S_memo = defaultdict(str)
    T_memo = defaultdict(str)

    for s, t in zip(S, T):
        if (S_memo[s] and S_memo[s] != t) or (T_memo[t] and T_memo[t] != s):
            print('No')
            exit()
        else:
            S_memo[s] = t
            T_memo[t] = s
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter


def f(V):
    V = sorted(list(map(str, Counter(V).values())))
    return ''.join(V)


S = input()
T = input()
ans = 'Yes' if f(S) == f(T) else 'No'
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
S,T = set(s),set(t)
sl = []
tl = []
for i in S:
    sl.append([j for j, x in enumerate(s) if x == i])

for i in T:
    tl.append([j for j, x in enumerate(t) if x == i])

if sorted(sl)==sorted(tl):print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
from collections import Counter
S=input()
T=input()
cS=Counter(S).most_common()
cT=Counter(T).most_common()

for k,j in zip(cS,cT):
    if(k[1]!=j[1]):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
dic = {}
flg = 'Yes'
for i in range(len(s)):
    if s[i] in dic.keys():
        if dic[s[i]] != t[i]:
            flg = 'No'
    else:
        dic[s[i]] = t[i]
dic2 = {}
for i in range(len(s)):
    if t[i] in dic2.keys():
        if dic2[t[i]] != s[i]:
            flg = 'No'
    else:
        dic2[t[i]] = s[i]
#print(dic)
print(flg)

Submission status: Accepted

Solution code:
from collections import Counter

print('Yes' if sorted(list(Counter(input()).values())) == 
       sorted(list(Counter(input()).values())) else 'No')

Submission status: Accepted

Solution code:
s = input()
t = input()
d = {}
for si, ti in zip(s, t):
    if si in d and d[si] != ti:
        print('No')
        exit()
    d[si] = ti
l = len(set(d.values()))
print('Yes' if len(d) == l else 'No')

Submission status: Accepted

Solution code:
s = input()
t = input()
d = {}
for si, ti in zip(s, t):
    if si in d:
        if d[si] != ti:
            print('No')
            exit()
    else:
        d[si] = ti
l = len(set(d.values()))
print('Yes' if len(d) == l else 'No')

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    S=input()
    T=input()
    X=[]
    Y=[]
    flag=True
    for i in range(len(S)):
        al=False
        if T[i] in Y:
            al=True
            if X[Y.index(T[i])]!=S[i]:
                flag=False
                break
        if S[i] in X:
            al=True
            if Y[X.index(S[i])]!=T[i]:
                flag=False
                break
        if al==False:
            X.append(S[i])
            Y.append(T[i])
    if flag:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

S = tuple(input())
T = tuple(input())

# S->T と T->S の変換表
s_to_t = defaultdict(set)
t_to_s = defaultdict(set)
for s,t in zip(S,T):
    s_to_t[s].add(t)
    t_to_s[t].add(s)


# 1対1対応しているか
flag = True
for v in s_to_t.values():
    if len(v) > 1:
        flag = False
for v in t_to_s.values():
    if len(v) > 1:
        flag = False

# print
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

s_to_t = defaultdict(set)
t_to_s = defaultdict(set)

for s, t in zip(S, T):
    s_to_t[s].add(t)
    t_to_s[t].add(s)

for v in s_to_t.values():
    if len(v) > 1:
        print("No")
        exit()
for v in t_to_s.values():
    if len(v) > 1:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
s=input()
t=input()
ds=dd(int)
dt=dd(int)
for ss in s:
    ds[ss]+=1
for tt in t:
    dt[tt]+=1
# print(ds)
# print(dt)
ls,lt=[],[]
for k,v in ds.items():
    ls.append(v)
for k,v in dt.items():
    lt.append(v)
# print(ls)
# print(lt)
ls.sort()
lt.sort()
for a,b in zip(ls,lt):
    if a!=b:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
s = str(input())
t = str(input())
l = len(s)
tmp = [[], []]
for i in range(l):
    if (not s[i] in tmp[0]) and (not t[i] in tmp[1]):
        tmp[0].append(s[i])
        tmp[1].append(t[i])
    else:
        if s[i] in tmp[0]:
            tmp2 = 0
            for j in range(len(tmp[0])):
                if s[i] == tmp[0][j]:
                    tmp2 = j
            if t[i] != tmp[1][tmp2]:
                print('No')
                sys.exit()
        else:
            print('No')
            sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

S = input()[:-1]
T = input()[:-1]
d = {}

for i in range(len(S)):
    if S[i] not in d:
        d[S[i]] = T[i]
    else:
        if d[S[i]]!=T[i]:
            print('No')
            exit()

d = {}

for i in range(len(T)):
    if T[i] not in d:
        d[T[i]] = S[i]
    else:
        if d[T[i]]!=S[i]:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
def main():
    S=input()
    T=input()
    di_S=dict()
    di_T=dict()
    for i in range(len(S)):
        if S[i] not in di_S:
            di_S[S[i]]=1
        else:
            di_S[S[i]]+=1
        if T[i] not in di_T:
            di_T[T[i]]=1
        else:
            di_T[T[i]]+=1
    li_S=sorted(di_S.values())
    li_T=sorted(di_T.values())

    flag=True
    for i in range(len(li_S)):
        if li_S!=li_T:
            flag=False
            print("No")
            break
    if flag:
        print("Yes")
if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

cant = 0
sr = [0]*26
tr = [0]*26
for i in range(len(s)):
        x = ord(s[i]) - ord('a')
        y = ord(t[i]) - ord('a')
        if s[i]!=t[i]:
                if sr[x]!=0 and sr[x]!=t[i] or tr[y]!=0 and tr[y]!=s[i]: cant = 1
        sr[x] = t[i]
        tr[y] = s[i]
print("YNeos"[cant::2])