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:

def solve():
    l = len(S)
    R  = [-1]*26
    R1 = [-1]*26
    is_ok = True
    for i in range(l):
        S_num = ord(S[i]) - ord("a")
        T_num = ord(T[i]) - ord("a")
        if R[S_num] == -1:
            R[S_num] = T_num
        else:
            if R[S_num] != T_num:
                is_ok = False
                break
        if R1[T_num] == -1:
            R1[T_num] = S_num
        else:
            if R1[T_num] != S_num:
                is_ok = False
                break
        
    if is_ok:
        print("Yes")
    else:
        print("No")


if __name__=="__main__":
    S = input()
    T = input()
#    S = [c for c in s]
#    T = [c for c in t]
    solve()

Submission status: Accepted

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

d = {}
ans = True
for i, v in enumerate(s):
    if v not in d:
        if t[i] in d.values():
            ans = False
            break
        else:
            d[v] = t[i]
    else:
        if d[v] != t[i]:
            ans = False
            break
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()
    T = SS()

    l = len(S)
    R0 = [-1] * 26
    R1 = [-1] * 26

    is_ok = True
    for i in range(l):
        S_num = ord(S[i]) - ord('a')
        T_num = ord(T[i]) - ord('a')
        # print(S_num, T_num)
        if R0[S_num] == -1:
            R0[S_num] = T_num
        else:
            if R0[S_num] != T_num:
                is_ok = False 
                break
        if R1[T_num] == -1:
            R1[T_num] = S_num
        else:
            if R1[T_num] != S_num:
                is_ok = False 
                break

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()
    T = SS()

    l = len(S)

    S_i = [[] for _ in range(26)]
    T_i = [[] for _ in range(26)]
    for i in range(l):
        S_i[ord(S[i]) - ord('a')].append(i)
        T_i[ord(T[i]) - ord('a')].append(i)

    S_set = set()
    T_set = set()
    for i in range(26):
        if S_i[i]: S_set.add(tuple(S_i[i]))
        if T_i[i]: T_set.add(tuple(T_i[i]))

    if S_set == T_set:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
s = input()
t = input()
l = len(s)
cs = [0]*26
ct = [0]*26
for i in range(l):
    cs[ord(s[i])-ord('a')] += 1
    ct[ord(t[i])-ord('a')] += 1
cs.sort()
ct.sort()
if cs==ct:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

alp='abcdefghijklmnopqrstuvwxyz'
d={}
for i in range(len(alp)):
    d[alp[i]]=i

t_arr=[[] for _ in range(26)]
s_arr=[[] for _ in range(26)]

for j in range(len(s)):
    a=s[j]
    b=t[j]
    if a in t_arr[d[b]]:
        continue
    else:
        t_arr[d[b]].append(a)

for j in range(len(s)):
    a=s[j]
    b=t[j]
    if b in s_arr[d[a]]:
        continue
    else:
        s_arr[d[a]].append(b)


ans='Yes'
for k in range(26):
    if len(t_arr[k])>=2:
        ans='No'
        break
    if len(s_arr[k])>=2:
        ans='No'
        break

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
ans=0
S=input()
T=input()
for i in range(len(S)):
 if d[S[i]]==0 or d[S[i]]==T[i]:
  d[S[i]]=T[i]
 else:
  ans+=1
  break
d = defaultdict(int)
for i in range(len(S)):
 if d[T[i]]==0 or d[T[i]]==S[i]:
  d[T[i]]=S[i]
 else:
  ans+=1
  break
if ans>0:
 print("No")
else:
 print("Yes")

Submission status: Accepted

Solution code:
from sys import exit

s = input()
t = input()

l = len(s)
d_s = dict()
d_t = dict()
for i in range(l):
    if s[i] in d_s:
        if d_s[s[i]] != t[i]:
            print('No')
            exit()
    else:
        d_s[s[i]] = t[i]
    
    if t[i] in d_t:
        if d_t[t[i]] != s[i]:
            print('No')
            exit()
    else:
        d_t[t[i]] = s[i]

print('Yes')

Submission status: Accepted

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

from collections import Counter

S_sorted = sorted(Counter(S).values(), reverse = True)
T_sorted = sorted(Counter(T).values(), reverse = True)

if S_sorted == T_sorted:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
d,d_=dict(),dict()
s,t=input(),input()
l=len(s)
for i in range(l):
    if s[i] not in d:
        d[s[i]]=[i]
    else:
        d[s[i]].append(i)
for i in range(l):
    if t[i] not in d_:
        d_[t[i]]=[i]
    else:
        d_[t[i]].append(i)
x=[sorted(i[1]) for i in list(d.items())]
y=[sorted(i[1]) for i in list(d_.items())]
x.sort()
y.sort()
print("Yes" if x==y else "No")

Submission status: Accepted

Solution code:
dic = {}
dic1 = {}
s=input()
t=input()
ans = "Yes"
for i in range(len(s)):
  try:
    if dic[s[i]]!=t[i]:
      ans = "No"
  except:
    dic[s[i]] = t[i]
  try:
    if dic1[t[i]]!=s[i]:
      ans = "No"
  except:
    dic1[t[i]] = s[i]
print(ans)

Submission status: Accepted

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

from collections import defaultdict

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

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

    s1 = {}
    t1 = {}

    for i, (s, t) in enumerate(zip(S, T)):
        if s in s1 and t in t1:
            if s1[s] != t1[t]:
                print('No')
                return
        elif s not in s1 and t not in t1:
            s1[s] = i
            t1[t] = i
        else:
            print('No')
            return
    
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
def solve():
    s = input()
    t = input()
    s_cnt = Counter(s)
    t_cnt = Counter(t)
    if all(sv == tv for sv, tv in zip(sorted(s_cnt.values()), sorted(t_cnt.values()))):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

dic1 = {}
dic2 = {}

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

    if tmp2 not in dic2:
        dic2[tmp2] = tmp1
    else:
        if dic2[tmp2] != tmp1:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
s = {d:[] for d in set(S)}
t = {d:[] for d in set(T)}

for i, (j,k) in enumerate(zip(S,T)):
    s[j] += [i]
    t[k] += [i]
a = sorted(s.values())
b = sorted(t.values())

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

Submission status: Accepted

Solution code:
S = input()
T = input()
n = len(S)
chars1 = []
chars2 = []
pos1 = {}
pos2 = {}
for i in range(n):
    c1 = S[i]
    c2 = T[i]
    if c1 in pos1:
        chars1[pos1[c1]].append(i)
    else:
        pos1[c1] = len(chars1)
        chars1.append([i])

    if c2 in pos2:
        chars2[pos2[c2]].append(i)
    else:
        pos2[c2] = len(chars2)
        chars2.append([i])
print('Yes' if chars1 == chars2 else 'No')

Submission status: Accepted

Solution code:
import collections

S = input()
T = input()

s = sorted(list(collections.Counter(S).values()))
t = sorted(list(collections.Counter(T).values()))

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 23 13:06:09 2020

@author: NEC-PCuser
"""
import string

S = input()
T = input()

dic = dict.fromkeys(string.ascii_lowercase, 0)
dic2 = dict.fromkeys(string.ascii_lowercase, 0)

for i in range(len(S)):
    dic[S[i]] += 1
    dic2[T[i]] += 1

li = []
li2 = []
for v in dic.values():
    li.append(v)
for v in dic2.values():
    li2.append(v)
li.sort()
li2.sort()

for i in range(len(li)):
    if li[i] != li2[i]:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

t2s = {}
s2t = {}

for s, t in zip(S, T):
    if s2t.get(s, t) != t:
        print('No')
        break
    if t2s.get(t, s) != s:
        print('No')
        break
    s2t[s] = t
    t2s[t] = s
else:
    print('Yes')

Submission status: Accepted

Solution code:
from collections import defaultdict

s=input()
t=input()
lis=defaultdict(lambda:"A")
lis2=defaultdict(lambda:"A")
for i,val in enumerate(s):
    if lis[val]=="A":
        lis[val]=t[i]
    else:
        if lis[val]!=t[i]:
            print("No")
            exit()
for i,val in enumerate(t):
    if lis2[val]=="A":
        lis2[val]=s[i]
    else:
        if lis2[val]!=s[i]:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

st = {}
ts = {}

for s, t in zip(S, T):
  if s not in st:
    st[s] = t
  else:
    if st[s] != t:
      print('No')
      break
  if t not in ts:
    ts[t] = s
  else:
    if ts[t] != s:
      print('No')
      break
else:
  print('Yes')

Submission status: Accepted

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

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


def solve(S: str, T: str):
    from collections import defaultdict
    d1 = defaultdict(set)
    d2 = defaultdict(set)
    for s, t in zip(S, T):
        d1[t].add(s)
        d2[s].add(t)
    return YES if max(map(len, d1.values())) < 2 and max(map(len, d2.values())) < 2 else NO

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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
    print(solve(S, T))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

alps_counter_s = Counter(S).most_common()
alps_counter_t = Counter(T).most_common()

for s, t in zip(alps_counter_s, alps_counter_t):
    if s[1] != t[1]:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
 
s = Counter(input())
t = Counter(input())
 
sv = sorted(s.values())
tv = sorted(t.values())
 

if sv == tv:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

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

Submission status: Accepted

Solution code:


S = input()
T = input()


dS = {}
dT = {}
for i in range(len(S)):
    dS.setdefault(T[i], S[i])
    if dS[T[i]] != S[i]:
        print("No")
        exit()
    dT.setdefault(S[i], T[i])
    if dT[S[i]] != T[i]:
        print("No")
        exit()
        


print("Yes")

Submission status: Accepted

Solution code:
S=input()
T=input()
U=list(S)
V=list(T)
dp=[0]*26
bp=[0]*26
for i in range(len(S)):
  dp[ord(U[i])-97]+=1
  bp[ord(V[i])-97]+=1
dp.sort()
bp.sort()
ans='Yes'
for i in range(len(dp)):
  if dp[i]!=bp[i]:
    ans='No'
    break
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = list(s())
T = list(s())
N = len(S)
s = [[] for _ in range(26)]
t = [[] for _ in range(26)]
for i in range(N):
    s[ord(S[i])-97].append(i)
    t[ord(T[i])-97].append(i)
for i in range(26):
    s[i].sort()
    t[i].sort()
for i in range(26):
    if s[i] not in t:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter

s = Counter(input())
t = Counter(input())

sv = sorted(s.values())
tv = sorted(t.values())

if sv == tv:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

s = Counter(input())
t = Counter(input())

sv = sorted(s.values())
tv = sorted(t.values())

if sv == tv:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
from collections import Counter

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

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

csv = sorted(cs.values())
ctv = sorted(ct.values())

if csv == ctv:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = {}
b = {}
i = 0
for c, d in zip(input(), input()):
    if c not in a and d not in b:
        a[c] = b[d] = i
        i += 1
    elif c in a and d in b:
        if a[c] != b[d]:
            print('No')
            break
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

ans='Yes'

sabc=[]
tabc=[]
number=0

for i in range(len(s)):
  try:
    tempa=sabc.index(s[i])+1
    try:
      tempb=tabc.index(t[i])+1
      if tempa!=tempb:
        ans='No'
        break
    except ValueError:
      ans='No'
      break
  except ValueError:
    try:
      tempb=tabc.index(t[i])+1
      ans='No'
      break
    except ValueError:
      sabc.append(s[i])
      sabc.append(number)
      tabc.append(t[i])
      tabc.append(number)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter


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

Submission status: Accepted

Solution code:
import sys

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


start=[-1]*26
end=[-1]*26

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

Submission status: Accepted

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

s_d = {}
t_d = {}
for i in range(len(s)):
    if s[i] not in s_d:
        new_num = len(s_d)+1
        s_d[s[i]] = new_num
        s_valid = -1
    else:
        s_valid = s_d[s[i]]

    if t[i] not in t_d:
        new_num = len(t_d)+1
        t_d[t[i]] = new_num
        t_valid = -1
    else:
        t_valid = t_d[t[i]]

    if s_valid != t_valid:
        print('No')
        break

else:
    print('Yes')

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
match=[]
accord=[]
for i in range(len(s)):
    if s[i] in match:
        ind=match.index(s[i])
        acc=accord[ind]
        if t[i]!=acc:
            print('No')
            exit()
    elif t[i] in accord:
        ind=accord.index(t[i])
        mat=match[ind]
        if s[i]!=mat:
            print('No')
            exit()
    else:
        match.append(s[i])
        accord.append(t[i])
print('Yes')

Submission status: Accepted

Solution code:
table = {alphabet: "-" for alphabet in "abcedfghijklmnopqrstuvwxyz"}
rev_table = {alphabet: "-" for alphabet in "abcedfghijklmnopqrstuvwxyz"}

s = str(input())
t = str(input())

flag = True

for i in range(len(s)):
    if table[s[i]] == t[i]:
        continue
    elif table[s[i]] == "-":
        table[s[i]] = t[i]
    else:
        flag = False
        break

for i in range(len(t)):
    if rev_table[t[i]] == s[i]:
        continue
    elif rev_table[t[i]] == "-":
        rev_table[t[i]] = s[i]
    else:
        flag = False
        break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def mi():
    return map(int, input().split())

def main():
    S = input()
    T = input()
    ds = {}
    dt = {}
    for i in range(len(S)):
        if not S[i] in ds:
            ds[S[i]] = 0
        if not T[i] in dt:
            dt[T[i]] = 0

        ds[S[i]] += 1
        dt[T[i]] += 1
    ls = sorted(list(ds.values()))
    lt = sorted(list(dt.values()))
    
    print('Yes' if ls == lt else 'No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    S_table = {}
    T_table = {}
    ans = "Yes"
    for s, t in zip(S, T):
        # S
        if s in S_table:
            if S_table[s] != t:
                ans = "No"
        else:
            S_table[s] = t
        # T
        if t in T_table:
            if T_table[t] != s:
                ans = "No"
        else:
            T_table[t] = s

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

def main():
    S = list(input())
    T = list(input())
    d1 = {}
    d2 = {}
    for k in set(T):
        d1[k] = set()
    for k in set(S):
        d2[k] = set()
    for s, t in zip(S, T):
        d1[t].add(s)
        d2[s].add(t)
    if all([len(v) == 1 for v in d1.values()]) and all([len(v) == 1 for v in d2.values()]):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

henkan1 = {chr(ord("a")+i) : set() for i in range(26) }
henkan2 = {chr(ord("a")+i) : set() for i in range(26) }

for i in range(l):
#    if s[i]!=t[i]:
    henkan1[s[i]].add(t[i])
    henkan2[t[i]].add(s[i])
        
if all(len(h) <=1 for h in henkan1.values()) and all(len(h) <=1 for h in henkan2.values()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

alphabet = [chr(i) for i in range(97, 97+26)]
dict_alphabet = {}
for i, alphabet in enumerate(alphabet):
    dict_alphabet[alphabet] = i

ans = 'Yes'
# 同じsに同じtが対応しているか
alphabet_s2t = [0] * 26
for i in range(n):
    if not alphabet_s2t[dict_alphabet[s[i]]]:
        alphabet_s2t[dict_alphabet[s[i]]] = t[i]
    else:
        if alphabet_s2t[dict_alphabet[s[i]]] != t[i]:
            ans = 'No'

alphabet_t2s = [0] * 26
for i in range(n):
    if not alphabet_t2s[dict_alphabet[t[i]]]:
        alphabet_t2s[dict_alphabet[t[i]]] = s[i]
    else:
        if alphabet_t2s[dict_alphabet[t[i]]] != s[i]:
            ans = 'No'
print(ans)

Submission status: Accepted

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

Rs = {}
Rt = {}

for s,t in zip(S,T):
    
    if s in Rs.keys() and Rs[s] != t:
        print("No")
        exit()
    if t in Rt.keys() and Rt[t] != s:
        print("No")
        exit()

    if not s in Rs.keys():
        Rs[s] = t
    if not t in Rt.keys():
        Rt[t] = s

ress = [""] * len(S)
for i,s in enumerate(S):
    ress[i] = Rs[s]

print("Yes" if "".join(ress)==T else "No")

Submission status: Accepted

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

Rs = {}
Rt = {}

for s,t in zip(S,T):
    
    if s in Rs.keys() and Rs[s] != t:
        print("No")
        exit()
    if t in Rt.keys() and Rt[t] != s:
        print("No")
        exit()

    if not s in Rs.keys():
        Rs[s] = t
    if not t in Rt.keys():
        Rt[t] = s

ress = [""] * len(S)
rest = [""] * len(S)
for i,s in enumerate(S):
    ress[i] = Rs[s]

for i,t in enumerate(T):
    rest[i] = Rt[t]
print("Yes" if "".join(ress)==T and "".join(rest)==S else "No")

Submission status: Accepted

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

abc = 'abcdefghijklmnopqrstuvwxyz'
sviewed = {c:False for c in abc}
spair = {}

tviewed = {c:False for c in abc}
tpair = {}

for i in range(N):
  si = S[i]
  ti = T[i]
  if sviewed[si] == True:
    if spair[si] != ti:
      print('No')
      exit()
  else:
    sviewed[si] = True
    spair[si] = ti
    
  if tviewed[ti] == True:
    if tpair[ti] != si:
      print('No')
      exit()
  else:
    tviewed[ti] = True
    tpair[ti] = si
    
print('Yes')

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
t = input()
cnt_s = defaultdict(int)
cnt_t = defaultdict(int)
for i in range(len(s)):
    cnt_s[s[i]] += 1
    cnt_t[t[i]] += 1

cnt_s = sorted(cnt_s.values())
cnt_t = sorted(cnt_t.values())
if len(cnt_s) != len(cnt_t):
    ans = "No"
else:
    ans = "Yes"
    for i in range(len(cnt_s)):
        if cnt_s[i] != cnt_t[i]:
            ans = "No"
            break
print(ans)

Submission status: Accepted

Solution code:
import sys
import collections

s = list(map(str,input()))
t = list(map(str,input()))
cnts = collections.Counter(s)
cntt = collections.Counter(t)
cs = sorted(cnts.values())
ct = sorted(cntt.values())

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

for i,j in zip(cs,ct):
    if i != j:
        print("No")
        sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
dic_s = defaultdict(str)
dic_t = defaultdict(str)
s = input()
t = input()
# sets = sorted(list(set(s)))
# sett

for i in range(len(s)):
    if dic_s[s[i]] or dic_t[t[i]]:
        #print(s[i],t[i],dic[s[i]], dic[t[i]])
        if dic_s[s[i]] == t[i] and dic_t[t[i]] == s[i]:
            pass
        else:
            print('No')
            exit()
    else:
        dic_s[s[i]] = t[i]
        dic_t[t[i]] = s[i]
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter
S = input()
T = input()
c_S = Counter(S)
c_T = Counter(T)
# print('c_S, c_T', c_S, c_T)
v1 = sorted(c_S.values())
v2 = sorted(c_T.values())
if len(v1) != len(v2):
    print('No')
    exit()
for s1, s2 in zip(v1, v2):
    if s1 != s2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

dic = {}
dic2 = {}

for i,j in zip(s,t):
    if j not in dic:
        if i in dic2:
            print("No")
            exit()
        dic[j] = i
        dic2[i] = j
    else:
        if dic[j] != i:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
s = input()
s = list(s)
t = input()
t = list(t)
import string
alpha = string.ascii_lowercase
alpha = list(alpha)
dic_1 = {}
dic_2 = {}
for a in alpha:
  dic_1[a] = 0
  dic_2[a] = 0
s_result = []  
t_result = []
for _ in s:
  if dic_1[_] == 0:
    i = max(dic_1.values()) + 1
    dic_1[_] = i
    s_result.append(i)
  else:
    s_result.append(dic_1[_])
for _ in t:
  if dic_2[_] == 0:
    i = max(dic_2.values()) + 1
    dic_2[_] = i
    t_result.append(i)
  else:
    t_result.append(dic_2[_])    
check = True

for i in range(len(s_result)):
  if s_result[i] != t_result[i]:
    check = False  
if check == True:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

sts = set(S)
stt = set(T)

for i in range(26):
  c = chr(ord('a')+i)
  idx1 = [i for i, x in enumerate(T) if x == c]
  st1 = set([])
  idx2 = [i for i, x in enumerate(S) if x == c]
  st2 = set([])
  
  for j in idx1:
    if S[j] not in st1 and len(st1) > 0:
      print('No')
      exit()
    elif len(st1) == 0:
      st1.add(S[j])
  for j in idx2:
    if T[j] not in st2 and len(st2) > 0:
      print('No')
      exit()
    elif len(st2) == 0:
      st2.add(T[j])
      
print('Yes')

Submission status: Accepted

Solution code:
s,t=input(),input()
ss,ts=[set()for i in range(26)],[set()for i in range(26)]
sc={}
tc={}
for i in range(len(s)):
    if s[i]not in sc:
        if t[i] in tc:print("No");exit()
        else:
            d=len(sc)
            ss[d].add(i)
            ts[d].add(i)
            tc[t[i]]=d
            sc[s[i]]=d
    else:
        if t[i]not in tc or sc[s[i]]!=tc[t[i]]:print("No");exit()
        else:
            ss[sc[s[i]]].add(i)
            ts[sc[s[i]]].add(i)
for i in range(26):
    if ss[i]!=ts[i]:print("No");break
else:print("Yes")

Submission status: Accepted

Solution code:
s=input()
t=input()
letters=[]
count=[]
for i in range(len(s)):
  if s[i] in letters:
    count[letters.index(s[i])].append(i)
  else:
    count.append([i])
    letters.append(s[i])
failflag=0
for i in count:
  r=t[i[0]]
  for j in i:
    if t[j]!=r:
      failflag=1
letters=[]
count=[]
for i in range(len(s)):
  if t[i] in letters:
    count[letters.index(t[i])].append(i)
  else:
    count.append([i])
    letters.append(t[i])
for i in count:
  r=s[i[0]]
  for j in i:
    if s[j]!=r:
      failflag=1
if failflag==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from collections import Counter
s = Counter(input())
t = Counter(input())
s_n = sorted([x for x in s.values()])
t_n = sorted([x for x in t.values()])
print("Yes" if s_n==t_n else "No")

Submission status: Accepted

Solution code:
a="abcdefghijklmnopqrstuvwxyz"
s=input()
t=input()
ds={}
dt={}
for i in a:ds[i]=dt[i]=""
for i in range(len(s)):
  if ds[s[i]]=="":ds[s[i]]=t[i]
  elif ds[s[i]]!=t[i]:exit(print("No"))
  if dt[t[i]]=="":dt[t[i]]=s[i]
  elif dt[t[i]]!=s[i]:exit(print("No"))
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

s = sorted(list(Counter(S).values()))
t = sorted(list(Counter(T).values()))

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

Submission status: Accepted

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

f = True
for (s1, s2) in [(s, t), (t, s)]:
    d = dict()
    for c1, c2 in zip(s1, s2):
        if c1 not in d:
            d[c1] = c2
        elif d[c1] != c2:
            f = False
            break

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

Submission status: Accepted

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

# 例abcdefg...のように文字列が1対1の矢印関係の場合は、
# どのような場合でも置き換えできる。問題は同じ文字が複数現れる場合

# S上に同じ文字sのある場所には
# T上にも同じ文字tがなくてはならない
# つまり、同じ値になっているインデックスの集合を取れば
# 全部同じになっているはず

# 文字種ごとにインデックスの集合を求める
ns = len(S)
indexS = {}
for i in range(ns):
    s = S[i]
    if s in indexS:
        indexS[s].append(i)
    else:
        indexS[s] = [i]
indexT = {}
for i in range(ns):
    t = T[i]
    if t in indexT:
        indexT[t].append(i)
    else:
        indexT[t] = [i]
# 先頭の文字から、インデックスの集合が等しいかチェック
for i in range(ns):
    s = S[i]
    t = T[i]
    i_s = len(indexS[s])
    i_t = len(indexT[t])
    if i_s != i_t:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict


def read():
    S = input().strip()
    T = input().strip()
    return S, T


def solve(S, T):
    N = len(S)
    u2t = dict()
    t2u = dict()
    for i in range(N):
        if S[i] not in u2t:
            u2t[S[i]] = T[i]
        elif u2t[S[i]] != T[i]:
            return "No"
        if T[i] not in t2u:
            t2u[T[i]] = S[i]
        elif t2u[T[i]] != S[i]:
            return "No"
    return "Yes"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

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

for s, t in zip(S, T):
    if s in D:
        if D[s] != t:
            print('No')
            exit()
    elif t in D.values():
        print('No')
        exit()
    else:
        D[s] = t

print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8

# https://atcoder.jp/contests/abc110


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

    memo1 = {}
    memo2 = {}
    for i in range(N):
        if S[i] not in memo1:
            memo1[S[i]] = T[i]
        else:
            if memo1[S[i]] != T[i]:
                return "No"
        if T[i] not in memo2:
            memo2[T[i]] = S[i]
        else:
            if memo2[T[i]] != S[i]:
                return "No"

    return "Yes"


print(main())