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 = str(input())
t = str(input())
ds = {chr(i+97): -1 for i in range(26)}
dt = {chr(i+97): -1 for i in range(26)}
for i in range(len(s)):
    if ds[s[i]] >= 0:
        if ds[s[i]] != ord(t[i]):
            print('No')
            break
    if dt[t[i]] >= 0:
        if dt[t[i]] != ord(s[i]):
            print('No')
            break
    if ds[s[i]] < 0:
        ds[s[i]] = ord(t[i])
    if dt[t[i]] < 0:
        dt[t[i]] = ord(s[i])
else:
    print('Yes')

Submission status: Accepted

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

m = dict()

for a, b in zip(s, t):
    if a in m and b != m[a]:
        print('No')
        exit()

    m[a] = b

if len(m) == len(set(m.values())):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = input()
b = input()
dic = {}

for i in range(len(a)):
  if not b[i] in dic:
    dic[b[i]] = a[i]
  else:
    if dic[b[i]] != a[i]:
      print("No")
      quit()
  #print(dic)
c = list(dic.values())
d = set(c)
#print(c)
#print(d)
if len(c) == len(d):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s=input()
t=input()
n=len(s)
s=sorted(s)
t=sorted(t)
Lists={}
nums=[]
Listt={}
numt=[]

for i in range(n):
    Lists.setdefault(s[i], 0)
    Listt.setdefault(t[i], 0)
    Lists[s[i]]+=1
    Listt[t[i]]+=1
    
for j in Lists.values():
    nums.append(j)
    
for j in Listt.values():
    numt.append(j)
#print(nums)
#print(numt)
#nums=sorted(Lists.values)
#numt=sorted(Listt.values)

if (sorted(nums)==sorted(numt)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
s = input()
t = input()
dic = {'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25}
sl = [0]*26
tl = [0]*26
for i in s: sl[dic[i]] += 1
for i in t: tl[dic[i]] += 1
sl.sort()
tl.sort()
for i in range(26):
    if sl[i] != tl[i]:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

S = input()
T = input()

S_dic = defaultdict(list)
T_dic = defaultdict(list)

for i in range(len(S)):
	S_dic[S[i]].append(i)
	T_dic[T[i]].append(i)

if sorted(S_dic.values()) == sorted(T_dic.values()):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
# C - String Transformation

S = list(str(input()))
T = list(str(input()))
l = len(S)
d = set()

ans = 'Yes'
for i in range(l):
    if S[i] != T[i]:
        tmp = S[i]
        if S[i] in d or T[i] in d:
            ans = 'No'
            break
        d.add(T[i])
        for j in range(i, l):
            if S[j] == tmp:
                S[j] = T[i]
            elif S[j] == T[i]:
                S[j] = tmp
    else:
        d.add(T[i])

print(ans)

Submission status: Accepted

Solution code:
def solve(s, t):
    dic1, dic2 = {}, {}
    for x, y in zip(s, t):
        if x in dic1:
            if dic1[x] != y:
                return False
        else:
            dic1[x] = y
        if y in dic2:
            if dic2[y] != x:
                return False
        else:
            dic2[y] = x
    return True


s = input()
t = input()

print('Yes' if solve(s, t) else 'No')

Submission status: Accepted

Solution code:
S=list(input())
T=list(input())
slist=[None]*26
flag=True
for i in range(len(S)):
    if slist[ord(S[i])-97] == None and T[i] not in slist:
        slist[ord(S[i])-97] = T[i]
    elif slist[ord(S[i])-97] != T[i]:
        flag = False
        break
    else:
        slist[ord(S[i])-97] = T[i]


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

Submission status: Accepted

Solution code:
S = input()
T = input()
N = len(S)
dictXY = {}
dictYX = {}
for i in range(N):
    X = S[i]
    Y = T[i]
    if X in list(dictXY.keys()):
        dictXY[X].append(Y)
    else:
        dictXY[X] = [Y]
    if Y in list(dictYX.keys()):
        dictYX[Y].append(X)
    else:
        dictYX[Y] = [X]

al=[chr(ord('a') + i) for i in range(26)]

flag = 0
for Z in al:
    if Z in list(dictXY.keys()):
        if len(set(dictXY[Z]))>1:
            flag = 1
    if Z in list(dictYX.keys()):
        if len(set(dictYX[Z]))>1:
            flag = 1
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    S = input()
    T = input()
    """
    置換が互換の積でかけることから、S->Tの変換がアルファベットの置換で表現できればよい。
    """
    d = {chr(i + 97): -1 for i in range(26)}
    d_inv = {chr(i + 97): -1 for i in range(26)}
    for i, s in enumerate(S):
        t = T[i]
        if d[s] != -1 or d_inv[t] != -1:
            if d[s] != t or d_inv[t] !=s:
                print("No")
                return
        d[s] = t
        d_inv[t] = s
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def examA():
    A = LI()
    A.sort()
    ans = A[2]*10+A[1]+A[0]
    print(ans)
    return

def examB():
    N, M, x, y = LI()
    X = LI()
    Y = LI()
    X.sort(); Y.sort()
    if max(X[-1],x)<min(Y[0],y):
        print("No War")
    else:
        print("War")
    return

def examC():
    S = SI()
    T = SI()
    N = len(S)
    Ds = defaultdict(str)
    Dt = defaultdict(str)
    for i in range(N):
        s = S[i]; t = T[i]
        if Ds[s]!="" and Ds[s]!=t:
            print("No")
            return
        Ds[s] = t
        if Dt[t] != "" and Dt[t] != s:
            print("No")
            return
        Dt[t] = s
    print("Yes")
    return

def examD():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

counter_s = Counter(S)
counter_t = Counter(T)

# print(counter_s, counter_t)
s_value = sorted(counter_s.values())
t_value = sorted(counter_t.values())

# print(s_value, t_value)
if s_value == t_value:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
S={}
T={}
for i in s:
    if i in S.keys():
        S[i]+=1
    else:
        S[i]=1
for i in t:
    if i in T.keys():
        T[i]+=1
    else:
        T[i]=1
Svalues=sorted(S.values())
Tvalues=sorted(T.values())
if Tvalues==Svalues:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s,t=[sorted(t.count(i)for i in set(t))for t in open(0)]
print('YNeos'[s!=t::2])

Submission status: Accepted

Solution code:
s,t=map(lambda x:sorted(x.count(i)for i in set(x)),open(0))
print('YNeos'[s!=t::2])

Submission status: Accepted

Solution code:
from collections import Counter
s1 = sorted(list(dict(Counter(input())).values()))
t1 = sorted(list(dict(Counter(input())).values()))
print(['No', 'Yes'][s1 == t1])

Submission status: Accepted

Solution code:
from collections import Counter
S = Counter(list(input()))
T = Counter(list(input()))
if len(S) != len(T):
    print("No")
else:
    Sv = []
    Tv = []
    for v in S.values():
        Sv.append(v)
    for v in T.values():
        Tv.append(v)
    Svc = Counter(Sv)
    Tvc = Counter(Tv)
    if Svc == Tvc:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s_to_t = {chr(c):set() for c in range(ord('a'),ord('z')+1)}
t_to_s = {chr(c):set() for c in range(ord('a'),ord('z')+1)}

for i in range(len(s)):
    s_to_t[s[i]].add(t[i])
    t_to_s[t[i]].add(s[i])

for c in range(ord('a'), ord('z')+1):
    if len(s_to_t[chr(c)]) > 1 or len(t_to_s[chr(c)]) > 1:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
s = input()
t = input()
d = {}
d2 = {}
for i in range(len(s)):
  if t[i] in d:
    if d[t[i]] != s[i]:
      print("No")
      break
  if s[i] in d2:
    if d2[s[i]] != t[i]:
      print("No")
      break
  else:
    d[t[i]] = s[i]
    d2[s[i]] = t[i]
else:
  print("Yes")

Submission status: Accepted

Solution code:
S=input()
T=input()
s=dict()
for i in range(len(S)):
    a=S[i]
    if a in s:
        s[a]+=1
    else:
        s[a]=1

t=dict()
for i in range(len(T)):
    a=T[i]
    if a in t:
        t[a]+=1
    else:
        t[a]=1

l=[]
r=[]
for idx in s:
    a=s[idx]
    l.append(a)
for idx in t:
    a=t[idx]
    r.append(a)

l.sort()
r.sort()
if len(l)!=len(r):
    print("No")
    exit()
for i in range(len(l)):
    if l[i]==r[i]:
        pass
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

# input
S = list(input())
S = "".join(sorted(S))
T = list(input())
T = "".join(sorted(T))

# check
counter_s = Counter(S).most_common()
counter_t = Counter(T).most_common()

if len(counter_t) != len(counter_s):
    print("No")
elif S == T:
    print("Yes")
else:
    c_match = [True] * len(counter_t)
    for i in range(len(counter_t)):
        co_s = counter_s[i][1]
        co_t = counter_t[i][1]

        if co_s != co_t:
            c_match[i] = False

    if c_match.count(False) == 0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

sd={}
td={}
cond=True
for i in range(len(S)):
    if S[i] not in sd:
        sd[S[i]]=T[i]
    else:
        if sd[S[i]]!=T[i]:
            cond=False
            break
    if T[i] not in td:
        td[T[i]]=S[i]
    else:
        if td[T[i]]!=S[i]:
            cond=False
            break

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

Submission status: Accepted

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

#alp={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}
#bet={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}

sd={}
td={}
cond=True
for i in range(len(S)):
    if S[i] not in sd:
        sd[S[i]]=T[i]
    else:
        if sd[S[i]]!=T[i]:
            cond=False
            break
    if T[i] not in td:
        td[T[i]]=S[i]
    else:
        if td[T[i]]!=S[i]:
            cond=False
            break

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

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
s_appeared = [0] * 26
t_appeared = [0] * 26
for i in range(len(S)):
    if S[i] != T[i]:
        s_temp = s_appeared[ord(S[i])-97]
        if s_temp == 0:
            s_appeared[ord(S[i])-97] = T[i]
        else:
            if T[i] != s_temp:
                print('No')
                break

        t_temp = t_appeared[ord(T[i])-97]
        if t_temp == 0:
            t_appeared[ord(T[i])-97] = S[i]
        else:
            if S[i] != t_temp:
                print('No')
                break
    else:
        s_appeared[ord(S[i])-97] = T[i]
        t_appeared[ord(T[i])-97] = S[i]
else:
    print('Yes')

Submission status: Accepted

Solution code:
a=input()
b=input()

memo = []

def swap(word,x,y):
	word=word.replace(x,'+')
	word=word.replace(y,'-')
	word=word.replace('+',y)
	word=word.replace('-',x)
	return word
	
for i in range(len(a)):
	if a[i] != b[i]:
		if a[i] in memo or b[i] in memo:
			print('No')
			break
		else:
			a=swap(a,a[i],b[i])
			memo.append(a[i])
			memo.append(b[i])
	
else:
	if a==b:
		print('Yes')
	else:
		print('No')

Submission status: Accepted

Solution code:
import sys

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

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

for i in range(len(s)):
  a=int(ord(s[i]))-97
  b=int(ord(t[i]))-97

  if start[a]!=-1 or goal[b]!=-1:
    if start[a]!=b or goal[b]!=a:
      print('No')
      sys.exit()
  start[a]=b
  goal[b]=a

print('Yes')

Submission status: Accepted

Solution code:
s = input()
t = input()
R1 = {i:-1 for i in "abcdefghijklmnopqrstuvwxyz"}
R2 = {i:-1 for i in "abcdefghijklmnopqrstuvwxyz"}
for i in range(len(s)):
    if R1[s[i]] != -1:
        if R1[s[i]] != t[i]:
            print("No")
            break
    else:
        R1[s[i]] = t[i]
    if R2[t[i]] != -1:
        if R2[t[i]] != s[i]:
            print("No")
            break
    else:
        R2[t[i]] = s[i]
else:
    print("Yes")

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

s = S()
T = S()
S = s
N = len(S)

dicS = DD(lambda: [])
dicT = DD(lambda: [])

for i in range(N):
  dicS[S[i]].append(i)
  dicT[T[i]].append(i)

l1 = list(dicS.values())
l2 = list(dicT.values())
l1.sort()
l2.sort()

if l1==l2:
  YE()
NE()

Submission status: Accepted

Solution code:
S=input()
T=input()
from collections import defaultdict
ds = defaultdict(str)
dt = defaultdict(str)
for s,t in zip(S,T):
  if ds[s]=='' or ds[s]==t:
    ds[s]=t
  else:
    print('No')
    exit(0)
  if dt[t]=='' or dt[t]==s:
    dt[t]=s
  else:
    print('No')
    exit(0)
print('Yes')

Submission status: Accepted

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

l = len(s)
d1 = dict()
d2 = dict()

for i in range(l):
    if s[i] not in d1:
        d1[s[i]] = t[i]
    elif d1[s[i]] != t[i]:
        print("No")
        exit()

for i in range(l):
    if t[i] not in d2:
        d2[t[i]] = s[i]
    elif d2[t[i]] != s[i]:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
T = input()

s = [[] for _ in range(26)]
t = [[] for _ in range(26)]

l = len(S)

for i in range(l):
    s[ord(S[i]) - ord('a')].append(i)
    t[ord(T[i]) - ord('a')].append(i)


def ok():
    ch = [False] * 26
    for i in range(l):
        if not ch[ord(S[i]) - ord('a')]:
            ch[ord(S[i]) - ord('a')] = True
            ls = s[ord(S[i]) - ord('a')]
            lt = t[ord(T[i]) - ord('a')]
            if ls != lt:
                return False
    return True

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

Submission status: Accepted

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

n=len(s)
s_d={}
t_d={}
s_n=[]
t_n=[]
s_cnt=1
t_cnt=1

for s_i, t_i in zip(s,t):

    if s_i in s_d:
        s_n.append(s_d[s_i])
    else:
        s_d[s_i]=s_cnt
        s_cnt+=1
        s_n.append(s_d[s_i])

    if t_i in t_d:
        t_n.append(t_d[t_i])
    else:
        t_d[t_i]=t_cnt
        t_cnt+=1
        t_n.append(t_d[t_i])

print('Yes' if s_n==t_n else 'No')

Submission status: Accepted

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

go = []
back = []
g = []
b = []
def has_duplicates(seq):
    return len(seq) != len(set(seq))


for i in range(len(s)):
  go.append(s[i]+t[i])
  back.append(t[i]+s[i])

go_l = set(go)
back_l = set(back)
go = list(go_l)
back = list(back_l)

#print(go)
#print(back)

for i in range(len(go)):
  g.append(go[i][0])
  b.append(back[i][0])
  
#print(g)
#print(b)
  
ansg = has_duplicates(g)
ansb = has_duplicates(b)

if ansg == True or ansb == True:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    s = list(input()[:-1])
    t = list(input()[:-1])
    N = len(s)
    S = {}
    T = {}
    t_si = 0
    t_ti = 0
    n_s = []
    n_t = []
    for si, ti in zip(s, t):
        if not si in S:
            S[si] = t_si
            n_s.append(t_si)
            t_si += 1
        else:
            n_s.append(S[si])
        if not ti in T:
            T[ti] = t_ti
            n_t.append(t_ti)
            t_ti += 1
        else:
            n_t.append(T[ti])

    for si, ti in zip(n_s, n_t):
        if si != ti:
            print('No')
            exit()
    print('Yes')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
s = input()
z = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
s_alpha = [[] for _ in range(26)]
z_alpha = [[] for _ in range(26)]
for num, i in enumerate(s):
    pos = alpha.index(i)
    s_alpha[pos].append(num)
for num, i in enumerate(z):
    pos = alpha.index(i)
    z_alpha[pos].append(num)
s_alpha.sort()
z_alpha.sort()
if s_alpha == z_alpha:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def String_kind(S):
    S_kind,S_kind_num,count = set(),{},0
    OP = []
    for i in range(len(S)):
        if S[i] not in S_kind:
            S_kind.add(S[i])
            S_kind_num[S[i]] = count
            count += 1
        OP.append(S_kind_num[S[i]])

    return OP

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

    S_kind,T_kind = String_kind(S),String_kind(T)
    if S_kind == T_kind:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():

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

    d = dict()
    d_inv = dict()
    for i in range(len(S)):
        if S[i] not in d:
            if T[i] in d_inv:
                return "No"
            else:
                d[S[i]] = T[i]
                d_inv[T[i]] = S[i]
        else:
            if d[S[i]] != T[i]:
                return "No"
    return "Yes"
        
if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
from collections import Counter

S=input()
T=input()
A=dict(Counter(list(S)))
B=dict(Counter(list(T)))

ans="Yes"
for m in A:
  for n in B:
    if A[m]==B[n]:
      del B[n]
      break
  else:
    ans="No"
    break
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

ms = defaultdict(str)
mt = defaultdict(str)
for i in range(n):
    if ms[s[i]] == '':
        ms[s[i]] = t[i]
    if mt[t[i]] == '':
        mt[t[i]] = s[i]
    if ms[s[i]] != t[i] or mt[t[i]] != s[i]:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

a = [0 for i in range(26)]
n = len(s)
dict = {}
for i in range(n):
	x = ord(t[i]) - ord("a")
	if s[i] not in dict:
		dict[s[i]] = t[i]
		a[x] += 1
	else:
		if dict[s[i]] != t[i]:
			print ("No")
			exit()

for i in range(26):
	if a[i] >= 2:
		print ("No")
		exit()
print ("Yes")

Submission status: Accepted

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

my_d = dict()

for i, ch in enumerate(s):
    if ch not in my_d:
        if t[i] in my_d.values():
            print('No')
            exit()
        else:
            my_d[ch] = t[i]
    else:
        if my_d[ch] != t[i]:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

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

dict_S = {}
dict_T = {}

for i in range(N):
    # print("dict_S: {}".format(dict_S))
    # print("dict_T: {}".format(dict_T))
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    dict_S[S[i]] = T[i]
    dict_T[T[i]] = S[i]
print("Yes")

Submission status: Accepted

Solution code:
s=str(input())
t=str(input())
temp=["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"]
s=list(s)
t=list(t)
temps=[0]*len(temp)
tempt=[0]*len(temp)
for i in range(0,len(temp)):
  temps[i]=s.count(temp[i])
  tempt[i]=t.count(temp[i])
temps.sort()
tempt.sort()
if temps==tempt:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()
st_dict = {}
flag = True
for i in range(len(s)):
    if s[i] not in st_dict:
        if t[i] in st_dict.values():
            flag = False
            break
        else:
            st_dict[s[i]] = t[i]
            
    else:
        if st_dict[s[i]] != t[i]:
            flag = False
if flag:
    print('Yes')
    
else:
    print('No')

Submission status: Accepted

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

my_d = dict()

for i, ch in enumerate(s):
    if ch not in my_d:
        if t[i] in my_d.values():
            print('No')
            exit()
        else:
            my_d[ch] = t[i]
    else:
        if my_d[ch] != t[i]:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys

S = input()
T = input()

changes = {}
changes_reverse = {}
for i in range(len(T)):
    #print(changes)
    if S[i] != T[i]:
        if S[i] in changes:
            if changes[S[i]] != T[i]:
                print('No')
                sys.exit(0)
        if T[i] in changes_reverse:
            if changes_reverse[T[i]] != S[i]:
                print('No')
                sys.exit(0)

        changes[S[i]] = T[i]
        changes_reverse[T[i]] = S[i]
    else:
        changes[S[i]] = T[i]
        changes_reverse[T[i]] = S[i]
        

print('Yes')
# print(changes)

Submission status: Accepted

Solution code:
S = input()
T = input()
dic1={}
dic2={}
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s!=t:
        if (s not in dic1) and (t not in dic2):
            dic1[s]=t
            dic2[t]=s
        elif (s in dic1) and (t in dic2):
            if dic1[s]!=t:
                print('No')
                break
            else:
                continue
        else:
            print('No')
            break
    else:
        dic1[s]=t
        dic2[t]=s
else:
    print('Yes')

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

S = input()
T = input()

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

# azzelをappleにするとき
# 問題参照

# aplezをappleにする時
# c1 = z c2 = aにすると
# apleaにできる
# c1 = a, c2 = pにすると
# aalep ⇄ できない

# Sの文字列にaがi1個、bがi2個,,,
# Tの文字列にaがj1個、bがj2個,,,あるとすると
# sort(i1, i2...)とsort(j1, j2...)が一致していればいい
# 構成要素の個数の集合が一致していればいい
if sorted(s.values()) == sorted(t.values()):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

s = S()
t = S()
l = len(s)
S_Alphabet = [-1]*26
T_Alphabet = [-1]*26
# ord('a') = 97
for i in range(l):
    si = ord(s[i])-97
    ti = ord(t[i])-97
    if S_Alphabet[si] == -1:
        S_Alphabet[si] = ti
    else:
        if S_Alphabet[si] == ti:
            continue
        else:
            print("No")
            exit()
    if T_Alphabet[ti] == -1:
        T_Alphabet[ti] = si
    else:
        if T_Alphabet[ti] == si:
            continue
        else:
            print("No")
            exit()
else:
    print("Yes")

Submission status: Accepted

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

flg=True

def dic(DIC,str):
    for num in range(len(str)):
        if str[num] not in DIC:
            DIC[str[num]]=[num]
        else:
            DIC[str[num]].append(num)
    return DIC

D_S={}
D_T={}

D_S=dic(D_S,S)
D_T=dic(D_T,T)

if len(D_S)==len(D_T):
    for lst in D_S.values():
        if lst not in D_T.values():
            flg=False
else:
    flg=False

if flg==True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()
ds = dict()
dt = dict()
ni = 1
for i in range(len(s)):
    si = s[i]
    ti = t[i]
    if not si in ds:
        ds[si] = ni
        if ti in dt:
            print("No")
            exit()
        else:
            dt[ti] = ni
            ni += 1
    elif (not ti in dt) or (not ds[si] == dt[ti]):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
t = input()
n = len(s)
changed_s = defaultdict(list)
changed_t = defaultdict(list)
flag = True
used = []
for i in range(n):
    if s[i] != t[i]:
        changed_s[s[i]].append(t[i])
        changed_t[t[i]].append(s[i])
    else:
        used.append(s[i])

#print(changed_s)
#print(changed_t)
#print(used)
for key, lis in changed_s.items():
    if len(set(lis)) == 1 and key in used:
        flag = False
    elif len(set(lis)) != 1:
        flag = False
for key, lis in changed_t.items():
    if len(set(lis)) == 1 and key in used:
        flag = False
    elif len(set(lis)) != 1:
        flag = False
if flag:
    print("Yes")
else:
    print("No")