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:
first = str(input())
second = str(input())
"""
def cycleis(start, dici, seen):
    curr = start
    #print("Curr: {}".format(curr))
    while seen[curr] != 1:
        #print("Bent Curr: {}".format(curr))
        seen[curr] = 1
        curr = dici[curr]
        if curr not in seen:
            return True

    if curr == start:
        return True
    else:
        return False
"""
good = True
dici = {}
dici2 = {}
seen = {}
#Check if the same thing goes to the same 
for i in range(0,len(first)):
    if first[i] in dici:
        if second[i] != dici[first[i]]:
            print("No",end='')
            good = False
            #print("A hiba: {} -> {}-ba megy itt meg {}-be kene".format(first[i], dici[i], second[i]))
            break
    else:
        dici[first[i]] = second[i]

    if second[i] in dici2:
        if first[i] != dici2[second[i]]:
            print("No", end='')
            good = False
            break
    else:
        dici2[second[i]] = first[i]

    #if first[i] not in seen:
    #    seen[first[i]] = 0

#print("Seen: {}, Dici: {}".format(seen,dici))
#Final check if a->c->a if c was in first.
"""
for i in dici.keys():
    if cycleis(i, dici, seen) == False:
        print("No", end='')
        good = False
        break"""
"""
for i in dici.keys():
    if dici[i] in dici:
        if dici[dici[i]] != i:
            print("A hiba: {} -> {}-ba megy itt meg {}-be kene".format(i, dici[i], dici[dici[i]]))
            good = False
            print("No", end='')
            break
"""
if good:
    print("Yes",end='')

Submission status: Accepted

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

direct_graph1 = {}
direct_graph2 = {}
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
for i in list(ascii_lowercase):
    direct_graph1[i] = None
    direct_graph2[i] = None

flg = 0
for s,t in zip(S,T):
    if direct_graph1[s] == None or direct_graph1[s] == t:
        direct_graph1[s] = t
    else:
        flg =1
    
    if direct_graph2[t] == None or direct_graph2[t] == s:
        direct_graph2[t] = s
    else:
        flg = 1

    if flg == 1:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
s=input()
t=input()
s1={}
t1={}
for i in range(len(s)):
    if s[i] in s1 and t[i] in t1:
        if s1[s[i]]!=t1[t[i]]:
            print("No")
            break
    elif s[i] not in s1 and t[i] not in t1:
        s1[s[i]]=i
        t1[t[i]]=i
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
from collections import defaultdict

def s2i(z):
    ret = []
    nz = defaultdict(int)
    for i in range(len(z)):
        if z[i] in nz:
            ret.append(nz[z[i]])
        else:
            x = len(nz) + 1
            ret.append(x)
            nz[z[i]] = x
    return ret

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

Submission status: Accepted

Solution code:
s=input()
t=input()
d=dict()
flag=True
ds=set()
for i in range(len(s)):

  if not(t[i] in d):
    if s[i] in ds:
      flag=False
      break
    d[t[i]]=s[i]
    ds.add(s[i])
  else:
    if d[t[i]]!=s[i]:
      flag=False
      break
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    d = dict()
    for s, t in zip(S, T):
        if s not in d.keys():
            if t in d.values():
                print('No')
                return
            d[s] = t
        else:
            if d[s] != t:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S, T = input(), input()
d = dict()
count = 0
S_list = []
for c in S:
    try:
        n = d[c]
    except:
        d[c] = n = count
        count += 1
    S_list.append(n)
d = dict()
count = 0
for m, c in zip(S_list, T):
    try:
        n = d[c]
    except:
        d[c] = n = count
        count += 1
    if n != m:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
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

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定



# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
s = input()
t = input()
n = len(s)
yes = True
x = [-1 for i in range(26)]
y = [-1 for i in range(26)]
for i in range(n):
    a = ord(s[i]) - 97
    b = ord(t[i]) - 97
    if x[a] != -1 or y[b] != -1:
        if x[a] != b or y[b] != a:
            yes = False
            break
    x[a] = b
    y[b] = a
if yes:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import math
import sys
import bisect
import heapq # 優先度付きキュー(最小値取り出し)

inf = 10**15
mod = 10**9+7
s = list(input())
t = list(input())
dict = {}
dict_t = {}
s_judge = [True for i in range(26)] # 全種類使っていない
t_judge = [True for i in range(26)] # 全種類使っていない
aint = ord('a')
flag = True
for i,c in enumerate(s):
    tmp = t[i]
    sint = ord(c)-aint
    tint = ord(tmp)-aint
    if s_judge[sint]:
        dict[sint] = tint
        s_judge[sint] = False
    else:
        if dict[sint] != tint:
            flag = False
            break
    if t_judge[tint]:
        dict_t[tint] = sint
        t_judge[tint] = False
    else:
        if dict_t[tint] != sint:
            flag = False
            break
if flag:
    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:
s = input().strip()
t = input().strip()


def get_patten(l):
    pattern = []
    d = dict()
    i = ord('a')
    for c in l:
        if c not in d:
            d[c] = chr(i)
            i += 1
        pattern.append(d[c])
    return pattern


ps = get_patten(s)
pt = get_patten(t)

if ps == pt:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import exit

s=input()
t=input()
alp=[0]*26
for i in range(len(s)):
	if alp[ord(s[i])-97]==0:
		alp[ord(s[i])-97]=t[i]
	else:
		if alp[ord(s[i])-97]!=t[i]:
			print("No")
			exit()
			
alp=[0]*26
for i in range(len(t)):
	if alp[ord(t[i])-97]==0:
		alp[ord(t[i])-97]=s[i]
	else:
		if alp[ord(t[i])-97]!=s[i]:
			print("No")
			exit()

print("Yes")

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


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

    sl = dict()
    tl = dict()
    for s, t in zip(S, T):
        if s not in sl:
            sl[s] = t
        else:
            if sl[s] != t:
                print('No')
                break

        if t not in tl:
            tl[t] = s
        else:
            if tl[t] != s:
                print('No')
                break
    else:
        print('Yes')


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def rle(l):
    hoge = list(set(l))
    huga = []
    for i in hoge:
        huga.append(l.count(i))
    huga.sort()
    return huga

def solve():
    s = list(input())
    t = list(input())
    if rle(s) == rle(t):
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# AtCoder
from collections import Counter
S = list(input())
T = list(input())
if sorted(Counter(S).values()) == sorted(Counter(T).values()):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    s = input()
    t = input()
    s_first_appeared = dict()
    s_replaced = [i for i in range(len(s))]
    for i, char in enumerate(s):
        if char not in s_first_appeared:
            s_first_appeared[char] = i
        else:
            s_replaced[i] = s_first_appeared[char]
    t_first_appeared = dict()
    t_replaced = [i for i in range(len(t))]
    for i, char in enumerate(t):
        if char not in t_first_appeared:
            t_first_appeared[char] = i
        else:
            t_replaced[i] = t_first_appeared[char]
    print('Yes') if s_replaced == t_replaced else print('No')





if __name__ == "__main__":
    main()

Submission status: Accepted

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

Ms = defaultdict(int)
Mt = defaultdict(int)

for i in range(len(S)):
    Ms[S[i]] += 1
    Mt[T[i]] += 1

ans = "Yes"

A = list(Ms.values())
A.sort()
B = list(Mt.values())
B.sort()

for i in range(len(A)):
    if A[i] != B[i]:
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
S = input().rstrip()
T = input().rstrip()
from collections import defaultdict
s2t = defaultdict(int)
t2s = defaultdict(int)
for s,t in zip(S,T):
    if (s2t[s] != 0 and s2t[s] != t) or (t2s[t] != 0 and t2s[t] != s):
        print('No')
        exit()
    s2t[s] = t
    t2s[t] = s
print('Yes')

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline

def myindex(l, s):
    if s in l:
        return l.index(s)
    else:
        return len(l)

def main():
    S = list(readline()[:-1])
    T = list(readline()[:-1])
    tmpS = []; tmpT = []
    cntS = 0; cntT = 0
    flag = True
    for i in range(len(S)):
        cntS = myindex(tmpS, S[i])
        cntT = myindex(tmpT, T[i])
        tmpS.append(S[i])
        tmpT.append(T[i])
        if cntS != cntT:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
import string
#======================================================#

def check(t, sidx):
    for idx in sidx.values():
        if idx:
            tmp = set()
            for i in idx:
                tmp.add(t[i])
            if len(tmp) > 1:
                return False
    return True

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

    sidx = {a: [] for a in string.ascii_lowercase}
    tidx = {a: [] for a in string.ascii_lowercase}
    for i, si in enumerate(s): sidx[si].append(i)
    for i, ti in enumerate(t): tidx[ti].append(i)

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

if __name__ == '__main__':
    main()

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:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
import string
#======================================================#

def main():
    s = IS()
    t = IS()
    tidx = {a: [] for a in string.ascii_lowercase}
    sidx = {a: [] for a in string.ascii_lowercase}
    for i, ti in enumerate(t):
        tidx[ti].append(i)
    for i, si in enumerate(s):
        sidx[si].append(i)
    for k, idx in tidx.items():
        tmp = set()
        for i in idx:
            tmp.add(s[i])
        if len(tmp) > 1:
            print('No')
            return None
    for k, idx in sidx.items():
        tmp = set()
        for i in idx:
            tmp.add(t[i])
        if len(tmp) > 1:
            print('No')
            return None
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

used = [False]*26
d = defaultdict(str)

flg = True
for i in range(len(S)):
    if S[i] in d:
        if d[S[i]] != T[i]:
            flg = False

    else:
        d[S[i]] = T[i]
        if used[ord(T[i])-ord('a')] is True:
            flg = False
        used[ord(T[i])-ord('a')] = True

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

Submission status: Accepted

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

keep=[0]*26
moji=["0"]*26
res=1

for i in range(0,len(s)):
  moji_s=s[i]
  moji_t=t[i]
  s_num=ord(moji_s)-97
  t_num=ord(moji_t)-97
  if keep[s_num]==0:
    keep[s_num]=1
    moji[s_num]=moji_t
  else:
    if moji[s_num]!=moji_t:
      res=0
      break
  kepkep=moji[s_num]
  moji[s_num]="0"
  if moji_t in moji:
    res=0
    break
  moji[s_num]=kepkep

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

Submission status: Accepted

Solution code:
import sys

S = str(input())
T = str(input())

jisho_s = {}
jisho_t = {}
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s in jisho_s and jisho_s[s] != t:
        print("No")
        sys.exit()
    if t in jisho_t and jisho_t[t] != s:
        print("No")
        sys.exit()
    if s not in jisho_s:
        jisho_s[s] = t
    if t not in jisho_t:
        jisho_t[t] = s

print("Yes")

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    t=input()
    s_lis=[[] for _ in range(32)]
    t_lis=[[] for _ in range(32)]
    for i,ss in enumerate(s):
        s_lis[ord(ss)-ord('a')].append(i)
    for i,tt in enumerate(t):
        t_lis[ord(tt)-ord('a')].append(i)
    ss_lis=[sl for sl in s_lis if len(sl)>0]
    tt_lis=[tl for tl in t_lis if len(tl)>0] 
    ss_lis.sort()
    tt_lis.sort()
    if all([True if x==y else False for x,y in zip(ss_lis,tt_lis)]):
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    main()

Submission status: Accepted

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

    st = dict()
    ts = dict()
    cond = True
    for sc, tc in zip(s, t):
        if st.get(sc, None) is None:
            st[sc] = tc
        if st[sc] != tc:
            cond = False
            break
        if ts.get(tc, None) is None:
            ts[tc] = sc
        if ts[tc] != sc:
            cond = False
            break

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


if __name__ == '__main__':
    main()

# s->tで、ある文字に対し,2文字以上の対応はできない
# t->sで、ある文字に対し,2文字以上の対応はできない
# s->tで、ある文字に対し,どの文字にも対応しないということはない（が気にしない）
# t->sで、ある文字に対し,どの文字にも対応しないということはない（が気にしない）
# 未対応があるとき26文字種出ていれば、重複が出ているし、
# 出ていない文字種があれば、未対応は隠れてしまう

Submission status: Accepted

Solution code:
import collections
S, T = input(), input()

S_char_count = [[c, n] for c, n in collections.Counter(S).items()]
T_char_count = [[c, n] for c, n in collections.Counter(T).items()]
S_char_count.sort(key=lambda S_char_count: S_char_count[1])
T_char_count.sort(key=lambda T_char_count: T_char_count[1])

ans = 'Yes'
if len(S_char_count) == len(T_char_count):
  for i in range(len(S_char_count)):
    if S_char_count[i][1] != T_char_count[i][1]:
      ans = 'No'
      break
else:
  ans = 'No'

print(ans)

Submission status: Accepted

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

s_c = sorted(Counter(s).values())
t_c = sorted(Counter(t).values())

if s_c==t_c:print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

s = input()
t = input()
c1 = collections.Counter(s)
c2 = collections.Counter(t)
value1 = []
value2 = []
for value in c1.values():
    value1.append(value)
for value in c2.values():
    value2.append(value)
value1.sort(),value2.sort()
if value1 == value2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

for i in range(N):
    if memo_s[S[i]] == -1 and memo_t[T[i]] == -1:
        memo_s[S[i]] = T[i]
        memo_t[T[i]] = S[i]
    else:
        if memo_s[S[i]] != T[i] or memo_t[T[i]] != S[i]:
            print("No")
            quit()

print("Yes")

Submission status: Accepted

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

R1 = [-1] * 26
R2 = [-1] * 26

l = len(S)
ord_a = ord("a")

for i in range(l):
    s = ord(S[i]) - ord_a
    t = ord(T[i]) - ord_a
    if R1[s] < 0:
        R1[s] = t
    else:
        if R1[s] != t:
            print("No")
            exit()
    if R2[t] < 0:
        R2[t] = s
    else:
        if R2[t] != s:
            print("No")
            exit()

print("Yes")

Submission status: Accepted

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

start = {chr(i):-1 for i in range(97,97+26)}
goal = {chr(i):-1 for i in range(97,97+26)}
ans = 'Yes'
for i in range(N):
    s = S[i]
    t = T[i]
    if start[s] != -1 and start[s] != t:
        ans = 'No'
    if goal[t] != -1 and goal[t] != s:
        ans = 'No'
    start[s] = t
    goal[t] = s

print(ans)

Submission status: Accepted

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

start = [-1 for i in range(26)]
goal = [-1 for i in range(26)]
a = ord('a')
ans = 'Yes'
for i in range(N):
    s = ord(S[i])-a
    t = ord(T[i])-a
    if start[s] != -1 and start[s] != t:
        ans = 'No'
    if goal[t] != -1 and goal[t] != s:
        ans = 'No'
    start[s] = t
    goal[t] = s

print(ans)

Submission status: Accepted

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

start = [-1 for i in range(26)]
goal = [-1 for i in range(26)]
a = ord('a')
ans = 'Yes'
for i in range(N):
    s = ord(S[i])-a
    t = ord(T[i])-a
    if start[s] != -1 or goal[t] != -1:
        if start[s] != t or goal[t] != s:
            ans = 'No'
    start[s] = t
    goal[t] = s


print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
N = len(S)
 
d = {chr(i):chr(i) for i in range(97,97+26)}
 
ans = 'Yes'
for i in range(N):
    now_si = d[S[i]]
    for k,v in d.items():
        if v == now_si:
            d[k] = T[i]
        elif v == T[i]:
            d[k] = now_si
 
for i in range(N):
    if d[S[i]] != T[i]:
        ans = 'No'
        break
 
 
print(ans)

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

S = input()
T = input()

if S==T:
    print("Yes")
    exit()

ls1 = ["?"]*26
ls2 = ["?"]*26
for i in range(len(S)):
    s = S[i]
    t = T[i]
    no1 = ord(s) - 97
    no2 = ord(t) - 97
    if ls1[no1]=="?":
        ls1[no1] = t
    else:
        if ls1[no1]==t:
            pass
        else:
            print("No")
            exit()
    if ls2[no2]=="?":
        ls2[no2] = s
    else:
        if ls2[no2]==s:
            pass
        else:
            print("No")
            exit()

print("Yes")
exit()