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

Fixed submission:
def calc_height(xs, ys, hs, cx, cy):
    ret = -1
    zeros = []
    for i in range(len(xs)):
        x = xs[i]
        y = ys[i]
        h = hs[i]
        if h == 0:
            zeros.append((x,y,h))
            continue
        a = abs(x - cx)
        b = abs(y - cy)
        ch = h + a + b
        if ret == -1:
            ret = ch
        else:
            if ret != ch:
                return -1
    for x, y, h in zeros:
        a = abs(x - cx)
        b = abs(y - cy)
        if ret - a - b > 0:
            return -1
    return ret


def solve(xs, ys, hs):
    for cx in range(101):
        for cy in range(101):
            h = calc_height(xs, ys, hs, cx, cy)
            if h > 0:
                return cx, cy, h


n = int(input())
xs = []
ys = []
hs = []
for i in range(n):
    x, y, h = list(map(int, input().split(' ')))
    xs.append(x)
    ys.append(y)
    hs.append(h)


print(' '.join([str(q) for q in solve(xs, ys, hs)]))

Buggy submission (verdict: Runtime Error):
def calc_height(xs, ys, hs, cx, cy):
    ret = -1
    zeros = []
    for i in range(len(xs)):
        x = xs[i]
        y = ys[i]
        h = hs[i]
        if h == 0:
            zeors.append((x,y,h))
            continue
        a = abs(x - cx)
        b = abs(y - cy)
        ch = h + a + b
        if ret == -1:
            ret = ch
        else:
            if ret != ch:
                return -1
    for x, y, h in zeros:
        a = abs(x - cx)
        b = abs(y - cy)
        if ret - a - b > 0:
            return -1
    return ret


def solve(xs, ys, hs):
    for cx in range(101):
        for cy in range(101):
            h = calc_height(xs, ys, hs, cx, cy)
            if h > 0:
                return cx, cy, h


n = int(input())
xs = []
ys = []
hs = []
for i in range(n):
    x, y, h = list(map(int, input().split(' ')))
    xs.append(x)
    ys.append(y)
    hs.append(h)


print(' '.join([str(q) for q in solve(xs, ys, hs)]))

Buggy submission (verdict: Runtime Error):
def calc_height(xs, ys, hs, cx, cy):
    ret = -1
    for i in range(len(xs)):
        x = xs[i]
        y = ys[i]
        h = hs[i]
        a = abs(x - cx)
        b = abs(y - cy)
        ch = h + a + b
        if ret == -1:
            ret = ch
        else:
            if ret != ch:
                return -1
    return ret


def solve(xs, ys, hs):
    for cx in range(101):
        for cy in range(101):
            h = calc_height(xs, ys, hs, cx, cy)
            if h > 0:
                return cx, cy, h


n = int(input())
xs = []
ys = []
hs = []
for i in range(n):
    x, y, h = list(map(int, input().split(' ')))
    xs.append(x)
    ys.append(y)
    hs.append(h)


print(' '.join([str(q) for q in solve(xs, ys, hs)]))
Problem p03696 (python)

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

i = 0
c = 0
min_c = 0
while i < N:
    if S[i] == "(":
        c += 1
    else:
        c -= 1
    min_c = min(c, min_c)
    i += 1

print("(" * (-min_c) + S + ")" * (c-min_c))

Buggy submission (verdict: Runtime Error):
def trim(S, N):
    a = 0
    while S[a] == ")":
        a += 1
    b = N-1
    while S[b] == "(":
        b -= 1
    return a, b


def count(S, a, b):
    i = a
    c = 0
    while i <= b:
        if S[i] == "(":
            c += 1
        else:
            c -= 1
        i += 1
    return c


N = int(input())
S = input()

a, b = trim(S, N)
if a > b:
    print("(" * a + S + ")" * (N-b-1))
else:
    c = count(S, a, b)

    if c > 0:
        print("(" * a + S + ")" * (N-b-1-c))
    else:
        print("(" * (a-c) + S + ")" * (N-b-1))
Problem p03455 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a = list(map(int, input().split()))

# 奇数か偶数の判断
if (a[0] * a[1])%2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
b = int(input())

# 奇数か偶数の判断
if (a * b)%2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
b = int(input())

# 奇数か偶数の判断
if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input(3))
b = int(input(4))

# 奇数か偶数の判断
if (a * b)%2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
b = int(input())

# 奇数か偶数の判断
if (a * b)%2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
b = int(input())

# 奇数か偶数の判断
if (a * b)%2 == 0:
    print('Even')
else:
    print('Odd')
Problem p03493 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
s = int(input())
t = str(s)
print(t.count('1'))

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

def how_many_times_divisible(n):
    ans = 0
    while n % 2 == 0:
        n /= 2
        ans += 1
    return ans
 

ans = min(map(how_many_times_divisible, a))
 
print(ans)
Problem p03105 (python)

Fixed submission:
A,B,C = map(int,input().split())
i = 0
while i < C and i < int(B/A):
    i += 1
print(i)

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
i = 0
while i < C or i < int B/A:
    i += 1
print(i)
Problem p03126 (python)

Fixed submission:
N,M = map(int,input().split())
KA = list(map(int,input().split()))

items = set(KA[1:])


for i in range(1,N):
    KA = list(map(int,input().split()))
    items = items & set(KA[1:])

ans = len(items)
print(ans)

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

items = set(KA[1:])


for i in range(1,N):
    KA = list(map(int,input().split()))
    items = items & set(KA[1:])

ans = len(items)
print(ans)
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input())
    B = int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print('Hello World')
else N == 2:
    A = int(input())
    B = int(input())
    print(A+B)
Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())

e = []
o = []
for i, v in enumerate(input().split(' ')):
    if i % 2 == 0:
        e.append(int(v))
    else:
        o.append(int(v))

if len(set(e + o)) == 1:
    print(int(len(e + o) / 2))
    exit()

if Counter(o).most_common()[0][0] == Counter(e).most_common()[0][0]:
    ans = min(len(o) - Counter(o).most_common()[1][1] + len(e) - Counter(e).most_common()[0][1], len(o) - Counter(o).most_common()[0][1] + len(e) - Counter(e).most_common()[1][1])
    print(ans)
else:
    print(len(o) - Counter(o).most_common()[0][1] + len(e) - Counter(e).most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
v1 = [v[0]]
v2 = []
for i in range(1,n):
    if i % 2 == 0:
        v1.append(v[i])
    else:
        v2.append(v[i])
c1 = Counter(v1)
c2 = Counter(v2)
mode1 = c1.most_common(1)
mode2 = c2.most_common(1)
if mode1[0][0] != mode2[0][0]:
    ans1 = len(v1)-mode1[0][1]
    ans2 = len(v2)-mode2[0][1]
    ans = ans1 + ans2
else:
    if mode1[0][1] == len(v1) and mode2[0][1] == len(v2):
       ans = min(mode1[0][1],mode2[0][1])
    elif mode1[0][1] == len(v1):
        ans1 = len(v)-mode2[0][1]
        ans2 = len(v)-mode1[0][1]-mode2[1][1]
        ans = min(ans1,ans2)
    elif mode2[0][1] == len(v2):
        ans1 = len(v)-mode1[1][1]-mode2[0][1]  
        ans2 = len(v)-mode1[0][1]
        ans = min(ans1,ans2)
    else:
        ans1 = len(v)-mode1[0][1]-mode2[1][1]
        ans2 = len(v)-mode1[1][1]-mode2[0][1]
        ans = min(ans1,ans2)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
v1 = [v[0]]
v2 = []
for i in range(1,n):
    if i % 2 == 0:
        v1.append(v[i])
    else:
        v2.append(v[i])
c1 = Counter(v1)
c2 = Counter(v2)
mode1 = c1.most_common(1)
mode2 = c2.most_common(1)
if mode1[0][0] != mode2[0][0]:
    ans1 = len(v1)-mode1[0][1]
    ans2 = len(v2)-mode2[0][1]
    ans = ans1 + ans2
else:
    if mode1[0][1] == len(v1) and mode2[0][1] == len(v2):
       ans = min(mode1[0][1],mode2[0][1])
    elif mode1[0][1] == len(v1):
        ans = len(v)-mode1[0][1]-mode2[1][1]
    elif mode2[0][1] == len(v2):
        ans = len(v)-mode1[1][1]-mode2[0][1]  
    else:
        ans1 = len(v)-mode1[0][1]-mode2[1][1]
        ans2 = len(v)-mode1[1][1]-mode2[0][1]
        ans = min(ans1,ans2)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
v1 = [v[0]]
v2 = []
for i in range(1,n):
    if i % 2 == 0:
        v1.append(v[i])
    else:
        v2.append(v[i])
c1 = Counter(v1)
c2 = Counter(v2)
mode1 = c1.most_common(1)
mode2 = c2.most_common(1)
if mode1[0][0] != mode2[0][0]:
    ans1 = len(v1)-mode1[0][1]
    ans2 = len(v2)-mode2[0][1]
    ans = ans1 + ans2
else:
    if mode1[0][1] == len(v1) and mode2[0][1] == len(v2):
       ans = min(mode1[0][1],mode2[0][1])
    else:
        ans1 = len(v)-mode1[0][1]-mode2[1][1]
        ans2 = len(v)-mode1[1][1]-mode2[0][1]
        ans = min(ans1,ans2)
print(ans)
Problem p03260 (python)

Fixed submission:
A,B = map(int,input().split())
if A != 2 and B != 2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-2):
        ans = math.gcd(ans,xlen[i+1])
    print(ans)
Problem p03274 (python)

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

min_t = 10e9
for i in range(N - K + 1):
    e = i + K - 1
    l = min(x[i], 0)
    r = max(x[e], 0)

    t = min(-l, r) * 2 + max(-l, r)
    min_t = min(min_t, t)

print(min_t)

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

ans = sum([abs(i) for i in x])
for i in range(N - K + 1):
    t = min(abs(x[i])+abs(x[i+K-1] - x[i]),abs(x[i+K-1]+abs(x[i+K-1]-x[i]))
    if t < ans:
        ans = t:

print(ans)
Problem p03288 (python)

Fixed submission:
r = int(input())
if r < 1200:
    ans = 'ABC'
elif r<2800:
    ans = 'ARC'
else:
    ans = 'AGC'
print(ans)

Buggy submission (verdict: Runtime Error):
D,G = map(int,input().split(' '))
l = [list(map(int,input().split())) for i in range(D)]

ans = 10**8
for i in range(2**D):
    score = 0
    tmp = 0
    n_list = []
    for j in range(D):
        if (i >> j & 1):
            k = l[j]
            score += (j+1)*100*k[0]+k[1]
            tmp += k[0]
        else:
            n_list.append([j+1]+l[j])
    e_flag = False
    for ii in n_list[::-1]:#[1or2or..,times,bonus]
        for jj in range(ii[1]-1):
            if score<G:
                score += ii[0]*100
                tmp += 1
            else:
                e_flag = True
                break
        if e_flag:
            break
    if score<G:
        continue
    ans = min(ans,tmp)
print(ans)
Problem p03324 (python)

Fixed submission:
num = list(map(int,input()
.split()))
if num[1] !=100:
    if num[0] == 0:
        ans = num[1]
    elif num[0] == 1:
        ans = num[1]*100
    elif num[0] == 2:
        ans = num[1]*10000
else:
    if num[0] == 0:
        ans = num[1]+1
    elif num[0] == 1:
        ans = num[1]*100+100
    elif num[0] == 2:
        ans = num[1]*10000+10000

print(ans)

Buggy submission (verdict: Runtime Error):
num = list(map(int,input()
.split()))
if num[2] !=100:
    if num[0] == 0:
        ans = num[1]
    elif num[0] == 1:
        ans = num[1]*100
    elif num[0] == 2:
        ans = num[1]*10000
else:
    if num[0] == 0:
        ans = num[1]+1
    elif num[0] == 1:
        ans = num[1]*100+100
    elif num[0] == 2:
        ans = num[1]*10000+10000

print(ans)

Buggy submission (verdict: Runtime Error):
num = list(map(int,input()
.split()))
if num[0] == 0:
    ans = num[1]
elif num[0] == 1:
    ans = num[1]*100
elif num[0] == 2:
    ans = num[1]*10000
else :
    
print(ans)
Problem p03106 (python)

Fixed submission:
A,B,K=map(int,input().split())
a=0
C=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        C.append(i)
print(C[-K])

Buggy submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
a=0
for i in range(min(A,B)):
    if A%i==0 and B%i==0:
        a+=1
        if a==K:
            print(i)
Problem p03139 (python)

Fixed submission:
N,A,B=map(int,input().split())
print(min(A,B),max(A+B-N,0))

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2==1:
    A=[]
    for i in range(N):
        a,b=map(int,input().split())
        c=a-b
        A.append([a,-b])
    A.sort()
    ao=0
    t=0
    for j in range(N):
        if j%2==0:
            ao+=A[j][0]
        else:
            t+=A[j][1]
    print(ao+t)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[]
for i in range(N):
    a,b=map(int,input().split())
    c=a-b
    A.append([a,-b])
A.sort()
ao=0
t=0
for j in range(N):
    if j%2==0:
        ao+=A[j][0]
    else:
        t+=A[j][1]
print(ao+t)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[]
for i in range(N):
    a,b=map(int,input().split())
    c=a-b
    A.append([c,-a,-b])
A.sort()
ao=0
t=0
for j in range(N):
    if j%2==0:
        ao+=-1*A[j][1]
    else:
        t+=-1*A[j][2]
print(ao-t)
Problem p03200 (python)

Fixed submission:
S=input()
a=0
b=0
for i in range(len(S)):
    if S[-i-1]=="B":
        a+=i-b
        b+=1
print(a)

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
A=list(map(int,input().split()))
Ae1=[]
Ao1=[]
for i in range(N):
    if A[i]%2==0:
        Ae1.append(A[i])
    else:
        Ao1.append(A[i])
if Ao1!=[]:
    s=0
    Ao=sorted(Ao1,reverse=True)
    i=0
    while i<=len(Ao)-1:
        a=int(math.log2(Ao[i]))
        if 2**(a+1)-Ao[i] in Ao[i:]:
            s+=1
            Ao.remove(2**(a+1)-Ao[i])
            i+=1
        else:
            i+=1
else:
    s=0
if Ae1!=[]:
    t=0
    Ae=sorted(Ae1,reverse=True)
    j=0
    while j<=len(Ae):
        b=int(math.log2(Ae[j]))
        if 2**(a+1)-Ae[j] in Ae[j:]:
            s+=1
            Ae.remove(2**(a+1)-Ae[j])
            j+=1
        else:
            j+=1
else:
    t=0
print(s+t)

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
A=list(map(int,input().split()))
A.sort()
s=0
i=1
while i<=len(A)-1:
    a=int(math.log2(A[-i]))
    if 2**(a+1)-A[-i] in A[:-i]:
        s+=1
        A.remove(2**(a+1)-A[-i])
        i+=1
    else:
        i+=1
print(s)
Problem p03211 (python)

Fixed submission:
s = input()
ans = 753
for i in range(len(s)):
    tmp = abs(753 - int(s[i:i+3]))
    if tmp < ans:
        ans = tmp
print(ans)

Buggy submission (verdict: Runtime Error):
s=int(input())
t=[]
for i in range(len(s)-2):
  a=s[i:i+2]
  t.append(abs(a-753))
print(min(t))
Problem p03282 (python)

Fixed submission:
S=input()
k=int(input())
for i in range(0,k):
    if S[i]!="1":
        print(S[i])
        break
else:
    print("1")

Buggy submission (verdict: Runtime Error):
S,K=input().split()
k=int(K)
for i in range(0,k):
    if S[i]!="1":
        print(S[i])
        break
else:
    print("1")
Problem p03290 (python)

Fixed submission:
D,G=map(int,input().split())
A=[]
for i in range(D):
    p,c=map(int,input().split())
    A.append([p,c])
a=10**9
for j in range(2**D):
    b=format(j, 'b')
    B="0"*(D-len(b))+str(b)
    S=[]
    N=[]
    for k in range(D):
        S.append((A[k][0]*(k+1)*100+A[k][1])*int(B[-k-1]))
        N.append(A[k][0]*int(B[-k-1]))
        if sum(S)>=G:
            s=sum(N)
            if a>s:
                a=s
        else:
            for l in range(D):
                if B[l]=="0" and (G-sum(S))<=((D-l)*100)*(A[-l-1][0]-1):
                    s=sum(N)+((G-sum(S))//((D-l)*100))+min(1,((G-sum(S))%((D-l)*100)))
                    if a>s:
                        a=s
                    break
print(a)

Buggy submission (verdict: Runtime Error):
D,G=map(int,input().split())
A=[]
for i in range(D):
    p,c=map(int,input().split())
    A.append([p,c])
a=10**9
for j in range(2**D):
    b=format(j, 'b')
    B="0"*(D-len(b))+str(b)
    S=[]
    N=[]
    for k in range(D):
        S.append((A[k][0]*(k+1)*100+A[k][1])*int(B[-k-1]))
        N.append(A[k][0]*int(B[-k-1]))
        if sum(S)>=G:
            s=sum(N)
            if a>s:
                a=s
        else:
            for l in range(D):
                if B[l]=="0" and (G-sum(S))<=((D-l)*100)*(A[-l-1][0]-1) :
                    s=sum(N)+((G-sum(S))//((D-l)*100))+min(1,((G-sum(S))%((D-l)*100)))
                    break
            if a>s:
                a=s
print(a)

Buggy submission (verdict: Runtime Error):
D,G=map(int,input().split())
A=[]
for i in range(D):
    p,c=map(int,input().split())
    A.append([p,c])
a=10**9
for j in range(2**D):
    b=format(j, 'b')
    B="0"*(D-len(b))+str(b)
    S=[]
    N=[]
    for k in range(D):
        S.append((A[k][0]*(k+1)*100+A[k][1])*int(B[-k-1]))
        N.append(A[k][0]*int(B[-k-1]))
        if sum(S)>=G:
            s=sum(N)
            if a>s:
                a=s
        else:
            for l in range(D):
                if B[l]=="0" and (G-sum(S))<=((D-l)*100)*(A[-l-1][0]-1) :
                    s=sum(N)+((G-sum(S))//((D-l)*100))+min(1,((G-sum(S))%((D-l)*100)))
                    break
            if a>s:
                a=s
print(a)

Buggy submission (verdict: Runtime Error):
D,G=map(int,input().split())
A=[]
for i in range(D):
    p,c=map(int,input().split())
    A.append([p,c])
a=10**9
for j in range(1,2**D):
    b=format(j, 'b')
    B="0"*(D-len(b))+str(b)
    S=[]
    N=[]
    for k in range(D):
        S.append((A[k][0]*(k+1)*100+A[k][1])*int(B[-k-1]))
        N.append(A[k][0]*int(B[-k-1]))
        if sum(S)>=G:
            s=sum(N)
            if a>s:
                a=s
        else:
            for l in range(D):
                if B[l]=="0" and (G-sum(S))<=((D-l)*100)*(A[-l-1][0]-1) :
                    s=sum(N)+((G-sum(S))//((D-l)*100))+min(1,((G-sum(S))%((D-l)*100)))
                    break
            if a>s:
                a=s
print(a)
Problem p03304 (python)

Fixed submission:
n,m,d=map(int,input().split())
if d==0:
    ans=(m-1)/n
else:
    ans=2*(m-1)*(n-d)/(n**2)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,d=map(int,input().split())
if n-d-1==0:
    ans=(m-1)*(2/n**2)
elif n-2*d<=0:
    ans=(m-1)/(n*2*(n-d-1))
else:
    ans=(m-1)*(2/(n*(n-2*d))+(1/(2*n*d)))
print(ans)
Problem p03393 (python)

Fixed submission:
S=input()
flag = False
if S=="zyxwvutsrqponmlkjihgfedcba":
    T="-1"
elif len(S)<=25:
    for i in range(97,123):
        if chr(i) not in S:
            T=S+chr(i)
            break
else:
    for i in range(2,27):
        for j in range(ord(S[-i])+1,123):
            if chr(j) not in S[:-i]:
                T=S[:-i]+chr(j)
                flag=True
                break
        if flag:
            break
print(T)

Buggy submission (verdict: Runtime Error):
S=input()
flag = False
if S=="zyxwvutsrqponmlkjihgfedcba":
    T="-1"
elif len(S)<=25:
    for i in range(97,123):
        if chr(i) not in S:
            T=S+chr(i)
            break
else:
    for i in range(2,26):
        for j in range(ord(S[-i])+1,123):
            if chr(j) not in S[:-i]:
                T=S[:-i]+chr(j)
                flag=True
                break
        if flag:
            break
print(T)
Problem p03403 (python)

Fixed submission:
A=int(input())
B=list(map(int,input().split()))
a=0
S=0
for i in range(len(B)):
    S+=abs(B[i]-a)
    a=B[i]
S+=abs(B[-1])
for j in range(len(B)):
    if j==0:
        if 0<=B[0]<=B[1] or 0>=B[0]>=B[1]:
            print(S)
        elif B[0]<=0<=B[1] or B[0]>=0>=B[1]:
            print(S-2*abs(B[0]))
        else:
            print(S-2*abs(B[1]-B[0]))
    elif j==len(B)-1:
        if 0<=B[-1]<=B[-2] or 0>=B[-1]>=B[-2]:
            print(S)
        elif B[-1]<=0<=B[-2] or B[-1]>=0>=B[-2]:
            print(S-2*abs(B[-1]))
        else:
            print(S-2*abs(B[-1]-B[-2]))
    else:
        if B[j-1]<=B[j]<=B[j+1] or B[j-1]>=B[j]>=B[j+1]:
            print(S)
        elif B[j]<=B[j-1]<=B[j+1] or B[j]>=B[j-1]>=B[j+1]:
            print(S-2*abs(B[j-1]-B[j]))
        else:
            print(S-2*abs(B[j+1]-B[j]))

Buggy submission (verdict: Runtime Error):
A=int(input())
B=list(map(int,input().split()))
a=0
S=0
for i in range(len(B)):
    S+=abs(B[i]-a)
    a=B[i]
S+=abs(B[-1])
for j in range(len(B)):
    if j=0:
        if 0<=B[0]<=B[1] or 0>=B[0]>=B[1]:
            print(S)
        elif B[0]<=0<=B[1] or B[0]>=0>=B[1]:
            print(S-abs(B[0]))
        else:
            print(S-abs(B[1]-B[0]))
    elif j=len(B)-1:
        if 0<=B[-1]<=B[-2] or 0>=B[-1]>=B[-2]:
            print(S)
        elif B[-1]<=0<=B[-2] or B[-1]>=0>=B[-2]:
            print(S-abs(B[-1]))
        else:
            print(S-abs(B[-1]-B[-2]))
    else:
        if B[j-1]<=B[j]<=B[j+1] or B[j-1]>=B[j]>=B[j+1]:
            print(S)
        elif B[j]<=B[j-1]<=B[j+1] or B[j]>=B[j-1]>=B[j+1]:
            print(S-abs(B[j-1]-B[j]))
        else:
            print(S-abs(B[j+1]-B[j]))
Problem p03544 (python)

Fixed submission:
n=int(input())
a=2
b=1
c=0
if n==0:
    c=2
elif n==1:
    c=1
else:
    for i in range(n-1):
        c=a+b
        a=b
        b=c
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=2
b=1
c=0
for i in range(N):
  c=a+b
  a=b
  b=c
print(c)
Problem p03559 (python)

Fixed submission:
from bisect import bisect_left, bisect_right
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for j in range(N):
    a=bisect_left(A, B[j])
    c=bisect_right(C, B[j])
    ans+=a*(N-c)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for j in range(N):
    a=bisect.bisect_left(a, B[j])
    c=bisect.bisect_right(a, B[j])
    ans+=a*c
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for j in range(N):
    a=bisect_left(a, B[j])
    c=bisect_right(a, B[j])
    ans+=a*c
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for j in range(N):
    a=bisect_left(a, B[i])
    c=bisect_right(a, B[i])
    ans+=a*c
print(ans)
Problem p03563 (python)

Fixed submission:
R=int(input())
G=int(input())
print(2*G-R)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
j=0
i=-1
flag = False
while i>=-1*len(S)-1+len(T):
    while j>=-1*len(T):
        if i==-1*len(S)-1+len(T):
            A="UNRESTORABLE"
            flag=True
            break
        elif j==-1*len(T):
            if i!=-1:
                P=S.replace(S[i-len(T)+1:i+1],T,1)
                A=P.replace("?","a")
                i=-1*len(S)-1+len(T)
                flag=True
                break
            else:
                P=S.replace(S[i-len(T)+1:],T,1)
                A=P.replace("?","a")
                flag=True
                break
        elif S[i+j]==T[j-1] or S[i+j]=="?":
            j=j-1
        else:
            j=0
            i=i-1
    if flag:
        break
print(A)