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 t in range(0, 10):
        for i in range(0, boxNum-1):
            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])
                if alist[i+1] < 0:
                    alist[i] = alist[i] + alist[i+1]
                    alist[i+1] = 0
        
    print(s)
    
candy()

Fixed submission:
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):
        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])
            if int(alist[i+1]) < 0:
                alist[i] = int(alist[i]) + int(alist[i+1])
                alist[i+1] = 0
        
    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):
        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])
            if alist[i+1] < 0:
                alist[i] = alist[i] + alist[i+1]
                alist[i+1] = 0
        
    print(s)
    
candy()

Fixed submission:
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):
        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])
            if int(alist[i+1]) < 0:
                alist[i] = int(alist[i]) + int(alist[i+1])
                alist[i+1] = 0
        
    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):
        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])
            if alist[i+1] < 0:
                alist[i] = alist[i] + alist[i+1]
                alist[i+1] = 0
        
    print(s)
    
candy()

Fixed submission:
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):
        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])
            if int(alist[i+1]) < 0:
                alist[i] = int(alist[i]) + int(alist[i+1])
                alist[i+1] = 0
        
    print(s)
    
candy()

Buggy python submission (verdict: Runtime Error):
def candy():
    N = int(input())
    x = int(input())
    a = int(input().split)

    s = 0
    for i in range(1, N-1):
        if (a[i] + a[i-1]) > x:
            s = s + (a[i] + a[i-1] - x)
            a[i] = x - a[i-1]
    print(s)
    
candy()

Fixed submission:
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):
        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])
            if int(alist[i+1]) < 0:
                alist[i] = int(alist[i]) + int(alist[i+1])
                alist[i+1] = 0
        
    print(s)
    
candy()