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:
import numpy as np
S    = np.sort(np.array(list(input())))
T    = np.sort(np.array(list(input())))
N    = len(S)
SArg = np.argsort(S)
TArg = np.argsort(T)
SAgT = S[TArg]
TAgS = T[SArg]

SBef = ''
TBef = ''
SFlag = True
for ST in range(0,N):
    SNow = S[ST]
    TNow = TAgS[ST]
    if SBef==SNow:
        if TBef!=TNow:
            SFlag = False
            break
    SBef = SNow
    TBef = TNow
        
SBef = ''
TBef = ''
TFlag = True
for TT in range(0,N):
    SNow = SAgT[TT]
    TNow = T[TT]
    if TBef==TNow:
        if SBef!=SNow:
            TFlag = False
            break
    SBef = SNow
    TBef = TNow
        
if SFlag and TFlag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

dc = {}
for i, s in enumerate(S):
    if s in dc and dc[s] != T[i]:
        print("No")
        exit()
    else:
        dc[s] = T[i]
else:
    print("Yes")

Submission status: Wrong Answer

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

dc = {}
for i, t in enumerate(T):
    if t in dc and dc[t] != s[i]:
        print("No")
        exit()
    else:
        dc[t] = s[i]
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter

s = list(input())
t = list(input())
'''
print(Counter(s), len(Counter(s)))
print(Counter(t), len(Counter(t)))
'''
if len(Counter(s)) == len(Counter(t)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    S = [item for item in input()]
    T = [item for item in input()]

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





if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
a_idx = ord('a')
S_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
T_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
leng = len(S)
for i in range(leng):
    S_Lis[ord(S[i])-a_idx].append(i)
    T_Lis[ord(T[i])-a_idx].append(i)
for i in range(26):
    tmpS = S_Lis[i]
    if len(tmpS) == 0 or tmpS == T_Lis[i]:
        continue
    else:
        flag = True
        for j in T_Lis.values():
            if list(set(tmpS) & set(j)) == tmpS:
                flag = False
                break
        if flag:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
codeList = [[] for i in range(26)]
answer = 'Yes'
for i in range(len(T)):
    asciiCode = ord(T[i]) - 97
    codeList[asciiCode].append(i)
for i in range(26):
    if len(codeList[i]) > 1:
        character = S[codeList[i][0]]
        for j in codeList[i]:
            if character != S[j]:
                answer = 'No'
                break
print(answer)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
a_idx = ord('a')
S_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
T_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
leng = len(S)
for i in range(leng):
    S_Lis[ord(S[i])-a_idx].append(i)
    T_Lis[ord(T[i])-a_idx].append(i)
for i in range(26):
    if len(S_Lis[i]) == 0 or len(T_Lis[i]) == 0 or set(S_Lis[i]) & set(T_Lis[i]) == set() or S_Lis[i] == T_Lis[i]:
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
s=list(input())
t=list(input())
change_st=defaultdict(int)
change_ts=defaultdict(int)
for i in range(len(s)):
    if change_st[s[i]]==0:
        change_st[s[i]]=t[i]
    else:
        if change_st[s[i]]!=t[i]:
            print("No")
            break
    if change_ts[t[i]]==0:
        change_ts[t[i]]==s[i]
    else:
        if change_ts[t[i]]!=s[i]:
            pritn("No")
            break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
s=list(input())
t=list(input())
change_st=defaultdict(int)
change_ts=defaultdict(int)
for i in range(len(s)):
    if change_st[s[i]]==0:
        change_st[s[i]]=t[i]
    else:
        if change_st[s[i]]!=t[i]:
            print("No")
            break
    if change_ts[t[i]]==0:
        change_ts[t[i]]==0
    else:
        if change_ts[t[i]]!=s[i]:
            pritn("No")
            break
else:
    print("Yes")

Submission status: Wrong Answer

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

n = len(s)
a = [-1]*26
flg = True

for i in range(n):
    snum = ord(s[i]) - 97
    tnum = ord(t[i]) - 97
    if a[snum] == -1:
        a[snum] = tnum
        if a[tnum] == -1:
            a[tnum] = snum
        elif a[tnum] != snum:
            flg = False
            break
    elif a[snum] != tnum:
        flg = False
        break
    
print('Yes') if flg else print('No')

Submission status: Wrong Answer

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = input()
    t = input()
    u = set()
    idx = -1
    loc_s = [[] for _ in range(26)]
    loc_t = [[] for _ in range(26)]
    for i in range(len(s)):
        if not s[i] in u:
            u.add(s[i])
            idx += 1
        loc_s[idx].append(i)
    
    idx = -1
    u = set()
    for i in range(len(s)):
        if not t[i] in u:
            u.add(t[i])
            idx += 1
        loc_t[idx].append(i)
    
    if loc_s == loc_t:
        print('Yes')
    else:
        print('No')
        
        
            
        
    
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

c = []
dic = {}
for i in range(len(s)):
    if s[i] == t[i]:
        c.append(s[i])
    elif t[i] not in dic:
        dic[t[i]] = s[i]
    elif t[i] in dic:
        if dic[t[i]] != s[i]:
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
T = input()

x = defaultdict(list)

for i, t in enumerate(T):
    x[t].append(S[i])

ok = True
for k, v in x.items():
    a = v[0]
    for c in v:
        if c != a:
            ok = False
            break
if ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
def main():
    s = list(input())
    t = list(input())
    s = Counter(s)
    t = Counter(t)
    if len(s)==len(t):
        print('Yes')
    else:
        print('No')
main()

Submission status: Wrong Answer

Solution code:
# 基本的には一文字ずつ変えていけば変わるはずだがある一つの文字に複数の別の文字が当たってると変換できない
# chokudai
# redkuoai
# redcouai
# reucodai
# raucodei
# iaucoder

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

from collections import defaultdict
s_dic = defaultdict(set)
t_dic = defaultdict(set)
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if len(s_dic[s]) > 0 and t not in s_dic[s]:
        print(False)
        exit()
    if len(t_dic[t]) > 0 and s not in t_dic[t]:
        print(False)
        exit()
    s_dic[s].add(t)
    t_dic[t].add(s)

print(True)

Submission status: Wrong Answer

Solution code:
from collections import Counter

S = input()
T = input()

alphabet = 'abcdefghijklmnopqrstuvwxyz'

S_counter = Counter(S)
T_counter = Counter(T)

flag = True

for i in alphabet:
    S_cnt = S_counter[i]
    T_cnt = T_counter[i]
    if S_cnt != T_cnt and S_cnt != 0 and T_cnt != 0:
        flag = False

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

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
t = input()
a = [0]*(ord('z')+1)

for i in range(len(s)):
    x = ord(s[i])
    y = ord(t[i])
    if (a[x] == 0 or a[x] == y) and (a[y] == 0 or a[y] == x):
        a[x] = y
        a[y] = x
    else:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
t = input()
a = [0]*(ord('z')+1)
b = [0]*(ord('z')+1)

for i in range(len(s)):
    x = ord(s[i])
    y = ord(t[i])
    if x != y and a[x] != y:
        if a[x] == 0:
            a[x] = y
            b[x] = 1
        else:
            print("No")
            exit()
if sum(b) % 2 == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
st = list(zip(s, t))
flag = True
for i in range(len(s)):
    for j in range(i, len(s)):
        if st[i][1] == st[j][1] and st[i][0] != st[j][0]:
            flag = False
            break
print("Yes") if flag else print("No")

Submission status: Wrong Answer

Solution code:
S = str(input())
T = str(input())
li = []

for i in range(len(S)):
  if S[i] == T[i]:
    li.append(S[i])

ans = 'Yes'
for l in li:
  if T.count(l) > 1:
    ans = 'No'
    break
print(ans)

Submission status: Wrong Answer

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

exchange = [-1] * 26
alpha2num = lambda c: ord(c) - ord('a')
#print(alpha2num('y')) #==> 24

for i in range(len(S)):
  if S[i] == T[i]:
    continue
  else:
    now_num = alpha2num(S[i])
    #print(now_num, exchange[now_num], alpha2num(T[i]))
    if exchange[now_num] == -1:
      exchange[now_num] = alpha2num(T[i])
    elif exchange[now_num] == alpha2num(T[i]):
      #print("yeee")
      continue
    else:
      print("No")
      quit()
  #print(exchange)    
  
exchange = sorted(exchange)
for i in range(1, 26):
  if exchange[i] == exchange[i - 1]:
    if exchange[i] != -1:
      print("No")
      quit()
  
print("Yes")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
n=len(s)
d={}
for i in range(n):
    ss=s[i]
    tt=t[i]
    if ss not in d:
        d[ss]=tt
    if ss in d and (ss,tt) not in d.items():
        print("No")
        exit()
    
print("Yes")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
d=dict(zip(s, t))
judge=0
for i in d:
    for j in d:
        if d[i]==j:
            if i!=d[j]:
                judge+=1
        """if d[i]==j:
            if i!=d[j]:
                judge+=1"""
        if i==j:
            if d[i]==d[j]:
                judge+=1
        if d[i]==d[j]:
            if i==j:
                judge+=1
if judge==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
d=dict(zip(s, t))
judge=0
for i in d:
    for j in d:
        """if d[i]==j:
            if i!=d[j]:
                judge+=1"""
        if i==j:
            judge+=1
        if d[i]==d[j]:
            judge+=1    
if judge==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
d=dict(zip(s, t))
judge=0
for i in d:
    c=0
    for j in d:
        if i==j:
            c+=1
        if d[i]==j:
            if i!=d[j]:
                judge+=1
    if c>1:
            judge+=1          
if judge==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
d=dict(zip(s, t))
judge=0
for i in d:
    for j in d:
        c=0
        if i==j:
            c+=1
        if c>1:
            judge+=1
        if d[i]==j:
            if i!=d[j]:
                judge+=1
                
if judge==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
d=dict(zip(s, t))
judge=0
for i in d:
    for j in d:
        if d[i]==j:
            if i!=d[j]:
                judge+=1
                
if judge==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
trans_dict = {}
flag = 1
for i in range(len(S)):
    if S[i] != T[i]:
        if (S[i] not in trans_dict):
            trans_dict[S[i]] = T[i]
        elif S[i] in trans_dict:
            if trans_dict[S[i]] != T[i]:
                flag = 0
if len(set(trans_dict.keys())) != len(set(trans_dict.values())):
    flag = 0
    
if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
trans_dict = {}
flag = 1
for i in range(len(S)):
    if S[i] != T[i]:
        if (S[i] not in trans_dict) or (T[i] not in trans_dict):
            trans_dict[S[i]] = T[i]
        elif S[i] in trans_dict:
            if trans_dict[S[i]] != T[i]:
                flag = 0
        elif T[i] in trans_dict:
            if trans_dict[T[i]] != S[i]:
                flag = 0
if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

from collections import defaultdict

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

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

    d = defaultdict(int)
    for s, t in zip(S, T):
        d[s] += 1
        d[t] -= 1
    
    d = [j for i, j in d.items() if j != 0]
    d.sort()

    if len(d) == 0:
        print('Yes')
    elif len(d) % 2 == 0:
        for i in range(len(d) // 2):
            if d[i] + d[len(d)-i-1] != 0:
                print('No')
                return 
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

dic = {}

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

print('Yes')

Submission status: Wrong Answer

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

C = {}

for i in range(N):
    if S[i] in C:
        if C[S[i]] == T[i]:
            continue
        else:
            print('No')
            break
    else:
        if S[i] == T[i]:
            continue
        else:
            C[S[i]] = T[i]
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
A = list(input())
B = list(input())

A = set(A)
B = set(B)

if len(A) == len(B):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
is_ok = True
N = len(S)
change = {}
for i in range(N):
    if S[i] == T[i]:
        if S[i] in change.keys():
            if change[S[i]] != S[i]:
                is_ok = False
                break
        change[S[i]] = S[i]
    else:
        if S[i] in change.keys():
            if change[S[i]] == S[i]:
                is_ok = False
                break
        change[S[i]] = T[i]
        change[T[i]] = S[i]
        S[i] = change[S[i]]

if not is_ok:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

mappings = {}

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

Submission status: Wrong Answer

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

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


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

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(solve(S, T))

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
s = input()
t = input()
x = {'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}
a = Counter(s)
b = Counter(t)
for i in a:
    x[i] = a[i]
for j in b:
    x[j] -= b[j]
for k in x:
    if x[k] % 2 == 1:
        print('No')
        quit()
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, input().split()))


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


# tの同じ文字がある位置は、sでも同じ文字でなければならない
pos_dic_s = defaultdict(list)
pos_dic_t = defaultdict(list)
s = S()
t = S()
for i, t_ in enumerate(s):
    pos_dic_s[t_].append(i)

for i, t_ in enumerate(t):
    pos_dic_t[t_].append(i)

for char in pos_dic_t:
    if (len(pos_dic_t[char]) > 0):
        c = s[pos_dic_t[char][0]]
        for pos in pos_dic_t[char]:
            if (c != s[pos]):
                print('No')
                exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter

S = input()
T = input()

alps_counter_s = Counter()
alps_counter_t = Counter()

for s in S:
  alps_counter_s[s] += 1

for t in T:
  alps_counter_t[t] += 1

if len(alps_counter_s.values()) == len(alps_counter_t.values()):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

tbl = {}
for s,t in zip(S,T):
    if t not in tbl:
        tbl[t] = s
    if tbl[t] != s:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

tbl = {}
for s,t in zip(S,T):
    if t not in tbl:
        tbl[t] = s
    print(tbl)
    if tbl[t] != s:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

sub_tbl = {}
for s,t in zip(S,T):
    if t not in sub_tbl:
        sub_tbl[t] = s
    if s!=sub_tbl[t]:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

sc = Counter(s)
tc = Counter(t)

if set(sc.values()) == set(tc.values()):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, input().split()))


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


# tの同じ文字がある位置は、sでも同じ文字でなければならない
pos_dic_s = defaultdict(list)
pos_dic_t = defaultdict(list)
s = S()
t = S()
for i, t_ in enumerate(s):
    pos_dic_s[t_].append(i)

for i, t_ in enumerate(t):
    pos_dic_t[t_].append(i)

for char in pos_dic_t:
    if (len(pos_dic_t[char]) > 1):
        c = s[pos_dic_t[char][0]]
        for pos in pos_dic_t[char]:
            # print(s[pos], c)
            if (c != s[pos]):
                print('No')
                exit()
print('Yes')

Submission status: Wrong Answer

Solution code:


S = input()
T = input()


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

print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
L = [c for c in S if c not in T]
L2 = [c for c in T if c not in S]
if len(L) != len(L2):
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

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

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

flag = True

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

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

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

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
n = len(S)
A = [[S[i],T[i]] for i in range(n)]
for i in range(n-1):
  for j in range(i+1,n):
    if A[i][0] in A[j]:
      if set(A[i]) != set(A[j]):
        print(A[i],A[j])
        print("No")
        exit()
      else:
        pass
    else:
      pass
      
print("Yes")

Submission status: Wrong Answer

Solution code:

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

from collections import defaultdict
s_basho = defaultdict(lambda: "NO")
for i,ss in enumerate(s):
    s_basho[ss]=i

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

for i in range(l):
    if s[i]!=t[i]:
        henkan1[s[i]].add(t[i])
        henkan2[t[i]].add(s[i])
        

if all(len(h) <=1 for h in henkan1.values()) and all(len(h) <=1 for h in henkan2.values()):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

ans = "Yes"
for i in range(len(S)-1):
  if (S[i] == S[i+1]) == (T[i] == T[i+1]):
    pass
  else:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

Rs = {}

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
import collections

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

print(cs)
print(ct)

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

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

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import collections

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

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

for i,j in zip(cnts.values(),cntt.values()):
    if i != j:
        print("No")
        sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import collections

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

print(cnts)
print(cntt)

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

for i,j in zip(cnts.values(),cntt.values()):
    if i != j:
        print("No")
        sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

s = list(map(str,input()))
t = list(map(str,input()))
memos = []
memot = []
anss = []
anst = []

for i in range(len(s)-1):
    if s[i] not in memos:
        memos.append(s[i])
        anss.append(0)
    else:
        anss.append(1)
    
    if t[i] not in memot:
        memot.append(t[i])
        anst.append(0)
    else:
        anst.append(1)
    
    if anss != anst:
        print("No")
        sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))

s = set(s)
t = set(t)

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

Submission status: Wrong Answer

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

dic = {}

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

print("Yes")

Submission status: Wrong Answer

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

dic = {}

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

print("Yes")

Submission status: Wrong Answer

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

dic = {}

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

print("Yes")

Submission status: Wrong Answer

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

dic = {}

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

print("Yes")

Submission status: Wrong Answer

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

dic = {}

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

print("Yes")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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