Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

N,M = map(int,input().split())

Observ = [i for i in range(1,N+1)]

h = input().split()
H = [int(i) for i in h]

def check(lis,item):
    if item in lis:
        return True
    else:
        return False

for i in range(M):
    bol = False
    A,B = map(int,input().split())
    HA = H[A-1]
    HB = H[B-1]
    if HA > HB:
        bol = check(Observ,B)
        if bol:
            Observ.remove(B)
    elif HA < HB:
        bol = check(Observ,A)
        if bol:
            Observ.remove(A)
    elif HA == HB:
        bol = check(Observ,A)
        if bol:
            Observ.remove(A)
        bol = check(Observ,B)
        if bol:
            Observ.remove(B)

ans = len(Observ)
print("{}".format(ans))

Fixed submission:
#coding:utf-8

N,M = map(int,input().split())

Observ = [1 for i in range(N)]

h = input().split()
H = [int(i) for i in h]

for i in range(M):
    A,B = map(int,input().split())
    HA = H[A-1]
    HB = H[B-1]
    if HA > HB:
        Observ[B-1] = 0
    elif HA < HB:
        Observ[A-1] = 0
    elif HA == HB:
        Observ[A-1] = 0
        Observ[B-1] = 0

ans = 0
for i in Observ:
    ans += i
    
print("{}".format(ans))
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

n = int(input())

a = input().split()

count = 0

r = [(n - int(m)) for n,m in enumerate(a)]
l = [(n + int(m)) for n,m in enumerate(a)]

r.remove(r[0])
l.remove(l[-1])

mar = max(r)
mir = min(r)
mal = max(l)
mil = min(l)

R = {i:0 for i in range(mir,mar + 1)}
L = {i:0 for i in range(mil,mal + 1)}

for n,m in zip(r,l):
    R[n] += 1
    L[m] += 1

for i in range(max(mir,mil),min(mar,mal)+1):
    count += R[i] * L[i]

print("{}".format(count))

Fixed submission:
#coding:utf-8

n = int(input())

a = input().split()

count = 0

r = [(n - int(m)) for n,m in enumerate(a)]
l = [(n + int(m)) for n,m in enumerate(a)]

r.remove(r[0])
l.remove(l[-1])

mar = max(r)
mir = min(r)
mal = max(l)
mil = min(l)

R = {}
L = {}

for n,m in zip(r,l):
    R[n] = 0
    L[m] = 0

for n,m in zip(r,l):
    R[n] += 1
    L[m] += 1

for i in R.keys():
    if i in L.keys():
        count += R[i] * L[i]

print("{}".format(count))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

n = int(input())

a = input().split()
A = [int(i) for i in a]

count = 0

for n1 in range(n-1):
    for n2 in range(n1,n):
        a1 = A[n1]
        a2 = A[n2]
        if abs(n1 - n2) == a1 + a2:
            count += 1

print("{}".format(count))

Fixed submission:
#coding:utf-8

n = int(input())

a = input().split()

count = 0

r = [(n - int(m)) for n,m in enumerate(a)]
l = [(n + int(m)) for n,m in enumerate(a)]

r.remove(r[0])
l.remove(l[-1])

mar = max(r)
mir = min(r)
mal = max(l)
mil = min(l)

R = {}
L = {}

for n,m in zip(r,l):
    R[n] = 0
    L[m] = 0

for n,m in zip(r,l):
    R[n] += 1
    L[m] += 1

for i in R.keys():
    if i in L.keys():
        count += R[i] * L[i]

print("{}".format(count))
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

n = int(input())
l = []
count = 0

for i in range(n):
    s = str(input())
    if s not in l:
        l.append(s)
        count += 1

print("{}".format(count))

Fixed submission:
#coding:utf-8

n = int(input())
l = []
count = 0

for i in range(n):
    s = str(input())
    l.append(s)

l = set(l)
count = len(l)
print("{}".format(count))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

n = int(input())
l = []

for i in range(n):
    s = str(input())
    if s not in l:
        l.append(s)

ans = len(l)

print("{}".format(ans))

Fixed submission:
#coding:utf-8

n = int(input())
l = []
count = 0

for i in range(n):
    s = str(input())
    l.append(s)

l = set(l)
count = len(l)
print("{}".format(count))
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
a = input().split()
lis = [0 for i in range(n)]
count = 0

for i in a:
    lis[int(i - 1)] += 1

for i in lis:
    print("{}".format(i))

Fixed submission:
#coding:utf-8
n = int(input())
a = input().split()
lis = [0 for i in range(n)]

for i in a:
    lis[int(i) - 1] += 1

for i in lis:
    print("{}".format(i))

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
a = input().split()
lis = [0 for i in range(n)]
count = 0

for i in a:
    lis[i] += 1

for i in lis:
    if count == 0:
        count = 1
        continue
    print("{}".format(i))

Fixed submission:
#coding:utf-8
n = int(input())
a = input().split()
lis = [0 for i in range(n)]

for i in a:
    lis[int(i) - 1] += 1

for i in lis:
    print("{}".format(i))
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

k = int(input())
count = 0

def gcd(a,b):
    if a >= b:
        k1, k2 = a, b
    elif a < b:
        k1, k2 = b, a

    r = k1 % k2
    if r != 0:
        return gcd(k2,r)
    elif r == 0:
        return k2

for a in range(1,k+1):

    for b in range(1,k+1):

        f = gcd(a,b)

        for c in range(1,k+1):

            g = gcd(f,c)
            count += g

print("{}".format(count))

Fixed submission:
#coding:utf-8

k = int(input())
count = 0

def gcd(a,b):
    if a >= b:
        k1, k2 = a, b
    elif a < b:
        k1, k2 = b, a

    r = k1 % k2
    if r != 0:
        return gcd(k2,r)
    elif r == 0:
        return k2

for a in range(1,k+1):

    for b in range(1,a+1):

        f = gcd(a,b)

        for c in range(1,b+1):

            g = gcd(f,c)
            
            if a == b and b != c:
                count += g * 3
            elif b == c and c != a:
                count += g * 3
            elif c == a and a != b:
                count += g * 3
            elif a == b and b == c:
                count += g
            else:
                count += g * 6

print("{}".format(count))
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
n, x, y = map(int, input().split())
anslist = []
for i in range(n-1):
    anslist.append(0)

for s in range(1,n):
    for p in range(s+1,n+1):
        dsp = abs(p - s)
        dsxyp = abs(x - s) + 1 + abs(p - y)
        dsyxp = abs(y - s) + 1 + abs(p - x)
        distance = min(dsp,dsxyp,dsyxp)
        anslist[distance - 1] += 1

for k in range(len(anslist)):
    print("{}".format(anslist[k]))

Fixed submission:
#coding:utf-8
n, x, y = map(int, input().split())
anslist = []
for i in range(n-1):
    anslist.append(0)

for s in range(1,n):
    for p in range(s+1,n+1):
        distance = min(abs(p - s),abs(x - s) + 1 + abs(p - y),abs(y - s) + 1 + abs(p - x))
        anslist[distance - 1] += 1

for k in range(len(anslist)):
    print("{}".format(anslist[k]))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
n, x, y = map(int, input().split())
anslist = []
for i in range(n-1):
    anslist.append(0)

for s in range(1,n):
    for p in range(s+1,n+1):
        dsp = abs(p - s)
        dsxp = abs(x - s) + abs(p - x)
        dsyp = abs(y - s) + abs(p - y)
        dsxyp = abs(x - s) + 1 + abs(p - y)
        dsyxp = abs(y - s) + 1 + abs(p - x)
        distance = min(dsp,dsxp,dsyp,dsxyp,dsyxp)
        anslist[distance - 1] += 1

for k in range(len(anslist)):
    print("{}".format(anslist[k]))

Fixed submission:
#coding:utf-8
n, x, y = map(int, input().split())
anslist = []
for i in range(n-1):
    anslist.append(0)

for s in range(1,n):
    for p in range(s+1,n+1):
        distance = min(abs(p - s),abs(x - s) + 1 + abs(p - y),abs(y - s) + 1 + abs(p - x))
        anslist[distance - 1] += 1

for k in range(len(anslist)):
    print("{}".format(anslist[k]))
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

n = int(input())
a = input().split()

list_n = [0 for i in range(n)]
basic = 0

for i in a:
    aa = int(i)
    count = list_n[aa - 1]
    basic += count
    list_n[aa - 1] += 1

ans = 0
for i in range(n):
    ans = 0
    lislis = list_n.copy()
    a1 = int(a[i])
    ans = basic - lislis[a1 - 1] + 1
    print("{}".format(int(ans)))

Fixed submission:
#coding:utf-8

n = int(input())
a = input().split()

list_n = [0 for i in range(n)]
basic = 0

for i in a:
    aa = int(i)
    count = list_n[aa - 1]
    basic += count
    list_n[aa - 1] += 1

ans = 0
for i in range(n):
    ans = 0
    a1 = int(a[i])
    ans = basic - list_n[a1 - 1] + 1
    print("{}".format(int(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

n = int(input())
a = input().split()

list_n = []

for i in range(n):
    list_n.append(0)

for i in a:
    aa = int(i)
    list_n[aa - 1] += 1

basic = 0
for i in list_n:
    basic += i * (i - 1) / 2

ans = 0
for i in range(n):
    ans = 0
    lislis = list_n.copy()
    a1 = int(a[i])
    ans = basic - lislis[a1 - 1] + 1
    print("{}".format(int(ans)))

Fixed submission:
#coding:utf-8

n = int(input())
a = input().split()

list_n = [0 for i in range(n)]
basic = 0

for i in a:
    aa = int(i)
    count = list_n[aa - 1]
    basic += count
    list_n[aa - 1] += 1

ans = 0
for i in range(n):
    ans = 0
    a1 = int(a[i])
    ans = basic - list_n[a1 - 1] + 1
    print("{}".format(int(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

n = int(input())
a = input().split()

list_n = []
list_a = []

for i in range(n):
    list_n.append(0)

for i in a:
    aa = int(i)
    list_a.append(aa)
    list_n[aa - 1] += 1

ans = 0
for i in range(n):
    ans = 0
    lislis = list_n.copy()
    a1 = list_a[i]
    lislis[a1 - 1] -= 1
    for t in lislis:
        ans += t * (t - 1) / 2
    print("{}".format(int(ans)))

Fixed submission:
#coding:utf-8

n = int(input())
a = input().split()

list_n = [0 for i in range(n)]
basic = 0

for i in a:
    aa = int(i)
    count = list_n[aa - 1]
    basic += count
    list_n[aa - 1] += 1

ans = 0
for i in range(n):
    ans = 0
    a1 = int(a[i])
    ans = basic - list_n[a1 - 1] + 1
    print("{}".format(int(ans)))
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

n,k = map(int,input()split())

if(n < 10):
  k = k + 100 * (10 - n)
  
print("{}".format(k))

Fixed submission:
#coding:utf-8

n,k = map(int,input().split())

if(n < 10):
  k = k + 100 * (10 - n)
  
print("{}".format(k))
Buggy python submission (verdict: Runtime Error):
n=int(intput())
if(n%9==0):
   print("YES')
else:
  print("NO")

Fixed submission:
n = list(input())
a = 0
for i in n:
    a += int(i)
if(a % 9 == 0):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
def main():
    _, _, m_num = map(int, input().split())
    a = [int(s) for s in input().split()]
    b = [int(s) for s in input().split()]

    min_price = min(a) + min(b)

    m = []
    for _ in range(m_num):
        price = a[x - 1] + b[y - 1] - c
        print(x, y, c, price)
        min_price = min(min_price, price)
    
    print(min_price)

main()

Fixed submission:
def main():
    _, _, m_num = map(int, input().split())
    a = [int(s) for s in input().split()]
    b = [int(s) for s in input().split()]

    min_price = min(a) + min(b)

    m = []
    for _ in range(m_num):
        x, y, c = map(int, input().split())
        price = a[x - 1] + b[y - 1] - c
        min_price = min(min_price, price)
    
    print(min_price)

main()
Buggy python submission (verdict: Time Limit Exceeded):
import re

def main():
    s = input()
    c = 0

    pat = re.compile(r'A+BC')
    while True:
        m = pat.search(s)
        if not m:
            break
        n = m.end() - m.start() - 2
        s = 'A' * n + s[m.end():]
        c += n

    print(c)
        


main()


Fixed submission:
def main():
    s = input()
    c = 0
    pos = 0
    a = 0

    while pos < len(s):
        if s[pos] == 'A':
            a += 1
            pos += 1
        elif s[pos:pos+2] == 'BC':
            c += a
            pos += 2
        else:
            a = 0
            pos += 1

    print(c)
        


main()

Buggy python submission (verdict: Time Limit Exceeded):
import re

def main():
    s = input()
    c = 0

    pat = re.compile('A*ABC')
    while True:
        m = pat.search(s)
        if not m:
            break
        n = len(m.group()) - 2
        t = 'BC' + 'A' * n
        s = s[:m.start()] + t + s[m.end():]
        c += n

    print(c)
        


main()


Fixed submission:
def main():
    s = input()
    c = 0
    pos = 0
    a = 0

    while pos < len(s):
        if s[pos] == 'A':
            a += 1
            pos += 1
        elif s[pos:pos+2] == 'BC':
            c += a
            pos += 2
        else:
            a = 0
            pos += 1

    print(c)
        


main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    c = 0
    while True:
        n = s.count('ABC')
        if n == 0:
            break
        c += n
        s = s.replace('ABC', 'BCA')
    print(c)
        


main()


Fixed submission:
def main():
    s = input()
    c = 0
    pos = 0
    a = 0

    while pos < len(s):
        if s[pos] == 'A':
            a += 1
            pos += 1
        elif s[pos:pos+2] == 'BC':
            c += a
            pos += 2
        else:
            a = 0
            pos += 1

    print(c)
        


main()
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

def main():
    n, m = map(int, input().split())
    a = [int(s) for s in input().split()]
    heapq.heapify(a)

    for _ in range(m):
        b, c = map(int, input().split())
        for _ in range(b):
            if a[0] >= c:
                break
            heapq.heapreplace(a, c)
    
    print(sum(a))

main()


Fixed submission:
from collections import defaultdict

def main():
    n, m = map(int, input().split())
    a = [int(s) for s in input().split()]
    cnt = defaultdict(int)

    for x in a:
        cnt[x] += 1
    
    for _ in range(m):
        b, c = map(int, input().split())
        cnt[c] += b
    
    rest = n
    s = 0
    for k in sorted(cnt.keys(), reverse=True):
        if cnt[k] >= rest:
            s += k * rest
            rest = 0
            break
        else:
            s += k * cnt[k]
            rest -= cnt[k]
    
    print(s)

main()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, namedtuple

def main():
    n = int(input())
    edges = defaultdict(list)

    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        edges[u-1].append((v - 1, w))
        edges[v-1].append((u - 1, w))
    
    vertexes = [None for _ in range(n)]
    vertexes[0] = 0
    traverse(0, edges, vertexes)

    for v in vertexes:
        print(v)

def traverse(u, edges, vertexes):
    for e in edges[u]:
        v, w = e
        if vertexes[v] is not None:
            continue

        if w % 2 == 0:
            vertexes[v] = vertexes[u]
        else:
            vertexes[v] = 1 - vertexes[u]
        traverse(v, edges, vertexes)

main()


Fixed submission:
from collections import defaultdict, deque

def main():
    n = int(input())
    edges = defaultdict(list)

    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        edges[u-1].append((v - 1, w))
        edges[v-1].append((u - 1, w))
    
    vertexes = solve(edges, n)
    for v in vertexes:
        print(v)

def solve(edges, n):
    vertexes = [None for _ in range(n)]
    vertexes[0] = 0

    q = deque()
    q.append(0)

    while q:
        u = q.popleft()

        for v, w in edges[u]:
            if vertexes[v] is not None:
                continue
            if w % 2 == 0:
                vertexes[v] = vertexes[u]
            else:
                vertexes[v] = 1 - vertexes[u]
            q.append(v)
    
    return vertexes
    
main()
Buggy python submission (verdict: Runtime Error):
import itertools
import math

def main():
    a, b, k = map(int, input().split())
    print(solve(a, b, k))

def solve(a, b, k):
    c = math.gcd(a, b)
    n = 0

    for i in range(c, 0, -1):
        if a % i == 0 and b % i == 0:
            n += 1
            if n == k:
                return i

main()


Fixed submission:
def main():
    a, b, k = map(int, input().split())
    print(solve(a, b, k))

def solve(a, b, k):
    n = 0
    for i in range(100, 0, -1):
        if a % i == 0 and b % i == 0:
            n += 1
            if n == k:
                return i

main()
Buggy python submission (verdict: Time Limit Exceeded):
def _solve(current, n, idx, x):
    if n >= len(x) - idx:
        return 0

    if n == 0:
        return x[-1] - current


    if current is None:
        return solve(x[idx], n - 1, idx + 1, x)

    a = x[idx] - current + solve(x[idx], n, idx + 1, x)
    b = solve(x[idx], n - 1, idx + 1, x)
    return min(a, b)

def solve(n, m, x):
    if n >= m:
        return 0

    dp = [[0 for _ in range(n + 1)] for _ in range(m)]
    dp[m-1][0] = x[-1] - x[-2]
    for i in range(1, n + 1):
        dp[m-1][i] = 0

    for idx in reversed(range(m - 1)):
        for i in range(n + 1):
            if i >= m - idx + 1:
                dp[idx][i] = 0
            elif i == 0:
                dp[idx][i] = x[-1] - x[idx-1]
            elif idx == 0:
                dp[idx][i] = dp[idx+1][i-1]
            else:
                a = x[idx] - x[idx - 1] + dp[idx+1][i]
                b = dp[idx+1][i-1]
                dp[idx][i] = min(a, b)

    return dp[0][n]

def main():
    n, m = map(int, input().split())
    x = [int(s) for s in input().split()]
    x.sort()

    print(solve(n, m, x))

main()


Fixed submission:
def solve(n, m, x):
    if n >= m:
        return 0

    y = [x[i + 1] - x[i] for i in range(m - 1)]
    y.sort(reverse=True)

    return x[-1] - x[0] - sum(y[:n-1])

def main():
    n, m = map(int, input().split())
    x = [int(s) for s in input().split()]
    x.sort()

    print(solve(n, m, x))

main()

Buggy python submission (verdict: Runtime Error):
def solve(current, n, idx, x):
    if n >= len(x) - idx:
        return 0

    if n == 0:
        return x[-1] - current


    if current is None:
        return solve(x[idx], n - 1, idx + 1, x)

    a = x[idx] - current + solve(x[idx], n, idx + 1, x)
    b = solve(x[idx], n - 1, idx + 1, x)
    return min(a, b)

def main():
    n, m = map(int, input().split())
    x = [int(s) for s in input().split()]
    x.sort()

    print(solve(None, n, 0, x))

main()


Fixed submission:
def solve(n, m, x):
    if n >= m:
        return 0

    y = [x[i + 1] - x[i] for i in range(m - 1)]
    y.sort(reverse=True)

    return x[-1] - x[0] - sum(y[:n-1])

def main():
    n, m = map(int, input().split())
    x = [int(s) for s in input().split()]
    x.sort()

    print(solve(n, m, x))

main()
Buggy python submission (verdict: Runtime Error):
n, limit = map(int, input().split())
x = []
for _ in range(n):
  c, t = map(int, input().split())
  x.append((c, t))

y = min(c for c, t in x if t <= limit)
print(y)
             

Fixed submission:
n, limit = map(int, input().split())
x = []
for _ in range(n):
  c, t = map(int, input().split())
  x.append((c, t))

y = min((c for c, t in x if t <= limit), default=0)
if y:
  print(y)
else:
  print('TLE')
Buggy python submission (verdict: Runtime Error):
from collections import namedtuple

Point = namedtuple('Point', ('x', 'y', 'h'))

def main():
    n = int(input())
    points = [read_point() for _ in range(n)]
    print(*solve(points))

def solve(points):
    for x in range(0, 101 + 1):
        for y in range(0, 100 + 1):
            h = points[0].h + abs(points[0].x - x) + abs(points[0].y - y)
            for p in points[1:]:
                h2 = p.h + abs(p.x - x) + abs(p.y - y)
                if (p.h > 0 and h2 != h) or h2 > h:
                    break
            else:
                return Point(x, y, h)

def read_point():
    x, y, h = map(int, input().split())
    return Point(x, y, h)

main()


Fixed submission:
from collections import namedtuple

Point = namedtuple('Point', ('x', 'y', 'h'))

def main():
    n = int(input())
    points = [read_point() for _ in range(n)]
    print(*solve(points))

def solve(points):
    for p in points:
        if p.h != 0:
            base = p
            break

    for x in range(0, 101 + 1):
        for y in range(0, 100 + 1):
            h = base.h + abs(base.x - x) + abs(base.y - y)
            for p in points:
                ph = max(h - abs(x - p.x) - abs(y - p.y), 0)
                if ph != p.h:
                    break
            else:
                return Point(x, y, h)

def read_point():
    x, y, h = map(int, input().split())
    return Point(x, y, h)

main()

Buggy python submission (verdict: Runtime Error):
from collections import namedtuple

Point = namedtuple('Point', ('x', 'y', 'h'))

def main():
    n = int(input())
    points = [read_point() for _ in range(n)]
    print(*solve(points))

def solve(points):
    for x in range(0, 101 + 1):
        for y in range(0, 100 + 1):
            h = points[0].h + abs(points[0].x - x) + abs(points[0].y - y)
            for p in points[1:]:
                h2 = p.h + abs(p.x - x) + abs(p.y - y)
                if h != h2:
                    break
            else:
                return Point(x, y, h)

def read_point():
    x, y, h = map(int, input().split())
    return Point(x, y, h)

main()


Fixed submission:
from collections import namedtuple

Point = namedtuple('Point', ('x', 'y', 'h'))

def main():
    n = int(input())
    points = [read_point() for _ in range(n)]
    print(*solve(points))

def solve(points):
    for p in points:
        if p.h != 0:
            base = p
            break

    for x in range(0, 101 + 1):
        for y in range(0, 100 + 1):
            h = base.h + abs(base.x - x) + abs(base.y - y)
            for p in points:
                ph = max(h - abs(x - p.x) - abs(y - p.y), 0)
                if ph != p.h:
                    break
            else:
                return Point(x, y, h)

def read_point():
    x, y, h = map(int, input().split())
    return Point(x, y, h)

main()
Buggy python submission (verdict: Runtime Error):
n = input()
x = (n - 1) // 111 + 1
print(x * 111)


Fixed submission:
n = int(input())
x = (n - 1) // 111 + 1
print(x * 111)
Buggy python submission (verdict: Time Limit Exceeded):
def make_reverse_index(s):
    idx = dict()

    for pos, c in enumerate(s):
        if c not in idx:
            idx[c] = set()
        idx[c].add(pos)

    return idx

def solve(s, t):
    idx1 = make_reverse_index(s)
    idx2 = make_reverse_index(t)

    for c1, c2 in zip(s, t):
        if idx1[c1] != idx2[c2]:
            return False

    return True

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

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

main()


Fixed submission:
def make_reverse_index(s):
    idx = dict()

    for pos, c in enumerate(s):
        if c not in idx:
            idx[c] = list()
        idx[c].append(pos)

    return idx

def solve(s, t):
    idx1 = make_reverse_index(s)
    idx2 = make_reverse_index(t)

    for i1 in idx1.values():
        c2 = t[i1[0]]
        i2 = idx2[c2]

        if i1 != i2:
            return False

    return True

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

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

main()