Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
a = list(map(int, input().split()))

c = 0

if x == 0:
	print(sum(a))
if a[0] > x:
	c += a[i] - (x-1)
	a[i] = x - 1
	
else:
	for i in range(n-1):
		if a[i] + a[i+1] > x:
			if a[i+1] >= a[i]:
				c += (a[i+1] - (x - a[i]))
				a[i+1] -= (a[i+1] - (x - a[i]))
			else:
				c += (a[i+1] - abs(x - a[i]))
				a[i+1] -= (a[i+1] - abs(x - a[i]))              

print(c) 

Fixed submission:
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    delta = max(0, a[i] + a[i+1] - x)
    a[i+1] -= delta
    if a[i+1] < 0:
        a[i] += a[i+1]
        a[i+1] = 0
    ans += delta
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, x = map(int, input().split())
a = list(map(int, input().split()))

c = 0

while True:
	f = 0	
	for i in range(n-1):
		if a[i] + a[i+1] > x:
			f = 1
			if a[i+1] >= a[i]:
				a[i+1] -= 1
			else:
				a[i] -= 1
			c += 1
			break
	if f == 0:
		break
print(c) 

Fixed submission:
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    delta = max(0, a[i] + a[i+1] - x)
    a[i+1] -= delta
    if a[i+1] < 0:
        a[i] += a[i+1]
        a[i+1] = 0
    ans += delta
print(ans)

Buggy python submission (verdict: Runtime Error):
def minimumNumOfCandies(candies,atmostValue):
  candiesToEat = 0
  for i in range( 0 , len ( candies ) - 1 ) :
    if( candies[i] > atmostValue ) :
      candiesToEat = candiesToEat + ( candies[i] - atmostValue)
      candies[i] = candies[i] - ( candies[i] - atmostValue )
    if( candies[i] + candies[i + 1] > atmostValue ):
      candiesToEat = candiesToEat + ( candies[i + 1] - atmostValue )
      candies[i + 1] = candies[i + 1] - ( candies[i + 1] - atmostValue)
  return candiesToEat
n = list(int(i) for i in input())
candies = list( int (i) for i in input())
print(minimumNumOfCandies(candies,n[1]))

Fixed submission:
def minimumNumOfCandies(candies,atmostValue):
  candiesToEat = 0
  for i in range( 0 , len ( candies ) - 1 ) :
    if( candies[i] > atmostValue ) :
      candiesToEat = candiesToEat + ( candies[i] - atmostValue)
      candies[i] = candies[i] - ( candies[i] - atmostValue )
    if( candies[i] + candies[i + 1] > atmostValue ):
      candiesToEat = candiesToEat + ( (candies[i + 1] + candies[i]) - atmostValue )
      candies[i + 1] = candies[i + 1] - ( (candies[i + 1] + candies[i])- atmostValue)
  return candiesToEat
n = list(int(i) for i in input().split())
candies = list( int (i) for i in input().split())
print(minimumNumOfCandies(candies,n[1]))
Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split())
t=sorted([input() for i in range(n)])
print(*t,sep="")

Fixed submission:
a, b, c = map(int, input().split())
if((a+b+c)-17 == 0):
	print("YES")
else:
	print("NO")
Buggy python submission (verdict: Runtime Error):
s = str(raw_input())

b, c, d = map(str, raw_input().split())

print 'A' + c[0] + 'C'


Fixed submission:
s = str(raw_input())

b, c, d = map(str, s.split())

print 'A' + c[0] + 'C'
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, raw_input().split())

i = a
count = 0
while i < b + 1:
    if i%x == 0:
        count = count + 1
    i = i + 1

print count


Fixed submission:
a, b, x = map(int, raw_input().split())

i = a
count = 0
count_b = 0
count_a = 0

count_b = b/x
count_a = (a-1)/x


print count_b - count_a

Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, raw_input().split())

i = a
count = 0
while i < b + 1:
    if x%i == 0:
        count = count + 1
    i = i + 1

print count


Fixed submission:
a, b, x = map(int, raw_input().split())

i = a
count = 0
count_b = 0
count_a = 0

count_b = b/x
count_a = (a-1)/x


print count_b - count_a

Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, raw_input().split())

i = a
count = 0
while i < b + 1:
    if x%i == 0:
        count = count + 1

print count


Fixed submission:
a, b, x = map(int, raw_input().split())

i = a
count = 0
count_b = 0
count_a = 0

count_b = b/x
count_a = (a-1)/x


print count_b - count_a

Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, raw_input().split())

i = a
count = 0
for i in i < b + 1:
    if x%i == 0:
        count = count + 1

print count


Fixed submission:
a, b, x = map(int, raw_input().split())

i = a
count = 0
count_b = 0
count_a = 0

count_b = b/x
count_a = (a-1)/x


print count_b - count_a

Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, raw_input().split())

i = a
count = 0
for i in i < b + 1:
    if x%i == 0:
        count++

print count


Fixed submission:
a, b, x = map(int, raw_input().split())

i = a
count = 0
count_b = 0
count_a = 0

count_b = b/x
count_a = (a-1)/x


print count_b - count_a
Buggy python submission (verdict: Time Limit Exceeded):
sa = str(raw_input())
sb = str(raw_input())
sc = str(raw_input())

n = 'a'
h = ''
while True:
    if n == 'a':
        if len(sa) < 1:
            break
        h, sa = sa[0], sa[1:]
        n = h
    elif n == 'b':
        if len(sb) < 1:
            break
        h, sb = sb[0], sb[1:]
        n = h
    elif n == 'c':
        if len(sc):
            break
        h, sc = sc[0], sc[1:]
        n = h

print str.upper(n)


Fixed submission:
a = int(raw_input())
b = int(raw_input())
h = int(raw_input())

s = (a + b) * h/2

print s
Buggy python submission (verdict: Runtime Error):
sa = str(raw_input())
sb = str(raw_input())
sc = str(raw_input())

n = 'a'
h = ''
while True:
    if n = 'a':
        if len(sa) < 1:
            break
        h, sa = sa[0], sa[1:]
        n = h
    elif n = 'b':
        if len(sb) < 1:
            break
        h, sb = sb[0], sb[1:]
        n = h
    elif n = 'c':
        if len(sc):
            break
        h, sc = sc[0], sc[1:]
        n = h

print n


Fixed submission:
sa = str(raw_input())
sb = str(raw_input())
sc = str(raw_input())

n = 'a'
h = ''
while True:
    if n == 'a':
        if len(sa) < 1:
            break
        h, sa = sa[0], sa[1:]
        n = h
    elif n == 'b':
        if len(sb) < 1:
            break
        h, sb = sb[0], sb[1:]
        n = h
    elif n == 'c':
        if len(sc) < 1:
            break
        h, sc = sc[0], sc[1:]
        n = h

print str.upper(n)
Buggy python submission (verdict: Runtime Error):
a, b, x= map(int, raw_input().split())
if a%x == 0:
    print b//x - a//x +1
else:
    print  b//x - a//x

Fixed submission:
input_line1 = raw_input()
input_list = input_line1.split()
output = [x[0] for x in input_list]
print ''.join(output)

Buggy python submission (verdict: Runtime Error):
input_list = raw_input.split()
output = x[0] for x in input_list
print ''.join(output)

Fixed submission:
input_line1 = raw_input()
input_list = input_line1.split()
output = [x[0] for x in input_list]
print ''.join(output)

Buggy python submission (verdict: Runtime Error):
input_line1 = raw_input()
input_list = input_line1.split()
output = x[0] for x in input_list
print ''.join(output)

Fixed submission:
input_line1 = raw_input()
input_list = input_line1.split()
output = [x[0] for x in input_list]
print ''.join(output)

Buggy python submission (verdict: Runtime Error):
input_line1 = raw_input()
input_list = input_line1.split()
output = x[0] for x in input_list
print ''.join(output)

Fixed submission:
input_line1 = raw_input()
input_list = input_line1.split()
output = [x[0] for x in input_list]
print ''.join(output)
Buggy python submission (verdict: Runtime Error):
a, b, x= raw_input().split()
if a%3 == 0:
    print b//x - a//x +1
else:
   print  b//x - a//x +1

Fixed submission:
a, b, x= map(int, raw_input().split())
if a%x == 0:
    print b//x - a//x +1
else:
    print  b//x - a//x

Buggy python submission (verdict: Runtime Error):
a, b, x= raw_input().split()
m = (b-a)//x
if a%x == 0 or b%x == 0:
    print m+1
else:
    print m

Fixed submission:
a, b, x= map(int, raw_input().split())
if a%x == 0:
    print b//x - a//x +1
else:
    print  b//x - a//x

Buggy python submission (verdict: Runtime Error):
a, b, x= raw_input().split()
m = a//b
if a%x == 0 or b%x == 0:
    print m+1
else:
    print m

Fixed submission:
a, b, x= map(int, raw_input().split())
if a%x == 0:
    print b//x - a//x +1
else:
    print  b//x - a//x
Buggy python submission (verdict: Runtime Error):
counter = 0
for i  in range(0, len(candies)-1):
    counter += candies[i+1] + candies[i] - x
    candies[i+1] = x - candies[i]
print counter

Fixed submission:
N, x = map(int, raw_input().split())
candies = map(int, raw_input().split())
counter = 0
for i  in range(0, len(candies)-1):
    delta = candies[i+1] + candies[i] - x
    if delta > 0:
        counter += delta
        candies[i+1] = x - candies[i]
        if candies[i+1] < 0:
            candies[i+1] = 0
print counter
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
flag = bool

if a == 5 and b ==7 and c==5:
    flag = True
if a ==7 and b==5 and c == 5:
    flag = True
if a ==5 and b==5 and c == 7:
    flag = True

if flag == True:
    print('YES')
else:
    print('NO')

Fixed submission:
a, b, c = input().split()

flag = bool

if a == '5' and b =='7' and c=='5':
    flag = True
if a =='7' and b=='5' and c == '5':
    flag = True
if a =='5' and b=='5' and c == '7':
    flag = True

if flag == True:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
s=input();l = len;p = print
if (s[0]==s[-1] * l(s)%2==0) + (s[0]!=s[-1] * l(s)%2==1):
    p("First")
else:
    p("Second")


Fixed submission:
s=input();l = len;p = print
if (s[0]==s[-1] and l(s)%2==0) or (s[0]!=s[-1] and l(s)%2==1):
    p("First")
else:
    p("Second")
Buggy python submission (verdict: Runtime Error):
s=input();l = len;p = print
if (s[0]==s[-1] * l(s)%2==0) + (s[0]!=s[-1] * l(s)%2==1):
    p("First")
else:
    p("Second")
s=input();l = len;p = print
if (s[0]==s[-1] * l(s)%2==0) + (s[0]!=s[-1] * l(s)%2==1):
    p("First")
else:
    p("Second")


Fixed submission:
s=input();l = len;p = print
if (s[0]==s[-1] and l(s)%2==0) or (s[0]!=s[-1] and l(s)%2==1):
    p("First")
else:
    p("Second")
Buggy python submission (verdict: Runtime Error):
# -*- config: utf-8 -*-
 
 
 
while(1):
    a,b,c = map(int,raw_input().split())
    j = 0
 
 
    if a + b == c or a + c == b or b + c== a:
        j=1
 
    if(j == 1):
        print 'Yes'
    else:
        print 'No'
 
 
 

Fixed submission:
# -*- config: utf-8 -*-
 
 
 
 
a,b,c = map(int,raw_input().split())
j = 0
 
 
if a + b == c or a + c == b or b + c== a:
    j=1
 
if(j == 1):
    print 'Yes'
else:
    print 'No'

Buggy python submission (verdict: Runtime Error):
# -*- config: utf-8 -*-
 
 
 
for i in range(10):
    a,b,c = map(int,raw_input().split())
    j = 0
 
 
    if a + b == c or a + c == b or b + c== a:
        j=1
 
    if(j == 1):
        print 'Yes'
    else:
        print 'No'
 
 
 

Fixed submission:
# -*- config: utf-8 -*-
 
 
 
 
a,b,c = map(int,raw_input().split())
j = 0
 
 
if a + b == c or a + c == b or b + c== a:
    j=1
 
if(j == 1):
    print 'Yes'
else:
    print 'No'

Buggy python submission (verdict: Runtime Error):
# -*- config: utf-8 -*-



for i in range(10):
    a,b,c = map(int,raw_input().split())
    j = 0


    if a + b == c or a + c == b or b + c== a:
        j=1

    if(j == 1):
        print 'YES'
    else:
        print 'NO'





Fixed submission:
# -*- config: utf-8 -*-
 
 
 
 
a,b,c = map(int,raw_input().split())
j = 0
 
 
if a + b == c or a + c == b or b + c== a:
    j=1
 
if(j == 1):
    print 'Yes'
else:
    print 'No'

Buggy python submission (verdict: Runtime Error):
# -*- config: utf-8 -*-



while(1):
    a,b,c = map(int,raw_input().split())
    j = 0


    if a + b == c or a + c == b or b + c== a:
        j=1

    if(j == 1):
        print 'YES'
    else:
        print 'NO'





Fixed submission:
# -*- config: utf-8 -*-
 
 
 
 
a,b,c = map(int,raw_input().split())
j = 0
 
 
if a + b == c or a + c == b or b + c== a:
    j=1
 
if(j == 1):
    print 'Yes'
else:
    print 'No'

Buggy python submission (verdict: Runtime Error):
# -*- config: utf-8 -*-


a = 0
b = 0
c = 0

a = input('>>>')
b = input('>>>')
c = input('>>>')

if a+b == c:
    j=1
if a+c == b:
    j=1
if b+c == a:
    j=1

if(j == 1):
    print 'YES'
else:
    print 'NO'



Fixed submission:
# -*- config: utf-8 -*-
 
 
 
 
a,b,c = map(int,raw_input().split())
j = 0
 
 
if a + b == c or a + c == b or b + c== a:
    j=1
 
if(j == 1):
    print 'Yes'
else:
    print 'No'

Buggy python submission (verdict: Runtime Error):
# -*- config: utf-8 -*-


a = 0
b = 0
c = 0

a = input('>>>')
b = input('>>>')
c = input('>>>')

if a+b == c:
    j=1
if a+c == b:
    j=1
if b+c == a:
    j=1

if(j == 1):
    print 'YES'
else:
    print 'NO'



Fixed submission:
# -*- config: utf-8 -*-
 
 
 
 
a,b,c = map(int,raw_input().split())
j = 0
 
 
if a + b == c or a + c == b or b + c== a:
    j=1
 
if(j == 1):
    print 'Yes'
else:
    print 'No'
Buggy python submission (verdict: Runtime Error):
item_list = [0]*100
cnt = 0
a = map(int, input().split())
for i in a:
    if not item_list[i]:
        item_list[i] = 1
        cnt += 1
print(cnt)

Fixed submission:
item_list = [0]*101
cnt = 0
a = map(int, input().split())
for i in a:
    if not item_list[i]:
        item_list[i] = 1
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
def candy():
    n = input().split()
    N = int(n[0])
    x = int(n[1])
    alist = [int(i) for i in input().split()]

    s = 0
    for i in range(0, N - 1):
        c = alist[i] , d = alist[i + 1]
        if int( alist[i] + alist[i + 1] ) > x:
            if int( alist[i] ) >= x:
                alist[i] = x
                alist[i + 1] = 0
            else :
                alist[i + 1] = x - a[i] 
            s += c - alist[i] + d - alist[i + 1]
        /*  
        if int(alist[i]) > x:
            s = s + int(alist[i+1])
            alist[i+1] = 0

        if int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i])
        */
    print(s)
candy()

Fixed submission:
def candy():
    n = []
    n = input().split()
    N = int(n[0])
    x = int(n[1])
    alist = [int(i) for i in input().split()]

    s = 0
    for i in range(0, N - 1):
        c = int(alist[i])
        d = int(alist[i + 1])
        if int( alist[i] + alist[i + 1] ) > x:
            if int( alist[i] ) >= x:
                alist[i] = x
                alist[i + 1] = 0
            else :
                alist[i + 1] = int(x - alist[i] )
            s += c - int(alist[i]) + d - int(alist[i + 1])
        """
        if int(alist[i]) > x:
            s = s + int(alist[i+1])
            alist[i+1] = 0

        if int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i])
        """
    print(s)
candy()

Buggy python submission (verdict: Runtime Error):
def candy():
    boxNum, x = [int(i) for i in input().split()]
    ain = input()
    alist = ain.split(' ')

    s = 0
    for i in range(0, boxNum-1):
        c = alist[i] , d = alist[i + 1]
        if int( alist[i] + alist[i + 1] ) > x:
            if int( alist[i] ) >= x:
                alist[i] = x
                alist[i + 1] = 0
            else :
                alist[i + 1] = x - a[i] 
            s += c - alist[i] + d - alist[i + 1]
        /*  
        if int(alist[i]) > x:
            s = s + int(alist[i+1])
            alist[i+1] = 0

        if int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i])
        */
    print(s)
candy()

Fixed submission:
def candy():
    n = []
    n = input().split()
    N = int(n[0])
    x = int(n[1])
    alist = [int(i) for i in input().split()]

    s = 0
    for i in range(0, N - 1):
        c = int(alist[i])
        d = int(alist[i + 1])
        if int( alist[i] + alist[i + 1] ) > x:
            if int( alist[i] ) >= x:
                alist[i] = x
                alist[i + 1] = 0
            else :
                alist[i + 1] = int(x - alist[i] )
            s += c - int(alist[i]) + d - int(alist[i + 1])
        """
        if int(alist[i]) > x:
            s = s + int(alist[i+1])
            alist[i+1] = 0

        if int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i])
        """
    print(s)
candy()
Buggy python submission (verdict: Runtime Error):
def p_grid(w, h):
	for i in range(h):
		for j in range(w):
			print(grid[j + w*i], end='')
		print()

def coloring():
    line = input()
    words = line.split()
    W = int(words[0])
    H = int(words[1])
    N = int(words[2])

    x = 0
    y = 0
    w = W
    h = H

    grid = []

    for i in range(h):
        for j in range(w):
            grid.append(0)

    for i in range(N):
      s = input()
      ws = s.split()
      x = int(ws[0])
      y = int(ws[1])
      a = int(ws[2])
      if a == 1 or a==3:
        #rect = x * y
        for i in range(y):
            for j in range(x):
                grid[j + w * i] = 1

        for i in range(h):
		    for j in range(w):
			    print(grid[j + w*i], end='')
		    print()

      if a == 2:
        #rect = (w - x) * y
        for i in range(y):
            for j in range(x,w):
                grid[j + w*i] = 1

        for i in range(h):
		    for j in range(w):
			    print(grid[j + w*i], end='')
		    print()

      if a == 4:
        #rect = x * (h - y)
        for i in range(y,h):
            for j in range(x):
                grid[j + w*i] = 1

        for i in range(h):
		    for j in range(w):
			    print(grid[j + w*i], end='')
		    print()
        
    print(grid.count(0))




coloring()

Fixed submission:
def coloring():
    line = input()
    words = line.split()
    W = int(words[0])
    H = int(words[1])
    N = int(words[2])

    x = 0
    y = 0
    w = W
    h = H

    grid = []

    for i in range(h):
        for j in range(w):
            grid.append(0)

    for i in range(N):
        s = input()
        ws = s.split()
        x = int(ws[0])
        y = int(ws[1])
        a = int(ws[2])
        if a == 1:
            #rect = x * whole
            for i in range(h):
                for j in range(x):
                    grid[j + w * i] = 1

        if a == 2:
            #rect = (w - x) * whole
            for i in range(h):
                for j in range(x,w):
                    grid[j + w*i] = 1

        if a==3:
            #rect = whole * y
            for i in range(y):
                for j in range(w):
                    grid[j + w * i] = 1
        
        if a == 4:
            #rect = whole * (h - y)
            for i in range(y,h):
                for j in range(w):
                    grid[j + w*i] = 1

        
    print(grid.count(0))


coloring()
Buggy python submission (verdict: Runtime Error):
def paint():
    a = int(input())
    b = int(input())
    c = int(input())
    count = 1
    if a != b:
        count += 1
    if a != c and b != c:
        count += 1

    print(count)

paint()

Fixed submission:
def paint():
    s = input()
    slist = s.split(' ')

    a = int(slist[0])
    b = int(slist[1])
    c = int(slist[2])
    count = 1
    if a != b:
        count += 1
    if a != c and b != c:
        count += 1

    print(count)

paint()

Buggy python submission (verdict: Runtime Error):
def paint():
    a = int(input())
    b = int(input())
    c = int(input())
    count = 1
    if a != b:
        count += 1
    if a != c and b != c:
        count += 1

    

    print(count)

paint()

Fixed submission:
def paint():
    s = input()
    slist = s.split(' ')

    a = int(slist[0])
    b = int(slist[1])
    c = int(slist[2])
    count = 1
    if a != b:
        count += 1
    if a != c and b != c:
        count += 1

    print(count)

paint()

Buggy python submission (verdict: Runtime Error):
def paint():
    a = int(input())
    b = int(input())
    c = int(input())
    count = 3

    if a == b:
        count -= 1
    if a == c:
        count -= 1
    if b == c:
        count -= 1

    print(count)

paint()

Fixed submission:
def paint():
    s = input()
    slist = s.split(' ')

    a = int(slist[0])
    b = int(slist[1])
    c = int(slist[2])
    count = 1
    if a != b:
        count += 1
    if a != c and b != c:
        count += 1

    print(count)

paint()
Buggy python submission (verdict: Runtime Error):
a, b, c = map(input().split(" "))

if a == 5 and b == 7 and c == 5 \
        or a == 5 and b == 5 and c == 7 \
        or a == 7 and b == 5 and c == 5:
    print("YES")
else:
    print("NO")


Fixed submission:
a, b, c = map(int, input().split(" "))

if a == 5 and b == 7 and c == 5 \
        or a == 5 and b == 5 and c == 7 \
        or a == 7 and b == 5 and c == 5:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
round=lambda x:(x*2+1)//2
a,b,c=[int(i) for i in input().split()]
num1=round(Decimal(b)/Decimal(c))
if(a%c==0):
    num2=round(a/c)-1
else:
    num2=round(a/c)

print(num1-num2)

Fixed submission:
from decimal import Decimal
# round=lambda x:(x*2+1)//2
a,b,c=[int(i) for i in input().split()]
num1=(Decimal(b)/Decimal(c))
if(a%c==0):
    num2=int(Decimal(a)/Decimal(c))-1
else:
    num2=int(Decimal(a)/Decimal(c))

print(int(num1-num2))
Buggy python submission (verdict: Runtime Error):
def minCandies(boxes,limit):
    out = 0
    for i in range(len(boxes) - 1):
        total = boxes[i] + boxes[i + 1]
        if total > limit:
            out += total - limit
            boxes[i + 1] = boxes[i + 1] - (total - limit)
            if boxes[i + 1] < 0:
                boxes[i + 1] = 0
    return out
    
num_of_boxes, limit = map(int,input().split())
boxes = list(map(int,input().split()))

if limit == 0:
    return sum(boxes)
elif max([a + b for (a,b) in zip(boxes[:-1],boxes[1:])) <= limit:
    return 0
else:
    return minCandies(boxes,limit)


Fixed submission:
def minCandies(boxes,limit):
    out = 0
    for i in range(len(boxes) - 1):
        total = boxes[i] + boxes[i + 1]
        if total > limit:
            out += total - limit
            boxes[i + 1] = boxes[i + 1] - (total - limit)
            if boxes[i + 1] < 0:
                boxes[i + 1] = 0
    return out

num_of_boxes, limit = map(int,input().split())
boxes = list(map(int,input().split()))

if limit == 0:
    print(sum(boxes))
elif max([a + b for (a,b) in zip(boxes[:-1],boxes[1:])]) <= limit:
    print(0)
else:
    print(minCandies(boxes,limit))
Buggy python submission (verdict: Runtime Error):
N,x =map(int, input().split())
candy = list(map(int, input().split()))
eat = 0

for i in range(N - 1):
    if(candy[i] + candy[i + 1] > x):
        ex = candy[i] + candy[i + 1] - x
        eat += ex
        if(candy[i + 1] >= ex):
            candy[i + 1] -= ex
        else:
            candy[i] -= ex - cndy[i + 1]
            candy[i + 1] = 0
print(eat)

Fixed submission:
N,x =map(int, input().split())
candy = list(map(int, input().split()))
eat = 0

for i in range(N - 1):
    if(candy[i] + candy[i + 1] > x):
        ex = candy[i] + candy[i + 1] - x
        eat += ex
        if(candy[i + 1] >= ex):
            candy[i + 1] -= ex
        else:
            candy[i] -= ex - candy[i + 1]
            candy[i + 1] = 0
print(eat)
Buggy python submission (verdict: Runtime Error):
data = list(map(lambda x: int(x), input().split()))
strings = [input() for _ in range(data[1])]
strings.sort()
s = ''
for x in strings:
    s += x
print(s)

Fixed submission:
data = list(map(int, input().split()))
strings = [input() for _ in range(data[0])]
strings.sort()
s = ''
for x in strings:
    s += x
print(s)