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:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

s = input()
t = input()
f = defaultdict(lambda : None)
for i in range(len(s)):
    si,ti = s[i],t[i]
    if f[si] != None:
        if f[si] != ti:
            print("No")
            quit()
    else:
        f[si] = ti
f = defaultdict(lambda : None)
for i in range(len(s)):
    si,ti = s[i],t[i]
    if f[ti] != None:
        if f[ti] != si:
            print("No")
            quit()
    else:
        f[ti] = si

print("Yes")

Submission status: Accepted

Solution code:
import collections
s = input()
t = input()
s = collections.Counter(s)
t = collections.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())
s=list(S)
t=list(T)
s.sort()
t.sort()
import collections
ss=collections.Counter(s)
tt=collections.Counter(t)
ans=0
a=[]
b=[]
for i in range(len(set(s))):
    a.append(ss.most_common()[i][1])
for i in range(len(set(t))):
    b.append(tt.most_common()[i][1])
if a==b:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections as C
import sys
s = input()
t = input()

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

ans = [0] * len(s)
stock = C.Counter([])
for i in range(len(s)):
    if s[i] not in stock.keys():
        stock[s[i]] = t[i]
    ans[i] = stock[s[i]]

ss = "".join(ans)

print("Yes") if ss == t and len(list(stock.keys())) == len(list(stock.values())) else print("No")

Submission status: Accepted

Solution code:
# 2019/08/16

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

c1={}
c2={}
for ss,tt in zip(s,t):
    if c1.get(ss) is None:
        c1[ss]=tt
    if c2.get(tt) is None:
        c2[tt]=ss
    if c1[ss]==tt and c2[tt]==ss:continue
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
s.sort()
t.sort()
s1={}
t1={}
s1_v=[]
t1_v=[]

for i in s:
    if not i in s1:
        s1[i]=1
    else:
        s1[i]+=1
    
for i in t:
    if not i in t1:
        t1[i]=1
    else:
        t1[i]+=1
        
for v in s1.values():
    s1_v+=[v]  
for v in t1.values():
    t1_v+=[v]  
    
s1_v.sort()
t1_v.sort()

if( s1_v == t1_v ):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict


def solve():
    s = input()
    t = input()
    ds = defaultdict(int)
    for c in s:
        ds[c] += 1
    nums_s = sorted(ds.values())
    dt = defaultdict(int)
    for c in t:
        dt[c] += 1
    nums_t = sorted(dt.values())
    return "Yes" if nums_s == nums_t else "No"


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

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

alp_s = []
alp_t = []
num_s = []
num_t = []
for i in range(len(s)):
    cnt = 0
    for j in alp_s:
        if s[i] == j:
            num_s[cnt] += 1
        cnt += 1
    if not s[i] in alp_s:
        alp_s.append(s[i])
        num_s.append(1)

    cnt = 0
    for j in alp_t:
        if t[i] == j:
            num_t[cnt] += 1
        cnt += 1
    if not t[i] in alp_t:
        alp_t.append(t[i])
        num_t.append(1)
    
    if num_s != num_t:
        print('No')
        quit()
print('Yes')

Submission status: Accepted

Solution code:
alpha2num = lambda c: ord(c) - ord('a') + 1

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

s = S.copy()
t = T.copy()

S_count = [0] * 27
T_count = [0] * 27

for i in range(len(S)):
   S_count[alpha2num(S[i])] += 1
   T_count[alpha2num(T[i])] += 1

S_count.sort()
T_count.sort()

if S_count == T_count:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections

s = input()
t = input()
sn = collections.Counter(s)
tn = collections.Counter(t)

if sorted(sn.values()) == sorted(tn.values()):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
import string

S = input()
T = input()

count1 = [0] * 26
count2 = [0] * 26


for j in range(26):
    count1[j] = S.count(string.ascii_lowercase[j])
    count2[j] = T.count(string.ascii_lowercase[j])

hantei = 1

for i in range(0,len(S)+1):
    count_tmp1 = 0
    count_tmp2 = 0
    for j in range(26):
        if i == count1[j] :
            count_tmp1 += 1
    for j in range(26):
        if i == count2[j] :
            count_tmp2 += 1
    if count_tmp1 != count_tmp2:
        hantei = 0
        break

if hantei == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = input()
dic_s = {}
dic_t = {}
conv_s = []
conv_t = []
cnt_s = 0
cnt_t = 0
ans = "Yes"

for i in range(len(s)):
    if s[i] not in dic_s:
        dic_s[s[i]] = cnt_s
        conv_s.append(dic_s[s[i]])
        cnt_s += 1

    elif s[i] in dic_s:
        conv_s.append(dic_s[s[i]])

    if t[i] not in dic_t:
        dic_t[t[i]] = cnt_t
        conv_t.append(dic_t[t[i]])
        cnt_t += 1
    elif t[i] in dic_t:
        conv_t.append(dic_t[t[i]])
    if conv_s[i] != conv_t[i]:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
import collections
s = input()
s = collections.Counter(s).most_common()
t = input()
t = collections.Counter(t).most_common()
if len(s) == len(t):
    for i in range(len(s)):
        if s[i][1] != t[i][1]:
            print("No")
            exit()
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:


import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()
t = input()

ss = [s.find(c) for c in s]
tt = [t.find(c) for c in t]

print("Yes" if ss == tt else "No")

Submission status: Accepted

Solution code:
s = input()
t = input()
ss = [s.find(i) for i in s]
tt = [t.find(i) for i in t]

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

Submission status: Accepted

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


abc = ["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"]
ls = []
lt = []
for i in range(len(abc)):
    ls.append(s.count(abc[i]))
    lt.append(t.count(abc[i]))
ls.sort()
lt.sort()
ans = "Yes"
if len(ls) == len(lt):
    for i in range(len(ls)):
        if ls[i] != lt[i]:
            ans = "No"
            break
else:
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ss = [s.find(i) for i in s]
tt = [t.find(i) for i in t]
if ss == tt:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

start = {}
goal = {}

for s, t in zip(S, T):
    if start.get(s) and start[s] != t:
        print('No')
        exit()
    if goal.get(t) and goal[t] != s:
        print('No')
        exit()

    start[s] = t
    goal[t] = s

print('Yes')

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

S = input()
T = input()
L = len(S)

# 置換辞書
# 一対一対応になっているか走査する
dds = defaultdict(int)
ddt = defaultdict(int)
for i in range(L):
    # i文字目
    s = S[i]
    t = T[i]
    if dds[s] == 0:
        dds[s] = t
    else:
        if dds[s] != t:
            print("No")
            sys.exit()
    if ddt[t] == 0:
        ddt[t] = s
    else:
        if ddt[t] != s:
            print("No")
            sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = input()
sconv = [-1] * 26
tconv = [-1] * 26
for i in range(len(s)):
    sa = ord(s[i]) - ord('a')
    ta = ord(t[i]) - ord('a')
    if (sconv[sa] > 0 and sconv[sa] != ta) or (tconv[ta] > 0 and tconv[ta] != sa):
        print('No')
        exit()
    sconv[sa] = ta
    tconv[ta] = sa

print('Yes')

Submission status: Accepted

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

countT = {}
countS = {}

for s, t in zip(S, T) :
    if t in countT :
        countT[t].append(s)
    else :
        countT[t] = [s]
    if s in countS :
        countS[s].append(t)
    else :
        countS[s] = [t]

for (_, s), (_, t) in zip(countS.items(), countT.items()) :
    if len(set(s)) >= 2 or len(set(t)) >= 2:
        print('No')
        break
else :
    print('Yes')

Submission status: Accepted

Solution code:
import collections as c
s=c.Counter(input())
t=c.Counter(input())
if sorted(s.values())==sorted(t.values()):
      print('Yes')
else:
      print('No')

Submission status: Accepted

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

A=[]
B=[]
C=[]
D=[]

for i in range(len(S)):
    if A.count(S[i])==0:
        A.append(S[i])
        B.append(T[i])
    else:
        if B[A.index(S[i])]!=T[i]:
            print("No")
            exit(0)

for i in range(len(T)):
    if C.count(T[i])==0:
        C.append(T[i])
        D.append(S[i])
    else:
        if D[C.index(T[i])]!=S[i]:
            print("No")
            exit(0)


print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = input()
ss = []
tt = []
stable = []
ttable = []
scnt = 0
tcnt = 0
for i in range(len(s)):
  for x in stable:
    if s[i] == x[0]:
      ss.append(x[1])
      break
  else:
    scnt += 1
    stable.append([s[i],scnt])
    ss.append(scnt)
for i in range(len(t)):
  for x in ttable:
    if t[i] == x[0]:
      tt.append(x[1])
      break
  else:
    tcnt += 1
    ttable.append([t[i],tcnt])
    tt.append(tcnt)
if ss == tt:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

dict_st = {}
dict_go = {}

for x, y in zip(S,T):
  if x not in dict_st:
    dict_st[x] = y
  elif dict_st[x] != y:
    print("No")
    break
  
  if y not in dict_go:
    dict_go[y] = x
  elif dict_go[y] != x:
      print("No")
      break
else:
  print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

CS = Counter(S).most_common()
CT = Counter(T).most_common()

for XS, XT in zip(CS,CT):
  if XS[1] != XT[1]:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
S = input().upper()
T = input().upper()
alpha2num = lambda c: ord(c) - ord('A') + 1
l = [[]for i in range(26)]
for i in range(len(S)):
    if T[i] not in l[alpha2num(S[i])-1]:
        l[alpha2num(S[i])-1].append(T[i])
l = [len(l[i]) for i in range(len(l))]

if max(l) == 1:
    l = [[] for i in range(26)]
    for i in range(len(T)):
        if S[i] not in l[alpha2num(T[i]) - 1]:
            l[alpha2num(T[i]) - 1].append(S[i])
    l = [len(l[i]) for i in range(len(l))]
    if max(l) == 1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict

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


def check(s, t):
    d = defaultdict(set)
    for i in range(len(s)):
        d[s[i]].add(t[i])
    for v in d.values():
        if len(v) > 1:
            return False
    return True

print('Yes' if check(s, t) and check(t, s) else 'No')

Submission status: Accepted

Solution code:
ss = list(input())
ts = list(input())

def check():
    global ss
    global ts
    d = {}
    for s,t in zip(ss,ts):
        if s in d:
            if d[s] != t:
                return False
        else:
            d[s] = t
    
    ss, ts = ts, ss
    d = {}    
    for s,t in zip(ss,ts):
        if s in d:
            if d[s] != t:
                return False
        else:
            d[s] = t
    return True

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

Submission status: Accepted

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

dic_s = {}
for i in range(len(s)):
    if s[i] not in dic_s.keys():
        dic_s[s[i]] = [i]
    else:
        dic_s[s[i]].append(i)

dic_t = {}
for i in range(len(t)):
    if t[i] not in dic_t.keys():
        dic_t[t[i]] = [i]
    else:
        dic_t[t[i]].append(i)

if sorted(list(dic_s.values())) == sorted(list(dic_t.values())):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()
data1 = [[0] for i in range(2)]
data2 = [[0] for i in range(2)]
for i in range(len(s)):
    if s[i] in data1[0]:
        if not data1[1][data1[0].index(s[i])] == t[i]:
            print("No")
            exit()
    else:
        data1[0].append(s[i])
        data1[1].append(t[i])

for i in range(len(s)):
    if t[i] in data2[0]:
        if not data2[1][data2[0].index(t[i])] == s[i]:
            print("No")
            exit()
    else:
        data2[1].append(s[i])
        data2[0].append(t[i])
print("Yes")

Submission status: Accepted

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

slist = [-1]*26
tlist = [-1]*26

for i in range(len(S)):
	if (slist[ord(S[i])-97] == -1 and tlist[ord(T[i])-97] == -1):
		slist[ord(S[i])-97] = ord(T[i])-97
		tlist[ord(T[i])-97] = ord(S[i])-97
	else:
		if (slist[ord(S[i])-97] != ord(T[i])-97 or tlist[ord(T[i])-97] != ord(S[i])-97):
			print("No")
			exit()
print("Yes")

Submission status: Accepted

Solution code:
import collections

S = input()
T = input()

cs = collections.Counter(S)
ct = collections.Counter(T)


if sorted(ct.values()) == sorted(cs.values()):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = inputs[0]
    T = inputs[1]

    appeared = {}
    appeared_count = {}
    for i, _ in enumerate(S):
        if T[i] in appeared:
            if not appeared[T[i]] == S[i]:
                return "No"
        else:
            appeared[T[i]] = S[i]
            if S[i] in appeared_count:
                appeared_count[S[i]] += 1
            else:
                appeared_count[S[i]] = 1
    for k, v in appeared_count.items():
        if v > 1:
            return "No"
    return "Yes"


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)

Submission status: Accepted

Solution code:
import collections

S = input()
T = input()

cs = collections.Counter(S)
ct = collections.Counter(T)

if sorted(ct.values()) == sorted(cs.values()):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:

s = input()
t = input()

srt = [-1]*26
grl = [-1]*26

for i in range(len(s)):
    n = ord(s[i]) - ord('a')
    m = ord(t[i]) - ord('a')
    
    if srt[n]!=-1 or grl[m] != -1:
        if srt[n] != m or grl[m] != n:
            print('No')
            exit()
    srt[n] = m
    grl[m] = n
print('Yes')

Submission status: Accepted

Solution code:
S, T = input(), input()
M = [[0]*26 for _ in range(26)]
a = ord('a')

for s,t in zip(S,T):
    M[ord(s)-a][ord(t)-a]=1

f = True
for i in range(26):
    sr, sc = 0, 0
    for j in range(26):
        sr += M[i][j]
        sc += M[j][i]

    if sr>1 or sc>1:
        f = False
        break

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

Submission status: Accepted

Solution code:
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
cv = "abcdefghijklmnopqrstuvwxyz"
convert = [cv[i] for i in range(26)]
s = input()
t = input()
a = [convert.index(s[i]) for i in range(len(s))]
b = [convert.index(t[i]) for i in range(len(t))]
c = [[] for i in range(26)]
d = [[] for i in range(26)]

for i in range(len(a)):
    c[a[i]].append(b[i])
for i in range(len(b)):
    d[b[i]].append(a[i])
for i in range(26):
    if len(set(c[i]))>1 or len(set(d[i]))>1:j(0)
j(1)

Submission status: Accepted

Solution code:
a=list(input());b=list(input())
aa=[];bb=[]
for c in [chr(ord('a')+k)for k in range(26)]:
	aa.append([i for i,j in enumerate(a) if j==c])
	bb.append([i for i,j in enumerate(b) if j==c])
if sorted(aa)==sorted(bb):
	print("Yes")
else:print("No")

Submission status: Accepted

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

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

a2n = [[] for i in range(26)]

for i in range(len(s)):
    if len(a2n[alpha2num(t[i])]) == 1:
        if a2n[alpha2num(t[i])][0] != alpha2num(s[i]):
            print('No')
            exit()
        else:
            continue
    
    a2n[alpha2num(t[i])].append(alpha2num(s[i]))
    
a2n = [[] for i in range(26)]

for i in range(len(s)):
    if len(a2n[alpha2num(s[i])]) == 1:
        if a2n[alpha2num(s[i])][0] != alpha2num(t[i]):
            print('No')
            exit()
        else:
            continue
    
    a2n[alpha2num(s[i])].append(alpha2num(t[i]))
        
print('Yes')

Submission status: Accepted

Solution code:
s = input()
t = input()
l = [0]*26
flag = 0
for i in range(len(s)):
    if l[ord(s[i])-ord("a")] == 0:
        if t[i] not in l:
            l[ord(s[i])-ord("a")] = t[i]
        else:
            flag = 1
            break
    else:
        if l[ord(s[i])-ord("a")] != t[i]:
            flag = 1
            break
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import OrderedDict

s = input()
t = input()

ds= OrderedDict()
dt= OrderedDict()

for i,(si,ti) in enumerate(zip(s,t)):
  if si in ds:
    ds[si].append(i)
  else:
    ds[si] = [i]
    
  if ti in dt:
    dt[ti].append(i)
  else:
    dt[ti] = [i]
    
ans = 'Yes'
for si,ti in zip(ds.values(),dt.values()):
  if si != ti:
    ans ='No'  
    
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
s0 = {}
t0 = {}
for i in range(len(s)):
    s0.setdefault(s[i], [])
    s0[s[i]].append(i)
for i in range(len(t)):
    t0.setdefault(t[i], [])
    t0[t[i]].append(i)
s0 = list(s0.values())
t0 = list(t0.values())
s0.sort()
t0.sort()
if s0 == t0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

def henkan(s, t):
  #a~zまでのリスト
  list = [chr(i) for i in range(97, 97+26)]
  #a~zまでの辞書
  dic = dict.fromkeys(list, 0)
  
  #sの文字を一つずつ見ていく
  for i in range(len(s)):
  #辞書にない文字だったら 辞書(s[i]) = t[i]
    if dic[s[i]] == 0:
      dic[s[i]] = t[i]
    
  #辞書にある文字だったら 辞書(s[i]) != t[i] だったら　return 0
    else:
      if dic[s[i]] != t[i]:
        return 0
  #最後まで行ったら return 1
  return 1
  
if henkan(s, t) and henkan(t, s):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s, t = input(), input()
dict_s, dict_t = {}, {}

for i in range(len(s)):
  if s[i] not in dict_s:
    dict_s[s[i]] = t[i]
  else:
    if dict_s[s[i]] != t[i]:
      print("No")
      exit()
  if t[i] not in dict_t:
    dict_t[t[i]] = s[i]
  else:
    if dict_t[t[i]] != s[i]:
      print("No")
      exit()

print("Yes")

Submission status: Accepted

Solution code:
S = input()
T = input()
ls = [0]*26
lt = [0]*26
al = [chr(ord('a')+i) for i in range(26)]
for i in range(S.__len__()):
    si = al.index(S[i])
    ti = al.index(T[i])
    ls[si] += 1
    lt[ti] += 1
ls.sort()
lt.sort()
if ls == lt:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
s0,t0=input(),input()
s,t=list(s0),list(t0)
n=len(s)
sn=set(s)
tn=set(t)
if len(sn)!=len(tn) or len(s)!=len(t):
  print('No')
  sys.exit()
for i in range(n):
  if s[i]!=t[i]:
    if s.index(s[i])!=t.index(t[i]):
      print('No')
      sys.exit()
print('Yes')

Submission status: Accepted

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

dict_st = {}
dict_ts = {}
ans = "Yes"
for x, y in zip(s, t):
  if x not in dict_st:
    dict_st[x] = y
  else:
    if dict_st[x] != y:
      ans = "No"
      break
  if y not in dict_ts:
    dict_ts[y] = x
  else:
    if dict_ts[y] != x:
      ans = "No"
      break
      
print(ans)

Submission status: Accepted

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


ans='Yes'
st=[0]*26
ts=[0]*26
for i in range(len(s)):
    sind = ord(s[i])-ord('a')
    tind = ord(t[i])-ord('a')
    
    if st[sind] == 0:
        st[sind] = t[i]
    if ts[tind] == 0:
        ts[tind] = s[i]
    
    if st[sind] == t[i] and ts[tind] == s[i]:
        continue
    else:
        ans='No'
        break
    
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
alp = "abcdefghijklmnopqrstuvwxyz"
A = [0]*26
for i in range(len(S)):
    if A[alp.index(T[i])] == 0:
        A[alp.index(T[i])] = S[i]
    elif A[alp.index(T[i])] != S[i]:
        print("No")
        exit()
A = [0]*26
for i in range(len(S)):
    if A[alp.index(S[i])] == 0:
        A[alp.index(S[i])] = T[i]
    elif A[alp.index(S[i])] != T[i]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import collections

s=input()
t=input()

cs = collections.Counter(s)
ct = collections.Counter(t)

print('Yes' if sorted(list(ct.values()))==sorted(list(cs.values())) else 'No')

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
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = LI()
    a.sort()
    a, b, c = a
    print(int(str(c)+str(b))+a)
    return

#B
def B():
    _, _, X, Y = LI()
    x = LI()
    y = LI()
    x.append(X)
    y.append(Y)
    x.sort()
    y.sort()
    print("No " * (x[-1] < y[0]) + "War")
    return

#C
def C():
    s = S()
    t = S()
    ds = defaultdict(int)
    dt = defaultdict(int)
    for i in range(len(s)):
        if ds[s[i]]:
            if ds[s[i]] == ord(t[i]):
                continue
            print("No")
            return
        if dt[t[i]]:
            if dt[t[i]] == ord(s[i]):
                continue
            print("No")
            return
        ds[s[i]] = ord(t[i])
        dt[t[i]] = ord(s[i])
    print("Yes")
    return

#D
def D():
    return

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

Submission status: Accepted

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

    rep = {}
    for ss, tt in zip(s, t):
        if ss in rep and rep[ss] != tt:
            print('No')
            return
        rep[ss] = tt

    if len(rep) == len(set(t)):
        print('Yes')
    else:
        print('No')


main()

Submission status: Accepted

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

s_dict = {}
t_dict = {}

s_arr = []
t_arr = []

s_len = 0
t_len = 0
for s in S:
    if s in s_dict:
        s_arr.append(s_dict[s])
    else:
        s_arr.append(s_len)
        s_dict[s] = s_len
        s_len += 1
for t in T:
    if t in t_dict:
        t_arr.append(t_dict[t])
    else:
        t_arr.append(t_len)
        t_dict[t] = t_len
        t_len += 1

if s_arr == t_arr:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

end = []
flag = 1
for i in range(len(s)):
  if s[i] not in end:
    end.append(s[i])
    for j in range(len(t)):
      if s[i] == s[j]:
        if t[i] != t[j]:
          flag = 0
      else:
        if t[i] == t[j]:
          flag = 0

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

Submission status: Accepted

Solution code:
chars = 'abcdefghijklmnopqrstuvwxyz'
s = input()
t = input()
l = len(s)

ds = {c: 0 for c in chars}
dt = {c: 0 for c in chars}

ans = 'Yes'
for cs, ct in zip(s, t):
    ds[cs] += 1
    dt[ct] += 1
    if ds[cs] != dt[ct]:
        ans = 'No'
        break
print(ans)

Submission status: Accepted

Solution code:
words = lambda t : list(map(t, input().split()))
s = input()
t = input()

dst = {}
dts = {}
a = "abcdefghijklmnopqrstuvwxyz"
for c in a:
    dst[c] = "-"
    dts[c] = "-"

ans = True
for i in range(len(s)):
    if dst[s[i]] == "-":
        dst[s[i]] = t[i]
    elif dst[s[i]] == t[i]:
        continue
    else:
        ans = False
        break
if ans == True:
    for i in range(len(s)):
        if dts[t[i]] == "-":
            dts[t[i]] = s[i]
        elif dts[t[i]] == s[i]:
            continue
        else:
            ans = False
            break

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ABC110C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

checktable=[]
checktable2=[]
for i in range(0,26):
	checktable.append(0)
	checktable2.append(0)

for i in range(0,len(s)):
	index=ord(s[i])-ord("a")
	if(checktable[index]==0):
		checktable[index]=ord(t[i])-ord("a")
	else:
		if(checktable[index]!=ord(t[i])-ord("a")):
			print("No")
			sys.exit()
for i in range(0,len(s)):
	index=ord(t[i])-ord("a")
	if(checktable2[index]==0):
		checktable2[index]=ord(s[i])-ord("a")
	else:
		if(checktable2[index]!=ord(s[i])-ord("a")):
			print("No")
			sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
S, T = input(), input()
conv_table = {}
inv_table = {}

able = True
for i in range(len(S)):
    if S[i] in conv_table:
        if conv_table[S[i]] != T[i]:
            able = False
            break
    else:
        conv_table[S[i]] = T[i]
    if T[i] in inv_table:
        if inv_table[T[i]] != S[i]:
            able = False
            break
    else:
        inv_table[T[i]] = S[i]
print('Yes' if able else 'No')

Submission status: Accepted

Solution code:
import numpy as np


s = input()
t = input()


trans = {}

flag = True
for i in range(len(s)):
    if s[i] in trans:
        temp = trans[s[i]]
        if temp == t[i]:
            continue
        else:
            flag = False
            break
    else:
        if t[i] not in trans.values():
           trans[s[i]] = t[i]
        else:
            flag = False
            break


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

Submission status: Accepted

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

d = dict()
dst = set()
for i, c in enumerate(S):
    if d.get(c) is None:
        if T[i] not in dst:
            d[c] = T[i]
            dst.add(T[i])
        else:
            print('No')
            exit(0)
    elif d[c] == T[i]:
        continue
    else:
        print('No')
        exit(0)
print('Yes')

Submission status: Accepted

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

dic_S = {}
dic_T = {}
s_S = set(S)
s_T = set(T)
List_S = []
List_T = []

for i in s_S:
    dic_S[i] = []

for j in range(len(S)):
    dic_S[S[j]].append(j)

for k in s_T:
    dic_T[k] = []
    
for l in range(len(T)):
    dic_T[T[l]].append(l)

for i in s_S:
    List_S.append(dic_S[i])

for j in s_T:
    List_T.append(dic_T[j])

List_S.sort()
List_T.sort()

if List_S == List_T:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
T = input()
R, R_ = [-1] * 26, [-1] * 26
for s, t in zip(S, T):
  s_ = ord(s) - ord('a')
  t_ = ord(t) - ord('a')
  if (R[s_] >= 0 and R[s_] != t_) or (R_[t_] >= 0 and R_[t_] != s_):
    print("No")
    break
  if R[s_] == -1:
    R[s_] = t_
  if R_[t_] == -1:
    R_[t_] = s_
else:
  print("Yes")

Submission status: Accepted

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

sl = {}
tl = {}

for i, j in zip(s, t):
    if i not in sl:
        sl[i] = j
    else:
        if sl[i] != j:
            print("No")
            break
    if j not in tl:
        tl[j] = i
    else:
        if tl[j] != i:
            print("No")
            break
else:
    print("Yes")

Submission status: Accepted

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

start = [-1 for _ in range(26)]
goal = [-1 for _ 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:
from collections import defaultdict
import numpy as np

d0 = defaultdict(set)
d1 = defaultdict(set)
s = input()
t = input()

# s->t, t->sで異なるマッピングがなければ良い
for i, s_ in enumerate(s):
    d0[s_].add(t[i])
for i, t_ in enumerate(t):
    d1[t_].add(s[i])

result = []
for key in d0:
    result.append(len(d0[key]))
for key in d1:
    result.append(len(d1[key]))
if np.max(result) >= 2:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
S = input()
T = input()
def calc(l):
    new_l = []
    adic = {}
    count = 0
    for c in l:
        if c in adic.keys():new_l.append(adic[c])
        else:
            new_l.append(count)
            adic[c] = count
            count += 1
    return new_l
if calc(S)==calc(T):print('Yes')
else:print('No')