Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = int(input())
F = [0]*N
H = inpl()
ans = 0
while True:
    for l in range(N):
        if F[l] < H[l]:
            for r in range(l+1, N):
                if F[r] < H[r]:
                    continue
                break
            else:
                r += 1
            if r > N:
                r = N
            for j in range(l, r):
                F[j] += 1
            if l < r:
                ans += 1
            break
    else:
        break
#assert F == H
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = int(input())
F = [0]*N
H = inpl()
ans = 0
while True:
    for l in range(N):
        if F[l] < H[l]:
            for r in range(l, N):
                if F[r] < H[r]:
                    continue
                break
            else:
                r += 1
            if r > N:
                r = N
            for j in range(l, r):
                F[j] += 1
            ans += 1
            break
    else:
        break
#assert F == H
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = int(input())
F = [0]*N
H = inpl()
ans = 0
checked = [0]*1000
while True:
    checked[ans] += 1
    for l in range(N):
        if F[l] < H[l]:
            for r in range(l+1, N):
                if F[r] < H[r]:
                    continue
                break
            else:
                r += 1
            if r > N:
                r = N
            for j in range(l, r):
                F[j] += 1
            if l < r:
                ans += 1
            break
    else:
        break
assert F == H
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = int(input())
F = [0]*N
H = inpl()
ans = 0
while True:
    for l in range(N):
        if F[l] < H[l]:
            for r in range(l, N):
                if F[r] < H[r]:
                    continue
                break
            else:
                r += 1
            if r > N:
                r = N
            for j in range(l, r):
                F[j] += 1
            ans += 1
            break
    else:
        break
#assert F == H
print(ans)
Buggy python submission (verdict: Runtime Error):
rom bisect import bisect
def inpl(): return list(map(int, input().split()))

N, L = inpl()
DP = [1e9]*(10**5 + 2)
DP[0] = 0
for i in range(N):
    DP2 = [1e9]*(10**5 + 2)
    w, v = inpl()

    for i in range(10**5, v-1, -1):
        DP2[i] = min(DP[i-v] + w, DP[i], DP2[i+1])
    for i in range(v-1, -1, -1):
        DP2[i] = min(DP[i], DP2[i+1])
    DP = DP2
print(bisect(DP, L)-1)

Fixed submission:
from bisect import bisect
def inpl(): return list(map(int, input().split()))

N, L = inpl()
DP = [1e10]*(10**5 + 2)
DP[0] = 0
for i in range(N):
    DP2 = [1e10]*(10**5 + 2)
    w, v = inpl()

    for i in range(10**5, v-1, -1):
        DP2[i] = min(DP[i-v] + w, DP[i], DP2[i+1])
    for i in range(v-1, -1, -1):
        DP2[i] = min(DP[i], DP2[i+1])
    DP = DP2
print(bisect(DP, L)-1)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

N, K = inpl()
A = inpl()
tmp = 0
S = [0]*N
Q = []
for i in range(N):
    tmp += A[i]
    S[i] = tmp
    Q.append(tmp)

tmp = 0
for i in range(1, N):
    tmp = S[i-1]
    for j in range(i, N):
        #print(i, j)
        v = S[j] -S[i-1]
        Q.append(v)

res = 0
L = len(Q)
I = len(bin(sum(A))) - 2
while True:
    ok = 0
    for i in range(I):
        num = res + 2**i
        tmp = 0
        for j in range(L):
            if num & Q[j] == num:
                tmp += 1
        if tmp >= K:
            ok = num

    I = len(bin(res - ok)) - 2
    if res < ok & ok > 0:
        res = ok
    else:
        break

print(res)

Fixed submission:
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

N, K = inpl()
A = inpl()
tmp = 0
S = [0]*N
Q = []
for i in range(N):
    tmp += A[i]
    S[i] = tmp
    Q.append(tmp)

tmp = 0
for i in range(1, N):
    tmp = S[i-1]
    for j in range(i, N):
        #print(i, j)
        v = S[j] -S[i-1]
        Q.append(v)

res = 0
while True:
    ok = 0
    for i in range(40):
        num = res + int("1" + "0"*i, 2)
        tmp = 0
        for j in range(len(Q)):
            if num & Q[j] == num:
                tmp += 1
        if tmp >= K:
            ok = num
    if res < ok:
        res = ok
    else:
        break
print(res)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import defaultdict
def inpl(): return list(map(int, input().split()))
H, W = inpl()
coins = []
grid = defaultdict(int)

z = 0
for h in range(H):
    for w, x in enumerate(input()):
        if x == "#":
            coins.append((w-h, w+h))
            #print(z, (w-h, w+h))
            z+= 1


ans = 0
check = set(coins)
for i in range(len(coins)):
    for j in range(i+1, len(coins)):
        a, b = coins[i]
        c, d = coins[j]
        if a == c or b == d:
            continue
        if (a, d) in check:
            pass
            #print((a, b), (c, d), (a, d))
        if (c, b) in check:
            pass
            #print((a, b), (c, d), (c, b))
        ans += ((a, d) in check) + ((c, b) in check)

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
A = sorted([int(input()) for _ in range(N)])
ans = 0
if N%2 == 0:
    B = []
    for i in range(N//2)[::-1]:
        if i%2:
            B.append(-i-1)
        else:
            B.append(i)
    for i in range(N//2):
        if i%2:
            B.append(i)
        else:
            B.append(-i-1)
    S = [A[b] for b in B]
    for i in range(N-1):
        ans += abs(S[i+1] - S[i])
else:
    M = N//2
    B = list(range(1, M+2))[::-1] + list(range(1, M+1))
    S = []
    for i, b in enumerate(B):
        if i%2:
            S.append(A[-b])
        else:
            S.append(A[b-1])
    for i in range(N-1):
        ans += abs(S[i+1] - S[i])

    S = []
    for i, b in enumerate(B):
        if i%2:
            S.append(A[b-1])
        else:
            S.append(A[-b])
    tmp = 0
    for i in range(N-1):
        tmp += abs(S[i+1] - S[i])
    ans = max(ans, tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from fractions import gcd
def inpl(): return list(map(int, input().split()))
N, M = inpl()
S = input()
T = input()

G = N*M // gcd(N, M)

ans = ["*"]*(G)

x = G//N
y = G//M
for n in range(N):
    ans[n*x] = S[n]

for m in range(M):
    if (ans[m*y] == "*") or (ans[m*y] == T[m]):
        ans[m*y] = T[m]
    else:
        print(-1)
        break
else:
    print(G)

Fixed submission:
# -*- coding: utf-8 -*-
from fractions import gcd
from bisect import bisect_left
def inpl(): return list(map(int, input().split()))
N, M = inpl()

S = input()
T = input()

if N > M:
    N, M = M, N
    S, T = T, S

G = N*M // gcd(N, M)

a = G//N
b = G//M

X = [a*i for i in range(N)]
Y = [b*j for j in range(M)]

for i, x in enumerate(X):
    j = bisect_left(Y, x)
    if j < M and Y[j] == x:
        if S[i] != T[j]:
            print(-1)
            break
else:
    print(G)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import defaultdict
from bisect import bisect
def inpl(): return list(map(int, input().split()))

def primes(N):
    sieve = [True]*(N+1)
    sieve[:2] = [False, False]
    for i in range(4, N+1, 2):
        sieve[i] = False

    for i in range(3, N+1, 2):
        if sieve:
            for j in range(2*i, N+1, i):
                sieve[j] = False
    P = []
    for i in range(N+1):
        if sieve[i]:
            P.append(i)
    return P

N, M = inpl()
P = primes(10**6)
searched = defaultdict(int)

Q = [1]

if N==1:
    print(M)
    exit()

if M%N == 0:
    ans = M//N
else:
    ans = 1
while Q:
    a = Q.pop()
    for p in P:
        c = a*p
        d = M - c*N
        if d < 0:
            break
        
        if d%c == 0:
            if not searched[c]:
                searched[c] = True
                ans = max(ans, c)
                Q.append(c)
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = int(input())
if N == 1:
    print("Hello World")
else:
    print(int(input()) + int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from collections import defaultdict
from bisect import bisect
def inpl(): return list(map(int, input().split()))

def primes(N):
    sieve = [True]*(N+1)
    sieve[:2] = [False, False]
    for i in range(4, N+1, 2):
        sieve[i] = False

    for i in range(3, N+1, 2):
        if sieve:
            for j in range(2*i, N+1, i):
                sieve[j] = False
    P = []
    for i in range(N+1):
        if sieve[i]:
            P.append(i)
    return P

N, M = inpl()
P = primes(10**6)
searched = defaultdict(int)

Q = [1]

if N==1:
    print(M)
    exit()

if M%N == 0:
    ans = M//N
else:
    ans = 1
while Q:
    a = Q.pop()
    for p in P:
        c = a*p
        d = M - c*N
        if d < 0:
            break
        
        if d%c == 0:
            if not searched[c]:
                searched[c] = True
                ans = max(ans, c)
                Q.append(c)
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
from collections import defaultdict
from bisect import bisect
def inpl(): return list(map(int, input().split()))

def primes(N):
    sieve = [True]*(N+1)
    sieve[:2] = [False, False]
    for i in range(4, N+1, 2):
        sieve[i] = False

    for i in range(3, N+1, 2):
        if sieve:
            for j in range(2*i, N+1, i):
                sieve[j] = False
    P = []
    for i in range(N+1):
        if sieve[i]:
            P.append(i)
    return P

N, M = inpl()
P = primes(10**6)
searched = defaultdict(int)

Q = [1]

if N==1:
    print(M)
    exit()

if M%N == 0:
    ans = M//N
else:
    ans = 1
while Q:
    a = Q.pop()
    for p in P:
        c = a*p
        d = M - c*N
        if d < 0:
            break
        
        if d%c == 0:
            if not searched[c]:
                searched[c] = True
                ans = max(ans, c)
                Q.append(c)
print(ans)
Buggy python submission (verdict: Runtime Error):
print(["No", "Yes"][Counter(Counter(input()).values()) == Counter(Counter(input()).values())])

Fixed submission:
from collections import Counter as C
print(["No", "Yes"][C(C(input()).values()) == C(C(input()).values())])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

S = input()
T = input()

for i in range(N+1):
    if S == T[i:] + T[:i]:
        print("Yes")
        break
else:
    print("No")

Fixed submission:
S = input()
T = input()

for i in range(len(S)):
    if S[i:] + S[:i] == T:
        print("Yes")
        break
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import defaultdict

N = int(input())
S = input()
A, B = S[:N], S[N:]
D = defaultdict(int)
ans = 0

def paint(X, i):
    r = ""
    b = ""
    for j, k in enumerate(format(i, "b").zfill(N)):
        if k == "1":
            r += X[j]
        else:
            b += X[j]
    return r, b

for i in range(2**N):
    r, b = paint(A, i)
    D[(r, b)] += 1

for i in range(2**N):
    r, b = paint(B, i)
    ans += D[(b[::-1], r[::-1])]

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = int(input())
A = list(inpl()) + [0]

i = 1
ans = 0
while i < N:
    if A[i-1] == A[i]:
        ans += 1
        i += 1
    i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop, heappush

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

GA = [[] for _ in range(N+1)]
GB = [[] for _ in range(N+1)]

for _ in range(M):
    u, v, a, b = map(int, input().split())
    GA[u].append([v, a])
    GA[v].append([u, a])
    GB[v].append([u, b])
    GB[u].append([v, b])

costa = [10**16]*(N+1)
costb = [10**16]*(N+1)

costa[S] = 0
costb[T] = 0
Q = [[0, S]]


while Q:
    c, p = heappop(Q)
    if costa[p] < c:
        continue

    for q, a in GA[p]:
        if costa[q] > c+a:
            costa[q] = c+a
            heappush(Q, [c+a, q])

Q = [[0, T]]

while Q:
    c, p = heappop(Q)
    if costb[p] < c:
        continue

    for q, b in GB[p]:
        if costb[q] > c+b:
            costb[q] = c+b
            heappush(Q, [c+b, q])

ans = []
tmp = 10**16

for i in range(N, -1, -1):
    
    tmp = min(tmp, costa[i] + costb[i])
    ans.append(10**15 - tmp)

print(*ans[::-1][1:], sep="\n")

Fixed submission:
from heapq import heappop, heappush

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

GA = [[] for _ in range(N+1)]
GB = [[] for _ in range(N+1)]

for _ in range(M):
    u, v, a, b = map(int, input().split())
    GA[u].append([v, a])
    GA[v].append([u, a])
    GB[v].append([u, b])
    GB[u].append([v, b])

costa = [10**16]*(N+1)
costb = [10**16]*(N+1)

costa[S] = 0
costb[T] = 0
Q = [[0, S]]


while Q:
    c, p = heappop(Q)
    if costa[p] < c:
        continue

    for q, a in GA[p]:
        if costa[q] > c+a:
            costa[q] = c+a
            heappush(Q, [c+a, q])

Q = [[0, T]]

while Q:
    c, p = heappop(Q)
    if costb[p] < c:
        continue

    for q, b in GB[p]:
        if costb[q] > c+b:
            costb[q] = c+b
            heappush(Q, [c+b, q])

ans = []
tmp = 10**16

for i in range(N, -1, -1):
    
    tmp = min(tmp, costa[i] + costb[i])
    ans.append(10**15 - tmp)

print(*ans[::-1][1:], sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from itertools import accumulate, product

N = int(input())
A = list(map(int, input().split()))
S = list(accumulate(A))
T = sum(A)
ans = 10**16

for j in range(1, N-1):
    PQ = S[j]
    RS = T - S[j]
    #print("PQ RS", PQ, RS)
    
    i1 = bisect(S, PQ/2) - 1
    i2 = bisect_left(S, PQ/2)
    
    k1 = bisect(S, RS/2 + PQ) - 1
    k2 = bisect_left(S, RS/2 + PQ)
    
    for i, k in product([i1, i2], [k1, k2]):
        #print(i, j, k)
        if i < 0 or i==j or j == k or k == N-1:
            continue
        PQRS = [S[i], S[j] - S[i], S[k] - S[j], T - S[k]]
        #print(PQRS)
        ans = min(ans, abs(max(PQRS) - min(PQRS)))

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from itertools import accumulate, product

N = int(input())
A = list(map(int, input().split()))
S = list(accumulate(A))
T = sum(A)
ans = 10**16

for j in range(1, N-1):
    PQ = S[j]
    RS = T - S[j]
    #print("PQ RS", PQ, RS)
    
    i1 = bisect(S, PQ/2) - 1
    i2 = bisect_left(S, PQ/2)
    
    k1 = bisect(S, RS/2 + PQ) - 1
    k2 = bisect_left(S, RS/2 + PQ)
    
    for i, k in product([i1, i2], [k1, k2]):
        #print(i, j, k)
        if i < 0 or i==j or j == k or k == N-1:
            continue
        PQRS = [S[i], S[j] - S[i], S[k] - S[j], T - S[k]]
        #print(PQRS)
        ans = min(ans, abs(max(PQRS) - min(PQRS)))

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max(A+B,
          A-B,
          A*X))

Fixed submission:
A, B = map(int, input().split())
print(max(A+B,
          A-B,
          A*B))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from itertools import accumulate
def inpl(): return map(int, input().split())

N, K, Q = inpl()
A = " " + input()
S = sorted(map(int, A.split()))
ans = S[Q-1] - S[0]
S = S[::-1]

while S:
    s = S.pop()
    A = A.replace(" {} ".format(s), " x ")

    OK = 0
    Que = A.split("x")

    tmp = []
    for q in Que:
        tmp.extend(sorted([int(x) for x in q.split()])[::-1][K-1:])
    if len(tmp) < Q:
        break
    tmp = sorted(tmp)
    ans = min(ans, tmp[Q-1] - tmp[0])

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
from itertools import accumulate
def inpl(): return map(int, input().split())

N, K, Q = inpl()
A = " " + input()
S = sorted(map(int, A.split()))
ans = S[Q-1] - S[0]
S = S[::-1]

while S:
    s = S.pop()
    A = A.replace(" {} ".format(s), " x ")

    OK = 0
    Que = A.split("x")

    tmp = []
    for q in Que:
        tmp.extend(sorted([int(x) for x in q.split()])[::-1][K-1:])
    if len(tmp) < Q:
        break
    tmp = sorted(tmp)
    ans = min(ans, tmp[Q-1] - tmp[0])

print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from itertools import accumulate
def inpl(): return map(int, input().split())

N, K, Q = inpl()
A = input()

S = sorted(map(int, A.split()))
ans = S[Q-1] - S[0]
S = S[::-1]
Que = [A]


while True:
    s = S.pop()
    nQ = []
    OK = 0
    for q in Que:
        for r in (" "+q).split(" {} ".format(s)):
            L = len(r.split())
            if L >= K:
                nQ.append(r)
                OK += (L - K + 1)
    if OK < Q:
        break
    tmp = []
    for q in nQ:
        tmp.extend(sorted([int(x) for x in q.split()])[::-1][K-1:])
    tmp = sorted(tmp)
    ans = min(ans, tmp[Q-1] - tmp[0])
    Que = nQ

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
from itertools import accumulate
def inpl(): return map(int, input().split())

N, K, Q = inpl()
A = " " + input()
S = sorted(map(int, A.split()))
ans = S[Q-1] - S[0]
S = S[::-1]

while S:
    s = S.pop()
    A = A.replace(" {} ".format(s), " x ")

    OK = 0
    Que = A.split("x")

    tmp = []
    for q in Que:
        tmp.extend(sorted([int(x) for x in q.split()])[::-1][K-1:])
    if len(tmp) < Q:
        break
    tmp = sorted(tmp)
    ans = min(ans, tmp[Q-1] - tmp[0])

print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())
print(max([1] + [pow(b, int(log(X, b))) for b in range(2, int(sqrt(X))+1)]))

Fixed submission:
from math import sqrt, log
X = int(input())
print(X if X in [243, 1000] else max([1] + [pow(b, int(log(X, b))) for b in range(2, int(sqrt(X))+1)]))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = int(input())
balls = [input().replace(" ", "") for _ in range(2*N)] + ["END"]

B = ["END"] + ["B{}".format(i) for i in range(1, N+1)[::-1]]
W = ["END"] + ["W{}".format(i) for i in range(1, N+1)[::-1]]

ans = 0
for i in range(2*N):
    b = balls.index(B[-1])
    w = balls.index(W[-1])
    if b < w:
        if b != i:
            ans += b-i
            del balls[b]
            balls.insert(i, B[-1])
        B.pop()
    else:
        if w != i:
            ans += w-i
            del balls[w]
            balls.insert(i, W[-1])
        W.pop()

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
S = input()
K = int(input())
ans = set()

for s in sorted(set(S)):
    if len(ans) >= K:
        break
    for i in range(len(S)):
        if S[i] == s:
            for k in range(K):
                ans.add(S[i:i+k+1])

print(sorted(ans)[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from itertools import combinations
def inpl(): return map(int, input().split())

N = int(input())
S = [list(input()) for _ in range(N)]
ans = 0

for k in range(N):
    for i, j in combinations(range(N), 2):
        if S[i][(j+k)%N] != S[j][(i+k)%N]:
            break
    else:
        ans += N

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
from itertools import combinations
def inpl(): return map(int, input().split())

N = int(input())
S = [list(input()) for _ in range(N)]
ans = 0

for k in range(N):
    for i, j in combinations(range(N), 2):
        if S[i][(j+k)%N] != S[j][(i+k)%N]:
            break
    else:
        ans += N

print(ans)
Buggy python submission (verdict: Runtime Error):
print(700+100*input().count(“o“))

Fixed submission:
print(700+100*input().count('o'))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import sqrt
def inpl(): return map(int, input().split())
Q = int(input())

def check(X, m):
    if X//m > m:
        return True
    else:
        return False

for q in range(Q):
    A, B = inpl()
    if A > B:
        A, B = B, A

    X = A*B
    if X <= 2:
        print(0)
        continue
    elif X == 3:
        print(1)
        continue
    
    L = int(sqrt(X))
    if L*L == X:
        L -= 1

    ok, ng = 1, X+1
    while ng - ok > 1:
        m = (ok+ng)//2
        if check(X-1, m):
            ok = m
        else:
            ng = m
    
    tmp = L + ok
    
    if A == B:
        print(tmp)
    else:
        if A>1 and X-1//(A-1) == B and X-1//A == B-1:
            print(tmp-2)
        elif (X-1)//A == A:
            print(tmp-2)
        else:
            print(tmp-1)

Fixed submission:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
A, B, C = sorted(list(inpl()))
res = 0
res += (C-B)
A += res
B += res
d, m = divmod(B-A, 2)
res += d+2*m
print(res)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = input()
ans = 0

while N:
    if N[0] == "9":
        ans += 9
        N = N[1:]
    else:
        break

if all([n=="9" for n in list(N[1:])]):
    print(ans + int(N[0]) + len(N[1:])*9)
elif ans == 0:
    if len(N) == 1:
        ans = int(N)
    else:
        ans += int(N[0]) - 1 + len(N[1:])*9
    print(ans)
elif len(N)==0:
    print(ans)
else:
    print(ans - 1 + len(N)*9)

Fixed submission:
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = input()

res = 0
for i, j in enumerate(N):
    if j != "9":
        break

if i >= 2:
    res += 9*(i-1)
    N = N[i-1:]

A = 10**(len(N)-1)

res += max(sum(map(int, N)), sum(map(int, str(int(N)//A*A-1))))
print(res)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = input().split()
x = int(a+b)
ok = [False]*(100100)

for i in range(1, 317):
    ok[i*i] = True

print("Yes" if ok[x] else "No")


Fixed submission:
# -*- coding: utf-8 -*-
a, b = input().split()
x = int(a+b)
ok = [False]*(100101)
 
for i in range(1, 317):
    ok[i*i] = True
 
print("Yes" if ok[x] else "No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = input()
n = len(S)
L = list(map(int, list(S)))
D = []
res = 0
for k in range(n-1):
    if L[k] != L[k+1]:
        D.append(max(k+1, n-k-1))

print(min(D))

Fixed submission:
# -*- coding: utf-8 -*-
S = input()
n = len(S)
L = list(map(int, list(S)))
D = []
res = 0
for k in range(n-1):
    if L[k] != L[k+1]:
        D.append(max(k+1, n-k-1))

if len(D):
    print(min(D))
else:
    print(n)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from itertools import product
from operator import xor
from functools import reduce
 
rS = input()
S = int(rS, 2)
 
L = len(rS)
k = len(rS)
 
dp = set([0])
while True:
    A = [sum([2**i for i in range(I, I+k)]) for I in range(L-k+1)]
    B = set([reduce(xor, A_) for i in range(0, L-k+1) for A_ in product(A, repeat=i+1)])
    dp.update([d^b for d, b in product(dp, B)])
    if S in dp:
        break
    else:
        #print(dp)
        k -= 1
print(k)

Fixed submission:
# -*- coding: utf-8 -*-
S = input()
n = len(S)
L = list(map(int, list(S)))
D = []
res = 0
for k in range(n-1):
    if L[k] != L[k+1]:
        D.append(max(k+1, n-k-1))

if len(D):
    print(min(D))
else:
    print(n)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from itertools import product
from operator import xor
from functools import reduce

rS = input()
S = int(rS, 2)

L = len(rS)
k = len(rS)

dp = set([0])
while True:
    A = [sum([2**i for i in range(I, I+k)]) for I in range(L-k+1)]
    B = set([reduce(xor, A_) for i in range(0, L-k+1) for A_ in product(A, repeat=i+1)])
    dp.update([d^b for d, b in product(dp, B)])
    if S in dp:
        break
    else:
        #print(dp)
        k -= 1
print(k)

Fixed submission:
# -*- coding: utf-8 -*-
S = input()
n = len(S)
L = list(map(int, list(S)))
D = []
res = 0
for k in range(n-1):
    if L[k] != L[k+1]:
        D.append(max(k+1, n-k-1))

if len(D):
    print(min(D))
else:
    print(n)