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 Counter
S=list(input())
T=list(input())
Tcnt=list(Counter(T).items())
# Tcnt2=[]
# for i in range(len(Tcnt)):
#     if Tcnt[i][1]>1:
#         Tcnt2.append(Tcnt[i][0])
# for i in range(len(Tcnt2)):
#     tmp=set([])
#     for j in range(len(S)):
#         if T[j]==Tcnt2[i]:
#             tmp.add(S[j])
#     if len(tmp)>1:
#         print('No')
#         exit()
# print('Yes')


# A=set([])
# for i in range(len(S)):
#     if S[i]!=T[i]:
#         A.add((min(S[i],T[i]),max(S[i],T[i])))
# # print(A,len(A))
# C=list(A)
# B=[]
# for i in range(len(C)):
#     for j in range(2):
#         B.append(C[i][j])
# # print(B)
# BX=list(set(list(Counter(B).values())))
# # print(BX)
# print('Yes' if len(BX)==1 else 'No')

E=set([])
for i in range(len(S)):
    if S[i]==T[i]:
        E.add(S[i])
Elist=list(E)
for i in range(len(Elist)):
    for j in range(len(S)):
        if S[j]==Elist[i]:
            if T[j]!=Elist[i]:
                print('No')
                exit()
        if T[j]==Elist[i]:
            if S[j]!=Elist[i]:
                print('No')
                exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
S = list(raw_input())
T = list(raw_input())
# print(S)
# print(T)

# corr = {}
# for i, s in enumerate(S):
#     print(i, s, T[i])
#     if s in corr.keys() and corr[s] != T[i]:
#         print("No")
#         exit(0)
#     corr[s] = T[i]
#     corr[T[i]] = s
# print("Yes")

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

for s in same:
    if (S+T).count(s) >= 3:
        print("No")
        exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
i=0
while(S!=[] and T!=[] and len(S) == len(T) and S !=T and not(len(S)==1 and S!=T)):
    if S[0] != T[0]:
        s = S[0]
        t = T[0]
        S = [i for i in S if i !=s and i!=t]
        T = [i for i in T if i !=s and i!=t]
    else:
        s =S[0]
        S = [i for i in S if i !=s]
        T = [i for i in T if i !=s]
if S == T:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
S = (input())
T = (input())
 
count1 = collections.Counter(S)
count2 = collections.Counter(T)
 
if len(S) == len(T):
    if len(count1) == len(count2):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S=list(input())
T=list(input())
SS=list(set(S))
ST=list(set(T))
Scounter=[]
Tcounter=[]
for i in range(len(SS)):
    Scounter.append(S.count(SS[i]))
for j in range(len(ST)):
    Tcounter.append(T.count(ST[j]))
if Scounter==Tcounter:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections
s = input()
t = input()
loop = len(s)
s_col = collections.Counter(s)
t_col = collections.Counter(t)
if len(s_col) == len(t_col):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
N=len(S)
Pairs=set()
Heads=set()
Tails=set()
for i in range(N):
    if S[i]!=T[i]:
        Pairs=Pairs|{(S[i],T[i])}
        Heads=Heads|{S[i]}
        Tails=Tails|{T[i]}
if len(Pairs)==len(Heads) and len(Pairs)==len(Tails):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main(S, T):
    cs = dict()

    for i, s in enumerate(S):
        t = T[i]
        if s != t:
            if t not in cs:
                cs[t] = s
            elif cs[t] == s:
                continue
            else:
                return "No"
    return "Yes"

if __name__ == "__main__":
    #assert main("azzel", "apple") == "Yes"
    #assert main("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu") == "Yes"
    #assert main("chokudai", "redcoder") == "No"
    S = input()
    T = input()
    print(main(S, T))

Submission status: Wrong Answer

Solution code:
def c_string_transformation(S, T):
    from collections import defaultdict
    c = defaultdict(str)
    for k, (c1, c2) in enumerate(zip(S, T)):
        c[c2] += c1
    ans = 'Yes'
    for k, v in c.items():
        if k != v and k in v:
            ans = 'No'
            break
    return ans

S = input()
T = input()
print(c_string_transformation(S, T))

Submission status: Wrong Answer

Solution code:
def main():
    """
    英小文字のみからなる文字列 S, T
    文字列 Sに対して、次の操作を何度でも行うことができます。

    操作
        2つの異なる英小文字 c1, c2を選び、
        Sに含まれる全ての 
        c1 を c2に、
        c2 を c1に、置き換える

    0回以上操作を行って、S を Tに一致させられるか判定

    1 <= |S| = |T| <= 2 * 10^5
    """
    S = input()
    T = input()

    ans = f(S, T)
    print(ans)


def f(S, T):
    """
    26文字存在しないとき
    S: abc
    T: def
        a -> d にしたい
        dbc
        dはSに存在しないので好きに変えられる, でよいか

    S: abc
    T: ddf
        a -> d: dbc
        b -> d: dが存在する
        bを存在しないものに変える: dzc, 状況は変わらない
        a,b入れ替えても意味がない
        a->x, b->x and x->b: bxc, 状況は変わらない

        割当がかぶっていると無理っぽい

    仮に3文字しか種類がない
    S: abc
    T: cab
        c->a, a->c: cba
        b->a, a->b: cab
    """
    import string
    d = {c: set() for c in string.ascii_lowercase}
    for c1, c2 in zip(S, T):
        d[c2].add(c1)

    for _, s in d.items():
        if len(s) >= 2:
            return "No"

    return "Yes"


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
s = sorted(s)
t = sorted(t)
i = 0
pres = s[0]
cnts = 0
pret = t[0]
cntt = 0
flag = 0
while i < len(s):
    if s[i] == pres:
        cnts += 1
    else:
        cnts = 1
        pres = s[i]
    if t[i] == pret:
        cntt += 1
    else:
        cntt = 1
        pret = t[i]
    i += 1
    if cnts != cntt:
        flag = 1
print("Yes" if flag == 0 else "No")

Submission status: Wrong Answer

Solution code:
c1 = input()
c2 = input()

length = len(c1)
list = {}
ok = True
for i in range(length):
    if(c2[i] in list):
        if(list[c2[i]] != c1[i]):
            ok = False
            exit
    else:
        list[c2[i]] = c1[i]
if(ok):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

    # ある文字cがsとtで場所が半端に一致していたらNO
    itti = []
    len_s = len(S)
    for i in range(len_s):
        if not S[i] in T:
            continue
        flag1 = False
        flag2 = False
        for j in range(len_s):
            if flag1 and flag2:
                print("No")
                exit()
            if S[i] == T[j]:
                if i == j:
                    flag1 = True
                    continue
                flag2 = True
                continue
    print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=list(input())
t=list(input())
ns=[0 for i in range(len(s))]
nt=[0 for i in range(len(s))]
us=[s[0]]
ut=[t[0]]
for i in range(1,len(s)):
    if s[i] in us:
        ns[i]=ns[us.index(s[i])]
    else:
        ns[i]=max(ns)+1
        us.append(s[i])
for i in range(1,len(t)):
    if t[i] in ut:
        nt[i]=nt[ut.index(t[i])]
    else:
        nt[i]=max(nt)+1
        ut.append(t[i])
if ns==nt:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
i=0
while(S!=[] and T!=[] and not (i == 0 and len(S) == len(T) and len(S)==1)):
    if S[0] != T[0]:
        s = S[0]
        t = T[0]
        S = [i for i in S if i !=s and i!=t]
        T = [i for i in T if i !=s and i!=t]
    else:
        s =S[0]
        S = [i for i in S if i !=s]
        T = [i for i in T if i !=s]
if S == [] and T ==[]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

S = raw_input()
T = raw_input()

m = {}

for i in range(len(S)):
    if S[i] != T[i]:
        if S[i] in m and m[S[i]] != T[i]:
            print "No"
            exit()
        else:
            m[S[i]] = T[i]
mm = {}
for c in m:
    mm[m[c]] = 1

if len(m) != len(mm):
    print "No"
else:
    print "Yes"

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
s=input()
t=input()
a=defaultdict(list)
b=defaultdict(list)
for i,(j,k) in enumerate(zip(s,t)):
  a[j].append(i)
  b[k].append(i)
aa=tuple(map(tuple,a.values()))
bb=tuple(map(tuple,b.values()))
if aa==bb:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
ss = {}
tt = {}
for i in range(0,len(s)):
    ss[s[i]] = ss.get(s[i], 0) + 1
    tt[t[i]] = tt.get(t[i], 0) + 1
ss = sorted(ss.items())
tt = sorted(tt.items())
ans = "Yes"
for i in range(0,len(ss)):
    if len(ss) != len(tt):
        ans = "No"
        break
    a,b = ss[i]
    a,c = tt[i]
    if b != c:
        ans = "No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
S_list = list([])
T_list = list([])

alphabets = "abcdefghijklmnopqrstuvwsyz"

for alphabet in alphabets:
    S_list.append(int(S.count(alphabet)))
    T_list.append(int(T.count(alphabet)))

S_list.sort()
T_list.sort()

if S_list == T_list:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import string

S = [i for i in input().split()][0]
T = [i for i in input().split()][0]

d = dict.fromkeys(string.ascii_lowercase, 0)

flag = 0
for i in range(len(S)):
    if S[i] is not T[i]:
        if d[str(S[i])] == T[i] and d[str(T[i])] == S[i]:
            pass
        elif d[str(S[i])] == 0 and d[str(T[i])] ==0:
            d[str(S[i])] = T[i]
            d[str(T[i])] = S[i]
        else:
            #print(S[i])
            #print(T[i])
            flag = 1
            print("No")

if flag == 0:
   print("Yes")

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
x=len(S)
S_lett=[]
T_lett=[]
for i in range(x):
	if (S[i] in S_lett) and (T[i] in T_lett):
		if S_lett.index(S[i]) != S_lett.index(S[i]):
			print("No")
			break
			
	elif (S[i] in S_lett)==0 and (T[i] in T_lett)==0:
		S_lett.append(S[i])
		T_lett.append(T[i])
	else:
		print("No")
		break
		
else:
	print("Yes")

Submission status: Wrong Answer

Solution code:
s1 = input()
s2 = input()
if len(s1) != len(s2):
    print("No")
else:
    D1 = {}
    D2 = {}
    flag = True
    for x, y in zip(s1, s2):
        if x not in D1:
            D1[x] = y
        else:
            flag = (flag and (D1[x] == [y]))
        if y not in D2:
            D2[y] = x
        else:
            flag = (flag and (D2[y] == [x]))
        if not flag:
            break
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import string

S = [i for i in input().split()][0]
T = [i for i in input().split()][0]

d = dict.fromkeys(string.ascii_lowercase, 0)

flag = 0
for i in range(len(S)):
    if S[i] is not T[i]:
        if d[str(S[i])] == T[i] and d[str(T[i])] == S[i]:
            pass
        elif d[str(S[i])] == 0 and d[str(T[i])] ==0:
            d[str(S[i])] = T[i]
            d[str(T[i])] = S[i]
        else:
            print(S[i])
            print(T[i])
            flag = 1
            print("No")

if flag == 0:
   print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

S = input()
T = input()

A = {}

isok = True
for i in range(len(S)):
    if S[i] in A:
        if T[i] != A[S[i]]:
            isok = False
            break
    else:
        A[S[i]] = T[i]
        
if isok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

slist=[]
tlist=[]

for i in range(len(s)):
    if s[i] not in slist:
        if t[i] not in tlist:
            slist.append(s[i])
            tlist.append(t[i])
        else:
            print('No')
            exit()
    elif t[slist.index(s[i])] != t[i]:
        print("No")
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
inputS = input()
arrayS = list(inputS)
arraySorted = list(inputS)
arraySorted.sort()
inputT = input()
arrayT = list(inputT)
arrayTSorted = list(inputT)
arrayTSorted.sort()

flagForA =0
# the same character search
index = 0
length = len(arrayS)
listForSame = []
while index < length-1:
    if arraySorted[index] == arraySorted[index+1]:
        if arraySorted[index] in listForSame:
            pass
        else:
            listForSame.append(arraySorted[index])
    index+=1
if listForSame == []:
    flagForA=1
else:
    flag =0
    listForSet =[]
    for caburi in listForSame:
        index2 =0
        listForAdd = []
        while index2 < length:
            if arrayS[index2] == caburi:
                listForAdd.append(index2)
            index2+=1
        listForSet.append(listForAdd)
    for everySet in listForSet:
        index3 =0
        while index3 < len(everySet)-1:
            if arrayT[everySet[index3]] == arrayT[everySet[index3+1]]:
                index3+=1
            else:
                flag =1
                flagForA=0
                break
    if flag ==0:
        flagForA=1
            
# the same character searchT
index = 0
length = len(arrayT)
listForSame = []
while index < length-1:
    if arrayTSorted[index] == arrayTSorted[index+1]:
        if arrayTSorted[index] in listForSame:
            pass
        else:
            listForSame.append(arrayTSorted[index])
    index+=1
if listForSame == []:
    flagForA=1
else:
    flag =0
    listForSet =[]
    for caburi in listForSame:
        index2 =0
        listForAdd = []
        while index2 < length:
            if arrayT[index2] == caburi:
                listForAdd.append(index2)
            index2+=1
        listForSet.append(listForAdd)
    for everySet in listForSet:
        index3 =0
        while index3 < len(everySet)-1:
            if arrayS[everySet[index3]] == arrayS[everySet[index3+1]]:
                index3+=1
            else:
                flag =1
                flagForA=0
                break
    if flag ==0:
        flagForA=1
            
    
        
if flagForA ==1:
    print("Yes")  
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
line="abcdefghijklmnopqrstuvwxyz"
for i in line :
    a=[]
    b=[]
    for j in range(len(t)):
        if i==t[j]:
            a.append(s[j])
            b.append(t[j])
    if len(set(a))!=len(set(b)):
        print("No")
        exit()
else:print("Yes")

Submission status: Wrong Answer

Solution code:
s1 = input()
s2 = input()

works = True
trans = {}

for c1, c2 in zip(s1, s2):
  if c2 in trans:
    if trans[c2] != c1:
      works = False
      break
  else:
    trans[c2] = c1
    
if works:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:

import math


def main():
    a = list(input())
    b = list(input())
    dica = {}
    dicb = {}
    dif = 0
    alpha = list("abcdefghijklmnopqrstuvwxyz")
    for aa,bb in zip(a,b):
        if aa != bb:
            if bb not in dica:  
                dica[bb] = aa
            else:
                if dica[bb] != aa:            
                    print("No")
                    return 0
            
            # if aa not in dica:
            #     dica[aa] = bb
            # if bb not in dicb:
            #     dicb[bb] = aa
            
            
    print("Yes")
    
    # for c in alpha:
    #     dica[c] = 0
    #     dicb[c] = 0
    # for temp in a:
    #     dica[temp] +=1
    # for temp in b:
    #     dicb[temp] +=1
    # for c in alpha:
    #     dif += (dica[c]-dicb[c])
    
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import string

S = [i for i in input().split()][0]
T = [i for i in input().split()][0]

d = dict.fromkeys(string.ascii_lowercase, 0)

for i in range(len(S)):
    if S[i] is not T[i]:
        if d[str(S[i])] == T[i] and d[str(T[i])] == S[i]:
            pass
        elif d[str(S[i])] == 0 and d[str(T[i])] ==0:
            d[str(S[i])] = T[i]
            d[str(T[i])] = S[i]
        else:
            print(S[i])
            print(T[i])
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
def nl(): return list(map(int, input().split()))
# print('Yes' if a else 'No')

s = input()
t = input()

d = dict()
flg = 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]:
            flg = False
            break
print('Yes' if flg else 'No')

Submission status: Wrong Answer

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

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

    # ある文字cがsとtで場所が半端に一致していたらNO
    itti = []
    len_s = len(S)
    for i in range(len_s):
        flag1 = False
        flag2 = False
        for j in range(len_s):
            if flag1 and flag2:
                print("No")
                exit()
            if S[i] == T[j]:
                if i == j:
                    flag1 = True
                    continue
                flag2 = True
                continue
    print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
s=input()
t=input()
dd=defaultdict(list)
for i,(j,k) in enumerate(zip(s,t)):
  dd[j].append(i)
  dd[k].append(i)
dd=dict(dd)
for i in dd.values():
  if len(i)%2:
    print("No")
    break
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

def syori(instr):
    moji = defaultdict(list)
    for i, s in enumerate(instr):
        moji[s].append(i)
    lis = list(moji.values())

    return (lis)



stra = input()
strb = input()

aset  = syori(stra)
bset = syori(strb)

if aset == bset:
    print("Yes")
else:
    print("No")

"""
if sega == segb and usaa == usab:
    print("Yes")
else:
    print("No")
"""

Submission status: Wrong Answer

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

d = {}
ans = 'Yes'
for s, t in zip(S, T):
    if t in d and d[t] != s:
        ans = 'No'
        break
    else:
        d[t] = s
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    S, T = [str(input()) for i in range(2)]
    if len(set(S)) == len(set(T)):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
xa = list(input())

ya = list(input())

an=[]

f=1

for i in range(len(xa)):
    if not xa[i]==ya[i]:
        tmp=[xa[i], ya[i]]
        for j in range(len(an)):
            if an[j][0]!=tmp[0] and an[j][1]==tmp[1]:
                f=-1
        if f>0:
            an.append(tmp)
        else:
            break
        
if f>0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

S_list = []
pre_c = S[0]
for i, c in enumerate(S[1:]):
    if c != pre_c:
        S_list.append(i)
        pre_c = c

T_list = []
pre_c = T[0]
for i, c in enumerate(T[1:]):
    if c != pre_c:
        T_list.append(i)
        pre_c = c

if S_list == T_list and len(set(S)) == len(set(T)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = list(input())
b = list(input())
c = len(a)
p = 0
d = [0 for i in range(27)]
if a == b:
	print("Yes")
else:
	for i in range(c):
		if a[i] == b[i]:
			k = ord(a[i])-97
			if d[k] != 2:
				d[k] = 1
			else:
				p = 1
				break
		else:
			k = ord(b[i])-97
			if d[k] != 1:
				d[k] = 2
			else:
				p = 1
				break
	if p == 1:
		print("No")
	else:
		print("Yes")

Submission status: Wrong Answer

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

alpha = "abcdefghijklmnopqrstuvwxyz" 

d = {}
for i in alpha:
    d[i] = None

for i in range(len(T)):
    if(d[T[i]] == None):
        d[T[i]] = S[i]
    elif(d[T[i]] != S[i]):
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
S=list(input())
T=list(input())
def bSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]

    return a
if bSort(S)==bSort(T):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",\
    "o","p","q","r","s","t","u","v","w","x","y","z"]
Mismatch = [[] for _ in range(26)]
Match = [False for _ in range(26)]
for i in range(len(S)):
    if S[i] != T[i]:
        Mismatch[alpha.index(S[i])].append(T[i])
        Mismatch[alpha.index(T[i])].append(S[i])
    else:
        Match[alpha.index(S[i])] = True

Able = True
for i in range(26):
    if Match[i]  and Mismatch[i]:
        Able = False

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

Submission status: Wrong Answer

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

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

S1 = S.values()
T1 = S.values()

if sorted(S1) == sorted(T1):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
n = len(s)
end = 0
alp = list("abcdefghijklmnopqrstuvwxyz")
for i in range(26):
    k = ""
    for j in range(n):
        if t[j] == alp[i]:
            if k == "" or s[j] == k:
                k = s[j]
            else:
                end = 1
                break
if end == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
S_list = set([])
T_list = set([])

alphabets = "abcdefghijklmnopqrstuvwsyz"

for alphabet in alphabets:
    S_list.add(int(S.count(alphabet)))
    T_list.add(int(T.count(alphabet)))

if S_list == T_list:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
if len(list(set(S) - set(T))) == len(list(set(T) - set(S))):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
x,f = [-1]*26,1
for i in range(len(s)):
	if x[ord(s[i])-97]!=x[ord(t[i])-97]: f=0
	else: x[ord(s[i])-97],x[ord(t[i])-97] = i,i
if f: print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
S=list(input())
T=list(input())
Tcnt=list(Counter(T).items())
# Tcnt2=[]
# for i in range(len(Tcnt)):
#     if Tcnt[i][1]>1:
#         Tcnt2.append(Tcnt[i][0])
# for i in range(len(Tcnt2)):
#     tmp=set([])
#     for j in range(len(S)):
#         if T[j]==Tcnt2[i]:
#             tmp.add(S[j])
#     if len(tmp)>1:
#         print('No')
#         exit()
# print('Yes')
A=set([])
for i in range(len(S)):
    if S[i]!=T[i]:
        A.add((min(S[i],T[i]),max(S[i],T[i])))
# print(A,len(A))
C=list(A)
B=[]
for i in range(len(C)):
    for j in range(2):
        B.append(C[i][j])
# print(B)
BX=list(set(list(Counter(B).values())))
# print(BX)
print('Yes' if len(BX)==1 else 'No')

Submission status: Wrong Answer

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

se = set()
for i in range(len(S)):
    if S[i] != T[i]:
        se.add(T[i])

for i in range(len(S)):
    if S[i] == T[i]:
        if S[i] in se:
            print("No")
            break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
c2pos=dict()
s_c2pos = dict()

for ix, c in enumerate(S):
    if s_c2pos.get(c) == None:
        s_c2pos[c] = [ix]
    else:
        s_c2pos[c].append(ix)

for ix, c in enumerate(T):
    if c2pos.get(c) == None:
        c2pos[c] = [ix]
    else:
        c2pos[c].append(ix)

res = "Yes"

for k, v in c2pos.items():
    if len(v) <= 1:
        continue

    if len(set([S[_v] for _v in v])) != 1:
        res = "No"

    if s_c2pos[S[v[0]]] != v:
        res = "No"
    
print(res)

Submission status: Wrong Answer

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

count1 = collections.Counter(S)
count2 = collections.Counter(T)

if len(S) == len(T):
    if len(count1) == len(count2):
        print('Yes')
    else:
        print('No')
else:
    print('Np')

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ls = [0]*26
for c,d in zip(s,t):
    p = ord(c)-ord('a')
    if ls[p]==0:
        ls[p] = d
    else:
        if d!=ls[p]:
            print('No')
            exit()
for i in range(26):
    if ls[i]!=0 and i==ord(ls[i])-ord('a') and ls.count(ls[i])>1:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
s = [S[i:i+1] for i in range(len(S))]
t = [T[i:i+1] for i in range(len(T))]
s.sort()
t.sort()
#print(s,t)
cs,ct = 0,0
for i in range(0,len(S) - 1):
    if s[i] != s[i+1]:
        cs += 1

if s[0] != s[-1]:
    cs += 1

for j in range(0, len(T) - 1):
    if t[j] != t[j + 1]:
        ct += 1

if t[0] != t[-1]:
    ct += 1

#print(cs,ct)

if cs == ct:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

d = {}
z = {}
flag = True
for i in range(len(S)):
    if S[i] not in d:
        d[S[i]] = T[i]
        z[T[i]] = S[i]

for k in d:
    if z[d[k]] != k:
        flag = False

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

Submission status: Wrong Answer

Solution code:
s=list(input())
t=list(input())
ns=[0 for i in range(len(s))]
nt=[0 for i in range(len(s))]
us=[s[0]]
ut=[t[0]]
for i in range(1,len(s)):
    if s[i] in us:
        ns[i]=ns[us.index(s[i])]
    else:
        ns[i]=ns[i-1]+1
        us.append(s[i])
for i in range(1,len(t)):
    if t[i] in ut:
        nt[i]=nt[ut.index(t[i])]
    else:
        nt[i]=nt[i-1]+1
        ut.append(t[i])
if ns==nt:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

s1 = sys.stdin.readline().strip()
s2 = sys.stdin.readline().strip()

pos_dct = {}
for i, c in enumerate(s2):
    if c not in pos_dct:
        pos_dct[c] = [i]
    else:
        pos_dct[c].append(i)

s1 = np.array(list(s1))
for key in pos_dct:
    tmp = s1[pos_dct[key]][0]
    judge = len(list(filter(lambda x: x != tmp, s1[pos_dct[key]])))
    if judge != 0:
        print("No")
        sys.exit()
print("Yes")

Submission status: Wrong Answer

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

print("Yes" if len(s-t^t-s) %2 == 0 else "No")

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ls = []
lt = []

for i in s:
  ls.append(i)
  
for j in t:
  lt.append(j)

ls = set(ls)
lt = set(lt)

if len(set(ls)) == len(set(lt)):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

alpha = "abcdefghijklmnopqrstuvwxyz" 

d = {}
for i in alpha:
    d[i] = None

for i in range(len(T)):
    if(S[i] != T[i]):
        if(d[T[i]] == None):
            d[T[i]] = S[i]
        elif(d[T[i]] != S[i]):
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
c2pos=dict()
for ix, c in enumerate(T):
    if c2pos.get(c) == None:
        c2pos[c] = [ix]
    else:
        c2pos[c].append(ix)

res = "Yes"

for k, v in c2pos.items():
    if len(v) <= 1:
        continue

    if len(set([S[_v] for _v in v])) != 1:
        res = "No"
print(res)

Submission status: Wrong Answer

Solution code:
from collections import Counter
s=input()
t=input()
s1=Counter(s)
t1=Counter(t)
ans='Yes'
if len(s1)!=len(t1):ans='No'
else:
    for i,j in zip(sorted(s1),sorted(t1)):
        if s1[i]!=t1[j]:ans='No'
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
alps = collections.defaultdict(int)
alpt = collections.defaultdict(int)
s = input()
t = input()
for i in s:
    alps[i] += 1
for i in t:
    alpt[i] += 1

alps = dict(alps)
alpt = dict(alpt)
alps = list(alps.values())
alpt = list(alpt.values())
if alps != alpt:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

s = input()
t = input()
dic = {}
for i in range(len(s)):
    if s[i] not in dic:
        dic[s[i]] = t[i]
    else:
        if dic[s[i]] != t[i]:
            print('No')
            exit()

s, t = '', ''
for a, b in dic.items():
    s += a
    t += b


def search(c, target):
    if c not in s:
        return True
    _searched = t[s.index(c)]
    if _searched == c:
        return _searched == target
    return True if _searched == target else search(_searched, target)


for i in range(len(s)):
    if not search(s[i], s[i]):
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
s=list(input())
t=list(input())
for i in range(len(t)-1):
    for j in range(1,len(t)-i):
        if t[i]==t[i+j]:
            if s[i]!=s[i+j]:
                if s[i]==t[i] or s[i+j]==t[i]:
                    print("No")
                    exit()
else:print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    T = input()
    cs = dict()
    to = set()
    for i, s in enumerate(S):
        t = T[i]
        if s != t:
            if s not in cs:
                if t in to:
                    print("No")
                    return
                to.add(t)
                cs[s] = t
            elif cs[s] == t:
                continue
            else:
                print("No")
                return
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding:utf-8

INF = float('inf')


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


S = input()
T = input()

tmp = []
word = []
prev = ''
hoge = 0
for s in S:
    if s == prev:
        hoge += 1
        continue
    else:
        if s not in word:
            tmp.append(hoge)
            word.append(s)
        else:
            tmp.append(None)
        hoge = 0
        prev = s


tmp2 = []
word = []
prev = ''
hoge = 0
for t in T:
    if t == prev:
        hoge += 1
        continue
    else:
        if t not in word:
            tmp2.append(hoge)
            word.append(t)
        else:
            tmp2.append(None)
        hoge = 0
        prev = t
# print(tmp)
# print(tmp2)
if tmp == tmp2:
    print('Yes')
else:
    print('No')