Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1

Fixed submission:
n = int(input())
a, b, c = [], [], []
for i in range(n):
    h = input().split(" ")
    a.append(int(h[0]))
    b.append(int(h[1]))
    c.append(int(h[2]))
sum_a, sum_b, sum_c = [a[0]], [b[0]], [c[0]]
for i in range(1, n):
    sum_a.append(a[i] + max(sum_b[i - 1], sum_c[i - 1]))
    sum_b.append(b[i] + max(sum_c[i - 1], sum_a[i - 1]))
    sum_c.append(c[i] + max(sum_a[i - 1], sum_b[i - 1]))
print(max(sum_a[n - 1], sum_b[n - 1], sum_c[n - 1]))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
l = list(map(int,input().split())) + [2**26 for _ in range(k)]

dist = [2**26 for _ in range(n+k)]
dist[n-1]= 0
for x in range(n-2,-1,-1):
    a = l[x]
    dist[x] = min(dist[y] + abs(a-l[y]) for y in range(x+1,x+1+k))
print (dist[0])


Fixed submission:
n,k = map(int,input().split())
l = list(map(int,input().split())) + [2**26 for _ in range(k)]

dist = [2**26 for _ in range(n+k)]
dist[n-1]= 0
for x in range(n-2,-1,-1):
    a = l[x]
    #dist[x] = min(dist[y] + abs(a-l[y]) for y in range(x+1,x+1+k))
    dist[x] = min(y + abs(a-b) for b,y in zip(l[x+1:x+1+k],dist[x+1:x+1+k]))
print (dist[0])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
l = list(map(int,input().split())) + [float("inf") for _ in range(k)]

dist = [float("inf") for _ in range(n+k)]
dist[n-1]= 0
for x in range(n-2,-1,-1):
    dist[x] = min(dist[y] + abs(l[x]-l[y]) for y in range(x+1,x+1+k))
print (dist[0])


Fixed submission:
n,k = map(int,input().split())
l = list(map(int,input().split())) + [2**26 for _ in range(k)]

dist = [2**26 for _ in range(n+k)]
dist[n-1]= 0
for x in range(n-2,-1,-1):
    a = l[x]
    #dist[x] = min(dist[y] + abs(a-l[y]) for y in range(x+1,x+1+k))
    dist[x] = min(y + abs(a-b) for b,y in zip(l[x+1:x+1+k],dist[x+1:x+1+k]))
print (dist[0])
Buggy python submission (verdict: Runtime Error):
n = int(input())
last_chosen = -1

max_points = 0
for i in range(n):
    days = list(map(int, input().split()))
    while True:
        act = max(days)
        idx = days.index(act)
        if idx != last_chosen:
            break
        days.pop(idx)
    max_points += days[idx]
    last_chosen = idx
print(max_points)


Fixed submission:
n=int(input())

dp=list(map(int,input().split()))
for day in range(1,n):
    m=[0]*3
    day_points=list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            if i!=j:
                 m[i]=max(m[i],day_points[i]+dp[j])
    dp=m
print(max(dp))

Buggy python submission (verdict: Runtime Error):
n = int(input())
last_chosen = -1

max_points = 0
for i in range(n):
    days = list(map(int, input().split()))
    while True:
        act = max(days)
        idx = days.index(act)
        if idx != last_chosen:
            break
        days.pop(idx)
    max_points += days[idx]
    last_chosen = idx
print(max_points)


Fixed submission:
n=int(input())

dp=list(map(int,input().split()))
for day in range(1,n):
    m=[0]*3
    day_points=list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            if i!=j:
                 m[i]=max(m[i],day_points[i]+dp[j])
    dp=m
print(max(dp))
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(float, input().split())
       
dp=[[0 for i in range(n+1)] for j in range(n+1)]
dp[0][0]=1

for i in range(1,n+1):
       for j in range(n+1):
       	if j==0:
       		dp[i][j]=(1.0-p[i-1])*dp[i-1][j]
       	else:
       		dp[i][j]=p[i-1]*dp[i-1][j-1]+(1.0-p[i-1])*dp[i-1][j]
res=0
for i in range(n//2+1,n+1):
       res+=dp[n][i]
print(res)       

Fixed submission:
n=int(input())
p=list(map(float, input().split()))
       
dp=[[0 for i in range(n+1)] for j in range(n+1)]
dp[0][0]=1

for i in range(1,n+1):
       for j in range(n+1):
       	if j==0:
       		dp[i][j]=(1.0-p[i-1])*dp[i-1][j]
       	else:
       		dp[i][j]=p[i-1]*dp[i-1][j-1]+(1.0-p[i-1])*dp[i-1][j]
res=0
for i in range(n//2+1,n+1):
       res+=dp[n][i]
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
# from sys import stdin, stdout
def helper(weights,values,n,capacity,memo):
    if(capacity==0 or n==0):
        return 0
    if((n,capacity) in memo):
        return memo[(n,capacity)]
    if(weights[n-1]<=capacity):
        memo[(n,capacity)]=max(values[n-1]+helper(weights,values,n-1,capacity- weights[n-1],memo),helper(weights,values,n-1,capacity,memo))
        return memo[(n,capacity)]
    memo[(n,capacity)]=helper(weights,values,n-1,capacity,memo)
    return memo[(n,capacity)]
n,capacity=map(int,input().split())
weights=[0]*n
values=[0]*n
for i in range(n):
    weights[i],values[i]=map(int,input().split())

memo={}
print(helper(weights,values,n,capacity,memo))

Fixed submission:
n,capacity=map(int,input().split())
weights=[0]*n
values=[0]*n
for i in range(n):
    weights[i],values[i]=map(int,input().split())
maxValue=sum(values)
dp=[[float("inf")]*(maxValue+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0]=0

for i in range(1,n+1):
    for j in range(1,maxValue+1):
        if(values[i-1]<=j):
            dp[i][j]=min(weights[i-1]+dp[i-1][j- values[i-1]],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]

ans=0
for i in range(maxValue+1):
    if(dp[n][i]<=capacity):
        ans=i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):


MOD = 1000000007

n = input()
a = []
for _ in range(n):
    a.append(map(int, raw_input().split()))

dp = [[0] * (1 << n) for _ in range(n + 1)]
for i in range(1 << n):
    dp[0][i] = 1
for i in range(1, n + 1):
    for mask in range(1, 1 << n):
        for j in range(n):
            if a[i - 1][j] == 1 and mask & (1 << j):
                dp[i][mask] += dp[i - 1][mask ^ (1 << j)]
                dp[i][mask] %= MOD
print(dp[n][(1 << n) - 1])

Fixed submission:


MOD = 1000000007

n = input()
a = []
for _ in range(n):
    a.append(map(int, raw_input().split()))

# dp[S] cant de match usando |S| primeros hombres y S mujeres
dp = [0] * (1 << n)
dp[0] = 1
for mask in range(1, 1 << n):
    i = bin(mask).count('1') - 1  # bin(6) => 0x110
    for j in range(n):
        if a[i][j] == 1 and mask & (1 << j):
            dp[mask] += dp[mask ^ (1 << j)]
            dp[mask] %= MOD
print(dp[(1 << n) - 1])
Buggy python submission (verdict: Time Limit Exceeded):


MOD = 1000000007

def F(k, s):
    return dp[k][s]

def solve(n):
    resp = 0
    n = map(int, str(n))
    pref = 0
    for i in range(len(n)):
        for d in range(n[i]):
            resp += F(len(n) - i - 1, (pref - d) % D)
        pref -= n[i]
        pref %= D
    return resp


K = raw_input()
D = input()

# dp[i][j] = cant de numeros de i digitos con suma % d = j
dp = [[0] * D for _ in range(len(K) + 1)]
dp[0][0] = 1
for i in range(1, len(K) + 1):
    for j in range(D):
        for d in range(10):
            dp[i][j] += dp[i - 1][(j - d) % D]

resp = solve(K) - 1
if sum(map(int, str(K))) % D == 0:
    resp += 1
print(resp % MOD)


Fixed submission:


MOD = 1000000007

def F(k, s):
    return dp[k][s]

def solve(n):
    resp = 0
    n = map(int, str(n))
    pref = 0
    for i in range(len(n)):
        for d in range(n[i]):
            resp += F(len(n) - i - 1, (pref - d) % D)
            resp %= MOD
        pref -= n[i]
        pref %= D
    return resp


K = raw_input()
D = input()

# dp[i][j] = cant de numeros de i digitos con suma % d = j
dp = [[0] * D for _ in range(len(K) + 1)]
dp[0][0] = 1
for i in range(1, len(K) + 1):
    for j in range(D):
        for d in range(10):
            dp[i][j] += dp[i - 1][(j - d) % D]
            dp[i][j] %= MOD

resp = solve(K) - 1
if sum(map(int, str(K))) % D == 0:
    resp += 1
print(resp % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
    dp[i][i] = a[i]

for i in range(n - 2, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

print(dp[0][n - 1])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
    dp[i][i] = a[i]

for i in range(n - 2, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

print(dp[0][n - 1])
Buggy python submission (verdict: Time Limit Exceeded):

A=[]
n=int(input())
for i in range(n):
    num=int(input())
    if(num in A):
        A.remove(num)
    else:
        A.append(num)
print(len(A))


Fixed submission:
A={-1:False}
n=int(input())
count=0
for i in range(n):
    num=int(input())
    try:
        
        if(A[num]==True):
            count-=1
            A[num]=False
        else:
            count+=1
            A[num]=True
    except:
        #print("exception",A,num)
        A[num]=True
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=[0]+[int(input())-k for i in range(n)]
for i in range(1,n+1):
	a[i]+=a[i-1]
b=sorted(a)+[-2e9-1]
c,d=0,dict()
for i in range(n+1):
	if b[i]!=b[i-1]:
		c+=1
		d[b[i]]=c
bit=[0]*(n+1)
def sum(i):
	res=0
	while i>0:
		res+=bit[i]
		i-=i&-i
	return res
def add(i):
	while i<=c:
		bit[i]+=1
		i+=i&-i
ans=0
for i in range(n+1):
	ans+=sum(d[a[i]])
	add(d[a[i]])
print(ans)

Fixed submission:
n,k=map(int,input().split())
a=[0]+[int(input())-k for i in range(n)]
for i in range(1,n+1):
	a[i]+=a[i-1]
b=sorted(a)+[-2e9-1]
c,d=0,dict()
for i in range(n+1):
	if b[i]!=b[i-1]:
		c+=1
		d[b[i]]=c
bit=[0]*(n+5)
def sum(i):
	res=0
	while i>0:
		res+=bit[i]
		i-=i&-i
	return res
def add(i):
	while i<=c:
		bit[i]+=1
		i+=i&-i
ans=0
for i in range(n+1):
	ans+=sum(d[a[i]])
	add(d[a[i]])
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=[0]+[int(input())-k for i in range(n)]
for i in range(1,n+1):
	a[i]+=a[i-1]
b=sorted(a)+[-2e9-1]
c,d=0,dict()
for i in range(n+1):
	if b[i]!=b[i-1]:
		c+=1
		d[b[i]]=c
bit=[0]*n
def sum(i):
	res=0
	while i>0:
		res+=bit[i]
		i-=i&-i
	return res
def add(i):
	while i<=c:
		bit[i]+=1
		i+=i&-i
ans=0
for i in range(n+1):
	ans+=sum(d[a[i]])
	add(d[a[i]])
print(ans)

Fixed submission:
n,k=map(int,input().split())
a=[0]+[int(input())-k for i in range(n)]
for i in range(1,n+1):
	a[i]+=a[i-1]
b=sorted(a)+[-2e9-1]
c,d=0,dict()
for i in range(n+1):
	if b[i]!=b[i-1]:
		c+=1
		d[b[i]]=c
bit=[0]*(n+5)
def sum(i):
	res=0
	while i>0:
		res+=bit[i]
		i-=i&-i
	return res
def add(i):
	while i<=c:
		bit[i]+=1
		i+=i&-i
ans=0
for i in range(n+1):
	ans+=sum(d[a[i]])
	add(d[a[i]])
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

class TailRecurseException:
	def __init__(self, args, kwargs):
		self.args = args
		self.kwargs = kwargs

def tail_call_optimized(g):
	def func(*args, **kwargs):
		f = sys._getframe()
		if f.f_back and f.f_back.f_back and f.f_back.f_back.f_code == f.f_code:
			raise TailRecurseException(args, kwargs)
		else:
			while 1:
				try:
					return g(*args, **kwargs)
				except TailRecurseException, e:
					args = e.args
					kwargs = e.kwargs
	func.__doc__ = g.__doc__
	return func

n,m=map(int,raw_input().split())
vis,ci,cb,cc=[0]*(n+1),0,0,0
g=[[] for i in range(n+1)]
def dfs(x,col):
	if vis[x]:
		return vis[x]==col
	vis[x],flag=col,True
	for i in g[x]:
		flag&=dfs(i,3-col)
	return flag
for i in range(m):
	u,v=map(int,raw_input().split())
	g[u]+=[v]
	g[v]+=[u]
for i in range(1,n+1):
	if vis[i]==0:
		if len(g[i])==0:
			ci+=1
		else:
			if dfs(i,1):
				cb+=1
			else:
				cc+=1
print ci*ci+2*ci*(n-ci)+cc*cc+2*cb*cc+2*cb*cb

Fixed submission:
n,c,k=map(int,input().split())
t=sorted([int(input()) for i in range(n)])
st,p,ans=-k,0,0
for i in t:
	if st+k<i or p==c:
		ans+=1
		p=1
		st=i
	else:
		p+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lb,ub,t=0,len(str(n)),9*n
while ub-lb>1:
	mid=(lb+ub)//2
	if sum(map(int,str(t+9*mid)))<=9*mid:
		ub=mid
	else:
		lb=mid
print(ub)

Fixed submission:
n=list(input())
n.reverse()
lb,ub=0,len(n)
def check(x):
	g=0
	for i in n:
		x-=(x+g-int(i))%10
		if x<0:
			break
		g=(x+g)//10
	return x>=0
while ub-lb>1:
	mid=(lb+ub)//2
	if check(9*mid):
		ub=mid
	else:
		lb=mid
print(ub)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lb,ub,t=0,len(str(n)),9*n
while ub-lb>1:
	mid=(lb+ub)//2
	if sum(map(int,str(t+9*mid)))<=9*mid:
		ub=mid
	else:
		lb=mid
print(ub)

Fixed submission:
n=list(input())
n.reverse()
lb,ub=0,len(n)
def check(x):
	g=0
	for i in n:
		x-=(x+g-int(i))%10
		if x<0:
			break
		g=(x+g)//10
	return x>=0
while ub-lb>1:
	mid=(lb+ub)//2
	if check(9*mid):
		ub=mid
	else:
		lb=mid
print(ub)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lb,ub=0,len(str(n))
while ub-lb>1:
	mid=(lb+ub)//2
	if sum(map(int,str(9*n+9*mid)))<=9*mid:
		ub=mid
	else:
		lb=mid
print(ub)

Fixed submission:
n=list(input())
n.reverse()
lb,ub=0,len(n)
def check(x):
	g=0
	for i in n:
		x-=(x+g-int(i))%10
		if x<0:
			break
		g=(x+g)//10
	return x>=0
while ub-lb>1:
	mid=(lb+ub)//2
	if check(9*mid):
		ub=mid
	else:
		lb=mid
print(ub)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
sum = 0
while (1 == 1):
    #Cがある時
    if c > 0:
        c = c - 1
        sum = sum + 1
        if a > 0:
            a = a - 1
        elif b > 0:
            b = b -1
            sum = sum + 1
        else :
            break
    # Cがない時
    else :
        if b > 0:
            b = b -1
            sum = sum + 1
        else :
            break

# 出力
print("{}" .format(sum))

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
result = 0
if a + b + 1 >= c:
  result = b + c
else:
  result = b + (a + b + 1)
# 出力
print("{}" .format(result))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
sum = 0
while (1 == 1):
    #Cがある時
    if c > 0:
        c = c - 1
        sum = sum + 1
        if a > 0:
            a = a - 1
        elif b > 0:
            b = b -1
            sum = sum + 1
        else :
            break
    # Cがない時
    else :
        if b > 0:
            b = b -1
            sum = sum + 1
        else :
            break

# 出力
print("{}" .format(sum))

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
result = 0
if a + b + 1 >= c:
  result = b + c
else:
  result = b + (a + b + 1)
# 出力
print("{}" .format(result))

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
A,B,C=a.split(' ')
A=int(A)
B=int(B)
C=int(C)
count=0
for i in range(C):
    count+=1
    if B!=0:
        count+=1
        B-=1
    elif A!=0:
        A-=1
    else:
        break
for i in range(B):
    count+=1
print(count)

Fixed submission:
a=input()
A,B,C=a.split(' ')
A=int(A)
B=int(B)
C=int(C)
count=0
if A+B<C:
    print(A+2*B+1)
else:
    print(B+C)

Buggy python submission (verdict: Runtime Error):
import sys
print(1 + min(sys.argv[0] + sys.argv[1], sys.argv[2] - 1) + sys.argv[1])

Fixed submission:
import sys
a, b, c = (int(i) for i in input().split())  
print(1 + min(a + b, c - 1) + b)

Buggy python submission (verdict: Runtime Error):
import sys
print(1 + min(sys.argv[1] + sys.argv[2], sys.argv[3] - 1) + sys.argv[2])

Fixed submission:
import sys
a, b, c = (int(i) for i in input().split())  
print(1 + min(a + b, c - 1) + b)

Buggy python submission (verdict: Runtime Error):
#input_str = input()
input_str = '8 8 1'
A, B, C = input_str.split()
A = int(A)
B = int(B)
C = int(C)

if A + B > C + 1:
    print(C*2+1)
else
	print((A+B)*2+1

Fixed submission:
input_str = input()

a, b, c = input_str.split()
a = int(a)
b = int(b)
c = int(c)

if a + b >= c:
    print(b + c)
else:
    print((a+b)*2 +1 - a)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

ls=len(s)
lt=len(t)
if ls < lt:
    print(errorword)
else:
    for i in range(ls-lt,-1,-1):
        is_matched = True
        s_slice = slice(i, lt+2)

        for s_char, t_char in zip(s[s_slice], t):
            # 文字が不一致かつ？以外の場合は文字列不一致のためbreak
            if (s_char != t_char) and s_char != '?':
                is_matched = False
                break
                
        # ここまでbreakせずに来たら文字列一致のため文字列Sを出力
        if is_matched:
            temp_sl1 = slice(0, i)
            temp_sl2 = slice(i+lt, ls+1)
            out_str = '{}{}{}'.format(s[temp_sl1], t, s[temp_sl2])
            print(out_str.replace('?', 'a'))
            break
    
    if not is_matched:
        print(errorword)

Fixed submission:
s = input()
t = input()
# s = 'c?????a'
# t = 'coder'
errorword = 'UNRESTORABLE'

ls=len(s)
lt=len(t)
if ls < lt:
    print(errorword)
else:
    for i in range(ls-lt,-1,-1):
        is_matched = True
        s_slice = slice(i, i+lt)

        for s_char, t_char in zip(s[s_slice], t):
            # 文字が不一致かつ？以外の場合は文字列不一致のためbreak
            if (s_char != t_char) and s_char != '?':
                is_matched = False
                break
                
        # ここまでbreakせずに来たら文字列一致のため文字列Sを出力
        if is_matched:
            temp_sl1 = slice(0, i)
            temp_sl2 = slice(i+lt, ls+1)
            out_str = '{}{}{}'.format(s[temp_sl1], t, s[temp_sl2])
            print(out_str.replace('?', 'a'))
            break
    
    if not is_matched:
        print(errorword)
Buggy python submission (verdict: Runtime Error):
n_in = int(input()) 
l = [int(input()) for i in range(n_in)] 
# l = [3, 5, 10, 11]

p = l[0]
for i in range(1, len(l)):
    q = l[i]

    if p >= q:
        m, n = p, q
    else:
        m, n = q, p

    while True:
        mod_value = m % n
        if mod_value  == 0:
            break

        m = n
        n = mod_value

    p = int(p*q/n)

print(p)

Fixed submission:
n_in = int(input()) 
t = [int(input()) for i in range(n_in)] 

p = t[0]
for i in range(1, len(t)):
    q = t[i]

    if p >= q:
        m, n = p, q
    else:
        m, n = q, p

    while True:
        mod_value = m % n
        if mod_value  == 0:
            break

        m = n
        n = mod_value

    p = p//n * q

print(p)

Buggy python submission (verdict: Runtime Error):
n_in = int(input()) 
l = [int(input()) for i in range(n_in)] 

p = l[0]
for i in range(1, len(l)):
    q = l[i]

    if p >= q:
        m = p
        n = q
    else:
        m = q
        n = p

    while True:
        mod_value = m % n

        if mod_value  == 0:
            n = mod_value
            break

        m = n
        n = mod_value

    p = int(p*q/n)

print(p)

Fixed submission:
n_in = int(input()) 
t = [int(input()) for i in range(n_in)] 

p = t[0]
for i in range(1, len(t)):
    q = t[i]

    if p >= q:
        m, n = p, q
    else:
        m, n = q, p

    while True:
        mod_value = m % n
        if mod_value  == 0:
            break

        m = n
        n = mod_value

    p = p//n * q

print(p)

Buggy python submission (verdict: Runtime Error):
n_in = int(input()) 
l = [int(input()) for i in range(n_in)] 

p = l[0]
for i in range(1, len(l)):
    q = l[i]

    if p >= q:
        m = p
        n = q
    else:
        m = q
        n = p

    while True:
        mod_value = m % n

        if mod_value  == 0:
            break

        m = n
        n = mod_value

    p = int(p*q/n)

print(p)

Fixed submission:
n_in = int(input()) 
t = [int(input()) for i in range(n_in)] 

p = t[0]
for i in range(1, len(t)):
    q = t[i]

    if p >= q:
        m, n = p, q
    else:
        m, n = q, p

    while True:
        mod_value = m % n
        if mod_value  == 0:
            break

        m = n
        n = mod_value

    p = p//n * q

print(p)
Buggy python submission (verdict: Runtime Error):

n, x = map(int, input().split())
l = list(map(int, input().split()))
total = 0

for i in range(n - 1):
    sub = l[i] + l[i+1]
    if sub > x:
        total += sub - x
        l[i+1] -= sub - x
        if l[i+1] > x:
            l[i] -= l[i+1] - x
            total += l[i+1 - x]




print(total)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
total = 0

for i in range(n - 1):
    diff = l[i] + l[i+1] - x
    if diff > 0:
        total += diff
        if diff > l[i+1]:
            l[i+1]=0
        else:
            l[i+1] -= diff

print(total)
Buggy python submission (verdict: Runtime Error):

s_long = input()

count = 0
prev = ''

for s in s_long:
    if prev == ''
        prev = s
        continue

    if prev != s:
        count += 1
        prev = s

print(count)

Fixed submission:
s_long = input()

count = 0
prev = ''

for s in s_long:
    if prev == '':
        prev = s
        continue

    if prev != s:
        count += 1
        prev = s

print(count)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
r = 0
     
if a + b >= c:
  r = b + c
else:
  r = a + b

print(r)

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

Buggy python submission (verdict: Runtime Error):
a, b, c = input()
r = 0

if a + b >= c:
  r = b + c
else:
  r = a + b

print(r)

Fixed submission:
a, b, c = map(int,input().split())
r = 0
if c <= a + b + 1:
  r = b + c
else:
  r = a + 2 * b + 1
print(r)
Buggy python submission (verdict: Runtime Error):
S = input()
count_B = 0
right_W = 0
for i in S:
  if i == "B":
    count_B += 1
  else:
    right_W = i
rb = len(S) - right_W - 1
print(count_B - rb)

Fixed submission:
S = input()
count_ans = 0
count_B = 0
right_W = 0
for i, c in enumerate(S):
	if c == "W":
		count_ans += count_B
	else:
		count_B += 1
print(count_ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
n, m = map(int,input().split())
s = input()
t = input()
j = 0
a = gcd(n, m)
for i, c in enumerate(s):
	if i % a == 0:
		if c != t[i // a * m]:
			j = -1
			break
if j >= 0:
	j = lcm(n, m)
print(j)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
n, m = map(int,input().split())
s = input()
t = input()
j = 0
a = gcd(n, m)
for i, c in enumerate(s):
	if i % (n // a) == 0:
		if c != t[(i // (n // a)) * (m // a)]:
			j = -1
			break
if j >= 0:
	j = lcm(n, m)
print(j)
Buggy python submission (verdict: Runtime Error):
a = int(input())
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
s = input()
# 出力
print("{} {}".format(a+b+c, s))

Fixed submission:
a,b,c=map(int,input().split())
if a+b > c-1:
  print(b+c)
else:
  print(a+2*b+1)
Buggy python submission (verdict: Runtime Error):
d = int(input())

if d = 25:
  print("Christmas")
elif d = 24:
  print("Christmas Eve")
elif d = 23:
  print("Christmas Eve Eve")
else
  print("Christmas Eve Eve Eve")


Fixed submission:
d = int(input())
string = 'Christmas'
for i in range(25-d):
  string += ' Eve'
print(string)
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input.split())

print(x+(y//2))

Fixed submission:
X,Y = map(int,input().split())
 
print( X + (Y // 2))

Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())
 
print(int(x+(y/2)))

Fixed submission:
X,Y = map(int,input().split())
 
print( X + (Y // 2))

Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())

  print(int(x+(y/2)))


Fixed submission:
X,Y = map(int,input().split())
 
print( X + (Y // 2))

Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())

if y==0:
 print(x+y)
else:
  print(int(x+(y/2)))


Fixed submission:
X,Y = map(int,input().split())
 
print( X + (Y // 2))

Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())

if x==0 or y==0:
 print(x+y)
else:
  print(int(x+(y/2)))


Fixed submission:
X,Y = map(int,input().split())
 
print( X + (Y // 2))

Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())

if x==0 or y==0:
 print(x+y)
else:
  print(x+(y/2))

Fixed submission:
X,Y = map(int,input().split())
 
print( X + (Y // 2))

Buggy python submission (verdict: Runtime Error):
x=int(input())
y=int(input())


print(x+(y/2)):

Fixed submission:
X,Y = map(int,input().split())
 
print( X + (Y // 2))