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: Wrong Answer

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)
d = dict()
for i in range(l):
    if not t[i] in d.keys():
        d[t[i]] = s[i]
    else:
        if d[t[i]] == s[i]:
            continue
        else:
            print("No")
            exit()
else:
    print("Yes")

Submission status: Wrong Answer

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

#print(changed_s)
#print(changed_t)
for lis in changed_s.values():
    if len(set(lis)) != 1:
        flag = False
for lis in changed_t.values():
    if len(set(lis)) != 1:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
s = input()
t = input()
n = len(s)
changed = defaultdict(list)
for i in range(n):
    if s[i] != t[i]:
        changed[s[i]].append(t[i])
#print(changed)
flag = True
for lis in changed.values():
    if len(set(lis)) != 1:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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 = {}
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 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: Wrong Answer

Solution code:
s=input()
t=input()
d=dict()
flag=True
for i in range(len(s)):
  if not(t[i] in d):
    d[t[i]]=s[i]
  else:
    if d[t[i]]!=s[i]:
      flag=False
      break
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
d=dict()
flag=True
for i in range(len(s)):
  if not(s[i] in d):
    d[s[i]]=t[i]
  else:
    if not(d[s[i]]==t[i]):
      flag=False
      break
    
ls=list(s)
if len(ls)==len(set(ls)):
  flag=True
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
d=dict()
flag=True
for i in range(len(s)):
  if not(s[i] in d):
    d[s[i]]=t[i]
  else:
    if not(d[s[i]]==t[i]):
      flag=False
      break
      
  if not(t[i] in d):
    d[t[i]]=s[i]
  else:
    if not(d[t[i]]==s[i]):
      flag=False
      break
ls=list(s)
if len(ls)==len(set(ls)):
  flag=True
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s =input()
t =input()
n = len(s)
d = {}
used = set([])

for i in range(n):
  if s[i] not in d:
    if t[i] in used:
      print('No')
      continue
    d[s[i]] = t[i]
    used.add(t[i])
  else:
    if d[s[i]] == t[i]:
      continue
    else:
      print('No')
      break
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
s =input()
t =input()
n = len(s)
d = {}
for i in range(n):
  if s[i] not in d:
    d[s[i]] = t[i]
  else:
    if d[s[i]] == t[i]:
      continue
    else:
      print('No')
      break
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter

S=input()
T=input()
N=len(S)
d=dict()

for i in range(N):
  if S[i]!=T[i]:
    if T[i] not in d:
      d[T[i]] = set(S[i])
    else:
      d[T[i]].add(S[i])
      
ans="Yes"
for pair in d:
  if len(d[pair])>1:
    ans="No"
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

S=input()
T=input()
N=len(S)
U=[]
V=[]

for i in range(N):
  if S[i]!=T[i]:
    U.append(S[i])
    V.append(T[i])
if len(U)%2!=0:
  print("No")
  exit()

ans="Yes"
A=dict(Counter(U))
B=dict(Counter(V))

U=sorted(B)
for i,a in enumerate(sorted(A)):
  if A[a]!=B[U[i]]:
    ans="No"
    break
                     
print(ans)

Submission status: Wrong Answer

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 == t:
            continue
        else:
            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: Wrong Answer

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()
    for i, s in enumerate(S):
        if s == T[i]:
            continue
        else:
            if s in sl.keys():
                if sl[s] != T[i]:
                    print('No')
                    sys.exit()
            elif s in sl.values():
                print('No')
                sys.exit()
            else:
                if T[i] in sl.values():
                    print('No')
                    sys.exit()
                else:
                    sl[s] = T[i]

    print('Yes')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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()
    for i, s in enumerate(S):
        if s == T[i]:
            continue
        else:
            if s in sl.keys():
                if sl[s] != T[i]:
                    print('No')
                    sys.exit()
            else:
                if T[i] in sl.values():
                    print('No')
                    sys.exit()
                else:
                    sl[s] = T[i]

    print('Yes')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

if len(set(S)) != len(set(T)):
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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()
    sidx = {a: [] for a in string.ascii_lowercase}
    for i, ti in enumerate(t):
        sidx[ti].append(i)
    for k, idx in sidx.items():
        tmp = set()
        for i in idx:
            tmp.add(s[i])
        if len(tmp) > 1:
            print('No')
            return None
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()
    n = len(s)
    sidx = {a: [] for a in string.ascii_lowercase}
    for i, ti in enumerate(t):
        sidx[ti].append(i)
    for k, idx in sidx.items():
        if idx:
            tmp = set()
            for i in idx:
                tmp.add(s[i])
            if len(tmp) != 1:
                print('No')
                return None
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

countlist=[0]*26
keeplist=[0]*26
dic={}
for i in range(0,len(t)):
  dic[t[i]]=1

res=1
for i in range(0,len(t)):
  moji_t=t[i]
  moji_s=s[i]
  clkeep=ord(moji_t)-97
  kekeep=ord(moji_s)-97
  countlist[clkeep]+=1
  if countlist[clkeep]>=2:
    if keeplist[clkeep]!=moji_s or( moji_t!=moji_s and moji_s in dic):
      res=0
      break
  else:
    keeplist[clkeep]=moji_s
    
if res==1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

countlist=[0]*26
keeplist=[0]*26

res=1
for i in range(0,len(t)):
  moji_t=t[i]
  moji_s=s[i]
  clkeep=ord(moji_t)-97
  countlist[clkeep]+=1
  if countlist[clkeep]>=2:
    if keeplist[clkeep]!=moji_s:
      res=0
      break
  else:
    keeplist[clkeep]=moji_s
    
if res==1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
import string
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()
    sc = Counter(S)
    tc = Counter(T)
    c = 0
    for s in string.ascii_lowercase:
        if s in sc.keys() and s in tc.keys():
            c += abs(sc[s] - tc[s])
        elif s in sc.keys():
            c += sc[s]
        elif s in tc.keys():
            c += tc[s]

    print('No' if (c // 2) % 2 else 'Yes')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

S.sort()
T.sort()

Ns=1
Nt=1

for i in range(1,len(S)):
    if S[i-1]!=S[i]:
        Ns+=1
    if T[i-1]!=T[i]:
        Nt+=1

if Ns-Nt==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
N = len(S)
done_alphabets = []

for i in range(N):
    if S[i] in done_alphabets:
        continue
    if S[i] != T[i]:
        memo_char_num = []
        for j in range(i+1, N):
            if T[j] == T[i]:
                memo_char_num.append(j)
        for k in memo_char_num:
            if S[i] != S[k]:
                print("No")
                quit()
        done_alphabets.append(S[i])
        done_alphabets.append(T[i])

print("Yes")

Submission status: Wrong Answer

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

change_dict = {}
ans = "Yes"
for c_s, c_t in zip(s, t):
    if c_t in change_dict and change_dict[c_t] != c_s:
        ans = "No"
        break
    change_dict[c_t] = c_s
print(ans)

Submission status: Wrong Answer

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

u = []
alphabet = [[] for _ in range(26)]

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

for i in range(25):
    for j in range(1, 26):
        if i == j:
            continue
        if alphabet[i] == alphabet[j] and alphabet[i] != []:
            print('No')
            exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
S = input()
T = input()
d = defaultdict(str)
ans = 'Yes'
for s, t in zip(S, T):
    if len(d[s]) > 0:
        if d[s] != t:
            ans = 'No'
    if len(d[t]) > 0:
        if d[t] != s:
            ans = 'No'
    d[s] = t
    d[t] = s

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
S = input()
T = input()
d = defaultdict(str)
ans = 'Yes'
for s, t in zip(S, T):
    if s != t:
        if d[s] == t and d[t] == s:
            continue
        if d[s] == '' and d[t] == '':
            d[s] = t
            d[t] = s
        else:
            ans = 'No'
            break

print(ans)

Submission status: Wrong Answer

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

ls_alpha = ["?"]*26
ls = []
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s in ls:
        if ls_alpha[ord(s)-97]==t:
            pass
        else:
            print("No")
            exit()
    else:
        ls.append(s)
        ls_alpha[ord(s)-97] = t
# print(ls_alpha)
print("Yes")
exit()

Submission status: Wrong Answer

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

ls_alpha = ["?"]*26
ls = []
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if t in ls:
        if ls_alpha[ord(s)-97]==t:
            pass
        else:
            print("No")
            exit()
    else:
        ls.append(s)
        ls_alpha[ord(s)-97] = t
# print(ls_alpha)
print("Yes")
exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
S = input()
T = input()
d = defaultdict(set)
ans = 'Yes'
for s, t in zip(S, T):
    d[s].add(t)
    d[t].add(s)

for k, v in d.items():
    if len(v) > 1:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

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

ls_alpha = ["?"]*26
# ls = []
# for i in range(len(S)):
#     s = S[i]
#     t = T[i]
#     if t in ls:
#         if ls_alpha[ord(s)-97]==t:
#             pass
#         else:
#             print("No")
#             exit()
#     else:
#         ls.append(t)
#         ls_alpha[ord(s)-97] = t
# # print(ls_alpha)
# print("Yes")

for i in range(len(S)):
    s = S[i]
    t = T[i]
    no = ord(s)-97
    if ls_alpha[no] == "?":
        ls_alpha[no] = t
    else:
        if ls_alpha[no]==t:
            pass
        else:
            print("No")
            exit()
print("Yes")
exit()

Submission status: Wrong Answer

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

ls_alpha = ["?"]*26
ls = []
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if t in ls:
        if ls_alpha[ord(s)-97]==t:
            pass
        else:
            print("No")
            exit()
    else:
        ls.append(t)
        ls_alpha[ord(s)-97] = t
# print(ls_alpha)
print("Yes")

Submission status: Wrong Answer

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

abc='abcdefghijklmnopqrstuvwxyz'
d=['' for i in range(26)]

for i in range(len(s)):
  si=s[i]
  ti=t[i]

  d[abc.index(si)]+=ti
  d[abc.index(ti)]+=si
for k in d:
  if len(set(k))>=3:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

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

d={}
for i in range(len(s)):
  si=s[i]
  ti=t[i]

  if si in d:
    d[si]+=[ti]
  else:
    d[si]=[ti]
for k in d.keys():
  if len(set(d[k]))!=1:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
A = {chr(i):0 for i in range(97,123)}
S = input().strip()
T = input().strip()
N = len(S)
G = {chr(i):[] for i in range(97,123)}
flag = 0
for i in range(N):
    a = S[i]
    b = T[i]
    if a==b and A[a]==0:
        A[a] = 2
    elif a==b and A[a]==1:
        flag = 1
        break
    else:
        if A[a]==2:
            flag = 1
            break
        G[a].append(b)
        G[b].append(a)
        A[a] = 1
        A[b] = 1
for a in G:
    if len(G[a])>2:
        flag = 1
        break
if flag==1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

from collections import Counter
a = Counter(S)
b = Counter(T)

cnt = 0
for i in a:
    if i in b:
        cnt += abs(a[i] - b[i])
    else:
        cnt += a[i]
        
if cnt %2 ==  0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

from collections import Counter
a = Counter(S)
b = Counter(T)

cnt = 0
for i in a:
    if i in b:
        cnt += abs(a[i] - b[i])
    else:
        cnt += a[i]
        
if cnt == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

ls = []
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s==t:
        pass
    else:
        if t in ls:
            print("No")
            exit()
        else:
            ls.append(t)
            S = S.replace(s,t)
            # print(S)
print("Yes")
exit()

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
S = len(set(s))
T = len(set(t))

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    check = {}
    for s, t in zip(S, T):
        if check.get(t, 0) != 0:
            if check.get(t) != s:
                print("No")
                break
        else:
            check[t] = s
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
from collections import Counter

s=input()
t=input()

c1=Counter(s)
c2=Counter(t)

k1=sorted(c1.keys())
k2=sorted(c2.keys())

if len(k1)==len(k2):
  for i in range(len(k1)):
    if c1[k1[i]]!=c2[k2[i]]:
      print('No')
      exit()
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

def check():
    n = len(S)
    dic = {}
    for i in range(n):
        if T[i] not in dic:
            dic[T[i]] = S[i]
        elif dic[T[i]] != S[i]:
            return 'No'
    return 'Yes'
print(check())