Problem:


Score : 300 points

Problem Statement

You are given strings S and T consisting of lowercase English letters.

You can perform the following operation on S any number of times:

Operation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.

Determine if S and T can be made equal by performing the operation zero or more times.

Constraints

1 \leq |S| \leq 2 \times 10^5

|S| = |T|

S and T consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

If S and T can be made equal, print Yes; otherwise, print No.

Sample Input 1

azzel
apple

Sample Output 1

Yes

azzel can be changed to apple, as follows:

Choose e as c_1 and l as c_2. azzel becomes azzle.

Choose z as c_1 and p as c_2. azzle becomes apple.

Sample Input 2

chokudai
redcoder

Sample Output 2

No

No sequences of operation can change chokudai to redcoder.

Sample Input 3

abcdefghijklmnopqrstuvwxyz
ibyhqfrekavclxjstdwgpzmonu

Sample Output 3

Yes



Sample input:
azzel
apple


Sample output:
Yes

Submission status: Accepted

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

Submission status: Accepted

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

d = [{},{}]

f=True

for s,t in zip(S,T):
    if t not in d[0]:
        d[0][t] = s
    else:
        if d[0][t] != s:
            f = False
            break
    if s not in d[1]:
        d[1][s] = t
    else:
        if d[1][s] != t:
            f = False
            break
if f:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np,math,itertools



def func(n:str):
   b=[]
   ll=[]
   for i in n:
      if not i in b:
         b+=[i]
      ll+=[b.index(i)]
   return ll


s=input()
t=input()
rs=False
##print(func(s))
if func(s)==func(t):print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
def con(s):
    li = list(s)
    out=[0]*len(li)
    cnt=0
    t={}
    for i in range(len(li)):
        if li[i] in t.keys():
            out[i] = t[li[i]]
        else:
            out[i] = cnt 
            t[li[i]] = cnt
            cnt += 1
    return out

s = input()
t = input()

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

Submission status: Accepted

Solution code:
S=input()
T=input()
dic={}
ans='Yes'
for i,x in enumerate(S):
    if dic.get(x,'')=='':
        dic[x]=T[i]
    elif dic[x]!=T[i]:
        ans='No'
        break
dic2={}
for i,x in enumerate(T):
    if ans=='No':
        break
    if dic2.get(x,'')=='':
        dic2[x]=S[i]
    elif dic2[x]!=S[i]:
        ans='No'
        break
print(ans)

Submission status: Accepted

Solution code:
from sys import stderr
from functools import reduce
from collections import defaultdict as dd
from operator import add


def f():
    return [int(i) for i in input().split()]


def yes(n):
    print("Yes" if n else "No")


def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)


s = input()
t = input()
pos_s = dd(list)
pos_t = dd(list)

for i, char in enumerate(s):
    pos_s[char].append(i)
for i, char in enumerate(t):
    pos_t[char].append(i)

for key_s, item_s in pos_s.items():
    for key_t, item_t in pos_t.items():
        if item_s == item_t:
            pos_s[key_s] = []
            pos_t[key_t] = []

yes(
    all([len(p) == 0 for p in pos_s.values()]) and all([len(p) == 0 for p in pos_t.values()]))

Submission status: Accepted

Solution code:
str1 = input()
str2 = input()

array1 = []
array2 = []

for i in range(97, 97+26):
    array1.append(str1.count(chr(i)))
    array2.append(str2.count(chr(i)))

for p in range(len(str1)):
    if(array1.count(p) != array2.count(p)):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
al="abcdefghijklmnopqrstuvwxyz"
D1={}
D2={}
for i in range(26):
    D1[al[i]]=0
    D2[al[i]]=0

#print(D)

s=input()
t=input()

n=0
for i in range(len(s)):
    if (D1[s[i]]!=0 and D1[s[i]]!=t[i]) or (D2[t[i]]!=0 and D2[t[i]]!=s[i]) :
        n=1
        #print(i)
    else:
        D1[s[i]]=t[i]
        D2[t[i]]=s[i]

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

Submission status: Accepted

Solution code:
s=list(input())	
t=list(input())	
def c(l, x):
    return [i for i, _x in enumerate(l) if _x == x]
ss = []
tt = []
ss.append(c(s,'a'))
tt.append(c(t,'a'))
ss.append(c(s,'b'))
tt.append(c(t,'b'))
ss.append(c(s,'c'))
tt.append(c(t,'c'))
ss.append(c(s,'d'))
tt.append(c(t,'d'))
ss.append(c(s,'e'))
tt.append(c(t,'e'))
ss.append(c(s,'f'))
tt.append(c(t,'f'))
ss.append(c(s,'g'))
tt.append(c(t,'g'))
ss.append(c(s,'h'))
tt.append(c(t,'h'))
ss.append(c(s,'i'))
tt.append(c(t,'i'))
ss.append(c(s,'j'))
tt.append(c(t,'j'))
ss.append(c(s,'k'))
tt.append(c(t,'k'))
ss.append(c(s,'l'))
tt.append(c(t,'l'))
ss.append(c(s,'m'))
tt.append(c(t,'m'))
ss.append(c(s,'n'))
tt.append(c(t,'n'))
ss.append(c(s,'o'))
tt.append(c(t,'o'))
ss.append(c(s,'p'))
tt.append(c(t,'p'))
ss.append(c(s,'q'))
tt.append(c(t,'q'))
ss.append(c(s,'r'))
tt.append(c(t,'r'))
ss.append(c(s,'s'))
tt.append(c(t,'s'))
ss.append(c(s,'t'))
tt.append(c(t,'t'))
ss.append(c(s,'u'))
tt.append(c(t,'u'))
ss.append(c(s,'v'))
tt.append(c(t,'v'))
ss.append(c(s,'w'))
tt.append(c(t,'w'))
ss.append(c(s,'x'))
tt.append(c(t,'x'))
ss.append(c(s,'y'))
tt.append(c(t,'y'))
ss.append(c(s,'z'))
tt.append(c(t,'z'))
ss.sort()
tt.sort()
#print(ss)
#print(tt)
if ss == tt:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

k = "abcdefghijklmnopqrstuvwxyz"
D_S = dict((c, []) for c in k)
D_T = dict((c, []) for c in k)

for i in range(len(S)):
    D_S[S[i]].append(i)
    D_T[T[i]].append(i)

for v_s in D_S.values():
    if v_s in D_T.values():
        continue
    print("No")
    break
else:
    print("Yes")

Submission status: Accepted

Solution code:
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

s = input()
t = input()
S = ""
T = ""

se = dict()
cnt = 0
for j in s:
    if not(j in se.keys()):
        se[j] = cnt
        cnt += 1
    S += str(se[j])

se = dict()
cnt = 0
for j in t:
    if not(j in se.keys()):
        se[j] = cnt
        cnt += 1
    T += str(se[j])

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

Submission status: Accepted

Solution code:
import numpy as np
import math

# K = int(input())
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
# S = input() # String

S = input() # String
T = input() # String

StoT = dict()
TtoS = dict()

for i, _ in enumerate(S):
    if S[i] not in StoT:
        if T[i] in TtoS and TtoS[T[i]] != S[i]:
            print('No')
            exit(0)
        StoT[S[i]] = T[i]
        TtoS[T[i]] = S[i]
    else:        
        # print(S[i])
        # print(mapping[c])
        if StoT[S[i]] != T[i]:
            print('No')
            exit(0)

print('Yes')

Submission status: Accepted

Solution code:

S = input()
T = input()

N = len(S)

d_s = {}
d_t = {}

S_i = []
T_i = []
for s, t in zip(S, T):
    if s in d_s.keys():
        S_i += [d_s[s]]
    else:
        d_s[s] = len(d_s)
        S_i += [d_s[s]]

    if t in d_t.keys():
        T_i += [d_t[t]]
    else:
        d_t[t] = len(d_t)
        T_i += [d_t[t]]

if S_i == T_i:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def slve():
	a = input()
	b = input() 
	a_chars = {}
	b_chars = {}

	for i in a:
		if i not in a_chars:
			a_chars[i] = 1
		else:
			a_chars[i] += 1

	for i in b:
		if i not in b_chars:
			b_chars[i] = 1
		else:
			b_chars[i] += 1

	a_l = [v for (k,v) in a_chars.items()]
	b_l = [v for (k,v) in b_chars.items()]
	a_l.sort()
	b_l.sort()
	for i in range(len(a_l)):
		if a_l[i] != b_l[i]:
			print("No")
			return 

	print("Yes")


slve()

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
check = [[] for i in range(26)]
for i in range(len(T)):
    check[ord(T[i]) - 97].append(i)
ans = 1
for i in check:
    for j in range(1, len(i)):
        if S[i[j]] != S[i[j - 1]]:
            ans = -1
            break
        
check = [[] for i in range(26)]
for i in range(len(S)):
    check[ord(S[i]) - 97].append(i)
for i in check:
    for j in range(1, len(i)):
        if T[i[j]] != T[i[j - 1]]:
            ans = -1
            break
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections
S = input()
T = input()
sc = sorted(collections.Counter(S).values())
tc = sorted(collections.Counter(T).values())

if sc == tc:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
ai = lambda: list(map(int, input().split()))
ai_ = lambda: [int(x) - 1 for x in input().split()]

s = input()
t = input()

import string
S = string.ascii_lowercase

ss = [[] for _ in range(26)]
for i in range(26):
    for j in range(len(s)):
        if S[i] == s[j]:
            ss[i].append(j)
ss = [tuple(k) for k in ss]


tt = [[] for _ in range(26)]
for i in range(26):
    for j in range(len(s)):
        if S[i] == t[j]:
            tt[i].append(j)
tt = [tuple(k) for k in tt]


from collections import Counter
if Counter(ss) == Counter(tt):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

sdic={}
snum=""
for i in s:
    if i not in sdic:
        sdic[i]=len(sdic)
        snum+=str(sdic[i])
    else:
        snum+=str(sdic[i])

tdic={}
tnum=""
for i in t:
    if i not in tdic:
        tdic[i]=len(tdic)
        tnum+=str(tdic[i])
    else:
        tnum+=str(tdic[i])

#print(snum, sdic)
#print(tnum, tdic)

if snum==tnum:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
msg=input()
patten=input()

bucket=[None,None]
bucket[0]=[0]*26
bucket[1]=[0]*26
for c in msg:
    bucket[0][ord(c)-ord('a')]+=1
for c in patten:
    bucket[1][ord(c)-ord('a')]+=1
bucket[0]=sorted(bucket[0])
bucket[1]=sorted(bucket[1])
winFlag=True
for i in range(len(bucket[0])):
    if(bucket[0][i]!=bucket[1][i]):
        winFlag=False
if winFlag==False:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

s_dict = {}
for i in S:
    if not i in s_dict.keys():
        s_dict[i] = 1
    else:
        s_dict[i] += 1

t_dict = {}
for i in T:
    if not i in t_dict.keys():
        t_dict[i] = 1
    else:
        t_dict[i] += 1

if sorted(s_dict.values()) == sorted(t_dict.values()):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=raw_input()
t=raw_input()
m={}
ret = "Yes"
for i,c in enumerate(s):
  if c in m and m[c]!=t[i]:ret = "No"
  m[c] = t[i]
if len(set(m[c] for c in m))!=len(m):ret = "No"
print ret

Submission status: Accepted

Solution code:
S = input()
T = input()
smap = {}
tmap = {}
replaceS = []
replaceT = []
n = 'a'
for c in S:
  if c not in smap:
    smap[c] = n
    n = chr(ord(n)+1)
  replaceS.append(smap[c])

n = 'a'
for c in T:
  if c not in tmap:
    tmap[c] = n
    n = chr(ord(n)+1)
  replaceT.append(tmap[c])

if ''.join(replaceS) == ''.join(replaceT) \
  and len(smap.keys()) == len(tmap.keys()):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

c_set = set()
for c in s:
    c_set.add(c)

t_set = set()
for c in c_set:
    isFirst = True
    tTemp = ""

    for i in range(len(s)):
        if isFirst:
            if s[i] == c:
                tTemp = t[i]
                isFirst = False
                if tTemp in t_set:
                    print("No")
                    exit()
                t_set.add(tTemp)
        else:
            if s[i] == c:
                if t[i] != tTemp:
                    print("No")
                    exit()

print("Yes")

Submission status: Accepted

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

used = []
res = []
for i in range(len(s)):
    if s[i] not in used:
        used.append(s[i])
    res.append(used.index(s[i]))
used = []
ret = []
for i in range(len(t)):
    if t[i] not in used:
        used.append(t[i])
    ret.append(used.index(t[i]))
if res == ret:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import stdin
a = stdin.readline().strip()
b = stdin.readline().strip()
ans = 'Yes'
di = {} 
hi = {}
n = len(a)
for i in xrange(n):
    if a[i] in di and di[a[i]]!=b[i]:
        ans = 'No'
        break 
    if b[i] in hi and hi[b[i]]!=a[i]:
        ans = 'No'
        break 
    hi[b[i]] = a[i]
    di[a[i]] = b[i] 
print ans

Submission status: Accepted

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

list_a_z = [chr(i) for i in range(97, 97+26)]

flag = True

for a in list_a_z:
    try:
        i = S.index(a)
        b = T[i]
        if [s == a for s in S] != [t == b for t in T]:
            flag = False
            break
    except:
        pass

if flag == True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
U = "abcdefghijklmnopqrstuvwxyz"
s = [0 for k in range(26)]
t = [0 for k in range(26)]

for k in range(26):
    s[k] += S.count(U[k])
    t[k] += T.count(U[k])
print("Yes" if sorted(s)==sorted(t) else "No")

Submission status: Accepted

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

cntS = Counter(S).most_common()
cntT = Counter(T).most_common()

Ans = "Yes"
if len(cntS)==len(cntT):
    for i in range(len(cntT)):
        if cntS[i][1] != cntT[i][1]:
            Ans = "No"
else:
    Ans = "No"

print(Ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
T = input()
DS = defaultdict(int)
for s in S:
  DS[s] += 1
CS = sorted(DS.values())
DT = defaultdict(int)
for t in T:
  DT[t] += 1
CT = sorted(DT.values())
if len(CS) == len(CT):
  for i in range(len(CS)):
    if CS[i] != CT[i]:
      print('No')
      break
  else:
    print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
L = [chr(i) for i in range(97, 97+26)]
countS = []
countT = []
for x in L:
    countS.append(S.count(x))
    countT.append(T.count(x))
countS.sort()
countT.sort()
if countS == countT:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S =input()
T =input()
convert_dict = {}

for i,s in enumerate(S):
    t = T[i]
    if s not in convert_dict:
        convert_dict[s]=t
    else:
        if convert_dict[s]==t:
            continue
        print("No")
        exit()

#duplicate check
if not len(convert_dict.keys()) == len(set(convert_dict.values())):
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

LISTS=[[] for i in range(30)]
LISTT=[[] for i in range(30)]

for i in range(L):
    LISTS[ord(S[i])-97].append(i)
    LISTT[ord(T[i])-97].append(i)


check=1
for i in range(30):
    if len(LISTS[i])>=2:
        for j in range(1,len(LISTS[i])):
            if T[LISTS[i][j]]!=T[LISTS[i][j-1]]:
                check=0


    if len(LISTT[i])>=2:
        for j in range(1,len(LISTT[i])):
            if S[LISTT[i][j]]!=S[LISTT[i][j-1]]:
                check=0

if check==1:
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter as C
print(["No", "Yes"][C(C(input()).values()) == C(C(input()).values())])

Submission status: Accepted

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

dct = {}

for x, y in zip(S, T):
    if x in dct.keys():
        if dct[x] != y:
            print("No")
            sys.exit()
    dct[x] = y

if len(set(dct.keys())) != len(set(dct.values())):
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

c_s = sorted([s.count(_c) for _c in set(s)])
c_t = sorted([t.count(_c) for _c in set(t)])

if c_s == c_t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
T = input()

ds = defaultdict(set)
for k, c in enumerate(S):
    ds[c] |= {k}
dt = defaultdict(set)
for k, c in enumerate(T):
    dt[c] |= {k}

dss = set(tuple(x) for x in ds.values())
dts = set(tuple(x) for x in dt.values())

print('Yes' if dss ^ dts == set() else 'No')

Submission status: Accepted

Solution code:
s=input()
t=input()
import collections
cs=collections.Counter(list(s))
ct=collections.Counter(list(t))
a,b=list(cs.values()),list(ct.values())
a.sort()
b.sort()
print("Yes" if a==b else "No")

Submission status: Accepted

Solution code:
S = input()
T = input()
Ls = [0]*26
Lt = [0]*26
for s in S:
    Ls[ord(s)-97] += 1
for t in T:
    Lt[ord(t)-97] += 1
Ls.sort()
Lt.sort()
if Ls==Lt:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

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

SS = Counter(S)
TT = Counter(T)

SS = list(SS.values())
SS.sort()

TT = list(TT.values())
TT.sort()

if SS == TT:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

ms = {}
mt = {}
for i in range(len(S)):
    if S[i] in ms.keys() and ms[S[i]] != T[i]:
        print('No')
        exit()

    if T[i] in mt.keys() and mt[T[i]] != S[i]:
        print('No')
        exit()

    ms[S[i]] = T[i]
    mt[T[i]] = S[i]

print('Yes')

Submission status: Accepted

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

dicta = dict()
dictb = dict()

for i in a:
	if i not in dicta:
		dicta[i] = 1
	else:
		dicta[i] += 1
	
for i in b:
	if i not in dictb:
		dictb[i] = 1
	else:
		dictb[i] += 1
		
		
if sorted(dicta.values()) == sorted(dictb.values()):
	print ('Yes')
else:
	print ('No')

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
lis = [0 for i in range(26)]
li = [0 for i in range(26)]
for i in range(len(s)):
  lis[ord(s[i])-ord("a")] += 1
  li[ord(t[i])-ord("a")] += 1
lis.sort()
li.sort()
for i in range(26):
  if lis[i] != li[i]:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
import sys
S = input()
T = input()
a = []
b = []
i = 0
while i < len(S):
  if S[i] in a:
    if T[i] in b and a.index(S[i]) == b.index(T[i]):
      pass
    else:
      print('No')
      sys.exit()
  else:
    if T[i] in b:
      print('No')
      sys.exit()
    else:
      a.append(S[i])
      b.append(T[i])
  i += 1
print('Yes')

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

s = ns()
t = ns()

cnt_s = Counter(s)
cnt_t = Counter(t)

val_s = sorted(list(cnt_s.values()))
val_t = sorted(list(cnt_t.values()))

if val_s == val_t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

P = set()
Q = set()

def conv(S):
    MS = {}
    idx = 0
    res = []
    for s in S:
        if s in MS:
            res.append(MS[s])
            continue
        MS[s] = idx
        res.append(idx)
        idx += 1
    return res

MS = conv(S)
MT = conv(T)

if MS == MT:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

alphas = [chr(i) for i in range(97,97+26)]

dics = {}
for a in alphas:
    dics[a] = s.count(a)
    s = s.replace(a, str(dics[a]))

dic_t = {}
for a in alphas:
    dic_t[a] = t.count(a)
    t = t.replace(a, str(dic_t[a]))

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

Submission status: Accepted

Solution code:
from collections import defaultdict

s = input()
t = input()

s_dict = defaultdict(int)
for char in s:
    s_dict[char] += 1

t_dict = defaultdict(int)
for char in t:
    t_dict[char] += 1

if sorted(s_dict.values()) == sorted(t_dict.values()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def f(S):
  M = {}
  for s in S:
    if s not in M:
      M[s] = chr(ord("a")+len(M))
  return "".join(M[s] for s in S)

S = raw_input()
T = raw_input()
print "Yes" if f(S)==f(T) else "No"

Submission status: Accepted

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

def to_num_list(s):
    seen = {}
    ret = []
    idx = 0
    for ch in s:
        if ch not in seen:
            seen[ch] = idx
            idx += 1
        ret.append(seen[ch])
    return ret

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

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

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

if sorted(s.values()) == sorted(t.values()):
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
X = list(map(int, input().split()))

ans = 10**6
for i in range(n-k):
  d1 = abs(X[i]) + abs(X[i] - X[i+k-1])
  d2 = abs(X[i+k-1]) + abs(X[i] - X[i+k-1])
  if ans > min(d1, d2):
    ans = min(d1,d2)
if ans == 10**6:
  print(0)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
import collections
a = list(input())
b = list(input())
A = collections.Counter(a)
B = collections.Counter(b)
Asort = sorted(A.values())
Bsort = sorted(B.values())
if list(Asort.values()) == list(Bsort.values()):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import collections
a = list(str(input()))
b = list(str(input()))
A = collections.Counter(a)
B = collections.Counter(b)
Asort = sorted(A.values())
Bsort = sorted(B.values())
if list(Asort.values()) == list(Bsort.values()):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import collections
a = list(str(input()))
b = list(str(input()))
A = collections.Counter(a)
B = collections.Counter(b)
Asort = sorted(A.values())
Bsort = sorted(B.values())
if Asort.values() == Bsort.values():
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import collections
a = list(input())
b = list(input())
A = collections.Counter(a)
B = collections.Counter(b)
Asort = sorted(A.values())
Bsort = sorted(B.values())
if Asort.values() == Bsort.values():
  print("Yes")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
import collections
a = list(map(str,input().split()))
b = list(map(str,input().split()))
A = collections.Counter(a)
B = collections.Counter(b)
Asort = sorted(A.values())
Bsort = sorted(B.values())
if Asort.values() == Bsort.values():
  print("Yes")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

S,T=input(),input()
C=[-1]*26
ans=True
for i in range(len(S)):
    if C[ston(S[i])]!=ston(T[i]):
        if ston(T[i])!=-1
            ans=False
            break
        C[ston(S[i])]=ston(T[i])
        C[ston(T[i])]=ston(S[i])
judge(ans)

Submission status: Runtime Error

Solution code:
S=input()
T=input()
d=[[] for i in range(26)]
for i,c in enumerate(S):
    d[ord(c)-ord('a')].append(i)
d2=[[] for i in range(26)]
for i,c in enumerate(T):
    d2[ord(c)-ord('a')].append(i)
d.sort(key=lambda x:x[0])
d2.sort(key=lambda x:x[0])
f=1
for i in range(26):
    if len(d[i])!=len(d2[i]):
        f=0
    else:
        for j in range(len(d[i])):
            if d[i]!=d2[i]:
                f=0
print(['No','Yes'][f])

Submission status: Runtime Error

Solution code:
from collections import defaultdict

S = input()
T = input()
s_li = [0] * len(S)   # 文字列Sに登場する文字の出現回数を順番に格納する
t_li = [0] * len(T)   # 文字列Tに登場する文字の出現回数を順番に格納する

# s_liを作っていく
s_cnt_dict = defaultdict(int)   # 文字ごとに出現回数をメモしていく
s_idx_dict = defaultdict(list)  # 同じ文字が出現するインデックスをメモしていく
for i in len(S):
    k = S[i]
    s_cnt_dict[k] += 1
    s_idx_dict[k].append(i)
for k in s_cnt_dict:
    for idx in s_idx_dict[k]:
        s_li[idx] = s_cnt_dict[k]

# t_liを作っていく
t_cnt_dict = defaultdict(int)   # 文字ごとに出現回数をメモしていく
t_idx_dict = defaultdict(list)  # 同じ文字が出現するインデックスをメモしていく
for i in len(T):
    k = T[i]
    t_cnt_dict[k] += 1
    t_idx_dict[k].append(i)
for k in t_cnt_dict:
    for idx in t_idx_dict[k]:
        t_li[idx] = t_cnt_dict[k]

print('Yes') if s_li == t_li else print('No')

Submission status: Runtime Error

Solution code:
"""
M <= 10 ** 5
なので全探索しても間に合いそう。
"""
N, M = map(int, input().split())
input_li = []   # 入力[p, y]の組み合わせを格納する二次元リスト
p_dict = {}     # pごとのyのリストを格納する辞書
ans_dict = {}   # キーp, yを指定することでIDが取り出せる辞書

# 入力をinput_liに詰めつつp_dictを作っていく
for _ in range(M):
    p, y = map(int, input().split())
    input_li.append([p, y])
    if p not in p_dict:
        li = [y]
        p_dict[p] = li
    else:
        p_dict[p].append(y)

# p_dictを元にans_dictを作っていく
for p in p_dict:
    li = sorted(p_dict[p])
    ans_dict[p] = {}
    for i in range(len(li)):
        p_id = '0' * (6 - len(str(p))) + str(p)
        c_id = '0' * (6 - len(str(i + 1))) + str(i + 1)
        ans_dict[p][li[i]] = p_id + c_id

# input_li順にIDを出力していく
for p, y in input_li:
    print(ans_dict[p][y])

Submission status: Runtime Error

Solution code:
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: Runtime Error

Solution code:
s,t = raw_input(), raw_input()
def f(s,t):
	cc = {}
	cr = {}
	for u,v in zip(s,t):
		if u in cc:
			if cc[u] != v: return False
		if v in cr:
			if cc[v] != u: return False
		
		cc[u] = v
		cr[v] = u
	return True
print 'Yes' if f(s,t) else 'No'

Submission status: Runtime Error

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


def check(A, B[Numeron App](https://numeron-app.herokuapp.com)[i]
        elif d[A[i]] != B[i]:
            return False
    return True


print("Yes" if check(S, T) and check(T, S) else "No")

Submission status: Runtime Error

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


N = z()
A = zz()


def get_sadness(A, b):
    sad = 0
    for i, a in enumerate(A):
        sad += abs(a - (b))
    return sad


for i in range(N):
    A[i] -= (i+1)
A = sorted(A)
# print(A)
if(N % 2 == 0):
    b = (A[N//2] + A[N//2 - 1])//2
else:
    b = A[N//2]
# print(b)

print(get_sadness(A, b))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

Solution code:
s,t=input(),input()
ss,ts=[set()for i in range(26)],[set()for i in range(26)]
sc={}
tc={}
for i in range(len(s)):
    if s[i]not in sc:
        if t[i] in tc:print("No");exit()
        else:
            d=len(sc)
            ss[d].add(i)
            ts[d].add(i)
            tc[t[i]]=d
            sc[s[i]]=d
    else:
        if sc[s[i]]!=tc[t[i]]:print("No");exit()
        else:
            ss[sc[s[i]]].add(i)
            ts[sc[s[i]]].add(i)
for i in range(26):
    if ss[i]!=ts[i]:print("No");break
else:print("Yes")

Submission status: Runtime Error

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

charmap = {}
for s, t in zip(S, T):
    if t in charmap:
        charmap[t].add(s)
        break
    else:
        charmap[t] = set(s)

# マッピングが1対1なら交換できる
result = True
for k, v in charmap.items():
    if not result:
        break
    if len(v) > 1:
        # 1対1でない場合でも全ての組で2対2,3対3,n対nになっているなら交換できる
        for c in v:
            if charmap[c] != v:
                result = False
                break

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

Submission status: Runtime Error

Solution code:
s = input()
t = input()
s_l = set(s)
t_l = set(t)
s = list(s_l)
t = list(t_l)
go = []
back = []
def has_duplicates(seq):
    return len(seq) != len(set(seq))


for i in range(len(s)):
  go.append(s[i])
  back.append(t[i])
  
ansg = has_duplicates(go)
ansb = has_duplicates(back)

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

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
x = a[0]
y = a[1]

n = a[0]
count = 0

while n <= y:
  n = n << 1
  count += 1
  
print(str(count))