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

s = input()
t = input()
c1 = collections.Counter(s)
c2 = collections.Counter(t)
s_values = sorted(list(c1.values()))
t_values = sorted(list(c2.values()))

if len(s) == len(t):
  if len(list(set(s))) == len(list(set(t))):
    if s_values == t_values:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
T = input()
s = defaultdict(int)
t = defaultdict(int)
for c in S:
    s[c] += 1
for c in T:
    t[c] += 1
sv = sorted(s.values())
tv = sorted(t.values())
if sv == tv:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S=input()
T=input()
Skey=sorted(set(S),key=S.index)
Tkey=sorted(set(T),key=T.index)

for index,i in enumerate(Skey):
  S=S.replace(i,str(index))
for index,i in enumerate(Tkey):
  T=T.replace(i,str(index))

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

Submission status: Accepted

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

Skey = sorted(set(S),key=S.index)
Tkey = sorted(set(T),key=T.index)

for idx,i in enumerate(Skey):
  S = S.replace(i,str(idx))
for idx,i in enumerate(Tkey):
  T = T.replace(i,str(idx))

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

Submission status: Accepted

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

s = list(input())
t = list(input())

s.sort()
t.sort()

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

s = array_count(s)
t = array_count(t)

def get_item_1 (arr):
    newarr = []
    for i in range(len(arr)):
        newarr.append(arr[i][1])
    return newarr

s = get_item_1(s)
t = get_item_1(t)

s.sort()
t.sort()

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

Submission status: Accepted

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

def hoge(text):
    assign = {}
    result = []
    for c in text:
        if c not in assign:
            assign[c] = len(assign)
        result.append(assign[c])
    return result

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

Submission status: Accepted

Solution code:
def main():
    Sdict = {}
    Tdict = {}
    S = list(input())
    T = list(input())
    for i in S:
        if i in Sdict.keys():
            Sdict[i] += 1
        else:
            Sdict[i] = 1
    for i in T:
        if i in Tdict.keys():
            Tdict[i] += 1
        else:
            Tdict[i] = 1
    if sorted(list(Sdict.values())) == sorted(list(Tdict.values())):
        print("Yes")
    else:
        print("No")

main()

Submission status: Accepted

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

s_c = []
t_c = []
for c in 'abcdefghijklmnopqrstuvwxyz':
    s_c.append(s.count(c))
    t_c.append(t.count(c))
s_c.sort()
t_c.sort()
if s_c == t_c:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

s_counter = []
t_counter = []
for c in 'abcdefghijklmnopqrstuvwxyz':
    s_counter.append(s.count(c))
    t_counter.append(t.count(c))

s_counter.sort()
t_counter.sort()

ans = 'Yes' if s_counter == t_counter else 'No'
print(ans)

Submission status: Accepted

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

sl = [0]*26
tl = [0]*26

for temp in S:
    tn = ord(temp) - ord("a")
    sl[tn] += 1

for temp in T:
    tn = ord(temp) - ord("a")
    tl[tn] += 1

sl.sort()
tl.sort()

ans = "Yes"
for n in range(26):
    if sl[n] == tl[n]:
        continue
    else:
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
import collections
S = list(input())
T = list(input())
S_c = sorted(collections.Counter(S).items(),key=lambda x:x[1])
T_c = sorted(collections.Counter(T).items(),key=lambda x:x[1])

if len(S_c) == len(T_c):
  for i in range(len(S_c)):
    if S_c[i][1] != T_c[i][1]:
      print('No')
      exit()
  else:
    print('Yes')
      
else:
  print('No')

Submission status: Accepted

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

StoT = {}
TtoS = {}

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

Submission status: Accepted

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

Skey = sorted(set(S),key=S.index)
Tkey = sorted(set(T),key=T.index)

for idx,i in enumerate(Skey):
  S = S.replace(i,str(idx))
for idx,i in enumerate(Tkey):
  T = T.replace(i,str(idx))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = [c for c in input()]
T = [c for c in input()]

def main():
    z = zip(S, T)
    s = set(z)
    unpacked = list(zip(*s))
    
    ans = [len(set(t)) == len(t) for t in unpacked]
    print('Yes' if all(ans) else 'No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

if sorted(sc.values()) == sorted(tc.values()):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

def fix(T,S):
    l = [[] for _ in range(26)]
    for k, c in enumerate([chr(ord("a") + i) for i in range(26)]):
        for i,t in enumerate(T):
            if t == c:
                l[k].append(i)

    for a in l:
        if len(a) <= 1:
            continue
        prop = S[a[0]]
        for i in a:
            if prop != S[i]:
                print("No")
                exit()

fix(T,S)
fix(S,T)

print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter as C
print(["No", "Yes"][C(C(input()).values()) == C(C(input()).values())])

Submission status: Accepted

Solution code:
import sys
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)


S = C(IS())
T = C(IS())
sv = sorted([v for v in S.values()])
tv = sorted([v for v in T.values()])
P('Yes') if sv == tv else P('No')  # これはうそ S = 'zazel' T = 'apple'でダメ

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

s = list(Counter(S).values())
t = list(Counter(T).values())
s.sort(reverse=True)
t.sort(reverse=True)

for i,j in zip(s,t):
    if i != j:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

f = lambda c,l:[i for i,x in enumerate(l) if c == x]

sc = []
ts = []
for s,t in zip(S,T):
	if not s in sc:
		sc.append(s)
		sind = f(s,S)
		tind = f(t,T)
		if sind != tind:
			print("No")
			exit()
print("Yes")

Submission status: Accepted

Solution code:
'''
考え方

なんらかの文字列IDを降って、指定した位置の文字の文字列IDが完全一致していること。
（アルファベットが何か、は関係ないので考慮しなくても良い）

なので、同一アルファベットがどの位置にあるか、というのが一致していればOK。

辞書型の変数を持つ。キーは「Sの文字列ID」、値は「その文字列IDが出現する位置」
'''


S = input()
T = input()
len_S = len(S)
len_T = len(T)

dict_s = {}
dict_t = {}
alphabets = 'abcdefghijklmnopqrstuvwxyz'

# INPUTの文字列ごとに、出現位置を辞書に格納する
for alphabet in alphabets:
  cnt = S.count(alphabet)
  if cnt == 0:
    continue
  else:
    dict_s[alphabet] = [i for i, x in enumerate(S) if x == alphabet]


# OUTPUTでも同じことをする
for alphabet in alphabets:
  cnt = T.count(alphabet)
  if cnt == 0:
    continue
  else:
    dict_t[alphabet] = [i for i, x in enumerate(T) if x == alphabet]


# 突合
dict_used = {}
cnt = 0
for key_src, value_src in dict_s.items():
  for key_trg, value_trg in dict_t.items():
    if value_src == value_trg and key_src not in dict_used:
      dict_used[key_src] = 1
      cnt += 1
      break


if len(dict_s) == cnt:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def main():
    S = input()
    sa = [-1]*len(S)
    T = input()
    ta = [-1]*len(T)
    dict_s = {}
    dict_t = {}
    for index, c in enumerate(S):
        if not (c in dict_s.keys()):
            dict_s[c] = len(dict_s.keys())
        sa[index] = dict_s[c]
    for index, c in enumerate(T):
        if not (c in dict_t.keys()):
            dict_t[c] = len(dict_t.keys())
        ta[index] = dict_t[c]
    for i in range(len(sa)):
        if sa[i] != ta[i]:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
S, T = "", ""


def set_inputs():
    global S, T
    S = get_str()
    T = get_str()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    mapper = dict()
    inverser = dict()
    for s, t in zip(S, T):
        m = mapper.get(s, None)
        if m and m != t:
            print("No")
            return
        mapper[s] = t
        i = inverser.get(t, None)
        if i and i != s:
            print("No")
            return
        inverser[t] = s
    print("Yes")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
set_s=sorted(set(s),key=s.index)
set_t=sorted(set(t),key=t.index)
s_dic={}
t_dic={}
k=0
for i in set_s:
    s_dic[i]=k
    k+=1
k=0
for i in set_t:
    t_dic[i]=k
    k+=1
flg=0
for a,b in zip(s,t):
    if s_dic[a]!=t_dic[b]:
        flg=1
if flg==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys

S = input()
T = input()
dic1 = defaultdict(str)
dic2 = defaultdict(str)

for x, y in zip(S, T):
    if not x in dic1:
        dic1[x] = y
    if not y in dic2:
        dic2[y] = x
    if x in dic1:
        if dic1[x] != y:
            print('No')
            sys.exit()
    if y in dic2:
        if dic2[y] != x:
            print('No')
            sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
small=list('abcdefghijklmnopqrstuvwxyz')
A=[0]*26
B=[0]*26
s=input()
t=input()
for i in range(26):
  A[i]=s.count(small[i])
  B[i]=t.count(small[i])
for i in range(len(s)):
  if A[small.index(s[i])]!=B[small.index(t[i])]:
    print('No')
    exit()
  else:
    A[small.index(s[i])]=-i-1
    B[small.index(t[i])]=-i-1
print('Yes')

Submission status: Accepted

Solution code:
S = input()
T = input()
s, t = [], []
for alp in "abcdefghijklmnopqrstuvwxyz":
  s.append(S.count(alp))
  t.append(T.count(alp))
s.sort()
t.sort()
if s == t:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#coding: utf-8
S = list(input())
T = list(input())
alpha = [chr(i) for i in range(97, 97+26)]
Sl = [0 for _ in range(26)]
Tl = [0 for _ in range(26)]
for i in range(len(alpha)):
    tmp = alpha[i]
    Sl[i] = S.count(tmp)
    Tl[i] = T.count(tmp)
Sl.sort()
Tl.sort()
print("Yes" if Sl==Tl else "No")

Submission status: Accepted

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

subs = {}
for s,t in zip(S,T):
    c = subs.get(s,t)
    if c == t:
        subs[s] = t
    else:
        print("No")
        break
else:
    if len(subs.values())-len(set(subs.values())) == 0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
S = input()
T = input()
alp = [chr(ord('a') + i) for i in range(26)]
kanri = [0]*26
flag = True
for i in range(len(S)):
  x = S[i]
  f = ord(x)-97
  if kanri[f] == 0:
    kanri[f] = T[i]
  else:
    if kanri[f] != T[i]:
      flag = False
      break
if flag:
  P = []
  for i in range(26):
    if kanri[i] != 0:
      P.append(kanri[i])
  Q = list(set(P))
  if len(Q) == len(P):
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
A = list(input())
B = list(input())
dicB = {}
dicA = {}
for i in range(len(A)):
    dicB.setdefault(B[i],A[i])
    dicA.setdefault(A[i],B[i])
    #print(dicB)
    #print(dicA)
    if dicB.get(B[i]) != A[i] or dicA.get(A[i]) != B[i]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import*
s=enumerate(input())
t=enumerate(input())
d1=defaultdict(list)
d2=defaultdict(list)
for k,v in s:
    d1[v].append(k)
for k,v in t:
    d2[v].append(k)
print(["No","Yes"][set(tuple(i)for i in d1.values())==set(tuple(i)for i in d2.values())])

Submission status: Accepted

Solution code:
def solve():
  query = 'abcdefghijklmnopqrstuvwxyz'
  squery = [0]*26
  tquery = [0]*26
  s = input()
  t = input()
  for i in range(26):
    tp = query[i]
    squery[i] = s.count(tp)
    tquery[i] = t.count(tp)
  squery.sort()
  tquery.sort()
  
  if squery == tquery : return 'Yes'
  else: return 'No'
    
  
print(solve())

Submission status: Accepted

Solution code:
S = input()
T = input()
li_S = [-1]*26
li_T = [-1]*26


for i in range(len(S)):
    li_S[ord(S[i])-97]=i if li_S[ord(S[i])-97]==-1 else li_S[ord(S[i])-97]
    li_T[ord(T[i])-97]=i if li_T[ord(T[i])-97]==-1 else li_T[ord(T[i])-97]


flag = True
for i in range(len(S)):
    if(li_S[ord(S[i])-97]!=li_T[ord(T[i])-97]):
        flag = False

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

Submission status: Accepted

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

dict1, dict2 = {}, {}

for i in list(S):
    dict1[i] = dict1.get(i, 0) + 1

for i in list(T):
    dict2[i] = dict2.get(i, 0) + 1


if sorted(dict1.values()) == sorted(dict2.values()) :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

S = Counter(input())
T = Counter(input())
s = sorted([v for v in S.values()])
t = sorted([v for v in T.values()])
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
""" AtCoder """
import collections

S = input()
T = input()

s = {}
t = {}

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

print("Yes")

Submission status: Accepted

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

def create_alphabet_array(s):
  alphabets = []
  list = [-1] * len(s)
  for i, item in enumerate(s):
    if not item in alphabets:
      alphabets.append(item)
    list[i] = alphabets.index(item)
  return list
  
slist = create_alphabet_array(s)
tlist = create_alphabet_array(t)

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

Submission status: Accepted

Solution code:
S, T = [input() for _ in range(2)]
smemo, tmemo = {}, {}
for si, ti in zip(S, T):
    if si in smemo and smemo[si] != ti or ti in tmemo and tmemo[ti] != si:
        print("No")
        quit()
    smemo[si], tmemo[ti] = ti, si
print("Yes")

Submission status: Accepted

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

sts = [set([]) for _ in range(26)]
rsts = [set([]) for _ in range(26)]

for i in range(len(S)):
    a = ord(S[i])-ord('a')
    b = ord(T[i])-ord('a')
    sts[a].add(b)
    rsts[b].add(a)

res=True
for st in sts:
    if res and len(st)>1:
        print('No')
        res=False
for st in rsts:
    if res and len(st)>1:
        print('No')
        res=False
if res:
    print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter

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

if list(map(lambda x: x[1],Counter(S).most_common())) != list(map(lambda x: x[1],Counter(T).most_common())):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = S()
    t = S()
    n = len(s)
    d = defaultdict(list)
    for i in range(n):
        d[s[i]].append(t[i])
    d2 = defaultdict(list)
    for i in range(n):
        d2[t[i]].append(s[i])
    for i in d.keys():
        k = d[i]
        k = list(set(d[i]))
        if len(k) > 1:
            print("No")
            quit()
    for i in d2.keys():
        k = d2[i]
        k = list(set(d2[i]))
        if len(k) > 1:
            print("No")
            quit()
    print("Yes")
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()

Submission status: Accepted

Solution code:
s = input()
t = input()
sUsed = ""
tUsed = ""
buf = []
flag = 0
while len(s) > 0 and len(t) > 0:
    s0 = s[0]
    t0 = t[0]
    sUsed += s0
    buf = [i for i,x in enumerate(s) if x == s0]
    s = s.replace(s0,"")
    if t0 in tUsed and len(tUsed) > 0:
        flag = 1
    if not buf == [i for i,x in enumerate(t) if x == t0]:
        flag = 1
    tUsed += t0
    t = t.replace(t0,"")
    buf.clear()
    if flag == 1:
        break
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

baseb = list("abcdefghijklmnopqrstuvwxyz")

N = 0


def solve(S: str, T: str):
    from collections import Counter

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

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


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def c():
    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 not start[a] == -1 or not goal[b] == -1:
            if not start[a] == b or not goal[b] == a:
                print("No")
                return 0
        else:
            start[a] = b
            goal[b] = a

    print("Yes")


c()

Submission status: Accepted

Solution code:
s = list(str(input()))
t = list(str(input()))
s_dict = {}
count = 0
for s_ in s:
    if s_ not in s_dict.keys():
        s_dict[s_] = count
        count += 1
t_dict = {}
count = 0
for t_ in t:
    if t_ not in t_dict.keys():
        t_dict[t_] = count
        count += 1
s = [s_dict[i] for i in s]
t = [t_dict[i] for i in t]
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=input()
T=input()
R=[-1]*26
R2=[-1]*26
flag=1

for i in range(len(S)):
    a=ord(S[i])-97
    b=ord(T[i])-97
    if R[a]!=-1 or R2[b]!=-1:
        if R[a]!=b or R2[b]!=a:
            flag=0
            break
    else:
        R[a]=b
        R2[b]=a
if flag==0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s=input()
t=input()
ds={}
dt={}
#l=[]
q=0
for i in range(len(s)):
    #d[s[i]]=t[i]
    if s[i] in ds.keys():
        if ds[s[i]]!=t[i]:
            q=1
            print("No")
            break
    else:
        #if s[i]==t[i]:
        #    l.append(t[i])
        #    ds[s[i]]=t[i]
        #else:
        #    ds[s[i]]=t[i]
        ds[s[i]]=t[i]
    if t[i] in dt.keys():
        if dt[t[i]]!=s[i]:
            q=1
            print("No")
            break
    else:
        dt[t[i]]=s[i]
#浮気してないか
if q==0:
    print("Yes")

Submission status: Accepted

Solution code:
import collections
S = [i for i in input()]
T = [i for i in input()]
Scount = collections.Counter(S)
Tcount = collections.Counter(T)
check = True
for (s,t) in zip(Scount.most_common(),Tcount.most_common()):
    if s[1]!=t[1]:
        check = False
        break
if check == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def solve(S, T):
    StoT = {}
    TtoS = {}
    for s, t in zip(S, T):
        if s not in StoT:
            StoT[s] = t
        if t not in TtoS:
            TtoS[t] = s
        
        if StoT[s] != t or TtoS[t] != s:
            return False

    return True
        


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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys

S = [x for x in input()]
T = [x for x in input()]

chars = dict([(c, i) for i, c in enumerate('abcdefghijklmnopqrstuvwxyz')])

match_chars = [[] for _ in range(26)]
for s, t in zip(S, T):
    match_chars[chars[s]].append(t)

for match_char in match_chars:
    if len(set(match_char)) > 1:
        print('No')
        sys.exit()
        
match_chars = [[] for _ in range(26)]
for s, t in zip(S, T):
    match_chars[chars[t]].append(s)

for match_char in match_chars:
    if len(set(match_char)) > 1:
        print('No')
        sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
S_dict = {}
T_dict = {}
S_dict[S[0]] = 1
T_dict[T[0]] = 1
for i in range(1, len(S)):
    s, t = S[i], T[i]
    if s in S_dict.keys():
        if t in T_dict.keys():
            if S_dict[s] == T_dict[t]:
                S_dict[s] += 1
                T_dict[t] += 1
            else:
                print('No')
                quit()
        else:
            print('No')
            quit()
    else:
        if t in T_dict.keys():
            print('No')
            quit()
        else:
            S_dict[s] = 1
            T_dict[t] = 1

if len(S_dict) == len(T_dict):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


def solve(s, t):
  tr_s = {} # s -> t
  tr_t = {} # t -> s
  for i in range(len(s)):
    if t[i] not in tr_t:
      tr_t[t[i]] = s[i]
    if s[i] not in tr_s:
      tr_s[s[i]] = t[i]

    if (tr_s[s[i]] != t[i]) or (tr_t[t[i]] != s[i]):
      return False

  return True


S = str(input())
T = str(input())
if solve(S, T):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

s_to_t = {}
t_to_s = {}
enable = True
for i in range(len(s)):
    char_s = s[i]
    char_t = t[i]
    if char_s in s_to_t and char_t != s_to_t[char_s]:
        enable = False
        break
    if char_t in t_to_s and char_s != t_to_s[char_t]:
        enable = False
        break
    s_to_t[char_s] = char_t
    t_to_s[char_t] = char_s

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

Submission status: Accepted

Solution code:
S=input()
T=input()
fr=[s for s in S] 
to=[t for t in T]
N=len(fr)
h1=[];h2=[]
error=False
for i in range(N):
    if fr[i]==to[i]:#a,a
        if (fr[i] not in h1) and (to[i] not in h2):
            h1.append(fr[i]);h2.append(to[i])
        elif ((fr[i] in h1) and (to[i] not in h2)) or ((fr[i] not in h1) and (to[i] in h2)):
            error=True
            break;
        else:
            if h1.index(fr[i])==h2.index(to[i]):
                pass
            else:
                error=True
                break;
    else:
        if (fr[i] not in h1) and (to[i] not in h2):
            h1.append(fr[i]);h2.append(to[i])
        elif ((fr[i] in h1) and (to[i] not in h2)) or ((fr[i] not in h1) and (to[i] in h2)):
            error=True
            break;
        else:
            if h1.index(fr[i])==h2.index(to[i]):
                pass
            else:
                error=True
                break;
if error:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

def judge(S,T):
    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")
                break
        else:
            start[a] = b
            goal[b] =a
        if i==len(S)-1:
            print("Yes")
            
judge(s,t)

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
char = []
flag = True
for i in range(len(S)):
    if S[i] != T[i]:
        if (S[i] not in char) and (T[i] not in char):
            table = str.maketrans({S[i]:T[i], T[i]:S[i]})
            S = S.translate(table)
            char.append(T[i])
        else:
            flag = False
            break
    else:
        char.append(T[i])
# print(S)
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter
S=input()
T=input()
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(min(len(d),len(c))):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2 and flag:
        e=[]
        for j in range(len(s)):
            if t[j]==d[i][0]:
                e.append(s[j])
        for j in range(len(e)-1):
            if e[j]!=e[j+1]:
                flag=False
                break
    if c[i][1]>=2 and flag:
        f=[]
        for j in range(len(s)):
            if s[j]==c[i][0]:
                f.append(t[j])
        for j in range(len(f)-1):
            if f[j]!=f[j+1]:
                flag=False
                break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
s = [0]*26
t = [0]*26

dict = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7,
        'i':8, 'j':9, 'k':10, 'l':11, 'm':12, 'n':13, 'o':14,
        'p':15, 'q':16, 'r':17, 's':18, 't':19, 'u':20, 'v':21,
        'w':22, 'x':23, 'y':24, 'z':25}

for i in range(len(S)):
    s[dict[S[i]]] += 1
    t[dict[T[i]]] += 1
s.sort()
t.sort()
print('YNeos'[s!=t::2])

Submission status: Accepted

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

def f(S):
    idx = []
    dic = []
    for s in S:
        if s in dic:
            idx.append(dic.index(s))
        else:
            idx.append(len(dic))
            dic.append(s)
    
    return idx

s_idx = f(S)
t_idx = f(T)
for i in range(len(S)):
    if s_idx[i] != t_idx[i]:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np

S=list(str(input()))
T=list(str(input()))
S_num=dict(Counter(S)).values()
T_num=dict(Counter(T)).values()
S_s=np.array([s for s in S_num])
T_s=np.array([s for s in T_num])

flag=False

if len(S_s)==len(T_s):
    if all(np.sort(S_s)==np.sort(T_s)):
        flag=True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(str(input()))
T = list(str(input()))
check = 1
bij1 = {}
bij2 = {}
for i in range(len(S)):
  if S[i] in bij1 and bij1[S[i]] != T[i]:
    check = 0
    break
  elif T[i] in bij2 and bij2[T[i]] != S[i]:
    check = 0
    break
  elif S[i] not in bij1 and T[i] not in bij2:
    bij1[S[i]] = T[i]
    bij2[T[i]] = S[i]
    
if check:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()
T = input()
s = []
t = []
for alp in "abcdefghijklmnopqrstuvwxyz":
  s.append(S.count(alp))
  t.append(T.count(alp))
if(sorted(s) == sorted(t)):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

import numpy as np
S_num = dict(Counter(S)).values()
T_num = dict(Counter(T)).values()
Ss = np.array([s for s in S_num])
Ts = np.array([s for s in T_num])

if len(Ss) != len(Ts):
    print("No")
else:
    if all(np.sort(Ss)==np.sort(Ts)):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
import collections as c
s=input()
t=input()
d=c.defaultdict(list)
d2=c.defaultdict(list)
for k,v in enumerate(s):
    d[v].append(k)
for k,v in enumerate(t):
    d2[v].append(k)
a=set(tuple(i) for i in d.values())
b=set(tuple(i) for i in d2.values())
if a==b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

s, t = input(), input()
c1 = sorted(Counter(s).values())
c2 = sorted(Counter(t).values())
print('Yes') if c1 == c2 else print('No')