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

Fixed submission:
def f():
  n, m = map(int, input().split())
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
print(f())

Buggy submission (verdict: Runtime Error):
import math

n,m = map(int, input().split())

for i in range(1, math.ceil(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if m // i > n:
        continue
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
import math

inputlist = list(map(int, input().split()))
n, m = inputlist[0], inputlist[1]

for i in range(1, int(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if i > m // n:
        continue
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
inputlist = list(map(int, input().split()))
n, m = inputlist[0], inputlist[1]

for i in range(1, int(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if i > m // n:
        continue
    ans = i
print(ans)
Problem p03262 (python)

Fixed submission:
n,x = map(int,input().split())
lst = list(map(int, input().split()))
 
lst.append(x)
lst.sort()
 
dif_lst = []
for i in range(len(lst)-1):
    dif = lst[i+1] - lst[i]
    dif_lst.append(lst[i+1] - lst[i])
dif_lst.sort()

lst = dif_lst
while True:
    dif_lst = [lst[0]]
    for i in range(len(lst)-1):
        dif = lst[i+1] - lst[i]
        if dif == 0:
            continue
        else:
            dif_lst.append(lst[i+1] - lst[i])
    dif_lst.sort()
    if dif_lst[0] == 1:
        print(1)
        break
    elif len(dif_lst) == 1:
        print(dif_lst[0])
        break
    lst = dif_lst

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
lst = list(map(int, input().split()))
 
lst.append(x)
lst.sort()
 
dif_lst = []
for i in range(len(lst)-1):
    dif = lst[i+1] - lst[i]
    dif_lst.append(lst[i+1] - lst[i])
dif_lst.sort()
 
def dif_get(lst):
    dif_lst = [lst[0]]
    for i in range(len(lst)-1):
        dif = lst[i+1] - lst[i]
        if dif == 0:
            continue
        else:
            dif_lst.append(lst[i+1] - lst[i])
    dif_lst.sort()
    if dif_lst[0] == 1:
        return 1
    elif len(dif_lst) == 1:
        return dif_lst[0]
    else:
        return dif_get(dif_lst)
 
print(dif_get(dif_lst))

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
lst = list(map(int, input().split()))
 
lst.append(x)
lst.sort()
 
dif_lst = []
for i in range(len(lst)-1):
    dif = lst[i+1] - lst[i]
    if dif == 0:
        continue
    else:
        dif_lst.append(lst[i+1] - lst[i])
dif_lst.sort()
 
def dif_get(lst):
    dif_lst = [lst[0]]
    for i in range(len(lst)-1):
        dif = lst[i+1] - lst[i]
        if dif == 0:
            continue
        else:
            dif_lst.append(lst[i+1] - lst[i])
    dif_lst.sort()
    if dif_lst[0] == 1:
        return 1
    if len(dif_lst) == 1:
        return dif_lst[0]
    else:
        return dif_get(dif_lst)
 
print(dif_get(dif_lst))

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

lst.append(x)
lst.sort()

dif_lst = []
for i in range(len(lst)-1):
    dif_lst.append(lst[i+1] - lst[i])
dif_lst.sort()

def dif_get(lst):
    dif_lst = [lst[0]]
    for i in range(len(lst)-1):
        dif = lst[i+1] - lst[i]
        if dif == 0:
            continue
        else:
            dif_lst.append(lst[i+1] - lst[i])
    dif_lst.sort()
    if dif_lst[0] == 1:
        return 1
    if len(dif_lst) == 1:
        return dif_lst[0]
    else:
        return dif_get(dif_lst)

print(dif_get(dif_lst))
Problem p03267 (python)

Fixed submission:
L = int(input())

n = 0
while 2**n <= L:
    n += 1

side_lst = []
    
rest = L - 2**(n-1)
next_num = 2**(n-1)

m = n
while rest > 0:
    if rest >= 2**(m-2):
        side_lst.append([m-1, n, next_num])
        next_num += 2**(m-2)
        rest -= 2**(m-2)
    m -= 1
    
print(n, len(side_lst)+(n-1)*2)
for i in side_lst:
    print(i[0], i[1], i[2])
    
for i in range(1, n):
    print(i, i+1, 0)
    print(i, i+1, 2**(i-1))

Buggy submission (verdict: Runtime Error):
L = int(input())

#頂点の数nを決める
n = 0
while 2**n < L:
    n += 1

rest = L - 2**(n-1)
next_num = 2**(n-1)

m = n
while rest > 0:
    if rest >= 2**(m-2):
        side_lst.append([m-1, n, next_num])
        next_num += 2**(m-2)
        rest -= 2**(m-2)
    m -= 1
    
print(n, len(side_lst)+(n-1)*2)
for i in side_lst:
    print(i[0], i[1], i[2])
    
for i in range(1, n):
    print(i, i+1, i)
    print(i, i+1, 2**(i-1))
Problem p03288 (python)

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

Buggy submission (verdict: Runtime Error):
import math

d, g = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(d)]

for k,i in enumerate(lst):
    i.append((k+1)*100)
    i.append(i[2]*i[0]+i[1])

def calcurate(pt, count, g, lst):
    lst1 = list()
    for i in lst:
        if i[3] > g - pt:
            lst1.append(i + [i[2]])
        else:
            lst1.append(i + [i[3]/i[0]])
    lst1 = sorted(lst1, key = lambda x: -x[-1])
    ps = lst1[0]
    if ps[3] > g - pt:
        count += math.ceil((g - pt) / ps[2])
        return print(count)
    elif ps[3] == g - pt:
        return print(count + ps[0])
    else:
        calcurate(pt+ps[3], count+ps[0], g, lst1[1:])

calcurate(0,0,g,lst)
Problem p03339 (python)

Fixed submission:
import numpy as np

n = int(input())
string = input()

lst_w = []
lst_e = []

count = 0
for i in string:
    if i == 'W':
        lst_w.append(count)
        count += 1
    else:
        lst_w.append(count)
        
count = 0
for i in string[::-1]:
    if i == 'E':
        lst_e.append(count)
        count += 1
    else:
        lst_e.append(count)
lst_e = lst_e[::-1]

print(min(np.array(lst_w) + np.array(lst_e)))

Buggy submission (verdict: Runtime Error):
n = int(input())
string = input()

lst_w = []
lst_e = []

count = 0
for i in string:
    if i == 'W':
        lst_w.append(count)
        count += 1
    else:
        lst_w.append(count)
        
count = 0
for i in string[::-1]:
    if i == 'E':
        lst_e.append(count)
        count += 1
    else:
        lst_e.append(count)
lst_e = lst_e[::-1]

print(min(np.array(lst_w) + np.array(lst_e)))
Problem p03340 (python)

Fixed submission:
import itertools

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

accum_xor = []
s = 0
for i in lst:
    s = s ^ i
    accum_xor.append(s)

accum_lst = list(itertools.accumulate(lst))

def bisearch(start, n, accum_xor, accum_lst):
    low = start
    high = n
    while True:
        i = (low+high)//2
        if start == 0:
            if accum_xor[i] == accum_lst[i]:
                low = i
            else:
                high = i
        else:
            if accum_xor[start-1] ^ accum_xor[i] == accum_lst[i] - accum_lst[start-1]:
                low = i
            else:
                high = i
        if high - low <= 1:
            if start == 0:
                if accum_xor[high] == accum_lst[high]:
                    flg = True
                else:
                    flg = False
            else:
                if accum_xor[start-1] ^ accum_xor[high] == accum_lst[high] - accum_lst[start-1]:
                    flg = True
                else:
                    flg = False
            break
    return high if flg else low

s = 0
for i in range(n):
    a = bisearch(i, n-1, accum_xor, accum_lst) - i + 1
    s += a
print(s)

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

accum_xor = []
s = 0
for i in lst:
    s = s ^ i
    accum_xor.append(s)

accum_lst = list(itertools.accumulate(lst))

def bisearch(start, n, accum_xor, accum_lst):
    low = start
    high = n
    while True:
        i = (low+high)//2
        if start == 0:
            if accum_xor[i] == accum_lst[i]:
                low = i
            else:
                high = i
        else:
            if accum_xor[start-1] ^ accum_xor[i] == accum_lst[i] - accum_lst[start-1]:
                low = i
            else:
                high = i
        if high - low <= 1:
            if start == 0:
                if accum_xor[high] == accum_lst[high]:
                    flg = True
                else:
                    flg = False
            else:
                if accum_xor[start-1] ^ accum_xor[high] == accum_lst[high] - accum_lst[start-1]:
                    flg = True
                else:
                    flg = False
            break
    return high if flg else low

s = 0
for i in range(n):
    a = bisearch(i, n-1, accum_xor, accum_lst) - i + 1
    s += a
print(s)

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

start = 0
end = 1
count = n
while start < n-1:
    s = lst[start]
    next_num = lst[end]
    while s + next_num == s ^ next_num:
        count += 1
        s = s + next_num
        end += 1
        next_num = lst[end]
        if end == n:
            break
    start += 1
    end = start + 1
print(count)
Problem p03352 (python)

Fixed submission:
import math
x = int(input())

res = 1
for b in range(2, math.ceil(math.sqrt(x))):
    p = 2
    while b**(p+1) <= x:
        p += 1
    res = max(res, b ** p)
print(res)

Buggy submission (verdict: Runtime Error):
import math

res = 1
for b in range(2, math.ceil(math.sqrt(x))):
    p = 2
    while b**(p+1) <= x:
        p += 1
    res = max(res, b ** p)
print(res)
Problem p03353 (python)

Fixed submission:
s = input()
k = int(input())
lst = []
start = 0
end = 1
while start < len(s):
    while end - start <= 5:
        lst.append(s[start:end])
        end += 1
    start += 1
    end = start +1
lst.append(s[-1])

print(sorted(list(set(lst)))[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
lst = []
for i in range(len(s)-4):
    for j in range(1, 6):
        lst.append(s[i:i+j])
print(sorted(list(set(lst)))[k-1])
Problem p03380 (python)

Fixed submission:
N = int(input())
lst = sorted(list(map(int, input().split())), reverse=True)

max_comb = -1
k = lst[0]
mid = k/2
high = 1
low = N-1
while abs(high - low) > 1:
    if mid - lst[(high+low)//2] ==0:
        high = (high+low) // 2
        low = high
        break
    elif mid - lst[(high+low)//2] > 0:
        low = (high+low)//2
    else:
        high = (high+low)//2
p = lst[high] if abs(mid - lst[high]) < abs(mid - lst[low]) else lst[low]
print(k, p)

Buggy submission (verdict: Runtime Error):
N = int(input())
lst = sorted(list(map(int, input().split())), reverse=True)

max_comb = -1
for i in range(N):
    if max_comb > scipy.misc.comb(lst[i], lst[i]//2, exact=1):
        break
    k = lst[i]
    mid = k/2
    high = i
    low = N-1
    dif = abs(mid - lst[low])
    #print(mid)
    while abs(high - low) > 1:
        if dif > abs(mid - lst[(high+low)//2]):
            dif = abs(mid - lst[(high+low)//2])
            low = (high+low)//2
        else:
            high = (high+low)//2
        #print(high, low)
    p = lst[high] if abs(mid - lst[high]) < abs(mid - lst[low]) else lst[low]
    comb = scipy.misc.comb(k, p, exact=1)
    if max_comb < comb:
        ans = (k, p)
        #print(ans, comb)
        max_comb = comb

print(ans)
Problem p03574 (python)

Fixed submission:
n, m = map(int, input().split())
lst = [input() for _ in range(n)]

def check(lst, i, j, n, m):
    if n == 1:
        row_lst = [0]
    elif i == 0:
        row_lst = [i, i+1]
    elif i == n-1:
        row_lst = [i-1, i]
    else:
        row_lst = [i-1, i, i+1]
    if m == 1:
        col_lst = [0]
    elif j == 0:
        col_lst = [j, j+1]
    elif j == m-1:
        col_lst = [j-1, j]
    else:
        col_lst = [j-1, j, j+1]
    count = 0
    for a in row_lst:
        for b in col_lst:
            if lst[a][b] == '#':
                count += 1
    return count


for i in range(n):
    ans = ''
    for j in range(m):
        if lst[i][j] == '#':
            ans += '#'
        else:
            ans += str(check(lst, i, j, n, m))
    print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
lst = [input() for _ in range(n)]

def check(lst, i, j, n, m):
    if i == 0:
        row_lst = [i, i+1]
    elif i == n-1:
        row_lst = [i-1, i]
    else:
        row_lst = [i-1, i, i+1]
    if j == 0:
        col_lst = [j, j+1]
    elif j == m-1:
        col_lst = [j-1, j]
    else:
        col_lst = [j-1, j, j+1]
    count = 0
    for a in row_lst:
        for b in col_lst:
            if lst[a][b] == '#':
                count += 1
    return count


for i in range(n):
    ans = ''
    for j in range(m):
        if lst[i][j] == '#':
            ans += '#'
        else:
            ans += str(check(lst, i, j, n, m))
    print(ans)
Problem p03575 (python)

Fixed submission:
# UnionFind構造

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]

count = 0
for i in range(len(lst)):
    llst = lst[:]
    del llst[i]
    a = UnionFind(n)
    for i in llst:
        a.union(i[0], i[1])
    rootset = set()
    for i in range(1, n+1):
        rootset.add(a.find(i))
    if len(rootset)==1:
        pass
    else:
        count += 1
        
print(count)

Buggy submission (verdict: Runtime Error):
# UnionFind構造

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(n)]

count = 0
for i in range(len(lst)):
    llst = lst[:]
    del llst[i]
    a = UnionFind(n)
    for i in llst:
        a.union(i[0], i[1])
    rootset = set()
    for i in range(1, n):
        rootset.add(a.find(i))
    if len(rootset)==1:
        pass
    else:
        count += 1
        
print(count)
Problem p03071 (python)

Fixed submission:
a,b = map(int, input().split())
if a != b:
    x= max([a,b])*2 -1
else:
    x =a*2
print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
b = list(map(int, input().split()))
mostHeight =b[0]
count = 0
for i in b:
    if(i >= mostHeight):
        mostHeight = i
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
b = [map(int, input().split())]
mostHeight =b[0]
count = 0
for i in b:
    if(i >= mostHeight):
        mostHeight = i
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
a =input()
b = [map(int, input().split())]
mostHeight =b[0]
count = 0
for i in b:
    if(i >= mostHeight):
        mostHeight = i
        count += 1
print(count)
Problem p03587 (python)

Fixed submission:
s = input()
l = [int(x) for x in list(str(s))]
count = 0
for i in l:
    if i == 1:
        count = count + 1
print(count)

Buggy submission (verdict: Runtime Error):
s = input()
print(l)
count = 0
for i in l:
    if i == 1:
        count = count + 1
print(count)
Problem p02885 (python)

Fixed submission:
a, b = map(int, input().split())
c = a - 2 * b
if c <= 0:
    print(0)
else:
    print(c)

Buggy submission (verdict: Runtime Error):
    a = input()
    b = input()
    number_a = int(a)
    number_b = int(b)
    c = number_a - 2 * number_b
    if c <= 0:
        print(0)
    else:
        print(c)

Buggy submission (verdict: Runtime Error):
a = input()
    b = input()
    number_a = int(a)
    number_b = int(b)
    c = number_a - 2 * number_b
    if c <= 0:
        print(0)
    else:
        print(c)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    a = input()
    b = input()
    number_a = int(a)
    number_b = int(b)
    c = number_a - 2 * number_b
    if c <= 0:
        print(0)
    else:
        print(c)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    a = input()
    b = input()
    c = a - 2 * b
    if c <= 0:
        print(0)
    else:
        print(c)
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
add = a + b
sub = a - b
mul = a * b
callist = [add, sub, mul]
print(max(callist))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
add = a + b
sub = a - b
mul = a * b
callist = [add, sub, mul]
print(max(callist))
Problem p02909 (python)

Fixed submission:
today = input()
 
if today == "Sunny":
  tomorrow = "Cloudy"
elif today == "Cloudy":
  tomorrow = "Rainy"
else:
  tomorrow = "Sunny"
 
print(tomorrow)

Buggy submission (verdict: Runtime Error):
today = input()
 
if today = "Sunny":
  tomorrow = "Cloudy"
elif today = "Cloudy":
  tomorrow = "Rainy"
else:
  tomorrow = "Sunny"
 
print(tomorrow)

Buggy submission (verdict: Runtime Error):
today = input()
 
if today = "Sunny":
  tomorrow = "Cloudy"
elseif today = "Cloudy":
  tomorrow = "Rainy"
else:
  tomorrow = "Sunny"
 
print(tomorrow)

Buggy submission (verdict: Runtime Error):
today = input()

if today = "Sunny":
  tomorrow = "Cloudy"
elseif today = "Cloudy":
  tomorrow = "Rainy"
else:
  tomorrow = "Rainy"

output(tomorrow)
Problem p02981 (python)

Fixed submission:
N, A, B = map(int, input().split())
print(min(N*A,B))

Buggy submission (verdict: Runtime Error):
N, A, B = int(input().split())
print(min(N*A,B))
Problem p02969 (python)

Fixed submission:
r = int(input())
ans = 3*r*r
print(ans)

Buggy submission (verdict: Runtime Error):
sys.stdin = f
r = int(input())
ans = 3*r*r
print(ans)
Problem p02994 (python)

Fixed submission:
data = input().split()
N = int(data[0])
L = int(data[1])
taste = []
for i in range(N):
    taste.append(L + (i+1) - 1)
absTaste = []
for i in range(N):
    absTaste.append(abs(taste[i]))
index = 0
minimum = 0
for i in range(1,N):
    if absTaste[i-1] > absTaste[i]:
        index = i
        minimum = taste[i]
ans = sum(taste) - taste[index]#sumはリスト内の数値の合計を計算する関数
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
f = open('BiteEating_input.txt', 'r')#ファイルを読み込み
lines = f.readlines()#変数linesに1行ずつ読み込み.linesは配列

data = input().split()
N = int(data[0])
L = int(data[1])
taste = []
for i in range(N):
    taste.append(L + (i+1) - 1)
absTaste = []
for i in range(N):
    absTaste.append(abs(taste[i]))
index = 0
minimum = 0
for i in range(1,N):
    if absTaste[i-1] > absTaste[i]:
        index = i
        minimum = taste[i]
ans = sum(taste) - taste[index]#sumはリスト内の数値の合計を計算する関数
print(ans)
Problem p03000 (python)

Fixed submission:
N, X = [int(line) for line in input().split()]
L = [int(line) for line in input().split()]

D = [0]#D1 = 0
for i in range(1,N+1):#座標Dの配列を作る
    Di = D[i-1] + L[i-1]
    D.append(Di)

ans = 0
for i in range(len(D)):#
    if D[i] <= X:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, X = [int(line) for line in input().split()]
L = [int(line) for line in input().split()]

D = [0]#D1 = 0
for i in range(1,N+1):#座標Dの配列を作る
    Di = D[i-1] + L[i-1]
    D.append(Di)

for i in range(len(D)):#
    if D[i] == X:
        index = i
        break
    elif D[i] > X:
        index = i - 1
        break
ans = index + 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, X = [int(line) for line in input().split()]
L = [int(line) for line in input().split()]

D = [0]#D1 = 0
for i in range(1,N+1):#座標Dの配列を作る
    Di = D[i-1] + L[i-1]
    D.append(Di)

for i in range(len(D)):#
    if D[i] == X:
        index = i
        break
    elif D[i] > X:
        index = i - 1
        break
ans = index + 1
print(ans)
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
if N == 1:
    print("Hello World")
elif N == 2:
    print(A + B)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
if N == 1:
    print("Hello World")
else:
    print(A + B)

Buggy submission (verdict: Runtime Error):
data = [int(input()) for i in range(3)]
N = data[0]
A = data[1]
B = data[2]
if N == 1:
    print("Hello World")
else:
    print(A + B)

Buggy submission (verdict: Runtime Error):
data = [int(input()) for i in range(3)]
N = data[0];A = data[1];B = data[2]
if N == 1:
    print("Hello World")
else:
    print(A + B)

Buggy submission (verdict: Runtime Error):
data = [int(input()) for i in range(3)]
N = data[0];A = data[1];B = data[2]
if N == 1:
    print("Hello World")
else:
    print(A + B)
Problem p03478 (python)

Fixed submission:
import math
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
total = 0
digit_total = 0

for i in range(1,N+1):
    size = int(math.log10(i)+1)
    digit = []
    for j in range(size):
        digit.append(int(str(i)[j-1]))
        digit_total += digit[j]
    if A <= digit_total and digit_total <= B:
        total += i
    digit_total = 0
print(total)

Buggy submission (verdict: Runtime Error):
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
total = 0
digit_total = 0

for i in range(1,N+1):
    size = int(math.log10(i)+1)
    digit = []
    for j in range(size):
        digit.append(int(str(i)[j-1]))
        digit_total += digit[j]
    if A <= digit_total and digit_total <= B:
        total += i
    digit_total = 0
print(total)
Problem p02917 (python)

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

mx = 0

for i in range(len(B)):

    if i==0 :

        if len(B)==1 :

            mx += B[0]*2

        else:

            if B[i] > B[i+1]:

                mx += B[i]+B[i+1]

            else:

                mx += B[i]*2

    elif i>0 :

        if i != len(B)-1:

            if B[i] < B[i+1]:

                mx += B[i]

            elif B[i] >= B[i+1]:

                mx += B[i+1]

        elif i == len(B)-1:

            mx += B[i]

print(mx)

Buggy submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
A = []



for i in range(len(B)):

    if i == 0:
        if len(B)==1 or B[i]<=B[i+1]:

            A.extend(B[:1]*2)

        elif B[i]>B[i+1]:

            A.extend(B[1:2]*2)

            
    if 0 < i < len(B):

        if B[i]<B[i+1]:


            A.append(B[i])

        elif B[i]>=B[i+1]:

            A.append(B[i+1])

    if i!=0 and i==len(B)-1:

        A.append(B[i])
            
        
from functools import reduce

print(reduce(lambda x,y : x+y,A))

Buggy submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
A = []

for i in range(len(B)):

    if i==0:
        if B[i]<B[i+1] or B[i]==B[i+1]:

            A.extend(B[:1]*2)

        elif B[i]>B[i+1]:

            A.extend(B[1:2]*2)
            
        

    elif i<len(B)-1 and B[i]>B[i+1]:

        A.append(B[i+1])

    else:

        A.append(B[i])
            
        

    
from functools import reduce

print(reduce(lambda x,y : x+y,A))