Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02690 (python)

Fixed submission:
X = int(input())

def check():
    for i in range(1000):
        for j in range(1000):
            if i**5 + j**5 == X:
                print(i, -j)
                return
            elif i**5 - j**5 == X:
                print(i, j)
                break

check()

Buggy submission (verdict: Runtime Error):
X = int(input())
p = 1e9

n = 1
C = [0]
while n**5 < p:
    C.append(n)
    n += 1

for i in C:
    for j in C:
        if i**5 + j**5 == X:
            a, b = i, -j
            break
        elif i**5 - j**5 == X:
            a, b = i, j
            break

print(a, b)
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
A = [input().split() for _ in range(M)]

c = [0]*N
w = [0]*N

ac = 0
wa = 0

for i, v in A:
    if c[int(i)-1] == 0:
        if v == 'WA':
            w[int(i)-1] += 1
        elif v == 'AC':
            ac += 1
            wa += w[int(i)-1]
            c[int(i)-1] = 1

print(ac, wa)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [input().split() for _ in range(M)]

c = [0]*N
w = [0]*M

ac = 0
wa = 0

for i, v in A:
    if c[int(i)-1] == 0:
        if v == 'WA':
            w[int(i)-1] += 1
        elif v == 'AC':
            ac += 1
            wa += w[int(i)-1]
            c[int(i)-1] = 1

print(ac, wa)
Problem p02803 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
maze = [input() for _ in range(H)]


def bfs(sty, stx):
    visited = [[-1]*W for _ in range(H)]
    q = deque()
    visited[sty][stx] = 0
    q.append((sty, stx, 0))


    def is_ok(y, x):
        if not 0 <= y <= H - 1:
            return False
        if not 0 <= x <= W - 1:
            return False
        if visited[y][x] != -1:
            return False
        if maze[y][x] == '#':
            return False
        return True


    while q:
        y, x, lv = q.popleft()
        for i in (-1, 1):
            if is_ok(y+i, x):
                visited[y+i][x] = lv+1
                q.append((y+i, x, lv+1))
            if is_ok(y, x+i):
                visited[y][x+i] = lv + 1
                q.append((y, x+i, lv+1))

    return max(max(r) for r in visited)

res = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '.':
            res = max(res, bfs(i, j))

print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np
from collections import deque

H, W = map(int, input().split())
maze = np.array([input() for _ in range(H)])


def bfs(sty, stx):
    visited = np.array([[-1 for _ in range(W)] for _ in range(H)])
    q = deque()
    q.append((sty, stx, 0))


    def is_ok(y, x):
        if not 0 <= y <= H - 1:
            return False
        if not 0 <= x <= W - 1:
            return False
        if visited[y][x] != -1:
            return False
        if maze[y][x] == '#':
            return False
        return True


    while q:
        y, x, lv = q.popleft()
        visited[y][x] = lv
        for i in (-1, 1):
            if is_ok(y+i, x):
                q.append((y+i, x, lv+1))
            if is_ok(y, x+i):
                q.append((y, x+i, lv+1))

    return np.max(visited)

res = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '.':
            steps = bfs(i, j)
            if steps > res:
                res = steps

print(res)
Problem p02804 (python)

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

p = 1000000007
X_max = 0
X_min = 0


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


for i in range(N-K+1):
    n = cmb(N-1-i, K-1, p)
    X_max += n*A[-(i+1)]
    X_max %= p
    X_min += n*A[i]
    X_min %= p

print(int((X_max - X_min) % p))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

mod = 1000000007
X_max = 0
X_min = 0

for i in range(N-K+1):
    n = comb(N-1-i, K-1)
    X_max += n*A[-(i+1)]
    X_max %= mod
    X_min += n*A[i]
    X_min %= mod

print(int((X_max - X_min) % mod))

Buggy submission (verdict: Runtime Error):
from math import factorial

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

X_max = 0
X_min = 0

nCr = {}

def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    return nCr[(n, r)]


for i in range(N-K+1):
    n = cmb(N-1-i, K-1)
    X_max += n*A[-(i+1)]
    X_min += n*A[i]

print((X_max - X_min) % 1000000007)

Buggy submission (verdict: Runtime Error):
from math import factorial

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

X_max = 0
X_min = 0

for i in range(N-K+1):
    X_max += (factorial(N-1-i) / factorial(K-1) / factorial(N-K-i))*A[-(i+1)]
    X_min += (factorial(N-1-i) / factorial(K-1) / factorial(N-K-i))*A[i]
    X_max %= 1000000007
    X_min %= 1000000007

print(int(X_max - X_min))

Buggy submission (verdict: Runtime Error):
from math import factorial

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

X_max = 0
X_min = 0

for i in range(N-K+1):
    X_max += (factorial(N-1-i) / factorial(K-1) / factorial(N-K-i))*A[-(i+1)]
    X_min += (factorial(N-1-i) / factorial(K-1) / factorial(N-K-i))*A[i]

print(int(X_max - X_min))
Problem p02814 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

def div2(x):
    c = 0
    while x%2==0:
        x //= 2
        c+=1
    return c

def test():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(N):
        if a[i]%2 == 1:
            return 0
        a[i] //= 2

    t = div2(a[0])
    for i in range(N):
        if div2(a[i]) != t:
            return 0
        a[i] >>= t
    M >>= t

    L = a[0]
    for i in range(1, N):
        L = lcm(L, a[i])
        if L > M:
            return 0

    ans = (M-L)//(2*L)+1
    return ans

print(test())

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

if len(a) == 1:
    f = a[0]//2
else:
    f = lcm(a[0]//2, a[1]//2)
    for i in range(2, N):
        f = lcm(f, a[i]//2)

if 1 <= f <= M:
    print((M-f)//(f*2) + 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().split()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

f = lcm(a[0], a[1])
for i in range(2, N):
    f = lcm(f, a[i])

if 1 <= f//2 <= M:
    print((M-f//2)//f + 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import fractions
 
N, M = map(int, input().split())
a = list(map(int, input().split()))
 
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
f = lcm(a[0], a[1])
for i in range(2, N):
    f = lcm(f, a[i])
 
if 1 <= f//2 <= M:
    print((M-f//2)//f + 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

f = lcm(a[0], a[1])
for i in range(2, N):
    f = lcm(f, a[i])

if 1 <= f//2 <= M:
    print((M-f//2)//f + 1)
else:
    print(0)
Problem p02844 (python)

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

ans = 0
for i in range(1000):
    n = "{:03}".format(i)
    index = 0
    c = 0
    for k in n:
        for j in range(index, N):
            if S[j] == k:
                index = j+1
                c+=1
                break
    if c == 3:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = str(input())

ans = 0
for i in range(1000):
    n = f"{i:03}"
    index = 0
    c = 0
    for k in n:
        for j in range(index, len(S)):
            if S[j] == k:
                index = j+1
                c+=1
                break
    if c == 3:
        ans += 1
print(ans)
Problem p02861 (python)

Fixed submission:
import math
import itertools
N = int(input())
town = [list(map(int, input().split())) for _ in range(N)]
path = []
for p in itertools.permutations(town):
    path.append(sum([math.sqrt((p[i+1][0]-p[i][0])**2 + (p[i+1][1]-p[i][1])**2) for i in range(len(p)-1)]))

print(sum(path)/len(path))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
town = [list(map(int, input().split())) for _ in range(N)]
path = []
for p in itertools.permutations(town):
    path.append(sum([math.sqrt((p[i+1][0]-p[i][0])**2 + (p[i+1][1]-p[i][1])**2) for i in range(len(p)-1)]))

print(sum(path)/len(path))

Buggy submission (verdict: Runtime Error):
N = int(input())
town = [list(map(int, input().split())) for _ in range(N)]
path = []
for p in itertools.permutations(town):
    path.append(sum([math.sqrt((p[i+1][0]-p[i][0])**2 + (p[i+1][1]-p[i][1])**2) for i in range(len(p)-1)]))

print(sum(path)/len(path))
Problem p02995 (python)

Fixed submission:

A, B, C, D = map(int, input().split())
U = B - A + 1

MofD = 0
MofCD = 0

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def lcm(x, y):
    return (x * y) // gcd(x, y)


def sten(st, en, x):
    if x == 1:
        return en - st + 1
    st = st // x if st % x == 0 else st // x + 1
    en = en // x
    st *= x
    en *= x
    if en >= st:
        n = (en - st) // x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
if C != D:
    MofD = sten(A, B, D)
    MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)

Buggy submission (verdict: Runtime Error):
import math
import sys
sys.setrecursionlimit(100000)
A, B, C, D = map(int, input().split())
U = B - A + 1


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def sten(st, en, x):
    st = math.ceil(st/x)*x
    en = math.floor(en/x)*x
    if en >= st:
        n = (en - st) // x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
MofD = sten(A, B, D)
MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)

Buggy submission (verdict: Runtime Error):
import math
import sys
sys.setrecursionlimit(100000)
A, B, C, D = map(int, input().split())
U = B - A + 1


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def sten(st, en, x):
    st = math.ceil(st/x)*x
    en = math.floor(en/x)*x
    if en >= st:
        n = (en - st) // x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
MofD = sten(A, B, D)
MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())
U = B - A + 1


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def sten(st, en, x):
    st = math.ceil(st/x)*x
    en = math.floor(en/x)*x
    if en >= st:
        n = (en - st) / x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
MofD = sten(A, B, D)
MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())
U = B - A + 1


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def sten(st, en, x):
    st = math.ceil(st/x)*x
    en = math.floor(en/x)*x
    if en >= st:
        n = (en - st)//x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
MofD = sten(A, B, D)
MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)
Problem p03006 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
p = defaultdict(int)
balls = [list(map(int, input().split())) for i in range(N)]

c = 0
if len(balls) <= 2:
    print(1)
else:
    for i in balls:
        for j in balls:
            c += 1
            if i == j:
                continue
            p[(j[0]-i[0]), j[1]-i[1]] += 1
    print(N-max(p.values()))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
d = defaultdict(int)
sx, sy = map(int, input().split())

for i in range(1, N):
    x, y = map(int, input().split())
    d[(x-sx, y-sy)] += 1
    sx, sy = x, y

print(N - max(d.values()))
Problem p03014 (python)

Fixed submission:
import numpy as np

H, W = map(int, input().split())
F = np.array([[1 if i == "." else 0 for i in input()] for _ in range(H)])
FU = np.zeros((H, W), dtype=int)
FD = np.zeros((H+1, W), dtype=int)
FL = np.zeros((H, W), dtype=int)
FR = np.zeros((H, W+1), dtype=int)

for i in range(H):
    FU[i] += (FU[i-1]+1)*F[i]

for i in range(H-1, -1, -1):
    FD[i] += (FD[i+1]+1)*F[i]

for i in range(W):
    FL[:, i] += (FL[:, i-1]+1)*F[:, i]

for i in range(W-1, -1, -1):
    FR[:, i] += (FR[:, i+1]+1)*F[:, i]

FV = FU + FD[:-1] - 1
FH = FL + FR[:, :-1] - 1
ans = np.max(FV+FH)
if ans >= 2:
    print(ans-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
F = [input() for _ in range(H)]
FH = [[0]*W for _ in range(H)]
FV = [[0]*W for _ in range(H)]


def search(x, y, c, d):
    if not (0 <= x < H and 0 <= y < W):
        return c
    if F[x][y] == "#":
        return c
    else:
        if d == "h":
            return search(x, y+1, c+1, "h")
        else:
            return search(x+1, y, c+1, "v")

ans = 0
for i in range(H):
    for j in range(W):
        if F[i][j] == "#":
            FH[i][j] = 0
        elif F[i][j] == ".":
            if FH[i][j-1] > 0:
                FH[i][j] = FH[i][j-1]
            else:
                FH[i][j] = search(i, j+1, 1, "h")

for i in range(H):
    for j in range(W):
        if F[i][j] == "#":
            FV[i][j] = 0
        elif F[i][j] == ".":
            if FV[i-1][j] > 0:
                FV[i][j] = FV[i-1][j]
            else:
                FV[i][j] = search(i+1, j, 1, "v")

ans = 0
for i in range(H):
    for j in range(W):
        if FH[i][j] + FV[i][j] > ans:
            ans = FH[i][j] + FV[i][j]

print(ans-1)
Problem p03035 (python)

Fixed submission:
A, B = map(int, input().split())
if A >= 13:
    print(B)
elif A >= 6:
    print(B//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
C = [c for b, c in BC for _ in range(b)]
A.sort()
C.sort(reverse=True)
d = deque([])
# d.extend(C[max(len(C)-N, 0):])
d.extend(C[:N])
#
# print(A)
# print(d)

i = 0
while d:
    q = d.popleft()
    if q > A[i]:
        A[i] = q
        i += 1
    else:
        break

print(sum(A))
Problem p03076 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders = [A, B, C, D, E]
max_fp = 10
ans = 0
last_order = 0

for i, order in enumerate(orders):
    if order % 10 < max_fp and order % 10 != 0:
        max_fp = order % 10
        last_order = i

for i, order in enumerate(orders):
    if i == last_order or order % 10 == 0:
        ans += order
    else:
        ans += (order // 10 + 1) * 10

print(ans)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders = [A, B, C, D, E]
max_fp = 10
ans = 0

for i, order in enumerate(orders):
    if order % 10 < max_fp and order % 10 != 0:
        max_fp = order % 10
        last_order = i

for i, order in enumerate(orders):
    if i == last_order or order % 10 == 0:
        ans += order
    else:
        ans += (order // 10 + 1) * 10

print(ans)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders = [A, B, C, D, E]
max_fp = 10
time = 0

for i, order in enumerate(orders):
    if order % 10 < max_fp and order % 10 != 0:
        max_fp = order % 10
        last_order = i

for i, order in enumerate(orders):
    if i == last_order or order % 10 == 0:
        time += order
    else:
        time += (order // 10 + 1) * 10

print(time)
Problem p03331 (python)

Fixed submission:
N = int(input())
factor_a = []
factor_b = []
ans = N
for a in range(1, N):
    sum_a = sum([int(i) for i in str(a)])
    sum_b = sum([int(i) for i in str(N-a)])
    if sum_a + sum_b < ans:
        ans = sum_a + sum_b
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
factor_a = []
factor_b = []
ans = N
if N % 2 == 0:
    for a in range(1, N/2+1):
        sum_a = sum([int(i) for i in str(a)])
        sum_b = sum([int(i) for i in str(N-a)])
        if sum_a + sum_b < ans:
            ans = sum_a + sum_b
else:
    for a in range(1, (N+1)/2+1):
        sum_a = sum([int(i) for i in str(a)])
        sum_b = sum([int(i) for i in str(N-a)])
        if sum_a + sum_b < ans:
            ans = sum_a + sum_b
print(ans)
Problem p03436 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
edges = ['#']*(W+2)
field = [edges]
dyx = [(0, 1), (0, -1), (1, 0), (-1, 0)]
bk = 0
for _ in range(H):
    line = list(input())
    bk += line.count('#')
    field.append(['#'] + line + ['#'])
field.append(edges)

steps = 1
q = deque()
field[1][1] = 1
q.append((1, 1, 1))

while q:
    cy, cx, lv = q.popleft()

    for dy, dx in dyx:
        ny, nx = dy+cy, dx+cx

        if field[ny][nx] == '.':
            field[ny][nx] = lv+1
            q.append((ny, nx, lv+1))
steps = str(field[H][W])
if steps.isnumeric():
    print(W*H-bk-int(steps))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque

H, W = map(int, input().split())
edges = ['#']*(W+2)
field = [edges]
dyx = [(0, 1), (0, -1), (1, 0), (-1, 0)]
bk = 0
for _ in range(H):
    line = list(input())
    bk += line.count('#')
    field.append(['#'] + line + ['#'])
field.append(edges)

steps = 1
q = deque()
field[1][1] = 1
q.append((1, 1, 1))

while q:
    cy, cx, lv = q.popleft()

    for dy, dx in dyx:
        ny, nx = dy+cy, dx+cx

        if field[ny][nx] == '.':
            field[ny][nx] = lv+1
            q.append((ny, nx, lv+1))
steps = field[H][W]
if steps.isnumeric():
    print(W*H-bk-steps)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque

H, W = map(int, input().split())
edges = ['#']*(W+2)
field = [edges]
dyx = [(0, 1), (0, -1), (1, 0), (-1, 0)]
bk = 0
for _ in range(H):
    line = list(input())
    bk += line.count('#')
    field.append(['#'] + line + ['#'])
field.append(edges)

steps = 1
q = deque()
field[1][1] = 1
q.append((1, 1, 1))

while q:
    cy, cx, lv = q.popleft()

    for dy, dx in dyx:
        ny, nx = dy+cy, dx+cx

        if field[ny][nx] == '.':
            field[ny][nx] = lv+1
            q.append((ny, nx, lv+1))
steps = field[H][W]

print(W*H-bk-steps)
Problem p03238 (python)

Fixed submission:
age = int(input())
if age == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)

Buggy submission (verdict: Runtime Error):
age = int(input())
if age == 1:
    print("Hello World")
else:
    A, B = map(int, input().split())
    print(A + B)
Problem p03455 (python)

Fixed submission:
a = input().split()
b = int(a[1])
a = int(a[0])
if (a * b) % 2:
  print("Odd")
else:
  print("Even")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = (a * b) / 2
if c == round(c):
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = (a * b) / 2
if c == round(c):
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = (a * b) / 2
if c == round(c):
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = a * b
if c / 2 == c // 2:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a = int(input)
b = int(input)
c = a * b
if c / 2 == c // 2:
  print(Even)
else:
  print(Odd)
Problem p03493 (python)

Fixed submission:
Si = input()
S1 = int(Si[0])
S2 = int(Si[1])
S3 = int(Si[2])
n = 0
if S1:
  n += 1
if S2:
  n += 1
if S3:
  n += 1
print(n)

Buggy submission (verdict: Runtime Error):
Si = int(input())
S1 = int(str(Si[-3]))
S2 = int(str(Si[-2]))
S3 = int(str(Si[-1]))
result = 0
if S1:
  result += 1
if S2:
  result += 1
if S3:
  result += 1
print(result)
Problem p02730 (python)

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

A=S[:(N-1)//2]
B=S[(N+3)//2-1:]

for i in range(len(S)):
	if S[i]!=S[-(i+1)]:
		print("No")
		exit()
for i in range(len(A)):
	if A[i]!=A[-(i+1)]:
		print("No")
		exit()
for i in range(len(B)):
	if B[i]!=B[-(i+1)]:
		print("No")
		exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)

A=S[:(N-1)//2]
B=S[(N+3)//2-1:])
for i in range(len(A)):
	if A[i]!=A[-(i+1)]:
		print("No")
		exit()
for i in range(len(B)):
	if B[i]!=B[-(i+1)]:
		print("No")
		exit()
print("Yes")
Problem p02780 (python)

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
E=[0]*N

for i in range (N):
	E[i]=((P[i]+1)/2)

L=[0]*(N+1)
L[0]=0

for i in range (N):
	L[i+1]=L[i]+E[i]

ans=0

for i in range (K,N+1):
	ans=max(ans,L[i]-L[i-K])

print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))
cnt=0
E=[0]*N
for i in range (N):
	E[i]=(P[i]+1)/2
for i in range(A):
	cnt=max(cnt,E[i:i+K])
print(cnt)

Buggy submission (verdict: Runtime Error):
P=list(map(int,input().split()))
cnt=0
tmp=0
ans=0
count=0
A=(N-K+1)
for i in range(A):
	#print(P[i:i+K])
	if cnt<sum(P[i:i+K]):
		cnt=sum(P[i:i+K])
		tmp=i
Q=P[tmp:tmp+K]
count=collections.Counter(Q)
C_K=list(count.keys())
C_V=list(count.values())
R=len(count.keys())
for i in range(R):
	ans+=(C_K[i]*(C_K[i]+1)/(2*C_K[i])*C_V[i])
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))
cnt=0
tmp=0
ans=0
count=0
for i in range(N-K+1):
	#print(P[i:i+K])
	if cnt<sum(P[i:i+K]):
		cnt=sum(P[i:i+K])
		tmp=i
Q=P[tmp:tmp+K]
count=collections.Counter(Q)
C_K=list(count.keys())
C_V=list(count.values())
R=len(count)
for i in range(R):
	ans+=(C_K[i]*(C_K[i]+1)/(2*C_K[i])*C_V[i])
print(ans)
Problem p02802 (python)

Fixed submission:
from collections import defaultdict

N,M=map(int,input().split())
P=[]
S=[]
for i in range (M):
	A,B=input().split()
	P.append(int(A))
	S.append(B)
Q=defaultdict(lambda:0)
R=defaultdict(lambda:0)
count=0
for i,j in zip(P,S):
  if Q[i]==0:
    if j=="AC":
      Q[i]=1
      count+=R[i]
    elif j=="WA":
      R[i]+=1
print(sum(Q.values()),count)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
L=[0]*N
A=0
W=0
tmp=[0]*M
for i in range(M):
	x,y=input().split()
	t=int(x)
	if L[t-1]==0:
		if y=="WA":
			tmp[t-1]+=1
		else:
			A+=1
			W+=tmp[t-1]
			L[t-1]=1
print(A,W)
Problem p02848 (python)

Fixed submission:
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
N = int(input())
S = input()
a = ''
for item in S:
  a_index = alphabet.index(item) + N
  if a_index > 25:
    a_index = a_index - 26
  a += alphabet[a_index]
print(a)

Buggy submission (verdict: Runtime Error):
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
N = int(input())
S = input()
a = ''
for item in S:
  a_index = alphabet.index(item) + n
  if a_index > 25:
    a_index = a_index - 26
  a += alphabet[a_index]
print(a)