Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque
import numpy as np

h, w = map(int, input().split())
S = [input() for _ in range(h)] # #.のグリッドの場合

starts = []
for i in range(h):
    for j in range(w):
        if S[i][j] == '.':
            starts.append((i,j))

step = [(1, 0), (-1, 0), (0, 1), (0, -1)]
ans = 0
for si in starts:
    maxlen = 0
    seen = [[0] * w for _ in range(h)]
    que = deque()
    que.append(si)
    while len(que) > 0:
        x, y = que.popleft()
        for xs, ys in step:
            xi, yi = x + xs, y + ys
            if xi < 0 or yi < 0 or xi >= h or yi >= w:
                continue
            if S[xi][yi] == '#':
                continue
            if seen[xi][yi] != 0:
                continue
            else:
                seen[xi][yi] = seen[x][y] + 1
                que.append((xi, yi))
                maxlen = max(maxlen, seen[xi][yi])
    #print(np.array(seen))
    ans = max(ans, maxlen)
print(ans)

Fixed submission:
from collections import deque
#import numpy as np

h, w = map(int, input().split())
S = [input() for _ in range(h)] # #.のグリッドの場合

starts = []
for i in range(h):
    for j in range(w):
        if S[i][j] == '.':
            starts.append((i,j))

step = [(1, 0), (-1, 0), (0, 1), (0, -1)]
ans = 0
for si in starts:
    maxlen = 0
    seen = [[0] * w for _ in range(h)]
    que = deque()
    que.append(si)
    #seen[si[0]][si[1]] = 1
    while len(que) > 0:
        x, y = que.popleft()
        for xs, ys in step:
            xi, yi = x + xs, y + ys
            if xi < 0 or yi < 0 or xi >= h or yi >= w:
                continue
            if xi == si[0] and yi == si[1]:
                continue
            if S[xi][yi] == '#':
                continue
            if seen[xi][yi] != 0:
                continue
            else:
                seen[xi][yi] = seen[x][y] + 1
                que.append((xi, yi))
                maxlen = max(maxlen, seen[xi][yi])
    #print(np.array(seen))
    ans = max(ans, maxlen)
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
xy = [0 for _ in range(n)]
for i in range(n):
    ai = int(input())
    xy[i] = [list(map(int , input().split())) for _ in range(ai)]

#print(xy)
#print(xy[0])
#print(xy[0][0])
ans = 0
for i in itertools.product([0, 1], repeat=n):
    ok = True
    cnt = sum(i)
    for j in range(n):
        xyj = xy[j]
        for xyk in xyj:
            if xyk[1] == 0:
                if i[xyk[0]] == 1:
                    ok = False
            elif xyk[1] == 1:
                if i[xyk[0]] == 0:
                    ok = False
    if ok:
        ans = max(ans, cnt)

print(ans)


Fixed submission:
import itertools
n = int(input())
xy = [0 for _ in range(n)]
for i in range(n):
    ai = int(input())
    xy[i] = [list(map(int , input().split())) for _ in range(ai)]

#print(xy)
#print(xy[0])
#print(xy[0][0])
ans = 0
for i in itertools.product([0, 1], repeat=n):
    ok = True
    cnt = sum(i)
    for j in range(n):
        xyj = xy[j]
        if i[j] == 1:
            for xyk in xyj:
                if xyk[1] == 1:
                    if i[xyk[0]-1] == 0:
                        ok = False
                elif xyk[1] == 0:
                    if i[xyk[0]-1] == 1:
                        ok = False
    #print(ok, i)
    if ok:
        ans = max(ans, cnt)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
l = set()
for i in range(n - 2):
    for j in range(i+1, n - 1):
        for k in range(j+1, n):
            l.add(s[i] + s[j] + s[k])
            #print(s[i] + s[j] + s[k])
print(len(l))



Fixed submission:
n = int(input())
s = input()

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            #print(str(i) + str(j)+ str(k))
            fi = s.find(str(i))
            if fi < 0:
                continue
            fj = s[fi+1:].find(str(j))
            if fj < 0:
                continue
            fk = s[(fi+1)+(fj+1):].find(str(k))
            if fk < 0:
                continue
            #print(str(i) + str(j)+ str(k), str(fi) + str(fj)+ str(fk))
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
l = set()
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            l.add(s[i] + s[j] + s[k])
print(len(l))



Fixed submission:
n = int(input())
s = input()

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            #print(str(i) + str(j)+ str(k))
            fi = s.find(str(i))
            if fi < 0:
                continue
            fj = s[fi+1:].find(str(j))
            if fj < 0:
                continue
            fk = s[(fi+1)+(fj+1):].find(str(k))
            if fk < 0:
                continue
            #print(str(i) + str(j)+ str(k), str(fi) + str(fj)+ str(fk))
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
c = []
a = []
for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    a.append(ai)
    c.append(sum(ci))

INF = 100 ** 18
dp = [INF] * (2**n + 1)
dp[0] = 0
for i in range(m):
    for j in range(0, 2**n):
        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i])

ans = dp[2**n-1]
if ans == INF:
    print(-1)
    exit()
print(ans)



Fixed submission:
n, m = map(int, input().split())
c = []
a = []
for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    a.append(ai)
    c.append(sum(ci))

INF = 100 ** 18
dp = [INF] * (2**n + 1)
dp[0] = 0
for i in range(m):
    for j in range(0, 2**n):
        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i])

ans = dp[2**n-1]
if ans == INF:
    print(-1)
    exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
print(sum(range(1, n)))


Fixed submission:
n = int(input())
ans = n * (n-1) // 2
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(range(1, n))
print(sum(a))


Fixed submission:
n = int(input())
ans = n * (n-1) // 2
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(range(1, n))
print(sum(map(lambda n: n % (n+1), a)))


Fixed submission:
n = int(input())
ans = n * (n-1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
print(1.0/sum(list(map(lambda x: 1.0 / x, a))))


Fixed submission:
n = int(input())
v = list(map(int, input().split()))
#n = 3
#v = list(map(int, "500 300 200".split()))
v.sort()
ans = v[0]
for i in range(1,n):
    ans = (v[i] + ans)/2
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
v.sort()
ans = v[0]
for i in v[1:]:
    ans = (v[i] + ans)/2
print(ans)


Fixed submission:
n = int(input())
v = list(map(int, input().split()))
#n = 3
#v = list(map(int, "500 300 200".split()))
v.sort()
ans = v[0]
for i in range(1,n):
    ans = (v[i] + ans)/2
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
#n = 3
#v = list(map(int, "500 300 200".split()))
v.sort()
ans = v[0]
for i in range(1,3):
    ans = (v[i] + ans)/2
print(ans)



Fixed submission:
n = int(input())
v = list(map(int, input().split()))
#n = 3
#v = list(map(int, "500 300 200".split()))
v.sort()
ans = v[0]
for i in range(1,n):
    ans = (v[i] + ans)/2
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

def func(n, x, y):
    lcm = x * y // math.gcd(x, y)
    return n - (n // x + n // y - n // lcm)

print(func(b, c, d) - func(a - 1, c, d))


Fixed submission:
import fractions

a, b, c, d = map(int, input().split())

def func(n, x, y):
    lcm = x * y // fractions.gcd(x, y)
    return n - (n // x + n // y - n // lcm)

print(func(b, c, d) - func(a - 1, c, d))
Buggy python submission (verdict: Runtime Error):
import sys 
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [int(input()) - 1 for _ in range(m)]
a.append(n)

dp = [-1] * max(3, n)
dp[0] = 1
dp[1] = 1
dp[2] = 2
def stepsum(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = stepsum(n-1) + stepsum(n-2)
    return dp[n]
prev = 0
ans = 1
for ai in a:
    if prev != 0 and ai - prev < 0:
        ans = 0
        break
    ans *= stepsum(ai - prev)
    prev = ai + 2

print(ans % ( 10 ** 9 + 7 ))


Fixed submission:
import sys 
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [int(input()) - 1 for _ in range(m)]
a.append(n)

dp = [-1] * max(3, n + 1)
dp[0] = 1
dp[1] = 1
dp[2] = 2
def stepsum(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = stepsum(n-1) + stepsum(n-2)
    return dp[n]
prev = 0
ans = 1
for ai in a:
    if prev != 0 and ai - prev < 0:
        ans = 0
        break
    ans *= stepsum(ai - prev)
    prev = ai + 2

print(ans % ( 10 ** 9 + 7 ))

Buggy python submission (verdict: Runtime Error):
import sys 
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [int(input()) - 1 for _ in range(m)]
a.append(n)

dp = [-1] * n
dp[0] = 1
dp[1] = 1
dp[2] = 2
def stepsum(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = stepsum(n-1) + stepsum(n-2)
    return dp[n]
prev = 0
ans = 1
for ai in a:
    if prev != 0 and ai - prev < 0:
        ans = 0
        break
    ans *= stepsum(ai - prev)
    prev = ai + 2

print(ans % ( 10 ** 9 + 7 ))


Fixed submission:
import sys 
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [int(input()) - 1 for _ in range(m)]
a.append(n)

dp = [-1] * max(3, n + 1)
dp[0] = 1
dp[1] = 1
dp[2] = 2
def stepsum(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = stepsum(n-1) + stepsum(n-2)
    return dp[n]
prev = 0
ans = 1
for ai in a:
    if prev != 0 and ai - prev < 0:
        ans = 0
        break
    ans *= stepsum(ai - prev)
    prev = ai + 2

print(ans % ( 10 ** 9 + 7 ))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
b = list(map(int , input().split()))

def dfs(s, ans):
    #print(s, ans)
    if len(s) == 0:
        print('\n'.join(map(str, reversed(ans))))
        exit()
        return
    for i in range(len(s)):
        if s[i] == i+1:
            s1 = s[:i] + s[i+1:]
            ans.append(s[i])
            dfs(s1, ans)
    if len(ans) > 0:
        ans.pop()

dfs(b, [])

print('-1')


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
b = list(map(int , input().split()))

def dfs(s, ans):
    if len(s) == 0:
        print('\n'.join(map(str, reversed(ans))))
        exit()
        return
    for i in range(len(s)):
        #if s[i] == i+1:
        #if s[i] == i+1 and max(s[:i] + [0]) >= i:
        if s[i] == i+1:
            s1 = s[:i] + s[i+1:]
            allok = True
            for j in range(len(s1)):
                if s1[j] > j+1:
                    allok = False
                    break
            #print(s[:i], s[i+1:],i)
            if allok:
                ans.append(s[i])
                dfs(s1, ans)
    if len(ans) > 0:
        ans.pop()

dfs(b, [])

print('-1')
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
l = len(s)
prev = ''

while s != prev:
    prev = s
    s = s.replace('01', '')
    s = s.replace('10', '')

print(l - len(s))

Fixed submission:
s = input()
c0 = 0
c1 = 0
for si in s:
    if si == '0':
        c0 += 1
    else:
        c1 += 1


print(2*min(c0,c1))
Buggy python submission (verdict: Runtime Error):
x = input().split()
#x = "3 5 0 4 3 6 2 7 2 5 3 3 4 0 5 3 7 5 3 7 2 7 5 7 0 7 2 9 3 2 9 1 3 6 2 0 2 4 6 4 2 3 3 5 7 4 0 6 9 7 6 7 9 8 5 2 2 0 4 7 6 5 5 4 6 3 2 3 0 5 4 3 3 6 2 3 4 2 4 0 8 9 4 6 5 4 3 5 3 2 0 8 2 1 3 4 5 7 8 6 4 0 3 5 2 6 1 2 5 3 2 1 6 9 2 5 6".split()
#x = "2 4 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 2 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 2 9 9 9 0 9 9 2 9 9 9 9 9 9 9 0 -1 -1 -1 -1 8 1 1 8".split()
h = int(x[0])
w = int(x[1])
d = []
for i in range(10):
    d.append(
        list(map(int, x[2 + i * 10 : 2 + i * 10 + 10]))
    )
a = []
for i in range(h):
    a.append(
        list(map(int, x[102 + i * w: 102 + i * w + w]))
    )
#d = [[0] * 10] * 10
for k in range(10):
    for i in range(10):
        for j in range(10):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

#for k in range(0, 10):
#    print(c[k])
#for k in range(0, 10):
#    print(d[k])
#print(d[8][1])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != 1 or a[i][j] != -1:
            ans += d[a[i][j]][1]
print(ans)


Fixed submission:
n = int(input())
l = list(map(int , input().split()))
l.sort(reverse=True)
#print(l[0], sum(l[1:]))
if l[0] < sum(l[1:]):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
s = int(input())
a = [s]
z = set(s)
idx = 1
for i in range(10**8):
    idx += 1
    if a[i] % 2 == 0:
        ai = a[i] // 2
    else:
        ai = 3 * a[i] + 1
    if ai in z:
        print(idx)
        exit()
    a.append(ai)
    z.add(ai)


Fixed submission:
s = int(input())
a = [s]
z = set([s])
idx = 1
for i in range(10**8):
    idx += 1
    if a[i] % 2 == 0:
        ai = a[i] // 2
    else:
        ai = 3 * a[i] + 1
    if ai in z:
        print(idx)
        exit()
    a.append(ai)
    z.add(ai)
Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]

INF = 10**9 + 100
MAX_V = 10**5 + 100
dp = [INF] * (MAX_V + 1)
dp[0] = 0

for wi, vi in wv:
	for sum_v in reversed(range(vi, MAX_V+1)):
        dp[sum_v] = min(dp[sum_v - vi] + wi, dp[sum_v])
#print(dp)
ans = 0
for i in range(MAX_V, -1, -1):
    if dp[i] <= w:
        print(i)
        exit()
#print(ans)


Fixed submission:
import numpy as np
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]

INF = 10**9 + 100
MAX_V = 10 ** 6

dp = np.full((n+1, MAX_V), INF, np.int64)
dp[0][0] = 0

for i, (wi, vi) in enumerate(wv):
    dp[i+1] = dp[i]
    np.minimum(dp[i][vi:], dp[i][:-vi] + wi, out=dp[i+1][vi:])

ans = np.where(dp[n] <= w)[0][-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int , input().split()))

n = len(v)
from collections import defaultdict
c0 = defaultdict(int)
for vi in v[0::2]:
    c0[vi] += 1
c1 = defaultdict(int)
for vi in v[1::2]:
    c1[vi] += 1

sc0 = sorted(c0.items(), key=lambda x: x[1])
sc1 = sorted(c1.items(), key=lambda x: x[1])

print(sc0)
print('-----------')
print(sc1)
if sc0[-1][0] != sc1[-1][0]:
    #print('--1')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-1][1])
    exit()
if len(sc0) == 1 and len(sc1) == 1:
    #print('--2')
    print(n//2)
    exit()
if sc0[-1][1] == sc1[-1][1]:
    if sc0[-2][1] > sc1[-2][1]:
        print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    else:
        print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()
if sc0[-1][1] > sc1[-1][1]:
    #print('--3')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    exit()
else:
    #print('--4')
    print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()
 (2054, 12394), (27775, 12395)
(50652, 12393), (27775, 12395)


Fixed submission:
n = int(input())
v = list(map(int , input().split()))

n = len(v)
from collections import defaultdict
c0 = defaultdict(int)
for vi in v[0::2]:
    c0[vi] += 1
c1 = defaultdict(int)
for vi in v[1::2]:
    c1[vi] += 1

sc0 = sorted(c0.items(), key=lambda x: x[1])
sc1 = sorted(c1.items(), key=lambda x: x[1])
#print(n)
#print(sc0)
#print('------------------')
#print(sc1)
if sc0[-1][0] != sc1[-1][0]:
    #print('--1')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-1][1])
    exit()
if len(sc0) == 1 and len(sc1) == 1:
    #print('--2')
    print(n//2)
    exit()
if sc0[-1][1] > sc1[-1][1]:
    #print('--3')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    exit()
if sc0[-1][1] < sc1[-1][1]:
    #print('--4')
    print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()
if sc0[-1][1] == sc1[-1][1]:
    if sc0[-2][1] < sc1[-2][1]:
        #print('--1',sc0[-1][1],sc1[-1][1], sc0[-2][1],sc1[-2][1])
        print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    else:
        #print('--1',sc0[-1][1],sc1[-1][1], sc0[-2][1],sc1[-2][1])
        print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()

#(92753, 12393), (2054, 12394), (27775, 12395)
#(55530, 10),    (50652, 12393),   (27775, 12395)
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
C = [list(map(int , input().split())) for _ in range(h)]


#import numpy as np
#print(np.array(C))
from collections import deque
step = [(0,1), (1,0)]
que = deque()
que.append((0,0))
seen = [[0] * w for _ in range(h)]
seen[0][0] = 1
ans = []
while len(que) > 0:
    x, y = que.popleft()
    for tx, ty in step:
        xi, yi = x + tx, y + ty
        if xi < 0 or yi < 0 or xi >= h or yi >= w:
            continue
        if seen[xi][yi] == 0:
            if C[x][y] % 2 == 1:
                C[x][y] -= 1
                C[xi][yi] += 1
                seen[xi][yi] = 1
                ans.append((x+1, y+1, xi+1, yi+1))
            que.append((xi, yi))
        #print(np.array(C))
        #print(np.array(seen))
#print(C, seen)
print(len(ans))
for ansi in ans:
    print(' '.join(map(str, ansi)))

Fixed submission:
h, w = map(int, input().split())
a = [list(map(int , input().split())) for _ in range(h)]

res = []
for hi in range(h):
    for wi in range(w-1):
        if a[hi][wi] % 2 == 1:
            a[hi][wi] -= 1
            a[hi][wi+1] += 1
            res.append((hi+1, wi+1, hi+1, wi+1+1))
for hi in range(h-1):
    wi = w - 1
    if a[hi][wi] % 2 == 1:
        a[hi][wi] -= 1
        a[hi+1][wi] += 1
        res.append((hi+1, wi+1, hi+1+1, wi+1))

print(len(res))
for resi in res:
    print(' '.join(map(str, resi)))

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
C = [list(map(int , input().split())) for _ in range(h)]


#import numpy as np
#print(np.array(C))
from collections import deque
step = [(0,1), (1,0)]
que = deque()
que.append((0,0))
seen = [[0] * w for _ in range(h)]
seen[0][0] = 1
ans = []
while len(que) > 0:
    x, y = que.popleft()
    for tx, ty in step:
        xi, yi = x + tx, y + ty
        if xi < 0 or yi < 0 or xi >= h or yi >= w:
            continue
        if seen[xi][yi] == 0:
            if C[x][y] % 2 == 1:
                C[x][y] -= 1
                C[xi][yi] += 1
                seen[xi][yi] = 1
                ans.append((x+1, y+1, xi+1, yi+1))
            que.append((xi, yi))
        #print(np.array(C))
        #print(np.array(seen))
#print(C, seen)
print(len(ans))
for ansi in ans:
    print(' '.join(map(str, ansi)))

Fixed submission:
h, w = map(int, input().split())
a = [list(map(int , input().split())) for _ in range(h)]

res = []
for hi in range(h):
    for wi in range(w-1):
        if a[hi][wi] % 2 == 1:
            a[hi][wi] -= 1
            a[hi][wi+1] += 1
            res.append((hi+1, wi+1, hi+1, wi+1+1))
for hi in range(h-1):
    wi = w - 1
    if a[hi][wi] % 2 == 1:
        a[hi][wi] -= 1
        a[hi+1][wi] += 1
        res.append((hi+1, wi+1, hi+1+1, wi+1))

print(len(res))
for resi in res:
    print(' '.join(map(str, resi)))
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

if s[0] == '1':
    print(s[1])
else:
    print(s[0])

Fixed submission:
s = input()
k = int(input())
k = k-1
def not1(t):
    for i in range(len(t)):
        if t[i] != '1':
            return (i, t[i])
    return (-1, '1')
(j, t) = not1(s)
if j == -1:
    print('1')
    exit()
if k < j:
    print('1')
    exit()
if k >= j:
    print(t)
    exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]
#sa = sum(a)
b.sort()
#print(b)
ans = 10 ** 10
for j in range(3):
    bi = b[n//2+j]
    s = 0
    for i in range(n):
        s += abs(b[i] - bi)
    #print(s)
    ans = min(ans, s)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]

b.sort()
idx= n//2
bi = b[idx]
ans = 0
for i in range(n):
    ans += abs(a[i] - (i + 1 + bi))
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]
#sa = sum(a)
b.sort()
#print(b)
ans = 10 ** 10
for j in range(3):
    bi = b[(n + j)//2]
    s = 0
    for i in range(n):
        s += abs(b[i] - bi)
    #print(s)
    ans = min(ans, s)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]

b.sort()
idx= n//2
bi = b[idx]
ans = 0
for i in range(n):
    ans += abs(a[i] - (i + 1 + bi))
print(ans)
Buggy python submission (verdict: Runtime Error):
d, n = map(int, input().split())

if n == 100:
    print(100 ** d * (n+1))
    exit()
print(100 ** d * n



Fixed submission:
d, n = map(int, input().split())

if n == 100:
    print(100 ** d * (n+1))
    exit()
print(100 ** d * n)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
n = 3
unit = [
    '####',
    '#.#.',
    '#.#.',
    '....'
]
row = [
    '.' + unit[0]*n + '#',
    '.' + unit[1]*n + '#',
    '.' + unit[2]*n + '#',
    '.' + unit[3]*n + '#'
]
grid = []
for i in range(n):
    grid.append(list(row[0]))
    grid.append(list(row[1]))
    grid.append(list(row[2]))
    grid.append(list(row[3]))
"""
# 黒
for i in range(n):
    grid[0][4*(i+1)] = 'x'
for i in range(n):
    grid[4*i][4] = 'y'
# 白
for i in range(n):
    grid[2][4*(i+1)-2] = 'w'
for i in range(n):
    grid[4*(i+1)-2][2] = 'v'
"""
# 白
for i in range(a//n+1):
    for j in range(n):
        if i * n + j < a-1:
            #print('#',4*(j+1)-2,4*(i+1)-2)
            grid[4*(i+1)-2][4*(j+1)-2] = '#'

# 黒
for i in range(b//n+1):
    for j in range(n):
        if i * n + j < b-1:
            #print('.',4*j,4*(i+1))
            grid[4*i][4*(j+1)] = '.'

print(len(grid), len(grid[0]))
for i in grid:
    print(''.join(i))



Fixed submission:
a, b = map(int, input().split())
n = 24
unit = [
    '####',
    '#.#.',
    '#.#.',
    '....'
]
row = [
    '.' + unit[0]*n + '#',
    '.' + unit[1]*n + '#',
    '.' + unit[2]*n + '#',
    '.' + unit[3]*n + '#'
]
grid = []
for i in range(n):
    grid.append(list(row[0]))
    grid.append(list(row[1]))
    grid.append(list(row[2]))
    grid.append(list(row[3]))
"""
# 黒
for i in range(n):
    grid[0][4*(i+1)] = 'x'
for i in range(n):
    grid[4*i][4] = 'y'
# 白
for i in range(n):
    grid[2][4*(i+1)-2] = 'w'
for i in range(n):
    grid[4*(i+1)-2][2] = 'v'
"""
# 白
for i in range(a//n+1):
    for j in range(n):
        if i * n + j < a-1:
            #print('#',4*(j+1)-2,4*(i+1)-2)
            grid[4*(i+1)-2][4*(j+1)-2] = '#'

# 黒
for i in range(b//n+1):
    for j in range(n):
        if i * n + j < b-1:
            #print('.',4*j,4*(i+1))
            grid[4*i][4*(j+1)] = '.'

print(len(grid), len(grid[0]))
for i in grid:
    print(''.join(i))
Buggy python submission (verdict: Runtime Error):
x = int(input().split())
a = int(input().split())
b = int(input().split())

print((x - a)%b)



Fixed submission:
x = int(input())
a = int(input())
b = int(input())

print((x - a)%b)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())
if (a+b) > (c,d):
    print('Left')
if (a+b) == (c,d):
    print('Balanced')
if (a+b) < (c,d):
    print('Right')


Fixed submission:
a,b,c,d = map(int, input().split())
if (a+b) > (c+d):
    print('Left')
if (a+b) == (c+d):
    print('Balanced')
if (a+b) < (c+d):
    print('Right')
Buggy python submission (verdict: Runtime Error):
#s = input()
"""
s = '101'
s = '100000000'
s = '00001011'
"""
k = len(s)
for i in range(1, len(s)):
    if s[i-1] != s[i+1]:
        k = min(k, max(i, len(s)-i))
print(k)




Fixed submission:
s = input()
"""
s = '101'
s = '100000000'
s = '00001011'
"""
k = len(s)
for i in range(1, len(s)):
    if s[i-1] != s[i]:
        k = min(k, max(i, len(s)-i))
print(k)