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

counta={}
countb={}

for i in s:
    if i in counta:
        counta[i] += 1
    else:
        counta[i] = 1

for y in t:
    if y in countb:
        countb[y] += 1
    else:
        countb[y] = 1

if sorted(counta.values())  == sorted(countb.values()):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S=input().strip()
T=input().strip()
fl=True
dicu={}
dicl={}
for i in range(len(S)):
    if S[i] in dicu:
        if dicu[S[i]] != T[i]:
            fl=False
            break
    else:
        dicu[S[i]]=T[i]
    if T[i] in dicl:
        if dicl[T[i]] != S[i]:
            fl=False
            break
    else:
        dicl[T[i]]=S[i]
if fl:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
j = [str(x) for x in list(str(s))]
t = input()
k = [str(x) for x in list(str(t))]

ar = []

for i in range(len(j)):
    if j[i] != k[i]:
        if j[i] in ar:
            break
        """if j[i] not in ar:
            ar.append(j[i])"""
        com = j[i]
        j[i] = k[i]
        if j[i] not in ar:
            ar.append(j[i])
        for h in range(len(j)):
            if j[h] == com:
                j[h] = k[i]
            elif j[h] == k[i] and h != i:
                j[h] = com
        for g in range(i + 1):
            if j[g] != k[g]:
                break
        else:  # 内側のforのelse節は内側ループが全部まわり切ったら実行される、つまり前の行のbreakで抜けた場合ここは実行されない
            continue  # 外側のforに対応するcontinue文、ここが実行されたら次の行のbreakには処理がいかず、外側のforの次のループにジャンプする
        break  # 外側のforを抜ける

if j == k:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def solution(s, t):
    cs = [0 for i in xrange(26)]
    for c in s:
        cs[ord(c) - ord('a')] += 1
    ps = { }
    for k in cs:
        if k > 0:
            if k not in ps:
                ps[k] = 1
            else:
                ps[k] += 1
    ct = [0 for i in xrange(26)]
    for c in t:
        ct[ord(c) - ord('a')] += 1
    for k in ct:
        if k > 0:
            if k not in ps:
                return False
            if ps[k] == 0:
                return False
            ps[k] -= 1
    return True

def main():
    s = raw_input().strip()
    t = raw_input().strip()
    if solution(s, t):
        print 'Yes'
    else:
        print 'No'

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
T = input()
dic = {}
flag = False
N = len(S)
for i in range(N):
    if S[i] in dic.keys():
        if T[i] != dic[S[i]]:
            flag = True
            break
    else:
        dic[S[i]] = T[i]

if flag or len(dic.values()) != len(set(dic.values())):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = input()
check = {}
ans = 0
for i in range(len(s)):
    if s[i] in check.keys():
        if t[i] != check[s[i]]:
            ans = 1
            break
    else:
        check[s[i]] = t[i]
if ans == 1 or len(check.values()) != len(set(check.values())):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s1 = input()
s2 = input()

s = set(zip(s1, s2))
lst = list(s)
if len(set([x[0] for x in lst])) != len(set([x[1] for x in lst])):
    print("No")
    exit(0)

ret = ""
for x in s1:
    appended = False
    for y in s:
        if y[0] == x:
            ret += y[1]
            appended = True
            break
    if not appended:
        ret += x
if s2 == ret:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = "Yes"
l = []
for i in range(len(s)):
    if s[i] in l:
        if s[i] != t[i]:
            ans = "No"
            break
    else:
        if t[i] in l:
            ans = "No"
            break
        if s[i] == t[i]:
            l.append(s[i])
        else:
            c1 = s[i]
            c2 = t[i]
            s = s.replace(c1, 'A')
            s = s.replace(c2, 'B')
            s = s.replace('A', c2)
            s = s.replace('B', c1)
            l.append(c2)
print(ans)

Submission status: Accepted

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

    s_dict = {}
    t_dict = {}

    for ch_s, ch_t in zip(S, T):
        if ch_t in t_dict.keys():
            if t_dict[ch_t] != ch_s:
                print("No")
                return
        else:
            t_dict[ch_t] = ch_s

        if ch_s in s_dict.keys():
            if s_dict[ch_s] != ch_t:
                print("No")
                return
        else:
            s_dict[ch_s] = ch_t
        #print("s",s_dict)
        #print("t",t_dict)

    print('Yes')
    return


main()

Submission status: Accepted

Solution code:
# abc110_c

from collections import Counter
from operator import itemgetter


def solve(seq1, seq2):
    if len(seq1) != len(seq2):
        return "No"
    letters1 = sorted(Counter(seq1).most_common(), key=itemgetter(1, 0), reverse=True)
    letters2 = sorted(Counter(seq2).most_common(), key=itemgetter(1, 0), reverse=True)
    for i in range(len(letters1)):
        if letters1[i][1] != letters2[i][1]:
            return "No"
    return "Yes"


if __name__ == "__main__":
    seq1 = input("")
    seq2 = input("")
    print(solve(seq1, seq2))

Submission status: Accepted

Solution code:
def solve(s, t):
    D1, D2 = {}, {}
    for i in range(len(s)):
        k = s[i]
        v = t[i]
        D1.setdefault(k, set()).add(v)
        D2.setdefault(v, set()).add(k)
        if (len(D1[k]) > 1) or (len(D2[v]) > 1):
            return "No"
    return "Yes"

assert solve("azzel", "apple") == "Yes"
assert solve("chokudai", "redcoder") == "No"
assert solve("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu") == "Yes"
s = raw_input()
t = raw_input()
print solve(s, t)

Submission status: Accepted

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

count_s = []
count_t = []
# 要素の出現回数のリストを作成
iterator = 'abcdefghijklmnopqrstuvwxyz'
for a in iterator:
    count_s.append(S.count(a))
    count_t.append(T.count(a))

count_s.sort()
count_t.sort()

if count_s == count_t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
lis = list(input())
lit = list(input())

counts = {}
countt = {}

for i in lis:
    if i not in counts.keys():
        counts[i] = 0
    counts[i] += 1

for i in lit:
    if i not in countt.keys():
        countt[i] = 0
    countt[i] += 1


counts = sorted(counts.items(),key = lambda x: x[1])
countt = sorted(countt.items(),key = lambda x: x[1])

flag = "Yes"
count = 0

for i in range(len(counts)):
    if counts[i][1] != countt[i][1]:
        flag = "No"
        break
    count += 1

print(flag)

Submission status: Accepted

Solution code:
S = input()
T = input()
l = len(S)
right = True
dic = {}
for i in range(l):
    if T[i] not in dic:
        dic[T[i]] = set()
    dic[T[i]].add(S[i])
for key, st in dic.items():
    if len(st) > 1:
        right = False
dic = {}
for i in range(l):
    if S[i] not in dic:
        dic[S[i]] = set()
    dic[S[i]].add(T[i])
for key, st in dic.items():
    if len(st) > 1:
        right = False
print("Yes" if right else "No")

Submission status: Accepted

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

aS = [ord(_) - ord('a') for _ in S]
aT = [ord(_) - ord('a') for _ in T]

aS2 = [[] for _ in range(26)]
aT2 = [[] for _ in range(26)]

for i in range(0, len(aS)):
    aS2[aS[i]].append(i)
    aT2[aT[i]].append(i)

if sorted(aS2) == sorted(aT2):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
from collections import deque

S = input()
T = input()
q = deque()
while len(S):
    indexes = [i for i, v in enumerate(S) if v == S[0]]
    q.append(indexes)
    S = S.replace(S[0], "")
while len(T):
    indexes = [i for i, v in enumerate(T) if v == T[0]]
    if q.popleft() != indexes:
        print("No")
        sys.exit()
    T = T.replace(T[0], "")
print("Yes")

Submission status: Accepted

Solution code:
s=input().rstrip()
t=input().rstrip()
def func(s,t):
  ds, dt = {}, {}
  for i,j in zip(s,t):
    if i not in ds:
      ds[i] = j
    elif ds[i]!=j:
      return "No"
    if j not in dt:
      dt[j] = i
    elif dt[j]!=i:
      return"No"
  return "Yes"
print(func(s,t))

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
start=[-1]*26
goal=[-1]*26
for i in range(len(s)):
    a=ord(s[i])-97
    b=ord(t[i])-97
    if start[a]!=-1 or goal[b]!=-1:
        if start[a]!=b or goal[b]!=a:
            print("No")
            exit()
    start[a]=b
    goal[b]=a

print("Yes")

Submission status: Accepted

Solution code:
L = [chr(i) for i in range(97,97+26)]
S = list(input())
T = list(input())

LS = []
LT = []

for i in range(26):
	LS.append(S.count(L[i]))
	LT.append(T.count(L[i]))

LS = sorted(LS)
LT = sorted(LT)

if LS == LT:
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

Rs = {}
Rt = {}
for i in range(len(S)):
    if S[i] in Rs.keys():
        if Rs[S[i]] != T[i]:
             print("No")
             exit()
    else:
        Rs[S[i]] = T[i]

    if T[i] in Rt.keys():
        if Rt[T[i]] != S[i]:
            print("No")
            exit()
    else:
        Rt[T[i]] = S[i]
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


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

    ss = []

    for ch in range(ord('a'), ord('z') + 1):
        ids = []

        for i in range(n):
            if chr(ch) == s[i]:
                ids.append(i)

        if ids:
            ss.append(ids)

    tt = []

    for ch in range(ord('a'), ord('z') + 1):
        ids = []

        for i in range(n):
            if chr(ch) == t[i]:
                ids.append(i)

        if ids:
            tt.append(ids)

    ss.sort()
    tt.sort()

    # print(ss)
    # print(tt)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=input()
T=input()
a=list(S.count(chr(ord('a') + i)) for i in range(26))
b=list(T.count(chr(ord('a') + i))for i in range(26))
a.sort()
b.sort()
if a==b:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = list(input())
b = list(input())
dica = {}
dicb = {}
la = []
lb = []
ite = 0
for ia in a:
  if ia in dica:
    la.append(dica[ia])
  else:
    dica[ia] = ite
    la.append(ite)
    ite+= 1

ite = 0
for ib in b:
  if ib in dicb:
    lb.append(dicb[ib])
  else:
    dicb[ib] = ite
    lb.append(ite)
    ite+= 1
if la == lb:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
"""
import string
al = string.ascii_lowercase

ord('A') =65
chr(65) ='A'
"""


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


s = input()
t = input()

chrList = [-1 for _ in range(26)]

flg = True
for i in range(len(s)):
    idx_s = c2i(s[i])
    idx_t = c2i(t[i])

    if chrList[idx_s] == -1:
        chrList[idx_s] = idx_t
    else:
        if chrList[idx_s] != idx_t:
            flg = False
            break

# 変換先が重複していないことを調べる
# 変換先のインデックスchrList[i]に該当するchkをTrueにしていく
chk = [False for _ in range(26)]
for i in range(26):
    if chrList[i] == -1:
        pass
    elif not chk[chrList[i]]:
        chk[chrList[i]] = True
    else:
        flg = False
        break

print('Yes' if flg else 'No')
# print(sorted(list(map(chr, list(map(lambda x: x + ord('a'), chrList))))))

Submission status: Accepted

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

ds = {}
dt = {}
for i in range(len(S)):
    if S[i] not in ds:
        ds[S[i]] = []
    if T[i] not in dt:
        dt[T[i]] = []
    ds[S[i]].append(i)
    dt[T[i]].append(i)

ans = 'Yes'
ds = ds.values()
dt = dt.values()
for x in ds:
    if x not in dt:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np

s = input()
t = input()

l = list(set([(s[i], t[i]) for i in range(len(s))]))

l1 = []
l2 = []

for i in l:
    l1.append(i[0])
    l2.append(i[1])

c1 = Counter(l1)
_, counts1 = zip(*c1.most_common())
k1 = np.where(np.array(counts1)>1)[0]

c2 = Counter(l2)
_, counts2 = zip(*c2.most_common())
k2 = np.where(np.array(counts2)>1)[0]

if len(k1) >= 1 or len(k2) >= 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s=input()
t=input()
l=len(s)
sl=[]
tl=[]
slist=[0]*26
tlist=[0]*26
flag=0
sabc=''
tabc=''
for i in range(l):
    sb=not s[i] in sabc
    tb=not t[i] in tabc
    if sb:
        sabc+=s[i]
    else:
        slist[sabc.find(s[i])]+=1
    if tb:
        tabc+=t[i]
    else:
        tlist[tabc.find(t[i])]+=1
    
    if slist!=tlist:
        flag=1
        break
if flag==1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = input()
t = input()
trans_in = [-1] * 26 
trans_out = [-1] * 26
for i in range(len(s)):
    a = ord(s[i]) - ord("a")
    b = ord(t[i]) - ord("a")
    # print(s[i], a)
    # print(t[i], b)
    if trans_in[a] != -1 or trans_out[b] != -1:
        if trans_in[a] != b or trans_out[b] != a:
            print("No")
            exit()
    trans_in[a] = b
    trans_out[b] = a
print("Yes")

Submission status: Accepted

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

d1 = dict()
d2 = dict()

ret = "Yes"

for s, t in zip(S, T):
    #print("{}-->{}".format(s, t))
    tmp1 = d1.get(s, None)
    tmp2 = d2.get(t, None)
    if (tmp1 == None or tmp1 == t) and (tmp2 == None or tmp2 == s):
        d1[s] = t
        d2[t] = s
    else:
        ret = "No"

print(ret)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
pair = []
li =[]
ans = "Yes"

for i in range(len(s)):
    if [s[i],t[i]] in li:
        pass
    else:
        li.append([s[i],t[i]])

def check2(pair,i,li):
    for j in range(len(pair)):
        if (li[i][0]==pair[j][0] and li[i][1]!=pair[j][1])or(li[i][0]!=pair[j][0] and li[i][1]==pair[j][1]):
            return False
    return True

for i in range(len(li)):
    if check2(pair,i,li):
        pair.append([li[i][0],li[i][1]])
    else:
        ans = "No"
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
st = ""

for i in range(len(s)):
    st += s[i] + t[i]

st_sprit = [st[i: i+2] for i in range(0, len(st), 2)]

s_unique = list(set(s))
t_unique = list(set(t))
st_sprit_unique = list(set(st_sprit))

if min(len(s_unique),len(t_unique)) == len(st_sprit_unique):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections
S=input()
T=input()
a1=collections.Counter(S)
a2=collections.Counter(T)
x=''
for i in range(len(S)):
    if a1[S[i]]!=a2[T[i]]:
        x='No'
if x=='':
    print('Yes')
else:
    print(x)

Submission status: Accepted

Solution code:
from collections import defaultdict

def a(s):
    dic = defaultdict(list)
    for i, ch in enumerate(s):
        dic[ch].append(i)
    return sorted(list(dic.values()))

s = input()
t = input()
print('Yes' if a(s) == a(t) else 'No')

Submission status: Accepted

Solution code:
import sys
S=input()
T=input()
N=len(S)
a=ord('a')
R=[-1]*26
Q=[-1]*26
for i in range(N):
    s=ord(S[i])-a
    t=ord(T[i])-a
    if R[s]!=-1:
        if Q[t]!=R[s]:
            print('No')
            sys.exit()
    if Q[t]!=-1:
        if R[s]!=Q[t]:
            print('No')
            sys.exit()  
    if R[s]==-1:
        R[s]=i
    if Q[t]==-1:
        Q[t]=i
print('Yes')

Submission status: Accepted

Solution code:
import sys
S=input()
T=input()
N=len(S)
L=['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']
Ss=[]
Ts=[]
for x in L:
    A=set()
    B=set()
    for i in range(N):
        if S[i]==x:
            A.add(i)
        if T[i]==x:
            B.add(i)
    Ss.append(A)
    Ts.append(B)
for A in Ss:
    flag=True
    for B in Ts:
        if A==B:
            flag=False
    if flag:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import defaultdict

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

S = input()
T = input()

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

Submission status: Accepted

Solution code:
S = input()
T = input()
l = len(S)
flag = "Yes"
Rs = [-1]*130
Rt = [-1]*130

for i in range(l):
    s = ord(S[i])
    t = ord(T[i])
    if Rs[s] < 0:
        Rs[s] = t
    if Rt[t] < 0:
        Rt[t] = s
    if Rs[s] > 0:
        if Rs[s] != t:
            flag = "No"
    if Rt[t] > 0:
        if Rt[t] != s:
            flag = "No"

print(flag)

Submission status: Accepted

Solution code:
word1 = input()
word2 = input()

def cnt_element(x):
    dict = {}
    for i in x:
        if i not in dict:
            dict[i] = 1
        else:
            dict[i] += 1
    return  sorted([x for x in dict.values()],reverse=True)

if cnt_element(word1) == cnt_element(word2):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

used = []
res  = []

for i in range(len(S)):
    if S[i] not in used:
        used.append(S[i])
    res.append(used.index(S[i]))

#print(used)
#print(res)
used = []
ret = []

for i in range(len(T)):
    if T[i] not in used:
        used.append(T[i])
    ret.append(used.index(T[i]))

if res == ret:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
abc = [chr(i) for i in range(97, 97+26)]
def index(list, char):
    return tuple(i for i, c in enumerate(list) if c == char)
s_ = [index(s, _) for _ in abc]
t_ = [index(t, _) for _ in abc]
print('Yes' if set(s_) == set(t_) else 'No')

Submission status: Accepted

Solution code:
s = input()
t = input()
sal = [0 for i in range(26)]
tal = [0 for i in range(26)]
s2, t2 = [], []
for i in range(26):
    sal[i] = s.count(chr(ord('a') + i))
    tal[i] = t.count(chr(ord('a') + i))
for i in range(len(s)):
    s2.append(sal[ord(s[i]) - ord('a')])
    t2.append(tal[ord(t[i]) - ord('a')])
if s2 != t2:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
s = input()
t = input()
s_dic = {}
t_dic = {}
flag = 0
for i in range(len(s)):
    if s[i] in s_dic:
        s_num = s_dic[s[i]]
    else:
        s_num = i
        s_dic[s[i]] = i
    if t[i] in t_dic:
        t_num = t_dic[t[i]]
    else:
        t_num = i
        t_dic[t[i]] = i
    if s_num != t_num:
        flag = 1
        break
if flag == 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

used = []
res  = []

for i in range(len(S)):
    if S[i] not in used:
        used.append(S[i])
    res.append(used.index(S[i]))

#print(used)
#print(res)
used = []
ret = []

for i in range(len(T)):
    if T[i] not in used:
        used.append(T[i])
    ret.append(used.index(T[i]))

if res == ret:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
flag = True
d1,d2 = dict(),dict()
for i in range(len(s)):
    if s[i] in d1:
        if d1[s[i]] != t[i]:
            flag = False
    else:
        d1[s[i]] = t[i]
        
for i in range(len(s)):
    if t[i] in d2:
        if d2[t[i]] != s[i]:
            flag = False
    else:
        d2[t[i]] = s[i]

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

Submission status: Accepted

Solution code:
s=input()
t=input()
s_dic={}
t_dic={}
flag=0
for i, c in enumerate(s):
  if c in s_dic:
    if s_dic[c]!=t[i]:
      flag=1
      break
  else:
  	s_dic[c]=t[i]
for i, c in enumerate(t):
  if c in t_dic:
    if t_dic[c]!=s[i]:
      flag=1
      break
  else:
  	t_dic[c]=s[i]
if flag==1:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
import copy

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

c = {}
for i in range(len(S)):
    if S[i] in c:
        if c[S[i]] != T[i]:
            print('No')
            exit()
    elif T[i] in c.values():
        ct = copy.copy(c)
        ct[S[i]] = T[i]
        keys = [k for k, v in ct.items() if v == T[i]]
        if len(set(keys)) != 1:
            print('No')
            exit()
    else:
        c[S[i]] = T[i]
    
print('Yes')

Submission status: Accepted

Solution code:
s = input()
t = input()
while s != "":
  x = s[0]
  y = t[0]
  for i in range(len(s)):
    if (s[i] == x and t[i] != y) or (s[i] != x and t[i] == y):
      print("No")
      exit()
  s = s.replace(x,"")
  t = t.replace(y,"")
print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = input()
dict_s = ["_"]*26
dict_t = ["_"]*26
alphabet = [chr(i) for i in range(97, 97 + 26)]
for i in range(len(s)):
    if dict_s[alphabet.index(s[i])] == "_":
        dict_s[alphabet.index(s[i])] = t[i]
    elif dict_s[alphabet.index(s[i])] != t[i]:
            print("No")
            exit()
    if dict_t[alphabet.index(t[i])] == "_":
        dict_t[alphabet.index(t[i])] = s[i]
    elif dict_t[alphabet.index(t[i])] != s[i]:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
RC110C
"""


s = list(input())
t = list(input())
n = len(s)

def exchange(a,b,c):
    if a != b and a!=c:
        return(a)
    elif a == b:
        return(c)
    elif a == c:
        return(b)

ans = 'Yes'

seen = set()
for i in range(n):
    sl = s.pop()
    tl = t.pop()
    if sl == tl:
        seen.add(sl)
    elif sl != tl and not tl in seen and not sl in seen:
        s = list(map(lambda a: exchange(a,sl,tl),s))
        seen.add(tl)
    else:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
index_S = sorted(map(S.count, set(S)))
index_T = sorted(map(T.count, set(T)))
if index_S == index_T:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import collections

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

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

slist = list(cs.values())
tlist = list(ct.values())

slist.sort()
tlist.sort()

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

Submission status: Accepted

Solution code:
def solve():
    alpha = "abcdefghijklmnopqrstuvwxyz"
    inp1, inp2 = input(), input()
    sz = dict(zip(list(alpha), [0] * 26))
    tz = dict(zip(list(alpha), [0] * 26))
    for i in range(len(inp1)):
        sz[inp1[i]] += 1
        tz[inp2[i]] += 1
        if sz[inp1[i]] != tz[inp2[i]]:
            print("No")
            return
    print("Yes")


solve()

Submission status: Accepted

Solution code:
def solve():
  from collections import Counter
  s = [i for i in sorted(Counter(input()).values())]
  t = [i for i in sorted(Counter(input()).values())]
  print(["No","Yes"][s==t])

solve()

Submission status: Accepted

Solution code:
S = input()
T = input()
f = [-1 for _ in range(130)]
g = [-1 for _ in range(130)]
ans = "Yes"
for i in range(len(S)):
  s = ord(S[i])
  t = ord(T[i])
  if f[s] == -1:
    f[s] = t
  else:
    if f[s] != t:
      ans = "No"
  if g[t] == -1:
    g[t] = s
  else:
    if g[t] != s:
      ans = "No"
print(ans)

Submission status: Accepted

Solution code:
from string import ascii_lowercase

s = input()
t = input()
dic = {}
used = {}
for c in ascii_lowercase:
    dic[c] = None
    used[c] = False

for ss, tt in zip(s, t):
    if dic[tt] is None:
        if used[ss]:
            print('No')
            exit()
        else:
            dic[tt] = ss
            used[ss] = True
    elif dic[tt] != ss:
        print('No')
        exit()
else:
    print('Yes')

Submission status: Accepted

Solution code:
#AtCorder Beginner Context 110 C String Transformation

import collections

#入力を1文字ずつリストにして変数に格納
s = list(input())
t = list(input())

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

slist = list(cs.values())
tlist = list(ct.values())

slist.sort()
tlist.sort()

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

Submission status: Accepted

Solution code:
S = input()
T = input()
sls = {chr(_): list() for _ in range(97, 97+26)}
tls = {chr(_): list() for _ in range(97, 97+26)}
for i in range(len(S)):
    sls[S[i]].append(i)
for i in range(len(T)):
    tls[T[i]].append(i)

for i in range(97, 97+26):
    t = sls[chr(i)]
    if len(t) > 1:
        for j in range(len(t)-1):
            if T[t[j]] != T[t[j+1]]:
                print('No')
                exit(0)

for i in range(97, 97 + 26):
    t = tls[chr(i)]
    if len(t) > 1:
        for j in range(len(t) - 1):
            if S[t[j]] != S[t[j + 1]]:
                print('No')
                exit(0)

print('Yes')

Submission status: Accepted

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

alphabets = 'abcdefghijklmnopqrstuvwxyz'

S_list = []
T_list = []

for i in alphabets:
    Scnt = S.count(i)
    Tcnt = T.count(i)
    if Scnt > 0:
        S_list.append(Scnt)
    if Tcnt > 0:
        T_list.append(Tcnt)

if sorted(T_list) == sorted(S_list):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

s= input()
t = input()






def solve(S,T):
    s_map  = {}
    t_map = {}

    for s in S:
        if s in s_map:
            s_map[s] += 1
        else:
            s_map[s] = 1

    
    for t in T:
        if t in t_map:
            t_map[t] += 1
        else:
            t_map[t] = 1

    s_l = []
    t_l = []

    for sss in s_map:
        s_l.append(s_map[sss])
    for ttt in t_map:
        t_l.append(t_map[ttt])

    return sorted(s_l) == sorted(t_l)


    

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

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
x = list(set(s))
y = list(set(t))
a = []
b = []

for i in range(len(set(s))):
    a.append(s.count(x[i]))
    
for j in range(len(set(t))):
    b.append(t.count(y[j]))
    
a.sort()
b.sort()

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

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
x = list(set(s))
y = list(set(t))
a = []
b = []
for i in range(len(set(s))):
  a.append(s.count(x[i]))
for j in range(len(set(t))):
  b.append(t.count(y[j]))
a.sort()
b.sort()
if a == b:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

S_list = []
T_list = []
alpha = "abcdefghijklmnopqrstuvwxyz"

for i in alpha:
    SS = S.count(i)
    TT = T.count(i)
    if SS > 0:
        S_list.append(SS)
    if TT > 0:
        T_list.append(TT)

if sorted(S_list) != sorted(T_list):
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

string = ''

for i in range(len(S)):
    if S[i] not in string:
        S_ch = [j for j, x in enumerate(S) if x == S[i]]
        T_ch = [j for j, x in enumerate(T) if x == T[i]]
        string += S[i]
        if S_ch != T_ch:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
s = input()
t = input()
snum = []
tnum = []
for c in range(ord('a'), ord('z') + 1):
    snum.append([i for i, x in enumerate(s) if x == chr(c)])
for c in range(ord('a'), ord('z') + 1):
    tnum.append([i for i, x in enumerate(t) if x == chr(c)])
snum.sort()
tnum.sort()
print('Yes' if snum == tnum else 'No')

Submission status: Accepted

Solution code:
S = input()
T = input()
alphabets = "abcdefghijklmnopqrstuvwxyz"

S_list=[]
T_list=[]
for c in alphabets:
    Scnt = S.count(c)
    Tcnt = T.count(c)
    if Scnt > 0:
        S_list.append(Scnt)
    if Tcnt > 0:
        T_list.append(Tcnt)

if sorted(S_list) == sorted(T_list):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
start = [-1]*30
goal = [-1]*30
count = 0
for i in range(0,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:
            count = 1
            break
    else:
        start[a] = b
        goal[b] = a
if count == 1:
    print("No")
elif count == 0:
    print("Yes")

Submission status: Accepted

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

i = 0
j = 0
ss = list()
tt = list()
slist = list()
tlist = list()

if len(S) == len(T):
   for s in S:
      if s in slist:
         ss.append(slist.index(s))
      else:
         ss.append(i)
         slist.append(s)
         i += 1

   for t in T:
      if t in tlist:
         tt.append(tlist.index(t))
      else:
         tt.append(j)
         tlist.append(t)
         j += 1

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

Submission status: Accepted

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

s = list(S)
t = list(T)

s.sort()
t.sort()

v = 0
w = 0

a = [0 for i in range(0,n)]
b = [0 for i in range(0,n)]

c = [0 for i in range(0,26)]
d = [0 for i in range(0,26)]

for i in range(0,n-1):
    if s[i] == s[i+1]:
        a[i+1] = v
    else:
        v += 1
        a[i+1] = v

for i in range(0,n-1):
    if t[i] == t[i+1]:
        b[i+1] = w
    else:
        w += 1
        b[i+1] = w

for i in range(0,26):
    c[i] = a.count(i)

for i in range(0,26):
    d[i] = b.count(i)

c.sort()
d.sort()

if c == d:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
T = input()

s_counter = defaultdict(int)
t_counter = defaultdict(int)

for s in S:
    s_counter[s] += 1
for t in T:
    t_counter[t] += 1

s_counter = sorted(list(s_counter.items()), key=lambda x: x[1])
t_counter = sorted(list(t_counter.items()), key=lambda x: x[1])

if len(s_counter) != len(t_counter):
    print("No")
else:
    flag = True
    for s_tup, t_tup in zip(s_counter, t_counter):
        if s_tup[1] != t_tup[1]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")