Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(reverse=True, key=itemgetter(1))

res = [0 for _ in range(M)]

for i, (a, b) in enumerate(AB):
    p = M - a
    while p >= 0 and res[p] != 0:
        p -= 1
    if p >= 0:
        res[p] = b

print(sum(res))


Fixed submission:
import heapq

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

AB = [[] for _ in range(M)]

for _ in range(N):
    a, b = map(int, input().split())
    if a - 1 < M:
        AB[a - 1].append(-b)

res = 0
cand = []

for i in range(M):
    AB[i].sort(reverse=True)
    for b in AB[i]:
        heapq.heappush(cand, b)
    if cand:
        mb = heapq.heappop(cand)
        res -= mb

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(reverse=True, key=itemgetter(1))

res = [0 for _ in range(M)]

for i, (a, b) in enumerate(AB):
    p = M - a
    while p >= 0 and res[p] != 0:
        p -= 1
    if p >= 0:
        res[p] = b

print(sum(res))


Fixed submission:
import heapq

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

AB = [[] for _ in range(M)]

for _ in range(N):
    a, b = map(int, input().split())
    if a - 1 < M:
        AB[a - 1].append(-b)

res = 0
cand = []

for i in range(M):
    AB[i].sort(reverse=True)
    for b in AB[i]:
        heapq.heappush(cand, b)
    if cand:
        mb = heapq.heappop(cand)
        res -= mb

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10 ** 9 + 7

S = input()
N = len(S)

dp = [[0 for _ in range(13)] for _ in range(N + 1)]
dp[0][0] = 1

for i, s in enumerate(S):
    c = -1 if s == "?" else int(s)

    for j in range(10):
        if c != -1 and c != j:
            continue
        for r in range(13):
            dp[i + 1][(r * 10 + j) % 13] += dp[i][r]

    for r in range(13):
        dp[i + 1][r] = dp[i + 1][r] % MOD

print(dp[N][5])


Fixed submission:
MOD = 10 ** 9 + 7

S = input()
N = len(S)

dp = [[0 for _ in range(13)] for _ in range(N + 5)]
dp[0][0] = 1

for i, s in enumerate(S):
    if s == "?":
        c = -1
    else:
        c = int(s)

    for j in range(10):
        if c != -1 and c != j:
            continue

        for r in range(13):
            dp[i + 1][(r * 10 + j) % 13] += dp[i][r]

        for r in range(13):
            dp[i + 1][r] %= MOD

print(dp[N][5])

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10 ** 9 + 7

S = input()
N = len(S)

dp = [[0 for _ in range(13)] for _ in range(N + 5)]
dp[0][0] = 1

for i, s in enumerate(S):
    if s == "?":
        c = -1
    else:
        c = int(s)

    for j in range(10):
        if c != -1 and c != j:
            continue

        for r in range(13):
            dp[i + 1][(r * 10 + j) % 13] += dp[i][r]

        for r in range(13):
            dp[i + 1][r] %= MOD

print(dp[N][5])


Fixed submission:
MOD = 10 ** 9 + 7

S = input()
N = len(S)

dp = [[0 for _ in range(13)] for _ in range(N + 5)]
dp[0][0] = 1

for i, s in enumerate(S):
    if s == "?":
        c = -1
    else:
        c = int(s)

    for j in range(10):
        if c != -1 and c != j:
            continue

        for r in range(13):
            dp[i + 1][(r * 10 + j) % 13] += dp[i][r]

        for r in range(13):
            dp[i + 1][r] %= MOD

print(dp[N][5])
Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

MOD = 10 ** 9 + 7

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

blue, red = K, N - K

p = 1 
d = 0

for i in range(1, blue + 1):
    print(int((comb(red + 1, p) % MOD) * (comb(blue - 1, d) % MOD) % MOD))
    p += 1
    d += 1


Fixed submission:
def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10 ** 9 + 7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


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

blue, red = K, N - K

p = 1 
d = 0

for i in range(1, blue + 1):
    print(int((comb(red + 1, p, mod) * comb(blue - 1, d, mod) % mod)))
    p += 1
    d += 1

Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

MOD = 10 ** 9 + 7

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

blue, red = K, N - K

p = 1 
d = 0

for i in range(1, blue + 1):
    print(int((comb(red + 1, p) * comb(blue - 1, d)) % MOD))
    p += 1
    d += 1



Fixed submission:
def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10 ** 9 + 7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


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

blue, red = K, N - K

p = 1 
d = 0

for i in range(1, blue + 1):
    print(int((comb(red + 1, p, mod) * comb(blue - 1, d, mod) % mod)))
    p += 1
    d += 1
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

res = 0

for i in range(N // R + 1):
    for j in range(N // G + 1):
        b = N - R * i - G * j
        if b >= 0 and b % B == 0:
            res += 1

print(res)


Fixed submission:
R, G, B, N = map(int, input().split())

res = 0

for i in range(N // R + 1):
    for j in range((N - R * i) // G + 1):
        b = N - R * i - G * j
        if b >= 0 and b % B == 0:
            res += 1

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

res = float("inf")

if "." not in S or "#" not in S:
    res = 0

for i in range(N):
    res = min(res, S[:i].count("#") + S[i:].count("."))

print(res)


Fixed submission:
N = int(input())
S = input()

res = float("inf")

# if "#" not in S or "." not in S:
#     res = 0

counts = []
counts.append((0, 0))
a, b = 0, 0
for s in S:
    if s == "#":
        a += 1
    elif s == ".":
        b += 1
    counts.append((a, b))

for i in range(N + 1):
    res = min(res, counts[i][0] + counts[-1][1] - counts[i][1])

print(res)
Buggy python submission (verdict: Runtime Error):
import itertools
import sys

input = sys.stdin.readline

maxn = 10000000000

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.append(-maxn)
B.append(-maxn)
C.append(-maxn)

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

apos, bpos, cpos = 0, 0, 0

while (apos + 1) * (bpos + 1) * (cpos + 1) < min(10 ** 7, X * Y * Z):
    if (
        apos < len(A) - 2
        and abs(A[apos] - A[apos + 1]) < abs(B[bpos] - B[bpos + 1])
        and abs(A[apos] - A[apos + 1]) < abs(C[cpos] - C[cpos + 1])
    ):
        apos += 1
    elif bpos < len(B) - 2 and B[bpos] - B[bpos + 1] < C[cpos] - C[cpos + 1]:
        bpos += 1
    else:
        cpos += 1

res = []
for a in list(itertools.product(A[: apos + 1], B[: bpos + 1], C[: cpos + 1])):
    res.append(a[0] + a[1] + a[2])

res.sort(reverse=True)
for k in range(K):
    print(res[k])


Fixed submission:
A = [int(input()) for _ in range(5)]
A.sort()

k = int(input())

if A[-1] - A[0] > k:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

binlen = len(bin(max(A))) - 2
while 2 ** binlen > K:
    binlen -= 1

if binlen < 0:
    print(sum(A))
    exit()

bitcount = [0] * (len(bin(max(A))) - 2)
for a in A:
    for i, s in enumerate(bin(a)[::-1][:-2]):
        if s == "1":
            bitcount[i] += 1

maxn = 2 ** binlen
mid = N / 2

for i in range(binlen + 1):
    if bitcount[i] < mid and i != binlen:
        maxn += 2 ** i
    elif bitcount[i] > mid and i == binlen:
        maxn -= 2 ** i
    elif i >= len(bitcount):
        maxn += 2 ** i

print(sum([maxn ^ a for a in A]))


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

binlen = 0
while 2 ** binlen <= K:
    binlen += 1
binlen -= 1

if binlen < 0:
    print(sum(A))
    exit()

bitcount = [0] * (len(bin(max(A))) - 2)
for a in A:
    for i, s in enumerate(bin(a)[::-1][:-2]):
        if s == "1":
            bitcount[i] += 1

maxn = 2 ** binlen
mid = N / 2

for i in range(binlen + 1):
    if i < len(bitcount):
        if bitcount[i] < mid and i != binlen:
            maxn += 2 ** i
        elif bitcount[i] > mid and i == binlen:
            maxn -= 2 ** i
    elif i != binlen:
        maxn += 2 ** i

pos = 0
while maxn > K:
    if bin(maxn)[2:][pos] == "1" and bin(K)[2:][pos] == "0":
        maxn -= 2 ** (len(bin(maxn)) - 3 - pos)
    pos += 1

print(sum([maxn ^ a for a in A]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

binlen = len(bin(max(A))) - 2
while 2 ** (binlen + 1) > K:
    binlen -= 1

if binlen < 0:
    print(sum(A))
    exit()

maxn = 0
for k in range(2 ** binlen, 2 ** (binlen + 1) + 1):
    maxn = max(maxn, sum([k ^ a for a in A]))
print(maxn)


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

binlen = 0
while 2 ** binlen <= K:
    binlen += 1
binlen -= 1

if binlen < 0:
    print(sum(A))
    exit()

bitcount = [0] * (len(bin(max(A))) - 2)
for a in A:
    for i, s in enumerate(bin(a)[::-1][:-2]):
        if s == "1":
            bitcount[i] += 1

maxn = 2 ** binlen
mid = N / 2

for i in range(binlen + 1):
    if i < len(bitcount):
        if bitcount[i] < mid and i != binlen:
            maxn += 2 ** i
        elif bitcount[i] > mid and i == binlen:
            maxn -= 2 ** i
    elif i != binlen:
        maxn += 2 ** i

pos = 0
while maxn > K:
    if bin(maxn)[2:][pos] == "1" and bin(K)[2:][pos] == "0":
        maxn -= 2 ** (len(bin(maxn)) - 3 - pos)
    pos += 1

print(sum([maxn ^ a for a in A]))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from operator import itemgetter
input = sys.stdin.readline

N = int(input())
A, B = [], []

for i in range(N):
    a, b = map(int, input().split())
    A.append([a, i])
    B.append([b, i])
A.sort(reverse=True, key=itemgetter(1))
B.sort(reverse=True, key=itemgetter(1))

ate = []
apoint, apos = 0, 0
bpoint, bpos = 0, 0
for i in range(N):
    if i % 2 == 0:
        while A[apos][1] in ate:
            apos += 1
        apoint += A[apos][0]
        ate.append(A[apos][1])
        apos += 1
    else:
        while B[bpos][1] in ate:
            bpos += 1
        bpoint += B[bpos][0]
        ate.append(B[bpos][1])
        bpos += 1
print(apoint - bpoint)


Fixed submission:
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a + b)
    B.append(b)

A.sort(reverse=True)
print(sum([ab for i, ab in enumerate(A) if i % 2 == 0]) - sum(B))

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter

N = int(input())
A, B = [], []

for i in range(N):
    a, b = map(int, input().split())
    A.append([a, i])
    B.append([b, i])
A.sort(reverse=True, key=itemgetter(1))
B.sort(reverse=True, key=itemgetter(1))

ate = []
apoint, apos = 0, 0
bpoint, bpos = 0, 0
for i in range(N):
    if i % 2 == 0:
        while True:
            if A[apos][1] not in ate:
                apoint += A[apos][0]
                ate.append(A[apos][1])
                break
            apos += 1
    else:
        while True:
            if B[bpos][1] not in ate:
                bpoint += B[bpos][0]
                ate.append(B[bpos][1])
                break
            bpos += 1
print(apoint - bpoint)


Fixed submission:
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a + b)
    B.append(b)

A.sort(reverse=True)
print(sum([ab for i, ab in enumerate(A) if i % 2 == 0]) - sum(B))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = list(map(int, input().split())).sorted()
if N[0] == 1 and N[1] == 4 and N[2] == 7 and N[3] == 9:
    print("YES")
else:
    print("NO")


Fixed submission:
import sys
input = sys.stdin.readline

N = sorted(list(map(int, input().split())))
if N[0] == 1 and N[1] == 4 and N[2] == 7 and N[3] == 9:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import collections
N, P = map(int, input().split())

factor = collections.defaultdict(int)

p = 2
n = P
while n > 1:
    while n % p == 0:
        factor[p] += 1
        n //= p
    p += 1

ans = 1
for key, value in factor.items():
    num = value
    while num >= N:
        ans *= key
        num -= N
print(ans)


Fixed submission:
import math
N, P = map(int, input().split())

for i in reversed(range(1, round(math.pow(P, 1 / N)) + 1)):
    if P % (i ** N) == 0:
        print(i)
        exit()
Buggy python submission (verdict: Runtime Error):
import re

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

burger = [None] * 51
burger[0] = "P"

for i in range(1, N + 1):
    burger[i] = "B" + burger[i - 1] + "P" + burger[i - 1] + "B"
    print(burger[i])

burger_x = burger[N][:X]
ans = len(re.findall("P", burger_x))
print(ans)

Fixed submission:
N, X = map(int, input().split())

a, p = [None] * (N + 1), [None] * (N + 1)
a[0], p[0] = 1, 1
for i in range(1, N + 1):
    a[i], p[i] = 2 * a[i - 1] + 3, 2 * p[i - 1] + 1


def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= a[N - 1] + 1:
        return f(N - 1, X - 1)
    else:
        return p[N - 1] + 1 + f(N - 1, X - a[N - 1] - 2)

print(f(N, X))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))


def countMask(a):
    ret = 0
    for x in cand:
        if (x & a) == a:
            ret += 1
    return ret


cand = []
for i in range(N):
    sum = 0
    for j in range(j, N):
        sum += A[j]
        cand.append(sum)

ans = 0

for i in range(40, -1, -1):
    if (countMask(ans | (1 << i)) >= K):
        ans |= 1 << i

print(ans)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))


def countMask(a):
    ret = 0
    for x in cand:
        if (x & a) == a:
            ret += 1
    return ret


cand = []
for i in range(N):
    sum = 0
    for j in range(i, N):
        sum += A[j]
        cand.append(sum)

ans = 0

for i in range(40, -1, -1):
    if (countMask(ans | (1 << i)) >= K):
        ans |= 1 << i

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted([int(input()) for i in range(N)])

if N % 2 == 0:
    print(2 * (sum(A[N // 2:]) - sum(A[:N // 2])) - (A[N // 2] - A[N // -1]))
else:
    print(2 * (sum(A[N // 2 + 1:]) - sum(A[:N // 2])) - min(A[N // 2] - A[N // 2 - 1], A[N // 2 + 1] - A[N // 2]))


Fixed submission:
S = input()

if len(S) == 2:
    print(S)
else:
    print(S[::-1])

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

if K % 2 == 1:
    A, B = B, A
print(int(A), int(B))

Fixed submission:
S = input()

if len(S) == 2:
    print(S)
else:
    print(S[::-1])

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

if K % 2 == 1:
    A, B = B, A
print(int(A), int(B))


Fixed submission:
S = input()

if len(S) == 2:
    print(S)
else:
    print(S[::-1])
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

for i in range(K):
	if A == 0 or B == 0:
		break
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

print(int(A), int(B))


Fixed submission:
A, B, K = map(int, input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

if K % 2 == 1:
    A, B = B, A
print(int(A), int(B))

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

for i in range(K):
	if A == 0 or B == 0:
		break
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

print(int(A), int(B))

Fixed submission:
A, B, K = map(int, input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

if K % 2 == 1:
    A, B = B, A
print(int(A), int(B))
Buggy python submission (verdict: Runtime Error):
N = input()
A = sorted([input() for i in range(N)])

if N % 2 == 0:
    ans = 2 * (sum(A[N // 2:]) - sum(A[:N // 2])) - (A[N // 2] - A[N // -1])
else:
    ans = 2 * (sum(A[N // +1:]) - sum(A[:N // 2])) - min(A[N // 2] - A[N // 2 - 1], A[N // 2 + 1] - A[N // 2])

print(ans)


Fixed submission:
N = int(input())
A = sorted([int(input()) for i in range(N)])

if N % 2 == 0:
    print(2 * (sum(A[N // 2:]) - sum(A[:N // 2])) - (A[N // 2] - A[N // 2 - 1]))
else:
    print(2 * (sum(A[N // 2 + 1:]) - sum(A[:N // 2])) - min(A[N // 2] - A[N // 2 - 1], A[N // 2 + 1] - A[N // 2]))
Buggy python submission (verdict: Runtime Error):
from math import gcd

N, M = map(int, input().split())
S = input(); T = input()

nm_gcd = gcd(N, M)
n, m = M // nm_gcd, N // nm_gcd
ans = N * M // nm_gcd
for i in range(nm_gcd):
    if S[i * m] != T[i * n]:
        ans = -1
        break

print(ans)

Fixed submission:
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def main():
    N, M = map(int, input().split())
    S = input()
    T = input()

    g = gcd(N, M)
    for i in range(g):
        if S[i * N // g] != T[i * M // g]:
            print("-1")
            exit()
    print(N * M // g)

main()

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def main():
    N, M = map(int, input().split())
    S, T = input().split()

    g = gcd(N, M)
    for i in range(g):
        if S[i * N / g] == T[i * M / g]:
            print("-1")
            exit()
    print(N * M / g)

main()


Fixed submission:
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def main():
    N, M = map(int, input().split())
    S = input()
    T = input()

    g = gcd(N, M)
    for i in range(g):
        if S[i * N // g] != T[i * M // g]:
            print("-1")
            exit()
    print(N * M // g)

main()
Buggy python submission (verdict: Runtime Error):
S = str(input())
T = str(input())

for i in range(int(len(S) / 2)):
    if S[i] == T[i]:
        continue
    else:
        s_before = S[i]
        S = S.replace(T[i], ',')
        S = S.replace(S[i], T[i])
        S = S.replace(',', s_before)
    if S[len(S) - i] == T[len(S) - i]:
        continue
    else:
        s_before = S[len(S) - i]
        S = S.replace(T[len(S) - i], ',')
        S = S.replace(S[len(S) - i], T[len(S) - i])
        S = S.replace(',', s_before)

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

Fixed submission:
import string

alphabet = string.ascii_lowercase

S = str(input())
T = str(input())
start = [-1 for i in range(len(alphabet))]
goal = [-1 for i in range(len(alphabet))]
tf = True

for i in range(len(S)):
    a = alphabet.index(S[i])
    b = alphabet.index(T[i])

    if (start[a] != -1 or goal[b] != -1):
        if (start[a] != b or goal[b] != a):
            tf = False
            break
    else:
        start[a] = b
        goal[b] = a

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

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
T = str(input())

for i in range(len(S)):
    if S[i] == T[i]:
        continue
    else:
        s_before = S[i]
        S = S.replace(T[i], ',')
        S = S.replace(S[i], T[i])
        S = S.replace(',', s_before)
    if (S == T):
        print("Yes")
        exit()

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

Fixed submission:
import string

alphabet = string.ascii_lowercase

S = str(input())
T = str(input())
start = [-1 for i in range(len(alphabet))]
goal = [-1 for i in range(len(alphabet))]
tf = True

for i in range(len(S)):
    a = alphabet.index(S[i])
    b = alphabet.index(T[i])

    if (start[a] != -1 or goal[b] != -1):
        if (start[a] != b or goal[b] != a):
            tf = False
            break
    else:
        start[a] = b
        goal[b] = a

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

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
T = str(input())

for i in range(len(S)):
    if S[i] == T[i]:
        continue
    else:
        s_before = S[i]
        S = S.replace(T[i], ',')
        S = S.replace(S[i], T[i])
        S = S.replace(',', s_before)


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

Fixed submission:
import string

alphabet = string.ascii_lowercase

S = str(input())
T = str(input())
start = [-1 for i in range(len(alphabet))]
goal = [-1 for i in range(len(alphabet))]
tf = True

for i in range(len(S)):
    a = alphabet.index(S[i])
    b = alphabet.index(T[i])

    if (start[a] != -1 or goal[b] != -1):
        if (start[a] != b or goal[b] != a):
            tf = False
            break
    else:
        start[a] = b
        goal[b] = a

if tf:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S = input()

count = 0
tf = True
if S[0] != "A" or S[1] == "C" or S[-1] == "C":
    tf = False

for i in range(len(S)):
	if tf:
		break
    if i == 0:
        continue
    if S[i] == "C":
        count += 1
    elif not S[i].islower():
        tf = False

if tf and count == 1:
    print("AC")
else:
    print("WA")


Fixed submission:
S = input()

count = 0
ans = True

if S[0] != "A":
    ans = False
if not "C" in S[2:-1]:
    ans = False
for s in S:
    if s.isupper():
        count += 1
if count > 2:
    ans = False

print("AC" if ans else "WA")
Buggy python submission (verdict: Runtime Error):
D, G = map(int, input().split())
PC = [tuple(map(int, input().split()))]

res = float("inf")
for bit in range(1 << D):
    sum = 0
    num = 0
    for i in range(D):
        if ((bit >> i) & 1):
            sum += (i + 1) * 100 * P[i] + C[i]
            num += P[i]
    if sum >= G:
        res = min(res, num)
    for i in range(D - 1, -1, -1):
        if ((bit >> i) & 1):
            continue
        for j in range(P[i] - 1):
            sum += (i + 1) * 100
            num + +
        if sum >= G:
            res = min(res, num)
            break
    print(res)


Fixed submission:
D, G = map(int, input().split())
PC = [tuple(map(int, input().split())) for _ in range(D)]

res = float("inf")
for bit in range(1 << D):
    summ = 0
    num = 0
    for i in range(D):
        if ((bit >> i) & 1):
            summ += (i + 1) * 100 * PC[i][0] + PC[i][1]
            num += PC[i][0]
    if summ >= G:
        res = min(res, num)
    for i in range(D - 1, -1, -1):
        if ((bit >> i) & 1):
            continue
        for _ in range(PC[i][0] - 1):
            summ += (i + 1) * 100
            num += 1
            if summ >= G:
                res = min(res, num)
                break
print(res)