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:
from collections import defaultdict
s = input()
t = input()
dic = defaultdict(lambda : None)
revdic = defaultdict(lambda : None)
for x, y in zip(s, t):
    if dic[x] == None and revdic[y] == None:
        dic[x] = y
        revdic[y] = x
    elif dic[x] != y or revdic[y] != x:
        print('No')
        quit()
print('Yes')

Submission status: Accepted

Solution code:
S = input()
T = input()
len_s = len(S)
ok = True
s_dict = {}
t_dict = {}
for i in range(len_s):
  if S[i] in s_dict and s_dict[S[i]] != T[i]:
    ok = False
    break
  if T[i] in t_dict and t_dict[T[i]] != S[i]:
    ok = False
    break
  s_dict[S[i]] = T[i]
  t_dict[T[i]] = S[i]
if ok:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
x=input()
y=input()

n=len(x)

def trn(s):
	c=[0]*n
	cnt=1
	for i in range(n):
		if c[i]==0:
			c[i]=cnt
			if i<n-1:
				for j in range(i+1,n):
					if s[j]==s[i]:
						c[j]=cnt
			cnt+=1
	return c

x_c=trn(x)
y_c=trn(y)

res='Yes'

for i in range(n):
	if x_c[i]!=y_c[i]:
		res='No'
		break

print(res)

Submission status: Accepted

Solution code:
S = {}
for i, s in enumerate(input()):
    if not s in S.keys():
        S[s] = [i]
    else:
        S[s].append(i)

T = {}
for i, t in enumerate(input()):
    if not t in T.keys():
        T[t] = [i]
    else:
        T[t].append(i)

Sa = sorted(S.values())
Ta = sorted(T.values())

if Sa == Ta:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Submission status: Accepted

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

ls = []
cnts = []
lt = []
cntt = []
m = len(s)
for i in range(m):
    if s[i] not in ls:
        ls.append(s[i])
        cnts.append(i)
    else:
        cnts.append(s.index(s[i]))
for i in range(m):
    if t[i] not in lt:
        lt.append(t[i])
        cntt.append(i)
    else:
        cntt.append(t.index(t[i]))

#print(cnts,cntt)

flag = 0

if cntt == cnts:
    flag = 1
if flag == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
from sys import exit, stdin
from collections import Counter
S = list(stdin.readline().rstrip())
T = list(stdin.readline().rstrip())
S, T = Counter(S).most_common(), Counter(T).most_common()
S, T = [t[1] for t in S], [t[1] for t in T]
if S == T:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
rs = [-1] * 26
rt = [-1] * 26 
n = len(s)

for i in range(n):
    chrnum = rs[ord(s[i]) - 97]
    if chrnum != -1:
        if t[i] == chr(chrnum + 97):
            continue
        else:
            print("No")
            exit()
    else:
        rs[ord(s[i]) - 97] = ord(t[i]) - 97

for i in range(n):
    chrnum = rt[ord(t[i]) - 97]
    if chrnum != -1:
        if s[i] == chr(chrnum + 97):
            continue
        else:
            print("No")
            exit()
    else:
        rt[ord(t[i]) - 97] = ord(s[i]) - 97
print("Yes")

Submission status: Accepted

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

ds = dict()
dt = dict()
tr = dict()
tr2 = dict()
res = True
for i in range(len(s)):
    ds[s[i]] = True
    dt[s[i]] = True
    if s[i] not in tr:
        tr[s[i]] = t[i]
    else:
        if tr[s[i]] != t[i]:
            res = False

    if t[i] not in tr2:
        tr2[t[i]] = s[i]
    else:
        if tr2[t[i]] != s[i]:
            res = False

#if (len(ds) == 26 or len(dt) == 26) and ds != dt:
#    res = False

print("Yes" if res else "No")

Submission status: Accepted

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

ds = dict()
dt = dict()
tr = dict()
tr2 = dict()
res = True
for i in range(len(s)):
    ds[s[i]] = True
    dt[s[i]] = True
    if s[i] not in tr:
        tr[s[i]] = t[i]
    else:
        if tr[s[i]] != t[i]:
            res = False

    if t[i] not in tr2:
        tr2[t[i]] = s[i]
    else:
        if tr2[t[i]] != s[i]:
            res = False

if (len(ds) == 26 or len(dt) == 26) and ds != dt:
    res = False

print("Yes" if res else "No")

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()

table = {}
ok = True
for i, t in enumerate(T):
    if t not in table:
        table[t] = S[i]
    if table[t] != S[i]:
        ok = False
if ok and len(set(table.values())) == len(table):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
flag = True
traslateT = [0] * 26
traslateS = [0] * 26
use = [False] * 26
for i in range(len(S)):
    si = ord(S[i]) - ord('a')
    ti = ord(T[i]) - ord('a')
    if(traslateS[si] != 0 and traslateS[si] != ti):
        flag = False
    if(traslateT[ti] != 0 and traslateT[ti] != si):
        flag = False
    traslateS[si] = ti
    traslateT[ti] = si

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

Submission status: Accepted

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

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

if len(set(s)) != len(set(t)):
    print('No')
    quit()

dif = {}
for x,y in zip(s,t):
    if x not in dif:
        dif[x] = y
    elif dif[x] != y:
        print('No')
        quit()
print('Yes')

Submission status: Accepted

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

d = {}
d2 = {}

for i in range(len(S)):
    if S[i] not in d: d.update({S[i]: T[i]})
    elif d[S[i]]==T[i]: pass
    else:
        print('No')
        exit()

    if T[i] not in d2: d2.update({T[i]: S[i]})
    elif d2[T[i]]==S[i]: pass
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
t = input()
s_chr_list = []
s_chr_num = 0
s_num_list = []
for i in range(len(s)):
    if s[i] in s_chr_list:
        s_same_chr = s_chr_list.index(s[i])
        s_num_list.append(s_same_chr)
    else:
        s_chr_list.append(s[i])
        s_chr_num += 1
        s_num_list.append(s_chr_num)
t_chr_list = []  
t_chr_num = 0
t_num_list = []        
for i in range(len(t)):
    if t[i] in t_chr_list:
        t_same_chr = t_chr_list.index(t[i])
        t_num_list.append(t_same_chr)
    else:
        t_chr_list.append(t[i])
        t_chr_num += 1
        t_num_list.append(t_chr_num)
if t_num_list == s_num_list:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

def main():
	s = input().strip()
	t = input().strip()
	l = [-1] * 26
	k = [-1] * 26
	a = ord('a')
	for i in range(len(s)):
		if l[ord(s[i]) - a] != -1 or k[ord(t[i]) - a] != -1:
			if l[ord(s[i]) - a] != t[i] or k[ord(t[i]) - a] != s[i]:
				print('No')
				return
		l[ord(s[i]) - a] = t[i]
		k[ord(t[i]) - a] = s[i]
	print('Yes')


if __name__ == '__main__':
	main()

Submission status: Accepted

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

s2t = dict()
t2s = dict()

flg = True
for i, (ss, tt) in enumerate(zip(s, t)):
    a = s2t.get(ss, None)
    if a is None:
        s2t[ss] = tt
    else:
        if a != tt:
            flg = False
            break

    b = t2s.get(tt, None)
    if b is None:
        t2s[tt] = ss
    else:
        if b != ss:
            flg = False
            break
print('Yes' if flg else 'No')

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

S = input()
T = input()

stlist = [[sc, tc] for sc, tc in zip(S, T)]


from operator import itemgetter

#まずはsでソート
stlist = sorted(stlist, key=itemgetter(0))

#同じ文字なのに違うことがあるか
prevsc = 'Z'
prevtc = 'Z' #これは無意味だが、とりあえず宣言しておく
for sc, tc in stlist:
  if prevsc == sc and prevtc != tc:
    print('No')
    exit()
  else:
    prevsc = sc
    prevtc = tc


#tでソート
stlist = sorted(stlist, key=itemgetter(1))

#同じ文字なのに違うことがあるか
prevsc = 'Z' #これは無意味だが、とりあえず宣言しておく
prevtc = 'Z'
for sc, tc in stlist:
  if prevtc == tc and prevsc != sc:
    print('No')
    exit()
  else:
    prevsc = sc
    prevtc = tc

print('Yes')

Submission status: Accepted

Solution code:
s,t=input(),input()
rs=[""for _ in range(26)]
rt=[""for _ in range(26)]
def a(n):return [chr(ord('a')+i)for i in range(26)].index(n)
for i in range(len(s)):
  ss,tt=a(s[i]),a(t[i])
  if rs[ss]=="":rs[ss]=t[i]
  elif rs[ss]!=t[i]:print("No");exit()
  if rt[tt]=="":rt[tt]=s[i]
  elif rt[tt]!=s[i]:print("No");exit()
print("Yes")

Submission status: Accepted

Solution code:

s = input()
t = input()

s_list = [ 0 for i in range(26) ]
t_list = [ 0 for i in range(26) ]
for i in range(len(s)):
    s_list[ord(s[i])-97] += 1
    t_list[ord(t[i])-97] += 1

s_list = sorted(s_list)
t_list = sorted(t_list)

if s_list == t_list:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
t=input()
ds={}
dt={}
for i in range(len(s)):
  ts=s[i]
  tt=t[i]
  if ts not in ds:
    ds[ts]=tt
    rs=tt
  else:
    rs=ds[ts]
  if tt not in dt:
    dt[tt]=ts
    rt=ts
  else:
    rt=dt[tt]
  if rs==tt and rt==ts:
    continue
  else:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
S = input()
T = input()
 
if len(set(S)) != len(set(T)):
    print("No")
    exit()
 
D = {}
for s, t in zip(S, T):
    if s not in D:
        D[s] = t
    elif D[s] != t:
        print("No")
        exit()
 
print("Yes")

Submission status: Accepted

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

if len(set(S)) != len(set(T)):
    print("No")
    exit()

D = {}
for s, t in zip(S, T):
    if s not in D:
        D[s] = t
    elif D[s] != t:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
# editorialを参考にした。なお、ord("a")=97,ord("b")=98...となっていることを使っている
S = input()
T = input()
StoT = [-1] * 26  # 変換は1対1対応をとっていないといけない
TfromS = [-1]*26
ans = 1

for i in range(len(S)):
    num_s = ord(S[i]) - 97
    num_t = ord(T[i])-97
    if StoT[num_s] == -1:
        StoT[num_s] = num_t
    else:
        if StoT[num_s] != num_t:
            ans = 0
            break

    if TfromS[num_t] == -1:
        TfromS[num_t] = num_s
    else:
        if TfromS[num_t] != num_s:
            ans = 0
            break

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

Submission status: Accepted

Solution code:
from collections import defaultdict

d1 = defaultdict(lambda: 'AA')
d2 = defaultdict(lambda: 'AA')

S = input()
T = input()

flag = True
for i in range(len(S)):
    if d2[T[i]] != 'AA':
        if d2[T[i]] != S[i]:
            flag = False
            break
    if d1[S[i]] != 'AA':
        if d1[S[i]] != T[i]:
            flag = False
            break
    d1[S[i]] = T[i]
    d2[T[i]] = S[i]

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

Submission status: Accepted

Solution code:
from collections import defaultdict

d1=defaultdict(lambda:'AA')
d2=defaultdict(lambda:'AA')
S=input()
T=input()
flag =True
for i in range(len(S)):
	if d1[S[i]]!='AA':
		if d1[S[i]] != T[i]:
			flag = False
			break
	if d2[T[i]]!='AA':
		if d2[T[i]]!=S[i]:
			flag =False
			break
	d1[S[i]]=T[i]
	d2[T[i]]=S[i]
if flag:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
mapping_s = {}
mapping_t = {}
count_s = 0
count_t = 0
code_s = []
code_t = []
for cs, ct in zip(s, t):
    if cs not in mapping_s:
        mapping_s[cs] = count_s
        count_s += 1
    if ct not in mapping_t:
        mapping_t[ct] = count_t
        count_t += 1
    code_s.append(mapping_s[cs])
    code_t.append(mapping_t[ct])
if code_s == code_t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#ABC110 C String Transformation

S = input()
T = input()

StoT = {}
TtoS = {}

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

Submission status: Accepted

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

if Counter(Counter(S).values()) == Counter(Counter(T).values()):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def shurui(s):
	m=set(s)
	ans=[]
	for i in m:
		ans.append(s.count(i))
	return sorted(ans)

def resolve():
	s=input()
	t=input()
	if shurui(s)==shurui(t):
		print('Yes')
	else:
		print('No')
resolve()

Submission status: Accepted

Solution code:
# ABC110C - String Transformation
def main():
    s, t = [input().rstrip() for _ in range(2)]
    d1, d2 = {}, {}
    for i, j in zip(s, t):
        if i not in d1:
            d1[i] = j
        if j not in d2:
            d2[j] = i
        if d1[i] != j or d2[j] != i:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC110C - String Transformation
def main():
    s, t = [input().rstrip() for _ in range(2)]
    d = {}
    for i, j in zip(s, t):
        if i not in d:
            d[i] = j
        else:
            if d[i] != j:
                print("No")
                break
    else:
        print("Yes" if len(set(s)) == len(set(t)) else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
alp_s = [0]*26
alp_t = [0]*26
for i in range(len(s)):
    a = ord(s[i])-ord("a")
    b = ord(t[i])-ord("a")
    alp_s[a]+=1
    alp_t[b]+=1
alp_s.sort()
alp_t.sort()
for i in range(26):
    if alp_s[i]!=alp_t[i]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
ls = [[] for _ in range(2)]
for i in range(len(s)):
    if s[i]==t[i]:
        if s[i] in ls[0]:
            index=ls[0].index(s[i])
            if t[i] == ls[1][index]:
                pass
            else:
                print("No")
                exit()

        else:
            if t[i] in ls[1]:
                print("No")
                exit()
            else:
                ls[0].append(s[i])
                ls[1].append(t[i])
    else:
        if s[i] in ls[0]:
            index = ls[0].index(s[i])
            if t[i] == ls[1][index]:
                pass
            else:
                print("No")
                exit()
        else:
            if t[i] in ls[1]:
                print("No")
                exit()
            else:
                ls[0].append(s[i])
                ls[1].append(t[i])
print("Yes")

Submission status: Accepted

Solution code:
import string
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

S=input()
T=input()

mp1={s: 0 for s in string.ascii_lowercase}
mp2={s: 0 for s in string.ascii_lowercase}
for i in range(len(S)):
    mp1[S[i]] += 1
    mp2[T[i]] += 1

li1 = list(mp1.values())
li2 = list(mp2.values())
li1.sort()
li2.sort()

print('Yes' if li1 == li2 else 'No')

Submission status: Accepted

Solution code:
s = input()
t = input()
lis = []
lit = []
anss = ""
anst = ""
n = len(s)
for i in range(n):
  if s[i] in lis:
    anss += str(lis.index(s[i]))
  else:
    lis.append(s[i])
    anss += str(lis.index(s[i]))
for i in range(n):
  if t[i] in lit:
    anst += str(lit.index(t[i]))
  else:
    lit.append(t[i])
    anst += str(lit.index(t[i]))
if anss == anst:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S=input()
T=input()
a=[None]*26
b=[None]*26
k=1
for i in range(26):
    for j in range(len(S)):
        if S[j]==chr(97+i):
            if a[i]==None:
                a[i]=T[j]
            else:
                if T[j]!=a[i]:
                    k=0
                    break
for i in range(26):
    for j in range(len(S)):
        if T[j]==chr(97+i):
            if b[i]==None:
                b[i]=S[j]
            else:
                if S[j]!=b[i]:
                    k=0
                    break
if k==1:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
s = input()
t = input()
d1 = defaultdict(set)
d2 = defaultdict(set)

for i in range(len(s)):
    d1[t[i]].add(s[i])
    d2[s[i]].add(t[i])
    if len(d1[t[i]])>1 or len(d2[s[i]])>1:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
t = input()
d1 = defaultdict(set)
d2 = defaultdict(set)
for i in range(len(s)):
  d1[t[i]].add(s[i])
  d2[s[i]].add(t[i])
  if len(d1[t[i]])>1 or len(d2[s[i]])>1:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
T = input()

dict = defaultdict()

for i in range(len(S)):
    if S[i] in dict:
        if dict[S[i]] != T[i]:
            print("No")
            exit()
    else:
        dict[S[i]] = T[i]

dict2 = {v:k for k, v in dict.items()}
for i in range(len(T)):
    if dict2[T[i]] != S[i]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

lst_s = []
lst_t = []
for i in range(len(s)):
    if lst_s.count(s[i])==0:
        lst_s.append(s[i])
    if lst_t.count(t[i])==0:
        lst_t.append(t[i])
    if lst_s.index(s[i]) != lst_t.index(t[i]):
        print("No")
        exit()
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()

r1 = {}
r2 = {}

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

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

Submission status: Accepted

Solution code:
S = input()
T = input()
s_dict = {}
t_dict = {}
duplicate_flag = 0
for s,t in zip(S,T):
    if not s in s_dict:
        s_dict[s] = t
        if not t in t_dict:
            t_dict[t] = s
        else:
            print("No")
            exit()
    elif s_dict[s] != t:
        print("No")
        exit()
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:
import collections as col
 
s = list(input())
t = list(input())
 
c1 = col.Counter(s)
c2 = col.Counter(t)
 
cv1 = sorted(c1.values())
cv2 = sorted(c2.values())
 
if cv1 == cv2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
#print(S, T)
if S == T:
    print('Yes')
    exit()
if len(S) != len(T):
    print('No')
    exit()

freqs = {}
freqt = {}

def calc_freq(S, freq):
    for s in S:
        if s not in freq:
            freq[s] = 1
        else:
            freq[s] += 1

calc_freq(S, freqs)
calc_freq(T, freqt)
# print(freqs)
# print(freqt)
anss = [freqs[x] for x in freqs]
anst = [freqt[x] for x in freqt]
anss.sort()
anst.sort()
# print(anss)
# print(anst)

if anss == anst:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections

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

c_s = collections.Counter(s)
s_values, s_counts = zip(*c_s.most_common())

c_t = collections.Counter(t)
t_values, t_counts = zip(*c_t.most_common())

if s_counts == t_counts:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# INPUT
first_word = input()
second_word = input()

# # PROCESS
answer = "No"
answer_dict = {}
answer_dict2 = {}

def check_dict(dic, val_word, check_word):
  answer_bool = True
  for i in range(len(val_word)):
    if (val_word[i] in dic.keys()):
      if (dic[val_word[i]] != check_word[i]):
        answer_bool = False
        break
    else:
      dic[val_word[i]] = check_word[i]

  return answer_bool

check_1 = check_dict(answer_dict, first_word, second_word)
check_2 = check_dict(answer_dict2, second_word, first_word)
if (check_1 and check_2):
  answer = "Yes"

# OUTPUT
print(answer)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():

  # a〜z
  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']

  l2=[list() for i in range(26)]
  l3=[list() for i in range(26)]

  s=S()
  t=S()

  for i in range(len(s)):
    if len(l2[l.index(s[i])])>0:
      if l2[l.index(s[i])][0]!=t[i]:
        return 'No'
    else:
      l2[l.index(s[i])].append(t[i])
    if len(l3[l.index(t[i])])>0:
      if l3[l.index(t[i])][0]!=s[i]:
        return 'No'
    else:
      l3[l.index(t[i])].append(s[i])

  return 'Yes'

print(main())

Submission status: Accepted

Solution code:
S = input()
T = input()
TS = list(zip(T, S))

TS_set = set()
for t,s in TS:
  TS_set.add((t,s))

S_set = set()
for x in TS_set:
  S_set.add(x[1])

T_set = set()
for x in TS_set:
  T_set.add(x[0])

print("Yes" if S == T or len(TS_set) == len(S_set) == len(T_set) else "No")

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    T = input()
    smap = {}
    tmap = {}
    for i in range(len(S)):
        if S[i] in smap: 
            if smap[S[i]] != T[i]:
                print("No")
                return
        else:
            smap[S[i]] = T[i]
        
        if T[i] in tmap: 
            if tmap[T[i]] != S[i]:
                print("No")
                return
        else:
            tmap[T[i]] = S[i]

    print("Yes")
    return


if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:

S = input()
T = input()

S_dic={}
T_dic={}

for i in range(len(S)):

    if S[i] in S_dic:
        S_dic[S[i]].append(i)
    else:
        S_dic[S[i]] = [i]

for i in range(len(T)):

    if T[i] in T_dic:
        T_dic[T[i]].append(i)
    else:
        T_dic[T[i]] = [i]


#print (S_dic)
#print (T_dic)

T_dicR = {}

for i in T_dic:
    T_dicR[ str(T_dic[i]) ] = 1

ans = True

for i in S_dic:

    if str(S_dic[i]) not in T_dicR:
        ans = False
        break

#print (T_dicR)

if ans:
    print ("Yes")

else:
    print ("No")

Submission status: Accepted

Solution code:
from collections import Counter
print("NYoe s"[sorted(list(Counter(input()).values()))==sorted(list(Counter(input()).values()))::2])

Submission status: Accepted

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

N = len(S)
A = []
B = []
X = {}
Y = {}
x = 0
y = 0

for n in range(N):
    if S[n] not in X:
        X[S[n]] = x
        A.append(x)
        x += 1
    if T[n] not in Y:
        Y[T[n]] = y
        B.append(y)
        y += 1
    if S[n] in X:
        A.append(X[S[n]])
    if T[n] in Y:
        B.append(Y[T[n]])
        
if A == B:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
S_dict = dict()
T_dict = dict()
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s not in S_dict:
        S_dict[s] = []
    if t not in T_dict:
        T_dict[t] = []
    S_dict[s].append(i)
    T_dict[t].append(i)
S_Value = []
T_Value = []
for s in S_dict.values():
    S_Value.append(s)
for t in T_dict.values():
    T_Value.append(t)
S_Value.sort()
T_Value.sort()
if S_Value == T_Value:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
 
def num_counter(s):
    form = []
    idx = 0
    visited = {}
    
    for ss in s:
        if ss not in visited:
            visited[ss] = idx
            idx += 1
        form.append(visited[ss])
    
    return form
    
S_form = num_counter(S)
T_form = num_counter(T)

if S_form == T_form:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict
sdic,tdic=defaultdict(int),defaultdict(int)
s=input()
t=input()

def count(str,dic):
    for i in str:
        dic[i]+=1
    dic=sorted(dic.items(),key=lambda x:x[1])
    lst=[]
    for i in range(len(dic)):
        lst.append(dic[i][1])
    return lst
  
slist=count(s,sdic); tlist=count(t,tdic)
if slist==tlist:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

if sorted(Sc.values()) == sorted(Tc.values()):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter

s = input().rstrip()
t = input().rstrip()

cs = Counter(s)
ct = Counter(t)
s_v = sorted(cs.values())
c_v = sorted(ct.values())

if len(s_v) != len(c_v):
    print('No')
else:
    for i1, i2 in zip(s_v, c_v):
        if i1 != i2:
            print('No')
            break
    else:
        print('Yes')

Submission status: Accepted

Solution code:
# PROXY

from collections import Counter
S = list(input())
T = list(input())
Tdup = sorted([e for e in set(T) if T.count(e) > 1], key=T.index)
Sdup = sorted([e for e in set(S) if S.count(e) > 1], key=S.index)
if len(T) == len(set(T)) and len(S) == len(set(S)):
    print("Yes")
elif len(S) != len(set(S)) and len(T) != len(set(T)) and len(Sdup) == len(Tdup):
    counter = 0
    while counter < len(Tdup):
        Tdupid = [i for i, x in enumerate(T) if x == Tdup[counter]]
        Sdupid = [i for i, x in enumerate(S) if x == Sdup[counter]]
        if Tdupid != Sdupid:
            print("No")
            break
        else:
            counter += 1
    else:
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  t=S()

  # a〜z
  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']

  l1=['']*26
  l2=['']*26

  for i in range(len(s)):
    if l1[l.index(s[i])]!='':
      if l1[l.index(s[i])]!=t[i]:
        return 'No'
    else:
      l1[l.index(s[i])]=t[i]

  for i in range(len(s)):
    if l2[l.index(t[i])]!='':
      if l2[l.index(t[i])]!=s[i]:
        return 'No'
    else:
      l2[l.index(t[i])]=s[i]

  return 'Yes'

print(main())

Submission status: Accepted

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

n=len(s)
az=list('abcdefghijklmnopqrstuvwxyz')
ls=[set() for i in range(26)]
ls2=[set() for i in range(26)]
ans='Yes'
di=dict()
for i in range(n):
    ls[az.index(t[i])].add(s[i])
    ls2[az.index(s[i])].add(t[i])
for i in range(26):
    if len(ls[i])>1:
        ans='No'
    if len(ls2[i])>1:
        ans='No'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

import sys

input = sys.stdin.readline

def main():
    S = input().strip()
    T = input().strip()
    m = {}
    for i in range(len(T)):
        if T[i] in m:
            if m[T[i]] != S[i]:
                print("No")
                return
        m[T[i]] = S[i]

    T2 = T[:]
    for i in range(len(S)):
        if S[i] == T2[i]:
            continue
        from_c = T2[i]
        to_c = S[i]
        T2 = T2.translate(str.maketrans({from_c: to_c, to_c: from_c}))

    if S != T2:
        print("No")
    else:
        print("Yes")

main()

Submission status: Accepted

Solution code:
from bisect import bisect, bisect_left
from collections import Counter, defaultdict
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor, mul

import sys
#input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))
S = input()
T = input()
P = defaultdict(set)

for i in range(len(S)):
    P[S[i]].add(T[i])
    

for v in P.values():
    if len(v) >= 2:
        print("No")
        break
else:
    if Counter(Counter(S).values()) == Counter(Counter(T).values()):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
S = input()
T = input()
alph = [chr(i) for i in range(97, 97+26)]
flag = True
for a in alph:
    S_pos = [i for i in range(len(S)) if S[i] == a]
    T_pos = [i for i in range(len(T)) if T[i] == a]
    if len(S_pos) > 1:
        for i in S_pos:
            if T[i] != T[S_pos[0]]:
                flag = False
                break
    if len(T_pos) > 1:
        for i in T_pos:
            if S[i] != S[T_pos[0]]:
                flag = False
                break
    if not flag:
        break

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

Submission status: Accepted

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

_d = {}
for i, t in enumerate(T):
  if S[i] == _d.setdefault(t, S[i]):
    continue
  else:
    print('No')
    break
else:
  if len(set([k for k,v in _d.items()]))==len(set([v for k,v in _d.items()])):
  	print('Yes')
  else:
    print('No')