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

Fixed submission:
from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
mod = 2019
while d:
    temp = d.pop()
    t = (t + (temp * m)) % mod
    m = (m * 10) % mod
    a.append(t%mod)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))

Buggy submission (verdict: Runtime Error):
S = input()
a = [0,int(S)%2019]
init = 0
for i in range(len(S)-1):
    S = S[1:]
    a.append(int(S)%2019)
b = [kv*(kv-1)//2 for kv in Counter(a).values() if kv > 1]
print(sum(b))

Buggy submission (verdict: Runtime Error):
S = input()
l = [int(n) for n in list(S)]
a = [0,int(S)%2019]
init = 0
for i in range(len(S)-1):
    S = S[1:]
    a.append(int(S)%2019)
b = [kv*(kv-1)//2 for kv in Counter(a).values() if kv > 1]
print(sum(b))
Problem p02714 (python)

Fixed submission:
N = int(input())
S = input()
r = S.count('R')
g = S.count('G')
b = S.count('B')
count = r * g * b
for i in range(N):
    for j in range(i+1,N-1):
        if 2*j - i <= N-1:
            l = set([S[i],S[j],S[2*j-i]])
            if len(l) == 3:
                count -= 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
def findlet(let,ind):
    add = st[ind:].count(let)
    if add > 0:
        if 2*ind < len():
            if st[2*ind] == let:
                add -= 1
        global count
        count += add
for i in range(N-2):
    st = S[i:]
    if st[0] == "R":
        for j in [x for x, y in enumerate(st) if y == 'G']:
            findlet("B",j)
        for j in [x for x, y in enumerate(st) if y == 'B']:
            findlet("G",j)
    elif st[0] == "G":
        for j in [x for x, y in enumerate(st) if y == 'B']:
            findlet("R",j)
        for j in [x for x, y in enumerate(st) if y == 'R']:
            findlet("B",j)
    else:
        for j in [x for x, y in enumerate(st) if y == 'R']:
            findlet("G",j)
        for j in [x for x, y in enumerate(st) if y == 'G']:
            findlet("R",j)
print(count)
Problem p02732 (python)

Fixed submission:
from collections import Counter
from scipy.misc import comb
N = int(input())
A = input().split()
C = Counter(A)
s = sum([comb(j, 2, exact=True) for j in C.values()])
for i in range(N):
    print(s-C[A[i]]+1)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from scipy.misc import comb
N = int(input())
A = input().split()
C = Counter(A)
def banned_count(seq):
    
    for i in range(N):
        count = 0
        C[A[i]] -= 1
        for j in C.values():
            if j >= 2:
                count = count + comb(j, 2, exact=True)
        print(count)
        C[A[i]] += 1
banned_count(A)
Problem p02755 (python)

Fixed submission:
import math
A,B = (int(x) for x in input().split())
A1 = math.ceil(A/0.08)
if float((A+1)/0.08).is_integer() == True:
    A2 = math.floor((A+1)/0.08)
else:
    A2 = math.floor((A+1)/0.08) + 1
B1 = math.ceil(B/0.1)
if float((B+1)/0.1).is_integer() == True:
    B2 = math.floor((B+1)/0.1)
else:
    B2 = math.floor((B+1)/0.1) + 1
a = range(A1, A2)
b = range(B1, B2)
c = set(a) & set(b)
if len(c) == 0:
          print(-1)
else:
          print(min(c))

Buggy submission (verdict: Runtime Error):
A,B = (int(x) for x in input().split())
a = range(math.ceil(A/0.08), math.floor(((A+1)/0.08)+1))
b = range(math.ceil(B/0.1), math.floor(((B+1)/0.1)+1))
c = set(a) & set(b)
if len(c) == 0:
          print(-1)
else:
          print(min(c))
Problem p02780 (python)

Fixed submission:
import numpy as np
N,K = (int(x) for x in input().split())
p1 = np.array(list(map(int, input().split())))
s1 = p1.cumsum()
s2 = np.append(0, s1)
p2 = np.array([(s2[i+K] - s2[i]) for i in range(N-K+1)])
max = np.amax(p2)
print((max+K) / 2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = (int(x) for x in input().split())
p1 = np.array(list(map(int, input().split())))
s1 = p1.cumsum()
p2 = np.array([(s1[i+K] - s1[i]) for i in range(N-K)])
max = np.amax(p2)
print((max+K) / 2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = (int(x) for x in input().split())
p1 = np.array(list(map(int, input().split())))
s1 = np.array([np.sum(p1[0:i+1]) for i in range(N)])
p2 = np.array([(s1[i+K] - s1[i]) for i in range(N-K)])
max = np.amax(p2)
print((max+K) / 2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = (int(x) for x in input().split())
p1 = np.array(list(map(int, input().split())))
p2 = (p1+1) / 2
p3 = np.array([np.sum(p2[i:i+K]) for i in range(N-K+1)])
print(np.amax(p3))
Problem p02787 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
H,N = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
mem = [0] * H
def dp(rem):
    global mem
    if rem <= 0:
        return 0
    elif mem[rem-1]:
        return mem[rem-1]
    else:
        a = min([dp(rem-AB[i][0]) + AB[i][1] for i in range(N)])
        mem[rem-1] = a
        return a
print(dp(H))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
H,N = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
mem = [0] * H
def dp(rem):
    global mem
    if mem[rem-1]:
        return mem[rem-1]
    elif rem <= 0:
        return 0
    else:
        a = min([dp(rem-AB[i][0]) + AB[i][1] for i in range(N)])
        mem[rem-1] = a
        return a
print(dp(H))
Problem p02814 (python)

Fixed submission:
import fractions
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

N,M = (int(x) for x in input().split())
a = list(map(int, input().split()))
temp = [a[0],a[0]//2]
broke = False
for i in range(1,N):
    gcd = xgcd(temp[0],a[i])
    if temp[1] % gcd[0] != (a[i]//2) % gcd[0]:
        broke = True
        break
    else:
        x = temp[1] + temp[0]*((a[i]//2)-temp[1])//gcd[0]*gcd[1]
        temp[0] = (temp[0] * a[i]) // fractions.gcd(temp[0], a[i])
        temp[1] = x % temp[0]
if broke:
    print('0')
else:
    dm = divmod(M,temp[0])
    if dm[1] >= temp[1]:
        print(dm[0]+1)
    else:
        print(dm[0])

Buggy submission (verdict: Runtime Error):
import fractions
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

N,M = (int(x) for x in input().split())
a = list(map(int, input().split()))
temp = [a[0],a[0]//2]
broke = False
for i in range(1,N):
    gcd = xgcd(temp[0],a[i])
    if temp[1] % gcd[0] != (a[i]//2) % gcd[0]:
        broke = True
        break
    else:
        x = temp[1] + temp[0]*((a[i]//2)-temp[1])//gcd[0]*gcd[1]
        temp[0] = (temp[0] * a[i]) // math.gcd(temp[0], a[i])
        temp[1] = x % temp[0]
if broke:
    print('0')
else:
    dm = divmod(M,temp[0])
    if dm[1] >= temp[1]:
        print(dm[0]+1)
    else:
        print(dm[0])

Buggy submission (verdict: Runtime Error):
import math
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

N,M = (int(x) for x in input().split())
a = list(map(int, input().split()))
temp = [a[0],a[0]//2]
broke = False
for i in range(1,N):
    gcd = xgcd(temp[0],a[i])
    if temp[1] % gcd[0] != (a[i]//2) % gcd[0]:
        broke = True
        break
    else:
        x = temp[1] + temp[0]*((a[i]//2)-temp[1])//gcd[0]*gcd[1]
        temp[0] = (temp[0] * a[i]) // math.gcd(temp[0], a[i])
        temp[1] = x % temp[0]
if broke:
    print('0')
else:
    dm = divmod(M,temp[0])
    if dm[1] >= temp[1]:
        print(dm[0]+1)
    else:
        print(dm[0])
Problem p02845 (python)

Fixed submission:
N,*A = map(int, open(0).read().split())
group = [0] * 3
ans = 1
for x in A:
    ans = (ans*group.count(x)) % 1000000007
    if ans == 0:
        print(0)
        break
    else:
        group[group.index(x)] += 1
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N,*A = map(int, open(0).read().split())
group = [0] * 3
ans = 1
for x in A:
    ans = (ans*group.count(x)) % (10**9+7)
    group[group.index(x)] += 1
print(ans)
Problem p02913 (python)

Fixed submission:
def rolling_hash(s):
    l = len(s)
    h = [0]*(l + 1)
    v = 0
    for i in range(l):
        h[i+1] = v = (v * base + ord(s[i])) % mod
    return h
def setup_pw(l):
    pw = [1]*(l + 1)
    v = 1
    for i in range(l):
        pw[i+1] = v = v * base % mod
    return pw
def get(h, b, l, r):
    return (h[r] - h[l] * b[r-l]) % mod

def check_bisect(l,h1,b1,h2,b2):
    for j in range(N-2*l+1):
        a1 = get(h1,b1,j,l+j)
        a2 = get(h2,b2,j,l+j)
        for k in range(N-2*l-j+1):
            if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
    return False

N = int(input())
S = input()
mod = 1000000007
base = 37
h1 = rolling_hash(S)
b1 = setup_pw(N)
base = 401
h2 = rolling_hash(S)
b2 = setup_pw(N)
left = 1
right = N // 2
finish = False
if N <= 26:
    s = set(list(S))
    if N <= 3:
        if len(s) < N:
            print('1')
        else:
            print('0')
        finish = True
    else:
        if len(s) == N:
            print('0')
            finish = True
while finish == False:
    if left == right:
        print(left)
        finish = True
    elif right - left == 1:
        if check_bisect(right,h1,b1,h2,b2):
            print(right)
        else:
            print(left)
        finish = True
    else:
        mid = (left+right) // 2
        if check_bisect(mid,h1,b1,h2,b2):
            left = mid
        else:
            right = mid - 1

Buggy submission (verdict: Runtime Error):
def rolling_hash(s):
    l = len(s)
    h = [0]*(l + 1)
    v = 0
    for i in range(l):
        h[i+1] = v = (v * base + ord(s[i])) % mod
    return h
def setup_pw(l):
    pw = [1]*(l + 1)
    v = 1
    for i in range(l):
        pw[i+1] = v = v * base % mod
    return pw
def get(h, b, l, r):
    return (h[r] - h[l] * b[r-l]) % mod

def check_bisect(l,h1,b1,h2,b2):
    for j in range(N-2*l+1):
        a1 = get(h1,b1,j,l+j)
        a2 = get(h2,b2,j,l+j)
        for k in range(N-2*l-j+1):
            if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
    return False

N = int(input())
S = input()
mod = 1000000007
base = 37
h1 = rolling_hash(S)
b2 = setup_pw(N)
base = 401
h2 = rolling_hash(S)
b2 = setup_pw(N)
left = 1
right = N // 2
finish = False
if N <= 26:
    s = set(list(S))
    if N <= 3:
        if len(s) < N:
            print('1')
        else:
            print('0')
        finish = True
    else:
        if len(s) == N:
            print('0')
            finish = True
while finish == False:
    if left == right:
        print(left)
        finish = True
    elif right - left == 1:
        if check_bisect(right,h1,b1,h2,b2):
            print(right)
        else:
            print(left)
        finish = True
    else:
        mid = (left+right) // 2
        if check_bisect(mid,h1,b1,h2,b2):
            left = mid
        else:
            right = mid - 1
Problem p02936 (python)

Fixed submission:
from collections import deque
N,Q = (int(x) for x in input().split())
connected = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = (int(x) for x in input().split())
    connected[a-1].append(b)
    connected[b-1].append(a)
counter = [0] * N
for _ in range(Q):
    p,x = (int(y) for y in input().split())
    counter[p-1] += x
ans = counter
q = deque([(1,0)])
searched = [0] * N
while q:
    a,p = q.popleft()
    if p != 0:
        ans[a-1] += ans[p-1]
    searched[a-1] = 1
    for child in connected[a-1]:
        if searched[child-1] == 0:
            q.append((child,a))
print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
from collections import deque
N,Q = (int(x) for x in input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]
par = [0] * N
ans = [0] * N
par[0] = 500000
for i in ab:
    temp = [par[j-1] for j in i]
    wch = temp.index(0)
    par[i[wch]-1] = i[abs(wch-1)]
def count(vert):
    if vert == 1:
        prev = 0
    else:
        prev = ans[par[vert-1]-1]
    ans[vert-1] = prev + sum([px[i][1] for i in range(Q) if px[i][0] == vert])
q = deque([1])
while len(q) > 0:
    temp = q.popleft()
    if temp is not None:
        count(temp)
        children = [x for x, y in enumerate(par) if y == temp]
        for child in children:
            q.append(child+1)
print(*ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
N,Q = (int(x) for x in input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]
par = [0] * N
ans = [0] * N
par[0] = 500000
for i in ab:
    temp = [par[j-1] for j in i]
    wch = temp.index(0)
    par[i[wch]-1] = i[abs(wch-1)]
def count(vert):
    if vert == 1:
        prev = 0
    else:
        prev = ans[par[vert-1]-1]
    ans[vert-1] = prev + sum([px[i][1] for i in range(Q) if px[i][0] == vert])
q = deque([1])
while len(q) > 0:
    temp = q.popleft()
    if temp is not None:
        count(temp)
        children = [x for x, y in enumerate(par) if y == temp]
        for child in children:
            q.append(child+1)
print(*ans)
Problem p02939 (python)

Fixed submission:
S = input()
count = 1
i = 0
initial_length = len(S)-1
l = S[0]
S = S + '&' + '%'
while i < initial_length:
    if l == S[i+1]:
        if i == initial_length-1:
            break
        elif S[i+2] == S[i+3]:
            l = S[i+3]
            i += 3
            count += 1
        else:
            l = S[i+1:i+3]
            i += 2
    else:
        l = S[i+1]
        i += 1
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
S = input()
def div(strings):
    if len(strings) == 0:
        return 0
    elif len(strings) == 1:
        return 1
    elif len(strings) == 2:
        if S[0] == S[1]:
            return 1
        else:
            return 2
    elif strings[len(strings)-1] != strings[len(strings)-2]:
        return div(strings[0:len(strings)-1]) + 1
    else:
        return div(strings[0:len(strings)-3]) + 2
print(div(S))

Buggy submission (verdict: Runtime Error):
S = input()
def div(strings):
    if len(strings) == 0:
        return 0
    elif len(strings) == 1:
        return 1
    elif len(strings) == 2:
        if S[0] == S[1]:
            return 1
        else:
            return 2
    elif strings[len(strings)-1] != strings[len(strings)-2]:
        return div(strings[0:len(strings)-1]) + 1
    else:
        return div(strings[0:len(strings)-3]) + 2
print(div(S))

Buggy submission (verdict: Runtime Error):
S = input()
def div(strings):
    if len(strings) == 0:
        return 0
    elif len(strings) == 1:
        return 1
    elif len(strings) == 2:
        if S[0] == S[1]:
            return 1
        else:
            return 2
    elif strings[len(strings)-1] != strings[len(strings)-2]:
        return div(strings[0:len(strings)-1]) + 1
    else:
        return div(strings[0:len(strings)-3]) + 2
if len(S) == 1:
    print(1)
elif len(S) == 2:
    if S[0] == S[1]:
        print(1)
    else:
        print(2)
else:
    print(div(S))
Problem p03006 (python)

Fixed submission:
from itertools import permutations
from collections import Counter

N,*xyf = map(int, open(0).read().split())
xy = [(xyf[i*2],xyf[i*2+1]) for i in range(N)]
if N == 1:
    print(1)
else:
    count = []
    for a, b in permutations(xy,2):
        count.append((b[0]-a[0],b[1]-a[1]))
    c = Counter(count)
    print(N-max(c.values()))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
from collections import Counter

N,*xyf = map(int, open(0).read().split())
xy = [(xyf[i*2],xyf[i*2+1]) for i in range(N)]
count = []
for a, b in permutations(xy,2):
    count.append((b[0]-a[0],b[1]-a[1]))
c = Counter(count)
print(N-max(c.values()))
Problem p03050 (python)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
divisors = make_divisors(N)
ans = 0
divisors.sort(reverse=True)
for x in divisors:
    if x > 1:
        temp = x - 1
        d,m = divmod(N,temp)
        if d != m:
            break
        else:
            ans += temp
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1,N+1):
    if N % i == 0:
        temp = N // i - 1
        d,m = divmod(N,temp)
        if d != m:
            break
        else:
            ans += temp
print(ans)
Problem p03078 (python)

Fixed submission:
from itertools import product
from heapq import *

X,Y,Z,K,*f = map(int, open(0).read().split())
A = f[:X]
B = f[X:X+Y]
C = f[X+Y:]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
AB = [sum(x) * (-1) for x in product(A,B)]
heapify(AB)
AB_picked = []
for i in range(K):
    if AB:
        AB_picked.append(heappop(AB)*(-1))
    else:
        break
ABC = [sum(x) * (-1) for x in product(AB_picked,C)]
heapify(ABC)
for i in range(K):
    print(heappop(ABC)*(-1))

Buggy submission (verdict: Runtime Error):
from itertools import product
from heapq import *

X,Y,Z,K,*f = map(int, open(0).read().split())
A = f[:X]
B = f[X:X+Y]
C = f[X+Y:]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
AB = [sum(x) * (-1) for x in product(A,B)]
heapify(AB)
AB_picked = []
for i in range(K):
    AB_picked.append(heappop(AB)*(-1))
ABC = [sum(x) * (-1) for x in product(AB_picked,C)]
heapify(ABC)
for i in range(K):
    print(heappop(ABC)*(-1))
Problem p03231 (python)

Fixed submission:
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

N,M = (int(x) for x in input().split())
S = list(input())
T = list(input())
if M > N:
    N,M = M,N
    S,T = T,S
dn = make_divisors(N)
dm = make_divisors(M)
dnm = dn & dm
if dnm == {1}:
    if S[0] == T[0]:
        print(N*M)
    else:
        print('-1')
else:
    gcd = max(dnm)
    n = N // gcd
    m = M // gcd
    for i in range(N//n):
        if S[n*i] != T[m*i]:
            print('-1')
            break
    else:
        print(N*M//gcd)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

N,M = (int(x) for x in input().split())
if M > N:
    N,M = M,N
    S,T = T,S
S = list(input())
T = list(input())
dn = make_divisors(N)
dm = make_divisors(M)
dnm = dn & dm
if dnm == {1}:
    if S[0] == T[0]:
        print(N*M)
    else:
        print('-1')
else:
    gcd = max(dnm)
    n = N // gcd
    m = M // gcd
    for i in range(N//n):
        if S[n*i] != T[m*i]:
            print('-1')
            break
    else:
        print(N*M//gcd)
Problem p03240 (python)

Fixed submission:
N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
for x in xyh:
    if x[2] > 0:
        base = x
        break
for i in range(101):
    for j in range(101):
        h = base[2] + abs(i-base[0]) + abs(j-base[1])
        for x in xyh:
            if x[2] != max(h-abs(i-x[0])-abs(j-x[1]),0):
                break
        else:
            print(i,j,h)
            exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = set()
for i in range(N):
    x,y,h = (int(x) for x in input().split())
    if h > 0:
        for j in range(101):
            for k in range(101):
                ans.add((j,k,h+abs(j-x)+abs(k-y)))
        break
for i in range(N):
    x,y,h = (int(x) for x in input().split())
    temp = set()
    for j in range(101):
        for k in range(101):
            temp.add((j,k,h+abs(j-x)+abs(k-y)))
    if len(ans&temp) > 0:
        ans = ans & temp
for x in ans:
    print(*x)
Problem p03274 (python)

Fixed submission:
import bisect

N,K = (int(x) for x in input().split())
x = list(map(int, input().split()))
bs = bisect.bisect_left(x,0)
ans = float('inf')
if bs == N:
    print(x[-K]*(-1))
    exit()
else:
    if x[bs] == 0:
        x.pop(bs)
        K -= 1
neg = bs
pos = N - bs
if len(x) == 0 or K == 0:
    print('0')
elif neg == 0:
    print(x[K-1])
else:
    for i in range(min(neg,K)+1):
        if i + pos < K:
                continue
        else:
            if i == 0:
                ans = min(ans,x[bs+K-1])
            elif i == K:
                ans = min(ans,x[bs-K]*(-1))
            else:
                tempn = x[bs-i] * (-1)
                tempp = x[bs+K-i-1]
                ans = min(ans,min(tempn,tempp)*2+max(tempn,tempp))
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

N,K = (int(x) for x in input().split())
x = list(map(int, input().split()))
bs = bisect.bisect_left(x,0)
ans = float('inf')
if x[bs] == 0:
    x.pop(bs)
    K -= 1
neg = bs
pos = N - bs
if len(x) == 0 or K == 0:
    print('0')
elif neg == 0:
    print(x[K-1])
elif pos == 0:
    print(x[-K]*(-1))
else:
    for i in range(min(neg,K)+1):
        if i + pos < K:
                continue
        else:
            if i == 0:
                ans = min(ans,x[bs+K-1])
            elif i == K:
                ans = min(ans,x[bs-K]*(-1))
            else:
                tempn = x[bs-i] * (-1)
                tempp = x[bs+K-i-1]
                ans = min(ans,min(tempn,tempp)*2+max(tempn,tempp))
    print(ans)
Problem p03550 (python)

Fixed submission:
N,Z,W = (int(x) for x in input().split())
a = list(map(int, input().split()))
if N == 1:
    print(abs(W-a[0]))
else:
    print(max(abs(a[-1]-W),abs(a[-1]-a[-2])))

Buggy submission (verdict: Runtime Error):
N,Z,W = (int(x) for x in input().split())
a = list(map(int, input().split()))
print(max(abs(a[-1]-W),abs(a[-1]-a[-2])))
Problem p03557 (python)

Fixed submission:
import bisect
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(A, i)*(N-bisect.bisect_right(C, i)) for i in B))

Buggy submission (verdict: Runtime Error):
from bisect import bisect
N = int(input())
A = sorted(list(map(int,input().split())))
A = sorted(list(map(int,input().split())))
A = sorted(list(map(int,input().split())))
count = 0
for i in range(N):
    minb = bisect(B, A[i])
    if minb == N:
        break
    for j in range(minb, N):
        if B[j] == A[i]:
            continue
        minc = bisect(C, B[j])
        if minc == N:
            break
        count += N - minc
print(count)
Problem p03611 (python)

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
c = Counter(a)
d = [c[i]+c[i+1]+c[i+2] for i in range(99998)]
print(max(d))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
c = Counter(a)
d = [c[i]+c[i+1]+c[i+2] for i in range(max(a)-1)]
print(max(d))