Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
h,w,k = map(int, input().split())

if w == 1:
    print(1)
    exit(0)

case = []

def createCase(s):
    if (len(s) == w-1):
        case.append(s)
        return
    if len(s) != 0 and s[-1] == "1" :
        createCase(s+"0")
    else:
        createCase(s+"0")
        createCase(s+"1")

createCase("")

for i in range(len(case)):
    case[i] = "0"+case[i]+"0"

# print(case)

move = [[0]*3 for _ in range(w)]

for i in range(w):
    for j in case:
        if j[i] == j[i+1] == "0":
            move[i][1] += 1
        if j[i+1] == "1":
            move[i][2] += 1
        if j[i] == "1":
            move[i][0] += 1

# print(move)

dp = [[0]*w for _ in range(h)]

fib = [0, 1, 2, 3, 5, 8, 13, 21]

dp[0][0] = fib[w-1]
dp[0][1] = fib[w-2]

for i in range(1, h):
    dp[i][0] = (dp[i-1][0]*move[0][1] + dp[i-1][1]*move[1][0]) % 1000000007
    for j in range(1, w-1):
        dp[i][j] = (dp[i-1][j]*move[j][1] + dp[i-1][j-1]*move[j-1][2] + dp[i-1][j+1]*move[j+1][0]) % 1000000007
    dp[i][-1] = (dp[i-1][-2]*move[-2][2] + dp[i-1][-1]*move[-1][1]) % 1000000007

# print(dp)

print(dp[-1][k-1])


Fixed submission:
a,b = map(int, input().split())
print(a+b//2)

Buggy python submission (verdict: Runtime Error):
a

Fixed submission:
a,b = map(int, input().split())
print(a+b//2)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
city = [[] for _ in range(n+1)]
ret = ["" for _ in range(m)]
def createSix(s):
    while len(s) != 6:
        s = "0" + s
    return s
for i in range(m):
    a,b = map(int, input().split())
    city[a].append((b, i))
for i in range(m):
    city[i].sort()
print(city)
for i in range(n+1):
    for j in range(len(city[i])):
        ret[city[i][j][1]] = createSix(str(i)) + createSix(str(j+1))
for i in ret:
    print(i)
    

    


Fixed submission:
a,b = map(int, input().split())
print(a+b//2)

Buggy python submission (verdict: Runtime Error):
t = int(input())
a,b = map(int, input().split())
ss = list(map(int, input().split()))
p = 0
mi= 99999999999999

for i in range(len(ss)):
    if mi > abs(b - (a - 0.006*ss[i])):
        p = i
        mi = abs(b - (a - 0.006*ss[i]))
print(p+1)



Fixed submission:
a,b = map(int, input().split())
print(a+b//2)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
city = [[] for _ in range(n+1)]
ret = ["" for _ in range(m)]
def createSix(s):
    while len(s) != 6:
        s = "0" + s
    return s
for i in range(m):
    a,b = map(int, input().split())
    city[a].append((b, i))
for i in range(m):
    city[i].sort()
print(city)
for i in range(n+1):
    for j in range(len(city[i])):
        ret[city[i][j][1]] = createSix(str(i)) + createSix(str(j+1))
for i in ret:
    print(i)
    

    


Fixed submission:
n,m = map(int,input().split())
city = [[] for _ in range(n+1)]
ret = ["" for _ in range(m)]
def createSix(s):
    while len(s) != 6:
        s = "0" + s
    return s
for i in range(m):
    a,b = map(int, input().split())
    city[a].append((b, i))
for i in range(n+1):
    city[i].sort()
for i in range(n+1):
    for j in range(len(city[i])):
        ret[city[i][j][1]] = createSix(str(i)) + createSix(str(j+1))
for i in ret:
    print(i)
Buggy python submission (verdict: Runtime Error):
b_tot, w_tot = 0, 0
for s in S:
    if s == '.':
        w_tot += 1
    else:
        b_tot += 1
b_left, w_left = 0, 0
tmp = 3 * 10**5
for s in S:
    if s == '.':
        w_left += 1
    else:
        b_left += 1
    tmp = min(tmp, b_left + w_tot - w_left)
print(tmp)


Fixed submission:
N = int(input())
S = input()
S = '.' + S

b_tot, w_tot = 0, 0
for s in S:
    if s == '.':
        w_tot += 1
    else:
        b_tot += 1

b_left, w_left = 0, 0
tmp = 3 * 10**5
for s in S:
    if s == '.':
        w_left += 1
    else:
        b_left += 1
    tmp = min(tmp, b_left + w_tot - w_left)
print(tmp)
Buggy python submission (verdict: Runtime Error):
from math import gcd
N = int(input())
A = list(map(int, input().split()))
tmp = gcd(A[0], A[1])
for a in A:
    tmp = gcd(tmp, a)
print(tmp)

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
tmp = gcd(A[0], A[1])
for a in A:
    tmp = gcd(tmp, a)
print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N, K = map(int, input().split())
A = list(map(int, input().split()))
K_bin = bin(K)[2:]
digit = max(len(K_bin), len(bin(max(A))[2:]))
B = [bin(a)[2:].zfill(digit) for a in A]
# d桁目の1の個数の，全てのA_iについての総和
C = [0] * digit
for b in B:
    for i, s in enumerate(b):
        if s == '1':
            C[i] += 1
GAIN = [2**i for i in range(digit)][::-1]
maxval = 0
for comb in product(('01'), repeat=digit):
    comb = ''.join(comb)
    if int(comb, 2) > K:
        break
    tmpval = 0
    for i in range(digit):
        res = C[i] if comb[i] == '0' else (N - C[i])
        tmpval += GAIN[i] * res
    maxval = max(maxval, tmpval)
print(maxval)


Fixed submission:
from itertools import product
N, K = map(int, input().split())
A = list(map(int, input().split()))
K_bin = bin(K)[2:]
digit = max(len(K_bin), len(bin(max(A))[2:]))
K_bin = K_bin.zfill(digit)
B = [bin(a)[2:].zfill(digit) for a in A]
# d桁目の0の個数の，全てのA_iについての総和
C = [0] * digit
for b in B:
    for i, s in enumerate(b):
        if s == '0':
            C[i] += 1
ideal = ''
for c in C:
    binary = '1' if c > N//2 else '0'
    ideal += binary
dp = [[0 for _ in range(2)] for _ in range(digit)]
cands = [0]
gain = [2**i for i in range(digit)][::-1]

def calc(s):
    ret = 0
    for i in range(digit):
        tmp = C[i] if s[i] == '1' else N-C[i]
        ret += tmp * gain[i]
    return ret

for i in range(digit):
    if K_bin[i] == '1':
        cands.append(calc(K_bin[:i] + '0' + ideal[i+1:]))
print(max(max(cands), calc(K_bin)))

Buggy python submission (verdict: Runtime Error):
from itertools import product
N, K = map(int, input().split())
A = list(map(int, input().split()))
K_bin = bin(K)[2:]
digit = len(K_bin)
B = [bin(a)[2:].zfill(digit) for a in A]
# d桁目の1の個数の，全てのA_iについての総和
C = [0] * digit
for b in B:
    for i, s in enumerate(b):
        if s == '1':
            C[i] += 1
GAIN = [2**i for i in range(digit)][::-1]
maxval = 0
for comb in product(('01'), repeat=digit):
    comb = ''.join(comb)
    if int(comb, 2) > K:
        break
    tmpval = 0
    for i in range(digit):
        res = C[i] if comb[i] == '0' else (N - C[i])
        tmpval += GAIN[i] * res
    maxval = max(maxval, tmpval)
print(maxval)

Fixed submission:
from itertools import product
N, K = map(int, input().split())
A = list(map(int, input().split()))
K_bin = bin(K)[2:]
digit = max(len(K_bin), len(bin(max(A))[2:]))
K_bin = K_bin.zfill(digit)
B = [bin(a)[2:].zfill(digit) for a in A]
# d桁目の0の個数の，全てのA_iについての総和
C = [0] * digit
for b in B:
    for i, s in enumerate(b):
        if s == '0':
            C[i] += 1
ideal = ''
for c in C:
    binary = '1' if c > N//2 else '0'
    ideal += binary
dp = [[0 for _ in range(2)] for _ in range(digit)]
cands = [0]
gain = [2**i for i in range(digit)][::-1]

def calc(s):
    ret = 0
    for i in range(digit):
        tmp = C[i] if s[i] == '1' else N-C[i]
        ret += tmp * gain[i]
    return ret

for i in range(digit):
    if K_bin[i] == '1':
        cands.append(calc(K_bin[:i] + '0' + ideal[i+1:]))
print(max(max(cands), calc(K_bin)))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000000000000)
N, M = map(int, input().split())
T = {}
D = [0 for _ in range(N+1)]
P = [0 for _ in range(N+1)]
root_id = {i for i in range(1, N+1)}
for _ in range(N+M-1):
    a, b = map(int, input().split())
    if a not in T:
        T[a] = [b]
    else:
        T[a].append(b)
    if b in root_id:
        root_id.remove(b)
root_id = root_id.pop()

def setdep(i, p, d):
    if D[i] == 0:
        D[i] = d
        P[i] = p
    else:
        if D[i] > d:
            T[p].remove(i)
            return None
        else: # D[i] < d:
            T[P[i]].remove(i)
            P[i] = p
    if i not in T:
        return None
    for j in T[i]:
        setdep(j, i, d+1)

setdep(root_id, 0, 1)
for p in P[1:]:
    print(p)

Fixed submission:
N, A, B = map(int, input().split())
print(min(A, B), end=' ')
print(max(A+B-N, 0))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
num = 0
while H:
    # リストHの0でない要素を探す
    for i in range(N):
        if H[i] != 0:
            while H[i] != 0:
                H[i] -= 1
                i += 1
    num += 1
print(num)

Fixed submission:
def get_nonzero_range(A):
    start, end = None, None
    N = len(A)
    for i in range(N):
        if A[i] != 0:
            start = i
            for j in range(i+1, N):
                if A[j] == 0:
                    end = j
                    return start, end
    else:
        return start, end

N = int(input())
H = list(map(int, input().split()))
H.append(0)
num = 0
while True:
    start, end = get_nonzero_range(H)
    if start == None:
        break
    else:
        for i in range(start, end):
            H[i] -= 1
        num += 1
print(num)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
TD = []
for _ in range(N):
    TD.append(list(map(int, input().split())))
TD.sort(key=lambda x: -x[1])

tmp_list = TD[:K]
removable_list = []
S = set()
base_pt = 0
for t, d in tmp_list:
    if t in S:
        removable_list.append([t, d])
    else:
        S.add(t)
    base_pt += d
kind = len(S)
removable_list.sort(key=lambda x: x[1])

pt = [base_pt + kind*kind]
i = 0
for t, d in TD[K:]:
    if t in S:
        continue
    kind += 1
    base_pt += d - removable_list[i][1]
    pt.append(base_pt + kind*kind)
    i += 1
print(max(pt))

Fixed submission:
N, K = map(int, input().split())
TD = []
for _ in range(N):
    TD.append(list(map(int, input().split())))
TD.sort(key=lambda x: -x[1])

removable_list = []
S = set()
base_pt = 0
for t, d in TD[:K]:
    if t in S:
        removable_list.append([t, d])
    else:
        S.add(t)
    base_pt += d
kind = len(S)
removable_list.sort(key=lambda x: x[1])

addable_list = []
for t, d in TD[K:]:
    if t in S:
        continue
    addable_list.append([t, d])
    S.add(t)

pt = [base_pt + kind*kind]
l = min(len(removable_list), len(addable_list))

for rl, al in zip(removable_list[:l], addable_list[:l]):
    kind += 1
    base_pt += al[1] - rl[1]
    pt.append(base_pt + kind*kind)
print(max(pt))
Buggy python submission (verdict: Runtime Error):
def trace(i, j, S, col, num_color):
    next_col = 1 - col
    num_color[col] += 1
    S[i][j] = 2
    if S[i-1][j] == next_col:
        trace(i-1, j, S, next_col, num_color)
    if S[i][j-1] == next_col:
        trace(i, j-1, S, next_col, num_color)
    if S[i+1][j] == next_col:
        trace(i+1, j, S, next_col, num_color)
    if S[i][j+1] == next_col:
        trace(i, j+1, S, next_col, num_color)
    return num_color[0] * num_color[1]

def main():
    H, W = map(int, input().split())
    # 黒0，白1，padding2
    S = [[2] * (W+2)]
    for _ in range(H):
        S.append([2] + [0 if s == '#' else 1 for s in input()] + [2])
    S.append([2] * (W+2))
    num_comb = 0
    for i in range(1, H+1):
        for j in range(1, W+1):
            if S[i][j] == 0:
                num_color = [0, 0]
                num_comb += trace(i, j, S, 0, num_color)
    print(num_comb)

main()

Fixed submission:
N = int(input())
H = int(input())
W = int(input())
print((N-H+1) * (N-W+1))

Buggy python submission (verdict: Runtime Error):
def trace(i, j, S, col, num_color):
    next_col = 1 - col
    num_color[col] += 1
    S[i][j] = 2
    if S[i-1][j] == next_col:
        trace(i-1, j, S, next_col, num_color)
    if S[i][j-1] == next_col:
        trace(i, j-1, S, next_col, num_color)
    if S[i+1][j] == next_col:
        trace(i+1, j, S, next_col, num_color)
    if S[i][j+1] == next_col:
        trace(i, j+1, S, next_col, num_color)
    return num_color[0] * num_color[1]

H, W = map(int, input().split())
# 黒0，白1，padding2
S = [[2] * (W+2)]
for _ in range(H):
    S.append([2] + [0 if s == '#' else 1 for s in input()] + [2])
S.append([2] * (W+2))
# print(S)
num_comb = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == 0:
            num_color = [0, 0]
            num_comb += trace(i, j, S, 0, num_color)
print(num_comb)


Fixed submission:
N = int(input())
H = int(input())
W = int(input())
print((N-H+1) * (N-W+1))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))

if N < K:
    print(abs(H[N-1]-H[0]))
else:
    C = [0] * N
    for i in range(K):
        C[i] = abs(H[i]-H[0])
    for i in range(K, N):
        C[i] = min([C[i-k] + abs(H[i]-H[i-k]) for k in range(K, 0, -1)])
    print(C[N-1])

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

if N < K:
    print(abs(H[N-1]-H[0]))
else:
    C = [0] * N
    for i in range(K):
        C[i] = abs(H[i]-H[0])
    for i in range(K, N):
        C[i] = min([C[i-k] + abs(H[i]-H[i-k]) for k in range(K, 0, -1)])
    print(C[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
dp = [0] * (M+1)
W, V = [], []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
for i in range(N):
    for j in range(M+1, -1, -1):
        if j + W[i] <= M:
            dp[j+W[i]] = max(dp[j + W[i]], dp[j] + V[i])
print(max(dp))

Fixed submission:
N, M = map(int, input().split())
dp = [0] * (M+1)
W, V = [], []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
for i in range(N):
    for j in range(M+1, -1, -1):
        if j + W[i] <= M:
            dp[j+W[i]] = max(dp[j + W[i]], dp[j] + V[i])
print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = 1000000
dp = [[10000000010 for _ in range(L+1)] for _ in range(N+1)]
W, V = [], []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
dp[0][0] = 0
for i in range(N):
    for j in range(L):
        if j + V[i] <= L:
            dp[i+1][j] = min(dp[i][j], dp[i][j-V[i]] + W[i])
        else:
            dp[i+1][j] = dp[i][j]
for i, d in enumerate(dp[N]):
    if d <= M:
        maxv = i
print(maxv)

Fixed submission:
N, M = map(int, input().split())
L = 100000
dp = [[1000000001 for _ in range(L+1)] for _ in range(N+1)]
W, V = [], []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
dp[0][0] = 0
for i in range(N):
    for j in range(L+1):
        if j - V[i] >= 0:
            dp[i+1][j] = min(dp[i][j], dp[i][j-V[i]] + W[i])
        else:
            dp[i+1][j] = dp[i][j]
for i, d in enumerate(dp[N]):
    if d <= M:
        maxv = i
print(maxv)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
dp = [['' for _ in range(len(t)+1)] for _ in range(len(s)+1)]
for i in range(1, len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + s[i-1]
        else:
            if len(dp[i-1][j]) > len(dp[i][j-1]):
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = dp[i][j-1]
print(dp[len(s)][len(t)])

Fixed submission:
s = ' ' + input()
t = ' ' + input()
dp = [[0 for _ in range(len(t))] for _ in range(len(s))]
for i in range(1, len(s)):
    for j in range(1, len(t)):
        if s[i] == t[j]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = len(s)-1, len(t)-1
ret = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ret += s[i]; i -= 1; j -= 1
print(ret[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
dp = [['' for _ in range(len(t)+1)] for _ in range(len(s)+1)]
for i in range(1, len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + s[i-1]
        else:
            if len(dp[i-1][j]) > len(dp[i][j-1]):
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = dp[i][j-1]
print(dp[len(s)][len(t)])

Fixed submission:
s = ' ' + input()
t = ' ' + input()
dp = [[0 for _ in range(len(t))] for _ in range(len(s))]
for i in range(1, len(s)):
    for j in range(1, len(t)):
        if s[i] == t[j]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = len(s)-1, len(t)-1
ret = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ret += s[i]; i -= 1; j -= 1
print(ret[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(float, input().split()))
dp = [[0 for _ in range(N+1)] for _ in range(1, N+1, 2)]

dp[0][0], dp[0][1] = 1-P[0], P[0]
for i in range(0, (N-1)//2):
    hh, tt = P[2*i+1] * P[2*i+2], (1 - P[2*i+1]) * (1 - P[2*i+2])
    ht = 1 - hh - tt
    for j in range(0, 2*i+2):
        dp[i+1][j+2] += hh * dp[i][j]
        dp[i+1][j+1] += ht * dp[i][j]
        dp[i+1][j] += tt * dp[i][j]
print(sum(dp[(N-1)//2][(N+1)//2:]))

Fixed submission:
N = int(input())
P = list(map(float, input().split()))
dp = [[0 for _ in range(N+1)] for _ in range(1, N+1, 2)]

dp[0][0], dp[0][1] = 1-P[0], P[0]
for i in range(0, (N-1)//2):
    hh, tt = P[2*i+1] * P[2*i+2], (1 - P[2*i+1]) * (1 - P[2*i+2])
    ht = 1 - hh - tt
    for j in range(0, 2*i+2):
        dp[i+1][j+2] += hh * dp[i][j]
        dp[i+1][j+1] += ht * dp[i][j]
        dp[i+1][j] += tt * dp[i][j]
print(sum(dp[(N-1)//2][(N+1)//2:]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))
pro = 1
for a in A:
    if a:
        pro *= a
if pro % 2 == 1:
    print('first')
else:
    print('second')

Fixed submission:
N = input()
cnt = 0
for n in N:
    if n == '2':
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N, P = map(int, input().split())
ProotN = pow(P, 1/N)
# print(ProotN)
for i in range(math.ceil(ProotN), 0, -1):
    if (P/i**N).is_integer():
        print(i)
        break

Fixed submission:
def prime_decomposition(n):
    i = 2
    dic = {}
    while i * i <= n:
        while n % i == 0:
            n /= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1
    if n > 1:
        dic[int(n)] = 1
    return dic

N, P = map(int, input().split())
d = prime_decomposition(P)
ret = 1
for k, v in d.items():
    if v >= N:
        ret *= k ** (v//N)
print(ret)
Buggy python submission (verdict: Runtime Error):
from math import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]
# print(diff)
for i in range(N-1):
    diff[i+1] = gcd(diff[i], diff[i+1])
print(diff[N-1])

Fixed submission:
from fractions import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]
# print(diff)
for i in range(N-1):
    diff[i+1] = gcd(diff[i], diff[i+1])
print(diff[N-1])

Buggy python submission (verdict: Runtime Error):
from math import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]
# print(diff)
for i in range(N-1):
    diff[i+1] = gcd(diff[i], diff[i+1])
print(diff[N-1])

Fixed submission:
from fractions import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]
# print(diff)
for i in range(N-1):
    diff[i+1] = gcd(diff[i], diff[i+1])
print(diff[N-1])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
X = list(map(int, input().split()))
minval = 10000000000
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
X = -X[::-1]
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
print(minval)

Fixed submission:
N, K = map(int, input().split())
X = list(map(int, input().split()))
minval = 10000000000
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
X = [-x for x in X[::-1]]
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
print(minval)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
X = list(map(int, input().split()))
minval = 10000000000
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
X = reversed(X)
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
print(minval)


Fixed submission:
N, K = map(int, input().split())
X = list(map(int, input().split()))
minval = 10000000000
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
X = [-x for x in X[::-1]]
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
print(minval)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (H+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Fixed submission:
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (W+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (H+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Fixed submission:
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (W+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (H+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
                break
    if flag == False:
        break
if flag:
    print('Yes')
else:
    print('No')

Fixed submission:
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (W+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')